123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- local formspec_good =
- 'formspec_version[3]'..
- 'size[10,12]'..
- 'bgcolor[;neither]'..
- 'background[-1,-1;12,14;tasks_forcefield_working_bg.png]'..
- 'image[3,1;1,1;tasks_quantum_coil.png]'..
- 'hypertext[0,4.75;4.,3;nil;<global halign=center valign=middle><style color=black size=30>Shields at 100%<style>]'
- local function formspec_bad(pos)
- local spos = pos.x ..','.. pos.y ..','.. pos.z
- local formspec =
- 'formspec_version[3]'..
- 'size[10,12]'..
- 'bgcolor[;neither]'..
- 'background[-1,-1;12,14;tasks_forcefield_bg.png]'..
- 'hypertext[0,4.75;4.,3;nil;<global halign=center valign=middle><style color=black size=30>Shields down!!! New Quantum coil needed ASAP.<style>]'..
- 'button_exit[6.25,6.25;3,1;gimme;Grab A Request Form]'..
- 'list[nodemeta:'..spos..';part;3,1;1,1;]'..
- 'listcolors[#10101020;#7DA3CC20]'..
- 'list[current_player;main;.125,9.75;8,2;]'..
- 'listring[current_player;main]'..
- 'listring[nodemeta:'..spos..';part]'..
- 'image[3,1;1,1;tasks_quantum_coil_line.png]'
- return formspec
- end
- local on_box = {
- type = 'fixed',
- fixed = {
- {-.5, -.5, -.5, .5, .5, .5},
- {-1.5, -.5, 1.45, 1.5, 1.5, 1.5}},}
- local off_box = {
- type = 'fixed',
- fixed = {
- {-.5, -.5, -.5, .5, .5, .5},},}
- minetest.register_node('tasks:forcefield_gen_on',{
- description = 'Forcefield Generator',
- drawtype = 'mesh',
- mesh = 'tasks_forcefield_gen.obj',
- tiles = {name = 'tasks_forcefield_gen_on.png'},
- paramtype = 'light',
- paramtype2 = 'facedir',
- light_source = 12,
- selection_box = on_box,
- collision_box = on_box,
- groups = {breakable = 1, tasks=1},
- on_construct = function(pos)
- tasks.on_construct(pos, 'Forcefield Generator', 'More like hole Generator')
- end,
- on_rightclick = function(pos, node, clicker)
- tasks.right_click_on(pos, node, clicker, formspec_good)
- end,
- on_timer = function(pos)
- local node = minetest.get_node(pos)
- local meta = minetest.get_meta(pos)
- local infotext = meta:get_string('info_repair')
- meta:set_string('infotext', infotext)
- minetest.swap_node(pos, {name = 'tasks:forcefield_gen_off', param2 = node.param2})
- end,
- })
- minetest.register_node('tasks:forcefield_gen_off',{
- description = 'Forcefield Generator',
- drawtype = 'mesh',
- mesh = 'tasks_forcefield_gen.obj',
- tiles = {name = 'tasks_forcefield_gen_off.png'},
- paramtype = 'light',
- paramtype2 = 'facedir',
- selection_box = off_box,
- collision_box = off_box,
- groups = {breakable = 1, not_in_creative_inventory=1, tasks=1},
- drop = 'tasks:forcefield_gen_on',
- req_form = 'tasks:quantum_coil_req',
- req_count = 2,
- on_rightclick = function(pos, node, clicker)
- tasks.right_click_off(pos, node, clicker, formspec_bad(pos))
- end,
- allow_metadata_inventory_put = function(pos, listname, index, stack, player)
- if listname == 'part' then
- if stack:get_name() == 'tasks:quantum_coil' then
- local player_attributes = player:get_meta()
- local luck = player_attributes:get_int('luck')
- if luck*2 < math.random(10) then
- minetest.chat_send_player(player:get_player_name(), 'You drop the coil, fortunately it doesn\'t break.')
- return 0
- else
- return 1
- end
- end
- return 0
- end
- end,
- on_metadata_inventory_put = function(pos, listname, index, stack, player)
- local name = player:get_player_name()
- local meta = minetest.get_meta(pos)
- local xp = meta:get_int('xp') or 10
- local inv = meta:get_inventory()
- local node = minetest.get_node(pos)
- local timer = minetest.get_node_timer(pos)
- local min = meta:get_int('time_min') or 300
- local max = meta:get_int('time_max') or 600
- local random_number = math.random(min,max)
- local infotext = meta:get_string('info_working')
- inv:set_stack('part', 1, '')
- minetest.swap_node(pos, {name = 'tasks:forcefield_gen_on', param2 = node.param2})
- minetest.close_formspec(name, 'tasks:part_req_form')
- meta:set_string('infotext', infotext)
- tasks.only_add_xp(xp, name)
- timer:start(random_number)
- end,
- })
|