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 / variable help.

Author
Message
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 17th Jan 2009 20:30
Ok well right now i'm really not understanding variables i'm trying to get it so when a enemy gets killed it sets the variable to 0 and when its zero it will change a different enemies script back to the main. What i said was probably hard to understand so heres and example of what i did.

In the enemies shoot script i put




i also tried putting


In side of the enemy that i want to go back to the main ai i put



when i tried the globalvar i did


and i put this both tries


]
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 17th Jan 2009 21:36
The variable to be set MUST be called first.


Here's how it works:

1) Tell the script what variable you will be checking/changing

2) Check/Change the variable.


Example:


In this code snippet, we first tell the script hat it will "always" be using "global variable #14". Then in state 1, we CHECK "global variable #14" to see if it is equal to 50.


To tell the script what variable to use:
localvar
globalvar

Local Vars are different from Global Vars. Local Variable #1 in Script A will not necessarily hold the same value as Local Variable #1 in Script B. The local variables can only be seen and used by their owning scripts and every script has their own local variables. Global variables may be seen and used by ALL scripts.


Hope that helped.


The one and only,


Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 17th Jan 2009 21:42
so how would i change the value of global variable #14?

]
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 17th Jan 2009 21:45


Will "always" use "global var #14", and when in state 1, will "set variable" (The one you told the script to use, which in this case is "global var #14") to 50.

So that will set Global Var 14 to a value of 50.


The one and only,


Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 17th Jan 2009 21:47
o ok let me try this ill be right back

]
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 17th Jan 2009 22:48 Edited at: 17th Jan 2009 23:08
it didn't work

EDIT: sorry i didnt edit my above post

EDIT it worked i just put setvar=0 and globalvar=14 in the destroy script.

]
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 17th Jan 2009 23:10 Edited at: 17th Jan 2009 23:11
When I personally think of a toggle variable I think of on and off. 0 being off and 1 being on. When you define the current variable it's default is 0 so I would probably then set the variable to 1 when you want to toggle the variable on (active).

Also, since you want to change a variable when a character is killed I would put it into the destroy fpi. The following is what I would do for the fadecorpse.fpi.

=========================================

;Artificial Intelligence Script

;Header

desc = Fade Out Disappear

;Triggers

:state=0:state=1,globalvar=14
:state=1:setvar=1
:state=1,alphafadeequal=100:decalphafade=0
:state=1,alphafadeequal=0:state=2,destroy

;End of Script

=============================================

Now, I'm at a loss as to what exactly you want done with the second character. However, in the script that you want to make the change:

:state=0:globalvar=14:state=1
:state=1,varequal=1:runfpidefault=1

Now what might be working is the logic for running the same or a different main script for the second character. I guess where I'm at a loss is why would you want to run the same script that was already assigned to the character originally?

Plystire's logic is correct so I would say it has to do with how you are implementing it.

addendum:

You did this all while I was writing that long post.

The past has a lot of memories to hold onto; but, today is chock full of new adventures, and, the future shouts out, "The best is yet to come!" -- TerryC
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 17th Jan 2009 23:30
Quote: ";Artificial Intelligence Script

;Header

desc = Fade Out Disappear

;Triggers

:state=0:state=1,globalvar=14
:state=1:setvar=1
:state=1,alphafadeequal=100:decalphafade=0
:state=1,alphafadeequal=0:state=2,destroy

;End of Script
"
Quote: "Also, since you want to change a variable when a character is killed I would put it into the destroy fpi. The following is what I would do for the fadecorpse.fpi."


thats almost exactly what i did thanks for the help

]

Login to post a reply

Server time is: 2024-11-24 18:37:52
Your offset time is: 2024-11-24 18:37:52