-
Notifications
You must be signed in to change notification settings - Fork 5
API
You can add a custom energy value to any item by:
- Adding it to
exchangeclone/energy_values.lua - Adding it to the
exchangeclone.energy_valuestable (in the format<itemstring> = value) - Setting
exchangeclone_custom_energyin the item/node definition - Setting the metadata field
exchangeclone_energy_valueof an ItemStack.
You can add an energy value for a group by adding {<groupname>, <value>} to exchangeclone.group_values or the Lua file mentioned above. Groups added later have a higher priority.
The priority is: metadata > exchangeclone_custom_energy > Lua file/exchangeclone.energy_values > group values > crafting recipes
See zzzz_exchangeclone_init/lib.lua for a disorganized list of a ton of functions used in ExchangeClone with very minor documentation. It's basically everything that doesn't belong anywhere else.
exchangeclone.register_craft(data): Takes the same parameters as minetest.register_craft, but doesn't actually register a crafting recipe (instead, it adds it to a list of recipes used to calculate automatic recipes). If you call minetest.register_craft, you don't need to call exchangeclone.register_craft for that same recipe.
exchangeclone.get_energy_value(item): Takes an itemstring or itemstack and returns its energy value (or nil if none/error). It accounts for Exchange Orb charge and the number of things in an itemstack. For example, exchangeclone.get_energy_value("default:cobble 99") or exchangeclone.get_energy_value(ItemStack("default:cobble 99")) would both return 99. It also supports "group:foo" syntax, but it goes through the entire list of items, which could cause significant lag, if it is used too frequently.
exchangeclone.get_player_energy(player): Returns the amount of personal energy a player has (or 0 in the case of an error).
exchangeclone.set_player_energy(player, amount): Sets the amount of personal energy a player has.
exchangeclone.add_player_energy(player, amount): Adds to the amount of personal energy a player has (amount can be negative to subtract).
exchangeclone.get_orb_itemstack_energy(itemstack): Returns the amount of energy stored in an orb (or nil if the stack is not an orb).
exchangeclone.get_orb_energy(inv, listname, index): Returns the amount of energy stored in an orb at a specific inventory position (or nil if the stack is not an orb). listname and index are "main" and 1 by default..
exchangeclone.set_orb_energy(inv, listname, index, amount): Sets the amount of energy stored in an orb at a specific inventory position. listname and index are "main" and 1 by default.
There are tons of other functions that could be useful. I'm not going to compile a list at the moment, so search the ExchangeClone folder for function exchangeclone. to find them.
I may eventually make better documentation, but it would take a lot of time I could spend actually making the mod.