Stencyl 3.4.0 is now out. Get it now!

Editing Hard-Coded Information in Stencyl

After working on a project for a period of time, you may want to change something that was set when you began but, oh no, you're not allowed to change it! What do you do; make your change, then transfer all the information you've built up? That could take a lot of time though, so here's a better idea: come to this post, and see if there's a section on whats troubling you.

I'm basically setting this up as a time-saving resource for those who want to change something that Stencyl currently does not offer an efficient way of doing. I have fun doing this, probably because most of these methods will involve directly editing saved game files. As a rule of thumb though, you should export a copy of your project (File > Export Game...) and have closed Stencyl before trying any of these suggestions. Also, because my computer only runs Windows, these instructions refer to files found under:
.
C:\Users\{user}\AppData\Roaming\Stencyl\stencylworks
.
Which can be navigated to by pressing Windows Key and searching %appdata%. I don't know where this is on other operating systems.

I will update sections if I learn more interesting things, and I will update this post if I find more useful methods, if anyone knows a little thing they do to save time, please post it below and I will try to add it in future.


Thank you,
Annulus


Changing the Names of Global Attributes
correct as of Stencyl 3.4.0 b9300

  • Navigate to your project folder (C:\Users\<user>\AppData\Roaming\Stencyl\stencylworks\{project name}).
  • Open to file game.xml with a text editor.
  • Scroll down until you reach the <attributes> tag.
This is where the global attributes for your project are listed. They are in the format
.
<a cid="b" id="c" name="d" save="e" value="f">
.
where:
  • a is the attribute type and can be any of number, text, boolean, list, or map.
  • b is the attribute category. See below for more information on this.
  • c is the attribute ID. It iterates from zero upwards with each new attribute, and I'm assuming this is what Stencyl uses to refer to global attributes when it loads the design-mode editor. This is why, when copying blocks between stencyl projects that contain global attributes, they can be swapped out for attributes of the wrong type or removed altogether. It currently seems like deleting a global attribute changes the ID's of all other attributes above it so that there are no 'gaps' in the iteration.
  • d is the name of the global attribute. You can change this to anything other than an existing attribute name using letters, numbers, underscores, and spaces. The attribute name cannot end with a space, and should maybe not start with an underscore (I'm not sure of this applies to haxe, but an underscore before a variable sometimes changes how that variable can be accessed in some languages).
  • e is a boolean (accepts true or false) which looks like it would change whether that global attribute is saved with the Save Game block. All attributes seem to be true by default, and I would reccomend not changing that. I haven't messed around with it, so I don't know if it would cause some kind of error. It might simply stop the project from saving that attribute, but then why make the change anyway.
  • f is the initial value of the attribute. numbers, text, and booleans will only take up the one line, but maps and lists with an initial 'value' will take up multiple lines (see the example below)

Regarding b:
Above the <attributes> tag is the <attcats> (attribute categories) tag. In this area you can modify the categories for your attributes[/li][/list]. The Default category has an id of -1, and I would reccomend not messing with it. Categories don't have as stringent an ID iteration as game attributes, and their names seem to accept any combination of any character (except for ", which is written as &quote;). You can change the information of categories under <attcats>, and by changing to value of b, you can change what category an attributes belong to.
Remember though that you can already rename and delete categories in Stencyl by secondary-clicking the category in the Attributes menu.

Example:
Below is an example piece of the game.xml file. I'm not going to show every kind of change that you can make to it because one; this section seems to be getting quite long and two; I'm lazy.
Code: [Select]
    <attcats>
        <cat id="-1" name="Default"/>
        <cat id="0" name="Player Information"/>
        <cat id="1" name="Game Information"/>
        <cat id="2" name="OUOy898y7 ou ioyu )()*0u yhiou9Y(&amp;T*7t9 t7897"/>
        <cat id="3" name="This Category Has No Items In It"/>
        <cat id="5" name="SingleQuote: ' DoubleQuote: &quot;"/>
    </attcats>
    <props/>
    <attributes>
        <boolean cid="1" id="2" name="Loading Level" save="true" value="false"/>
        <number cid="1" id="3" name="Game Stage" save="true" value="6.0"/>
        <number cid="5" id="0" name="Health" save="true" value="97.0"/>
        <list cid="-1" id="10" name="Empty List" save="true" val="list"/>
        <map cid="0" id="5" name="Defeated Enemies" save="true" val="map">
            <TEXT key="Goblin" order="0" value="14"/>
            <TEXT key="Snake" order="1" value="3"/>
            <TEXT key="Dragon" order="2" value="0"/>
            <TEXT key="Elephant" order="3" value="1"/>
            <TEXT key="Human" order="4" value="8"/>
            <TEXT key="Elf" order="5" value="6"/>
        </map>
        <list cid="0" id="1" name="Inventory" save="true" val="list">
            <text order="0" value="Apple"/>
            <text order="1" value="Apple"/>
            <text order="2" value="Bread"/>
            <text order="3" value="Key"/>
            <text order="4" value="Purple Gem"/>
        </list>
        <boolean cid="-1" id="7" name="Is This Boolean True" save="true" value="true"/>
        <list cid="-1" id="12" name="Arbitrary List" save="true" val="list">
            <number order="0" value="6346.0"/>
            <number order="1" value="1312.0"/>
            <text order="2" value="text"/>
            <text order="3" value="some more text"/>
            <text order="4" value="blahblahblah"/>
            <text order="5" value="2352462 - 1134"/>
        </list>
        <text cid="0" id="4" name="Name" save="true" value="Mohammad"/>
        <map cid="-1" id="11" name="Empty Map" save="true" val="map"/>
    </attributes>
Notes:
This has only happened the last time I changed a global attribute name, but I had to open every behaviour that contained that changed attribute so that the new name was noticed when the projected was compiled. The Stencyl programming-thingy refers to global attributes by their ID, but it writes the actual haxe program with the global attribute names. This problem might be more easily fixed by doing Run > Clean Project but I haven't actually tried that.


Changing Scene Tile Width and Height
correct as of Stencyl 3.4.0 b9300

Tiles are useful if you make use of tilesets, making presentation easier to organise and easing the amount of time spent processing actors or images.
If you want to change the tile-size of a scene but have already attached and configured several scene behaviours, organised your layers, and/or placed actors, it would normally be really time-consuming to make that change. But not anymore!
  • Navigate to the scenes repository (C:\Users\{user}\AppData\Roaming\Stencyl\stencylworks\games\{project name}\scenes).
  • The scenes of your project are labelled with a numerical identification based on the order that you created them in. If you only know the name of the scene you want to edit, you can find the ID of that scene in the scenes.xml file with the format:
    .
    <scene desc="{scene description}" format="{stencyl version}" id="{scene ID}" name="{scene name}"/>
    .
  • Once you know the ID of the scene you want to edit, open {scene ID}.xml and look at the second line, it should start with <scene. the 17th and 18th labels of that scene tag are tileh="x" and tilew="y", which record the tile height and width of the scene respectively. Feel free to change these to any number above zero.
  • Make sure to check the scene(s) you changed to tile size of before trying to compile the project. Stencyl will round down the height and width of the scene to the nearest integer of tiles (e.g. a 500px wide screen with tiles 32px wide will become 15 tiles, or 480px wide). No word on what this will do to any formatting already on the scene, but my guess is that everything is anchored to the top left so you just won't be able to see anything that gets cut out.

Example:
Below is one of the scene .xml files from one of my projects. This is me speculating (because remember, I'm not one of the people who actually maintain Stencyl), but I get the impression that:
  • The color labels under the <layers> tag refer to the colour of the border surrounding selected actors in the scene editor for each layer (as each layer has a different colour).
  • Everything under the <snippets> tag refers to all of the attributes of every behaviour attached to the scene, and all of the global attributes, as well as their default values.
Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<scene depth="16" desc="" eventsnippetid="0" extheight="1376" extwidth="2656" extx="-32" exty="-32" format="3.4.0" gravx="-0.0" gravy="0.0" height="1312" id="0" name="GeneralProgram_Sc" revision="" savecount="0" tiled="1" tileh="640" tilew="1280" type="standard" width="2592">
    <layers>
        <color-bg blue="255" green="255" red="255"/>
        <layer blendMode="normal" color="100,168,234" id="0" locked="false" name="Layer 0" opacity="100" order="15" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
        <layer blendMode="normal" color="0,255,0" id="1" locked="false" name="Layer 1" opacity="100" order="14" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
        <layer blendMode="normal" color="64,64,64" id="2" locked="false" name="Layer 2" opacity="100" order="13" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
        <layer blendMode="normal" color="255,0,255" id="3" locked="false" name="Layer 3" opacity="100" order="12" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
        <layer blendMode="normal" color="255,175,175" id="4" locked="false" name="Layer 4" opacity="100" order="11" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
        <layer blendMode="normal" color="255,200,0" id="5" locked="false" name="Layer 5" opacity="100" order="10" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
        <layer blendMode="normal" color="0,0,255" id="6" locked="false" name="Layer 6" opacity="100" order="9" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
        <layer blendMode="normal" color="255,0,0" id="7" locked="false" name="Layer 7" opacity="100" order="8" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
        <layer blendMode="normal" color="255,255,0" id="8" locked="false" name="Layer 8" opacity="100" order="7" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
        <layer blendMode="normal" color="0,255,0" id="9" locked="false" name="Layer 9" opacity="100" order="6" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
        <layer blendMode="normal" color="64,64,64" id="10" locked="false" name="Layer 10" opacity="100" order="5" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
        <layer blendMode="normal" color="255,0,255" id="11" locked="false" name="Layer 11" opacity="100" order="4" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
        <layer blendMode="normal" color="255,175,175" id="12" locked="false" name="Layer 12" opacity="100" order="3" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
        <layer blendMode="normal" color="100,168,234" id="13" locked="false" name="Layer 13" opacity="100" order="2" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
        <layer blendMode="normal" color="255,200,0" id="14" locked="false" name="Layer 14" opacity="100" order="1" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
        <layer blendMode="normal" color="0,0,255" id="15" locked="false" name="Layer 15" opacity="100" order="0" scrollFactorX="1.0" scrollFactorY="1.0" visible="true"/>
    </layers>
    <joints/>
    <regions/>
    <terrainRegions/>
    <actors/>
    <snippets>
        <s enabled="true" id="3">
            <prop id="1" list="0" val="0.0"/>
            <prop id="2" list="1" val=""/>
            <prop id="3" list="1" val=""/>
            <prop id="4" list="1" val=""/>
            <prop id="5" list="0" val="4"/>
            <prop id="6" list="0" val="0"/>
            <prop id="7" list="0" val="0.0"/>
            <prop id="8" list="0" val="2"/>
            <prop id="9" list="0" val="0.0"/>
            <prop id="10" list="0" val="11"/>
            <prop id="11" list="0" val="0.0"/>
            <prop id="12" list="0" val="0.0"/>
            <prop id="13" list="0" val="0.0"/>
            <prop id="14" list="0" val="0.0"/>
            <prop id="15" list="0" val="64"/>
            <prop id="16" list="0" val="4"/>
            <prop id="17" list="0" val="0.0"/>
            <prop id="18" list="0" val="0.0"/>
            <prop id="19" list="0" val="0.0"/>
            <prop id="20" list="0" val="0.0"/>
            <prop id="21" list="0" val="false"/>
            <prop id="22" list="0" val="0.0"/>
            <prop id="23" list="0" val="0.0"/>
            <prop id="24" list="0" val="0.0"/>
            <prop id="25" list="0" val="0.0"/>
            <prop id="27" list="1" val="">
                <text order="0" value="con"/>
                <text order="1" value="prn"/>
                <text order="2" value="aux"/>
                <text order="3" value="nul"/>
                <text order="4" value="com1"/>
                <text order="5" value="com2"/>
                <text order="6" value="com3"/>
                <text order="7" value="com4"/>
                <text order="8" value="com5"/>
                <text order="9" value="com6"/>
                <text order="10" value="com7"/>
                <text order="11" value="com8"/>
                <text order="12" value="com9"/>
                <text order="13" value="lpt1"/>
                <text order="14" value="lpt2"/>
                <text order="15" value="lpt3"/>
                <text order="16" value="lpt4"/>
                <text order="17" value="lpt5"/>
                <text order="18" value="lpt6"/>
                <text order="19" value="lpt7"/>
                <text order="20" value="lpt8"/>
                <text order="21" value="lpt9"/>
            </prop>
        </s>
        <s enabled="true" id="15">
            <prop id="1" list="0" val="11"/>
        </s>
    </snippets>
    <terrain/>
    <atlases members="" retainAtlases="true"/>
</scene>
Notes:
I've only actually done this once, so if something else happens or anyone else has more information please put it down below and I'll add it in, thank you.


Bombini

  • Posts: 830

Irock

  • *
  • Posts: 2838
This could be a useful thread!

Here's something I wrote for myself a few days ago after having to modify a custom block I was working on multiple times. It's not very descriptive but hopefully it could be of use to someone:

Adding New Fields to Existing Custom Blocks

1. Open YOUR_BEHAVIOR'S_CLASSNAME.design document in /snippets/
2. Find relevant <receiver> for your custom block and note the second value.
3. Open /resources/data.xml
4. Find "custom-YOURVALUE"
5. Modify block text under "gui" and add new field with appropriate name, order and type.
6. Go back to the CLASSNAME.design file.
7. Add "get-byobval" value to end of <receiver> tag.