0 votes
by (470 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
by (68.6k 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.

by (470 points)
ah you right, sorry for my mindless question
...