enigma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Enigma-devel] Please upgrade to Lua 5


From: Roland Illig
Subject: [Enigma-devel] Please upgrade to Lua 5
Date: Sun, 24 Oct 2004 08:49:49 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041007 Debian/1.7.3-5

Hi,

I would like Lua to be upgraded to version 5 because it allows nicer function closures. The attached example does not work with Lua 4, but with Lua 5.

If you don't have the time for this upgrade I may help you.

Roland
-- uncomment for Lua 4
-- true = (0 == 0)
-- false = not true

onoff = {}
onoff[false] = "off"
onoff[true] = "on"

switches = {}
for y = 0, 4 do
  switches[y] = {}
  for x = 0, 4 do
    switches[y][x] = false
  end -- for
end -- for

function toggle(on, x, y)
  switches[y][x] = on
  print("switch ("..x..","..y..") toggled "..onoff[on]..".")
end -- function

function make_toggle(x, y)
  return function(on)
    return toggle(on, x, y)
  end -- function
end -- function

toggle12 = function(on) toggle(on, 1, 2) end

toggle12(true)
toggle12(false)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]