goldfish911 Posted June 20, 2015 Share Posted June 20, 2015 I asked a similar question way back, but I can't find the topic from my profile. So here's my situation.I'm working on fiddling around with a variation of the component kramped.lua. I want to change its purpose from causing events when things are KILLED to causing events when things are CRAFTED or PROTOTYPED. So I noticed this code: self.inst:ListenForEvent( "killed", function(inst,data) self:onkilledother(data.victim) end )and this code:function Danger:onkilledother(victim) --assigns value based on victim, learn to assign value based on item crafted if victim.prefab == "pigman" then if not victim.components.werebeast or not victim.components.werebeast:IsInWereState() then self:OnNaughtyAction(3) end elseif victim.prefab == "babybeefalo" then self:OnNaughtyAction(6) elseif victim.prefab == "teenbird" then self:OnNaughtyAction(2) elseif victim.prefab == "smallbird" then self:OnNaughtyAction(6) elseif victim.prefab == "beefalo" then self:OnNaughtyAction(4) elseif victim.prefab == "crow" then self:OnNaughtyAction(1) elseif victim.prefab == "robin" then self:OnNaughtyAction(2) elseif victim.prefab == "robin_winter" then self:OnNaughtyAction(2) elseif victim.prefab == "butterfly" then self:OnNaughtyAction(1) elseif victim.prefab == "rabbit" then self:OnNaughtyAction(1) elseif victim.prefab == "tallbird" then self:OnNaughtyAction(2) elseif victim.prefab == "bunnyman" then self:OnNaughtyAction(3) elseif victim.prefab == "penguin" then self:OnNaughtyAction(2) end endendSo I've managed to figure out how to set up the functions for various things being crafted or prototyped, but I don't know what event to "listen" for and what data that event contains(item crafted?).Any tips? Link to comment Share on other sites More sharing options...
Kzisor Posted June 20, 2015 Share Posted June 20, 2015 @goldfish911, scripts/components/builderself.inst:PushEvent("buildstructure", { item = prod, recipe = recipe }) self.inst:PushEvent("builditem", { item = prod, recipe = recipe }) Link to comment Share on other sites More sharing options...
goldfish911 Posted June 20, 2015 Author Share Posted June 20, 2015 @goldfish911, scripts/components/builderself.inst:PushEvent("buildstructure", { item = prod, recipe = recipe }) self.inst:PushEvent("builditem", { item = prod, recipe = recipe }) Thanks!So if I changed that first line in the OP to this:self.inst:ListenForEvent( "builditem", function(inst,data) self:onbuiltitem(data.itembuilt) end )it would take the item that was created and put it in the function "onbuiltitem" as an argument? Link to comment Share on other sites More sharing options...
Kzisor Posted June 20, 2015 Share Posted June 20, 2015 @goldfish911, data.item Link to comment Share on other sites More sharing options...
goldfish911 Posted June 20, 2015 Author Share Posted June 20, 2015 @goldfish911, data.item I can't rename it to data.itembuilt? Link to comment Share on other sites More sharing options...
Kzisor Posted June 20, 2015 Share Posted June 20, 2015 @goldfish911, no because that isn't what is being pushed, it's data.item. Link to comment Share on other sites More sharing options...
goldfish911 Posted June 20, 2015 Author Share Posted June 20, 2015 @goldfish911, no because that isn't what is being pushed, it's data.item. Thanks for clearing that up! Link to comment 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