Jump to content
Sign in to follow this  
That Homeless Guy

Testing for when the game is running Lua

Recommended Posts

I can't seem to find anything in the game code that detects when the game has started.
eg: after the click to start screen. I found that the game keeps track of gamestates but searching "InGameState" yields nothing in the Lua.
I have a click responsive script that spits an error on the "Click to start" screen. It is a benign error and the script has no use in the loading states or menu state so it's not a huge issue but I'd rather clean up the error for my mods users. I was getting by with a test for if the player existed before, but now that I have added some more functionality, the error occurs because the player exists when other elements of the game world don't until the black loading screen is gone.

Share this post


Link to post
Share on other sites

Pretty sure there is an event that fires after the game has loaded (Black screen is gone).

Events.OnGameStart

You could have it fire a function that sets a "GameHasStarted = true" and make your thing depended on that being true through if then else.

Share this post


Link to post
Share on other sites

Pretty sure there is an event that fires after the game has loaded (Black screen is gone).

Events.OnGameStart

You could have it fire a function that sets a "GameHasStarted = true" and make your thing depended on that being true through if then else.

Perfect

I assume the counter event is Event.OnGameExit.

I was aware that the gamestate changed in between clicking and the game being visible. I just wasn't sure how t could be referenced.

I haven't used an Event driven system like this since I got my java certification.

Share this post


Link to post
Share on other sites

Perfect

I assume the counter event is Event.OnGameExit.

I was aware that the gamestate changed in between clicking and the game being visible. I just wasn't sure how t could be referenced.

I haven't used an Event driven system like this since I got my java certification.

There probably is a better way but I'm a complete noob when it comes to coding, the solution I gave you is the only one I can come up with using my limited knowledge.

Check this out, someone made a reference sheet. http://theindiestone.com/forums/index.php/topic/16660-full-project-zomboid-lua-reference-sheet/?hl=%2Bevents#entry207691

It lists all the events and whatnot.

As far as GameStates themselves go here are all I could find which is all in here http://theindiestone.com/zomboidjavadocs/

 

AlphaWarningState, CharacterCreationState, ChooseStory, GameLoadingState, IngameState, LoadGamePopupState, LoginState, MainScreenState,ModBrowserState, PrefaceState, PresentsState

I did some more digging but didn't find a much better solution than the one I suggested :S

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...