Easygoing Eyebeast Thralni Posted May 18, 2007 Share Posted May 18, 2007 I'm currently busy updating WtRM to versionb 2.0.0, but I have stumbled upon a large, worrying problem: It seems the start_state of the scenario script is only run once, while other states, after they have been triggered by the start_state, run constantly. Is there something in the following bit of code, copied out from the start_state, that could cause this behavior? Code: beginstate START_STATE;// [string]a = 1;print_num(a);if (get_flag(28,0) == 1) { day1 = (get_flag(250,4)); if (what_day_of_scenario() > (day1 + 1)) { set_flag(28,0,2); print_str_color("[string]",3); } if (get_flag(200,2) == 0) { day1 = get_flag(250,4); if (what_day_of_scenario() == (day1 + 1)) { set_flag(200,2,1); print_str_color("[string]",3); } } } (Note that there is no break; call, because I didn't copy the whole start_state) The reason for me believing that the start_state isn't run proparly, is that the call print_num is only run once, as the digit "1" is only displayed once. However, if I insert a "set_state_continue" call in the above if-call, that state will be run over and over again... As it is now, the start_state is only run once, and then never again. That is, until you reload your saved game or start over with the entire scenario. Then the start_state is run, and again, only for one time. Then it stops. Anybody have an idea what could cause this? i think the above code is the culprit, as I was working on that particulair bit of the start_state when a long time ago, when it decided to malfunction. Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Thralni Posted May 18, 2007 Author Share Posted May 18, 2007 Yay for double posts in less than an hour. I thought this might have been important enough for a new post, otherwise correct me, edit the previous post with what I'm saying here and delete this post. Anyway: I noticed that I had a lot of if-calls in which I had "set_state_continue"-calls. Indeed, when I removed them all, everything worked fine. Is this a known bug in BoA, something new, or did I do something excruciatingly stupid I still don't know off what it is? Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted May 18, 2007 Share Posted May 18, 2007 If calls have a tendency to get things not to run if you're not careful, but just because you might be careless with the condition, not because of any bug. Do you have anything before the print_num(a) call in the START_STATE? Quote Link to comment Share on other sites More sharing options...
Hatchling Cockatrice Archaeolagent Posted May 18, 2007 Share Posted May 18, 2007 One other possibility that jumps to mind is that at some point in the code after the section you copied, you get stuck in a loop. Quote Link to comment Share on other sites More sharing options...
Unflappable Drayk Lazarus. Posted May 18, 2007 Share Posted May 18, 2007 If you use set_state_continue in the start_state, it will not come back and run the remainder of the start_state. So if the first lines are if(1) set_state_continue() the rest of your start_state will never be run. Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Thralni Posted May 18, 2007 Author Share Posted May 18, 2007 Kelandon: I checked all consitions probably a hundred times by now. It's all as it should be, in the right place, with the right condition, using the right flag, to be checked for the intended value. So there is no problem there. No, I have placed nothing before the print_num(a) call. Slartucker: I don't have any loop anywhere, and even if I did, I assume that the whole game would then freeze and not let me play on. Correct me if I'm wrong. Lazarus: Yes, I know. That's just how the call works, and I know that. Problem is, is that the start_sate is never run anymore (this means it never seems to be run when I take a step, switch places or do something else that should make the start_state run), until I reload. Then the start state is run the first time, when I take a step, and all other steps I take don't trigger the start_state. Instead the state is triggered to which the set_state_continue call pointed. Okay, time for a small progress update, and the way I came to the conclusion in my last post. I was talking to Nikki, who advised me to get all code out of the start_state and replace it with a print_num call, so i could start checking what bit of code is the culprit, giving me this: Code: beginstate START_STATE;print_num(a);break; After that, I slowly started adding in all code that was previously in the start_state. The start_state started malfunctioning when I entered this code: Code: day5 = what_day_of_scenario();if (day5 >= 120) { day4 = (day5 - 120); set_state_continue(13); }[a lot more if call like the above anbd below examples were here, but I took them out for now] if (day5 < 12) { day4 = day5; set_state_continue(13); } The code started working again when I did this: Code: if (day5 >= 120) { day4 = (day5 - 120);// set_state_continue(13); }[a lot more if call like the above anbd below examples were here, but I took them out for now] if (day5 < 12) { day4 = day5;// set_state_continue(13); } The reason I suspected the set_state_continue, was that I had taken out such a call in another place in the same start_state, and that managed to make things work just a bit better, so I thought I'd try it again, and it worked. Now, this is all very unfortunate, but really not such a big problem. I can just put in state 13 in all those if calls and be done with it. I'd just like to know why this happens, because I can't see anything obvious about it... I checked all my other scripts to see if there was any other place in which this could occur but didn't. I found one script in which I had put a set_state_continue, but this wasn't very alarming, as it was the only state in the start_state and therefor didn't make things complicated. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted May 18, 2007 Share Posted May 18, 2007 If you really want an explanation, I think you need to post the whole START_STATE. Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Thralni Posted May 18, 2007 Author Share Posted May 18, 2007 Code: beginstate START_STATE; // The thing with appointment mayor of Filberton a = 1; print_num(a); if (get_flag(28,0) == 1) { day1 = (get_flag(250,4)); if (what_day_of_scenario() > (day1 + 1)) { set_flag(28,0,2); print_str_color("[string]",3); } if (get_flag(200,2) == 0) { day1 = get_flag(250,4); if (what_day_of_scenario() == (day1 + 1)) { set_flag(200,2,1); print_str_color("[string]",3); } } } // The arrest of commander Johnson in Fort Filbert if (get_flag(28,1) == 2) { if (get_flag(12,11) == 0) { day2 = get_flag(250,5); if (what_day_of_scenario() == (day2 + 2)) { set_flag(12,11,1); } } } // The destruction of the empire HQ and consequences if (get_flag(12,11) != 1) { if (get_flag(41,0) == 0) { if (get_flag(121,0) == 0) { if (what_day_of_scenario() >= 10) { set_flag(121,0,1); set_town_visibility(18,1); message_dialog("[string]",""); } } } } // Sheep disappearing in town 16 day5 = what_day_of_scenario(); if (day5 >= 120) { day4 = (day5 - 120); set_state_continue(13); } if (day5 >= 108) { day4 = (day5 - 108); set_state_continue(13); } if (day5 >= 96) { day4 = (day5 - 96); set_state_continue(13); } if (day5 >= 84) { day4 = (day5 - 84); set_state_continue(13); } if (day5 >= 72) { day4 = (day5 - 72); set_state_continue(13); } if (day5 >= 60) { day4 = (day5 - 60); set_state_continue(13); } if (day5 >= 48) { day4 = (day5 - 48); set_state_continue(13); } if (day5 >= 36) { day4 = (day5 - 36); set_state_continue(13); } if (day5 >= 24) { day4 = (day5 - 24); set_state_continue(13); } if (day5 >= 12) { day4 = (day5 - 12); set_state_continue(13); } if (day5 < 12) { day4 = day5; set_state_continue(13); } break; Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Niemand Posted May 18, 2007 Share Posted May 18, 2007 I tested it, and it really does seem to execute state 13 over and over again without ever going back to the START_STATE. However, I was able to fix it by putting Code: set_state(START_STATE); at the end of state 13. Also, Thralni, you should really use Code: day4 = day5 % 12; instead of that huge set of if statements. Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Thralni Posted May 19, 2007 Author Share Posted May 19, 2007 Yeah, I probably should, though I made that script when I was very unexperienced and had no idea of all these mathematical expressions. thanks for the tip, I'll defintely use it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.