From 37933b4bbdbbdc0f47a5f3055ac6aaadc744f379 Mon Sep 17 00:00:00 2001 From: NathanSalapat Date: Sun, 20 Nov 2016 15:07:07 -0600 Subject: [PATCH] added abm to add things to power core. --- abms.lua | 43 +++++++++++++++++++++++++++++++++++++++++++ chats.lua | 6 ------ init.lua | 1 + nodes.lua | 20 +++++++++++++++++--- 4 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 abms.lua diff --git a/abms.lua b/abms.lua new file mode 100644 index 0000000..9fa0a39 --- /dev/null +++ b/abms.lua @@ -0,0 +1,43 @@ +illuminati_gift_table1 = { --Common items + 'default:cobble', + 'default:obsidian', + 'default:mese_crystal_fragment', +} + +illuminati_gift_table2 = { --Rare items + 'default:mese', + 'default:diamondblock', + 'default:goldblock', +} + +illuminati_gift_table3 = { --Super rare items + 'illuminati:core_off', + 'illuminati:cone_off', +} + +function give_gift(pos, table) + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + local max = #(table) + local gift_num = math.random(1,max) + local gift = table[gift_num] + inv:set_stack('dst', 1, gift) +end + +minetest.register_abm({ + nodenames = {'illuminati:core_on'}, + interval = 60, + chance = 5, + action = function(pos) + local gift_type = math.random(1,10) + if gift_type <= 1 then --Super rare item + give_gift(pos, illuminati_gift_table3) + end + if gift_type >= 2 and gift_type <= 8 then --Comon item + give_gift(pos, illuminati_gift_table1) + end + if gift_type > 8 then --Rare item + give_gift(pos, illuminati_gift_table2) + end + end +}) diff --git a/chats.lua b/chats.lua index 675bcc7..0ea7cee 100644 --- a/chats.lua +++ b/chats.lua @@ -30,12 +30,6 @@ function select_player(player, table) end end -minetest.register_on_chat_message(function(name,message) - if string.match(message, '%p%p%p%p%p%p%p%p') then - minetest.chat_send_player(name, ' Do you have a broken keyboard?') - end -end) - minetest.register_on_dieplayer(function(player) select_player(player, illuminati.death_message_table) end) diff --git a/init.lua b/init.lua index 5076cd3..c7a4dff 100644 --- a/init.lua +++ b/init.lua @@ -3,3 +3,4 @@ illuminati = {} dofile(minetest.get_modpath('illuminati')..'/chats.lua') dofile(minetest.get_modpath('illuminati')..'/nodes.lua') dofile(minetest.get_modpath('illuminati')..'/relics.lua') +dofile(minetest.get_modpath('illuminati')..'/abms.lua') diff --git a/nodes.lua b/nodes.lua index 60fbca1..642285e 100644 --- a/nodes.lua +++ b/nodes.lua @@ -98,9 +98,23 @@ minetest.register_node('illuminati:core_on',{ fixed = {-.4, -.5, -.4, .4, .5, .4}, }, on_construct = function(pos) - print 'seeing if this calls when the node is placed.' - -- I'll eventually make something happen more than changing the nodes. - -- Maybe the crystals with generate some items or do something. + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + inv:set_size('main', 8*4) + inv:set_size('dst', 1) + meta:set_string('formspec', + 'size[8,6]'.. + 'label[2.65,0;#_#~~ ^ |-| ^ ~~#_#]'.. + 'list[current_name;dst;3.5,1;1,1;]'.. + 'list[current_player;main;0,2.25;8,4;]'.. + 'listring[]') + end, + on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local damage_chance = math.random(1,2) + if damage_chance == 1 then + local hp = player:get_hp() + player:set_hp(hp - 1) + end end, after_dig_node = function(pos) local ps1 = {x=pos.x-3, y=pos.y-1, z=pos.z}