Howdy, Stranger!

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

if with set in HARLOWE

Hi I have a problem
I have two images

(set:$chestImage to ' ')
(set: $x to 5)
(click: '<img src="icons/avatar/male/male1.png">')[(set: $x to 1)]
(click: '<img src="icons/avatar/female/female1.png">')[(set: $x to 0)]

(if: $x is 1){(set: $chestImage to '<img src="icons/avatar/male/male1.png">')}

(else-if: $x is 0){(set: $chestImage to '<img src="icons/avatar/female/female1.png">')}

I want that when I click img male it puts set x to 1 and then chestImage to the src
and the same with the female image

this is for a character selection.


  • edited February 2017
    The biggest problem with your code is one of timing. The (if:) macros execute when the passage is first displayed. Interactive macros—e.g. (click:) and (link:)—are only executed when the player interacts with them. This means that by the time the player is able to click on either of your interactive macros to activate them, any (if:) macros within the same passage have already been executed. The solution is to put all of the modifications within the hooks of the interactive macros.

    I believe something like the following will do what you want:
    	(set: $chestImage to '')
    	(set: $x to 5)
    (link: '<img src="icons/avatar/male/male1.png">')[{
    	(set: $x to 1)
    	(set: $chestImage to '<img src="icons/avatar/male/male1.png">')
    	(goto: "NEXT")
    (link: '<img src="icons/avatar/female/female1.png">')[{
    	(set: $x to 0)
    	(set: $chestImage to '<img src="icons/avatar/female/female1.png">')
    	(goto: "NEXT")
  • it works :smiley: A lot of thanks :smiley: !!!!!!
Sign In or Register to comment.