Skip to content

Commit

Permalink
v1.0.2.0
Browse files Browse the repository at this point in the history
- adequate sellpoints (#11)
  • Loading branch information
Mmtrx committed Oct 28, 2023
1 parent ddd395d commit 45ccc22
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
34 changes: 23 additions & 11 deletions chaffMission.lua
Original file line number Diff line number Diff line change
Expand Up @@ -198,33 +198,44 @@ function adjustMissionTypes(name)
end
end

function isTargetFilltype(typeNames)
-- return true if typeNames contain straw or hay
local txt = typeNames.." "
if string.find(txt, "GRASS_WINDROW ") or string.find(txt, "STRAW ") then
return true
end
return false
end

function addSellingStation(self, superFunc, components, xmlFile, key, ...)
-- add chaff only for normal sellingstations that allow missions
local added = false
local needFtKey = false
if key == "placeable.sellingStation" and xmlFile:getBool(key.."#allowMissions", true)
and not xmlFile:getBool(key.."#hideFromPricesMenu", false) then

debugPrint("*** checking selling station:")
local added = false

xmlFile:iterate(key..".unloadTrigger", function(index, unloadTriggerKey)
local fillTypeNames = xmlFile:getString(unloadTriggerKey.."#fillTypes")
local fillTypeCategories = xmlFile:getValue(unloadTriggerKey .. "#fillTypeCategories")
debugPrint(" * unload %d: %s / %s", index, fillTypeNames, fillTypeCategories)

-- add only to triggers with wheat or straw:
-- add only to triggers with hay or straw:
if fillTypeNames == nil then
fillTypeNames = ""
--local indexes = g_fillTypeManager:getFillTypesByCategoryNames(fillTypeCategories, "Warning: SellingStation has invalid fillTypeCategory '%s'.")
local catNames = string.split(fillTypeCategories, " ")
for _, cat in ipairs(catNames) do
if g_fillTypeManager:getIsFillTypeInCategory(FillType.CHAFF, cat) then
-- Chaff already in selling station, can skip this
if added then added = false end
added = false
break
end
added = added or g_fillTypeManager:getIsFillTypeInCategory(FillType.WHEAT, cat) or
g_fillTypeManager:getIsFillTypeInCategory(FillType.STRAW, cat)
added = added or g_fillTypeManager:getIsFillTypeInCategory(FillType.DRYGRASS_WINDROW, cat)
or g_fillTypeManager:getIsFillTypeInCategory(FillType.GRASS_WINDROW, cat)
or g_fillTypeManager:getIsFillTypeInCategory(FillType.STRAW, cat)
end

elseif string.find(fillTypeNames, "WHEAT") or string.find(fillTypeNames, "STRAW") then
added = true
else
added = isTargetFilltype(fillTypeNames)
end

if added then
Expand All @@ -233,10 +244,11 @@ function addSellingStation(self, superFunc, components, xmlFile, key, ...)
types = types .. " CHOPPEDMAIZE"
end
xmlFile:setString(unloadTriggerKey.."#fillTypes", fillTypeNames.. types)
needFtKey = true
end
end)

if added then
if needFtKey then
local numberOfFillTypes = -1
xmlFile:iterate(key..".fillType", function(_, _)
numberOfFillTypes = numberOfFillTypes + 1
Expand Down
7 changes: 5 additions & 2 deletions modDesc.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="77">
<author>Mmtrx</author>
<version>1.0.1.0</version>
<version>1.0.2.0</version>
<title>
<en>Forage Contracts</en>
<de>Häcksel-Aufträge</de>
Expand All @@ -14,9 +14,12 @@
<![CDATA[
Implements field forage harvest contracts
Changelog v1.0.2.0
- adequate sellpoints (#11)
Changelog v1.0.1.1
- fix MP sync (#3)
- Russian translation (#5)
- Russian, Czech translation (#5)
Changelog v1.0.1.0
- Allow choppedmaize fillType for Maize+ (#2)
Expand Down

0 comments on commit 45ccc22

Please sign in to comment.