Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Navmarkup test
- NavMarkup = {}
- NavMarkup.data = {}
- NavMarkup.markup = {}
- NavMarkup.markup.vectorSectors={}
- NavMarkup.markup.roidSectors={}
- NavMarkup.markup.stormSectors={}
- function NavMarkup.GenMarkupTable(sysId) --Function to check systemnotes markup and generate markup based on this
- local sysnotes_import = LoadSystemNotes(sysId)
- local system_table = unspickle(sysnotes_import)
- NavMarkup.markup.vectorSectors={}
- NavMarkup.markup.roidSectors={} -- Clear the tables
- for i,v in pairs(system_table) do
- local comparison_string = string.lower(v)
- if string.find(comparison_string,"roid") then
- table.insert(NavMarkup.markup.roidSectors, i)
- end
- if string.find(comparison_string,"vector") then
- table.insert(NavMarkup.markup.vectorSectors, i)
- end
- end
- end
- NavMarkup.hazardColors = {
- "160 255 160", -- Vector
- "155 155 155", -- Unmarked Roid sector
- "20 20 200", -- Storm
- "20 20 200", -- The rest are just legacy stuff for making a hirearchical markup scheme - not sure if i will use it yet
- "20 20 200",
- "20 20 200",
- "20 20 200",
- }
- function NavMarkup:GetMapForSystem (sysId)
- local mapName
- mapName = string.format("lua/maps/system%02dmap.lua", sysId)
- local map = dofile (mapName)
- return mapName, map
- end
- function NavMarkup:CreateMapUI (sysId)
- local navmap = iup.navmap {}
- local mapName = NavMarkup:GetMapForSystem (sysId)
- navmap:loadmap (2, mapName, sysId-1)
- return navmap
- end
- NavMarkup.lastLoadedSysId = 0
- function NavMarkup:CreateNavmapUI (pdaTab)
- local navmap = pdaTab [1][1][1]
- local oldLoadMap = navmap.loadmap
- function navmap:loadmap (type, path, id)
- oldLoadMap (self, type, path, id)
- NavMarkup.lastLoadedSysId = 0
- NavMarkup.GenMarkupTable(id + 1)
- if type == 2 then
- NavMarkup.lastLoadedSysId = id + 1
- NavMarkup:PaintSystemHazards (navmap, id + 1, NavMarkup.markup.roidSectors, NavMarkup.markup.vectorSectors)
- end
- end
- end
- function NavMarkup:IsEncounteredVectorSector (s1)
- local result = false
- for i,v in pairs(NavMarkup.markup.vectorSectors) do
- local comparison_string = tostring(v)
- if string.find (comparison_string,s1) then
- result = true
- end
- end
- return result
- end
- -- Check record for hostile bots
- function NavMarkup:IsEncounteredRoidSector (s1)
- local result = false
- for i,v in pairs(NavMarkup.markup.roidSectors) do
- local comparison_string = tostring(v)
- if string.find (comparison_string,s1) then
- result = true
- end
- end
- return result
- end
- function NavMarkup:IsRecordedStormSector (s1)
- local result = false
- for i,v in pairs(NavMarkup.markup.stormSectors) do
- local comparison_string = tostring(v)
- if string.find (comparison_string,s1) then
- result = true
- end
- end
- return result
- end
- function NavMarkup:PaintSystemHazards (navmap, sysId, storms, bots)
- -- Paint all the storm sectors
- local sectorId, color, colorId
- local x, y
- for x = 1, 16 do
- for y = 1, 16 do
- color = 0
- sectorId = NavMarkup:BuildSectorId (sysId, x, y)
- if NavMarkup:IsEncounteredVectorSector (sectorId) then color = color + 1 end
- if NavMarkup:IsEncounteredRoidSector (sectorId) then color = color + 2 end
- if NavMarkup:IsRecordedStormSector (sectorId) then color = color + 4 end
- -- Set the sector color based on hazard
- if color > 0 then
- colorId = string.format ("COLOR%d", sectorId)
- navmap [colorId] = NavMarkup.hazardColors [color]
- end
- end
- end
- end
- function NavMarkup:RecordStorm (s1, inStation) -- Very basic, need to add timestamp functionality
- if not NavMarkup:IsRecordedStormSector(s1) then
- table.insert (NavMarkup.markup.stormSectors, s1)
- end
- end
- function NavMarkup:OnEvent (event, data)
- if event == "STORM_STARTED" then
- NavMarkup:RecordStorm (GetCurrentSectorid ())
- end
- end
- function NavMarkup:BuildLocationId (x, y)
- return 16 * (x - 1) + y
- end
- function NavMarkup:BuildSectorId (sysId, x, y)
- return 256 * (sysId-1) + NavMarkup:BuildLocationId (x, y)
- end
- function NavMarkup:test()
- NavMarkup:CreateNavmapUI (StationPDAShipNavigationTab)
- NavMarkup:CreateNavmapUI (PDAShipNavigationTab)
- NavMarkup:CreateNavmapUI (CapShipPDAShipNavigationTab)
- end
- NavMarkup:test()
- RegisterEvent (NavMarkup, "STORM_STARTED")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement