0 votes
by (710 points)

Hello,

I am trying to have a link change dynamically when the player selects an option from a dropdown menu. So if the player selects "shake hand", the link would also display "shake hand". I am using ChapelR's dialog macro (https://github.com/ChapelR/custom-macros-for-sugarcube-2/blob/master/scripts/dialog-api-macro-set.js).

<<link 'Interact with John'>>
	<<dialog 'Action'>>
		<<dropdown '$action' 'greet' 'shake hand'>>
		<<link '$action'>>
			<<if $action is 'greet'>>
				<<dialog 'Greet'>>
					You greet John.
				<</dialog>>
			<<elseif $action is "shake hand">>
				<<dialog 'Shake Hands'>>
					You shake John's hand.
				<</dialog>>
			<</if>>
		<</link>>
	<</dialog>>
<</link>>

 

1 Answer

+1 vote
by (550 points)
selected by
 
Best answer

ChapelR says to use the built in <<listbox>> on this Github page.

Now then to actually answer your question I can not find a way to update the link but I did create this workaround where the link has a generalized term such as interact.

<<dialog 'Action'>>
  <<listbox "$action">>
	  <<option "Greet" "greet" selected>>
	  <<option "Shake hand" "shake hand">>
  <</listbox>>
  <<link Interact>>
	  <<if $action is "greet">>
		  <<dialog 'Greet'>>
			  You greet John.
		  <</dialog>>
	  <<elseif $action is "shake hand">>
		  <<dialog 'Shake Hands'>>
			  You shake John's hand.
		  <</dialog>>
	  <</if>>
  <</link>>
<</dialog>>

 

...