Changeset 6417 for code/trunk/data/lua
- Timestamp:
- Dec 25, 2009, 10:23:58 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/data/lua/LuaStateInit.lua
r5695 r6417 15 15 16 16 -- Redirect dofile in order to load with the resource manager 17 -- Note: The function does not behave exactly like LuaState::doFile because the 18 -- default argument here for the group is not "General" but 19 -- "NoResourceGroupProvided". This resolves to the resource group used to 20 -- do the current file. 21 doFile = function(filename, resourceGroup) 22 local bSearchOtherPaths = (resourceGroup == nil) or false 23 resourceGroup = resourceGroup or "NoResourceGroupProvided" 24 luaState:doFile(filename, resourceGroup, bSearchOtherPaths) 17 doFile = function(filename) 18 luaState:doFile(filename) 25 19 -- Required because the C++ function cannot return whatever might be on the stack 26 return LuaStateReturnValue 20 return LuaStateReturnValue -- C-injected global variable 27 21 end 28 22 original_dofile = dofile … … 31 25 -- Create includeFile function that preparses the file according 32 26 -- to a function provided to the LuaState constructor (in C++) 33 -- Note: See the same notes as for doFile 34 include = function(filename, resourceGroup) 35 local bSearchOtherPaths = (resourceGroup == nil) or false 36 resourceGroup = resourceGroup or "NoResourceGroupProvided" 37 luaState:includeFile(filename, resourceGroup, bSearchOtherPaths) 27 include = function(filename) 28 luaState:includeFile(filename) 38 29 -- Required because the C++ function cannot return whatever might be on the stack 39 return LuaStateReturnValue 30 return LuaStateReturnValue -- C-injected global variable 40 31 end 41 32 42 33 -- Replace require function with almost similar behaviour 43 -- The difference is that you need to provide a resource group 44 -- Default value there is the current one (if present) or else "General" 45 -- But the loaded modules are then stored with only with the name (where name has no .lua extension) 46 -- CAUTION: That also means that you need to take care of conflicting filenames among groups 47 -- Furthermore the moduleName parameters is appended with the .lua extension when looking for the file 34 -- The loaded modules are then stored with their names (where name has no .lua extension) 35 -- Furthermore the ".lua" extension is appended to the moduleName parameter when looking for the file 48 36 old_require = require 49 require = function(moduleName, resourceGroup) 50 local bSearchOtherPaths = (resourceGroup == nil) or false 51 resourceGroup = resourceGroup or "NoResourceGroupProvided" 52 if not luaState:fileExists(moduleName .. ".lua", resourceGroup, bSearchOtherPaths) then 37 require = function(moduleName) 38 if not luaState:fileExists(moduleName .. ".lua") then 53 39 return nil 54 40 end … … 60 46 _REQUIREDNAME_OLD = _REQUIREDNAME 61 47 _REQUIREDNAME = moduleName 62 luaState:doFile(moduleName .. ".lua" , resourceGroup, bSearchOtherPaths)48 luaState:doFile(moduleName .. ".lua") 63 49 _LOADED[moduleName] = LuaStateReturnValue or true 64 50 -- restore old value … … 67 53 return _LOADED[moduleName] 68 54 end 55 56 -- Convenience function for console commands 57 orxonox.execute = function(command) 58 orxonox.CommandExecutor:execute(command) 59 end
Note: See TracChangeset
for help on using the changeset viewer.