Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted

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.

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

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.

Posted

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 biggrin.gif)


--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?

Posted

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

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

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.

Posted

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.

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...