MCServer Lua implementation
#16
I forgot it's not a good idea to require another plugin directly. But you can still share functions between them if you use them from another lua file used similar as a header file.

If you want to know how to use SQLite with lua and have Lua 5.1 installed on your PC there should be a luasql folder in the lua/5.1/clibs folder. Place the folder luasql with the sqlite3.dll into the main directory of MCServer. I attached an example (sqlite-test.lua) on how to use sqlite3. You can test it with SciTE included with Lua or some similar lua compiler.

There are some issues though. Such as crashing when reloading plugins and an issue with passing a table to Fetch to retrieve an entire row. It would be awesome if FakeTruth includes a wrapper for SQlite in API because the lua version lacks a lot of things like virtual tables and R*Tree implementation (The best way to do area indexing for a cuboid plugin!) And it's a hell of a lot faster then using ini files.

I've also included an example of how to make your plugin using SQLite. With a link containing the sqlite3.dll incase you dont' have it in your lua library.

Just download attached files (TestEconomy1,TestEconomy2 and economy_data_manipulation) and place them in the Plugins folder. Add TestEconomy1 and TestEconomy2 into settings. Put luasql folder into the main MCServer.



Basic use:

TestEconomy2 creates a new database and table that adds a default balance of 300 when a player joins. use /money command to check balance. The check balance function is in economy_data_manipulation

TestEconomy1 is a separate plugin. Does not require sqlite3.dll. But It does need to require economy_data_manipluation. with /addmoney you can add money to your balance and displays the new balance.

The whole point of this example is if another plugin does not use SQlite3 it can require economy_data_manipulation.lua and be able to alter the balance or manipulate the database created by TestEconomy1 without the need to rewrite code or use sqlite3.dll.

This was all tested. If you run into an Issue while testing this, tell me.

Oh and I recommend using SQLite Browser to easily view database files:
http://sqlitebrowser.sourceforge.net/

I suppose you can all do this Flatfile too if you don't use SQLite. Just read from an INI.

Soo....if this isn't what you want to do then I have no idea how you intend on making your plugin. Just trying to help you.
Reply
Thanks given by:


Messages In This Thread
MCServer Lua implementation - by Tybor - 03-02-2011, 04:09 AM
RE: MCServer Lua implementation - by FakeTruth - 03-02-2011, 05:57 AM
RE: MCServer Lua implementation - by Tybor - 03-02-2011, 07:27 AM
RE: MCServer Lua implementation - by FakeTruth - 03-02-2011, 07:25 AM
RE: MCServer Lua implementation - by codename_B - 03-02-2011, 07:48 AM
RE: MCServer Lua implementation - by Tybor - 03-03-2011, 03:01 AM
RE: MCServer Lua implementation - by FakeTruth - 03-03-2011, 07:05 AM
RE: MCServer Lua implementation - by Tybor - 03-04-2011, 03:16 AM
RE: MCServer Lua implementation - by FakeTruth - 03-04-2011, 04:41 AM
RE: MCServer Lua implementation - by Tybor - 03-04-2011, 04:51 AM
RE: MCServer Lua implementation - by Revolucas - 03-04-2011, 08:44 AM
RE: MCServer Lua implementation - by Tybor - 03-05-2011, 03:11 AM
RE: MCServer Lua implementation - by Revolucas - 03-18-2011, 12:46 PM
RE: MCServer Lua implementation - by Tybor - 03-19-2011, 04:13 AM
RE: MCServer Lua implementation - by FakeTruth - 03-04-2011, 10:54 PM
RE: MCServer Lua implementation - by Revolucas - 03-19-2011, 11:05 AM
RE: MCServer Lua implementation - by Tybor - 03-19-2011, 05:48 PM
RE: MCServer Lua implementation - by Revolucas - 03-19-2011, 07:49 PM
RE: MCServer Lua implementation - by Tybor - 03-19-2011, 08:15 PM
RE: MCServer Lua implementation - by FakeTruth - 04-15-2011, 10:21 PM
RE: MCServer Lua implementation - by Megamanx266 - 05-27-2011, 05:39 PM
RE: MCServer Lua implementation - by FakeTruth - 05-27-2011, 11:39 PM
RE: MCServer Lua implementation - by Megamanx266 - 05-28-2011, 05:13 AM
RE: MCServer Lua implementation - by FakeTruth - 05-28-2011, 07:20 AM
RE: MCServer Lua implementation - by Megamanx266 - 05-28-2011, 08:57 AM
RE: MCServer Lua implementation - by FakeTruth - 05-28-2011, 09:17 AM
RE: MCServer Lua implementation - by FakeTruth - 05-29-2011, 01:00 PM



Users browsing this thread: 1 Guest(s)