PDA

View Full Version : Replacing lua scripts with one in an extension...



Doswelk
January 30th, 2009, 17:50
I was playing around with trying to turn the Box into an extension, if I create a scripts folder and copy chat_manager.lua and chat_chat.lua to that and then modify them do I need to do anything in the extension.xml to access them?

Thanks

Oberoten
January 30th, 2009, 18:00
I was playing around with trying to turn the Box into an extension, if I create a scripts folder and copy chat_manager.lua and chat_chat.lua to that and then modify them do I need to do anything in the extension.xml to access them?

Thanks

You need to use :
<script name="ChatManager" file="scripts/chatmanager.lua" /> In extension.xml Same as your ruleset uses it in it's Base.XML.

- Obe

Tenian
January 30th, 2009, 18:14
I do believe the author of The Box was working on this. At least I remember posts about it.

Valarian
February 7th, 2009, 12:37
I'm having a similar problem with implementing Double-Click dice rolling in an extension. The chatmanager.lua file is exactly the same as the base ruleset, except for the addition of the two die rolling routines


-- Joshuha - Auto Dice Rolling --
function dieCheck(type, bonus, name)
if control then
local dice = {};
table.insert(dice, type);
control.throwDice("dice", dice, bonus, name);
end
end

-- Ian M Kirby - Added die roller for multiple dice
function diceCheck(number, type, bonus, name)
if control then
local dice = {};
for i = 1, number, 1 do
table.insert(dice, type);
end
control.throwDice("dice", dice, bonus, name);
end
end


I've tried the above reference in the extension.xml to override the ChatManager. This results a warning that the duplicate reference to ChatManager will be ignored.

I've then tried putting the two dice rolling routines in a separate file called chatdice.lua, with the following extension.xml reference


<script name="chatdice" file="scripts/chatdice.lua" />


Still doesn't work, and I really don't know why. Has anyone got a modification to the chatmanager.lua script working in an extension?

Getting the error:
[07.02.2009 12:31] Script Error: [string "charsheet_main:strengthbonus"]:1: attempt to call field 'diceCheck' (a nil value)

Valarian
February 7th, 2009, 17:44
Okay, I think I've now got this working ...

In the extension.xml, register the script as another name


<script name="ChatDice" file="scripts/chatdice.lua" />


Put the dice rolling routines in a separate script file (called chatdice.lua). Call "ChatManager.control" rather than just "control".


-- Joshuha - Auto Dice Rolling --
function dieCheck(type, bonus, name)
if ChatManager.control then
local dice = {};
table.insert(dice, type);
ChatManager.control.throwDice("dice", dice, bonus, name);
end
end

-- Ian M Kirby - Added die roller for multiple dice
function diceCheck(number, type, bonus, name)
if ChatManager.control then
local dice = {};
for i = 1, number, 1 do
table.insert(dice, type);
end
ChatManager.control.throwDice("dice", dice, bonus, name);
end
end


When calling the code, use ChatDice rather than ChatManager.


ChatDice.diceCheck(2, "d6", dieMod + getValue(), dieLabel);