Jump to content

Recommended Posts

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?  

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
×
  • Create New...