[PoC] NPC Build Queue [npcbuildqueue]

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

[PoC] NPC Build Queue [npcbuildqueue]

by IcyDiamond » Sat Jul 21, 2018 07:55

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: 1537
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex
 

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

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

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

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

by IcyDiamond » Sat Jul 21, 2018 20:18

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

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

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

by ShadMOrdre » Tue Jul 24, 2018 07:40

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: 2589
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

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

by TenPlus1 » Tue Jul 24, 2018 12:31

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: 1537
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

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

by texmex » Tue Jul 24, 2018 14:22

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?
 

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

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

by TenPlus1 » Tue Jul 24, 2018 14:24

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: 3834
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

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

by Sokomine » Tue Jul 24, 2018 16:39

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: 2303
Joined: Wed Oct 19, 2016 15:18
Location: Russia, Moscow
GitHub: Andrey2470T
In-game: Andrey01

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

by Andrey01 » Tue Jul 24, 2018 19:44

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: 2303
Joined: Wed Oct 19, 2016 15:18
Location: Russia, Moscow
GitHub: Andrey2470T
In-game: Andrey01

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

by Andrey01 » Tue Jul 24, 2018 21:09

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: 135
Joined: Fri Mar 30, 2018 08:55
Location: Estonia
GitHub: LunaSquee
IRC: IcyDiamond
In-game: IcyDiamond

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

by IcyDiamond » Wed Jul 25, 2018 15:53

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: 471
Joined: Mon Dec 29, 2014 08:07
Location: USA
GitHub: ShadMOrdre
In-game: shadmordre

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

by ShadMOrdre » Wed Jul 25, 2018 16:16

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: 135
Joined: Fri Mar 30, 2018 08:55
Location: Estonia
GitHub: LunaSquee
IRC: IcyDiamond
In-game: IcyDiamond

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

by IcyDiamond » Wed Jul 25, 2018 17:41

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: 2303
Joined: Wed Oct 19, 2016 15:18
Location: Russia, Moscow
GitHub: Andrey2470T
In-game: Andrey01

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

by Andrey01 » Wed Jul 25, 2018 19:07

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: 234
Joined: Sun Apr 01, 2018 10:46

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

by Astrobe » Thu Jul 26, 2018 19:56

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


Return to WIP Mods



Who is online

Users browsing this forum: No registered users and 3 guests