includesAny in IF

0 votes
asked Nov 10, 2017 by acki (390 points)

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


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


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

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)


1 Answer

+1 vote
answered Nov 10, 2017 by TheMadExile (50,230 points)
selected Nov 13, 2017 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 Nov 13, 2017 by acki (390 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.