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 / Problem with Unity - Using Variables in Multiple .dba files

Author
Message
vorconan
18
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 17th Nov 2007 10:09
Hi, this is probably a stupid question but basically, I've just started to use scripting in my project, using Unity.

I've assigned a variable from an script to a DBPro variable. The problem is that I have seperate .dba files, and the variable is not recognized in them for some reason.

Is there any way I can declare a variable from the script and make it available in all .dba files?

Thanks



Bozzy
18
Years of Service
User Offline
Joined: 10th Sep 2006
Location: Birmingham, UK
Posted: 17th Nov 2007 11:00
Can't you just use a global variable

"I'm a firm believer that if a team scores one goal, then the other has to score two to win."
vorconan
18
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 17th Nov 2007 11:43 Edited at: 17th Nov 2007 11:44
I have been doing that, it just that the other .dba file won't recognize it. It will if you use and number value instead of reading out of a script though, but that eliminates the point of the script.



BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Nov 2007 15:37
Getting the value from a script will make no difference, you must have a problem elsewhere in your code.

vorconan
18
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 17th Nov 2007 16:46
Ok, I thought that might be the case. I'll have a good check now.

Thanks



vorconan
18
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 17th Nov 2007 21:03 Edited at: 17th Nov 2007 21:04
No, I can't find anything wrong. Here's a simplified version of what sort of code I use:

Main DBA File -



Other DBA File -





BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Nov 2007 21:23
Is ForwardSpeed a global variable? If not, your function will create a new local ForwardSpeed which will default to zero.

vorconan
18
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 17th Nov 2007 23:48 Edited at: 17th Nov 2007 23:49
That makes sense, but if I put Global at the start then it results in a declaration error because of the int("ForSpeed")

UPDATE - Ok, the Global business is definitely the problem, but I can't see any reason why it wouldn't declare it just because it uses a value from a script.



vorconan
18
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 18th Nov 2007 00:20 Edited at: 18th Nov 2007 00:21
Ok, I've found a work around until someone finds an answer:



I'm no expert but this can't be good for speed if I keep using it for all variables. But its only a temporary solution I guess.



Bozzy
18
Years of Service
User Offline
Joined: 10th Sep 2006
Location: Birmingham, UK
Posted: 18th Nov 2007 00:42
I think that is the way you're going to have to do it.

"I'm a firm believer that if a team scores one goal, then the other has to score two to win."
vorconan
18
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 18th Nov 2007 11:33
Yeah, it seems the only workaround really, other than storing the values in an array which may be faster, but correct me if I'm wrong.



vorconan
18
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 18th Nov 2007 13:23
That makes much more sense, thanks a lot for that Windowskiller.



Login to post a reply

Server time is: 2024-11-25 09:19:27
Your offset time is: 2024-11-25 09:19:27