Jump to content

Recommended Posts

Posted

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

Posted

i hope to understand this soon ^^ thanks

 

I was really just avoiding this issue altogether but now I say, "let's do this!"

Core I5 2.67 / 16GB RAM / GTX 670

Zbrush/ Blender / Photoshop CS6 / Renoise / Genetica / Leadwerks 3

  • 4 weeks later...
Posted

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

Posted

Thats briljant Andy! I see that this works fine.

 

I wonder how the binary files can be loaded though. I assume Lua can somehow load the binary file an parse it back into a normal Lua for running with 'dofile'.

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.

×
×
  • Create New...