Zwischen speichern

This commit is contained in:
2026-07-02 19:50:56 +02:00
parent e1694513e9
commit 3f8203b7d9
3 changed files with 48 additions and 7 deletions
+45 -7
View File
@@ -1,4 +1,4 @@
-- Variablen
-- Variablen
Produktion = {}
@@ -7,7 +7,7 @@ Produktion.debugPrefix = "[LS25-Mine] "
Produktion.fillType = "PAYDIRT"
Produktion.amountPerHour = 40000
Produktion.debugProductionInterval = 30000
Produktion.animationAcceleration = 0.25
Produktion.animationSpeedMax = 1.0
@@ -29,21 +29,49 @@ function Produktion.registerEventListeners(placeableType)
SpecializationUtil.registerEventListener(placeableType, "onFinalizePlacement", Produktion)
end
function Produktion.registerXMLPaths(schema, basePath)
schema:setXMLSpecializationType("Produktion")
schema:register(XMLValueType.STRING, basePath .. ".produktion#fillType", "Fill type produced by this mine", Produktion.fillType)
schema:register(XMLValueType.FLOAT, basePath .. ".produktion#amountPerHour", "Amount produced per game hour", Produktion.amountPerHour)
schema:setXMLSpecializationType()
end
-- Initialisierung
function Produktion:onLoad(savegame)
local xmlFillType = self.xmlFile:getValue("placeable.produktion#fillType", Produktion.fillType)
local xmlAmountPerHour = self.xmlFile:getValue("placeable.produktion#amountPerHour", Produktion.amountPerHour)
if Produktion.debug then
local debugCapacity = self.xmlFile:getValue("placeable.silo.storages.storage(0)#capacity")
print(Produktion.debugPrefix .. "XML-Test amount raw: " .. tostring(xmlAmountPerHour))
print(Produktion.debugPrefix .. "XML-Test capacity: " .. tostring(debugCapacity))
end
self.produktionFillType = xmlFillType
if self.produktionFillType == nil or self.produktionFillType == "" then
self.produktionFillType = Produktion.fillType
end
self.produktionAmountPerHour = tonumber(xmlAmountPerHour)
if self.produktionAmountPerHour == nil then
self.produktionAmountPerHour = Produktion.amountPerHour
end
self.produktionFirstUpdatePrinted = false
self.produktionAnimationSpeed = 0
self.produktionAnimationTargetSpeed = 0
self.produktionWasFull = false
self.produktionBuffer = 0
self.produktionDebugTimer = 0
self.produktionDebugAmount = 0
if self.raiseActive ~= nil then
self:raiseActive()
end
if Produktion.debug then
print(Produktion.debugPrefix .. "Konfiguration: " .. tostring(self.produktionFillType) .. " / " .. tostring(self.produktionAmountPerHour) .. " L/h")
print(Produktion.debugPrefix .. "Produktion.lua wurde geladen")
end
end
@@ -77,7 +105,11 @@ function Produktion:onUpdate(dt)
end
local gameTimeHours = (dt * timeScale) / 3600000
local amountToProduce = Produktion.amountPerHour * gameTimeHours
local amountToProduce = self.produktionAmountPerHour * gameTimeHours
if Produktion.debug then
self.produktionDebugTimer = self.produktionDebugTimer + dt
end
self.produktionBuffer = self.produktionBuffer + amountToProduce
@@ -121,11 +153,11 @@ function Produktion:produce(amount)
return 0
end
local fillTypeIndex = g_fillTypeManager:getFillTypeIndexByName(Produktion.fillType)
local fillTypeIndex = g_fillTypeManager:getFillTypeIndexByName(self.produktionFillType)
if fillTypeIndex == nil then
if Produktion.debug then
print(Produktion.debugPrefix .. "FillType nicht gefunden: " .. Produktion.fillType)
print(Produktion.debugPrefix .. "FillType nicht gefunden: " .. self.produktionFillType)
end
return 0
@@ -160,7 +192,13 @@ function Produktion:produce(amount)
self.produktionWasFull = false
if producedAmount >= 1 then
print(Produktion.debugPrefix .. "Produziert: " .. tostring(math.floor(producedAmount)) .. " L " .. Produktion.fillType)
self.produktionDebugAmount = self.produktionDebugAmount + producedAmount
if self.produktionDebugTimer >= Produktion.debugProductionInterval then
print(Produktion.debugPrefix .. "Produziert: " .. tostring(math.floor(self.produktionDebugAmount)) .. " L " .. self.produktionFillType .. " in den letzten " .. tostring(Produktion.debugProductionInterval / 1000) .. "s")
self.produktionDebugTimer = 0
self.produktionDebugAmount = 0
end
end
elseif hasFreeCapacity == false and self.produktionWasFull ~= true then
self.produktionWasFull = true
@@ -194,4 +232,4 @@ function Produktion:updateAnimationState(isProducing, dt)
-- self:setAnimationTime("mineWorkAnimation", self.produktionAnimationSpeed, true)
-- oder:
-- setRotation(self.animationNode, 0, self.produktionAnimationSpeed, 0)
end
end