This commit is contained in:
root 2021-01-07 21:52:00 +01:00
parent 996ad39d64
commit f95799f554
24 changed files with 191 additions and 89 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 793 B

View File

@ -9,7 +9,6 @@ advtrains.hhud[player:get_player_name()] = nil
end)
local mletter={[1]="F", [-1]="R", [0]="N"}
local doorstr={[-1]="|<>| >|<", [0]=">|< >|<", [1]=">|< |<>|"}
function advtrains.on_control_change(pc, train, flip)
local maxspeed = train.max_speed or 10
@ -89,38 +88,55 @@ function advtrains.on_control_change(pc, train, flip)
end
function advtrains.update_driver_hud(pname, train, flip)
local inside=train.text_inside or ""
advtrains.set_trainhud(pname, inside.."\n"..advtrains.hud_train_format(train, flip))
local ft, ht = advtrains.hud_train_format(train, flip)
advtrains.set_trainhud(pname, inside.."\n"..ft, ht)
end
function advtrains.clear_driver_hud(pname)
advtrains.set_trainhud(pname, "")
end
function advtrains.set_trainhud(name, text)
function advtrains.set_trainhud(name, text, driver)
local hud = advtrains.hud[name]
local player=minetest.get_player_by_name(name)
if not player then
return
end
local driverhud = {
hud_elem_type = "image",
name = "ADVTRAINS_DRIVER",
position = {x=0.5, y=0.7},
offset = {x=0,y=5},
text = driver or "",
alignment = {x=0,y=1},
scale = {x=1,y=1},}
if not hud then
hud = {}
hud = {["driver"]={}}
advtrains.hud[name] = hud
hud.id = player:hud_add({
hud_elem_type = "text",
name = "ADVTRAINS",
number = 0xFFFFFF,
position = {x=0.5, y=0.7},
offset = {x=0, y=0},
offset = {x=0, y=-5},
text = text,
scale = {x=200, y=60},
alignment = {x=0, y=0},
alignment = {x=0, y=-1},
})
hud.oldText=text
return
elseif hud.oldText ~= text then
player:hud_change(hud.id, "text", text)
hud.oldText=text
hud.driver = player:hud_add(driverhud)
else
if hud.oldText ~= text then
player:hud_change(hud.id, "text", text)
hud.oldText=text
end
if hud.driver then
player:hud_change(hud.driver, "text", driver or "")
elseif driver then
hud.driver = player:hud_add(driverhud)
end
end
end
function advtrains.set_help_hud(name, text)
local hud = advtrains.hhud[name]
local player=minetest.get_player_by_name(name)
@ -160,67 +176,135 @@ Value Disp Control Meaning
]]
function advtrains.hud_train_format(train, flip)
local fct=flip and -1 or 1
if not train then return "" end
if not train then return "","" end
local sformat = string.format -- this appears to be faster than (...):format
local max = train.max_speed or 10
local res = train.speed_restriction or max
local res = train.speed_restriction
local vel = advtrains.abs_ceil(train.velocity)
local vel_kmh=advtrains.abs_ceil(advtrains.ms_to_kmh(train.velocity))
local levers = "B - o +"
local tlev=train.lever
local levers = {[0] = "emg","b","r","n","p"}
local lvrcolor = {[0] = "red", "orange", "orange", "cyan", "cyan"}
local tlev=train.lever or 1
if train.velocity==0 and not train.active_control then tlev=1 end
if tlev == 0 then levers = ">BB< - o +" end
if tlev == 1 then levers = ">B< - o +" end
if tlev == 2 then levers = "B >-< o +" end
if tlev == 3 then levers = "B - >o< +" end
if tlev == 4 then levers = "B - o >+<" end
local topLine, firstLine
local st = {}
if train.debug then st = {train.debug} end
local secondLine
local ht = {"[combine:300x150:0,0=(advtrains_hud_bg.png^[resize\\:300x150)"}
ht[#ht+1] = "100,0=(advtrains_hud_" .. (flip and "reverse" or "forward") .. ".png^[resize\\:100x20^[makealpha\\:#000000)"
ht[#ht+1] = "200,0=(advtrains_hud_" .. (levers[tlev] or "bg") .. ".png^[resize\\:100x20^[multiply\\:" .. (lvrcolor[tlev] or "#000000") .. "^[makealpha\\:#000000)"
if train.tarvelocity or train.atc_command then
local b=" "
local tvels=""
if train.tarvelocity then
local tvel = advtrains.abs_ceil(train.tarvelocity)
tvels = "|"..string.rep("+", tvel)..string.rep("_", max-tvel)
end
if train.atc_brake_target then
b="-B-"
end
local ad = ""
if train.atc_delay then
ad = " "..advtrains.abs_ceil(train.atc_delay).."s "
end
secondLine="ATC"..b..": "..tvels..ad..(train.atc_command or "")
else
secondLine = "Manual operation"
if train.ctrl.lzb then
secondLine = "-!- Safety override -!-"
ht[#ht+1] = "100,20=(advtrains_hud_atc.png^[resize\\:100x20^[makealpha\\:#000000)"
end
if train.ctrl.lzb then
ht[#ht+1] = "200,20=(advtrains_hud_lzb.png^[resize\\:100x20^[multiply\\:red^[makealpha\\:#000000)"
end
if train.is_shunt then
ht[#ht+1] = "100,40=(advtrains_hud_shunt.png^[resize\\:100x20^[makealpha\\:#000000)"
end
if train.door_open == -1 then
ht[#ht+1] = "100,60=(advtrains_hud_left_door.png^[resize\\:100x20^[makealpha\\:#000000)"
elseif train.door_open == 1 then
ht[#ht+1] = "200,60=(advtrains_hud_right_door.png^[resize\\:100x24^[makealpha\\:#000000)"
end
-- speed indication(s)
local function sevenseg(digit, x, y, w, h, m)
--[[
-1-
2 3
-4-
5 6
-7-
]]
local segs = {
{h, 0, w, h},
{0, h, h, w},
{w+h, h, h, w},
{h, w+h, w, h},
{0, w+2*h, h, w},
{w+h, w+2*h, h, w},
{h, 2*(w+h), w, h}}
local trans = {
[0] = {true, true, true, false, true, true, true},
[1] = {false, false, true, false, false, true, false},
[2] = {true, false, true, true, true, false, true},
[3] = {true, false, true, true, false, true, true},
[4] = {false, true, true, true, false, true, false},
[5] = {true, true, false, true, false, true, true},
[6] = {true, true, false, true, true, true, true},
[7] = {true, false, true, false, false, true, false},
[8] = {true, true, true, true, true, true, true},
[9] = {true, true, true, true, false, true, true}}
local ent = trans[digit or 10]
if not ent then return end
for i = 1, 7, 1 do
if ent[i] then
local s = segs[i]
ht[#ht+1] = sformat("%d,%d=(advtrains_hud_bg.png^[resize\\:%dx%d^%s)",x+s[1], y+s[2], s[3], s[4], m)
end
end
end
local shtind = train.is_shunt and "S" or ">"
topLine=" ["..mletter[fct].."] {"..levers.."} "..doorstr[(train.door_open or 0)].." "..(train.line and "L: "..train.line or "")
firstLine=attrans("Speed:").." |"..string.rep("+", vel)..string.rep("_", res-vel).."|"..string.rep("_", max-res)..shtind.." "..vel_kmh.." km/h"
if train.speed_restriction == 0 then
firstLine = "OVERRUN RED SIGNAL! Examine situation and reverse train to move again."
sevenseg(math.floor(vel/10), 5, 5, 20, 10, "[colorize\\:red\\:255")
sevenseg(vel%10, 55, 5, 20, 10, "[colorize\\:red\\:255")
for i = 1, vel, 1 do
ht[#ht+1] = sformat("%d,100=(advtrains_hud_bg.png^[resize\\:11x30^[colorize\\:white)", i*14-3)
end
for i = max+1, 20, 1 do
ht[#ht+1] = sformat("%d,100=(advtrains_hud_bg.png^[resize\\:11x30^[colorize\\:lightgray)", i*14-3)
end
if res and res > 0 then
ht[#ht+1] = sformat("%d,95=(advtrains_hud_bg.png^[resize\\:3x40^[colorize\\:red\\:255)", 8+res*14)
end
if train.tarvelocity then
ht[#ht+1] = sformat("%d,130=(advtrains_hud_arrow.png^[multiply\\:cyan^[transformFY^[makealpha\\:#000000)", 2+train.tarvelocity*14)
end
local lzb = train.lzb
local i = 1
while i<=#lzb.oncoming do
local k = lzb.oncoming[i]
secondLine = secondLine .. "\n".."LZB: speed limit ["..(k.spd or "E")..("] in %.1f m"):format(k.idx-train.index)
if k.spd == 0 then
if lzb and lzb.oncoming then
local oc = lzb.oncoming
for i = 1, #oc do
local spd = oc[i].spd
if not spd then
ht[#ht+1] = "203,43=(advtrains_hud_bg.png^[resize\\:14x14^[colorize\\:lime\\:255)"
elseif spd == 0 then
ht[#ht+1] = "283,43=(advtrains_hud_bg.png^[resize\\:14x14^[colorize\\:red\\:255)"
elseif tonumber(spd) then
ht[#ht+1] = "243,43=(advtrains_hud_bg.png^[resize\\:14x14^[colorize\\:orange\\:255)"
ht[#ht+1] = sformat("%d,85=(advtrains_hud_arrow.png^[multiply\\:red^[makealpha\\:#000000)", 2+spd*14)
end
break
end
i=i+1
end
return (train.debug or "").."\n"..topLine.."\n"..firstLine.."\n"..secondLine
if res and res == 0 then
st[#st+1] = attrans("OVERRUN RED SIGNAL! Examine situation and reverse train to move again.")
end
if train.atc_command then
st[#st+1] = sformat("ATC: %s%s", train.atc_delay and advtrains.abs_ceil(train.atc_delay).."s " or "", train.atc_command or "")
end
return table.concat(st,"\n"), table.concat(ht,":")
end
local _, texture = advtrains.hud_train_format { -- dummy train object to demonstrate the train hud
max_speed = 15, speed_restriction = 12, velocity = 12, tarvelocity = 15,
active_control = true, lever = 3, ctrl = {lzb = true}, is_shunt = true,
door_open = 1, lzb = {oncoming = {{spd=6}}}
}
minetest.register_node("advtrains:hud_demo",{
description = "Train HUD demonstration",
tiles = {texture},
groups = {cracky = 3, not_in_creative_inventory = 1}
})
minetest.register_craft {
output = "advtrains:hud_demo",
recipe = {
{"default:paper", "default:paper", "default:paper"},
{"default:paper", "advtrains:trackworker", "default:paper"},
{"default:paper", "default:paper", "default:paper"},
}
}

View File

@ -1,6 +1,6 @@
# License for textures/media
Copyright (C) 2019-2020 Panquesito7, David Leal (halfpacho@gmail.com)\
Copyright (C) 2019-2021 Panquesito7, David Leal (halfpacho@gmail.com)\
Copyright (C) Various other Minetest developers/contributors
[David Leal](https://github.com/Panquesito7) ([CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)):
@ -42,7 +42,7 @@ Copyright (C) [davidthecreator](https://forum.minetest.net/memberlist.php?mode=v
## License for source code
Copyright (C) 2019-2020 Panquesito7, David Leal (halfpacho@gmail.com)\
Copyright (C) 2019-2021 Panquesito7, David Leal (halfpacho@gmail.com)\
Copyright (C) Various other Minetest developers/contributors
GNU LESSER GENERAL PUBLIC LICENSE

View File

@ -119,7 +119,7 @@ It shall work with MT 5.0.0 and above, though.
## License
Copyright (C) 2019-2020 Panquesito7, David Leal\
Copyright (C) 2019-2021 Panquesito7, David Leal\
Copyright (C) Various other Minetest developers/contributors
See [`LICENSE.md`](https://github.com/minetest-mods/cloud_items/blob/master/LICENSE.md) for more information.

View File

@ -1,7 +1,7 @@
--[[
Adds powerful cloud tools for Minetest.
Copyright (C) 2019-2020 David Leal (halfpacho@gmail.com)
Copyright (C) 2019-2021 David Leal (halfpacho@gmail.com)
Copyright (C) Various other Minetest developers/contributors
This library is free software; you can redistribute it and/or
@ -21,7 +21,7 @@ USA
==========================================================================
Dependencies: WorldEdit, default (included in Minetest Game)
Dependencies: WorldEdit, Vehicle Mash, default (included in Minetest Game)
Optional dependencies: 3D Armor, Tool Ranks, More Blocks, multitools, stairs (included in Minetest Game)
--]]
@ -531,7 +531,10 @@ local ship_def = {
}
-- Cloud ship (based on the Vehicle Mash boat)
loadfile(minetest.get_modpath(minetest.get_current_modname()) .. "/ship.lua")(table.copy(ship_def))
local boat_enabled = minetest.settings:get_bool("cloud_items.enable_cloud_car")
if boat_enabled or boat_enabled == nil then
loadfile(minetest.get_modpath(minetest.get_current_modname()) .. "/ship.lua")(table.copy(ship_def))
end
----------------
-- Cloud car --
@ -573,7 +576,10 @@ local car_def = {
}
-- Cloud car (similar from the CAR01 from Vehicle Mash)
loadfile(minetest.get_modpath(minetest.get_current_modname()) .. "/car.lua")(table.copy(car_def))
local car_enabled = minetest.settings:get_bool("cloud_items.enable_cloud_ship")
if car_enabled or car_enabled == nil then
loadfile(minetest.get_modpath(minetest.get_current_modname()) .. "/car.lua")(table.copy(car_def))
end
-------------
-- Crafts --

View File

@ -0,0 +1,4 @@
# Vehicle settings
cloud_items.enable_cloud_car (Enable/disable cloud car) bool true
cloud_items.enable_cloud_ship (Enable/disable cloud ship) bool true

View File

@ -8,7 +8,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = {
mod = "redo",
version = "20210104",
version = "20210107",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {}
}
@ -572,7 +572,8 @@ function mob_class:attempt_flight_correction(override)
local flyable_nodes = minetest.find_nodes_in_area(
{x = pos.x - 1, y = pos.y - 1, z = pos.z - 1},
{x = pos.x + 1, y = pos.y + 1, z = pos.z + 1}, searchnodes)
{x = pos.x + 1, y = pos.y + 0, z = pos.z + 1}, searchnodes)
-- pos.y + 0 hopefully fixes floating swimmers
if #flyable_nodes < 1 then
return false

View File

@ -1,7 +1,8 @@
stamina = {players = {}}
STAMINA_TICK = 800 -- time in seconds after that 1 stamina point is taken
STAMINA_TICK = tonumber(minetest.settings:get("stamina_tick")) or 800
-- time in seconds after that 1 stamina point is taken
STAMINA_TICK_MIN = 4 -- stamina ticks won't reduce stamina below this level
STAMINA_HEALTH_TICK = 4 -- time in seconds after player gets healed/damaged
STAMINA_MOVE_TICK = 0.5 -- time in seconds after the movement is checked
@ -204,11 +205,7 @@ end
-- Time based stamina functions
local stamina_timer = 0
local health_timer = 0
local action_timer = 0
local poison_timer = 0
local drunk_timer = 0
local stamina_timer, health_timer, action_timer, poison_timer, drunk_timer = 0,0,0,0,0
local function stamina_globaltimer(dtime)
@ -230,11 +227,13 @@ local function stamina_globaltimer(dtime)
if stamina.players[name]
and stamina.players[name].drunk then
-- play burp sound every 20 seconds when drunk
local num = stamina.players[name].drunk
if num and num > 0 and math.floor(num / 20) == num / 20 then
minetest.sound_play("stamina_burp", {to_player = name, gain = 0.7}, true)
end
-- play burp sound every 20 seconds when drunk
local num = stamina.players[name].drunk
if num and num > 0 and math.floor(num / 20) == num / 20 then
minetest.sound_play("stamina_burp",
{to_player = name, gain = 0.7}, true)
end
stamina.players[name].drunk = stamina.players[name].drunk - 1
@ -287,7 +286,7 @@ end
and stamina.players[name].poisoned then
player:hud_change(stamina.players[name].hud_id,
"text", "stamina_hud_fg.png")
"text", "stamina_hud_fg.png")
stamina.players[name].poisoned = nil
end
@ -357,7 +356,7 @@ end
maxsize = 1.0,
vertical = false,
collisiondetection = false,
texture = "default_dirt.png",
texture = "default_dirt.png"
})
end
@ -478,8 +477,7 @@ function stamina.eat(hp_change, replace_with_item, itemstack, user, pointed_thin
elseif hp_change < 0 then
-- assume hp_change < 0
user:hud_change(stamina.players[name].hud_id, "text",
"stamina_hud_poison.png")
user:hud_change(stamina.players[name].hud_id, "text", "stamina_hud_poison.png")
stamina.players[name].poisoned = -hp_change
end
@ -513,12 +511,14 @@ function stamina.eat(hp_change, replace_with_item, itemstack, user, pointed_thin
maxexptime = 1,
minsize = 1,
maxsize = 2,
texture = texture,
texture = texture
})
-- if player drinks bucket of milk then stop poison and being drunk
if itemstack:get_name() == "mobs:bucket_milk"
or itemstack:get_name() == "mobs:glass_milk" then
-- if player drinks milk then stop poison and being drunk
local item_name = itemstack:get_name() or ""
if item_name == "mobs:bucket_milk"
or item_name == "mobs:glass_milk"
or item_name == "farming:soy_milk" then
stamina.players[name].poisoned = 0
stamina.players[name].drunk = 0
@ -556,11 +556,11 @@ function stamina.eat(hp_change, replace_with_item, itemstack, user, pointed_thin
stamina.players[name].units = 0
user:hud_change(stamina.players[name].hud_id, "text",
"stamina_hud_poison.png")
"stamina_hud_poison.png")
minetest.chat_send_player(name,
minetest.get_color_escape_sequence("#1eff00")
.. "You suddenly feel tipsy!")
.. "You suddenly feel tipsy!")
end
end
@ -615,8 +615,7 @@ and minetest.settings:get_bool("enable_stamina") ~= false then
if stamina.players[name].poisoned
or stamina.players[name].drunk then
player:hud_change(stamina.players[name].hud_id,
"text", "stamina_hud_fg.png")
player:hud_change(stamina.players[name].hud_id, "text", "stamina_hud_fg.png")
end
stamina.players[name].exhaustion = 0

View File

@ -3,3 +3,5 @@ sprint (Enable sprint) bool true
sprint_particles (Enable sprint particles) bool true
enable_stamina (Enable stamina/hunger) bool true
stamina_tick (Time in seconds after which 1 saturation point is taken) float 800

View File

@ -1,5 +1,8 @@
# Credit where credit is due
Copyright (C) 2015-2016 blert2112 and contributors
Copyright (C) 2019-2021 Panquesito7 and contributors
- Black, Blue, Brown, Cyan, Dark Green, Dark Grey, Green, Grey, Magenta, Orange, Pink, Red, Violet, White, Yellow, Hot Rod, Nyan Ride, Oerkki Bliss, and Road Master from: "Car" by Esteban
- <https://forum.minetest.net/viewtopic.php?f=13&t=7407>
- License:

View File

@ -1,7 +1,7 @@
# Vehicle Mash [![Build status](https://github.com/minetest-mods/vehicle_mash/workflows/build/badge.svg)](https://github.com/minetest-mods/vehicle_mash/actions) [![ContentDB](https://content.minetest.net/packages/Panquesito7/vehicle_mash/shields/downloads/)](https://content.minetest.net/packages/Panquesito7/vehicle_mash/)
- Current version: 2.2.2
- By [blert2112](https://github.com/blert2112), and improvements by [Panquesito7](https://github.com/Panquesito7).
- By [blert2112](https://github.com/blert2112), and handed over to [Panquesito7](https://github.com/Panquesito7).
![Screenshot](https://raw.githubusercontent.com/minetest-mods/vehicle_mash/master/screenshot.png)
@ -43,6 +43,9 @@ For further information or help, see:\
## License
Copyright (C) 2015-2016 blert2112 and contributors
Copyright (C) 2019-2021 Panquesito7 and contributors
All licenses of previous works, of course, apply. (see credits below)
As far as the work I did... It's really just a fork of a fork of a fork of a fork, tossed it all into a blender and spun it on puree for a bit. Baked it for a while and set it on the counter to cool. What I mean is, make what you will of it, it matters not to me.