Skip to content

Commit

Permalink
Updates L10n, made Button in P-Menu translatable, fixed bug with prod…
Browse files Browse the repository at this point in the history
…uctions/silos in one placeable

closes
#5
#4
  • Loading branch information
braeven committed May 29, 2023
1 parent 3973c77 commit 07a2098
Show file tree
Hide file tree
Showing 14 changed files with 190 additions and 16 deletions.
1 change: 1 addition & 0 deletions l10n/l10n_br.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<text name="Revamp_OpenProduction" text="Gerenciar a produção" />
<text name="Revamp_SpawnItem" text="Geração manual de paletes" />
<text name="finance_ProductionDeliveryCosts" text="Encargos de entrega da produção" />
<text name="Revamp_ShowAnimalsOverview" text="Mostrar animais" />

<!-- game Settings menu -->
<text name="Revamp_Settings_Title" text="Revamp" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_cz.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<text name="Revamp_OpenProduction" text="Otevřít menu výroby" />
<text name="Revamp_SpawnItem" text="Vyskladnění" />
<text name="finance_ProductionDeliveryCosts" text="Poplatek za dodání výroby" />
<text name="Revamp_ShowAnimalsOverview" text="Výstavní zvířata" />

<!-- game Settings menu -->
<text name="Revamp_Settings_Title" text="Revamp" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<text name="Revamp_OpenProduction" text="Produktion verwalten" />
<text name="Revamp_SpawnItem" text="Auslagern" />
<text name="finance_ProductionDeliveryCosts" text="Produktions Liefergebühren" />
<text name="Revamp_ShowAnimalsOverview" text="Tiere Anzeigen" />

<!-- game Settings menu -->
<text name="Revamp_Settings_Title" text="Revamp" />
Expand Down
3 changes: 2 additions & 1 deletion l10n/l10n_en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
<!-- Production menu -->
<text name="Revamp_OpenProduction" text="Open Production Menu" />
<text name="Revamp_SpawnItem" text="Spawn Items" />
<text name="finance_ProductionDeliveryCosts" text="Delivery Costs Productions" />
<text name="finance_ProductionDeliveryCosts" text="Productions Delivery Costs" />
<text name="Revamp_ShowAnimalsOverview" text="Show Animals" />

<!-- game Settings menu -->
<text name="Revamp_Settings_Title" text="Revamp" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_es.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<text name="Revamp_OpenProduction" text="Producción Abierta" />
<text name="Revamp_SpawnItem" text="Generar Artículos" />
<text name="finance_ProductionDeliveryCosts" text="Costes de entrega de producción" />
<text name="Revamp_ShowAnimalsOverview" text="Mostrar animales" />

<!-- game Settings menu -->
<text name="Revamp_Settings_Title" text="Revamp" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_fr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<text name="Revamp_OpenProduction" text="Ouvrir le menu de production" />
<text name="Revamp_SpawnItem" text="Générer des marchandises" />
<text name="finance_ProductionDeliveryCosts" text="Coûts des livraisons des productions" />
<text name="Revamp_ShowAnimalsOverview" text="Afficher les animaux" />

<!-- game Settings menu -->
<text name="Revamp_Settings_Title" text="Paramètres Revamp" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_it.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<text name="Revamp_OpenProduction" text="Produzione aperta" />
<text name="Revamp_SpawnItem" text="Generare articoli" />
<text name="finance_ProductionDeliveryCosts" text="Costi di consegna della produzione" />
<text name="Revamp_ShowAnimalsOverview" text="Mostra animali" />

<!-- game Settings menu -->
<text name="Revamp_Settings_Title" text="Revamp" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_no.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<text name="Revamp_OpenProduction" text="Åpne Produksjon Meny" />
<text name="Revamp_SpawnItem" text="Spawn Items" />
<text name="finance_ProductionDeliveryCosts" text="Leveringskostnader Produksjon" />
<text name="Revamp_ShowAnimalsOverview" text="Vis frem dyr" />

<!-- game Settings menu -->
<text name="Revamp_Settings_Title" text="revamp" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_pl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<text name="Revamp_OpenProduction" text="Otwórz menu produkcji" />
<text name="Revamp_SpawnItem" text="Wydaj palety" />
<text name="finance_ProductionDeliveryCosts" text="Koszt dostawy produkcji" />
<text name="Revamp_ShowAnimalsOverview" text="Pokaż zwierzęta" />

<!-- game Settings menu -->
<text name="Revamp_Settings_Title" text="Revamp - Ustawienia" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_ru.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<text name="Revamp_OpenProduction" text="Управление производством" />
<text name="Revamp_SpawnItem" text="На поддоны" />
<text name="finance_ProductionDeliveryCosts" text="Сборы за доставку продукции" />
<text name="Revamp_ShowAnimalsOverview" text="Показать животных" />

<!-- game Settings menu -->
<text name="Revamp_Settings_Title" text="Revamp" />
Expand Down
2 changes: 2 additions & 0 deletions l10n/l10n_sv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@
<text name="Revamp_productionHoursDependent" text="%s %s" />
<text name="Revamp_monthlyProduction" text="%s en gång i månaden" />
<text name="Revamp_productionMode" text="Produktionsläge" />

<!-- Production menu -->
<text name="Revamp_OpenProduction" text="Öppna produktionsmenyn" />
<text name="Revamp_SpawnItem" text="Generera föremål" />
<text name="finance_ProductionDeliveryCosts" text="Produktion Leveranskostnader" />
<text name="Revamp_ShowAnimalsOverview" text="Visa djur" />

<!-- game Settings menu -->
<text name="Revamp_Settings_Title" text="Revamp" />
Expand Down
17 changes: 16 additions & 1 deletion modDesc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modDesc descVersion="74">
<author>Braeven</author>
<contributors>Achimobil</contributors>
<version>1.4.1.5</version>
<version>1.4.1.6</version>
<title>
<en>Production Revamp</en>
</title>
Expand Down Expand Up @@ -106,6 +106,11 @@ Version 1.4.1.4
Version 1.4.1.5
* Bugfix with manual spawning and opening hours
Version 1.4.1.6
* Translations updated
* Buttons in production menu made translatable
* Bug fixed when selling in combination of silo with productions in a placeable
]]>
</en>
<de>
Expand Down Expand Up @@ -206,6 +211,11 @@ Version 1.4.1.4
Version 1.4.1.5
* Bugfix mit manuellen spawnen und Öffnungszeiten
Version 1.4.1.6
* Übersetzungen aktualisiert
* Butten im Produktionsmenü übersetzbar gemacht
* Bug gefixxt beim Verkaufen in Kombination von Silo mit Produktionen in einen Placeable
]]>
</de>
<fr>
Expand Down Expand Up @@ -306,6 +316,11 @@ Version 1.4.1.4
Version 1.4.1.5
* Correction de bug avec le spawn manuel et les heures d'ouverture
Version 1.4.1.6
* Traductions mises à jour
* Boutons du menu de production rendus traduisibles
* Correction d'un bug lors de la vente en combinaison de silo avec des productions dans un placeable
]]>
</fr>
</description>
Expand Down
8 changes: 4 additions & 4 deletions scripts/revamp_animalSystem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Copyright (C) braeven, Achimobil, 2022
Author: braeven, Achimobil
Date: 27.12.2022
Version: 1.0.2.0
Date: 29.05.2023
Version: 1.0.2.1
Contact/Help/Tutorials:
discord.gg/gHmnFZAypk
Expand All @@ -17,6 +17,7 @@ Changelog:
1.0.0.0 @ 24.11.2022 - Initial commit
1.0.1.0 @ 21.12.2022 - Verschiedene Gesundheitseinstellungen ermöglicht
1.0.2.0 @ 27.12.2022 - Anpassung für die Tier-Übersicht
1.0.2.0 @ 29.05.2023 - Button Übersetzbar gemacht
Important:.
No changes are allowed to this script without permission from Braeven.
Expand All @@ -33,15 +34,14 @@ RevampAnimals = {}

--Production Revamp: MenüButton um sich mögliche Tiere/FillTypes anzeigen zu lassen
function RevampAnimals:updateMenuButtons(superFunc)
local buttonText = "Tiere Anzeigen"
local isProductionListActive = self.productionList == FocusManager:getFocusedElement()
local production, productionPoint = self:getSelectedProduction()

if isProductionListActive and productionPoint.animalTypes ~= nil then
table.insert(self.menuButtonInfo, {
profile = "buttonOk",
inputAction = InputAction.MENU_EXTRA_1,
text = buttonText,
text = self.i18n:getText("Revamp_ShowAnimalsOverview"),
callback = function()
ProductionAnimalOverview:show(productionPoint)
end
Expand Down
167 changes: 157 additions & 10 deletions scripts/revamp_sellProductionFix.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ Production Sell Fix - Sells Goods that are still in a Production, when selling t
Copyright (C) Achimobil, braeven, 2022
Date: 22.12.2022
Version: 1.0.0.0
Date: 29.05.2023
Version: 1.1.0.0
Contact/Help/Tutorials:
discord.gg/gHmnFZAypk
Changelog:
1.0.0.0 @ 22.12.2022 - Initial Release
1.1.0.0 @ 29.05.2023 - Added Support for Combination Silo + ProductionPoint
Important:.
No changes are allowed to this script without permission from Achimobil AND Braeven.
Expand Down Expand Up @@ -43,14 +44,13 @@ PlaceableProductionPoint.registerEventListeners = Utils.prependedFunction(Placea

function RevampSellFix:canBeSold(superFunc)
local spec = self.spec_productionPoint

spec.sellWarningText = g_i18n:getText("Revamp_ProductionNotEmpty")
local warning = spec.sellWarningText .. "\n"

local totalFillLevel = 0
spec.totalFillTypeSellPrice = 0

--DebugUtil.printTableRecursively(spec.productionPoint, test, 2, 3)

for fillTypeIndex, fillLevel in pairs(spec.productionPoint.storage.fillLevels) do
totalFillLevel = totalFillLevel + fillLevel

Expand Down Expand Up @@ -78,6 +78,38 @@ function RevampSellFix:canBeSold(superFunc)
end
end

if self.spec_silo ~= nil then
local spec2 = self.spec_silo
spec2.totalFillTypeSellPrice = 0

for fillTypeIndex, fillLevel in pairs(spec2.storages[1].fillLevels) do
totalFillLevel = totalFillLevel + fillLevel

if fillLevel > 0 then
local lowestSellPrice = math.huge

for _, unloadingStation in pairs(g_currentMission.storageSystem:getUnloadingStations()) do
if unloadingStation.owningPlaceable ~= nil and unloadingStation.isSellingPoint and unloadingStation.acceptedFillTypes[fillTypeIndex] then
local price = unloadingStation:getEffectiveFillTypePrice(fillTypeIndex)

if price > 0 then
lowestSellPrice = math.min(lowestSellPrice, price)
end
end
end

if lowestSellPrice == math.huge then
lowestSellPrice = 0.5
end

local price = fillLevel * lowestSellPrice * PlaceableSilo.PRICE_SELL_FACTOR
local fillType = g_fillTypeManager:getFillTypeByIndex(fillTypeIndex)
warning = string.format("%s%s (%s) - %s: %s\n", warning, fillType.title, g_i18n:formatVolume(fillLevel), g_i18n:getText("ui_sellValue"), g_i18n:formatMoney(price, 0, true, true))
spec2.totalFillTypeSellPrice = spec2.totalFillTypeSellPrice + price
end
end
end

if totalFillLevel > 0 then
return true, warning
end
Expand All @@ -89,15 +121,130 @@ end

function RevampSellFix:onSell()
local spec = self.spec_productionPoint

--Bei wiederkaufbaren Produktionen das Lager nullen
for fillTypeIndex, fillLevel in pairs(spec.productionPoint.storage.fillLevels) do
if fillLevel > 0 then
spec.productionPoint.storage.fillLevels[fillTypeIndex] = 0
end
end

if self.isServer and spec.totalFillTypeSellPrice > 0 then
g_currentMission:addMoney(spec.totalFillTypeSellPrice, self:getOwnerFarmId(), MoneyType.SOLD_PRODUCTS, true, true)

if spec.totalFillTypeSellPrice ~= nil then
if self.isServer and spec.totalFillTypeSellPrice > 0 then
g_currentMission:addMoney(spec.totalFillTypeSellPrice, self:getOwnerFarmId(), MoneyType.SOLD_PRODUCTS, true, true)
spec.totalFillTypeSellPrice = nil
end
end
if self.spec_silo ~= nil then
if self.spec_silo.totalFillTypeSellPrice ~= nil then
if self.isServer and self.spec_silo.totalFillTypeSellPrice > 0 then
g_currentMission:addMoney(self.spec_silo.totalFillTypeSellPrice, self:getOwnerFarmId(), MoneyType.HARVEST_INCOME, true, true)
self.spec_silo.totalFillTypeSellPrice = nil
end
end
end
end



function RevampSellFix:onSellSilo()
local spec = self.spec_silo

if spec.totalFillTypeSellPrice ~= nil then
if self.isServer and spec.totalFillTypeSellPrice > 0 then
g_currentMission:addMoney(spec.totalFillTypeSellPrice, self:getOwnerFarmId(), MoneyType.HARVEST_INCOME, true, true)
spec.totalFillTypeSellPrice = nil
end
end
if self.spec_productionPoint~=nil then
if self.spec_productionPoint.totalFillTypeSellPrice~=nil then
if self.isServer and self.spec_productionPoint.totalFillTypeSellPrice > 0 then
g_currentMission:addMoney(self.spec_productionPoint.totalFillTypeSellPrice, self:getOwnerFarmId(), MoneyType.SOLD_PRODUCTS, true, true)
self.spec_productionPoint.totalFillTypeSellPrice = nil
end
end
end
end

PlaceableSilo.onSell = Utils.overwrittenFunction(PlaceableSilo.onSell, RevampSellFix.onSellSilo)



function RevampSellFix:canBeSoldSilo(superFunc)
local spec = self.spec_silo

if spec.storagePerFarm then
return false, nil
end

local warning = spec.sellWarningText .. "\n"
local totalFillLevel = 0
spec.totalFillTypeSellPrice = 0

for fillTypeIndex, fillLevel in pairs(spec.storages[1].fillLevels) do
totalFillLevel = totalFillLevel + fillLevel

if fillLevel > 0 then
local lowestSellPrice = math.huge

for _, unloadingStation in pairs(g_currentMission.storageSystem:getUnloadingStations()) do
if unloadingStation.owningPlaceable ~= nil and unloadingStation.isSellingPoint and unloadingStation.acceptedFillTypes[fillTypeIndex] then
local price = unloadingStation:getEffectiveFillTypePrice(fillTypeIndex)

if price > 0 then
lowestSellPrice = math.min(lowestSellPrice, price)
end
end
end

if lowestSellPrice == math.huge then
lowestSellPrice = 0.5
end

local price = fillLevel * lowestSellPrice * PlaceableSilo.PRICE_SELL_FACTOR
local fillType = g_fillTypeManager:getFillTypeByIndex(fillTypeIndex)
warning = string.format("%s%s (%s) - %s: %s\n", warning, fillType.title, g_i18n:formatVolume(fillLevel), g_i18n:getText("ui_sellValue"), g_i18n:formatMoney(price, 0, true, true))
spec.totalFillTypeSellPrice = spec.totalFillTypeSellPrice + price
end
end

if self.spec_productionPoint ~= nil then
local spec2 = self.spec_productionPoint
spec2.totalFillTypeSellPrice = 0

for fillTypeIndex, fillLevel in pairs(spec2.productionPoint.storage.fillLevels) do
totalFillLevel = totalFillLevel + fillLevel

if fillLevel > 0 then
local lowestSellPrice = math.huge

for _, unloadingStation in pairs(g_currentMission.storageSystem:getUnloadingStations()) do
if unloadingStation.owningPlaceable ~= nil and unloadingStation.isSellingPoint and unloadingStation.acceptedFillTypes[fillTypeIndex] then
local price = unloadingStation:getEffectiveFillTypePrice(fillTypeIndex)

if price > 0 then
lowestSellPrice = math.min(lowestSellPrice, price)
end
end
end

if lowestSellPrice == math.huge then
lowestSellPrice = 0.5
end

local price = fillLevel * lowestSellPrice * PlaceableSilo.PRICE_SELL_FACTOR
local fillType = g_fillTypeManager:getFillTypeByIndex(fillTypeIndex)
warning = string.format("%s%s (%s) - %s: %s\n", warning, fillType.title, g_i18n:formatVolume(fillLevel), g_i18n:getText("ui_sellValue"), g_i18n:formatMoney(price, 0, true, true))
spec2.totalFillTypeSellPrice = spec2.totalFillTypeSellPrice + price
end
end
end

if totalFillLevel > 0 then
return true, warning
end
end

return true, nil
end

PlaceableSilo.canBeSold = Utils.overwrittenFunction(PlaceableSilo.canBeSold, RevampSellFix.canBeSoldSilo)

0 comments on commit 07a2098

Please sign in to comment.