Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

Get position of the element of the array (SugarCube)

$
0
0
How to get position of the element of the array and put it in a variable when you press the button?

So, we have an array with objects inside. Just for example:

screen1.PNG

Here is the code to display this array (objects set previously, of course):
<<for $y = 0; $y < $moduleArray.length; $y++>>		
	<<for $x = 0; $x < $moduleArray[$y].length; $x++>>		
		
		
		<<set $moduleArray[$y][$x].xy = ($y + ',' + $x)>>	
	

		<<button "<<= $moduleArray[$y][$x].xy>>" >> 		
			
					
			<<set $currentPosition.xy = $moduleArray[$y][$x].xy>> <-This, of course, does not work. The question how to make so that worked.
		
					
			<<script>>		
		
			Dialog.setup("Module", "module");
                        Dialog.wiki(Story.get("modCreate").processText());
			Dialog.open(null, function() { Engine.show() } ); 
	
			<</script>>
			

		<</button>>
		
		

	<</for>>
	<<= "<br><br>">>
<</for>>


p.s. I apologize for my English

Viewing all articles
Browse latest Browse all 1844

Trending Articles