Open Aldiev opened 9 years ago
Let's work with a simple example
3
0
2
4
6
Let's say we are working with state 2. So when you apply state 2, you want to check if state 3 exists.
If state 3 exists, then you nullify it and set the state to 0. else, If state 3 doesn't exist, and state 2 exists, then you apply state 4 else, state 3 doesn't exist, and state 2 doesn't exist, so you apply state 2.
if a.state?(3)
a.remove_state(3)
return 0
elsif a.state?(2)
a.remove_state(2)
return 4
elsif a.state?(4)
a.remove_state(4)
return 6
else
return 2
end
Note the use of elsif
.
You will go through all of those states and check whether you have it or not. The assumption here is that you will only ever have one of them (eg: you won't have state 2 and 5 together)
For each state, you would remove the old state, and then add the new one. If you have none of those states, then it is assumed that you are currently at state 0, so you would just return 2.
Your example makes perfect sense, and I figured that was precisely what I needed. But even just inserting this tag as is causes the game to freeze when testing. I at first tried to extend it to encompass the whole spectrum, then checked to see if maybe I could start from this exact example, no such luck with neither. Gone over the other scripts currently plugged in, none of them are conflicting. Besides that, causing any state now seems to freeze the game, even if I've removed their connection to conditional states. This is all only upon the moment you try and cause the state in question... Hm.
I'll continue to run through this. I hadn't realized I should add the code for state removal (somehow. I didn't know what I was thinking.) So this is already on the right track, I'm sure.
Actually might be having an issue where it's infinitely looping.
eg, you add state 2...and then it goes and upgrades it to stage 4...but then upon adding stage 4, it proceeds to add stage 6, and then it just keeps adding and adding and adding.
That's my number-one suspicion right now, but I'm not seeing it.
the elseifs shouldn't be linking that way, and it's not like I haven't capped it with 'end'. It also doesn't explain why basic states are causing problems now.
(Wow, I really don't like navigating github's interface. Let's just hope this turns out.)
At present, the conditional states script has been useful, but I've been trying to make every state interact with one another. To explain this, I'll have to go into a little detail. What I've been trying to do is create a spectrum for the game to work off of. to simplify, it looks like this;
1 7 5 3 0 2 4 6 1
If '0' is your neutral, nothing-yet-different state, having 3 or 2 dealt to you will inflict 3 or 2. if you already have those states, it moves you to the next corresponding 'tier' so to speak, until you hit 1 -death. I've been using the notetags in hopes of making these states move you up and down this ladder in relation to their own and opposing values; if you were 0, and get inflicted with 7, you move to 7 -if you have 7, and are inflicted with 6 (the opposite end of the spectrum) you return to 0. Having 2 already, and getting inflicted with 7, bumps you up to 5 -so on, so forth.
I've tried both using the 0 value and making a substitute state for neutral, let's call that 8. 0 caused problems even though it should be referring to having no state at all. My problem has been making states overwrite one another in general, though more than once I've run into "conversion of nil to integer" (the reason I dropped 0 as a value) and finally just plain freezing the game when causing a state. The notetag for '2' in this example looks as follows: