Referencing resources through expression

This forum is currently in read-only mode.
  • I just wanted to ask if there really is no way to reference a resource in your project's "Files" folder other than by its numbered index in the list? With me using a function to play sounds for ease of use and communication with external files, I can't ever change the order of the files in the Files folder without the functions playing the incorrect sounds until I put the list back in the old order.

    Basically, if I pick a resource (in any plugin I've tried that accesses them) through "use expression", only a number will work. Writing "gun.wav" (Construct will even convert a choice to a string on its own) will not load the file. Either Construct only remembers the files through index number, or there's a way to write it that wouldn't occur to me?

    If it's impossible I guess I'd either deal with it as I have, or make events that plays the sounds I want regardless of list (though that makes for a lot of events), or maybe someone has a better tip? <img src="smileys/smiley1.gif" border="0" align="middle" />

  • The resource filenames are not included when exporting.

    You can work around it with this plugin:

  • Oh? How? I was looking at it briefly earlier and didn't find any particular expressions of use, but it again was briefly.

    I'll mess with it later then if you don't feel like explaining a lot.

  • It's pretty simple. Use the action "extract resource" to assign a name to a resource, you would probably do this at the start of the layout.

    + System: Start of layout
    -> Resource: Extract Resource "brick.png" as "img1"
    -> Resource: Extract Resource "box.png" as "img2"

    Then you can load the resource with any action that loads from a filename.

    -> Sprite: Load frame from Resource ("img1")
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ah, thanks. Thought it didn't work at first (using it for sound) but I had to Autoplay from "file".

    How does this plugin handle the memory of this though? If I extract all my samples at start, do I double the memory usage somehow? And if this doesn't add potential more memory "stops" as new sounds load to play it'll be dandy.

    I guess I'm asking if the plugin just references resources differently or if it literally removes data from the resource folder and stores its own copies.

  • Resources are inside the exe. The Resource plugin extracts them from the exe to a temp file and creates a hashtable associating a name with the filename. Try "Set text to Resource("img1")" to see where the file was extracted to.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)