PDA

View Full Version : First script error report - learning to decode



Varsuuk
March 28th, 2018, 16:31
so, I am guessing that if the error was in a lua file I’d have been eased into error fixing a bit more gently.

I tried loading the Ruleset and got the following:

Script Error: [string “charsheet_classes:title”]:1:’end’ expected near ‘<eof>’
Ruleset Warning: Could not load script file [Ruleset Foo&Bar][campaign/scripts/char_labelframetop.lua]
...repeat above line 4 more times...
Script Error: [string “charsheet_main:classlevel”]:1:’end’ expected near ‘<eof>’

In record_char_foo.xml the windowclass “charsheet_main” does indeed indeed precede charsheet_classes (so its reverse order but still adjacent)

I assume because it is not a .lua, that the <script> entry triggering this is only able to report as line ONE. Fine, but still not conversant with these. What dodges the :classlevel and :title tell me?


I also assume it says end expected near eof because it is chomping subsequent lives nes looking for a stray “end” in some (embedded?) script.


I am not looking for exact answers or I’d post more of it in context, rather just a better understanding of what to take from those 2 error lines to help me understand what it is saying to me.

Trenloe
March 28th, 2018, 16:43
Some quick feedback:

“charsheet_classes:title” usually means <windowclass>:<controlname>

You're correct, <script> entries in XML are essentially one line as far as error reporting goes.

If the error reported is "script error" then this is an error within the LUA syntax or resulting API calls.

Putting this all together: Script Error: [string “charsheet_classes:title”]:1:’end’ expected near ‘<eof>’

Means:
- Script error: The error is in the LUA <script> code.
- The error is in the "title" control in the "charsheet_classes" windowclass.
- There will be a missing "end" LUA entry. As LUA uses end to close virtually every nest (function, if-then, etc., etc.) you'll need to check through all of the code to make sure all of the LUA code is closed properly.

Varsuuk
March 28th, 2018, 17:29
Thank you, that is what I checked and found no errors.

Obviously, I am wrong and the interpreter is correct, so I went to the tried and true... comment out top level methods or scripts and keep going down until find the culprit(s). Found it was somewhere in the first <script> but when finally removed the first error by removing code could not SEE what was wrong. Especially since commenting out in xml the various lua “function/end” pairs worked fine with <!— > notation.

THEN, I saw it. umm I was using <!— > pairs inside the script tag inside the XML file. So, I’m glad I posted athe question as it might help others.


If, like me, you believe in documenting stuff to help you reread later easier... note that if you are inside a pen xml <script> tag pair, you have entered lualand no matter that you are commenting inside an xml file.

Darn eclipse correctly syntax highlighted my xml comment tags (and didn’t on my lua ones when i n an xml file and does in ax lua file) so it helped trick me.


Now can go find same issue in second report. I fixed the initial warnings in between in jiffy, this other than was killing me ;)

Trenloe
March 28th, 2018, 17:50
See the main three things to consider with LUA in XML here: https://www.fantasygrounds.com/wiki/index.php/Developer_Guide_-_Rulesets_-_Scripting#Using_Scripts

Varsuuk
March 28th, 2018, 18:00
Thank you Trenloe!

I came here to post my second issue since it was related but not the same - I had angle brackets inside the comment section. (Yup, I read those points, thats why was always using [[ when I REMEMBERED vs -- lol but I forgot about "<" and ">" bah ;) damn syntax coloring placebo! )

<script>
...
--[[ This widgetTitle is created by a script supporting
<windowtitlebar> control ]]
...
</script>

All good now. Since I got this far, now I hope to take the minimal single char sheet to begin testing the code I added then I will add more to it and hopefully now always keep it in "running state" now that seem to have the minimal stuff to get it up.

Varsuuk
March 28th, 2018, 18:08
Oh, and the last <> thing was in script portion of an earlier defined template used in the charsheet_classes window.

If I grok correctly, do templates basically devolve to “macros” in like C? The name is tricky if you come from C++ ;)