Howdy, Stranger!

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

[Harlowe] Setting Datamap's Property to Another in Same Datamap

When initializing datamaps in Harlowe, how can I set one property to the value of another in the same datamap?

Right now, the first property's value is random, and the second property is set to zero, but I'd rather it be set to the first property's value. I just use the (set:) macro afterwards.

For example:
(set: $player to 
	(datamap:
    "STR", "(random: 17, 21)",
    "AGI", "(random: 15, 18)",
    "maxHP", "(random: 59, 68)",
    "HP", 0,
    "maxMP", "(random: 28, 33)",
    "MP", 0,
    "gold", 0,
    "exp", 0,
    "level", 1))

How can I set $player's HP to $player's max HP? As you can see, $player's maxHP is random, so I'm not sure if it's possible or not.

Thanks!

Comments

  • Currently you have the "maxMP" attribute storing a macro call "(random: 28, 33)" instead of the result of calling the macro (random: 28, 33), this means that every time you reference the "maxMP" attribute you will possible get a different answer.
    a: (print: $player's maxHP)
    b: (print: $player's maxHP) <-- most like different to a:
    c: (print: $player's maxHP) <-- most like different to a: and b:
    

    If you want the relevant $player attributes to contain random generated numerical values then just remove the double quotes, and then use a normal (set:) to assign HP a value.
    (set: $player to 
    	(datamap:
        "STR", (random: 17, 21),
        "AGI", (random: 15, 18),
        "maxHP", (random: 59, 68),
        "HP", 0,
        "maxMP", (random: 28, 33),
        "MP", 0,
        "gold", 0,
        "exp", 0,
        "level", 1))
    
    (set: $player's HP to $player's maxHP)
    HP: (print: $player's HP)
    

    If you want relevant $player attributes to contain macro calls then I don't know of a way to make the two attributes contain the same numerical value.
  • Yeah, I noticed I put quotes around that in my post. Duh.

    Okay, I didn't think there was a way to set one property to another.

    Thanks!
Sign In or Register to comment.