PDA

View Full Version : Help me with variables please


05thouldm
2003-10-11, 09:14 AM
ok i understand switches and that but what are variables for whats the difference between them and switches? And i would like to know how to use variables well and what things there best for doing and.1. can someone tell me how to make an event with more than 2 preconditions like- you have to hit all 4 switches to open a door

thanks in advance:D

BlueCube
2003-10-11, 12:31 PM
ok i understand switches and that but what are variables for whats the difference between them and switches?

Switches have an on/off state, while variables have a numeric value. You can add/subtract/whatever to a variable, as well.


And i would like to know how to use variables well and what things there best for doing

They're best used for.. well.. anything that has to do with a number. You can keep track of something (say, how many times you tried to open a locked chest), set something to a value ("You've killed 10 slimes in the arena, so you've earned 10 potions!").. basically, anything that has a number assigned to it (including your current Map/X/Y position) can be useful with a variable.


and.1. can someone tell me how to make an event with more than 2 preconditions like- you have to hit all 4 switches to open a door


I'll call the switches to open the door "keypads" so you won't be confused when I refer to one instead of the on/off switch.

You can use:

1) An parallel-process, 2-page event that keeps track of when all the switches are used (page 1 would use a branch-within-a-branch-within-a-branch-within-a-branch style for checking everything.. setting a switch for page 2 to be activated)

(I don't have RPGMaker where I'm at, so it's time for pseudocode.. this is on Page 1)

<> If switch (0050:Keypad1_Switch) is ON
...<> If switch (0051:Keypad2_Switch) is ON
......<>If switch (0052:Keypad3_Switch) is ON
.........<>If switch (0053:Keypad4_Switch) is ON
............<>Turn switch (0054:Door_Is_Open) ON
.........<>End
......<>End
...<>End
<>End

===============

2) A variable system, where each keypad adds 1 to a variable, then switches itself off.

(This is just one of the keypads.. just change the switch name for each one. Page 1 is first, obviously.)

On key press, No preconditions

<> Turn switch (0030:Keypad1_Switch) ON
<> Variable (0010:Keypad_Total): Add 1
<>

(Page 2)

On key press, Precondition (0030:Keypad1_Switch) is ON

<> Message "You already activated this switch.. pressing it again won't do anything."
<>

(Now, this is the door event)

(Page 1)

On Key press, no preconditions, image is closed door

<> Message "Cube: This door is locked. Looks like we need to hit 4 switches."
<>

(Page 2)

On Key press, precondition (0010:Keypad_Total) is equal to 4, below hero, image is blank

<>

=====================

thanks in advance:D

No big deal, this is about the only forum I actually POST in.

05thouldm
2003-10-14, 04:11 PM
Thank you that really helps now I can use variables too and sorry i didnt know that i would have to start a new thread for each question but i will in future. My game can now have better puzzles and stuff thanks again!