silvesary Posted July 6, 2020 Share Posted July 6, 2020 (edited) Back at it again with mod characters Anyways, this time I'm trying to get a character to forget all map progress every 6-7 days but I can't find any code for it, only console commands and people complaining about losing map progress in wilderness worlds(lol) Anyways, I hope someone can help me out! Forgetting the map is my current mod character's sorta gimmick as he forgets things a lot. Edited July 6, 2020 by silvesary Link to comment https://forums.kleientertainment.com/forums/topic/119843-mod-chara-help-forget-map-progress-every-other-day/ Share on other sites More sharing options...
-LukaS- Posted July 6, 2020 Share Posted July 6, 2020 AddPrefabPostInit("wilson", function(inst) -- I used wilsons prefab file you can just put the functions in your characters file local days = 0 -- Setting the amount of days local function CountDays(inst, iscaveday) -- Counting the days function if iscaveday then -- Checking if it's day days = days + 1 -- Adding to the amount of days end print(days) -- Just checking the amount of days, you can delete it if days >= math.random(6, 7) then -- Simple if statement to check the amount of days, I used math.random but you can set a solid number GLOBAL.TheWorld.minimap.MiniMap:ClearRevealedAreas() -- Clear the map days = 0 -- Set the days back to '0' end end local function OnInit(inst) -- On init function inst:WatchWorldState("iscaveday", CountDays) -- Watching for worlds state a.k.a night, dusk or day CountDays(inst, GLOBAL.TheWorld.state.iscaveday) end inst:DoTaskInTime(0, OnInit) -- Init function end) This should do the trick. 2 Link to comment https://forums.kleientertainment.com/forums/topic/119843-mod-chara-help-forget-map-progress-every-other-day/#findComment-1351500 Share on other sites More sharing options...
silvesary Posted July 6, 2020 Author Share Posted July 6, 2020 Thanks for the help! I will say however, I am running into an issue with getting the code to work. I have replaced wilson with my mod character's name and yet I get this error everytime i attempt to run the code. Any advice? Link to comment https://forums.kleientertainment.com/forums/topic/119843-mod-chara-help-forget-map-progress-every-other-day/#findComment-1351543 Share on other sites More sharing options...
-LukaS- Posted July 7, 2020 Share Posted July 7, 2020 (edited) The method I used in my example has to be put in the modmain.lua. If you want to put it in a characters prefab file use this: local function CountDays(inst, iscaveday) if iscaveday then days = days + 1 end print(days) if days >= math.random(6, 7) then GLOBAL.TheWorld.minimap.MiniMap:ClearRevealedAreas() days = 0 end end local function OnInit(inst) local days = 0 inst:WatchWorldState("iscaveday", CountDays) CountDays(inst, GLOBAL.TheWorld.state.iscaveday) end inst:DoTaskInTime(0, OnInit) Edited July 7, 2020 by IThatGuyI 2 Link to comment https://forums.kleientertainment.com/forums/topic/119843-mod-chara-help-forget-map-progress-every-other-day/#findComment-1351887 Share on other sites More sharing options...
silvesary Posted July 7, 2020 Author Share Posted July 7, 2020 It works, that did it! Thanks a ton man, cheers! 1 Link to comment https://forums.kleientertainment.com/forums/topic/119843-mod-chara-help-forget-map-progress-every-other-day/#findComment-1351918 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