Building a character's skill list with respective levels, using individual tiddlers

This is a complicated structure, and I think we may be making some conflicting assumptions. Let me clarify some of mine:

  • Data tiddlers (like the “Character/spellbook” example in your screenshot) are purely for holding data; they don’t need a special UI (and in fact, can’t have one, since the type — set to application/x-tiddler-dictionary in this instance — is already defining a dictionary-type ViewTemplate.) Rather, our goal is to build an interface for editing the data tiddler without ever opening it, and then display that interface as part of a template used elsewhere.
  • <$let spellbook={{{ [<currentTiddler>] [[spellbook]] +[join[/]] }}}> ← This code sets the <<spellbook>> variable to a value = <<currentTiddler>>/spellbook.; the <<spellbook>> variable sets the name of the data tiddler being edited. This means that my code won’t be editing any indexes on <<currentTiddler>>, i.e. the tiddler where the template is displayed. I was envisioning it being used as part of an EditTemplate for a character tiddler, so <<currentTiddler>> would be the name of the character… but I’m not sure exactly what your ideal structure looks like.
    • Do make sure that, wherever this template is displayed, the <<currentTiddler>> is not a dictionary tiddler, and the tiddler whose title corresponds to <<currentTiddler>>/spellbook is.
    • It looks like, at present, you’re trying to use my code as part of a general list of spells, not a list of spells known by a particular character. In this case, I imagine you don’t actually want to edit the level at which a particular character knows the spell… because in this situation, there’s no character defined. Is that right?

First, to fix your code, tiddler="<<currentTiddler>>" should be tiddler=<<currentTiddler>>. You don’t want to use quotations marks around any <<variable>> or {{!!transclusion}} when it’s used as the value of an attribute (like tiddler in this $select widget). Quotation marks indicate a literal value, so your current code would be changing the spellbook field of the tiddler with the literal title “<<currentTiddler>>”.

If a character only has one spellbook and all character spellbooks (i.e., data tiddlers) following the CharacterName/spellbook naming convention, then no, you don’t need a field listing this title. I gave the $select example because you’d asked about how to build a dynamic dropdown, and at the time I wasn’t sure about the sort of character/spellbook relationship you were envisioning.

  • If, for example, you had a bunch of prebuilt spellbook data tiddlers with titles like Spellbook A, Spellbook B, etc., and you wanted each character to use one of these preset spellbooks rather than an individualized one whose title can be programmatically determined, it’d be helpful to have a spellbook field that specifies which spellbook should be used for that character.

I would try moving the level-editing code from GURPSSpellbookEditTemplate to GURPSCharEditTemplate.

Got it.

I will still keep the nomenclature for clarity, however, the option to select what spellbook is associated to a character is a good middle ground to some flexibility without diving into the complexity of having multiple spellbooks for one character (which would mean that we also have to deal with duplicates of spells in those spellbooks, for example).

So first, I fixed the code error in the <<selectspellbook>> macro as you indicated, which makes the drop down correctly assign a tiddler tagged with GURPS Spellbook in the spellbook field of a character.

Then changed the GURPSCharViewTemplate to switch to the spellbook field:

<$list filter="[all[current]tag[Char]]">
<$let spellbook={{!!spellbook}}>
''Spellbook'': <$link to=<<spellbook>>/>

<table><tr>
    <th>Spell</th>
    <th>Level</th>
  </tr><$list filter="[<spellbook>indexes[]]" variable="spell">
<$let level={{{ [<spellbook>getindex<spell>] ~0 }}}> <!-- displays "0" if the <<spell>> index does not exist or is blank -->  
<tr><td><$link to=<<spell>>/></td><td> <<level>></td></tr>

</$let>
</$list></table>
</$let>
</$list>

Which correctly toggles the display to whatever spellbook is specified in the field.

image image

Now for the edition of the levels in the spell/level pair of the spellbook data tiddler, I moved the edition code to the GURPSCharEditTemplate, and arranged it so it doesn’t display the value in a multiline, and the whole thing is displayed in a nice table:

|!Edit spell levels:|<|
<table><tr>
<th>Spell</th>
<th> Level</th>
</tr><$let spellbook={{!!spellbook}}><$list filter="[<spellbook>indexes[]]" variable="spell"><tr><td><<spell>></td><td><$edit-text tiddler=<<spellbook>> index=<<spell>> type=number default="0" size=2 tag=input/></td></tr></$list></$let></table>

Which works!

So thanks again a ton for all your help @etardiff, I’m getting somewhere :slight_smile:

For those watching this thread, a quick update to show where I’m at. Still a looooot of work to go, but the basics are starting to be usable :stuck_out_tongue_winking_eye:

Character edition, spell levels:
bookdatatiddleredition

Spellbook edition:
bookdatatiddleredition2

Thanks again @etardiff for you invaluable help!

2 Likes

I’m going to have to subscribe to this thread, because I’m hoping to do something similar for Warhammer Fantasy Roleplay 4th edition, but am a total blank slate when it comes to the kind of deep tiddler coding knowledge represented here. I’ve only previously used it with basic markup, with which I’m comfortable. But this, this is beautiful coding.

Agreed. Building a wiki for a self designed RPG, and currently I’m still busy adding mainly text.

When I started this I had the choice of working in TW or say Ulysses, and I’m glad I chose for TW, because a lot more seems to be possible.

Question for RaHaNGS, GURPs has also extensive rules for creating Magic Items, is that also in the works?

Some of the Magic Crafting rules of GURPS I have adapted, others I have invented on my own (as far as I know).

1 Like

GURPS has extensive rules for EVERYTHING lol

Personally, I’m not into comprehensive systems like GURPS can be, I like to keep things as simple and streamlined as possible for players, so I doubt I will dig all that deep into translating every single rule (for instance there are some logarithmic tables or super-complex modifiers I don’t intend to use). My objective is to round up a nice looking and easy enough to use GURPS frame to create character sheets (stats, skills, traits), and background elements. I haven’t used GURPS since the 2nd edition and I’m currently re-learning most of it as I go on the 4th one. I’ll see what I want or need to integrate as I progress (slowly). My most pressing concern and first really advanced feature after I set up the basic scope I’m currently working on is to provide character points counts, and that alone can be tricky with traits that have their own unique cost mechanics. Assume I will simplify stuff here and there :stuck_out_tongue_winking_eye:

Oh, and I hate that it’s using imperial scales rather than metric. So I have some macros that convert what’s in the books, because I’m trying to keep the numbers in line with the books (and I input everything in the OG measurements).

update: getting the hang of it.

my TW now checks in the spell list of a character if the prerequisites of any given spell are fulfilled, giving relevant details if they are not; as long as the prerequisites are either:

  • another spell
  • a certain level of the Magery advantage
  • a certain number of spells in a certain college
  • Edit: a certain number of spells in each college of set number of colleges (e.g. “2 spells each in 2 colleges”)

Examples below (with a character named “Character” and fake data on the spells for testing):


That should cover a majority of the prerequisites types a spell can have. I’ll update the code if I stumble upon other types of prerequisites (which is very possible given the nature of GURPS rules). Yay!

Edit: Also happy to report that one can now edit spells and advantages themselves, not just their levels, directly in the character tiddler:
bookdatatiddleredition3

1 Like