Setting the value of a key (in a map) using the <setattr [game ...]> tag?


  • *
  • Posts: 34

« Last Edit: June 28, 2020, 01:07:17 pm by leodaguy »


  • *
  • Posts: 4583
Here's the Haxe could you would want.
Code: [Select]
getGameAttribute("My Game Attribute").set("My Map Key", "A New Value");

That can be translated to dialog messages like this. (Take note: We're using getattr and not setattr because we're not setting the GA to a new value. We're getting the GA which is a map, and telling that map to set one of its keys to a new value.)
Code: [Select]
getGameAttribute("My Game Attribute")
<getattr [game "My Game Attribute"]>

map.set("key", "value");
<say map set [key value]>

All together:
<say <getattr [game "My Game Attribute"]> set ["My Map Key" "A New Value"]>
<say <getattr [game "My Game Attribute"]> set ["My Map Key" 100]>
<say <getattr [game "My Game Attribute"]> set ["My Map Key" <getattr [game "My Other Game Attr"]>]>

As you can see it quickly grows out of hand. You can work like this, but I wouldn't really recommend it. It's often better to call some event in your Stencyl code that does what you need it to.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)