[MOD] Commodities markets [commoditymarket] 0.3

User avatar
Hamlet
Member
 
Posts: 700
Joined: Sat Jul 29, 2017 21:09
Location: Lombardy, Italy
GitHub: h4ml3t
IRC: H4mlet

Re: [MOD] Commodities markets [commoditymarket] 0.2

by Hamlet » Tue Dec 31, 2019 14:41

FaceDeer wrote:This mod implements marketplaces where players can post buy and sell offers for various items, allowing for organic market forces to determine the relative values of the resources in a world. [...]


This is the Mod Of The Year 2019.

FaceDeer wrote:This mod is released under the MIT license.


---> Normally I would stay silent, but.

The MIT License does not require code disclosure, therefore anyone is legally entitled to use your code CLOSE ITS SOURCE and just add a mention about the fact that you made it, let's call it "CC-BY".
EDIT:
"[...] including without limitation the rights to use, copy, modify, merge, [...]"
It states "to modify", which implies code disclosure...
Okay, I was wrong. Still I think GPL would be more clear. *zips his mouth*


For this piece of work?! Are you serious?!
Seriously, you "MIT License guys" are "shooting into your own b*lls".

<--- End of the very-personal-and-humble-opinion.

All hail FaceDeer, yet another awesome mod. :)
 

FaceDeer
Member
 
Posts: 444
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [MOD] Commodities markets [commoditymarket] 0.3

by FaceDeer » Tue Dec 31, 2019 17:09

Hamlet wrote:This is the Mod Of The Year 2019.


Gosh! But don't be hasty, there's a few hours left yet.

True story: I started work on this mod because I was out camping for two weeks and only had my tablet along with me for company. My tablet doesn't have the horsepower to do map generation modding, I didn't have art tools installed, and I just generally don't care for the touchscreen interface when playing Minetest. So I thought to myself "which of my mod ideas can I work on where all I have to do to test it is launch a game and click on the node right in front of me?" :)

Hamlet wrote:
FaceDeer wrote:This mod is released under the MIT license.


---> Normally I would stay silent, but.


Heh. I can dual-license it to GPL as well, if you like.

The reason I use MIT as my default license is specifically because of the openness, I don't want anyone having to worry about fiddly license concerns if they want to copy and paste a chunk of my code or incorporate this mod into a modpack or game. I actually avoid the "non-commerical" CC licenses when looking for source assets (it comes up on Freesound sometimes) just in case someone wants to bundle my stuff with something that's got a price on it in some way (like a humble bundle, for example).

I don't use WTFPL because it's legally sloppy and some educational users of Minetest refuse mods with that license because it's got foul language. CC0 is not intended as a software license, and simply declaring "public domain" doesn't work in some jurisdictions (and theoretically puts me at more legal jeopardy than the "we decline all warranties" language of open source licenses, should someone try using my mod to run a nuclear power plant or something). I mainly just want people to have fun using these things I make.

That reminds me, I need to send this mod's github repository off to the minetest-mods group. I should probably move this thread into the "Mod Releases" forum soon too, it's been used on a live server for a couple of months and seems to be reasonably stable at this point. Maybe once I've got my version of the "settlements" mod properly stood up so there's a way to have all the different default markets appear in world. If anyone has last-minute bugs they've been holding onto, now's the time to mention them.
 

User avatar
FreeGamers
Member
 
Posts: 468
Joined: Sat May 25, 2019 00:15
Location: United States
GitHub: is proprietary I use NotABug

Re: [MOD] Commodities markets [commoditymarket] 0.2

by FreeGamers » Tue Dec 31, 2019 18:08

No bugs or complaints from my server. Over the last few months there were a few complaints from players that the market was hard to use and the interface is confusing in the buy/sell menu. That is a subjective opinion so it may vary. I both agree and disagree, I think that goes away once you make an order or two to try out. But for your typical MT player, there are probably simplification or more clear language in the buy/sell menu might help. I may play around with this when I have some time and see if I can come up better column labels or something to try to help this.

I haven't seen fatal bugs from this mod in a long while.
 

User avatar
FreeGamers
Member
 
Posts: 468
Joined: Sat May 25, 2019 00:15
Location: United States
GitHub: is proprietary I use NotABug

Re: [MOD] Commodities markets [commoditymarket] 0.2

by FreeGamers » Wed Jan 01, 2020 00:47

This is why I love keeping my players in the loop about things:

They're reporting to me that King's Market is now crashing the server. They took to covering it themselves (glitching through the protection) by using sand to prevent it from crashing the server. Then reported it to me(with a timestamp) when I came back online in chat. How cool? Very cool.

So I think your last update might have had some problems?

Code: Select all
2019-12-30 17:54:38: ACTION[Main]: Server: Shutting down
2019-12-30 17:54:38: ACTION[Main]: [mana] Server shuts down. Rescuing data into mana.mt
2019-12-30 17:54:38: ACTION[Main]: [mana] Wrote mana data into /var/games/minetest-server/.minetest/worlds/world//mana.mt.
2019-12-30 17:54:39: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'default' in callback item_OnPlace(): ...bin/../mods/lib_system/commoditymarket/formspecs.lua:15: attempt to get length of local 'tiles' (a nil value)
2019-12-30 17:54:39: ERROR[Main]: stack traceback:
2019-12-30 17:54:39: ERROR[Main]:       ...bin/../mods/lib_system/commoditymarket/formspecs.lua:15: in function 'get_icon'
2019-12-30 17:54:39: ERROR[Main]:       ...bin/../mods/lib_system/commoditymarket/formspecs.lua:231: in function <...bin/../mods/lib_system/commoditymarket/formspecs.lua:216>
2019-12-30 17:54:39: ERROR[Main]:       (tail call): ?
2019-12-30 17:54:39: ERROR[Main]:       ...ux/bin/../mods/lib_system/commoditymarket/market.lua:616: in function 'show_market'
2019-12-30 17:54:39: ERROR[Main]:       .../mods/lib_system/commoditymarket/default_markets.lua:62: in function 'on_rightclick'
2019-12-30 17:54:39: ERROR[Main]:       ...inetest-5.2.0-dev-linux/bin/../builtin/game/item.lua:418: in function <...inetest-5.2.0-dev-linux/bin/../builtin/game/item.lua:411>
2019-12-30 17:54:39: ERROR[Main]:       (tail call): ?


Version 5.2.0-dev
 

FaceDeer
Member
 
Posts: 444
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [MOD] Commodities markets [commoditymarket] 0.2

by FaceDeer » Wed Jan 01, 2020 03:56

FreeGamers wrote:2019-12-30 17:54:39: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'default' in callback item_OnPlace(): ...bin/../mods/lib_system/commoditymarket/formspecs.lua:15: attempt to get length of local 'tiles' (a nil value)
[/code]


Interesting. I think this might be a coincidence. I was able to reproduce this crash by creating a node type that had neither an inventory_image nor a tiles table defined and putting that node into the market inventory. The crash is in the code that looks up what image to use for the little icon, I've fixed it so that in this sort of situation it'll show the "unknown_item.png" texture rather than crashing.

I'm curious what item actually caused that, could you update to the latest commoditymarket and look through the items it's showing in the marketplace for anything with a valid name but an unknown_item.png icon? It's possible that there's some rare way of putting textures on a node that I've overlooked. I'll hit the 5.2 lua_api.txt documentation in the meantime and see if I can spot anything.
 

User avatar
FreeGamers
Member
 
Posts: 468
Joined: Sat May 25, 2019 00:15
Location: United States
GitHub: is proprietary I use NotABug

Re: [MOD] Commodities markets [commoditymarket] 0.2

by FreeGamers » Wed Jan 01, 2020 07:38

Yep, there is an unknown that is not getting purged. No string name.

Its at the top of the list too when sorted alphabetically. I'm not sure what it was.
 

FaceDeer
Member
 
Posts: 444
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [MOD] Commodities markets [commoditymarket] 0.2

by FaceDeer » Wed Jan 01, 2020 23:51

FreeGamers wrote:Yep, there is an unknown that is not getting purged. No string name.

Its at the top of the list too when sorted alphabetically. I'm not sure what it was.


I'll modify the purge_unknowns command to have it purge anything that would get the "unknown_item.png" icon. And I'll have it output a list of the items that were purged in the process to help with future troubleshooting. When you purge it, let me know the itemname it reports - I might be able to find a bug in some other mod in the process. :)
 

User avatar
FreeGamers
Member
 
Posts: 468
Joined: Sat May 25, 2019 00:15
Location: United States
GitHub: is proprietary I use NotABug

Re: [MOD] Commodities markets [commoditymarket] 0.2

by FreeGamers » Thu Jan 02, 2020 04:34

Have you completed the update? I see a push from 5 hours ago.
 

FaceDeer
Member
 
Posts: 444
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [MOD] Commodities markets [commoditymarket] 0.2

by FaceDeer » Thu Jan 02, 2020 05:45

Yup. In hindsight I should have added a log entry as well as player chat when purging items, but the information should be there. Just make sure to note it down. I'll add a log entry later, I'm not in a place where I can test the code I write at the moment.
 

User avatar
FreeGamers
Member
 
Posts: 468
Joined: Sat May 25, 2019 00:15
Location: United States
GitHub: is proprietary I use NotABug

Re: [MOD] Commodities markets [commoditymarket] 0.2

by FreeGamers » Thu Jan 02, 2020 19:19

Are you going to leave the settlements:junglewood for the other buildings? It is intended to be used with mobs_npc to spawn traders and npc's in the towns. I will try to set some time aside to write an attendant for the market when I can. It somewhat helps to create a interactive settlement. I would like to do some improvements to try to keep the npc's spawned by this near their villages. In my game they often go wandering about away from town and can be found in weird places like the ocean.

I see that you removed the settlements:junglewood from the king's market schematic. I suppose since these will spawn in automatically in towns, I can setup the spawn abm to spawn on junglewood (floor) near commoditymarket:kings_market.
 

User avatar
FreeGamers
Member
 
Posts: 468
Joined: Sat May 25, 2019 00:15
Location: United States
GitHub: is proprietary I use NotABug

Re: [MOD] Commodities markets [commoditymarket] 0.2

by FreeGamers » Thu Jan 02, 2020 20:15

See attached. Here are two mobs I've added better support for settlements too.

The npc will now try to stay near settlements:junglewood instead of wandering throughout the world. They retain most of the mobs_npc properties still and can be hired and can drop basic items.

The kings_market_clerk will bring up the kings_market interface on right click from a player. I've removed his original trading functions as well. He stands still by default but if for some reason this changes he will attempt to stay_near commoditymarket:kings_market. I've altered his spawn parameters slightly to spawn him ontop of junglewood (made an assumption here that my be incorrect) near kings_markets. There can only be one of these mobs at a time in an active block area.

I did not alter the mobs_npc:trader because he just stands in place and did not need any behavior changes. So it would be a bit more efficient to just leave him as is instead of declaring another mob.

A night_market_clerk could be made simply by copying the kings_market_clerk and changing the spawning behavior or whatever else you'd like.
Attachments
settlements_npcs_mkii.zip
(3.61 KiB) Downloaded 3 times
 

FaceDeer
Member
 
Posts: 444
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [MOD] Commodities markets [commoditymarket] 0.2

by FaceDeer » Fri Jan 03, 2020 21:06

Currently, the settlements mod replaces default:junglewood in the building schematics with settlements:junglewood automatically when the schematic is placed. So the market schematic I added should have settlements:junglewood flooring when it gets placed in-world by the mod.

My usual pattern when I take an existing mod and "run away" with it like I'm doing here is that I try to ensure that it can still be set up to do exactly the same thing it did before, just more efficiently and with hooks or settings to allow that functionality to be extended further. So it should be possible to drop it in as a replacement for the old one and have it still work like it did. Once I get things sorted out a bit better I'll bring this up on the settlements forum thread and see if the current mod maintainers want to take my revised version back as a pull request before I start going farther afield with it.

If you want to maintain the "only during the day" and "only during the night" behaviour of those two markets, make sure to wrap the open-market function call with a check. It's not done inside the open-market call itself.
 

User avatar
FreeGamers
Member
 
Posts: 468
Joined: Sat May 25, 2019 00:15
Location: United States
GitHub: is proprietary I use NotABug

Re: [MOD] Commodities markets [commoditymarket] 0.2

by FreeGamers » Fri Jan 03, 2020 21:46

Darn, you didn't even look at my upload, RIP. Yes, I've accounted for the time-checks in the king's market. So i'll just create a pack for my own server's usage that will anticipate the eventual settlements update to be placing kings markets. This supplementary pack will place mobs near the markets to announce them, give them a hud nametag, and give them a bit more life. I'm going to await the completion of your branch before I adapt something to it even more though. I have plenty of other mobs and tweaks to get done in the mean-time.
 

FaceDeer
Member
 
Posts: 444
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [MOD] Commodities markets [commoditymarket] 0.2

by FaceDeer » Sat Jan 04, 2020 02:51

Sorry, it's been a hectic day. I wrote that response on a phone, I couldn't open the attachment and mess about with it to see.
 

User avatar
Nathan.S
Member
 
Posts: 969
Joined: Wed Sep 24, 2014 17:47
Location: Bigsby Texas
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: [MOD] Commodities markets [commoditymarket] 0.2

by Nathan.S » Tue Jan 07, 2020 16:30

We just discovered an error on my server, items with inventory_images larger than 16px got cropped. I will try and dig into the code and see if there is a way to ensure larger items are scaled down. I'm not great with formspecs though.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course
 

FaceDeer
Member
 
Posts: 444
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [MOD] Commodities markets [commoditymarket] 0.2

by FaceDeer » Tue Jan 07, 2020 17:54

Formspec table images are hard to do much with, alas. They don't allow modifiers, and I don't recall there being scaling modifiers in any event, so it could be that there's no solution to this without engine modifications. I read in some old forum posts once that there used to be a way to trick Minetest into giving the actual inventory image to formspecs to use, which would be ideal, but it was a hack that got "fixed" at some point. I'll see if there's an existing feature request and if not I'll add one, that would be the ideal solution.
 

User avatar
Nathan.S
Member
 
Posts: 969
Joined: Wed Sep 24, 2014 17:47
Location: Bigsby Texas
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: [MOD] Commodities markets [commoditymarket] 0.2

by Nathan.S » Fri Jan 10, 2020 04:31

Another bug. If you place carts:cart in the inventory everything goes wonky, as in the picture. After a few minutes of pulling my hair out, thinking it was something with the description that was breaking things, and changing everything I could, all to no avail. I discovered that if the inventory_image uses the inventorycube modifier it breaks the formspec. Some other image modifiers seem to work fine though. Didn't do extensive testing, so I'm not sure if that's the only modifier that breaks it or not.
Thankfully I can very easily fix this by providing the rendered image as an image instead of relying of the modifier.
Attachments
screenshot_20200109_221317.png
(515.72 KiB) Not downloaded yet
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course
 

FaceDeer
Member
 
Posts: 444
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [MOD] Commodities markets [commoditymarket] 0.2

by FaceDeer » Fri Jan 10, 2020 17:02

Nathan.S wrote:Another bug. If you place carts:cart in the inventory everything goes wonky, as in the picture. After a few minutes of pulling my hair out, thinking it was something with the description that was breaking things, and changing everything I could, all to no avail. I discovered that if the inventory_image uses the inventorycube modifier it breaks the formspec. Some other image modifiers seem to work fine though. Didn't do extensive testing, so I'm not sure if that's the only modifier that breaks it or not.
Thankfully I can very easily fix this by providing the rendered image as an image instead of relying of the modifier.


This one I can fix easily enough. The icons in formspec tables actually don't work with any kind of modifier at all, so I've got code that strips everything off of the texture string aside from the base .png filename. The code didn't account for the [inventorycube case because it's a bit of an odd duck compared to the other modifiers. Now it extracts the "left" side of the inventory cube and uses that texture for the icon.

Edit: I've requested modifier support in table images as a feature request, fingers crossed it gets some support. :)
 

FaceDeer
Member
 
Posts: 444
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [MOD] Commodities markets [commoditymarket] 0.2

by FaceDeer » Wed Jan 15, 2020 18:36

Turns out the large icon problem can actually be crippling if the image being used for an item is big enough, stretching the icon column so wide that the rest of the table isn't accessible. This was discovered with the "billboard" mod, presumably there are others out there that are also problematic.

So I've added some workarounds to commoditymarket to allow these issues to be handled while (hopefully) awaiting an engine-side solution.

There's now a global setting to disable icons entirely, as well as per-player preferences for disabling icons if they should want to do that. That's a decent emergency "just make it usable again" workaround.

For "fixing" things a little better, I added the following two API calls to commoditymarket:

Code: Select all
commoditymarket.override_item_icon(item_name, new_icon_texture)
commoditymarket.override_image_icon(old_icon_texture, new_icon_texture)


These can be used to fix a specific problem case in a given game. For example,

Code: Select all
commoditymarket.override_item_icon("default:cobble", "default_wood.png")
commoditymarket.override_image_icon("default_stone.png", "default_wood.png")


Will cause cobble and stone to use the default_wood.png texture as their icon, overriding whatever commoditymarket would have been able to deduce from the item's definition. Overriding the item icon is item-specific, overriding the image icon will kick in whenever commoditymarket would determine a particular item's icon to be something that matches the first parameter (useful if there's a whole swath of items that all end up with the same bad icon texture).

This is kind of hacky, it requires server admins to potentially get their hands a little dirty with special-case coding. But you can stick all these overrides into a separate mod, and they're harmless when those items aren't around, so I could create a list of overrides for problems in common mods perhaps.
 

FaceDeer
Member
 
Posts: 444
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [MOD] Commodities markets [commoditymarket] 0.3

by FaceDeer » Sun Jan 19, 2020 18:40

I just did a pretty big refactor, cleaving this mod in twain. Everything that was in this mod is now split up into two: the basic API is in the old commoditymarket repository as before, but the five default markets have been split out into the "commoditymarket_fantasy" mod.

I had originally created these markets just to serve as testbeds for the API's various features, but they got rather fleshed out and elaborate in their own right. This way they can continue to live and grow as their own thing, but if someone wants to use Commoditymarket's API for their own markets without having all that stuff hanging around unused it's trivial to just leave that other mod out now.

I've tested the aliases and this should upgrade cleanly for existing worlds, just add commoditymarket_fantasy to your game and everything should "just work." Though of course no warrantee is provided, express or implied. Make backups of important worlds before major upgrades, as always!
 

User avatar
Diamond knight
Member
 
Posts: 473
Joined: Sun Apr 19, 2015 19:50
Location: Chilling in Constantinople
GitHub: Diamondknight
In-game: Ferrumprinceps
 

FaceDeer
Member
 
Posts: 444
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [MOD] Commodities markets [commoditymarket] 0.3

by FaceDeer » Thu Jan 23, 2020 23:23

Hm... the basic concept behind Trade Portals and commoditymarket are pretty different, duplicating Trade Portal's behaviour would probably enough changes to the code that it'd be easier to just write a whole new mod for that.

That said, there are a few "maybe someday" enhancements to commoditymarket that I've pondered that might move it in that direction a bit. I've considered the possibility of writing up some form of trading "bot" that a server admin could set up to stimulate economic activity by automatically issuing buy and sell orders, increasing market depth for various items. And I've considered adding the option of having the market charge fees of some sort, which could be made to vary depending on map location perhaps. Either of these would have a lot of complex effects on the economy though, hence why they're under the "maybe someday" category.

If someone's interested in writing trading bots for commoditymarket I could add a few API calls to simplify the task. Right now the API is centered around displaying the market formspec to a player and processing player inputs, which isn't necessarily ideal for a bot.
 

Previous

Return to WIP Mods



Who is online

Users browsing this forum: No registered users and 5 guests