Hello everyone,
I'm working on a project to synchronise player inventories in Minetest with the Dolibarr ERP system. The aim is to allow each player to view and manage their inventory directly from Dolibarr, using CSV files to communicate between the two systems.
So far, I've managed to create CSV files from MineTest using a Lua mod. And from Dolibarr I can read CSV files from a local location and save them to the SQL database. However, I'm having trouble establishing a reliable connection between Minetest and Dolibarr. It seems that I need to install LuaSocket to make HTTP requests, which I can't do.
I downloaded LuaSocket here (https://github.com/rjpcomputing/luaforwindows/releases) and extracted the core.ddl, socket.lua, socket.http files and added them to MineTest/lua but I don't think that's enough.z
I'm on Windows.
Thank you
Synchronizing Minetest Player Inventory with Dolibarr ERP
- LMD
- Member
- Posts: 1477
- Joined: Sat Apr 08, 2017 08:16
- GitHub: appgurueu
- IRC: appguru[eu]
- In-game: LMD
- Location: Germany
- Contact:
Re: Synchronizing Minetest Player Inventory with Dolibarr ERP
There is no need to install luasocket to make HTTP requests; Minetest has its own APIs for that: http://api.minetest.net/minetest-namesp ... p-requests
Re: Synchronizing Minetest Player Inventory with Dolibarr ERP
Thanks you !
local http_api = minetest.request_http_api()
local function export_inventory_to_dolibarr(player)
// ...
http_api.fetch({
url = "http://localhost/dolibarr/api/index.php ... tinventory",
method = "POST",
timeout = 10,
data = minetest.write_json(data),
rawdata = true,
headers = {
["Content-Type"] = "application/json"
}
}
// ...
}
local http_api = minetest.request_http_api()
local function export_inventory_to_dolibarr(player)
// ...
http_api.fetch({
url = "http://localhost/dolibarr/api/index.php ... tinventory",
method = "POST",
timeout = 10,
data = minetest.write_json(data),
rawdata = true,
headers = {
["Content-Type"] = "application/json"
}
}
// ...
}
Re: Synchronizing Minetest Player Inventory with Dolibarr ERP
Is it possible for Minetest to receive incoming HTTP requests from Dolibarr?
If not, what would be a better approach to update inventories from an external system?
Thanks
If not, what would be a better approach to update inventories from an external system?
Thanks
- LMD
- Member
- Posts: 1477
- Joined: Sat Apr 08, 2017 08:16
- GitHub: appgurueu
- IRC: appguru[eu]
- In-game: LMD
- Location: Germany
- Contact:
Re: Synchronizing Minetest Player Inventory with Dolibarr ERP
No, you can only make outgoing HTTP requests. But that isn't really a problem since you can just switch from listening for events to polling a server (your own application server, probably) for events.