From 64c97e99b19b7b7cbb80ef3e725256e08ca62f7b Mon Sep 17 00:00:00 2001 From: NathanSalapat Date: Sat, 30 Apr 2016 07:47:11 -0500 Subject: [PATCH] textures for the store. --- depends.txt | 1 - init.lua | 146 +++++++++++++++++------------------ readme.txt | 6 ++ textures/autostore_front.png | Bin 0 -> 320 bytes textures/autostore_off.png | Bin 0 -> 277 bytes textures/autostore_side.png | Bin 0 -> 261 bytes textures/autostore_top.png | Bin 0 -> 334 bytes 7 files changed, 79 insertions(+), 74 deletions(-) create mode 100644 readme.txt create mode 100644 textures/autostore_front.png create mode 100644 textures/autostore_off.png create mode 100644 textures/autostore_side.png create mode 100644 textures/autostore_top.png diff --git a/depends.txt b/depends.txt index 739f218..4ad96d5 100644 --- a/depends.txt +++ b/depends.txt @@ -1,2 +1 @@ default -currency diff --git a/init.lua b/init.lua index 59ba664..249c70f 100644 --- a/init.lua +++ b/init.lua @@ -4,18 +4,18 @@ minetest.register_privilege("autostore", { }) formspec_owner = - 'size[8,6;]'.. - 'label[0,0;Selling What:]'.. - 'list[context;selling;2,0;1,1;]'.. - 'label[0,1;For How Much:]'.. - 'list[context;cost;2,1;1,1;]'.. - 'field[5.3,0.4;3,1;sname;store name;Unconfigured Store]'.. - 'button_exit[6,1;2,1;save;Save Store]'.. - 'list[current_player;main;0,2;8,4;]' + 'size[8,6;]'.. + 'label[0,0;Selling What:]'.. + 'list[context;selling;2,0;1,1;]'.. + 'label[0,1;For How Much:]'.. + 'list[context;cost;2,1;1,1;]'.. + 'field[5.3,0.4;3,1;sname;store name;Unconfigured Store]'.. + 'button_exit[6,1;2,1;save;Save Store]'.. + 'list[current_player;main;0,2;8,4;]' minetest.register_node('autostore:store_1', { description = 'store', - tiles = {'default_wood.png'}, + tiles = {'autostore_top.png', 'autostore_side.png', 'autostore_side.png', 'autostore_side.png', 'autostore_side.png', 'autostore_front.png'}, groups = {oddly_breakable_by_hand=3, choppy=2}, paramtype = 'light', paramtype2 = 'facedir', @@ -23,15 +23,15 @@ minetest.register_node('autostore:store_1', { on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() - meta:set_string('infotext', 'Unconfigured Store') - meta:set_string('formspec', formspec_owner) + meta:set_string('infotext', 'Unconfigured Store') + meta:set_string('formspec', formspec_owner) inv:set_size("selling", 1) inv:set_size("cost", 1) - inv:set_size("input", 1) - inv:set_size("output", 1) + inv:set_size("input", 1) + inv:set_size("output", 1) end, - after_place_node = function(pos, placer) + after_place_node = function(pos, placer) if minetest.check_player_privs(placer:get_player_name(), {autostore = true}) then else minetest.remove_node(pos) @@ -39,53 +39,53 @@ minetest.register_node('autostore:store_1', { end end, - can_dig = function(pos, player) - if minetest.check_player_privs(player:get_player_name(), {autostore = true}) then - return true - else - return false - end - end, + can_dig = function(pos, player) + if minetest.check_player_privs(player:get_player_name(), {autostore = true}) then + return true + else + return false + end + end, - on_receive_fields = function(pos, formname, fields, sender) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - local out = inv:get_stack("output", 1) - local node = minetest.get_node(pos) - if fields ['save'] then - minetest.swap_node(pos,{name = 'autostore:store', param2=node.param2}) - local selling_1 = inv:get_stack("selling", 1) - local cost_1 = inv:get_stack('cost', 1) - local selling_thing = selling_1:get_name() - local cost_thing = cost_1:get_name() - meta:set_string('infotext', fields.sname) - meta:set_string('selling', selling_thing) - meta:set_string('cost', cost_thing) - meta:set_string('formspec', - 'size[8,6;]'.. - 'label[0,0;Selling:]'.. - 'item_image_button[1.5,0;1,1;'..selling_thing..';blah;]'.. - 'label[0,1;For:]'.. - 'item_image_button[1.5,1;1,1;'..cost_thing..';blah;]'.. - 'label[3,0;Pay:]'.. - 'list[context;input;4.5,0;1,1;]'.. - 'label[3,1;Take:]'.. - 'list[context;output;4.5,1;1,1;]'.. - 'button[6,0;2,1;buy;Buy Now]'.. - 'list[current_player;main;0,2;8,4;]') - end + on_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local out = inv:get_stack("output", 1) + local node = minetest.get_node(pos) + if fields ['save'] then + minetest.swap_node(pos,{name = 'autostore:store', param2=node.param2}) + local selling_1 = inv:get_stack("selling", 1) + local cost_1 = inv:get_stack('cost', 1) + local selling_thing = selling_1:get_name() + local cost_thing = cost_1:get_name() + meta:set_string('infotext', fields.sname) + meta:set_string('selling', selling_thing) + meta:set_string('cost', cost_thing) + meta:set_string('formspec', + 'size[8,6;]'.. + 'label[0,0;Selling:]'.. + 'item_image_button[1.5,0;1,1;'..selling_thing..';blah;]'.. + 'label[0,1;For:]'.. + 'item_image_button[1.5,1;1,1;'..cost_thing..';blah;]'.. + 'label[3,0;Pay:]'.. + 'list[context;input;4.5,0;1,1;]'.. + 'label[3,1;Take:]'.. + 'list[context;output;4.5,1;1,1;]'.. + 'button[6,0;2,1;buy;Buy Now]'.. + 'list[current_player;main;0,2;8,4;]') + end end, }) minetest.register_node('autostore:store', { description = 'store', - tiles = {'default_wood.png'}, + tiles = {'autostore_top.png', 'autostore_side.png', 'autostore_side.png', 'autostore_side.png', 'autostore_side.png', 'autostore_front.png'}, groups = {oddly_breakable_by_hand=3, choppy=2}, paramtype = 'light', paramtype2 = 'facedir', - drop = 'autostore:store_1', + drop = 'autostore:store_1', - after_place_node = function(pos, placer) + after_place_node = function(pos, placer) if minetest.check_player_privs(placer:get_player_name(), {autostore = true}) then else minetest.remove_node(pos) @@ -93,27 +93,27 @@ minetest.register_node('autostore:store', { end end, - can_dig = function(pos, player) - if minetest.check_player_privs(player:get_player_name(), {autostore = true}) then - return true - else - return false - end - end, + can_dig = function(pos, player) + if minetest.check_player_privs(player:get_player_name(), {autostore = true}) then + return true + else + return false + end + end, - on_receive_fields = function(pos, formname, fields, sender) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - local out = inv:get_stack("output", 1) - local cost_thing = meta:get_string('cost') - local selling_thing = meta:get_string('selling') - if fields['buy'] then - local instack = inv:get_stack("input", 1) - if instack:get_name() == cost_thing and out:item_fits(selling_thing) then - instack:take_item() - inv:set_stack("input",1,instack) - inv:add_item("output",selling_thing) - end - end - end, + on_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local out = inv:get_stack("output", 1) + local cost_thing = meta:get_string('cost') + local selling_thing = meta:get_string('selling') + if fields['buy'] then + local instack = inv:get_stack("input", 1) + if instack:get_name() == cost_thing and out:item_fits(selling_thing) then + instack:take_item() + inv:set_stack("input",1,instack) + inv:add_item("output",selling_thing) + end + end + end, }) diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..6ee3675 --- /dev/null +++ b/readme.txt @@ -0,0 +1,6 @@ +This mod adds one node and a privilege. +The node is a "store" where one can buy a single itemstack for a different itemstack, there are no limitations as to what can be used as the payment or the product being sold. +A player needs the autostore privilege to dig or place the node. +Once an unconfigured store is placed right click on it to open the formspec and set what is being sold and for how much and give it a name, then click save. +Once the store is saved any player can buy the items. +The beautiful thing about this store is there is no inventory to maintain, so once it is setup it will be able to sell the itmes forever. diff --git a/textures/autostore_front.png b/textures/autostore_front.png new file mode 100644 index 0000000000000000000000000000000000000000..974477959da4b01b534b48126912e0ab96de2e52 GIT binary patch literal 320 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!6#=yXs@#Xw?AcwIy$lZzA{J3v0ki%Kv5n0T@ zz@G@hj4SMyX95MqszM@45=%=m@{1T4DsFxD);Z~MhM9r=J5zMQ<^wfA6^A`t978Nl z-wix1$fU@_%VYcI2J6*`#yKwze0&jc@ZJSBons4mXGh#+Z)0@1_VvZ=hr*NgJYh{- zTYG`0(>L3HcWb4l< z?9OiQlEZb|UcNZtD_?SD!cM(A8_gbTP8B}4v+1D3W$PMZBkaOu;d4XZ`o9NxI+w$o?*Ejlp|?YVMN?myxU7Y{wj TWOu_3=voF(S3j3^P64`C2y|*syt_TU-k}J2Bsng|)<@3X_9Dh7DE&Dy5$Ug2%2+mg3 zV(-`#vy?^YlIe_7o@+W>BYFR3M&F&Od-%&mO^p}JhJ;7m2^=S6M8 z_YWRUwNCBcVRJgQ-`ecT^)ELM>B~Aq{)@K!Y#D9A`00}0tll>ge}Qgd@O1TaS?83{ F1OQ$^V_*OP literal 0 HcmV?d00001 diff --git a/textures/autostore_top.png b/textures/autostore_top.png new file mode 100644 index 0000000000000000000000000000000000000000..441f6ea8d0f8cfa4468a98f0f951a8650abf1075 GIT binary patch literal 334 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!6#=yXs@#Xw?AcwIy$lZzA{J3v0ki%Kv5n0T@ zz@G@hj4SMyX95MqszM@45=%=m@{1T4DsFxD);Z~MhM9r=J5zMQ<^wfA6&F2S978Nl zC!aZY?%#O^79WK}2M#ne3aTAqdeq1e(en0F2;15lH+c%S8l2mDbR~za!GRl}{y(n& zXu0|Ulg|m64F^t7F%V(gAgQ43D0E^~VvX7ihFyUMcEZeJ3`KHx{BpPw{x$4wWaLjc z`1}C3xSqorhw=x})pcw$$_sZfuGbH6;+uWlK%_xs;$F654Yxmu+@2LN6PO;nG7C$wuwSM c=UNyTl8$A2F!H9F0zJpz>FVdQ&MBb@0Qp9DjsO4v literal 0 HcmV?d00001