Sell loot

When this script runs after someone selected a dialogue option, it will sell all items in the player’s unit’s inv

{
“triggers”: ,
“conditions”: [
{
“operator”: “==”,
“operandType”: “boolean”
},
true,
true
],
“actions”: [
{
“type”: “forAllUnits”,
“unitGroup”: {
“function”: “allUnitsOwnedByPlayer”,
“player”: {
“function”: “getLastPlayerSelectingDialogueOption”
}
},
“actions”: [
{
“type”: “forAllItems”,
“itemGroup”: {
“function”: “allItemsOwnedByUnit”,
“entity”: {
“function”: “selectedUnit”
}
},
“actions”: [
{
“type”: “condition”,
“conditions”: [
{
“operandType”: “itemType”,
“operator”: “==”
},
{
“function”: “getItemTypeOfItem”,
“entity”: {
“function”: “selectedItem”
}
},
“WmBuFwHgJK”
],
“then”: [
{
“type”: “destroyEntity”,
“entity”: {
“function”: “selectedItem”
}
},
{
“type”: “setPlayerAttribute”,
“attribute”: “points”,
“entity”: {
“function”: “getOwner”,
“entity”: {
“function”: “selectedUnit”
}
},
“value”: {
“function”: “calculate”,
“items”: [
{
“operator”: “+”
},
{
“function”: “getPlayerAttribute”,
“attribute”: “points”,
“entity”: {
“function”: “getOwner”,
“entity”: {
“function”: “selectedUnit”
}
}
},
{
“function”: “calculate”,
“items”: [
{
“operator”: “*”
},
30,
{
“function”: “getCurrentAmmoOfItem”,
“item”: {
“function”: “selectedItem”
}
}
]
}
]
}
}
],
“else”:
}
]
}
]
}
],
“name”: “sell loot”,
“parent”: “baXoQWRr1c”,
“key”: “wlqw5IGuJD”,
“order”: 7
}

1 Like

Note that the value of every loot assumed to be the same in the program. If you want to set the price of the items, you need to add an entity attribute named “Price” to every item type that can be looted, and change the line of adding player’s points accordingly. From (30 * (ammo of )selected item))) to ((Price of (selected item)) * (ammo of (selected item))).

thanks for that :smiley: . . . . . . . . . . .

Hi, glad you are contributing. However, this script is not usable in JSON state since it depends on attribute and unit IDs.

Please create an open source game that demonstrates this instead, then update your original post.

2 Likes

u right thats a smarter way to automating the system

1 Like

no problem! glad found it useful!

yeah you right… scripts like these can be used by pasting the code in the JSON list button
image
i wish theres a way to catagorize the games i made cuz its getting really messy and i hate to make spend extra game slots to make it even more messy

Yea we should, but we do not want to use one of our precious game slots just to demonstrate a single idea. I think there needs a system to extend the game slot count of people who made demonstrations.

Im sure i remember reading somewhere that mino will extend ur game slots, but the thing is my library of games are already getting really messy and if i flood it with more scraps of code that takes up a game slots space then it will be super messy. i wish theres a way to categorize games like the script folders but for games

1 Like

That’ll be a great idea