Help with your scripting

entity.onUpdateStop( ) call to pass id string to event...

entity.onUpdateStop( ) call to pass id string to event...

Postby ucm » 18 Nov 2012, 11:03

I was wondering if we could have a ummm... well in my other engine, there would be the ability to use object.update = false; or scene.update = false; to stop a scene from updating but i always thought it would be awesome to be able to specify a onTimer like string to call with something like this:

Code: Select all
scene.updateStop("someString1");

function onUpdateStop(updateStopId){
   if updateStopId == "someString1" then {
      ...
   }
}


( sorry for the mix of Lua and JavaScript; i'm still working out some things mentally for the two languages xD )
User avatar
ucm
Skyline Padawan
 
Posts: 69
Joined: 26 Oct 2012, 04:19
Location: USA

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby ucm » 18 Nov 2012, 11:07

Forgot to mention the biggest benefit is that the function would first execute any code immediately at the .updateStop call and ''then'' the object/entity/scene would stop it's update passes until a .updateStart() function is called to 'restart' the update passes...

Then something like having a flag set for whether or not the onFirstUpdate should get called 'again' on a .updateStart() call... something like .callFistUpdateOnUpdateStart = true/false ...... or something xD
User avatar
ucm
Skyline Padawan
 
Posts: 69
Joined: 26 Oct 2012, 04:19
Location: USA

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby StarFire » 18 Nov 2012, 13:36

Skyline has a game state system which can have code specifically set to run in each state. When a new state is called via

Code: Select all
sky.setGameState(enum.GS_GameOver());


the currently running state will have its onExit() function called and following this the new state will have its onEnter() function called before any onUpdate() are called. Note that the updates for the previous state will not run now, only the update for the new state.

for example lets imagine we are running in the game_main state.

onUpdate_GameMain() - this runs for as long as we are in the game_main state.

Note: onUpdate_GameMain() - all the GameMain state fucntions are the normal default functions such as onUpdate(), onKeyDown() etc with no extra text. please see http://www.chi-ad.com/Skyline/API/Lua/h ... vents.html for more info.

you make a call to change state to the game_over state with sky.setGameState(enum.GS_GameOver()), the following happen:

1) onUpdate_GameMain() stops running
2) onExit_GameMain() is called and runs its code once.
3) onEnter_GameOver() is called and ran once.
4) onUpdate_GameOver() now starts running.
5) any code in the GameMain functions will now be dormant until the state is awoken again with the setGameState(enum.GS_GameMain()) command and all code in the new state GameOver is active.
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: entity.onUpdateStop( ) вызов передать идентификатор стро

Postby ant0N » 18 Nov 2012, 13:40

Thank you NightHawk! now I understand how it works!!! :D
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby StarFire » 18 Nov 2012, 13:46

Pleased to have helped :D
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby ucm » 19 Nov 2012, 09:32

lol! xD

I'm trying; i swear xD

ok lets see...

so all the events in everything run like normal if there is only one single game state. then newbies to game state theory ( like me ) can get a good start on the concept....

Lets call this state gameStateGameMain

next:

I script my events as if there was only ever this one single game state ( this would be the equivilant to other engine that do not have a game state feature )

next:

if i wanted to create a second game state then i'd call this new game state anything i want... like: gameStateMainMenu

EDIT:
you make a call to change state to the game_over state with sky.setGameState(enum.GS_GameOver()),

EDIT: Then i call this like sky.setGameState(enum.gameStateMainMenu())

then all events currrently running ( because they are running in the game state called at doc start: gameStateGameMain ) will stop by first calling a event for the game state changing or exiting... then they are all stopped...

^-- immediately next the game state gameStateMainMenu will start running as if that was the original game state specified to run at doc start

Now "only" the events listed in the game state gameStateMainMenu are run "and" these events are run in the same order as any other game state does including the original game state that runs at doc start....

ermm.. do i get it or? O:)

*1* Also do we have a way to specify the "Set Initial Game State at Doc Start" ? i would love that :D

*2* Also could we have a function to change the game state to a string specified game state like sky.changeGameState("gameStateMainMenu") ? using a string means i can quickly and easily do a lot of nifty things using strings like in my other engine i'd send the name of a function i'd like to call as the objectId or timerId along with other string-based codes to specify what if condition ro switch case i want to run ( comes in mega handy all the time! ) 8-)

*3* hmmmmmmm i just thought of something; is it possible to have multiple game states called in an ordered string array list? or would that be too messy from both programmers side and scripters side?? hmmm xD
User avatar
ucm
Skyline Padawan
 
Posts: 69
Joined: 26 Oct 2012, 04:19
Location: USA

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby StarFire » 19 Nov 2012, 11:57

Yes is sounds like you have the idea : )

*1* Also do we have a way to specify the "Set Initial Game State at Doc Start" ? i would love that[/quote

You just call setState in your main script onInit()

*2* Also could we have a function to change the game state to a string specified game state like sky.changeGameState("gameStateMainMenu") ? using a string means i can quickly and easily do a lot of nifty things using strings like in my other engine i'd send the name of a function i'd like to call as the objectId or timerId along with other string-based codes to specify what if condition ro switch case i want to run ( comes in mega handy all the time! )


I am not sure this will be possible as the engine needs to know all the states the at exist at compile time. The states are called by numeric ids so not sure if what ask could be possible! The big use for the states initially was to take care of pause, game start screens, option,game over etc the animation system has a built in state for controlling anim flow. In time we may be able to so more with the main engine run states, we can add as many as need though. Currently there is 5 but we could have 50!

*3* hmmmmmmm i just thought of something; is it possible to have multiple game states called in an ordered string array list? or would that be too messy from both programmers side and scripters side?? hmmm xD


you could have an array of state ids ;)
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby ucm » 19 Nov 2012, 12:33

umm are you saying that you need to manually create the various game states during engine build time in the C++ ide ?

hmmmmmm.... well if we could create our own gamestates then that would be a major advantage....

could you program a document-wide setting for 'user-defined states' then at runtime, the player first checks out the states listed in the settings and then links all the appropriate event handler functions to the user-defined states?

lol i 'think' i know what i'm talking about buuuut i probably don't xD
User avatar
ucm
Skyline Padawan
 
Posts: 69
Joined: 26 Oct 2012, 04:19
Location: USA

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby StarFire » 19 Nov 2012, 12:36

Yes in time there will be a way, we could have a number of user states such as onUpdate_User1
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby ucm » 19 Nov 2012, 12:37

ucm wrote:umm are you saying that you need to manually create the various game states during engine build time in the C++ ide ?

hmmmmmm.... well if we could create our own gamestates then that would be a major advantage....

could you program a document-wide setting for 'user-defined states' then at runtime, the player first checks out the states listed in the settings and then links all the appropriate event handler functions to the user-defined states?

lol i 'think' i know what i'm talking about buuuut i probably don't xD


hmmmm... you know... the more i think about it how about having a 'pre-defined' list of states in the document-wide settings then at doc start, the player would only 'activate' the ones specified in that settings list and use a specified id like "GS0" "GS1" ect and then the listbox could have a place for the user to enter in notes about the desired user-define state a sort of note-to-self <- then that listbox be available in the main development environment as a separate panel box so that they can actively see their note during scripting time ;)
User avatar
ucm
Skyline Padawan
 
Posts: 69
Joined: 26 Oct 2012, 04:19
Location: USA

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby StarFire » 19 Nov 2012, 13:16

The states are only active if they are called, until then they lay dormant and add no load to the game( invisible to the system). If you just used the game main state which is the basic state onUpdate(), onkeyDown() etc the other states don't exist until setState is called. You don't need to add their functions to the script unless you want to activate them. This is designed so you don't need to mange them yourself.
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby Shando » 17 Mar 2013, 09:27

Just a quick question on States......

I presume when a State has already been run, and you've changed to another State, that if you change back to the initial State it will start as if it had never run before?

e.g:

State1 runs
State2 called so State1 exits
State1 called so State2 exits <-- I am assuming that State1 does not remember anything about it's previous life???

Regards

Shando
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby SolarPortal » 17 Mar 2013, 12:07

It does, but if you want to change/reset, use that states onEnter() function.
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby Shando » 17 Mar 2013, 12:40

Hi SolarPortal,

So, if I had some Global Variables that existed in State1, they would be persistent across all States?

Regards

Shando
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby StarFire » 17 Mar 2013, 16:21

yes, the scripts global var is persistent across all states, its only the update loops,enter + exit that change.

hope this helps ;)
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby Shando » 19 Mar 2013, 03:22

Sorry, one final thing on States:

Yes in time there will be a way, we could have a number of user states such as onUpdate_User1


This sounds like an excellent idea to me, we could have say a dozen "User" States that are pre-built into the engine (I can't think of anything that would need more than that, but I may be wrong :?: ) Doing this would enable us to code our own States using the pre-defined "User" States, thus alleviating the need for total control. Obviously it would be up to the programmer to keep track of which State does what, but that's what the comments are for ;)

Just my 2c (and hopefully a quick and easy implementation in Skyline 8-) )

Regards

Shando
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby StarFire » 19 Mar 2013, 16:20

Hey Shando thank you for the request ;)
I will give this some thought but for now we have added it our feature request list. It sounds like it will be possible, as we added many extra states but have not activated them, if you are happy keeping the generic naming (yes comments our our friend, especially in 6 months time when we have to go back over the code!) we should be able to expose them to lua for you. ;)
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby Shando » 19 Mar 2013, 21:36

Hi NightHawk,

Yes, I'd be happy with generic naming - what does the rest of the community think????

Regards

Shando
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: entity.onUpdateStop( ) call to pass id string to event..

Postby Shando » 14 Dec 2013, 00:20

Hi Guys,

we should be able to expose them to lua for you


Just wondering if you got any further with exposing the generic states?

Thanks

Shando
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 3 guests