extenz Posted October 28, 2016 Share Posted October 28, 2016 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 ;-; Quote Link to comment Share on other sites More sharing options...
Roland Posted October 28, 2016 Share Posted October 28, 2016 Script.box = "" --entity Script.material = nil function Script:Start() self.material = Material:Create() self.material:SetColor(1,0,0) end function Script:Collision(entity, position, normal, speed) self.box:SetMaterial(self.material) end Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
extenz Posted October 28, 2016 Author Share Posted October 28, 2016 Nope, that doesn't work either. http://i.imgur.com/NEp7vFe.png I think there's something wrong with my Leadwerks Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted October 28, 2016 Share Posted October 28, 2016 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. Quote Link to comment Share on other sites More sharing options...
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.