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 / Question about States.

Author
Message
IntRepid Bullet
13
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Australia
Posted: 29th Jul 2011 12:22
Alright, I have one question, that I can't get around...

I'm getting into scripting, I've learnt the commands and actions, how to set out everything. But, there is one thing I don't understand. Can someone please explain how states work, as in State=0. I know there meant to do with something like a loop, so it reads the script over and over. But can someone give me a brief, and.. "easy" explination of how they work? Thankyou.

Yeh, I'm a noob. <3
Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 29th Jul 2011 15:21
I'm not sure from your OP that you know how scripts are used by FPSC, so I'll try to explain.

Every active, dynamic entity within an FPSC game 'reads' the script nominated within its "Main Script" property one, for each 'frame' of the main game loop. For info, the main game loop is part of the game code that updates all the object posisions, determines object impacts, etc. and is executed many times a second. When people talk of games achieving 60 FPS, they mean that the main game loop is executes 60 times every second.

When it comes to the STATE within a script, I always think of it as a variable. More specifically a variable that only the entity running the script can see. FPSC then provides 1 script CONDITION (to test/question the state variable) and 2 script ACTIONS (to modify the state variable) for you to interact with this state variable.

The state 'variable' of every script starts of at 0. This is why some scripts use the script CONDITION "state=0" during the first few lines to define HUDs and custom variables.

In order to change the value of the state variable, "incstate=x" can be used to increase the state variable by x (incstate=5 would increase the state variable by 5) or "state=x" can used to set the state variable to x.

I hope this helps.

maho76
13
Years of Service
User Offline
Joined: 31st May 2011
Location: universe-hub, playing the flute
Posted: 29th Jul 2011 17:44 Edited at: 29th Jul 2011 17:58
a common way to control and organize complex scripts. most 1-3 line scripts dont need it, but most people nevertheless define states out of their practice.

:state=0:action,action,state=10

for common example means that after executing the actions it directly jumps to state 10 without executing states 1-9.

most scripts are written so that basic behavior is set up with the first states and then jump to bigger states to get it more complex so you have not to rewrite it all the time when you add something. like a chapter index of a book with pointing on additions in the apendix.

if you are totally insane you can do the same with variables,
but that is much more complex way to get the same result.
(i think ched does this sometimes when the lights are out, he loves vars^^ ... sorry for that, master. )

Login to post a reply

Server time is: 2024-11-24 06:26:23
Your offset time is: 2024-11-24 06:26:23