Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Check global in script.

Page: 1 of 1
 Pikmin
03-28-2008, 10:28 AM
#1
What function can be used to check a global within a OnEnter script, and how can I make it so that if it returns that the global is 1 it applies the effect only the first time you enter the module not over and over?
 Robespierre
03-28-2008, 10:36 PM
#2
Okay. Let's say your original global is called "Global_Check". This is the code you would use to return that global:

void main() {
if (GetGlobalBoolean("Global_Check") && (GetEnteringObject() == GetFirstPC()))
}


This means that it will check the global if the PC is entering the module. Place this in the On_enter script for the module you want. Then you can add the script for whatever should happen if the global is 1.

Now, if you don't want this to happen again, you can either set the global to 0 like so

void main() {
if (GetGlobalBoolean("Global_Check") && (GetEnteringObject() == GetFirstPC())) {
SetGlobalBoolean("Global_Check", 0);
}
}

Or (if you want to use the "Global_Check" boolean for something else) you can set a new global (let's call it "Check_Visited") to 1 and add that to the On_Enter script like so:

void main() {
if (GetGlobalBoolean("Global_Check") && (GetEnteringObject() == GetFirstPC())) && (!GetGlobalBoolean("Check_Visited") {
SetGlobalBoolean("Check_Visited", 1);
}
}


And that should do it. That way the script won't fire if you're already visited an area.
Page: 1 of 1