[Orxonox-commit 1954] r6671 - in code/branches/gamestates2/data: gui/scripts lua
rgrieder at orxonox.net
rgrieder at orxonox.net
Thu Apr 1 13:52:24 CEST 2010
Author: rgrieder
Date: 2010-04-01 13:52:24 +0200 (Thu, 01 Apr 2010)
New Revision: 6671
Added:
code/branches/gamestates2/data/lua/Tools.lua
Modified:
code/branches/gamestates2/data/gui/scripts/InitialiseGUI.lua
Log:
Added Tools.lua and moved 'find' in InitialiseGUI.lua to 'table.findIndex' in Tools.lua.
Modified: code/branches/gamestates2/data/gui/scripts/InitialiseGUI.lua
===================================================================
--- code/branches/gamestates2/data/gui/scripts/InitialiseGUI.lua 2010-04-01 11:46:53 UTC (rev 6670)
+++ code/branches/gamestates2/data/gui/scripts/InitialiseGUI.lua 2010-04-01 11:52:24 UTC (rev 6671)
@@ -73,16 +73,7 @@
end
end
-local function find(table, value)
- for i, v in ipairs(table) do
- if v == value then
- return i
- end
- end
- return nil
-end
-
------------------------
--- Global functions ---
------------------------
@@ -193,7 +184,7 @@
-- Remove sheet with its tuple from the table
root:removeChildWindow(sheetTuple.menuSheet.window)
- table.remove(activeMenuSheets, find(activeMenuSheets, sheetTuple))
+ table.remove(activeMenuSheets, table.findIndex(activeMenuSheets, sheetTuple))
activeMenuSheets[name] = nil
activeMenuSheets.size = activeMenuSheets.size - 1
activeMenuSheets.topSheet = activeMenuSheets[activeMenuSheets.size]
Added: code/branches/gamestates2/data/lua/Tools.lua
===================================================================
--- code/branches/gamestates2/data/lua/Tools.lua (rev 0)
+++ code/branches/gamestates2/data/lua/Tools.lua 2010-04-01 11:52:24 UTC (rev 6671)
@@ -0,0 +1,17 @@
+function handleDefArg(argument, defaultValue)
+ if argument == nil then
+ return defaultValue
+ else
+ return argument
+ end
+end
+
+function table.findIndex(table, value)
+ for i, v in ipairs(table) do
+ if v == value then
+ return i
+ end
+ end
+ return 0
+end
+
Property changes on: code/branches/gamestates2/data/lua/Tools.lua
___________________________________________________________________
Added: svn:eol-style
+ native
More information about the Orxonox-commit
mailing list