From 97c447bedb9405f0c204aaf959b05113488dfd06 Mon Sep 17 00:00:00 2001 From: elite Date: Sat, 22 Jul 2017 15:20:03 -0400 Subject: [PATCH] add [invhack] mod --- worldmods/invhack/init.lua | 87 ++++++++++++++++++++ worldmods/invhack/readme.txt | 8 ++ worldmods/invhack/textures/hacktool_inv.png | Bin 0 -> 1604 bytes 3 files changed, 95 insertions(+) create mode 100644 worldmods/invhack/init.lua create mode 100644 worldmods/invhack/readme.txt create mode 100644 worldmods/invhack/textures/hacktool_inv.png diff --git a/worldmods/invhack/init.lua b/worldmods/invhack/init.lua new file mode 100644 index 0000000..3d46016 --- /dev/null +++ b/worldmods/invhack/init.lua @@ -0,0 +1,87 @@ +hacktool={} + +hacktool.gui=function(itemstack, user, pointed_thing) + if pointed_thing.type~="object" then return end + local player=pointed_thing.ref + if player:is_player()==false then return end + hacktool.tmp={} + hacktool.tmp=player + local inv=player:get_inventory() + local gui="size[8,4]" + local x=0 + local y=0 + + for i=1,32,1 do + gui=gui .."item_image_button[" .. x ..",".. y.. ";1,1;".. inv:get_stack("main",i):get_name() ..";inv" .. i ..";\n\n\b\b\b" .. inv:get_stack("main",i):get_count() .."]" + x=x+1 + if x>=8 then + x=0 + y=y+1 + end + end + minetest.after((0.1), function(gui) + return minetest.show_formspec(user:get_player_name(), "invhack.form",gui) + end, gui) +end + +minetest.register_privilege("invhack", { + description = "Let you hack players inventory", + give_to_singleplayer= true, +}) + + + +minetest.register_on_player_receive_fields(function(player, form, pressed) + if form=="invhack.form" then + local name=player:get_player_name() + local n=0 + + if pressed.quit then + if hacktool.tmp then hacktool.tmp=nil end + return + end + + if not minetest.check_player_privs(name, {invhack=true}) then + minetest.chat_send_player(name, "Missing privilege: invhack") + return + end + + if hacktool.tmp==nil or hacktool.tmp:is_player()~=true then + hacktool.tmp=nil + minetest.chat_send_player(name, "The tempoary variable is empty or the player offline") + return + end + + for i=1,32,1 do + n=i + if pressed["inv" .. i] then break end + end + if pressed["inv" .. n] then + local pinv=hacktool.tmp:get_inventory() + local uinv=player:get_inventory() + local stack=pinv:get_stack("main",n) + local n2=0 + local f=true + for i=1,32,1 do + n2=i + if uinv:get_stack("main",i):get_count()==0 then f=false break end + end + if f then minetest.chat_send_player(name, "Error: Your inventory is full") return end + uinv:set_stack("main",n2,stack) + pinv:set_stack("main",n,nil) + end + end +end) + + + +minetest.register_tool("invhack:tool", { + description = "Inventory hack tool", + range = 15, + inventory_image = "hacktool_inv.png", + groups = {not_in_creative_inventory=1}, + on_use = function(itemstack, user, pointed_thing) + hacktool.gui(itemstack, user, pointed_thing) + return itemstack + end, +}) \ No newline at end of file diff --git a/worldmods/invhack/readme.txt b/worldmods/invhack/readme.txt new file mode 100644 index 0000000..f12a394 --- /dev/null +++ b/worldmods/invhack/readme.txt @@ -0,0 +1,8 @@ +Licenses: code LGPL 2.1 media CC BY-SA 3.0 +Created by: UjEdwin +Date: 2016-03-29 + +See and or take items from players main inventory. +The invhack privilege requires to take items. + +Tool: invhack:tool \ No newline at end of file diff --git a/worldmods/invhack/textures/hacktool_inv.png b/worldmods/invhack/textures/hacktool_inv.png new file mode 100644 index 0000000000000000000000000000000000000000..b59a64ccbd754c957ba7c535d953fbb52bf0e0a2 GIT binary patch literal 1604 zcmV-K2D|x*P)&WNwoj$ZNX^CCiDfNN_ z-^=D(-`;Dly$@v=296T+K?4$r1a+hY0302G+1c6W0DONW1X8Kg%iG)ApS9cVKO~dM zfBvonW@cs*vMj%!%jIzE)-6bq^lT!Lc<*;1kV>WA?{>Ry>$;Bq{(ji)c33PHsH*yE zDwVqQs066J+AxtweBSHzp3Y=4;5ZIv&z=QM(^y(sLbKV#o{l2O$K65a_!8VKSM#rzpyo`)uRg2>^f~ z2mwV={#&h90}Bfa=w~6gpeSnR)rMh!rfHN)CDiM6bUGbc z*Y)qtpFi(Elm?Q?B&8_I2!O?6v532O?;;cm!Rz%xmSyB}ISdUA!RPaVVHhkgFN5cK z_D!oG#Wud$Tt9xPN#QL|KNE~5vr>ChTHA-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