Nycidian Posted October 21, 2013 Share Posted October 21, 2013 (edited) 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? Edited October 21, 2013 by Nycidian Link to comment https://forums.kleientertainment.com/forums/topic/28914-some-event-qestions/ Share on other sites More sharing options...
Malacath Posted October 21, 2013 Share Posted October 21, 2013 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 https://forums.kleientertainment.com/forums/topic/28914-some-event-qestions/#findComment-348708 Share on other sites More sharing options...
Nycidian Posted October 21, 2013 Author Share Posted October 21, 2013 (edited) 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. Edited October 21, 2013 by Nycidian Link to comment https://forums.kleientertainment.com/forums/topic/28914-some-event-qestions/#findComment-348739 Share on other sites More sharing options...
Malacath Posted October 21, 2013 Share Posted October 21, 2013 (edited) Look at the mod Winnifred (not on steam), there you can find good examples for working with eqipping and unequipping. I can be more precise when I'm home again.EDIT: I'm home now. Do you need me to be more precise? Edited October 21, 2013 by Malacath Link to comment https://forums.kleientertainment.com/forums/topic/28914-some-event-qestions/#findComment-348740 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