Sign in to follow this  
goldfish911

What/where is the code for an event of something being crafted or prototyped?

Recommended Posts

goldfish911    61

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	endend

So 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?

 

 

Share this post


Link to post
Share on other sites
Kzisor    1060

@goldfish911, scripts/components/builder

self.inst:PushEvent("buildstructure", { item = prod, recipe = recipe }) self.inst:PushEvent("builditem", { item = prod, recipe = recipe }) 

Share this post


Link to post
Share on other sites
goldfish911    61

 

@goldfish911, scripts/components/builder

self.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?

Share this post


Link to post
Share on other sites

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
Sign in to follow this