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 / Can someone explain some scripting to me

Author
Message
Dragon slayer
18
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 30th Oct 2012 03:21
Call me dumb, call me stupid but there are some things I just don't get about scripting. This is an auto door script and I will try to explain what I am not getting!



Ok I understand that the script will almost always start with
:state=0, I understand the condition anything = 75 but I am not to sure I understand the other states. I know there is a list of conditions and actions but is there a list of states or do you just number your state= as you go along and if you need that state 6 lines down set that state in the line and the program will go back and find it?

I saw some code in nickydudes book, State=0, plriswithin=120,state=4 what is state=4

I think I almost have this but there is something I am missing with the state stuff. Thanks for any help you can give me with this!!!

Dragonslayer
BlackFox
FPSC Master
16
Years of Service
User Offline
Joined: 5th May 2008
Location: Knight to Queens Bishop 3
Posted: 30th Oct 2012 04:15
Quote: "Ok I understand that the script will almost always start with
:state=0, I understand the condition anything = 75 but I am not to sure I understand the other states. I know there is a list of conditions and actions but is there a list of states or do you just number your state= as you go along and if you need that state 6 lines down set that state in the line and the program will go back and find it?"


There is no list of "states". Think of "states" as "line numbers" in code. Granted, you can have multiple lines with the same "states" (for example, defining huds), but the states generally are used to keep track of where the script is to go after done the line above.

For example, I will show a simple script to display a hud when a key is pressed.



----------

Here is the breakdown:

"state 0"- define(s) the hud(s); also jumps to "state 2"

"state 2"- defines where to go if the defined key is pressed, which is "state 5"

"state 5"- jump to "state 10"

"state 10" shows the defined hud name, starts a timer and jumps to "state 11"

"state 11"- after timer reached set time and the defined key is pressed, removes the hud and goes to "state 12"

"state 12"- if the defined key is pressed, start a timer again and go to next line

"state 15"- timer reaches set time, go to final "state" after starting the timer again

"state 20"- timer reaches the time and jumps the script back to "state 2"

--------

So as I mentioned, the "states" are the lines of code the script uses to know where to go and what to do. A good practice is to always remember to:

1. keep your script organized- helps to define your hud(s) at the "state=0" lines so you know where they are, not in the middle. This also helps to track any script errors.

2. Remember that you are restricted to 350 lines of code in scripts.

Quote: "I saw some code in nickydudes book, State=0, plriswithin=120,state=4 what is state=4"


You would need the full script. That line in itself will not do anything, but is either a snippet of a completed script or an example.


There's no problem that can't be solved without applying a little scripting.
Dragon slayer
18
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 30th Oct 2012 04:37
That helped a lot you are the man!!! Maybe I did not really say it right but that was the way I was thinking, just the way you explained it but I was not totally sure.

That snippet I put up from nickydude was part of a script in his book. State 4 was 4 or 5 lines down. That code was the first line but now I understand that state=4 means that the program jumps down those 4 or 5 lines and executes the code on the state=4 line. I still have a lot to learn and try but this cleared up a lot, THANKS!!!

Dragonslayer
Dragon slayer
18
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 2nd Nov 2012 22:57 Edited at: 2nd Nov 2012 23:14
I have been off for a few days working. I drive a truck and have time to think about things while driving. One thing I did not get is why there could be so many lines of the same state number. I think I figured that out.

I saw a script that started at state = 0 then player did something then it went to state 1 then something else then it went to state 4 and there were about 4 or 5 lines of state 4. So from what I understand about scripting the script will skip to the first state 4 line and go through all the state 4 lines from top to bottom doing all the tasks until it encounters say a state 2 command then it will go and do all these until there is another state command.

So going by what blackfox says that the states can be thought of as line numbers multiple lines that have the same state number could be thought of as one big series of commands. Is this right?

Dragonslayer
BlackFox
FPSC Master
16
Years of Service
User Offline
Joined: 5th May 2008
Location: Knight to Queens Bishop 3
Posted: 2nd Nov 2012 23:45
The reason you will see multiple lines with the same "state" is because is saves time and lines in scripting. For example...

this script...



...is the exact same as this one...



...only written differently. There are times where you may need to have "multiple" state lines, such as waiting to see if a key out of a choice of 3 is pressed, like this...



Or perhaps you need a value of a variable checked...



...in which case the "checking" uses the same state line.


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

Login to post a reply

Server time is: 2024-11-23 19:59:10
Your offset time is: 2024-11-23 19:59:10