That Homeless Guy Posted January 19, 2016 Share Posted January 19, 2016 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 More sharing options...
Svarog Posted January 19, 2016 Share Posted January 19, 2016 Pretty sure there is an event that fires after the game has loaded (Black screen is gone).Events.OnGameStartYou 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 More sharing options...
That Homeless Guy Posted January 19, 2016 Author Share Posted January 19, 2016 Pretty sure there is an event that fires after the game has loaded (Black screen is gone).Events.OnGameStartYou could have it fire a function that sets a "GameHasStarted = true" and make your thing depended on that being true through if then else.PerfectI 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 More sharing options...
Svarog Posted January 19, 2016 Share Posted January 19, 2016 PerfectI 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#entry207691It 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, PresentsStateI 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 More sharing options...
That Homeless Guy Posted January 19, 2016 Author Share Posted January 19, 2016 I'm certain this is probably the right way to do it. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now