Initial Code Commit

Initial Code Commit from local repository
master
Sirrobzeroone 2022-07-31 17:54:09 +10:00
parent 7b9aafe2b9
commit ec993421c7
29 changed files with 983 additions and 123 deletions

121
LICENSE
View File

@ -1,121 +0,0 @@
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.

View File

@ -1,2 +1,38 @@
# worm_farm
Adds a worm farm to grow worms in primarily for fishing in ethereal
# Worm Farm
Thanks to Tenplus1 for his excellent Ethereal mod and Xanadu server, without those two this mod wouldn't exist.
Simple mod although hopefully fairly feature rich. Adds a Worm Farm to Minetest which can accept most green waste material which the worms will eat and use to reproduce and create more worms which you can then use for fishing. The worms will also produce worm tea (if bonemeal mod and vessels mod are active) and dirt although slowly.
The mod is primarily aimed to be used with Ethereal mod's fishing however I have made it fairly easy to configure if you wish to use it with another game or if theres another fishing mod let me know and I'll add support for it.
## Overview
The Worms in the worm farm are very self-contained and so long as you keep feeding them something they will produce worms for use when fishing. However if you:
- Keep the Worm Farm Hydrated and
- Feed them foods they like
They will produce worms for fishing faster and the population of worms inside the Worm farm will grow, which will also produce worms faster and allow them to eat food faster. Although not a direct simulation of a real life worm farm the worms do like and dislike similar foods to there real life cousins. For example they will rapidly devour melon slices and dislike anything with garlic immensly. The worms in the worm farm will also eat their more favorite foods first.
## API functions
### Register Worm Food/Water
worm_farm.register_worm_food_water(thing_name, amount, return_empty, type)
#### Register Worm Food
Registering a worm food only makes use of the first two fields in the function. The lower the time in seconds the more the worms like the food. It is recommended the lowest you go for their most favorite foods is 4 (seconds). If the defaults are not changed once you exceed 10 secs worm farm population wont increase when they eat that food. Once 20 secs is exceeded the worm population will decline when they eat that food as it i semi-toxic/takes to long for them to eat.
Nodes or items can be registered worms will eat both
example (only provide 1st two values):
worm_farm.register_worm_food_water("default:paper", 7 )
Worms can eat paper and it will take them 7 seconds to eat a single piece if no bonus's or penalties are being applied. Once they finish eating a worm will be avaliable to collect and use for baiting fishing hooks.
#### Register Worm Water
The worm farm needs to be kept moist to keep the worms happy. Additional items can be registered that hydrate/add water to the farm. If not changed the maximum water storage for the farm is 400 units. A bucket of water will hydrate the farm completely where as a glass of carrot juice from farmign redo only adds 100 units of hydration.
Nodes or items can be registered
example (provide all four values):
worm_farm.register_worm_food_water("bucket:bucket_water", 400, "bucket:bucket_empty" , "w")
When the worm farm is right clicked with a bucket of water, it will be filled with 400 units of water/hydration. The player will get an empty bucket back. The "w" flag is so the function knows this is a water registration - bit redundant as I could just check for empty item value, future update maybe.

145
i_add_worm_food_water.lua Normal file
View File

@ -0,0 +1,145 @@
--------------------------------------------------------------
-- _ _ _ _____ --
-- | | | |___ ___ _____ | __|___ ___ _____ --
-- | | | | . | _| | | __|_.|| _| | --
-- |_____|___|_| |_|_|_| |__| |__||_| |_|_|_| --
--------------------------------------------------------------
-- Worm Farm --
--------------------------------------------------------------
-- Add worm food and hydrate items --
--------------------------------------------------------------
---------------
-- Worm Food --
---------------
-- Lower seconds for food indicate worms like the food more
-- very dense/fiberous, high acidic, high aromatic foods they tend to dislike.
if worm_farm.is_default then
-- food
-- worm_farm.register_worm_food_water(reg name, time in seconds)
worm_farm.register_worm_food_water("default:apple", 6)
worm_farm.register_worm_food_water("default:papyrus", 6)
worm_farm.register_worm_food_water("default:paper", 7)
worm_farm.register_worm_food_water("default:book", 15)
worm_farm.register_worm_food_water("default:book_written", 15)
worm_farm.register_worm_food_water("group:flower", 6)
worm_farm.register_worm_food_water("group:grass", 7)
worm_farm.register_worm_food_water("group:leaves", 6)
worm_farm.register_worm_food_water("group:mushroom", 8)
worm_farm.register_worm_food_water("group:sapling", 8)
-- water/hydrate
-- worm_farm.register_worm_food_water(reg name, refill amount, reg name empty vessel, "w" to indicate water/hydrate)
worm_farm.register_worm_food_water("bucket:bucket_water", 400, "bucket:bucket_empty" , "w")
end
if worm_farm.is_ethereal then
-- food
worm_farm.register_worm_food_water("ethereal:golden_apple", 2)
worm_farm.register_worm_food_water("ethereal:banana", 6)
worm_farm.register_worm_food_water("ethereal:lemon", 15)
worm_farm.register_worm_food_water("ethereal:orange", 15)
worm_farm.register_worm_food_water("ethereal:sushi_kappamaki", 5)
worm_farm.register_worm_food_water("ethereal:olive", 8)
-- water/hydrate
worm_farm.register_worm_food_water("ethereal:lemonade", 100, "vessels:drinking_glass", "w")
end
if worm_farm.is_bucket_wooden then
-- water/hydrate
worm_farm.register_worm_food_water("bucket_wooden:bucket_water", 400, "bucket_wooden:bucket_empty", "w")
end
if worm_farm.is_farming then
-- food
worm_farm.register_worm_food_water("farming:wheat", 9)
worm_farm.register_worm_food_water("farming:bread", 8)
end
if worm_farm.is_farming_redo then
--food
worm_farm.register_worm_food_water("farming:apple_pie", 7)
worm_farm.register_worm_food_water("farming:artichoke", 20)
worm_farm.register_worm_food_water("farming:baked_potato", 6)
worm_farm.register_worm_food_water("farming:bread", 8)
worm_farm.register_worm_food_water("farming:bread_slice", 6)
worm_farm.register_worm_food_water("farming:bread_multigrain", 8)
worm_farm.register_worm_food_water("farming:barley", 9)
worm_farm.register_worm_food_water("farming:beans", 6)
worm_farm.register_worm_food_water("farming:beetroot", 7)
worm_farm.register_worm_food_water("farming:blackberry", 5)
worm_farm.register_worm_food_water("farming:blueberries", 5)
worm_farm.register_worm_food_water("farming:cabbage", 4)
worm_farm.register_worm_food_water("farming:carrot", 5)
worm_farm.register_worm_food_water("farming:carrot_gold", 2)
worm_farm.register_worm_food_water("farming:chili_pepper", 25)
worm_farm.register_worm_food_water("farming:cocoa_beans_raw", 6)
worm_farm.register_worm_food_water("farming:cocoa_beans", 6)
worm_farm.register_worm_food_water("farming:chocolate_block", 5)
worm_farm.register_worm_food_water("farming:chocolate_dark", 6)
worm_farm.register_worm_food_water("farming:cookie", 7)
worm_farm.register_worm_food_water("farming:coffee_beans", 4)
worm_farm.register_worm_food_water("farming:corn", 6)
worm_farm.register_worm_food_water("farming:corn_cob", 5)
worm_farm.register_worm_food_water("farming:cucumber", 4)
worm_farm.register_worm_food_water("farming:donut", 6)
worm_farm.register_worm_food_water("farming:donut_chocolate", 6)
worm_farm.register_worm_food_water("farming:donut_apple", 6)
worm_farm.register_worm_food_water("farming:garlic", 25)
worm_farm.register_worm_food_water("farming:garlic_clove", 25)
worm_farm.register_worm_food_water("farming:garlic_braid", 30)
worm_farm.register_worm_food_water("farming:garlic_bread", 20)
worm_farm.register_worm_food_water("farming:grapes", 5)
worm_farm.register_worm_food_water("farming:hemp_leaf", 7)
worm_farm.register_worm_food_water("farming:hemp_fibre", 9)
worm_farm.register_worm_food_water("farming:hemp_block", 15)
worm_farm.register_worm_food_water("farming:jackolantern", 8)
worm_farm.register_worm_food_water("farming:jaffa_cake", 9)
worm_farm.register_worm_food_water("farming:lettuce", 4)
worm_farm.register_worm_food_water("farming:mochi", 8)
worm_farm.register_worm_food_water("farming:melon_slice", 4)
worm_farm.register_worm_food_water("farming:melon_8", 8)
worm_farm.register_worm_food_water("farming:mint_leaf", 6)
worm_farm.register_worm_food_water("farming:oat", 9)
worm_farm.register_worm_food_water("farming:onion", 15)
worm_farm.register_worm_food_water("farming:pasta", 8)
worm_farm.register_worm_food_water("farming:parsley", 6)
worm_farm.register_worm_food_water("farming:pea_pod", 6)
worm_farm.register_worm_food_water("farming:pepper", 7) -- sweet bellpeppers
worm_farm.register_worm_food_water("farming:pepper_yellow", 7)
worm_farm.register_worm_food_water("farming:pepper_red" , 7)
worm_farm.register_worm_food_water("farming:pineapple" , 15)
worm_farm.register_worm_food_water("farming:pineapple_ring", 11)
worm_farm.register_worm_food_water("farming:popcorn", 5)
worm_farm.register_worm_food_water("farming:potato", 8)
worm_farm.register_worm_food_water("farming:potato_salad", 5)
worm_farm.register_worm_food_water("farming:pumpkin_slice", 7)
worm_farm.register_worm_food_water("farming:pumpkin", 9)
worm_farm.register_worm_food_water("farming:pumpkin_bread", 7)
worm_farm.register_worm_food_water("farming:raspberries", 5)
worm_farm.register_worm_food_water("farming:rhubarb", 11)
worm_farm.register_worm_food_water("farming:rhubarb_pie", 7)
worm_farm.register_worm_food_water("farming:rice", 9)
worm_farm.register_worm_food_water("farming:rice_bread", 8)
worm_farm.register_worm_food_water("farming:rye", 9)
worm_farm.register_worm_food_water("farming:spaghetti", 8)
worm_farm.register_worm_food_water("farming:soy_pod", 11)
worm_farm.register_worm_food_water("farming:sunflower", 6)
worm_farm.register_worm_food_water("farming:sunflower_bread", 8)
worm_farm.register_worm_food_water("farming:toast", 7)
worm_farm.register_worm_food_water("farming:toast_sandwich", 7)
worm_farm.register_worm_food_water("farming:tofu", 12)
worm_farm.register_worm_food_water("farming:tofu_cooked", 12)
worm_farm.register_worm_food_water("farming:tomato", 7)
worm_farm.register_worm_food_water("farming:vanilla", 11)
worm_farm.register_worm_food_water("farming:wheat", 9)
worm_farm.register_worm_food_water("group:plant", 7)
-- water/hydrate
worm_farm.register_worm_food_water("farming:glass_water", 100,"vessels:drinking_glass", "w")
worm_farm.register_worm_food_water("farming:carrot_juice", 100,"vessels:drinking_glass", "w")
worm_farm.register_worm_food_water("farming:cactus_juice", 100,"vessels:drinking_glass", "w")
worm_farm.register_worm_food_water("farming:smoothie_berry", 100,"vessels:drinking_glass", "w")
worm_farm.register_worm_food_water("farming:pineapple_juice", 100,"vessels:drinking_glass", "w")
end

38
i_add_worms_dirt.lua Normal file
View File

@ -0,0 +1,38 @@
--------------------------------------------------------------
-- _ _ _ _____ --
-- | | | |___ ___ _____ | __|___ ___ _____ --
-- | | | | . | _| | | __|_.|| _| | --
-- |_____|___|_| |_|_|_| |__| |__||_| |_|_|_| --
--------------------------------------------------------------
-- Worm Farm --
--------------------------------------------------------------
-- Add worms as drop to dirt nodes --
--------------------------------------------------------------
-- add worms as dirt drop
-- default mod dirt drops
if worm_farm.is_default then
worm_farm.register_worm_drop("default:dirt", 40)
worm_farm.register_worm_drop("default:dirt_with_grass", 40)
worm_farm.register_worm_drop("default:dirt_with_rainforest_litter", 30)
worm_farm.register_worm_drop("default:dirt_with_dry_grass", 55)
end
-- farming mod soil drops
if worm_farm.is_farming or worm_farm.is_farming_redo then
worm_farm.register_worm_drop("farming:soil", 40)
worm_farm.register_worm_drop("farming:soil_wet", 35)
worm_farm.register_worm_drop("farming:dry_soil_wet", 55)
end
-- ethereal mod dirt drops
if worm_farm.is_ethereal then
worm_farm.register_worm_drop("ethereal:bamboo_dirt", 40)
worm_farm.register_worm_drop("ethereal:jungle_dirt", 30)
worm_farm.register_worm_drop("ethereal:grove_dirt", 40)
worm_farm.register_worm_drop("ethereal:prairie_dirt", 40)
worm_farm.register_worm_drop("ethereal:crystal_dirt", 45)
worm_farm.register_worm_drop("ethereal:mushroom_dirt", 45)
worm_farm.register_worm_drop("ethereal:gray_dirt", 55)
end

349
i_functions.lua Normal file
View File

@ -0,0 +1,349 @@
--------------------------------------------------------------
-- _ _ _ _____ --
-- | | | |___ ___ _____ | __|___ ___ _____ --
-- | | | | . | _| | | __|_.|| _| | --
-- |_____|___|_| |_|_|_| |__| |__||_| |_|_|_| --
--------------------------------------------------------------
-- Worm Farm --
--------------------------------------------------------------
-- Functions --
--------------------------------------------------------------
-- translation
local S = worm_farm.translate
-- register worm food/water
function worm_farm.register_worm_food_water(name, time_amount, rtn_empty, flag)
local insert_table = worm_farm.worm_foods
local sub_tab = "ind"
local sec_wat = "sec"
if flag == "w" then
insert_table = worm_farm.worm_hydrate
sec_wat = "water"
end
if string.find(name, "group:") then
sub_tab = "grp"
end
table.insert(insert_table[sub_tab], {name = name ,[sec_wat] = time_amount, empty = rtn_empty})
end
-- register dirt nodes drop worms
function worm_farm.register_worm_drop(dirt_name, rare)
local existing_drops
local new_drops = {}
new_drops.items = {}
local is_insert = true
if type(minetest.registered_nodes[dirt_name].drop) == "table" then
existing_drops = table.copy(minetest.registered_nodes[dirt_name].drop)
new_drops.max_items = existing_drops.max_items + 1
-- drop items structure has 2x word "items" as keys one below
-- the other in the table structure easy to get confused
-- https://minetest.gitlab.io/minetest/definition-tables/#node-definition
for _, item in pairs(existing_drops.items) do -- top items
item.rarity = item.rarity or 0 -- catch nils turn to 0
-- our worm item needs to be inserted
-- in the correct rarity order
if rare < item.rarity then
if item.rarity == 0 then item.rarity = nil end -- catch 0 turn back to nil
table.insert(new_drops.items,item)
elseif rare >= item.rarity and is_insert then
if item.rarity == 0 then item.rarity = nil end -- catch 0 turn back to nil
table.insert(new_drops.items,{items = {worm_farm.nodes.worm},rarity = rare})
table.insert(new_drops.items,item)
is_insert = false
else
if item.rarity == 0 then item.rarity = nil end -- catch 0 turn back to nil
table.insert(new_drops.items,item)
end
end
else
existing_drops = minetest.registered_nodes[dirt_name].drop
new_drops.max_items = 2
table.insert(new_drops.items,{items = {worm_farm.nodes.worm},rarity = rare})
table.insert(new_drops.items,{items = {existing_drops}})
end
minetest.override_item(dirt_name, {
drop = new_drops
})
end
-- node/item name/group check - flag is optional
function worm_farm.name_group(thing_name, flag)
local check_table = worm_farm.worm_foods
local found = false
local thing_def
if flag == "w" then
check_table = worm_farm.worm_hydrate
end
-- name check first
for _, item in ipairs(check_table.ind) do
if item.name == thing_name then
found = true
thing_def = item
break
end
end
-- group check second
if not found then
for _, item in ipairs(check_table.grp) do
local name_split = string.split(item.name, ":")
local group = minetest.get_item_group(thing_name, name_split[2])
if group ~= 0 then
found = true
thing_def = item
break
end
end
end
-- found must be first result returned
return found, thing_def
end
-- worm farm formspec
function worm_farm.worm_farm_form(pos)
local n_meta = minetest.get_meta(pos)
local w_lvl = n_meta:get_int("water_level")
local p_lvl = n_meta:get_int("worm_pop")
local time_end = n_meta:get_int("time_end")
local time_cnt = n_meta:get_int("time_cnt")
local pop_sum = S("Critical")
local w_lvl_p = math.floor((w_lvl/worm_farm.water_max)*100)
local p_lvl_p = math.floor((p_lvl/worm_farm.pop_max)*100)
local t_lvl_p = math.floor((time_cnt/time_end)*100)
local l_name = pos.x..","..pos.y..","..pos.z
local bonemeal = ""
local tt_worm_food = S("Worm Food")
local tt_water_stored = S("Water Stored")
local tt_worm_pop = S("Worm Population")
if p_lvl > worm_farm.pop_crit and p_lvl < worm_farm.pop_med then pop_sum = S("Low")
elseif p_lvl >= worm_farm.pop_med and p_lvl < worm_farm.pop_high then pop_sum = S("Medium")
elseif p_lvl >= worm_farm.pop_high then pop_sum = S("High")
end
if worm_farm.is_bonemeal and worm_farm.is_vessels then
bonemeal = "list[nodemeta:"..l_name..";empty_bottle;3.25,3.5;1,1;0]"..
"image[3.25,3.5;1,1;"..worm_farm.textures.bottle.."^[opacity:32]"
end
local form = "formspec_version[4]"..
"size[10.25,10.25]"..
"list[nodemeta:"..l_name..";worm_food;2,1;3,1;0]"..
"tooltip[2,1;3,1;"..tt_worm_food.."]"..
"image[1.75,2.25;1,1;"..worm_farm.textures.dirt.."]"..
"image[2.75,2.25;1,1;"..worm_farm.textures.dirt.."]"..
"image[3.75,2.25;1,1;"..worm_farm.textures.dirt.."]"..
"image[4.75,2.25;1,1;"..worm_farm.textures.dirt.."]"..bonemeal..
"image[6,2.25;1,1;"..worm_farm.textures.worm.."^[colorize:#3a3a3a:200^[lowpart:"..t_lvl_p..":"..worm_farm.textures.worm.."]"..
"image[0.4,0.5;0.5,3.5;worm_farm_meter_back.png^[lowpart:"..w_lvl_p..":worm_farm_meter_water.png]"..
"image[0.4,0.5;0.5,3.5;worm_farm_meter_front.png]"..
"image[0.4,4.15;0.5,0.5;worm_farm_icon_fluid_water.png]"..
"tooltip[0.4,4.15;0.75,0.75;"..tt_water_stored..": "..w_lvl_p.."%]"..
"image[1.25,0.5;0.25,3.5;worm_farm_meter_pop_back.png^[lowpart:"..p_lvl_p..":worm_farm_meter_pop_pop.png]"..
"image[1.25,0.5;0.25,3.5;worm_farm_meter_pop_front.png]"..
"image[1.15,4.15;.5,.5;"..worm_farm.textures.worm.."]"..
"tooltip[1.15,4.15;0.75,0.75;"..tt_worm_pop..": "..pop_sum.."]"..
"list[nodemeta:"..l_name..";output;7.25,1;2,3;0]"..
"list[current_player;main;0.25,5;8,1;0]"..
"list[current_player;main;0.25,6.5;8,3;8]"
return form
end
-- worm breeding/replication code
function worm_farm.timer_replicate(pos, elapsed)
local timer = minetest.get_node_timer(pos)
local n_meta = minetest.get_meta(pos)
local rep_cycle = n_meta:get_int("rep_cycle")
local time_end = n_meta:get_int("time_end")
local time_cnt = n_meta:get_int("time_cnt")
local worm_pop = n_meta:get_int("worm_pop")
local worm_tea = n_meta:get_int("worm_tea")
local worm_dirt = n_meta:get_int("worm_dirt")
local water_level = n_meta:get_int("water_level")
local inv = n_meta:get_inventory()
local worm_stack = ItemStack(worm_farm.nodes.worm.." 1")
local bottle_stack = ItemStack(worm_farm.nodes.bottle.." 1")
local tea_stack = ItemStack("worm_farm:worm_tea 1")
local dirt_stack = ItemStack(worm_farm.nodes.dirt.." 1")
if time_cnt >= time_end then
if rep_cycle == 0 and inv:is_empty("worm_food") then
n_meta:set_int("time_cnt", 0)
n_meta:set_string("formspec", worm_farm.worm_farm_form(pos))
return false -- false timer no longer runs
elseif not inv:room_for_item("output", worm_stack) then
n_meta:set_int("time_cnt", 0)
n_meta:set_string("formspec", worm_farm.worm_farm_form(pos))
return false
-- should never end up here but left as catch
else
-- This else produces a worm and sets up the next timer cycle
-- add a worm
if rep_cycle == 1 then
inv:add_item("output", worm_stack)
-- bonus worm(s) if population is high
if worm_pop >= worm_farm.pop_high then
for inv_loc = 1,worm_farm.pop_high_b,1 do
if inv:room_for_item("output", worm_stack) then
inv:add_item("output", worm_stack)
end
end
end
-- check worm_tea
if worm_farm.is_bonemeal and not inv:is_empty("empty_bottle") then
if worm_tea >= worm_farm.worm_tea then
if inv:room_for_item("output", tea_stack) then
inv:add_item("output", tea_stack)
inv:remove_item("empty_bottle", bottle_stack)
n_meta:set_int("worm_tea",0)
else
n_meta:set_string("formspec", worm_farm.worm_farm_form(pos))
return false
end
else
if worm_pop >= worm_farm.pop_high then
n_meta:set_int("worm_tea",worm_tea+1+worm_farm.pop_high_b)
else
n_meta:set_int("worm_tea",worm_tea+1)
end
end
end
-- check worm_dirt
if worm_dirt >= worm_farm.dirt then
if inv:room_for_item("output", dirt_stack) then
inv:add_item("output", dirt_stack)
n_meta:set_int("worm_dirt",0)
else
n_meta:set_int("time_cnt", 0)
n_meta:set_string("formspec", worm_farm.worm_farm_form(pos))
return false
end
else
if worm_pop >= worm_farm.pop_high then
n_meta:set_int("worm_dirt",worm_dirt+1+worm_farm.pop_high_b)
else
n_meta:set_int("worm_dirt",worm_dirt+1)
end
end
end
-- next cycle check and start
if inv:is_empty("worm_food") or not inv:room_for_item("output", worm_stack) then
n_meta:set_int("rep_cycle", 0)
n_meta:set_int("time_cnt", 0)
n_meta:set_string("formspec", worm_farm.worm_farm_form(pos))
return false
else
-- find the location of our favorite worm food
-- inside worm_food inventory basically the item
-- with the lowest time in sec's
local wf_size = inv:get_size("worm_food")
local stack
local base_secs = 10
local pop_bonus = 0
local water_bonus = 0
local time_secs = 10
local min_sec = 9999
for inv_loc = 1,wf_size,1 do
local temp_stack = inv:get_stack("worm_food", inv_loc)
if not temp_stack:is_empty() then
local found, food_def = worm_farm.name_group(temp_stack:get_name())
if found and food_def.sec < min_sec then
stack = temp_stack
base_secs = food_def.sec
min_sec = food_def.sec
end
end
end
-- Did we find any items worms can eat if not end
if not stack then n_meta:set_int("rep_cycle", 0) return false end
-- use food, not being specific in regards to inv position
inv:remove_item("worm_food", stack:get_name().." 1")
-- check if we have water
if water_level > 0 then
water_bonus = worm_farm.water_bonus
n_meta:set_int("water_level", water_level - worm_farm.water_use)
end
-- check for population bonus/penalty
if worm_pop <= worm_farm.pop_crit then
pop_bonus = -1 * worm_farm.pop_crit_b
elseif worm_pop >= worm_farm.pop_med then
pop_bonus = worm_farm.pop_med_b
if worm_pop >= worm_farm.pop_high then
pop_bonus = pop_bonus + worm_farm.pop_med_b
end
end
-- calculate our replication time for next cycle
-- and start timer
time_secs = base_secs - water_bonus - pop_bonus
if time_secs < 1 then
time_secs = 1
end
n_meta:set_int("status",1)
n_meta:set_int("rep_cycle", 1)
n_meta:set_int("time_end",time_secs)
n_meta:set_int("time_cnt",0)
minetest.get_node_timer(pos):start(1.0) -- redundant
-- check and increase/decrease our population
if water_bonus ~= 0 and base_secs <= worm_farm.food_pop then
-- worm population increases by 5% each cycle
worm_pop = math.ceil(worm_pop+(worm_pop*0.05))
if worm_pop > worm_farm.pop_max then
worm_pop = worm_farm.pop_max
end
n_meta:set_int("worm_pop",worm_pop)
elseif water_bonus <= 0 or base_secs > worm_farm.food_pop_d then
-- no water, worm numbers decrease by 5% each cycle
worm_pop = math.floor(worm_pop-(worm_pop*0.05))
if worm_pop < worm_farm.pop_min then
worm_pop = worm_farm.pop_min
end
n_meta:set_int("worm_pop",worm_pop)
end
end
end
else
-- increment timer
n_meta:set_int("time_cnt", time_cnt+1)
end
-- update formspec
n_meta:set_string("formspec", worm_farm.worm_farm_form(pos))
return true
end

189
i_nodes_items.lua Normal file
View File

@ -0,0 +1,189 @@
--------------------------------------------------------------
-- _ _ _ _____ --
-- | | | |___ ___ _____ | __|___ ___ _____ --
-- | | | | . | _| | | __|_.|| _| | --
-- |_____|___|_| |_|_|_| |__| |__||_| |_|_|_| --
--------------------------------------------------------------
-- Worm Farm --
--------------------------------------------------------------
-- Register Nodes, Items and Recipes --
--------------------------------------------------------------
-- translation
local S = worm_farm.translate
-- deregister ethereal worm recipe
if worm_farm.is_ethereal then
minetest.clear_craft({
output = "ethereal:worm",
recipe = {
{"default:dirt","default:dirt"}
}
})
end
-- Register recipe
minetest.register_craft({
output = "worm_farm:worm_farm",
recipe = {
{worm_farm.nodes.wood,worm_farm.nodes.wood,worm_farm.nodes.wood},
{worm_farm.nodes.worm,worm_farm.nodes.soil,worm_farm.nodes.worm},
{worm_farm.nodes.wood,worm_farm.nodes.wood,worm_farm.nodes.wood}
}
})
-- Register Node
minetest.register_node("worm_farm:worm_farm", {
description = S("Worm Farm"),
drawtype = "normal",
paramtype2 = "facedir",
tiles = {"worm_farm_farm_top.png",
"worm_farm_farm_bottom.png",
"worm_farm_farm_side.png"},
groups = {choppy = 2, oddly_breakable_by_hand = 3},
sounds = worm_farm.sounds.sound_wood,
after_place_node = function(pos, placer)
local n_meta = minetest.get_meta(pos)
n_meta:set_string("infotext", S("Worm Farm"))
n_meta:set_string("formspec", worm_farm.worm_farm_form(pos))
n_meta:set_int("rep_cycle",0)
n_meta:set_int("time_end",0)
n_meta:set_int("time_cnt",0)
n_meta:set_int("water_level",0)
n_meta:set_int("worm_tea",0)
n_meta:set_int("worm_dirt",0)
n_meta:set_int("worm_pop",2)
local inv = n_meta:get_inventory()
inv:set_size("worm_food", 3)
inv:set_size("empty_bottle",1)
inv:set_size("output",6)
end,
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local n_meta = minetest.get_meta(pos);
-- this is(maybe was)the offical way to close node formspec - blank it
-- https://github.com/minetest/minetest/pull/4675#issuecomment-257179262
-- still results in a flicker of the underlying formspec before blanking.
n_meta:set_string("formspec", "")
-- Adding water check
local is_water, water_def = worm_farm.name_group(itemstack:get_name(),"w")
if is_water then
cur_water_level = n_meta:get_int("water_level")
add_water = water_def.water
new_water_level = cur_water_level + add_water
if new_water_level > worm_farm.water_max then
new_water_level = worm_farm.water_max
end
-- I had some issues with set_wielded_item and items that stack
-- even inv:set_stack had similar issue not sure if bug or me?
local s_max = itemstack:get_stack_max()
itemstack:take_item()
if s_max == 1 then
player:set_wielded_item(water_def.empty.." 1")
else
local inv = player:get_inventory()
if inv:room_for_item("main", water_def.empty.." 1") then
inv:add_item("main", water_def.empty.." 1")
else
minetest.item_drop(water_def.empty.." 1", player, player:get_pos())
end
end
n_meta:set_int("water_level",new_water_level)
-- restore the formspec - if it's not done here there
-- can be an empty click when next clicking without water item
minetest.after(0.2, function()
n_meta:set_string("formspec", worm_farm.worm_farm_form(pos))
end)
else
n_meta:set_string("formspec", worm_farm.worm_farm_form(pos))
end
end,
on_receive_fields = function(pos, formname, fields, sender)
end,
on_timer = worm_farm.timer_replicate,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname == "output" then
return 0
elseif listname == "empty_bottle" then
if stack:get_name() == worm_farm.nodes.bottle then
return stack:get_count()
else
return 0
end
elseif listname == "worm_food" then
if worm_farm.name_group(stack:get_name()) then
return stack:get_count()
else
return 0
end
end
end,
on_metadata_inventory_put = function(pos)
minetest.get_node_timer(pos):start(1.0)
end,
on_metadata_inventory_move = function(pos)
minetest.get_node_timer(pos):start(1.0)
end,
on_metadata_inventory_take = function(pos)
minetest.get_node_timer(pos):start(1.0)
end,
can_dig = function(pos, player)
local n_meta = minetest.get_meta(pos);
local inv = n_meta:get_inventory()
return inv:is_empty("worm_food") and inv:is_empty("output") and inv:is_empty("empty_bottle")
end
})
-- Register Worm Tea Concentrate - made this strength 4 its very strong irl
if worm_farm.is_bonemeal and worm_farm.is_vessels then
minetest.register_craftitem("worm_farm:worm_tea", {
description = S("Worm Tea Concentrate"),
inventory_image = "worm_farm_worm_tea.png",
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then
return
end
if minetest.is_protected(pointed_thing.under, user:get_player_name()) then
return
end
if bonemeal:on_use(pointed_thing.under, 4) then
if not bonemeal.is_creative(user:get_player_name()) then
itemstack:take_item()
local inv = user:get_inventory()
if inv:room_for_item("main", worm_farm.nodes.bottle.." 1") then
inv:add_item("main", worm_farm.nodes.bottle.." 1")
else
minetest.item_drop(worm_farm.nodes.bottle.." 1", user, user:get_pos())
end
end
end
return itemstack
end
})
end

117
init.lua Normal file
View File

@ -0,0 +1,117 @@
--------------------------------------------------------------
-- _ _ _ _____ --
-- | | | |___ ___ _____ | __|___ ___ _____ --
-- | | | | . | _| | | __|_.|| _| | --
-- |_____|___|_| |_|_|_| |__| |__||_| |_|_|_| --
--------------------------------------------------------------
-- Worm Farm --
--------------------------------------------------------------
-- https://patorjk.com/software/taag - Rectangles --
--------------------------------------------------------------
-----------------
-- Basic Setup --
-----------------
-- modname and path
local m_name = minetest.get_current_modname()
local m_path = minetest.get_modpath(m_name)
-- setup mod global table/sub tables
worm_farm = {}
worm_farm.nodes = {}
worm_farm.textures = {}
worm_farm.sounds = {}
worm_farm.worm_foods = {}
worm_farm.worm_foods.ind = {}
worm_farm.worm_foods.grp = {}
worm_farm.worm_hydrate = {}
worm_farm.worm_hydrate.ind = {}
worm_farm.worm_hydrate.grp = {}
-- worm farm settings
worm_farm.water_max = 400 -- storage max in farm
worm_farm.water_use = 1 -- water used to create 1 worm
worm_farm.water_bonus = 2 -- number of seconds removed for having water
worm_farm.worm_tea = 198 -- Number of worms produced to get 1x worm tea
worm_farm.dirt = 297 -- Number of worms produced to get 1x dirt
worm_farm.pop_crit = 30 -- worm population density critical limit - less than or equal
worm_farm.pop_crit_b = 4 -- worm density critical time penalty
worm_farm.pop_med = 120 -- worm population density medium limit - greater than or equal
worm_farm.pop_med_b = 1 -- worm density medium time bonus
worm_farm.pop_high = 175 -- worm population density high limit - greater than or equal
worm_farm.pop_high_b = 1 -- worm density high output bonus worm, bonus tea/dirt count (player also gets medium bonus x2)
worm_farm.pop_max = 200 -- worm population density max
worm_farm.pop_min = 2 -- worm population density min
worm_farm.food_pop = 10 -- Any food with a value above this will prevent population growth (worms hate food)
worm_farm.food_pop_d = 20 -- Any food with a value above this will cause population to decline (toxic to worms)
-- translation
worm_farm.translate = minetest.get_translator(m_name)
-- conditional mods
worm_farm.is_default = minetest.get_modpath("default")
worm_farm.is_ethereal = minetest.get_modpath("ethereal")
worm_farm.is_bonemeal = minetest.get_modpath("bonemeal")
worm_farm.is_vessels = minetest.get_modpath("vessels")
worm_farm.is_farming = minetest.get_modpath("farming")
worm_farm.is_bucket_wooden = minetest.get_modpath("bucket_wooden")
-- farming_redo check
if worm_farm.is_farming and farming.mod then
worm_farm.is_farming_redo = minetest.get_modpath("farming")
worm_farm.is_farming = nil
end
----------------------------
-- Int/Ext Resource Setup --
----------------------------
-- worm_farm internal fallbacks
-- Nodes/Items
worm_farm.nodes.worm = "worm_farm:worm"
worm_farm.nodes.dirt = "mapgen_stone"
worm_farm.nodes.soil = "group:crumbly"
worm_farm.nodes.wood = "group:choppy"
worm_farm.nodes.bottle = ""
-- Textures
worm_farm.textures.worm = "worm_farm_worm.png"
worm_farm.textures.dirt = "worm_farm_dirt.png"
worm_farm.textures.bottle = ""
-- Sounds
worm_farm.sounds.sound_wood = {}
-- external mod integration
if worm_farm.is_default then
-- Nodes/Items
worm_farm.nodes.dirt = "default:dirt"
worm_farm.nodes.soil = "group:soil"
worm_farm.nodes.wood = "group:wood"
-- Textures
worm_farm.textures.dirt = "default_dirt.png"
-- Sounds
worm_farm.sounds.sound_wood = default.node_sound_wood_defaults()
end
if worm_farm.is_vessels then
-- Nodes/Items
worm_farm.nodes.bottle = "vessels:glass_bottle"
-- Textures
worm_farm.textures.bottle = "vessels_glass_bottle.png"
end
if worm_farm.is_ethereal then
-- Nodes/Items
worm_farm.nodes.worm = "ethereal:worm"
--Textures
worm_farm.textures.worm = "ethereal_worm.png"
end
dofile(m_path .. "/i_functions.lua")
dofile(m_path .. "/i_add_worms_dirt.lua")
dofile(m_path .. "/i_add_worm_food_water.lua")
dofile(m_path .. "/i_nodes_items.lua")

40
license.txt Normal file
View File

@ -0,0 +1,40 @@
---------------------------------------------------
-- __ _ --
-- | | |_|___ ___ ___ ___ ___ --
-- | |__| | _| -_| |_ -| -_| --
-- |_____|_|___|___|_|_|___|___| --
---------------------------------------------------
-- CC0 1.0 Universal --
---------------------------------------------------
-- To the extent possible under law, --
-- SirrobZeroone has waived all copyright and --
-- related or neighboring rights to this work. --
-- This work is published from: Australia. --
---------------------------------------------------
Applies to 3d models, textures and lua code/script
https://creativecommons.org/publicdomain/zero/1.0/
CC0 1.0 Universal (CC0 1.0)
Public Domain Dedication
This is a human-readable summary of the Legal Code
read the full text:https://creativecommons.org/publicdomain/zero/1.0/legalcode
No Copyright
The person who associated a work with this deed has dedicated the work to the public domain
by waiving all of his or her rights to the work worldwide under copyright law, including all
related and neighboring rights, to the extent allowed by law.
You can copy, modify, distribute and perform the work, even for commercial purposes, all without
asking permission. See Other Information below.
Other Information
In no way are the patent or trademark rights of any person affected by CC0, nor are the rights
that other persons may have in the work or in how the work is used, such as publicity or privacy rights.
Unless expressly stated otherwise, the person who associated a work with this deed makes no warranties
about the work, and disclaims liability for all uses of the work, to the fullest extent
permitted by applicable law. When using or citing the work, you should not imply endorsement by
the author or the affirmer.

View File

@ -0,0 +1,10 @@
# textdomain:worm_farm
Critical=
Low=
Medium=
High=
Worm Food=
Water Stored=
Worm Population=
Worm Farm=
Worm Tea Concentrate=

10
locale/worm_farm.de.tr Normal file
View File

@ -0,0 +1,10 @@
# textdomain:worm_farm
Critical=Kritisch
Low=Niedrig
Medium=Mittel
High=Hoch
Worm Food=Wurmfutter
Water Stored=Wasser Gespeichert
Worm Population=Wurm Population
Worm Farm=Wurm Bauernhof
Worm Tea Concentrate= Wurm Tee Konzentrat

10
locale/worm_farm.es.tr Normal file
View File

@ -0,0 +1,10 @@
# textdomain:worm_farm
Critical=Crítico
Low=Bajo
Medium=Medio
High=Alto
Worm Food=Comida de Gusano
Water Stored=Agua Almacenada
Worm Population=Población de Gusanos
Worm Farm=Granja de Gusanos
Worm Tea Concentrate= Concentrado de Té de Lombriz

10
locale/worm_farm.fr.tr Normal file
View File

@ -0,0 +1,10 @@
# textdomain:worm_farm
Critical=Critique
Low=Bas
Medium=Moyen
High=Haute
Worm Food=Nourriture pour les Vers
Water Stored=L'eau Stockée
Worm Population=Population de vers
Worm Farm=Ferme de vers
Worm Tea Concentrate=Concentré de Thé de Vers

10
locale/worm_farm.ru.tr Normal file
View File

@ -0,0 +1,10 @@
# textdomain:worm_farm
Critical=Критический
Low=Низкий
Medium=Середина
High=Высокая
Worm Food=Червячная Eда
Water Stored=Вода Xранится
Worm Population=Популяция червей
Worm Farm=Червячная ферма
Worm Tea Concentrate=Концентрат червячного чая

10
locale/worm_farm.zh_CN.tr Normal file
View File

@ -0,0 +1,10 @@
# textdomain:worm_farm
Critical=批判的
Low=低的
Medium=中等的
High=高的
Worm Food=蠕虫食物
Water Stored=蓄水
Worm Population=蠕虫种群 人口
Worm Farm=蠕虫农场
Worm Tea Concentrate=虫茶浓缩液

7
mod.conf Normal file
View File

@ -0,0 +1,7 @@
name = worm_farm
description = Adds a way for worms to be cultivated for fishing - designed for use with Ethereal
depends =
optional_depends = default, ethereal, bonemeal, farming, vessels
author = Sirrobzeroone
release = 0.1
title = Worm Farm

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
textures/worm_farm_dirt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

BIN
textures/worm_farm_worm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 719 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 B