Skrakle Posted March 4, 2015 Posted March 4, 2015 I'm loading my entities in lua in App:Start() and i need to set script files for them, is there a way to assign them in lua? I've tried something like entity.Script="Scripts/Objects/Triggers/CollisionTrigger.lua" but no luck. Quote
Rick Posted March 4, 2015 Posted March 4, 2015 That's a good question. I normally just make prefabs and load the prefabs then. Quote
Genebris Posted March 4, 2015 Posted March 4, 2015 I don't think that's possbile, but if you want you can create a pivot point with a script, save as prefab and parent it to entities you want to add script to. Obviously you will need to use self.entity:GetParent() in this script instead of self.entity. Quote
Skrakle Posted March 4, 2015 Author Posted March 4, 2015 I've created a pivot, attached script CollisionTriggers.lua and i loaded it. Now i'm trying to attach it to the entity. I've tried this: App.lua entity[0]={}; entity[0]=LoadEntity("Models/Characters/Dwarf/dwarfmale_run.mdl",10,0,-20,0.05,1,Collision.Character,Entity.CharacterPhysics); local parent=entity[0]:GetParent(); if (parent~=nil) then Prefab:Load("Prefabs/collisions_generic.pfb") end CollisionTriggers.lua function Script:Start() self.enabled=true end function Script:Collision(entity, position, normal, speed) if self.enabled then self.component:CallOutputs("Collision") end end function Script:Enable()--in if self.enabled==false then self.enabled=true self:CallOutputs("Enable") end end function Script:Disable()--in if self.enabled then self.enabled=false self:CallOutputs("Disable") end end parent returns nil... How do i attach it to the entity? Quote
AggrorJorn Posted March 4, 2015 Posted March 4, 2015 You can use self.entity:SetScript("Scripts/myScript.lua") 4 Quote
Rick Posted March 4, 2015 Posted March 4, 2015 Well that solves that lol [edit] Is that documented? Quote
AggrorJorn Posted March 4, 2015 Posted March 4, 2015 Well that solves that lol [edit] Is that documented? I remember using it for a written tutorial Josh asked me to make: http://www.leadwerks.com/werkspace/page/tutorials/_/script/introduction-to-lua-scripting-r103 But I can't seem to find it in the command reference. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.