PDA

View Full Version : [MongTraveller] Character Sheet Design Question



mwbay
July 7th, 2011, 01:15
Hi there...

I'm brand new to this, but I'm working to convert the Classic Traveller ruleset to Mongoose Traveller. In MongTrav, Characteristics have modifiers, much like they do in D&D. My goal is to add a column of boxes that auto-calculate those mods based on the current Characteric levels.

I've managed to tweak the Character Sheet to shift the UPP and Armor data over, and added the "Mod." header. Now, I'm trying to figure out how to create the column of boxes.

https://atlantagamer.net/untitled.jpg

There's a script in the charsheet_main.xml file that appears to do it, but I've got no idea how to read that yet.


function onInit()
local pnode = window.getDatabaseNode();
for i,char in ipairs(Global.Lookups.Characteristics) do
local node = pnode.createChild("characteristics."..char.position);
local win = createWindow(node);
if win.name.getValue()=="" then win.name.setValue(char.name) end;
if win.abbreviation.getValue()=="" then win.abbreviation.setValue(char.abbreviation) end;
if win.gpcode.getValue()=="" then win.gpcode.setValue(char.gpcode) end;
if char.physical then
win.damage.setVisible(true);
win.encumbrance.setVisible(true);
end
end
applyFilter();
applySort();
end

If anyone has any suggestions for how to achieve this, I'd love to hear them!

StuartW
July 8th, 2011, 08:33
Classic Traveller uses window classes to implement characteristics, which means that each row on the characteristics (such as Education) is actually an entry in a list of windows: they just don't scroll so they look like they are part of the character sheet itself. To edit them, you need to look in the definition of the sub-window.

The window definition (charsheet_characteristic) is in the charsheet_listclasses.xml file, and you'd need to add a new field at the bottom of this definition to do what you want.

Once you've added the field, post back here and I'll help you write the code to calculate the bonus automatically.

Hope that helps,

Stuart

mwbay
July 8th, 2011, 12:21
Hope that helps

Stuart...

Thanks for responding. It took only a few minutes to get this:

https://www.atlantagamer.net/untitled2.jpg

Following the example in charsheet_listclasses.xml, I was able to create code that calculates the modifiers when the sheet initializes.


<script>
local current = nil;

function onInit()
if super and super.onInit then
super.onInit();
end
current = window.current.getDatabaseNode();
recalc();
end

function onDrag(...)
return window.onDrag(...);
end

function recalc()
if current then
local val = current.getValue();
local dm = 3;
if val == 0 then dm = -1
elseif val == 1 then dm = -2
elseif val == 2 then dm = -2
elseif val == 3 then dm = -1
elseif val == 4 then dm = -1
elseif val == 5 then dm = -1
elseif val == 6 then dm = 0
elseif val == 7 then dm = 0
elseif val == 8 then dm = 0
elseif val == 9 then dm = 1
elseif val == 10 then dm = 1
elseif val == 11 then dm = 1
elseif val == 12 then dm = 2
elseif val == 13 then dm = 2
elseif val == 14 then dm = 2
end
setValue(dm);
end
end
</script>


This works! But only when the sheet appears, not when changes are made to the values of the sheet. And I know there are much better ways to do this - I'm just happy I got it to work so quickly.

My next step is to get this recalculation to happen every time there is a change in a value in the current column.

Fun!

StuartW
July 11th, 2011, 06:50
I think the best bet would be to put an extra few lines of code in the script for the 'current' field. That field automatically updates when any of the other values change, so you just need to make it recalc your bonus field.

In the 'current' script block, edit the recalc function as follows (new code in red, and I've assumed your new field is called bonus):


if base and adj and dmg and enc then
local val = base.getValue() + adj.getValue() - math.abs(dmg.getValue()) + enc.getValue();
setValue(val);
if window.bonus and window.bonus.recalc then
window.bonus.recalc();
end
end


Hope that helps

Stuart

mwbay
July 11th, 2011, 12:30
Like a charm!

krb243
July 13th, 2011, 04:45
wow, i cant wait to get my grubby paws on the montrav ruleset! thanx guys for working on it:D

krb243
July 17th, 2011, 22:32
hey mwbay, any luck with the mongt ruleset?

mwbay
July 17th, 2011, 22:34
Howdy...

I'm working on it still. I'll start a new, official thread for discussion of it.

Valarian
July 18th, 2011, 09:36
wow, i cant wait to get my grubby paws on the montrav ruleset! thanx guys for working on it:D
There is currently a character sheet in the Wiki. It's an extension on the (now dead) Foundation ruleset. While you're waiting for the conversion of the Classic Traveller ruleset.

Trenloe
September 20th, 2011, 02:18
Howdy...

I'm working on it still. I'll start a new, official thread for discussion of it.

Hey mwbay! How are you progressing with the Mongoose Traveller ruleset? I don't have much experience with rulesets and Lua, but if there's anything I could help out with give me a shout! :)