AggrorJorn Posted December 6, 2009 Share Posted December 6, 2009 hi. I want to know how to make objects (onjects you can pick up), member of a class. for example: an oil lamp becomes member of the class "PickingUpItem". this way I can send Raytraces to this class only. Only way no to do this is with ENTITY_MODEL. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 7, 2009 Author Share Posted December 7, 2009 Perhaps I have to use a different explanation. The raytraces that are used with the switch in the tunnel level, check on the ENTITY_MODEL. when it is a moddel a message can be sent. I wonder if I can make those raytraces check on my own kind of class instead of every moddel. Quote Link to comment Share on other sites More sharing options...
Josh Posted December 7, 2009 Share Posted December 7, 2009 Why would you want to only check for objects that can be picked up? If there is a wall between you and the object, the raycast won't see it. Use collision types for this. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 7, 2009 Author Share Posted December 7, 2009 I want to display a hand icon on the mouse position when a player can interact with an object. As it is now, the raytrace returns a true when it hits a moddel, thus it prety much always shows a hand icon on screen (walls are also moddels and will activate the hand icon). The hand icon only needs to appear when a raytrace sees a certain moddel of a certain class. Quote Link to comment Share on other sites More sharing options...
Rick Posted December 7, 2009 Share Posted December 7, 2009 You could give a setting for models that you want to be picked. pickable = true for example. Then check this setting. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 7, 2009 Author Share Posted December 7, 2009 You could give a setting for models that you want to be picked. pickable = true for example. Then check this setting. hmm, didn't think of that, nice one. For the first time I used a LUA menu style for this (getting a menu option makes it look really professional ) --hand icon menu group=grid:AddGroup( "Hand icon" ) group:AddProperty( "Show hand icon", PROPERTY_BOOL ) this code was added to the switch.lua. If I want to retrieve the state of the bool value from the FPS Controller script, do I have to use the GetKey and Setkey commans for this? Quote Link to comment Share on other sites More sharing options...
Josh Posted December 7, 2009 Share Posted December 7, 2009 You could use model:GetKey() or you could set an internal value when the Lua script calls SetKey(). function SetKey(model,key,value) if key=="pickable" then entity.pickable=tonumber(value) else end end Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 8, 2009 Author Share Posted December 8, 2009 I'm not 100% sure how to use the SetKey and GetKey functions. I have the following in the switch.lua: --hand icon menu group=grid:AddGroup( "Hand icon" ) group:AddProperty( 'Show hand icon', PROPERTY_BOOL,'showicon') function SetKey(model,key,value) if key=="showicon" then entity.pickable=tonumber(value) end return 1 end Is 'showicon' in AddProperty the Key here? In the FPScontroller I use a raytrace: pick=CameraPick(camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,2.0),0,0) if pick~=nil then repeat if pick.entity:GetClass()==ENTITY_MODEL then break end pick.entity=pick.entity.parent until pick.entity==nil -- show hand true or false if pick.entity~=nil then ????GetKey("showicon","true") handIcon = true end else handIcon = false end At the question marks I need to retrieve if the value is true or false from 'showicon' in the switch.lua. As I understand this is done by the GetKey. Quote Link to comment Share on other sites More sharing options...
Rick Posted December 8, 2009 Share Posted December 8, 2009 I'm not 100% sure how to use the SetKey and GetKey functions. I have the following in the switch.lua: --hand icon menu group=grid:AddGroup( "Hand icon" ) group:AddProperty( 'Show hand icon', PROPERTY_BOOL,'showicon') function SetKey(model,key,value) if key=="showicon" then entity.pickable=tonumber(value) end return 1 end Is 'showicon' in AddProperty the Key here? In the FPScontroller I use a raytrace: pick=CameraPick(camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,2.0),0,0) if pick~=nil then repeat if pick.entity:GetClass()==ENTITY_MODEL then break end pick.entity=pick.entity.parent until pick.entity==nil -- show hand true or false if pick.entity~=nil then ????GetKey("showicon","true") handIcon = true end else handIcon = false end At the question marks I need to retrieve if the value is true or false from 'showicon' in the switch.lua. As I understand this is done by the GetKey. In your set key I think you need to get the entity from the model passed into the function. I think there is some base_Entity() or whatever where you can pass in a model and get the entity (which would really be a lua table object and not an LE TEntity). You would probably need to do the same thing in your picking code as well because I think pick.entity is TEntity and not the lua table object, but I could be wrong there. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 8, 2009 Author Share Posted December 8, 2009 I think this is all a litlle bit above me. I think I''ll wait for some tutorials about this. Thanks for your help, I apprecate it. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 9, 2009 Author Share Posted December 9, 2009 I'll make a new topic for this, as the question is now different. 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.