The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: VampireHSS on January 29, 2006, 02:59:15 PM

Title: Conditional Branch Script
Post by: VampireHSS on January 29, 2006, 02:59:15 PM
Could someone make me a Conditional Branch Script: If hero 001 class is 003
Please
Title: Conditional Branch Script
Post by: Dwarra? on January 29, 2006, 04:23:21 PM
a little more specific? and if you want a certain conditional branch youll need events not scripts
Title: Re: Conditional Branch Script
Post by: Tsunokiette on January 29, 2006, 06:44:33 PM
Quote from: VampireHSS
Could someone make me a Conditional Branch Script: If hero 001 class is 003
Please


if $game_party.actors[1].class_name == 'Class Name'

end

that should work
Title: Conditional Branch Script
Post by: VampireHSS on January 29, 2006, 07:59:29 PM
Quote
if $game_party.actors[1].class_name == 'Class Name'

Is it suposed to become like this:
Quote
if $game_party.actors[1].class_name == 003: Mage

????
Title: Conditional Branch Script
Post by: Zeriab on January 29, 2006, 08:06:56 PM
Quote from: VampireHSS
Quote
if $game_party.actors[1].class_name == 'Class Name'

Is it suposed to become like this:
Quote
if $game_party.actors[1].class_name == 003: Mage

????

No, It's supposed to be like this:

if $game_party.actors[1].class_name == "Mage"

end
Title: Conditional Branch Script
Post by: VampireHSS on January 29, 2006, 08:10:23 PM
It's not working
Title: Re: Conditional Branch Script
Post by: Zeriab on January 29, 2006, 08:42:38 PM
Quote from: VampireHSS
Could someone make me a Conditional Branch Script: If hero 001 class is 003
Please


Meh, I haven't read the post properly. What you asking for is to check if hero number 001 in the database have the class set to 003, right? If so what you want is this:

Code: [Select]
if $data_actors[1].class_id == 3
  #write code here
end
Title: Conditional Branch Script
Post by: VampireHSS on January 29, 2006, 08:47:09 PM
Quote
if $data_actors[1].class_id == 3
  #write code here
end

What do you mean by "write code here" ? Is it suposed for me to do anything there?
Title: Conditional Branch Script
Post by: Zeriab on January 29, 2006, 08:50:15 PM
Yes, sorry if it was obvious what you should do. You are supposed to write whatever you want to happen when the conditions are fulfilled. Also if you want something else to happen if the condition is not fulfilled use this:

Code: [Select]
if $data_actors[1].class_id == 3
 
else
 
end


@Tsu I think you are forgetting that the first hero is $game_party.actors[0], not 1.

Edit: Corrected the note to Tsu
Title: Conditional Branch Script
Post by: VampireHSS on January 29, 2006, 08:53:44 PM
Oh, now I'm understanding. LOL  :oops:
It doesn't work. It says syntax error
Title: Conditional Branch Script
Post by: Zeriab on January 29, 2006, 09:01:15 PM
What exactly have you written? (Remember casing is important!)

Also if you used my note to Tsu, that would explain the error, because it was wrong. I have corrected it I think.
Title: Conditional Branch Script
Post by: VampireHSS on January 29, 2006, 09:07:37 PM
Well... in the condition branch script line i put this:
Quote
if $data_actors[1].class_id == 3

So it is this:
Quote
Contitional Branch: Script: if $data_actors[1].class_id == 3
Message: Done
else
Message: NOOOOOOOOOOOOOOOOO
end


This is what I've done to test it.
Title: Conditional Branch Script
Post by: Zeriab on January 29, 2006, 09:14:23 PM
I totally misunderstood what you meant.  :whoa:

No wonder you get a syntax error.
In the script you want to end up with a boolean. If you write true you will get the message "Done" shown. If you writefalse you will get the message "NOOOOOOOOOOOOOOOOO" shown.
Don't worry, the fix is easy. Just delete the if. This should fix the matter.

Edit: Just enter $data_actors[1].class_id == 3
Title: Conditional Branch Script
Post by: blueXx on January 29, 2006, 09:15:51 PM
i am wondering:
if you need to condition the job therefore it is changed in the game correct?
if not just work as you setted it in the db
if i am right, after the change make a variable operation
(1 = warrior, 2 = something else 3= mage, like their position in the database)

then you can conditional "if variable(jobs) = 3 then"
and that will solve everything
Title: Conditional Branch Script
Post by: VampireHSS on January 29, 2006, 09:30:56 PM
THANKS Zeriab
Title: Conditional Branch Script
Post by: Tsunokiette on January 30, 2006, 08:58:17 PM
Quote from: Zeriab
Also if you used my note to Tsu, that would explain the error, because it was wrong. I have corrected it I think.


In response to teh note, the $game_party.actors array actualy starts at 1 as opposed to 0, that's one way enterbrain found they could screw with us lol. :lol:
Title: Conditional Branch Script
Post by: Zeriab on January 30, 2006, 11:34:07 PM
I know. That's why I always test if $something[1] really is number one.
It might have something to do with hashes starting at 1 and arrays at 0 or the other way around, but when you don't have to declare the type a common good thing to do is to test if what you think you get really is what you get.