summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2025-03-19 18:27:01 +0100
committerFedja Beader <fedja@protonmail.ch>2025-03-19 18:27:42 +0100
commit468d684c4729e371c70d3cedbc050ffb992d0b54 (patch)
tree0511bff006b0fd0e0cfb72b80be550e569876d6f
parent874fe0e1909d3594568a466085fc1545a7f2b311 (diff)
downloadserverdata-468d684c4729e371c70d3cedbc050ffb992d0b54.tar.gz
serverdata-468d684c4729e371c70d3cedbc050ffb992d0b54.tar.bz2
serverdata-468d684c4729e371c70d3cedbc050ffb992d0b54.tar.xz
serverdata-468d684c4729e371c70d3cedbc050ffb992d0b54.zip
Overengineer empty boxes, to make it easier to implement #102
-rw-r--r--npc/items/emptybox.txt95
1 files changed, 59 insertions, 36 deletions
diff --git a/npc/items/emptybox.txt b/npc/items/emptybox.txt
index 2f676b115..24b9aa03a 100644
--- a/npc/items/emptybox.txt
+++ b/npc/items/emptybox.txt
@@ -1,6 +1,6 @@
// TMW2 scripts.
// Authors:
-// Jesusalva
+// Jesusalva, Fedja
// Description:
// Allows to create your own fish/plushroom/croconut box
@@ -8,47 +8,70 @@
close;
OnUse:
+ // qty, itemID, boxItemId
+ setarray .@boxMatrix, 50, Aquada, AquadaBox,
+ 20, CommonCarp, FishBox,
+ 8, Croconut, CroconutBox,
+ 7, GrassCarp, FishBox,
+ 87, Plushroom, PlushroomBox;
+
+ // Strings presented to player, indexes must match above.
+ setarray .@boxStrings, l("50 Aquadas"),
+ l("20 Common Carps"),
+ l("8 Croconuts"),
+ l("7 Grass Carps"),
+ l("87 Plushrooms");
+
+ if (getarraysize(.@boxMatrix) % 3 != 0)
+ Exception("Invalid array size: "+getarraysize(.@boxMatrix),
+ RB_DEFAULT|RB_ISFATAL);
+
+ if (getarraysize(.@boxStrings) * 3 != getarraysize(.@boxMatrix))
+ Exception("Invalid array size: "+getarraysize(.@boxStrings)
+ +"*3 !="+getarraysize(.@boxMatrix), RB_DEFAULT|RB_ISFATAL);
+
mesn;
mesc l("You can fill this box with the following items:");
- mesc l("- @@ @@", 7, getitemlink(GrassCarp));
- mesc l("- @@ @@", 8, getitemlink(Croconut));
- mesc l("- @@ @@", 20, getitemlink(CommonCarp));
- mesc l("- @@ @@", 87, getitemlink(Plushroom));
+
+ setarray .@menuOptions$, l("Don't fill"), "-1";
+
+ //freeloop(true);
+ for (.@index = 0; .@index < getarraysize(.@boxStrings); .@index++) {
+ .@matrixIndex = 3 * .@index;
+ .@amount = .@boxMatrix[.@matrixIndex];
+ .@itemID = .@boxMatrix[.@matrixIndex + 1];
+
+ mesc l("- %03d %s", .@amount, getitemlink(.@itemID));
+ if (countitem(.@itemID) >= .@amount) {
+ array_push(.@menuOptions$, .@boxStrings(.@index));
+ array_push(.@menuOptions$, str(.@index));
+ }
+ }
+ //freeloop(false);
+
+
+ // Do the request
mes "";
mesc l("Fill with what?");
- select
- l("Don't fill"),
- rif(countitem(GrassCarp) >= 7, l("7 Grass Carps")),
- rif(countitem(Croconut) >= 8, l("8 Croconuts")),
- rif(countitem(CommonCarp) >= 20, l("20 Common Carps")),
- rif(countitem(Aquada) >= 50, l("50 Aquadas")),
- rif(countitem(Plushroom) >= 87, l("87 Plushrooms"));
+
+ menuint2(.@menuOptions$);
+ deletearray(.@menuOptions$);
+
mes "";
- switch (@menu) {
- case 2:
- delitem GrassCarp, 7;
- getitem FishBox, 1;
- break;
- case 3:
- delitem Croconut, 8;
- getitem CroconutBox, 1;
- break;
- case 4:
- delitem CommonCarp, 20;
- getitem FishBox, 1;
- break;
- case 5:
- delitem Aquada, 50;
- getitem AquadaBox, 1;
- break;
- case 6:
- delitem Plushroom, 87;
- getitem PlushroomBox, 1;
- break;
- default:
- getitem EmptyBox, 1;
+
+ if (@menuret >= 0) {
+ .@matrixIndex = 3 * .@menuret;
+
+ .@amount = .@boxMatrix[.@matrixIndex];
+ .@itemID = .@boxMatrix[.@matrixIndex + 1];
+ .@boxID = .@boxMatrix[.@matrixIndex + 2];
+
+ inventoryplace .@boxID, 1;
+
+ delitem EmptyBox, 1;
+ delitem .@itemID, .@amount;
+ getitem .@boxID, 1;
}
- delitem EmptyBox, 1;
closedialog;
close;
}