PDA

View Full Version : Phase 2



Fenloh
October 8th, 2008, 16:58
Since Phase 1 is almost done i am moving on to phase 2. The Skillist

I have a skillist with again 3 fields (rating, modifier and check. Unfortunatly i want to add the first 2 and the value of the Attribute linked to the skill and display it in the 3rd box. That box is a Box again from which i can dragdrop the Dice to the Board.
I have used the templates from the Main Charsheetpage. It looks fine and the numbers displayed are being put into the database (so it seems). The Dragdrop works fine too.

1. I have a Textlistitem that can only have 8 different states. IŽd like to to cycle through the posibilities on CTRL-Mouseclick. Any Ideas?

2. How can i add up the Numbers from the first 2 fields (Score and Bonus) and add up the Value of the Checkfield of the Stat that belongs to the skill

3. When I dragdrop the Checkfield iŽd like to display the Name of the Skill (in the Namefield)

4. Is it possible that skills with an empty Name are either not saved or deleted somehow?

Thanks again already in Advance for some help.

Foen
October 8th, 2008, 22:08
On your first point, there is something similar I've used elsewhere called a 'multitext'. It displays as a text, but stores as a number which represents the current state:



<template name="multitext">
<stringcontrol>
<statelabels mergerule="resetandadd">
<state>On</state>
<state>Off</state>
</statelabels>
<script file="scripts/template_multitext.lua" />
<static />
</stringcontrol>
</template>

The script file is:


-- The sourceless value is used if the multitext is used in a window not bound to the database
-- or if the <sourceless /> flag is specifically set

local sourcelessvalue = 1;
local enabled = true;

function setState(state)
if self.beforeStateChanged then
state = self.beforeStateChanged(state);
end
if state == nil or state == false then
state = 1;
end
if source then
source.setValue(state);
else
sourcelessvalue = state;
update();
end
end

function update()
if source then
setValue(statelabels[1].state[source.getValue()]);
else
setValue(statelabels[1].state[sourcelessvalue]);
end
if self.onStateChanged then
self.onStateChanged();
end
end

function getState()
if source then
return source.getValue();
else
return sourcelessvalue;
end
end

function onClickDown(button, x, y)
if enabled then
local newstate = getState() + 1;
if newstate > table.getn(statelabels[1].state) then
newstate = 1;
end
setState(newstate);
end
end

function onInit()
if super
and super.onInit then
super.onInit();
end
setValue(statelabels[1].state[1]);

if not sourceless and window.getDatabaseNode() then
-- Get value from source node
if sourcename then
source = window.getDatabaseNode().createChild(sourcename[1], "number");
else
source = window.getDatabaseNode().createChild(getName(), "number");
end
if source then
source.onUpdate = update;
update();
end
-- Get static flag from database node
if window.getDatabaseNode().isStatic() then
enabled = false;
end
else
-- Use internal value, initialize to state if <state /> is specified
if state then
sourcelessvalue = state[1];
update();
end
end
-- allow <readonly/> to override the database node setting
if readonly then
enabled = false;
end
end

function setEnabled(state)
if not sourceless and window.getDatabaseNode() then
-- Get static flag from database node
if window.getDatabaseNode().isStatic() then
state = false;
end
end
enabled = state;
end

You use it in a ruleset window class as follows:


<multitext name='mychoice'>
<anchored>...</anchored>
<statelabels>
<state>My First State</state>
<state>State #2</state>
<state>Another State</state>
</statelabels>
</multitext>

Clicking on the control cycles it between the different states, and it exposes getState() and setState(statenumber) methods.

It probably isn't quite what you want, but it might give you an idea about how to implement your text list item.

Stuart

Fenloh
October 9th, 2008, 05:40
That is neat coding there, but you are right, that is not what i had in Mind. I only need the Name of the Skill in the Chat_Chat.lua in the Description.

e.g.
The Name of the Skill is "activeskill1" and the total Dice is 5

Then the text in the Roll on the Chattable should read

Player: Activeskill Check (activeskill1) (5) then the 5 Dice are displayed.

right now it reads Activeskill Check (5) then the Dice.

Fenloh
October 9th, 2008, 13:16
Well, the Version is getting further. So far i only have a few more Bugs to think of. Maybe someone is willing to help me looking over the Code.
I could send the ruleset and speak about it via Teamspeak.

I am from Germany, beware of the Timeframe :).

Would be great if someone could help me there.

Fenloh

Foen
October 10th, 2008, 06:23
Fenloh

I'd love to help, but I'm pretty busy on the Rolemaster ruleset at the moment, and that is occupying the time I don't spend on my wife or my day-job!

Individual code questions are easier, and I'll do what I can to help out.

Cheers

Stuart

Fenloh
October 10th, 2008, 07:43
Rolemaster.. jaix.. now that will be complicated...

Well i am still having trouble with global values.. but ill get to it i think.

tks anyway and dont waste any time that you can spend with your wife. For me it is the best time, and i almost never let a chance pass by that i can be with her.

Fenloh