RE: [cw] I'm lost trying to assign a variable.
Ahhh, Ok I see what was going on.
I’m moving forward with my script, I’m sure I’ll have more questions… ;)
The reason you're seeing this behavior is that references with $@ are purely textual substitutions, not variable references. (That's so you can use such references in the text parts of dialog boxes.) Since the value of SystemName is a string, what you're doing is assigning sname=Feri, instead of sname="Feri".
Perhaps the most reliable way of referencing values in the character sheet from a script is use eval with three arguments.
In your case you would use the following assignment:
sname=eval('SystemName', 0, 1);
On 3/14/13 12:06 AM, Eric Jackson wrote:
Ok I have a script that is trying to generate trade info between planets.
So far I have:
var pop,startpop,endpop, PassValue, SName;
getFileName fileName, "Select Destination System", "*.chr";
PassValue = HexToDec(pop) + (startpop+endpop);
dialog ok, Dialog Title;
text Trade Report:;
displayexp "format('From %s to %s',SName)";
displayexp "format('Population: %d Start Mod: %d End Mod: %d Value: %d', HexToDec(pop),startpop, endpop, PassValue)";
The problem is the value of SName is always 0, even though $@SystemName is equal to “Feri”. Running the script debugger right before the dialog here are the variables:
Filename: “C:/Users/Eric/Skydrive/Traveller/System Data/Entrope.chr”
Why won’t SName take the proper value?