Howdy, Stranger!

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

How am I supposed to store stats in Datamaps with Harlowe?

For example, I would like to say that the character has a squash with a rating of 2 stars, a pumpkin of 4 stars and a watermelon of 3.4 stars while their rival has a squash with a rating of 4.64 stars, a watermelon of 3 stars and a pumpkin of 5 stars, however, the guide is unclear on how you're supposed to make datamaps and how you're supposed to use them to store stats.

Comments

  • Try the following, it implements your request of two variables ($character and $rival) with the attributes mentioned.
    {
    (set: $character to (datamap: "squash", 2, "pumpkin", 4, "watermelon", 3.4))
    
    (set: $rival to (datamap: "squash", 4.64, "watermelon", 3,"pumpkin", 5))
    
    }Printout the variable's values...
    
    ''character:''
    squash (print: $character's squash) stars
    pumpkin (print: $character's pumpkin) stars
    watermelon (print: $character's watermelon) stars
    
    ''rival:''
    squash (print: $rival's squash) stars
    pumpkin (print: $rival's pumpkin) stars
    watermelon (print: $rival's watermelon) stars
    
    ... as you can see you assign the output of the (datamap:) macro to a variable using a (set:) macro.

    note: normally you could use the (print:) macro to output the contents of a datamap variable but that does not currently work due to a but in Harlowe 1.2.1
  • edited December 2015
    By "guide", are you referring to the official Harlowe docs (on the (datamap:) macro)?

    Setting the datamaps could be done like so:
    {
    (set: $your to (datamap:
    	"squash",     2,
    	"pumpkin",    4,
    	"watermelon", 3.4
    ))
    (set: $rival to (datamap:
    	"squash",     4.64,
    	"pumpkin",    5,
    	"watermelon", 3
    ))
    }
    

    Changing individual values:
    {
    (set: $your's squash to 5)
    (set: $rival's pumpkin to 4.5)
    }
    

    Printing the datamaps out:
    Your stats
    * Squash: (print: $your's squash) stars
    * Pumpkin: (print: $your's pumpkin) stars
    * Watermelon: (print: $your's watermelon) stars
    
    Rival's stats
    * Squash: (print: $rival's squash) stars
    * Pumpkin: (print: $rival's pumpkin) stars
    * Watermelon: (print: $rival's watermelon) stars
    
  • Would this also allow for text to be stored as variables in the same way?
  • The Example usage included in the (datamap:) documentation shows it being used for String (text) values.
Sign In or Register to comment.