Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Writing your first QuickAction

SirBitesalot edited this page Jan 23, 2021 · 8 revisions

To explain how to write your first QuickAction we look at the "Add10KEddies" QuickAction. It is assumed that you have read QuickAction Overview and QuickAction Setup.

Getting the correct node

To get a correct node we can create a variable and use the "where" extension combined with "FirstOrDefault" on the "nodes" variable from the predefiend variables.

Note that the following steps could be done on one line but for claritywe do it seperate.

In this case we search for the first node that is named "inventory" like this:

var inventoryNode = nodes.where(n => n.Name == "inventory").FirstOrDefault();

Getting the actual data

The actual representation that contains the data in a parsed format is stored in the "Value" property of the node:

var inventory = inventoryNode.Value;

Getting the subinventory

Get the subinventory with Id "1" (this is Vs main Inventory):

var subInventory = inventory.SubInventories.where(si => si.InventoryId == 1).FirstOrDefault()

Getting an Item

Get the first Item that has the name "Items.money"

var eddies = subInventory.Items.where(i => i.ItemTdbId.Name == "Items.money").FirstOrDefault();

Cast the data of the item

The data of the of the item needs to be cast into the correct type or else it will only be represented as a string and properties cant be accessed.

In this case we want to cast the "Data" property of our item to "SimpleItemData":

var typedEddieData = host.cast(lib.CyberCAT.Core.Classes.NodeRepresentations.ItemData.SimpleItemData, eddies.Data);

Increment Quantity

As last step we increment the "Quantity" property by 10.000

typedEddieData.Quantity += 10000;