Jump to content

Need help with a simple code


extenz
 Share

Recommended Posts

Okay so I'm probably just stupid and doing something wrong because I haven't used Leadwerks in a while now but I need help with this little code -

 

Script.box = "" --entity

function Script:Start()
  local material = Material:Create()
  material:SetColor(1,0,0)
end

function Script:Collision(entity, position, normal, speed)
  self.box:SetMaterial(material)
end

 

I put it on a trigger ( Collision type is set to trigger, "box" is set to a CSG ) and everytime I enter the trigger the game just stops responding.

I also tried Material:Load but that does not work either.

 

Please help ;-;

Link to comment
Share on other sites

As Rolands example states: You are declaring the material veriable in the start function. It no longer exists out of that function, so in the collision function, lua has no idea what that variable is.

 

Another caveat: does your csg box have mass or a script attached to it? Otherwise it is being 'collapsed' at startup (for performance sake), and will no be accesable in the script.

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...