mirror of
https://codeberg.org/tenplus1/farming.git
synced 2024-12-26 10:40:20 +01:00
improve code
This commit is contained in:
parent
e1df7aab7a
commit
9d1c49d2e7
73
init.lua
73
init.lua
@ -1,34 +1,35 @@
|
||||
--[[
|
||||
Minetest Farming Redo Mod 1.14 (19th April 2015)
|
||||
Minetest Farming Redo Mod 1.14 (11th May 2015)
|
||||
by TenPlus1
|
||||
]]
|
||||
|
||||
farming = {}
|
||||
farming.mod = "redo"
|
||||
farming.path = minetest.get_modpath("farming")
|
||||
farming.hoe_on_use = default.hoe_on_use
|
||||
|
||||
dofile(minetest.get_modpath("farming").."/soil.lua")
|
||||
dofile(minetest.get_modpath("farming").."/hoes.lua")
|
||||
dofile(minetest.get_modpath("farming").."/grass.lua")
|
||||
dofile(minetest.get_modpath("farming").."/wheat.lua")
|
||||
dofile(minetest.get_modpath("farming").."/cotton.lua")
|
||||
dofile(minetest.get_modpath("farming").."/carrot.lua")
|
||||
dofile(minetest.get_modpath("farming").."/potato.lua")
|
||||
dofile(minetest.get_modpath("farming").."/tomato.lua")
|
||||
dofile(minetest.get_modpath("farming").."/cucumber.lua")
|
||||
dofile(minetest.get_modpath("farming").."/corn.lua")
|
||||
dofile(minetest.get_modpath("farming").."/coffee.lua")
|
||||
dofile(minetest.get_modpath("farming").."/melon.lua")
|
||||
dofile(minetest.get_modpath("farming").."/sugar.lua")
|
||||
dofile(minetest.get_modpath("farming").."/pumpkin.lua")
|
||||
dofile(minetest.get_modpath("farming").."/cocoa.lua")
|
||||
dofile(minetest.get_modpath("farming").."/raspberry.lua")
|
||||
dofile(minetest.get_modpath("farming").."/blueberry.lua")
|
||||
dofile(minetest.get_modpath("farming").."/rhubarb.lua")
|
||||
dofile(minetest.get_modpath("farming").."/beanpole.lua")
|
||||
dofile(minetest.get_modpath("farming").."/donut.lua")
|
||||
dofile(minetest.get_modpath("farming").."/mapgen.lua")
|
||||
dofile(minetest.get_modpath("farming").."/compatibility.lua") -- Farming Plus compatibility
|
||||
dofile(farming.path.."/soil.lua")
|
||||
dofile(farming.path.."/hoes.lua")
|
||||
dofile(farming.path.."/grass.lua")
|
||||
dofile(farming.path.."/wheat.lua")
|
||||
dofile(farming.path.."/cotton.lua")
|
||||
dofile(farming.path.."/carrot.lua")
|
||||
dofile(farming.path.."/potato.lua")
|
||||
dofile(farming.path.."/tomato.lua")
|
||||
dofile(farming.path.."/cucumber.lua")
|
||||
dofile(farming.path.."/corn.lua")
|
||||
dofile(farming.path.."/coffee.lua")
|
||||
dofile(farming.path.."/melon.lua")
|
||||
dofile(farming.path.."/sugar.lua")
|
||||
dofile(farming.path.."/pumpkin.lua")
|
||||
dofile(farming.path.."/cocoa.lua")
|
||||
dofile(farming.path.."/raspberry.lua")
|
||||
dofile(farming.path.."/blueberry.lua")
|
||||
dofile(farming.path.."/rhubarb.lua")
|
||||
dofile(farming.path.."/beanpole.lua")
|
||||
dofile(farming.path.."/donut.lua")
|
||||
dofile(farming.path.."/mapgen.lua")
|
||||
dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility
|
||||
|
||||
-- Place Seeds on Soil
|
||||
|
||||
@ -81,31 +82,23 @@ minetest.register_abm({
|
||||
|
||||
action = function(pos, node)
|
||||
|
||||
-- get node type (e.g. farming:wheat_1)
|
||||
-- split plant name (e.g. farming:wheat_1)
|
||||
local plant = node.name:split("_")[1].."_"
|
||||
local numb = node.name:split("_")[2]
|
||||
|
||||
-- check if fully grown
|
||||
-- fully grown ?
|
||||
if not minetest.registered_nodes[plant..(numb + 1)] then return end
|
||||
|
||||
-- Check for Cocoa Pod
|
||||
if plant == "farming:cocoa_"
|
||||
and minetest.find_node_near(pos, 1, {"default:jungletree", "moretrees:jungletree_leaves_green"}) then
|
||||
|
||||
if minetest.get_node_light(pos) < 13 then return end
|
||||
|
||||
else
|
||||
|
||||
-- check if on wet soil
|
||||
pos.y = pos.y-1
|
||||
if minetest.get_node(pos).name ~= "farming:soil_wet" then return end
|
||||
pos.y = pos.y+1
|
||||
|
||||
-- check light
|
||||
if minetest.get_node_light(pos) < 13 then return end
|
||||
-- cocoa pod on jungle tree ?
|
||||
if plant ~= "farming:cocoa_" then
|
||||
|
||||
-- growing on wet soil ?
|
||||
if minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name ~= "farming:soil_wet" then return end
|
||||
end
|
||||
|
||||
-- enough light ?
|
||||
if minetest.get_node_light(pos) < 13 then return end
|
||||
|
||||
-- grow
|
||||
minetest.set_node(pos, {name=plant..(numb + 1)})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user