Open AFCMS opened 4 years ago
Technically, commoditymarket does have mineclone2 compatibility - it doesn't depend on the "default" mod. However, https://github.com/minetest-mods/commoditymarket_fantasy isn't, and I expect that's what you'd like to see made mineclone2 compatible?
I'm taking a look through the code right now, pulling out the "default" stuff, and mostly it's just a matter of textures. Most of the items seem to have direct mineclone2 analogues. However, the Undermarket uses mese as a currency, which doesn't appear to exist in Mineclone2. Do you know what the equivalent would be? Redstone, perhaps? I also don't see a direct analog for "default:chest_locked", which is one of the crafting inputs for the caravan market. I've never played Minecraft so I'm not familiar with some of this stuff, if you know what I should swap for those let me know.
I'll spend today reworking some of commoditymarket_fantasy's internals to make it easier to adapt to other game contexts.
Oh, and if you don't mind doing a little footwork for me, I could also use a list of common "default" items that the markets' listings should be pre-populated with. In minetest_game I used:
"default:axe_bronze","default:axe_diamond","default:axe_mese","default:axe_steel","default:axe_steel","default:axe_stone","default:axe_wood","default:pick_bronze","default:pick_diamond","default:pick_mese","default:pick_steel","default:pick_stone","default:pick_wood","default:shovel_bronze","default:shovel_diamond","default:shovel_mese","default:shovel_steel","default:shovel_stone","default:shovel_wood","default:sword_bronze","default:sword_diamond","default:sword_mese","default:sword_steel","default:sword_stone","default:sword_wood", "default:blueberries", "default:book", "default:bronze_ingot", "default:clay_brick", "default:clay_lump", "default:coal_lump", "default:copper_ingot", "default:copper_lump", "default:diamond", "default:flint", "default:gold_ingot", "default:gold_lump", "default:iron_lump", "default:mese_crystal", "default:mese_crystal_fragment", "default:obsidian_shard", "default:paper", "default:steel_ingot", "default:stick", "default:tin_ingot", "default:tin_lump", "default:acacia_tree", "default:acacia_wood", "default:apple", "default:aspen_tree", "default:aspen_wood", "default:blueberry_bush_sapling", "default:bookshelf", "default:brick", "default:bronzeblock", "default:bush_sapling", "default:cactus", "default:clay", "default:coalblock", "default:cobble", "default:copperblock", "default:desert_cobble", "default:desert_sand", "default:desert_sandstone", "default:desert_sandstone_block", "default:desert_sandstone_brick", "default:desert_stone", "default:desert_stone_block", "default:desert_stonebrick", "default:diamondblock", "default:dirt", "default:glass", "default:goldblock", "default:gravel", "default:ice", "default:junglegrass", "default:junglesapling", "default:jungletree", "default:junglewood", "default:ladder_steel", "default:ladder_wood", "default:large_cactus_seedling", "default:mese", "default:mese_post_light", "default:meselamp", "default:mossycobble", "default:obsidian", "default:obsidian_block", "default:obsidian_glass", "default:obsidianbrick", "default:papyrus", "default:pine_sapling", "default:pine_tree", "default:pine_wood", "default:sand", "default:sandstone", "default:sandstone_block", "default:sandstonebrick", "default:sapling", "default:silver_sand", "default:silver_sandstone", "default:silver_sandstone_block", "default:silver_sandstone_brick", "default:snow", "default:snowblock", "default:steelblock", "default:stone", "default:stone_block", "default:stonebrick", "default:tinblock", "default:tree", "default:wood"
But I wouldn't know where to start with collecting a similar list for MC2. I can leave it blank for now, which means players will need to add items to their market inventories explicitly to make them show up.
I've created a branch, https://github.com/minetest-mods/commoditymarket_fantasy/tree/mineclone2_support , that should be working for both minetest_game and mineclone2. I've set redstone as the currency for the undermarket and I left the default item list blank for now.
You'll need the latest commoditymarket version to go along with this, there was a bug in its doc support and mineclone2 includes the doc mod so that'd trigger a crash with the previous version.
Charging a small market:
local market_def = {
description = "Market",
long_description = "Market",
currency = {
["mcl_core:gold_ingot"] = 1000,
["commoditymarket:gold_coins"] = 1
},
currency_symbol = "$",
inventory_limit = 100000,
sell_limit = 100000,
allow_item = function(item) return true end,
anonymous = false,
}
local market_name = "Market"
commoditymarket.register_market(market_name, market_def)
minetest.register_chatcommand("market", {
description = "Togle market",
func = function(name, param)
local player_name = minetest.get_player_by_name(name)
local msg = "Opening market..."
if player_name then
minetest.chat_send_player(name, msg)
commoditymarket.show_market("Market", name)
end
end,
})
Doesn't work:
2020-07-03 21:17:56: ERROR[Main]: ModError: Failed to load and run script from C:\Users\Util7\Documents\Louis\minetest-5.2.0-win64\bin\..\mods\mcl_server\mcl_market\init.lua:
2020-07-03 21:17:56: ERROR[Main]: ....2.0-win64\bin\..\mods\commoditymarket-master/market.lua:529: attempt to index local 'item_def' (a nil value)
2020-07-03 21:17:56: ERROR[Main]: stack traceback:
2020-07-03 21:17:56: ERROR[Main]: ....2.0-win64\bin\..\mods\commoditymarket-master/market.lua:529: in function 'make_doc_entry'
2020-07-03 21:17:56: ERROR[Main]: ....2.0-win64\bin\..\mods\commoditymarket-master/market.lua:574: in function 'register_market'
2020-07-03 21:17:56: ERROR[Main]: ...t-5.2.0-win64\bin\..\mods\mcl_server\mcl_market\init.lua:43: in main chunk
2020-07-03 21:17:56: ERROR[Main]: Voir debug.txt pour plus d'informations.
2020-07-03 21:17:56: ACTION[Main]: Server: Shutting down
2020-07-03 21:18:47: ERROR[Main]: Veuillez choisir un nom !
With default:gold_ingot
as currency and minetest_game
, its work perfectly.
Did you register the commoditymarket:gold_coins craftitem? commoditymarket_fantasy only does that if one of the markets that uses gold has been enabled, if you're not using commoditymarket_fantasy then those won't exist and it'd result in an error like this. I'll add an assert that should make the error more informative.
You can just remove it from the currency definition and the market should work fine with just gold bars. Players just won't be able to withdraw smaller denominations than that.
Oh, and a word of warning about game balance. If you create a market that a player can access via a chat command like this, you're giving them access to an inventory that they can stash stuff into and take stuff out of anywhere and that survives player death and respawn. You might want to reduce the inventory and sell limits. That's one reason why I set those limits so small for the trader's caravan market in commoditymarket_fantasy, and put other limits on player access (such as needing to craft an item to "summon" the market and having it take two minutes to arrive).
Like that?
minetest.register_craftitem("mcl_market:gold_coins", {
description = "Gold Coins",
_doc_items_longdesc = "A gold ingot is far too valuable to use as a basic unit of value, so it has become common practice to divide the standard gold bar into @1 small disks to make trade easier.",
_doc_items_usagehelp = "Gold coins can be deposited and withdrawn from markets that accept them as currency. These markets can make change if you have @1 coins and would like them back in ingot form again.",
inventory_image = "commoditymarket_gold_coins.png",
stack_max = coins_per_ingot,
})
local market_def = {
description = "Market",
long_description = "Market",
currency = {
["mcl_core:gold_ingot"] = 1000,
["mcl_market:gold_coins"] = 1
},
currency_symbol = "$",
inventory_limit = 100000,
sell_limit = 100000,
allow_item = function(item) return true end,
anonymous = false,
}
local market_name = "Market"
commoditymarket.register_market(market_name, market_def)
minetest.register_chatcommand("market", {
description = "Togle market",
func = function(name, param)
local player_name = minetest.get_player_by_name(name)
local msg = "Opening market..."
if player_name then
minetest.chat_send_player(name, msg)
commoditymarket.show_market("Market", name)
end
end,
})
Doesn't work:
ModError: Failed to load and run script from C:\Users\Util7\Documents\Louis\minetest-5.2.0-win64\bin\..\mods\mcl_server\mcl_market\init.lua:
....2.0-win64\bin\..\mods\commoditymarket-master/market.lua:529: attempt to index local 'item_def' (a nil value)
stack traceback:
....2.0-win64\bin\..\mods\commoditymarket-master/market.lua:529: in function 'make_doc_entry'
....2.0-win64\bin\..\mods\commoditymarket-master/market.lua:574: in function 'register_market'
...t-5.2.0-win64\bin\..\mods\mcl_server\mcl_market\init.lua:52: in main chunk
Voir debug.txt pour plus d'informations.
Oh, and a word of warning about game balance. If you create a market that a player can access via a chat command like this, you're giving them access to an inventory that they can stash stuff into and take stuff out of anywhere and that survives player death and respawn. You might want to reduce the inventory and sell limits. That's one reason why I set those limits so small for the trader's caravan market in commoditymarket_fantasy, and put other limits on player access (such as needing to craft an item to "summon" the market and having it take two minutes to arrive).
Thanks for advise !
Ah, I believe I've spotted what's wrong. Is your test mod.conf declaring a dependency on mcl_core? Your mod references mcl_core:gold_ingot, but if you don't depend on mcl_core it might not be registered yet.
I've merged the mineclone2 support branch in commoditymarket_fantasy into main, I'll be closing this issue soon since I believe it's satisfied now.
I think this issue can be closed, as you suggested
It would be cool to have a support for Mineclone2, because Mineclone2 don't have a server market yet. So, setting up a survival server with Mineclone2 is very difficult.