How would you create a Mouseover

Blitz3D Forums/Blitz3D Beginners Area/How would you create a Mouseover

Nexus6(Posted 2005) [#1]
I am currently putting the finishing touches to a hybrid A*/waypoint editor. I would like to be able to place the cursor over a particular waypoint and for the waypoint ID number to be displayed.

The nodes are just cloned spheres stored in an array, its the array reference number I would like to display.

I know I should be using entitypick, entitypickmode, camerapick etc commands but just cant figure out how it would display the correct array ref number.

Any help appreciated.


Dazman(Posted 2005) [#2]
Its difficult to answer without seeing your code. If you've written it the way i would then you could loop through your array until you find the one that is equal to the result of the CameraPick -Does that make sense?


Duckstab[o](Posted 2005) [#3]
entitypick and camera pick will return sphere global id
ie
max=100
dim waypoint(max)
wp_id#=CameraPick ( camera,mousex(),mousey())

;if you know the max size of your array you can do

for times=1 to max
if waypoint(times)=wp_id# then wp_ref=times
next

then Wp_ref returns the value needed

wrap that in a function and bingo


big10p(Posted 2005) [#4]
I guess you could also store the array index as the name of each sphere:

waypoint_ent = CreateSphere()

Const MAX_WAYPOINTS = 100
Dim waypoint(MAX_WAYPOINTS)

For n = 1 To MAX_WAYPOINTS
	waypoint(n) = CopyEntity(waypoint_ent) 
	NameEntity waypoint(n),n
Next

.
.
.

picked_wp = CameraPick(cam,MouseX(),MouseY())
If picked_wp Then Text MouseX(),MouseY(),"Waypoint No: " + EntityName$(picked_wp) 


Or, a better solution would be to have your waypoints as an array of Types, and just store the index as one of the Fields. This will allow you to store other info related to each waypoint, which you may want to do later on:

Type waypointT
  Field ent
  Field index
  .
  .
  .
End Type



Strider Centaur(Posted 2005) [#5]
I stongly sugest using types for this in B3D.

Mainly because there are good and fast built in fratures for looping, creating and deleting them. This makes making changes to the waypoint list much easier than arrays. You may want to track prvious and next waypoints in the type as well.

[code]
Type Waypoint
field ent
field index
field nextWP
field prevWP
end Type


This will make it easy to change and navigate the waypoint list with simple For Each loops.


Nexus6(Posted 2005) [#6]
Thankyou very much to everybody who replied, all your comments were very useful, and more importantly,,,,, IT WORKED.

I didn't use types. Not because I didn't think it would work, but because when I was first learning Blitz, Types seemed so confusing. Unfortuantely that feeling stuck, and so far I've always managed not to use them. I really should take the time and learn how to use them effectively, but are they any faster?

Once again thanks for your help Dazman, Duckstab[o], Big10p and Strider Centaur.