milson Posted June 6, 2013 Share Posted June 6, 2013 I only want to override the onpickedfn in grass.lua to add another cutgrass to the player's inventory.Obviously i want the code in the mainmod file. It doens't work this way:function grassPostInit(inst) inst.onpickedfn = function(self) self.SoundEmitter:PlaySound("dontstarve/wilson/pickup_reeds") self.AnimState:PlayAnimation("picking") if self.components.pickable:IsBarren() then self.AnimState:PushAnimation("idle_dead") else self.AnimState:PushAnimation("picked") end local pla = GLOBAL.GetPlayer() local cutg = GLOBAL.SpawnPrefab("cutgrass") pla.components.inventory:GiveItem(cutg, nil, Vector3(TheSim:GetScreenPos(self.Transform:GetWorldPosition()))) endendAddPrefabPostInit("grass", grassPostInit)Does somebody have an idea? ^^ Link to comment https://forums.kleientertainment.com/forums/topic/20154-question-so-what-am-i-doin-wrong/ Share on other sites More sharing options...
Heavenfall Posted June 6, 2013 Share Posted June 6, 2013 doinst.components.pickable.onpickedfn = function(self) Link to comment https://forums.kleientertainment.com/forums/topic/20154-question-so-what-am-i-doin-wrong/#findComment-194920 Share on other sites More sharing options...
Heavenfall Posted June 6, 2013 Share Posted June 6, 2013 Also GLOBAL. before Vector3() Link to comment https://forums.kleientertainment.com/forums/topic/20154-question-so-what-am-i-doin-wrong/#findComment-194922 Share on other sites More sharing options...
milson Posted June 6, 2013 Author Share Posted June 6, 2013 Oh... thanks. Totaly missed that. Link to comment https://forums.kleientertainment.com/forums/topic/20154-question-so-what-am-i-doin-wrong/#findComment-194942 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