From 89fcf29f2e66d835614cf33f90553f0a9ba986a0 Mon Sep 17 00:00:00 2001 From: NathanSalapat Date: Sat, 23 Apr 2016 10:32:58 -0500 Subject: [PATCH] initial upload --- depends.txt | 1 + init.lua | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ license.txt | 1 + mod.conf | 1 + 4 files changed, 58 insertions(+) create mode 100644 depends.txt create mode 100644 init.lua create mode 100644 license.txt create mode 100644 mod.conf diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +default diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..ca26617 --- /dev/null +++ b/init.lua @@ -0,0 +1,55 @@ +-- Monies +-- currency:minegeld, currency:minegeld_5, currency:minegeld_10 + +local merch_table = { -- Selling, Cost, Store Name, Node Name +{'default:pick_wood', 'currency:minegeld_5', 'Wooden Pickaxes', 'wood_pick'}, +{'default:gold_lump', 'currency:minegeld_5', 'Gold Lumps', 'gold_lump'}, +} + +for i in ipairs (merch_table) do + local selling = merch_table[i][1] + local cost = merch_table[i][2] + local sname = merch_table[i][3] + local nname = merch_table[i][4] + +minetest.register_node('autostore:'..nname, { + description = sname, + tiles = {'default_wood.png'}, + groups = {choppy=2,oddly_breakable_by_hand=2, attached_node=1}, + paramtype = 'light', + paramtype2 = 'facedir', + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + inv:set_size('main', 8*4) + inv:set_size("input", 1) + inv:set_size("output", 1) + meta:set_string('formspec', + 'size[8,6]'.. + 'label[0,0;Selling:]'.. + 'label[0,1;For:]'.. + 'item_image_button[1,0;1,1;'..selling..';blah;]'.. + 'item_image_button[1,1;1,1;'..cost..';blah;]'.. + 'label[2.5,0;Pay here:]'.. + 'label[2.5,1;Take your stuff:]'.. + 'list[current_name;input;5,0;1,1;]'.. + 'list[current_name;output;5,1;1,1;]'.. + 'button[6,0;2,1;buy;Buy Now]'.. + 'list[current_player;main;0,2;8,4;]') + meta:set_string('infotext', sname) + end, + on_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if fields['buy'] then + local instack = inv:get_stack("input", 1) + if instack:get_name() == cost then + instack:take_item() + inv:set_stack("input",1,instack) + inv:add_item('output',selling) + end + end + end, +}) + +end diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..c82e5b2 --- /dev/null +++ b/license.txt @@ -0,0 +1 @@ +By NathanS21(Nathan Salapat) CC by SA 4.0 diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..6c78814 --- /dev/null +++ b/mod.conf @@ -0,0 +1 @@ +name = autostore