PDA

View Full Version : example from guide not working: runequest damage mod in Classis Traveller ruleset



Archlyte
April 1st, 2015, 16:21
I have been modifying the classic traveler ruleset, and I wanted to do a runequest style damage modifier so I used the example on this site. The problem im getting is that nothing displays in the field, and I get Script Error: [string ""]:1: 'then' expected near '&'.
Is the setDice function the problem? I put in all of the customdice in the appropriate file. I'm not sure what is going wrong. Any help is appreciated. The script is as follows:

function recalc()
local siz = window.getDatabaseNode().
getChild("characteristics.C3.current").getValue();
local str = window.getDatabaseNode().
getChild("characteristics.C1.current").getValue();
local tot = siz+str;
if tot > 121 then
setDice({"d10","d10","d4"});
elseif tot > 111 then
setDice({"d10","d10","d2"});
elseif tot > 101 then
setDice({"d10","d10"});
elseif tot > 91 then
setDice({"d10","d8"});
elseif tot > 81 then
setDice({"d8","d8"});
elseif tot > 71 then
setDice({"d8","d6"});
elseif tot > 61 then
setDice({"d6","d6"});
elseif tot > 51 then
setDice({"d12"});
elseif tot > 46 then
setDice({"d10"});
elseif tot > 41 then
setDice({"d8"});
elseif tot > 36 then
setDice({"d6"});
elseif tot > 31 then
setDice({"d4"});
elseif tot > 26 then
setDice({"d2"});
elseif tot > 21 then
setDice({"d2","m2"});
elseif tot > 16 then
setDice({"m2"});
elseif tot > 11 then
setDice({"m4"});
elseif tot > 6 then
setDice({"m6"});
elseif tot > 1 then
setDice({"m8"});

end
end

function onInit()
local siznode = window.getDatabaseNode().
getChild("characteristics.C3.current");
local strnode = window.getDatabaseNode().
getChild("characteristics.C1.current");
if siznode and strnode then
siznode.onUpdate = recalc;
strnode.onUpdate = recalc;
end
recalc();
end

Nylanfs
April 1st, 2015, 16:44
Don't forget to use the code
stuff so you don't have walls of text. :)

Archlyte
April 1st, 2015, 17:18
yeah sorry. I will do that in the future

Archlyte
April 1st, 2015, 23:37
Script Error: [string ""]:1: 'then' expected near '&'.
is the real issue here (besides the dice not showing in the modifier window) because it gives an error. Because it gives the line as "1" is this likely to be an error produced by one of the scripts?

Dakadin
April 1st, 2015, 23:56
If it is a lua file then use > instead of >. the > is for XML files.

Archlyte
April 2nd, 2015, 00:16
If it is a lua file then use > instead of >. the > is for XML files.

Hey Dakadin thanks for the reply :)

the function is in a file called charsheet_main.xml and it doesn't refer to any script files so I'm guessing its not completed with a lua function. I will try changing the symbol and see if that works.

Dakadin
April 2nd, 2015, 00:18
In that case change

>

to

>

> is a special XML character that represents the > symbol because that symbol is used extensively in XML.

Archlyte
April 2nd, 2015, 00:21
I changed all of the ">" to ">" and received a new error
Runtime Notice: Reloading ruleset
Script Error: [string "charsheet_main:<unnamed>"]:1: attempt to call global 'setDice' (a nil value)

Dakadin
April 2nd, 2015, 00:24
It is giving that error because it doesn't recognize the setDice function. Is setDice another function in that part of the script section or somewhere else?

Archlyte
April 2nd, 2015, 00:31
It is giving that error because it doesn't recognize the setDice function. Is setDice another function in that part of the script section or somewhere else?

It is the only appearance of it in the ruleset that I know of. I thought it referenced the base layer of the game but would it need to be represented in a lua file within the ruleset to be called on? The tutorial I got it from didn't mention that.

Dakadin
April 2nd, 2015, 00:53
It looks like it is a function for a diecontrol. Here is the wiki entry: https://www.fantasygrounds.com/refdoc/diecontrol.xcp#setDice

If the control the script is attached to is a diecontrol, then it should recognize the function. If you have a diecontrol in your XML file you should be able to use the function with that control. Hopefully that helps.

Archlyte
April 2nd, 2015, 06:40
It looks like it is a function for a diecontrol. Here is the wiki entry: https://www.fantasygrounds.com/refdoc/diecontrol.xcp#setDice

If the control the script is attached to is a diecontrol, then it should recognize the function. If you have a diecontrol in your XML file you should be able to use the function with that control. Hopefully that helps.

it did help, but in a way I didn't expect. I had to change the thing from a diefield to diecontrol and it worked. Thanks again :)