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.

Newcomers DBPro Corner / How do you avoid hard-coded object numbers...?

Author
Message
JazW
17
Years of Service
User Offline
Joined: 14th Jun 2007
Location:
Posted: 14th Jun 2007 08:41
I've been searching the forums and banging my head on dark basic for a couple of days now and I just it...

I thought using a free_object function I found on this forum was the way to handle object numbers like this:



But the clone command throws an illegal object error...

Someone please put me out of my misery and explain how the smart people handle object numbers
Gil Galvanti
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 14th Jun 2007 18:31
That code looks fine, it might be something with the function, so post it here too .


JazW
17
Years of Service
User Offline
Joined: 14th Jun 2007
Location:
Posted: 14th Jun 2007 22:42
Yeah I realised I forgot to paste that bit of code, but couldnt edit the post until it had been vetted by a moderator...

This is the function I'm using:
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 14th Jun 2007 23:40 Edited at: 14th Jun 2007 23:43
I'm not sure that "o" needs to be a dword. Does this function work:



That's all I can see thats different from the one I'm using, which works fine.

Anyway, I handle my objects exactly as you are, although now I'm using arrays (along with that Free_Object() function). So, I'm storing the objects in an array instead. (an array is like a variable with lots of different slots that can hold values, kind of like a dresser with drawers in it)

See if my function works. If not, then I'm not sure what's wrong...




EDIT: Okay! I tested your function and it worked fine. Here's what I did, its the same thing as your function, and it's working 100% for me.



JazW
17
Years of Service
User Offline
Joined: 14th Jun 2007
Location:
Posted: 15th Jun 2007 03:36
Thanks for the feedback!

The problem seems to be something to do with the scope of variables... converting the function i was calling clone object in, to a gosub fixed the problem, and my pawns now spawn! Yay!

However... I now get an illegal object number error when trying to move the objects ive just cloned...

If someone with time on their hands could explain why the code below doesnt work, I'd appreciate it!

Pharoseer
17
Years of Service
User Offline
Joined: 21st Feb 2007
Location: Right behind you
Posted: 19th Jun 2007 01:01
Check the codebase. I just uploaded an example of a resource manager that I use and I noticed at least one other example. My method avoids the constant looping in the function you're currently using, but you can't re-use an index number at the moment.

~Pharoseer

Login to post a reply

Server time is: 2024-11-25 17:27:08
Your offset time is: 2024-11-25 17:27:08