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 / Get ID of object? (Not sure what the ID is)

Author
Message
Mugen Wizardry
User Banned
Posted: 15th Sep 2010 07:52
Ok. How do I get the ID of an object I don't know the ID number to? I created trees, and randomly assigned an object number. I prefer doing it this way so i dont have to sit there and type out 2000 id's.

It would be GREAT if someone could tell me how to do this!

Thanks!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
bergice
19
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 15th Sep 2010 10:05 Edited at: 15th Sep 2010 10:07
Another thread just like this was recently posted:

http://forum.thegamecreators.com/?m=forum_view&t=175632&b=1


Usually i just setup functions for finding free object id's and then i set up types and arrays for different objects (npc's, static objects etc) and in each of these arrays i can also store the object id's for these npcs and static objects.

9cdfb439c7876e703e307864c9167a15
Mugen Wizardry
User Banned
Posted: 15th Sep 2010 16:46
Yes, but I would rather not use find free object. I would like to get the ID of a random tree so that I can move it in my game like a level editor.

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 15th Sep 2010 17:03
Oh my god dude, will you listen to what people are trying to tell you?

You use find free object, assign it to an array, and viola, you have your object id.

Mugen Wizardry
User Banned
Posted: 15th Sep 2010 18:01
Omg, dude. Stop being a jerk and highjacking my threads. All's I asked for is a SIMPLE answer, and I never get one. I will use in MY game what I want to use.

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 15th Sep 2010 18:20
You keep trying to do it the hard way.... If that's what you want, then good luck! If all you are wanting is to check a mouse collision for editing, you don't need to store the object number (use "pick object"). If you need the object number for anything else, you will HAVE to store the object number somewhere. Most people like to keep that info in a array. Just use your random object number generator and store your "tree" numbers in an array like:


Now, as far as the way you get a free object number; WHY do you insist on using a random to do that?

The fastest code is the code never written.
Mugen Wizardry
User Banned
Posted: 15th Sep 2010 18:25
Ok. I'm gonna be straight forward with you because u obviously don't get it. I'm using Smaas' Landscape generator to create a level editor, where I can change the size and position of the trees.

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
HowDo
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 15th Sep 2010 18:45
so lets see you've use another program to randomly place all the trees, and now you want to know which one you are looking at or have a mouse cursor over.

one way might be to use a while/ endwhile code where you check if a block from 1 to 100 is there.

or as mention above use pick object which will tell you straight away what the id object numbers is when the mouse cursor is over it.

Dark Physics makes any hot drink go cold.
Mugen Wizardry
User Banned
Posted: 15th Sep 2010 18:49
right. but what i need is to ALWAYS know the ID, so that way I can't select any other objects BUT the trees.

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
HowDo
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 15th Sep 2010 19:05
well there's if object on screen command where you check if the object on screen and object picked is within the limit, you must already know what your highest object number was before you randomly added all the trees.

so it might look like this



Dark Physics makes any hot drink go cold.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Sep 2010 19:05
Quote: "but what i need is to ALWAYS know the ID, so that way I can't select any other objects BUT the trees."


If you use pick object and YOU select a tree then surely pick object will return the object number of that tree. I can see there might be a problem if you try this with your eyes shut.

Quote: "Ok. I'm gonna be straight forward with you"


That would certainly help.

Quote: "because u obviously don't get it"


I certainly don't.

From your first post:

Quote: "I prefer doing it this way so i dont have to sit there and type out 2000 id's."


You don't if you use pick object.
Lost in Thought
22
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 15th Sep 2010 19:18
Or if you want to do it with your eye's closed ... if you know the texture file name you could write a loop to search for that. Save all the tree numbers into an array. Dim the array as treeNum(0) and insert an element at bottom for each tree it finds. When you are done the array count for treeNum(0) will even tell you how many trees you have. When you use pick object test the number returned against the numbers in the array. If it matches any ... it's a tree. If not ... well you know.

Mugen Wizardry
User Banned
Posted: 15th Sep 2010 19:35
ok. I came up with a code that will detect an object within the tree range at the distance of 10 and if it intersects.

Now the PROBLEM is its not showing the text at all.



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 15th Sep 2010 19:56
Quote: "Omg, dude. Stop being a jerk and highjacking my threads."


Firstly, thanks. Secondly, I fail to see how i'm hijacking your thread, it seems every thread you make you ask for help, get given it, and say it's not what you want until someone provides you with code.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Sep 2010 20:57
Mugen Wizardry

The pick object function returns the id of the object you picked so why are you testing every possible object number when you already know the number?

From the Help file:

Quote: "PICK OBJECT
This command will return the Object Number of the closest object at the specified screen coordinates"


You really should spend more time studying those.
Mugen Wizardry
User Banned
Posted: 15th Sep 2010 21:24
I edited my code here.

Take a look:



Now that I have this, is it accurate? If not, what is it missing?

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Sep 2010 21:30
Does it work?

If it doesn't, why don't you just check one thing at a time. For example check that the value of picked is sensible. You can do this yourself.
Mugen Wizardry
User Banned
Posted: 15th Sep 2010 21:37 Edited at: 15th Sep 2010 21:38
No. for some reason, intersect is always 0..



Everything under global is being called in the main loop.

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Sep 2010 22:13
Did the pick object work?

In other words, have you tried printing the value of picked BEFORE doing anything else. If that works then there's something wrong with your intersection code which has nothing to do with pick object. As I said, deal with one issue at a time.

I can't help you with the rest because you haven't given enough details. For example, what's the value of maxpickdist#?
Mugen Wizardry
User Banned
Posted: 15th Sep 2010 22:30
maxpickdist# = 10.0

the pick object didnt work.

i printed the value and it always returns 0.

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
HowDo
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 15th Sep 2010 22:34
well if you put pick object above the control mouseclick bit you might see if its seeing anything

like so


Dark Physics makes any hot drink go cold.
Mugen Wizardry
User Banned
Posted: 15th Sep 2010 23:21
this SORTA works.

NOW the problem is shooting an invisible line from my player to pmaxdist# and if player is within range, then highlight tree.

i DONT wanna detect anything on the ground. just straight ahead, and <= 10 units.



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Sep 2010 23:28
Mugen Wizardry

The following code works perfectly for me

Mugen Wizardry
User Banned
Posted: 16th Sep 2010 00:13 Edited at: 16th Sep 2010 00:13
Ok. That works. But I modded it just a bit. I want it when my player is facing the tree within -70 to 70 degrees on the y rotation, and he is 10 units away from whatever object he picks, THEN it shows the text on the center of the screen



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
HowDo
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 17th Sep 2010 18:57
not sure how you would code it, it would be something like if within distance of 10 then check if your -70 or 70 from the angle your at.

something like this (not tested)


Dark Physics makes any hot drink go cold.

Login to post a reply

Server time is: 2026-07-22 17:33:32
Your offset time is: 2026-07-22 17:33:32