NotSoSavvy Posted January 10, 2014 Share Posted January 10, 2014 Morning all. I'll preface this with the always-worrying "I'm new to this but I'm learning" statement so you know what you're getting into. Now, my problem is that I'm trying to write a lua collision script that only recognises a specific non-player object. I've got a part in the middle that we will call Lathe, and a hitbox around it. If I place a specific other part within that hitbox, let's call it Drill, I want the collision script to activate. I don't want it to activate for any other collision. So...possible? I haven't had a vast amount of luck trying to modify the standard collision script, and can't find any obvious documentation on it. Quote Link to comment Share on other sites More sharing options...
nate066 Posted January 10, 2014 Share Posted January 10, 2014 I did a jump-pad tutorial and it shows how to do that. http://www.leadwerks.com/werkspace/page/tutorials/_/jump-pad-tutorial-r54 or you can just download my script SelectiveCollisionTrigger.lua Quote Link to comment Share on other sites More sharing options...
NotSoSavvy Posted January 10, 2014 Author Share Posted January 10, 2014 Thank you, that solved it! One problem down, several thousand unknown ones to go. Marvelous. Edit: Well, it solved it as long as the selected entity is me. No luck with a selected box falling into it. Does the collision box default to only reacting to certain types of entity? Quote Link to comment Share on other sites More sharing options...
Marcus Posted January 10, 2014 Share Posted January 10, 2014 What I do is define variables in each of my classes. I just call it something like: Script.entityType = "Player" Then on the other entity that I want to get a collision with, I just check what object type I'm colliding with: if entity.script.entityType == "Player" then -- Do something end Quote Link to comment Share on other sites More sharing options...
Rick Posted January 10, 2014 Share Posted January 10, 2014 @Marcus If something that doesn't have that variable hits the script I think the script would give an error. Doing a check that the variable exists should help avoid that. if entity.script.entityType ~= nil then if entity.script.entityType == "Player" then end end Quote Link to comment Share on other sites More sharing options...
Marcus Posted January 10, 2014 Share Posted January 10, 2014 @Marcus If something that doesn't have that variable hits the script I think the script would give an error. Doing a check that the variable exists should help avoid that. if entity.script.entityType ~= nil then if entity.script.entityType == "Player" then end end Good catch. 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.