SexScripts : Multidimensional Array - https://ss.deviatenow.com:443/viewtopic.php?f=4&t=327 Page 1 of 1

Multidimensional Array

Brigadoom [ Sat Aug 03, 2013 3:14 am ]

I have been trying to work out the syntax of multidimensional or nested arrays.

Would you be able to tell me how I define these and call them?

Re: Multidimensional Array

doti [ Sat Aug 03, 2013 10:12 am ]

Multidimensionnal arrays are created as arrays of arrays. See a simple array of strings :
Code:
//create
def tools = ["whip","cane","paddle"]
//replace "cane" with "stick"
tools[1] = "stick"
//get one, the second one
showPopup(tools[1])

//iterate (read all)
for(def tool : tools)
  showPopup(tool)

Now a 2-dimensions array, that is an array of array of strings :
Code:
def tools2 = [["whip","cane","paddle"],["whips","canes","paddles"]]
tools2[0][1] = "stick"
tools2[1][1] = "sticks"
showPopup(tools2[0][1])

//tools2 is an array of array of strings, tools is an array of strings, tool is as string
for(def tools : tools2)
  for(def tool : tools)
    showPopup(tool)

Re: Multidimensional Array

Brigadoom [ Sun Aug 04, 2013 1:38 pm ]

Thank you!

I was defining them correctly but calling them like this: tools2[0,1]

Appreciate the help ;)

Re: Multidimensional Array

Brigadoom [ Sat Aug 10, 2013 3:11 am ]

Fresh multi dimensional array question. How can I call tools2.size to count the main items of an array ie: [[0,0],[1,1],[2,2]] = 3? I keep getting 2.

Re: Multidimensional Array

doti [ Sat Aug 10, 2013 9:00 am ]

Well, I tried the code below, and got 3 :
Code:
def tools2 =  [[0,0],[1,1],[2,2]]
showPopup(tools2.size)

Re: Multidimensional Array

Brigadoom [ Sat Aug 10, 2013 5:01 pm ]

Lovely, thanks for all the help Doti. That is the last thing i need to finish my script. Gonna just do some polishing then I'll upload it.

Re: Multidimensional Array

Brigadoom [ Sun Aug 11, 2013 3:57 am ]

Scratch that, just one more question (columbo style). If I wanted to add additional data lines into a multi-array at a later stage, how would you do it?

Re: Multidimensional Array

doti [ Sun Aug 11, 2013 10:36 am ]

Use .add()
Code:
def tools2 =  [[0,0],[1,1],[2,2]]
tools2.add([3,3])
showPopup(tools2.size) // => 4

Page 1 of 1 All times are UTC + 1 hour [ DST ]
https://ss.deviatenow.com:443/
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010, 2011