Skip to content
ItsClonkAndre edited this page Dec 13, 2024 · 2 revisions

Welcome to the Pack & Carry wiki!
Learn which IV-SDK .NET script commands this mod has to offer, and how you can use them!

Index

  • How to use the script commands
    • Example script
    • Adding a new item to the inventory
    • Subscribing to an item on-click event
  • Available Commands
    • Inventory Commands
    • Item Commands
    • Tag Commands
    • Popup Item Commands
    • Icon Commands
    • Tooltip Commands
    • Flag Commands
  • Available Event Commands
    • What are those?
    • All Commands

How to use the script commands

Example script

Check out the PACApiTest script, to see how you can use the script commands.

Adding a new item to the inventory

Adding a new item is pretty simple.
First, we need to get the ID of the player inventory using the "GET_PLAYER_INVENTORY_ID" command.

private Guid playerInventoryID;

void Test()
{
	if (SendScriptCommand("PackAndCarry", "GET_PLAYER_INVENTORY_ID", null, out object result))
	{
		playerInventoryID = (Guid)result;
	}
}

After we got the ID of the player inventory, we can start adding stuff to it!

private Guid playerInventoryID;
private Guid addedItemID;

void Test()
{
object[] args = new object[] { playerInventoryID, 1234u, "Center Text", "Top Left Text", "Top Right Text", "Bottom Left Text", "Bottom Right Text" };
    if (SendScriptCommand("PackAndCarry", "ADD_NEW_ITEM_TO_INVENTORY", args, out object result))
    {
        addedItemID = (Guid)result;
    }
}

And that's it...

Subscribing to an item on-click event

After we added an item to the inventory, how do we know if the item was clicked?
We have more script commands for that!
Let's use the "SUBSCRIBE_TO_ON_ITEM_CLICK_EVENT_FOR_ITEM" command for that.

private Guid playerInventoryID;
private Guid addedItemID;

void Test()
{
    if (SendScriptCommand("PackAndCarry", "SUBSCRIBE_TO_ON_ITEM_CLICK_EVENT_FOR_ITEM", new object[] { playerInventoryID, addedItemID }, out object result))
    {
        bool didSubscribe = Convert.ToBoolean(result);
    }
}

Now, your script will receive a "PAC_ON_ITEM_CLICKED" script command everytime the item was clicked on.

private object Main_ScriptCommandReceived(Script fromScript, object[] args, string command)
{
    if (command == "PAC_ON_ITEM_CLICKED")
    {
	    // Get the arguments from the array
	    Guid inventoryId = (Guid)args[0];
        Guid itemId = (Guid)args[1];
        int itemIndex = (int)args[2];
	    
	    // Do stuff with them...
    }
}

Pretty simple!

Available Commands

Inventory Commands

  • GET_PLAYER_INVENTORY_ID

    • Required Arguments: None.
    • Returns: A Guid which is the players inventory ID.
  • GET_AMOUNT_OF_FREE_SLOTS_IN_INVENTORY

    • Required Arguments:
      • Guid: The target inventory ID.
    • Returns: An integer which holds the amount of free inventory slots.

Item Commands

  • ADD_NEW_ITEM_TO_INVENTORY

    • Required Arguments:
      • Guid: The target inventory ID.
      • uint: The custom hash for this item.
      • string: The button text for this item (Shows up in the center of the item).
      • string: The text in the top-left corner of the item.
      • string: The text in the top-right corner of the item.
      • string: The text in the bottom-left corner of the item.
      • string: The text in the bottom-right corner of the item.
    • Returns: A Guid which is the ID of the newly added inventory item.
  • REMOVE_ITEM_FROM_INVENTORY

    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
    • Returns: A boolean which indicates if the item was successfully removed from the target inventory.
  • DOES_ITEM_EXISTS_IN_INVENTORY

    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
    • Returns: A boolean which indicates if the item exists in the target inventory.

Tag Commands

  • ADD_TAG_TO_ITEM

    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
      • string: The tag to add to the target item.
      • object: A custom object to store in the tag (Can be null).
    • Returns: A boolean which indicates if the tag was added in the target item.
  • REMOVE_TAG_FROM_ITEM

    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
      • string: The tag to remove from the target item.
    • Returns: A boolean which indicates if the tag was removed from the target item.
  • DOES_ITEM_HAVE_TAG

    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
      • string: The tag to check for.
    • Returns: A boolean which indicates if the tag exists in the target item.

Popup Item Commands

  • ADD_POPUP_ITEM_TO_ITEM

    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
      • string: The item to add to the items popup menu.
    • Returns: A boolean which indicates if the popup was added in the target items popup menu.
  • REMOVE_POPUP_ITEM_FROM_ITEM

    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
      • string: The item to remove from the items popup menu.
    • Returns: A boolean which indicates if the popup was removed from the target items popup menu.
  • DOES_ITEM_HAVE_POPUP_ITEM

    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
      • string: The item to check for.
    • Returns: A boolean which indicates if the popup exists in the target items popup menu.

Icon Commands

  • ADD_ICON_TO_ITEM

    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
      • IntPtr: The pointer to the icon (texture).
      • int: The icon width.
      • int: The icon height.
    • Returns: A boolean which indicates if the icon was added to the target item.
  • REMOVE_ICON_FROM_ITEM

    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
    • Returns: A boolean which indicates if the icon was removed from the target item.

Tooltip Commands

  • SET_ITEM_TOOLTIP
    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
      • string: The tooltip for the item.
    • Returns: A boolean which indicates if the tooltip was added to the target item.

Flag Commands

  • SET_ITEM_NOT_REMOVED_FROM_INVENTORY_ON_MOD_UNLOAD
    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
      • boolean: Do we want to set it or not?
    • Returns: A boolean which indicates if the flag was set for the target item.

Available Event Commands

What are those?

"Event Commands" are just regular IV-SDK .NET script commands, but they will be used to send a script command back to your Script when something happens.
For Example: When sending the script command "SUBSCRIBE_TO_ON_ITEM_CLICK_EVENT_FOR_ITEM" to Pack & Carry, your Script will receive a "PAC_ON_ITEM_CLICKED" script command which lets you know that an item was clicked.

All Commands

  • SUBSCRIBE_TO_ON_ITEM_DRAGGED_OUT_EVENT_FOR_ITEM

    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
    • Returns: A boolean which indicates if we successfully subscribed to this event.
    • Additional Notes: When this event fires, a “PAC_ON_ITEM_DRAGGED_OUT” script command will be sent to the subscriber script.
    • Unsubscribe command: UNSUBSCRIBE_FROM_ON_ITEM_DRAGGED_OUT_EVENT_FOR_ITEM (Same arguments, same return value)
  • SUBSCRIBE_TO_ON_ITEM_DRAGGED_TO_NEW_SLOT_EVENT_FOR_ITEM

    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
    • Returns: A boolean which indicates if we successfully subscribed to this event.
    • Additional Notes: When this event fires, a “PAC_ON_ITEM_DRAGGED_TO_NEW_SLOT” script command will be sent to the subscriber script.
    • Unsubscribe command: UNSUBSCRIBE_FROM_ON_ITEM_DRAGGED_TO_NEW_SLOT_EVENT_FOR_ITEM (Same arguments, same return value)
  • SUBSCRIBE_TO_ON_ITEM_CLICK_EVENT_FOR_ITEM

    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
    • Returns: A boolean which indicates if we successfully subscribed to this event.
    • Additional Notes: When this event fires, a “PAC_ON_ITEM_CLICKED” script command will be sent to the subscriber script.
    • Unsubscribe command: UNSUBSCRIBE_FROM_ON_ITEM_CLICK_EVENT_FOR_ITEM (Same arguments, same return value)
  • SUBSCRIBE_TO_ON_POPUP_ITEM_CLICK_EVENT_FOR_ITEM

    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
    • Returns: A boolean which indicates if we successfully subscribed to this event.
    • Additional Notes: When this event fires, a “PAC_ON_POPUP_ITEM_CLICKED” script command will be sent to the subscriber script.
    • Unsubscribe command: UNSUBSCRIBE_FROM_ON_POPUP_ITEM_CLICK_EVENT_FOR_ITEM (Same arguments, same return value)
  • SUBSCRIBE_TO_ON_ITEM_BEING_LEFT_BEHIND_EVENT_FOR_ITEM

    • Required Arguments:
      • Guid: The target inventory ID.
      • Guid: The target item ID.
    • Returns: A boolean which indicates if we successfully subscribed to this event.
    • Additional Notes: When this event fires, a “PAC_ON_ITEM_BEING_LEFT_BEHIND” script command will be sent to the subscriber script.
    • Unsubscribe command: UNSUBSCRIBE_FROM_ON_ITEM_BEING_LEFT_BEHIND_EVENT_FOR_ITEM (Same arguments, same return value)