Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/resource2/data/lua/LuaStateInit.lua @ 5654

Last change on this file since 5654 was 5654, checked in by rgrieder, 15 years ago
  • Implemented file management via resource manager and loading of resource locations via XML. Changes made:
    • SoundManager loads via memory stream rather than via file
    • Loader uses LuaState::includeFile() to load an XML file and passes the lua tag remover function to its LuaState.
    • ConfigFileManager still loads with hard paths because the files are required before Ogre gets created
  • Renamed LuaBind to LuaState, deSingletonised it and added new features:
    • doFile(), doString(), includeFile(), includeString() where include will preparse the string with a function provided with LuaState::setIncludeParser
    • Moved lua tags replace function to Loader (since it's actually an XML related task)
    • Using data_path/lua/LuaInitScript.lua to provide the following functions
      • logMessage(level, message)
      • doFile, dofile, include (all working with relative paths but within the same resource group)
  • Modified Script class to work with LuaState and fixed its XML Loader
  • Adjusted all level and include files (both "include" and "dofile" lua commands)
  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1-- Note: luaState is a pointer to the LuaState instance that created this lua state
2
3-- Redirect debug to print
4debug = print
5
6-- Redirect print to the C++ print function
7print = function(s)
8  luaState:luaPrint(s)
9end
10
11-- Create function to log text like COUT, but always prints a line!
12logMessage = function(level, message)
13  luaState:luaLog(level, message)
14end
15
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.
21doFile = function(filename, resourceGroup)
22  local bSearchOtherPaths = (resourceGroup == nil) or false
23  resourceGroup = resourceGroup or "NoResourceGroupProvided"
24  luaState:doFile(filename, resourceGroup, bSearchOtherPaths)
25end
26dofile = doFile
27
28-- Create includeFile function that preparses the file according
29-- to a function provided to the LuaState constructor (in C++)
30-- Note: See the same notes as for doFile
31include = function(filename, resourceGroup)
32  local bSearchOtherPaths = (resourceGroup == nil) or false
33  resourceGroup = resourceGroup or "NoResourceGroupProvided"
34  luaState:includeFile(filename, resourceGroup, bSearchOtherPaths)
35end
Note: See TracBrowser for help on using the repository browser.