0 votes
asked by (410 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 by (55.4k points)
selected by
 
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 by (410 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.
...