Assign private var value... [solved]

For questions about using Classic.

Post » Sat Dec 18, 2010 4:29 pm

I have a question again.

I have a private variable on a menu item that I try to assign a value, according to when characters are obtained.

It should work like this: if slot1 = 0, then it will be assigned the value. But if not 0, slot2 will get the value instead, and so on and so forth... So far I put it up like this:


(too lazy to make an example .cap right now)

But when I run the debugger, I can see that the value in slot1 is still overwritten when I obtain the second character, instead of moving on to slot2 :S I tried a few variations as you can see, without luck.

Any better suggestions?
B
10
S
3
G
3
Posts: 110
Reputation: 2,206

Post » Sat Dec 18, 2010 6:43 pm

It looks like your actions all set slot1 to 1 in every event, so slot2 is never set. From what you wrote t appears that this isn't the intended behavior.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Sat Dec 18, 2010 7:15 pm

Well, in "obtainElli" it is always supposed to set them to one, and in "obtainSheila" (partly visible in the bottom) it should be 2.

But if one of the slots is taken, it should move on to the next. Fx slot1 = 1 and you obtain Sheila, then slot2 should get 2. But in my case it still enters 2 into slot1 even though it was already filled.

I hope that makes sense. My code is probably overly complicated for what it is supposed to do <_<
B
10
S
3
G
3
Posts: 110
Reputation: 2,206

Post » Sun Dec 19, 2010 7:52 pm

As Davioware pointed out, the code above doesn't seem to allow what you describe that you want it to do.

It's difficult to figure out a code fragment like that without knowing what happens before or after with this data, though...

If you have six character slots, and you want each newly available character to be added to the first open slot (apparently as a unique number), then you should be setting the same slot as you are checking in each event, and also include a 'no open slots' case if that is possible.

[code:2cjhgygj]On function "ObtainElli":

'slot1' <= 0 : set 'slot1' to 1

else 'slot2' <= 0 : set 'slot2' to 1

else 'slot3' <= 0 : set 'slot3' to 1

... etc ...

else 'slot6' <= 0 : set 'slot6' to 1

else : call function("noRoomLeftInParty")
[/code:2cjhgygj]

Then it would seem that the next "ObtainCharacter" function should set each to 2 instead of 1. If this is how it should work, then you could do this with one function that accepts a parameter for the number to set the first empty slot to, and call it with a different number for each character.
B
3
S
2
G
2
Posts: 187
Reputation: 1,449

Post » Sun Jan 09, 2011 8:41 am

Finally back...

I tried what you said and used "else", but it still doesn't work. Here is example cap I made of it all:

http://www.mediafire.com/?3jc0g4uv4amzuye

I'm a bit hopeless in trying to built this character menu. If anyone has any suggestions for better ways of doing it, I'd be interested of course.

The "member number" variable is intended to be used in the menu as well, so that construct remembers which member was clicked, and opens a new menu accordingly. At least that's the plan...

Edit: Oh my... I tried thinking of how to do this from the very bottom, and have found a different way that actually works. The members show up correctly in my menu now.

Thanks for chiming in though :) Until next time, heh.
B
10
S
3
G
3
Posts: 110
Reputation: 2,206


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests