added Vending Machines.

master
NathanSalapat 2017-05-06 21:06:44 -05:00
parent 71b26eb2f3
commit a1aa0e144a
10 changed files with 119 additions and 19 deletions

View File

@ -1,3 +1,8 @@
2017-05-06:
Added more nodes to the spawn mod.
Added vending machines.
Added a temporary texture for the inventory GUI and tweaked some positions.
2017-05-04:
Added a few more nodes for spawn; ramps, wall blocks, widow edge.
Animated the spawn:console tops.

View File

@ -2,29 +2,20 @@ gamer = {}
-- GUI related stuff
gamer.gui_bg = 'bgcolor[#080808BB;true]'
gamer.gui_bg_img = 'background[5,5;1,1;gui_formbg.png;true]'
gamer.gui_bg_img = 'background[5,5;1,1;gui_background.png;true]'
gamer.gui_slots = 'listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]'
function gamer.get_hotbar_bg(x,y)
local out = ''
for i=0,7,1 do
out = out ..'image['..x+i..','..y..';1,1;gui_hb_bg.png]'
end
return out
end
gamer.gui_survival_form = 'size[8,8.5]'..
gamer.gui_survival_form = 'size[8,7.5]'..
gamer.gui_bg..
gamer.gui_bg_img..
gamer.gui_slots..
'list[current_player;main;0,4.25;8,1;]'..
'list[current_player;main;0,5.5;8,3;8]'..
'list[current_player;craft;1.75,0.5;3,3;]'..
'list[current_player;craftpreview;5.75,1.5;1,1;]'..
'image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]'..
'list[current_player;main;0,3.5;8,1;]'..
'list[current_player;main;0,4.5;8,3;8]'..
'list[current_player;craft;0,0;3,3;]'..
'list[current_player;craftpreview;4,1;1,1;]'..
'image[3,1;1,1;gui_furnace_arrow_bg.png^[transformR270]'..
'listring[current_player;main]'..
'listring[current_player;craft]'..
gamer.get_hotbar_bg(0,4.25)
'listring[current_player;craft]'
minetest.register_item(':', {
type = 'none',
@ -37,7 +28,8 @@ minetest.register_item(':', {
crumbly = {times={[2]=3.00, [3]=0.70}, uses=0, maxlevel=1},
snappy = {times={[3]=0.40}, uses=0, maxlevel=1},
oddly_breakable_by_hand = {times={[1]=3.50,[2]=2.00,[3]=0.10}, uses=0},
cracky = {times={[3]=0.40, [4]=0.30,}, uses=0, maxlevel=2}
cracky = {times={[3]=0.40, [4]=0.30,}, uses=0, maxlevel=2},
spawn = {times={[1]=.1,}, uses=0}
},
damage_groups = {fleshy=1},
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

View File

@ -11,3 +11,4 @@ dofile(minetest.get_modpath('spawn')..'/floors.lua')
dofile(minetest.get_modpath('spawn')..'/rails.lua')
dofile(minetest.get_modpath('spawn')..'/objects.lua')
dofile(minetest.get_modpath('spawn')..'/walls.lua')
dofile(minetest.get_modpath('spawn')..'/vending_machine.lua')

View File

@ -38,7 +38,7 @@ minetest.register_node('spawn:console1', {
type = 'vertical_frames',
aspect_w = 32,
aspect_h = 32,
length = 1.0,
length = 2.0,
},}, 'spawn_console_front.png'},
groups = {oddly_breakable_by_hand=3}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,102 @@
formspec_owner =
'size[8,7;]'..
'label[0,0;Selling What:]'..
'list[context;selling;2,0;1,1;]'..
'field[3.3,0.4;1,1;sellinga;;1]'..
'label[0,1;For How Much:]'..
'list[context;cost;2,1;1,1;]'..
'field[3.3,1.4;1,1;costa;;1]'..
'field[5.3,0.4;3,1;sname;store name;Unconfigured Vending Machine]'..
'field[0.3,2.4;8,1;desc;item description;What this item is.]'..
'button_exit[5,1;3,1;save;Save Vending Machine]'..
'list[current_player;main;0,3;8,4;]'
minetest.register_node('spawn:vending1', {
description = 'Unconfigured Vending Machine',
tiles = {'autostore_top.png', 'autostore_side.png', 'autostore_side.png', 'autostore_side.png', 'autostore_side.png', 'autostore_off.png'},
groups = {spawn=1},
paramtype = 'light',
paramtype2 = 'facedir',
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
meta:set_string('infotext', 'Unconfigured Vending Machine')
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)
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 = 'spawn:vending', 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()
local selling_amount = tonumber(fields.sellinga)
local cost_amount = tonumber(fields.costa)
local desc = fields.desc
meta:set_string('infotext', fields.sname)
meta:set_string('sellinga', selling_amount)
meta:set_string('costa', cost_amount)
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,0;1,1;'..selling_thing..' '..selling_amount..';blah;]'..
'label[0,1;For:]'..
'item_image_button[1,1;1,1;'..cost_thing..' '..cost_amount..';blah;]'..
'label[2,0;Pay:]'..
'list[context;input;3,0;1,1;]'..
'label[2,1;Take:]'..
'list[context;output;3,1;1,1;]'..
'textarea[4.3,0;4,2;;'..desc..';]'..
'button[6,1;2,1;buy;Buy Now]'..
'list[current_player;main;0,2;8,4;]')
end
end,
})
minetest.register_node('spawn:vending', {
description = 'Vending Machine',
tiles = {'autostore_top.png', 'autostore_side.png', 'autostore_side.png', 'autostore_side.png', 'autostore_side.png', 'autostore_front.png'},
groups = {spawn=1},
paramtype = 'light',
paramtype2 = 'facedir',
drop = 'spawn:vending1',
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 cost_amount = tonumber(meta:get_string('costa'))
local selling_thing = meta:get_string('selling')
local selling_amount = tonumber(meta:get_string('sellinga'))
local sell_output = selling_thing..' '..selling_amount
if fields['buy'] then
local instack = inv:get_stack("input", 1)
if instack:get_name() == cost_thing and instack:get_count() >= cost_amount and out:item_fits(sell_output) then
instack:take_item(cost_amount)
inv:set_stack("input",1,instack)
inv:add_item("output",sell_output)
end
end
end,
})
minetest.register_node('spawn:vending_dud', {
description = 'Vending Machine',
tiles = {'autostore_top.png', 'autostore_side.png', 'autostore_side.png', 'autostore_side.png', 'autostore_side.png', 'autostore_off.png'},
groups = {spawn=1},
paramtype = 'light',
paramtype2 = 'facedir',
})