[Mod] Villagers for Minetest [villagers][v0.17]

Post Reply
User avatar
ErrorNull
Member
Posts: 270
Joined: Thu Mar 03, 2016 00:43
GitHub: ErrorNull0

[Mod] Villagers for Minetest [villagers][v0.17]

by ErrorNull » Post

This mod spawns villagers in Sokomine's mg_villages mod. I want to provide a light-weight and simple mod where villagers have enough basic interactivity to make the villages more fun to visit and explore. The villagers will walk around, dig some things, provide random facts or smalltalk by chatting, and buy sell items by trading. They will not befriend you, become your travel buddy, or similate a daily routine or social community.

I also focus on making the villager's appearance (skin, hair, clothing, etc) and chat dialogue random but also based on the region, climate, and type of village and building.

Image
Image

VISAUL FEATURES:
-chat popup bubbles and not player console
-skin, hair, clothing types randomly chosen
-random chat dialogue but also based on job
-random names but also based on region & age
-villagers stay near their assigned plots
-remembers prior position & actions on re-spawn
-continues prior action after chatting/trading
-villagers cannot 'hear you' if chatting to fast

TECHNICAL FEATURES:
-villagers spawn using LBM's and not ABM's
-infrequent action calculations - every 4-6 sec
-minimal walking & standing animation glitches
-checks if multiplayers chat/trade same villager

REQUIREMENTS: Sokomine's main villages mod: [mg_villages]

RECOMMENDED MODS:
[cottages] - adds more village types: medieval, charachoal, lumberjack, claytrader, logcabin, tent
[village_gambit] - adds village type 'gambit'
[village_towntest] - adds village type 'cornernote'
[village_sandcity] - adds village type 'sandcity'
[village_ruins] - adds village type 'ruins'

VERSION: v0.17
Warning! Mod is still very work-on-progress. Expect errors and halfway implemented features. It is available now to simply test and gather your feedback and report errors. Villagers do not yet support the GRASSHUT village type, so it may not work correctly or at all - or crash the game. My expected roadmap:
* v0.18 = playable trading system
* v0.20 = support more farming/food/drinks mods
* v0.25 = create chat dialogue based on each job type
* v0.30 = improve movement & actions algorithm
* v0.35 = hostile mob interaction
* v0.40 = unique clothes for certain jobs

LICENCE: WTFPL
TODO: TODO.txt on GitHub
CHANGELOG: README.txt on GitHub

DOWNLOAD [VILLAGERS] HERE! GitHub page for Villagers
Attachments
villagers2.png
villagers2.png (373.38 KiB) Viewed 5201 times
villagers.png
villagers.png (568.55 KiB) Viewed 5201 times
Last edited by ErrorNull on Sat Jul 29, 2017 23:58, edited 47 times in total.

User avatar
maikerumine
Member
Posts: 1420
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: [Mod] Villagers for Minetest [villagers]

by maikerumine » Post

This is sweet!!!
Talamh Survival Minetest-->viewtopic.php?f=10&t=12959

zorman2000
Member
Posts: 84
Joined: Tue Jul 26, 2016 18:18
GitHub: hkzorman
In-game: zorman2000

Re: [Mod] Villagers for Minetest [villagers]

by zorman2000 » Post

Hey, this looks very interesting! You just ninja'd me by an hour! viewtopic.php?f=9&t=17918

User avatar
ErrorNull
Member
Posts: 270
Joined: Thu Mar 03, 2016 00:43
GitHub: ErrorNull0

Re: [Mod] Villagers for Minetest [villagers]

by ErrorNull » Post

@ maikerumine - thanks! If you find any bugs or have suggestions let me know.

@ zorman2000 - oh hey, your advanced_npc looks very interesting as well! you have already implemented things i'm still working on like trading, using beds, sitting on benches, and walking in/out of a building. i will surely need to chat with you more to get your inspiration and of course will credit you.

at the same time, you also plan the scope of your NPCs to do much more than i care for my villagers to do. my focus is on simplicity and being processor/server friendly, so i don't plan things like: establishing friendships, tame animals and ride carts, governments and economic activity simulation. i'm glad your mod is here too to offer more choices to everyone!

User avatar
TumeniNodes
Member
Posts: 2941
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: [Mod] Villagers for Minetest [villagers]

by TumeniNodes » Post

Looks promising
A Wonderful World

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: [Mod] Villagers for Minetest [villagers]

by Sokomine » Post

It's great how diffrent the villagers look like - and yet their style is somewhat similar withhin a given village. That's excellent! And it fits well to the villages.

Punching the villagers for talking is a bit risky as punching counts as an attack in other circumstances. It'd be safer to have chat on right-click by default. Trading could be an extra option for the player.

The chat itself is very nice. The comic style chatboxes look very good. Villagers even say good-bye if a player ends the chat with them! That's very nice. It'd be nice if they would stop their plans about walking in the future or would stop when walking and a player starts talking to them. Maybe a more general "the villager is busy/doesn't seem to hear you right now" would be more convincing than "busy with planning walking" :-) But that's a small detail. Sometimes the texts are a bit too long for the text chat box and the box ought to be larger. I also had to add a check for "and text_string " in line 2489 in init.lua as the text_string parameter was at least once empty. In the long term it would be great it players could "answer" the mobs by clicking on a button. The owner of the tavern was asking me if I like the weather...but how shall I reply? :) That mobs show what they are (gender, age, profession, ...) when pointing at them is also great. It's very nice that villagers show their names in the chat boxes. It's great that the villagers have diffrent chats based on their profession. Some of their chats won't work without other mods installed (yeti, slimes, ..). Players would look for those monsters in vain.

Some of the sentences the villagers say randomly might count as "wisdom" and perhaps be stored in a book the player carries with him/her. That's something I'd love to have in AdventureTest as well. Maybe that's more important once there are quests (something for later on :-)). Players could also become known to the villagers over time. Maybe less to individual villagers than to the village as a whole due to that taking up less storage space.

One villager was even observed harvesting wheat and replanting :-)

Trading does not seem to work. A miller offered some wheat - but it was only a 9x9 grid and I had no idea where to move the wheat or which price he was demanding. Drawing items out of the trade grid and throwing them to the floor for later pickup works. The villager said "thanks", but it seemed to be a very odd, one-sided trade.

Regarding code-style: One single big file is not so good for maintenance. Splitting it up into smaller files would be easier to read. It's already well-organized inside.

To have the villagers move only in 8 directions and not entirely randomly might be a good idea and help them a lot to get around inside their villages. But what will they do if mobs attack them? They'll eventually have to learn how to defend their homes. Afterwards they could of course just teleport to the center of the current node they're standing on and continue to walk about from there without trouble.

It's good that there are traders assigned to the wagons. Building types bench, deco, empty, field, fountain, pasture, pit, shed, spawn, tent, wagon and well do not get inhabitants assigned in the newest version of mg_villages due to there beeing no beds where they could sleep. It's a good idea that villagers are intrested in these spots and keep talking about them. Maybe any villager could talk about those spots if he's there or that's his target. To have travellers/traders sleep in their wagons is also a good idea but might need closer inspection of the wagons. Not all seem suitable for sleeping. Maybe people staying in the inn/pub (if there is one) could own a wagon and be travellers.
ErrorNull wrote: - Stays within certain distance from their initial spawn point.
That's a very good idea.
ErrorNull wrote: - complete trading function
I do of course like the trading function from my mobf_trader mod. Else I wouldn't have written it :-) It ought to be possible to integrate that as well. Perhaps the formspec is not always perfectly nice...
ErrorNull wrote: - add unique chat dialogue for remaining villager types
Those add a lot of life to the mobs. The existing ones are fine already. But more certainly can't hurt :-)
ErrorNull wrote: - improve eye and hair placement on some villagers
- add proper clothing textures for 'travelers'
- add body textures for 'old' aged villagers
The look of the villagers is one of the major strengths of this mod. Any further improvment there is certainly very good and will make it even better. But it's very good already.
ErrorNull wrote: - villagers can walk through and open/close doors and gates
That ought to work in combination with my mob_world_interaction mod that's based on burlis pathfinder. No need to write that anew. You still need to call the appropriate functions in your movement code. There does not seem to be a path-following movement code included? Perhaps the one from npcf will do. I got good results with it.
ErrorNull wrote: - tower guard spawn atop the tower too!
The tower in village type "nore" has a bed now and will get a guard assigned. The guard doesn't have any idea of where his workplace is. None of the mobs has such knowledge. The code stores which plot they work on, but...that's only the start. Mobs ought to be attracted to the appropriate tool-nodes for their work. Bakers and smiths ought to love furnaces, millers my handmill and perhaps the treshing floor, guards the top of their towers (which is not a special node...), farmers fields...but no such code exists so far.
ErrorNull wrote: - multiple villagers spawn in taverns
Hm, some could be visitors from neighbouring villages, but most of them ought to be locals. A tavern (and the benches in it) are targets of high intrest for a poor working mob...they just don't know it yet. But I'd rather have villagers go there than special villagers spawning just in the pub.
ErrorNull wrote: - villagers appear in their homes and lay in their beds at night
- villagers climb stairs
- villagers sit on furniture
That's the job of mob_world_interaction. The sleeping in bed, finding a place next to a bed/bench/table to stand, the pathfinding...all that exists already. Learning to use other furniture will follow. And stairs are no problem for burlis pathfinder or the movement code from i.e. npcf. The mob still has to decide which node he wants to use next.
ErrorNull wrote: - figure out how to use GitHub
Once you've created a repository, github will tell you what to do. Having a (unix) shell at hand helps a lot.
ErrorNull wrote: (regarding zorman2000s mod)
at the same time, you also plan the scope of your NPCs to do much more than i care for my villagers to do. my focus is on simplicity and being processor/server friendly, so i don't plan things like: establishing friendships, tame animals and ride carts, governments and economic activity simulation. i'm glad your mod is here too to offer more choices to everyone!
Don't undervalue establishing friendship. Especially young players want to be friends with everyone. Establishing a relationship with others (often also animals and sometimes even machines) is a very human behaviour. It's important that your actions towards the villagers have reasonable consequences. It's ok if they're forgiving errors fast, but building up and establishing friendship with the village could be a very convenient goal for players. The mod will be most useful in singleplayer when there are no other players available. Ressources are less short in such an environment then on a server.

Anyway...a great mod. Thank you for writing and publishing it! I'm looking forward to future updates and will continue to play with it.
A list of my mods can be found here.

User avatar
ErrorNull
Member
Posts: 270
Joined: Thu Mar 03, 2016 00:43
GitHub: ErrorNull0

Re: [Mod] Villagers for Minetest [villagers]

by ErrorNull » Post

Hi Sokomine, thanks much for your input! And thanks for pointing out the code error. I will address that on my next update!

I originally gave players ability to initiate chat while villagers were walking but due to the simplistic and grid-like nature of their walking mechanics it would complicate calculations more than I desire as villagers' positions between nodes would require me to compensate positioning whenever that chat attempt occurs. For now, I will definitely tweak the code enough to allow chatting while villagers are digging and when villagers 'prepare to walk'.

Having the ability for the player to respond back to chat could be a long term goal, but for now my inspiration are from the old school cosole games like zelda 2 and final fantasy where the npc's are fairly simple and just walk around a bit and give you some random dialogue... and some provide useful ones too. I do intend to include quests into the dialogue. But yes, haha.. some of the dialogue include details for TenPlus1's mob's redo, because that will be a much encouraged optional mod to have loaded. I may make it required at some point. =)

Yes, the trading is just a dummy system right now. Not at all representative of it's final form. =) However, you will notice on the trading formspec that the villagers do maintain the crops/plants they dig - and for now you can steal them!

Honestly, I have not considered hostile mobs attacking them. For now, everytime villagers are hit, their HP is restored. And i just assumed Mobs Redo will not spawn hostiles within your protected villages? is that true? of course other people can install other mob systems. So this will be something I will be keeping in mind.

About how many characters of text do you see is best for the chat bubble? I'm using Windows 10 and I'm sure we are all using different operating systems and font settings and so I will need to find a middle ground.


Thanks for all your other tips and suggestions. I'll let you know if I need more clarification on your mob_world_interaction mod and other things as I keep working here...

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: [Mod] Villagers for Minetest [villagers]

by Sokomine » Post

ErrorNull wrote: I originally gave players ability to initiate chat while villagers were walking but due to the simplistic and grid-like nature of their walking mechanics it would complicate calculations more than I desire as villagers' positions between nodes would require me to compensate positioning whenever that chat attempt occurs. For now, I will definitely tweak the code enough to allow chatting while villagers are digging and when villagers 'prepare to walk'.
Won't it be enough to center them on the node they're standing on once the chat is finished and/or they consider to walk elsewhere? That way you could stick to your simplistic movement (which isn't bad in a blocky environment).
ErrorNull wrote: Having the ability for the player to respond back to chat could be a long term goal, but for now my inspiration are from the old school cosole games like zelda 2 and final fantasy where the npc's are fairly simple and just walk around a bit and give you some random dialogue... and some provide useful ones too. I do intend to include quests into the dialogue.
I don't really know the Zelda or final fantasy games. The very old point-and-click-adventures might come to mind here (i.e. Monkey Island and the lot of them). That means: No free dialogue but preselected possible answers. The mob would just offer 2-4 diffrent answers/questions for the player and respond accordingly. That's still more than enough work to do for convincing quests, but it's at least a lot easier than free dialogue.
ErrorNull wrote: But yes, haha.. some of the dialogue include details for TenPlus1's mob's redo, because that will be a much encouraged optional mod to have loaded. I may make it required at some point. =)
Just mention it as "highly recommended" :-)
ErrorNull wrote: Yes, the trading is just a dummy system right now. Not at all representative of it's final form. =) However, you will notice on the trading formspec that the villagers do maintain the crops/plants they dig - and for now you can steal them!
Poor villagers! I want to help them...not steal their few possesions from them.
ErrorNull wrote: Honestly, I have not considered hostile mobs attacking them. For now, everytime villagers are hit, their HP is restored. And i just assumed Mobs Redo will not spawn hostiles within your protected villages? is that true? of course other people can install other mob systems. So this will be something I will be keeping in mind.
Take a look at BrandonReeses AdventureTest game as hosted on his TerraQuest server. The villagers there don't know much at all...but they do combat hostile mobs and even reward the player if he/she helps the villagers by fighting against their enemies. It's part of the story there. A lone guard at night with his fellows all asleep might have a hard time fighting off all those dirt-, sand- and stonemobs wandering in...and they will wander in even if they won't spawn in protected areas (no idea if they don't spawn there). You'll have those hostile mobs wandering around. It would be odd if they'd only attack the player, while villagers and hostile monsters would ignore each other.
ErrorNull wrote: About how many characters of text do you see is best for the chat bubble? I'm using Windows 10 and I'm sure we are all using different operating systems and font settings and so I will need to find a middle ground.
That could be complicated as the letters do not seem to have the same width. The sentence "They only like to roam about at night," exceeds the bubble with its first and last two letters, while "The snow can be a peaceful place." almost fits in.

You also ought to take a look at what mg_villages already provides regarding inhabitants, their names, ages, family relationships, places for sleeping and jobs. It's admittedly pretty new. The arrays mg_villages.inhabitants.names_male and mg_villages.inhabitants.names_female can be set to other names. It's not as versatile as your code in some way - it doesn't distinguish by region or age - but it does assure that family members do not share the same first name and that villagers with the same profession in the same village have diffrent first names as well. The creation of inhabitant data happens in mg_villages.part_of_village_spawned - so you need to call the original function in order to get that data.

I've added a function mg_villages.inhabitants.get_names_list_full that will allow you to to provide your own specific lists of names.

Get the latest version of mg_villages, install mob_world_interaction, right-click a plotmarker and read the text you'll get in chat if you're intrested about how assignment of inhabitants to houses works. There's now some debug information about how many steps the path from the place next to the mob's bed to the middle of the front side of the house (=potential place for spawning mobs) contains and where the front door might be. That's a bit of scroll but probably of intrest. The front door position isn't safed anywhere yet, and its calculation ought to be more efficient.
A list of my mods can be found here.

User avatar
ErrorNull
Member
Posts: 270
Joined: Thu Mar 03, 2016 00:43
GitHub: ErrorNull0

Re: [Mod] Villagers for Minetest [villagers]

by ErrorNull » Post

Quick Update v0.11

[fixed]
- prevent 'traveler' villager types from being young/child physical size
- fix NIL dialogue error when chatting with certain 'farmer' villagers
- allow chat when villager is about to walk and when villager is digging

[improved]
- custom dialogue when player chats while villager is about to walk or while digging
- alert messages now include villager's name
- tweaked chat text to better fit width of the chat bubble. thanks sokomine for pointing that out. i plan to create a function to automatically resize the chat dialogue width to fit the chat bubbles!

[added]
- all travelers now wear straps with either backpack or sword on their backs
Last edited by ErrorNull on Mon Jun 19, 2017 23:06, edited 1 time in total.

User avatar
ErrorNull
Member
Posts: 270
Joined: Thu Mar 03, 2016 00:43
GitHub: ErrorNull0

Re: [Mod] Villagers for Minetest [villagers]

by ErrorNull » Post

Quick Update v0.12

[fixed]
- digging of field/garden crops only allowed by farmers and field workers
- walking on newly planted field/garden only allowed by farmers and field workers
- 'traveler' villagers only spawn from 'empty' plot types now and no longer also from 'deco'

[improved]
- tweaked chatbubble positioning when trading
- shifted eyes down a few pixels to better match hair position
- optimized some code regarding hair auto-generating and chat dialogue while trading

[added]
- old aged male villagers have gray hair (or bald) and facial hair
- old aged female villagers have gray hair
- old aged villagers of either genders might wear eye glasses
- while villager is digging, chat dialogue reflects what is it they are digging (wheat, cotton, grass, snow)
- custom chat dialogue for allmende and deco villager types

It will be several days until the next update. I will be working on adding in the proper trading functionality now. the funny looking 9x9 grid will be no more...
Image
Attachments
old villagers.png
old villagers.png (233.29 KiB) Viewed 5201 times

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: [Mod] Villagers for Minetest [villagers]

by Sokomine » Post

ErrorNull wrote: all travelers now wear straps with either backpack or sword on their backs
Very nice! The other changes/bugfixes/completitions are also very good.
ErrorNull wrote: - old aged male villagers have gray hair (or bald) and facial hair
- old aged female villagers have gray hair
- old aged villagers of either genders might wear eye glasses
You did excellent work with them! They look lovely. I'm looking forward to see more of them.
ErrorNull wrote: - custom chat dialogue for allmende and deco villager types
Difficult to say something about those. Hints about the purpose of the allmende can't hurt as most players do not seem to understand it. The deco part...hmm...I guess they like how their village looks like :-) In general there ought to be no villagers assigned to these spots. They need to live elsewhere, have a bed in a house.
ErrorNull wrote: It will be several days until the next update. I will be working on adding in the proper trading functionality now. the funny looking 9x9 grid will be no more...
Hm. There are already the trading functions in my mobf_trader mod or in advanced_npc. Do we really need a third option? Even if so...some common things ought to be common to all the villager mods.
A list of my mods can be found here.

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

Re: [Mod] Villagers for Minetest [villagers]

by Devy » Post

Do you have a Github for this mod?

User avatar
ErrorNull
Member
Posts: 270
Joined: Thu Mar 03, 2016 00:43
GitHub: ErrorNull0

Re: [Mod] Villagers for Minetest [villagers]

by ErrorNull » Post

Devy wrote:Do you have a Github for this mod?
Hi Devy - I currently do not have Github but I will look into getting that setup by next week. :)
Sokomine wrote: Difficult to say something about those. Hints about the purpose of the allmende can't hurt as most players do not seem to understand it. The deco part...hmm...I guess they like how their village looks like :-) In general there ought to be no villagers assigned to these spots. They need to live elsewhere, have a bed in a house.
I do agree, there should not be villagers tied to the plot types like deco, allmende, empty, etc. But to not have a villager initially spawn from these plots seem like a waste of good spawnpoint. Hehehe. :) So in later updates I will look into converting these spawned villagers to free roaming villagers - where their movement it not limited by 10 block radius of their spawn point and perhaps they follow the village roads. At night, since they have no homes, they will simply de-spawn (signifying the villager traveled away from the village somewhere) or might see them sleeping under a tree. You can see the start of this idea in the chat dialogue so far with my 'traveler' villagers -- though for now, they are tied to the 'empty' plot types. The villagers you see now are meant to be 'stationary' and belong to their building/plot. I do plan to have villagers (like travelers) who the player will see always walking the streets and passing through the village and who are always on the move. So this would be another style of villager I plan.
Sokomine wrote: Hm. There are already the trading functions in my mobf_trader mod or in advanced_npc. Do we really need a third option? Even if so...some common things ought to be common to all the villager mods.
Here's what I'm looking for in trading and maybe your mobf_trader function can do most of this?
- all villagers can offer to trade what they dug/harvested (wheat, cotton, snow/snowballs, grass, etc)
- when those items are sold out, player must wait for villager to dig/harvest more
- certain villagers (traders, shops, forge, bakery, etc) will also offer specialty items for trade
- these villagers will offer anywhere from 1 to 4 different specialty items but no more
- all items offered for trade by any villager requires only a single item from player
- i do not wish to require player to give multiple different items for a single item the villager is offering

User avatar
TumeniNodes
Member
Posts: 2941
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: [Mod] Villagers for Minetest [villagers]

by TumeniNodes » Post

I really wish individuals working on similar mobs mods would just give it a shot, trying to combine forces...

There are already numerous mobs mods... working as a group might really make some wonderous progress

I do like this though ; )
A Wonderful World

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: [Mod] Villagers for Minetest [villagers]

by Sokomine » Post

ErrorNull wrote: I do plan to have villagers (like travelers) who the player will see always walking the streets and passing through the village and who are always on the move. So this would be another style of villager I plan.
That might be ok as well. Even mobs moving just randomly about do add a considerable amount of life to villages.
ErrorNull wrote: Here's what I'm looking for in trading and maybe your mobf_trader function can do most of this?
- all villagers can offer to trade what they dug/harvested (wheat, cotton, snow/snowballs, grass, etc)
- when those items are sold out, player must wait for villager to dig/harvest more
- certain villagers (traders, shops, forge, bakery, etc) will also offer specialty items for trade
- these villagers will offer anywhere from 1 to 4 different specialty items but no more
- all items offered for trade by any villager requires only a single item from player
- i do not wish to require player to give multiple different items for a single item the villager is offering
My traders are very powerful. What you ask for is but a subset of what they can do. trader_village.lua already contains some prototypes of traders. The prototypes have all the trades the trader will ever offer. Each trader will only offer a random subset and a random amount of these trades each time.

Example for a trader who offers the following trades:
Trade goods 1: He sells 12 wheat for one iron lump.
Trade goods 2: For 20 cotton, the player can either pay with 5 coal, 2 iron lumps or 15 torches. The player chooses how he wants to pay.
Trade goods 3: For 2 snow, the trader asks for 1 leaves block.
Trade goods 4: For one my_mod:my_special_item block, the player has to pay one mese block.

Code: Select all

self.trader_goods = {
  {"farming:wheat 12", "default:iron_lump"},
  {"farming:cotton 20", "default:coal_lump 5", "default:iron_lump 2", "default:torch 15"},
  {"default:snow 2", "default:leaves"},
  {"my_mod:my_special_item", "default:mese"},
}
But now we have a trader with a finite inventory. He may for example have the following in his stock: A stock of 1 (one) of the my_mod:my_special_item things (which is trade good nr. 4). 5 of trade good nr. 2 (=farming:cotton) and 100 of trade good nr. 3 (a lot of snow). No wheat available. His trader_stock table would look like this:

Code: Select all

self.trader_stock = {
  { 4, 1 },
  { 2, 5 },
  { 3, 100 }
}
When such a trader sells one item, his stock is decreased. In general after each trade, the function mobf_trader.trader_with_stock_after_sale will get called and add some new trades so that it doesn't get too boring for the player. You might want to override it. Or maybe just mobf_trader.trader_with_stock_add_random_offer - which will add the new offer (and stock). You also need to set self.trader_typ = "individual" for traders to work the way I described here.

In theory, you can just add your mob to the mobf_trader.add_as_trader table and it will be truned into a trader. However, the on_rightclick function of your mob will then be the one of mobf_trader. That might not be what you want. Better call mobf_trader.trader_entity_trade( self, clicker ); manually when the player wishes to trade. You'll also have to take care that all the needed variables (staticdata) get stored and restored at the right time.
A list of my mods can be found here.

LouisCyfer
Member
Posts: 46
Joined: Sun Jun 25, 2017 02:24
GitHub: LouisCyfer

Re: [Mod] Villagers for Minetest [villagers]

by LouisCyfer » Post

@ErrorNull:

I have occoured some nil errors occouring in spawnVillager(pos, building_type, region)

I do assume building_type sometimes spits that out, unsure why because i haven't looked into how the type is handled (your code is impressive tho hehe)

the error happens while the if math.random function

Code: Select all

	--get GENDER and save to 'vGender' object custom field
	local gender = "male"
	if math.random(BUILDING_DATA[building_type].female) == 1 then
		gender = "female"
	end
	luaEntity.vGender = gender
I did write a determine code to find that out (yet new to lua but its pretty simple so far xD)
NOTE: this code is WTFPL licensed, also its ment as suggestion/improvement idea

Code: Select all

	--get GENDER and save to 'vGender' object custom field
	local gender = "male"

	print("building_type is a " .. type(building_type))

	if type(building_type) == "nil" then
		building_type = "0"
	end

	print("building_type is a " .. type(building_type))

	if type(building_type) == "string" then
		if math.random(BUILDING_DATA[building_type].female) == 1 then
			gender = "female"
		end
	end

	-- if math.random(BUILDING_DATA[building_type].female) == 1 then
		-- gender = "female"
	-- end

	luaEntity.vGender = gender
ideas, suggestions/etc are welcome :)

EDIT:
line 3901 might be involved aswell where building_data.typ is beeing put into spawnVillager

Code: Select all

local luaEntity = spawnVillager(spawn_pos, building_data.typ , region_type)
Last edited by LouisCyfer on Sun Jun 25, 2017 03:31, edited 4 times in total.

User avatar
ErrorNull
Member
Posts: 270
Joined: Thu Mar 03, 2016 00:43
GitHub: ErrorNull0

Re: [Mod] Villagers for Minetest [villagers]

by ErrorNull » Post

hi LouisCyfer - thanks for letting me know of this error. my mod is complaining because it's not aware of some extra building types that are spawning in your game. i believe you might have some of the extra village types like cottage, cornernote/towntest villages, or gambit installed? i will update my code to fix this by tomorrow as well as other fixes and improvements. stay tuned! =)

LouisCyfer
Member
Posts: 46
Joined: Sun Jun 25, 2017 02:24
GitHub: LouisCyfer

Re: [Mod] Villagers for Minetest [villagers]

by LouisCyfer » Post

ahhh that makes sense, because I seem to have some extra types .. here's a list of mods I use
  • .minetest/mods/3d_armor
    .minetest/mods/aliveai
    .minetest/mods/ambience
    .minetest/mods/bedrock2
    .minetest/mods/biome_lib
    .minetest/mods/bows
    .minetest/mods/caverealms
    .minetest/mods/display_modpack
    .minetest/mods/esmobs
    .minetest/mods/ethereal
    .minetest/mods/farming
    .minetest/mods/fishing
    .minetest/mods/gps
    .minetest/mods/hud_hunger
    .minetest/mods/intllib
    .minetest/mods/lightning
    .minetest/mods/minetestu_skinsdb
    .minetest/mods/moreblocks
    .minetest/mods/nether
    .minetest/mods/plantlife_modpack
    .minetest/mods/stoneworks
    .minetest/mods/unified_inventory
    .minetest/mods/villagers
    .minetest/mods/villages
    .minetest/mods/weather_pack
    .minetest/mods/whitelist
    .minetest/mods/xpanes
very cool and ty for reply :) *stays tuned*

EDIT: I assume making a quick workaround by basicially forcing the building_type to 0 or something might help for now?

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: [Mod] Villagers for Minetest [villagers]

by Sokomine » Post

ErrorNull wrote: hi LouisCyfer - thanks for letting me know of this error. my mod is complaining because it's not aware of some extra building types that are spawning in your game. i believe you might have some of the extra village types like cottage, cornernote/towntest villages, or gambit installed? i will update my code to fix this by tomorrow as well as other fixes and improvements. stay tuned! =)
In theory most things - village types, building types - can be extended by new mods. Players can create their own building types. It might be a good idea to have a fallback in such a case. So far, nobody created his/her own village type :-(
LouisCyfer wrote: .minetest/mods/villages
Which one would that be? My mod is called mg_villages (because it is based upon Nores mg mapgen). There are other villages mod out there but most are not really working.
A list of my mods can be found here.

User avatar
ErrorNull
Member
Posts: 270
Joined: Thu Mar 03, 2016 00:43
GitHub: ErrorNull0

Re: [Mod] Villagers for Minetest [villagers]

by ErrorNull » Post

Quick Update v0.13

fixes:
- white chat bubble image no longer disappears on rare occasions while chatting
- some chat dialogue no longer appear twice in succession
- moved existing dialogue to villager types that make more sense: from secular to library, and trader to shop

improvements:
- redo and optimize code for dynamic body customization (skin, eyes, hair, etc)
- redo and optimize code for dynamic clothing customization (shirts, pants, dresses, boots, etc)
- reworked colorization for all body and clothing textures
- moved all lua constants for names, plots, colors, textures, dialogue, etc into its own lua file
- tweaked relationship between village types and region type

additions:
- unique texture for priests (though it's not that great for now), which are villagers that spawn by churches.
- unique 'got to go' message after villager has spoken through their 'main' dialgue
- color variation between body skin colors of villagers among different regions types *
- support for cottage, village_towntest, and village_gambit building mods
- custom dialgue for 'baker', 'mill', 'trader', 'hut', and 'secular'

notes:
I'm currently developing my villagers mod with the following additional mods installed: cottages, village_gambit, village_towntest, and village_sandcity. I will soon be adding Mobs Redo (by TenPlus1) when I start working with mob interactions, and then Farming Redo (also by TenPlus1).

* I've added 4 main skin color variations that villagers will exhibit that attempts to give an illusion of different climate/regional or races of villagers:

Light skinned villagers appear in cold regions and wear darker clothing, 'normal' skin villagers appear in 'normal' climate regions, tanned skin villagers show up in 'native' regions and like to wear dark colors and some males like to go shirtless, and dark/brown skin villagers show up in desert villages and prefer white/light color clothing and wear full dresses.

I would suggest to visit each of the different villages that mg_villages has to offer and see how different the villagers as a group look between villages, yet consistent in dress style and color theme within each village type. Hope you like it. Please report any bugs and as always I welcome any feedback, good and bad! I will be working on the trading system for my next update... for sure this time. >_<

@ LouisCyfer - ah yes, exactly what sokomine said ... there is no such mod that is only called 'villages' . totally missed that clue.

@ Sokomine - at some point i would like to make my own village types too, but for now just focusing on villagers. your mg_villagers mod can do so much, we can only focus on one feature at a time. =)

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: [Mod] Villagers for Minetest [villagers]

by Sokomine » Post

ErrorNull wrote: I would suggest to visit each of the different villages that mg_villages has to offer and see how different the villagers as a group look between villages, yet consistent in dress style and color theme within each village type. Hope you like it. Please report any bugs and as always I welcome any feedback, good and bad! I will be working on the trading system for my next update... for sure this time. >_<
The trading system is less important. My mobf_trader mod is more or less a trading api, and advanced_npc has its own trading system. That's already covered - even in diffrent flavours :-) What's unique and of great value is your skin system - that the villagers have a unique look while sill looking roughly similar inside each village. That's a very very good feature. I love it a lot. The chat is also very nice.
ErrorNull wrote: @ Sokomine - at some point i would like to make my own village types too, but for now just focusing on villagers. your mg_villagers mod can do so much, we can only focus on one feature at a time. =)
Of course. Same problem here. There are also other mods I created and which need to be maintained. And then there's the occasional house somewhere on a server that just calls for beeing placed...lots of things to do :-)

Something else: While experimenting with spawning of mobs in general through mg_villages I noticed that they don't always show up. Advanced_npc even overrides the plotmarker in order to spawn mobs. Perhaps it would be helpful if I'd take the positions in front of the house (one is assigned to each bed) and would place easy-to-override mob spawners there. They'd probably best store village_id, plot_nr and bed_nr - as that's enough to identify the data of the mob that is to...er...be...there. Perhaps a mob spawner placed one node below the ground could be helpful.
A list of my mods can be found here.

LouisCyfer
Member
Posts: 46
Joined: Sun Jun 25, 2017 02:24
GitHub: LouisCyfer

Re: [Mod] Villagers for Minetest [villagers]

by LouisCyfer » Post

LouisCyfer wrote:
Sokomine wrote: -snip -
Which one would that be? My mod is called mg_villages (because it is based upon Nores mg mapgen). There are other villages mod out there but most are not really working.
thats correct, I downloaded/renamed the folder from HEREso that the minus'es are erased (obviously MT has issues with mods having any "-" in the foldername) so its just villages instead of villages-for-minetest-modpack-master .. is it mandatory/rather important to have the foldername of the villages mg_villages or should i rename the modpack folder to mp_villages?

EDIT:

getting this when attempting to trade with free hands right-click:

Code: Select all

2017-06-26 01:05:36: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'villagers' in callback luaentity_Rightclick(): /home/louiscyfer/.minetest/mods/villagers/init.lua:1507: attempt to get length of field 'vSell' (a nil value)
2017-06-26 01:05:36: ERROR[Main]: stack traceback:
2017-06-26 01:05:36: ERROR[Main]: 	/home/louiscyfer/.minetest/mods/villagers/init.lua:1507: in function 'getTradingFormspec'
2017-06-26 01:05:36: ERROR[Main]: 	/home/louiscyfer/.minetest/mods/villagers/init.lua:1540: in function 'tradeVillager'
2017-06-26 01:05:36: ERROR[Main]: 	/home/louiscyfer/.minetest/mods/villagers/init.lua:1865: in function </home/louiscyfer/.minetest/mods/villagers/init.lua:1856>

User avatar
ErrorNull
Member
Posts: 270
Joined: Thu Mar 03, 2016 00:43
GitHub: ErrorNull0

Re: [Mod] Villagers for Minetest [villagers]

by ErrorNull » Post

@ LouisCyfer - error fixed! Thanks for pointing that out. I was progressing with a bit with the new trading formspec and forgot to comment out that code which is still incomplete.

@ Sokomine - I will also be experimenting with inserting your mobf trader code upon rightclick on my villagers and see how that works out.
Sokomine wrote:Something else: While experimenting with spawning of mobs in general through mg_villages I noticed that they don't always show up. Advanced_npc even overrides the plotmarker in order to spawn mobs. Perhaps it would be helpful if I'd take the positions in front of the house (one is assigned to each bed) and would place easy-to-override mob spawners there. They'd probably best store village_id, plot_nr and bed_nr - as that's enough to identify the data of the mob that is to...er...be...there. Perhaps a mob spawner placed one node below the ground could be helpful.
I do notice that when using your mobf traders in your villages, that it's fairly consistent it will spawn one trader for each building type. When i try the alternative technique by hooking in mobs redo so that the mobs redo traders spawn on the plotmarkers (which is also advanced_npc technique) it takes some time for the traders/villagers to appear and perhaps do not spawn consistently either. Is that what you're referring to?

For now i'm pretty happy with how my villagers spawn since it's done during mapgen time of your villages like how your mobf traders get generated. So far it seems i am getting one villager for each building type without fail... and their spawn positions are either inside the building (which is cool) and outside the building (nearby). My next goal is to obtain the position of the beds (and even position of the doors if possible?) that are part of each building and have my villagers optionally spawn near those points.

LouisCyfer
Member
Posts: 46
Joined: Sun Jun 25, 2017 02:24
GitHub: LouisCyfer

Re: [Mod] Villagers for Minetest [villagers]

by LouisCyfer » Post

ErrorNull wrote:@ LouisCyfer - error fixed! Thanks for pointing that out. I was progressing with a bit with the new trading formspec and forgot to comment out that code which is still incomplete.
I'm aware of it and I'm thankful that you respond at all, taking care of written code is not always self-understanding.
plus thatfor this topic is in the WIP section ;)

.. so far the earlier error did not re-appear again for me and I'm glad I could help with my less understanding in lua

User avatar
ErrorNull
Member
Posts: 270
Joined: Thu Mar 03, 2016 00:43
GitHub: ErrorNull0

Re: [Mod] Villagers for Minetest [villagers]

by ErrorNull » Post

I think I figured out github! Here's the link. If it doesn't work like how it should, let me know...
https://github.com/ErrorNull0/villagers

update: looks like my Readme file still refers to v0.12 near the top, so shows in github too. hehe. of course it's 0.13 now. I'll correct when I'm back from work.
Last edited by ErrorNull on Mon Jun 26, 2017 02:10, edited 2 times in total.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 10 guests