sirrNaDE Posted September 5, 2021 Share Posted September 5, 2021 hey there, so there is a problem im having with my code. i am trying to delete the map progress whenever he opens it local master_postinit = function(inst) -- Set starting inventory inst.starting_inventory = start_inv[TheNet:GetServerGameMode()] or start_inv.default -- choose which sounds this character will play inst.soundsname = "webber" -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used inst.talker_path_override = "dontstarve_DLC001/characters/" -- Stats inst.components.health:SetMaxHealth(TUNING.WAWERLY_HEALTH) inst.components.hunger:SetMax(TUNING.WAWERLY_HUNGER) inst.components.sanity:SetMax(TUNING.WAWERLY_SANITY) -- Damage multiplier (optional) inst.components.combat.damagemultiplier = 1 -- Hunger rate (optional) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE inst.OnLoad = onload inst.OnNewSpawn = onload inst:DoPeriodicTask(2.0, function(inst) ExecuteConsoleCommand("TheWorld.minimap.MiniMap:ClearRevealedAreas()") end) function MapScreen:OnBecomeActive() ExecuteConsoleCommand("TheWorld.minimap.MiniMap:ClearRevealedAreas()") end end so:mapsceen:onbecomeactive is what i used until not long ago, and doperiodictask is what i used as a change, if the onbecomeactive would just not work (don't worry, i didn't use them together, i just had the onbecomeactive, then i deleted it, and replaced it with the periodictask). thing is, none of them really work. it either deleted the progress for every character, or just crashed the game when i desperately tried to insert inst. before the ExecuteConsoleCommand. so i got a question, do you guys know how to delete my map progress after opening the map? Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/ Share on other sites More sharing options...
Monti18 Posted September 6, 2021 Share Posted September 6, 2021 I think the problem is that you are running these commands on the server, so not on the client that should lose the progress. Try adding these functions to the common_postinit and then add them to if TheNet:GetIsClient() or not TheNet:GetServerIsDedicated() then if TheNet:GetIsClient() or not TheNet:GetServerIsDedicated() then inst:DoPeriodicTask(2.0, function(inst) ExecuteConsoleCommand("TheWorld.minimap.MiniMap:ClearRevealedAreas()") end) --or function MapScreen:OnBecomeActive() ExecuteConsoleCommand("TheWorld.minimap.MiniMap:ClearRevealedAreas()") end end This way the code will only run on the client, where it should reset the progress. 1 Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/#findComment-1491508 Share on other sites More sharing options...
sirrNaDE Posted September 6, 2021 Author Share Posted September 6, 2021 Come to think of it, what's the difference between common_postinit and master_postinit? Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/#findComment-1491541 Share on other sites More sharing options...
Monti18 Posted September 6, 2021 Share Posted September 6, 2021 Common_postinit is run on the client and on the server, contrary to master_postinit which is only run on the server. If you compare it to the fn of items, common_postinit is the same as everything that comes before if not TheWorld.ismastersim then return inst end and everything that comes afterwards is like the master_postinit 1 Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/#findComment-1491558 Share on other sites More sharing options...
sirrNaDE Posted September 6, 2021 Author Share Posted September 6, 2021 Ah, I see. I will test it later. as for now, thanks alot for the info. Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/#findComment-1491577 Share on other sites More sharing options...
sirrNaDE Posted September 6, 2021 Author Share Posted September 6, 2021 oh, the thing is, that i needed it to delete map only for my character, as when i would play for example Warly, it would do it the normal way. but still thanks, as that saved me a headache for later on Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/#findComment-1491641 Share on other sites More sharing options...
Monti18 Posted September 6, 2021 Share Posted September 6, 2021 Oh is it now deleting the map for each character? Then try this: if inst.prefab == "yourcharacter" then --replace with your character prefab if TheNet:GetIsClient() or not TheNet:GetServerIsDedicated() then inst:DoPeriodicTask(2.0, function(inst) ExecuteConsoleCommand("TheWorld.minimap.MiniMap:ClearRevealedAreas()") end) --or function MapScreen:OnBecomeActive() ExecuteConsoleCommand("TheWorld.minimap.MiniMap:ClearRevealedAreas()") end end end This should make it only run for your character. 1 Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/#findComment-1491658 Share on other sites More sharing options...
sirrNaDE Posted September 6, 2021 Author Share Posted September 6, 2021 So, since it fails to find the prefab name, I'm gonna check. The prefab file is gonna be pretty much the file under scrips/prefabs/(for example)waxwell.lua. in that case the prefab name would be "waxwell", right? Or is there another way to get the name? Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/#findComment-1491672 Share on other sites More sharing options...
Monti18 Posted September 6, 2021 Share Posted September 6, 2021 return MakePlayerCharacter("yourcharacter", prefabs, assets, common_postinit, master_postinit, prefabs) The end of your character prefab should look like this. In this case, the prefab name would be yourcharacter. 1 Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/#findComment-1491680 Share on other sites More sharing options...
sirrNaDE Posted September 6, 2021 Author Share Posted September 6, 2021 (edited) nvm, i'm just gonna go straight to the code. this is how my common_postinit looks like local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "waverly.tex" ) --tags inst:AddTag("waverly") if inst.prefab == "waverly" then if TheNet:GetIsClient() or not TheNet:GetServerIsDedicated() then function MapScreen:OnBecomeActive() ExecuteConsoleCommand("TheWorld.minimap.MiniMap:ClearRevealedAreas()") MapScreen._base.OnBecomeActive(self) if not TheWorld.minimap.MiniMap:IsVisible() then TheWorld.minimap.MiniMap:ToggleVisibility() end self.minimap:UpdateTexture() end end end end that is how it looks like. the thing below the ExecuteConsoleCommand is to have the circle around visible on the map. i'm sorry it has to go for so long, my stupid brain couldnt find any tutorials on making stuff character only. i will let you be after this one, i swear, like you've already done alot if you dont find anything wrong, im gonna take a big study on the inst.prefab function Edited September 6, 2021 by sirrNaDE Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/#findComment-1491684 Share on other sites More sharing options...
Monti18 Posted September 6, 2021 Share Posted September 6, 2021 No worries, I'm happy to help! I got you covered! AddPlayerPostInit(function(inst) if TheNet:GetIsClient() or not TheNet:GetServerIsDedicated() then if inst.prefab == "waverly" then TheWorld.minimap.MiniMap:ContinuouslyClearRevealedAreas(true) else TheWorld.minimap.MiniMap:ContinuouslyClearRevealedAreas(false) end end end) The reason it didn't work was because the character initialization takes some time, that's why the prefab name was not there. If you add this function in DoTaskInTime(0,fn) it will work as the prefab name will be there. When trying to get it to work, I found this nice function ContinuouslyClearRevealedAreas. I does what it's called, so no need to make complicated functions if you have there I added it now in a AddPlayerPostInit fn as otherwise the map would be continualy cleared when changing character. When I tested it it was working as intented If you have more questions, don't hesitate to ask! 1 Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/#findComment-1491708 Share on other sites More sharing options...
sirrNaDE Posted September 6, 2021 Author Share Posted September 6, 2021 put that into common_postinit? btw, i cant thank you enough, you have officialy seen me go through all stages of grief, and still went on Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/#findComment-1491713 Share on other sites More sharing options...
Monti18 Posted September 6, 2021 Share Posted September 6, 2021 In the modmain Haha you're welcome! 1 Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/#findComment-1491714 Share on other sites More sharing options...
sirrNaDE Posted September 6, 2021 Author Share Posted September 6, 2021 well theres a problem [string "../mods/Wawerly the lost and confused/modma..."]:73: attempt to index global 'TheNet' (a nil value) LUA ERROR stack traceback: ../mods/Wawerly the lost and confused/modmain.lua(73,1) in function 'fn' scripts/modutil.lua(505,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(169,1) in function 'prefabpostinitany' scripts/mainfunctions.lua(322,1) line 73 is the: if TheNet:GetIsClient() or not TheNet:GetServerIsDedicated() then in other mods, people use GLOBAL.TheNet..., shouldnt it be there aswell? Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/#findComment-1491716 Share on other sites More sharing options...
Monti18 Posted September 6, 2021 Share Posted September 6, 2021 If you have errors like these, it's mostly the GLOBAL that is missing, as a lot of function are not in the environement of the modmain, so you just need a GLOBAL before. Add this before the code snippet: local TheNet = GLOBAL.TheNet local TheWorld = GLOBAL.TheWorld 2 Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/#findComment-1491717 Share on other sites More sharing options...
sirrNaDE Posted September 6, 2021 Author Share Posted September 6, 2021 ooh it works. damn, map suffering is no more. again, i cant thank you enough, this was more painful than it should have been, and i did for sure learn something from this 1 Link to comment https://forums.kleientertainment.com/forums/topic/133307-deleting-map-progress-for-my-character/#findComment-1491720 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