From 82c99d61481c2a2e9510a46fd01f78dc5373f195 Mon Sep 17 00:00:00 2001 From: Aaron Suen Date: Tue, 10 Oct 2023 00:06:24 -0400 Subject: [PATCH] YCTIWY markers visually fade with age --- mods/nc_player_yctiwy/init.lua | 21 +++++++++++++++--- .../textures/nc_player_yctiwy_marker_1.png | Bin 336 -> 477 bytes .../textures/nc_player_yctiwy_marker_2.png | Bin 380 -> 436 bytes .../textures/nc_player_yctiwy_marker_3.png | Bin 344 -> 477 bytes 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/mods/nc_player_yctiwy/init.lua b/mods/nc_player_yctiwy/init.lua index 31efc194..f977a8c5 100644 --- a/mods/nc_player_yctiwy/init.lua +++ b/mods/nc_player_yctiwy/init.lua @@ -3,8 +3,8 @@ local ItemStack, math, minetest, next, nodecore, pairs, string, table, vector = ItemStack, math, minetest, next, nodecore, pairs, string, table, vector -local math_pi, math_random, string_format, table_concat - = math.pi, math.random, string.format, table.concat +local math_floor, math_pi, math_random, string_format, table_concat + = math.floor, math.pi, math.random, string.format, table.concat -- LUALOCALS > --------------------------------------------------------- nodecore.amcoremod() @@ -34,6 +34,16 @@ local hidden = nodecore.setting_bool( case the entities are later reenabled.]] ) or disabled +local halflife = nodecore.setting_float( + "nc_yctiwy_halflife", + 30, + "Half-life of marker decay", + [[YCTIWY markers show visible "decay" as players are + continuously offline for long periods of time. This is + the number of days that it takes for half of the + remaining color to bleed out of the marker.]] +) * 86400 + ------------------------------------------------------------------------ -- DATABASE @@ -290,7 +300,12 @@ local function markertexture(pname) colors[i] = string_format("(%s_marker_%d.png^[multiply:%s)", modname, i, colors[i]) end - return table_concat(colors, "^") + local age = minetest.get_gametime() - (db[pname] or {seen = 0}).seen + local decay = math_floor(240 * (1 - 0.5 ^ (age / halflife))) + print(string_format("%s age=%d decay=%d", pname, age, decay)) + return string_format("%s^(%s_marker_1.png^%s_marker_2.png^%s_marker_3.png" + .. "^[multiply:#a0a0a0^[opacity:%d)", + table_concat(colors, "^"), modname, modname, modname, decay) end minetest.register_entity(modname .. ":marker", { diff --git a/mods/nc_player_yctiwy/textures/nc_player_yctiwy_marker_1.png b/mods/nc_player_yctiwy/textures/nc_player_yctiwy_marker_1.png index 18757849247aaee16f5e04b6d26dc27988781ad8..cb8ba3e14f1a983a685359610e64921bf281125b 100644 GIT binary patch literal 477 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyCj)#!T!HkgS+f=_Sg>f(qQ#3B zFI~EH#flXxSFT*QZr%Fz>o;uJuyNzYO`A4t-n@D1)~(yNZQH(m`;Hwu4jede@ZiB? z$BtdOa^=pQJC7bcdiwO~t5>hyy?giR)2Hv>zyJF6>-X>9fByXW`}gm^fB*jf{|~eU zZUxZ%wQJV`O$HjZd-raLX@?IVK62#9i4!MIpFVx&%$alN&H)X-e*OB*n>X*>yZ7YD zljqN$1Fd-f{yor&uV26Z{P`1T3&aYb`42b5IsrYSToU9L%)m$xTs)d_9H@MOr;B4q z#jUreFY+C95NLha$dn<Y5wUuIyGmd%o~dWx$4trek;v9CDQ&ZCobDiz~za@#A{nVmL%TX{djA(!3U;= zerDgk73|yXGLK=Vq6Zi6s@Ip#s@k(PXteV6au;$a2DbOf*gB;gcyx0bJC~wey4c_E fjepEl_VMV)d{a1AY{*;>bSs0WtDnm{r-UW|ZbJTi delta 320 zcmV-G0l)s;1JDAH8Gi%-007x@vVQ;o0T)R`K~#9!?a@P?CP5Gd@QktT1C00M6O3@4 zQLlR4wr$(CZQD|P6~EVJW=p$zv3~zV2qQ*}7%_56Nhk9QP9LqVdeV{V8dW_^AI^Yh zyVDaN1>s2US~ z3~dJyKvoYNe|r^$=t;;&5lYd3L3i8+NdR&fG7(P!HQ6XaG3wBbN$6lOP%Z%=JmubP zM7z^I1fFsl7wex6Qdk5h;}@P? SA6e`G0000qNRsQ4e z1wCi0Q@xy$%-)s$zu)gx0Qi?W9*^AZc5VUG_2qKmdcEdgFn{21IJ65O!`tnqPPtqz zIUbKW8jaZN^_abB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