6 Commits bd698e2117 ... 0583a3b5d5

Auteur SHA1 Bericht Datum
  BluebirdGreycoat 0583a3b5d5 Add sound 3 jaren geleden
  BlueBird51 fef2232ded Merge branch 'fix-twisted-vine-growth' of gimp/musttest_game into master 3 jaren geleden
  BlueBird51 787d45e460 Merge branch 'fix-join/leave-messages' of gimp/musttest_game into master 3 jaren geleden
  BluebirdGreycoat 2ac91eb23f Add booths for issuing currency automatically 3 jaren geleden
  gimp c0d83c6d90 override core.send_{join,leave}_message() and handle messages there 3 jaren geleden
  gimp c3635206a8 try to fix twisted vine growth 3 jaren geleden
6 gewijzigde bestanden met toevoegingen van 134 en 33 verwijderingen
  1. 45 30
      mods/chat_colorize/init.lua
  2. 1 1
      mods/currency/init.lua
  3. 2 1
      mods/default/tvine.lua
  4. 84 0
      mods/easyvend/exchange.lua
  5. 1 0
      mods/easyvend/init.lua
  6. 1 1
      mods/moreores/_config.txt

+ 45 - 30
mods/chat_colorize/init.lua

@@ -3,6 +3,8 @@ chat_colorize = chat_colorize or {}
 chat_colorize.player_just_died = chat_colorize.player_just_died or {}
 chat_colorize.modpath = minetest.get_modpath("chat_colorize")
 
+local S = core.get_translator("chat_colorize")
+
 -- Localize for performance.
 local math_random = math.random
 
@@ -122,36 +124,6 @@ chat_colorize.send_all = function(message)
   if string.sub(message, 1, 1) == "#" then
     color = chat_colorize.COLOR_CYAN
     is_server_message = true
-  --elseif string.sub(message, 1, 2) == "* " then
-  --  color = chat_colorize.COLOR_ORANGE
-  elseif string.sub(message, 1, 3) == "***" then
-    -- Some players can have join/leave messages hidden.
-    if should_suppress(message) then return end
-    
-    color = chat_colorize.COLOR_GRAY
-    -- Add <> around player's name.
-    message = string.gsub(message, "%*%*%* ([%w_%-]+) ", "*** <%1> ")
-
-		-- Get player's internal name, so we can substitute their nick.
-		local nick = string.match(message, "<([%w_%-]+)>")
-		if nick then
-			message = string.gsub(message, "<[%w_%-]+>", "<" .. rename.gpn(nick) .. ">")
-		end
-
-    -- Rewrite the timeout message.
-		-- March 20, 2018: changed "timed out" to "connection broke" for better understanding.
-    message = string.gsub(message, ". %(timed out%)$", ". (Broken connection.)")
-
-		-- Check whether this is a player-leave-game message.
-		local is_leaveplayer = message:find("left the game")
-
-		if nick and is_leaveplayer and chat_colorize.is_ragequit(nick) then
-			message = message .. " (" .. ragequit[math_random(1, #ragequit)] .. ".)"
-		end
-
-		if nick then
-			chat_logging.report_leavejoin_player(nick, message)
-		end
   end
   
   if is_server_message then
@@ -164,6 +136,49 @@ if not chat_colorize.registered then
 	minetest.chat_send_all = function(...) return chat_colorize.send_all(...) end
 	minetest.chat_send_player = function(...) return chat_colorize.send_player(...) end
 
+	function core.send_join_message(player_name)
+		if not core.is_singleplayer() and not chat_colorize.should_suppress(player_name) then
+			local color = chat_colorize.COLOR_GRAY
+			local prefix = "*** "
+			local alias = "<" .. rename.gpn(player_name) .. ">"
+			local message = " joined the game."
+
+			-- Send colored, prefixed, translatable message to chat using player's alias.
+			chat_colorize.old_chat_send_all(color .. prefix .. S("@1" .. message, alias))
+
+			-- Send bare prefix + alias + message to log.
+			chat_logging.report_leavejoin_player(player_name, prefix .. alias .. message)
+		end
+	end
+
+	function core.send_leave_message(player_name, timed_out)
+		if not core.is_singleplayer() and not chat_colorize.should_suppress(player_name) then
+			local color = chat_colorize.COLOR_GRAY
+			local prefix = "*** "
+			local alias = "<" .. rename.gpn(player_name) .. ">"
+			local message = " left the game."
+			local to_spc, timeout_suffix = "", ""
+			local rq_spc, ragequit_suffix = "", ""
+
+			if timed_out then
+				to_spc, timeout_suffix = " ", "(Broken connection.)"
+			end
+
+			if chat_colorize.is_ragequit(player_name) then
+				rq_spc, ragequit_suffix = " ", "(" .. ragequit[math_random(1, #ragequit)] .. ".)"
+			end
+
+			-- Send colored, prefixed, translatable message [ + translatable timeout_suffix ]
+			-- [ + translatable ragequit_suffix ] to chat using player's alias.
+			chat_colorize.old_chat_send_all(color .. prefix .. S("@1" .. message, alias) ..
+				to_spc .. S(timeout_suffix) .. rq_spc .. S(ragequit_suffix))
+
+			-- Send bare prefix + alias + message [ + timeout suffix ] [ + ragequit suffix ] to log.
+			chat_logging.report_leavejoin_player(player_name, prefix .. alias .. message ..
+				to_spc .. timeout_suffix .. rq_spc .. ragequit_suffix)
+		end
+	end
+
 	chat_colorize.registered = true
 end
 

+ 1 - 1
mods/currency/init.lua

@@ -1,7 +1,7 @@
 
 currency = currency or {}
 currency.modpath = minetest.get_modpath("currency")
-currency.stackmax = 100
+currency.stackmax = 256
 currency.data = currency.data or {}
 currency.dirty = true
 currency.filename = minetest.get_worldpath() .. "/currency.txt"

+ 2 - 1
mods/default/tvine.lua

@@ -277,6 +277,7 @@ end
 
 function tvine.on_timer(pos, elapsed)
 	--minetest.chat_send_all("# Server: Plant timer @ " .. minetest.pos_to_string(pos) .. "!")
+	local p = vector.new(pos)
 	local node = minetest.get_node(pos)
 	local result = tvine.grow(pos, node)
 	-- Plant has reached max height.
@@ -286,7 +287,7 @@ function tvine.on_timer(pos, elapsed)
 
 	local min = tvine.steptime.min
 	local max = tvine.steptime.max
-	minetest.get_node_timer(pos):start(math_random(min, max))
+	minetest.get_node_timer(p):start(math_random(min, max))
 	--return true
 end
 

+ 84 - 0
mods/easyvend/exchange.lua

@@ -0,0 +1,84 @@
+
+exchange = exchange or {}
+exchange.modpath = minetest.get_modpath("easyvend")
+
+exchange.types = {
+	{name = "Gold", key = "gold", rate = 35, image = "default_gold_ingot.png", item = "default:gold_ingot", block = "default:goldblock"},
+	{name = "Silver", key = "silver", rate = 14, image = "moreores_silver_ingot.png", item = "moreores:silver_ingot", block = "moreores:silver_block"},
+	{name = "Copper", key = "copper", rate = 9, image = "default_copper_ingot.png", item = "default:copper_ingot", block = "default:copperblock"},
+}
+
+for k, v in ipairs(exchange.types) do
+	exchange["on_punch_" .. v.key] = function(pos, node, puncher, pt)
+		local pname = puncher:get_player_name()
+		local inv = puncher:get_inventory()
+		if inv:contains_item("main", v.item) then
+			if currency.room(pname, v.rate) then
+				currency.add(pname, v.rate)
+				inv:remove_item("main", v.item)
+				local cash = currency.tell(pname)
+				minetest.chat_send_player(pname, "# Server: Currency exchanged: you receive " .. v.rate .. " minegeld. You now have " .. cash .. " MG.")
+				easyvend.sound_deposit(pos)
+			else
+				local cash = currency.tell(pname)
+				minetest.chat_send_player(pname, "# Server: Not enough room in your inventory. You currently have " .. cash .. " MG.")
+			end
+		else
+			local cash = currency.tell(pname)
+			minetest.chat_send_player(pname, "# Server: You don't have any " .. v.key .. ". You currently have " .. cash .. " MG.")
+		end
+	end
+
+	exchange["on_construct_" .. v.key] = function(pos, node, puncher, pt)
+		local meta = minetest.get_meta(pos)
+		meta:set_string("infotext",
+			v.name .. " Currency Exchange\nPunch to exchange " .. v.key ..
+			" for MG\n1 " .. v.key .. " = " .. v.rate .. " MG")
+	end
+end
+
+if not exchange.run_once then
+	for k, v in ipairs(exchange.types) do
+		minetest.register_node(":exchange:kiosk_" .. v.key, {
+			description = v.name .. " Currency Exchange",
+
+			tiles = {
+				"easyvend_vendor_side.png^" .. v.image,
+				"easyvend_vendor_side.png",
+				"easyvend_ad_booth.png",
+				"easyvend_ad_booth.png",
+				"easyvend_ad_booth.png",
+				"easyvend_ad_booth.png",
+			},
+
+			paramtype2 = "facedir",
+			groups = utility.dig_groups("furniture", {flammable = 2}),
+			sounds = default.node_sound_wood_defaults(),
+
+			on_construct = function(pos, node, puncher, pt)
+				(exchange["on_construct_" .. v.key])(pos, node, puncher, pt)
+			end,
+
+			on_punch = function(pos, node, puncher, pt)
+				(exchange["on_punch_" .. v.key])(pos, node, puncher, pt)
+			end,
+		})
+	end
+
+	for k, v in ipairs(exchange.types) do
+		minetest.register_craft({
+			output = "exchange:kiosk_" .. v.key,
+			recipe = {
+				{'', 'passport:passport_adv', ''},
+				{"market:booth", "voidchest:voidchest_closed", v.block},
+				{'', v.block, ''},
+			},
+		})
+	end
+
+	local c = "exchange:core"
+	local f = exchange.modpath .. "/exchange.lua"
+	reload.register_file(c, f, false)
+
+	exchange.run_once = true
+end

+ 1 - 0
mods/easyvend/init.lua

@@ -46,6 +46,7 @@ easyvend.traversable_node_types = {
 
 easyvend.registered_chests = {}
 dofile(minetest.get_modpath("easyvend") .. "/ads.lua")
+dofile(minetest.get_modpath("easyvend") .. "/exchange.lua")
 
 
 if minetest.get_modpath("reload") then

+ 1 - 1
mods/moreores/_config.txt

@@ -9,7 +9,7 @@
 -- Chunk sizes for ore generation (bigger = ore deposits are more scattered around) (scarcity)
 moreores_tin_chunk_size = 10
 moreores_silver_chunk_size = 12
-moreores_mithril_chunk_size = 16
+moreores_mithril_chunk_size = 19
 
 moreores_tin_chunk_radius = 3
 moreores_silver_chunk_radius = 3