added abm to add things to power core.

master
NathanSalapat 2016-11-20 15:07:07 -06:00
parent a6dacd964c
commit 37933b4bbd
4 changed files with 61 additions and 9 deletions

43
abms.lua Normal file
View File

@ -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
})

View File

@ -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, '<Illuminati> Do you have a broken keyboard?')
end
end)
minetest.register_on_dieplayer(function(player)
select_player(player, illuminati.death_message_table)
end)

View File

@ -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')

View File

@ -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}