Compare commits

...

5 Commits

Author SHA1 Message Date
Dorian Wouters 0b135bf1b4 Merge pull request #1 from Thomas--S/recipe_fix
Fix recipe bug
2017-02-25 13:30:01 -05:00
Thomas--S 9cb31b5335 Fix recipe bug
Remove a unnecessary space to make the mod work with unified_inventory
2017-02-25 08:57:47 +01:00
Wouters Dorian f13da8bbf9 Update README.md 2015-11-01 16:17:23 +01:00
Wouters Dorian ab3f6020bd Support Farming Redo soil wetting, Support cactus, papyrus and tree growth 2015-11-01 16:14:25 +01:00
Wouters Dorian 6b22898557 Make unbreakable and refillable with water sources 2015-10-31 16:04:52 +01:00
2 changed files with 101 additions and 7 deletions

View File

@ -31,6 +31,8 @@ The bucket is **not** consumed, only the water it contains is.
* Wet soils
* Speed up crop growth
* Grow cactus and papyrus
* Grow trees
* Spread grass
* Convert dry grass to normal grass
* Put out fires

106
init.lua
View File

@ -2,7 +2,7 @@ local MODNAME = "waterican"
--
-- Waterican (by gravgun)
-- v1.0
-- v1.2
-- A mod that add watering cans that make crops grow faster.
--
-- LICENSE: GPLv3+
@ -22,13 +22,19 @@ local function waternode(user, pos)
return -- dafuq?
end
-- Soil wetting
-- General soil wetting
local soil = nodedef.soil
if soil and node.name == soil.dry then
minetest.set_node(pos, {name=soil.wet})
return
end
-- Farming soil wetting (compatibility with Farming Redo)
if node.name == "farming:soil" then
minetest.set_node(pos, {name="farming:soil_wet"})
return
end
-- Seed growth
if minetest.get_item_group(node.name, "seed") > 0 and nodedef.fertility then
local grow = false
@ -60,6 +66,18 @@ local function waternode(user, pos)
return
end
-- Cactus growth
if node.name == "default:cactus" then
default.grow_cactus(pos, minetest.get_node(pos))
return
end
-- Papyrus growth
if node.name == "default:papyrus" then
default.grow_papyrus(pos, minetest.get_node(pos))
return
end
-- Grow grass on dirt
-- Convery dry grass to grass
if (node.name == "default:dirt" and minetest.find_node_near(pos, 1, {"default:dirt_with_grass"}))
@ -82,6 +100,54 @@ local function waternode(user, pos)
{pos = pos, max_hear_distance = 16, gain = 0.25})
return
end
-- Tree growth
if math.random() > 0.9 then
-- The code in this `if` statement is copied from the `default` mod, therefore is LGPLv2.1+.
-- If Minetest coredevs had the lil' idea to plan ahead, they would have **named** ABMs
-- so we can reuse them OR added a way to force ABMs to trigger on certain nodes.
-- But no, they seem way too dumb for that simple shit.
local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z})
if not node_under then
return
end
local name_under = node_under.name
local is_soil = minetest.get_item_group(name_under, "soil")
if is_soil == 0 then
return
end
local mapgen = minetest.get_mapgen_params().mgname
if node.name == "default:sapling" then
minetest.log("action", "A sapling grows into a tree at "..
minetest.pos_to_string(pos))
if mapgen == "v6" then
default.grow_tree(pos, random(1, 4) == 1)
else
default.grow_new_apple_tree(pos)
end
elseif node.name == "default:junglesapling" then
minetest.log("action", "A jungle sapling grows into a tree at "..
minetest.pos_to_string(pos))
if mapgen == "v6" then
default.grow_jungle_tree(pos)
else
default.grow_new_jungle_tree(pos)
end
elseif node.name == "default:pine_sapling" then
minetest.log("action", "A pine sapling grows into a tree at "..
minetest.pos_to_string(pos))
if mapgen == "v6" then
default.grow_pine_tree(pos)
else
default.grow_new_pine_tree(pos)
end
elseif node.name == "default:acacia_sapling" then
minetest.log("action", "An acacia sapling grows into a tree at "..
minetest.pos_to_string(pos))
default.grow_new_acacia_tree(pos)
end
end
end
local function water(user, minp, maxp, chance)
@ -94,7 +160,7 @@ local function water(user, minp, maxp, chance)
end
end
end
local particle_count = math.random(2, 6) * (maxp.x-minp.x+1) * (maxp.z-minp.z+1)
local particle_count = math.random(1, 4) * (maxp.x-minp.x+1) * (maxp.z-minp.z+1)
for _=0,particle_count do
minetest.add_particle({
pos = {x = rr(minp.x, maxp.x), y = maxp.y + 0.7, z = rr(minp.z, maxp.z) },
@ -122,10 +188,33 @@ local function reg_waterican(def)
local toolname = MODNAME .. ":waterican_" .. def.material
minetest.register_tool(toolname, {
description = "Waterican" .. matname,
liquids_pointable = true,
inventory_image = img,
wield_image = img .. "^[transformFX",
wield_scale = {x = 1, y = 1, z = 6},
on_use = function(itemstack, user, pointed_thing)
local wear = itemstack:get_wear()
-- Refill if pointing at water and not already full
if pointed_thing.type == "node" then
local node = minetest.get_node(pointed_thing.under)
-- Don't check for default, since Watericans that
-- wear out are only available if default is.
if node.name == "default:water_source" then
if wear > 0 then
itemstack:set_wear(0)
minetest.set_node(pointed_thing.under, {name="air"})
return itemstack
end
return
end
end
-- Worn out = no more water.
if wear == 65534 then
return
end
if pointed_thing.type == "node" then
p = pointed_thing.under
if user:get_player_control().sneak then
@ -135,11 +224,14 @@ local function reg_waterican(def)
end
end
if def.uses then
local wearadd = 0
if user:get_player_control().sneak then
itemstack:add_wear(65535/(def.uses*9)+1)
wearadd = 65534/(def.uses*9)+1
else
itemstack:add_wear(65535/def.uses+1)
wearadd = 65534/def.uses+1
end
wearadd = math.min(wearadd, 65534-wear)
itemstack:add_wear(wearadd)
return itemstack
end
end
@ -155,7 +247,7 @@ if default then
minetest.register_craft({
output = out,
recipe = {
{"", " ", item},
{"", "", item},
{item, "bucket:bucket_water", item},
{"", item, ""}
},
@ -165,7 +257,7 @@ if default then
})
end
end
reg_craft(reg_waterican({material = "diamond", materialname = "Diamond", color = "#00FFFF", uses = 60, chance = 0.9}),
reg_craft(reg_waterican({material = "diamond", materialname = "Diamond", color = "#00FFFF", uses = 60, chance = 0.8}),
"default:diamond")
reg_craft(reg_waterican({material = "mese", materialname = "Mese", color = "#FFFF00", uses = 50, chance = 0.7}),
"default:mese_crystal")