Bug Issue: [Code Mode] Default values for exposed variables don't refresh in the behaviors


Pages: 1

SadiQ

  • Level 5 Stencyler
January 17, 2016, 08:08:22 am
After exposing a variable from a code mode behavior,  I am forced to remove the behavior from the actor (and I presume scene in the case of a scene behavior) to allow Stencyl to refresh the default values I added:

Before removing the behavior from the actor:


After removing the behavior and reattaching it again:


captaincomic

  • Master Stencyler
  • *
January 17, 2016, 02:01:24 pm
This may be working as intended. If you have the behavior attached to some scenes/actors, and change the default value, it won't update the default values for those scenes/actors. The default value is only used to populate the fields at the time you attach the behavior.


Issue updated by captaincomic - January 17, 2016, 02:26:38 pm
  • Status changed from New to Need Info


SadiQ

  • Level 5 Stencyler
January 18, 2016, 05:38:18 am
I just created a blank game with a scene behavior and I created an attribute like this:
Code: [Select]
@:attribute("id='1' name='StringAttribute1' desc='Just some text' default='Testing1'") //the < default=' '> part is missing from stencylpedia!!!
public var StringAttribute1:String; //this defaults to 'null' if I'm not mistaken??.

     ...

    public inline function draw(g:G)
{
g.drawString("" + StringAttribute1, 100, 100);
}
When I attach this behavior to my scene I see the Default value of "Testing1" in the behaviors tab for my attribute, and when I test the game I see Testing1 being drawn on the screen, which suggests that the default=' ' field I added in the attribute declaration line is the one responsible for the value of my string variable. To confirm this I declared my string like this: public var StringAttribute1:String = "HandValue";  //this should now default to "HandValue", yet when I test the game I still see "Testing1" being drawn on the screen. (The default value is what I add in the behaviors tab, but I want it to start with an initial value when I attach the behavior to a scene).

I then added a second attribute, without removing the behavior from my scene and reattaching it again:
Code: [Select]
@:attribute("id='1' name='StringAttribute1' desc='Just some text' default='Testing1'")
public var StringAttribute1:String; //this defaults to 'null' if I'm not mistaken??.

@:attribute("id='2' name='StringAttribute2' desc='Just some other text' default='OtherText'")
public var StringAttribute2:String;

    ...

    public inline function draw(g:G)
{
g.drawString("" + StringAttribute1, 100, 100);
g.drawString("" + StringAttribute2, 100, 200);
}

This time I see "Testing1" and 'null' being drawn on the screen, which means my second attribute doesn't see the default value that I want it to have unless I first remove the behavior from the scene and I reattach it again.

If I want to send the behavior to someone, or attach it to a scene/actor after it's done there's no problem, but it's really annoying when I just want to expose some attributes one at a time and test them properly.



captaincomic

  • Master Stencyler
  • *
January 21, 2016, 03:56:28 pm
Okay, I see, it's about adding new attributes. Afaict, it is necessary to reload the scene or actor that has the behavior attached after exposing a new attribut in code mode. No need to remove and reattach it though.


captaincomic

  • Master Stencyler
  • *
January 21, 2016, 04:01:20 pm
Quote
//the < default=' '> part is missing from stencylpedia!!!
Updated the article (I also added a note to clarify that reloading is necessary).


SadiQ

  • Level 5 Stencyler
January 22, 2016, 08:33:34 pm
Ahh. Yes. The topic didn't allow for a longer length, as it was supposed to be Default values for exposed variables don't refresh in the behaviors tab . As for reloading, I only used that when creating extensions, so I actually forgot about that option.
You could also change the Stencylpedia article under How to Define Attributes from
Code: [Select]
//Expose your attributes to Stencyl like this
[Attribute(id="1", name="Display Name", desc="An Attribute")]
public var attributeName:String = "default";
to:
Code: [Select]
//Expose your attributes like this:
//@:attribute("id='1' name='Display Name' desc='An Attribute'")
//public var attributeName:String;


captaincomic

  • Master Stencyler
  • *
January 24, 2016, 12:21:03 pm
Oh, yes, thanks for pointing that out. It was still using the old syntax in the article.


Issue updated by captaincomic - January 25, 2016, 03:40:42 pm
  • Status changed from Need Info to Closed


Pages: 1

Details

  • Reported
    January 17, 2016, 08:08:22 am
  • Updated
    January 25, 2016, 03:40:42 pm

  • View Status
    Public
  • Type
    Bug
  • Status
    Closed
  • Priority
    Normal
  • Version
    3.4.0 beta2
  • Fixed in
    (none)
  • Assigned to
    (none)
  • Category
    (none)

Tags