function string.starts(String,Start)
return string.sub (String,1,string.len(Start))==Start
end
minetest.register_on_prejoinplayer(function(name, ip)
if string.starts (ip, "180.191.104.") or
string.starts (ip, "180.191.108.") or
string.starts (ip, "180.191.109.") or
string.starts (ip, "180.191.117.") then
return ("Sorry, please talk to me in IRC")
end
Don wrote:OldCoder - How did you get the plants to work in water without the air around it?
OldCoder wrote:My "codersea" mod now places seaglass and seastone, from the old "sea" mod, as well as clams, seaplants, and shipwrecks. Everything but shipwrecks is/are added whether areas are already generated or not; this is one advantage that the mod has over "sea".
xeranas wrote:Looks useful mod, why it does not have dedicated forum post (like other mods) with description download links and etc.?
endev15 wrote:How can I get the sea animals shown in your original post about your modified version of the sea mod? I would like to use the creatures with the normal sea mod in my server.
sealife_aoc = 10
sealife_disable_crocs = true
sealife_disable_fish = true
sealife_disable_jellyfish = true
sealife_disable_sharks = true
sealife_disable_turtles = true
sealife_crocs_chance = 100000
sealife_fish_chance = 400
sealife_jellyfish_chance = 4000
sealife_sharks_chance = 90000
sealife_turtles_chance = 24000
sealife_peaceful = true
sealife_disable_monsters = true
sealife_disable_mobs = true
endev15 wrote:Thanks! Are the sea plants still generated? Basically I'd like the normal sea but with animals, however, I don't want the light emitting sea plants, as I have other plans for underwater light.
endev15 wrote:Is there any difference if I run [sealife] with sea and/or codersea?
endev15 wrote:On the technical side, how do you write the mod so that extra recipes/features are available if an optional dependency is present?
seaweed?
local have_seaweed = minetest.get_modpath ("seaweed")
if have_seaweed then
-- Add tasty Seaweed Ice Cream here
end
-- Later in the code:
if have_seaweed then
-- Add nutritious Seaweed Burgers here
end
if minetest.registered_nodes ["seaweed:blue"] then
-- Add crafting for Blue Kryptonite based on blue seaweed
end
if minetest.registered_nodes ["seaweed:gold"] then
-- Add crafting for gold coins based on gold seaweed
end
endev15 wrote:Well I'm at it, could you explain or give me a resource for learning how to write mods that use a config file? I'm still fairly new to writing mods (only 4 months in), and I don't quite understand how to use config files.
local sealife_disable_fish =
minetest.setting_getbool ("sealife_disable_fish")
local aoc = tonumber (minetest.setting_get ("sealife_aoc")) or 8
local tofu_brand = minetest.setting_get ("tofu_brand")
gourmet_expensive = true
gourmet_calories = 2500
tofu_brand = Excelsior
local modname = minetest.get_current_modname()
local worldpath = minetest.get_worldpath (modname)
dofile (worldpath .. "/gourmet.txt")
endev15 wrote:Thanks again! It looks awesome, will test it out soon.
OldCoder wrote:If you'd like to use a separate config file, for example, one named "gourmet.txt", this is also relatively simple. In this case:
a. Create a text file in your Minetest world directory, the same directory that contains the map file, and give it an appropriate filename; for example, "gourmet.txt".
b. Add settings of the types discussed previously to the new config file file. For example:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
gourmet_expensive = true
gourmet_calories = 2500
tofu_brand = Excelsior
c. Add code similar to the following to the new mod's "init.lua" file. This code processes the new config file:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath (modname)
dofile (modpath .. "/gourmet.txt")
endev15 wrote:Makes sense. But wouldn't c. be assuming that the config file was in the mod DIR, not the world DIR? That's just fine to me, and something I am also fairly interested in.
"get_modpath" returns the path to a mod's directory
"get_worldpath" returns the path to a world's directory
endev15 wrote:If the mod cannot find the file specified through dofile, I would assume it gives an error. So how can I first have the mod check and see if the file exists?
function file_exists (name)
local f = io.open (name, "r")
if f ~= nil then io.close (f) return true else return false end
end
endev15 wrote:Moving further, how do I have the mod create a file itself within the worlds/<worldname> folder and write data to this file to be used later?
local modname = minetest.get_current_modname()
local worldpath = minetest.get_worldpath (modname)
endev15 wrote:Upon reading this again, I also do not quite understand how I can get certain chunks of data from a custom config file. Especially one read through dofile. (like how you called minetest.setting_get and then the specific name of the setting.)
gourmet_calories = 2500
endev15 wrote:BTW, is there a place (GitHub?) where we can browse the code of your different mods without having to download?
minetest.register_on_chat_message (function (name, message)
local cmd = "/mobimmortal"
if message:sub(0, #cmd) == cmd then
if message == '/mobimmortal' then
local player = minetest.env:get_player_by_name(name)
if minetest.check_player_privs(name, {worldedit=true}) then
local pos = player:getpos()
local ent = nil
local tnob = minetest.get_objects_inside_radius (pos, 5)
local nnob = table.getn (tnob)
if (nnob > 0) then
for foo,obj in ipairs (tnob) do
ent = obj:get_luaentity()
if ent ~= nil then
if ent.lifetimer then
ent.lifetimer = 20000
end
end
end
end
else
minetest.chat_send_player (name,
"Sorry, you don't have privileges for that")
end
return true
end
end
end)
- if not self.tamed then
+ if not self.tamed and self.lifetimer < 10000 then
self.lifetimer = self.lifetimer - dtime
nodenames = { "default:dirt" } ,
neighbors = { "bacon:ore" } ,
interval = 10 ,
chance = 100 ,
minetest.register_node ("dilithium:dirt", {
description = "Dirt" ,
tiles = {"default_dirt.png"} ,
groups = { crumbly = 3, soil = 1 } ,
sounds = default.node_sound_dirt_defaults() ,
drop = "default:dirt" ,
})
minetest.register_node ("dilithium:dilithium", {
description = "Dilithium" ,
tiles = {"dilithium.png"} ,
-- Add definitions for other features here
})
bacon
pizza
minetest.register_node ("dilithium:dirt", {
description = "Dirt",
tiles = {"default_dirt.png"} ,
groups = { crumbly = 3, soil = 1 } ,
sounds = default.node_sound_dirt_defaults() ,
drop = "default:dirt" ,
})
minetest.register_abm({
nodenames = { "default:dirt" } ,
neighbors = { "bacon:ore" } ,
interval = 10 ,
chance = 100 ,
action = function (pos, node, aoc, aocwider)
if math.random (1, 10) <= 5 then
newnode = "dilithium:dirt"
else
newnode = "pizza:pizzabox"
end
minetest.add_node (pos, {name = newnode})
end
})
Users browsing this forum: No registered users and 4 guests