includesAny in IF

0 votes
asked Nov 10 by acki (240 points)

Hello. Have some trouble with <Array>.includesAny. 

StoryInit

<<set $eye to {
	"left": 1,
	"right": 2
}>>

widget

<<widget "eye_view_l">>\
	<<if $eye.left.includesAny("голуб", "красн")>>\
        <<print $eye.left.random()>>ой\
	<<elseif $eye.left.includesAny("зелен", "розов")>>\
		<<print $eye.left.random()>>ый\
	<</if>>\
<</widget>>\

Set eye colors

<<link "Зеленый">><<set $eye.left to "зелен">><<refresh>><</link>>
<<link "Голубой">><<set $eye.left to "голуб">><<refresh>><</link>>

But widget in text gives me that

Error: <<eye_view_l>>: error within widget contents (Error: <<if>>: bad conditional expression in <<if>> clause: State.variables.eye.left.includesAny is not a function)

why?

1 Answer

+1 vote
answered Nov 10 by TheMadExile (17,510 points)
selected 5 days ago by acki
 
Best answer
<<set $eye to {
	"left": 1,
	"right": 2
}>>

In what you've shown, you're setting both $eye.left and $eye.right up as numbers, not arrays.

commented 5 days ago by acki (240 points)
ah you right, sorry for my mindless question
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...