how can I do this?

Blitz3D Forums/Blitz3D Programming/how can I do this?

If I have a data structure...

type TYPE_ob
  field mesh
  field x#,y#
end type


...and mesh is pickable, I can use camerapick to return the entity...

ENT = camerapick(cam,mousex,mousey)


...is there any way to go from the returned entity ENT to the associated data structure?

for example, to allow me then to set ENT\x# or whatever?


function which_type_ob_did_i_pick.type_ob (ENT)

  picked.type_ob=null

    for this.type_ob = each type_ob

      if this\mesh=ent then picked=this
    
    next

  return picked

end function



type TYPE_ob
  field mesh
  field x#,y#
end type

t.TYPE_ob = new TYPE_ob
t\mesh = createcube()

;-----

nameentity t\mesh,handle(t)

ENT = camerapick(cam,mousex,mousey)
t.TYPE_ob = object.TYPE_ob(entityname(ENT))


Ta Daaa

Ooh good one. I hadn't come across nameentity before.

store the pointer in the datastruct. faster than entityname

Cheers - I just discovered almost the same method that Binary_Moon posted, but yours is a bit slicker.

Thanks guys.
James