Author Topic: Taking my hand at Lua  (Read 20859 times)

0 Members and 3 Guests are viewing this topic.

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: Taking my hand at Lua
« Reply #15 on: June 08, 2012, 02:16:04 pm »
It is, but he can use it as a reference once he learns more about how to program.
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline cyanophycean314

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 363
  • Rating: +43/-1
  • It's You!
    • View Profile
Re: Taking my hand at Lua
« Reply #16 on: June 08, 2012, 02:57:26 pm »
This is basically the menu I used in my first few games. You can change it to to be more flexible, and use objects (I don't think you know that yet.)

Code: [Select]
--Menu

function on.paint(gc)
if not init then
x = 25
y = 65
val = 1
end
gc:drawString("Option 1",40,60,"top")
gc:drawString("Option 2",40,75,"top")
gc:drawString("Option 3",40,90,"top")
gc:drawString("Option 4",40,105,"top")
gc:fillRect(x,y,10,10)
end

function on.arrowKey(dir)
--Moves the cursor
if dir == "up" then
y = y - 15
val = val - 1
elseif dir == "down" then
y = y + 15
val = val + 1
end
--Wrap around
if val == 0 then
y = 110
val = 4
elseif val == 5 then
y = 65
val = 1
end
platform.window:invalidate()
end

function on.enterKey()
if val == "whatever you want" then
"DO THIS"
elseif val == "this option" then
"DO THIS"
end
platform.window:invalidate()
end