Jump to content

Mod Chara Help: Forget Map Progress Every Other Day


Recommended Posts

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 by silvesary
Link to comment
Share on other sites

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.

  • Like 2
Link to comment
Share on other sites

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?ndfgsljhweotjgsjl.thumb.PNG.a987767133f2c3816af0864e6fc23f12.PNG

Link to comment
Share on other sites

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 by IThatGuyI
  • Like 2
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
 Share

×
  • Create New...