Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Map Array

Hi

I'm trying to create a simple map in Twine 2 Harlowe, however I am having difficulty (because i'm not very good at this). I'm trying to use (altering) Dan Cox method from Sugarcube to no avail. This is what i've done, trying different syntax.

Map system
(display: "Location")
(if: $mapArray($positionY-1 and $positionX) is 1)[
North]

(else-if: $mapArray[$positionY][$positionX+1] is 1)[
East]

(else-if: $mapArray(($positionY+1)($positionX)) = 1)[
South]

(else-if: $mapArray(($positionY)($positionX-1) = 1))[
West]


My array comes from here:
(set: $maparray to (array:
(0,0,0,0,0),
(0,1,1,0,0),
(0,1,0,1,0),
(0,0,1,1,0),
(0,1,1,2,0)))

(set: $positionX to 1)
(set: $positionY to 1)


Thoughts?

Comments

  • Please use the C button in the comment field's tool-bar to wrap your code examples with code markup, it makes them easier to find and read.

    The following is a corrected version of your example, with shorten variable names.
    (set: $x to 2)
    (set: $y to 2)
    
    (set: $map to (array:
    	(array: 0,0,0,0,0),
    	(array: 0,1,1,0,0),
    	(array: 0,1,0,1,0),
    	(array: 0,0,1,1,0),
    	(array: 0,1,1,2,0)
    ))
    
    (display: "Location")
    (if: $map's ($y - 1)'s ($x) is 1)[ [[North]]]
    (if: $map's ($y)'s ($x + 1) is 1)[ [[East]]]
    (if: $map's ($y + 1)'s ($x) is 1)[ [[South]]]
    (if: $map's ($y)'s ($x - 1) is 1)[ [[West]]]
    
    note: One difference between the arrays used in SugarCube and those used in Harlowe is that in SC the first element in an array has an index of zero (0), where as in H the first element has an index of one (1).
  • Cheers bud. Didn't know about the C button. I see it now. I'm a n00b from n00b Central. Population = 1. So if I was to write a macro to say that (in code markup)
    (set: $n00b to 1)
    
    ;-) Thanks for the quick reply.
Sign In or Register to comment.