Setting An Attribute Automatically

JeffreyDriver

  • Posts: 2262
I've run into this issue lots of times, and never been able to solve it.

See the attached image. I was hoping that I could set the list attribute 'Current Area' to a game attribute ('Area 1') automatically without having to use if/otherwise statements by taking the scene name, splitting it up into a list, then picking items from that list to set it.

How would this be done?

Anyone know the reason for the attribute not accepting a text block?

« Last Edit: December 15, 2017, 01:18:57 pm by JeffreyDriver »

NickamonPoppytail

  • *
  • Posts: 1117
I don’t think you can type in text into a “set [list Attribute]”.

I’m not sure if it’s possible to check things like the scene name (if the scene name is not already an item in a list) without using “if/otherwise blocks.[/list]
Upcoming Projects
Poppytail 5 and Pixeltail: Fifth and sixth main instalments in Poppytail series. A Game About Trimming Hedges: Final Version: An updated version of the original AGATH. One Million: Last-one-standing style small project. The Poppytales: Platformer boss rush with character collecting. Skies n' Fall: Boss rush shooter prequel to Rise n' Brawl. Precious: Weird platformer. Christmas Time 2: Sequel to Christmas Time 1.

JeffreyDriver

  • Posts: 2262
I don’t think you can type in text into a “set [list Attribute]”.

I’m not sure if it’s possible to check things like the scene name (if the scene name is not already an item in a list) without using “if/otherwise blocks.[/list]

Yeah, the thing is, as I've learnt more about Stencyl I've worked harder to automate everything I can, and it strikes me as odd that there are certain things that I can't stick a 'as text' box into.

I've fixed my current issue by using a dozen if/otherwise statements, but it would be cool if I could do that with 3 or 4 blocks, rather than 20+. Also, it would scale up.

merrak

  • *
  • Posts: 2644
I wasn't sure what you're trying to do. Do you have a screenshot of the current code using if/then blocks?

JeffreyDriver

  • Posts: 2262
I wasn't sure what you're trying to do. Do you have a screenshot of the current code using if/then blocks?

Image attached. I'm trying to assign a game attribute to a local attribute by referring to it by name.

« Last Edit: December 16, 2017, 07:32:51 am by JeffreyDriver »

SadiQ

  • Posts: 1795
You should be able to replace ALL the if/otherwise_if blocks with a single statement:

_CurrentLevel  should be replaced with the name that stencyl uses for your Current Level attribute (right click on it and select View Code), and make sure you leave that space after Area.
The code block contains this :
Code: [Select]
getGameAttribute("Area " + _CurrentLevel[Std.int(1)])
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

LIBERADO

  • *
  • Posts: 2716
Maybe this block could help you:
   
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

JeffreyDriver

  • Posts: 2262
@SadiQ Thanks, that's working.

@Liberado Thanks, I did try that initially, but it wasn't working for me.

NickamonPoppytail

  • *
  • Posts: 1117
Maybe this block could help you:
   


@Liberado Thanks, I did try that initially, but it wasn't working for me.

Shouldn’t this work if the block was “set Current Area (value of game attribute with name ((Area )& (get item # 1 from (Current Level))))”?
 
Note: There should be a space at the end of the word “Area”, since your game attributes contain spaces.
Upcoming Projects
Poppytail 5 and Pixeltail: Fifth and sixth main instalments in Poppytail series. A Game About Trimming Hedges: Final Version: An updated version of the original AGATH. One Million: Last-one-standing style small project. The Poppytales: Platformer boss rush with character collecting. Skies n' Fall: Boss rush shooter prequel to Rise n' Brawl. Precious: Weird platformer. Christmas Time 2: Sequel to Christmas Time 1.

JeffreyDriver

  • Posts: 2262
Maybe this block could help you:
   


@Liberado Thanks, I did try that initially, but it wasn't working for me.

Shouldn’t this work if the block was “set Current Area (value of game attribute with name ((Area )& (get item # 1 from (Current Level))))”?
 
Note: There should be a space at the end of the word “Area”, since your game attributes contain spaces.

I'm sure I did this. Am I wrong? Should this have worked?

NickamonPoppytail

  • *
  • Posts: 1117
Maybe this block could help you:
   


@Liberado Thanks, I did try that initially, but it wasn't working for me.

Shouldn’t this work if the block was “set Current Area (value of game attribute with name ((Area )& (get item # 1 from (Current Level))))”?
 
Note: There should be a space at the end of the word “Area”, since your game attributes contain spaces.

I'm sure I did this. Am I wrong? Should this have worked?

Try this again. It should work.
Upcoming Projects
Poppytail 5 and Pixeltail: Fifth and sixth main instalments in Poppytail series. A Game About Trimming Hedges: Final Version: An updated version of the original AGATH. One Million: Last-one-standing style small project. The Poppytales: Platformer boss rush with character collecting. Skies n' Fall: Boss rush shooter prequel to Rise n' Brawl. Precious: Weird platformer. Christmas Time 2: Sequel to Christmas Time 1.