Accessing global vars from the interaction edcitor in script?

Started by Isegrim, Tue 27/04/2004 19:20:24

Previous topic - Next topic

Isegrim

Is there a way to handle a global var which is used in the script in the interactions editor (conditional: If variable...) or the other way round?

and is there a direct way to check "Player has been in room" in script?
This post was generated automatically and therefore bears no signature.

strazer

A partial answer to your first question can be found in the AGS tidbits & snippets page:
"You can only read interaction editor's global variables with the GetGraphicalVariable (string variable_name) function."

Scorpiorus

Quote from: Isegrim on Tue 27/04/2004 19:20:24
Is there a way to handle a global var which is used in the script in the interactions editor (conditional: If variable...) or the other way round?
The only way is to create a global variable by means of the Interaction Editor and then access it with GetGraphicalVariable()/SetGraphicalVariable() script functions. Kinda counterwise :)


Quoteand is there a direct way to check "Player has been in room" in script?
Nope, afaik. But you can have an array to store how many times player visited a certain room:

//main global script:

#define ROOMS_MAX 1000

int roomVisits[ROOMS_MAX];

function on_event(int event, int data) {

   if (event == ENTER_ROOM) {
      if (data>=0 && data<ROOMS_MAX) roomVisits[data]++;
   }
}


function HasBeenInRoom(int room) {
   if (room>=0 && room<ROOMS_MAX) return roomVisits[room];
   else return 0;
}

//script header:
import function HasBeenInRoom(int room);

Quote from: strazer on Tue 27/04/2004 19:25:04
A partial answer to your first question can be found in the AGS tidbits & snippets page:
"You can only read interaction editor's global variables with the GetGraphicalVariable (string variable_name) function."
Yeah, that was untill AGS v2.6 (I think) was released. SetGraphicalVariable() is there. :)

~Cheers

strazer

Ah, I thought you meant "You can only read graphical variables with this function:", not "You can only read graphical variables, with this function:".
I've never used the interaction editor apart from the basics, so I never thought about it. The sentence just looked important. :)
I'll remove it then, thanks.

Isegrim

Thanks to both of you!

This would allow another workaround for the room check: I could set a global var (like room1, room2 etc) to 1 whenever the according room is entered for the first time...
But, to be honest, I was just wondering without having a something definite in mind...  ;D
This post was generated automatically and therefore bears no signature.

Scorpiorus

Quote from: strazer on Tue 27/04/2004 20:06:07
Ah, I thought you meant "You can only read graphical variables with this function:", not "You can only read graphical variables, with this function:".
I've never used the interaction editor apart from the basics, so I never thought about it. The sentence just looked important. :)
I'll remove it then, thanks.
I've just figured out that SetGraphicalVariable() was added into the 2.61beta2, so it's kinda unofficial. :)

Quote from: Isegrim on Tue 27/04/2004 20:37:05This would allow another workaround for the room check: I could set a global var (like room1, room2 etc) to 1 whenever the according room is entered for the first time...
Yeah, but still it could be a good idea to be able to check HasBeenInRoom condition via the script.

~Cheers

SSH

Actually, since the runtime engine knows whether to execute the "First time player eneters room" interaction or not, it must keep track of whether the player has been to each room. It would be handy if there was a built-in function to access this data!

if ( HasBeenInRoom(int roomno) ) {
}

12

Pumaman


SMF spam blocked by CleanTalk