Closed EdMSL closed 1 year ago
what about using $stingVar in the map bracket?
It works, thanks
Can I get the value of variable of another quest in a similar way? F.e. there is a variable someVariable on any quest script for quest with name "SomeQuest".
scn SomeQuestScn
short someVariable
//some other code
and I want to get value of this someVariable variable from my another script. By default we write:
scn MyScript
short myvar
Let myvar := SomeQuest.someVariable
Is there any way to get value by variable?
Let stingVar := "someVariable "
Let myvar := SomeQuest[$stingVar ] // not works
Quest variables are scoped by itself:
; quest script
scn quest
int i
array_var a
; other script
string_var string
array_var array
let x := quest.a[$string]
let x := array[$quest.i]
They accept all operators as well
Yes, but I want to get value of variable from another script by string:
let sting := "a"
let x := quest[$string]
//or
let x := quest["a"]
I'm not sure what you're asking exactly, all quest variables are scoped like so: quest-ref-name.variable-ref-name
If you want to get the value of said quest var by string, you can still stringicize with $
Let x := some_array[$quest.var]
If you want to get the value of a quest array variable you can still do that:
Let x := quest.var[$some_array]
This is a quest script for MyQuest:
scn MyQuestScript
short attempts
short doonce
begin MenuMode
if doonce != 1
set attempts to 10
set doonce to 1
endif
end
This is an another script:
scn GetAttemptsScript
string_var text
short data
short isGetData
begin GameMode
if isGetData != 1
// by default we write:
let data := MyQuest.attempts //data will be 10
// but I want:
let text := "attempts"
let data := MyQuest[$text] //not works
set isGetData to 1
endif
end
MyQuest
isn't a variable
What is MyQuest ? Is this a Reference?
You did let data := MyQuest[$text]
MyQuest
is not a variable, and also doesn't seem to be a valid reference either (like a quest reference). You can only subscript or member access array and string variables
Ok. You writed:
all quest variables are scoped like so: quest-ref-name.variable-ref-name
I should to write
let quest-ref-name.variable-ref-name := 1
Is there any way to replace variable-ref-name by value of var_string?
var_string x
let x := "some"
let quest-ref-name[$x] := 1 //not works
Quest variables behave like namespaces in other languages (e.g. std::cout
in C++, string.format
in Lua, etc...). They're a token themselves and work as a whole. There's no other way to access quest variables
You can do $quest.variable
to stringicize quest variables as $
operates on the whole of the quest variable. You need to include this all if you want to use $
[]
is for subscripting arrays and strings. It is not for anything else
You can use this GetVariable
scn MyQuestScript ; from questo MyQuest
float myVar
float anotherMyVar
string_var nameOfProperty
float value
...
let nameOfProperty := "myVar" ; or "anotherMyVar"
let value := GetVariable $nameOfProperty MyQuest
Is there something similar to this for setting a quest variable?
P.S. I think I can use RunScriptLine function.
I have a stringMap like this:
I can get value of key "keytwo" by command aaaDBTAMArr["keytwo"]. Is there any way to get value of some key by variable?
It doesn't work, neither does aaaDBTAMArr->stingVar.