added hoe bome as lucky block prize

This commit is contained in:
TenPlus1 2018-04-09 11:31:48 +01:00
parent a4e8182d90
commit 1a2bc350c5
5 changed files with 149 additions and 1 deletions

View File

@ -13,6 +13,7 @@ This mod works by adding your new plant to the {growing=1} group and numbering t
Changelog: Changelog:
1.35 - Deprecated bronze/mese/diamond hoe's, added hoe bomb and deprecated hoe's as lucky block prizes
1.34 - Added scarecrow Base (5x sticks in a cross shape) 1.34 - Added scarecrow Base (5x sticks in a cross shape)
1.33 - Added cooking utensils (wooden bowl, saucepan, cooking pot, baking tray, skillet, cutting board, mortar & pestle, juicer, glass mixing bowl) for easier food crafts. 1.33 - Added cooking utensils (wooden bowl, saucepan, cooking pot, baking tray, skillet, cutting board, mortar & pestle, juicer, glass mixing bowl) for easier food crafts.
1.32 - Added Pea plant (textures by Andrey01) - also added Wooden Bowl and Pea Soup crafts 1.32 - Added Pea plant (textures by Andrey01) - also added Wooden Bowl and Pea Soup crafts
@ -56,7 +57,7 @@ Changelog:
0.1 - Fixed growing bug 0.1 - Fixed growing bug
0.0 - Initial release 0.0 - Initial release
Lucky Blocks: 25 Lucky Blocks: 28
License of media (textures): License of media (textures):

143
hoebomb.lua Normal file
View File

@ -0,0 +1,143 @@
-- load support for intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
-- creative check
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
function is_creative(name)
return creative_mode_cache or minetest.check_player_privs(name, {creative = true})
end
-- hoe bomb function
local function hoe_area(pos)
local r = 5 -- radius
-- remove flora (grass, flowers etc.)
local res = minetest.find_nodes_in_area(
{x = pos.x - r, y = pos.y - 1, z = pos.z - r},
{x = pos.x + r, y = pos.y + 2, z = pos.z + r},
{"group:flora"})
for n = 1, #res do
minetest.swap_node(res[n], {name = "air"})
end
-- replace dirt with tilled soil
res = nil
res = minetest.find_nodes_in_area_under_air(
{x = pos.x - r, y = pos.y - 1, z = pos.z - r},
{x = pos.x + r, y = pos.y + 2, z = pos.z + r},
{"group:soil"})
for n = 1, #res do
minetest.swap_node(res[n], {name = "farming:soil"})
end
end
-- throwable hoe bomb
minetest.register_entity("farming:hoebomb_entity", {
physical = true,
visual = "sprite",
visual_size = {x = 1.0, y = 1.0},
textures = {"farming_hoe_bomb.png"},
collisionbox = {0,0,0,0,0,0},
lastpos = {},
player = "",
on_step = function(self, dtime)
if not self.player then
self.object:remove()
return
end
local pos = self.object:get_pos()
if self.lastpos.x ~= nil then
local vel = self.object:getvelocity()
-- only when potion hits something physical
if vel.x == 0
or vel.y == 0
or vel.z == 0 then
if self.player ~= "" then
-- round up coords to fix glitching through doors
self.lastpos = vector.round(self.lastpos)
hoe_area(self.lastpos)
end
self.object:remove()
return
end
end
self.lastpos = pos
end
})
-- actual throwing function
local function throw_potion(itemstack, player)
local playerpos = player:get_pos()
local obj = minetest.add_entity({
x = playerpos.x,
y = playerpos.y + 1.5,
z = playerpos.z
}, "farming:hoebomb_entity")
local dir = player:get_look_dir()
local velocity = 20
obj:setvelocity({
x = dir.x * velocity,
y = dir.y * velocity,
z = dir.z * velocity
})
obj:setacceleration({
x = dir.x * -3,
y = -9.5,
z = dir.z * -3
})
obj:setyaw(player:get_look_yaw() + math.pi)
obj:get_luaentity().player = player
end
-- hoe bomb item
minetest.register_craftitem("farming:hoe_bomb", {
description = S("Hoe Bomb (use or throw on grassy areas to hoe land"),
inventory_image = "farming_hoe_bomb.png",
groups = {flammable = 2, not_in_creative_inventory = 1},
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type == "node" then
hoe_area(pointed_thing.above)
else
throw_potion(itemstack, user)
if not is_creative(user:get_player_name()) then
itemstack:take_item()
return itemstack
end
end
end,
})

View File

@ -660,4 +660,5 @@ if farming.donuts then dofile(farming.path.."/donut.lua") end
dofile(farming.path.."/mapgen.lua") dofile(farming.path.."/mapgen.lua")
dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility
dofile(farming.path.."/hoebomb.lua")
dofile(farming.path.."/lucky_block.lua") dofile(farming.path.."/lucky_block.lua")

View File

@ -10,6 +10,7 @@ if minetest.get_modpath("lucky_block") then
{"nod", "farming:jackolantern", 0}, {"nod", "farming:jackolantern", 0},
{"tro", "farming:jackolantern_on"}, {"tro", "farming:jackolantern_on"},
{"nod", "default:river_water_source", 1}, {"nod", "default:river_water_source", 1},
{"tel"},
{"dro", {"farming:trellis", "farming:grapes"}, 5}, {"dro", {"farming:trellis", "farming:grapes"}, 5},
{"dro", {"farming:bottle_ethanol"}, 1}, {"dro", {"farming:bottle_ethanol"}, 1},
{"nod", "farming:melon", 0}, {"nod", "farming:melon", 0},
@ -22,6 +23,7 @@ if minetest.get_modpath("lucky_block") then
{"dro", {"farming:pot"}, 1}, {"dro", {"farming:pot"}, 1},
{"dro", {"farming:baking_tray"}, 1}, {"dro", {"farming:baking_tray"}, 1},
{"dro", {"farming:skillet"}, 1}, {"dro", {"farming:skillet"}, 1},
{"exp", 4},
{"dro", {"farming:mortar_pestle"}, 1}, {"dro", {"farming:mortar_pestle"}, 1},
{"dro", {"farming:cutting_board"}, 1}, {"dro", {"farming:cutting_board"}, 1},
{"dro", {"farming:juicer"}, 1}, {"dro", {"farming:juicer"}, 1},
@ -29,5 +31,6 @@ if minetest.get_modpath("lucky_block") then
{"dro", {"farming:hoe_bronze"}, 1}, {"dro", {"farming:hoe_bronze"}, 1},
{"dro", {"farming:hoe_mese"}, 1}, {"dro", {"farming:hoe_mese"}, 1},
{"dro", {"farming:hoe_diamond"}, 1}, {"dro", {"farming:hoe_diamond"}, 1},
{"dro", {"farming:hoe_bomb"}, 10},
}) })
end end

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B