mirror of
https://notabug.org/TenPlus1/lucky_block.git
synced 2024-08-21 09:44:05 +02:00
Added custom function ability
This commit is contained in:
parent
5313bd6cf7
commit
f7aebd12d4
@ -16,3 +16,4 @@ Changelog:
|
|||||||
- 0.1 - Initial release
|
- 0.1 - Initial release
|
||||||
- 0.2 - New api commands added thanks to blert2112
|
- 0.2 - New api commands added thanks to blert2112
|
||||||
- 0.3 - New blocks added, also error checking, new options and schematic rehaul
|
- 0.3 - New blocks added, also error checking, new options and schematic rehaul
|
||||||
|
- 0.4 - Added ability to add custom functions within lucky blocks
|
||||||
|
22
api.txt
22
api.txt
@ -263,6 +263,28 @@ Strike player and place permanent flame
|
|||||||
{"lig", "fire:permanent_flame"}
|
{"lig", "fire:permanent_flame"}
|
||||||
|
|
||||||
|
|
||||||
|
Custom Function
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This allows mod makers to use there own functions when opening lucky blocks and
|
||||||
|
passes the block position and player opening it.
|
||||||
|
|
||||||
|
{"cus", myfunction}
|
||||||
|
|
||||||
|
e.g.
|
||||||
|
|
||||||
|
Punch player and deal 5 damage points (function first then line to add l.block)
|
||||||
|
|
||||||
|
local function punchy(pos, player)
|
||||||
|
player:punch(player, 1.0, {
|
||||||
|
full_punch_interval = 1.0,
|
||||||
|
damage_groups = {fleshy = 5}
|
||||||
|
}, nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
{"cus", punchy}
|
||||||
|
|
||||||
|
|
||||||
Final Words
|
Final Words
|
||||||
===========
|
===========
|
||||||
|
|
||||||
|
15
init.lua
15
init.lua
@ -3,8 +3,17 @@ lucky_block = {}
|
|||||||
lucky_schems = {}
|
lucky_schems = {}
|
||||||
lucky_block.seed = PseudoRandom(os.time())
|
lucky_block.seed = PseudoRandom(os.time())
|
||||||
|
|
||||||
|
-- example custom function (punches player with 5 damage)
|
||||||
|
local function punchy(pos, player)
|
||||||
|
player:punch(player, 1.0, {
|
||||||
|
full_punch_interval = 1.0,
|
||||||
|
damage_groups = {fleshy = 5}
|
||||||
|
}, nil)
|
||||||
|
end
|
||||||
|
|
||||||
-- default blocks
|
-- default blocks
|
||||||
local lucky_list = {
|
local lucky_list = {
|
||||||
|
{"cus", punchy},
|
||||||
{"fal", {"default:wood", "default:gravel", "default:sand", "default:desert_sand", "default:stone", "default:dirt", "default:goldblock"}, 0},
|
{"fal", {"default:wood", "default:gravel", "default:sand", "default:desert_sand", "default:stone", "default:dirt", "default:goldblock"}, 0},
|
||||||
{"lig"},
|
{"lig"},
|
||||||
{"nod", "lucky_block:super_lucky_block", 0},
|
{"nod", "lucky_block:super_lucky_block", 0},
|
||||||
@ -503,6 +512,12 @@ local lucky_block = function(pos, digger)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- custom function
|
||||||
|
elseif action == "cus" then
|
||||||
|
|
||||||
|
local func = lucky_list[luck][2]
|
||||||
|
|
||||||
|
func(pos, digger)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user