Page 2 of 4

Re: [MOD] Commodities markets [commoditymarket] 0.1

Posted: Mon Jul 29, 2019 16:56
by Yvanhoe
Just wanted to mention the little known "¤". It is a symbol that means "unspecified currency" and I checked that it is rendered correctly in the default Minetest font.

https://en.wikipedia.org/wiki/Currency_(typography)

Re: [MOD] Commodities markets [commoditymarket] 0.1

Posted: Mon Jul 29, 2019 17:12
by FaceDeer
FreeGamers wrote:Do you think the trader's caravan will make the other shops not commonly used? Its open 24/7 and accessible anywhere. What is the benefit of using the King's or Night shop instead? I know they are configurable and just simply meant to be templates to have other options, but could you share some thoughts on how these are intended to differentiate?
My thought with the trader's caravan was that I'd like it to be strictly small-volume, so you'd use it for things you need a couple of *right now* (I'm starving to death in the desert and need to buy food, I'm deep underground and have run out of torches, I don't have quite enough Mese to finish this one bit of work I'm doing, etc.). I don't have enough tools available to do that yet, though - limiting the player inventory just means you have to dump mass quantities of goods onto the caravan with lots of smaller sell orders. I'll have to add a "sell volume limit" as well.

An idea I've been considering is a non-refundable listing fee. If it cost gold simply to create a listing, with no guarantee of a sale to recoup it, people would be more willing to haul their goods back to town to use the market without a fee for the more speculative stuff. This makes sense, IMO, wandering merchants aren't going to want to haul around large amounts of stuff for free. They want to make some money off of the convenience they provide and the risks they take.

Another idea is having buy and sell orders expire automatically after a certain time. So putting a listing for something that isn't likely to sell for a long time on the trade caravan is a waste, and it should be put on a long-term market instead.
FreeGamers wrote: Also, how would worn tools be handled?
Just remembered I never addressed this question. Worn tools are rejected by the market, only as-new items are allowed. :) The market also rejects items that have metadata on their itemstacks, such as written books, since internally it's not storing them *as* itemstacks and that data would be lost otherwise.
Yvanhoe wrote: Just wanted to mention the little known "¤"
Commoditymarket uses that symbol in the event that a market definition doesn't provide one of its own. :) A market can use it explicitly if there's nothing else suitable, though.


Edit: Figured I'd mention for FreeGamers, I just figured out the "Invalid table column option:"" (value="")" error. It was caused by a bit of bad formspec layout that only happened in the case where the market list was being displayed with zero market entries, which would be most likely to happen if you were filtering to show only markets where you had placed orders but didn't actually have any orders placed (as in the case where you'd just bought yourself out, the test case you mentioned it in). It was because I was giving the icon column a list of zero image entries to choose from. Will be fixed next time I push a change.

Edit 2: I just added an optional "sell_limit" parameter for the market definition and set it to 1000 for the caravan trader. The other stationary markets have no sell limit set, they're still infinite.

Re: [MOD] Commodities markets [commoditymarket] 0.1

Posted: Wed Jul 31, 2019 01:36
by FaceDeer
Made a change to how the caravan trader works, physically. Now instead of actually crafting and placing a caravan in-world, a player crafts a trading caravan signpost.

Upon placing the signpost on the ground, the signpost will check the terrain in front of it to determine if there's a good space for a trading caravan to arrive. Currently it checks a 3x3 patch of land to see if there's walkable ground and the 3x3 cube over it is composed of air. If the patch of land is suitable, it counts down a timer for 2 minutes and then a trading caravan appears. Ten minutes later (with a timer that is reset whenever a player opens the market UI) the caravan disappears, and if the player wants it back they can right-click on the sign to start the 2 minute spawn timer again. There are sounds that play on the caravan's arrival and departure in case the player's busy with something while they wait.

This doesn't really change much about how the caravan's actual market functions, but hopefully it will convey the market's mobile and communal nature better.

Oh, one problem with existing worlds upgrading to this; all existing caravan markets are now going to disappear ten minutes after their last use. There's a non-craftable "permanent" version that appears in the creative inventory that server admins can place in-world, to represent places where trading caravans might hang around long-term (such as next to other large fixed marketplaces), that can be used if you like.

I haven't made the trade caravan itself look more wagon-like, I think I'll make a full mesh version for that and that'll be a bit of work.

Re: [MOD] Commodities markets [commoditymarket] 0.1

Posted: Thu Aug 01, 2019 07:27
by FaceDeer
I've now made a full mesh version of the trade caravan that looks like a proper wagon.

This thing is starting to feel a bit less prototypey and a bit more "actual alpha release". Is anyone other than FreeGamers currently playing with this mod, and have you seen any crashes or other bugs? I might take that big scary warning off of the top of the thread now, if it seems all clear. The default markets could probably still use some tweaking for balance and such, but the basic system is starting to feel sound.

Re: [MOD] Commodities markets [commoditymarket] 0.1

Posted: Thu Aug 01, 2019 18:47
by u18398
I get this after enabling the mod:
2019-08-01 20:39:37: ERROR[Main]: ModError: Failed to load and run script from .minetest/mods/commoditymarket/init.lua:
2019-08-01 20:39:37: ERROR[Main]:.minetest/mods/commoditymarket/market.lua:422: invalid escape sequence near '"'
2019-08-01 20:39:37: ERROR[Main]: stack traceback:
2019-08-01 20:39:37: ERROR[Main]: [C]: in function 'dofile'
2019-08-01 20:39:37: ERROR[Main]: .minetest/mods/commoditymarket/init.lua:5: in main chunk
2019-08-01 20:39:37: ERROR[Main]: Siehe debug.txt für Details.
2019-08-01 20:39:37: ACTION[Main]: Server: Shutting down

Re: [MOD] Commodities markets [commoditymarket] 0.1

Posted: Thu Aug 01, 2019 21:11
by FaceDeer
Gundul wrote:I get this after enabling the mod:

2019-08-01 20:39:37: ERROR[Main]:.minetest/mods/commoditymarket/market.lua:422: invalid escape sequence near '"'
Hm, I was afraid of something like this. It looks like this error is caused by your build of Minetest choking on one of the Unicode currency symbols used by one of the markets. It works on my machine, and others have had no problem with it, but unicode support might potentially not be universal among all builds of Minetest. I'll need to do some digging into how to get Lua to fail more gracefully in situations where it encounters a character it can't handle.

If you made no changes to the mod's settings before you tried running it then the only market that would have been initialized by default would be the Trader's Caravan, which uses the ☼ symbol (U+263C). If you want to confirm that that's the specific problem you could go into default_markets.lua and replace the three instances of "\u{263C}" with "$" (or whatever other basic currency symbol you like) and see if the crash still happens. Meanwhile I'll look into making the currency symbols more robust in general.

Edit: Oh! I think I may see what's going on. The "\u{}" syntax for unicode escape sequences was introduced in Lua 5.3, but pre-Minetest 5.0 uses Lua 5.1. What version of Minetest are you running? I haven't tried this mod with Minetest 4.17, it could be as simple as just sticking "☼" directly into the code instead of using the unicode escape sequence to add Minetest 4.17 support. I'll test that when I get home in a few hours.

Re: [MOD] Commodities markets [commoditymarket] 0.1

Posted: Thu Aug 01, 2019 22:22
by FreeGamers
The new trading caravan looks nice FaceDeer.

Re: [MOD] Commodities markets [commoditymarket] 0.1

Posted: Fri Aug 02, 2019 02:27
by FaceDeer
I tried running commoditymarkets in an old install of Minetest 0.4.16 and it worked fine, so unfortunately I'm at a bit of a loss, Gundul. I notice that you're German-localized from that snippet of log you pasted, maybe your version of Minetest was compiled with different unicode support? Anyway, I've updated the code to use literal unicode strings instead of escape sequences, so if you try it again it might at least produce a *different* error message. Or hopefully no error at all!

I also tweaked the caravan's model very slightly - after wandering around with them in my test world for a bit I couldn't shake the feeling that they were too narrow, so I widened them very slightly. I also added some corner posts textured with darker wood to give them a bit more visual definition. And while I was at it, I rubbed grimy coal all over the Goblin Exchange to make it look goblinier. I'm reasonably satisfied with its look now. :)

And finally, I removed the "can_dig" restrictions from the other market nodes. I figure server admins will have their own preferred tools for protecting nodes against player interference, if they want, so better to not hard-code a solution.

Re: [MOD] Commodities markets [commoditymarket] 0.1

Posted: Sat Aug 03, 2019 07:44
by u18398
FaceDeer wrote:I tried running commoditymarkets in an old install of Minetest 0.4.16 and it worked fine, so unfortunately I'm at a bit of a loss, Gundul. I notice that you're German-localized from that snippet of log you pasted, maybe your version of Minetest was compiled with different unicode support? Anyway, I've updated the code to use literal unicode strings instead of escape sequences, so if you try it again it might at least produce a *different* error message. Or hopefully no error at all!
You were right, this seems to be a minetest version problem. With Minetest5.0.1 from ubuntu ppa stable I still get
this error message, even with your newly updated code:

Code: Select all


2019-08-03 09:30:00: ERROR[Main]: ModError: Failed to load and run script from .minetest/mods/commoditymarket/init.lua:
2019-08-03 09:30:00: ERROR[Main]: .minetest/mods/commoditymarket/market.lua:422: invalid escape sequence near '"'
2019-08-03 09:30:00: ERROR[Main]: stack traceback:
2019-08-03 09:30:00: ERROR[Main]: 	[C]: in function 'dofile'
2019-08-03 09:30:00: ERROR[Main]: 	.minetest/mods/commoditymarket/init.lua:5: in main chunk
2019-08-03 09:30:00: ERROR[Main]: Siehe debug.txt für Details.
2019-08-03 09:30:00: ACTION[Main]: Server: Shutting down

But right now I use my self compiled Minetest 5.1.0-dev and everything works fine.

Re: [MOD] Commodities markets [commoditymarket] 0.1

Posted: Sat Aug 03, 2019 08:56
by gpcf
I'm seeing a way of how to integrate this with advtrains... The stock could get delivered to players with freight trains then, addding a good use for them.

Re: [MOD] Commodities markets [commoditymarket] 0.1

Posted: Sat Aug 03, 2019 14:52
by FaceDeer
Gundul wrote:You were right, this seems to be a minetest version problem. With Minetest5.0.1 from ubuntu ppa stable I still get this error message, even with your newly updated code
Would you like me to file an issue with whoever's maintaining that build of Minetest? You'll have to direct me to them, I'm a Windows plebian myself.
gpcf wrote:I'm seeing a way of how to integrate this with advtrains... The stock could get delivered to players with freight trains then, addding a good use for them.
Oh, that sounds neat. I can add optional "on_inventory_put" and "on_inventory_take" callbacks of some sort to the market definition API to allow you to intercept and handle the player putting stuff into the market or taking it back out, is that the step you were thinking of requiring trains for? Maybe some sort of custom logging interface to hook into as well, to allow you to add "player's stock arrived at market" notices?

Re: [MOD] Commodities markets [commoditymarket] 0.1

Posted: Sat Aug 03, 2019 16:00
by u18398
FaceDeer wrote:
Gundul wrote:You were right, this seems to be a minetest version problem. With Minetest5.0.1 from ubuntu ppa stable I still get this error message, even with your newly updated code
Would you like me to file an issue with whoever's maintaining that build of Minetest? You'll have to direct me to them, I'm a Windows plebian myself.
All I know from the ppa is here:
https://launchpad.net/~minetestdevs/+ar ... ntu/stable
I am using ubuntu 16.04. Never tried on newer ubuntu versions.

Re: [MOD] Commodities markets [commoditymarket] 0.2

Posted: Tue Dec 24, 2019 20:24
by Nathan.S
Using the latest dev build it seems I'm unable to input a Quantity when trying to sell or buy stock. I get the info text when hovering over the box, but can't click in it. I get no debug or terminal information about it.

Re: [MOD] Commodities markets [commoditymarket] 0.2

Posted: Fri Dec 27, 2019 23:02
by Clyde
Hello,

your mod works fine, but it seems it has some trouble, when the description of a node contains a comma (,).

In this case, the description was: "aviation device, fly priv for "..(flength/60).." min"
The result:
Image

As i changed the description to: "aviation device (fly priv for "..(flength/60).." min)"
it works:
Image

The mod was the Aviation-Device from Gundul:
viewtopic.php?t=16661

Hope it helps you,
Greetings, Clyde.

Re: [MOD] Commodities markets [commoditymarket] 0.2

Posted: Sun Dec 29, 2019 19:52
by FaceDeer
Nathan.S wrote:Using the latest dev build it seems I'm unable to input a Quantity when trying to sell or buy stock. I get the info text when hovering over the box, but can't click in it. I get no debug or terminal information about it.
How peculiar. It appears that the tooltip formspec element is somehow intercepting and obstructing any attempt to click on elements "underneath" it. That's definitely a new Minetest engine bug, I'll file an issue. But I've found a simple workaround; I reordered the tooltip element's definition to be before the field definition and that appears to be working again.

Edit: issue filed.
Clyde wrote:Hello,

your mod works fine, but it seems it has some trouble, when the description of a node contains a comma
I added minetest.formspec_escape() calls to sanitize player inputs a while back but didn't think to sanitize item descriptions or other such mod-generated strings. I've added a bunch of formspec_escape calls, I think I've got all the possible ways of inserting outside text into commoditymarket formspecs covered now. Thanks for catching this.

Re: [MOD] Commodities markets [commoditymarket] 0.2

Posted: Sun Dec 29, 2019 20:51
by Clyde
FaceDeer wrote:
Clyde wrote:Hello,

your mod works fine, but it seems it has some trouble, when the description of a node contains a comma
I added minetest.formspec_escape() calls to sanitize player inputs a while back but didn't think to sanitize item descriptions or other such mod-generated strings. I've added a bunch of formspec_escape calls, I think I've got all the possible ways of inserting outside text into commoditymarket formspecs covered now. Thanks for catching this.
Seems to be a very rarely case, but now it works.
Greetings, Clyde

Re: [MOD] Commodities markets [commoditymarket] 0.2

Posted: Sun Dec 29, 2019 21:11
by Nathan.S
My issues with the formspec seems to have been fixed as well. Thanks FaceDeer.

Re: [MOD] Commodities markets [commoditymarket] 0.2

Posted: Mon Dec 30, 2019 07:10
by FaceDeer
While I was rooting around in Commodities Market I wound up doing a few new things I wasn't expecting to get to any time soon. I added a bit of mapgen code that places Goblin Markets and Undermarkets randomly in some dungeons (this can be disabled by setting their spawn probabilities to 0), and I added the ability to set specific market node types to act as "protected" so players can't dig them up and cart them away.

Someday I might add mapgen code for scattering King's Market, Night Market and maybe trading post nodes around on the surface of the world too, but that's a bit more complicated. I'll want to include some kind of building schematic for them to be in rather than just having them sit out in the open. My original idea was that they might be incorporated into schematics used by the various town-generating mods.

Re: [MOD] Commodities markets [commoditymarket] 0.2

Posted: Mon Dec 30, 2019 09:51
by FreeGamers
Ooh I'll have to update to that! Cool.

Automated market placement would be nice for me. One less thing I don't have to manage. I've had to follow and place these myself at player's requests so far.

If I may make a suggestion: there are mods that add towns to the game. I use the settlements mod. (There are others like mg_villages) It places NPCs and small towns in sensible places on the surface. Perhaps that would be an excellent mod to hook into to place King's Markets.

I have no suggestions for night markets though.

Re: [MOD] Commodities markets [commoditymarket] 0.2

Posted: Mon Dec 30, 2019 13:53
by FaceDeer
Oh, nice. I haven't seen the settlements mod before, it looks a lot simpler than mg_villages. Every time I've looked at fiddling with mg_villages I bounced off of how daunting it was. It looks like settlements can just have new schematics dropped in to the schematics folder and they'll be added to the villages? I'll try putting together some little trading buildings and such that can be dropped in.

Re: [MOD] Commodities markets [commoditymarket] 0.2

Posted: Mon Dec 30, 2019 15:12
by FreeGamers
Yeah, I chose the settlements mod because it was a lot simpler than the full blown mg_villages and variations. It looks very nice, but I only wanted sparse and very basic settlements for my world. They are an embellishment, not a major component as players are intended to be the primary developing force, not schematics.

Re: [MOD] Commodities markets [commoditymarket] 0.2

Posted: Mon Dec 30, 2019 22:35
by FaceDeer
Well, now you've gone and done it. I want that settlements mod, I'm going to use it with dfcaverns and do all sorts of wonderful horrible things with it. But I just spent some time looking through the code, and I think I'm going to be rewriting it almost from the ground up. So much for spare time. :)

For the immediate issue, however, you might want to try out this quick change I just made to the version I forked off to play with:

kingsmarket.mts and such

It replaces the existing "townhall" structure with a new schematic that's a trade depot with a King's Market built into it, and with a 50% chance that there'll be a Night Market hidden out back behind the building. I figured that settlements were rare enough that it was okay to put a King's Market in each one, as a first pass solution for mapgenning those in.

Edit: whoops, take the commit after that one. I used some vessels:shelf nodes in that trade depot and settlement wasn't initializing them correctly, had to fix that.

Re: [MOD] Commodities markets [commoditymarket] 0.2

Posted: Mon Dec 30, 2019 22:47
by FreeGamers
Yeah, believe me, they are not very common but not rare either. I've been pretty happy with how frequently they show up.

The night market is just outside of the kings market? seems a bit easy too catch the criminals that way. what about a tavern or sewer or something :P

Let me know if you would like any mob_redo api features involved. You could probably spawn an attendant next to the market node and hook your interface onto them and tell the api to allow only one attendent to spawn at a time. the mobs api can make sure the attendent stays there or trys to stay near the shop. I've done a lot of mob writing the last 5 or 6 months. I'm not fantastic at it still, still learning more, but i've learned the api quite a bit.

Re: [MOD] Commodities markets [commoditymarket] 0.2

Posted: Mon Dec 30, 2019 23:04
by FaceDeer
FreeGamers wrote:The night market is just outside of the kings market? seems a bit easy too catch the criminals that way. what about a tavern or sewer or something :P
Longer term, yeah, I'll want them to be separate buildings. But as I understand how the code currently works, I can't define a building with a condition "only one of these allowed per town", I can only change the relative frequency of building spawns. So it's either hijack the townhall structure (there's always one of those in the center of each settlement) or maybe wind up with a half dozen Kings' Markets and Night Markets crowded together. This seemed like the better approach to manage with just a few hours' work. :)
FreeGamers wrote:Let me know if you would like any mob_redo api features involved. You could probably spawn an attendant next to the market node and hook your interface onto them and tell the api to allow only one attendent to spawn at a time. the mobs api can make sure the attendent stays there or trys to stay near the shop. I've done a lot of mob writing the last 5 or 6 months. I'm not fantastic at it still, still learning more, but i've learned the api quite a bit.
Will do. I've never really tinkered with mobs before, so it'll be brand new turf for me and I'm sure you're well ahead of me on that.

If you want to integrate commoditymarket into a mob already, I tried to make the API super flexible. All you need to do to make the King's Market appear is to execute the following line:

Code: Select all

commoditymarket.show_market("kings", player_name)
The King's Market node is really just a thing for a player to click on to make that line execute, you could make the market pop up under any other circumstances you wanted. Just make sure you called

Code: Select all

commoditymarket.register_market("kings", kings_def)
at some point to ensure the market you're trying to show actually exists, though.

Re: [MOD] Commodities markets [commoditymarket] 0.2

Posted: Mon Dec 30, 2019 23:09
by FreeGamers
Yeah, I can just tell a mob to run that code when a player right clicks on the mob. I'll find some npc's and dress them up appropriately for the job. I think for players, it helps the market get noticed a bit more to have an NPC there. I've been using npc's in my game but have been placing them manually and giving them nametags like "King's Market Clerk" and the nametag brings attention to the area as well.