Target Practice Posted December 27, 2021 Share Posted December 27, 2021 (edited) I am an absolute baboon brain when it comes to coding in LUA, I have already learned too many other coding languages and I am trying my best to pick up DST modifications. This is my modmain.lua local require = GLOBAL.require local WorldEditor = TheWorld require "constants" while(true) do WorldEditor:PushEvent("ms_setclocksegs", {day=6,dusk=4,night=6}) end When running this, the server fails to start, and I have tried many variations of this code, but no matter what, if it doesn't crash, the line of code that is meant to set the clock segments does not work. All I wish to do is for my first step into addons is to make this random mod just permanently set the clock segments to 6,4,6. The reason I chose WorldEditor:PushEvent("ms_setclocksegs", {day=6,dusk=4,night=6}) is because as a console command it works as: TheWorld:PushEvent("ms_setclocksegs", {day=6,dusk=4,night=6}) I presumed I could simply define a variable as TheWorld, but that doesn't appear to be the case. Edited December 27, 2021 by Target Practice Further Elaboration on choice of command Link to comment https://forums.kleientertainment.com/forums/topic/136523-require-assistance-newbie-modmaker/ Share on other sites More sharing options...
Leonidas IV Posted December 29, 2021 Share Posted December 29, 2021 I've never seen any mod code using while, maybe that's the problem Link to comment https://forums.kleientertainment.com/forums/topic/136523-require-assistance-newbie-modmaker/#findComment-1529204 Share on other sites More sharing options...
FruityRounds_06 Posted December 29, 2021 Share Posted December 29, 2021 Can someone help me with my mod not working? (I am also a really bad Modder) So, I tried to add a new recipe tab but it just crashes. (Dedicated server failed to start) Can someone help me. modmain.lua Look at the bottom in the --war robots tab. Also, disclaimer my mod is a character mod with a half resprited boltgun to it I plan on changing it completely. Link to comment https://forums.kleientertainment.com/forums/topic/136523-require-assistance-newbie-modmaker/#findComment-1529279 Share on other sites More sharing options...
Target Practice Posted December 30, 2021 Author Share Posted December 30, 2021 7 hours ago, Leonidas IV said: I've never seen any mod code using while, maybe that's the problem I understand that it may be the loop but also that's not the problem. I need to figure out how to get TheWorld:PushEvent("ms_setclocksegs", {day=6,dusk=4,night=6}) working again. I honestly have no clue how to obtain "TheWorld" variable, but i have to. I know it's defined in "scripts/prefabs/world" but i'm not sure exactly how to obtain that variable. Link to comment https://forums.kleientertainment.com/forums/topic/136523-require-assistance-newbie-modmaker/#findComment-1529301 Share on other sites More sharing options...
Leonidas IV Posted December 30, 2021 Share Posted December 30, 2021 16 hours ago, Target Practice said: I honestly have no clue how to obtain "TheWorld" variable You need to say that this variable is in global scope, so you can do GLOBAL.TheWorld:PushEvent("ms_setclocksegs", {day=6,dusk=4,night=6}) 18 hours ago, FruityRounds_06 said: Can someone help me with my mod not working? (I am also a really bad Modder) So, I tried to add a new recipe tab but it just crashes. (Dedicated server failed to start) Can someone help me. modmain.lua 3.41 kB · 1 download Look at the bottom in the --war robots tab. Also, disclaimer my mod is a character mod with a half resprited boltgun to it I plan on changing it completely. You better create a new topic Link to comment https://forums.kleientertainment.com/forums/topic/136523-require-assistance-newbie-modmaker/#findComment-1529459 Share on other sites More sharing options...
FruityRounds_06 Posted December 30, 2021 Share Posted December 30, 2021 How do I keep track of the topics i create i cant figure it out Link to comment https://forums.kleientertainment.com/forums/topic/136523-require-assistance-newbie-modmaker/#findComment-1529518 Share on other sites More sharing options...
Leonidas IV Posted January 1, 2022 Share Posted January 1, 2022 On 12/30/2021 at 6:20 PM, FruityRounds_06 said: How do I keep track of the topics i create i cant figure it out You should be getting notifications. Try to see the settings or follow the topic. Link to comment https://forums.kleientertainment.com/forums/topic/136523-require-assistance-newbie-modmaker/#findComment-1529974 Share on other sites More sharing options...
FruityRounds_06 Posted January 6, 2022 Share Posted January 6, 2022 TY Link to comment https://forums.kleientertainment.com/forums/topic/136523-require-assistance-newbie-modmaker/#findComment-1530921 Share on other sites More sharing options...
FurryEskimo Posted January 9, 2022 Share Posted January 9, 2022 @Target Practice Oh, I think I might see the issue. It’s just a hunch, but I did use the While command. Basically it loops as long as the condition is true. If you’d told it to loop While True, it may just be looping forever. Perhaps that’s the issue? Link to comment https://forums.kleientertainment.com/forums/topic/136523-require-assistance-newbie-modmaker/#findComment-1531542 Share on other sites More sharing options...
Target Practice Posted January 25, 2022 Author Share Posted January 25, 2022 (edited) On 1/9/2022 at 6:43 PM, FurryEskimo said: @Target Practice Oh, I think I might see the issue. It’s just a hunch, but I did use the While command. Basically it loops as long as the condition is true. If you’d told it to loop While True, it may just be looping forever. Perhaps that’s the issue? @FurryEskimo If that's the case, do you recommend another way to have this mod work as intended? It's only intention is to set the time of day so that it never changes from what the player set it's to. I've done the setup for config and fixed everything except for the fact it crashes from using a while(true) loop. I'm pretty certain the command even works in game, without the crashing part. EDIT: I just ran the mod without a while(true) loop, it's crashing anyways, the dedicated server fails to start with this as the modmain: local require = GLOBAL.require require "constants" GLOBAL.TheWorld:PushEvent("ms_setclocksegs", {day=6,dusk=4,night=6}) Edited January 25, 2022 by Target Practice Crash reason changed Link to comment https://forums.kleientertainment.com/forums/topic/136523-require-assistance-newbie-modmaker/#findComment-1534972 Share on other sites More sharing options...
Monti18 Posted January 25, 2022 Share Posted January 25, 2022 At the moment when the modmain is loaded, TheWorld doesn't exist, it only exists when the server is started. Try adding it in a AddSimPostInit AddSimPostInit(function() GLOBAL.TheWorld:PushEvent("ms_setclocksegs", {day=6,dusk=4,night=6}) end) From there on you can either do a periodic task or something else, depending on how you want to do it. Link to comment https://forums.kleientertainment.com/forums/topic/136523-require-assistance-newbie-modmaker/#findComment-1535073 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