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.
;Artificial Intelligence Script
;Header
desc = View the Map
;Triggers
:state=0:hudreset,hudx=50,hudy=50,hudimagefine=YOURHUDIMAGE,hudname=YOURHUDNAME,hudhide=1,hudmake=display
:state=0:state=2
;VIEWING HUD (M KEY)
:state=2,scancodekeypressed=50:state=5
:state=5:state=10
:state=10:hudshow=YOURHUDNAME,etimerstart,state=11
:state=11,etimergreater=500,scancodekeypressed=50:hudunshow=YOURHUDNAME,state=12
:state=12,scancodekeypressed=50:etimerstart,state=15
:state=15,etimergreater=500:etimerstart,state=20
;Reset Main delay
:state=20,etimergreater=150:state=2
;End of Script
----------
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.