Page 1 of 2
Script Variable from .cfg
Posted: Tue Jan 27, 2004 3:18 am
by omniscient
is it possibel to make a script variable varied by a value in a config file? if so, how?
Posted: Tue Jan 27, 2004 11:53 pm
by nuggets
are you trying to define o set a user key? or something completely different?
Posted: Wed Jan 28, 2004 12:47 am
by omniscient
well, i was thinking about making a checkers game. u would use w to move ur piece up asd to do what u would imagin theyd do and so on. i was thinking about using a config so that u would bind w to add to a variable that the script could read to make the piece move up. is there an easier way?
Posted: Thu Jan 29, 2004 9:42 pm
by omniscient
so waht do u guys think, is it possible?
Posted: Sat Jan 31, 2004 3:34 am
by nuggets
so the real question is, what program should i use to make a checkers game, all i have at the moment is radiant and have a good understanding of that, so shall i just create it using MOH setup?
Posted: Sat Jan 31, 2004 6:41 am
by omniscient
im not really making checkers, it was just an example. does anyone know if this is possible?!
Posted: Sat Jan 31, 2004 8:29 am
by jv_map
You could do this in the cfg file:
set "test_variable" "2"
Then in your script you could do:
Code: Select all
while(getcvar test_variable != "2")
waitframe
iprintlnbold_noloc "Yay you execed the fancy cfg file!!"
Posted: Sat Jan 31, 2004 11:48 pm
by omniscient
ok good so it is possible, thanks.
while(getcvar test_variable != "2")
whats the ! for? could it be replaced with an =?
Posted: Sun Feb 01, 2004 9:06 am
by jv_map
!= means 'is not'

Posted: Mon Feb 02, 2004 4:11 am
by omniscient
haha, guess thats a no then, thanks a lot.
Posted: Wed Mar 10, 2004 12:53 am
by omniscient
I ahte to bring this back but could i do:
set "test_variable" 2
Then in the script :
Code: Select all
while(getcvar test_variable = 2)
waitframe
iprintlnbold_noloc "Yay I execed the fancy cfg file!!"
would that work
Posted: Sat Mar 13, 2004 3:54 pm
by dcoshea
omniscient wrote:I ahte to bring this back but could i do:
set "test_variable" 2
Then in the script :
Code: Select all
while(getcvar test_variable = 2)
waitframe
iprintlnbold_noloc "Yay I execed the fancy cfg file!!"
would that work
The thing is, you detect that the player hit the key when the value of the variable CHANGES - so you'd initialize the variable to some value, say 0:
then wait for it to change and do something
Code: Select all
while (1) { // loop forever
while (getcvar "test_variable" == 0) {
waitframe
}
// we got here because the variable is no longer 0
local.newval = getcvar "test_variable"
iprintln_noloc "the variable changed to " local.newval
// now set the variable back to 0 again, waiting for the next change
setcvar "test_variable" 0
}
This is how admin tools like MAM accept commands via rcon - if you type 'rcon <password> command foo', it causes the cvar 'command' to get the value 'foo'. A thread detects the cvar's value has changed from '' and processes the command and takes some appropriate action.
Regards,
David
Posted: Mon Mar 15, 2004 3:53 am
by omniscient
where in that script does the variable change?
Posted: Mon Mar 15, 2004 5:37 am
by dcoshea
omniscient wrote:where in that script does the variable change?
You change the variable by using 'set' at the console and the script changes it back (after processing the event) by using 'setcvar "test_variable" 0'.
Regards,
David
Posted: Wed Mar 17, 2004 1:50 am
by omniscient
oh, i didnt read close enough, i understand what u just did now. mb. thanks for the help, but could i do what i asked???