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 / Function questions

Author
Message
Nameless
20
Years of Service
User Offline
Joined: 11th Apr 2004
Location: U.S.A.
Posted: 31st Jul 2006 01:25 Edited at: 31st Jul 2006 01:25
Okay, I was wondering if there is any way to create objects,
lights, and camera's in a function,this way I could organize my
code much more effeciently. Whenever, I try it I get an error
saying whatever I tried to create does not exist. Also, if you
declare an array in a function is it automatically global? Thanks
in advance for any help.
Euphoria
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: United Kingdom
Posted: 31st Jul 2006 03:06
Arrays are global, as are constants. Variables are local.

Yes you can create anything in a function, you just need to ensure the data it requires (object numbers etc..) is visible to it, otherwise you will get the errors you are experiencing now.



Alternately you could use an array to hold object/camera numbers and access it directly from within a function (as its global). Be careful as a lot of global definitions can cause confusion with bigger projects.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 31st Jul 2006 03:33
ARRAYS can only be created outside of the function in order to be global.

In order to make a variable global, write Global variable where variable is your variable.

Constants, declared using the #Constant Variable=3 command, are gloabal as well. #Constant is the actual command. Variable=3 is an example.

WARNING: If you have DBC nothing but the array thing will work

Nameless
20
Years of Service
User Offline
Joined: 11th Apr 2004
Location: U.S.A.
Posted: 31st Jul 2006 15:53
Thanks for the help guys, that cleared things up a bit for me.

Login to post a reply

Server time is: 2024-11-26 14:45:38
Your offset time is: 2024-11-26 14:45:38