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 / Can object numbers be strings?

Author
Message
Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 30th Dec 2006 10:10
when you use
Load object "island.x",object number
is it possible to somehow make the object number a word instead of a number? or will that result in an error or something?

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 30th Dec 2006 11:43
you could cast a variable name as an object number

IslandOBJNUM = 100


That said its probably neater to create a UDT with an array and cast it like this

Island(1).OBJNUM = 100

so therefore

load object Island(1).FILENAME,Island(1).OBJNUM

Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 30th Dec 2006 11:48
in other words no but thats a good substitute thanks indi

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 30th Dec 2006 11:54
the media can be used as a variable name, so yes.
The media number is a word which is an integer variable casted back to a number.

Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 30th Dec 2006 11:57
so could i have



indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 30th Dec 2006 12:37
yes, thats an integer variable name, im guessing your new to programming.
thats the basis for declaring a variable name wether it be an integer / float or long float etc..

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 30th Dec 2006 18:23
Why wouldnt you just try it? You have all of the source code there, you couldve just pressed F5 and seen it work.

Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 31st Dec 2006 00:38
not new just couldn't be bothered trying it while i was modelling lol

Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 31st Dec 2006 00:46
im gonna do this



so i set the object names on with sets the variables then i use the variables as the object numbers making life easier to remember what to type when dealing with that object.

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 31st Dec 2006 00:46
you nailed it regardless kieran, happy coding mate..

Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 31st Dec 2006 00:48
thanks and sorry for being lazy lol

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 31st Dec 2006 00:49 Edited at: 31st Dec 2006 00:52
there is no problem with asking questions, thats why we are all here.
dont forget about local variable scope in functions.

Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 31st Dec 2006 00:51
I couldve solved it without yu i was being lazy and asked instead of just testing it myself.

sorry lol

Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 31st Dec 2006 01:24 Edited at: 31st Dec 2006 01:26
You could also use a function to generate those numbers, I tried something similar to what you are doing a long time ago but as my project got bigger it became a chore to sift through loads of numbers. It also makes it nearly impossible to have more than one type of object.

Here's how I do object numbers, whenever I want a cube for example I do this:



Then I can use the mycube variable whenever I'm using the cube. The make_obj_cube() function will get an unused object id number and make a cube with it. (The parameter is for the cube size.) It's also good with arrays because I can write something like



Here's the functions I use to make a cube.



"Did I ever tell you how I got the nickname the Dragon of the West?"
"I'm not interested in a lengthy anecdote, Uncle."
"It's more of a demonstration really."
Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 31st Dec 2006 02:07
thats a good idea but im gonna stick with my function

Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 31st Dec 2006 12:58
Just thought I would drop in and say to Kieran that your function won't work.

This is no good:


If you tested it, you would see that it fails with an Object Number Illegal error. The reason that it fails is because you have declared your variables (island & mountiain) inside a function. When you do that the variables are local to that function only.
If you want to do it your way, then you will need to make your variables Global so that they are recognised throughout your code.

Like this:


Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 31st Dec 2006 13:43
yeah i did notice but i didnt want to ask another nooby question lol thanks scraggle your the man.

(by the way cute lil avatar )

Roxas
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 2nd Jan 2007 01:40
and the best way would be



I have no soul.. I nobody.. I have no heart.. I have felt in the darkness.. Im the darkness.. Whatever..

Login to post a reply

Server time is: 2024-09-25 15:20:20
Your offset time is: 2024-09-25 15:20:20