Julian97 Posted July 5, 2015 Share Posted July 5, 2015 I wanted my custom Character to act differently in different Seasons. But if i want to acces seasonmanager the Game just crashes and says that seasonmanager is a nil Value. I do not know what Value nil has. I only learned C++ so far. Here is my Function:local call_this_on_update = function(inst) if not inst.components.seasonmanager.seasonmode == "caves" then if inst.components.seasonmanager:IsSummer() then Act like it's Summer. end if inst.components.seasonmanager:IsWinter() then Act like it's Winter. end else inst.components.health:StopRegen() endendThe Function is run from this Line of Code that i put in the fn Function of Scripts/Prefabs/Character.lua :inst:DoTaskInTime(10,function()call_this_on_update(inst)end) Link to comment https://forums.kleientertainment.com/forums/topic/55885-seasonmanager-a-nil-value/ Share on other sites More sharing options...
Blueberrys Posted July 6, 2015 Share Posted July 6, 2015 (edited) @Julian97 nil in lua is essentially equivalent of null in c++ You're calling "call_this_on_update" and passing in the "inst" variable which refers to the player's instance. The seasonsmanager component is attached to the world, not the player.You can use GetWorld() to get the world's instance.local call_this_on_update = function(inst) -- This inst refers to the player -- because of how you called it local world_inst = GetWorld() if not world_inst.components.seasonmanager.seasonmode == "caves" then if world_inst.components.seasonmanager:IsSummer() then -- Act like it's Summer. end if world_inst.components.seasonmanager:IsWinter() then -- Act like it's Winter. end else inst.components.health:StopRegen() endend Edited July 6, 2015 by Blueberrys Link to comment https://forums.kleientertainment.com/forums/topic/55885-seasonmanager-a-nil-value/#findComment-652164 Share on other sites More sharing options...
Julian97 Posted July 8, 2015 Author Share Posted July 8, 2015 I've already fixed it with the same Solution but Thanks anyway... Still though . With older Problems being fixed newer do arrive .I've tried to use some already implemented Sounds from the ROG Expansion with player.SoundEmitter:PlaySound("dontstarve/+SoundName") but this only works with Sounds from the Standart Game . While i'm at it . Is there also a Variable/Function which tells you if ROG is installed ? Link to comment https://forums.kleientertainment.com/forums/topic/55885-seasonmanager-a-nil-value/#findComment-652660 Share on other sites More sharing options...
Blueberrys Posted July 8, 2015 Share Posted July 8, 2015 @Julian97 As with all assets, I think you need to use the correct path. Check out how the RoG files access the sounds you're trying to use. Yes.-- Returns boolean valueTheSim:IsDLCInstalled(GLOBAL.REIGN_OF_GIANTS)TheSim:IsDLCInstalled(1) -- If the first doesn't workSee dlcsupport.lua Link to comment https://forums.kleientertainment.com/forums/topic/55885-seasonmanager-a-nil-value/#findComment-652664 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