Jump to content

HowTo using LUA script as data file


AndyGFX
 Share

Recommended Posts

Sample data file [game.lua]:


return
{
   pos = {0,1,2},
   name = "player1",
   other =
	{
		items =
			{"item1","item1","item1"}
	}

}


 

 

call in code:

 



GameData = dofile("game.lua")

-- test data

print(GameData.pos[1],GameData.pos[2],GameData.pos[3])
print(GameData.name)
print(GameData.other.items[1])
print(GameData.other.items[2])
print(GameData.other.items[3])


 

Note: When your data are static, then is possible compile file to binary format: luac -o game.data game.lua, but then you don't forget change filename in your code, when output filename isn't same.

[HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64

[sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx

 

76561197970156808.pngAndyGFX.png

Link to comment
Share on other sites

  • 4 weeks later...

of course ;)

 

 

method #1

os.execute("luac -o game.data game.lua")

 

method #2

os.execute("path to bat file, where bat file contains luac ....")

 

EDIT:

 

When you haven't installed full LUA libs for windows, use this link http://code.google.com/p/luaforwindows/downloads/detail?name=LuaForWindows_v5.1.4-37.exe'>http://code.google.com/p/luaforwindows/downloads/detail?name=LuaForWindows_v5.1.4-37.exe from main page: http://code.google.com/p/luaforwindows/

[HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64

[sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx

 

76561197970156808.pngAndyGFX.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...