Mod integration and automation, and data management

Post Reply
loosewheel
Member
Posts: 155
Joined: Mon Dec 28, 2020 01:19
GitHub: loosewheel
In-game: loosewheel

Mod integration and automation, and data management

by loosewheel » Post

Just some thoughts for an implementation to support mod integration and automation, and data management.

Currently the only place to store per item data is in metadata, which is limited and difficult to manage, and prone to causing crashes if its not. This implementation provides for per item data to be stored in the world folder instead, keeping burden on the metadata to a minimum.

There is also not much to properly integrate mods to employ automation. While functions can be constructed to perform most basic operations at a high level, I have not found a universal method to place a node at a specific position without requiring mod specific code.

By providing the set of these high level functions for modders to use, they gain the advantage of being able to perform these basic operations without having to navigate the whole process, and in doing so implement the necessary callbacks for the data management system to work.

Because this requires a systemic influence it would have to be included similar to the builtin code. I have not done this so am speaking from ignorance, but builtin is there so I assume its possible.

The proposal in a nutshell is:

Implemented handlers (callbacks) in definition

on_drop_item (itemstack, dropper, pos)
returns itemstack to drop

on_pickup_item (itemstack, player)
returns itemstack to picked up

on_destroy_item (itemstack)
no return used

on_copy_item (itemstack)
returns copied itemstack - the opportunity to duplicate the data and assign a new data_id

on_place_exact (itemstack, pos, look_dir, pointed_thing, player_name, controls, silent)
returns if placed - true or false

Data management.
minetest.new_data_id ()
minetest.get_datapath (modname)
minetest.serialize_data (modname, data_id, data, context)
minetest.deserialize_data (modname, data_id, context)
minetest.remove_data (modname, data_id, context)

Mod integration and automation.
minetest.destroy_item (itemstack)
minetest.destroy_inventory (inv, listname)
minetest.destroy_node (pos, force, silent, far_node)
minetest.dig_node (pos, toolname, silent, far_node)
minetest.drop_item (itemstack, dropper, pos)
minetest.pickup_item (entity, player, cleanup)
minetest.copy_item (itemstack)
minetest.place_item (itemstack, pos, look_dir, pointed_thing, placer_name, controls, silent)
minetest.can_break_node (pos, toolname)
minetest.get_adjacent_pos (pos, param2, side)


The code is here.

This code has not been run. Some I just wrote and some are snippets of code I’ve used. I’ve provided it for review and discussion.

User avatar
jwmhjwmh
Developer
Posts: 125
Joined: Sun Jul 18, 2021 14:10
GitHub: TurkeyMcMac

Re: Mod integration and automation, and data management

by jwmhjwmh » Post

These look good. You should open an issue or pull request at https://github.com/minetest/minetest.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests