Sign in to follow this  
Monty_Droppings

GetSeasonManager in DST alternative?, Summer/Winter hat

Recommended Posts

In my character mod in DS:ROG, I had a hat for my character that functioned as a dual insulator. I did it with this following code in the local function onequip(inst, owner):

inst.temperatureTask = inst:DoTaskInTime(5, function(inst)
        if GetSeasonManager():GetCurrentTemperature() > 35 then
            inst.components.insulator:SetSummer()
        else
            inst.components.insulator:SetWinter()
        end
    end)

 

In DST, there doesn't seem to be GetSeasonManager, so looking at the straw hat code for a summer insulator, I thought I'd try this:

inst.temperatureTask = inst:DoTaskInTime(5, function(inst)
        if TheWorld.state.temperature > 35 then
            inst.components.insulator:SetSummer()
			
        else
            inst.components.insulator:SetWinter()
			
        end
    end)

But no dice, any idea whats going wrong?

 

Full DST attempt: http://pastebin.com/1nwQsubE

 

ROG version of the dual insulating hat that worked: http://pastebin.com/ZVefxdjL

 

 

 

Edited by Monty_Droppings

Share this post


Link to post
Share on other sites
4 hours ago, Maris said:

First tell what's wrong ;)

Well I mean the my DST version of the code just isn't working. I can load and play the game fine with my character mod, it's just when I put the hat on to test insulation, it works in the winter but does nothing in the summer to stop overheating. 

Share this post


Link to post
Share on other sites
Maris    233

Test your code using prints. Example:

print("Declare the task...") 
inst.temperatureTask = inst:DoTaskInTime(5, function(inst)
	print("Check temperature:", TheWorld.state.temperature)
	if TheWorld.state.temperature > 35 then
		inst.components.insulator:SetSummer()
		print("Summer!")
	else
		inst.components.insulator:SetWinter()
		print("Winter")
	end
	print("Check insulator type:",
		(inst.components.insulator.type == SEASONS.WINTER) and "winter" or "summer"
	)
end)

 

Share this post


Link to post
Share on other sites
2 hours ago, Maris said:

Test your code using prints. Example:


print("Declare the task...") 
inst.temperatureTask = inst:DoTaskInTime(5, function(inst)
	print("Check temperature:", TheWorld.state.temperature)
	if TheWorld.state.temperature > 35 then
		inst.components.insulator:SetSummer()
		print("Summer!")
	else
		inst.components.insulator:SetWinter()
		print("Winter")
	end
	print("Check insulator type:",
		(inst.components.insulator.type == SEASONS.WINTER) and "winter" or "summer"
	)
end)

 

I'm not sure what that means even after googling(I even looked through the forum guide), like what is "printing?" . I don't actually know lua, I've just been looking at functions that do similar things to what I want and fiddle with it until sometimes they work.

 

 

Share this post


Link to post
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
Sign in to follow this