[ACE] Help with Tsukihime's Event Wrapper?

David Bergström

Death Arcana follower.
Veteran
Joined
Sep 7, 2013
Messages
148
Reaction score
7
First Language
English
Primarily Uses
Hey everyone,
I'm using Tsukihime's 'Event Wrapper' script at the moment, and I'v encountered a slight problem that no matter how many times I try to fix it, I can't seem to shake. Basically, I'm trying to script an 'crop' event that when the date ($game_variables[2]) changes, the even spits out a random number (which works) and then, due to this random number, either advances a stage in its growth, or reverts back to it's previous, un-watered state.
 

# setup first page event.character_name = "$Farm Soil" event.character_index = 0 event.priority_type = 1 event.trigger = 0 event.direction_fix = true event.build { call_script("self_variable('c_date', $game_variables[2])") show_text add_message("Would you like to water crop?") show_choices(["Yes","No"],0) choice_branch(0) { call_script("self_switch('c_water',true)") show_text add_message("You watered the crop.") control_self_switch("A", 0)} #turn on self-switch A when done } choice_branch(1) {} } # setup second page event.set_page(1) event.character_name = "$Farm Soil" event.character_index = 0 event.direction = 4 event.pattern = 0 event.trigger = 0 event.direction_fix = true #setup conditions for the second page event.condition.self_switch = "A" # require self-switch A to be set event.build { add_comment("<parallel page: 3>") show_text add_message("You have already watered this crop.") } # setup third page event.set_page(2) event.character_name = "$Farm Soil" event.character_index = 0 event.direction = 4 event.pattern = 0 event.trigger = 4 event.direction_fix = true #setup conditions for the third page event.condition.self_switch = "A" # require self-switch A to be set event.build { add_comment("<parallel page>") cond_if("self_variable('c_date')!=$game_variables[2]") { call_script("self_variable('c_chance',rand(60))") cond_if("self_variable('c_chance')>=30"){ call_script("self_variable('c_date', $game_variables[2])") call_script("self_switch('c_water',false)") control_self_switch("B",0) control_self_switch("A",1)} cond_else{ call_script("self_variable('c_date', $game_variables[2])") call_script("self_switch('c_water',false)") control_self_switch("A",1) } cond_else {} } #control_self_switch("A",1) } By my logic, given that the vast majority of the condition check works, the problem would have to be around lines 83-87 of the code, but for the life of me, I can't work out where I am going wrong!

Any help with this would be greatly appreciated!

Thanks in advance guys! :D
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
What does it actually get up to? Are you sure the self switches are getting changed correctly in that last bit, and the correct ones are used as conditions? I can see where you turn off self switch B, but I can't see where it's turned on, or where it's used as a condition. You also seem to be doing the same thing (with the exception of self switch B) , in both the if true and if false sections. So if self switch B doesn't actually DO anything, I wouldn't expect to see any difference in what happens whether the random number is below 30 or not.


Could you add a call_script("p c_chance>=30") after the cond_if on line 78, and a call_script("p c_chance<30") after the cond_else on line 83? As in, add some visible output to the console so you can see what bits are running correctly and what aren't?


Pop in a link to Hime's script too, in case I need to look it up to investigate anything :)
 
Last edited by a moderator:

David Bergström

Death Arcana follower.
Veteran
Joined
Sep 7, 2013
Messages
148
Reaction score
7
First Language
English
Primarily Uses
Here's the link to Hime's script Shaz (http://www.rpgmakervxace.net/topic/5511-event-wrapper-scripting-your-events/)

and the above code is a snippet of the entire event (mainly because it's 250+ lines long), but basically, self switch 'B' event is almost identical to the first page shown above, but it displays the crop at a different growth stage. The event itself contains 3 cycles checking almost the same thing shown in lines 74-91, each time checking that (in terms of the game) a day has passed, before creating a random chance of the crop growing. In theory, if the grop doesn't grow, it should reverse to it's pre-watered state (hence why here it turns off self_switch 'A' - which is turned on via watering). The growth aspect works fine, but for whatever reason if the growth conditions aren't met (e.g 'c_chance' is < 30), it just stagnates on the two parallel event pages of two and three. The only difference that should occur between whether or not 'c_chance'>30 is what self switches are changed, however when it gets the 'cond_else' branch it doesn't appear to effect the self switches.

I really hope the above makes sense and wasn't just a ramble! :\

Thank you so much for your help with this Shaz! :D
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
You're not turning self switch A off. You're turning it on, which means there'll be no difference, because that page wouldn't even be running if it wasn't on.


Maybe that's the problem - you're setting it to 1 in both results of the condition.
 

David Bergström

Death Arcana follower.
Veteran
Joined
Sep 7, 2013
Messages
148
Reaction score
7
First Language
English
Primarily Uses
Hmm, I just swapped all the '1's and '0's in the event, and it functions identically (which is odd in itself), but there's still no reverting to pre-watered state when conditions aren't met.

The toggling of self switch 'A' under both conditions is deliberate, because 'A' is a condition of the event pages on lines 56-60 and 74-91, and in order for it to revert to the 'un-watered' state of lines 31-42, it would need to be disabled. Likewise, if the crop meets conditions to grow, self switch 'B' will be turned on, and as such whether or not 'A' is on shouldn't effect it's processing. (I made it turn off even if it does advance a stage to keep things neat, in case it conflicts in the future and such). 
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
This looks a little funny when you export it...not sure if it makes a difference though if you correct it (the outer else branch is nested wrong)

3rdpage.jpg

Anyways so basically self-switch B is turned on, but page 4 is not activating? (@Shaz, he has more pages to this event)

EDIT: the event works fine. The problem is your conditional branch in your parallel page

cond_if("self_variable('c_date')!=$game_variables[2]")Presumably you have a time system in your game so that plants grow over-time. However, this condition is the one that's causing problems for me. If I change it to something that's always true, then the event pages proceed correctly."Would you like to water this crop?" Yes

...

"A plant is started to grow here. Would you like to water this ...? " ...
 
Last edited by a moderator:

David Bergström

Death Arcana follower.
Veteran
Joined
Sep 7, 2013
Messages
148
Reaction score
7
First Language
English
Primarily Uses
hmmm, that is odd. So totally ridiculous question coming here Tsukihime; Which is set to 'ON', 0 or 1?
I looked in the demo and it appears as though '0' is, however if you invert the numbers (make all 0's into 1's and vice versa) the script performs the exact same way?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
No, I don't think you should swap them ALL. Just the one on line 86 (which is where I assume you want to go back to the previous page if the self variable is < 30).

event.build { add_comment("<parallel page>") cond_if("self_variable('c_date')!=$game_variables[2]") { call_script("self_variable('c_chance',rand(60))") cond_if("self_variable('c_chance')>=30"){ call_script("self_variable('c_date', $game_variables[2])") call_script("self_switch('c_water',false)") control_self_switch("B",0) control_self_switch("A",1)} cond_else{ call_script("self_variable('c_date', $game_variables[2])") call_script("self_switch('c_water',false)") control_self_switch("A",1) } cond_else {} } #control_self_switch("A",1) }Are your {} matching correctly?{ on line 74 corresponds with } on line 91

{ on line 76 corresponds with } on line 89 - which means you've got that last cond_else inside the true result of that first condition. Should it be before the } on line 89, or after it?

Here's what you've got in there, as pseudocode:

If the self-variable 'c_date' is not the same as $game_variables[2] get a random number between 0 and 59 if the random number is 30 or more set the self-variable 'c_date' to $game_variables[2] turn off the self-switch 'c_water' turn off self switch B turn on self switch A otherwise set the self-variable 'c_date' to $game_variables[2] turn off the self-switch 'c_water' turn on self switch A endotherwise ('c_date' is the same as $game_variables[2]) do nothingendIs that what you want to happen, and when? How often does $game_variables[2] get updated?Since this page is conditioned by self switch A being turned on, and both of those true/false results will turn on self switch A, they have no effect. At what point is self switch B turned on? It's turned off here, and if it's already off, that will also make no difference.

Have you actually set this up as a REAL event to test that your logic works? If it's such a big and complicated event, I suggest you do that - get it working as a real event first, and then worry about setting it up with Hime's event wrapper script. If it WILL work as a regular event, maybe you should consider using one of the event cloning/spawning scripts around, rather than the event wrapper.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
hmmm, that is odd. So totally ridiculous question coming here Tsukihime; Which is set to 'ON', 0 or 1?


I looked in the demo and it appears as though '0' is, however if you invert the numbers (make all 0's into 1's and vice versa) the script performs the exact same way?
In the editor, 0 is ON, 1 is OFF


I've made it so that true is ON, and false is OFF, because it's not very intuitive how the numbers are set up.


There was a bug where typing in 0 or 1 always defaulted to 0.
 
Last edited by a moderator:

David Bergström

Death Arcana follower.
Veteran
Joined
Sep 7, 2013
Messages
148
Reaction score
7
First Language
English
Primarily Uses
In the editor, 0 is ON, 1 is OFF

I've made it so that true is ON, and false is OFF, because it's not very intuitive how the numbers are set up.

There was a bug where typing in 0 or 1 always defaulted to 0.
Hmm, given what your event exporter came up with as an output, I may be experiencing that bug - which could also explain why whether or not I use 0 or 1 for on, the script reacts the same?

And with regards to what you said Shaz;

If you invert what is done to the self switches (turn on 'B' and turn off 'A'), then that's exactly what I want to happen, but it doesn't! :(

And I plotted it out as a real event and it works, so I'm not actually sure why the above doesn't...

If I could use the event creator, I would, but the limitation of 4 self switches by the editor makes it impossible to event the crops the way I need them two (with 4 different growth stages each with dry and wet)
 
Last edited by a moderator:

David Bergström

Death Arcana follower.
Veteran
Joined
Sep 7, 2013
Messages
148
Reaction score
7
First Language
English
Primarily Uses
Oh really? I'll take a look at that now!

Thank you so much to the both of you for all your help, you've both been fantastic!

I'll see how things go with this script Tsukihime! :D
 

David Bergström

Death Arcana follower.
Veteran
Joined
Sep 7, 2013
Messages
148
Reaction score
7
First Language
English
Primarily Uses
Hey again guys,
I'm trying out how things work with 'Custom Page Conditions' but it doesn't appear to be compatible with PK8's 'Self Data Suite', without which, It seems I'm still running into the problem with the editor restricting it to four self switches.
 

So I was wondering, is there a way for me to fix the bug you spoke of above, Tsukihime?
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
I've already fixed the 0/1 bug.


What compatibility issues are there? Do the script calls behave incorrectly? Does the game crash?
 
Last edited by a moderator:

David Bergström

Death Arcana follower.
Veteran
Joined
Sep 7, 2013
Messages
148
Reaction score
7
First Language
English
Primarily Uses
Oh? How long ago? (I ask because I've had your script downloaded for maybe a month or two now)

And I get an error when I start a new game saying "Custom Page Conditions line 186: No Method Error occurred" followed by "undefined method "self_variable" for #game_event:.......etc" where "self_variable" is the call for the self data suite
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I'm not sure if it matters, but do you have the self data suite ABOVE the custom page conditions script in the list?
 

David Bergström

Death Arcana follower.
Veteran
Joined
Sep 7, 2013
Messages
148
Reaction score
7
First Language
English
Primarily Uses
I do. It's the at the top of the list. Now that you mention it though, I'll place the custom events higher and see what happens...

EDIT: Sadly, no change, still threw up the same error XD



EDIT II:
*Sigh* I almost put this in a new post, because rules or not, it deserves one. I figured I might as well try everything to fix my problem, and so re-added Hime's Event Wrapper. It works brilliantly. Not a hitch. At all.

I STILL HAD THE COPY WITH THE BUG!

*Sigh* I feel so stupid!

But seriously, thank you SO MUCH for all your help, both of you! You've both been fantastic, and so patient!
Hopefully, this will be the last time you hear from me looking for advice for some time eh?

Again, thank you so much guys, you two are an asset to the community here XD
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,981
Members
137,563
Latest member
cexojow
Top