AlkarGreener
December 16th, 2020, 13:00
FG ruleset coning newb here, but some experience with scripting.
I am trying to code the Star Wars OpenD6 wild die. To start simple, I have coded it in game_elements.xml as follows. Note, this is in FGU if it matters.
<!--wild die, DEV 15 Dec 2020, Mykl Sandusky
function SystemMessage is a copy from \scripts\manager_chat.lua
- only shows when a standard die type is user for the name
- unsure how to make it a different color than the standard d6
- unsure how to limit to 1 die being rolled
- unsure how to roll an additional die when a 6 is rolled
- NOTE: Savage Worlds ruleset uses a wild die, can that code be used?
-->
<die name="dF" label="wild die">
<model>d6</model>
<icon>d6icon</icon>
<position>160,-68</position>
<script>
function onValue(result)
local modresult = result;
if result == 1 then
modresult = 0;
SystemMessage("ZERO rolled on the wild die!");
end
if result == 6 then
SystemMessage("SIX rolled on the wild die!");
rollWildDie();
end
return math.ceil(modresult);
end
function rollWildDie()
SystemMessage("ROLL ANOTHER DIE!");
end
function SystemMessage(sText)
local msg = {font = "systemfont"};
msg.text = sText;
Comm.addChatMessage(msg);
end
</script>
</die>
For now, I have added rollWildDie to confirm it will be called when a 6 is rolled. I need it to roll the wild die again and add the value, including keep rolling as long as a 6 is returned.
I would also like to block right-clicking and selecting multiple dice.
Also, I have been unable to call the global SystemMessage function. Well, I assumed it was global.
Any suggestions?
I am trying to code the Star Wars OpenD6 wild die. To start simple, I have coded it in game_elements.xml as follows. Note, this is in FGU if it matters.
<!--wild die, DEV 15 Dec 2020, Mykl Sandusky
function SystemMessage is a copy from \scripts\manager_chat.lua
- only shows when a standard die type is user for the name
- unsure how to make it a different color than the standard d6
- unsure how to limit to 1 die being rolled
- unsure how to roll an additional die when a 6 is rolled
- NOTE: Savage Worlds ruleset uses a wild die, can that code be used?
-->
<die name="dF" label="wild die">
<model>d6</model>
<icon>d6icon</icon>
<position>160,-68</position>
<script>
function onValue(result)
local modresult = result;
if result == 1 then
modresult = 0;
SystemMessage("ZERO rolled on the wild die!");
end
if result == 6 then
SystemMessage("SIX rolled on the wild die!");
rollWildDie();
end
return math.ceil(modresult);
end
function rollWildDie()
SystemMessage("ROLL ANOTHER DIE!");
end
function SystemMessage(sText)
local msg = {font = "systemfont"};
msg.text = sText;
Comm.addChatMessage(msg);
end
</script>
</die>
For now, I have added rollWildDie to confirm it will be called when a 6 is rolled. I need it to roll the wild die again and add the value, including keep rolling as long as a 6 is returned.
I would also like to block right-clicking and selecting multiple dice.
Also, I have been unable to call the global SystemMessage function. Well, I assumed it was global.
Any suggestions?