Discord
Login
Community
DARK THEME

Extarcting a item from a list

I realize to extract an item from a list you

list.0.variable

it will return with the variable of the data but if you use a variable like

list.point.variable

then you will get errors all i need is a way to define point as a variable.

Just use objects! i.e.

fruitColors = object
  apple = "red"
  orange = "orange"
  peach = "pink"
end

You can then get the values inside of them

print(fruitColors.apple) // prints "red"
print(fruitColors["peach"]) // prints "pink"

You can even use variables with the second method :D

fruit = "orange"
print(fruitColors[fruit]) // prints "orange"
fruit = "apple"
print(fruitColors[fruit]) // prints "red"
point = object
   x=1
   y=2
end

list = []
list.push( point )
for item in list 
  print( item )
end

Thanks, very cool. you saved 30 fps

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community