Jump to content

Testing for when the game is running Lua


That Homeless Guy

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.

Link to comment
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.

Link to comment
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.

Link to comment
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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...