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 Variable Trouble

Author
Message
ApertureGFX
10
Years of Service
User Offline
Joined: 5th Mar 2014
Location: United Kingdom
Posted: 16th Mar 2014 17:15
Greetings all,

I'm currently attempting to use a global variable to influence a series of events in different scripts - except it's not working. I've tinkered around a bit, but had no success. Does anyone know what I'm doing wrong?

What's in the scripts are as follows:

An 'initial' script declares the variable:



A second script changes this variable:



A third scripts acts upon this change:



Any help here would be appreciated.
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 17th Mar 2014 08:58 Edited at: 17th Mar 2014 08:59
In the init script, use "::dimvar=remove 0" instead of ":dimvar=remove 0"
Think of ":"s as an if statement:



If you don't have a second ":" then it essentially ends up being like this:



If you don't have any conditions (eg, you just want that part of code to always execute) then just put two colons, so you end up with "::dimvar=remove 0" instead of ":dimvar=remove 0".

BlackFox
FPSC Master
15
Years of Service
User Offline
Joined: 5th May 2008
Location: Knight to Queens Bishop 3
Posted: 17th Mar 2014 16:03
You only need the variable name with "dimvar". You would use the numerical value with the variable when using commands such as "setvar".

For example, I made a traversing levels demo where you go into the 2nd level and it splits into three- Level 3 holds a key, level 4 holds nothing, and level 5 is the locked door which requires the key from level 3. In my level 3, I have the key appear script as follows:



Each time I enter level 3, if I have already picked up the key once, it checks the variable "key" and if the value is 0, it runs the default script assigned; if the value is 1, it destroys the key.

Next is the pickup script for the key.



When I approach the key and pick it up, the variable "key" is called (dimvar=key) and then I set the value to 1. So when I exit level 3 back to 2 and return to 3, the key will not appear (as outlined above).

Now we look at the locked door in level 5.



As you can see, if I went from level 2 to 5, the door will not unlock as it checks the variable "key". If the value equals 1, I can unlock it; if not, the door remains locked.

I have a video showing this. You start in level 1, go to 5 to discover the locked door, back to 2, to level 3 for the key, back to 5. I even go back to 3 just to show the key does not appear because of the variable value. Hopefully it will help you.



There's no problem that can't be solved without applying a little scripting.
ApertureGFX
10
Years of Service
User Offline
Joined: 5th Mar 2014
Location: United Kingdom
Posted: 17th Mar 2014 21:16
@TZK: Thank you, I'll bear that in mind, useful tip!

@Blackfox: I don't think I could have expected a better answer. After looking over your examples, I got it to work a charm. Thank you!
BlackFox
FPSC Master
15
Years of Service
User Offline
Joined: 5th May 2008
Location: Knight to Queens Bishop 3
Posted: 22nd Mar 2014 15:44
Quote: "@Blackfox: I don't think I could have expected a better answer. After looking over your examples, I got it to work a charm. Thank you! "


Glad to be of help.

There's no problem that can't be solved without applying a little scripting.

Login to post a reply

Server time is: 2024-03-28 16:06:25
Your offset time is: 2024-03-28 16:06:25