Having Problems with a Game Attribute

SpookyBurger

  • Posts: 82
Hi!  I'm having a very weird problem with a game attribute.  For some reason I'm not able to access what's in the list.  I made a simple test block, where Y should equal 60, but it only prints out as 40.  I tested it before and after the "If Item Position In List contains 1.0".  I've even tried deleting the game attribute, remaking it, and re plugging it into the test behaviors.  Is there something really obvious I'm missing here?  Thanks in advance for any help!
Please try out my latest build of Patient 9 here.   http://www.stencyl.com/game/play/23179

gamegirlxl

  • Posts: 713
What if you had a list like this: index---value

0---false
1---true
2---true
3---false

So instead of searching for a value you check the status of what is in that value.

If that doesn't work, you should consider a hash, which would let you have "2.6", "-1", or even "potato" as the id.  I think you put your string, which needs to have quotes, inside a code block and that is the id.  I think.  But only as a last resort.

SpookyBurger

  • Posts: 82
Unfortunately the way I set up my inventory "system" I need to be able to search for a number in a game attribute list (this is really annoying since I was able to search for values in a behavior list just fine)

Sorry what's a hash?
Please try out my latest build of Patient 9 here.   http://www.stencyl.com/game/play/23179

Photon

  • Posts: 2693
I only see two "increment y by 20" blocks, in which case 20 + 20 = 40.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

gamegirlxl

  • Posts: 713
Hashes are special lists.  Normal lists, like yours, use numbers as indexes, like an_array[15], if you look into AS3.  But you can have an_array[pumpernickel].  I was learning Ruby, and I picked up the term, so it might not be QUITE the right word for AS3/Stencyl...

I wasn't sure what was causing the problem, so I guess that probably wont fix it.  I thought it might have been an issue with the list itself, or something.

thegenericbanana

  • *
  • Posts: 494
Pretty sure it's just 40 because there's 2 increment y by 20 blocks. Why do you think it should print out as 60?
Johnny Turbo's Surgery Frenzy

Meestar

  • Posts: 652
The issue I see with your code is the if statement.  I've personally never worked with the "if list contains x" block, but from the short test I made it yielded no results for me.  And for thegenericbanana and Photon, if the code had worked, it should have indeed returned 60.  There is a 20 in the if statement and the other increment block is WITHIN A REPEAT code block and he has two items in his list, so it would have been 20 + 20 + 20 = 60.  Is there any particular reason why you need to use the "if list contains x" block?  I also found it interesting that your looping the number of items in a list other than the one you're checking.  I would suggest changing your "if list contains x" block into something like "if get item #[current loop count] from [Item In Position List] = 1.0"
PM me if you require help.  I'm always glad to help out!

Photon

  • Posts: 2693
Never mind. Ignore this post please. :P
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

thegenericbanana

  • *
  • Posts: 494
Well, yeah, should've seen that, but wouldn't it be 80 instead of 60 (Both are inside repeat block)? Not sure why it says 40, my guess is that it doesn't register that it contains 1.0 and therefore just does the increment y by 20 on the bottom twice. Put a print block into the if contains 1.0 and see if it prints twice, prints once or no times. When you say you tried before and after the contains block, do you mean you tried it before putting the contains if with just another increment y by 20 or you just added the whole thing?

« Last Edit: November 15, 2013, 10:12:18 pm by thegenericbanana »
Johnny Turbo's Surgery Frenzy

Meestar

  • Posts: 652
It wouldn't be 80 because only one item in the list is 1.0, the other is 2.0.
PM me if you require help.  I'm always glad to help out!

thegenericbanana

  • *
  • Posts: 494
It wouldn't be 80 because only one item in the list is 1.0, the other is 2.0.
But it repeats it twice, and both times it includes 1.0?
Johnny Turbo's Surgery Frenzy

Meestar

  • Posts: 652
PM me if you require help.  I'm always glad to help out!