Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / Global Variables

Author
Message
General Jackson
User Banned
Posted: 6th Mar 2011 04:14
With a global variable, can I go about setting it in one script, and have another script use that variable? If so how would I go about doing it?

Anotherwords for example having a character perform an action which would set a global variable, which would then trigger another entity that has that same global variable and is waiting for it to be set, perform an action.

I hope I explained myself

Thanks,

GJ
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 6th Mar 2011 08:48
Hey GJ, I thought you moved on to Unity or something like that.

Anyway, if someone hasn't answered this by the time I come back later Sunday (6th) then I will answer it. I'm too tired to attempt now (1:48 Sunday morning)
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 6th Mar 2011 19:37 Edited at: 6th Mar 2011 20:03
To use a global variable as a Boolean flag.

There are 100 possible global variables. They are indexed 0 to 99. You set the index by using the command globalvar=x where x is 0 to 99. Whenever you set the index then that is the global variable used for the conditions or actions needed. globalvar=x is also an action.

There are three actions that are used after the global variable is set:

1. decvar=x
2. incvar=x
3. setvar=x

You can place the following code in the script of an entity or trigger zone that is always being accessed every game loop. You can set another script, say from a character, dynamic entity, or triggers zone, by activateifused command. Use the desired activate number.



Now you want to do some actions in accordance with the global variable that was set to 1.

You will need to use one of the conditions. There are four conditions.

1. varequal=x
2. vargreater=x
3. varless=x
4. varnotequal=x

where x is the value that is equal, greater, less, or not equal.



There are a lot of different ways to script what you need to do. What you need to remembers is to set the global variable index. Once it is set then all other conditions and actions will refer to that global variable. Also remember that if the global variable index is set in one script and then it is set in another script before you take action on it, then the index is changed and you may not be taking action on the right script. I have done this several times since I do a lot of scripting. It is also somewhat difficult to debug.

Addendum:

Plys mod v1.09 for named variables has been implemented in v1.18. However, I'm not sure how they are used yet. It looks like that regardless of it being a named variable or an index, there are still only 100 variables.
General Jackson
User Banned
Posted: 6th Mar 2011 20:51
Quote: "Hey GJ, I thought you moved on to Unity or something like that."

I decided to use both FPSC and Unity....oh yes and DBP

Thanks very much Flatlander!
I appreciate the help, now I need to put it to use.
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 6th Mar 2011 21:06 Edited at: 7th Mar 2011 03:12
You're welcome.

Login to post a reply

Server time is: 2024-11-24 12:07:15
Your offset time is: 2024-11-24 12:07:15