Saturday, May 7, 2011

r639 - Inventory Accessible via Scripting

This update brings inventory accessibility to scripting.

The player gains a new command called getInventory which returns an inventory.

Inventory Commands
getSizeInventory() - How many slots does this inventory have?
getName() - The name of this inventory
getStackLimit() - The max quantity items can have for this inventory
Item getItemInSlot(int slot) - Returns the item in the specified slot
Item decrementItem(int slot, int amount) - Reduces the item in the specified slot by the specified amount and returns back the item.
setSlot(int slot, Item item) - Sets the specified slot to the passed in item.
emptySlot(int slot) - Empties the specified slot of its item.

Player Inventory Commands
int getSlotContainingItem(int itemID) - Returns the first slot containing the specified itemID.
setCurrentItem(int slot) - Sets the slot for the current item
changeCurrentItem(int i) - Changes the current item by the amount specified.
boolean consumeItem(int itemID) - Consumes one item of the specified itemID.  If there isn't any to consume it returns false otherwise true if it succeeded.
boolean consumeItemAmount(int itemID, int damage, int amount) - Consumes the item up to the specified amount if they are available (items must match the same amount of damage).  If there isn't enough to consume it returns false otherwise true if it succeeded.
int getArmorValue() - Returns the player's inventory amount.
dropAllItems() - Drops all the player's items.
Item getCurrentItem() - Returns the current item.
Item getOffhandItem() - Returns the current offhand item
swapOffhandWithMain() - Swaps offhand and main hand.
boolean addItem(Item item) - Adds the passed in item if it can.

Item Commands
setItemID(int itemID)
setQuantity(int i)
setDamage(int i)
Item copy()

New commands are available as well for creatures.

EntityCreature Commands
setTarget(Entity e)
hasPath() - Does this creature have a path set
pathToEntity(Entity e) - Will path to the specified entity
pathToBlock(int x, int y, int z) - Paths to the specified block coordinates

With Maps -
No Maps -


  1. -Speechless outletting of air-

    I... I'm no coder, but I absolutely must learn how to use these...

  2. Oh, on that note, have you considered, at point, creating a sort of basic coding tutorial, just enough so that even non-coders with little to no experience could take advantage of this block as well?

  3. Or at least point us to a site with a good tutorial?

  4. I would love to see a revamp on the Message Block if there's time. Thirty characters is incredibly small -- barely a full sentence.

    What I suggest is not using the default chat pane and instead create a larger area that is centered toward the bottom of the screen (like where the music staff is).

    I'd also love to see messages that pause the game so you can read them (you know, the "Press SPACE to continue..." kind of messages)

    It'll make dialogue a lot easier to incorporate into a game.

  5. Ooo, That's a great suggestion, sivius. I agree, that should definitely be added.

    I'm currently playing a great RPG called Geneforge (5, to be exact..), and god only knows how hard it would be to play this game if you got attacked while reading the message that says something along the lines of "Down the path you see a campsite. Many armored men sit around it. They don't look like Guardians, or rebels. Bandits. If you don't move quickly, they'll probably see you and attack."