tipforeveryone Posted March 11, 2018 Share Posted March 11, 2018 I found this topic But is there any detail tutorial (step by step) which show me how to use Database ? Thanks Quote Link to comment Share on other sites More sharing options...
CangoJoe Posted March 11, 2018 Share Posted March 11, 2018 Depending on how much data you plan to handle, have you considered CSV files? It's pretty much a fancy text file that has been formatted with commas. It's kind of a poor mans database solution, but at least you won't need any external libraries or apps to read and write data, plus you can always import the data to a SQL database in the future if need be. There's lots of tutorials and code samples readily available around the web. Quote Link to comment Share on other sites More sharing options...
tipforeveryone Posted March 12, 2018 Author Share Posted March 12, 2018 Thanks, but I mean How to use database in Leadwerks just dont know where to start. I have bunch of weapons and want to store their parameters (rate of fire, model path ...) to a database, any kind of database. Talking about CSV files, how can I use them ? Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted March 12, 2018 Share Posted March 12, 2018 Couldn't you just use a table for your data storage? Quote Link to comment Share on other sites More sharing options...
tipforeveryone Posted March 12, 2018 Author Share Posted March 12, 2018 5 minutes ago, Thirsty Panther said: Couldn't you just use a table for your data storage? yes, I am using table, but in the future my game data will be much more complex . therefore I need a database, this helps me easier to manage data too 1 Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 12, 2018 Share Posted March 12, 2018 Have you tried http://lua.sqlite.org/index.cgi/index ? Quote Link to comment Share on other sites More sharing options...
CangoJoe Posted March 12, 2018 Share Posted March 12, 2018 12 hours ago, tipforeveryone said: Thanks, but I mean How to use database in Leadwerks just dont know where to start. I have bunch of weapons and want to store their parameters (rate of fire, model path ...) to a database, any kind of database. Talking about CSV files, how can I use them ? CSV files are great for small amounts of data, but flexible enough to be used in large games as well. I've seen them used in several major titles - Armed Assault (Operation Flashpoint) used it to contain unit/weapon data among other things. Here's some instructions on how to create a CSV file - it's really easy: https://www.computerhope.com/issues/ch001356.htm And here's a Lua code sample that shows how to insert data from a CSV file into a table and vice-versa: http://nocurve.com/2014/03/05/simple-csv-read-and-write-using-lua/ CSVs make a good stepping stone towards learning and using SQL DBs but, I haven't tried using LUA and SQL together 'yet' to make any good tutorial recommendations. 1 Quote Link to comment Share on other sites More sharing options...
Rick Posted March 12, 2018 Share Posted March 12, 2018 I looked at this for a few mins the other day, since I made the original post, and since that original file isn't in the post (is it anywhere? I can't find it on my side) someone would have to create this DLL again. Once that's done it's really easy to work with if you have sql experience. Using a database is generally just easier (once it's setup) if you're doing a lot of querying, updating, & inserting but this sounds like you just need a config file that has a nice editor. I have a json library I got from somewhere that turns lua tables into json and the other way around too, plus I know there are a bunch of json editors out there that give a nice tool for visually working with that data. Perhaps that would be helpful? 1 Quote Link to comment Share on other sites More sharing options...
wayneg Posted April 17, 2018 Share Posted April 17, 2018 would this be the right path to success? Get Sqlite3 here: https://www.sqlite.org/download.html Get DLL here: https://www.dll-files.com/lua5.1.dll.html Rename Lua5.1.dll to sqlite3.dll regsvr32 C:\Windows\System32\sqlite3.dll Directory of C:\Temp <DIR> luasql lua5.1.exe sqlite3.dll hello.lua require "luasql.sqlite3" env = luasql.sqlite3() conn = env:connect("test.sqlite") assert(conn:execute("create table if not exists tbl1(one varchar(10), two smallint)")) assert(conn:execute("insert into tbl1 values('hello!',10)")) assert(conn:execute("insert into tbl1 values('goodbye',20)")) cursor = assert(conn:execute("select * from tbl1")) row = {} while cursor:fetch(row) do print(table.concat(row, '|')) end cursor:close() conn:close() env:close() Quote Link to comment Share on other sites More sharing options...
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.