OldCoder general development

User avatar
programmingchicken
Member
 
Posts: 537
Joined: Sat Apr 18, 2015 02:20
GitHub: ProgrammingChicken
IRC: gamer chicken
In-game: gamerdude

Re: OldCoder general mod issues

by programmingchicken » Fri Oct 23, 2015 19:41

Hrm. Maybe you would need to gather resources to be able to create a translator machine, or-
sorry, offtopic
I'm bold. I'm sarcastic. I'm PChicken.
 

User avatar
Inocudom
Member
 
Posts: 2889
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

Re: OldCoder general mod issues

by Inocudom » Sat Oct 24, 2015 04:29

Make good use of this topic as much as you can, OldCoder. There are people that are interested in your ideas and can help you. I myself don't understand anything about coding, so all I can do is give advice.
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: OldCoder general mod issues

by paramat » Sat Oct 24, 2015 18:08

OldCoder, optional ABM catch-up is merged:
https://github.com/minetest/minetest/pull/3248
https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L3078
Default is true for backwards compatibility
 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder general mod issues

by OldCoder » Sun Oct 25, 2015 01:06


Paramat, thank you. I'll update and test.

I've have gone with default false in this case. The number of mods working correctly by default would have been significantly higher.

However, the change means that I can drop one of my MT patches and ultimately distribute the "mobset" that I'm working on. Santa Monster Slayer, the Dahaka, and CoRNeRNoTe's Critters are appreciative.

BTW you may recall Solartest, the concept where different planets with distinct biomes exist in the same _game.

The coder who'd offered to work on that project this year was not able to proceed. If I eventually tackle Solartest myself, perhaps you'll offer some thoughts.

FWIW I like the idea of having Mars, Venus, Pluto, etc., or possibly Amtor, Barsoom, Pyrrus (Deathworld), Trantor, and other worlds in a spaceship-based _game.


Image

 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder general mod issues

by OldCoder » Sun Nov 08, 2015 10:21


I've got a "frequent flyer" troll in my worlds with quite a few identities. I don't have time to deal with him presently. He's only used a few subnets so far, but there are a lot of possible IPV4 addresses and it isn't practical to ban them individually. So, I've patched the xban2 mod temporarily to block his known subnets.

This may block a few legitimate people, but I figure that I can add code to whitelist them if necessary.

If you'd like to do something similar, the patch is explained below. The code should probably iterate over a list of subnets as opposed to using hardcoded compares as is done here; I might fix that at a later date.

Edit xban2/init.lua. Look for a register_on_prejoinplayer line. Insert the string.starts function shown below immediately before that line. Insert the if-then-end block shown below immediately after that line.


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
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


 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: OldCoder general mod issues

by Hybrid Dog » Sun Nov 08, 2015 14:29

OldCoder, if you don't grant interact to the "frequent flyer", he (you wrote that it's male) can be ignored, can't he?

If it's a server where you get it automatically, you could use that mod, l think he doesn't want to wait several seconds each time he takes a new accound.
 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder general mod issues

by OldCoder » Sun Nov 08, 2015 20:33


HybridDog:

1. He acquires interact by using dozens of names. So, he's a griefing risk.

2. He knows that I try to be helpful. So, he pretends to be somebody who needs a great deal of help and wastes time.

I don't have many people helping to run worlds. Most people just come and ask for things; they don't stop to think and help. There are exceptions, and I appreciate them, but the exceptions are in only a few of my worlds.

I'm also busy IRL. I'd prefer to spend my limited MT time on things like my map sewing machine, AI for the talking mobs, travelnet fixes, etc. Wasting time talking to the same person who does the same things repeatedly under different names isn't high on the agenda.

 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder general mod issues

by OldCoder » Mon Jan 04, 2016 11:03


Here's a Minetest mod in progress that some people may find fun. It can be used to give each player his or her own theme sound:

http://minetest.org/playerthemesound.zip

Operation is simple; when the player joins the game, the mod plays the sound. Gain and range are adjustable.

Installation instructions are in the "readme.txt" file provided with the mod. Note: It is suggested that theme sounds be kept short (usually 2 to 4 seconds) and not too loud.

Thanks go to the following people:

* bug_zapper, for help with debugging
* DuckCoder, for inspiring the mod with his request for a Quack Quack entrance sound
* Genshin and Thomas-S, for looking for sound files

Just for fun, here's the first appearance of DuckCoder, who tried to out-rhyme OldCoder and got quacked:

<DuckCoder> hi
<DuckCoder> i code ducks for a living
<OldCoder> code ducks
<DuckCoder> yes
<OldCoder> do you make bucks
<DuckCoder> lots of bucks for my ducks
<OldCoder> lots of bucks for ducks
* OldCoder will not say WTFs

<DuckCoder> lots
<OldCoder> lots of lucks
<OldCoder> Bucks for ducks is lucks
<DuckCoder> ducks love bucks for their friend chuck who is also a duck
<OldCoder> You must have plenty plucks
<OldCoder> Agree I am sure does Chucks

<halt_> OC, u feeling ok?
<OldCoder> Lucks bucks for ducks fill trucks with bucks chucks
<DuckCoder> lots of plucks from the bucks that i got from chuck the duck
<OldCoder> halt_ don't trip me up
<halt_> XD
<Genshin> lol
<halt_> what r u doing?

<DuckCoder> My truck is often filled with chuck the duck, because he makes bucks from the luck he brings
<OldCoder> Chucks gave you bucks to fill trucks with ducks? This is lotta lucks to get bucks for ducks. At ducks no one says yucks.
<OldCoder> Yucks are not for coder trucks ducks
<halt_> -_-
<DuckCoder> LOL

<OldCoder> Bucks are not sucks bucks are lotta lucks, Chucks
<DuckCoder> DuckCider
<DuckCoder> lol
<DuckCoder> cider
<DuckCoder> made from ducks
<OldCoder> Duck Cider is a drink for another day hooray
<halt_> ducky pies XD
<DuckCoder> i drink that stuff all day


Image


Image

 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: OldCoder general mod issues

by Hybrid Dog » Mon Jan 04, 2016 12:49

l guess you did a typo: replace pos=pos with pos=player_pos.
 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder general mod issues

by OldCoder » Fri Mar 18, 2016 08:50


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".

The goals of "codersea" are to produce a more interesting undersea world and to make building under the waves more practical. The mod will be released after more development and testing. In the interim, I've started to use it to replace "sea" in my worlds.


Image

 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: OldCoder general mod issues

by Don » Fri Mar 18, 2016 11:35

OldCoder - How did you get the plants to work in water without the air around it?
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder general mod issues

by OldCoder » Fri Mar 18, 2016 16:54



Don wrote:OldCoder - How did you get the plants to work in water without the air around it?


The credit for that feature goes to Topywo, the author of the old "sea" mod. The old mod replaces normal water blocks around "sea" objects with custom water blocks. If the "sea" objects are removed subsequently, the mod reverts the custom blocks to their normal state.

"codersea" is a fork of "sea" 0.4.2 that provides these features:

* Most importantly, if "codersea" is added to an existing world, it places objects even in areas that are already generated. "sea" 0.4.2 only places objects in areas that are generated subsequently.

Shipwrecks are an exception. Presently, "codersea", like "sea", only places shipwrecks in new areas.

* "codersea" aims to make underwater regions more inhabitable as well as more interesting. So, "codersea" seaplants provide illumination; i.e., they glow by default. This feature is optional. Additionally, the level of illumination is adjustable.

* "sea" provides craftable items, such as seablocks and seaglass, that I think work as naturally occurring objects. "codersea" supports "sea's" crafting recipes, but also adds the items to underwater areas. This feature is optional.

* "sea" is a relatively complicated modpack. This isn't necessary, as the mods are lightweight. "codersea" merges the "sea" mods into just one or possibly two mods; I may or may not keep "stairsshine" as a separate mod.

* "codersea" is a separate mod with its own namespace, but it works as a drop-in replacement for "sea". In some cases, the new mod aliases "sea" objects to "codersea" equivalents. In other cases, it removes "sea" objects and generates new "codersea" objects instead.

* "codersea" omits one "sea" mod, "whiteshell", that I'm told can cause problems.

Last edited by OldCoder on Sun Mar 20, 2016 09:50, edited 1 time in total.
 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder general mod issues

by OldCoder » Sun Mar 20, 2016 04:23


"codersea" now generates high-resolution animated starfish as well as low-resolution animated clams. Thanks go to Kaeza for a tip related to "get_objects_inside_radius".

Clams and starfish complain if you attack them.

Clams may be bumped up to a higher resolution at some point.


Image

 

User avatar
xeranas
Member
 
Posts: 99
Joined: Fri Feb 05, 2016 11:06
GitHub: xeranas

Re: OldCoder general mod issues

by xeranas » Sun Mar 20, 2016 13:45

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".

Looks useful mod, why it does not have dedicated forum post (like other mods) with description download links and etc.?
 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder general mod issues

by OldCoder » Sun Mar 20, 2016 23:39


xeranas wrote:Looks useful mod, why it does not have dedicated forum post (like other mods) with description download links and etc.?


Thanks for the interest. The mod will move to its own thread when it's released. The new thread will include a download link and documentation.

This thread is about pieces that are coming together. Codersea has moved gradually from experiments with the Sea modpack to a separate mod that is nearly ready for initial release.

I'll test it in my worlds for a while and make changes based on player feedback.

 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder general mod issues

by OldCoder » Tue Mar 22, 2016 04:15


1. Two players were too aggressive about harvesting Codersea clams and starfish, so I've given the sea animals a means for self-defense.

There's a chance now, when you attack a clam or a starfish, that it'll turn out to be an exploding variety. The animals are made out of dynamite now.

2. As a separate change, at Thomas-S's suggestion, Codersea dirt and sand nodes, which are used to implement a node accounting trick, turn back into ordinary dirt and sand when you dig them.


Image


Update:

<kaiserjayarh> sup kreatons
<kaiserjayarh> lol
<kaiserjayarh> oh my
<Kreatons> ..?
<kaiserjayarh> lol someones banging them clams again
<Kreatons> It was me
<kaiserjayarh> ah ic
<Kreatons> I didnt know
<kaiserjayarh> so they attack you apparently?
<Kreatons> I just kil what I see

If some players "just kil what they see", I assume that I'll need to amp up the bunnies. I'm thinking of adding the rabbit from "Monty Python and the Holy Grail".

 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder general mod issues

by OldCoder » Wed Mar 30, 2016 04:35


This is a cross-post from my Lord of the Test thread.

By popular demand, Pet Ores have been added to Lord of the Test. These are similar to the Pet Rocks of the 1970s but more active and more valuable.

I haven't implemented taming yet, but presently they'll follow you if you're wielding black wool. In the future, you may be able to tame them by feeding them uranium flavored licorice or something similar.

The ores aren't very intelligent yet, but they're smarter than ordinary rocks.

They'll follow you, as indicated above, you can right-click on them to cage them with a "ccmobs" cage or make them squeak, and if you crush them, they drop their respective materials.

The ores are produced by a copy of RHR's "ccmobs" mod that I've forked. The fork will be released after development and testing. Credit for the framework goes to RHR, though I've started to make fixes and tweaks.

Each ore may be modified independently of the others. For example, ores can have individual spawn rates, sounds, viewing ranges, etc.

The screenshot shows friendly copper, diamond, and iron ores visiting to say hello. Gold and other ores will be added shortly.


Image


Update: The pet ores seem to be reasonably popular:

<irondude> rn i'm looking for those ore pets XD
<DaleK> :D
<DaleK> i have some
<irondude> i shoulda grabbed them up when oldcoder didn't fix the numbers XD
<irondude> there was like tons of them around XD

<Ruth_Rose> its walking..uh cappoer :D
<Ruth_Rose> i mean copper
<Ruth_Rose> hiiiiii copper thingy
<Captain_America_> can we get night vision (see in dark)
<Ruth_Rose> hiiii diamonde thingy
<Captain_America_> can I see?
<Ruth_Rose> tp to me
<Ruth_Rose> hi copper and dimonde things
<Captain_America_> whow!
<Ruth_Rose> dimond over here
<Ruth_Rose> and copper
<Captain_America_> I want one for a pet
<Ruth_Rose> yea me two
<Captain_America_> they are so cute!

<devorch> i found a diamond ore mob
<irondude> nice
<irondude> i have like all the ore pets xd
<devorch> look
<devorch> iron look
<irondude> yep i see it
<irondude> lel

 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder mod concepts

by OldCoder » Fri Apr 15, 2016 06:31


This is a copy of a letter to soultest, who asked about the procedure for making planetoids:

It's easy to make little planets using WorldEdit. Try this:

1. Add the WorldEdit modpack to your copy of Minetest
2. Run Minetest in single user mode and play as the admin user
3. Grant yourself the fly privilege
4. Fly up about 80 nodes
5. Execute the following commands:

//1
//2
//sphere 30 default:dirt_with_grass
//sphere 28 default:stone
//sphere 5 default:lava_flowing


The result is a planetoid of radius 30, with dirt two nodes deep, 23 nodes below that of stone, and a heart of fire.

Depending on the surface nodes that you use, your planetoids may end up with plants and animals.


Image

 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: OldCoder mod concepts

by Hybrid Dog » Fri Apr 15, 2016 13:45

OldCoder, there's a way to make orbs which are not simple spheres:
it depends on worldedit (due to the //lua) and vector_extras (for the explosion_perlin)
//lua local me = minetest.get_player_by_name("singleplayer") local pos = vector.round(me:getpos()) for _,t in pairs(vector.explosion_perlin(8, 20, {seed=4})) do local p = vector.add(pos, t[1]) local name if not t[2] then name = "default:stone" else name = "default:dirt" end minetest.set_node(p, {name=name}) end print("done")

l made one and took screenshots of it from various sides:
ImageImageImage
Attachments
screenshot_20160415_153746.png
screenshot_20160415_153746.png (302.86 KiB) Viewed 3900 times
screenshot_20160415_153751.png
screenshot_20160415_153751.png (182.86 KiB) Viewed 3900 times
screenshot_20160415_153801.png
screenshot_20160415_153801.png (128.45 KiB) Viewed 3900 times
 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder mod concepts

by OldCoder » Fri Apr 15, 2016 17:37


Hybrid Dog, thank you.

Modders can also use supplemental mapgens, which run on top of the MT core mapgen, or entirely new mapgens, to generate objects of different types.

In the example shown below, a supplemental mapgen has been used to create a comet. We're just inside the comet's gaseous exterior and looking at the icy center.


Image

 

User avatar
octacian
Member
 
Posts: 408
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian

Re: OldCoder mod concepts

by octacian » Sun May 01, 2016 02:41

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.
God isn't dead!

My Coolest Mods:
MicroExpansion, Working Computers, Interchangeable Hands

Check out my YouTube channel! (octacian)
 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder mod concepts

by OldCoder » Mon May 02, 2016 05:19


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.


I've prepared a ZIP file for you.

I don't have links for the original mods, but I've merged them into a single mod that adds a few useful features.

The new mod is named "sealife", but one of its features is that you can rename it. This feature is discussed further down. You can obtain the mod from:

http://minetest.org/mods/sealife.zip

Here are the details:

* "sealife" depends on default and Mobs Redo. No other mods should be needed. For example, "sealife" works with "sea" and "codersea", but doesn't depend on either.

* You can increase or decrease the population density using this conf-file setting:

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
sealife_aoc = 10

Larger numbers mean more sealife. Smaller numbers mean less sealife. It's best not to use a very large number here.

* You can disable individual types of sea creatures using one or more of these conf-file settings:

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
sealife_disable_crocs     = true
sealife_disable_fish      = true
sealife_disable_jellyfish = true
sealife_disable_sharks    = true
sealife_disable_turtles   = true

* You can change spawn rates for sea creatures using these conf-file settings:

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
sealife_crocs_chance     = 100000
sealife_fish_chance      =    400
sealife_jellyfish_chance =   4000
sealife_sharks_chance    =  90000
sealife_turtles_chance   =  24000

Larger numbers mean fewer creatures. Smaller numbers mean more creatures. It's best not to use numbers below 100 here.

* To change monsters into peaceful creatures, use this setting:

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
sealife_peaceful = true

* To disable monsters instead of making them peaceful, use this setting instead:

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
sealife_disable_monsters = true

* To disable all of the "sealife" mobs, either temporarily or permanently, use this setting:

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
sealife_disable_mobs = true

* If one or more of the "sealife" mob types is/are disabled, existing individuals will continue to live. However, new ones won't be spawned.

* After you install the mod, you can rename the mod folder to create a new version with a different namespace. This feature is useful for developers. You need to do this before using the mod for the first time, though, or you'll end up with unknown entities.

For example, if you rename "sealife" to "endevfish", the mod will generate "endevfish:shark_medium" instead of "sealife:shark_medium".

* Renaming the mod doesn't change the names of the conf-file settings discussed previously.

* The ZIP file for Mobs Redo can be obtained at the following link:

https://github.com/tenplus1/mobs_redo/archive/master.zip

Note that you must rename the Mobs Redo folder from "mobs_redo-master" to just "mobs" after unpacking the ZIP file.

* The screenshot below shows the new mod running in a world that has just "minetest_game" and Mobs Redo installed.

Sand has been patched to glow here so as to make the scene visible. The jellyfish spawn rate has also been increased as a test. A shark can be seen approaching to the upper left.


Image

 

User avatar
octacian
Member
 
Posts: 408
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian

Re: OldCoder mod concepts

by octacian » Tue May 03, 2016 03:49

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.

Is there any difference if I run it with sea and/or codersea? On the technical side, how do you write the mod so that extra recipes/features are available if an optional dependency is present?

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.

Thanks again! It looks awesome, will test it out soon.
God isn't dead!

My Coolest Mods:
MicroExpansion, Working Computers, Interchangeable Hands

Check out my YouTube channel! (octacian)
 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder mod concepts

by OldCoder » Tue May 03, 2016 05:53


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.

The "sealife" mod just generates mobs presently; i.e., crocs, fish, jellyfish, sharks, and turtles. If I add sea-plants later, they should be compatible with "sea" and "codersea".

Note: The light-emitting plants in "codersea" are optional. The primary feature of "codersea" is that it works with areas that are already mapgenned. The "sea" mod doesn't support this. This is the main reason that I wrote "codersea". Most of the other features can be turned on or off to suit the needs of a world owner.

endev15 wrote:Is there any difference if I run [sealife] with sea and/or codersea?

There shouldn't be any difference. The "sealife" mod should work with both "sea" and "codersea". I've thought of some possible compatibility issues but I'll address them in the next release.

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?

Let's imagine that you'd like to have a new mod, named "gourmet", use features from an existing mod, named "seaweed", and you'd like this to be optional.

For example, perhaps the "gourmet" mod will provide a crafting recipe for a dessert named Seaweed Ice Cream, if and only if the "seaweed" mod is present.

There are two or three steps, depending on what you need, all of them pretty simple:

a. The first step is to add a line similar to the following to the "depends.txt" file for the new mod:

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
seaweed?

This is just the name of the optional mod with a question mark added.

b. The second step is to add conditional code of the following type to the new mod:

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 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

c. As an alternative to (b), or in addition to (b), you can add code to the new mod that tests for the existence of specific nodes. 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
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.

There are several ways to use config and/or data files. We'll discuss two approaches here.

The simplest approach is to have your mods use the standard config file, "minetest.conf". To do this, proceed as follows:

a. Make up names for configuration options. Important: Try to make them unique. For example, the name "gourmet_magic" is unique enough. The name "magic" is too general and may conflict with other mods.

b. Decide which settings are numbers, which are flags (true or false), and which are strings.

c. Add code to your mod to read the settings. Set reasonable default values where necessary.

You'll find examples of (c) in the "sealife" source files. For example, the following code from "fish.lua" reads a boolean flag from "minetest.conf":

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 sealife_disable_fish  =
    minetest.setting_getbool ("sealife_disable_fish")

The following code from the same file reads an integer setting and sets a default value of 8:

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 aoc = tonumber (minetest.setting_get ("sealife_aoc")) or 8

If a setting is just a string, code of the following type should work:

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 tofu_brand = minetest.setting_get ("tofu_brand")

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 worldpath = minetest.get_worldpath (modname)
dofile (worldpath .. "/gourmet.txt")


endev15 wrote:Thanks again! It looks awesome, will test it out soon.

You're welcome. Let us see what you come up with.

Last edited by OldCoder on Tue May 03, 2016 16:53, edited 1 time in total.
 

User avatar
octacian
Member
 
Posts: 408
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian

Re: OldCoder mod concepts

by octacian » Tue May 03, 2016 14:05

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")



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.

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?

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? For example, some type of computer disk, where a directory would be created in the world folder which in turn stored several files storing the data of each disk.

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.)

BTW, is there a place (GitHub?) where we can browse the code of your different mods without having to download?
God isn't dead!

My Coolest Mods:
MicroExpansion, Working Computers, Interchangeable Hands

Check out my YouTube channel! (octacian)
 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder mod concepts

by OldCoder » Tue May 03, 2016 16:51


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.

1. Yes, you caught a mistake on my part. I'll edit my previous post to use "get_worldpath" instead of "get_modpath".

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
"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?

2. To do this, use the following utility function:

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
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?

3. If it's just a single data file, you can proceed as follows:

a. Determine the world-directory path using this code:

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 worldpath = minetest.get_worldpath (modname)

b. Use Lua I/O write calls to write data to a file stored in the "worldpath" folder. Use Lua I/O read calls later to retrieve data from the file.

c. Optionally, use "minetest.serialize" and "minetest.deserialize" to encode data structures for storage and to decode them after retrieval.

d. Or use Lua I/O write calls to write data to the file as Lua code. Use "dofile" later to execute the file and thereby retrieve the data. There is more about this approach further down.

e. Or, more simply, use the Minetest mod "datastorage" to handle data storage. Note: The documentation for the mod suggests that it's for per-player storage, but it can be used for other purposes.

f. Or study or fork the "datastorage" mod's code to produce the code that you need for your purposes.

4. The "datastorage" mod may be obtained using the following link:

https://github.com/minetest-technic/datastorage/archive/master.zip

Note: Remember to rename the "datastorage-master" folder to "datastorage" after unpacking the ZIP file.

5. If there's a number of data files, especially if there's one or more files per player, don't clutter up the world folder. Instead, create a subdirectory in the world folder to hold the files.

The "datastorage" mod does this automatically. To see how to do this yourself, study the mod's source code.

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.)

6. There are at least two approaches:

a. Config files that are handled using "dofile"
b. Arbitrary data files of the types discussed in part 3 above

If I understand correctly, config files that are handled using "dofile" lack the interface that is provided for "minetest.conf" and are used more simply.

In short, the config files are executed as Lua code and the settings defined therein become Lua variables that other code can use subsequently.

So, if a "dofile"-type config file is used, and it contains a line of the following form:

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_calories = 2500

a variable named "gourmet_calories" is created and its value is equal to the number 2500.

Note that arbitrary Lua code may be used in "dofile"-type config files, so data may be stored as human-readable tables.

If config settings are created through a GUI and human-readable isn't important, you might use the approaches discussed in part 3 instead of the "dofile" approach.

endev15 wrote:BTW, is there a place (GitHub?) where we can browse the code of your different mods without having to download?

7. I've been with Minetest for four years now, and I've made bug fixes to mods since the start, but until last year, most of my coding efforts went to two projects:

a. A world framework known as "minebest"
b. A world editor known as "minesplice"

Note: "minebest" actually has its own IRC channel, Freenode ##minebest (with two ##). However, the channel is presently low-traffic.

I've been doing more Minetest mod work recently and I plan to put new or modified mods on GitHub in due course.

8. Edit: As Rubenwardy points out, if you're referring to Minetest mods in general as opposed to my mods, you'll find plenty of code examples and API information in GitHub repositories and elsewhere.

Here are some useful links:

# Minetest Mods Team:
https://github.com/minetest-mods

# datastorage mod:
https://github.com/minetest-technic/datastorage

# Minetest default "_game":
https://github.com/minetest/minetest_game

# ShadowNinja's mods:
https://github.com/ShadowNinja

# TenPlus1's mods:
https://github.com/tenplus1

# VanessaE's Dreambuilder modpack:
https://github.com/VanessaE/dreambuilder_modpack

# Rubenwardy's Minetest Modding book:
http://rubenwardy.com/minetest_modding_book/lua_api.html

# Minetest Lua API Modding Reference:
https://github.com/minetest/minetest/blob/master/doc/lua_api.txt

Last edited by OldCoder on Wed May 04, 2016 00:30, edited 3 times in total.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: OldCoder mod concepts

by rubenwardy » Tue May 03, 2016 17:03

Look at the minetest-mods org on github
 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder mod concepts

by OldCoder » Tue May 17, 2016 07:46


Do you have a lot of Minetest pets? Here are some Pet Coder tips.

The tips are free and, to close the deal, I'll throw in a science-fiction story about interstellar telepathic cat warriors who fight rat-dragons made of emotions.

The cat-warrior story was written by a Cold War spy named Paul Linebarger, pseudonym Cordwainer Smith. YoungCoder read the story about 50 years ago. Thinking of names for cats tonight reminded me of it.

Alyssa has collected a dozen Minetest kitty cats. Actually, she says, she demands that other Minetesters pay her rent in the form of felines.

<Tim> I wish to build here
<Alyssa> You'll need to pay rent
<Tim> Very well. One gold coin?
<Alyssa> No; it shall be one cat per month
<Tim> A magic cat? Or one made of silver?
<Alyssa> A regular cat will do
<Tim> Not an expensive cat?
<Alyssa> Just a cat, but it should purr

The cats are simply pixel pets. However, Alyssa has named some of them. If you name something, it becomes more real. She was regretful when somebody opened a door and allowed one of the cats, Jasper, to escape and wander off.

<Alyssa> Jasper, where are you?
<crickets> chirp

In Minetest, untamed animals die of old age quickly. Alyssa doesn't understand how to tame animals yet, so her cats were destined to join the choir invisible.

I decided to prevent this by making her pets immortal despite the fact that they were untamed.

<OldCoder> Cats, you're going to live long and prosper
<cats> What's the cat-ch?
<OldCoder> None; I'm going to try this because I'm sorry about Jasper
<cats> Sounds good to us
<cats> Miao

I didn't want to bother with something like Immortality Brand pet chow that I'd need to feed to the cats one by one. So, instead, as a quick fix, I wrote an immortality mod that simply granted long life to all mobs nearby when it was invoked.

Here's the source code for the mod:

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
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 a Minetest player has worldedit privileges, this mod lets him or her use the following command:

/mobimmortal

The /mobimmortal command sets the lifetimer for all mobs within a radius of 5 nodes from the player to 20000, which is pretty long. The change didn't have the right effect, though. In fact, after I restarted the world, mobs that had received the immortality treatment expired prematurely.

So, to ensure that things would work as I expected, I patched my copy of TenPlus1's mobs API module, mobs/api.lua, as follows:

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
- if not self.tamed then
+ if not self.tamed and self.lifetimer < 10000 then
       self.lifetimer = self.lifetimer - dtime


After this change, the /mobimmortal command worked correctly.

Note: I could have designed my mod to tame mobs instead of making them immortal. But the immortality approach was simpler.

The next step was to make it easier to keep track of all of the furballs.

I added the nametag mod, which allows people to name minepets or, actually, most entities. Note: To read more about the nametag mod or obtain it, visit the following link:

https://forum.minetest.net/viewtopic.php?f=9&t=13784

The nametag mod worked as advertised. I named all of the cats and included a Jasper II. So, now, there are a dozen immortal cats living on a rooftop in Wizard School, and it's possible to tell which is which.

<OldCoder> Captain Wow, I named you after one of the cat heroes in The Game of Rat and Dragon
<Captain Wow> What's the link?
<OldCoder> The link is:

http://www.gutenberg.org/files/29614/29614-h/29614-h.htm

Screenshot follows:


Image


And here's some scenes from The Game of Rat and Dragon, which you can read at the link provided previously:

Image

 

User avatar
octacian
Member
 
Posts: 408
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian

Re: OldCoder mod concepts

by octacian » Mon Jun 20, 2016 20:18

Any ideas for using ABMs in ore generation? I wanted to review your codersea mod as I believe you did so there, but can't find a link.
God isn't dead!

My Coolest Mods:
MicroExpansion, Working Computers, Interchangeable Hands

Check out my YouTube channel! (octacian)
 

OldCoder
Administrator
 
Posts: 345
Joined: Mon Oct 01, 2012 14:59

Re: OldCoder mod concepts

by OldCoder » Mon Jun 20, 2016 23:23


endev15 asked for ideas related to ore generation using ABMs. He wanted to know, in particular, about the approach that my "codersea" mod uses.

The original "sea" mod uses normal ore generation to place special nodes underwater. ABMs are then used to grow sea-plants above those nodes. The problem with this is that normal ore generation only works at Minetest mapgen time. So, if you add the "sea" mod to an existing world, it doesn't work for underwater areas that have already been generated.

To fix the problem, I dropped the ore generation part and wrote new ABMs to convert ordinary dirt and sand to the special nodes that the plants needed.

This approach can be generalized to implement ore generation, or other types of node generation, as the conversion of a percentage of existing nodes that meet the right conditions.

The steps listed below, which are based on a simplified version of what the "codersea" mod does, should work. However, this generalized approach isn't ideal, because of the need for step #6.

1) Start a new mod. For this example, we'll assume that it's named "dilithium".

2) Add an ABM with "nodenames" and "neighbors" set up to select ordinary nodes that are candidates for conversion to new node types such as new ores. We'll refer to the nodes in "nodenames" as "candidate" nodes. Set "interval" to 10 and "chance" to 100. 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
nodenames = { "default:dirt" } ,
neighbors = { "bacon:ore"    } ,
interval  =  10 ,
chance    = 100 ,

In this case, dirt that happens to have bacon ore as a neighbor is a candidate for conversion.

3) Define new nodes, in the new mod, that are identical to the "candidate" nodes in "nodenames" except for their names and one other thing: the new nodes should drop the corresponding "candidate" nodes. We'll refer to these as "processed" nodes.

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
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" ,
})

4) Add new code to the new mod to define nodes that "candidate" nodes may be converted to. We'll refer to these as "replacement" nodes. 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
minetest.register_node ("dilithium:dilithium", {
    description = "Dilithium" ,
    tiles = {"dilithium.png"} ,
-- Add definitions for other features here
})

5) Extend the ABM to make it change a "candidate" node, based on probabilities or other factors, into one of three things:

* One of the "processed" nodes
* One of the "replacement" nodes
* A node defined in some other mod

6) You may need to modify other mods to make them treat "replacement" nodes the same as corresponding "candidate" nodes.

The following simple but complete version of the "dilithium" mod illustrates the preceding approach. This mod converts half of the regular "default:dirt" nodes that happen to be neighbors of bacon ore to pizza boxes. "default:dirt" nodes that don't turn into pizza boxes are replaced with "dilithium:dirt" nodes, which the mod will not process further.

Note that Minetest _games typically convert surface "default:dirt" nodes to "default:dirt_with_grass", so this mod will have an effect primarily underground.

The "depends.txt" for this mod should be:

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
bacon
pizza

To see the entire mod, you'll need to scroll. Use the scrollbar on the right:

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
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
})

The following screenshot shows "default:dirt" nodes that have been converted by the mod into pizza boxes and "dilithium:dirt" nodes. The bacon ore involved has been removed to make the results visible.

Image

 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron