Skip to content
ThePython edited this page Nov 19, 2023 · 7 revisions

API

You can add a custom energy value to any item by:

  • Adding it to _exchangeclone_energy/energy_values.lua
  • Adding it to the exchangeclone.energy_values table (in the format <itemstring> = value)
  • Setting exchangeclone_custom_energy in the item/node definition
  • Setting the metadata field exchangeclone_energy_value of 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

See 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.

A few specific functions that are likely to be frequently used:

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 if it is used too frequently.

exchangeclone.get_player_energy(player): Returns the amount of personal energy a player has (or 0 if 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 (nil if not orb).

exchangeclone.get_orb_energy(inv, listname, index): Returns the amount of energy stored in an orb at a specific inventory position (nil if not orb). listname and index are "main" and 1 by default..

exchangeclone.get_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 several 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 adding features.

Clone this wiki locally