PDA

View Full Version : Comment in a function



Grimmbart
February 28th, 2019, 16:57
Hi all

Is it possible to add a comment in a function when the fuction is in a XML file ?

Example :


<template name="number_char_ability_Mod">
<number_chartotal>
<anchored position="right" offset="12,0" width="30" />
<frame name="fieldLightSquare" offset="7,5,7,5" />
<rollable />
<displaysign />

<script>
function onSourceUpdate()
local nodeWin = window.getDatabaseNode();

here my comment

Thank's

damned
February 28th, 2019, 18:32
try
-- [ comment ]

Trenloe
February 28th, 2019, 18:34
Use 2 dashes followed by 2 square brackets:

--[[ comment text ]]

This, and other differences for LUA scripts in a FG XML file, are detailed here: https://www.fantasygrounds.com/wiki/index.php/Developer_Guide_-_Rulesets_-_Scripting#Using_Scripts

Grimmbart
February 28th, 2019, 20:48
Thank 's for all.

Varsuuk
March 7th, 2019, 19:57
Yup, I was just about to point to that page (although mine is from some old color page I bookmarked)

Speaking of this page, that example about accessing xml data... I notice the first tab had two children (something) which has a 1= in front of it and “normal” which did not have a 2= in front. All he other children seem to follow this system as described.

Always meant to ask but always forget. Is it a typo, or just another thing I don’t yet understand?

Trenloe
March 7th, 2019, 20:11
Speaking of this page, that example about accessing xml data... I notice the first tab had two children (something) which has a 1= in front of it and “normal” which did not have a 2= in front. All he other children seem to follow this system as described.

Always meant to ask but always forget. Is it a typo, or just another thing I don’t yet understand?
You're not reading the curly brackets {} correctly. "empty" and "normal" are both children of "states". "normal" is at the same level as "empty", it is not a level higher. "states[1]" encompasses both the "empty" and "normal" children - which are actually states[1]["empty'] and states[1]["normal] in LUA.

More on LUA multidimensional tables here: https://www.lua.org/pil/11.2.html

Varsuuk
March 7th, 2019, 20:56
I agree they are on the same level.
Are first and second on the same level to flags as I thought i was reading?

because it seems both should be same (again unless misreading) so:
flags[1][“first”] and flags[1][“second”]


I looked at the link, it had the standard multidimensional array info I’d expect coming from C based languages including layout math pointer thing.


I just didn’t see a diff between the number or level of children states and flags had. But the former had one entry and latter had two entries. again I feel as if any moment I’m going to facepalm.