Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 20:05
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, kzhao, alibaba), 627 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Global value #71824
04/22/06 20:30
04/22/06 20:30
Joined: Apr 2004
Posts: 516
USA
Trooper119 Offline OP
User
Trooper119  Offline OP
User

Joined: Apr 2004
Posts: 516
USA
Quick question and I must appologize for not having the time to look through the forumns but I couldn't find it in the manuel.

How do you set a global value within ALL of your code?

I will elaborate, I'm trying not to use skills but I will use them if that is how you do it, I want to be able to set a value in one piece of code, and use the include function to insert it into another piece of code and be able to manipulate and use that value with both pieces of code. How is this possible? what defines must you put in? etc.


A clever person solves a problem.
A wise person avoids it.
--Einstein

Currently Codeing: Free Lite-C
Re: Global value [Re: Trooper119] #71825
04/22/06 21:57
04/22/06 21:57
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
ämm... I think I donīt got it right, but hereīs my answer:

var super_global_var; //You just have to put it outside the funcs

function set_to_10()
{
if(super_global_var!=10){super_global_var=10;}
}

function set_to_20()
{
if(super_global_var!=20){super_global_var=20;}
}

Re: Global value [Re: TWO] #71826
04/22/06 22:04
04/22/06 22:04
Joined: Apr 2004
Posts: 516
USA
Trooper119 Offline OP
User
Trooper119  Offline OP
User

Joined: Apr 2004
Posts: 516
USA
I see where your going with this, isn't there any way to do it without putting it in a function? Don't get me wrong it would work just fine but it seems a bit messy to have to create and manage a function for something as simple as a single variable.


A clever person solves a problem.
A wise person avoids it.
--Einstein

Currently Codeing: Free Lite-C
Re: Global value [Re: Trooper119] #71827
04/22/06 22:07
04/22/06 22:07
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
var super_global_var=20; ?

Re: Global value [Re: TWO] #71828
04/22/06 22:14
04/22/06 22:14
Joined: Apr 2004
Posts: 516
USA
Trooper119 Offline OP
User
Trooper119  Offline OP
User

Joined: Apr 2004
Posts: 516
USA
yes but that variable is lost when you go into a new .wdl, so if you create var super_global_var = 20; in "supercool.wdl", just because you import "supercool.wdl" in your "justfine.wdl" won't make (when you try to edit) super_global_var = 30; a valid paramter, your code will yell at you saying "what in the world is this super_global_var, tell me if i'm wrong about this, but I think that is how it works, I havn't tried this out in a while.


A clever person solves a problem.
A wise person avoids it.
--Einstein

Currently Codeing: Free Lite-C
Re: Global value [Re: Trooper119] #71829
04/22/06 22:20
04/22/06 22:20
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
Yes *g* got a bright lamp over my head... (Sorry, in my holidays my english is turned out ->Iīm ger )

If you set, say, main.wdl in your level (Map Properties) and define there 'var somewhat;' you can use this in all scripts, if its declined _before_ the includes and other functions eg:

var blabla;

include <something.wdl>;

If you decline a Var in, say, 'something.wdl' you can use it in something.wdl and in all fallowing scripts eg:

include <render.wdl>;//Canīt use the var here in this script
include <something.wdl>;//Decline the Var here
include <a_car.wdl>;//and you can use it in this script


And if you change it in one script, it has the same new value in all other scripts...

Is that what you meant?

Re: Global value [Re: TWO] #71830
04/22/06 22:57
04/22/06 22:57
Joined: Apr 2004
Posts: 516
USA
Trooper119 Offline OP
User
Trooper119  Offline OP
User

Joined: Apr 2004
Posts: 516
USA
I think I understand, and I must say your english is great for you being German. So you are saying if I define var available; in ANY .wdl code, (such as abc.wdl) I can use the variable in abc.wdl in ANY .wdl code after that, including if you put (say abc.wdl) in your level code
example:
include <abc.wdl>
...your main level's code...
function wowthisiscool
{
available = 20; //THIS WOULD WORK?
}
then you can put the var avariable in ANYTHING after the include? Hope that made sense. If that's right, I don't understand why I got this in my head that you couldn't?


A clever person solves a problem.
A wise person avoids it.
--Einstein

Currently Codeing: Free Lite-C
Re: Global value [Re: Trooper119] #71831
04/23/06 05:58
04/23/06 05:58
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
yes


xXxGuitar511
- Programmer
Re: Global value [Re: xXxGuitar511] #71832
04/23/06 06:52
04/23/06 06:52
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
The only thing to do that a func knows a var is to decline it before, where is all the same

But look at Local vars

function blabla
{
var muhu;
}

Now only the func itīs declined in knows the var!


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1