Synchronizing Minetest Player Inventory with Dolibarr ERP

Post Reply
DoliMine
New member
Posts: 4
Joined: Fri Oct 04, 2024 12:17

Synchronizing Minetest Player Inventory with Dolibarr ERP

by DoliMine » Post

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

User avatar
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

by LMD » Post

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
My stuff: Projects - Mods - Website

DoliMine
New member
Posts: 4
Joined: Fri Oct 04, 2024 12:17

Re: Synchronizing Minetest Player Inventory with Dolibarr ERP

by DoliMine » Post

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"
}
}
// ...
}

DoliMine
New member
Posts: 4
Joined: Fri Oct 04, 2024 12:17

Re: Synchronizing Minetest Player Inventory with Dolibarr ERP

by DoliMine » Post

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

User avatar
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

by LMD » Post

DoliMine wrote:
Sun Oct 06, 2024 18:15
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
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.
My stuff: Projects - Mods - Website

Post Reply