questions about script

Started by randypana, Mon 19/08/2013 00:28:28

Previous topic - Next topic

randypana

 hello I can explain about the variables and parameters, the tutorials do not help at all, thanks
I'm busy doing nothing ;)

Gilbert

Can you be more specific on what you are going to do? Otherwise it's quite hard to help you.

Lewis

#2
Do you mean global variables?

If so, they're a way of setting states across the game which allow you more control of what happens at various points in the game.

Let's say you have a room. Depending on which of three different phases in the game you are in, something different will happen in that room.

Let's use this as an example:

Early part of game -- character approaches you on entering
Middle part of the game -- character gives you something on entering
Late part of the game -- character stands by the window and sings at you

First thing to do is go into the global variables window and add a new variable. Let's call it room1_state.

Set it to 'int' (integer - i.e. you're going to be using a number to define it), and set the starting int to 1 (as in, 'state 1 of 3').

First thing to do is trigger the changes of global variable state at the appropriate points in the game - i.e. the points at which you want the room's state to change (must be before entering the room in this instance):

Code: AGS
room1_state=1;

room1_state=2;

room1_state=3;


Then, in room_AfterFadeIn, you need to call it:

Code: AGS
if (room1_state == 1) {
    //character approaches on entering
    }
else if (room1_state == 2) {
    //character gives you something on entering
    }
else if (room1_state == 3) {
    //character stands by window and sings at you
    }


Hopefully this makes a bit more sense - I know the manual is light on this stuff.
Returning to AGS after a hiatus. Co-director of Richard & Alice and The Charnel House Trilogy.

SMF spam blocked by CleanTalk