AndyGFX Posted April 30, 2010 Posted April 30, 2010 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. Quote [HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64 [sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx
diedir Posted April 30, 2010 Posted April 30, 2010 waouh ! so clever and usefull !! many thanks Andy i always search for as simple tables Quote AMD Ryzen 5900HX - Nvidia RTX 3070 - 32 Go - 1To SSD - W11
Pancakes Posted April 30, 2010 Posted April 30, 2010 i hope to understand this soon ^^ thanks I was really just avoiding this issue altogether but now I say, "let's do this!" Quote Core I5 2.67 / 16GB RAM / GTX 670 Zbrush/ Blender / Photoshop CS6 / Renoise / Genetica / Leadwerks 3
flachdrache Posted May 1, 2010 Posted May 1, 2010 Yeah, one of my projects "might" incorporate Lua exclusively and handling its datastructures is something i have to do "next". Thx for the heads up. Quote AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3 zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5 Xxploration FPS in progress ...
AggrorJorn Posted May 29, 2010 Posted May 29, 2010 Can you run this from script? luac -o game.data game.lua Because my program doesn't accept that. Quote
AndyGFX Posted May 29, 2010 Author Posted May 29, 2010 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/ Quote [HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64 [sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx
AggrorJorn Posted May 30, 2010 Posted May 30, 2010 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'. Quote
Recommended Posts
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.