TheHockeyGods Posted September 13, 2013 Share Posted September 13, 2013 So I am trying to make it so that hallucinations corrupt flowers around them, making them evil flowers. The (not working) code I currently have is:local function AuraCorruptFlowers(inst, range) local hitcount = 0 local pt = Vector3(inst.Transform:GetWorldPosition() ) local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, range) for i,ent in ipairs(ents) do if (ent:HasTag("flower") and not ent:HasTag("corruptflower")) then BecomeCorruptFlower(ent) end end return hitcountend--[[other stuff]]--AddPrefabPostInit("nightmarecreature", AuraCorruptFlowers) I don't understand where to go from here... Link to comment https://forums.kleientertainment.com/forums/topic/27715-help-making-nightmares-corrupt-flowers/ Share on other sites More sharing options...
simplex Posted September 13, 2013 Share Posted September 13, 2013 Didn't someone write a mod doing something similar? Link to comment https://forums.kleientertainment.com/forums/topic/27715-help-making-nightmares-corrupt-flowers/#findComment-320800 Share on other sites More sharing options...
TheHockeyGods Posted September 13, 2013 Author Share Posted September 13, 2013 (edited) Didn't someone write a mod doing something similar? This is for a custom character, and to be quite honest Simplex... I looked at and didn't quite understand how pieces fit together in Blackhouse. Edited September 13, 2013 by TheHockeyGods Link to comment https://forums.kleientertainment.com/forums/topic/27715-help-making-nightmares-corrupt-flowers/#findComment-320802 Share on other sites More sharing options...
simplex Posted September 13, 2013 Share Posted September 13, 2013 (edited) I wrote a pair of components, "corruptible" and "corruptionaura". They'd do exactly what you're looking for, but aaaanyway. Surrounding the body of AuraCorruptFlowers with an inst:DoPeriodicTask() should work. Edited September 13, 2013 by simplex Link to comment https://forums.kleientertainment.com/forums/topic/27715-help-making-nightmares-corrupt-flowers/#findComment-320807 Share on other sites More sharing options...
TheHockeyGods Posted September 14, 2013 Author Share Posted September 14, 2013 Let me be more clear, I understand how the files worked together... it was the separate functions inside those components that didn't fit together for me. I have:local function AuraCorruptFlowers(inst, range) local hitcount = 0 local pt = Vector3(inst.Transform:GetWorldPosition() ) local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, range) inst:DoPeriodicTask() for i,ent in ipairs(ents) do if (ent:HasTag("flower") and not ent:HasTag("corruptflower")) then BecomeCorruptFlower(ent) end end return hitcountend--[[x]]--AddPrefabPostInit("nightmarecreature", AuraCorruptFlowers)Still not working. Thanks for taking a look. Link to comment https://forums.kleientertainment.com/forums/topic/27715-help-making-nightmares-corrupt-flowers/#findComment-320866 Share on other sites More sharing options...
simplex Posted September 14, 2013 Share Posted September 14, 2013 (edited) local function AuraCorruptFlowers(inst, range) local hitcount = 0 local pt = Vector3(inst.Transform:GetWorldPosition() ) local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, range) inst:DoPeriodicTask() for i,ent in ipairs(ents) do if (ent:HasTag("flower") and not ent:HasTag("corruptflower")) then BecomeCorruptFlower(ent) end end return hitcountend--[[x]]--AddPrefabPostInit("nightmarecreature", AuraCorruptFlowers)Still not working. Thanks for taking a look.The DoPeriodicTask should be surrounding the whole function, not just that part. And you're not really passing anything to it! local function AuraCorruptFlowers(inst, range) inst:DoPeriodicTask(1, function(inst) local pt = Vector3(inst.Transform:GetWorldPosition() ) local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, range) for i,ent in ipairs(ents) do if (ent:HasTag("flower") and not ent:HasTag("corruptflower")) then BecomeCorruptFlower(ent) end end end)end Edited September 14, 2013 by simplex Link to comment https://forums.kleientertainment.com/forums/topic/27715-help-making-nightmares-corrupt-flowers/#findComment-320868 Share on other sites More sharing options...
TheHockeyGods Posted September 14, 2013 Author Share Posted September 14, 2013 The DoPeriodicTask should be surrounding the whole function, not just that part. And you're not really passing anything to it! local function AuraCorruptFlowers(inst, range) inst:DoPeriodicTask(1, function(inst) local pt = Vector3(inst.Transform:GetWorldPosition() ) local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, range) for i,ent in ipairs(ents) do if (ent:HasTag("flower") and not ent:HasTag("corruptflower")) then BecomeCorruptFlower(ent) end end end)end /facepalm on my side... Its still not working, but I now believe its because of my BecomeCorruptFlower function which I previously thought was okay...local function BecomeCorruptFlower(ent) if not ent:HasTag("corruptflower") then SpawnPrefab( "flower_evil" ) endend Link to comment https://forums.kleientertainment.com/forums/topic/27715-help-making-nightmares-corrupt-flowers/#findComment-320975 Share on other sites More sharing options...
simplex Posted September 14, 2013 Share Posted September 14, 2013 (edited) @TheHockeyGods local function BecomeCorruptFlower(inst) if not inst:HasTag("corruptflower") and inst.prefab ~= "flower_evil" then local evil = SpawnPrefab("flower_evil") evil:AddTag("corruptflower") evil.Transform:SetPosition( inst:GetPosition():Get() ) inst:Remove() endendBut I'm not quite sure what you're aiming with the "corruptflower" tag. Is it supposed to mark just the "new" evil flowers? Edited September 14, 2013 by simplex Link to comment https://forums.kleientertainment.com/forums/topic/27715-help-making-nightmares-corrupt-flowers/#findComment-321112 Share on other sites More sharing options...
simplex Posted September 14, 2013 Share Posted September 14, 2013 @TheHockeyGods Oh yes, you need to change you AddPrefabPostInit call as well. nightmarecreature is the name of the file that defines them, but the actual prefab names are "crawlingnightmare" and "nightmarebeak". Link to comment https://forums.kleientertainment.com/forums/topic/27715-help-making-nightmares-corrupt-flowers/#findComment-321177 Share on other sites More sharing options...
Torigoma Posted September 14, 2013 Share Posted September 14, 2013 Didn't someone write a mod doing something similar?http://forums.kleientertainment.com/index.php?/files/file/153-blackhouse-watch-your-dreams-grow-open-source/ Link to comment https://forums.kleientertainment.com/forums/topic/27715-help-making-nightmares-corrupt-flowers/#findComment-321305 Share on other sites More sharing options...
TheHockeyGods Posted September 23, 2013 Author Share Posted September 23, 2013 @TheHockeyGods local function BecomeCorruptFlower(inst) if not inst:HasTag("corruptflower") and inst.prefab ~= "flower_evil" then local evil = SpawnPrefab("flower_evil") evil:AddTag("corruptflower") evil.Transform:SetPosition( inst:GetPosition():Get() ) inst:Remove() endend But I'm not quite sure what you're aiming with the "corruptflower" tag. Is it supposed to mark just the "new" evil flowers? My goal here is that I want nightmares to have an aura that turns regular flowers into evil flowers and adds the tag "corruptflower" so that I can add effects to only evil flowers with the tag. I don't want all evil flowers to have these effects, only ones turned evil this way. @TheHockeyGodsOh yes, you need to change you AddPrefabPostInit call as well. nightmarecreature is the name of the file that defines them, but the actual prefab names are "crawlingnightmare" and "nightmarebeak".Sorry for the delay @ simplexThanks for the information on the hallucinations. Currently this is the code that I have regarding making nightmares corrupt flowers. All in modmain.lualocal evilAuraMaxRange = 20local function CorruptFlowers(prefab) prefab:AddTag("corruptflower")end-- Nightmares corrupt flowerslocal function updateAura(inst, dt) auraRange = evilAuraMaxRange inst.updateTask = inst:DoPeriodicTask(1, updateAura, nil, 1)endlocal function BecomeCorruptFlower(inst) if not inst:HasTag("corruptflower") and inst.prefab ~= "flower" then local evil = SpawnPrefab("flower_evil") evil:AddTag("corruptflower") evil.Transform:SetPosition( inst:GetPosition():Get() ) inst:Remove() endendlocal function AuraCorruptFlowers(inst, range) inst:DoPeriodicTask(1, function(inst) local pt = Vector3(inst.Transform:GetWorldPosition() ) local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, range) for i,ent in ipairs(ents) do if (ent:HasTag("flower") and not ent:HasTag("corruptflower")) then BecomeCorruptFlower(ent) end end end)endAddPrefabPostInit("evil_flower", CorruptFlowers)AddPrefabPostInit("crawlingnightmare", "nightmarebeak", AuraCorruptFlowers) Can't seem to get the nightmares to transform the flowers yet. Link to comment https://forums.kleientertainment.com/forums/topic/27715-help-making-nightmares-corrupt-flowers/#findComment-328403 Share on other sites More sharing options...
simplex Posted September 23, 2013 Share Posted September 23, 2013 @TheHockeyGods The range parameter of AuraCorruptFlowers is not being set. You should make it a local variable and give it a fixed value. A prefab postinit only receives the entity as its argument. Link to comment https://forums.kleientertainment.com/forums/topic/27715-help-making-nightmares-corrupt-flowers/#findComment-328464 Share on other sites More sharing options...
TheHockeyGods Posted September 25, 2013 Author Share Posted September 25, 2013 I changed AuraCorruptFlowers tolocal function AuraCorruptFlowers(inst, range) inst:DoPeriodicTask(1, function(inst) local pt = Vector3(inst.Transform:GetWorldPosition() ) local evilAuraMaxRange = 20 auraRange = evilAuraMaxRange local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, range) for i,ent in ipairs(ents) do if (ent:HasTag("flower") and not ent:HasTag("corruptflower")) then BecomeCorruptFlower(ent) end end end)endI wrote the range for AuraCorruptFlowers the same way I wrote it in updateAura, but to no avail. Link to comment https://forums.kleientertainment.com/forums/topic/27715-help-making-nightmares-corrupt-flowers/#findComment-329724 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