0 votes
by (870 points)
:: equip manager puppets[nobr]
<<for _i, _puppet range $puppets>>
	<div class="actor menu" @id="_i">
		<div class="inmenu stats" style="padding-left: 0px">

			<<capture _puppet>>
			<<link _puppet.name>>
				<<run _puppet.equip(_item)>>
				<<unset _item>>
				<<replace "#equipment>><<include "equipmentlist">><</replace>>
				<<replace "#puppets">><<include "equip manager puppets">><</replace>>
			<</link>>
			<</capture>>

		<br/>
		<br/>
		<<for _k, _v range _puppet.stats>>
			<span class="statname"><<print _k>></span>
			<<print _puppet.get(_k)>>
			<br/>
		<</for>>
		</div>
		<div class="inmenu equipment">
			<<for _k, _v range _puppet.equipment>>
				<div>_k: 
				<<if _v !== null>>
				<span style="font-weight: normal">
				_v.name<br/>
				<span class="actdesc">_v.info</span>
				</span>
				<</if>>
				</div>
			<</for>>
		</div>
	</div>
<</for>>

When I attempt to visit this passage, I am told that <<capture>>, <<link>>, and <<replace>> do not have closing tags, even though as you can see, they do. Additionally, the final two close divs display as plaintext, and I am told the close for exists outside of its call macro.

If I comment out the first section, the equipment section sort-of displays correctly, but it says there is no close tag for the for loop, even though, as you can see, there is.

This nearly identical code displays without issue:

:: party manager puppets[nobr]
<<for _i, _puppet range $puppets>>
	<div class="actor menu" @id="_i">
		<div class="inmenu stats" style="padding-left: 0px">
		<<capture _i>>
		<<link _puppet.name>>
			<<if def _s>>
				<<run $('#' + _s).removeClass("selected")>>
				<<if _s != _i>>
					<<set _s = _i>>
					<<run $('#' + _s).addClass("selected")>>
				<<else>>
					<<unset _s>>
				<</if>>
			<<else>>
				<<set _s = _i>>
				<<run $('#' + _i).addClass("selected")>>
			<</if>>
			<<replace "#status">><<include "party manager reserve">><</replace>>
		<</link>>
		<</capture>>
		<br/>
		<br/>
		<<for _k, _v range _puppet.stats>>
			<span class="statname"><<print _k>></span>
			<<print _puppet.get(_k)>>
			<br/>
		<</for>>
		</div>
		<div class="inmenu equipment">
			<<for _k, _v range _puppet.equipment>>
				<div>_k: <<if _v !== null>><span style="font-weight: normal">_v.name<br/><span class="actdesc">_v.info</span></span><</if>></div>
			<</for>>
		</div>
	</div>
<</for>>

Why are the close tags not registering? I have encountered this problem before when one half of the macro exists outside a conditional statement and the other exists inside, but I believe I have avoided that here. Does anyone know why this is happening?

1 Answer

+1 vote
by (44.7k points)
selected by
 
Best answer

The problem is here:

<<replace "#equipment>>

You're missing a closing " in that <<replace>> macro.

Generally, when you get that error it's either a missing ", ', or > somewhere, so next time you see that problem you should know what to look for.

Have fun!  :-)

by (870 points)

It was that simple? T_T

Ah well, live and learn I guess. If it's not too much to ask, I have a related design question. I tweaked the passage a bit, and it now looks like this:

:: equip manager puppets[nobr]
<<for _i, _puppet range $puppets>>
	<div class="actor menu" @id="_i">
		<div class="inmenu stats" style="padding-left: 0px">
		<<capture _i>>
		<<link _puppet.name>>
			<<if def _s>>
				<<run $('#' + _s).removeClass("selected")>>
				<<if _s != _i>>
					<<set _s = _i>>
					<<run $('#' + _s).addClass("selected")>>
				<<else>>
					<<unset _s>>
				<</if>>
			<<else>>
				<<set _s = _i>>
				<<run $('#' + _i).addClass("selected")>>
			<</if>>
			<<replace "#status">><<equipmentlist>><</replace>>
		<</link>>
		<</capture>>
		<br/>
		<<for _k, _v range _puppet.stats>>
			<span class="statname"><<print _k>>:</span>
			<<print _puppet.get(_k)>>
			<br/>
		<</for>>
		</div>
	
		<div class="inmenu equipment">
		<<for _k, _v range _puppet.equipment>>
			<div style="display:inline-block">
			_k: <<if _v !== null>>
			<div style="display: inline-block; font-weight: normal">_v.name
			<span style="float:right">
			<<capture _puppet, _k>>
			<<link "[X]">>
				<<run _puppet.unequip(_k)>>
				<<replace "#status">><<equipmentlist>><</replace>>
				<<replace "#puppets">><<include "equip manager puppets">><</replace>>
			<</link>>
			<</capture>>
			</span>
			<br/>
			<span class="actdesc">_v.info</span>
			</div>
			<</if>>
			</div>
			<br/>
		<</for>>
		</div>
	</div>
<</for>>

What I'm trying to do here is: If a character has nothing equipped in a slot, the screen will just show "[Slot]: " with nothing after it. If the slot does have equipment in it, the name is displayed after the colon, the unequip button is printed on the same line, and then the equipment's mechanical effect is printed under it on another line.

However, if I print all of this on a single line, then when I make a line break to display the equipment's effect, that's printed directly under the "[Slot]: " display, which is unclear and looks ugly. I tried to circumvent this by turning everything relating to the equipment into an inline block element; however, that displays the opposite of the way I want, with all other elements aligned to its base rather than its top. Now the equipment's name and effect are aligned with each other, but the "[Slot]: " marker points to the effect rather than the name.

(Additionally, the unequip button doesn't move to the right of the larger "actor" container as I want it to, even when I set the equipment div to width=100%. Is there an intermediate element that's getting in the way?)

I know there are ways to change the alignment of an element to the top rather than the base, but I believe that requires adding a container element and I fear I'm just going to tangle myself up if I don't know what I'm doing. I could also make one block for all the slot listings and another for the equipment display, but that would require running two for loops since I would have to populate the blocks one at a time, which seems like bad coding practice.

How would you suggest formatting this?

(I can send you images on Discord if this is too confusing)

by (44.7k points)
The simplest way is to just do it as a table.  However, you will need to build the table within a string variable, and then print that string, because SugarCube doesn't like printing a "head" element without also printing its matching "tail" element at the same time.
by (870 points)
I thought tables are considered bad practice? I could do a grid instead.
by (44.7k points)
Meh.  If it's the best tool for the job, and it sounds like it is in this case, there's nothing wrong with using it.

Really, it sounds like you want to produce a table of data, so it makes sense to me to use a table for that.
...