feat: add FS25_FarmHUD mod and FarmHUD desktop companion app
Initial commit: the FS25 Lua mod (live.json data export), the FS25-WebDashboard project (Node/web dashboard + PySide6 desktop variant), and FarmHUD (standalone PySide6 companion app with Discord Rich Presence, settings, and installer).
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
|
||||
<modDesc descVersion="92">
|
||||
<author>christianolah56</author>
|
||||
<version>1.4.0.0</version>
|
||||
|
||||
<title>
|
||||
<en>FarmHUD</en>
|
||||
<de>FarmHUD</de>
|
||||
</title>
|
||||
|
||||
<description>
|
||||
<en><![CDATA[
|
||||
Exports live telemetry (speed, RPM, cruise control, fuel, all vehicles on the map,
|
||||
farm finances, ingame time and weather, and more) to a small JSON file so the
|
||||
FarmHUD desktop app - or a browser-based dashboard on your PC/phone/tablet -
|
||||
can show it in real time.
|
||||
|
||||
This mod does NOT change any gameplay. It only reads data and writes it to:
|
||||
Documents/My Games/FarmingSimulator2025/modSettings/FS25_FarmHUD/live.json
|
||||
|
||||
You need the separate FarmHUD app (or the "server" + "web" dashboard) from the
|
||||
same download to actually view this data - see the README.
|
||||
]]></en>
|
||||
<de><![CDATA[
|
||||
Exportiert Live-Daten (Geschwindigkeit, Drehzahl, Tempomat, Tankfüllstand, alle
|
||||
Fahrzeuge auf der Karte, Betriebsfinanzen, Spielzeit und Wetter u.v.m.) in eine
|
||||
kleine JSON-Datei, damit die FarmHUD-Desktop-App - oder ein browserbasiertes
|
||||
Dashboard auf deinem PC/Handy/Tablet - sie in Echtzeit anzeigen kann.
|
||||
|
||||
Dieser Mod verändert keinerlei Spielverhalten. Er liest nur Daten und schreibt sie nach:
|
||||
Dokumente/My Games/FarmingSimulator2025/modSettings/FS25_FarmHUD/live.json
|
||||
|
||||
Du brauchst die separate FarmHUD-App (oder den "server" + "web" Dashboard-Teil)
|
||||
aus demselben Download, um diese Daten zu sehen - siehe README.
|
||||
]]></de>
|
||||
</description>
|
||||
|
||||
<iconFilename>icon_farmhud.dds</iconFilename>
|
||||
<multiplayer supported="true" />
|
||||
|
||||
<extraSourceFiles>
|
||||
<sourceFile filename="scripts/Json.lua" />
|
||||
<sourceFile filename="scripts/FarmHUD.lua" />
|
||||
</extraSourceFiles>
|
||||
</modDesc>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,108 @@
|
||||
--[[
|
||||
Json.lua - minimal, dependency-free JSON encoder for FS25_FarmHUD.
|
||||
|
||||
Farming Simulator's Lua sandbox does not ship a JSON library, so we bring our
|
||||
own tiny encoder. Only encoding is needed (the mod never reads JSON back),
|
||||
so this intentionally does not implement a decoder.
|
||||
|
||||
Usage:
|
||||
local text = Json.encode({ foo = "bar", list = {1, 2, 3} })
|
||||
]]
|
||||
|
||||
Json = {}
|
||||
|
||||
local ESCAPES = {
|
||||
["\\"] = "\\\\",
|
||||
["\""] = "\\\"",
|
||||
["\n"] = "\\n",
|
||||
["\r"] = "\\r",
|
||||
["\t"] = "\\t",
|
||||
}
|
||||
|
||||
local function encodeString(s)
|
||||
s = tostring(s)
|
||||
s = s:gsub('[\\"\n\r\t]', ESCAPES)
|
||||
-- strip any other control characters that would produce invalid JSON
|
||||
s = s:gsub("[\1-\31]", "")
|
||||
return '"' .. s .. '"'
|
||||
end
|
||||
|
||||
local function isArray(t)
|
||||
local count = 0
|
||||
for _ in pairs(t) do
|
||||
count = count + 1
|
||||
end
|
||||
if count == 0 then
|
||||
return true -- treat empty tables as empty arrays ([]) rather than {}
|
||||
end
|
||||
for i = 1, count do
|
||||
if t[i] == nil then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local encodeValue
|
||||
|
||||
local function encodeArray(t, out)
|
||||
out[#out + 1] = "["
|
||||
local n = #t
|
||||
for i = 1, n do
|
||||
if i > 1 then
|
||||
out[#out + 1] = ","
|
||||
end
|
||||
encodeValue(t[i], out)
|
||||
end
|
||||
out[#out + 1] = "]"
|
||||
end
|
||||
|
||||
local function encodeObject(t, out)
|
||||
out[#out + 1] = "{"
|
||||
local first = true
|
||||
for k, v in pairs(t) do
|
||||
if not first then
|
||||
out[#out + 1] = ","
|
||||
end
|
||||
first = false
|
||||
out[#out + 1] = encodeString(k)
|
||||
out[#out + 1] = ":"
|
||||
encodeValue(v, out)
|
||||
end
|
||||
out[#out + 1] = "}"
|
||||
end
|
||||
|
||||
encodeValue = function(v, out)
|
||||
local t = type(v)
|
||||
if v == nil then
|
||||
out[#out + 1] = "null"
|
||||
elseif t == "string" then
|
||||
out[#out + 1] = encodeString(v)
|
||||
elseif t == "number" then
|
||||
if v ~= v or v == math.huge or v == -math.huge then
|
||||
out[#out + 1] = "null" -- NaN / Infinity are not valid JSON
|
||||
else
|
||||
out[#out + 1] = tostring(v)
|
||||
end
|
||||
elseif t == "boolean" then
|
||||
out[#out + 1] = v and "true" or "false"
|
||||
elseif t == "table" then
|
||||
if isArray(v) then
|
||||
encodeArray(v, out)
|
||||
else
|
||||
encodeObject(v, out)
|
||||
end
|
||||
else
|
||||
-- functions, userdata, threads: not representable, encode as null
|
||||
out[#out + 1] = "null"
|
||||
end
|
||||
end
|
||||
|
||||
---Encode a Lua value (typically a table) as a JSON string.
|
||||
---@param value any
|
||||
---@return string
|
||||
function Json.encode(value)
|
||||
local out = {}
|
||||
encodeValue(value, out)
|
||||
return table.concat(out)
|
||||
end
|
||||
Reference in New Issue
Block a user