So much power! Unfortunately, I don't understand it all ;-) Trying to transclude...

115 views
Skip to first unread message

Chris Normand

unread,
Feb 12, 2020, 12:03:04 AM2/12/20
to TiddlyWiki
I have been using TW5 to document my campaign.  Nothing fancy, just tags and lists, etc.   Now, I want to document the GURPS spells that I have been creating.   Sorry for the long example, but I wanted to give as much context as possible.

Here is what the spells would look like in GURPS:

“Magic MIssile 1”
Innate Attack (crushing) 1d-1, 3.5
  Cosmic, no roll required, +100%
  Increased 1/2D, 5x, +10%   1/2D 10 yds
  Reduced Range, x1/5, -20%   Max 20 yds
  Spell w/components, -50%
  [40%/5]

“Magic MIssile 2”
Innate Attack (crushing) 1d+1, 6.5
  Cosmic, no roll required, +100%
  Increased 1/2D, 5x, +10%   1/2D 10 yds
  Reduced Range, x1/5, -20%   Max 20 yds
  Spell w/components, -50%
  [40%/10]

I had 3 design goals:
Hide the information on how the spell was "built", using the GURPS rules, unless the player specifically wanted to read it.  This would reduce the clutter.
Be able to "find all spells that cost 5"
Be able to "find all variants of 'Magic Missile"

I figured the best way to model this would be using a data tiddlers and a template.     Searching the group, I found a way to hide the "build" information so that it doesn't clutter up the interface.   The template tiddler is:

BasicSpellFormat
<$button class="tc-btn-visible" popup=<<qualify "$:/temp/popup1">>>
//{{##spell}}// ''{{##damage}}'' {{##range}} [{{##cost}}]
</$button>
<$reveal type="nomatch" state=<<qualify "$:/temp/popup1">> text=""><br>
{{##build}}
</$reveal>

And the data tiddlers are:

MagicMissileData1
{
"spell":"Magic Missile",
"damage":"1d-1 cr",
"range":"(1/2D: 10 yds, Max: 20 yds)",
"cost":5,
"build":"Innate Attack (crushing) 1d+1, 6.5<br>&nbsp;&nbsp;Cosmic, no roll required, +100%<br>&nbsp;&nbsp;Increased 1/2D, 5x, +10%   1/2D 10 yds<br>&nbsp;&nbsp;Reduced Range, x1/5, -20%   Max 20 yds<br>&nbsp;&nbsp;Spell w/components, -50%<br>&nbsp;&nbsp;[40%/10]"
}

and
MagicMissileData2
{
"spell":"Magic Missile",
"damage":"1d+1 cr",
"range":"(1/2D: 10 yds, Max: 20 yds)",
"cost":10,
"build":"Innate Attack (crushing) 1d+1, 6.5<br>&nbsp;&nbsp;Cosmic, no roll required, +100%<br>&nbsp;&nbsp;Increased 1/2D, 5x, +10%   1/2D 10 yds<br>&nbsp;&nbsp;Reduced Range, x1/5, -20%   Max 20 yds<br>&nbsp;&nbsp;Spell w/components, -50%<br>&nbsp;&nbsp;[40%/10]"
}

And the final tiddlers are

[[Magic Missile 1]]
{{MagicMissileData1||BasicSpellFormat}}

and

[[Magic Missile 2]]
{{MagicMissileData2||BasicSpellFormat}}

It looks like this (when expanded):


My questions:

1.  Is there a better way to encode newlines (and non-breaking spaces) into the "build" index data?   Having to type "<br>;nbsp;&nbsp;" for each new line is a lot of redundant work.  I know I can't put newlines in a dictionary data tiddler, but it also seems that I cannot encode newlines in a JSON data tiddler either.  I could live with using an escape character sequence ("\n"), but I couldn't figure out how to parse the data in the template tiddler.  All I could do was output the data ({{##build}}), so I had to encode the raw HTML into the data itself (not ideal).  Can I use a "filter", or write some javascript?

2.  How would I list all tiddlers for "all spells that cost 5" or "all variants of 'Magic Missile'"?    Have I made it too complex?   I went with this approach because if I just used plain tiddlers with a few custom fields (i.e. "cost" and "name"), I would have to copy and paste the button code into each tiddler, and I was trying to save myself all of that copy/pasting.

I have more questions, but I shall refrain for now.   Any help would, of course, be greatly appreciated.

Chris

P.S.   I am a 20+yr Java programmer, so I am not afraid of a little syntax ;-)  I just don't know what it is.


Mat

unread,
Feb 12, 2020, 3:26:35 AM2/12/20
to TiddlyWiki
TL:DR 

Chris Normand wrote:
1.  Is there a better way to encode newlines (and non-breaking spaces) into the "build" index data?   Having to type "<br>;nbsp;&nbsp;" for each new line is a lot of redundant work.

Ideas to try out
  • You could put that into a macro and instead call the macro
  • You could exchange the double nbsp for whatever the name of that character is that mades a tab jump space
  • You could put the things above that <br> string of yours in a div and style the div - or replace that string with an empty div and style it.
  • Or, a combo, put a div in a macro to call the macro e.g \define z() <div style="..."></div>    and in the text call macro with <<z>>
  • I didn't read carefully enough to understand what it is you want to separate but maybe it is every <p> in which case you can add a style for p's in tiddler without having to manually add any p's because they're already there. (Or maybe it's a <li> instead of a <p>)
2.  How would I list all tiddlers for "all spells that cost 5" or "all variants of 'Magic Missile'"? 

Try <$list filter="""[all[tiddlers]cost[5]]""">... i.e you use the listwidget (one of the most important widgets, learn it ;-)

<:-)

Mark S.

unread,
Feb 12, 2020, 10:14:58 AM2/12/20
to TiddlyWiki
I'm afraid my eyes are watering a bit here. And people do this for fun, right?

There are very few tools built into TW for using data dictionaries. They're good for certain situations, but not good for a lot of analysis and processing.

If you change your design so that each spell is its own tiddler and all the parameters are in their own fields, it will become much easier to extract and present the tiddlers you want.

I'm assuming that all the information in "build" means something? So you might want to extract or compare tiddlers based on the content of the build? In that case, break out the content of the build into fields as well. In presentation you can then list the fields and automatically insert the line breaks. If the builds are never broken out, and the information never used for analysis, then there would need to be something in the line to indicate where you want the linebreaks inserted.

hth

Chris Normand

unread,
Feb 12, 2020, 1:36:11 PM2/12/20
to TiddlyWiki
Yeah, sorry about the information overload... but I had seen too many questions with very little context, and I didn't want to make that same mistake.

Thank you for the explanation.   I think my years of backend development may have lead me down the wrong path.  I think I will go with your idea.  ;-)
Reply all
Reply to author
Forward
0 new messages