PDA

View Full Version : Various New Ruleset Coding Questions



damned
November 28th, 2014, 11:09
I need some help with a few coding queries:

1. In CoreRPG manager_combat.lua there exists the following code that announce a new Combat Round like [ROUND 4]

-- Announce new round
local msg = {font = "narratorfont", icon = "turn_flag"};
msg.text = "[" .. Interface.getString("combat_tag_round") .. " " .. nCurrent .. "]";
Comm.deliverChatMessage(msg);
I wish to modify this slightly - to announce [ROUND 4] Players Reroll Initiative. I can edit the msg.txt statement in the manager_combat.lua in CoreRPG with the obvious issue that it will get overwritten next time MW shares some new goodness around.
Ive been advised by that other Code guru Trenloe that I should put changes to this file in manager_combat2.lua instead. When I add this I get the following error being generated by msg.text line:

Script Error: [string "scripts/manager_combat2.lua"]:86: attempt to index global 'Interface' (a nil value)
Could someone help me understand how to fix this...?

dulux-oz
November 28th, 2014, 13:28
That's weird - Interface is a core package, it should be available everywhere - you haven't inadvertently misspelled it or used the name elsewhere as a variable or something (by mistake, of course)?

Cheers

damned
November 28th, 2014, 20:42
In terms of misspelling - no - its cut and paste from manager_combat.lua
Is it trying to reference something that is only within manager_combat.lua that it cant?

msg.text = "[" .. Interface.getString("combat_tag_round") .. " " .. nCurrent .. "]";

combat_tag_round is a string ROUND so that is not it
maybe its nCurrent...?
No - I remove " " .. nCurrent .. from the string and it still occurs...

so maybe its timing - that error happens on launch...

Ahhh - I think thats it... more digging required.

Moon Wizard
November 30th, 2014, 00:33
Yes, currently the global FG API packages are initialized at the same time as the ruleset script files. Unfortunately, they are currently interleaved in some fashion determined by C++, causing some race situations around script initialization. It most often occurs for code outside functions, since that code is executed when the script is loaded. (as opposed to code in functions, such as onInit, which is only called later).

Regards,
JPG

dulux-oz
November 30th, 2014, 03:49
Yeah, launch errors are always a PITA - I've gotten into the habit of checking if something exists before calling it as a function or function parameter now :rolleyes:

Glad we put you on the right track

Cheers