ljp Posted June 29, 2020 Share Posted June 29, 2020 I'm making a mod that automatically equip a light source when night comes. I add an event handler by: player:ListenForEvent("nighttime", fn) Following the example in beard.lua:inst:ListenForEvent( "daycomplete", function(inst, data)...) , so I create a new component, use inst:AddComponent("test") in modmain, and use ListenForEvent in my test class funtion body. But it doesn't work. Then I found a previous post in forum with maybe similar problem and tried AddPlayerPostInit(function(inst, data) inst:AddComponent("test") inst:ListenForEvent("nighttime", inst.component.test.fn) end) in modmain.lua. But it still has no effect. I change the content of fn to a print and find no record in log.txt. Could someone tell me how should I use it? Link to comment https://forums.kleientertainment.com/forums/topic/119611-listenforevent-in-mod-has-no-effect-where-should-i-put-it/ 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