View Full Version : Description value in script
Grimmbart
June 15th, 2009, 16:38
Hi.
In a numberfield, i set 'description' value. After, in the numberfield script, i need to access to the description. How can i do that ?
local desc = getDescription(); ???
<numberfield>
....
<description text="here i am" />
<script>
local desc = getDescription();
</script>
</numberfield>
Lithl
June 15th, 2009, 17:29
I'm not certain how attributes are accessed, but if it were <description>here i am</description>, then the Lua would be local desc = self.description[1];
Grimmbart
June 15th, 2009, 17:54
Thank's but that is not good !!
self.description[1] return boolean value !!??
Lithl
June 15th, 2009, 20:48
Are you still using an attribute when you try that Lua code? See Ruleset Modification Guide (https://www.fantasygrounds.com/modguide/scripting.xcp): from the section "Accessing XML parameters from script"...
Any tag with no child tags is represented as a string value if it has text contents, or the boolean value true if the containing tag is singular or empty.
Your XML code, <description text="here i am" /> is a singular tag, so the Lua gets "true". If you change it to <description>here i am</description, then the Lua code should work fine.
There's probably a way to access the attribute, I just don't know what it is.
Foen
June 16th, 2009, 06:40
I don't know how attributes are treated - it is an undocumented feature of the FG xml. Some attributes can be used instead of tags but that used is deprecated, for example:
<tabtarget next="nextctl" prev="prevctl"/>
is the same as:
<tabtarget><next>nextctl</next><prev>prevctl</prev></tabtarget>
But the second approach is encouraged and the first is considered out-moded (I think it is there to support FG 1 conversion to FG II).
Foen
Grimmbart
June 16th, 2009, 08:16
Thank's, now it's good !!
Nicolas.
rule of three
June 16th, 2009, 21:07
I was going to post my question here but I see that you were faster than me.
Thanks Grimmbart :D
That should simplify my dicethrower script.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.