Hime-Works / Requests

Bug reports and requests that may require longer discussions and is not suitable to leave on the blog
http://himeworks.com/
GNU General Public License v2.0
7 stars 9 forks source link

Conditional States self-interaction (Help, learning) #307

Open Aldiev opened 9 years ago

Aldiev commented 9 years ago

(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:

if a.state?(7) 5 elseif(5) 3 elseif(3) 10 elseif(10) 2 elseif(2) 4 elseif(4) 6 elseif(6) 1 end This is the compressed version after collaborating with a friend of mine, who is more experienced in scripting than I am (I haven't been at it for very long.) I still have the extended version in notepad, which I've also experimented with at length. It reads as follows: if a.state?(7) 5 if a.state?(5) 3 if a.state?(3) 0 if a.state?(0) 2 if a.state?(2) 4 if a.state?(4) 6 if a.state?(6) 1 else 0 end else 0 end else 0 end else 0 end else 0 end else 0 end else 0 end I've only been testing 2 so far. All 0 values have been switched with 8 as needed when trying to fix the nil to integer problem. I've been wracking my brain over this for a while now, thinking perhaps states can't just move over to death, or I'm creating an infinite loop, but I'm not seeing it -and tweaking any part of it rarely changes anything. If you have any ideas, I'm all ears. I know this problem is awfully convoluted. If you get around to this, thank you so much in advance. (I also apologize for cheating with labels through the title, but for some reason trying to add them makes my browser go about as fast as a slug dragging a cinderblock.)
HimeWorks commented 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.

Aldiev commented 9 years ago

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.

HimeWorks commented 9 years ago

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.

Aldiev commented 9 years ago

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.