Skip to content

Commit

Permalink
[Reviewed] [Inventories] Use extension variables (#1310)
Browse files Browse the repository at this point in the history
  • Loading branch information
D8H authored Jun 24, 2024
1 parent e2e2425 commit f935818
Showing 1 changed file with 63 additions and 48 deletions.
111 changes: 63 additions & 48 deletions extensions/reviewed/Inventories.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "Inventories",
"previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/Glyphster Pack/Master/SVG/Education and Learning/032fea6b6614c8b1c923bc3336520e8c24a418d18c16dae507ef2e885e01f8c9_Education and Learning_education_school_bag_backpack.svg",
"shortDescription": "Manage inventory items.",
"version": "1.0.0",
"version": "1.0.1",
"description": "Manage inventory items with limited or unlimited item capacity.",
"tags": [
"inventory",
Expand All @@ -22,6 +22,15 @@
"IWykYNRvhCZBN3vEgKEbBPOR3Oc2"
],
"dependencies": [],
"globalVariables": [],
"sceneVariables": [
{
"folded": true,
"name": "Inventories",
"type": "structure",
"children": []
}
],
"eventsFunctions": [
{
"description": "Add an item in an inventory.",
Expand All @@ -42,8 +51,8 @@
"",
"+",
"1",
"GetArgumentAsString(\"InventoryName\")",
"GetArgumentAsString(\"ItemName\")",
"InventoryName",
"ItemName",
""
]
}
Expand Down Expand Up @@ -85,8 +94,8 @@
"",
"-",
"1",
"GetArgumentAsString(\"InventoryName\")",
"GetArgumentAsString(\"ItemName\")",
"InventoryName",
"ItemName",
""
]
}
Expand Down Expand Up @@ -125,7 +134,7 @@
"value": "SetReturnNumber"
},
"parameters": [
"Variable(_SimpleInventory[GetArgumentAsString(\"InventoryName\")][GetArgumentAsString(\"ItemName\")].Count)"
"Inventories[InventoryName][ItemName].Count"
]
}
]
Expand Down Expand Up @@ -167,21 +176,21 @@
},
"parameters": [
"",
"GetArgumentAsString(\"InventoryName\")",
"GetArgumentAsString(\"ItemName\")",
"InventoryName",
"ItemName",
""
]
}
],
"actions": [
{
"type": {
"value": "ModVarScene"
"value": "SetNumberVariable"
},
"parameters": [
"_SimpleInventory[GetArgumentAsString(\"InventoryName\")][GetArgumentAsString(\"ItemName\")].Count",
"Inventories[InventoryName][ItemName].Count",
"=",
"max(0, GetArgumentAsNumber(\"Value\"))"
"max(0, Value)"
]
}
]
Expand All @@ -195,21 +204,21 @@
},
"parameters": [
"",
"GetArgumentAsString(\"InventoryName\")",
"GetArgumentAsString(\"ItemName\")",
"InventoryName",
"ItemName",
""
]
}
],
"actions": [
{
"type": {
"value": "ModVarScene"
"value": "SetNumberVariable"
},
"parameters": [
"_SimpleInventory[GetArgumentAsString(\"InventoryName\")][GetArgumentAsString(\"ItemName\")].Count",
"Inventories[InventoryName][ItemName].Count",
"=",
"clamp(0, Inventories::ItemCapacity(GetArgumentAsString(\"InventoryName\"), GetArgumentAsString(\"ItemName\")), GetArgumentAsNumber(\"Value\"))"
"clamp(0, Inventories::ItemCapacity(InventoryName, ItemName), Value)"
]
}
]
Expand Down Expand Up @@ -249,8 +258,8 @@
"",
">",
"0",
"GetArgumentAsString(\"InventoryName\")",
"GetArgumentAsString(\"ItemName\")",
"InventoryName",
"ItemName",
""
]
}
Expand Down Expand Up @@ -299,7 +308,7 @@
"value": "SetReturnNumber"
},
"parameters": [
"Variable(_SimpleInventory[GetArgumentAsString(\"InventoryName\")][GetArgumentAsString(\"ItemName\")].Capacity)"
"Inventories[InventoryName][ItemName].Capacity"
]
}
]
Expand Down Expand Up @@ -337,12 +346,12 @@
"actions": [
{
"type": {
"value": "ModVarScene"
"value": "SetNumberVariable"
},
"parameters": [
"_SimpleInventory[GetArgumentAsString(\"InventoryName\")][GetArgumentAsString(\"ItemName\")].Capacity",
"Inventories[InventoryName][ItemName].Capacity",
"=",
"GetArgumentAsNumber(\"Value\")"
"Value"
]
}
]
Expand Down Expand Up @@ -376,11 +385,12 @@
"conditions": [
{
"type": {
"value": "SceneVariableAsBoolean"
"value": "BooleanVariable"
},
"parameters": [
"_SimpleInventory[GetArgumentAsString(\"InventoryName\")][GetArgumentAsString(\"ItemName\")].IsCapacityLimited",
"True"
"Inventories[InventoryName][ItemName].IsCapacityLimited",
"True",
""
]
}
],
Expand Down Expand Up @@ -435,11 +445,12 @@
"actions": [
{
"type": {
"value": "SetSceneVariableAsBoolean"
"value": "SetBooleanVariable"
},
"parameters": [
"_SimpleInventory[GetArgumentAsString(\"InventoryName\")][GetArgumentAsString(\"ItemName\")].IsCapacityLimited",
"False"
"Inventories[InventoryName][ItemName].IsCapacityLimited",
"False",
""
]
}
]
Expand All @@ -459,11 +470,12 @@
"actions": [
{
"type": {
"value": "SetSceneVariableAsBoolean"
"value": "SetBooleanVariable"
},
"parameters": [
"_SimpleInventory[GetArgumentAsString(\"InventoryName\")][GetArgumentAsString(\"ItemName\")].IsCapacityLimited",
"True"
"Inventories[InventoryName][ItemName].IsCapacityLimited",
"True",
""
]
}
]
Expand Down Expand Up @@ -506,8 +518,8 @@
},
"parameters": [
"",
"GetArgumentAsString(\"InventoryName\")",
"GetArgumentAsString(\"ItemName\")",
"InventoryName",
"ItemName",
""
]
},
Expand All @@ -518,9 +530,9 @@
"parameters": [
"",
">=",
"Inventories::ItemCapacity(GetArgumentAsString(\"ItemName\"), GetArgumentAsString(\"InventoryName\"))",
"GetArgumentAsString(\"InventoryName\")",
"GetArgumentAsString(\"ItemName\")",
"Inventories::ItemCapacity(ItemName, InventoryName)",
"InventoryName",
"ItemName",
""
]
}
Expand Down Expand Up @@ -565,10 +577,11 @@
"conditions": [
{
"type": {
"value": "SceneVariableAsBoolean"
"value": "BooleanVariable"
},
"parameters": [
"_SimpleInventory[GetArgumentAsString(\"InventoryName\")][GetArgumentAsString(\"ItemName\")].IsEquipped",
"Inventories[InventoryName][ItemName].IsEquipped",
"",
""
]
}
Expand Down Expand Up @@ -624,11 +637,12 @@
"actions": [
{
"type": {
"value": "SetSceneVariableAsBoolean"
"value": "SetBooleanVariable"
},
"parameters": [
"_SimpleInventory[GetArgumentAsString(\"InventoryName\")][GetArgumentAsString(\"ItemName\")].IsEquipped",
"False"
"Inventories[InventoryName][ItemName].IsEquipped",
"False",
""
]
}
]
Expand All @@ -648,11 +662,12 @@
"actions": [
{
"type": {
"value": "SetSceneVariableAsBoolean"
"value": "SetBooleanVariable"
},
"parameters": [
"_SimpleInventory[GetArgumentAsString(\"InventoryName\")][GetArgumentAsString(\"ItemName\")].IsEquipped",
"True"
"Inventories[InventoryName][ItemName].IsEquipped",
"True",
""
]
}
]
Expand Down Expand Up @@ -693,11 +708,11 @@
"actions": [
{
"type": {
"value": "CopyVariableToArgument"
"value": "CopyVariableToArgument2"
},
"parameters": [
"\"SceneVariable\"",
"_SimpleInventory[GetArgumentAsString(\"InventoryName\")]"
"Inventories[InventoryName]"
]
}
]
Expand Down Expand Up @@ -733,11 +748,11 @@
"actions": [
{
"type": {
"value": "CopyArgumentToVariable"
"value": "CopyArgumentToVariable2"
},
"parameters": [
"\"SceneVariable\"",
"_SimpleInventory[GetArgumentAsString(\"InventoryName\")]"
"Inventories[InventoryName]"
]
}
]
Expand Down

0 comments on commit f935818

Please sign in to comment.