PDA

View Full Version : Trying to create a condition track



Doswelk
June 9th, 2007, 17:51
I am creating a ruleset and I have got a bit stuck....

I am trying to create a condition track that affects defenses, attack rolls, skill and ability checks.

I know I'll need to write a lua script to do this, but could nayone give me some pointers?

The condition track needs to have 6 check boxes and 4 of the conditions has a numbercontrol, with a specifc nuber set to them.

What I cannot work out is out to get FGII to display a checkbox, I suspect I need to create a lua script and fields for them to display?

To give an idea of what I am trying to achieve:



Unaffected ()
[ -1] To all rolls ()
[ -2] To all rolls ()
[ -5] To all rolls ()
[-10] To all rolls ()
Unconscious ()


Thanks in advance.

[-10]

joshuha
June 9th, 2007, 21:25
How are you going to determine if a roll meets the criteria of defenses, attack rolls, skill and ability checks?

The code for the condition track wouldn't be too bad but the hard part is going to be how you determine when to take the -2 off a roll. What if the roll is for damage, etc. You would need to somehow flag the type of rolls you want to get the -2 so when it knows when to deduct them. The other thought might be making it so the players have a button or something next to the modifier box that they can hit that will automatically throw in a modifier there for the current penalty they are at.

Doswelk
June 9th, 2007, 23:52
How are you going to determine if a roll meets the criteria of defenses, attack rolls, skill and ability checks?

The code for the condition track wouldn't be too bad but the hard part is going to be how you determine when to take the -2 off a roll. What if the roll is for damage, etc. You would need to somehow flag the type of rolls you want to get the -2 so when it knows when to deduct them. The other thought might be making it so the players have a button or something next to the modifier box that they can hit that will automatically throw in a modifier there for the current penalty they are at.

It did not need to be automated....

If we were playing on paper they would do it manually, so not the end of the world....

I was just thinking that I could have a number box showing the modifier, controlled by a script depending on how many boxes were checked the value in the number box would change....

joshuha
June 10th, 2007, 14:21
As far as creating the slots, wouldn't something similiar to the spell lists circles that you check work for you?

That code is in charsheet_spellcounter.lua. Basically its just adding/removing bitmapwidgets to the sheet.

Toadwart
June 10th, 2007, 20:33
If all you want is a tickbox next to each condition this is easily achieved. Take a look at charsheet_spells.xml and common_templates.xml.
There is a template called "checkbox" that is used for the "spontaneous" indicator and also the (memorized/cast circles).
Basically all you'd need is to create fields using that template (as shown below).
No lua scripting should be required unless you want to do something fancy, like disabling or automatically setting/unsetting some conditions when another one is selected/unselected . . .




<checkbox name="condition_unaffected">
<anchored>
<left>
<to>yourunaffectedstringfield</to>
<anchor>left</anchor>
<offset>5</offset>
</left>
<bottom>
<to>yourunaffectedstringfield</to>
<anchor>bottom</anchor>
<offset>-1</offset>
</bottom>
<size>
<width>20</width>
<height>20</height>
</size>
</anchored>
<!-- you can include the stateicon tags to specify the images or you can leave them out and it will use the default tickbox icons defined in the template (indicator_checkon and indicator_checkoff)
<stateicons>
<on>indicator_casterspontaneous</on>
<off>indicator_casterprep</off>
</stateicons>
-->
<tooltip>
<text>Unaffected on/off</text>
</tooltip>
</checkbox>


<checkbox name="condition_minus1">
<anchored>
<left>
<to>yourminus1stringfield</to>
<anchor>left</anchor>
<offset>5</offset>
</left>
<bottom>
<to>yourminus1stringfield</to>
<anchor>bottom</anchor>
<offset>-1</offset>
</bottom>
<size>
<width>20</width>
<height>20</height>
</size>
</anchored>
<tooltip>
<text>Minus1 on/off</text>
</tooltip>
</checkbox>

... etc

Doswelk
June 12th, 2007, 00:11
If all you want is a tickbox next to each condition this is easily achieved. Take a look at charsheet_spells.xml and common_templates.xml.
There is a template called "checkbox" that is used for the "spontaneous" indicator and also the (memorized/cast circles).
Basically all you'd need is to create fields using that template (as shown below).
No lua scripting should be required unless you want to do something fancy, like disabling or automatically setting/unsetting some conditions when another one is selected/unselected . . .




<checkbox name="condition_unaffected">
<anchored>
<left>
<to>yourunaffectedstringfield</to>
<anchor>left</anchor>
<offset>5</offset>
</left>
<bottom>
<to>yourunaffectedstringfield</to>
<anchor>bottom</anchor>
<offset>-1</offset>
</bottom>
<size>
<width>20</width>
<height>20</height>
</size>
</anchored>
<!-- you can include the stateicon tags to specify the images or you can leave them out and it will use the default tickbox icons defined in the template (indicator_checkon and indicator_checkoff)
<stateicons>
<on>indicator_casterspontaneous</on>
<off>indicator_casterprep</off>
</stateicons>
-->
<tooltip>
<text>Unaffected on/off</text>
</tooltip>
</checkbox>


<checkbox name="condition_minus1">
<anchored>
<left>
<to>yourminus1stringfield</to>
<anchor>left</anchor>
<offset>5</offset>
</left>
<bottom>
<to>yourminus1stringfield</to>
<anchor>bottom</anchor>
<offset>-1</offset>
</bottom>
<size>
<width>20</width>
<height>20</height>
</size>
</anchored>
<tooltip>
<text>Minus1 on/off</text>
</tooltip>
</checkbox>

... etc


I'm getting nowhere with this....

This is the section of code I have:



<genericcontrol name="conditionframe">
<bounds>335,290,160,300</bounds>
<frame>
<name>sheetgroup</name>
</frame>
</genericcontrol>
<stringcontrol name="conditionlabel">
<anchored>
<to>conditionframe</to>
<position>insidetop</position>
<offset>0,10</offset>
</anchored>
<font>sheetlabel</font>
<static>Condition</static>
<center />
</stringcontrol>
<genericcontrol name="conditionnormal">
<bounds> 345,310,140,40</bounds>
<frame>
<name>sheetfocus</name>
</frame>
</genericcontrol>
<stringcontrol name="normallabel">
<anchored>
<to>conditionnormal</to>
<position>insideleft</position>
<offset>10,-10</offset>
</anchored>
<font>sheetlabel</font>
<static>NORMAL</static>
</stringcontrol>


(Looked at the sheet again and it's normal not unaffected).

Anyway if I create a checkbox it is not displayed!

Dachannien
June 12th, 2007, 00:40
Looks like you're altogether missing the part of the code that creates the checkbox itself. Maybe you didn't copy/paste the whole thing?

Doswelk
June 12th, 2007, 10:15
D'OH!



<genericcontrol name="conditionframe">
<bounds>335,290,160,210</bounds>
<frame>
<name>sheetgroup</name>
</frame>
</genericcontrol>
<stringcontrol name="conditionlabel">
<anchored>
<to>conditionframe</to>
<position>insidetop</position>
<offset>0,10</offset>
</anchored>
<font>sheetlabel</font>
<static>Condition</static>
<center />
</stringcontrol>
<genericcontrol name="conditionnormal">
<bounds> 345,310,140,40</bounds>
<frame>
<name>sheetfocus</name>
</frame>
</genericcontrol>
<stringcontrol name="normallabel">
<anchored>
<to>conditionnormal</to>
<position>insideleft</position>
<offset>10,-10</offset>
</anchored>
<font>sheetlabel</font>
<static>NORMAL</static>
</stringcontrol>
<checkbox name="condition_normal">
<anchored>
<left>
<to>conditionnormal</to>
<anchor>left</anchor>
<offset>5</offset>
</left>
<bottom>
<to>conditionnormal</to>
<anchor>bottom</anchor>
<offset>-1</offset>
</bottom>
<size>
<width>20</width>
<height>20</height>
</size>
</anchored>


Using this code above the check box appears in the very bottom left of the character sheet!

I am coming to the conclusion that I do not understand the anchoring code (the library description did not enlighten me either!)

I am feeling a bit thick right now..... :(

rushl23
June 12th, 2007, 13:49
Ah! The Saga Star Wars... I was wondering about this, and I'd hoped that someone was on it. I'm not an xml guy, so I didn't think I could tackle it.

If you don't mind, how far along are you? And do you mind sharing when you're done?

:D

Doswelk
June 12th, 2007, 15:21
<looking around for any Hasbro persons> Erm nope, not a copyrighted licensed system in any way relating to a certian 6 films no sir!...

The ruleset may be called SWd20 but that's a coincidence!

Seriously it's going slowly (it was just going to be for when not all my Modern players were around on a night), that siad given it was just going to be a character sheet with no rules, and has no images or mentions any brand names anywhere (other than the fact that there are force points), if it does get finished then I'll might PM it to people........

<looks around again and slinks back into the shadows.....>

Dachannien
June 12th, 2007, 19:52
When you are doing edge-to-edge anchoring using the tags like <left> and <bottom>, you have to specify the <parent> tag to indicate whose edges you are anchoring to.

This is different from the "shortcut" anchoring where you specify another object using the <to> tag and then use <position> to specify what part of that object you want to be anchored to.

In other words, on your checkbox, change the <to> tags to <parent> tags, and I think that will get it.

Toadwart
June 12th, 2007, 20:29
Are you including standard d20 ruleset xml files in your base.xml?
The checkbox template is defined in the common_templates.xml file. It also needs template_checkbox.lua in the scripts folder.
You'll also need to make sure you have the graphics for your ticked/unticked state loaded somewhere. The ones it uses by default (indicator_checkon amd indicator_checkoff) are defined in graphics.xml (and the files are icons/indicator_checkon.png and icons/indicator_checkoff.png)

-------------
Anchoring while very powerful is also rather confusing.

Remember that you can still fall back to using the simple <bounds>x,y,width,height</bounds> notation instead.
If your frame is not re-sizeable, which is usually the case for charactersheets then hardcoding the position of the control is fine [imho].
Anchoring them can make it a bit easier to move fields around I guess but it can also be a pain if you have to change the anchoring...