April 18, 2024, 03:15:45 PM
Welcome,
Guest
Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
For WME related articles and tutorials visit
WME Resource Center
.
Home
Help
Search
Calendar
Login
Register
Wintermute Engine Forum
>
Wintermute Engine
>
Technical forum
>
Topic:
Global variable problem
« previous
next »
Pages: [
1
]
Print
Author
Topic: Global variable problem (Read 4362 times)
0 Members and 1 Guest are viewing this topic.
wisemanxxx
Lurker
Karma: 0
Offline
Posts: 10
Global variable problem
«
on:
May 17, 2010, 12:27:31 PM »
I want some global values like score, time, player's name etc.
I put a global variable in base.inc (I tried const.inc and game.script too).
Anywhere in game I change this value and use it with a textbox.
But textbox always shows null.Only it works when I give value in same script.
Logged
metamorphium
Global Moderator
Addicted to WME forum
Karma: 12
Offline
Gender:
Posts: 1511
Vampires!
Re: Global variable problem
«
Reply #1 on:
May 17, 2010, 04:07:39 PM »
base.inc
serves for common declarations (shorthand).
Base.inc
Code: WME Script
global
score;
Test_script1.script
Code: WME Script
score =
10
;
Test_script2.script
Code: WME Script
Game
.
Msg
(
score
)
;
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet
ugo
Вредная ворона
Regular poster
Karma: 2
Offline
Gender:
Posts: 156
Делаю кве
Re: Global variable problem
«
Reply #2 on:
November 10, 2010, 11:43:10 AM »
But, if this script again to launched, variable again to assumes value 10.
What should i do?
Logged
shuin
Occasional poster
Karma: 0
Offline
Gender:
Posts: 51
Re: Global variable problem
«
Reply #3 on:
November 10, 2010, 06:45:19 PM »
Did you initialize the global in the include file? You shouldn't do that
Logged
Untitled project status: production
ugo
Вредная ворона
Regular poster
Karma: 2
Offline
Gender:
Posts: 156
Делаю кве
Re: Global variable problem
«
Reply #4 on:
November 11, 2010, 05:14:35 AM »
Do not sure, I`m understand all correct.
"include file" is this - "Test_script1.script" or "Test_script2.script" or some else?
How can i initialize the global?
Whenever "Test_script1.script" is run, variable again to assumes value 10.
But I need saved new value. For example 11.
Logged
Mnemonic
WME developer
Administrator
Addicted to WME forum
Karma: 41
Offline
Gender:
Posts: 5683
Re: Global variable problem
«
Reply #5 on:
November 11, 2010, 07:34:08 AM »
If you insist on setting the value in the included file, you can check if the variable already has some value.
Code: WME Script
global
someVar;
if
(
someVar ==
null
)
someVar =
10
;
This will only set the value the first time.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum.
ugo
Вредная ворона
Regular poster
Karma: 2
Offline
Gender:
Posts: 156
Делаю кве
Re: Global variable problem
«
Reply #6 on:
November 11, 2010, 07:58:56 AM »
Thanks.
Logged
Print
Pages: [
1
]
« previous
next »
Wintermute Engine Forum
>
Wintermute Engine
>
Technical forum
>
Topic:
Global variable problem