TransWikia.com

Creating a lookup table of datamaps in Harlowe/Twine

Game Development Asked by the_e on January 4, 2021

I’m attempting to procedurally-generate a list of linked Passages in Harlowe 3 and am running into that lovely wall of simplified programming that is presented to the developer. The thing is that I just want to prototype a simple story without converting everything over to Sugarcube/Snowman.

What I am trying to do and am struggling with is figuring out how to generate an Array of Passages and link them together. I am absolutely OK with creating temporary lookup tables to link things together, however I’m struggling with the syntax for it.

My current feeling is that something like this should work, but I can’t wrap my head around the API reference for this kind of activity. The following is a pseudo-code attempt at what I’m trying to accomplish … it doesn’t work straight up but is an amalgamation of what I’ve been trying.

(set: $rooms to (a:))
(set: $num_rooms to range(1,20))
(for: each _iter, $num_rooms)[
  (set: $rooms to $rooms + (a: (dm: "title", "Room " + _iter, "Description", "Room " + _iter + " Description"))))
]

(set: $lookup to (dm:))
(for: each $room, $rooms):
  (for: each $room2, $rooms)):
    (if: $room is not $room2):
      <!-- random chance that it links up, example here to set the 'left' passage -->
      (set: $lookup to $lookup + (dm: "Room1_Left", $room2))      

Then later on, pull up:

[[Go left | $lookup->Room1_Left]]

The issue is that I am struggling with some of the syntax here. The above code doesn’t work for me and I’m struggling with coercing it into the ‘ideal’ format.

If this is completely infeasible then that is fine, but I’m fairly certain I can hack this in with the correct syntax. (Future projects I’d switch over to Sugarcube, but I want to try and give this the old college try before I completely dump it and refactor).

Edit

I got frustrated and switched over to Sugarcube (and 15 minutes into reading documentation/examples I’m already beyond where I got with Harlowe). HOWEVER I’m going to leave this question up for now as I can see it being exceedingly valid for non-programmers to extend their IF games. If a good answer rolls along I’ll try it out in my local project.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP