Page 1 of 3

[Mod] Traders [mobf_trader]

Posted: Wed Apr 09, 2014 14:21
by Sokomine
Want to trade?
Image

Features of the traders:
  • they never wander around and do not use any cpu ressources while not trading - they're completely passive (=server friendly!)
  • very tiny media data footprint - no increase in connection time
  • no dependencies on other mods
  • new skins can be added (any playerskin will do)
  • highly configurable: Name, animation, height, width and texture can be set.
  • they can be picked up, carried around and placed at a new location (provided you own the mob)
  • each trader can make up to 24 diffrent offers simultaneously
  • for each offer, there may be up to 6 diffrent ways of payment (3 for more complex offers)
  • complex offers may consist of packages of up to 4 item stacks which can be exchanged simultaneously
  • The exchange of items is done automaticly. Clicking on the desired good and then on the payment will do the trade. There's no need for moving your inventory around manually.
  • There is a wide variety of pre-defined traders for lots of mods and goods (lumberjacks, farmers, ..)
  • Players can create individual traders which sell goods from locked chests owned by the player.
  • No need to waste trade goods in order to store what the trader is supposed to sell.
  • You can let your trader buy items if you either know the item name of what you want (i.e. default:nyancat) or do have at least one sample item.
  • Money and money2 are supported.
  • Trade offers can be edited, deleted and added.
  • With the /trader command, traders can be spawned by players who have the mob_basics_spawn priv.
  • Players can get a limited amount of own traders by using a special large trader chest.
  • The /moblist command shows you where all the traders are.
  • After a /clearallobjects, the /moblist command can also be used to restore the removed mobs by requesting a copy for your inventory and placing that back into the world.
  • Extra large chests fascilitate storage management for the traders.
Sample offer of a trader of the type misc (similar to the old trader in mobf):
Image

When you click on one of the goods (this time, it's a player-owned trader selling packages), it may look like this:
Image

The mod is named mobf_trader, although the only thing they still have in common with the traders found in Sapiers animals modpack is the way they trade and some of the goods they offer. The mod is a continuation of/replacement for mobf_trader from my random_buildings modpack - and more. Not only does it add traders that offer fixed sets of goods (i.e. the lumberjacks which sell moretree wood) - it also adds traders that can be used and configured by players. In short: Whenever you want players to be able to trade, this might be the mod for you.

Unlike other mob mods, this one is very lightweight. There is no additional media data for large models which might increase connection time - there's just a tiny number of skins (same as playerskins) which is practically nothing. The player model is used for the mobs. Traders that stand around on your server and wait for customers do exactly that - they stand around all day, using no cpu ressources for movement or anything else whatsoever. They're completely passive until you right-click them and do the trade. At that instant, they act like shops.

Admins with the mob_basics_spawn priv can spawn traders with the chat command

Code: Select all

/trader
which will print a list of avaiable types if it is called without parameters; or with

Code: Select all

/trader default
in order to get a trader similar to the one in the animals modpack.


There are plenty of pre-defined types available. You can easily add your own ones if you take a look at the way traders are defined. But that's not all: There are also traders of the type individual that can be configured ingame and be used by players to trade goods with other players.


In order to get your own trader, you first need to craft an extra large chest. That one makes it easier for the trader to access the inventory from which he is supposed to sell your goods. However, the trader may also use other locked chests (including technic's gold chests) owned by you. Image

That special chest contains up to 400 slots. Click on Select rows to access the other slots. To compensate for that large inventory, it does not tolerate other locked chests close to it and will refuse to be placed too close to one.
Image

If you want to get an overview of all the things you've stored in that large chest, click on Statistic:
Image

And, to finally get your trader, click on Request Trader. Each player may have up to 2 traders (this can be changed). Each trader costs you 12 gold ingots, which you have to place inside the large chest. The price is of course configurable.
Image

Traders can be configured: Animation (stand, sit, sleep, walk, mine and walk&mine) can be set (stand or sit are probably the best choice); the name can be set; height and width are changeable (smaller mobs will float a bit - no way to change that), and of course the texture can be
set. Image

Now right-click the trader and arrange the items in your inventory in the topmost row. The item at the top left will be the one you're selling - the other items will be possible payments. The item names and their amount is shown in the formspec below and can be changed before you click on Store.
Image

This is how this offer looks like:
Image

You can also offer up to four items as a package. The prices may similarily consist of up to four diffrent items. The colored background (green, blue, grey, blue) shows you which inventory slots will be used for what: Green is what you offer, and the rest are up to three diffrent alternate prices.
Image


That more complex offer will look like this:
Image

And here is how it looks after you have bought something (in this case, payment 3 was choosen):
Image

Sometimes you want to buy some items of a kind - i.e. a few stacks of junglewood (from other players) - but do not want to have your entire trade chest filled with it. In such a case, click on Limits. Item name, amount of that item found in your chest, when to sell, when to buy, and the nodename are listed.
Image

Click on one of those items to change the limits:
Image


Download: https://github.com/Sokomine/mobf_trader ... master.zip
Browse code: https://github.com/Sokomine/mobf_trader
Version: 0.5
Licence: GPLv3
License for textures: CC-BY-SA; three of the skins are done by Jordach
directly, and the one with the hat was done by Addi (based on Jordachs skin)
Depends on: -nothing-

Supports:
  • default (clay trader, flowers, misc, default, ores)
  • animals modpack
  • farming plus
  • moretrees
  • money: use
    money 123 to set a price of 123 credits; use money2 123 if you
    use the money2 mod (each instead of i.e. default:cobble 99)
This mod has been inspired by Stus NPC framework and is to some degree a framework in itshelf. All the trading happens inside mob_trading.lua inside its own namespace. Thus, if you like the trading aspect but not the rest, you can use it in your own mods.

Some traders from the first generation of this mod can be seen in action on the King-Arthurs Land server.

There may still be bugs (all those formspecs and user input are likely to contain errors), but it ought to work well enough already. If you operate a server, please at least give it a try as it will fascilitate trading a lot.

Posted: Wed Apr 09, 2014 14:38
by Krock
Wow! I didn't expect it that good when you told about this.

Yes, bugs are there:
Image

Posted: Wed Apr 09, 2014 14:51
by Sokomine
Krock wrote: Yes, bugs are there:
That's right, those bugs are to be expected. After all all these mobs share the same collusion box. Trying to change that did not work out well - mobs where sinking gradually into the floor...The best way around that problem is to make height differences not too extreme.

Posted: Thu Apr 10, 2014 14:04
by addi
Thats the best mod ever wirten for minetst!

its just great :-)

now its possible to trade wich other players.
also its now possible to get (a lot of) clay on servers where is no clay anymore!
an its complete without dependencies!!

ok there are some "bugs" but that are no bugs, thats a "user input failure" you can just fix it if you dont enter so much height differences.

realy realy good mod!

lot of thanks for doing that!

Re: [Mod] Traders [mobf_trader]

Posted: Tue May 20, 2014 00:36
by Sokomine
I've added some more default traders which will eventually be villagers in a medieval-type village and which try to sell what people in such villages created. They usually take twice as much as the receipe would cost and offer almost anything from default plus cottages. Some items from mobf (saddle, sheers, lasso, net) are also sold. The baker not only offers bread, he also has pies (bushes/plantslib) in store. Those new traders are not of much use on their own (crafting it yourshelf is usually cheaper). They will live in the cottages already seen in my villages mod. I'm currently trying to integrate them into Nores mapgen.

It would be great if there'd be some more textures for the traders/mobs. The ones Jordach did are fine already - they're just not enough. More variety would be great, i.e. diffrent colors (shades of blue, grey and brown). Thus, if any of you is good at making skins, please help!

Re: [Mod] Traders [mobf_trader]

Posted: Fri Feb 27, 2015 16:04
by Sokomine
There was a bug in the traders which led to a crash. That has been fixed now, so please update! As a side effect, the mod now comes with a config.lua file where you can set the amount of mobs and traders a player may have. The initial value of 2 proved to be too low; I've increased the default value to 12 mobs per player. That may sound much, but as they're peaceful and do nothing but stand around, the additional load for a server will be minimal.

Additional textures for the trader mobs would be welcome! They can wear normal player skins, but won't profit directly from installed skin mods as that might be confusing.

Re: [Mod] Traders [mobf_trader]

Posted: Thu Mar 26, 2015 09:20
by Ivà
Trying this interesting mod as suggested I couldn't edit the trader with the config button in formspec. When I push the button the formspec disappears and nothing more happens.

I tried debug options on server but get no more information than this in debug.log:

Code: Select all

Trying to spawn mobf_trader:trader of type glassmaker at (-0.67199999094009,27.5,-69.231002807617)
18:48:09: ACTION[ServerThread]: [mob_basics] Error: ID already taken. Can not spawn mob.
But the mob spawns, and I can trade with it as well, only that is always the same texture and the same size and I can't configure it. I'm using 0.4.12 client and server with only default game and this mod. Sokomine tell me if I can do something more to debug the problem.

Re: [Mod] Traders [mobf_trader]

Posted: Fri Mar 27, 2015 17:37
by Sokomine
Iva wrote: Trying this interesting mod as suggested I couldn't edit the trader with the config button in formspec. When I push the button the formspec disappears and nothing more happens.

I tried debug options on server but get no more information than this in debug.log:

Code: Select all
Trying to spawn mobf_trader:trader of type glassmaker at (-0.67199999094009,27.5,-69.231002807617)
18:48:09: ACTION[ServerThread]: [mob_basics] Error: ID already taken. Can not spawn mob.
It seems you got a duplicate of that particular trader somewhere in your world. There can only be one with the same ID. Please try to pick the trader up and then delete what you got. If that doesn't work, try to punch him or delete the entity with other means (afaik WorldEdit has a command for that as well).
Iva wrote: But the mob spawns, and I can trade with it as well, only that is always the same texture and the same size and I can't configure it. I'm using 0.4.12 client and server with only default game and this mod. Sokomine tell me if I can do something more to debug the problem.
There was a recent change in minetest_game that caused the traders to become invisible. I've changed the name of the model so that they'll become visible with latest minetest_game again.

Re: [Mod] Traders [mobf_trader]

Posted: Sat Apr 11, 2015 21:04
by Danfun64
Do the traders spawn in houses like the animals modpack, or do they need be be spawn manually? If not, can you add that as a feature?

Re: [Mod] Traders [mobf_trader]

Posted: Sun Apr 12, 2015 00:20
by Sokomine
Danfun64 wrote: Do the traders spawn in houses like the animals modpack, or do they need be be spawn manually? If not, can you add that as a feature?
Currently, all traders have to be spawned manually. This is helpful for servers that wish to use the mod - there will only be traders around that have been placed by a player or an admin. In the future, I plan to integrate them into mg_villages as well. My older mod, random_buildings, already had some traders. Those where based on mobf. These mobf_traders here in this mod are far more advanced and lightweight for the server and only share the mobf* in their name.
The pre-configured traders in this mod here are those that are designed as future inhabitants of the villages and single houses. They even got suitable skins for that work.

Re: [Mod] Traders [mobf_trader]

Posted: Mon Apr 13, 2015 22:42
by Danfun64
Sokomine wrote:In the future, I plan to integrate them into mg_villages as well.
What do you mean by that? Do you intend to add the traders directly to the mg_villages code while keeping the spawnable traders a separate mod, or do you intend to have the two mods work together?

In either case, after the integration, will traders appear automatically where they are supposed to, or must a new world be generated?

Re: [Mod] Traders [mobf_trader]

Posted: Sun Apr 19, 2015 02:29
by Sokomine
Danfun64 wrote: What do you mean by that? Do you intend to add the traders directly to the mg_villages code while keeping the spawnable traders a separate mod, or do you intend to have the two mods work together?
They will both be two seperate mods which will be working together. mg_villages does support a lot of other mods already without having to depend on them. If they're not installed, nothing will happen. But if the other mods (i.e. the traders) are installed, you'll get more functionallity (i.e. they'll be spawned in the future).
Danfun64 wrote: In either case, after the integration, will traders appear automatically where they are supposed to, or must a new world be generated?
Good question. It might be easier to ask for a new world. That's one of the reasons why I havn't officially released the mod yet.

Re: [Mod] Traders [mobf_trader]

Posted: Sun Apr 19, 2015 06:28
by Ivà
Sokomine, I need to disable mob_basics.update_visual_size (the code that randomize the size of new traders) to solve the problem of some traders become invisible when reloaded or placed (not when generated).

As far as I can see, for some reason the trader vsize decimal data is ignored when saved to mod_mob_basics.data, I mean, if a new trader has a vsize of x=0.91, y= 1.1, z=0.91, it is saved as x=0, y=1 and z=0, so makes the trader invisible when reloaded (size of 0).

But I couldn't figure out why this happens, maybe the minetest serialize and deserialize function? I don't know... Maybe I'm the only one who happens this and get a bug elsewhere...

Re: [Mod] Traders [mobf_trader]

Posted: Sun Apr 19, 2015 19:59
by Diamond knight
Suggestion:

You should make a variant that is kinda like mc villager trading to make this mod usefull for single player.

Re: [Mod] Traders [mobf_trader]

Posted: Thu May 07, 2015 13:21
by christoferl
I am having an issue getting the trader to create complicated trades (more than one item for payment). Am I not seeing a step in setting it up?

updated - OOps
- I found it - thank you for the fantastic mod...

Re: [Mod] Traders [mobf_trader]

Posted: Thu Jun 18, 2015 01:35
by Sokomine
Diamond knight wrote: Suggestion: You should make a variant that is kinda like mc villager trading to make this mod usefull for single player.
Can you explain in detail what you have in mind? I'm not very familiar with the mc villagers.

The mod received an update today. If mobf_trader.ALL_TRADERS_RANDOM = true is set in config.lua, then each trader will get a random stock. The trade offers made are still determined by the type of the trader (i.e. a blacksmith will sell blacksmith products), but each trader has only some offers instead of the complete set, thus creating more diverse and intresting traders. New offers are added randomly with a certain chance after each completed trade. Once the trader has sold his stock, the trade offer will disappear.

Please test this new feature and report any bugs. I hope that it can be useful for other mob mods as well. The mod is set up in such a way that it can easily be used by mobs from other mods, provided they provide some information about who they are and what type of trader they are.

The skins for the traders are not diverse enough yet. More skin textures, clothing and other variants would be highly welcome! With the new system of combining textures, there ought to be a way to make those traders look more distinct than now.

Re: [Mod] Traders [mobf_trader]

Posted: Thu Jun 18, 2015 07:37
by Rochambeau
Maybe it's the wrong thread but are you planning to spawn these traders in their workplaces in mg_villages? It would make the villages feel more alive.

I recently tried the game Adventuretest and liked the populated villages very, very much.
Here is how Adventuretest does it (line 427).

----------

Edit: nevermind. Got it working. Forgot to install mod handle-schematics.

Re: [Mod] Traders [mobf_trader]

Posted: Fri Jun 19, 2015 03:57
by Sokomine
Rochambeau wrote: Maybe it's the wrong thread but are you planning to spawn these traders in their workplaces in mg_villages? It would make the villages feel more alive.
I'm already doing so in recent versions. The houses in the villages even know how many traders they ought to spawn, and the traders are set up in such a way that they'll fit to the building style (trader_village.lua; males will get medieval jobs, while females will sell farming_plus products). There are still some errors in the spawning code - far less traders are placed than expected. Some may be found on roofs due to inperfect spawning. And they won't move around at all, just stand there all day long.
Rochambeau wrote: I recently tried the game Adventuretest and liked the populated villages very, very much.
Here is how Adventuretest does it (line 427).
Yes, I do love AdventureTest as well. That got villages that feel really alive, while mg_villages villages are too static without mobs roaming around.

As mobf_trader was always intended to be of use for other mob mods and just provide the trading interface, I've added overrides for on_rightclick for the peaceful villagers in AdventureTest. Tests would be welcome! Just pull the latest version of this mod and use it together with AdventureTest.

Re: [Mod] Traders [mobf_trader]

Posted: Fri Jun 19, 2015 05:30
by Rochambeau
Sokomine wrote:Yes, I do love AdventureTest as well. That got villages that feel really alive, while mg_villages villages are too static without mobs roaming around.

As mobf_trader was always intended to be of use for other mob mods and just provide the trading interface, I've added overrides for on_rightclick for the peaceful villagers in AdventureTest. Tests would be welcome! Just pull the latest version of this mod and use it together with AdventureTest.
The only reason I played Adventuretest were actually the randomly generated villages. Now that I've found mg_villages I went back to play minetest_game with a selection of my favourite mods.

To make villages/buildings look more alive I tried a different approach by using mobs redos NPCs. I make them spawn above mg_villages:plotmarker and they roam around and even guard the village. When they see hostile mobs, they run towards and attack them which is actually pretty cool!

Re: [Mod] Traders [mobf_trader]

Posted: Fri Jun 19, 2015 16:31
by Sokomine
Rochambeau wrote: The only reason I played Adventuretest were actually the randomly generated villages. Now that I've found mg_villages I went back to play minetest_game with a selection of my favourite mods.
AdventureTest has something on its own. That experience point system, together with the difficult way of crafting things, forms a new type of gameplay. I didn't really built anything on BrandonReeses' testserver - that game was just more about exploring and survival.
Rochambeau wrote: To make villages/buildings look more alive I tried a different approach by using mobs redos NPCs. I make them spawn above mg_villages:plotmarker and they roam around and even guard the village. When they see hostile mobs, they run towards and attack them which is actually pretty cool!
Ah. That's a nice approach as well! You can add "mobs:npc" to the list mobf_trader.add_as_trader in config.lua that comes with this mod in order to teach those npc how to trade. Sadly, mobs redo has only very few mobs that are of a peaceful persuasion; the others try to...embrace...their customers too much. I've considered teaching dirt mobs to trade, but...they turned out to be solely intrested in buying dirt, and even then didn't have anything to offer in return :-)

Using the plotmarker as a passive node for spawning mods is a very creative idea and may work well. I considered turning them into active spawners when I created them. Apart from mobs willing to trade, cattle like chicken and cows would also be highly welcome in villages. They usually don't roam the wilderness alone on their own, those tamed mobs...

Re: [Mod] Traders [mobf_trader]

Posted: Sat Jun 20, 2015 01:10
by Sokomine
The non-hostile mobs from the Lord of the Test game and the "npc" from the mobs redo mod now act as traders as well, provided their mod and mobf_trader are both installed.

Re: [Mod] Traders [mobf_trader]

Posted: Thu Aug 13, 2015 04:10
by Sokomine
The traders are now wielding the items they want to sale. If one doesn't update his offer after you bought the last item, please just right-click him again.

Trader willing to sell black wool:
Image

Re: [Mod] Traders [mobf_trader]

Posted: Thu Aug 13, 2015 13:46
by ExeterDad
^^ Nice!
Of course I'm not suprised, all your work is nice :)

Re: [Mod] Traders [mobf_trader]

Posted: Mon Sep 14, 2015 21:28
by mahmutelmas06
Could you provide intllib support. Then we can translate it to our languages.

Re: [Mod] Traders [mobf_trader]

Posted: Mon Sep 14, 2015 21:54
by Sokomine
mahmutelmas06 wrote: Could you provide intllib support. Then we can translate it to our languages.
Someone did that already for my cottages mod, so it is certainly doable. The trouble is that that way of translating mods only works in singleplayer; multiplayer servers will still most of the time only provide english texts.