. . . Posted June 17, 2016 Share Posted June 17, 2016 Hello, can someone maybe help me ? So, this code I put in dirtpile.lua I want to make my character be able to find treasure in dirtpiles but not other characters so I tried this SpawnPrefab("small_puff").Transform:SetPosition(pt:Get()) if math.random() > 0.39 and inst:HasTag("mosslingwhisperer") then SpawnPrefab("small_puff").Transform:SetPosition(pt:Get()) elseif math.random() > 0.25 and inst:HasTag("mosslingwhisperer") then SpawnPrefab("mole").Transform:SetPosition(pt:Get()) elseif math.random() > 0.15 and inst:HasTag("mosslingwhisperer") then SpawnPrefab("goldnugget").Transform:SetPosition(pt:Get()) elseif math.random() > 0.1 and inst:HasTag("mosslingwhisperer") then SpawnPrefab("redgem").Transform:SetPosition(pt:Get()) elseif math.random() > 0.1 and inst:HasTag("mosslingwhisperer") then SpawnPrefab("bluegem").Transform:SetPosition(pt:Get()) elseif math.random() > 0.01 and inst:HasTag("mosslingwhisperer") then SpawnPrefab("thulecite").Transform:SetPosition(pt:Get()) end but it doesn't work... I know it doesn't work because i'm probably telling the code that if the dirtpile has that tag to activate the code but I have no idea how to tell the code to activate that when a character with that tag triggers the dirtpile, can someone kinda help me ? Thanks for reading !!! Link to comment Share on other sites More sharing options...
Muche Posted June 17, 2016 Share Posted June 17, 2016 I'm guessing you've put this into OnInvestigated function. That receives two parameters - inst and doer. So one can either follow up where those parameters come from - dirtpile assigns OnInvestigated function to inst.components.activatable.OnActivate, activatable component calls that field in DoActivate function, actions.lua|ACTIONS.ACTIVATE.fn calls act.target.components.activatable:DoActivate(act.doer). Thus it could be expected that the inst parameter refers to the dirtpile entity and the doer parameter to the player entity who initiated the investigate action. Or, one could put a debug print inside the OnInvesigated function to find out what the paraterers are: print(string.format("[dirtpile|OnInvestigated] inst=%s, doer=%s, pt=%s", tostring(inst), tostring(doer), tostring(pt))) Link to comment Share on other sites More sharing options...
. . . Posted June 17, 2016 Author Share Posted June 17, 2016 Thank you Muche !! I switched inst to doer & it works fine now, thank you so much !!!! 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