Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted

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?

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...