mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Warehouse v0.6.4
- Added possibility to auto save assets on mission end. - Minor bug fixes.
This commit is contained in:
parent
d2db1e56cc
commit
e0afd19a94
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,7 @@
|
|||||||
-- * Strategic components such as capturing, defending and destroying warehouses and their associated infrastructure.
|
-- * Strategic components such as capturing, defending and destroying warehouses and their associated infrastructure.
|
||||||
-- * Intelligent spawning of aircraft on airports (only if enough parking spots are available).
|
-- * Intelligent spawning of aircraft on airports (only if enough parking spots are available).
|
||||||
-- * Possibility to hook into events and customize actions.
|
-- * Possibility to hook into events and customize actions.
|
||||||
-- * Persistance of assets. Warehouse assets can be saved and loaded from file.
|
-- * Persistence of assets. Warehouse assets can be saved and loaded from file.
|
||||||
-- * Can be easily interfaced to other MOOSE classes.
|
-- * Can be easily interfaced to other MOOSE classes.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
@ -680,7 +680,7 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- # Persistance of Assets
|
-- # Persistence of Assets
|
||||||
--
|
--
|
||||||
-- Assets in stock of a warehouse can be saved to a file on your hard drive and then loaded from that file at a later point. This enables to restart the mission
|
-- Assets in stock of a warehouse can be saved to a file on your hard drive and then loaded from that file at a later point. This enables to restart the mission
|
||||||
-- and restore the warehouse stock.
|
-- and restore the warehouse stock.
|
||||||
@ -699,7 +699,7 @@
|
|||||||
--
|
--
|
||||||
-- in the file "MissionScripting.lua", which is located in the subdirectory "Scripts" of your DCS installation root directory.
|
-- in the file "MissionScripting.lua", which is located in the subdirectory "Scripts" of your DCS installation root directory.
|
||||||
--
|
--
|
||||||
-- ### Don'ts
|
-- ### Don't!
|
||||||
--
|
--
|
||||||
-- Do not use **semi-colons** or **equal signs** in the group names of your assets as these are used as separators in the saved and loaded files texts.
|
-- Do not use **semi-colons** or **equal signs** in the group names of your assets as these are used as separators in the saved and loaded files texts.
|
||||||
-- If you do, it will cause problems and give you a headache!
|
-- If you do, it will cause problems and give you a headache!
|
||||||
@ -711,10 +711,16 @@
|
|||||||
-- The parameter *filename* is optional and defines the name of the saved file. By default this is automatically created from the warehouse id and name, for example
|
-- The parameter *filename* is optional and defines the name of the saved file. By default this is automatically created from the warehouse id and name, for example
|
||||||
-- "Warehouse-1234_Batumi.txt".
|
-- "Warehouse-1234_Batumi.txt".
|
||||||
--
|
--
|
||||||
-- warehouseBatumi:Save("D:\\My Warehouse Data\\")
|
-- warehouseBatumi:Save("D:\\My Warehouse Data\\")
|
||||||
--
|
--
|
||||||
-- This will save all asset data to in "D:\\My Warehouse Data\\Warehouse-1234_Batumi.txt".
|
-- This will save all asset data to in "D:\\My Warehouse Data\\Warehouse-1234_Batumi.txt".
|
||||||
--
|
--
|
||||||
|
-- ### Automatic Save at Mission End
|
||||||
|
--
|
||||||
|
-- The assets can be saved automatically when the mission is ended via the @{WAREHOUSE.SetSaveOnMissionEnd}(*path*, *filename*) function, i.e.
|
||||||
|
--
|
||||||
|
-- warehouseBatumi:SetSaveOnMissionEnd("D:\\My Warehouse Data\\")
|
||||||
|
--
|
||||||
-- ## Load Assets
|
-- ## Load Assets
|
||||||
--
|
--
|
||||||
-- Loading assets data from file is achieved by the @{WAREHOUSE.Load}(*path*, *filename*) function. The parameter *path* specifies the path on the file system where the
|
-- Loading assets data from file is achieved by the @{WAREHOUSE.Load}(*path*, *filename*) function. The parameter *path* specifies the path on the file system where the
|
||||||
@ -727,9 +733,9 @@
|
|||||||
--
|
--
|
||||||
-- Loading the assets is done by
|
-- Loading the assets is done by
|
||||||
--
|
--
|
||||||
-- warehouseBatumi:New(STATIC:FindByName("Warehouse Batumi"))
|
-- warehouseBatumi:New(STATIC:FindByName("Warehouse Batumi"))
|
||||||
-- warehouseBatumi:Load("D:\\My Warehouse Data\\")
|
-- warehouseBatumi:Load("D:\\My Warehouse Data\\")
|
||||||
-- warehouseBatumi:Start()
|
-- warehouseBatumi:Start()
|
||||||
--
|
--
|
||||||
-- This sequence loads all assets from file. If a warehouse was captured in the last mission, it also respawns the static warehouse structure with the right coaliton.
|
-- This sequence loads all assets from file. If a warehouse was captured in the last mission, it also respawns the static warehouse structure with the right coaliton.
|
||||||
-- However, it due to DCS limitations it is not possible to set the airbase coalition. This has to be done manually in the mission editor. Or alternatively, one could
|
-- However, it due to DCS limitations it is not possible to set the airbase coalition. This has to be done manually in the mission editor. Or alternatively, one could
|
||||||
@ -1720,7 +1726,7 @@ WAREHOUSE.db = {
|
|||||||
|
|
||||||
--- Warehouse class version.
|
--- Warehouse class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
WAREHOUSE.version="0.6.3"
|
WAREHOUSE.version="0.6.4"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO: Warehouse todo list.
|
-- TODO: Warehouse todo list.
|
||||||
@ -4944,6 +4950,7 @@ function WAREHOUSE:onbeforeLoad(From, Event, To, path, filename)
|
|||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
self:_ErrorMessage(string.format("ERROR: file %s does not exist! Cannot load assets.", filename), 60)
|
self:_ErrorMessage(string.format("ERROR: file %s does not exist! Cannot load assets.", filename), 60)
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -4996,6 +5003,7 @@ function WAREHOUSE:onafterLoad(From, Event, To, path, filename)
|
|||||||
local descriptors=UTILS.Split(asset,";")
|
local descriptors=UTILS.Split(asset,";")
|
||||||
|
|
||||||
local asset={}
|
local asset={}
|
||||||
|
local isasset=false
|
||||||
for _,descriptor in pairs(descriptors) do
|
for _,descriptor in pairs(descriptors) do
|
||||||
|
|
||||||
local keyval=UTILS.Split(descriptor,"=")
|
local keyval=UTILS.Split(descriptor,"=")
|
||||||
@ -5008,15 +5016,20 @@ function WAREHOUSE:onafterLoad(From, Event, To, path, filename)
|
|||||||
elseif keyval[1]=="country" then
|
elseif keyval[1]=="country" then
|
||||||
-- Get country id.
|
-- Get country id.
|
||||||
Country=tonumber(keyval[2])
|
Country=tonumber(keyval[2])
|
||||||
elseif #keyval==2 then
|
else
|
||||||
|
|
||||||
|
-- This is an asset.
|
||||||
|
isasset=true
|
||||||
|
|
||||||
local key=keyval[1]
|
local key=keyval[1]
|
||||||
local val=keyval[2]
|
local val=keyval[2]
|
||||||
|
|
||||||
|
--env.info(string.format("FF asset key=%s val=%s", key, val))
|
||||||
|
|
||||||
-- Livery or skill could be "nil".
|
-- Livery or skill could be "nil".
|
||||||
if val=="nil" then
|
if val=="nil" then
|
||||||
val=nil
|
val=nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Convert string to number where necessary.
|
-- Convert string to number where necessary.
|
||||||
if key=="cargobay" or key=="weight" or key=="loadradius" then
|
if key=="cargobay" or key=="weight" or key=="loadradius" then
|
||||||
@ -5030,13 +5043,14 @@ function WAREHOUSE:onafterLoad(From, Event, To, path, filename)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Add to table.
|
-- Add to table.
|
||||||
table.insert(assets, asset)
|
if isasset then
|
||||||
|
table.insert(assets, asset)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Respawn warehouse with prev coalition if necessary.
|
-- Respawn warehouse with prev coalition if necessary.
|
||||||
self:E(string.format("Changing country %d-->%d (before)", self:GetCountry(), Country))
|
|
||||||
if Country~=self:GetCountry() then
|
if Country~=self:GetCountry() then
|
||||||
self:E(string.format("Changing country %d-->%d (after)", self:GetCountry(), Country))
|
self:T(self.wid..string.format("Changing warehouse country %d-->%d on loading assets.", self:GetCountry(), Country))
|
||||||
self:ChangeCountry(Country)
|
self:ChangeCountry(Country)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -7743,7 +7757,7 @@ end
|
|||||||
function WAREHOUSE:_ErrorMessage(text, duration)
|
function WAREHOUSE:_ErrorMessage(text, duration)
|
||||||
duration=duration or 20
|
duration=duration or 20
|
||||||
if duration>0 then
|
if duration>0 then
|
||||||
MESSAGE:New(text, duration):ToAllIf()
|
MESSAGE:New(text, duration):ToAll()
|
||||||
end
|
end
|
||||||
self:E(self.wid..text)
|
self:E(self.wid..text)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user