Please specify version and format if asking for help, or apply optional tags above:
Twine Version: Twine 2
Story Format: Sugarcube 2.34.1
Hi!
I just started out and as such first played around with the twine default, Harlowe. Now I want to transfer my work into Sugarcube and everything’s going fine except when I wanted to transfer my Quest Journal system.
In Harlowe I have this.
(set: $quest1 to (dm:
'Name', 'Princess in Trouble',
'Description', 'The dragon has kidnapped the princess, the kingdom needs their hero!',
'Objective', 'Save the princess',
'Reward' , '$10 000 000'))
(set:$quest2 to (dm:
'Name', 'Terrible Dragon',
'Description', 'The dragon has kidnapped the princess, the kingdom needs their hero!', 'Objective',
'Kill the dragon',
'Reward', '$1 000 000'))
(set: $quest to (a: "(link-repeat: 'quest1')[(replace: ?display)[(print: $quest1)]]", "(link-repeat: 'quest2')[(replace: ?display)[(print: $quest2)]]"))
(align:"=><=")+(box:"X")[(text-style:"bold","emboss","expand")[Quest Journal]]
(if: $quest's length > 0)[\
(for: each _index, ...(range: 1, $quest's length))[(print: $quest's (_index))<br>]
]
|display>[
Description: This is the description
Objective: This is the objective
Reward: This is the reward]
It worked perfectly, except when I transferred the code into sugarcube I realised the two formats print their datamaps differently, while in Harlowe it was in a nice column format, Sugarcube used arrows and commas which looked bad, so I changed the code to this:
<<silently>><<set $quest1 to {
Name: 'Princess in Trouble',
Description: 'The dragon has kidnapped the princess, the kingdom needs their hero!',
Objective: 'Save the princess',
Reward: '$10 000 000'
}>>
<<set $quest2 to {
Name: 'Terrible Dragon',
Description: 'The dragon has kidnapped the princess, the kingdom needs you hero!',
Objective: 'Kill the dragon',
Reward: '$1 000 000'
}>>
<<set $quest to [
"<<link 'quest1'>><<replace #des>><<=$quest1.Description>><</replace>><<replace #obj>><<=$quest1.Objective>><</replace>><<replace #rew>><<=$quest1.Reward>><</replace>><</link>>", "<<link 'quest2'>><<replace #des>><<=$quest2.Description>><</replace>><<replace #obj>><<=$quest2.Objective>><</replace>><<replace #rew>><<=$quest2.Reward>><</replace>><</link>>"]>>
<</silently>><h1 class="quest">Quest Journal</h1>
<<if $quest.length > 0 >>
<<for _i to 0; _i lt $quest.length; _i++>><<print $quest[_i]>><</for>>
<</if>>
Description: @@#des;This is the description@@
Objective: @@#obj;This is the objective@@
Reward: @@#rew;This is the Reward@@
Which works fine but you’ll notice that the array looks ugly and is even more difficult to type out. I want to ask if there’s a better way to do this or if not, how could I make a widget to help things along?
Thanks!