Jump to content

Some Event Qestions


Nycidian

Recommended Posts

So I have 3 events I would like to see in my mod the problem is that they don't seem to trigger like other events For example oneatsomething using the same method works but these 3 don't trigger at all.

 

self.tick.gruesomeEquip = self.inst:ListenForEvent("equipped", function(inst, data) self:OnEquipped(data) end)self.tick.gruesomeUnequip = self.inst:ListenForEvent("unequipped", function(inst, data) self:OnUnequipped(data) end)--self.tick.gruesomeGrowFromButterfly = self.inst:ListenForEvent("growfrombutterfly", function(inst, data) self:OnGrowFromButterfly(data) end)
This is being called from a component file BTW.
 
 
Hopefully someone can help me out.
 
Edit:
 
In addition how does one access GLOBAL when not in modmain.lua?
Link to comment
Share on other sites

 

So I have 3 events I would like to see in my mod the problem is that they don't seem to trigger like other events For example oneatsomething using the same method works but these 3 don't trigger at all.

 

self.tick.gruesomeEquip = self.inst:ListenForEvent("equipped", function(inst, data) self:OnEquipped(data) end)self.tick.gruesomeUnequip = self.inst:ListenForEvent("unequipped", function(inst, data) self:OnUnequipped(data) end)--self.tick.gruesomeGrowFromButterfly = self.inst:ListenForEvent("growfrombutterfly", function(inst, data) self:OnGrowFromButterfly(data) end)
This is being called from a component file BTW.
 
 
Hopefully someone can help me out.

 

The problem is that the events are pushed by a certain entity. In the case of "growfrombutterfly" for example the entity pushing the event is the flower that's grown. Thus listening to this event from your entity (self.inst), which is  most likely not the flower, won't do anything.

For this specific event you cannot listen from a different entity as far as I know. For other, like "dusktime" you can specifiy the source you want to listen as a third argument, but that only works properly for entities that are persistent. And we all agree that flowers are not persistent  ; )

inst:ListenForEvent("dusktime", OnListen, GetWorld())

So you might want to find a workaround, like integrating that code in the flower itself somehow.

Link to comment
Share on other sites

The problem is that the events are pushed by a certain entity. In the case of "growfrombutterfly" for example the entity pushing the event is the flower that's grown. Thus listening to this event from your entity (self.inst), which is  most likely not the flower, won't do anything.

For this specific event you cannot listen from a different entity as far as I know. For other, like "dusktime" you can specifiy the source you want to listen as a third argument, but that only works properly for entities that are persistent. And we all agree that flowers are not persistent  ; )

inst:ListenForEvent("dusktime", OnListen, GetWorld())

So you might want to find a workaround, like integrating that code in the flower itself somehow.

Alright then how would I add a function to the garland one of the things I find very difficult in modding DS is attaching functions I just can't seem to wrap my head around how and why it works.

 

Say I wanted to install an event listener for "equipped" that would change a variable on a new component that is installed in a custom player prefab.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...