[PoC] NPC Build Queue [npcbuildqueue]

Post Reply
User avatar
IcyDiamond
Member
Posts: 169
Joined: Fri Mar 30, 2018 08:55
GitHub: LunaSquee
IRC: IcyDiamond
In-game: IcyDiamond
Location: Estonia
Contact:

[PoC] NPC Build Queue [npcbuildqueue]

by IcyDiamond » Post

This is a proof-of-concept which instructs your NPCs to "build" schematics. Requires Mobs Redo by Tenplus1.

Instead of just placing a schematic in the world, this PoC will allow you to instruct your NPCs to "act out" the building of a schematic! This means that the NPC will be breaking and placing nodes in order, in layers.

See the Demonstration Video.

Source Code: https://gitlab.icynet.eu/evert/npcbuildqueue
License: CC0
Last edited by IcyDiamond on Sat Jan 19, 2019 17:45, edited 1 time in total.
Web developer | Minetest modder | Systems Administrator | Donate
Mods - elepower | melterns | towny

User avatar
texmex
Member
Posts: 1752
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by texmex » Post

That is awesome!
Mods | Support Mesehub: bc1qluuests9rxmlnvpjrhsnyjg9ucwy6z3r0y3srw

User avatar
Devy
Member
Posts: 132
Joined: Sat Jan 21, 2017 02:31
GitHub: CoderForTheBetter
In-game: devy

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by Devy » Post

Wow. This is really great.

User avatar
TenPlus1
Member
Posts: 2936
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by TenPlus1 » Post

Nicely done IcyDiamond :) love it.

User avatar
IcyDiamond
Member
Posts: 169
Joined: Fri Mar 30, 2018 08:55
GitHub: LunaSquee
IRC: IcyDiamond
In-game: IcyDiamond
Location: Estonia
Contact:

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by IcyDiamond » Post

Thanks, guys! Glad you like it.
Web developer | Minetest modder | Systems Administrator | Donate
Mods - elepower | melterns | towny

ShadMOrdre
Member
Posts: 741
Joined: Mon Dec 29, 2014 08:07
GitHub: ShadMOrdre
In-game: shadmordre
Location: USA

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by ShadMOrdre » Post

Nice mod, Icy.

Would it be possible to enable the NPC to randomly choose a schem from a folder, instead of having it hard coded?

Shad
MY MODS: lib_ecology lib_materials lib_clouds lib_node_shapes ---- Inspired By: Open Source Virtual World Simulator Opensimulator.

User avatar
TenPlus1
Member
Posts: 2936
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by TenPlus1 » Post

You could add blueprint items for each build and when you right-click an NPC with one of the blueprints they build it where they stand :)

User avatar
texmex
Member
Posts: 1752
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by texmex » Post

Do the NPCs need the required nodes in inventory to complete the build? If not that would be a good feature I think. Optionally they could perhaps be made to start out building with what they have?
Mods | Support Mesehub: bc1qluuests9rxmlnvpjrhsnyjg9ucwy6z3r0y3srw

User avatar
TenPlus1
Member
Posts: 2936
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by TenPlus1 » Post

How about a schematic store block that takes what it needs for the builds from your inventory and returns a blueprint item you can use on npc's to build it :)

Sokomine
Member
Posts: 4184
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by Sokomine » Post

The NPC running around and building the house looks very nice in the video. However, this isn't the first mod that does this kind of thing; Towntest existed a lot earlier. The main difference seems to be that this mod is mobs_redo based? That's good because that's a very popular mod supported by many. I hope this mod gets further developped than all those previous attempts.

My mod citybuilder (or, to be more preceise, the handle_schematics mod behind it) takes a slightly diffrent approach at mobs building schematics. Instead of letting the mob do all the work and build from scratch, the idea is to let the player choose a schematic with a special build chest (the same one that is used for copying/saving buildings) and spawn the selected building with special nodes that indicate what needs to be done where and how in order to create the structure. There are two special nodes: A "dig here" indicator (upside-down red pickaxe) and a scaffolding node that acts like a ladder. It's not perfect yet but you can test it already if you place a handle_schematics:build chest in your singleplayer world, revoke your creative priv and spawn a building.

The advantage of this approach is that players and (multiple) mobs can build on the same structure without too much confusion arising. It boils down to find all the dig_here-indicators in the area and right-click them often enough until they go away. Afterwards, find all the scaffolding nodes and similarily right-click them until they, too, go away. If that's done, the structure ought to stand there more or less (doors and other status-changing nodes may need manual updates). Players who want to help need to have the nodes that are to be placed inside their inventory. There isn't any tool required for digging the nodes with the dig-here-indicator yet.

I'm looking for a mob that can help with this build process. The mob would have to search for the two nodes of intrest in the desired area (or just in its environment), walk there as closely as possible and call a function in those nodes. There's no inventory handling for such potential mobs yet. Wielding the right tool or block might look more impressive to players who watch the process. The scaffolding nodes allow players and mobs to get closer to the place where they want to do something. Trouble is that mobs won't know about nodes they can climb.
A list of my mods can be found here.

User avatar
Andrey01
Member
Posts: 2460
Joined: Wed Oct 19, 2016 15:18
GitHub: Andrey2470T
In-game: Andrey01
Location: Russia, Moscow

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by Andrey01 » Post

I`ve watched Demonstration video and i can say the NPC builds realistically. However, why can they build through blocks? 1:29 - 1:50 (One NPC built his roof that being behind the wall).

User avatar
Andrey01
Member
Posts: 2460
Joined: Wed Oct 19, 2016 15:18
GitHub: Andrey2470T
In-game: Andrey01
Location: Russia, Moscow

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by Andrey01 » Post

And btw, here is an error with NPC (it happened when i had clicked him):

Code: Select all

2018-07-25 00:05:34: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'npcbuildqueue' in callback luaentity_Step(): ...user/opt/minetest/bin/../mods/npcbuildqueue/init.lua:229: attempt to call method 'yaw' (a nil value)
2018-07-25 00:05:34: ERROR[Main]: stack traceback:
2018-07-25 00:05:34: ERROR[Main]: 	...user/opt/minetest/bin/../mods/npcbuildqueue/init.lua:229: in function 'do_custom'
2018-07-25 00:05:34: ERROR[Main]: 	...home/user/opt/minetest/bin/../mods/mobs_redo/api.lua:2734: in function <...home/user/opt/minetest/bin/../mods/mobs_redo/api.lua:2676>
Minetest version is 5.0.0-dev.

User avatar
IcyDiamond
Member
Posts: 169
Joined: Fri Mar 30, 2018 08:55
GitHub: LunaSquee
IRC: IcyDiamond
In-game: IcyDiamond
Location: Estonia
Contact:

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by IcyDiamond » Post

Andrey01 wrote:And btw, here is an error with NPC (it happened when i had clicked him):

Code: Select all

2018-07-25 00:05:34: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'npcbuildqueue' in callback luaentity_Step(): ...user/opt/minetest/bin/../mods/npcbuildqueue/init.lua:229: attempt to call method 'yaw' (a nil value)
2018-07-25 00:05:34: ERROR[Main]: stack traceback:
2018-07-25 00:05:34: ERROR[Main]: 	...user/opt/minetest/bin/../mods/npcbuildqueue/init.lua:229: in function 'do_custom'
2018-07-25 00:05:34: ERROR[Main]: 	...home/user/opt/minetest/bin/../mods/mobs_redo/api.lua:2734: in function <...home/user/opt/minetest/bin/../mods/mobs_redo/api.lua:2676>
Minetest version is 5.0.0-dev.
I cannot reproduce this. More details?
Web developer | Minetest modder | Systems Administrator | Donate
Mods - elepower | melterns | towny

ShadMOrdre
Member
Posts: 741
Joined: Mon Dec 29, 2014 08:07
GitHub: ShadMOrdre
In-game: shadmordre
Location: USA

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by ShadMOrdre » Post

Icy,

I did encounter the same error, using 0.4.16. My solution was to comment out the call to mobs:yaw.

I think this might be related to using different player models, and trying to have the NPC "look" at where they are building.

As a side note, at first the NPCs were invisible, and I had to copy the default character.b3d file into the mod folder and rename it to mobs_character.b3d. Perhaps this is the incorrect player model file, and the above call to mobs:yaw would work with a correct model. Neither your mod or mobs_redo had a mobs_character.b3d file, so I used the one from MT game default mod.

Shad
MY MODS: lib_ecology lib_materials lib_clouds lib_node_shapes ---- Inspired By: Open Source Virtual World Simulator Opensimulator.

User avatar
IcyDiamond
Member
Posts: 169
Joined: Fri Mar 30, 2018 08:55
GitHub: LunaSquee
IRC: IcyDiamond
In-game: IcyDiamond
Location: Estonia
Contact:

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by IcyDiamond » Post

ShadMOrdre wrote:Icy,

I did encounter the same error, using 0.4.16. My solution was to comment out the call to mobs:yaw.

I think this might be related to using different player models, and trying to have the NPC "look" at where they are building.

As a side note, at first the NPCs were invisible, and I had to copy the default character.b3d file into the mod folder and rename it to mobs_character.b3d. Perhaps this is the incorrect player model file, and the above call to mobs:yaw would work with a correct model. Neither your mod or mobs_redo had a mobs_character.b3d file, so I used the one from MT game default mod.

Shad
That's weird because :yaw is a mobs_redo API function https://notabug.org/TenPlus1/mobs_redo/ ... i.lua#L171
And yes, the example was made with mobs_npc enabled.
Web developer | Minetest modder | Systems Administrator | Donate
Mods - elepower | melterns | towny

User avatar
Andrey01
Member
Posts: 2460
Joined: Wed Oct 19, 2016 15:18
GitHub: Andrey2470T
In-game: Andrey01
Location: Russia, Moscow

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by Andrey01 » Post

IcyDiamond wrote:
Andrey01 wrote:And btw, here is an error with NPC (it happened when i had clicked him):

Code: Select all

2018-07-25 00:05:34: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'npcbuildqueue' in callback luaentity_Step(): ...user/opt/minetest/bin/../mods/npcbuildqueue/init.lua:229: attempt to call method 'yaw' (a nil value)
2018-07-25 00:05:34: ERROR[Main]: stack traceback:
2018-07-25 00:05:34: ERROR[Main]: 	...user/opt/minetest/bin/../mods/npcbuildqueue/init.lua:229: in function 'do_custom'
2018-07-25 00:05:34: ERROR[Main]: 	...home/user/opt/minetest/bin/../mods/mobs_redo/api.lua:2734: in function <...home/user/opt/minetest/bin/../mods/mobs_redo/api.lua:2676>
Minetest version is 5.0.0-dev.
I cannot reproduce this. More details?
When i had clicked one NPC i got that error. And it can not find a model for your npc (just unknown one that like doesn`t exist). As i said i use 5.0.0-dev.

Astrobe
Member
Posts: 328
Joined: Sun Apr 01, 2018 10:46

Re: [Mod] NPC Build Queue API [npcbuildqueue]

by Astrobe » Post

This probably means that you are calling yaw() on the wrong object (maybe self.object:yaw() instead of self:yaw()).

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests