-
Notifications
You must be signed in to change notification settings - Fork 5
API
You can add a custom EMC value to any item by:
- Adding it to
zzzz_exchangeclone_init/base_emc_values.lua
- Adding it to the
exchangeclone.emc_values
table (in the format<itemstring> = value
) - Setting
exchangeclone_custom_emc
in the item/node definition - Setting the metadata field
exchangeclone_emc_value
of an ItemStack.
You can add an EMC 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_emc
in item definition > Lua file/exchangeclone.emc_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 EMC values). If you call minetest.register_craft
, you don't need to call exchangeclone.register_craft
for that same recipe.
exchangeclone.get_emc_value(item)
: Takes an itemstring or itemstack and returns its EMC value (or nil if none/error). It accounts for Star charge and the number of things in an itemstack. For example, exchangeclone.get_emc_value("default:cobble 99")
or exchangeclone.get_emc_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_emc(player)
: Returns the amount of personal EMC a player has (or 0 in the case of an error).
exchangeclone.set_player_emc(player, amount)
: Sets the amount of personal EMC a player has.
exchangeclone.add_player_emc(player, amount)
: Adds to the amount of personal EMC a player has (amount can be negative to subtract).
exchangeclone.get_star_itemstack_emc(itemstack)
: Returns the amount of EMC stored in an Klein/Magnum Star (or nil if the stack is not an Star).
exchangeclone.get_star_emc(inv, listname, index)
: Returns the amount of EMC stored in a Star at a specific inventory position (or nil if the stack is not an Klein/Magnum Star). listname
and index
are "main"
and 1
by default..
exchangeclone.set_star_emc(inv, listname, index, amount)
: Sets the amount of EMC stored in a star 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.