Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / how can i get selected object number

Author
Message
nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 30th Dec 2011 23:05
when i select one object i want to move it through the parameters of dialog box, it can be done if there is object id available, but i can't get id of the selected object

this is my select function, see marked lines for the problem
program crashes with 'invalid object id' error

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 30th Dec 2011 23:17
Try:

If object exist(highlight) then .... so the error must disappear because only will do the sentences if it really exist.

Cheer.

I'm not a grumpy grandpa
Daniel TGC
Retired Moderator
19
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 31st Dec 2011 01:40
If this is a matter of you losing the ID of your object when it's dragged under or through another object, then there are seveal solutions.

1) Make your dragged object higher than the object you are dragging it over. That way the ID will be consistent.

2) Check if the mouse click has finished. If it has not then it's still dragging and you can just keep that objects ID in memory until you let go.

This is assuming I understand your problem correctly. It is a little unclear what exactly you're attempting to do.
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 1st Jan 2012 13:11
Why hasn't 'LastSelected' been given a value?

nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 1st Jan 2012 17:30
well the idea was to select the object witch works, and to return id of selected object witch should be 'LastSelected as integer'. can someone show me the easiest way to get object id?
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 1st Jan 2012 23:25 Edited at: 1st Jan 2012 23:29
Ok, I did a bit of work creating a object selection program which looks for a mouse release event at the closest object under the mouse. Pick Object does all the main work; all I have done is created a global variable for you to check which object the player has selected.

This can be used in your program by calling the HandleObjectMouseSelection function in your loop.



nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 3rd Jan 2012 20:36
HandleObjectMouseSelection is the function very similar to what i used in my program, but your code helped me see where was the error so now it works great, thanks

Login to post a reply

Server time is: 2026-07-10 06:30:28
Your offset time is: 2026-07-10 06:30:28