From 25c9d8e106868499bc487aa5df7e074d5555f183 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Mon, 2 Jul 2018 12:30:05 -0300 Subject: Update shovel code. It will use drag'n'drop feature. It'll also have protection so you don't bury items too difficult to obtain, items which are bound, and your own shovel (ofc). PS. Legacy code was NOT updated to meet with @gumi standards, only new one. The code was tested. --- npc/items/shovel.txt | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/npc/items/shovel.txt b/npc/items/shovel.txt index f01a0fcb..c6bc8224 100644 --- a/npc/items/shovel.txt +++ b/npc/items/shovel.txt @@ -1,5 +1,6 @@ // Evol scripts. // Author: +// Jesusalva // Travolta // Description: // NPC to use shovel (dig, bury etc) @@ -84,19 +85,30 @@ function Bury { narrator S_FIRST_BLANK_LINE | S_LAST_BLANK_LINE, l("What would you like to bury?"); .@items$ = ""; - getinventorylist; - for (.@i = 0; .@i < @inventorylist_count; .@i++) + + mes("##B" + l("Drag and drop an item from your inventory.") + "##b"); + + .@id = requestitem(); + + // You cannot bury: Items you don't have, your shovel, Bound Items, and items which are not dropped by any mobs. + // The "item not dropped by any mob" is temporary, and should be replaced by "items with trade restrictions" later. + if (.@id < 1 || countitem(.@id) < 1 || .@id == IronShovel || checkbound(.@id) || !getiteminfo(.@id, ITEMINFO_MAXCHANCE)) { - .@items$ = .@items$ + getitemname(@inventorylist_id[.@i]) + ":"; - debugmes getitemname(@inventorylist_id[.@i]); + @ShovelLastUsed = 0; + if (.@id == IronShovel || checkbound(.@id)) + mes(col(l("You cannot bury this item!"))); + else if (!getiteminfo(.@id, ITEMINFO_MAXCHANCE)) + mes(col(l("This item is too precious, you cannot part with it!"))); + else + mes(col(l("You give up."))); + return; } - .@idx = select(.@items$) - 1; - .@id = @inventorylist_id[.@idx]; + .@amount = 1; - if (@inventorylist_amount[.@idx] > 1) + if (countitem(.@id) > 1) { narrator S_FIRST_BLANK_LINE | S_LAST_BLANK_LINE, l("Amount?"); - input .@amount, 1, @inventorylist_amount[.@idx]; + input .@amount, 1, countitem(.@id); } getmapxy(.@map$, .@x, .@y, 0); -- cgit v1.2.3-70-g09d2