From f92988ad96ffe5e8476e305bea9cde28da454d11 Mon Sep 17 00:00:00 2001 From: OldCoder Date: Tue, 27 Jul 2021 22:01:23 -0700 Subject: [PATCH] Convert ZIP version to git repo --- README.txt | 7 + depends.txt | 1 + init.lua | 303 ++++++++++++++++++++++++++++++++++ license.txt | 58 +++++++ textures/trail_flat_wheat.png | Bin 0 -> 281 bytes textures/trail_trailside.png | Bin 0 -> 629 bytes textures/trail_trailtop.png | Bin 0 -> 324 bytes 7 files changed, 369 insertions(+) create mode 100644 README.txt create mode 100644 depends.txt create mode 100644 init.lua create mode 100644 license.txt create mode 100644 textures/trail_flat_wheat.png create mode 100644 textures/trail_trailside.png create mode 100644 textures/trail_trailtop.png diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..3937a54 --- /dev/null +++ b/README.txt @@ -0,0 +1,7 @@ +Trail 0.3.1 by paramat +For Minetest 0.4.15 and later +Depends: default +Licenses: Source code MIT. Textures CC BY-SA (3.0) + +This mod was developed from 'desire path' mod by Casimir +https://forum.minetest.net/viewtopic.php?id=3390 diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..331d858 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +default \ No newline at end of file diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..3fe03a9 --- /dev/null +++ b/init.lua @@ -0,0 +1,303 @@ +-- Parameters + +local FOO = true -- Enable footprints. +local FUNCYC = 0.2 -- Function cycle in seconds. +local TRACHA = 0.1 -- Chance walked dirt/grass is worn and compacted to trail:trail. +local ICECHA = 0.05 -- Chance walked snowblock is compacted to ice. + +local EROSION = true -- Enable footprint and trail:trail erosion. +local EROINT = 16 -- Erosion interval. +local EROCHA = 128 -- Erosion 1/x chance. + +-- Player positions + +local player_pos = {} +local player_pos_previous = {} + +minetest.register_on_joinplayer(function(player) + player_pos_previous[player:get_player_name()] = {x = 0, y = 0, z = 0} +end) + +minetest.register_on_leaveplayer(function(player) + player_pos_previous[player:get_player_name()] = nil +end) + +-- Nodes + +minetest.register_node("trail:trail", { + tiles = {"trail_trailtop.png", "default_dirt.png", + "default_dirt.png^trail_trailside.png"}, + groups = {crumbly = 2}, + drop = "default:dirt", + sounds = default.node_sound_dirt_defaults(), +}) + +minetest.register_node("trail:dirt", { + description = "Dirt With Footprint", + tiles = {"default_dirt.png^default_footprint.png", "default_dirt.png"}, + groups = {crumbly = 3, soil = 1}, + drop = "default:dirt", + sounds = default.node_sound_dirt_defaults(), +}) + +minetest.register_node("trail:dirt_with_grass", { + description = "Dirt with Grass and Footprint", + tiles = {"default_grass.png^default_footprint.png", "default_dirt.png", + {name = "default_dirt.png^default_grass_side.png", + tileable_vertical = false}}, + groups = {crumbly = 3, soil = 1, spreading_dirt_type = 1}, + drop = "default:dirt", + sounds = default.node_sound_dirt_defaults({ + footstep = {name = "default_grass_footstep", gain = 0.25}, + }), +}) + +minetest.register_node("trail:dirt_with_dry_grass", { + description = "Dirt with Dry Grass and Footprint", + tiles = {"default_dry_grass.png^default_footprint.png", "default_dirt.png", + {name = "default_dirt.png^default_dry_grass_side.png", + tileable_vertical = false}}, + groups = {crumbly = 3, soil = 1, spreading_dirt_type = 1}, + drop = "default:dirt", + sounds = default.node_sound_dirt_defaults({ + footstep = {name = "default_grass_footstep", gain = 0.4}, + }), +}) + +minetest.register_node("trail:dirt_with_snow", { + description = "Dirt with Snow and Footprint", + tiles = {"default_snow.png^default_footprint.png", "default_dirt.png", + {name = "default_dirt.png^default_snow_side.png", + tileable_vertical = false}}, + groups = {crumbly = 3, soil = 1, spreading_dirt_type = 1}, + drop = "default:dirt", + sounds = default.node_sound_dirt_defaults({ + footstep = {name = "default_snow_footstep", gain = 0.15}, + }), +}) + +minetest.register_node("trail:sand", { + description = "Sand With Footprint", + tiles = {"default_sand.png^default_footprint.png", "default_sand.png"}, + groups = {crumbly = 3, falling_node = 1, sand = 1}, + drop = "default:sand", + sounds = default.node_sound_sand_defaults(), +}) + +minetest.register_node("trail:desert_sand", { + description = "Desert Sand With Footprint", + tiles = {"default_desert_sand.png^default_footprint.png", "default_desert_sand.png"}, + groups = {crumbly = 3, falling_node = 1, sand = 1}, + drop = "default:desert_sand", + sounds = default.node_sound_sand_defaults(), +}) + +minetest.register_node("trail:silver_sand", { + description = "Silver Sand With Footprint", + tiles = {"default_silver_sand.png^default_footprint.png", "default_silver_sand.png"}, + groups = {crumbly = 3, falling_node = 1, sand = 1}, + drop = "default:silver_sand", + sounds = default.node_sound_sand_defaults(), +}) + +minetest.register_node("trail:snow", { + description = "Snow With Footprint", + tiles = {"default_snow.png^default_footprint.png", "default_snow.png"}, + inventory_image = "default_snowball.png", + wield_image = "default_snowball.png", + paramtype = "light", + buildable_to = true, + floodable = true, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5}, + }, + }, + groups = {crumbly = 3, falling_node = 1, puts_out_fire = 1}, + drop = "default:snow", + sounds = default.node_sound_dirt_defaults({ + footstep = {name = "default_snow_footstep", gain = 0.15}, + dug = {name = "default_snow_footstep", gain = 0.2}, + dig = {name = "default_snow_footstep", gain = 0.2} + }), +}) + +minetest.register_node("trail:snowblock", { + description = "Snow Block With Footprint", + tiles = {"default_snow.png^default_footprint.png", "default_snow.png"}, + groups = {crumbly = 3, puts_out_fire = 1, cools_lava = 1}, + drop = "default:snowblock", + sounds = default.node_sound_dirt_defaults({ + footstep = {name = "default_snow_footstep", gain = 0.15}, + dug = {name = "default_snow_footstep", gain = 0.2}, + dig = {name = "default_snow_footstep", gain = 0.2} + }), +}) + +minetest.register_node("trail:wheat", { + description = "Flattened Wheat", + tiles = {"trail_flat_wheat.png"}, + inventory_image = "trail_flat_wheat.png", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + buildable_to = true, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, -3 / 8, 0.5} + }, + }, + groups = {snappy = 3, flammable = 2, attached_node = 1}, + drop = "", + sounds = default.node_sound_leaves_defaults(), +}) + +-- Globalstep function + +local timer = 0 + +if FOO then + minetest.register_globalstep(function(dtime) + timer = timer + dtime + if timer > FUNCYC then + timer = 0 + for _, player in ipairs(minetest.get_connected_players()) do + local pos = player:getpos() + player_pos[player:get_player_name()] = { + x = math.floor(pos.x + 0.5), + y = math.floor(pos.y + 0.2), + z = math.floor(pos.z + 0.5) + } + + local p_ground = { + x = math.floor(pos.x + 0.5), + y = math.floor(pos.y + 0.4), + z = math.floor(pos.z + 0.5) + } + local n_ground = minetest.get_node(p_ground).name + local p_groundpl = { + x = math.floor(pos.x + 0.5), + y = math.floor(pos.y - 0.5), + z = math.floor(pos.z + 0.5) + } + local p_snow = { + x = math.floor(pos.x + 0.5), + y = math.floor(pos.y + 1.2), + z = math.floor(pos.z + 0.5) + } + local n_snow = minetest.get_node(p_snow).name + local p_snowpl = { + x = math.floor(pos.x + 0.5), + y = math.floor(pos.y + 0.5), + z = math.floor(pos.z + 0.5) + } + + --if player_pos_previous[player:get_player_name()] == nil then + --break + --end + + if player_pos[player:get_player_name()].x ~= + player_pos_previous[player:get_player_name()].x or + player_pos[player:get_player_name()].y < + player_pos_previous[player:get_player_name()].y or + player_pos[player:get_player_name()].z ~= + player_pos_previous[player:get_player_name()].z then + + if n_ground == "default:dirt" then + minetest.set_node(p_groundpl, {name = "trail:dirt"}) + elseif n_ground == "default:dirt_with_grass" then + minetest.set_node(p_groundpl, {name = "trail:dirt_with_grass"}) + elseif n_ground == "default:dirt_with_dry_grass" then + minetest.set_node(p_groundpl, {name = "trail:dirt_with_dry_grass"}) + elseif n_ground == "default:dirt_with_snow" then + minetest.set_node(p_groundpl, {name = "trail:dirt_with_snow"}) + elseif n_ground == "trail:dirt" or + n_ground == "trail:dirt_with_grass" or + n_ground == "trail:dirt_with_dry_grass" then + if math.random() <= TRACHA then + minetest.set_node(p_groundpl, {name = "trail:trail"}) + end + + elseif n_ground == "default:sand" then + minetest.set_node(p_groundpl, {name = "trail:sand"}) + elseif n_ground == "default:desert_sand" then + minetest.set_node(p_groundpl, {name = "trail:desert_sand"}) + elseif n_ground == "default:silver_sand" then + minetest.set_node(p_groundpl, {name = "trail:silver_sand"}) + + elseif n_snow == "default:snow" then + minetest.set_node(p_snowpl, {name = "trail:snow"}) + elseif n_ground == "default:snowblock" then + minetest.set_node(p_groundpl, {name = "trail:snowblock"}) + elseif n_ground == "trail:snowblock" then + if math.random() <= ICECHA then + minetest.set_node(p_groundpl, {name = "default:ice"}) + end + + elseif n_snow == "farming:wheat_5" or + n_snow == "farming:wheat_6" or + n_snow == "farming:wheat_7" or + n_snow == "farming:wheat_8" then + minetest.set_node(p_snowpl, {name = "trail:wheat", + param2 = math.random(0, 1)}) + end + end + + player_pos_previous[player:get_player_name()] = { + x = player_pos[player:get_player_name()].x, + y = player_pos[player:get_player_name()].y, + z = player_pos[player:get_player_name()].z + } + end + end + end) +end + +-- ABM + +if EROSION then + minetest.register_abm({ + nodenames = { + "trail:dirt", + "trail:dirt_with_grass", + "trail:dirt_with_dry_grass", + "trail:dirt_with_snow", + "trail:sand", + "trail:desert_sand", + "trail:silver_sand", + "trail:snow", + "trail:snowblock", + "trail:trail" + }, + interval = EROINT, + chance = EROCHA, + action = function(pos, node, _, _) + local nodename = node.name + + if nodename == "trail:dirt" then + minetest.set_node(pos, {name = "default:dirt"}) + elseif nodename == "trail:dirt_with_grass" then + minetest.set_node(pos, {name = "default:dirt_with_grass"}) + elseif nodename == "trail:dirt_with_dry_grass" then + minetest.set_node(pos, {name = "default:dirt_with_dry_grass"}) + elseif nodename == "trail:dirt_with_snow" then + minetest.set_node(pos, {name = "default:dirt_with_snow"}) + elseif nodename == "trail:sand" then + minetest.set_node(pos, {name = "default:sand"}) + elseif nodename == "trail:desert_sand" then + minetest.set_node(pos, {name = "default:desert_sand"}) + elseif nodename == "trail:silver_sand" then + minetest.set_node(pos, {name = "default:silver_sand"}) + elseif nodename == "trail:snow" then + minetest.set_node(pos, {name = "default:snow"}) + elseif nodename == "trail:snowblock" then + minetest.set_node(pos, {name = "default:snowblock"}) + elseif nodename == "trail:trail" then + minetest.set_node(pos, {name = "default:dirt"}) + end + end + }) +end diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..23a8b6d --- /dev/null +++ b/license.txt @@ -0,0 +1,58 @@ +License of source code +---------------------- + +The MIT License (MIT) +Copyright (C) 2013-2017 paramat + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, and to permit +persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +For more details: +https://opensource.org/licenses/MIT + +License of media (textures) +--------------------------- + +Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) +Copyright (C) 2013-2017 paramat + +You are free to: +Share — copy and redistribute the material in any medium or format. +Adapt — remix, transform, and build upon the material for any purpose, even commercially. +The licensor cannot revoke these freedoms as long as you follow the license terms. + +Under the following terms: + +Attribution — You must give appropriate credit, provide a link to the license, and +indicate if changes were made. You may do so in any reasonable manner, but not in any way +that suggests the licensor endorses you or your use. + +ShareAlike — If you remix, transform, or build upon the material, you must distribute +your contributions under the same license as the original. + +No additional restrictions — You may not apply legal terms or technological measures that +legally restrict others from doing anything the license permits. + +Notices: + +You do not have to comply with the license for elements of the material in the public +domain or where your use is permitted by an applicable exception or limitation. +No warranties are given. The license may not give you all of the permissions necessary +for your intended use. For example, other rights such as publicity, privacy, or moral +rights may limit how you use the material. + +For more details: +http://creativecommons.org/licenses/by-sa/3.0/ diff --git a/textures/trail_flat_wheat.png b/textures/trail_flat_wheat.png new file mode 100644 index 0000000000000000000000000000000000000000..24a87c24e42324dd2fbd98ca134f9328e60e0050 GIT binary patch literal 281 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|I14-?iy0WW zg+Z8+Vb&Z8pdfpRr>`sfT~0nGL5_>I=i`Awt36#DLo7}&ogB+`$UvaQeU_S97;CM_ z`xl~no5D3*1*CMBscil6`PDMsEpPU{P5C+FtV;LkpI=xPw_Ie>ad=_Jz_9nsiAMhS znGJ_}tUX>bANYFhQ&`7Z<^#I|melXk<9+cvk>i`(GV6$$HPcd;u1J1(E4-*;|K%m? z*S2@B^EqXKB@}*PR(#e2z(6 a=XbBx`=a>c`~{%189ZJ6T-G@yGywq9)@>jF literal 0 HcmV?d00001 diff --git a/textures/trail_trailside.png b/textures/trail_trailside.png new file mode 100644 index 0000000000000000000000000000000000000000..4d30eb346f5d11d89cefc7af2f73a7b7ff1d02ff GIT binary patch literal 629 zcmV-*0*d{KP)SJpYsfOPwaJEp%%iU@iKO!3JN+wA1=guz`TMUwmuKQWSgY_j4gk*cWZ!qr^JI(* z(T&y`vrm%5%qXj%*SP*kcgz|TxW*u6kR<1Mk_r3qp!ZJ9Nkj(#Glmazt@W+c3L>N@ zF`ulp0GOrF+QFvE_54K?#WN9L&d!QJfo}lgdQ#0OwNelSAxYewRTkEEK0dx<)o$@Q z$#fLtTlzqBqgLhP<2!qMpsFNEdNSuk5RUzUX9C>vUXW52)r?Iy_SQJ|2dx>a+%_UQ zg0M>P`img+esUZSw5*D#;O^8~n6rNlCdvEz7kZzhJF5g_Qp{-WxOuD+jO$5j#@Szl zfwTW4)9HP(N+7C;2x~2T3`$wV47C1+5`mc!2%^Ft?JH;Rcn)fJSdwW18p2;dfS@nJcY`eF0 zw@<5j$5OD(*zaUY*>t=Z?j=-wK<)-`L)*_pFbYh&Bqh*(5SVotOvnU1>yLbb;K^t)9_Ie#5K P00000NkvXXu0mjfGA|{0 literal 0 HcmV?d00001 diff --git a/textures/trail_trailtop.png b/textures/trail_trailtop.png new file mode 100644 index 0000000000000000000000000000000000000000..6e20023b28a93af9d109e48e0860071f8d6d0bae GIT binary patch literal 324 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!aez;VYks72VYGX3w0lX6M`^5Q zNt{<%f=^k3UqwPdd7^JsQb1KoP)$lmb!u>JdT4!mXmfVtWbOyKK<%6b9+AZi4BWyX z%*Zfnjs#GUy~NYkmHi>30Gp!bHqp0JfkI0>T^vIsF7x(#3%M9_FwK3z{loLjUw`Yo z7?aolFZtuuADs$2gCB_%c06#MA$#JUXYkglXZyG2HvD2cIC;@8;YOv_sm)9`wBCJP zIvw4)Q%;--8MIA${G`>H;} z((f!5Iq!rGR;OK1OL}-}#pX+iR=;h$gDyYXT9$Y1tg3$2zLY8JJ9z&vdfetvb)9(F Q4(MJ6Pgg&ebxsLQ0G$$iZvX%Q literal 0 HcmV?d00001