[Mod] Simple Mobs [mobs]

Locked
User avatar
kaeza
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

by kaeza » Post

Silent-Hunter wrote:I can't seem to add only_peaceful_mobs = true to the minetest.conf, as it reverts when the game starts.
Do not edit `minetest.conf' while the game is running.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal

User avatar
Silent-Hunter
Member
Posts: 30
Joined: Wed Nov 06, 2013 20:06

by Silent-Hunter » Post

Thanks! That's odd, I didn't think I did. I must have forgotten to close it first.

wcwyes
Member
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Post

Is there a way to add a function to the spawn command? Like

Code: Select all

mobs:register_spawn("dwarves:dwarf", {"default:stone"}, 3, -1, 7000, 3, -7000)
If spawn then
    local name=dwarves:dwarf
    if minetest.get_node(pos.x-2, pos.y, pos.z).name=="air" then
        minetest.env:add_entity(pos.x-2, pos.y, pos.z, name)
    end
    if minetest.get_node(pos.x+2, pos.y, pos.z).name=="air" then
        minetest.env:add_entity(pos.x+2, pos.y, pos.z, name)
    end
    if minetest.get_node(pos.x, pos.y, pos.z-2).name=="air" then
        minetest.env:add_entity(pos.x, pos.y, pos.z-2, name)
    end
    if minetest.get_node(pos.x, pos.y, pos.z+2).name=="air" then
        minetest.env:add_entity(pos.x, pos.y, pos.z+2, name)
    end
end
I know this isn't how it's done but it's a start. I only know of two other options, of one which is improper programming methods, the other just more complicated. I would rather keep it in the mobs family.

User avatar
Ikishida
Member
Posts: 107
Joined: Sat Aug 17, 2013 08:02
Location: (secret)

by Ikishida » Post

hey,pilzadam,is it okay if i change the textures
to make a pokemon mod?(also,I'll change the
names)
When life hands you lemons,throw it back at life saying "I don't need your goddamn lemons!" =D

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

Ikishida wrote:hey,pilzadam,is it okay if i change the textures
to make a pokemon mod?(also,I'll change the
names)
Hmmm.... Let me quote the WTFPL:
WTFPL wrote:You just DO WHAT THE FUCK YOU WANT TO.

User avatar
Ikishida
Member
Posts: 107
Joined: Sat Aug 17, 2013 08:02
Location: (secret)

by Ikishida » Post

PilzAdam wrote:
Ikishida wrote:hey,pilzadam,is it okay if i change the textures
to make a pokemon mod?(also,I'll change the
names)
Hmmm.... Let me quote the WTFPL:
WTFPL wrote:You just DO WHAT THE FUCK YOU WANT TO.
uhh...I mean,can I post when I made a fork?
When life hands you lemons,throw it back at life saying "I don't need your goddamn lemons!" =D

User avatar
VanessaE
Moderator
Posts: 4655
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaE
Location: Western NC
Contact:

by VanessaE » Post

22:58:27: ERROR[main]: ERROR: An unhandled exception occurred: ServerError: LuaError: ...minetest/.minetest/games/vanessae_game/mods/mobs/api.lua:243: attempt to index local 'p' (a nil value)
22:58:27: ERROR[main]: stack traceback:
22:58:27: ERROR[main]: ...minetest/.minetest/games/vanessae_game/mods/mobs/api.lua:243: in function <...minetest/.minetest/games/vanessae_game/mods/mobs/api.lua:115>
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)

ElectricSolstice
Member
Posts: 90
Joined: Tue Aug 20, 2013 02:00

by ElectricSolstice » Post

VanessaE wrote:22:58:27: ERROR[main]: ERROR: An unhandled exception occurred: ServerError: LuaError: ...minetest/.minetest/games/vanessae_game/mods/mobs/api.lua:243: attempt to index local 'p' (a nil value)
22:58:27: ERROR[main]: stack traceback:
22:58:27: ERROR[main]: ...minetest/.minetest/games/vanessae_game/mods/mobs/api.lua:243: in function <...minetest/.minetest/games/vanessae_game/mods/mobs/api.lua:115>
I don't know why that happened, but I do know that the local p is supposed to be the position of a player and it uses minetest.get_connected_players to get this player. Do you have any other details on this error?

I was thinking in his version of the mod though that something was slightly off about the code for following, but I can't remember offhand what I changed. Although, I don't think it'll fix whatever that occured.

Also, people keep in mind my commits that still has yet to be reviewed. My version has the mobs actually jumping to chase you.

https://github.com/ElectricSolstice/mobs


Do you somehow have players that return nil when you get their position?
Last edited by ElectricSolstice on Fri Nov 15, 2013 08:14, edited 1 time in total.

User avatar
VanessaE
Moderator
Posts: 4655
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaE
Location: Western NC
Contact:

by VanessaE » Post

I'm not at all sure what the circumstances were that caused this error to pop up - it was just one of those random things (I see a restart on the servers' IRC channel, check the log, and... like that).
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

VanessaE wrote:22:58:27: ERROR[main]: ERROR: An unhandled exception occurred: ServerError: LuaError: ...minetest/.minetest/games/vanessae_game/mods/mobs/api.lua:243: attempt to index local 'p' (a nil value)
22:58:27: ERROR[main]: stack traceback:
22:58:27: ERROR[main]: ...minetest/.minetest/games/vanessae_game/mods/mobs/api.lua:243: in function <...minetest/.minetest/games/vanessae_game/mods/mobs/api.lua:115>
proller reported that too. I think it might happen since https://github.com/minetest/minetest/co ... a890cd05c5.
My guess is that on_step() runs before register_on_leaveplayer(). (That would be a bug in the engine then.)

ElectricSolstice
Member
Posts: 90
Joined: Tue Aug 20, 2013 02:00

by ElectricSolstice » Post

VanessaE wrote:I'm not at all sure what the circumstances were that caused this error to pop up - it was just one of those random things (I see a restart on the servers' IRC channel, check the log, and... like that).
If all you care about is a quick fix for the mod on your server, you could probably wrap that bit of code in an if statement. All that code there does is check for players to start following and a mob wouldn't need to follow a non existant player if pilzAdam is right about step being called before register_on_leaveplayer.

change right after line 242
so if starting at line 241, change it to look like this

Code: Select all

local s = self.object:getpos()
local p = player:getpos()
if p~= nil then
   local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
   if self.view_range and dist < self.view_range then
      self.following = player
   end
end

Last edited by ElectricSolstice on Fri Nov 15, 2013 17:26, edited 1 time in total.

User avatar
VanessaE
Moderator
Posts: 4655
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaE
Location: Western NC
Contact:

by VanessaE » Post

Thanks, I'll give it a try.
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)

User avatar
VanessaE
Moderator
Posts: 4655
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaE
Location: Western NC
Contact:

by VanessaE » Post

Seems to help - a similar fix was needed for the subroutine near line 222 also.
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)

User avatar
Dukie
New member
Posts: 3
Joined: Sat Nov 16, 2013 19:22

by Dukie » Post

PilzAdam wrote:Depends:
default
fire
I'm new to Minetest, and recently setup a server for my and my two boys to play on. Working very nicely!

This mod looked interesting, but I can't seem to find the "fire" mod, which it appears to be dependent on.

I've dug through the "Mod Releases" area, and have found other mods mentioning fire, but have had no luck finding a mod specifically titled simply "Fire".

Does anyone have a link please?

Thanks so much! :)

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

Dukie wrote:
PilzAdam wrote:Depends:
default
fire
I'm new to Minetest, and recently setup a server for my and my two boys to play on. Working very nicely!

This mod looked interesting, but I can't seem to find the "fire" mod, which it appears to be dependent on.

I've dug through the "Mod Releases" area, and have found other mods mentioning fire, but have had no luck finding a mod specifically titled simply "Fire".

Does anyone have a link please?

Thanks so much! :)
Fire is part of minetest_game, so you dont need to install it as an external mod.

User avatar
Dukie
New member
Posts: 3
Joined: Sat Nov 16, 2013 19:22

by Dukie » Post

PilzAdam wrote:Fire is part of minetest_game, so you dont need to install it as an external mod.
Thanks! I found that out in the few minutes after I posted.. The "find" command works wonders, eh? ;-)

So - Now I've enabled the mod, and when I fire up the server it bonks out, :(

I grabbed Minetest via github.com a few nights ago, so it's a fairly new build.

I grabbed the Simple Mobs mod today via:
$ wget -O simplemobs.zip https://github.com/PilzAdam/mobs/zipball/master

Once I unzipped it, I moved it to the mobs directory:
$ mv PilzAdam-mobs-c49cc47 simplemobs
$ mv simplemobs /home/minetest/minetest_server/minetest-minetest-bb54e2c/mods/

I then added "load_mod_simplemobs = true" to my "/home/minetest/minetest_server/minetest-minetest-bb54e2c/worlds/world/world.mt" file.

And when I start the server, I get the following:
-snip-
Automatically selecting world at [/home/minetest/minetest_server/minetest-minetest-bb54e2c/bin/../worlds/world]
14:40:41: ERROR[main]: ========== ERROR FROM LUA ===========
14:40:41: ERROR[main]: Failed to load and run script from
14:40:41: ERROR[main]: /home/minetest/minetest_server/minetest-minetest-bb54e2c/bin/../mods/simplemobs/init.lua:
14:40:41: ERROR[main]: ...est-minetest-bb54e2c/bin/../mods/simplemobs/init.lua:1: attempt to concatenate a nil value
14:40:41: ERROR[main]: stack traceback:
14:40:41: ERROR[main]: ...est-minetest-bb54e2c/bin/../mods/simplemobs/init.lua:1: in main chunk
14:40:41: ERROR[main]: =======END OF ERROR FROM LUA ========
14:40:41: ERROR[main]: Server: Failed to load and run /home/minetest/minetest_server/minetest-minetest-bb54e2c/bin/../mods/simplemobs/init.lua
14:40:41: ERROR[main]: ERROR: An unhandled exception occurred: ModError: Failed to load and run /home/minetest/minetest_server/minetest-minetest-bb54e2c/bin/../mods/simplemobs/init.lua

In thread 7fbb13658740:
/root/minetest/minetest-minetest-bb54e2c/src/main.cpp:1854: int main(int, char**): Assertion '0' failed.
Debug stacks:
DEBUG STACK FOR THREAD 7fbb13658740:
#0 int main(int, char**)
(Leftover data: #1 Dedicated server branch)
Aborted (core dumped)
-snip-

$ /home/minetest/minetest_server/minetest_server.bin --version
minetestserver 0.4.7-dev
Build info: VER=0.4.7-dev BUILD_TYPE=Release RUN_IN_PLACE=1 USE_GETTEXT=0 USE_SOUND=0 USE_CURL=1 USE_FREETYPE=0 USE_LUAJIT=0 STATIC_SHAREDIR=.

Any ideas or suggestions would be most appreciated, :)
Last edited by Dukie on Sat Nov 16, 2013 20:00, edited 1 time in total.

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

Dukie wrote:
PilzAdam wrote:Fire is part of minetest_game, so you dont need to install it as an external mod.
Thanks! I found that out in the few minutes after I posted.. The "find" command works wonders, eh? ;-)

So - Now I've enabled the mod, and when I fire up the server it bonks out, :(

I grabbed Minetest via github.com a few nights ago, so it's a fairly new build.

I grabbed the Simple Mobs mod today via:
$ wget -O simplemobs.zip https://github.com/PilzAdam/mobs/zipball/master

Once I unzipped it, I moved it to the mobs directory:
$ mv PilzAdam-mobs-c49cc47 simplemobs
$ mv simplemobs /home/minetest/minetest_server/minetest-minetest-bb54e2c/mods/

I then added "load_mod_simplemobs = true" to my "/home/minetest/minetest_server/minetest-minetest-bb54e2c/worlds/world/world.mt" file.

And when I start the server, I get the following:

Code: Select all

-snip-
Automatically selecting world at [/home/minetest/minetest_server/minetest-minetest-bb54e2c/bin/../worlds/world]
14:40:41: ERROR[main]: ========== ERROR FROM LUA ===========
14:40:41: ERROR[main]: Failed to load and run script from
14:40:41: ERROR[main]: /home/minetest/minetest_server/minetest-minetest-bb54e2c/bin/../mods/simplemobs/init.lua:
14:40:41: ERROR[main]: ...est-minetest-bb54e2c/bin/../mods/simplemobs/init.lua:1: attempt to concatenate a nil value
14:40:41: ERROR[main]: stack traceback:
14:40:41: ERROR[main]:  ...est-minetest-bb54e2c/bin/../mods/simplemobs/init.lua:1: in main chunk
14:40:41: ERROR[main]: =======END OF ERROR FROM LUA ========
14:40:41: ERROR[main]: Server: Failed to load and run /home/minetest/minetest_server/minetest-minetest-bb54e2c/bin/../mods/simplemobs/init.lua
14:40:41: ERROR[main]: ERROR: An unhandled exception occurred: ModError: Failed to load and run /home/minetest/minetest_server/minetest-minetest-bb54e2c/bin/../mods/simplemobs/init.lua

In thread 7fbb13658740:
/root/minetest/minetest-minetest-bb54e2c/src/main.cpp:1854: int main(int, char**): Assertion '0' failed.
Debug stacks:
DEBUG STACK FOR THREAD 7fbb13658740:
#0  int main(int, char**)
(Leftover data: #1  Dedicated server branch)
Aborted (core dumped)
-snip-

$ /home/minetest/minetest_server/minetest_server.bin --version
minetestserver 0.4.7-dev
Build info: VER=0.4.7-dev BUILD_TYPE=Release RUN_IN_PLACE=1 USE_GETTEXT=0 USE_SOUND=0 USE_CURL=1 USE_FREETYPE=0 USE_LUAJIT=0 STATIC_SHAREDIR=.
Any ideas or suggestions would be most appreciated, :)
Rename the modfolder to "mobs". More info: viewtopic.php?id=6450

falsegrayburger
Member
Posts: 158
Joined: Sat Aug 03, 2013 15:16
In-game: naro

by falsegrayburger » Post

good mod

User avatar
Dukie
New member
Posts: 3
Joined: Sat Nov 16, 2013 19:22

by Dukie » Post

PilzAdam wrote:Rename the modfolder to "mobs". More info: viewtopic.php?id=6450
That did it! Thanks very much! :)

Time to go read-up on naming conventions, :)

wcwyes
Member
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Post

wcwyes wrote:Is there a way to add a function to the spawn command? Like

Code: Select all

mobs:register_spawn("dwarves:dwarf", {"default:stone"}, 3, -1, 7000, 3, -7000)
If spawn then
    local name=dwarves:dwarf
    if minetest.get_node(pos.x-2, pos.y, pos.z).name=="air" then
        minetest.env:add_entity(pos.x-2, pos.y, pos.z, name)
    end
    if minetest.get_node(pos.x+2, pos.y, pos.z).name=="air" then
        minetest.env:add_entity(pos.x+2, pos.y, pos.z, name)
    end
    if minetest.get_node(pos.x, pos.y, pos.z-2).name=="air" then
        minetest.env:add_entity(pos.x, pos.y, pos.z-2, name)
    end
    if minetest.get_node(pos.x, pos.y, pos.z+2).name=="air" then
        minetest.env:add_entity(pos.x, pos.y, pos.z+2, name)
    end
end
I know this isn't how it's done but it's a start. I only know of two other options, of one which is improper programming methods, the other just more complicated. I would rather keep it in the mobs family.
I've got it loading but it doesn't seem to do anything,

Code: Select all

    attack_type = "dogfight",
    action = function(pos)
    function dwarves.scatter(pos)
        if minetest.get_node(pos.x-2).name=="air" then
            minetest.env:add_entity(pos.x-2, {name=dwarves:dwarf}),
        end
        if minetest.get_node(pos.x+2).name=="air" then
            minetest.env:add_entity(pos.x+2, {name=dwarves:dwarf}),
        end
        if minetest.get_node(pos.z-2).name=="air" then
            minetest.env:add_entity(pos.z-2, {name=dwarves:dwarf})
        end
        if minetest.get_node(pos.z+2).name=="air" then
            minetest.env:add_entity(pos.z+2, {name=dwarves:dwarf}),
        end
        minetest.env:remove_entity(pos)
        end
end,
help please.
Last edited by wcwyes on Mon Nov 18, 2013 06:28, edited 1 time in total.

User avatar
AndrOn
Member
Posts: 50
Joined: Fri May 31, 2013 22:32
Location: Orléans, France

by AndrOn » Post

hey as I usually do I modified some of the code for my own game so that the mobs would drop the items when killed by an arrow (from throwing mod), instead of losing it, and found it much funnier, because now hunting has a point

In mobs/api you just replace the :

Code: Select all

 if self.object:get_hp() <= 0 then ......................... end 
by:

Code: Select all

            if self.object:get_hp() <= 0 then
                if hitter and hitter:is_player() and hitter:get_inventory() then
                    for _,drop in ipairs(self.drops) do
                        if math.random(1, drop.chance) == 1 then
                            hitter:get_inventory():add_item("main", ItemStack(drop.name.." "..math.random(drop.min, drop.max)))
                        end
                    end
                else
                    for _,drop in ipairs(self.drops) do
                        if math.random(1, drop.chance) == 1 
                        then
                            minetest.env:add_item(self.object:getpos(), drop.name.." "..math.random(drop.min, drop.max))
                        end
                    end
                end
                
            end
Basically, it drops the item when the mob dies, but i've not tested every possible death. Also, you may not want to use it on a server because items will be also dropped when light kills the mobs, causing random items drops everywhere.

I'm also going to try and use it for mob farming ;) I replaced the drops to be more interesting to farm.
k8NzxjXgxpd3KOKx8pz2z12pStfpe5tR

User avatar
Nightshade
Member
Posts: 25
Joined: Thu Oct 24, 2013 15:25

by Nightshade » Post

What do I need to change to get the mobs to spawn more frequently?

ElectricSolstice
Member
Posts: 90
Joined: Tue Aug 20, 2013 02:00

by ElectricSolstice » Post

Nightshade wrote:What do I need to change to get the mobs to spawn more frequently?
I'm guessing change the chance in mob.register_spawn on whichever monster you want to spawn more. I'm guessing a lower number would make it spawn more often because it uses an abm to spawn the monsters. For example,

change

Code: Select all

mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1, 7000, 3, 31000)
to

Code: Select all

mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1, 3000, 3, 31000)
and I think they should spawn a little more than twice as they already do. However, I haven't tried it yet, so you'll have to tweak that number to your desire.

george90867
Member
Posts: 25
Joined: Fri Jul 26, 2013 17:42

by george90867 » Post

is it in 0.4.8?

User avatar
Nightshade
Member
Posts: 25
Joined: Thu Oct 24, 2013 15:25

by Nightshade » Post

ElectricSolstice wrote:
Nightshade wrote:What do I need to change to get the mobs to spawn more frequently?
I'm guessing change the chance in mob.register_spawn on whichever monster you want to spawn more. I'm guessing a lower number would make it spawn more often because it uses an abm to spawn the monsters. For example,

change

Code: Select all

mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1, 7000, 3, 31000)
to

Code: Select all

mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1, 3000, 3, 31000)
and I think they should spawn a little more than twice as they already do. However, I haven't tried it yet, so you'll have to tweak that number to your desire.
Thanks, Electric. I'll test it out some time. I just wasn't sure which value in that mess to change (I'm not a coder...)
Last edited by Nightshade on Thu Dec 05, 2013 20:37, edited 1 time in total.

Locked

Who is online

Users browsing this forum: No registered users and 4 guests