I works now via a message system, but it's not really the way I want it. I would have prefered the Lua menu. This is what you do:
1.
make a new lua file called 'Icons' with the following:
require("scripts/class")
require("scripts/hooks")
icon= LoadTexture("abstract::hand.dds")
function HookIcon()
SetBlend(1)
DrawImage(icon,GraphicsWidth()/2-25,GraphicsHeight()/2-25,50,50)
SetBlend(0)
end
2.
In your main code, include the previously made lua script.
require("Scripts/icons")
3.
The main loop is going to send a message to the object that is picked. in your main loop place this:
--Check for icons!
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
if pick.entity~=nil then
pick.entity:SendMessage("icon",controller,0)
end
else
RemoveHook("Flip",HookIcon)
end
4.
in the class script of your object (like the switch) add the following:
require("scripts/class")
local class=CreateClass(...)
function class:CreateObject(model)
local object=self.super:CreateObject(model)
function object:ReceiveMessage(message,extra)
if message=="icon" then
AddHook("Flip",HookIcon)
end
end
end
add the code from step 4 to every object where you want an icon to appear. Once again: this is not the best way to do it, but maybe for now it will do the job.