content
stringlengths
5
1.05M
local stone = 0 local grass = stone + 1 local grass2 = grass + 1 local grass3 = grass2 + 1 teal_tileset_core = -- Indexes for the normal map tileset, modify this if the tileset changes { { name = "stone", index = stone }, { name = "grass", index = grass }, { name = "grass2", index = grass2 }, { name = "grass3", index = grass3 }, } teal_fight_tileset_core = -- Indexes for the fight tileset, internally used by the MapComponent { -- This must not be modified walk = 0, empty = 1, red = 2, blue = 3 }
object_tangible_quest_outbreak_outbreak_facility_vent_02 = object_tangible_quest_outbreak_shared_outbreak_facility_vent_02:new { } ObjectTemplates:addTemplate(object_tangible_quest_outbreak_outbreak_facility_vent_02, "object/tangible/quest/outbreak/outbreak_facility_vent_02.iff")
--[[ Copyright (c) 2016 Technicolor Delivery Technologies, SAS The source code form of this Transformer component is subject to the terms of the Clear BSD license. You can redistribute it and/or modify it under the terms of the Clear BSD License (http://directory.fsf.org/wiki/License:ClearBSD) See LICENSE file for more details. ]] local proxy = require("datamodel-bck") local fd = assert(io.open("/proc/sys/kernel/random/uuid", "r")) local uuid = fd:read('*l') uuid = string.gsub(uuid,"-","") fd:close() local M = {} M.__index = function (table, key) local f = function(...) return proxy[key](uuid, ...) end table[key] = f return f end return setmetatable({},M)
local FrameCounter = require("frame_counter/frame_counter") local utils = require("utils/utils") local settings = require("settings/settings") local Action = require("controller/action") local Controller = {} function Controller:new(board) local controller = { board = board, frameCounters = { moveLeft = FrameCounter:new(1/settings.leftRightSpeed), moveRight = FrameCounter:new(1/settings.leftRightSpeed), moveDown = FrameCounter:new(1/settings.softDropSpeed), }, actions = { moveLeft = Action:new(settings.keyBindings.moveLeft, "self.board.movement:moveLeft()"), moveRight = Action:new(settings.keyBindings.moveRight, "self.board.movement:moveRight()"), moveDown = Action:new(settings.keyBindings.moveDown, "self.board.movement:moveDown()"), rotateCw = Action:new(settings.keyBindings.rotateCw, "self.board.movement:rotateCw()"), rotateCcw = Action:new(settings.keyBindings.rotateCcw, "self.board.movement:rotateCcw()"), hardDrop = Action:new(settings.keyBindings.hardDrop, "self.board.movement:hardDrop()"), hold = Action:new(settings.keyBindings.hold, "self.board:holdCurrentTetromino()"), } } self.__index = self setmetatable(controller, self) return controller end function Controller:run(action) if action ~= nil then loadstring("local self = ...; " .. self.actions[action].funcStr)(self) end end function Controller:handleNonRepeatKeys(key, scancode, isrepeat) self:run(utils.getKeyFromValue(settings.keyBindings, key)) end function Controller:handleRepeatKeys(frames) for action, _ in pairs(self.frameCounters) do if love.keyboard.isDown(settings.keyBindings[action]) then self.frameCounters[action]:add(frames) if self.frameCounters[action]:exceeds(settings.autoShiftDelay) then self.frameCounters[action]:subtract(self.frameCounters[action].maxFrames) self:run(action) end else self.frameCounters[action]:reset() end end end return Controller
local boxer = {} function boxer.new_box(boxes, font) local ret = {} table.insert(boxes, ret) ret.lines = {} ret.padding = 10 ret.line_height = 20 ret.width = 180 ret.color = { 50, 50, 50, 200 } ret.font = font return ret end function boxer.new_line(box, text, color) table.insert(box.lines, { color = color or { 0, 0, 0, 255 }, text = text }) end function boxer.draw(boxes) local function draw_box(box, position) love.graphics.setFont(box.font) love.graphics.setColor(box.color[1], box.color[2], box.color[3], box.color[4]) love.graphics.rectangle("fill", position.x, position.y, box.width + box.padding * 2, #box.lines * box.line_height + box.padding * 2) local last_color for i, line in ipairs(box.lines) do if line.color ~= last_color then love.graphics.setColor(line.color[1], line.color[2], line.color[3], line.color[4]) end love.graphics.print(line.text, position.x + box.padding, position.y + box.padding + (i-1) * box.line_height) end love.graphics.setColor(255, 255, 255, 255) end local offset = 0 for i, box in ipairs(boxes) do local position = { x = box.padding, y = box.padding } if i > 1 then local prev_box = boxes[i-1] position.y = #prev_box.lines * prev_box.line_height + prev_box.padding * 4 position.y = position.y + offset offset = position.y - box.padding end draw_box(box, position) end end return boxer
-- Holds custom descriptions for view-item-info -- Originally by PeridexisErrant -- Mod-specific overrides for The Earth Strikes Back! mod by Dirst --[[=begin item-descriptions ================= Exports a table with custom description text for every item in the game. Used by `view-item-info`; see instructions there for how to override for mods. =end]] -- Each line near the bottom has 53 characters of room until -- it starts clipping over the UI in an ugly fashion. -- For proper spacing, 50 characters is the maximum. -- Descriptions which aren't pushed down the page by -- barrel contents or such line up with the UI on the -- 11th line down. There is room for a 10th long line -- without clipping, but stopping at 9 leaves enough space -- for ideal legibility. -- The following people contributed descriptions: -- Raideau, PeridexisErrant, /u/Puffin4Tom, /u/KroyMortlach -- /u/genieus, /u/TeamsOnlyMedic, /u/johny5w, /u/DerTanni -- /u/schmee101, /u/coaldiamond, /u/stolencatkarma, /u/sylth01 -- /u/MperorM, /u/SockHoarder, /u/_enclave_, WesQ3 -- /u/Xen0nex, /u/Jurph if not moduleMode then print("scripts/more-item-descriptions.lua is a content library; calling it does nothing.") end local help --[[ This script has a single function: to return a custom description for certain items in The Earth Strikes Back! mod. If "raw/scripts/item-descriptions.lua" exists, it will entirely replace this one. Instead, mods should use "raw/scripts/more-item-descriptions.lua" to add content or replace descriptions on a case-by-case basis. If an item description cannot be found in the latter script, view-item-info will fall back to the former. ]] -- see http://dwarffortresswiki.org/index.php/cv:Item_token descriptions = { BLOCKS = { "Blocks can be used for constructions in place of raw materials such", "as logs or bars. Cutting boulders into blocks gives four times as", "many items, all of which are lighter for faster hauling and yield", "smooth constructions.", "Three blocks of the same layer stone can be used to build a Tribute."}, BOULDER = { "Mining may yield loose stones for industry. There are four categories:", "non-economic stones for building materials, ores for metal industry,", "gems, and special-purpose economic stones like flux/coal/lignite.", "An Awakened Stone that is slain will revert to a normal boulder."}, GEM = { "A large gem. It can be sacrificed at a Tribute or used as a trade good."}, ROCK = { "A small rock, sharpened as a weapon in Adventure mode.", "A Pet Rock that is slain will revert to a normal rock."}, ROUGH = { "Rough gemstones and raw glass are cut by a Gem Cutter at a Jeweler's", "Workshop into small decorative gems.", "A miner can attempt to extract a Gem Seed from a rough Hidden Gem in an", "appropriate Tribute.", "A cut Hidden Gem can be sacrificed at an appropriate Tribute."}, SMALLGEM = {"Cut gemstones and the odd gizzard stone (a product of butchering", "certain species of animals) are used by a Gem Setter to decorate items", "at a Jeweler's Workshop.", "A cut Hidden Gem can be sacrificed at a Tribute of the associated ", "layer stone."} }
-- autocmd BufWritePre <buffer> <cmd>EslintFixAll<CR> require'lspconfig'.eslint.setup{ -- on_attach = require('lsp').on_attach, } -- capabilities = require('coq').capabilities, -- require'lspconfig'.eslint.setup(require "coq".lsp_ensure_capabilities())
-- 補充lua沒有的數學庫 local math = math local Math = { __index = math, e = math.exp(1) } setmetatable(Math, Math) function Math.round(num) if num >= 0 then return math.floor(num + 0.5) else return math.ceil(num - 0.5) end end -- 無參數 產生(0, 1)的隨機整數 -- 只有參數n 產生[1, n]的隨機整數 -- 兩個參數 產生[n, m]的隨機整數 -- n, m 非整數會報錯 math.randomseed(tonumber(tostring(os.time()):reverse():sub(1, 6))) function Math.rand(n, m) local modf = math.modf if not n then return math.random() end if not m then n = modf(n) return math.random(n) end n = modf(n) m = modf(m) return math.random(n, m) end -- 確認值是否超出最大或最小值 function Math.bound(value_min, value, value_max) -- 沒有上下限,直接回傳值 if not (value_min or value_max) then return value end if not value_min then return math.min(value_max, value) end if not value_max then return math.max(value_min, value) end return math.min(value_max, math.max(value_min, value)) end -- 此函數計算最大公因數(GreatestCommonFactor) -- 遞歸比起for會慢很多,這裡把較大的數當作迴圈次數,才不會出現迴圈結束卻還沒得到結果的問題 function Math.gcf(num1, num2) local big_num, small_num if num1 > num2 then big_num = num1 small_num = num2 else big_num = num2 small_num = num1 end for i = 1, big_num do big_num = big_num % small_num if big_num == 0 then return small_num end -- 保證big_num > small_num big_num, small_num = small_num, big_num end end function Math.angle(s_x, s_y, t_x, t_y) local theta = math.atan(t_y - s_y, t_x - s_x) return theta < 0 and 2 * math.pi + theta or theta end function Math.inRange(x, lower, higher) return (x >= lower) and x <= higher end -- 以p為起點,向右作一條射線,看射線跟邊相交的點的數量是奇還偶 function Math.inPolygon(p, points) local in_poly = false -- 奇數次表示在裡面,偶數次表示在外面 local next, x for i, pt in ipairs(points) do next = points[i == #points and 1 or i+1] -- 點在頂點上 if (p.x == pt.x and p.y == pt.y) or (p.x ==next.x and p.y == next.y) then return true end -- 點經過水平的邊不算 -- 點的y座標比兩端點都低或都高,都代表碰不到邊 -- 如果經過頂點,會把頂點歸類在射線的上側 if p.y > math.min(pt.y, next.y) and p.y <= math.max(pt.y, next.y) then -- 射線與線段相交的x x = pt.x + (p.y - pt.y) * (next.x - pt.x) / (next.y - pt.y) -- 點在線上 if x == p.x then return true end -- 透過判斷射線起始點在預期的x的左右邊,可以知道它有無跨過線段 if x > p.x then in_poly = not in_poly end end end return in_poly end return Math
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]] require("lualib_bundle"); local ____exports = {} local ____log = require("lib.log") local Log = ____log.default local ____game = require("lib.game") local getPlayers = ____game.getPlayers local ____player_2Ddata = require("data.player-data") local getPlayerData = ____player_2Ddata.getPlayerData local initPlayer = ____player_2Ddata.initPlayer local ____global_2Dsave_2Ddata = require("data.global-save-data") local Global = ____global_2Dsave_2Ddata.default local ____resource_2Dsite_2Dcreator = require("lib.resource-site-creator") local clearDraftResourceSite = ____resource_2Dsite_2Dcreator.clearDraftResourceSite local finalizeResourceSite = ____resource_2Dsite_2Dcreator.finalizeResourceSite local registerResourceSite = ____resource_2Dsite_2Dcreator.registerResourceSite local scanResourceSite = ____resource_2Dsite_2Dcreator.scanResourceSite local ____settings_2Ddata = require("data.settings-data") local SettingsData = ____settings_2Ddata.default ____exports.ResourceTracker = __TS__Class() local ResourceTracker = ____exports.ResourceTracker ResourceTracker.name = "ResourceTracker" function ResourceTracker.prototype.____constructor(self) end function ResourceTracker.prototype.OnTick(self, event) local forceKeys = __TS__ObjectKeys(Global.forceData) local ticksBetweenChecks = SettingsData.TickBetweenChecks local currentTick = event.tick for ____, forceKey in ipairs(forceKeys) do local resourceSites = Global.forceData[forceKey].resourceSites for ____, resourceSite in __TS__Iterator(resourceSites) do if currentTick - resourceSite.lastResourceCheckTick > ticksBetweenChecks then local totalAmount = 0 for ____, ____value in ipairs(__TS__ObjectEntries(resourceSite.trackedPositionKeys)) do local key = ____value[1] local value = ____value[2] totalAmount = totalAmount + Global.trackedResources[key].resourceAmount end resourceSite.totalAmount = totalAmount end end end end function ResourceTracker.prototype.updateResourceAmounts(self) local cacheIteration = Global.cacheIteration if not cacheIteration then return end if not cacheIteration.force then end do local i = 0 while i < 50 do i = i + 1 end end end function ResourceTracker.prototype.updatePlayers(self, event) if not Global.valid or not Global.playerData then Log:warnAll("updatePlayers() => Either Global or Global.playerData was invalid") return end local players = getPlayers(nil) for ____, player in ipairs(players) do local playerData = getPlayerData(nil, player.index) if not playerData then initPlayer(nil, player.index) playerData = getPlayerData(nil, player.index) elseif not player.connected and playerData.draftResourceSite then clearDraftResourceSite(nil, player.index) end local ____playerData_draftResourceSite_0 = playerData if ____playerData_draftResourceSite_0 ~= nil then ____playerData_draftResourceSite_0 = ____playerData_draftResourceSite_0.draftResourceSite end if ____playerData_draftResourceSite_0 then local resourceSite = playerData.draftResourceSite if #resourceSite.nextToScan > 0 then scanResourceSite(nil, player.index) elseif not resourceSite.finalizing then finalizeResourceSite(nil, player.index) elseif resourceSite.finalizingSince + 120 == event.tick then registerResourceSite(nil, player.index) end if resourceSite.isOverlayBeingCreated then self:processOverlayForExistingResourceSite(player.index) end end if playerData and event.tick % playerData.guiUpdateTicks == 15 + player.index then self:updateUi(player.index) end end end function ResourceTracker.prototype.updateUi(self, playerIndex) end function ResourceTracker.prototype.processOverlayForExistingResourceSite(self, index) end local resourceCache = __TS__New(____exports.ResourceTracker) ____exports.default = resourceCache return ____exports
local data local ffi if type(rawget(_G, "jit")) == 'table' then ffi = require("ffi") data = ffi.new("char[32768]") else data = {} local i = 0 while i < 32768 do data[i] = 0 i = i + 1 end end local i = 0 local w = function(c) io.write(string.char(c)) end local r = function() return io.read(1):byte() end i = i + 121 data[i] = 0 i = i + 41 data[i] = 0 i = i + 41 data[i] = 0 i = i + 41 data[i] = 0 i = i + 1 data[i] = 27 w(data[i]) data[i] = data[i] + 64 w(data[i]) data[i] = data[i] - 19 w(data[i]) data[i] = data[i] - 45 w(data[i]) data[i] = data[i] + 64 w(data[i]) data[i] = data[i] - 41 w(data[i]) data[i] = data[i] + 24 w(data[i]) data[i] = 27 w(data[i]) data[i] = data[i] + 64 w(data[i]) data[i] = data[i] - 41 w(data[i]) data[i] = data[i] + 9 w(data[i]) data[i] = data[i] - 9 w(data[i]) data[i] = data[i] + 5 w(data[i]) data[i] = data[i] + 17 w(data[i]) data[i] = data[i] + 12 w(data[i]) data[i] = data[i] + 27 w(data[i]) data[i] = data[i] + 8 w(data[i]) data[i] = data[i] - 18 w(data[i]) data[i] = data[i] + 13 w(data[i]) data[i] = data[i] + 1 w(data[i]) data[i] = data[i] - 83 w(data[i]) data[i] = data[i] + 79 w(data[i]) data[i] = data[i] - 9 w(data[i]) data[i] = data[i] - 70 w(data[i]) data[i] = data[i] + 40 w(data[i]) data[i] = data[i] + 25 w(data[i]) data[i] = data[i] + 13 w(data[i]) data[i] = data[i] + 1 w(data[i]) data[i] = data[i] - 6 w(data[i]) data[i] = data[i] - 73 w(data[i]) data[i] = data[i] + 73 w(data[i]) data[i] = data[i] + 5 w(data[i]) data[i] = data[i] - 78 w(data[i]) data[i] = data[i] + 34 w(data[i]) data[i] = data[i] + 48 w(data[i]) data[i] = data[i] - 17 w(data[i]) data[i] = data[i] + 8 w(data[i]) data[i] = data[i] + 5 w(data[i]) data[i] = data[i] - 8 w(data[i]) data[i] = data[i] - 60 w(data[i]) data[i] = data[i] + 57 w(data[i]) data[i] = data[i] + 8 w(data[i]) data[i] = 27 w(data[i]) data[i] = data[i] + 64 w(data[i]) data[i] = data[i] - 40 w(data[i]) data[i] = data[i] + 8 w(data[i]) data[i] = data[i] - 10 w(data[i]) data[i] = data[i] + 4 w(data[i]) data[i] = data[i] + 19 w(data[i]) data[i] = data[i] + 15 w(data[i]) data[i] = data[i] + 27 w(data[i]) data[i] = data[i] - 9 w(data[i]) data[i] = data[i] + 11 w(data[i]) w(data[i]) data[i] = data[i] - 15 w(data[i]) data[i] = data[i] + 9 w(data[i]) data[i] = data[i] - 78 w(data[i]) data[i] = data[i] + 66 w(data[i]) data[i] = data[i] + 23 w(data[i]) data[i] = data[i] - 89 w(data[i]) data[i] = data[i] + 35 w(data[i]) data[i] = data[i] + 41 w(data[i]) data[i] = data[i] - 3 w(data[i]) data[i] = data[i] - 3 w(data[i]) w(data[i]) data[i] = data[i] + 9 w(data[i]) data[i] = data[i] + 3 w(data[i]) data[i] = data[i] - 14 w(data[i]) data[i] = data[i] - 68 w(data[i]) data[i] = data[i] + 55 w(data[i]) data[i] = data[i] + 24 w(data[i]) data[i] = data[i] - 3 w(data[i]) data[i] = data[i] - 6 w(data[i]) data[i] = data[i] - 70 w(data[i]) data[i] = data[i] + 28 w(data[i]) data[i] = data[i] + 44 w(data[i]) data[i] = data[i] + 12 w(data[i]) w(data[i]) data[i] = data[i] - 4 w(data[i]) data[i] = data[i] - 54 w(data[i]) data[i] = data[i] - 11 w(data[i]) w(data[i]) data[i] = data[i] + 72 w(data[i]) w(data[i]) w(data[i]) data[i] = data[i] - 73 w(data[i]) data[i] = data[i] + 53 w(data[i]) data[i] = data[i] + 9 w(data[i]) data[i] = data[i] - 3 w(data[i]) data[i] = data[i] - 3 w(data[i]) w(data[i]) data[i] = data[i] + 9 w(data[i]) data[i] = data[i] + 3 w(data[i]) data[i] = data[i] - 14 w(data[i]) data[i] = data[i] - 54 w(data[i]) data[i] = data[i] + 51 w(data[i]) data[i] = data[i] + 19 w(data[i]) data[i] = data[i] - 69 w(data[i]) data[i] = data[i] + 51 w(data[i]) data[i] = data[i] + 4 w(data[i]) data[i] = data[i] - 3 w(data[i]) data[i] = data[i] + 13 w(data[i]) data[i] = data[i] + 5 w(data[i]) data[i] = data[i] - 70 w(data[i]) data[i] = data[i] + 15 w(data[i]) data[i] = 0 i = i + 1 data[i] = 9 i = i + 1 data[i] = 3 i = i + 2 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 2 data[i] = 0 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 1 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 1 i = i + 3 end i = i - 3 while data[i] ~= 0 do i = i + 1 data[i] = 45 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = data[i] + 43 i = i + 1 end i = i - 3 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = data[i] - 1 i = i + 3 end data[i] = 16 i = i + 1 data[i] = 14 i = i + 4 data[i] = 0 i = i + 1 data[i] = 0 i = i - 9 if (data[i] ~= 0) then data[i + 9] = data[i + 9] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 9 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 9] = data[i - 9] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i - 4 data[i] = data[i] + 5 i = i + 4 end ffi.fill(data + i + 1, 2, 0) i = i - 7 if (data[i] ~= 0) then data[i + 9] = data[i + 9] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 9 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 9] = data[i - 9] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 1 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i - 3 data[i] = data[i] + 10 i = i + 3 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 8 if (data[i] ~= 0) then data[i + 8] = data[i + 8] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 8 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 8] = data[i - 8] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 25 i = i - 3 data[i] = 0 i = i + 2 while data[i] ~= 0 do i = i + 2 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = data[i] - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 8 if (data[i] ~= 0) then data[i + 8] = data[i + 8] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 8 if (data[i] ~= 0) then data[i - 8] = data[i - 8] + (-(data[i] / -1)) * 1 data[i - 4] = data[i - 4] + (-(data[i] / -1)) * -1 data[i] = 0 end data[i] = 0 i = i - 8 if (data[i] ~= 0) then data[i + 8] = data[i + 8] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 8 if (data[i] ~= 0) then data[i - 8] = data[i - 8] + (-(data[i] / -1)) * 1 data[i - 4] = data[i - 4] + (-(data[i] / -1)) * -1 data[i] = 0 end ffi.fill(data + i + 1, 2, 0) i = i - 7 if (data[i] ~= 0) then data[i + 9] = data[i + 9] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 9 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 9] = data[i - 9] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 2 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i - 4 data[i] = data[i] - 5 i = i + 4 end data[i] = 0 i = i - 9 if (data[i] ~= 0) then data[i + 9] = data[i + 9] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 9 if (data[i] ~= 0) then data[i - 9] = data[i - 9] + (-(data[i] / -1)) * 1 data[i - 3] = data[i - 3] + (-(data[i] / -1)) * -1 data[i] = 0 end data[i] = 27 w(data[i]) data[i] = data[i] + 64 w(data[i]) ffi.fill(data + i + 1, 2, 0) i = i - 3 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 3 data[i] = 0 i = i + 6 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 7] = data[i - 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 5] = data[i - 5] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 2 data[i] = 0 i = i + 5 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 6] = data[i - 6] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 1 data[i] = 0 i = i + 4 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 data[i] = 1 i = i - 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i + 4 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 data[i] = 1 i = i - 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i + 6 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i - 6 data[i] = data[i] + 48 w(data[i]) i = i + 6 end i = i - 2 end i = i - 6 data[i] = data[i] - 32 w(data[i]) ffi.fill(data + i + 1, 2, 0) i = i - 4 if (data[i] ~= 0) then data[i + 6] = data[i + 6] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 6 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 6] = data[i - 6] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 3 data[i] = 0 i = i + 6 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 7] = data[i - 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 5] = data[i - 5] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 2 data[i] = 0 i = i + 5 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 6] = data[i - 6] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 1 data[i] = 0 i = i + 4 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 data[i] = 1 i = i - 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i + 4 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 data[i] = 1 i = i - 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i + 6 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i - 6 data[i] = data[i] + 48 w(data[i]) i = i + 6 end i = i - 2 end i = i - 6 data[i] = data[i] + 13 w(data[i]) ffi.fill(data + i + 1, 2, 0) i = i - 5 if (data[i] ~= 0) then data[i + 7] = data[i + 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 7 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 7] = data[i - 7] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 88 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 2 data[i] = 1 i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i + 2 data[i] = 120 w(data[i]) i = i - 1 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i - 6 w(data[i]) i = i + 6 end i = i - 1 data[i] = 0 i = i - 8 if (data[i] ~= 0) then data[i + 8] = data[i + 8] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 6 data[i] = 0 i = i + 2 if (data[i] ~= 0) then data[i - 8] = data[i - 8] + (-(data[i] / -1)) * 1 data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = data[i] - 1 i = i + 2 end i = i - 2 while data[i] ~= 0 do i = i - 3 w(data[i]) w(data[i]) i = i + 3 data[i] = data[i] - 1 end i = i - 3 w(data[i]) i = i + 5 data[i] = 0 i = i - 8 if (data[i] ~= 0) then data[i + 8] = data[i + 8] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 6 data[i] = 0 i = i + 2 if (data[i] ~= 0) then data[i - 8] = data[i - 8] + (-(data[i] / -1)) * 1 data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = data[i] - 1 i = i + 2 end i = i - 2 while data[i] ~= 0 do i = i - 3 w(data[i]) w(data[i]) i = i + 3 data[i] = data[i] - 1 end i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 7 if (data[i] ~= 0) then data[i + 7] = data[i + 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 7 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 7] = data[i - 7] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 88 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 2 data[i] = 1 i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i + 2 data[i] = 120 w(data[i]) i = i - 1 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i - 6 w(data[i]) i = i + 6 end i = i - 8 end i = i + 3 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 7 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 0 i = i + 10 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 8] = data[i - 8] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 48 if (data[i] ~= 0) then data[i + 48] = data[i + 48] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 48 if (data[i] ~= 0) then data[i - 48] = data[i - 48] + (-(data[i] / -1)) * 1 data[i - 9] = data[i - 9] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 9 while data[i] ~= 0 do i = i - 3 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 1 i = i + 6 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = data[i] - 1 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 end i = i - 2 data[i] = 0 i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 while data[i] ~= 0 do i = i + 4 end i = i - 38 data[i] = data[i] + 1 i = i + 48 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 5 data[i] = data[i] - 1 i = i + 5 end i = i - 1 end i = i - 5 data[i] = data[i] + 1 i = i + 2 data[i] = 1 i = i + 2 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 2 data[i] = 0 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 1 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 1 i = i + 3 end i = i - 3 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 1 i = i + 1 data[i] = 2 i = i + 1 data[i] = 8 ffi.fill(data + i + 1, 2, 1) i = i + 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 4 i = i - 2 data[i] = 0 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 1 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 1 i = i + 3 end i = i - 3 while data[i] ~= 0 do i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end ffi.fill(data + i + 1, 3, 0) i = i + 5 data[i] = 0 i = i + 1 data[i] = 0 i = i - 10 if (data[i] ~= 0) then data[i + 10] = data[i + 10] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 10 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 10] = data[i - 10] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 1 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i - 3 data[i] = 1 i = i + 1 data[i] = 1 i = i + 2 end ffi.fill(data + i + 1, 2, 0) i = i - 8 if (data[i] ~= 0) then data[i + 10] = data[i + 10] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 10 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 10] = data[i - 10] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 3 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i - 3 data[i] = 1 i = i + 2 data[i] = 1 i = i + 1 end data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 2 data[i] = 0 i = i - 15 if (data[i] ~= 0) then data[i + 15] = data[i + 15] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 14 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 15] = data[i - 15] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 14 if (data[i] ~= 0) then data[i + 14] = data[i + 14] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 13 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 14] = data[i - 14] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 3 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 13 if (data[i] ~= 0) then data[i + 13] = data[i + 13] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 12 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 13] = data[i - 13] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 9 data[i] = 0 end i = i - 219 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 0 i = i + 222 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 220] = data[i - 220] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 16 if (data[i] ~= 0) then data[i + 16] = data[i + 16] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 16 if (data[i] ~= 0) then data[i - 16] = data[i - 16] + (-(data[i] / -1)) * 1 data[i - 221] = data[i - 221] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 221 while data[i] ~= 0 do i = i - 3 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 1 i = i + 6 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = data[i] - 1 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 end i = i - 2 data[i] = 0 i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 while data[i] ~= 0 do i = i + 4 end i = i + 42 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 0 i = i + 182 data[i] = 0 i = i - 12 if (data[i] ~= 0) then data[i + 12] = data[i + 12] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 12 if (data[i] ~= 0) then data[i - 12] = data[i - 12] + (-(data[i] / -1)) * 1 data[i - 180] = data[i - 180] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 16 if (data[i] ~= 0) then data[i + 16] = data[i + 16] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 16 if (data[i] ~= 0) then data[i - 16] = data[i - 16] + (-(data[i] / -1)) * 1 data[i - 181] = data[i - 181] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 181 while data[i] ~= 0 do i = i - 3 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 1 i = i + 6 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = data[i] - 1 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 end i = i - 2 data[i] = 0 i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 while data[i] ~= 0 do i = i + 4 end i = i + 42 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 0 i = i + 142 data[i] = 0 i = i - 11 if (data[i] ~= 0) then data[i + 11] = data[i + 11] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 11 if (data[i] ~= 0) then data[i - 140] = data[i - 140] + (-(data[i] / -1)) * 1 data[i - 11] = data[i - 11] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 16 if (data[i] ~= 0) then data[i + 16] = data[i + 16] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 16 if (data[i] ~= 0) then data[i - 16] = data[i - 16] + (-(data[i] / -1)) * 1 data[i - 141] = data[i - 141] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 141 while data[i] ~= 0 do i = i - 3 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 1 i = i + 6 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = data[i] - 1 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 end i = i - 2 data[i] = 0 i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 while data[i] ~= 0 do i = i + 4 end i = i + 126 data[i] = data[i] + 1 i = i + 13 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 12 if (data[i] ~= 0) then data[i + 12] = data[i + 12] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 data[i] = 0 i = i + 7 if (data[i] ~= 0) then data[i - 12] = data[i - 12] + (-(data[i] / -1)) * 1 data[i - 7] = data[i - 7] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 11 if (data[i] ~= 0) then data[i + 11] = data[i + 11] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 12 if (data[i] ~= 0) then data[i - 12] = data[i - 12] + (-(data[i] / -1)) * 1 data[i - 11] = data[i - 11] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 7 if (data[i] ~= 0) then data[i + 7] = data[i + 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 data[i] = 0 i = i + 11 if (data[i] ~= 0) then data[i - 11] = data[i - 11] + (-(data[i] / -1)) * 1 data[i - 7] = data[i - 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 10 data[i] = data[i] - 1 i = i + 1 data[i] = 0 i = i + 1 data[i] = data[i] + 1 i = i + 7 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 12 if (data[i] ~= 0) then data[i + 12] = data[i + 12] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 data[i] = 0 i = i + 7 if (data[i] ~= 0) then data[i - 12] = data[i - 12] + (-(data[i] / -1)) * 1 data[i - 7] = data[i - 7] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 13 if (data[i] ~= 0) then data[i + 13] = data[i + 13] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 12 if (data[i] ~= 0) then data[i - 13] = data[i - 13] + (-(data[i] / -1)) * 1 data[i - 12] = data[i - 12] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 7 if (data[i] ~= 0) then data[i + 7] = data[i + 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 6 data[i] = 0 i = i + 13 if (data[i] ~= 0) then data[i - 13] = data[i - 13] + (-(data[i] / -1)) * 1 data[i - 7] = data[i - 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 10 data[i] = data[i] - 1 i = i + 1 data[i] = 0 i = i + 1 data[i] = data[i] + 1 i = i + 7 end i = i - 4 end ffi.fill(data + i + 1, 2, 0) i = i - 4 if (data[i] ~= 0) then data[i + 6] = data[i + 6] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 6 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 6] = data[i - 6] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 2 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i + 4 data[i] = 2 i = i + 2 data[i] = 0 i = i + 1 data[i] = 0 i = i - 15 if (data[i] ~= 0) then data[i + 15] = data[i + 15] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 15 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 15] = data[i - 15] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i + 1 data[i] = 0 i = i - 56 if (data[i] ~= 0) then data[i + 56] = data[i + 56] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 52 data[i] = 0 i = i + 4 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i - 56] = data[i - 56] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 end ffi.fill(data + i + 1, 2, 0) i = i - 13 if (data[i] ~= 0) then data[i + 15] = data[i + 15] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 15 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 15] = data[i - 15] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 1 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i + 1 data[i] = 0 i = i - 138 if (data[i] ~= 0) then data[i + 138] = data[i + 138] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 134 data[i] = 0 i = i + 4 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i - 138] = data[i - 138] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 end ffi.fill(data + i + 1, 2, 0) i = i - 13 if (data[i] ~= 0) then data[i + 15] = data[i + 15] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 15 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 15] = data[i - 15] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 2 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i + 1 data[i] = 0 i = i - 97 if (data[i] ~= 0) then data[i + 97] = data[i + 97] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 93 data[i] = 0 i = i + 4 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i - 97] = data[i - 97] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 end ffi.fill(data + i + 1, 2, 0) i = i - 13 if (data[i] ~= 0) then data[i + 15] = data[i + 15] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 15 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 15] = data[i - 15] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i - 55 data[i] = data[i] - 1 i = i + 40 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 0 i = i + 13 data[i] = 0 i = i + 5 data[i] = 0 i = i - 56 if (data[i] ~= 0) then data[i + 56] = data[i + 56] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 56 if (data[i] ~= 0) then data[i - 17] = data[i - 17] + (-(data[i] / -1)) * 1 data[i - 56] = data[i - 56] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 17 while data[i] ~= 0 do i = i - 3 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 1 i = i + 5 data[i] = data[i] - 1 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 end i = i - 2 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 while data[i] ~= 0 do i = i + 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 end i = i + 2 if (data[i] ~= 0) then data[i + 11] = data[i + 11] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 15 end ffi.fill(data + i + 1, 2, 0) i = i - 13 if (data[i] ~= 0) then data[i + 15] = data[i + 15] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 15 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 15] = data[i - 15] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 1 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i - 137 data[i] = data[i] - 1 i = i + 40 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 0 i = i + 95 data[i] = 0 i = i + 5 data[i] = 0 i = i - 138 if (data[i] ~= 0) then data[i + 138] = data[i + 138] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 138 if (data[i] ~= 0) then data[i - 99] = data[i - 99] + (-(data[i] / -1)) * 1 data[i - 138] = data[i - 138] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 99 while data[i] ~= 0 do i = i - 3 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 1 i = i + 5 data[i] = data[i] - 1 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 end i = i - 2 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 while data[i] ~= 0 do i = i + 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 end i = i + 2 if (data[i] ~= 0) then data[i + 93] = data[i + 93] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 97 end ffi.fill(data + i + 1, 2, 0) i = i - 13 if (data[i] ~= 0) then data[i + 15] = data[i + 15] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 15 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 15] = data[i - 15] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 2 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i - 96 data[i] = data[i] - 1 i = i + 40 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 0 i = i + 54 data[i] = 0 i = i + 5 data[i] = 0 i = i - 97 if (data[i] ~= 0) then data[i + 97] = data[i + 97] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 97 if (data[i] ~= 0) then data[i - 58] = data[i - 58] + (-(data[i] / -1)) * 1 data[i - 97] = data[i - 97] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 58 while data[i] ~= 0 do i = i - 3 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 1 i = i + 5 data[i] = data[i] - 1 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 end i = i - 2 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 while data[i] ~= 0 do i = i + 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 end i = i + 2 if (data[i] ~= 0) then data[i + 52] = data[i + 52] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 56 end ffi.fill(data + i + 1, 2, 0) i = i - 11 if (data[i] ~= 0) then data[i + 13] = data[i + 13] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 13 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 13] = data[i - 13] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i - 15 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 0 i = i + 18 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 16] = data[i - 16] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 56 if (data[i] ~= 0) then data[i + 56] = data[i + 56] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 56 if (data[i] ~= 0) then data[i - 17] = data[i - 17] + (-(data[i] / -1)) * 1 data[i - 56] = data[i - 56] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 17 while data[i] ~= 0 do i = i - 3 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 1 i = i + 6 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = data[i] - 1 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 end i = i - 2 data[i] = 0 i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 while data[i] ~= 0 do i = i + 4 end i = i - 38 data[i] = data[i] + 1 i = i + 55 end ffi.fill(data + i + 1, 2, 0) i = i - 11 if (data[i] ~= 0) then data[i + 13] = data[i + 13] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 13 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 13] = data[i - 13] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 1 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i - 97 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 0 i = i + 100 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 98] = data[i - 98] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 138 if (data[i] ~= 0) then data[i + 138] = data[i + 138] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 138 if (data[i] ~= 0) then data[i - 99] = data[i - 99] + (-(data[i] / -1)) * 1 data[i - 138] = data[i - 138] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 99 while data[i] ~= 0 do i = i - 3 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 1 i = i + 6 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = data[i] - 1 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 end i = i - 2 data[i] = 0 i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 while data[i] ~= 0 do i = i + 4 end i = i - 38 data[i] = data[i] + 1 i = i + 137 end ffi.fill(data + i + 1, 2, 0) i = i - 11 if (data[i] ~= 0) then data[i + 13] = data[i + 13] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 13 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 13] = data[i - 13] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 2 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i - 56 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 0 i = i + 59 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 57] = data[i - 57] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 97 if (data[i] ~= 0) then data[i + 97] = data[i + 97] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 97 if (data[i] ~= 0) then data[i - 58] = data[i - 58] + (-(data[i] / -1)) * 1 data[i - 97] = data[i - 97] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 58 while data[i] ~= 0 do i = i - 3 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 1 i = i + 6 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = data[i] - 1 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 end i = i - 2 data[i] = 0 i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 while data[i] ~= 0 do i = i + 4 end i = i - 38 data[i] = data[i] + 1 i = i + 96 end ffi.fill(data + i + 1, 2, 0) i = i - 11 if (data[i] ~= 0) then data[i + 13] = data[i + 13] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 13 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 13] = data[i - 13] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i + 1 data[i] = 0 i = i - 56 if (data[i] ~= 0) then data[i + 56] = data[i + 56] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 53 data[i] = 0 i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 56] = data[i - 56] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 end ffi.fill(data + i + 1, 2, 0) i = i - 11 if (data[i] ~= 0) then data[i + 13] = data[i + 13] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 13 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 13] = data[i - 13] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 1 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i + 1 data[i] = 0 i = i - 138 if (data[i] ~= 0) then data[i + 138] = data[i + 138] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 135 data[i] = 0 i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 138] = data[i - 138] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 end ffi.fill(data + i + 1, 2, 0) i = i - 11 if (data[i] ~= 0) then data[i + 13] = data[i + 13] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 13 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 13] = data[i - 13] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 2 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i + 1 data[i] = 0 i = i - 97 if (data[i] ~= 0) then data[i + 97] = data[i + 97] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 94 data[i] = 0 i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 97] = data[i - 97] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 end i = i - 1 while data[i] ~= 0 do data[i] = data[i] - 1 i = i + 4 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 data[i] = 1 i = i - 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 data[i] = 0 i = i - 18 if (data[i] ~= 0) then data[i + 18] = data[i + 18] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 13 data[i] = 0 i = i + 5 if (data[i] ~= 0) then data[i - 18] = data[i - 18] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 8 if (data[i] ~= 0) then data[i + 8] = data[i + 8] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 data[i] = 0 i = i + 4 if (data[i] ~= 0) then data[i - 8] = data[i - 8] + (-(data[i] / -1)) * 1 data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 32 i = i + 2 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i + 1 data[i] = 0 i = i - 16 if (data[i] ~= 0) then data[i + 16] = data[i + 16] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 11 data[i] = 0 i = i + 5 if (data[i] ~= 0) then data[i - 16] = data[i - 16] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 7 if (data[i] ~= 0) then data[i + 7] = data[i + 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 data[i] = 0 i = i + 4 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i - 7] = data[i - 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 88 i = i + 2 end i = i - 1 data[i] = 16 i = i + 1 data[i] = 14 i = i + 4 data[i] = 0 i = i + 1 data[i] = 0 i = i - 9 if (data[i] ~= 0) then data[i + 9] = data[i + 9] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 9 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 9] = data[i - 9] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i - 4 data[i] = data[i] + 5 i = i + 4 end ffi.fill(data + i + 1, 2, 0) i = i - 7 if (data[i] ~= 0) then data[i + 9] = data[i + 9] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 9 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 9] = data[i - 9] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 1 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i - 3 data[i] = data[i] + 10 i = i + 3 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 8 if (data[i] ~= 0) then data[i + 8] = data[i + 8] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 8 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 8] = data[i - 8] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 25 i = i - 3 data[i] = 0 i = i + 2 while data[i] ~= 0 do i = i + 2 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = data[i] - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 11 if (data[i] ~= 0) then data[i + 11] = data[i + 11] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 11 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * -1 data[i - 11] = data[i - 11] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 11 if (data[i] ~= 0) then data[i + 11] = data[i + 11] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 11 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * -1 data[i - 11] = data[i - 11] + (-(data[i] / -1)) * 1 data[i] = 0 end ffi.fill(data + i + 1, 2, 0) i = i - 7 if (data[i] ~= 0) then data[i + 9] = data[i + 9] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 9 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 9] = data[i - 9] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 2 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 3 while data[i] ~= 0 do data[i] = 0 i = i - 4 data[i] = data[i] - 5 i = i + 4 end data[i] = 0 i = i - 6 if (data[i] ~= 0) then data[i + 6] = data[i + 6] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 6 if (data[i] ~= 0) then data[i - 6] = data[i - 6] + (-(data[i] / -1)) * 1 data[i - 3] = data[i - 3] + (-(data[i] / -1)) * -1 data[i] = 0 end data[i] = 27 w(data[i]) data[i] = data[i] + 64 w(data[i]) ffi.fill(data + i + 1, 2, 0) i = i - 3 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 3 data[i] = 0 i = i + 6 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 7] = data[i - 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 5] = data[i - 5] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 2 data[i] = 0 i = i + 5 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 6] = data[i - 6] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 1 data[i] = 0 i = i + 4 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 data[i] = 1 i = i - 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i + 4 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 data[i] = 1 i = i - 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i + 6 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i - 6 data[i] = data[i] + 48 w(data[i]) i = i + 6 end i = i - 2 end i = i - 6 data[i] = data[i] - 32 w(data[i]) ffi.fill(data + i + 1, 2, 0) i = i - 4 if (data[i] ~= 0) then data[i + 6] = data[i + 6] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 6 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 6] = data[i - 6] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 3 data[i] = 0 i = i + 6 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 7] = data[i - 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 5] = data[i - 5] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 2 data[i] = 0 i = i + 5 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 6] = data[i - 6] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 1 data[i] = 0 i = i + 4 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 data[i] = 1 i = i - 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i + 4 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 data[i] = 1 i = i - 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i + 6 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i - 6 data[i] = data[i] + 48 w(data[i]) i = i + 6 end i = i - 2 end i = i - 6 data[i] = data[i] + 13 w(data[i]) ffi.fill(data + i + 1, 2, 0) i = i - 5 if (data[i] ~= 0) then data[i + 7] = data[i + 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 7 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 7] = data[i - 7] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 88 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 2 data[i] = 1 i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i + 2 data[i] = 120 w(data[i]) i = i - 1 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i - 6 w(data[i]) i = i + 6 end i = i - 1 data[i] = 0 i = i - 11 if (data[i] ~= 0) then data[i + 11] = data[i + 11] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 9 data[i] = 0 i = i + 2 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 11] = data[i - 11] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = data[i] - 1 i = i + 2 end i = i - 2 while data[i] ~= 0 do i = i - 3 w(data[i]) w(data[i]) i = i + 3 data[i] = data[i] - 1 end i = i - 3 w(data[i]) i = i + 5 data[i] = 0 i = i - 11 if (data[i] ~= 0) then data[i + 11] = data[i + 11] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 9 data[i] = 0 i = i + 2 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 11] = data[i - 11] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = data[i] - 1 i = i + 2 end i = i - 2 while data[i] ~= 0 do i = i - 3 w(data[i]) w(data[i]) i = i + 3 data[i] = data[i] - 1 end i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 7 if (data[i] ~= 0) then data[i + 7] = data[i + 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 7 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 7] = data[i - 7] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 88 i = i - 2 data[i] = 1 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 end i = i - 2 data[i] = 1 i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i + 2 data[i] = 120 w(data[i]) i = i - 1 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i - 6 w(data[i]) i = i + 6 end i = i - 9 end i = i + 1 data[i] = 10 w(data[i]) data[i] = 1 i = i + 1 data[i] = 1 i = i + 1 data[i] = 27 w(data[i]) data[i] = data[i] + 64 w(data[i]) ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 3 data[i] = 0 i = i + 6 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 7] = data[i - 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 5] = data[i - 5] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 2 data[i] = 0 i = i + 5 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 6] = data[i - 6] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 1 data[i] = 0 i = i + 4 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 data[i] = 1 i = i - 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i + 4 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 data[i] = 1 i = i - 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i + 6 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i - 6 data[i] = data[i] + 48 w(data[i]) i = i + 6 end i = i - 2 end i = i - 6 data[i] = data[i] - 32 w(data[i]) ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 3 data[i] = 0 i = i + 6 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 7] = data[i - 7] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 5] = data[i - 5] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 2 data[i] = 0 i = i + 5 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 6] = data[i - 6] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i + 1 data[i] = 0 i = i - 2 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end i = i - 3 end i = i - 1 data[i] = 0 i = i + 4 data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * -1 data[i] = 0 end i = i + 1 end i = i - 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 10 i = i - 5 data[i] = 0 i = i + 4 while data[i] ~= 0 do i = i + 3 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i + 1 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 3 data[i] = data[i] - 1 i = i + 2 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 4 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 1 i = i + 1 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = 0 i = i + 1 end i = i - 1 while data[i] ~= 0 do data[i] = 0 i = i - 7 data[i] = data[i] + 1 i = i + 7 end i = i - 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 data[i] = 1 i = i - 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i + 4 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i + 1 data[i] = 0 i = i - 4 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 data[i] = 1 i = i - 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 data[i] = data[i] + 48 w(data[i]) i = i - 1 data[i] = data[i] + 48 w(data[i]) i = i + 6 data[i] = data[i] - 1 i = i - 1 end i = i + 1 while data[i] ~= 0 do data[i] = 0 i = i - 6 data[i] = data[i] + 48 w(data[i]) i = i + 6 end i = i - 2 end i = i - 6 data[i] = data[i] + 13 w(data[i]) i = i - 2 data[i] = 200 while data[i] ~= 0 do i = i + 1 data[i] = 200 while data[i] ~= 0 do i = i + 1 data[i] = 100 data[i] = 0 i = i - 1 data[i] = data[i] - 1 end i = i - 1 data[i] = data[i] - 1 end i = i - 5 end i = i - 4 data[i] = data[i] + 1 i = i + 4 data[i] = 0 i = i + 1 data[i] = 0 i = i - 5 if (data[i] ~= 0) then data[i + 5] = data[i + 5] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 5 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 5] = data[i - 5] + (-(data[i] / -1)) * 1 data[i] = 0 end data[i] = 4 i = i - 2 data[i] = 0 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 1 i = i + 3 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 1 i = i + 3 end i = i - 3 end i = i - 2 data[i] = data[i] - 1 i = i + 2 data[i] = 0 i = i - 2 if (data[i] ~= 0) then data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 8 data[i] = data[i] - 1 i = i - 204 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 0 i = i + 207 data[i] = 0 i = i + 8 data[i] = 0 i = i - 9 if (data[i] ~= 0) then data[i + 9] = data[i + 9] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 9 if (data[i] ~= 0) then data[i - 9] = data[i - 9] + (-(data[i] / -1)) * 1 data[i - 214] = data[i - 214] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 214 while data[i] ~= 0 do i = i - 3 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 1 i = i + 5 data[i] = data[i] - 1 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 end i = i - 2 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 while data[i] ~= 0 do i = i + 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 end i = i + 2 if (data[i] ~= 0) then data[i + 205] = data[i + 205] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 40 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 0 i = i + 170 data[i] = 0 i = i + 5 data[i] = 0 i = i - 9 if (data[i] ~= 0) then data[i + 9] = data[i + 9] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 9 if (data[i] ~= 0) then data[i - 9] = data[i - 9] + (-(data[i] / -1)) * 1 data[i - 174] = data[i - 174] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 174 while data[i] ~= 0 do i = i - 3 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 1 i = i + 5 data[i] = data[i] - 1 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 end i = i - 2 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 while data[i] ~= 0 do i = i + 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 end i = i + 2 if (data[i] ~= 0) then data[i + 168] = data[i + 168] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 40 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 0 i = i + 131 data[i] = 0 i = i + 4 data[i] = 0 i = i - 9 if (data[i] ~= 0) then data[i + 9] = data[i + 9] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 9 if (data[i] ~= 0) then data[i - 9] = data[i - 9] + (-(data[i] / -1)) * 1 data[i - 134] = data[i - 134] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 134 while data[i] ~= 0 do i = i - 3 data[i] = 0 i = i - 1 data[i] = 0 i = i - 1 data[i] = 1 i = i + 5 data[i] = data[i] - 1 if (data[i] ~= 0) then data[i - 4] = data[i - 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 4 end i = i - 2 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i + 2] = data[i + 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 if (data[i] ~= 0) then data[i - 2] = data[i - 2] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 1 while data[i] ~= 0 do i = i + 2 if (data[i] ~= 0) then data[i + 4] = data[i + 4] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 2 end i = i + 2 if (data[i] ~= 0) then data[i + 129] = data[i + 129] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 126 data[i] = 0 i = i + 1 data[i] = 0 i = i + 7 data[i] = 8 ffi.fill(data + i + 1, 2, 0) i = i - 9 if (data[i] ~= 0) then data[i + 11] = data[i + 11] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 11 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 11] = data[i - 11] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 1 i = i + 3 end i = i - 3 while data[i] ~= 0 do i = i - 8 data[i] = data[i] - 9 i = i + 2 data[i] = data[i] + 1 i = i + 7 data[i] = 8 ffi.fill(data + i + 1, 2, 0) i = i - 9 if (data[i] ~= 0) then data[i + 11] = data[i + 11] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 11 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 11] = data[i - 11] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 1 i = i + 3 end i = i - 3 end i = i + 1 data[i] = 2 ffi.fill(data + i + 1, 2, 0) i = i - 9 if (data[i] ~= 0) then data[i + 11] = data[i + 11] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 11 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 11] = data[i - 11] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 1 i = i + 3 end i = i - 3 while data[i] ~= 0 do i = i - 8 data[i] = data[i] - 3 i = i + 1 data[i] = data[i] + 1 i = i + 8 data[i] = 2 ffi.fill(data + i + 1, 2, 0) i = i - 9 if (data[i] ~= 0) then data[i + 11] = data[i + 11] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 11 if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i - 11] = data[i - 11] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 0 i = i + 3 data[i] = 0 i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 while data[i] ~= 0 do i = i - 2 data[i] = data[i] - 1 i = i + 1 data[i] = data[i] - 1 ffi.fill(data + i + 1, 2, 0) i = i - 1 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 data[i] = 0 i = i - 3 if (data[i] ~= 0) then data[i + 3] = data[i + 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 3 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 3] = data[i - 3] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 2 data[i] = 1 i = i + 2 end i = i - 1 end i = i - 1 end data[i] = 0 i = i - 1 if (data[i] ~= 0) then data[i + 1] = data[i + 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i + 1 while data[i] ~= 0 do if (data[i] ~= 0) then data[i - 1] = data[i - 1] + (-(data[i] / -1)) * 1 data[i] = 0 end i = i - 3 data[i] = 1 i = i + 3 end i = i - 3 end i = i - 4 data[i] = data[i] + 1 i = i + 3 end i = i - 2 end
-- import local TaskModule = require 'candy.task.Task' local Task = TaskModule.Task ---@class AsyncImageLoadTask : Task local AsyncImageLoadTask = CLASS:AsyncImageLoadTask ( Task ) :MODEL {} function AsyncImageLoadTask:__init ( path, transform ) self.imagePath = path self.imageTransform = transform end local n = 0 function AsyncImageLoadTask:onExec ( queue ) if not self.imagePath then return self:fail () end local img = MOAIImage.new () self.img = img function self.callback () if img:getSize () <= 0 then return self:fail () else return self:complete ( img ) end end img:loadAsync(self.imagePath, self:requestThreadTaskQueue(), self.callback, self.imageTransform) end function AsyncImageLoadTask:toString () return "<imageLoadTask>" .. self.imagePath end return AsyncImageLoadTask
modifier_puck_dream_coil_lua = class({}) -------------------------------------------------------------------------------- -- Classifications function modifier_puck_dream_coil_lua:IsHidden() return false end function modifier_puck_dream_coil_lua:IsDebuff() return true end function modifier_puck_dream_coil_lua:IsStunDebuff() return false end function modifier_puck_dream_coil_lua:GetAttributes() return MODIFIER_ATTRIBUTE_MULTIPLE end function modifier_puck_dream_coil_lua:IsPurgable() return false end -------------------------------------------------------------------------------- -- Initializations function modifier_puck_dream_coil_lua:OnCreated( kv ) -- references self.center = Vector( kv.coil_x, kv.coil_y, kv.coil_z ) if self:GetCaster():HasScepter() then self.break_radius = self:GetAbility():GetSpecialValueFor( "coil_break_radius" ) -- special value self.break_stun = self:GetAbility():GetSpecialValueFor( "coil_stun_duration_scepter" ) -- special value self.break_damage = self:GetAbility():GetSpecialValueFor( "coil_break_damage_scepter" ) -- special value self.scepter = true else self.break_radius = self:GetAbility():GetSpecialValueFor( "coil_break_radius" ) -- special value self.break_stun = self:GetAbility():GetSpecialValueFor( "coil_stun_duration" ) -- special value self.break_damage = self:GetAbility():GetSpecialValueFor( "coil_break_damage" ) -- special value end if IsServer() then self:PlayEffects() end end function modifier_puck_dream_coil_lua:OnRefresh( kv ) end function modifier_puck_dream_coil_lua:OnDestroy( kv ) end -------------------------------------------------------------------------------- -- Modifier Effects function modifier_puck_dream_coil_lua:DeclareFunctions() local funcs = { MODIFIER_EVENT_ON_UNIT_MOVED, } return funcs end function modifier_puck_dream_coil_lua:OnUnitMoved( params ) if IsServer() then if params.unit~=self:GetParent() then return end -- if too far if (params.new_pos-self.center):Length2D()>self.break_radius then -- damage local damageTable = { victim = self:GetParent(), attacker = self:GetCaster(), damage = self.break_damage, damage_type = DAMAGE_TYPE_MAGICAL, ability = self:GetAbility(), --Optional. } ApplyDamage(damageTable) -- stun if not self:GetParent():IsMagicImmune() or self.scepter then self:GetParent():AddNewModifier( self:GetCaster(), -- player source self, -- ability source "modifier_generic_stunned_lua", -- modifier name { duration = self.break_stun } -- kv ) end -- effects local sound_cast = "Hero_Puck.Dream_Coil_Snap" EmitSoundOn( sound_cast, self:GetParent() ) -- destroy self:Destroy() end end end -------------------------------------------------------------------------------- -- Graphics & Animations function modifier_puck_dream_coil_lua:PlayEffects() -- Get Resources local particle_cast = "particles/units/heroes/hero_puck/puck_dreamcoil_tether.vpcf" -- Create Particle -- local effect_cast = ParticleManager:CreateParticle( particle_cast, PATTACH_ABSORIGIN, self:GetParent() ) local effect_cast = assert(loadfile("lua_abilities/rubick_spell_steal_lua/rubick_spell_steal_lua_arcana"))(self, particle_cast, PATTACH_ABSORIGIN, self:GetParent() ) ParticleManager:SetParticleControl( effect_cast, 0, self.center ) ParticleManager:SetParticleControlEnt( effect_cast, 1, self:GetParent(), PATTACH_POINT_FOLLOW, "attach_hitloc", self:GetParent():GetOrigin(), -- unknown true -- unknown, true ) -- buff particle self:AddParticle( effect_cast, false, false, -1, false, false ) end
require 'lfs' -- Ensure the test is launched within the specs/ folder assert(string.match(lfs.currentdir(), "specs")~=nil, "You must run this test in specs folder") local initial_dir = lfs.currentdir() -- Go to specs folder while (not string.match(lfs.currentdir(), "/specs$")) do lfs.chdir("..") end local specs_dir = lfs.currentdir() lfs.chdir("..")-- one more directory and it is lib root -- Include Dataframe lib dofile("init.lua") -- Go back into initial dir lfs.chdir(initial_dir) describe("Indexing the dataframe", function() describe("Retrieving index",function() local df = Dataframe(specs_dir.."/data/simple_short.csv") assert.are.same(df["$Col A"], df:get_column('Col A')) assert.are.same(df["$Col C"], df:get_column('Col C')) end) describe("Retrieving index",function() local df = Dataframe(specs_dir.."/data/simple_short.csv") -- Wait until https://github.com/torch/torch7/issues/693 is resolved it("Retrieves a single row",function() local subset = df[1] assert.is.truthy(subset, "Fails to subset row") assert.are.same(subset["Col A"], 1) assert.are.same(subset["Col C"], 1000) end) it("Retrieves a several rows",function() local subset = df[Df_Array(1, 3)] assert.is.truthy(subset, "Fails to subset rows") assert.are.same(subset:size(1), 2) assert.are.same(subset:size(2), df:size(2)) end) it("Retrieves a continuous set of rows",function() local subset = df["1:4"] assert.is.truthy(subset, "Fails to subset rows with continuous syntax") assert.are.same(subset:size(1), 4) assert.are.same(subset:size(2), df:size(2)) end) end) describe("Set row via the newindex",function() local df = Dataframe(specs_dir.."/data/simple_short.csv") it("Set a single row",function() df[1]= {["Col A"] = 3231} assert.are.same(df[1]["Col A"], 3231) end) end) describe("Create a copy of the table",function() local df = Dataframe(Df_Dict({a={1,2,3}})) it("Check that it's a true copy and not a reference",function() local new_df = df:copy() new_df[1] = {a=2} assert.are.same(new_df:size(1), df:size(1)) assert.are.same(new_df:size(2), df:size(2)) assert.is_false(new_df[1].a == df[1].a) -- Check that htis matches also the shape assert.are.same(new_df:shape(), df:shape()) end) end) it("Returns the size of the Dataframe",function() local a = Dataframe(Df_Dict({test = {1,nil,3, 4}, test2 = {5, 9, 99, 88}})) assert.are.same(a:size(1), 4) assert.are.same(a:size(2), 2) end) describe("Gets the version number",function() local df = Dataframe() it("The torch.version goes to version()",function() assert.are.same(torch.version(df), df:version()) end) end) describe("Check the __len__",function() local df = Dataframe(Df_Dict{a={1,2,3,4,5}}) it("__len__ should return the n_rows",function() assert.are.same(df:__len__(), df.n_rows) end) it("# should return the n_rows #skip_version_LUA51",function() assert.are.same(#df, df.n_rows) end) end) describe("Check the __eq__",function() it("Should be equal",function() local a = Dataframe(Df_Dict{a={1,2,3,4,5}}) local b = Dataframe(Df_Dict{a={1,2,3,4,5}}) assert.is_true(a == b) assert.is_false(a ~= b) a:set(2, Df_Dict{a=0/0}) b:set(2, Df_Dict{a=0/0}) assert.is_true(a == b, "Fails with nan values") assert.is_false(a ~= b, "Fails with nan values") end) it("Should not be equal",function() local a = Dataframe(Df_Dict{a={1,2,3,4,5}}) local b = Dataframe(Df_Dict{a={1,3,4,5}}) local c = Dataframe(Df_Dict{a={1,2,3,4,6}}) local d = Dataframe(Df_Dict{a={1,2,3,0/0,6}}) local e = Dataframe(Df_Dict{b={1,2,3,4,5}}) local f = Dataframe(Df_Dict{a={1,2,3,4,5}, b={1,2,3,4,5}}) assert.is_true(a ~= b, "Fail to differ row length") assert.is_true(a ~= c, "Fail to differ values") assert.is_true(a ~= d, "Fail to differ nan") assert.is_true(a ~= e, "Fail to differ column names") assert.is_true(a ~= f, "Fail to differ number of columns") end) end) end)
ITEM.name = "Darkness" ITEM.desc = "A story of a man and his realizations" ITEM.price = 0 ITEM.flag = "3" ITEM.iconCam = { pos = Vector(0, 200, 6), ang = Angle(0, 270, 0), fov = 4.5, } ITEM.contents = [[ <p align="center"><font color='red' size='6'>DARKNESS</font></p><br/> <font color='black' size='3'> Brian 'Joker' Doughty says "Holy fucking shit."<br/><br/> Brian 'Joker' Doughty says "People."<br/><br/> Brian 'Joker' Doughty says "Then again, you guys probably are the ones who just stand around and act like they're alive."<br/><br/> Brian 'Joker' Doughty says "When really you're just robots holding weapons and planning on the human's untimely death."<br/><br/> Brian 'Joker' Doughty says "I bet one of you are about to turn around and shoot me right now for unfolding your plans."<br/><br/> **Brian 'Joker' Doughty glances around. "Anyone? Huh?"<br/><br/> **One of the guards just nods to the other. They both turn to look at Brian.<br/><br/> Brian 'Joker' Doughty says "I fucking knew it."<br/><br/> **They both look back at each other and nod once again.<br/><br/> Brian 'Joker' Doughty says "You two have been planning since day one."<br/><br/> Brian 'Joker' Doughty says "Since this whole thing started."<br/><br/> Brian 'Joker' Doughty says "It's a conspiracy."<br/><br/> **One of the guards begins making clicking noises to the other.<br/><br/> Brian 'Joker' Doughty says "Anyone out there really isn't dead. Us humans are hallucinating."<br/><br/> Brian 'Joker' Doughty says "You've drugged us to think they're flesh-eating parasitic zom-zoms."<br/><br/> **The guards are just clicking back and forth now.<br/><br/> Brian 'Joker' Doughty says "And they're the ones truly suffering."<br/><br/> **They're still clicking.<br/><br/> Brian 'Joker' Doughty says "They come to us for help, and we see them attacking."<br/><br/> **Suddenly, people.<br/><br/> **Brian 'Joker' Doughty glances around.<br/><br/> Brian 'Joker' Doughty says "WHO ARE YOU PEOPLE."<br/><br/> **Brian 'Joker' Doughty raises his hands up to his chest, glancing down at them,<br/><br/> Brian 'Joker' Doughty says "This whole fucking life has been a lie."<br/><br/> Brian 'Joker' Doughty says "I am not a nineteen-year-old American jackass."<br/><br/> **The one black man closest to Brian just stares at him.<br/><br/> **Lovingly.<br/><br/> Brian 'Joker' Doughty says "I am not living in the middle of an apocalypse- well, actually, yes I am."<br/><br/> **Brian 'Joker' Doughty glances up at he man. "STOP IT."<br/><br/> **The man winks.<br/><br/> Brian 'Joker' Doughty says "What I truly am is-"<br/><br/> **Brian 'Joker' Doughty gasps, soon falling onto his knees as he pulls out his copy of Metro 2033. "I AM REALLY ARTYOM."<br/><br/> Brian 'Joker' Doughty says "THIS BOOK IS JUST A RECOLLECTION OF MY LIFE IN THE PAST EIGHT DAYS."<br/><br/> **The black man makes a clicking noise and nods, "Metro for the pure race."<br/><br/> Brian 'Joker' Doughty says "THE DARK ONES DID ACTUALLY STOP ME FROM LAUNCHING THE NUKES AND NOW I'M IN THEIR VERSION OF PURGATORIAL HELL."<br/><br/> Brian 'Joker' Doughty yells "MILLER! KHAN! ULHMAN? ANYBODY?"<br/><br/> **One of the guards just furrows his brow as he watches Brian in amusement. The black man just seems terrified of him now.<br/><br/> Brian 'Joker' Doughty yells "I NEED HELP! PLEASE, DON'T LEAVE ME TO DIE LIKE THIS!"<br/><br/> **Brian 'Joker' Doughty soon jumps up to his feet, glancing around in a panicked way. "No. NO! YOU'RE ALL NOT REAL! YOU'REALLNOTREAL!" He soon bolts off, screaming.<br/><br/> **Brian 'Joker' Doughty slams into a wall, grunting heavily as he falls backwards onto the floor, unconscious.<br/><br/> **What with this kind of commotion, it wouldn't be hard to believe that a guard would come up to check Brian, scan him and then sit him up against a wall or something.<br/><br/> **Which they do. The guard that does arrive also slaps Brian in the face and leaves quickly. </font> ]]
if string.sub(UI.GetAppVersion(),1,9) ~= "1.0.0.262" then -- =========================================================================== -- Production Panel / Purchase Panel -- =========================================================================== include( "ToolTipHelper" ); include( "InstanceManager" ); include( "TabSupport" ); include( "Civ6Common" ); include( "SupportFunctions" ); include( "AdjacencyBonusSupport"); include( "DragSupport" ); include( "CitySupport" ); -- =========================================================================== -- Constants -- =========================================================================== local RELOAD_CACHE_ID :string = "ProductionPanel"; local COLOR_LOW_OPACITY :number = 0x3fffffff; local HEADER_Y :number = 41; local WINDOW_HEADER_Y :number = 150; local TOPBAR_Y :number = 28; local SEPARATOR_Y :number = 20; local BUTTON_Y :number = 48; local DISABLED_PADDING_Y:number = 10; local TEXTURE_BASE :string = "UnitFlagBase"; local TEXTURE_CIVILIAN :string = "UnitFlagCivilian"; local TEXTURE_RELIGION :string = "UnitFlagReligion"; local TEXTURE_EMBARK :string = "UnitFlagEmbark"; local TEXTURE_FORTIFY :string = "UnitFlagFortify"; local TEXTURE_NAVAL :string = "UnitFlagNaval"; local TEXTURE_SUPPORT :string = "UnitFlagSupport"; local TEXTURE_TRADE :string = "UnitFlagTrade"; local BUILDING_IM_PREFIX :string = "buildingListingIM_"; local BUILDING_DRAWER_PREFIX :string = "buildingDrawer_"; local ICON_PREFIX :string = "ICON_"; local LISTMODE :table = {PRODUCTION = 1, PURCHASE_GOLD = 2, PURCHASE_FAITH=3}; local EXTENDED_BUTTON_HEIGHT = 60; local DEFAULT_BUTTON_HEIGHT = 48; local PRODUCTION_TYPE :table = { BUILDING = 1, UNIT = 2, CORPS = 3, ARMY = 4, PLACED = 5, PROJECT = 6 }; -- =========================================================================== -- Members -- =========================================================================== local m_queueIM = InstanceManager:new( "UnnestedList", "Top", Controls.ProductionQueueList ); local m_listIM = InstanceManager:new( "NestedList", "Top", Controls.ProductionList ); local m_purchaseListIM = InstanceManager:new( "NestedList", "Top", Controls.PurchaseList ); local m_purchaseFaithListIM = InstanceManager:new( "NestedList", "Top", Controls.PurchaseFaithList ); local m_tabs; local m_productionTab; -- Additional tracking of the tab control data so that we can select between graphical tabs and label tabs local m_purchaseTab; local m_faithTab; local m_maxProductionSize :number = 0; local m_maxPurchaseSize :number = 0; local m_isQueueMode :boolean = false; local m_TypeNames :table = {}; local m_kClickedInstance; local m_isCONTROLpressed :boolean = false; local prodBuildingList; local prodWonderList; local prodUnitList; local prodDistrictList; local prodProjectList; local purchBuildingList; local purchGoldBuildingList; local purchFaithBuildingList; local purchUnitList; local purchGoldUnitList local purchFaithUnitList local showDisabled :boolean = true; local m_recommendedItems:table; -- Production Queue local nextDistrictSkipToFront = false; local showStandaloneQueueWindow = true; local _, screenHeight = UIManager:GetScreenSizeVal(); local quickRefresh = true; local lastProductionCompletePerCity = {}; local buildingPrereqs = {}; local mutuallyExclusiveBuildings = {}; local m_PrevDropTargetSlot = -1; local m_PrevDropTargetInstance = nil; local m_Districts : number = UILens.CreateLensLayerHash("Districts"); ------------------------------------------------------------------------------ -- Collapsible List Handling ------------------------------------------------------------------------------ function OnCollapseTheList() m_kClickedInstance.List:SetHide(true); m_kClickedInstance.ListSlide:SetSizeY(0); m_kClickedInstance.ListAlpha:SetSizeY(0); Controls.PauseCollapseList:SetToBeginning(); m_kClickedInstance.ListSlide:SetToBeginning(); m_kClickedInstance.ListAlpha:SetToBeginning(); Controls.ProductionList:CalculateSize(); Controls.PurchaseList:CalculateSize(); Controls.ProductionList:ReprocessAnchoring(); Controls.PurchaseList:ReprocessAnchoring(); Controls.ProductionListScroll:CalculateInternalSize(); Controls.PurchaseListScroll:CalculateInternalSize(); end -- =========================================================================== function OnCollapse(instance:table) m_kClickedInstance = instance; instance.ListSlide:Reverse(); instance.ListAlpha:Reverse(); instance.ListSlide:SetSpeed(15.0); instance.ListAlpha:SetSpeed(15.0); instance.ListSlide:Play(); instance.ListAlpha:Play(); instance.HeaderOn:SetHide(true); instance.Header:SetHide(false); Controls.PauseCollapseList:Play(); --By doing this we can delay collapsing the list until the "out" sequence has finished playing end -- =========================================================================== function OnExpand(instance:table) if(quickRefresh) then instance.ListSlide:SetSpeed(100); instance.ListAlpha:SetSpeed(100); else instance.ListSlide:SetSpeed(3.5); instance.ListAlpha:SetSpeed(4); end m_kClickedInstance = instance; instance.HeaderOn:SetHide(false); instance.Header:SetHide(true); instance.List:SetHide(false); instance.ListSlide:SetSizeY(instance.List:GetSizeY()); instance.ListAlpha:SetSizeY(instance.List:GetSizeY()); instance.ListSlide:SetToBeginning(); instance.ListAlpha:SetToBeginning(); instance.ListSlide:Play(); instance.ListAlpha:Play(); Controls.ProductionList:CalculateSize(); Controls.PurchaseList:CalculateSize(); Controls.ProductionList:ReprocessAnchoring(); Controls.PurchaseList:ReprocessAnchoring(); Controls.ProductionListScroll:CalculateInternalSize(); Controls.PurchaseListScroll:CalculateInternalSize(); end -- =========================================================================== function OnTabChangeProduction() Controls.MiniProductionTab:SetSelected(true); Controls.MiniPurchaseTab:SetSelected(false); Controls.MiniPurchaseFaithTab:SetSelected(false); Controls.PurchaseFaithMenu:SetHide(true); Controls.PurchaseMenu:SetHide(true); Controls.ChooseProductionMenu:SetHide(false); if (Controls.SlideIn:IsStopped()) then UI.PlaySound("Production_Panel_ButtonClick"); UI.PlaySound("Production_Panel_Open"); end end -- =========================================================================== function OnTabChangePurchase() Controls.MiniProductionTab:SetSelected(false); Controls.MiniPurchaseTab:SetSelected(true); Controls.MiniPurchaseFaithTab:SetSelected(false); Controls.ChooseProductionMenu:SetHide(true); Controls.PurchaseFaithMenu:SetHide(true); Controls.PurchaseMenu:SetHide(false); UI.PlaySound("Production_Panel_ButtonClick"); end -- =========================================================================== function OnTabChangePurchaseFaith() Controls.MiniProductionTab:SetSelected(false); Controls.MiniPurchaseTab:SetSelected(false); Controls.MiniPurchaseFaithTab:SetSelected(true); Controls.ChooseProductionMenu:SetHide(true); Controls.PurchaseMenu:SetHide(true); Controls.PurchaseFaithMenu:SetHide(false); UI.PlaySound("Production_Panel_ButtonClick"); end -- =========================================================================== -- Placement/Selection -- =========================================================================== function BuildUnit(city, unitEntry) local tParameters = {}; tParameters[CityOperationTypes.PARAM_UNIT_TYPE] = unitEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; CityManager.RequestOperation(city, CityOperationTypes.BUILD, tParameters); end -- =========================================================================== function BuildUnitCorps(city, unitEntry) local tParameters = {}; tParameters[CityOperationTypes.PARAM_UNIT_TYPE] = unitEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; tParameters[CityOperationTypes.MILITARY_FORMATION_TYPE] = MilitaryFormationTypes.CORPS_MILITARY_FORMATION; CityManager.RequestOperation(city, CityOperationTypes.BUILD, tParameters); end -- =========================================================================== function BuildUnitArmy(city, unitEntry) local tParameters = {}; tParameters[CityOperationTypes.PARAM_UNIT_TYPE] = unitEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; tParameters[CityOperationTypes.MILITARY_FORMATION_TYPE] = MilitaryFormationTypes.ARMY_MILITARY_FORMATION; CityManager.RequestOperation(city, CityOperationTypes.BUILD, tParameters); end -- =========================================================================== function BuildBuilding(city, buildingEntry) local building :table = GameInfo.Buildings[buildingEntry.Hash]; local bNeedsPlacement :boolean = building.RequiresPlacement; UI.SetInterfaceMode(InterfaceModeTypes.SELECTION); local pBuildQueue = city:GetBuildQueue(); if (pBuildQueue:HasBeenPlaced(buildingEntry.Hash)) then bNeedsPlacement = false; end -- If it's a Wonder and the city already has the building then it doesn't need to be replaced. if (bNeedsPlacement) then local cityBuildings = city:GetBuildings(); if (cityBuildings:HasBuilding(buildingEntry.Hash)) then bNeedsPlacement = false; end end if(not pBuildQueue:CanProduce(buildingEntry.Hash, true)) then -- For one reason or another we can't produce this, so remove it RemoveFromQueue(city:GetID(), 1, true); BuildFirstQueued(city); return; end if ( bNeedsPlacement ) then -- If so, set the placement mode local tParameters = {}; tParameters[CityOperationTypes.PARAM_BUILDING_TYPE] = buildingEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; UI.SetInterfaceMode(InterfaceModeTypes.BUILDING_PLACEMENT, tParameters); else local tParameters = {}; tParameters[CityOperationTypes.PARAM_BUILDING_TYPE] = buildingEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; CityManager.RequestOperation(city, CityOperationTypes.BUILD, tParameters); end end -- =========================================================================== function ZoneDistrict(city, districtEntry) local district :table = GameInfo.Districts[districtEntry.Hash]; local bNeedsPlacement :boolean = district.RequiresPlacement; local pBuildQueue :table = city:GetBuildQueue(); if (pBuildQueue:HasBeenPlaced(districtEntry.Hash)) then bNeedsPlacement = false; end -- Almost all districts need to be placed, but just in case let's check anyway if (bNeedsPlacement ) then -- If so, set the placement mode local tParameters = {}; tParameters[CityOperationTypes.PARAM_DISTRICT_TYPE] = districtEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; UI.SetInterfaceMode(InterfaceModeTypes.DISTRICT_PLACEMENT, tParameters); else -- If not, add it to the queue. local tParameters = {}; tParameters[CityOperationTypes.PARAM_DISTRICT_TYPE] = districtEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; CityManager.RequestOperation(city, CityOperationTypes.BUILD, tParameters); UI.PlaySound("Confirm_Production"); end end -- =========================================================================== function AdvanceProject(city, projectEntry) local tParameters = {}; tParameters[CityOperationTypes.PARAM_PROJECT_TYPE] = projectEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; CityManager.RequestOperation(city, CityOperationTypes.BUILD, tParameters); end -- =========================================================================== function PurchaseUnit(city, unitEntry) local tParameters = {}; tParameters[CityCommandTypes.PARAM_UNIT_TYPE] = unitEntry.Hash; tParameters[CityCommandTypes.PARAM_MILITARY_FORMATION_TYPE] = MilitaryFormationTypes.STANDARD_MILITARY_FORMATION; if (unitEntry.Yield == "YIELD_GOLD") then tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_GOLD"].Index; UI.PlaySound("Purchase_With_Gold"); else tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_FAITH"].Index; UI.PlaySound("Purchase_With_Faith"); end CityManager.RequestCommand(city, CityCommandTypes.PURCHASE, tParameters); end -- =========================================================================== function PurchaseUnitCorps(city, unitEntry) local tParameters = {}; tParameters[CityCommandTypes.PARAM_UNIT_TYPE] = unitEntry.Hash; tParameters[CityCommandTypes.PARAM_MILITARY_FORMATION_TYPE] = MilitaryFormationTypes.CORPS_MILITARY_FORMATION; if (unitEntry.Yield == "YIELD_GOLD") then tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_GOLD"].Index; UI.PlaySound("Purchase_With_Gold"); else tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_FAITH"].Index; UI.PlaySound("Purchase_With_Faith"); end CityManager.RequestCommand(city, CityCommandTypes.PURCHASE, tParameters); end -- =========================================================================== function PurchaseUnitArmy(city, unitEntry) local tParameters = {}; tParameters[CityCommandTypes.PARAM_UNIT_TYPE] = unitEntry.Hash; tParameters[CityCommandTypes.PARAM_MILITARY_FORMATION_TYPE] = MilitaryFormationTypes.ARMY_MILITARY_FORMATION; if (unitEntry.Yield == "YIELD_GOLD") then tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_GOLD"].Index; UI.PlaySound("Purchase_With_Gold"); else tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_FAITH"].Index; UI.PlaySound("Purchase_With_Faith"); end CityManager.RequestCommand(city, CityCommandTypes.PURCHASE, tParameters); end -- =========================================================================== function PurchaseBuilding(city, buildingEntry) local tParameters = {}; tParameters[CityCommandTypes.PARAM_BUILDING_TYPE] = buildingEntry.Hash; if (buildingEntry.Yield == "YIELD_GOLD") then tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_GOLD"].Index; UI.PlaySound("Purchase_With_Gold"); else tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_FAITH"].Index; UI.PlaySound("Purchase_With_Faith"); end CityManager.RequestCommand(city, CityCommandTypes.PURCHASE, tParameters); end -- =========================================================================== function PurchaseDistrict(city, districtEntry) local district :table = GameInfo.Districts[districtEntry.Type]; local bNeedsPlacement :boolean = district.RequiresPlacement; local pBuildQueue :table = city:GetBuildQueue(); if (pBuildQueue:HasBeenPlaced(districtEntry.Hash)) then bNeedsPlacement = false; end -- Almost all districts need to be placed, but just in case let's check anyway if (bNeedsPlacement ) then -- If so, set the placement mode local tParameters = {}; tParameters[CityOperationTypes.PARAM_DISTRICT_TYPE] = districtEntry.Hash; tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_GOLD"].Index; UI.SetInterfaceMode(InterfaceModeTypes.DISTRICT_PLACEMENT, tParameters); else -- If not, add it to the queue. local tParameters = {}; tParameters[CityOperationTypes.PARAM_DISTRICT_TYPE] = districtEntry.Hash; tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_GOLD"].Index; CityManager.RequestCommand(city, CityCommandTypes.PURCHASE, tParameters); UI.PlaySound("Purchase_With_Gold"); end end -- =========================================================================== -- GAME Event -- City was selected. -- =========================================================================== function OnCitySelectionChanged( owner:number, cityID:number, i, j, k, isSelected:boolean, isEditable:boolean) local localPlayerId:number = Game.GetLocalPlayer(); if owner == localPlayerId and isSelected then -- Already open then populate with newly selected city's data... if (ContextPtr:IsHidden() == false) and Controls.PauseDismissWindow:IsStopped() and Controls.AlphaIn:IsStopped() then Refresh(); end end end -- =========================================================================== -- GAME Event -- eOldMode, mode the engine was formally in -- eNewMode, new mode the engine has just changed to -- =========================================================================== function OnInterfaceModeChanged( eOldMode:number, eNewMode:number ) -- If this is raised while the city panel is up; selecting to purchase a -- plot or manage citizens will close it. if eNewMode == InterfaceModeTypes.CITY_MANAGEMENT or eNewMode == InterfaceModeTypes.VIEW_MODAL_LENS then if not ContextPtr:IsHidden() then Close(); end end end -- =========================================================================== -- GAME Event -- Unit was selected (impossible for a production panel to be up; close it -- =========================================================================== function OnUnitSelectionChanged( playerID : number, unitID : number, hexI : number, hexJ : number, hexK : number, bSelected : boolean, bEditable : boolean ) local localPlayer = Game.GetLocalPlayer(); if playerID == localPlayer then -- If a unit is selected and this is showing; hide it. local pSelectedUnit:table = UI.GetHeadSelectedUnit(); if pSelectedUnit ~= nil and not ContextPtr:IsHidden() then OnHide(); end end end -- =========================================================================== -- Actual closing function, may have been called via click, keyboard input, -- or an external system call. -- =========================================================================== function Close() if (Controls.SlideIn:IsStopped()) then -- Need to check to make sure that we have not already begun the transition before attempting to close the panel. UI.PlaySound("Production_Panel_Closed"); Controls.SlideIn:Reverse(); Controls.AlphaIn:Reverse(); if(showStandaloneQueueWindow) then Controls.QueueSlideIn:Reverse(); Controls.QueueAlphaIn:Reverse(); else Controls.QueueAlphaIn:SetAlpha(0); end Controls.PauseDismissWindow:Play(); LuaEvents.ProductionPanel_Close(); end end -- =========================================================================== -- Close via click function OnClose() Close(); end -- =========================================================================== -- Open the panel -- =========================================================================== function Open() if ContextPtr:IsHidden() then -- The ContextPtr is only hidden as a callback to the finished SlideIn animation, so this check should be sufficient to ensure that we are not animating. -- Sets up proper selection AND the associated lens so it's not stuck "on". UI.PlaySound("Production_Panel_Open"); LuaEvents.ProductionPanel_Open(); UI.SetInterfaceMode(InterfaceModeTypes.SELECTION); Refresh(); ContextPtr:SetHide(false); Controls.ProductionListScroll:SetScrollValue(0); -- Size the panel to the maximum Y value of the expanded content Controls.AlphaIn:SetToBeginning(); Controls.SlideIn:SetToBeginning(); Controls.AlphaIn:Play(); Controls.SlideIn:Play(); if(showStandaloneQueueWindow) then Controls.QueueAlphaIn:SetToBeginning(); Controls.QueueSlideIn:SetToBeginning(); Controls.QueueAlphaIn:Play(); Controls.QueueSlideIn:Play(); ResizeQueueWindow(); end end end -- =========================================================================== function OnHide() ContextPtr:SetHide(true); Controls.PauseDismissWindow:SetToBeginning(); end -- =========================================================================== -- Initialize, Refresh, Populate, View -- Update the layout based on the view model -- =========================================================================== function View(data, persistCollapse) local selectedCity = UI.GetHeadSelectedCity(); -- Get the hashes for the top three recommended items m_recommendedItems = selectedCity:GetCityAI():GetBuildRecommendations(); PopulateList(data, LISTMODE.PRODUCTION, m_listIM); PopulateList(data, LISTMODE.PURCHASE_GOLD, m_purchaseListIM); PopulateList(data, LISTMODE.PURCHASE_FAITH, m_purchaseFaithListIM); if(persistCollapse) then if(prodDistrictList ~= nil and not prodDistrictList.HeaderOn:IsHidden()) then OnExpand(prodDistrictList); end if(prodWonderList ~= nil and not prodWonderList.HeaderOn:IsHidden()) then OnExpand(prodWonderList); end if(prodUnitList ~= nil and not prodUnitList.HeaderOn:IsHidden()) then OnExpand(prodUnitList); end if(prodProjectList ~= nil and not prodProjectList.HeaderOn:IsHidden()) then OnExpand(prodProjectList); end if(purchFaithBuildingList ~= nil and not purchFaithBuildingList.HeaderOn:IsHidden()) then OnExpand(purchFaithBuildingList); end if(purchGoldBuildingList ~= nil and not purchGoldBuildingList.HeaderOn:IsHidden()) then OnExpand(purchGoldBuildingList); end if(purchFaithUnitList ~= nil and not purchFaithUnitList.HeaderOn:IsHidden()) then OnExpand(purchFaithUnitList); end if(purchGoldUnitList ~= nil and not purchGoldUnitList.HeaderOn:IsHidden()) then OnExpand(purchGoldUnitList); end else if(prodDistrictList ~= nil) then OnExpand(prodDistrictList); end if(prodWonderList ~= nil) then OnExpand(prodWonderList); end if(prodUnitList ~= nil) then OnExpand(prodUnitList); end if(prodProjectList ~= nil) then OnExpand(prodProjectList); end if(purchFaithBuildingList ~= nil) then OnExpand(purchFaithBuildingList); end if(purchGoldBuildingList ~= nil) then OnExpand(purchGoldBuildingList); end if(purchFaithUnitList ~= nil ) then OnExpand(purchFaithUnitList); end if(purchGoldUnitList ~= nil) then OnExpand(purchGoldUnitList); end m_tabs.SelectTab(m_productionTab); end -- if( Controls.PurchaseList:GetSizeY() == 0 ) then Controls.NoGoldContent:SetHide(false); else Controls.NoGoldContent:SetHide(true); end if( Controls.PurchaseFaithList:GetSizeY() == 0 ) then Controls.NoFaithContent:SetHide(false); else Controls.NoFaithContent:SetHide(true); end end function ResetInstanceVisibility(productionItem: table) if (productionItem.ArmyCorpsDrawer ~= nil) then productionItem.ArmyCorpsDrawer:SetHide(true); productionItem.CorpsArmyArrow:SetSelected(true); productionItem.CorpsRecommendedIcon:SetHide(true); productionItem.CorpsButtonContainer:SetHide(true); productionItem.CorpsDisabled:SetHide(true); productionItem.ArmyRecommendedIcon:SetHide(true); productionItem.ArmyButtonContainer:SetHide(true); productionItem.ArmyDisabled:SetHide(true); productionItem.CorpsArmyDropdownArea:SetHide(true); end if (productionItem.BuildingDrawer ~= nil) then productionItem.BuildingDrawer:SetHide(true); productionItem.CompletedArea:SetHide(true); end productionItem.RecommendedIcon:SetHide(true); productionItem.Disabled:SetHide(true); end -- =========================================================================== function PopulateList(data, listMode, listIM) listIM:ResetInstances(); local districtList; local buildingList; local wonderList; local projectList; local unitList; local queueList; Controls.PauseCollapseList:Stop(); local selectedCity = UI.GetHeadSelectedCity(); local pBuildings = selectedCity:GetBuildings(); local cityID = selectedCity:GetID(); local cityData = GetCityData(selectedCity); local localPlayer = Players[Game.GetLocalPlayer()]; if(listMode == LISTMODE.PRODUCTION) then m_maxProductionSize = 0; -- Populate Current Item local buildQueue = selectedCity:GetBuildQueue(); local productionHash = 0; local completedStr = ""; local currentProductionHash = buildQueue:GetCurrentProductionTypeHash(); local previousProductionHash = buildQueue:GetPreviousProductionTypeHash(); local screenX, screenY:number = UIManager:GetScreenSizeVal() if( currentProductionHash == 0 and previousProductionHash == 0 ) then Controls.CurrentProductionArea:SetHide(true); Controls.ProductionListScroll:SetSizeY(screenY-120); Controls.ProductionListScroll:CalculateSize(); Controls.ProductionListScroll:SetOffsetY(10); completedStr = ""; else Controls.CurrentProductionArea:SetHide(false); Controls.ProductionListScroll:SetSizeY(screenY-175); Controls.ProductionListScroll:CalculateSize(); Controls.ProductionListScroll:SetOffsetY(65); if( currentProductionHash == 0 ) then productionHash = previousProductionHash; Controls.CompletedArea:SetHide(false); completedStr = Locale.ToUpper(Locale.Lookup("LOC_TECH_KEY_COMPLETED")); else Controls.CompletedArea:SetHide(true); productionHash = currentProductionHash; completedStr = "" end end local currentProductionInfo :table = GetProductionInfoOfCity( data.City, productionHash ); if (currentProductionInfo.Icons ~= nil) then Controls.CurrentProductionName:SetText(Locale.ToUpper(Locale.Lookup(currentProductionInfo.Name)).." "..completedStr); Controls.CurrentProductionProgress:SetPercent(currentProductionInfo.PercentComplete); Controls.CurrentProductionProgress:SetShadowPercent(currentProductionInfo.PercentCompleteNextTurn); Controls.CurrentProductionIcon:SetIcon(currentProductionInfo.Icons[#currentProductionInfo.Icons]); if(currentProductionInfo.Description ~= nil) then Controls.CurrentProductionIcon:SetToolTipString(Locale.Lookup(currentProductionInfo.Description)); else Controls.CurrentProductionIcon:SetToolTipString(); end local numberOfTurns = currentProductionInfo.Turns; if numberOfTurns == -1 then numberOfTurns = "999+"; end; Controls.CurrentProductionCost:SetText("[ICON_Turn]".. numberOfTurns); Controls.CurrentProductionProgressString:SetText("[ICON_ProductionLarge]"..currentProductionInfo.Progress.."/"..currentProductionInfo.Cost); end -- Populate Districts ------------------------ CANNOT purchase districts districtList = listIM:GetInstance(); districtList.Header:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_DISTRICTS_BUILDINGS"))); districtList.HeaderOn:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_DISTRICTS_BUILDINGS"))); local dL = districtList; -- Due to lambda capture, we need to copy this for callback if ( districtList.districtListIM ~= nil ) then districtList.districtListIM:ResetInstances(); else districtList.districtListIM = InstanceManager:new( "DistrictListInstance", "Root", districtList.List); end -- In the interest of performance, we're keeping the instances that we created and resetting the data. -- This requires a little bit of footwork to remember the instances that have been modified and to manually reset them. for _,type in ipairs(m_TypeNames) do if ( districtList[BUILDING_IM_PREFIX..type] ~= nil) then --Reset the states for the building instance managers districtList[BUILDING_IM_PREFIX..type]:ResetInstances(); end if ( districtList[BUILDING_DRAWER_PREFIX..type] ~= nil) then --Reset the states of the drawers districtList[BUILDING_DRAWER_PREFIX..type]:SetHide(true); end end for i, item in ipairs(data.DistrictItems) do if(GameInfo.Districts[item.Hash].RequiresPopulation and cityData.DistrictsNum < cityData.DistrictsPossibleNum) then if(GetNumDistrictsInCityQueue(selectedCity) + cityData.DistrictsNum >= cityData.DistrictsPossibleNum) then item.Disabled = true; if(not string.find(item.ToolTip, "COLOR:Red")) then item.ToolTip = item.ToolTip .. "[NEWLINE][NEWLINE][COLOR:Red]" .. Locale.Lookup("LOC_DISTRICT_ZONE_POPULATION_TOO_LOW_SHORT", cityData.DistrictsPossibleNum * 3 + 1); end end end local districtListing = districtList["districtListIM"]:GetInstance(); ResetInstanceVisibility(districtListing); -- Check to see if this district item is one of the items that is recommended: for _,hash in ipairs( m_recommendedItems) do if(item.Hash == hash.BuildItemHash) then districtListing.RecommendedIcon:SetHide(false); end end local nameStr = Locale.Lookup("{1_Name}", item.Name); if (item.Repair) then nameStr = nameStr .. "[NEWLINE]" .. Locale.Lookup("LOC_PRODUCTION_ITEM_REPAIR"); end if (item.Contaminated) then nameStr = nameStr .. Locale.Lookup("LOC_PRODUCTION_ITEM_DECONTAMINATE"); end districtListing.LabelText:SetText(nameStr); local turnsStrTT:string = ""; local turnsStr:string = ""; if(item.HasBeenBuilt and GameInfo.Districts[item.Type].OnePerCity == true and not item.Repair and not item.Contaminated and item.Progress == 0 and not item.TurnsLeft) then turnsStrTT = Locale.Lookup("LOC_HUD_CITY_DISTRICT_BUILT_TT"); turnsStr = "[ICON_Checkmark]"; districtListing.RecommendedIcon:SetHide(true); else if(item.TurnsLeft) then local numberOfTurns = item.TurnsLeft; if numberOfTurns == -1 then numberOfTurns = "999+"; turnsStrTT = Locale.Lookup("LOC_HUD_CITY_WILL_NOT_COMPLETE"); else turnsStrTT = numberOfTurns .. Locale.Lookup("LOC_HUD_CITY_TURNS_TO_COMPLETE", item.TurnsLeft); end turnsStr = numberOfTurns .. "[ICON_Turn]"; else turnsStrTT = Locale.Lookup("LOC_HUD_CITY_DISTRICT_BUILT_TT"); turnsStr = "[ICON_Checkmark]"; districtListing.RecommendedIcon:SetHide(true); end end if (item.Disabled) then if(item.HasBeenBuilt and GameInfo.Districts[item.Type].OnePerCity == true) then turnsStrTT = Locale.Lookup("LOC_HUD_CITY_DISTRICT_BUILT_TT"); turnsStr = "[ICON_Checkmark]"; end end if(item.Progress > 0) then districtListing.ProductionProgressArea:SetHide(false); local districtProgress = item.Progress/item.Cost; if (districtProgress < 1) then districtListing.ProductionProgress:SetPercent(districtProgress); else districtListing.ProductionProgressArea:SetHide(true); end else districtListing.ProductionProgressArea:SetHide(true); end districtListing.CostText:SetToolTipString(turnsStrTT); districtListing.CostText:SetText(turnsStr); districtListing.Button:SetToolTipString(item.ToolTip); districtListing.Disabled:SetToolTipString(item.ToolTip); districtListing.Icon:SetIcon(ICON_PREFIX..item.Type); local districtType = item.Type; -- Check to see if this is a unique district that will be substituted for another kind of district if(GameInfo.DistrictReplaces[item.Type] ~= nil) then districtType = GameInfo.DistrictReplaces[item.Type].ReplacesDistrictType; end local uniqueBuildingIMName = BUILDING_IM_PREFIX..districtType; local uniqueBuildingAreaName = BUILDING_DRAWER_PREFIX..districtType; table.insert(m_TypeNames, districtType); districtList[uniqueBuildingIMName] = InstanceManager:new( "BuildingListInstance", "Root", districtListing.BuildingStack); districtList[uniqueBuildingAreaName] = districtListing.BuildingDrawer; districtListing.CompletedArea:SetHide(true); if (item.Disabled) then if(item.HasBeenBuilt and GameInfo.Districts[item.Type].OnePerCity == true) then districtListing.CompletedArea:SetHide(false); districtListing.Disabled:SetHide(true); else if(showDisabled) then districtListing.Disabled:SetHide(false); districtListing.Button:SetColor(COLOR_LOW_OPACITY); else districtListing.Root:SetHide(true); end end else districtListing.Root:SetHide(false); districtListing.Disabled:SetHide(true); districtListing.Button:SetColor(0xFFFFFFFF); end districtListing.Button:SetDisabled(item.Disabled); districtListing.Button:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); districtListing.Button:RegisterCallback( Mouse.eLClick, function() if(m_isCONTROLpressed) then nextDistrictSkipToFront = true; else nextDistrictSkipToFront = false; end QueueDistrict(data.City, item, nextDistrictSkipToFront); end); districtListing.Button:RegisterCallback( Mouse.eMClick, function() nextDistrictSkipToFront = true; QueueDistrict(data.City, item, true); RecenterCameraToSelectedCity(); end); if(not IsTutorialRunning()) then districtListing.Button:RegisterCallback( Mouse.eRClick, function() LuaEvents.OpenCivilopedia(item.Type); end); end districtListing.Root:SetTag(UITutorialManager:GetHash(item.Type)); end districtList.List:CalculateSize(); districtList.List:ReprocessAnchoring(); if (districtList.List:GetSizeY()==0) then districtList.Top:SetHide(true); else m_maxProductionSize = m_maxProductionSize + HEADER_Y + SEPARATOR_Y; districtList.Header:RegisterCallback( Mouse.eLClick, function() OnExpand(dL); end); districtList.Header:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); districtList.HeaderOn:RegisterCallback( Mouse.eLClick, function() OnCollapse(dL); end); districtList.HeaderOn:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); end prodDistrictList = dL; -- Populate Nested Buildings ----------------- for i, buildingItem in ipairs(data.BuildingItems) do local displayItem = true; -- PQ: Check if this building is mutually exclusive with another if(mutuallyExclusiveBuildings[buildingItem.Type]) then for mutuallyExclusiveBuilding in GameInfo.MutuallyExclusiveBuildings() do if(mutuallyExclusiveBuilding.Building == buildingItem.Type) then if(IsBuildingInQueue(selectedCity, GameInfo.Buildings[mutuallyExclusiveBuilding.MutuallyExclusiveBuilding].Hash) or pBuildings:HasBuilding(GameInfo.Buildings[mutuallyExclusiveBuilding.MutuallyExclusiveBuilding].Index)) then displayItem = false; end elseif(mutuallyExclusiveBuilding.MutuallyExclusiveBuilding == buildingItem.Type) then if(IsBuildingInQueue(selectedCity, GameInfo.Buildings[mutuallyExclusiveBuilding.Building].Hash) or pBuildings:HasBuilding(GameInfo.Buildings[mutuallyExclusiveBuilding.Building].Index)) then displayItem = false; end end end end if(buildingItem.Hash == GameInfo.Buildings["BUILDING_PALACE"].Hash) then displayItem = false; end if(not buildingItem.IsWonder and not IsBuildingInQueue(selectedCity, buildingItem.Hash) and displayItem) then local uniqueDrawerName = BUILDING_DRAWER_PREFIX..buildingItem.PrereqDistrict; local uniqueIMName = BUILDING_IM_PREFIX..buildingItem.PrereqDistrict; if (districtList[uniqueIMName] ~= nil) then local buildingListing = districtList[uniqueIMName]:GetInstance(); ResetInstanceVisibility(buildingListing); -- Check to see if this is one of the recommended items for _,hash in ipairs( m_recommendedItems) do if(buildingItem.Hash == hash.BuildItemHash) then buildingListing.RecommendedIcon:SetHide(false); end end buildingListing.Root:SetSizeX(305); buildingListing.Button:SetSizeX(305); local districtBuildingAreaControl = districtList[uniqueDrawerName]; districtBuildingAreaControl:SetHide(false); --Fill the meter if there is any progress, hide it if not if(buildingItem.Progress > 0) then buildingListing.ProductionProgressArea:SetHide(false); local buildingProgress = buildingItem.Progress/buildingItem.Cost; if (buildingProgress < 1) then buildingListing.ProductionProgress:SetPercent(buildingProgress); else buildingListing.ProductionProgressArea:SetHide(true); end else buildingListing.ProductionProgressArea:SetHide(true); end local nameStr = Locale.Lookup("{1_Name}", buildingItem.Name); if (buildingItem.Repair) then nameStr = nameStr .. "[NEWLINE]" .. Locale.Lookup("LOC_PRODUCTION_ITEM_REPAIR"); end buildingListing.LabelText:SetText(nameStr); local turnsStrTT:string = ""; local turnsStr:string = ""; local numberOfTurns = buildingItem.TurnsLeft; if numberOfTurns == -1 then numberOfTurns = "999+"; turnsStrTT = Locale.Lookup("LOC_HUD_CITY_WILL_NOT_COMPLETE"); else turnsStrTT = numberOfTurns .. Locale.Lookup("LOC_HUD_CITY_TURNS_TO_COMPLETE", buildingItem.TurnsLeft); end turnsStr = numberOfTurns .. "[ICON_Turn]"; buildingListing.CostText:SetToolTipString(turnsStrTT); buildingListing.CostText:SetText(turnsStr); buildingListing.Button:SetToolTipString(buildingItem.ToolTip); buildingListing.Disabled:SetToolTipString(buildingItem.ToolTip); buildingListing.Icon:SetIcon(ICON_PREFIX..buildingItem.Type); if (buildingItem.Disabled) then if(showDisabled) then buildingListing.Disabled:SetHide(false); buildingListing.Button:SetColor(COLOR_LOW_OPACITY); else buildingListing.Button:SetHide(true); end else buildingListing.Button:SetHide(false); buildingListing.Disabled:SetHide(true); buildingListing.Button:SetSizeY(BUTTON_Y); buildingListing.Button:SetColor(0xffffffff); end buildingListing.Button:SetDisabled(buildingItem.Disabled); buildingListing.Button:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); buildingListing.Button:RegisterCallback( Mouse.eLClick, function() QueueBuilding(data.City, buildingItem); end); buildingListing.Button:RegisterCallback( Mouse.eMClick, function() QueueBuilding(data.City, buildingItem, true); RecenterCameraToSelectedCity(); end); if(not IsTutorialRunning()) then buildingListing.Button:RegisterCallback( Mouse.eRClick, function() LuaEvents.OpenCivilopedia(buildingItem.Type); end); end buildingListing.Button:SetTag(UITutorialManager:GetHash(buildingItem.Type)); end end end -- Populate Wonders ------------------------ CANNOT purchase wonders wonderList = listIM:GetInstance(); wonderList.Header:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_CITY_WONDERS"))); wonderList.HeaderOn:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_CITY_WONDERS"))); local wL = wonderList; if ( wonderList.wonderListIM ~= nil ) then wonderList.wonderListIM:ResetInstances() else wonderList.wonderListIM = InstanceManager:new( "BuildingListInstance", "Root", wonderList.List); end for i, item in ipairs(data.BuildingItems) do if(item.IsWonder and not IsWonderInQueue(item.Hash)) then local wonderListing = wonderList["wonderListIM"]:GetInstance(); ResetInstanceVisibility(wonderListing); for _,hash in ipairs( m_recommendedItems) do if(item.Hash == hash.BuildItemHash) then wonderListing.RecommendedIcon:SetHide(false); end end local nameStr = Locale.Lookup("{1_Name}", item.Name); if (item.Repair) then nameStr = nameStr .. "[NEWLINE]" .. Locale.Lookup("LOC_PRODUCTION_ITEM_REPAIR"); end wonderListing.LabelText:SetText(nameStr); if(item.Progress > 0) then wonderListing.ProductionProgressArea:SetHide(false); local wonderProgress = item.Progress/item.Cost; if (wonderProgress < 1) then wonderListing.ProductionProgress:SetPercent(wonderProgress); else wonderListing.ProductionProgressArea:SetHide(true); end else wonderListing.ProductionProgressArea:SetHide(true); end local turnsStrTT:string = ""; local turnsStr:string = ""; local numberOfTurns = item.TurnsLeft; if numberOfTurns == -1 then numberOfTurns = "999+"; turnsStrTT = Locale.Lookup("LOC_HUD_CITY_WILL_NOT_COMPLETE"); else turnsStrTT = numberOfTurns .. Locale.Lookup("LOC_HUD_CITY_TURNS_TO_COMPLETE", item.TurnsLeft); end turnsStr = numberOfTurns .. "[ICON_Turn]"; wonderListing.CostText:SetText(turnsStr); wonderListing.CostText:SetToolTipString(turnsStrTT); wonderListing.Button:SetToolTipString(item.ToolTip); wonderListing.Disabled:SetToolTipString(item.ToolTip); wonderListing.Icon:SetIcon(ICON_PREFIX..item.Type); if (item.Disabled) then if(showDisabled) then wonderListing.Disabled:SetHide(false); wonderListing.Button:SetColor(COLOR_LOW_OPACITY); else wonderListing.Button:SetHide(true); end else wonderListing.Button:SetHide(false); wonderListing.Disabled:SetHide(true); wonderListing.Button:SetSizeY(BUTTON_Y); wonderListing.Button:SetColor(0xffffffff); end wonderListing.Button:SetDisabled(item.Disabled); wonderListing.Button:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); wonderListing.Button:RegisterCallback( Mouse.eLClick, function() nextDistrictSkipToFront = false; QueueBuilding(data.City, item); end); wonderListing.Button:RegisterCallback( Mouse.eMClick, function() nextDistrictSkipToFront = true; QueueBuilding(data.City, item, true); RecenterCameraToSelectedCity(); end); if(not IsTutorialRunning()) then wonderListing.Button:RegisterCallback( Mouse.eRClick, function() LuaEvents.OpenCivilopedia(item.Type); end); end wonderListing.Button:SetTag(UITutorialManager:GetHash(item.Type)); end end wonderList.List:CalculateSize(); wonderList.List:ReprocessAnchoring(); if (wonderList.List:GetSizeY()==0) then wonderList.Top:SetHide(true); else m_maxProductionSize = m_maxProductionSize + HEADER_Y + SEPARATOR_Y; wonderList.Header:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); wonderList.Header:RegisterCallback( Mouse.eLClick, function() OnExpand(wL); end); wonderList.HeaderOn:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); wonderList.HeaderOn:RegisterCallback( Mouse.eLClick, function() OnCollapse(wL); end); end prodWonderList = wL; --=================================================================================================================== ------------------------------------------ Populate the Production Queue -------------------------------------------- --=================================================================================================================== m_queueIM:ResetInstances(); if(#prodQueue[cityID] > 0) then queueList = m_queueIM:GetInstance(); if (queueList.queueListIM ~= nil) then queueList.queueListIM:ResetInstances(); else queueList.queueListIM = InstanceManager:new("QueueListInstance", "Root", queueList.List); end local itemEncountered = {}; for i, qi in pairs(prodQueue[cityID]) do local queueListing = queueList["queueListIM"]:GetInstance(); ResetInstanceVisibility(queueListing); queueListing.ProductionProgressArea:SetHide(true); if(qi.entry) then local info = GetProductionInfoOfCity(selectedCity, qi.entry.Hash); local turnsText = info.Turns; if(itemEncountered[qi.entry.Hash]) then turnsText = math.ceil(info.Cost / cityData.ProductionPerTurn); else if(info.Progress > 0) then queueListing.ProductionProgressArea:SetHide(false); local progress = info.Progress/info.Cost; if (progress < 1) then queueListing.ProductionProgress:SetPercent(progress); else queueListing.ProductionProgressArea:SetHide(true); end end end local suffix = ""; if(GameInfo.Units[qi.entry.Hash]) then local unitDef = GameInfo.Units[qi.entry.Hash]; local cost = 0; if(prodQueue[cityID][i].type == PRODUCTION_TYPE.CORPS) then cost = qi.entry.CorpsCost; if(unitDef.Domain == "DOMAIN_SEA") then suffix = " " .. Locale.Lookup("LOC_UNITFLAG_FLEET_SUFFIX"); else suffix = " " .. Locale.Lookup("LOC_UNITFLAG_CORPS_SUFFIX"); end elseif(qi.type == PRODUCTION_TYPE.ARMY) then cost = qi.entry.ArmyCost; if(unitDef.Domain == "DOMAIN_SEA") then suffix = " " .. Locale.Lookup("LOC_UNITFLAG_ARMADA_SUFFIX"); else suffix = " " .. Locale.Lookup("LOC_UNITFLAG_ARMY_SUFFIX"); end elseif(qi.type == PRODUCTION_TYPE.UNIT) then cost = qi.entry.Cost; end if(itemEncountered[qi.entry.Hash] and info.Progress ~= 0) then turnsText = math.ceil(cost / cityData.ProductionPerTurn); local percentPerTurn = info.PercentCompleteNextTurn - info.PercentComplete; if(info.PercentCompleteNextTurn < 1) then turnsText = math.ceil(1/percentPerTurn); else turnsText = "~" .. turnsText; end else turnsText = info.Turns; local progress = info.Progress / cost; if (progress < 1) then queueListing.ProductionProgress:SetPercent(progress); end end end if(qi.entry.Repair) then suffix = " (" .. Locale.Lookup("LOC_UNITOPERATION_REPAIR_DESCRIPTION") .. ")" end queueListing.LabelText:SetText(Locale.Lookup(qi.entry.Name) .. suffix); queueListing.Icon:SetIcon(info.Icons[#info.Icons]) queueListing.CostText:SetText(turnsText .. "[ICON_Turn]"); if(i == 1) then queueListing.Active:SetHide(false); end itemEncountered[qi.entry.Hash] = true; end -- EVENT HANDLERS -- queueListing.Button:RegisterCallback( Mouse.eRClick, function() if(CanRemoveFromQueue(cityID, i)) then if(RemoveFromQueue(cityID, i)) then if(i == 1) then BuildFirstQueued(selectedCity); else Refresh(true); end end end end); queueListing.Button:RegisterCallback( Mouse.eMouseEnter, function() if(UI.GetInterfaceMode() ~= InterfaceModeTypes.DISTRICT_PLACEMENT and qi.plotID > -1) then UILens.SetAdjacencyBonusDistict(qi.plotID, "Placement_Valid", {}) end end); queueListing.Button:RegisterCallback( Mouse.eMouseExit, function() if(UI.GetInterfaceMode() ~= InterfaceModeTypes.DISTRICT_PLACEMENT) then UILens.ClearLayerHexes( m_Districts ); end end); queueListing.Button:RegisterCallback( Mouse.eLDblClick, function() MoveQueueIndex(cityID, i, 1); BuildFirstQueued(selectedCity); end); queueListing.Button:RegisterCallback( Mouse.eMClick, function() MoveQueueIndex(cityID, i, 1); BuildFirstQueued(selectedCity); RecenterCameraToSelectedCity(); end); queueListing.Draggable:RegisterCallback( Drag.eDown, function(dragStruct) OnDownInQueue(dragStruct, queueListing, i); end ); queueListing.Draggable:RegisterCallback( Drag.eDrag, function(dragStruct) OnDragInQueue(dragStruct, queueListing, i); end ); queueListing.Draggable:RegisterCallback( Drag.eDrop, function(dragStruct) OnDropInQueue(dragStruct, queueListing, i); end ); end end end --End if LISTMODE.PRODUCTION - display districts, NESTED buildings, and wonders if(listMode ~= LISTMODE.PRODUCTION) then --If we are purchasing, then buildings don't have to be displayed in a nested way -- Populate Districts ------------------------ districtList = listIM:GetInstance(); districtList.Header:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_DISTRICTS"))); districtList.HeaderOn:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_DISTRICTS"))); local dL = districtList; if ( districtList.districtListIM ~= nil) then districtList.districtListIM:ResetInstances(); else districtList.districtListIM = InstanceManager:new( "DistrictListInstance", "Root", districtList.List); end for i, item in ipairs(data.DistrictPurchases) do if (item.Yield == "YIELD_GOLD" and listMode == LISTMODE.PURCHASE_GOLD) then local districtListing = districtList["districtListIM"]:GetInstance(); ResetInstanceVisibility(districtListing); districtListing.ProductionProgressArea:SetHide(true); local nameStr = Locale.Lookup(item.Name); local costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_GOLD_TEXT", item.Cost); if (item.CantAfford) then costStr = "[COLOR:Red]" .. costStr .. "[ENDCOLOR]"; end for _,hash in ipairs( m_recommendedItems) do if (item.Hash == hash.BuildItemHash) then districtListing.RecommendedIcon:SetHide(false); end end districtListing.LabelText:SetText(nameStr); districtListing.CostText:SetText(costStr); districtListing.Button:SetToolTipString(item.ToolTip); districtListing.Disabled:SetToolTipString(item.ToolTip); districtListing.Icon:SetIcon(ICON_PREFIX..item.Type); if (item.Disabled) then if(showDisabled) then districtListing.Disabled:SetHide(false); districtListing.Button:SetColor(COLOR_LOW_OPACITY); else districtListing.Button:SetHide(true); end else districtListing.Button:SetHide(false); districtListing.Disabled:SetHide(true); districtListing.Button:SetColor(0xffffffff); end districtListing.Button:SetDisabled(item.Disabled); districtListing.Button:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); districtListing.Button:RegisterCallback( Mouse.eLClick, function() PurchaseDistrict(data.City, item); end); end end -- Populate Buildings ------------------------ buildingList = listIM:GetInstance(); buildingList.Header:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_BUILDINGS"))); buildingList.HeaderOn:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_BUILDINGS"))); local bL = buildingList; if ( buildingList.buildingListIM ~= nil ) then buildingList.buildingListIM:ResetInstances(); else buildingList.buildingListIM = InstanceManager:new( "BuildingListInstance", "Root", buildingList.List); end for i, item in ipairs(data.BuildingPurchases) do if ((item.Yield == "YIELD_GOLD" and listMode == LISTMODE.PURCHASE_GOLD) or (item.Yield == "YIELD_FAITH" and listMode == LISTMODE.PURCHASE_FAITH)) then local buildingListing = buildingList["buildingListIM"]:GetInstance(); ResetInstanceVisibility(buildingListing); buildingListing.ProductionProgressArea:SetHide(true); -- Since this is DEFINITELY a purchase instance, hide the progress bar local nameStr = Locale.Lookup(item.Name); local costStr; if (item.Yield == "YIELD_GOLD") then costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_GOLD_TEXT", item.Cost); else costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_FAITH_TEXT", item.Cost); end if item.CantAfford then costStr = "[COLOR:Red]" .. costStr .. "[ENDCOLOR]"; end for _,hash in ipairs( m_recommendedItems) do if(item.Hash == hash.BuildItemHash) then buildingListing.RecommendedIcon:SetHide(false); end end buildingListing.LabelText:SetText(nameStr); buildingListing.CostText:SetText(costStr); buildingListing.Button:SetToolTipString(item.ToolTip); buildingListing.Disabled:SetToolTipString(item.ToolTip); buildingListing.Icon:SetIcon(ICON_PREFIX..item.Type); if (item.Disabled) then if(showDisabled) then buildingListing.Disabled:SetHide(false); buildingListing.Button:SetColor(COLOR_LOW_OPACITY); else buildingListing.Button:SetHide(true); end else buildingListing.Button:SetHide(false); buildingListing.Disabled:SetHide(true); buildingListing.Button:SetColor(0xffffffff); end buildingListing.Button:SetDisabled(item.Disabled); if(not IsTutorialRunning()) then buildingListing.Button:RegisterCallback( Mouse.eRClick, function() LuaEvents.OpenCivilopedia(item.Type); end); end buildingListing.Button:RegisterCallback( Mouse.eLClick, function() PurchaseBuilding(data.City, item); end); end end buildingList.List:CalculateSize(); buildingList.List:ReprocessAnchoring(); if (buildingList.List:GetSizeY()==0) then buildingList.Top:SetHide(true); else m_maxPurchaseSize = m_maxPurchaseSize + HEADER_Y + SEPARATOR_Y; buildingList.Header:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); buildingList.Header:RegisterCallback( Mouse.eLClick, function() OnExpand(bL); end); buildingList.HeaderOn:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); buildingList.HeaderOn:RegisterCallback( Mouse.eLClick, function() OnCollapse(bL); end); end if( listMode== LISTMODE.PURCHASE_GOLD) then purchGoldBuildingList = bL; elseif (listMode == LISTMODE.PURCHASE_FAITH) then purchFaithBuildingList = bL; end end -- End if NOT LISTMODE.PRODUCTION -- Populate Units ------------------------ local primaryColor, secondaryColor = UI.GetPlayerColors( Players[Game.GetLocalPlayer()]:GetID() ); local darkerFlagColor :number = DarkenLightenColor(primaryColor,(-85),255); local brighterFlagColor :number = DarkenLightenColor(primaryColor,90,255); local brighterIconColor :number = DarkenLightenColor(secondaryColor,20,255); local darkerIconColor :number = DarkenLightenColor(secondaryColor,-30,255); unitList = listIM:GetInstance(); unitList.Header:SetText(Locale.ToUpper(Locale.Lookup("LOC_TECH_FILTER_UNITS"))); unitList.HeaderOn:SetText(Locale.ToUpper(Locale.Lookup("LOC_TECH_FILTER_UNITS"))); local uL = unitList; if ( unitList.unitListIM ~= nil ) then unitList.unitListIM:ResetInstances(); else unitList.unitListIM = InstanceManager:new( "UnitListInstance", "Root", unitList.List); end if ( unitList.civilianListIM ~= nil ) then unitList.civilianListIM:ResetInstances(); else unitList.civilianListIM = InstanceManager:new( "CivilianListInstance", "Root", unitList.List); end local unitData; if(listMode == LISTMODE.PRODUCTION) then unitData = data.UnitItems; else unitData = data.UnitPurchases; end for i, item in ipairs(unitData) do local unitListing; if ((item.Yield == "YIELD_GOLD" and listMode == LISTMODE.PURCHASE_GOLD) or (item.Yield == "YIELD_FAITH" and listMode == LISTMODE.PURCHASE_FAITH) or listMode == LISTMODE.PRODUCTION) then if (item.Civilian) then unitListing = unitList["civilianListIM"]:GetInstance(); else unitListing = unitList["unitListIM"]:GetInstance(); end ResetInstanceVisibility(unitListing); -- Check to see if this item is recommended for _,hash in ipairs( m_recommendedItems) do if(item.Hash == hash.BuildItemHash) then unitListing.RecommendedIcon:SetHide(false); end end local costStr = ""; local costStrTT = ""; if(listMode == LISTMODE.PRODUCTION) then -- ProductionQueue: We need to check that there isn't already one of these in the queue if(prodQueue[cityID][1] and prodQueue[cityID][1].entry.Hash == item.Hash) then item.TurnsLeft = math.ceil(item.Cost / cityData.ProductionPerTurn); item.Progress = 0; end -- Production meter progress for parent unit if(item.Progress > 0) then unitListing.ProductionProgressArea:SetHide(false); local unitProgress = item.Progress/item.Cost; if (unitProgress < 1) then unitListing.ProductionProgress:SetPercent(unitProgress); else unitListing.ProductionProgressArea:SetHide(true); end else unitListing.ProductionProgressArea:SetHide(true); end local numberOfTurns = item.TurnsLeft; if numberOfTurns == -1 then numberOfTurns = "999+"; costStrTT = Locale.Lookup("LOC_HUD_CITY_WILL_NOT_COMPLETE"); else costStrTT = numberOfTurns .. Locale.Lookup("LOC_HUD_CITY_TURNS_TO_COMPLETE", item.TurnsLeft); end costStr = numberOfTurns .. "[ICON_Turn]"; else unitListing.ProductionProgressArea:SetHide(true); if (item.Yield == "YIELD_GOLD") then costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_GOLD_TEXT", item.Cost); else costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_FAITH_TEXT", item.Cost); end if item.CantAfford then costStr = "[COLOR:Red]" .. costStr .. "[ENDCOLOR]"; end end -- PQ: Check if we already have max spies including queued if(item.Hash == GameInfo.Units["UNIT_SPY"].Hash) then local localDiplomacy = localPlayer:GetDiplomacy(); local spyCap = localDiplomacy:GetSpyCapacity(); local numberOfSpies = 0; -- Count our spies local localPlayerUnits:table = localPlayer:GetUnits(); for i, unit in localPlayerUnits:Members() do local unitInfo:table = GameInfo.Units[unit:GetUnitType()]; if unitInfo.Spy then numberOfSpies = numberOfSpies + 1; end end -- Loop through all players to see if they have any of our captured spies local players:table = Game.GetPlayers(); for i, player in ipairs(players) do local playerDiplomacy:table = player:GetDiplomacy(); local numCapturedSpies:number = playerDiplomacy:GetNumSpiesCaptured(); for i=0,numCapturedSpies-1,1 do local spyInfo:table = playerDiplomacy:GetNthCapturedSpy(player:GetID(), i); if spyInfo and spyInfo.OwningPlayer == Game.GetLocalPlayer() then numberOfSpies = numberOfSpies + 1; end end end -- Count travelling spies if localDiplomacy then local numSpiesOffMap:number = localDiplomacy:GetNumSpiesOffMap(); for i=0,numSpiesOffMap-1,1 do local spyOffMapInfo:table = localDiplomacy:GetNthOffMapSpy(Game.GetLocalPlayer(), i); if spyOffMapInfo and spyOffMapInfo.ReturnTurn ~= -1 then numberOfSpies = numberOfSpies + 1; end end end if(spyCap > numberOfSpies) then for _,city in pairs(prodQueue) do for _,qi in pairs(city) do if(qi.entry.Hash == item.Hash) then numberOfSpies = numberOfSpies + 1; end end end if(numberOfSpies >= spyCap) then item.Disabled = true; -- No existing localization string for "Need more spy slots" so we'll just gray it out -- item.ToolTip = item.ToolTip .. "[NEWLINE][NEWLINE][COLOR:Red]" .. Locale.Lookup("???"); end end end -- PQ: Check if we already have max traders queued if(item.Hash == GameInfo.Units["UNIT_TRADER"].Hash) then local playerTrade :table = localPlayer:GetTrade(); local routesActive :number = playerTrade:GetNumOutgoingRoutes(); local routesCapacity:number = playerTrade:GetOutgoingRouteCapacity(); local routesQueued :number = 0; if(routesCapacity >= routesActive) then for _,city in pairs(prodQueue) do for _,qi in pairs(city) do if(qi.entry.Hash == item.Hash) then routesQueued = routesQueued + 1; end end end if(routesActive + routesQueued >= routesCapacity) then item.Disabled = true; if(not string.find(item.ToolTip, "[COLOR:Red]")) then item.ToolTip = item.ToolTip .. "[NEWLINE][NEWLINE][COLOR:Red]" .. Locale.Lookup("LOC_UNIT_TRAIN_FULL_TRADE_ROUTE_CAPACITY"); end end end end local nameStr = Locale.Lookup("{1_Name}", item.Name); unitListing.LabelText:SetText(nameStr); unitListing.CostText:SetText(costStr); if(costStrTT ~= "") then unitListing.CostText:SetToolTipString(costStrTT); end unitListing.TrainUnit:SetToolTipString(item.ToolTip); unitListing.Disabled:SetToolTipString(item.ToolTip); -- Show/hide religion indicator icon if unitListing.ReligionIcon then local showReligionIcon:boolean = false; if item.ReligiousStrength and item.ReligiousStrength > 0 then if unitListing.ReligionIcon then local religionType = data.City:GetReligion():GetMajorityReligion(); if religionType > 0 then local religion:table = GameInfo.Religions[religionType]; local religionIcon:string = "ICON_" .. religion.ReligionType; local religionColor:number = UI.GetColorValue(religion.Color); unitListing.ReligionIcon:SetIcon(religionIcon); unitListing.ReligionIcon:SetColor(religionColor); unitListing.ReligionIcon:LocalizeAndSetToolTip(religion.Name); unitListing.ReligionIcon:SetHide(false); showReligionIcon = true; end end end unitListing.ReligionIcon:SetHide(not showReligionIcon); end -- Set Icon color and backing local textureName = TEXTURE_BASE; if item.Type ~= -1 then if (GameInfo.Units[item.Type].Combat ~= 0 or GameInfo.Units[item.Type].RangedCombat ~= 0) then -- Need a simpler what to test if the unit is a combat unit or not. if "DOMAIN_SEA" == GameInfo.Units[item.Type].Domain then textureName = TEXTURE_NAVAL; else textureName = TEXTURE_BASE; end else if GameInfo.Units[item.Type].MakeTradeRoute then textureName = TEXTURE_TRADE; elseif "FORMATION_CLASS_SUPPORT" == GameInfo.Units[item.Type].FormationClass then textureName = TEXTURE_SUPPORT; elseif item.ReligiousStrength > 0 then textureName = TEXTURE_RELIGION; else textureName = TEXTURE_CIVILIAN; end end end -- Set colors and icons for the flag instance unitListing.FlagBase:SetTexture(textureName); unitListing.FlagBaseOutline:SetTexture(textureName); unitListing.FlagBaseDarken:SetTexture(textureName); unitListing.FlagBaseLighten:SetTexture(textureName); unitListing.FlagBase:SetColor( primaryColor ); unitListing.FlagBaseOutline:SetColor( primaryColor ); unitListing.FlagBaseDarken:SetColor( darkerFlagColor ); unitListing.FlagBaseLighten:SetColor( brighterFlagColor ); unitListing.Icon:SetColor( secondaryColor ); unitListing.Icon:SetIcon(ICON_PREFIX..item.Type); -- Handle if the item is disabled if (item.Disabled) then if(showDisabled) then unitListing.Disabled:SetHide(false); unitListing.TrainUnit:SetColor(COLOR_LOW_OPACITY); unitListing.RecommendedIcon:SetHide(true); else unitListing.TrainUnit:SetHide(true); end else unitListing.TrainUnit:SetHide(false); unitListing.Disabled:SetHide(true); unitListing.TrainUnit:SetColor(0xffffffff); end unitListing.TrainUnit:SetDisabled(item.Disabled); unitListing.TrainUnit:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); if (listMode == LISTMODE.PRODUCTION) then unitListing.TrainUnit:RegisterCallback( Mouse.eLClick, function() QueueUnit(data.City, item, m_isCONTROLpressed); end); unitListing.TrainUnit:RegisterCallback( Mouse.eMClick, function() QueueUnit(data.City, item, true); RecenterCameraToSelectedCity(); end); else unitListing.TrainUnit:RegisterCallback( Mouse.eLClick, function() PurchaseUnit(data.City, item); end); end if(not IsTutorialRunning()) then unitListing.TrainUnit:RegisterCallback( Mouse.eRClick, function() LuaEvents.OpenCivilopedia(item.Type); end); end unitListing.TrainUnit:SetTag(UITutorialManager:GetHash(item.Type)); -- Controls for training unit corps and armies. -- Want a special text string for this!! #NEW TEXT #LOCALIZATION - "You can only directly build corps and armies once you have constructed a military academy." -- LOC_UNIT_TRAIN_NEED_MILITARY_ACADEMY if item.Corps or item.Army then --if (item.Disabled) then -- if(showDisabled) then -- unitListing.CorpsDisabled:SetHide(false); -- unitListing.ArmyDisabled:SetHide(false); -- end --end unitListing.CorpsArmyDropdownArea:SetHide(false); unitListing.CorpsArmyDropdownButton:RegisterCallback( Mouse.eLClick, function() local isExpanded = unitListing.CorpsArmyArrow:IsSelected(); unitListing.CorpsArmyArrow:SetSelected(not isExpanded); unitListing.ArmyCorpsDrawer:SetHide(not isExpanded); unitList.List:CalculateSize(); unitList.List:ReprocessAnchoring(); unitList.Top:CalculateSize(); unitList.Top:ReprocessAnchoring(); if(listMode == LISTMODE.PRODUCTION) then Controls.ProductionList:CalculateSize(); Controls.ProductionListScroll:CalculateSize(); elseif(listMode == LISTMODE.PURCHASE_GOLD) then Controls.PurchaseList:CalculateSize(); Controls.PurchaseListScroll:CalculateSize(); elseif(listMode == LISTMODE.PURCHASE_FAITH) then Controls.PurchaseFaithList:CalculateSize(); Controls.PurchaseFaithListScroll:CalculateSize(); end end); end if item.Corps then -- Check to see if this item is recommended for _,hash in ipairs( m_recommendedItems) do if(item.Hash == hash.BuildItemHash) then unitListing.CorpsRecommendedIcon:SetHide(false); end end unitListing.CorpsButtonContainer:SetHide(false); -- Production meter progress for corps unit if (listMode == LISTMODE.PRODUCTION) then -- ProductionQueue: We need to check that there isn't already one of these in the queue if(IsHashInQueue(selectedCity, item.Hash)) then item.CorpsTurnsLeft = math.ceil(item.CorpsCost / cityData.ProductionPerTurn); item.Progress = 0; end if(item.Progress > 0) then unitListing.ProductionCorpsProgressArea:SetHide(false); local unitProgress = item.Progress/item.CorpsCost; if (unitProgress < 1) then unitListing.ProductionCorpsProgress:SetPercent(unitProgress); else unitListing.ProductionCorpsProgressArea:SetHide(true); end else unitListing.ProductionCorpsProgressArea:SetHide(true); end local turnsStr = item.CorpsTurnsLeft .. "[ICON_Turn]"; local turnsStrTT = item.CorpsTurnsLeft .. Locale.Lookup("LOC_HUD_CITY_TURNS_TO_COMPLETE", item.CorpsTurnsLeft); unitListing.CorpsCostText:SetText(turnsStr); unitListing.CorpsCostText:SetToolTipString(turnsStrTT); else unitListing.ProductionCorpsProgressArea:SetHide(true); if (item.Yield == "YIELD_GOLD") then costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_GOLD_TEXT", item.CorpsCost); else costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_FAITH_TEXT", item.CorpsCost); end if (item.CorpsDisabled) then if (showDisabled) then unitListing.CorpsDisabled:SetHide(false); end costStr = "[COLOR:Red]" .. costStr .. "[ENDCOLOR]"; end unitListing.CorpsCostText:SetText(costStr); end unitListing.CorpsLabelIcon:SetText(item.CorpsName); unitListing.CorpsLabelText:SetText(nameStr); unitListing.CorpsFlagBase:SetTexture(textureName); unitListing.CorpsFlagBaseOutline:SetTexture(textureName); unitListing.CorpsFlagBaseDarken:SetTexture(textureName); unitListing.CorpsFlagBaseLighten:SetTexture(textureName); unitListing.CorpsFlagBase:SetColor( primaryColor ); unitListing.CorpsFlagBaseOutline:SetColor( primaryColor ); unitListing.CorpsFlagBaseDarken:SetColor( darkerFlagColor ); unitListing.CorpsFlagBaseLighten:SetColor( brighterFlagColor ); unitListing.CorpsIcon:SetColor( secondaryColor ); unitListing.CorpsIcon:SetIcon(ICON_PREFIX..item.Type); unitListing.TrainCorpsButton:SetToolTipString(item.CorpsTooltip); unitListing.CorpsDisabled:SetToolTipString(item.CorpsTooltip); if (listMode == LISTMODE.PRODUCTION) then unitListing.TrainCorpsButton:RegisterCallback( Mouse.eLClick, function() QueueUnitCorps(data.City, item); end); unitListing.TrainCorpsButton:RegisterCallback( Mouse.eMClick, function() QueueUnitCorps(data.City, item, true); RecenterCameraToSelectedCity(); end); else unitListing.TrainCorpsButton:RegisterCallback( Mouse.eLClick, function() PurchaseUnitCorps(data.City, item); end); end end if item.Army then -- Check to see if this item is recommended for _,hash in ipairs( m_recommendedItems) do if(item.Hash == hash.BuildItemHash) then unitListing.ArmyRecommendedIcon:SetHide(false); end end unitListing.ArmyButtonContainer:SetHide(false); if (listMode == LISTMODE.PRODUCTION) then -- ProductionQueue: We need to check that there isn't already one of these in the queue if(IsHashInQueue(selectedCity, item.Hash)) then item.ArmyTurnsLeft = math.ceil(item.ArmyCost / cityData.ProductionPerTurn); item.Progress = 0; end if(item.Progress > 0) then unitListing.ProductionArmyProgressArea:SetHide(false); local unitProgress = item.Progress/item.ArmyCost; unitListing.ProductionArmyProgress:SetPercent(unitProgress); if (unitProgress < 1) then unitListing.ProductionArmyProgress:SetPercent(unitProgress); else unitListing.ProductionArmyProgressArea:SetHide(true); end else unitListing.ProductionArmyProgressArea:SetHide(true); end local turnsStrTT:string = ""; local turnsStr:string = ""; local numberOfTurns = item.ArmyTurnsLeft; if numberOfTurns == -1 then numberOfTurns = "999+"; turnsStrTT = Locale.Lookup("LOC_HUD_CITY_WILL_NOT_COMPLETE"); else turnsStrTT = numberOfTurns .. Locale.Lookup("LOC_HUD_CITY_TURNS_TO_COMPLETE", item.ArmyTurnsLeft); end turnsStr = numberOfTurns .. "[ICON_Turn]"; unitListing.ArmyCostText:SetText(turnsStr); unitListing.ArmyCostText:SetToolTipString(turnsStrTT); else unitListing.ProductionArmyProgressArea:SetHide(true); if (item.Yield == "YIELD_GOLD") then costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_GOLD_TEXT", item.ArmyCost); else costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_FAITH_TEXT", item.ArmyCost); end if (item.ArmyDisabled) then if (showDisabled) then unitListing.ArmyDisabled:SetHide(false); end costStr = "[COLOR:Red]" .. costStr .. "[ENDCOLOR]"; end unitListing.ArmyCostText:SetText(costStr); end unitListing.ArmyLabelIcon:SetText(item.ArmyName); unitListing.ArmyLabelText:SetText(nameStr); unitListing.ArmyFlagBase:SetTexture(textureName); unitListing.ArmyFlagBaseOutline:SetTexture(textureName); unitListing.ArmyFlagBaseDarken:SetTexture(textureName); unitListing.ArmyFlagBaseLighten:SetTexture(textureName); unitListing.ArmyFlagBase:SetColor( primaryColor ); unitListing.ArmyFlagBaseOutline:SetColor( primaryColor ); unitListing.ArmyFlagBaseDarken:SetColor( darkerFlagColor ); unitListing.ArmyFlagBaseLighten:SetColor( brighterFlagColor ); unitListing.ArmyIcon:SetColor( secondaryColor ); unitListing.ArmyIcon:SetIcon(ICON_PREFIX..item.Type); unitListing.TrainArmyButton:SetToolTipString(item.ArmyTooltip); unitListing.ArmyDisabled:SetToolTipString(item.ArmyTooltip); if (listMode == LISTMODE.PRODUCTION) then unitListing.TrainArmyButton:RegisterCallback( Mouse.eLClick, function() QueueUnitArmy(data.City, item); end); unitListing.TrainArmyButton:RegisterCallback( Mouse.eMClick, function() QueueUnitArmy(data.City, item, true); RecenterCameraToSelectedCity(); end); else unitListing.TrainArmyButton:RegisterCallback( Mouse.eLClick, function() PurchaseUnitArmy(data.City, item); end); end end end -- end faith/gold check end -- end iteration through units unitList.List:CalculateSize(); unitList.List:ReprocessAnchoring(); if (unitList.List:GetSizeY()==0) then unitList.Top:SetHide(true); else m_maxProductionSize = m_maxProductionSize + HEADER_Y + SEPARATOR_Y; unitList.Header:RegisterCallback( Mouse.eLClick, function() OnExpand(uL); end); unitList.HeaderOn:RegisterCallback( Mouse.eLClick, function() OnCollapse(uL); end); end if( listMode== LISTMODE.PURCHASE_GOLD) then purchGoldUnitList = uL; elseif (listMode == LISTMODE.PURCHASE_FAITH) then purchFaithUnitList = uL; else prodUnitList = uL; end if(listMode == LISTMODE.PRODUCTION) then --Projects can only be produced, not purchased -- Populate Projects ------------------------ projectList = listIM:GetInstance(); projectList.Header:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_PROJECTS"))); projectList.HeaderOn:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_PROJECTS"))); local pL = projectList; if ( projectList.projectListIM ~= nil ) then projectList.projectListIM:ResetInstances(); else projectList.projectListIM = InstanceManager:new( "ProjectListInstance", "Root", projectList.List); end -- Check for queued project and list it as well -- if(prodQueue[cityID] and prodQueue[cityID][1] and GameInfo.Projects[prodQueue[cityID][1].entry.Hash]) then -- local activeQueueItem = prodQueue[cityID][1].entry; -- table.insert(data.ProjectItems, activeQueueItem); -- end for i, item in ipairs(data.ProjectItems) do local projectListing = projectList.projectListIM:GetInstance(); ResetInstanceVisibility(projectListing); -- Check to see if this item is recommended for _,hash in ipairs( m_recommendedItems) do if(item.Hash == hash.BuildItemHash) then projectListing.RecommendedIcon:SetHide(false); end end -- ProductionQueue: We need to check that there isn't already one of these in the queue if(IsHashInQueue(selectedCity, item.Hash)) then item.TurnsLeft = math.ceil(item.Cost / cityData.ProductionPerTurn); item.Progress = 0; end -- Production meter progress for project if(item.Progress > 0) then projectListing.ProductionProgressArea:SetHide(false); local projectProgress = item.Progress/item.Cost; if (projectProgress < 1) then projectListing.ProductionProgress:SetPercent(projectProgress); else projectListing.ProductionProgressArea:SetHide(true); end else projectListing.ProductionProgressArea:SetHide(true); end local numberOfTurns = item.TurnsLeft; if numberOfTurns == -1 then numberOfTurns = "999+"; end; local nameStr = Locale.Lookup("{1_Name}", item.Name); local turnsStr = numberOfTurns .. "[ICON_Turn]"; projectListing.LabelText:SetText(nameStr); projectListing.CostText:SetText(turnsStr); projectListing.Button:SetToolTipString(item.ToolTip); projectListing.Disabled:SetToolTipString(item.ToolTip); projectListing.Icon:SetIcon(ICON_PREFIX..item.Type); if (item.Disabled) then if(showDisabled) then projectListing.Disabled:SetHide(false); projectListing.Button:SetColor(COLOR_LOW_OPACITY); else projectListing.Button:SetHide(true); end else projectListing.Button:SetHide(false); projectListing.Disabled:SetHide(true); projectListing.Button:SetColor(0xffffffff); end projectListing.Button:SetDisabled(item.Disabled); projectListing.Button:RegisterCallback( Mouse.eLClick, function() QueueProject(data.City, item); end); projectListing.Button:RegisterCallback( Mouse.eMClick, function() QueueProject(data.City, item, true); RecenterCameraToSelectedCity(); end); if(not IsTutorialRunning()) then projectListing.Button:RegisterCallback( Mouse.eRClick, function() LuaEvents.OpenCivilopedia(item.Type); end); end projectListing.Button:SetTag(UITutorialManager:GetHash(item.Type)); end projectList.List:CalculateSize(); projectList.List:ReprocessAnchoring(); if (projectList.List:GetSizeY()==0) then projectList.Top:SetHide(true); else m_maxProductionSize = m_maxProductionSize + HEADER_Y + SEPARATOR_Y; projectList.Header:RegisterCallback( Mouse.eLClick, function() OnExpand(pL); end); projectList.HeaderOn:RegisterCallback( Mouse.eLClick, function() OnCollapse(pL); end); end prodProjectList = pL; end -- end if LISTMODE.PRODUCTION ----------------------------------- if( listMode == LISTMODE.PRODUCTION) then m_maxProductionSize = m_maxProductionSize + districtList.List:GetSizeY() + unitList.List:GetSizeY() + projectList.List:GetSizeY(); end Controls.ProductionList:CalculateSize(); Controls.ProductionListScroll:CalculateSize(); Controls.PurchaseList:CalculateSize(); Controls.PurchaseListScroll:CalculateSize(); Controls.PurchaseFaithList:CalculateSize(); Controls.PurchaseFaithListScroll:CalculateSize(); -- DEBUG %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --for _,data in ipairs( m_recommendedItems) do -- if(GameInfo.Types[data.BuildItemHash].Type ~= nil) then -- print("Hash = ".. GameInfo.Types[data.BuildItemHash].Type); -- else -- print("Invalid hash received = " .. data.BuildItemHash); -- end --end -- DEBUG %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end function OnLocalPlayerChanged() Refresh(); end function OnPlayerTurnActivated(player, isFirstTimeThisTurn) if (isFirstTimeThisTurn and Game.GetLocalPlayer() == player) then CheckAndReplaceAllQueuesForUpgrades(); Refresh(); lastProductionCompletePerCity = {}; end end -- Returns ( allReasons:string ) function ComposeFailureReasonStrings( isDisabled:boolean, results:table ) if isDisabled and results ~= nil then -- Are there any failure reasons? local pFailureReasons : table = results[CityCommandResults.FAILURE_REASONS]; if pFailureReasons ~= nil and table.count( pFailureReasons ) > 0 then -- Collect them all! local allReasons : string = ""; for i,v in ipairs(pFailureReasons) do allReasons = allReasons .. "[NEWLINE][NEWLINE][COLOR:Red]" .. Locale.Lookup(v) .. "[ENDCOLOR]"; end return allReasons; end end return ""; end function ComposeProductionCostString( iProductionProgress:number, iProductionCost:number) -- Show production progress only if there is progress present if iProductionCost ~= 0 then local TXT_COST :string = Locale.Lookup( "LOC_HUD_PRODUCTION_COST" ); local TXT_PRODUCTION :string = Locale.Lookup( "LOC_HUD_PRODUCTION" ); local costString :string = tostring(iProductionCost); if iProductionProgress > 0 then -- Only show fraction if build progress has been made. costString = tostring(iProductionProgress) .. "/" .. costString; end return "[NEWLINE][NEWLINE]" .. TXT_COST .. ": " .. costString .. " [ICON_Production] " .. TXT_PRODUCTION; end return ""; end -- Returns ( tooltip:string, subtitle:string ) function ComposeUnitCorpsStrings( sUnitName:string, sUnitDomain:string, iProdProgress:number, iCorpsCost:number ) local tooltip :string = Locale.Lookup( sUnitName ) .. " "; local subtitle :string = ""; if sUnitDomain == "DOMAIN_SEA" then tooltip = tooltip .. Locale.Lookup("LOC_UNITFLAG_FLEET_SUFFIX"); subtitle = "(" .. Locale.Lookup("LOC_HUD_UNIT_PANEL_FLEET_SUFFIX") .. ")"; else tooltip = tooltip .. Locale.Lookup("LOC_UNITFLAG_CORPS_SUFFIX"); subtitle = "(" .. Locale.Lookup("LOC_HUD_UNIT_PANEL_CORPS_SUFFIX") .. ")"; end tooltip = tooltip .. "[NEWLINE]---" .. ComposeProductionCostString( iProdProgress, iCorpsCost ); return tooltip, subtitle; end function ComposeUnitArmyStrings( sUnitName:string, sUnitDomain:string, iProdProgress:number, iArmyCost:number ) local tooltip :string = Locale.Lookup( sUnitName ) .. " "; local subtitle :string = ""; if sUnitDomain == "DOMAIN_SEA" then tooltip = tooltip .. Locale.Lookup("LOC_UNITFLAG_ARMADA_SUFFIX"); subtitle = "("..Locale.Lookup("LOC_HUD_UNIT_PANEL_ARMADA_SUFFIX")..")"; else tooltip = tooltip .. Locale.Lookup("LOC_UNITFLAG_ARMY_SUFFIX"); subtitle = "("..Locale.Lookup("LOC_HUD_UNIT_PANEL_ARMY_SUFFIX")..")"; end tooltip = tooltip .. "[NEWLINE]---" .. ComposeProductionCostString( iProdProgress, iArmyCost ); return tooltip, subtitle; end -- Returns ( isPurchaseable:boolean, kEntry:table ) function ComposeUnitForPurchase( row:table, pCity:table, sYield:string, pYieldSource:table, sCantAffordKey:string ) local YIELD_TYPE :number = GameInfo.Yields[sYield].Index; -- Should we display this option to the player? local tParameters = {}; tParameters[CityCommandTypes.PARAM_UNIT_TYPE] = row.Hash; tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = YIELD_TYPE; if CityManager.CanStartCommand( pCity, CityCommandTypes.PURCHASE, true, tParameters, false ) then local isCanStart, results = CityManager.CanStartCommand( pCity, CityCommandTypes.PURCHASE, false, tParameters, true ); local isDisabled :boolean = not isCanStart; local allReasons :string = ComposeFailureReasonStrings( isDisabled, results ); local sToolTip :string = ToolTipHelper.GetUnitToolTip( row.Hash ) .. allReasons; local isCantAfford :boolean = false; --print ( "UnitBuy ", row.UnitType,isCanStart ); -- Collect some constants so we don't need to keep calling out to get them. local nCityID :number = pCity:GetID(); local pCityGold :table = pCity:GetGold(); local TXT_INSUFFIENT_YIELD :string = "[NEWLINE][NEWLINE][COLOR:Red]" .. Locale.Lookup( sCantAffordKey ) .. "[ENDCOLOR]"; -- Affordability check if not pYieldSource:CanAfford( nCityID, row.Hash ) then sToolTip = sToolTip .. TXT_INSUFFIENT_YIELD; isDisabled = true; isCantAfford = true; end local pBuildQueue :table = pCity:GetBuildQueue(); local nProductionCost :number = pBuildQueue:GetUnitCost( row.Index ); local nProductionProgress :number = pBuildQueue:GetUnitProgress( row.Index ); sToolTip = sToolTip .. ComposeProductionCostString( nProductionProgress, nProductionCost ); local kUnit :table = { Type = row.UnitType; Name = row.Name; ToolTip = sToolTip; Hash = row.Hash; Kind = row.Kind; Civilian = row.FormationClass == "FORMATION_CLASS_CIVILIAN"; Disabled = isDisabled; CantAfford = isCantAfford, Yield = sYield; Cost = pCityGold:GetPurchaseCost( YIELD_TYPE, row.Hash, MilitaryFormationTypes.STANDARD_MILITARY_FORMATION ); ReligiousStrength = row.ReligiousStrength; CorpsTurnsLeft = 0; ArmyTurnsLeft = 0; Progress = 0; }; -- Should we present options for building Corps or Army versions? if results ~= nil then kUnit.Corps = results[CityOperationResults.CAN_TRAIN_CORPS]; kUnit.Army = results[CityOperationResults.CAN_TRAIN_ARMY]; local nProdProgress :number = pBuildQueue:GetUnitProgress( row.Index ); if kUnit.Corps then local nCost = pBuildQueue:GetUnitCorpsCost( row.Index ); kUnit.CorpsCost = pCityGold:GetPurchaseCost( YIELD_TYPE, row.Hash, MilitaryFormationTypes.CORPS_MILITARY_FORMATION ); kUnit.CorpsTooltip, kUnit.CorpsName = ComposeUnitCorpsStrings( row.Name, row.Domain, nProdProgress, nCost ); kUnit.CorpsDisabled = not pYieldSource:CanAfford( nCityID, row.Hash, MilitaryFormationTypes.CORPS_MILITARY_FORMATION ); if kUnit.CorpsDisabled then kUnit.CorpsTooltip = kUnit.CorpsTooltip .. TXT_INSUFFIENT_YIELD; end end if kUnit.Army then local nCost = pBuildQueue:GetUnitArmyCost( row.Index ); kUnit.ArmyCost = pCityGold:GetPurchaseCost( YIELD_TYPE, row.Hash, MilitaryFormationTypes.ARMY_MILITARY_FORMATION ); kUnit.ArmyTooltip, kUnit.ArmyName = ComposeUnitArmyStrings( row.Name, row.Domain, nProdProgress, nCost ); kUnit.ArmyDisabled = not pYieldSource:CanAfford( nCityID, row.Hash, MilitaryFormationTypes.ARMY_MILITARY_FORMATION ); if kUnit.ArmyDisabled then kUnit.ArmyTooltip = kUnit.ArmyTooltip .. TXT_INSUFFIENT_YIELD; end end end return true, kUnit; end return false, nil; end function ComposeBldgForPurchase( pRow:table, pCity:table, sYield:string, pYieldSource:table, sCantAffordKey:string ) local YIELD_TYPE :number = GameInfo.Yields[sYield].Index; local tParameters = {}; tParameters[CityCommandTypes.PARAM_BUILDING_TYPE] = pRow.Hash; tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = YIELD_TYPE; if CityManager.CanStartCommand( pCity, CityCommandTypes.PURCHASE, true, tParameters, false ) then local isCanStart, pResults = CityManager.CanStartCommand( pCity, CityCommandTypes.PURCHASE, false, tParameters, true ); local isDisabled :boolean = not isCanStart; local sAllReasons :string = ComposeFailureReasonStrings( isDisabled, pResults ); local sToolTip :string = ToolTipHelper.GetBuildingToolTip( pRow.Hash, playerID, pCity ) .. sAllReasons; local isCantAfford :boolean = false; -- Affordability check if not pYieldSource:CanAfford( cityID, pRow.Hash ) then sToolTip = sToolTip .. "[NEWLINE][NEWLINE][COLOR:Red]" .. Locale.Lookup(sCantAffordKey) .. "[ENDCOLOR]"; isDisabled = true; isCantAfford = true; end local pBuildQueue :table = pCity:GetBuildQueue(); local iProductionCost :number = pBuildQueue:GetBuildingCost( pRow.Index ); local iProductionProgress :number = pBuildQueue:GetBuildingProgress( pRow.Index ); sToolTip = sToolTip .. ComposeProductionCostString( iProductionProgress, iProductionCost ); local kBuilding :table = { Type = pRow.BuildingType, Name = pRow.Name, ToolTip = sToolTip, Hash = pRow.Hash, Kind = pRow.Kind, Disabled = isDisabled, CantAfford = isCantAfford, Cost = pCity:GetGold():GetPurchaseCost( YIELD_TYPE, pRow.Hash ), Yield = sYield }; return true, kBuilding; end return false, nil; end function ComposeDistrictForPurchase( pRow:table, pCity:table, sYield:string, pYieldSource:table, sCantAffordKey:string ) local YIELD_TYPE :number = GameInfo.Yields[sYield].Index; local tParameters = {}; tParameters[CityCommandTypes.PARAM_DISTRICT_TYPE] = pRow.Hash; tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = YIELD_TYPE; if CityManager.CanStartCommand( pCity, CityCommandTypes.PURCHASE, true, tParameters, false ) then local isCanStart, pResults = CityManager.CanStartCommand( pCity, CityCommandTypes.PURCHASE, false, tParameters, true ); local isDisabled :boolean = not isCanStart; local sAllReasons :string = ComposeFailureReasonStrings( isDisabled, pResults ); local sToolTip :string = ToolTipHelper.GetDistrictToolTip( pRow.Hash ) .. sAllReasons; local isCantAfford :boolean = false; -- Affordability check if not pYieldSource:CanAfford( cityID, pRow.Hash ) then sToolTip = sToolTip .. "[NEWLINE][NEWLINE][COLOR:Red]" .. Locale.Lookup(sCantAffordKey) .. "[ENDCOLOR]"; isDisabled = true; isCantAfford = true; end local pBuildQueue :table = pCity:GetBuildQueue(); local iProductionCost :number = pBuildQueue:GetDistrictCost( pRow.Index ); local iProductionProgress :number = pBuildQueue:GetDistrictProgress( pRow.Index ); sToolTip = sToolTip .. ComposeProductionCostString( iProductionProgress, iProductionCost ); local kDistrict :table = { Type = pRow.DistrictType, Name = pRow.Name, ToolTip = sToolTip, Hash = pRow.Hash, Kind = pRow.Kind, Disabled = isDisabled, CantAfford = isCantAfford, Cost = pCity:GetGold():GetPurchaseCost( YIELD_TYPE, pRow.Hash ), Yield = sYield }; return true, kDistrict; end return false, nil; end -- =========================================================================== function Refresh(persistCollapse) local playerID :number = Game.GetLocalPlayer(); local pPlayer :table = Players[playerID]; if (pPlayer == nil) then return; end local selectedCity = UI.GetHeadSelectedCity(); if (selectedCity ~= nil) then local cityGrowth = selectedCity:GetGrowth(); local cityCulture = selectedCity:GetCulture(); local buildQueue = selectedCity:GetBuildQueue(); local playerTreasury= pPlayer:GetTreasury(); local playerReligion= pPlayer:GetReligion(); local cityGold = selectedCity:GetGold(); local cityBuildings = selectedCity:GetBuildings(); local cityDistricts = selectedCity:GetDistricts(); local cityID = selectedCity:GetID(); local cityData = GetCityData(selectedCity); local cityPlot = Map.GetPlot(selectedCity:GetX(), selectedCity:GetY()); if(not prodQueue[cityID]) then prodQueue[cityID] = {}; end CheckAndReplaceQueueForUpgrades(selectedCity); local new_data = { City = selectedCity, Population = selectedCity:GetPopulation(), Owner = selectedCity:GetOwner(), Damage = pPlayer:GetDistricts():FindID( selectedCity:GetDistrictID() ):GetDamage(), TurnsUntilGrowth = cityGrowth:GetTurnsUntilGrowth(), CurrentTurnsLeft = buildQueue:GetTurnsLeft(), FoodSurplus = cityGrowth:GetFoodSurplus(), CulturePerTurn = cityCulture:GetCultureYield(), TurnsUntilExpansion = cityCulture:GetTurnsUntilExpansion(), DistrictItems = {}, BuildingItems = {}, UnitItems = {}, ProjectItems = {}, BuildingPurchases = {}, UnitPurchases = {}, DistrictPurchases = {}, }; local currentProductionHash = buildQueue:GetCurrentProductionTypeHash(); for row in GameInfo.Districts() do if row.Hash == currentProductionHash then new_data.CurrentProduction = row.Name; end local isInPanelList :boolean = not row.InternalOnly; local bHasProducedDistrict :boolean = cityDistricts:HasDistrict( row.Index ); local isInQueue :boolean = IsHashInQueue( selectedCity, row.Hash ); local turnsLeft :number = buildQueue:GetTurnsLeft( row.DistrictType ); if (isInPanelList or isInQueue) and ( buildQueue:CanProduce( row.Hash, true ) or bHasProducedDistrict or isInQueue ) then local isCanProduceExclusion, results = buildQueue:CanProduce( row.Hash, false, true ); local isDisabled :boolean = not isCanProduceExclusion; if(isInQueue) then bHasProducedDistrict = true; turnsLeft = nil; isDisabled = true; end -- If at least one valid plot is found where the district can be built, consider it buildable. local plots :table = GetCityRelatedPlotIndexesDistrictsAlternative( selectedCity, row.Hash ); if plots == nil or table.count(plots) == 0 then -- No plots available for district. Has player had already started building it? local isPlotAllocated :boolean = false; local pDistricts :table = selectedCity:GetDistricts(); for _, pCityDistrict in pDistricts:Members() do if row.Index == pCityDistrict:GetType() then isPlotAllocated = true; break; end end -- If not, this district can't be built. Guarantee that isDisabled is set. if not isPlotAllocated then isDisabled = true; end end local allReasons :string = ComposeFailureReasonStrings( isDisabled, results ); local sToolTip :string = ToolTipHelper.GetToolTip(row.DistrictType, Game.GetLocalPlayer()) .. allReasons; local iProductionCost :number = buildQueue:GetDistrictCost( row.Index ); local iProductionProgress :number = buildQueue:GetDistrictProgress( row.Index ); sToolTip = sToolTip .. ComposeProductionCostString( iProductionProgress, iProductionCost ); table.insert( new_data.DistrictItems, { Type = row.DistrictType, Name = row.Name, ToolTip = sToolTip, Hash = row.Hash, Kind = row.Kind, TurnsLeft = turnsLeft, Disabled = isDisabled, Repair = cityDistricts:IsPillaged( row.Index ), Contaminated = cityDistricts:IsContaminated( row.Index ), Cost = iProductionCost, Progress = iProductionProgress, HasBeenBuilt = bHasProducedDistrict }); end -- Can it be purchased with gold? local isAllowed, kDistrict = ComposeDistrictForPurchase( row, selectedCity, "YIELD_GOLD", playerTreasury, "LOC_BUILDING_INSUFFICIENT_FUNDS" ); if isAllowed then table.insert( new_data.DistrictPurchases, kDistrict ); end end for row in GameInfo.Buildings() do if row.Hash == currentProductionHash then new_data.CurrentProduction = row.Name; end -- PQ: Determine if we have requirements in the queue local hasPrereqTech = row.PrereqTech == nil; local hasPrereqCivic = row.PrereqCivic == nil; local isPrereqDistrictInQueue = false; local disabledTooltip = nil; local doShow = true; if(not row.IsWonder) then local prereqTech = GameInfo.Technologies[row.PrereqTech]; local prereqCivic = GameInfo.Civics[row.PrereqCivic]; local prereqDistrict = GameInfo.Districts[row.PrereqDistrict]; if(prereqTech and pPlayer:GetTechs():HasTech(prereqTech.Index)) then hasPrereqTech = true; end if(prereqCivic and pPlayer:GetCulture():HasCivic(prereqCivic.Index)) then hasPrereqCivic = true; end if((prereqDistrict and IsHashInQueue( selectedCity, prereqDistrict.Hash)) or cityDistricts:HasDistrict(prereqDistrict.Index, true)) then isPrereqDistrictInQueue = true; if(not IsHashInQueue( selectedCity, prereqDistrict.Hash )) then if(cityDistricts:IsPillaged(prereqDistrict.Index)) then disabledTooltip = Locale.Lookup("LOC_BUILDING_CONSTRUCT_DISTRICT_IS_PILLAGED"); elseif(cityDistricts:IsContaminated(prereqDistrict.Index)) then disabledTooltip = Locale.Lookup("LOC_BUILDING_CONSTRUCT_DISTRICT_IS_CONTAMINATED"); end end end if(not isPrereqDistrictInQueue) then for replacesRow in GameInfo.DistrictReplaces() do if(row.PrereqDistrict == replacesRow.ReplacesDistrictType) then local replacementDistrict = GameInfo.Districts[replacesRow.CivUniqueDistrictType]; if((replacementDistrict and IsHashInQueue( selectedCity, replacementDistrict.Hash)) or cityDistricts:HasDistrict(replacementDistrict.Index, true)) then isPrereqDistrictInQueue = true; if(not IsHashInQueue( selectedCity, replacementDistrict.Hash )) then if(cityDistricts:IsPillaged(replacementDistrict.Index)) then disabledTooltip = Locale.Lookup("LOC_BUILDING_CONSTRUCT_DISTRICT_IS_PILLAGED"); elseif(cityDistricts:IsContaminated(replacementDistrict.Index)) then disabledTooltip = Locale.Lookup("LOC_BUILDING_CONSTRUCT_DISTRICT_IS_CONTAMINATED"); end end end break; end end end if(not isPrereqDistrictInQueue) then local canBuild, reasons = buildQueue:CanProduce(row.BuildingType, false, true); if(not canBuild and reasons) then local pFailureReasons = reasons[CityCommandResults.FAILURE_REASONS]; if pFailureReasons ~= nil and table.count( pFailureReasons ) > 0 then for i,v in ipairs(pFailureReasons) do if("LOC_BUILDING_CONSTRUCT_IS_OCCUPIED" == v) then disabledTooltip = Locale.Lookup("LOC_BUILDING_CONSTRUCT_IS_OCCUPIED"); end end end end end local civTypeName = PlayerConfigurations[playerID]:GetCivilizationTypeName(); -- Check for unique buildings for replaceRow in GameInfo.BuildingReplaces() do if(replaceRow.CivUniqueBuildingType == row.BuildingType) then local traitName = "TRAIT_CIVILIZATION_" .. row.BuildingType; local isCorrectCiv = false; for traitRow in GameInfo.CivilizationTraits() do if(traitRow.TraitType == traitName and traitRow.CivilizationType == civTypeName) then isCorrectCiv = true; break; end end if(not isCorrectCiv) then doShow = false; end end if(replaceRow.ReplacesBuildingType == row.BuildingType) then local traitName = "TRAIT_CIVILIZATION_" .. replaceRow.CivUniqueBuildingType; local isCorrectCiv = false; for traitRow in GameInfo.CivilizationTraits() do if(traitRow.TraitType == traitName and traitRow.CivilizationType == civTypeName) then isCorrectCiv = true; break; end end if(isCorrectCiv) then doShow = false; end end end -- Check for building prereqs if(buildingPrereqs[row.BuildingType]) then local prereqInQueue = false; for prereqRow in GameInfo.BuildingPrereqs() do if(prereqRow.Building == row.BuildingType) then for replaceRow in GameInfo.BuildingReplaces() do if(replaceRow.ReplacesBuildingType == prereqRow.PrereqBuilding and IsHashInQueue(selectedCity, GameInfo.Buildings[replaceRow.CivUniqueBuildingType].Hash)) then prereqInQueue = true; break; end end if(prereqInQueue or IsHashInQueue(selectedCity, GameInfo.Buildings[prereqRow.PrereqBuilding].Hash)) then prereqInQueue = true; -- Check for buildings enabled by dominant religious beliefs if(GameInfo.Buildings[row.Hash].EnabledByReligion) then doShow = false; if ((table.count(cityData.Religions) > 1) or (cityData.PantheonBelief > -1)) then local modifierIDs = {}; if cityData.PantheonBelief > -1 then local beliefType = GameInfo.Beliefs[cityData.PantheonBelief].BeliefType; for belief in GameInfo.BeliefModifiers() do if belief.BeliefType == beliefType then table.insert(modifierIDs, belief.ModifierID); break; end end end if (table.count(cityData.Religions) > 0) then for _, beliefIndex in ipairs(cityData.BeliefsOfDominantReligion) do local beliefType = GameInfo.Beliefs[beliefIndex].BeliefType; for belief in GameInfo.BeliefModifiers() do if belief.BeliefType == beliefType then table.insert(modifierIDs, belief.ModifierID); end end end end if(#modifierIDs > 0) then for i=#modifierIDs, 1, -1 do if(string.find(modifierIDs[i], "ALLOW_")) then modifierIDs[i] = string.gsub(modifierIDs[i], "ALLOW", "BUILDING"); if(row.BuildingType == string.gsub(modifierIDs[i], "ALLOW", "BUILDING")) then doShow = true; end end end end end end break; end end end if(not prereqInQueue) then doShow = false; end end -- Check for river adjacency requirement if (row.RequiresAdjacentRiver and not cityPlot:IsRiver()) then doShow = false; end -- Check for wall obsolescence if(row.OuterDefenseHitPoints and pPlayer:GetCulture():HasCivic(GameInfo.Civics["CIVIC_CIVIL_ENGINEERING"].Index)) then doShow = false; end -- Check for internal only buildings if(row.InternalOnly) then doShow = false end -- Check that the player has a government of an adequate tier if(row.GovernmentTierRequirement) then local eSelectedPlayerGovernmentId:number = pPlayer:GetCulture():GetCurrentGovernment(); if eSelectedPlayerGovernmentId ~= -1 then local selectedPlayerGovernment = GameInfo.Governments[eSelectedPlayerGovernmentId]; if(selectedPlayerGovernment.Tier) then local eSelectedPlayerGovernmentTier:number = tonumber(string.sub(selectedPlayerGovernment.Tier, 5)); local buildingGovernmentTierRequirement:number = tonumber(string.sub(row.GovernmentTierRequirement, 5)); if(eSelectedPlayerGovernmentTier < buildingGovernmentTierRequirement) then doShow = false; end else doShow = false; end else doShow = false; end end -- Check if it's been built already if(hasPrereqTech and hasPrereqCivic and isPrereqDistrictInQueue and doShow) then for _, district in ipairs(cityData.BuildingsAndDistricts) do if district.isBuilt then local match = false; for _,building in ipairs(district.Buildings) do if(building.Name == Locale.Lookup(row.Name)) then if(building.isBuilt and not building.isPillaged) then doShow = false; else doShow = true; end match = true; break; end end if(match) then break; end end end else doShow = false; end end if not row.MustPurchase and ( buildQueue:CanProduce( row.Hash, true ) or (doShow and not row.IsWonder) ) then local isCanStart, results = buildQueue:CanProduce( row.Hash, false, true ); local isDisabled :boolean = false; if(row.IsWonder or not doShow) then isDisabled = not isCanStart; end local allReasons :string = ComposeFailureReasonStrings( isDisabled, results ); local sToolTip :string = ToolTipHelper.GetBuildingToolTip( row.Hash, playerID, selectedCity ) .. allReasons; local iProductionCost :number = buildQueue:GetBuildingCost( row.Index ); local iProductionProgress :number = buildQueue:GetBuildingProgress( row.Index ); if(disabledTooltip) then isDisabled = true; if(not string.find(sToolTip, "COLOR:Red")) then sToolTip = sToolTip .. "[NEWLINE][NEWLINE][COLOR:Red]" .. disabledTooltip .. "[ENDCOLOR]"; end end sToolTip = sToolTip .. ComposeProductionCostString( iProductionProgress, iProductionCost ); local iPrereqDistrict = ""; if row.PrereqDistrict ~= nil then iPrereqDistrict = row.PrereqDistrict; end table.insert( new_data.BuildingItems, { Type = row.BuildingType, Name = row.Name, ToolTip = sToolTip, Hash = row.Hash, Kind = row.Kind, TurnsLeft = buildQueue:GetTurnsLeft( row.Hash ), Disabled = isDisabled, Repair = cityBuildings:IsPillaged( row.Hash ), Cost = iProductionCost, Progress = iProductionProgress, IsWonder = row.IsWonder, PrereqDistrict = iPrereqDistrict } ); end -- Can it be purchased with gold? if row.PurchaseYield == "YIELD_GOLD" then local isAllowed, kBldg = ComposeBldgForPurchase( row, selectedCity, "YIELD_GOLD", playerTreasury, "LOC_BUILDING_INSUFFICIENT_FUNDS" ); if isAllowed then table.insert( new_data.BuildingPurchases, kBldg ); end end -- Can it be purchased with faith? if row.PurchaseYield == "YIELD_FAITH" or cityGold:IsBuildingFaithPurchaseEnabled( row.Hash ) then local isAllowed, kBldg = ComposeBldgForPurchase( row, selectedCity, "YIELD_FAITH", playerReligion, "LOC_BUILDING_INSUFFICIENT_FAITH" ); if isAllowed then table.insert( new_data.BuildingPurchases, kBldg ); end end end for row in GameInfo.Units() do if row.Hash == currentProductionHash then new_data.CurrentProduction = row.Name; end -- Can it be built normally? if not row.MustPurchase and buildQueue:CanProduce( row.Hash, true ) then local isCanProduceExclusion, results = buildQueue:CanProduce( row.Hash, false, true ); local isDisabled :boolean = not isCanProduceExclusion; local sAllReasons :string = ComposeFailureReasonStrings( isDisabled, results ); local sToolTip :string = ToolTipHelper.GetUnitToolTip( row.Hash ) .. sAllReasons; local nProductionCost :number = buildQueue:GetUnitCost( row.Index ); local nProductionProgress :number = buildQueue:GetUnitProgress( row.Index ); sToolTip = sToolTip .. ComposeProductionCostString( nProductionProgress, nProductionCost ); local kUnit :table = { Type = row.UnitType, Name = row.Name, ToolTip = sToolTip, Hash = row.Hash, Kind = row.Kind, TurnsLeft = buildQueue:GetTurnsLeft( row.Hash ), Disabled = isDisabled, Civilian = row.FormationClass == "FORMATION_CLASS_CIVILIAN", Cost = nProductionCost, Progress = nProductionProgress, Corps = false, CorpsCost = 0, CorpsTurnsLeft = 1, CorpsTooltip = "", CorpsName = "", Army = false, ArmyCost = 0, ArmyTurnsLeft = 1, ArmyTooltip = "", ArmyName = "", ReligiousStrength = row.ReligiousStrength }; -- Should we present options for building Corps or Army versions? if results ~= nil then if results[CityOperationResults.CAN_TRAIN_CORPS] then kUnit.Corps = true; kUnit.CorpsCost = buildQueue:GetUnitCorpsCost( row.Index ); kUnit.CorpsTurnsLeft = buildQueue:GetTurnsLeft( row.Hash, MilitaryFormationTypes.CORPS_MILITARY_FORMATION ); kUnit.CorpsTooltip, kUnit.CorpsName = ComposeUnitCorpsStrings( row.Name, row.Domain, nProductionProgress, kUnit.CorpsCost ); end if results[CityOperationResults.CAN_TRAIN_ARMY] then kUnit.Army = true; kUnit.ArmyCost = buildQueue:GetUnitArmyCost( row.Index ); kUnit.ArmyTurnsLeft = buildQueue:GetTurnsLeft( row.Hash, MilitaryFormationTypes.ARMY_MILITARY_FORMATION ); kUnit.ArmyTooltip, kUnit.ArmyName = ComposeUnitArmyStrings( row.Name, row.Domain, nProductionProgress, kUnit.ArmyCost ); end end table.insert(new_data.UnitItems, kUnit ); end -- Can it be purchased with gold? if row.PurchaseYield == "YIELD_GOLD" then local isAllowed, kUnit = ComposeUnitForPurchase( row, selectedCity, "YIELD_GOLD", playerTreasury, "LOC_BUILDING_INSUFFICIENT_FUNDS" ); if isAllowed then table.insert( new_data.UnitPurchases, kUnit ); end end -- Can it be purchased with faith? if row.PurchaseYield == "YIELD_FAITH" or cityGold:IsUnitFaithPurchaseEnabled( row.Hash ) then local isAllowed, kUnit = ComposeUnitForPurchase( row, selectedCity, "YIELD_FAITH", playerReligion, "LOC_BUILDING_INSUFFICIENT_FAITH" ); if isAllowed then table.insert( new_data.UnitPurchases, kUnit ); end end end for row in GameInfo.Projects() do if row.Hash == currentProductionHash then new_data.CurrentProduction = row.Name; end if buildQueue:CanProduce( row.Hash, true ) and not (row.MaxPlayerInstances and IsHashInAnyQueue(row.Hash)) then local isCanProduceExclusion, results = buildQueue:CanProduce( row.Hash, false, true ); local isDisabled :boolean = not isCanProduceExclusion; local allReasons :string = ComposeFailureReasonStrings( isDisabled, results ); local sToolTip :string = ToolTipHelper.GetProjectToolTip( row.Hash ) .. allReasons; local iProductionCost :number = buildQueue:GetProjectCost( row.Index ); local iProductionProgress :number = buildQueue:GetProjectProgress( row.Index ); sToolTip = sToolTip .. ComposeProductionCostString( iProductionProgress, iProductionCost ); table.insert(new_data.ProjectItems, { Type = row.ProjectType, Name = row.Name, ToolTip = sToolTip, Hash = row.Hash, Kind = row.Kind, TurnsLeft = buildQueue:GetTurnsLeft( row.ProjectType ), Disabled = isDisabled, Cost = iProductionCost, Progress = iProductionProgress }); end end View(new_data, persistCollapse); ResizeQueueWindow(); SaveQueues(); end end -- =========================================================================== function ShowHideDisabled() --Controls.HideDisabled:SetSelected(showDisabled); showDisabled = not showDisabled; Refresh(); end -- =========================================================================== -- LUA Event -- =========================================================================== function OnCityPanelChooseProduction() if (ContextPtr:IsHidden()) then Refresh(); else if (m_tabs.selectedControl ~= m_productionTab) then m_tabs.SelectTab(m_productionTab); end end end -- =========================================================================== -- LUA Event -- =========================================================================== function OnNotificationPanelChooseProduction() if ContextPtr:IsHidden() then Open(); --else --TESTING TO SEE IF THIS FIXES OUR TUTORIAL BUG. -- if Controls.PauseDismissWindow:IsStopped() then -- Close(); -- else -- Controls.PauseDismissWindow:Stop(); -- Open(); -- end end end -- =========================================================================== -- LUA Event -- =========================================================================== function OnCityPanelChoosePurchase() if (ContextPtr:IsHidden()) then Refresh(); OnTabChangePurchase(); m_tabs.SelectTab(m_purchaseTab); else if (m_tabs.selectedControl ~= m_purchaseTab) then OnTabChangePurchase(); m_tabs.SelectTab(m_purchaseTab); end end end -- =========================================================================== -- LUA Event -- =========================================================================== function OnCityPanelChoosePurchaseFaith() if (ContextPtr:IsHidden()) then Refresh(); OnTabChangePurchaseFaith(); m_tabs.SelectTab(m_faithTab); else if (m_tabs.selectedControl ~= m_faithTab) then OnTabChangePurchaseFaith(); m_tabs.SelectTab(m_faithTab); end end end -- =========================================================================== -- LUA Event -- Outside source is signaling production should be closed if open. -- =========================================================================== function OnProductionClose() if not ContextPtr:IsHidden() then Close(); end end -- =========================================================================== -- LUA Event -- Production opened from city banner (anchored to world view) -- =========================================================================== function OnCityBannerManagerProductionToggle() m_isQueueMode = false; if(ContextPtr:IsHidden()) then Open(); else end end -- =========================================================================== -- LUA Event -- Production opened from city information panel -- =========================================================================== function OnCityPanelProductionOpen() m_isQueueMode = false; Open(); end -- =========================================================================== -- LUA Event -- Production opened from city information panel - Purchase with faith check -- =========================================================================== function OnCityPanelPurchaseFaithOpen() m_isQueueMode = false; Open(); m_tabs.SelectTab(m_faithTab); end -- =========================================================================== -- LUA Event -- Production opened from city information panel - Purchase with gold check -- =========================================================================== function OnCityPanelPurchaseGoldOpen() m_isQueueMode = false; Open(); m_tabs.SelectTab(m_purchaseTab); end -- =========================================================================== -- LUA Event -- Production opened from a placement -- =========================================================================== function OnStrategicViewMapPlacementProductionOpen() m_isQueueMode = false; Open(); end -- =========================================================================== -- LUA Event -- =========================================================================== function OnTutorialProductionOpen() m_isQueueMode = false; Open(); end -- =========================================================================== -- LUA Event -- =========================================================================== function OnProductionOpenForQueue() m_isQueueMode = true; Open(); end -- =========================================================================== -- LUA Event -- =========================================================================== function OnCityPanelPurchasePlot() Close(); end -- =========================================================================== -- LUA Event -- Set cached values back after a hotload. -- =========================================================================== function OnGameDebugReturn( context:string, contextTable:table ) if context ~= RELOAD_CACHE_ID then return; end m_isQueueMode = contextTable["m_isQueueMode"]; local isHidden:boolean = contextTable["isHidden"]; if not isHidden then Refresh(); end end -- =========================================================================== -- Keyboard INPUT Up Handler -- =========================================================================== function KeyUpHandler( key:number ) if (key == Keys.VK_ESCAPE) then Close(); return true; end if (key == Keys.VK_CONTROL) then m_isCONTROLpressed = false; return true; end return false; end -- =========================================================================== -- Keyboard INPUT Down Handler -- =========================================================================== function KeyDownHandler( key:number ) if (key == Keys.VK_CONTROL) then m_isCONTROLpressed = true; return true; end return false; end -- =========================================================================== -- UI Event -- =========================================================================== function OnInputHandler( pInputStruct:table ) local uiMsg = pInputStruct:GetMessageType(); if uiMsg == KeyEvents.KeyUp then return KeyUpHandler( pInputStruct:GetKey() ); end; if uiMsg == KeyEvents.KeyDown then return KeyDownHandler( pInputStruct:GetKey() ); end; return false; end -- =========================================================================== -- UI Event -- =========================================================================== function OnInit( isReload:boolean ) if isReload then LuaEvents.GameDebug_GetValues( RELOAD_CACHE_ID ); end end -- =========================================================================== -- UI Event -- =========================================================================== function OnShutdown() LuaEvents.GameDebug_AddValue(RELOAD_CACHE_ID, "m_isQueueMode", m_isQueueMode ); LuaEvents.GameDebug_AddValue(RELOAD_CACHE_ID, "prodQueue", prodQueue ); LuaEvents.GameDebug_AddValue(RELOAD_CACHE_ID, "isHidden", ContextPtr:IsHidden() ); end -- =========================================================================== -- =========================================================================== function Resize() --local contentSize = (m_maxProductionSize > m_maxPurchaseSize) and m_maxProductionSize or m_maxPurchaseSize; --contentSize = contentSize + WINDOW_HEADER_Y; --local w,h = UIManager:GetScreenSizeVal(); --local maxAllowable = h - Controls.Window:GetOffsetY() - TOPBAR_Y; --local panelSizeY = (contentSize < maxAllowable) and contentSize or maxAllowable; --Controls.Window:SetSizeY(panelSizeY); --Controls.ProductionListScroll:SetSizeY(panelSizeY-Controls.WindowContent:GetOffsetY()); --Controls.PurchaseListScroll:SetSizeY(panelSizeY-Controls.WindowContent:GetOffsetY()); --Controls.DropShadow:SetSizeY(panelSizeY+100); end -- =========================================================================== -- =========================================================================== function CreateCorrectTabs() local MAX_TAB_LABEL_WIDTH = 273; local productionLabelX = Controls.ProductionTab:GetTextControl():GetSizeX(); local purchaseLabelX = Controls.PurchaseTab:GetTextControl():GetSizeX(); local purchaseFaithLabelX = Controls.PurchaseFaithTab:GetTextControl():GetSizeX(); local tabAnimControl; local tabArrowControl; local tabSizeX; local tabSizeY; Controls.ProductionTab:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.PurchaseTab:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.PurchaseFaithTab:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.MiniProductionTab:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.MiniPurchaseTab:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.MiniPurchaseFaithTab:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.MiniProductionTab:SetHide(true); Controls.MiniPurchaseTab:SetHide(true); Controls.MiniPurchaseFaithTab:SetHide(true); Controls.ProductionTab:SetHide(true); Controls.PurchaseTab:SetHide(true); Controls.PurchaseFaithTab:SetHide(true); Controls.MiniTabAnim:SetHide(true); Controls.MiniTabArrow:SetHide(true); Controls.TabAnim:SetHide(true); Controls.TabArrow:SetHide(true); local labelWidth = productionLabelX + purchaseLabelX; if GameCapabilities.HasCapability("CAPABILITY_FAITH") then labelWidth = labelWidth + purchaseFaithLabelX; end if(labelWidth > MAX_TAB_LABEL_WIDTH) then tabSizeX = 44; tabSizeY = 44; Controls.MiniProductionTab:SetHide(false); Controls.MiniPurchaseTab:SetHide(false); Controls.MiniPurchaseFaithTab:SetHide(false); Controls.MiniTabAnim:SetHide(false); Controls.MiniTabArrow:SetHide(false); m_productionTab = Controls.MiniProductionTab; m_purchaseTab = Controls.MiniPurchaseTab; m_faithTab = Controls.MiniPurchaseFaithTab; tabAnimControl = Controls.MiniTabAnim; tabArrowControl = Controls.MiniTabArrow; else tabSizeX = 42; tabSizeY = 34; Controls.ProductionTab:SetHide(false); Controls.PurchaseTab:SetHide(false); Controls.PurchaseFaithTab:SetHide(false); Controls.TabAnim:SetHide(false); Controls.TabArrow:SetHide(false); m_productionTab = Controls.ProductionTab; m_purchaseTab = Controls.PurchaseTab; m_faithTab = Controls.PurchaseFaithTab; tabAnimControl = Controls.TabAnim; tabArrowControl = Controls.TabArrow; end m_tabs = CreateTabs( Controls.TabRow, tabSizeX, tabSizeY, 0xFF331D05 ); m_tabs.AddTab( m_productionTab, OnTabChangeProduction ); if GameCapabilities.HasCapability("CAPABILITY_GOLD") then m_tabs.AddTab( m_purchaseTab, OnTabChangePurchase ); else Controls.PurchaseTab:SetHide(true); Controls.MiniPurchaseTab:SetHide(true); end if GameCapabilities.HasCapability("CAPABILITY_FAITH") then m_tabs.AddTab( m_faithTab, OnTabChangePurchaseFaith ); else Controls.MiniPurchaseFaithTab:SetHide(true); Controls.PurchaseFaithTab:SetHide(true); end m_tabs.CenterAlignTabs(0); m_tabs.SelectTab( m_productionTab ); m_tabs.AddAnimDeco(tabAnimControl, tabArrowControl); end --- ========================================================================================================= -- ====================================== PRODUCTION QUEUE MOD FUNCTIONS =================================== --- ========================================================================================================= --- ======================================================================================================= -- === Production event handlers --- ======================================================================================================= --- =========================================================================== -- Fires when a city's current production changes --- =========================================================================== function OnCityProductionChanged(playerID:number, cityID:number) Refresh(); end function OnCityProductionUpdated( ownerPlayerID:number, cityID:number, eProductionType, eProductionObject) if(ownerPlayerID ~= Game.GetLocalPlayer()) then return end lastProductionCompletePerCity[cityID] = nil; end --- =========================================================================== -- Fires when a city's production is completed -- Note: This seems to sometimes fire more than once for a turn --- =========================================================================== function OnCityProductionCompleted(playerID, cityID, orderType, unitType, canceled, typeModifier) if (playerID ~= Game.GetLocalPlayer()) then return end; local pPlayer = Players[ playerID ]; if (pPlayer == nil) then return end; local pCity = pPlayer:GetCities():FindID(cityID); if (pCity == nil) then return end; local currentTurn = Game.GetCurrentGameTurn(); -- Only one item can be produced per turn per city if(lastProductionCompletePerCity[cityID] and lastProductionCompletePerCity[cityID] == currentTurn) then return; end if(prodQueue[cityID] and prodQueue[cityID][1]) then -- Check that the production is actually completed local productionInfo = GetProductionInfoOfCity(pCity, prodQueue[cityID][1].entry.Hash); local pDistricts = pCity:GetDistricts(); local pBuildings = pCity:GetBuildings(); local isComplete = false; if(prodQueue[cityID][1].type == PRODUCTION_TYPE.BUILDING or prodQueue[cityID][1].type == PRODUCTION_TYPE.PLACED) then if(GameInfo.Districts[prodQueue[cityID][1].entry.Hash] and pDistricts:HasDistrict(GameInfo.Districts[prodQueue[cityID][1].entry.Hash].Index, true)) then isComplete = true; elseif(GameInfo.Buildings[prodQueue[cityID][1].entry.Hash] and pBuildings:HasBuilding(GameInfo.Buildings[prodQueue[cityID][1].entry.Hash].Index)) then isComplete = true; elseif(productionInfo.PercentComplete >= 1) then isComplete = true; end if(not isComplete) then return; end end -- PQ: Experimental local productionType = prodQueue[cityID][1].type; if(orderType == 0) then if(productionType == PRODUCTION_TYPE.UNIT or productionType == PRODUCTION_TYPE.CORPS or productionType == PRODUCTION_TYPE.ARMY) then if(GameInfo.Units[prodQueue[cityID][1].entry.Hash].Index == unitType) then isComplete = true; end end elseif(orderType == 1) then -- Building/wonder if(productionType == PRODUCTION_TYPE.BUILDING or productionType == PRODUCTION_TYPE.PLACED) then local buildingInfo = GameInfo.Buildings[prodQueue[cityID][1].entry.Hash]; if(buildingInfo and buildingInfo.Index == unitType) then isComplete = true; end end -- Check if this building is in our queue at all if(not isComplete and IsHashInQueue(pCity, GameInfo.Buildings[unitType].Hash)) then local removeIndex = GetIndexOfHashInQueue(pCity, GameInfo.Buildings[unitType].Hash); RemoveFromQueue(cityID, removeIndex, true); if(removeIndex == 1) then BuildFirstQueued(pCity); else Refresh(true); end SaveQueues(); return; end elseif(orderType == 2) then -- District if(productionType == PRODUCTION_TYPE.PLACED) then local districtInfo = GameInfo.Districts[prodQueue[cityID][1].entry.Hash]; if(districtInfo and districtInfo.Index == unitType) then isComplete = true; end end elseif(orderType == 3) then -- Project if(productionType == PRODUCTION_TYPE.PROJECT) then local projectInfo = GameInfo.Projects[prodQueue[cityID][1].entry.Hash]; if(projectInfo and projectInfo.Index == unitType) then isComplete = true; end end end if(not isComplete) then Refresh(true); return; end table.remove(prodQueue[cityID], 1); if(#prodQueue[cityID] > 0) then BuildFirstQueued(pCity); end lastProductionCompletePerCity[cityID] = currentTurn; SaveQueues(); end end --- ======================================================================================================= -- === Load/Save --- ======================================================================================================= --- ========================================================================== -- Updates the PlayerConfiguration with all ProductionQueue data --- ========================================================================== function SaveQueues() PlayerConfigurations[Game.GetLocalPlayer()]:SetValue("ZenProductionQueue", DataDumper(prodQueue, "prodQueue")); end --- ========================================================================== -- Loads ProductionQueue data from PlayerConfiguration, and populates the -- queue with current production information if saved info not present --- ========================================================================== function LoadQueues() local localPlayerID = Game.GetLocalPlayer(); if(PlayerConfigurations[localPlayerID]:GetValue("ZenProductionQueue") ~= nil) then loadstring(PlayerConfigurations[localPlayerID]:GetValue("ZenProductionQueue"))(); end if(not prodQueue) then prodQueue = {}; end local player = Players[localPlayerID]; local cities = player:GetCities(); for j, city in cities:Members() do local cityID = city:GetID(); local buildQueue = city:GetBuildQueue(); local currentProductionHash = buildQueue:GetCurrentProductionTypeHash(); local plotID = -1; if(not prodQueue[cityID]) then prodQueue[cityID] = {}; end if(not prodQueue[cityID][1] and currentProductionHash ~= 0) then -- Determine the type of the item local currentType = 0; local productionInfo = GetProductionInfoOfCity(city, currentProductionHash); productionInfo.Hash = currentProductionHash; if(productionInfo.Type == "UNIT") then currentType = buildQueue:GetCurrentProductionTypeModifier() + 2; elseif(productionInfo.Type == "BUILDING") then if(GameInfo.Buildings[currentProductionHash].MaxWorldInstances == 1) then currentType = PRODUCTION_TYPE.PLACED; local pCityBuildings :table = city:GetBuildings(); local kCityPlots :table = Map.GetCityPlots():GetPurchasedPlots( city ); if (kCityPlots ~= nil) then for _,plot in pairs(kCityPlots) do local kPlot:table = Map.GetPlotByIndex(plot); local wonderType = kPlot:GetWonderType(); if(wonderType ~= -1 and GameInfo.Buildings[wonderType].BuildingType == GameInfo.Buildings[currentProductionHash].BuildingType) then plotID = plot; end end end else currentType = PRODUCTION_TYPE.BUILDING; end elseif(productionInfo.Type == "DISTRICT") then currentType = PRODUCTION_TYPE.PLACED; elseif(productionInfo.Type == "PROJECT") then currentType = PRODUCTION_TYPE.PROJECT; end if(currentType == 0) then print("Could not find production type for hash: " .. currentProductionHash); end prodQueue[cityID][1] = { entry=productionInfo, type=currentType, plotID=plotID } elseif(currentProductionHash == 0) then end end -- Populate our table for building prerequisites for prereqRow in GameInfo.BuildingPrereqs() do buildingPrereqs[prereqRow.Building] = 1; end for building in GameInfo.MutuallyExclusiveBuildings() do mutuallyExclusiveBuildings[building.Building] = 1; end end --- ======================================================================================================= -- === Queue information --- ======================================================================================================= --- =========================================================================== -- Checks if there is a specific building hash in a city's Production Queue --- =========================================================================== function IsBuildingInQueue(city, buildingHash) local cityID = city:GetID(); if(prodQueue and #prodQueue[cityID] > 0) then for _, qi in pairs(prodQueue[cityID]) do if(qi.entry and qi.entry.Hash == buildingHash) then if(qi.type == PRODUCTION_TYPE.BUILDING or qi.type == PRODUCTION_TYPE.PLACED) then return true; end end end end return false; end --- =========================================================================== -- Checks if there is a specific wonder hash in all Production Queues --- =========================================================================== function IsWonderInQueue(wonderHash) for _,city in pairs(prodQueue) do for _, qi in pairs(city) do if(qi.entry and qi.entry.Hash == wonderHash) then if(qi.type == PRODUCTION_TYPE.PLACED) then return true; end end end end return false; end --- =========================================================================== -- Checks if there is a specific hash in all Production Queues --- =========================================================================== function IsHashInAnyQueue(hash) for _,city in pairs(prodQueue) do for _, qi in pairs(city) do if(qi.entry and qi.entry.Hash == hash) then return true; end end end return false; end --- =========================================================================== -- Checks if there is a specific item hash in a city's Production Queue --- =========================================================================== function IsHashInQueue(city, hash) local cityID = city:GetID(); if(prodQueue and #prodQueue[cityID] > 0) then for i, qi in pairs(prodQueue[cityID]) do if(qi.entry and qi.entry.Hash == hash) then return true; end end end return false; end --- =========================================================================== -- Returns the first instance of a hash in a city's Production Queue --- =========================================================================== function GetIndexOfHashInQueue(city, hash) local cityID = city:GetID(); if(prodQueue and #prodQueue[cityID] > 0) then for i, qi in pairs(prodQueue[cityID]) do if(qi.entry and qi.entry.Hash == hash) then return i; end end end return nil; end --- =========================================================================== -- Get the total number of districts (requiring population) -- in a city's Production Queue still requiring placement --- =========================================================================== function GetNumDistrictsInCityQueue(city) local numDistricts = 0; local cityID = city:GetID(); local pBuildQueue = city:GetBuildQueue(); if(#prodQueue[cityID] > 0) then for _,qi in pairs(prodQueue[cityID]) do if(GameInfo.Districts[qi.entry.Hash] and GameInfo.Districts[qi.entry.Hash].RequiresPopulation) then if (not pBuildQueue:HasBeenPlaced(qi.entry.Hash)) then numDistricts = numDistricts + 1; end end end end return numDistricts; end --- ============================================================================= -- [Doing it this way is ridiculous and hacky but I am tired; Please forgive me] -- Checks the Production Queue for matching reserved plots --- ============================================================================= GameInfo.Districts['DISTRICT_CITY_CENTER'].IsPlotValid = function(pCity, plotID) local cityID = pCity:GetID(); if(#prodQueue[cityID] > 0) then for j,item in ipairs(prodQueue[cityID]) do if(item.plotID == plotID) then return false; end end end return true; end --- ======================================================================================================= -- === Drag and Drop - Highlighting --- ======================================================================================================= function HighlightActiveQueueItem_DropTarget( tTargetInstance:table ) local nTargetSlot :number = tTargetInstance and tTargetInstance.ButtonContainer.id or -1; if( nTargetSlot ~= m_PrevDropTargetSlot) then if ( m_PrevDropTargetSlot ~= -1 ) then -- m_PrevDropTargetInstance.HoverArrow:SetShow( false ); m_PrevDropTargetInstance.Draggable:SetOffsetX(0); end if ( tTargetInstance ) then -- tTargetInstance.HoverArrow:SetShow( true ); tTargetInstance.Draggable:SetOffsetX(-10); end m_PrevDropTargetSlot = nTargetSlot; m_PrevDropTargetInstance = tTargetInstance; end end --- ======================================================================================================= -- === Drag and Drop --- ======================================================================================================= function GetCurrentDragTarget( tDraggedControl:table, index:number ) local tViableDragTargets :table = {}; -- also is its own map to get parent table from specific control. local cityID = UI.GetHeadSelectedCity():GetID(); -- We now need to loop through the controls for each queue item to pass to the new Drag'n'Drop system if(#m_queueIM.m_AllocatedInstances < 1) then -- There are no queue instances... bail else for i,tQueueControl in ipairs(m_queueIM.m_AllocatedInstances[1].queueListIM.m_AllocatedInstances) do if(i ~= index) then tQueueControl.ButtonContainer.id = i; tQueueControl.ButtonContainer.Instance = tQueueControl; table.insert( tViableDragTargets, tQueueControl.ButtonContainer ); end end end local tBestTarget :table = DragSupport_GetBestOverlappingControl( tDraggedControl, tViableDragTargets ); return tBestTarget; end --- =========================================================================== -- Fires when picking up an item in the Production Queue --- =========================================================================== function OnDownInQueue( dragStruct:table, queueListing:table, index:number ) UI.PlaySound("Play_UI_Click"); HighlightActiveQueueItem_DropTarget(nil); end --- =========================================================================== -- Fires when dragging an item in the Production Queue --- =========================================================================== function OnDragInQueue( dragStruct:table, queueListing:table, index:number ) local dragControl:table = dragStruct:GetControl(); local tAcceptableTarget :table = nil; if dragControl then tAcceptableTarget = GetCurrentDragTarget( dragControl, index ); tAcceptableTarget = tAcceptableTarget and tAcceptableTarget.Instance or nil; end HighlightActiveQueueItem_DropTarget( tAcceptableTarget ); end --- =========================================================================== -- Fires when dropping an item in the Production Queue --- =========================================================================== function OnDropInQueue( dragStruct:table, queueListing:table, index:number ) local dragControl:table = dragStruct:GetControl(); local tViableDragTargets :table = {}; local city = UI.GetHeadSelectedCity(); local cityID = city:GetID(); table.insert( tViableDragTargets, Controls.ProductionQueuePanel ); local tBest :table = DragSupport_GetBestOverlappingControl( dragControl, tViableDragTargets ); if(tBest ~= nil) then local tTargetQueueItem :table = GetCurrentDragTarget(dragControl, index); if(tTargetQueueItem ~= nil and index ~= tTargetQueueItem.id) then -- If the target is valid, swap them MoveQueueIndex(cityID, index, tTargetQueueItem.id); dragControl:StopSnapBack(); if(index == 1 or tTargetQueueItem.id == 1) then BuildFirstQueued(city); else Refresh(true); end elseif(not tTargetQueueItem or index == tTargetQueueItem.id) then -- Dropped on itself, just abort end else -- Dropped off the panel entirely; remove from queue dragControl:StopSnapBack(); RemoveFromQueue(cityID, index); BuildFirstQueued(city); Refresh(); end HighlightActiveQueueItem_DropTarget(nil); UI.PlaySound("Main_Menu_Mouse_Over"); end --- ======================================================================================================= -- === Queueing/Building --- ======================================================================================================= --- ========================================================================== -- Adds unit of given type to the Production Queue and builds it if requested --- ========================================================================== function QueueUnitOfType(city, unitEntry, unitType, skipToFront) local cityID = city:GetID(); local index = 1; if(not prodQueue[cityID]) then prodQueue[cityID] = {}; end if(not skipToFront) then index = #prodQueue[cityID] + 1; end table.insert(prodQueue[cityID], index, { entry=unitEntry, type=unitType, plotID=-1 }); if(#prodQueue[cityID] == 1 or skipToFront) then BuildFirstQueued(city); else Refresh(true); end UI.PlaySound("Confirm_Production"); end --- ========================================================================== -- Adds unit to the Production Queue and builds if requested --- ========================================================================== function QueueUnit(city, unitEntry, skipToFront) QueueUnitOfType(city, unitEntry, PRODUCTION_TYPE.UNIT, skipToFront); end --- ========================================================================== -- Adds corps to the Production Queue and builds if requested --- ========================================================================== function QueueUnitCorps(city, unitEntry, skipToFront) QueueUnitOfType(city, unitEntry, PRODUCTION_TYPE.CORPS, skipToFront); end --- ========================================================================== -- Adds army to the Production Queue and builds if requested --- ========================================================================== function QueueUnitArmy(city, unitEntry, skipToFront) QueueUnitOfType(city, unitEntry, PRODUCTION_TYPE.ARMY, skipToFront); end --- ========================================================================== -- Adds building to the Production Queue and builds if requested --- ========================================================================== function QueueBuilding(city, buildingEntry, skipToFront) local building :table = GameInfo.Buildings[buildingEntry.Type]; local bNeedsPlacement :boolean = building.RequiresPlacement; local pBuildQueue = city:GetBuildQueue(); if (pBuildQueue:HasBeenPlaced(buildingEntry.Hash)) then bNeedsPlacement = false; end UI.SetInterfaceMode(InterfaceModeTypes.SELECTION); if (bNeedsPlacement) then local tParameters = {}; tParameters[CityOperationTypes.PARAM_BUILDING_TYPE] = buildingEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; UI.SetInterfaceMode(InterfaceModeTypes.BUILDING_PLACEMENT, tParameters); else local cityID = city:GetID(); local plotID = -1; local buildingType = PRODUCTION_TYPE.BUILDING; if(not prodQueue[cityID]) then prodQueue[cityID] = {}; end if(building.RequiresPlacement) then local pCityBuildings :table = city:GetBuildings(); local kCityPlots :table = Map.GetCityPlots():GetPurchasedPlots( city ); if (kCityPlots ~= nil) then for _,plot in pairs(kCityPlots) do local kPlot:table = Map.GetPlotByIndex(plot); local wonderType = kPlot:GetWonderType(); if(wonderType ~= -1 and GameInfo.Buildings[wonderType].BuildingType == building.BuildingType) then plotID = plot; buildingType = PRODUCTION_TYPE.PLACED; end end end end table.insert(prodQueue[cityID], { entry=buildingEntry, type=buildingType, plotID=plotID }); if(skipToFront) then if(MoveQueueIndex(cityID, #prodQueue[cityID], 1) ~= 0) then Refresh(true); else BuildFirstQueued(city); end elseif(#prodQueue[cityID] == 1) then BuildFirstQueued(city); else Refresh(true); end UI.PlaySound("Confirm_Production"); end end --- ========================================================================== -- Adds district to the Production Queue and builds if requested --- ========================================================================== function QueueDistrict(city, districtEntry, skipToFront) UI.SetInterfaceMode(InterfaceModeTypes.SELECTION); local district :table = GameInfo.Districts[districtEntry.Type]; local bNeedsPlacement :boolean = district.RequiresPlacement; local pBuildQueue :table = city:GetBuildQueue(); if (pBuildQueue:HasBeenPlaced(districtEntry.Hash)) then bNeedsPlacement = false; end if (bNeedsPlacement) then local tParameters = {}; tParameters[CityOperationTypes.PARAM_DISTRICT_TYPE] = districtEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; UI.SetInterfaceMode(InterfaceModeTypes.DISTRICT_PLACEMENT, tParameters); else local tParameters = {}; tParameters[CityOperationTypes.PARAM_DISTRICT_TYPE] = districtEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; local cityID = city:GetID(); if(not prodQueue[cityID]) then prodQueue[cityID] = {}; end local index = 1; if(not skipToFront) then index = #prodQueue[cityID] + 1; end table.insert(prodQueue[cityID], index, { entry=districtEntry, type=PRODUCTION_TYPE.PLACED, plotID=-1, tParameters=tParameters }); if(#prodQueue[cityID] == 1 or skipToFront) then BuildFirstQueued(city); else Refresh(true); end UI.PlaySound("Confirm_Production"); end end --- ========================================================================== -- Adds project to the Production Queue and builds if requested --- ========================================================================== function QueueProject(city, projectEntry, skipToFront) local cityID = city:GetID(); if(not prodQueue[cityID]) then prodQueue[cityID] = {}; end local index = 1; if(not skipToFront) then index = #prodQueue[cityID] + 1; end table.insert(prodQueue[cityID], index, { entry=projectEntry, type=PRODUCTION_TYPE.PROJECT, plotID=-1 }); if(#prodQueue[cityID] == 1 or skipToFront) then BuildFirstQueued(city); else Refresh(true); end UI.PlaySound("Confirm_Production"); end --- =========================================================================== -- Check if removing an index would result in an empty queue --- =========================================================================== function CanRemoveFromQueue(cityID, index) local totalItemsToRemove = 1; if(prodQueue[cityID] and #prodQueue[cityID] > 1 and prodQueue[cityID][index]) then local destIndex = MoveQueueIndex(cityID, index, #prodQueue[cityID], true); if(destIndex > 0) then totalItemsToRemove = totalItemsToRemove + 1; CanRemoveFromQueue(cityID, destIndex + 1); end end if(totalItemsToRemove == #prodQueue[cityID]) then return false; else return true; end end --- =========================================================================== -- Remove a specific index from a city's Production Queue --- =========================================================================== function RemoveFromQueue(cityID, index, force) if(prodQueue[cityID] and (#prodQueue[cityID] > 1 or force) and prodQueue[cityID][index]) then local destIndex = MoveQueueIndex(cityID, index, #prodQueue[cityID]); if(destIndex > 0) then -- There was a conflict RemoveFromQueue(cityID, destIndex + 1); table.remove(prodQueue[cityID], destIndex); else table.remove(prodQueue[cityID], #prodQueue[cityID]); end return true; end return false; end --- ========================================================================== -- Directly requests the city to build a placed district/wonder using -- tParameters provided from the StrategicView callback event --- ========================================================================== function BuildPlaced(city, tParameters) -- Check if we still have enough population for a district we're about to place local districtHash = tParameters[CityOperationTypes.PARAM_DISTRICT_TYPE]; if(districtHash) then local pCityDistricts = city:GetDistricts(); local numDistricts = pCityDistricts:GetNumZonedDistrictsRequiringPopulation(); local numPossibleDistricts = pCityDistricts:GetNumAllowedDistrictsRequiringPopulation(); if(GameInfo.Districts[districtHash] and GameInfo.Districts[districtHash].RequiresPopulation and numDistricts <= numPossibleDistricts) then if(GetNumDistrictsInCityQueue(city) + numDistricts > numPossibleDistricts) then RemoveFromQueue(city:GetID(), 1); BuildFirstQueued(city); return; end end end CityManager.RequestOperation(city, CityOperationTypes.BUILD, tParameters); end --- ========================================================================== -- Builds the first item in the Production Queue --- ========================================================================== function BuildFirstQueued(pCity) local cityID = pCity:GetID(); if(prodQueue[cityID][1]) then if(prodQueue[cityID][1].type == PRODUCTION_TYPE.BUILDING) then BuildBuilding(pCity, prodQueue[cityID][1].entry); elseif(prodQueue[cityID][1].type == PRODUCTION_TYPE.UNIT) then BuildUnit(pCity, prodQueue[cityID][1].entry); elseif(prodQueue[cityID][1].type == PRODUCTION_TYPE.ARMY) then BuildUnitArmy(pCity, prodQueue[cityID][1].entry); elseif(prodQueue[cityID][1].type == PRODUCTION_TYPE.CORPS) then BuildUnitCorps(pCity, prodQueue[cityID][1].entry); elseif(prodQueue[cityID][1].type == PRODUCTION_TYPE.PLACED) then if(not prodQueue[cityID][1].tParameters) then if(GameInfo.Buildings[prodQueue[cityID][1].entry.Hash]) then BuildBuilding(pCity, prodQueue[cityID][1].entry); else ZoneDistrict(pCity, prodQueue[cityID][1].entry); end else BuildPlaced(pCity, prodQueue[cityID][1].tParameters); end elseif(prodQueue[cityID][1].type == PRODUCTION_TYPE.PROJECT) then AdvanceProject(pCity, prodQueue[cityID][1].entry); end else Refresh(true); end end --- ============================================================================ -- Lua Event -- This is fired when a district or wonder plot has been selected and confirmed --- ============================================================================ function OnStrategicViewMapPlacementProductionClose(tProductionQueueParameters) local cityID = tProductionQueueParameters.pSelectedCity:GetID(); local entry = GetProductionInfoOfCity(tProductionQueueParameters.pSelectedCity, tProductionQueueParameters.buildingHash); entry.Hash = tProductionQueueParameters.buildingHash; if(not prodQueue[cityID]) then prodQueue[cityID] = {}; end local index = 1; if(not nextDistrictSkipToFront) then index = #prodQueue[cityID] + 1; end table.insert(prodQueue[cityID], index, { entry=entry, type=PRODUCTION_TYPE.PLACED, plotID=tProductionQueueParameters.plotId, tParameters=tProductionQueueParameters.tParameters }); if(nextDistrictSkipToFront or #prodQueue[cityID] == 1) then BuildFirstQueued(tProductionQueueParameters.pSelectedCity); end Refresh(true); UI.PlaySound("Confirm_Production"); end --- =========================================================================== -- Move a city's queue item from one index to another --- =========================================================================== function MoveQueueIndex(cityID, sourceIndex, destIndex, noMove) local direction = -1; local actualDest = 0; local sourceInfo = prodQueue[cityID][sourceIndex]; if(sourceIndex < destIndex) then direction = 1; end for i=sourceIndex, math.max(destIndex-direction, 1), direction do -- Each time we swap, we need to check that there isn't a prereq that would break if(sourceInfo.type == PRODUCTION_TYPE.BUILDING and prodQueue[cityID][i+direction].type == PRODUCTION_TYPE.PLACED) then local buildingInfo = GameInfo.Buildings[sourceInfo.entry.Hash]; if(buildingInfo and buildingInfo.PrereqDistrict) then local districtInfo = GameInfo.Districts[prodQueue[cityID][i+direction].entry.Hash]; if(districtInfo and (districtInfo.DistrictType == buildingInfo.PrereqDistrict or (GameInfo.DistrictReplaces[prodQueue[cityID][i+direction].entry.Hash] and GameInfo.DistrictReplaces[prodQueue[cityID][i+direction].entry.Hash].ReplacesDistrictType == buildingInfo.PrereqDistrict))) then actualDest = i; break; end end elseif(sourceInfo.type == PRODUCTION_TYPE.PLACED and prodQueue[cityID][i+direction].type == PRODUCTION_TYPE.BUILDING) then local buildingInfo = GameInfo.Buildings[prodQueue[cityID][i+direction].entry.Hash]; local districtInfo = GameInfo.Districts[sourceInfo.entry.Hash]; if(buildingInfo and buildingInfo.PrereqDistrict) then if(districtInfo and (districtInfo.DistrictType == buildingInfo.PrereqDistrict or (GameInfo.DistrictReplaces[sourceInfo.entry.Hash] and GameInfo.DistrictReplaces[sourceInfo.entry.Hash].ReplacesDistrictType == buildingInfo.PrereqDistrict))) then actualDest = i; break; end end elseif(sourceInfo.type == PRODUCTION_TYPE.BUILDING and prodQueue[cityID][i+direction].type == PRODUCTION_TYPE.BUILDING) then local destInfo = GameInfo.Buildings[prodQueue[cityID][i+direction].entry.Hash]; local sourceBuildingInfo = GameInfo.Buildings[sourceInfo.entry.Hash]; if(GameInfo.BuildingReplaces[destInfo.BuildingType]) then destInfo = GameInfo.Buildings[GameInfo.BuildingReplaces[destInfo.BuildingType].ReplacesBuildingType]; end if(GameInfo.BuildingReplaces[sourceBuildingInfo.BuildingType]) then sourceBuildingInfo = GameInfo.Buildings[GameInfo.BuildingReplaces[sourceBuildingInfo.BuildingType].ReplacesBuildingType]; end local halt = false; for prereqRow in GameInfo.BuildingPrereqs() do if(prereqRow.Building == sourceBuildingInfo.BuildingType) then if(destInfo.BuildingType == prereqRow.PrereqBuilding) then halt = true; actualDest = i; break; end end if(prereqRow.PrereqBuilding == sourceBuildingInfo.BuildingType) then if(destInfo.BuildingType == prereqRow.Building) then halt = true; actualDest = i; break; end end end if(halt == true) then break; end end if(not noMove) then prodQueue[cityID][i], prodQueue[cityID][i+direction] = prodQueue[cityID][i+direction], prodQueue[cityID][i]; end end return actualDest; end --- =========================================================================== -- Check the entire queue for mandatory item upgrades --- =========================================================================== function CheckAndReplaceAllQueuesForUpgrades() local localPlayerId:number = Game.GetLocalPlayer(); local player = Players[localPlayerId]; if(player == nil) then return; end local cities = player:GetCities(); for j, city in cities:Members() do CheckAndReplaceQueueForUpgrades(city); end end --- =========================================================================== -- Check a city's queue for items that must be upgraded or removed -- as per tech/civic knowledge --- =========================================================================== function CheckAndReplaceQueueForUpgrades(city) local playerID = Game.GetLocalPlayer(); local pPlayer = Players[playerID]; local pTech = pPlayer:GetTechs(); local pCulture = pPlayer:GetCulture(); local buildQueue = city:GetBuildQueue(); local cityID = city:GetID(); local pBuildings = city:GetBuildings(); local civTypeName = PlayerConfigurations[playerID]:GetCivilizationTypeName(); local removeUnits = {}; if(not prodQueue[cityID]) then prodQueue[cityID] = {} end for i, qi in pairs(prodQueue[cityID]) do if(qi.type == PRODUCTION_TYPE.UNIT or qi.type == PRODUCTION_TYPE.CORPS or qi.type == PRODUCTION_TYPE.ARMY) then local unitUpgrades = GameInfo.UnitUpgrades[qi.entry.Hash]; if(unitUpgrades) then local upgradeUnit = GameInfo.Units[unitUpgrades.UpgradeUnit]; -- Check for unique units for unitReplaces in GameInfo.UnitReplaces() do if(unitReplaces.ReplacesUnitType == unitUpgrades.UpgradeUnit) then local match = false; for civTraits in GameInfo.CivilizationTraits() do if(civTraits.TraitType == "TRAIT_CIVILIZATION_" .. unitReplaces.CivUniqueUnitType and civTraits.CivilizationType == civTypeName) then upgradeUnit = GameInfo.Units[unitReplaces.CivUniqueUnitType]; match = true; break; end end if(match) then break; end end end if(upgradeUnit) then local canUpgrade = true; if(upgradeUnit.PrereqTech and not pTech:HasTech(GameInfo.Technologies[upgradeUnit.PrereqTech].Index)) then canUpgrade = false; end if(upgradeUnit.PrereqCivic and not pCulture:HasCivic(GameInfo.Civics[upgradeUnit.PrereqCivic].Index)) then canUpgrade = false; end local canBuildNewUnit = buildQueue:CanProduce( upgradeUnit.Hash, false, true ); -- Only auto replace if we CAN'T queue the old unit if(not buildQueue:CanProduce( qi.entry.Hash, true ) and canUpgrade and canBuildNewUnit) then local isCanProduceExclusion, results = buildQueue:CanProduce( upgradeUnit.Hash, false, true ); local isDisabled :boolean = not isCanProduceExclusion; local sAllReasons :string = ComposeFailureReasonStrings( isDisabled, results ); local sToolTip :string = ToolTipHelper.GetUnitToolTip( upgradeUnit.Hash ) .. sAllReasons; local nProductionCost :number = buildQueue:GetUnitCost( upgradeUnit.Index ); local nProductionProgress :number = buildQueue:GetUnitProgress( upgradeUnit.Index ); sToolTip = sToolTip .. ComposeProductionCostString( nProductionProgress, nProductionCost ); prodQueue[cityID][i].entry = { Type = upgradeUnit.UnitType, Name = upgradeUnit.Name, ToolTip = sToolTip, Hash = upgradeUnit.Hash, Kind = upgradeUnit.Kind, TurnsLeft = buildQueue:GetTurnsLeft( upgradeUnit.Hash ), Disabled = isDisabled, Civilian = upgradeUnit.FormationClass == "FORMATION_CLASS_CIVILIAN", Cost = nProductionCost, Progress = nProductionProgress, Corps = false, CorpsCost = 0, CorpsTurnsLeft = 1, CorpsTooltip = "", CorpsName = "", Army = false, ArmyCost = 0, ArmyTurnsLeft = 1, ArmyTooltip = "", ArmyName = "" }; if results ~= nil then if results[CityOperationResults.CAN_TRAIN_CORPS] then kUnit.Corps = true; kUnit.CorpsCost = buildQueue:GetUnitCorpsCost( upgradeUnit.Index ); kUnit.CorpsTurnsLeft = buildQueue:GetTurnsLeft( upgradeUnit.Hash, MilitaryFormationTypes.CORPS_MILITARY_FORMATION ); kUnit.CorpsTooltip, kUnit.CorpsName = ComposeUnitCorpsStrings( upgradeUnit.Name, upgradeUnit.Domain, nProductionProgress, kUnit.CorpsCost ); end if results[CityOperationResults.CAN_TRAIN_ARMY] then kUnit.Army = true; kUnit.ArmyCost = buildQueue:GetUnitArmyCost( upgradeUnit.Index ); kUnit.ArmyTurnsLeft = buildQueue:GetTurnsLeft( upgradeUnit.Hash, MilitaryFormationTypes.ARMY_MILITARY_FORMATION ); kUnit.ArmyTooltip, kUnit.ArmyName = ComposeUnitArmyStrings( upgradeUnit.Name, upgradeUnit.Domain, nProductionProgress, kUnit.ArmyCost ); end end elseif(canUpgrade and not canBuildNewUnit) then -- Can't build the old or new unit. Probably missing a resource. Remove from queue. table.insert(removeUnits, i); end end else local canBuildUnit = buildQueue:CanProduce( qi.entry.Hash, false, true ); if(not canBuildUnit) then table.insert(removeUnits, i); end end elseif(qi.type == PRODUCTION_TYPE.BUILDING or qi.type == PRODUCTION_TYPE.PLACED) then if(qi.entry.Repair == true and GameInfo.Buildings[qi.entry.Hash]) then local isPillaged = pBuildings:IsPillaged(GameInfo.Buildings[qi.entry.Hash].Index); if(not isPillaged) then -- Repair complete, remove from queue table.insert(removeUnits, i); end end -- Check if a queued wonder is still available if(GameInfo.Buildings[qi.entry.Hash] and GameInfo.Buildings[qi.entry.Hash].MaxWorldInstances == 1) then if(not buildQueue:CanProduce(qi.entry.Hash, true)) then table.insert(removeUnits, i); elseif(not IsCityPlotValidForWonderPlacement(city, qi.plotID, GameInfo.Buildings[qi.entry.Hash]) and not buildQueue:HasBeenPlaced(qi.entry.Hash)) then table.insert(removeUnits, i); end end end end if(#removeUnits > 0) then for i=#removeUnits, 1, -1 do local success = RemoveFromQueue(cityID, removeUnits[i]); if(success and removeUnits[i] == 1) then BuildFirstQueued(city); end end end end function IsCityPlotValidForWonderPlacement(city, plotID, wonder) if(not plotID or plotID == -1) then return true end if Map.GetPlotByIndex(plotID):CanHaveWonder(wonder.Index, city:GetOwner(), city:GetID()) then return true; else return false; end end --- ======================================================================================================= -- === UI handling --- ======================================================================================================= --- ========================================================================== -- Resize the Production Queue window to fit the items --- ========================================================================== function ResizeQueueWindow() Controls.QueueWindow:SetSizeY(1); local windowHeight = math.min(math.max(#prodQueue[UI.GetHeadSelectedCity():GetID()] * 32 + 38, 70), screenHeight-300); Controls.QueueWindow:SetSizeY(windowHeight); Controls.ProductionQueueListScroll:SetSizeY(windowHeight-38); Controls.ProductionQueueListScroll:CalculateSize(); end --- ========================================================================== -- Slide-in/hide the Production Queue panel --- ========================================================================== function CloseQueueWindow() Controls.QueueSlideIn:Reverse(); Controls.QueueWindowToggleDirection:SetText("<"); end --- ========================================================================== -- Slide-out/show the Production Queue panel --- ========================================================================== function OpenQueueWindow() Controls.QueueSlideIn:SetToBeginning(); Controls.QueueSlideIn:Play(); Controls.QueueWindowToggleDirection:SetText(">"); end --- ========================================================================== -- Toggle the visibility of the Production Queue panel --- ========================================================================== function ToggleQueueWindow() showStandaloneQueueWindow = not showStandaloneQueueWindow; if(showStandaloneQueueWindow) then OpenQueueWindow(); else CloseQueueWindow(); end end --- =============================================================================== -- Control Event -- Fires when the production panel has finished fading in -- Use this to, if it is toggled off, delay showing the Production Queue panel -- (and therefore toggle tab) unitl after the production panel is there to -- cover it up --- =============================================================================== function OnPanelFadeInComplete() if(not showStandaloneQueueWindow) then Controls.QueueAlphaIn:Play(); end end --- =========================================================================== -- Recenter the camera over the selected city -- This is here for the sake of middle mouse clicking on a production item -- which ordinarily recenters the map to the cursor position --- =========================================================================== function RecenterCameraToSelectedCity() local kCity:table = UI.GetHeadSelectedCity(); UI.LookAtPlot( kCity:GetX(), kCity:GetY() ); end function ResetSelectedCityQueue() local selectedCity = UI.GetHeadSelectedCity(); if(not selectedCity) then return end local cityID = selectedCity:GetID(); if(not cityID) then return end local buildQueue = selectedCity:GetBuildQueue(); local currentProductionHash = buildQueue:GetCurrentProductionTypeHash(); local plotID = -1; if(prodQueue[cityID]) then prodQueue[cityID] = {}; end if(currentProductionHash ~= 0) then -- Determine the type of the item local currentType = 0; local productionInfo = GetProductionInfoOfCity(selectedCity, currentProductionHash); productionInfo.Hash = currentProductionHash; if(productionInfo.Type == "UNIT") then currentType = buildQueue:GetCurrentProductionTypeModifier() + 2; elseif(productionInfo.Type == "BUILDING") then if(GameInfo.Buildings[currentProductionHash].MaxWorldInstances == 1) then currentType = PRODUCTION_TYPE.PLACED; local pCityBuildings :table = selectedCity:GetBuildings(); local kCityPlots :table = Map.GetCityPlots():GetPurchasedPlots( selectedCity ); if (kCityPlots ~= nil) then for _,plot in pairs(kCityPlots) do local kPlot:table = Map.GetPlotByIndex(plot); local wonderType = kPlot:GetWonderType(); if(wonderType ~= -1 and GameInfo.Buildings[wonderType].BuildingType == GameInfo.Buildings[currentProductionHash].BuildingType) then plotID = plot; end end end else currentType = PRODUCTION_TYPE.BUILDING; end elseif(productionInfo.Type == "DISTRICT") then currentType = PRODUCTION_TYPE.PLACED; elseif(productionInfo.Type == "PROJECT") then currentType = PRODUCTION_TYPE.PROJECT; end if(currentType == 0) then print("Could not find production type for hash: " .. currentProductionHash); end prodQueue[cityID][1] = { entry=productionInfo, type=currentType, plotID=plotID } end Refresh(); end --- ========================================================================================================= --- ========================================================================================================= --- ========================================================================================================= --- ========================================================================================================= -- ============================================= MODULE INITIALIZATION ===================================== --- ========================================================================================================= function Initialize() LoadQueues(); Controls.PauseCollapseList:Stop(); Controls.PauseDismissWindow:Stop(); CreateCorrectTabs(); Resize(); -- ===== Event listeners ===== Controls.CloseButton:RegisterCallback(Mouse.eLClick, OnClose); Controls.CloseButton:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.PauseCollapseList:RegisterEndCallback( OnCollapseTheList ); Controls.PauseDismissWindow:RegisterEndCallback( OnHide ); Controls.QueueWindowToggle:RegisterCallback(Mouse.eLClick, ToggleQueueWindow); Controls.AlphaIn:RegisterEndCallback( OnPanelFadeInComplete ) Controls.ProductionTabSelected:SetSpeed(100); Controls.QueueWindowReset:RegisterCallback(Mouse.eLClick, ResetSelectedCityQueue); ContextPtr:SetInitHandler( OnInit ); ContextPtr:SetInputHandler( OnInputHandler, true ); ContextPtr:SetShutdown( OnShutdown ); Events.CitySelectionChanged.Add( OnCitySelectionChanged ); Events.InterfaceModeChanged.Add( OnInterfaceModeChanged ); Events.UnitSelectionChanged.Add( OnUnitSelectionChanged ); Events.LocalPlayerChanged.Add( OnLocalPlayerChanged ); Events.PlayerTurnActivated.Add( OnPlayerTurnActivated ); LuaEvents.CityBannerManager_ProductionToggle.Add( OnCityBannerManagerProductionToggle ); LuaEvents.CityPanel_ChooseProduction.Add( OnCityPanelChooseProduction ); LuaEvents.CityPanel_ChoosePurchase.Add( OnCityPanelChoosePurchase ); LuaEvents.CityPanel_ProductionClose.Add( OnProductionClose ); LuaEvents.CityPanel_ProductionOpen.Add( OnCityPanelProductionOpen ); LuaEvents.CityPanel_PurchaseGoldOpen.Add( OnCityPanelPurchaseGoldOpen ); LuaEvents.CityPanel_PurchaseFaithOpen.Add( OnCityPanelPurchaseFaithOpen ); LuaEvents.CityPanel_ProductionOpenForQueue.Add( OnProductionOpenForQueue ); LuaEvents.CityPanel_PurchasePlot.Add( OnCityPanelPurchasePlot ); LuaEvents.GameDebug_Return.Add( OnGameDebugReturn ); LuaEvents.NotificationPanel_ChooseProduction.Add( OnNotificationPanelChooseProduction ); LuaEvents.StrageticView_MapPlacement_ProductionOpen.Add( OnStrategicViewMapPlacementProductionOpen ); LuaEvents.StrageticView_MapPlacement_ProductionClose.Add( OnStrategicViewMapPlacementProductionClose ); LuaEvents.Tutorial_ProductionOpen.Add( OnTutorialProductionOpen ); Events.CityProductionChanged.Add( OnCityProductionChanged ); Events.CityProductionCompleted.Add(OnCityProductionCompleted); Events.CityProductionUpdated.Add(OnCityProductionUpdated); Events.CityMadePurchase.Add(Refresh); end Initialize(); else -- =========================================================================== -- Production Panel / Purchase Panel -- =========================================================================== include( "ToolTipHelper" ); include( "InstanceManager" ); include( "TabSupport" ); include( "Civ6Common" ); include( "SupportFunctions" ); include( "AdjacencyBonusSupport"); include( "DragSupport" ); include( "CitySupport" ); -- =========================================================================== -- Constants -- =========================================================================== local RELOAD_CACHE_ID :string = "ProductionPanel"; local COLOR_LOW_OPACITY :number = 0x3fffffff; local HEADER_Y :number = 41; local WINDOW_HEADER_Y :number = 150; local TOPBAR_Y :number = 28; local SEPARATOR_Y :number = 20; local BUTTON_Y :number = 48; local DISABLED_PADDING_Y:number = 10; local TEXTURE_BASE :string = "UnitFlagBase"; local TEXTURE_CIVILIAN :string = "UnitFlagCivilian"; local TEXTURE_RELIGION :string = "UnitFlagReligion"; local TEXTURE_EMBARK :string = "UnitFlagEmbark"; local TEXTURE_FORTIFY :string = "UnitFlagFortify"; local TEXTURE_NAVAL :string = "UnitFlagNaval"; local TEXTURE_SUPPORT :string = "UnitFlagSupport"; local TEXTURE_TRADE :string = "UnitFlagTrade"; local BUILDING_IM_PREFIX :string = "buildingListingIM_"; local BUILDING_DRAWER_PREFIX :string = "buildingDrawer_"; local ICON_PREFIX :string = "ICON_"; local LISTMODE :table = {PRODUCTION = 1, PURCHASE_GOLD = 2, PURCHASE_FAITH=3}; local EXTENDED_BUTTON_HEIGHT = 60; local DEFAULT_BUTTON_HEIGHT = 48; local PRODUCTION_TYPE :table = { BUILDING = 1, UNIT = 2, CORPS = 3, ARMY = 4, PLACED = 5, PROJECT = 6 }; -- =========================================================================== -- Members -- =========================================================================== local m_queueIM = InstanceManager:new( "UnnestedList", "Top", Controls.ProductionQueueList ); local m_listIM = InstanceManager:new( "NestedList", "Top", Controls.ProductionList ); local m_purchaseListIM = InstanceManager:new( "NestedList", "Top", Controls.PurchaseList ); local m_purchaseFaithListIM = InstanceManager:new( "NestedList", "Top", Controls.PurchaseFaithList ); local m_tabs; local m_productionTab; -- Additional tracking of the tab control data so that we can select between graphical tabs and label tabs local m_purchaseTab; local m_faithTab; local m_maxProductionSize :number = 0; local m_maxPurchaseSize :number = 0; local m_isQueueMode :boolean = false; local m_TypeNames :table = {}; local m_kClickedInstance; local m_isCONTROLpressed :boolean = false; local prodBuildingList; local prodWonderList; local prodUnitList; local prodDistrictList; local prodProjectList; local purchBuildingList; local purchGoldBuildingList; local purchFaithBuildingList; local purchUnitList; local purchGoldUnitList local purchFaithUnitList local showDisabled :boolean = true; local m_recommendedItems:table; -- Production Queue local nextDistrictSkipToFront = false; local showStandaloneQueueWindow = true; local _, screenHeight = UIManager:GetScreenSizeVal(); local quickRefresh = true; local lastProductionCompletePerCity = {}; local buildingPrereqs = {}; local mutuallyExclusiveBuildings = {}; local m_PrevDropTargetSlot = -1; local m_PrevDropTargetInstance = nil; ------------------------------------------------------------------------------ -- Collapsible List Handling ------------------------------------------------------------------------------ function OnCollapseTheList() m_kClickedInstance.List:SetHide(true); m_kClickedInstance.ListSlide:SetSizeY(0); m_kClickedInstance.ListAlpha:SetSizeY(0); Controls.PauseCollapseList:SetToBeginning(); m_kClickedInstance.ListSlide:SetToBeginning(); m_kClickedInstance.ListAlpha:SetToBeginning(); Controls.ProductionList:CalculateSize(); Controls.PurchaseList:CalculateSize(); Controls.ProductionList:ReprocessAnchoring(); Controls.PurchaseList:ReprocessAnchoring(); Controls.ProductionListScroll:CalculateInternalSize(); Controls.PurchaseListScroll:CalculateInternalSize(); end -- =========================================================================== function OnCollapse(instance:table) m_kClickedInstance = instance; instance.ListSlide:Reverse(); instance.ListAlpha:Reverse(); instance.ListSlide:SetSpeed(15.0); instance.ListAlpha:SetSpeed(15.0); instance.ListSlide:Play(); instance.ListAlpha:Play(); instance.HeaderOn:SetHide(true); instance.Header:SetHide(false); Controls.PauseCollapseList:Play(); --By doing this we can delay collapsing the list until the "out" sequence has finished playing end -- =========================================================================== function OnExpand(instance:table) if(quickRefresh) then instance.ListSlide:SetSpeed(100); instance.ListAlpha:SetSpeed(100); else instance.ListSlide:SetSpeed(3.5); instance.ListAlpha:SetSpeed(4); end m_kClickedInstance = instance; instance.HeaderOn:SetHide(false); instance.Header:SetHide(true); instance.List:SetHide(false); instance.ListSlide:SetSizeY(instance.List:GetSizeY()); instance.ListAlpha:SetSizeY(instance.List:GetSizeY()); instance.ListSlide:SetToBeginning(); instance.ListAlpha:SetToBeginning(); instance.ListSlide:Play(); instance.ListAlpha:Play(); Controls.ProductionList:CalculateSize(); Controls.PurchaseList:CalculateSize(); Controls.ProductionList:ReprocessAnchoring(); Controls.PurchaseList:ReprocessAnchoring(); Controls.ProductionListScroll:CalculateInternalSize(); Controls.PurchaseListScroll:CalculateInternalSize(); end -- =========================================================================== function OnTabChangeProduction() Controls.MiniProductionTab:SetSelected(true); Controls.MiniPurchaseTab:SetSelected(false); Controls.MiniPurchaseFaithTab:SetSelected(false); Controls.PurchaseFaithMenu:SetHide(true); Controls.PurchaseMenu:SetHide(true); Controls.ChooseProductionMenu:SetHide(false); if (Controls.SlideIn:IsStopped()) then UI.PlaySound("Production_Panel_ButtonClick"); UI.PlaySound("Production_Panel_Open"); end end -- =========================================================================== function OnTabChangePurchase() Controls.MiniProductionTab:SetSelected(false); Controls.MiniPurchaseTab:SetSelected(true); Controls.MiniPurchaseFaithTab:SetSelected(false); Controls.ChooseProductionMenu:SetHide(true); Controls.PurchaseFaithMenu:SetHide(true); Controls.PurchaseMenu:SetHide(false); UI.PlaySound("Production_Panel_ButtonClick"); end -- =========================================================================== function OnTabChangePurchaseFaith() Controls.MiniProductionTab:SetSelected(false); Controls.MiniPurchaseTab:SetSelected(false); Controls.MiniPurchaseFaithTab:SetSelected(true); Controls.ChooseProductionMenu:SetHide(true); Controls.PurchaseMenu:SetHide(true); Controls.PurchaseFaithMenu:SetHide(false); UI.PlaySound("Production_Panel_ButtonClick"); end -- =========================================================================== -- Placement/Selection -- =========================================================================== function BuildUnit(city, unitEntry) local tParameters = {}; tParameters[CityOperationTypes.PARAM_UNIT_TYPE] = unitEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; CityManager.RequestOperation(city, CityOperationTypes.BUILD, tParameters); end -- =========================================================================== function BuildUnitCorps(city, unitEntry) local tParameters = {}; tParameters[CityOperationTypes.PARAM_UNIT_TYPE] = unitEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; tParameters[CityOperationTypes.MILITARY_FORMATION_TYPE] = MilitaryFormationTypes.CORPS_MILITARY_FORMATION; CityManager.RequestOperation(city, CityOperationTypes.BUILD, tParameters); end -- =========================================================================== function BuildUnitArmy(city, unitEntry) local tParameters = {}; tParameters[CityOperationTypes.PARAM_UNIT_TYPE] = unitEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; tParameters[CityOperationTypes.MILITARY_FORMATION_TYPE] = MilitaryFormationTypes.ARMY_MILITARY_FORMATION; CityManager.RequestOperation(city, CityOperationTypes.BUILD, tParameters); end -- =========================================================================== function BuildBuilding(city, buildingEntry) local building :table = GameInfo.Buildings[buildingEntry.Hash]; local bNeedsPlacement :boolean = building.RequiresPlacement; UI.SetInterfaceMode(InterfaceModeTypes.SELECTION); local pBuildQueue = city:GetBuildQueue(); if (pBuildQueue:HasBeenPlaced(buildingEntry.Hash)) then bNeedsPlacement = false; end -- If it's a Wonder and the city already has the building then it doesn't need to be replaced. if (bNeedsPlacement) then local cityBuildings = city:GetBuildings(); if (cityBuildings:HasBuilding(buildingEntry.Hash)) then bNeedsPlacement = false; end end if(not pBuildQueue:CanProduce(buildingEntry.Hash, true)) then -- For one reason or another we can't produce this, so remove it RemoveFromQueue(city:GetID(), 1, true); BuildFirstQueued(city); return; end if ( bNeedsPlacement ) then -- If so, set the placement mode local tParameters = {}; tParameters[CityOperationTypes.PARAM_BUILDING_TYPE] = buildingEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; UI.SetInterfaceMode(InterfaceModeTypes.BUILDING_PLACEMENT, tParameters); else local tParameters = {}; tParameters[CityOperationTypes.PARAM_BUILDING_TYPE] = buildingEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; CityManager.RequestOperation(city, CityOperationTypes.BUILD, tParameters); end end -- =========================================================================== function ZoneDistrict(city, districtEntry) local district :table = GameInfo.Districts[districtEntry.Hash]; local bNeedsPlacement :boolean = district.RequiresPlacement; local pBuildQueue :table = city:GetBuildQueue(); if (pBuildQueue:HasBeenPlaced(districtEntry.Hash)) then bNeedsPlacement = false; end -- Almost all districts need to be placed, but just in case let's check anyway if (bNeedsPlacement ) then -- If so, set the placement mode local tParameters = {}; tParameters[CityOperationTypes.PARAM_DISTRICT_TYPE] = districtEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; UI.SetInterfaceMode(InterfaceModeTypes.DISTRICT_PLACEMENT, tParameters); else -- If not, add it to the queue. local tParameters = {}; tParameters[CityOperationTypes.PARAM_DISTRICT_TYPE] = districtEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; CityManager.RequestOperation(city, CityOperationTypes.BUILD, tParameters); UI.PlaySound("Confirm_Production"); end end -- =========================================================================== function AdvanceProject(city, projectEntry) local tParameters = {}; tParameters[CityOperationTypes.PARAM_PROJECT_TYPE] = projectEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; CityManager.RequestOperation(city, CityOperationTypes.BUILD, tParameters); end -- =========================================================================== function PurchaseUnit(city, unitEntry) local tParameters = {}; tParameters[CityCommandTypes.PARAM_UNIT_TYPE] = unitEntry.Hash; tParameters[CityCommandTypes.PARAM_MILITARY_FORMATION_TYPE] = MilitaryFormationTypes.STANDARD_MILITARY_FORMATION; if (unitEntry.Yield == "YIELD_GOLD") then tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_GOLD"].Index; UI.PlaySound("Purchase_With_Gold"); else tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_FAITH"].Index; UI.PlaySound("Purchase_With_Faith"); end CityManager.RequestCommand(city, CityCommandTypes.PURCHASE, tParameters); end -- =========================================================================== function PurchaseUnitCorps(city, unitEntry) local tParameters = {}; tParameters[CityCommandTypes.PARAM_UNIT_TYPE] = unitEntry.Hash; tParameters[CityCommandTypes.PARAM_MILITARY_FORMATION_TYPE] = MilitaryFormationTypes.CORPS_MILITARY_FORMATION; if (unitEntry.Yield == "YIELD_GOLD") then tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_GOLD"].Index; UI.PlaySound("Purchase_With_Gold"); else tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_FAITH"].Index; UI.PlaySound("Purchase_With_Faith"); end CityManager.RequestCommand(city, CityCommandTypes.PURCHASE, tParameters); end -- =========================================================================== function PurchaseUnitArmy(city, unitEntry) local tParameters = {}; tParameters[CityCommandTypes.PARAM_UNIT_TYPE] = unitEntry.Hash; tParameters[CityCommandTypes.PARAM_MILITARY_FORMATION_TYPE] = MilitaryFormationTypes.ARMY_MILITARY_FORMATION; if (unitEntry.Yield == "YIELD_GOLD") then tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_GOLD"].Index; UI.PlaySound("Purchase_With_Gold"); else tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_FAITH"].Index; UI.PlaySound("Purchase_With_Faith"); end CityManager.RequestCommand(city, CityCommandTypes.PURCHASE, tParameters); end -- =========================================================================== function PurchaseBuilding(city, buildingEntry) local tParameters = {}; tParameters[CityCommandTypes.PARAM_BUILDING_TYPE] = buildingEntry.Hash; if (buildingEntry.Yield == "YIELD_GOLD") then tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_GOLD"].Index; UI.PlaySound("Purchase_With_Gold"); else tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_FAITH"].Index; UI.PlaySound("Purchase_With_Faith"); end CityManager.RequestCommand(city, CityCommandTypes.PURCHASE, tParameters); end -- =========================================================================== function PurchaseDistrict(city, districtEntry) local district :table = GameInfo.Districts[districtEntry.Type]; local bNeedsPlacement :boolean = district.RequiresPlacement; local pBuildQueue :table = city:GetBuildQueue(); if (pBuildQueue:HasBeenPlaced(districtEntry.Hash)) then bNeedsPlacement = false; end -- Almost all districts need to be placed, but just in case let's check anyway if (bNeedsPlacement ) then -- If so, set the placement mode local tParameters = {}; tParameters[CityOperationTypes.PARAM_DISTRICT_TYPE] = districtEntry.Hash; tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_GOLD"].Index; UI.SetInterfaceMode(InterfaceModeTypes.DISTRICT_PLACEMENT, tParameters); else -- If not, add it to the queue. local tParameters = {}; tParameters[CityOperationTypes.PARAM_DISTRICT_TYPE] = districtEntry.Hash; tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = GameInfo.Yields["YIELD_GOLD"].Index; CityManager.RequestCommand(city, CityCommandTypes.PURCHASE, tParameters); UI.PlaySound("Purchase_With_Gold"); end end -- =========================================================================== -- GAME Event -- City was selected. -- =========================================================================== function OnCitySelectionChanged( owner:number, cityID:number, i, j, k, isSelected:boolean, isEditable:boolean) local localPlayerId:number = Game.GetLocalPlayer(); if owner == localPlayerId and isSelected then -- Already open then populate with newly selected city's data... if (ContextPtr:IsHidden() == false) and Controls.PauseDismissWindow:IsStopped() and Controls.AlphaIn:IsStopped() then Refresh(); end end end -- =========================================================================== -- GAME Event -- eOldMode, mode the engine was formally in -- eNewMode, new mode the engine has just changed to -- =========================================================================== function OnInterfaceModeChanged( eOldMode:number, eNewMode:number ) -- If this is raised while the city panel is up; selecting to purchase a -- plot or manage citizens will close it. if eNewMode == InterfaceModeTypes.CITY_MANAGEMENT or eNewMode == InterfaceModeTypes.VIEW_MODAL_LENS then if not ContextPtr:IsHidden() then Close(); end end end -- =========================================================================== -- GAME Event -- Unit was selected (impossible for a production panel to be up; close it -- =========================================================================== function OnUnitSelectionChanged( playerID : number, unitID : number, hexI : number, hexJ : number, hexK : number, bSelected : boolean, bEditable : boolean ) local localPlayer = Game.GetLocalPlayer(); if playerID == localPlayer then -- If a unit is selected and this is showing; hide it. local pSelectedUnit:table = UI.GetHeadSelectedUnit(); if pSelectedUnit ~= nil and not ContextPtr:IsHidden() then OnHide(); end end end -- =========================================================================== -- Actual closing function, may have been called via click, keyboard input, -- or an external system call. -- =========================================================================== function Close() if (Controls.SlideIn:IsStopped()) then -- Need to check to make sure that we have not already begun the transition before attempting to close the panel. UI.PlaySound("Production_Panel_Closed"); Controls.SlideIn:Reverse(); Controls.AlphaIn:Reverse(); if(showStandaloneQueueWindow) then Controls.QueueSlideIn:Reverse(); Controls.QueueAlphaIn:Reverse(); else Controls.QueueAlphaIn:SetAlpha(0); end Controls.PauseDismissWindow:Play(); LuaEvents.ProductionPanel_Close(); end end -- =========================================================================== -- Close via click function OnClose() Close(); end -- =========================================================================== -- Open the panel -- =========================================================================== function Open() if ContextPtr:IsHidden() then -- The ContextPtr is only hidden as a callback to the finished SlideIn animation, so this check should be sufficient to ensure that we are not animating. -- Sets up proper selection AND the associated lens so it's not stuck "on". UI.PlaySound("Production_Panel_Open"); LuaEvents.ProductionPanel_Open(); UI.SetInterfaceMode(InterfaceModeTypes.SELECTION); Refresh(); ContextPtr:SetHide(false); Controls.ProductionListScroll:SetScrollValue(0); -- Size the panel to the maximum Y value of the expanded content Controls.AlphaIn:SetToBeginning(); Controls.SlideIn:SetToBeginning(); Controls.AlphaIn:Play(); Controls.SlideIn:Play(); if(showStandaloneQueueWindow) then Controls.QueueAlphaIn:SetToBeginning(); Controls.QueueSlideIn:SetToBeginning(); Controls.QueueAlphaIn:Play(); Controls.QueueSlideIn:Play(); ResizeQueueWindow(); end end end -- =========================================================================== function OnHide() ContextPtr:SetHide(true); Controls.PauseDismissWindow:SetToBeginning(); end -- =========================================================================== -- Initialize, Refresh, Populate, View -- Update the layout based on the view model -- =========================================================================== function View(data, persistCollapse) local selectedCity = UI.GetHeadSelectedCity(); -- Get the hashes for the top three recommended items m_recommendedItems = selectedCity:GetCityAI():GetBuildRecommendations(); PopulateList(data, LISTMODE.PRODUCTION, m_listIM); PopulateList(data, LISTMODE.PURCHASE_GOLD, m_purchaseListIM); PopulateList(data, LISTMODE.PURCHASE_FAITH, m_purchaseFaithListIM); if(persistCollapse) then if(prodDistrictList ~= nil and not prodDistrictList.HeaderOn:IsHidden()) then OnExpand(prodDistrictList); end if(prodWonderList ~= nil and not prodWonderList.HeaderOn:IsHidden()) then OnExpand(prodWonderList); end if(prodUnitList ~= nil and not prodUnitList.HeaderOn:IsHidden()) then OnExpand(prodUnitList); end if(prodProjectList ~= nil and not prodProjectList.HeaderOn:IsHidden()) then OnExpand(prodProjectList); end if(purchFaithBuildingList ~= nil and not purchFaithBuildingList.HeaderOn:IsHidden()) then OnExpand(purchFaithBuildingList); end if(purchGoldBuildingList ~= nil and not purchGoldBuildingList.HeaderOn:IsHidden()) then OnExpand(purchGoldBuildingList); end if(purchFaithUnitList ~= nil and not purchFaithUnitList.HeaderOn:IsHidden()) then OnExpand(purchFaithUnitList); end if(purchGoldUnitList ~= nil and not purchGoldUnitList.HeaderOn:IsHidden()) then OnExpand(purchGoldUnitList); end else if(prodDistrictList ~= nil) then OnExpand(prodDistrictList); end if(prodWonderList ~= nil) then OnExpand(prodWonderList); end if(prodUnitList ~= nil) then OnExpand(prodUnitList); end if(prodProjectList ~= nil) then OnExpand(prodProjectList); end if(purchFaithBuildingList ~= nil) then OnExpand(purchFaithBuildingList); end if(purchGoldBuildingList ~= nil) then OnExpand(purchGoldBuildingList); end if(purchFaithUnitList ~= nil ) then OnExpand(purchFaithUnitList); end if(purchGoldUnitList ~= nil) then OnExpand(purchGoldUnitList); end m_tabs.SelectTab(m_productionTab); end -- if( Controls.PurchaseList:GetSizeY() == 0 ) then Controls.NoGoldContent:SetHide(false); else Controls.NoGoldContent:SetHide(true); end if( Controls.PurchaseFaithList:GetSizeY() == 0 ) then Controls.NoFaithContent:SetHide(false); else Controls.NoFaithContent:SetHide(true); end end function ResetInstanceVisibility(productionItem: table) if (productionItem.ArmyCorpsDrawer ~= nil) then productionItem.ArmyCorpsDrawer:SetHide(true); productionItem.CorpsArmyArrow:SetSelected(true); productionItem.CorpsRecommendedIcon:SetHide(true); productionItem.CorpsButtonContainer:SetHide(true); productionItem.CorpsDisabled:SetHide(true); productionItem.ArmyRecommendedIcon:SetHide(true); productionItem.ArmyButtonContainer:SetHide(true); productionItem.ArmyDisabled:SetHide(true); productionItem.CorpsArmyDropdownArea:SetHide(true); end if (productionItem.BuildingDrawer ~= nil) then productionItem.BuildingDrawer:SetHide(true); productionItem.CompletedArea:SetHide(true); end productionItem.RecommendedIcon:SetHide(true); productionItem.Disabled:SetHide(true); end -- =========================================================================== function PopulateList(data, listMode, listIM) listIM:ResetInstances(); local districtList; local buildingList; local wonderList; local projectList; local unitList; local queueList; Controls.PauseCollapseList:Stop(); local selectedCity = UI.GetHeadSelectedCity(); local pBuildings = selectedCity:GetBuildings(); local cityID = selectedCity:GetID(); local cityData = GetCityData(selectedCity); local localPlayer = Players[Game.GetLocalPlayer()]; if(listMode == LISTMODE.PRODUCTION) then m_maxProductionSize = 0; -- Populate Current Item local buildQueue = selectedCity:GetBuildQueue(); local productionHash = 0; local completedStr = ""; local currentProductionHash = buildQueue:GetCurrentProductionTypeHash(); local previousProductionHash = buildQueue:GetPreviousProductionTypeHash(); local screenX, screenY:number = UIManager:GetScreenSizeVal() if( currentProductionHash == 0 and previousProductionHash == 0 ) then Controls.CurrentProductionArea:SetHide(true); Controls.ProductionListScroll:SetSizeY(screenY-120); Controls.ProductionListScroll:CalculateSize(); Controls.ProductionListScroll:SetOffsetY(10); completedStr = ""; else Controls.CurrentProductionArea:SetHide(false); Controls.ProductionListScroll:SetSizeY(screenY-175); Controls.ProductionListScroll:CalculateSize(); Controls.ProductionListScroll:SetOffsetY(65); if( currentProductionHash == 0 ) then productionHash = previousProductionHash; Controls.CompletedArea:SetHide(false); completedStr = Locale.ToUpper(Locale.Lookup("LOC_TECH_KEY_COMPLETED")); else Controls.CompletedArea:SetHide(true); productionHash = currentProductionHash; completedStr = "" end end local currentProductionInfo :table = GetProductionInfoOfCity( data.City, productionHash ); if (currentProductionInfo.Icon ~= nil) then Controls.CurrentProductionName:SetText(Locale.ToUpper(Locale.Lookup(currentProductionInfo.Name)).." "..completedStr); Controls.CurrentProductionProgress:SetPercent(currentProductionInfo.PercentComplete); Controls.CurrentProductionProgress:SetShadowPercent(currentProductionInfo.PercentCompleteNextTurn); Controls.CurrentProductionIcon:SetIcon(currentProductionInfo.Icon); if(currentProductionInfo.Description ~= nil) then Controls.CurrentProductionIcon:SetToolTipString(Locale.Lookup(currentProductionInfo.Description)); else Controls.CurrentProductionIcon:SetToolTipString(); end local numberOfTurns = currentProductionInfo.Turns; if numberOfTurns == -1 then numberOfTurns = "999+"; end; Controls.CurrentProductionCost:SetText("[ICON_Turn]".. numberOfTurns); Controls.CurrentProductionProgressString:SetText("[ICON_ProductionLarge]"..currentProductionInfo.Progress.."/"..currentProductionInfo.Cost); end -- Populate Districts ------------------------ CANNOT purchase districts districtList = listIM:GetInstance(); districtList.Header:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_DISTRICTS_BUILDINGS"))); districtList.HeaderOn:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_DISTRICTS_BUILDINGS"))); local dL = districtList; -- Due to lambda capture, we need to copy this for callback if ( districtList.districtListIM ~= nil ) then districtList.districtListIM:ResetInstances(); else districtList.districtListIM = InstanceManager:new( "DistrictListInstance", "Root", districtList.List); end -- In the interest of performance, we're keeping the instances that we created and resetting the data. -- This requires a little bit of footwork to remember the instances that have been modified and to manually reset them. for _,type in ipairs(m_TypeNames) do if ( districtList[BUILDING_IM_PREFIX..type] ~= nil) then --Reset the states for the building instance managers districtList[BUILDING_IM_PREFIX..type]:ResetInstances(); end if ( districtList[BUILDING_DRAWER_PREFIX..type] ~= nil) then --Reset the states of the drawers districtList[BUILDING_DRAWER_PREFIX..type]:SetHide(true); end end for i, item in ipairs(data.DistrictItems) do if(GameInfo.Districts[item.Hash].RequiresPopulation and cityData.DistrictsNum < cityData.DistrictsPossibleNum) then if(GetNumDistrictsInCityQueue(selectedCity) + cityData.DistrictsNum >= cityData.DistrictsPossibleNum) then item.Disabled = true; if(not string.find(item.ToolTip, "COLOR:Red")) then item.ToolTip = item.ToolTip .. "[NEWLINE][NEWLINE][COLOR:Red]" .. Locale.Lookup("LOC_DISTRICT_ZONE_POPULATION_TOO_LOW_SHORT", cityData.DistrictsPossibleNum * 3 + 1); end end end local districtListing = districtList["districtListIM"]:GetInstance(); ResetInstanceVisibility(districtListing); -- Check to see if this district item is one of the items that is recommended: for _,hash in ipairs( m_recommendedItems) do if(item.Hash == hash.BuildItemHash) then districtListing.RecommendedIcon:SetHide(false); end end local nameStr = Locale.Lookup("{1_Name}", item.Name); if (item.Repair) then nameStr = nameStr .. "[NEWLINE]" .. Locale.Lookup("LOC_PRODUCTION_ITEM_REPAIR"); end if (item.Contaminated) then nameStr = nameStr .. Locale.Lookup("LOC_PRODUCTION_ITEM_DECONTAMINATE"); end districtListing.LabelText:SetText(nameStr); local turnsStrTT:string = ""; local turnsStr:string = ""; if(item.HasBeenBuilt and GameInfo.Districts[item.Type].OnePerCity == true and not item.Repair and not item.Contaminated and item.Progress == 0 and not item.TurnsLeft) then turnsStrTT = Locale.Lookup("LOC_HUD_CITY_DISTRICT_BUILT_TT"); turnsStr = "[ICON_Checkmark]"; districtListing.RecommendedIcon:SetHide(true); else if(item.TurnsLeft) then local numberOfTurns = item.TurnsLeft; if numberOfTurns == -1 then numberOfTurns = "999+"; turnsStrTT = Locale.Lookup("LOC_HUD_CITY_WILL_NOT_COMPLETE"); else turnsStrTT = numberOfTurns .. Locale.Lookup("LOC_HUD_CITY_TURNS_TO_COMPLETE", item.TurnsLeft); end turnsStr = numberOfTurns .. "[ICON_Turn]"; else turnsStrTT = Locale.Lookup("LOC_HUD_CITY_DISTRICT_BUILT_TT"); turnsStr = "[ICON_Checkmark]"; districtListing.RecommendedIcon:SetHide(true); end end if (item.Disabled) then if(item.HasBeenBuilt and GameInfo.Districts[item.Type].OnePerCity == true) then turnsStrTT = Locale.Lookup("LOC_HUD_CITY_DISTRICT_BUILT_TT"); turnsStr = "[ICON_Checkmark]"; end end if(item.Progress > 0) then districtListing.ProductionProgressArea:SetHide(false); local districtProgress = item.Progress/item.Cost; if (districtProgress < 1) then districtListing.ProductionProgress:SetPercent(districtProgress); else districtListing.ProductionProgressArea:SetHide(true); end else districtListing.ProductionProgressArea:SetHide(true); end districtListing.CostText:SetToolTipString(turnsStrTT); districtListing.CostText:SetText(turnsStr); districtListing.Button:SetToolTipString(item.ToolTip); districtListing.Disabled:SetToolTipString(item.ToolTip); districtListing.Icon:SetIcon(ICON_PREFIX..item.Type); local districtType = item.Type; -- Check to see if this is a unique district that will be substituted for another kind of district if(GameInfo.DistrictReplaces[item.Type] ~= nil) then districtType = GameInfo.DistrictReplaces[item.Type].ReplacesDistrictType; end local uniqueBuildingIMName = BUILDING_IM_PREFIX..districtType; local uniqueBuildingAreaName = BUILDING_DRAWER_PREFIX..districtType; table.insert(m_TypeNames, districtType); districtList[uniqueBuildingIMName] = InstanceManager:new( "BuildingListInstance", "Root", districtListing.BuildingStack); districtList[uniqueBuildingAreaName] = districtListing.BuildingDrawer; districtListing.CompletedArea:SetHide(true); if (item.Disabled) then if(item.HasBeenBuilt and GameInfo.Districts[item.Type].OnePerCity == true) then districtListing.CompletedArea:SetHide(false); districtListing.Disabled:SetHide(true); else if(showDisabled) then districtListing.Disabled:SetHide(false); districtListing.Button:SetColor(COLOR_LOW_OPACITY); else districtListing.Root:SetHide(true); end end else districtListing.Root:SetHide(false); districtListing.Disabled:SetHide(true); districtListing.Button:SetColor(0xFFFFFFFF); end districtListing.Button:SetDisabled(item.Disabled); districtListing.Button:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); districtListing.Button:RegisterCallback( Mouse.eLClick, function() if(m_isCONTROLpressed) then nextDistrictSkipToFront = true; else nextDistrictSkipToFront = false; end QueueDistrict(data.City, item, nextDistrictSkipToFront); end); districtListing.Button:RegisterCallback( Mouse.eMClick, function() nextDistrictSkipToFront = true; QueueDistrict(data.City, item, true); RecenterCameraToSelectedCity(); end); if(not IsTutorialRunning()) then districtListing.Button:RegisterCallback( Mouse.eRClick, function() LuaEvents.OpenCivilopedia(item.Type); end); end districtListing.Root:SetTag(UITutorialManager:GetHash(item.Type)); end districtList.List:CalculateSize(); districtList.List:ReprocessAnchoring(); if (districtList.List:GetSizeY()==0) then districtList.Top:SetHide(true); else m_maxProductionSize = m_maxProductionSize + HEADER_Y + SEPARATOR_Y; districtList.Header:RegisterCallback( Mouse.eLClick, function() OnExpand(dL); end); districtList.Header:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); districtList.HeaderOn:RegisterCallback( Mouse.eLClick, function() OnCollapse(dL); end); districtList.HeaderOn:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); end prodDistrictList = dL; -- Populate Nested Buildings ----------------- for i, buildingItem in ipairs(data.BuildingItems) do local displayItem = true; -- PQ: Check if this building is mutually exclusive with another if(mutuallyExclusiveBuildings[buildingItem.Type]) then for mutuallyExclusiveBuilding in GameInfo.MutuallyExclusiveBuildings() do if(mutuallyExclusiveBuilding.Building == buildingItem.Type) then if(IsBuildingInQueue(selectedCity, GameInfo.Buildings[mutuallyExclusiveBuilding.MutuallyExclusiveBuilding].Hash) or pBuildings:HasBuilding(GameInfo.Buildings[mutuallyExclusiveBuilding.MutuallyExclusiveBuilding].Index)) then displayItem = false; end elseif(mutuallyExclusiveBuilding.MutuallyExclusiveBuilding == buildingItem.Type) then if(IsBuildingInQueue(selectedCity, GameInfo.Buildings[mutuallyExclusiveBuilding.Building].Hash) or pBuildings:HasBuilding(GameInfo.Buildings[mutuallyExclusiveBuilding.Building].Index)) then displayItem = false; end end end end if(buildingItem.Hash == GameInfo.Buildings["BUILDING_PALACE"].Hash) then displayItem = false; end if(not buildingItem.IsWonder and not IsBuildingInQueue(selectedCity, buildingItem.Hash) and displayItem) then local uniqueDrawerName = BUILDING_DRAWER_PREFIX..buildingItem.PrereqDistrict; local uniqueIMName = BUILDING_IM_PREFIX..buildingItem.PrereqDistrict; if (districtList[uniqueIMName] ~= nil) then local buildingListing = districtList[uniqueIMName]:GetInstance(); ResetInstanceVisibility(buildingListing); -- Check to see if this is one of the recommended items for _,hash in ipairs( m_recommendedItems) do if(buildingItem.Hash == hash.BuildItemHash) then buildingListing.RecommendedIcon:SetHide(false); end end buildingListing.Root:SetSizeX(305); buildingListing.Button:SetSizeX(305); local districtBuildingAreaControl = districtList[uniqueDrawerName]; districtBuildingAreaControl:SetHide(false); --Fill the meter if there is any progress, hide it if not if(buildingItem.Progress > 0) then buildingListing.ProductionProgressArea:SetHide(false); local buildingProgress = buildingItem.Progress/buildingItem.Cost; if (buildingProgress < 1) then buildingListing.ProductionProgress:SetPercent(buildingProgress); else buildingListing.ProductionProgressArea:SetHide(true); end else buildingListing.ProductionProgressArea:SetHide(true); end local nameStr = Locale.Lookup("{1_Name}", buildingItem.Name); if (buildingItem.Repair) then nameStr = nameStr .. "[NEWLINE]" .. Locale.Lookup("LOC_PRODUCTION_ITEM_REPAIR"); end buildingListing.LabelText:SetText(nameStr); local turnsStrTT:string = ""; local turnsStr:string = ""; local numberOfTurns = buildingItem.TurnsLeft; if numberOfTurns == -1 then numberOfTurns = "999+"; turnsStrTT = Locale.Lookup("LOC_HUD_CITY_WILL_NOT_COMPLETE"); else turnsStrTT = numberOfTurns .. Locale.Lookup("LOC_HUD_CITY_TURNS_TO_COMPLETE", buildingItem.TurnsLeft); end turnsStr = numberOfTurns .. "[ICON_Turn]"; buildingListing.CostText:SetToolTipString(turnsStrTT); buildingListing.CostText:SetText(turnsStr); buildingListing.Button:SetToolTipString(buildingItem.ToolTip); buildingListing.Disabled:SetToolTipString(buildingItem.ToolTip); buildingListing.Icon:SetIcon(ICON_PREFIX..buildingItem.Type); if (buildingItem.Disabled) then if(showDisabled) then buildingListing.Disabled:SetHide(false); buildingListing.Button:SetColor(COLOR_LOW_OPACITY); else buildingListing.Button:SetHide(true); end else buildingListing.Button:SetHide(false); buildingListing.Disabled:SetHide(true); buildingListing.Button:SetSizeY(BUTTON_Y); buildingListing.Button:SetColor(0xffffffff); end buildingListing.Button:SetDisabled(buildingItem.Disabled); buildingListing.Button:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); buildingListing.Button:RegisterCallback( Mouse.eLClick, function() QueueBuilding(data.City, buildingItem); end); buildingListing.Button:RegisterCallback( Mouse.eMClick, function() QueueBuilding(data.City, buildingItem, true); RecenterCameraToSelectedCity(); end); if(not IsTutorialRunning()) then buildingListing.Button:RegisterCallback( Mouse.eRClick, function() LuaEvents.OpenCivilopedia(buildingItem.Type); end); end buildingListing.Button:SetTag(UITutorialManager:GetHash(buildingItem.Type)); end end end -- Populate Wonders ------------------------ CANNOT purchase wonders wonderList = listIM:GetInstance(); wonderList.Header:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_CITY_WONDERS"))); wonderList.HeaderOn:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_CITY_WONDERS"))); local wL = wonderList; if ( wonderList.wonderListIM ~= nil ) then wonderList.wonderListIM:ResetInstances() else wonderList.wonderListIM = InstanceManager:new( "BuildingListInstance", "Root", wonderList.List); end for i, item in ipairs(data.BuildingItems) do if(item.IsWonder and not IsWonderInQueue(item.Hash)) then local wonderListing = wonderList["wonderListIM"]:GetInstance(); ResetInstanceVisibility(wonderListing); for _,hash in ipairs( m_recommendedItems) do if(item.Hash == hash.BuildItemHash) then wonderListing.RecommendedIcon:SetHide(false); end end local nameStr = Locale.Lookup("{1_Name}", item.Name); if (item.Repair) then nameStr = nameStr .. "[NEWLINE]" .. Locale.Lookup("LOC_PRODUCTION_ITEM_REPAIR"); end wonderListing.LabelText:SetText(nameStr); if(item.Progress > 0) then wonderListing.ProductionProgressArea:SetHide(false); local wonderProgress = item.Progress/item.Cost; if (wonderProgress < 1) then wonderListing.ProductionProgress:SetPercent(wonderProgress); else wonderListing.ProductionProgressArea:SetHide(true); end else wonderListing.ProductionProgressArea:SetHide(true); end local turnsStrTT:string = ""; local turnsStr:string = ""; local numberOfTurns = item.TurnsLeft; if numberOfTurns == -1 then numberOfTurns = "999+"; turnsStrTT = Locale.Lookup("LOC_HUD_CITY_WILL_NOT_COMPLETE"); else turnsStrTT = numberOfTurns .. Locale.Lookup("LOC_HUD_CITY_TURNS_TO_COMPLETE", item.TurnsLeft); end turnsStr = numberOfTurns .. "[ICON_Turn]"; wonderListing.CostText:SetText(turnsStr); wonderListing.CostText:SetToolTipString(turnsStrTT); wonderListing.Button:SetToolTipString(item.ToolTip); wonderListing.Disabled:SetToolTipString(item.ToolTip); wonderListing.Icon:SetIcon(ICON_PREFIX..item.Type); if (item.Disabled) then if(showDisabled) then wonderListing.Disabled:SetHide(false); wonderListing.Button:SetColor(COLOR_LOW_OPACITY); else wonderListing.Button:SetHide(true); end else wonderListing.Button:SetHide(false); wonderListing.Disabled:SetHide(true); wonderListing.Button:SetSizeY(BUTTON_Y); wonderListing.Button:SetColor(0xffffffff); end wonderListing.Button:SetDisabled(item.Disabled); wonderListing.Button:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); wonderListing.Button:RegisterCallback( Mouse.eLClick, function() nextDistrictSkipToFront = false; QueueBuilding(data.City, item); end); wonderListing.Button:RegisterCallback( Mouse.eMClick, function() nextDistrictSkipToFront = true; QueueBuilding(data.City, item, true); RecenterCameraToSelectedCity(); end); if(not IsTutorialRunning()) then wonderListing.Button:RegisterCallback( Mouse.eRClick, function() LuaEvents.OpenCivilopedia(item.Type); end); end wonderListing.Button:SetTag(UITutorialManager:GetHash(item.Type)); end end wonderList.List:CalculateSize(); wonderList.List:ReprocessAnchoring(); if (wonderList.List:GetSizeY()==0) then wonderList.Top:SetHide(true); else m_maxProductionSize = m_maxProductionSize + HEADER_Y + SEPARATOR_Y; wonderList.Header:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); wonderList.Header:RegisterCallback( Mouse.eLClick, function() OnExpand(wL); end); wonderList.HeaderOn:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); wonderList.HeaderOn:RegisterCallback( Mouse.eLClick, function() OnCollapse(wL); end); end prodWonderList = wL; --=================================================================================================================== ------------------------------------------ Populate the Production Queue -------------------------------------------- --=================================================================================================================== m_queueIM:ResetInstances(); if(#prodQueue[cityID] > 0) then queueList = m_queueIM:GetInstance(); if (queueList.queueListIM ~= nil) then queueList.queueListIM:ResetInstances(); else queueList.queueListIM = InstanceManager:new("QueueListInstance", "Root", queueList.List); end local itemEncountered = {}; for i, qi in pairs(prodQueue[cityID]) do local queueListing = queueList["queueListIM"]:GetInstance(); ResetInstanceVisibility(queueListing); queueListing.ProductionProgressArea:SetHide(true); if(qi.entry) then local info = GetProductionInfoOfCity(selectedCity, qi.entry.Hash); local turnsText = info.Turns; if(itemEncountered[qi.entry.Hash]) then turnsText = math.ceil(info.Cost / cityData.ProductionPerTurn); else if(info.Progress > 0) then queueListing.ProductionProgressArea:SetHide(false); local progress = info.Progress/info.Cost; if (progress < 1) then queueListing.ProductionProgress:SetPercent(progress); else queueListing.ProductionProgressArea:SetHide(true); end end end local suffix = ""; if(GameInfo.Units[qi.entry.Hash]) then local unitDef = GameInfo.Units[qi.entry.Hash]; local cost = 0; if(prodQueue[cityID][i].type == PRODUCTION_TYPE.CORPS) then cost = qi.entry.CorpsCost; if(unitDef.Domain == "DOMAIN_SEA") then suffix = " " .. Locale.Lookup("LOC_UNITFLAG_FLEET_SUFFIX"); else suffix = " " .. Locale.Lookup("LOC_UNITFLAG_CORPS_SUFFIX"); end elseif(qi.type == PRODUCTION_TYPE.ARMY) then cost = qi.entry.ArmyCost; if(unitDef.Domain == "DOMAIN_SEA") then suffix = " " .. Locale.Lookup("LOC_UNITFLAG_ARMADA_SUFFIX"); else suffix = " " .. Locale.Lookup("LOC_UNITFLAG_ARMY_SUFFIX"); end elseif(qi.type == PRODUCTION_TYPE.UNIT) then cost = qi.entry.Cost; end if(itemEncountered[qi.entry.Hash] and info.Progress ~= 0) then turnsText = math.ceil(cost / cityData.ProductionPerTurn); local percentPerTurn = info.PercentCompleteNextTurn - info.PercentComplete; if(info.PercentCompleteNextTurn < 1) then turnsText = math.ceil(1/percentPerTurn); else turnsText = "~" .. turnsText; end else turnsText = info.Turns; local progress = info.Progress / cost; if (progress < 1) then queueListing.ProductionProgress:SetPercent(progress); end end end if(qi.entry.Repair) then suffix = " (" .. Locale.Lookup("LOC_UNITOPERATION_REPAIR_DESCRIPTION") .. ")" end queueListing.LabelText:SetText(Locale.Lookup(qi.entry.Name) .. suffix); queueListing.Icon:SetIcon(info.Icon) queueListing.CostText:SetText(turnsText .. "[ICON_Turn]"); if(i == 1) then queueListing.Active:SetHide(false); end itemEncountered[qi.entry.Hash] = true; end -- EVENT HANDLERS -- queueListing.Button:RegisterCallback( Mouse.eRClick, function() if(CanRemoveFromQueue(cityID, i)) then if(RemoveFromQueue(cityID, i)) then if(i == 1) then BuildFirstQueued(selectedCity); else Refresh(true); end end end end); queueListing.Button:RegisterCallback( Mouse.eMouseEnter, function() if(not UILens.IsLayerOn( LensLayers.DISTRICTS ) and qi.plotID > -1) then UILens.SetAdjacencyBonusDistict(qi.plotID, "Placement_Valid", {}) end end); queueListing.Button:RegisterCallback( Mouse.eMouseExit, function() if(not UILens.IsLayerOn( LensLayers.DISTRICTS )) then UILens.ClearLayerHexes( LensLayers.DISTRICTS ); end end); queueListing.Button:RegisterCallback( Mouse.eLDblClick, function() MoveQueueIndex(cityID, i, 1); BuildFirstQueued(selectedCity); end); queueListing.Button:RegisterCallback( Mouse.eMClick, function() MoveQueueIndex(cityID, i, 1); BuildFirstQueued(selectedCity); RecenterCameraToSelectedCity(); end); queueListing.Draggable:RegisterCallback( Drag.eDown, function(dragStruct) OnDownInQueue(dragStruct, queueListing, i); end ); queueListing.Draggable:RegisterCallback( Drag.eDrag, function(dragStruct) OnDragInQueue(dragStruct, queueListing, i); end ); queueListing.Draggable:RegisterCallback( Drag.eDrop, function(dragStruct) OnDropInQueue(dragStruct, queueListing, i); end ); end end end --End if LISTMODE.PRODUCTION - display districts, NESTED buildings, and wonders if(listMode ~= LISTMODE.PRODUCTION) then --If we are purchasing, then buildings don't have to be displayed in a nested way -- Populate Districts ------------------------ districtList = listIM:GetInstance(); districtList.Header:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_DISTRICTS"))); districtList.HeaderOn:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_DISTRICTS"))); local dL = districtList; if ( districtList.districtListIM ~= nil) then districtList.districtListIM:ResetInstances(); else districtList.districtListIM = InstanceManager:new( "DistrictListInstance", "Root", districtList.List); end for i, item in ipairs(data.DistrictPurchases) do if (item.Yield == "YIELD_GOLD" and listMode == LISTMODE.PURCHASE_GOLD) then local districtListing = districtList["districtListIM"]:GetInstance(); ResetInstanceVisibility(districtListing); districtListing.ProductionProgressArea:SetHide(true); local nameStr = Locale.Lookup(item.Name); local costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_GOLD_TEXT", item.Cost); if (item.CantAfford) then costStr = "[COLOR:Red]" .. costStr .. "[ENDCOLOR]"; end for _,hash in ipairs( m_recommendedItems) do if (item.Hash == hash.BuildItemHash) then districtListing.RecommendedIcon:SetHide(false); end end districtListing.LabelText:SetText(nameStr); districtListing.CostText:SetText(costStr); districtListing.Button:SetToolTipString(item.ToolTip); districtListing.Disabled:SetToolTipString(item.ToolTip); districtListing.Icon:SetIcon(ICON_PREFIX..item.Type); if (item.Disabled) then if(showDisabled) then districtListing.Disabled:SetHide(false); districtListing.Button:SetColor(COLOR_LOW_OPACITY); else districtListing.Button:SetHide(true); end else districtListing.Button:SetHide(false); districtListing.Disabled:SetHide(true); districtListing.Button:SetColor(0xffffffff); end districtListing.Button:SetDisabled(item.Disabled); districtListing.Button:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); districtListing.Button:RegisterCallback( Mouse.eLClick, function() PurchaseDistrict(data.City, item); end); end end -- Populate Buildings ------------------------ buildingList = listIM:GetInstance(); buildingList.Header:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_BUILDINGS"))); buildingList.HeaderOn:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_BUILDINGS"))); local bL = buildingList; if ( buildingList.buildingListIM ~= nil ) then buildingList.buildingListIM:ResetInstances(); else buildingList.buildingListIM = InstanceManager:new( "BuildingListInstance", "Root", buildingList.List); end for i, item in ipairs(data.BuildingPurchases) do if ((item.Yield == "YIELD_GOLD" and listMode == LISTMODE.PURCHASE_GOLD) or (item.Yield == "YIELD_FAITH" and listMode == LISTMODE.PURCHASE_FAITH)) then local buildingListing = buildingList["buildingListIM"]:GetInstance(); ResetInstanceVisibility(buildingListing); buildingListing.ProductionProgressArea:SetHide(true); -- Since this is DEFINITELY a purchase instance, hide the progress bar local nameStr = Locale.Lookup(item.Name); local costStr; if (item.Yield == "YIELD_GOLD") then costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_GOLD_TEXT", item.Cost); else costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_FAITH_TEXT", item.Cost); end if item.CantAfford then costStr = "[COLOR:Red]" .. costStr .. "[ENDCOLOR]"; end for _,hash in ipairs( m_recommendedItems) do if(item.Hash == hash.BuildItemHash) then buildingListing.RecommendedIcon:SetHide(false); end end buildingListing.LabelText:SetText(nameStr); buildingListing.CostText:SetText(costStr); buildingListing.Button:SetToolTipString(item.ToolTip); buildingListing.Disabled:SetToolTipString(item.ToolTip); buildingListing.Icon:SetIcon(ICON_PREFIX..item.Type); if (item.Disabled) then if(showDisabled) then buildingListing.Disabled:SetHide(false); buildingListing.Button:SetColor(COLOR_LOW_OPACITY); else buildingListing.Button:SetHide(true); end else buildingListing.Button:SetHide(false); buildingListing.Disabled:SetHide(true); buildingListing.Button:SetColor(0xffffffff); end buildingListing.Button:SetDisabled(item.Disabled); if(not IsTutorialRunning()) then buildingListing.Button:RegisterCallback( Mouse.eRClick, function() LuaEvents.OpenCivilopedia(item.Type); end); end buildingListing.Button:RegisterCallback( Mouse.eLClick, function() PurchaseBuilding(data.City, item); end); end end buildingList.List:CalculateSize(); buildingList.List:ReprocessAnchoring(); if (buildingList.List:GetSizeY()==0) then buildingList.Top:SetHide(true); else m_maxPurchaseSize = m_maxPurchaseSize + HEADER_Y + SEPARATOR_Y; buildingList.Header:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); buildingList.Header:RegisterCallback( Mouse.eLClick, function() OnExpand(bL); end); buildingList.HeaderOn:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); buildingList.HeaderOn:RegisterCallback( Mouse.eLClick, function() OnCollapse(bL); end); end if( listMode== LISTMODE.PURCHASE_GOLD) then purchGoldBuildingList = bL; elseif (listMode == LISTMODE.PURCHASE_FAITH) then purchFaithBuildingList = bL; end end -- End if NOT LISTMODE.PRODUCTION -- Populate Units ------------------------ local primaryColor, secondaryColor = UI.GetPlayerColors( Players[Game.GetLocalPlayer()]:GetID() ); local darkerFlagColor :number = DarkenLightenColor(primaryColor,(-85),255); local brighterFlagColor :number = DarkenLightenColor(primaryColor,90,255); local brighterIconColor :number = DarkenLightenColor(secondaryColor,20,255); local darkerIconColor :number = DarkenLightenColor(secondaryColor,-30,255); unitList = listIM:GetInstance(); unitList.Header:SetText(Locale.ToUpper(Locale.Lookup("LOC_TECH_FILTER_UNITS"))); unitList.HeaderOn:SetText(Locale.ToUpper(Locale.Lookup("LOC_TECH_FILTER_UNITS"))); local uL = unitList; if ( unitList.unitListIM ~= nil ) then unitList.unitListIM:ResetInstances(); else unitList.unitListIM = InstanceManager:new( "UnitListInstance", "Root", unitList.List); end if ( unitList.civilianListIM ~= nil ) then unitList.civilianListIM:ResetInstances(); else unitList.civilianListIM = InstanceManager:new( "CivilianListInstance", "Root", unitList.List); end local unitData; if(listMode == LISTMODE.PRODUCTION) then unitData = data.UnitItems; else unitData = data.UnitPurchases; end for i, item in ipairs(unitData) do local unitListing; if ((item.Yield == "YIELD_GOLD" and listMode == LISTMODE.PURCHASE_GOLD) or (item.Yield == "YIELD_FAITH" and listMode == LISTMODE.PURCHASE_FAITH) or listMode == LISTMODE.PRODUCTION) then if (item.Civilian) then unitListing = unitList["civilianListIM"]:GetInstance(); else unitListing = unitList["unitListIM"]:GetInstance(); end ResetInstanceVisibility(unitListing); -- Check to see if this item is recommended for _,hash in ipairs( m_recommendedItems) do if(item.Hash == hash.BuildItemHash) then unitListing.RecommendedIcon:SetHide(false); end end local costStr = ""; local costStrTT = ""; if(listMode == LISTMODE.PRODUCTION) then -- ProductionQueue: We need to check that there isn't already one of these in the queue if(prodQueue[cityID][1] and prodQueue[cityID][1].entry.Hash == item.Hash) then item.TurnsLeft = math.ceil(item.Cost / cityData.ProductionPerTurn); item.Progress = 0; end -- Production meter progress for parent unit if(item.Progress > 0) then unitListing.ProductionProgressArea:SetHide(false); local unitProgress = item.Progress/item.Cost; if (unitProgress < 1) then unitListing.ProductionProgress:SetPercent(unitProgress); else unitListing.ProductionProgressArea:SetHide(true); end else unitListing.ProductionProgressArea:SetHide(true); end local numberOfTurns = item.TurnsLeft; if numberOfTurns == -1 then numberOfTurns = "999+"; costStrTT = Locale.Lookup("LOC_HUD_CITY_WILL_NOT_COMPLETE"); else costStrTT = numberOfTurns .. Locale.Lookup("LOC_HUD_CITY_TURNS_TO_COMPLETE", item.TurnsLeft); end costStr = numberOfTurns .. "[ICON_Turn]"; else unitListing.ProductionProgressArea:SetHide(true); if (item.Yield == "YIELD_GOLD") then costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_GOLD_TEXT", item.Cost); else costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_FAITH_TEXT", item.Cost); end if item.CantAfford then costStr = "[COLOR:Red]" .. costStr .. "[ENDCOLOR]"; end end -- PQ: Check if we already have max spies including queued if(item.Hash == GameInfo.Units["UNIT_SPY"].Hash) then local localDiplomacy = localPlayer:GetDiplomacy(); local spyCap = localDiplomacy:GetSpyCapacity(); local numberOfSpies = 0; -- Count our spies local localPlayerUnits:table = localPlayer:GetUnits(); for i, unit in localPlayerUnits:Members() do local unitInfo:table = GameInfo.Units[unit:GetUnitType()]; if unitInfo.Spy then numberOfSpies = numberOfSpies + 1; end end -- Loop through all players to see if they have any of our captured spies local players:table = Game.GetPlayers(); for i, player in ipairs(players) do local playerDiplomacy:table = player:GetDiplomacy(); local numCapturedSpies:number = playerDiplomacy:GetNumSpiesCaptured(); for i=0,numCapturedSpies-1,1 do local spyInfo:table = playerDiplomacy:GetNthCapturedSpy(player:GetID(), i); if spyInfo and spyInfo.OwningPlayer == Game.GetLocalPlayer() then numberOfSpies = numberOfSpies + 1; end end end -- Count travelling spies if localDiplomacy then local numSpiesOffMap:number = localDiplomacy:GetNumSpiesOffMap(); for i=0,numSpiesOffMap-1,1 do local spyOffMapInfo:table = localDiplomacy:GetNthOffMapSpy(Game.GetLocalPlayer(), i); if spyOffMapInfo and spyOffMapInfo.ReturnTurn ~= -1 then numberOfSpies = numberOfSpies + 1; end end end if(spyCap > numberOfSpies) then for _,city in pairs(prodQueue) do for _,qi in pairs(city) do if(qi.entry.Hash == item.Hash) then numberOfSpies = numberOfSpies + 1; end end end if(numberOfSpies >= spyCap) then item.Disabled = true; -- No existing localization string for "Need more spy slots" so we'll just gray it out -- item.ToolTip = item.ToolTip .. "[NEWLINE][NEWLINE][COLOR:Red]" .. Locale.Lookup("???"); end end end -- PQ: Check if we already have max traders queued if(item.Hash == GameInfo.Units["UNIT_TRADER"].Hash) then local playerTrade :table = localPlayer:GetTrade(); local routesActive :number = playerTrade:GetNumOutgoingRoutes(); local routesCapacity:number = playerTrade:GetOutgoingRouteCapacity(); local routesQueued :number = 0; if(routesCapacity >= routesActive) then for _,city in pairs(prodQueue) do for _,qi in pairs(city) do if(qi.entry.Hash == item.Hash) then routesQueued = routesQueued + 1; end end end if(routesActive + routesQueued >= routesCapacity) then item.Disabled = true; if(not string.find(item.ToolTip, "[COLOR:Red]")) then item.ToolTip = item.ToolTip .. "[NEWLINE][NEWLINE][COLOR:Red]" .. Locale.Lookup("LOC_UNIT_TRAIN_FULL_TRADE_ROUTE_CAPACITY"); end end end end local nameStr = Locale.Lookup("{1_Name}", item.Name); unitListing.LabelText:SetText(nameStr); unitListing.CostText:SetText(costStr); if(costStrTT ~= "") then unitListing.CostText:SetToolTipString(costStrTT); end unitListing.TrainUnit:SetToolTipString(item.ToolTip); unitListing.Disabled:SetToolTipString(item.ToolTip); -- Show/hide religion indicator icon if unitListing.ReligionIcon then local showReligionIcon:boolean = false; if item.ReligiousStrength and item.ReligiousStrength > 0 then if unitListing.ReligionIcon then local religionType = data.City:GetReligion():GetMajorityReligion(); if religionType > 0 then local religion:table = GameInfo.Religions[religionType]; local religionIcon:string = "ICON_" .. religion.ReligionType; local religionColor:number = UI.GetColorValue(religion.Color); unitListing.ReligionIcon:SetIcon(religionIcon); unitListing.ReligionIcon:SetColor(religionColor); unitListing.ReligionIcon:LocalizeAndSetToolTip(religion.Name); unitListing.ReligionIcon:SetHide(false); showReligionIcon = true; end end end unitListing.ReligionIcon:SetHide(not showReligionIcon); end -- Set Icon color and backing local textureName = TEXTURE_BASE; if item.Type ~= -1 then if (GameInfo.Units[item.Type].Combat ~= 0 or GameInfo.Units[item.Type].RangedCombat ~= 0) then -- Need a simpler what to test if the unit is a combat unit or not. if "DOMAIN_SEA" == GameInfo.Units[item.Type].Domain then textureName = TEXTURE_NAVAL; else textureName = TEXTURE_BASE; end else if GameInfo.Units[item.Type].MakeTradeRoute then textureName = TEXTURE_TRADE; elseif "FORMATION_CLASS_SUPPORT" == GameInfo.Units[item.Type].FormationClass then textureName = TEXTURE_SUPPORT; elseif item.ReligiousStrength > 0 then textureName = TEXTURE_RELIGION; else textureName = TEXTURE_CIVILIAN; end end end -- Set colors and icons for the flag instance unitListing.FlagBase:SetTexture(textureName); unitListing.FlagBaseOutline:SetTexture(textureName); unitListing.FlagBaseDarken:SetTexture(textureName); unitListing.FlagBaseLighten:SetTexture(textureName); unitListing.FlagBase:SetColor( primaryColor ); unitListing.FlagBaseOutline:SetColor( primaryColor ); unitListing.FlagBaseDarken:SetColor( darkerFlagColor ); unitListing.FlagBaseLighten:SetColor( brighterFlagColor ); unitListing.Icon:SetColor( secondaryColor ); unitListing.Icon:SetIcon(ICON_PREFIX..item.Type); -- Handle if the item is disabled if (item.Disabled) then if(showDisabled) then unitListing.Disabled:SetHide(false); unitListing.TrainUnit:SetColor(COLOR_LOW_OPACITY); unitListing.RecommendedIcon:SetHide(true); else unitListing.TrainUnit:SetHide(true); end else unitListing.TrainUnit:SetHide(false); unitListing.Disabled:SetHide(true); unitListing.TrainUnit:SetColor(0xffffffff); end unitListing.TrainUnit:SetDisabled(item.Disabled); unitListing.TrainUnit:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); if (listMode == LISTMODE.PRODUCTION) then unitListing.TrainUnit:RegisterCallback( Mouse.eLClick, function() QueueUnit(data.City, item, m_isCONTROLpressed); end); unitListing.TrainUnit:RegisterCallback( Mouse.eMClick, function() QueueUnit(data.City, item, true); RecenterCameraToSelectedCity(); end); else unitListing.TrainUnit:RegisterCallback( Mouse.eLClick, function() PurchaseUnit(data.City, item); end); end if(not IsTutorialRunning()) then unitListing.TrainUnit:RegisterCallback( Mouse.eRClick, function() LuaEvents.OpenCivilopedia(item.Type); end); end unitListing.TrainUnit:SetTag(UITutorialManager:GetHash(item.Type)); -- Controls for training unit corps and armies. -- Want a special text string for this!! #NEW TEXT #LOCALIZATION - "You can only directly build corps and armies once you have constructed a military academy." -- LOC_UNIT_TRAIN_NEED_MILITARY_ACADEMY if item.Corps or item.Army then --if (item.Disabled) then -- if(showDisabled) then -- unitListing.CorpsDisabled:SetHide(false); -- unitListing.ArmyDisabled:SetHide(false); -- end --end unitListing.CorpsArmyDropdownArea:SetHide(false); unitListing.CorpsArmyDropdownButton:RegisterCallback( Mouse.eLClick, function() local isExpanded = unitListing.CorpsArmyArrow:IsSelected(); unitListing.CorpsArmyArrow:SetSelected(not isExpanded); unitListing.ArmyCorpsDrawer:SetHide(not isExpanded); unitList.List:CalculateSize(); unitList.List:ReprocessAnchoring(); unitList.Top:CalculateSize(); unitList.Top:ReprocessAnchoring(); if(listMode == LISTMODE.PRODUCTION) then Controls.ProductionList:CalculateSize(); Controls.ProductionListScroll:CalculateSize(); elseif(listMode == LISTMODE.PURCHASE_GOLD) then Controls.PurchaseList:CalculateSize(); Controls.PurchaseListScroll:CalculateSize(); elseif(listMode == LISTMODE.PURCHASE_FAITH) then Controls.PurchaseFaithList:CalculateSize(); Controls.PurchaseFaithListScroll:CalculateSize(); end end); end if item.Corps then -- Check to see if this item is recommended for _,hash in ipairs( m_recommendedItems) do if(item.Hash == hash.BuildItemHash) then unitListing.CorpsRecommendedIcon:SetHide(false); end end unitListing.CorpsButtonContainer:SetHide(false); -- Production meter progress for corps unit if (listMode == LISTMODE.PRODUCTION) then -- ProductionQueue: We need to check that there isn't already one of these in the queue if(IsHashInQueue(selectedCity, item.Hash)) then item.CorpsTurnsLeft = math.ceil(item.CorpsCost / cityData.ProductionPerTurn); item.Progress = 0; end if(item.Progress > 0) then unitListing.ProductionCorpsProgressArea:SetHide(false); local unitProgress = item.Progress/item.CorpsCost; if (unitProgress < 1) then unitListing.ProductionCorpsProgress:SetPercent(unitProgress); else unitListing.ProductionCorpsProgressArea:SetHide(true); end else unitListing.ProductionCorpsProgressArea:SetHide(true); end local turnsStr = item.CorpsTurnsLeft .. "[ICON_Turn]"; local turnsStrTT = item.CorpsTurnsLeft .. Locale.Lookup("LOC_HUD_CITY_TURNS_TO_COMPLETE", item.CorpsTurnsLeft); unitListing.CorpsCostText:SetText(turnsStr); unitListing.CorpsCostText:SetToolTipString(turnsStrTT); else unitListing.ProductionCorpsProgressArea:SetHide(true); if (item.Yield == "YIELD_GOLD") then costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_GOLD_TEXT", item.CorpsCost); else costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_FAITH_TEXT", item.CorpsCost); end if (item.CorpsDisabled) then if (showDisabled) then unitListing.CorpsDisabled:SetHide(false); end costStr = "[COLOR:Red]" .. costStr .. "[ENDCOLOR]"; end unitListing.CorpsCostText:SetText(costStr); end unitListing.CorpsLabelIcon:SetText(item.CorpsName); unitListing.CorpsLabelText:SetText(nameStr); unitListing.CorpsFlagBase:SetTexture(textureName); unitListing.CorpsFlagBaseOutline:SetTexture(textureName); unitListing.CorpsFlagBaseDarken:SetTexture(textureName); unitListing.CorpsFlagBaseLighten:SetTexture(textureName); unitListing.CorpsFlagBase:SetColor( primaryColor ); unitListing.CorpsFlagBaseOutline:SetColor( primaryColor ); unitListing.CorpsFlagBaseDarken:SetColor( darkerFlagColor ); unitListing.CorpsFlagBaseLighten:SetColor( brighterFlagColor ); unitListing.CorpsIcon:SetColor( secondaryColor ); unitListing.CorpsIcon:SetIcon(ICON_PREFIX..item.Type); unitListing.TrainCorpsButton:SetToolTipString(item.CorpsTooltip); unitListing.CorpsDisabled:SetToolTipString(item.CorpsTooltip); if (listMode == LISTMODE.PRODUCTION) then unitListing.TrainCorpsButton:RegisterCallback( Mouse.eLClick, function() QueueUnitCorps(data.City, item); end); unitListing.TrainCorpsButton:RegisterCallback( Mouse.eMClick, function() QueueUnitCorps(data.City, item, true); RecenterCameraToSelectedCity(); end); else unitListing.TrainCorpsButton:RegisterCallback( Mouse.eLClick, function() PurchaseUnitCorps(data.City, item); end); end end if item.Army then -- Check to see if this item is recommended for _,hash in ipairs( m_recommendedItems) do if(item.Hash == hash.BuildItemHash) then unitListing.ArmyRecommendedIcon:SetHide(false); end end unitListing.ArmyButtonContainer:SetHide(false); if (listMode == LISTMODE.PRODUCTION) then -- ProductionQueue: We need to check that there isn't already one of these in the queue if(IsHashInQueue(selectedCity, item.Hash)) then item.ArmyTurnsLeft = math.ceil(item.ArmyCost / cityData.ProductionPerTurn); item.Progress = 0; end if(item.Progress > 0) then unitListing.ProductionArmyProgressArea:SetHide(false); local unitProgress = item.Progress/item.ArmyCost; unitListing.ProductionArmyProgress:SetPercent(unitProgress); if (unitProgress < 1) then unitListing.ProductionArmyProgress:SetPercent(unitProgress); else unitListing.ProductionArmyProgressArea:SetHide(true); end else unitListing.ProductionArmyProgressArea:SetHide(true); end local turnsStrTT:string = ""; local turnsStr:string = ""; local numberOfTurns = item.ArmyTurnsLeft; if numberOfTurns == -1 then numberOfTurns = "999+"; turnsStrTT = Locale.Lookup("LOC_HUD_CITY_WILL_NOT_COMPLETE"); else turnsStrTT = numberOfTurns .. Locale.Lookup("LOC_HUD_CITY_TURNS_TO_COMPLETE", item.ArmyTurnsLeft); end turnsStr = numberOfTurns .. "[ICON_Turn]"; unitListing.ArmyCostText:SetText(turnsStr); unitListing.ArmyCostText:SetToolTipString(turnsStrTT); else unitListing.ProductionArmyProgressArea:SetHide(true); if (item.Yield == "YIELD_GOLD") then costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_GOLD_TEXT", item.ArmyCost); else costStr = Locale.Lookup("LOC_PRODUCTION_PURCHASE_FAITH_TEXT", item.ArmyCost); end if (item.ArmyDisabled) then if (showDisabled) then unitListing.ArmyDisabled:SetHide(false); end costStr = "[COLOR:Red]" .. costStr .. "[ENDCOLOR]"; end unitListing.ArmyCostText:SetText(costStr); end unitListing.ArmyLabelIcon:SetText(item.ArmyName); unitListing.ArmyLabelText:SetText(nameStr); unitListing.ArmyFlagBase:SetTexture(textureName); unitListing.ArmyFlagBaseOutline:SetTexture(textureName); unitListing.ArmyFlagBaseDarken:SetTexture(textureName); unitListing.ArmyFlagBaseLighten:SetTexture(textureName); unitListing.ArmyFlagBase:SetColor( primaryColor ); unitListing.ArmyFlagBaseOutline:SetColor( primaryColor ); unitListing.ArmyFlagBaseDarken:SetColor( darkerFlagColor ); unitListing.ArmyFlagBaseLighten:SetColor( brighterFlagColor ); unitListing.ArmyIcon:SetColor( secondaryColor ); unitListing.ArmyIcon:SetIcon(ICON_PREFIX..item.Type); unitListing.TrainArmyButton:SetToolTipString(item.ArmyTooltip); unitListing.ArmyDisabled:SetToolTipString(item.ArmyTooltip); if (listMode == LISTMODE.PRODUCTION) then unitListing.TrainArmyButton:RegisterCallback( Mouse.eLClick, function() QueueUnitArmy(data.City, item); end); unitListing.TrainArmyButton:RegisterCallback( Mouse.eMClick, function() QueueUnitArmy(data.City, item, true); RecenterCameraToSelectedCity(); end); else unitListing.TrainArmyButton:RegisterCallback( Mouse.eLClick, function() PurchaseUnitArmy(data.City, item); end); end end end -- end faith/gold check end -- end iteration through units unitList.List:CalculateSize(); unitList.List:ReprocessAnchoring(); if (unitList.List:GetSizeY()==0) then unitList.Top:SetHide(true); else m_maxProductionSize = m_maxProductionSize + HEADER_Y + SEPARATOR_Y; unitList.Header:RegisterCallback( Mouse.eLClick, function() OnExpand(uL); end); unitList.HeaderOn:RegisterCallback( Mouse.eLClick, function() OnCollapse(uL); end); end if( listMode== LISTMODE.PURCHASE_GOLD) then purchGoldUnitList = uL; elseif (listMode == LISTMODE.PURCHASE_FAITH) then purchFaithUnitList = uL; else prodUnitList = uL; end if(listMode == LISTMODE.PRODUCTION) then --Projects can only be produced, not purchased -- Populate Projects ------------------------ projectList = listIM:GetInstance(); projectList.Header:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_PROJECTS"))); projectList.HeaderOn:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_PROJECTS"))); local pL = projectList; if ( projectList.projectListIM ~= nil ) then projectList.projectListIM:ResetInstances(); else projectList.projectListIM = InstanceManager:new( "ProjectListInstance", "Root", projectList.List); end -- Check for queued project and list it as well -- if(prodQueue[cityID] and prodQueue[cityID][1] and GameInfo.Projects[prodQueue[cityID][1].entry.Hash]) then -- local activeQueueItem = prodQueue[cityID][1].entry; -- table.insert(data.ProjectItems, activeQueueItem); -- end for i, item in ipairs(data.ProjectItems) do local projectListing = projectList.projectListIM:GetInstance(); ResetInstanceVisibility(projectListing); -- Check to see if this item is recommended for _,hash in ipairs( m_recommendedItems) do if(item.Hash == hash.BuildItemHash) then projectListing.RecommendedIcon:SetHide(false); end end -- ProductionQueue: We need to check that there isn't already one of these in the queue if(IsHashInQueue(selectedCity, item.Hash)) then item.TurnsLeft = math.ceil(item.Cost / cityData.ProductionPerTurn); item.Progress = 0; end -- Production meter progress for project if(item.Progress > 0) then projectListing.ProductionProgressArea:SetHide(false); local projectProgress = item.Progress/item.Cost; if (projectProgress < 1) then projectListing.ProductionProgress:SetPercent(projectProgress); else projectListing.ProductionProgressArea:SetHide(true); end else projectListing.ProductionProgressArea:SetHide(true); end local numberOfTurns = item.TurnsLeft; if numberOfTurns == -1 then numberOfTurns = "999+"; end; local nameStr = Locale.Lookup("{1_Name}", item.Name); local turnsStr = numberOfTurns .. "[ICON_Turn]"; projectListing.LabelText:SetText(nameStr); projectListing.CostText:SetText(turnsStr); projectListing.Button:SetToolTipString(item.ToolTip); projectListing.Disabled:SetToolTipString(item.ToolTip); projectListing.Icon:SetIcon(ICON_PREFIX..item.Type); if (item.Disabled) then if(showDisabled) then projectListing.Disabled:SetHide(false); projectListing.Button:SetColor(COLOR_LOW_OPACITY); else projectListing.Button:SetHide(true); end else projectListing.Button:SetHide(false); projectListing.Disabled:SetHide(true); projectListing.Button:SetColor(0xffffffff); end projectListing.Button:SetDisabled(item.Disabled); projectListing.Button:RegisterCallback( Mouse.eLClick, function() QueueProject(data.City, item); end); projectListing.Button:RegisterCallback( Mouse.eMClick, function() QueueProject(data.City, item, true); RecenterCameraToSelectedCity(); end); if(not IsTutorialRunning()) then projectListing.Button:RegisterCallback( Mouse.eRClick, function() LuaEvents.OpenCivilopedia(item.Type); end); end projectListing.Button:SetTag(UITutorialManager:GetHash(item.Type)); end projectList.List:CalculateSize(); projectList.List:ReprocessAnchoring(); if (projectList.List:GetSizeY()==0) then projectList.Top:SetHide(true); else m_maxProductionSize = m_maxProductionSize + HEADER_Y + SEPARATOR_Y; projectList.Header:RegisterCallback( Mouse.eLClick, function() OnExpand(pL); end); projectList.HeaderOn:RegisterCallback( Mouse.eLClick, function() OnCollapse(pL); end); end prodProjectList = pL; end -- end if LISTMODE.PRODUCTION ----------------------------------- if( listMode == LISTMODE.PRODUCTION) then m_maxProductionSize = m_maxProductionSize + districtList.List:GetSizeY() + unitList.List:GetSizeY() + projectList.List:GetSizeY(); end Controls.ProductionList:CalculateSize(); Controls.ProductionListScroll:CalculateSize(); Controls.PurchaseList:CalculateSize(); Controls.PurchaseListScroll:CalculateSize(); Controls.PurchaseFaithList:CalculateSize(); Controls.PurchaseFaithListScroll:CalculateSize(); -- DEBUG %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --for _,data in ipairs( m_recommendedItems) do -- if(GameInfo.Types[data.BuildItemHash].Type ~= nil) then -- print("Hash = ".. GameInfo.Types[data.BuildItemHash].Type); -- else -- print("Invalid hash received = " .. data.BuildItemHash); -- end --end -- DEBUG %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end function OnLocalPlayerChanged() Refresh(); end function OnPlayerTurnActivated(player, isFirstTimeThisTurn) if (isFirstTimeThisTurn and Game.GetLocalPlayer() == player) then CheckAndReplaceAllQueuesForUpgrades(); Refresh(); lastProductionCompletePerCity = {}; end end -- Returns ( allReasons:string ) function ComposeFailureReasonStrings( isDisabled:boolean, results:table ) if isDisabled and results ~= nil then -- Are there any failure reasons? local pFailureReasons : table = results[CityCommandResults.FAILURE_REASONS]; if pFailureReasons ~= nil and table.count( pFailureReasons ) > 0 then -- Collect them all! local allReasons : string = ""; for i,v in ipairs(pFailureReasons) do allReasons = allReasons .. "[NEWLINE][NEWLINE][COLOR:Red]" .. Locale.Lookup(v) .. "[ENDCOLOR]"; end return allReasons; end end return ""; end function ComposeProductionCostString( iProductionProgress:number, iProductionCost:number) -- Show production progress only if there is progress present if iProductionCost ~= 0 then local TXT_COST :string = Locale.Lookup( "LOC_HUD_PRODUCTION_COST" ); local TXT_PRODUCTION :string = Locale.Lookup( "LOC_HUD_PRODUCTION" ); local costString :string = tostring(iProductionCost); if iProductionProgress > 0 then -- Only show fraction if build progress has been made. costString = tostring(iProductionProgress) .. "/" .. costString; end return "[NEWLINE][NEWLINE]" .. TXT_COST .. ": " .. costString .. " [ICON_Production] " .. TXT_PRODUCTION; end return ""; end -- Returns ( tooltip:string, subtitle:string ) function ComposeUnitCorpsStrings( sUnitName:string, sUnitDomain:string, iProdProgress:number, iCorpsCost:number ) local tooltip :string = Locale.Lookup( sUnitName ) .. " "; local subtitle :string = ""; if sUnitDomain == "DOMAIN_SEA" then tooltip = tooltip .. Locale.Lookup("LOC_UNITFLAG_FLEET_SUFFIX"); subtitle = "(" .. Locale.Lookup("LOC_HUD_UNIT_PANEL_FLEET_SUFFIX") .. ")"; else tooltip = tooltip .. Locale.Lookup("LOC_UNITFLAG_CORPS_SUFFIX"); subtitle = "(" .. Locale.Lookup("LOC_HUD_UNIT_PANEL_CORPS_SUFFIX") .. ")"; end tooltip = tooltip .. "[NEWLINE]---" .. ComposeProductionCostString( iProdProgress, iCorpsCost ); return tooltip, subtitle; end function ComposeUnitArmyStrings( sUnitName:string, sUnitDomain:string, iProdProgress:number, iArmyCost:number ) local tooltip :string = Locale.Lookup( sUnitName ) .. " "; local subtitle :string = ""; if sUnitDomain == "DOMAIN_SEA" then tooltip = tooltip .. Locale.Lookup("LOC_UNITFLAG_ARMADA_SUFFIX"); subtitle = "("..Locale.Lookup("LOC_HUD_UNIT_PANEL_ARMADA_SUFFIX")..")"; else tooltip = tooltip .. Locale.Lookup("LOC_UNITFLAG_ARMY_SUFFIX"); subtitle = "("..Locale.Lookup("LOC_HUD_UNIT_PANEL_ARMY_SUFFIX")..")"; end tooltip = tooltip .. "[NEWLINE]---" .. ComposeProductionCostString( iProdProgress, iArmyCost ); return tooltip, subtitle; end -- Returns ( isPurchaseable:boolean, kEntry:table ) function ComposeUnitForPurchase( row:table, pCity:table, sYield:string, pYieldSource:table, sCantAffordKey:string ) local YIELD_TYPE :number = GameInfo.Yields[sYield].Index; -- Should we display this option to the player? local tParameters = {}; tParameters[CityCommandTypes.PARAM_UNIT_TYPE] = row.Hash; tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = YIELD_TYPE; if CityManager.CanStartCommand( pCity, CityCommandTypes.PURCHASE, true, tParameters, false ) then local isCanStart, results = CityManager.CanStartCommand( pCity, CityCommandTypes.PURCHASE, false, tParameters, true ); local isDisabled :boolean = not isCanStart; local allReasons :string = ComposeFailureReasonStrings( isDisabled, results ); local sToolTip :string = ToolTipHelper.GetUnitToolTip( row.Hash ) .. allReasons; local isCantAfford :boolean = false; --print ( "UnitBuy ", row.UnitType,isCanStart ); -- Collect some constants so we don't need to keep calling out to get them. local nCityID :number = pCity:GetID(); local pCityGold :table = pCity:GetGold(); local TXT_INSUFFIENT_YIELD :string = "[NEWLINE][NEWLINE][COLOR:Red]" .. Locale.Lookup( sCantAffordKey ) .. "[ENDCOLOR]"; -- Affordability check if not pYieldSource:CanAfford( nCityID, row.Hash ) then sToolTip = sToolTip .. TXT_INSUFFIENT_YIELD; isDisabled = true; isCantAfford = true; end local pBuildQueue :table = pCity:GetBuildQueue(); local nProductionCost :number = pBuildQueue:GetUnitCost( row.Index ); local nProductionProgress :number = pBuildQueue:GetUnitProgress( row.Index ); sToolTip = sToolTip .. ComposeProductionCostString( nProductionProgress, nProductionCost ); local kUnit :table = { Type = row.UnitType; Name = row.Name; ToolTip = sToolTip; Hash = row.Hash; Kind = row.Kind; Civilian = row.FormationClass == "FORMATION_CLASS_CIVILIAN"; Disabled = isDisabled; CantAfford = isCantAfford, Yield = sYield; Cost = pCityGold:GetPurchaseCost( YIELD_TYPE, row.Hash, MilitaryFormationTypes.STANDARD_MILITARY_FORMATION ); ReligiousStrength = row.ReligiousStrength; CorpsTurnsLeft = 0; ArmyTurnsLeft = 0; Progress = 0; }; -- Should we present options for building Corps or Army versions? if results ~= nil then kUnit.Corps = results[CityOperationResults.CAN_TRAIN_CORPS]; kUnit.Army = results[CityOperationResults.CAN_TRAIN_ARMY]; local nProdProgress :number = pBuildQueue:GetUnitProgress( row.Index ); if kUnit.Corps then local nCost = pBuildQueue:GetUnitCorpsCost( row.Index ); kUnit.CorpsCost = pCityGold:GetPurchaseCost( YIELD_TYPE, row.Hash, MilitaryFormationTypes.CORPS_MILITARY_FORMATION ); kUnit.CorpsTooltip, kUnit.CorpsName = ComposeUnitCorpsStrings( row.Name, row.Domain, nProdProgress, nCost ); kUnit.CorpsDisabled = not pYieldSource:CanAfford( nCityID, row.Hash, MilitaryFormationTypes.CORPS_MILITARY_FORMATION ); if kUnit.CorpsDisabled then kUnit.CorpsTooltip = kUnit.CorpsTooltip .. TXT_INSUFFIENT_YIELD; end end if kUnit.Army then local nCost = pBuildQueue:GetUnitArmyCost( row.Index ); kUnit.ArmyCost = pCityGold:GetPurchaseCost( YIELD_TYPE, row.Hash, MilitaryFormationTypes.ARMY_MILITARY_FORMATION ); kUnit.ArmyTooltip, kUnit.ArmyName = ComposeUnitArmyStrings( row.Name, row.Domain, nProdProgress, nCost ); kUnit.ArmyDisabled = not pYieldSource:CanAfford( nCityID, row.Hash, MilitaryFormationTypes.ARMY_MILITARY_FORMATION ); if kUnit.ArmyDisabled then kUnit.ArmyTooltip = kUnit.ArmyTooltip .. TXT_INSUFFIENT_YIELD; end end end return true, kUnit; end return false, nil; end function ComposeBldgForPurchase( pRow:table, pCity:table, sYield:string, pYieldSource:table, sCantAffordKey:string ) local YIELD_TYPE :number = GameInfo.Yields[sYield].Index; local tParameters = {}; tParameters[CityCommandTypes.PARAM_BUILDING_TYPE] = pRow.Hash; tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = YIELD_TYPE; if CityManager.CanStartCommand( pCity, CityCommandTypes.PURCHASE, true, tParameters, false ) then local isCanStart, pResults = CityManager.CanStartCommand( pCity, CityCommandTypes.PURCHASE, false, tParameters, true ); local isDisabled :boolean = not isCanStart; local sAllReasons :string = ComposeFailureReasonStrings( isDisabled, pResults ); local sToolTip :string = ToolTipHelper.GetBuildingToolTip( pRow.Hash, playerID, pCity ) .. sAllReasons; local isCantAfford :boolean = false; -- Affordability check if not pYieldSource:CanAfford( cityID, pRow.Hash ) then sToolTip = sToolTip .. "[NEWLINE][NEWLINE][COLOR:Red]" .. Locale.Lookup(sCantAffordKey) .. "[ENDCOLOR]"; isDisabled = true; isCantAfford = true; end local pBuildQueue :table = pCity:GetBuildQueue(); local iProductionCost :number = pBuildQueue:GetBuildingCost( pRow.Index ); local iProductionProgress :number = pBuildQueue:GetBuildingProgress( pRow.Index ); sToolTip = sToolTip .. ComposeProductionCostString( iProductionProgress, iProductionCost ); local kBuilding :table = { Type = pRow.BuildingType, Name = pRow.Name, ToolTip = sToolTip, Hash = pRow.Hash, Kind = pRow.Kind, Disabled = isDisabled, CantAfford = isCantAfford, Cost = pCity:GetGold():GetPurchaseCost( YIELD_TYPE, pRow.Hash ), Yield = sYield }; return true, kBuilding; end return false, nil; end function ComposeDistrictForPurchase( pRow:table, pCity:table, sYield:string, pYieldSource:table, sCantAffordKey:string ) local YIELD_TYPE :number = GameInfo.Yields[sYield].Index; local tParameters = {}; tParameters[CityCommandTypes.PARAM_DISTRICT_TYPE] = pRow.Hash; tParameters[CityCommandTypes.PARAM_YIELD_TYPE] = YIELD_TYPE; if CityManager.CanStartCommand( pCity, CityCommandTypes.PURCHASE, true, tParameters, false ) then local isCanStart, pResults = CityManager.CanStartCommand( pCity, CityCommandTypes.PURCHASE, false, tParameters, true ); local isDisabled :boolean = not isCanStart; local sAllReasons :string = ComposeFailureReasonStrings( isDisabled, pResults ); local sToolTip :string = ToolTipHelper.GetDistrictToolTip( pRow.Hash ) .. sAllReasons; local isCantAfford :boolean = false; -- Affordability check if not pYieldSource:CanAfford( cityID, pRow.Hash ) then sToolTip = sToolTip .. "[NEWLINE][NEWLINE][COLOR:Red]" .. Locale.Lookup(sCantAffordKey) .. "[ENDCOLOR]"; isDisabled = true; isCantAfford = true; end local pBuildQueue :table = pCity:GetBuildQueue(); local iProductionCost :number = pBuildQueue:GetDistrictCost( pRow.Index ); local iProductionProgress :number = pBuildQueue:GetDistrictProgress( pRow.Index ); sToolTip = sToolTip .. ComposeProductionCostString( iProductionProgress, iProductionCost ); local kDistrict :table = { Type = pRow.DistrictType, Name = pRow.Name, ToolTip = sToolTip, Hash = pRow.Hash, Kind = pRow.Kind, Disabled = isDisabled, CantAfford = isCantAfford, Cost = pCity:GetGold():GetPurchaseCost( YIELD_TYPE, pRow.Hash ), Yield = sYield }; return true, kDistrict; end return false, nil; end -- =========================================================================== function Refresh(persistCollapse) local playerID :number = Game.GetLocalPlayer(); local pPlayer :table = Players[playerID]; if (pPlayer == nil) then return; end local selectedCity = UI.GetHeadSelectedCity(); if (selectedCity ~= nil) then local cityGrowth = selectedCity:GetGrowth(); local cityCulture = selectedCity:GetCulture(); local buildQueue = selectedCity:GetBuildQueue(); local playerTreasury= pPlayer:GetTreasury(); local playerReligion= pPlayer:GetReligion(); local cityGold = selectedCity:GetGold(); local cityBuildings = selectedCity:GetBuildings(); local cityDistricts = selectedCity:GetDistricts(); local cityID = selectedCity:GetID(); local cityData = GetCityData(selectedCity); local cityPlot = Map.GetPlot(selectedCity:GetX(), selectedCity:GetY()); if(not prodQueue[cityID]) then prodQueue[cityID] = {}; end CheckAndReplaceQueueForUpgrades(selectedCity); local new_data = { City = selectedCity, Population = selectedCity:GetPopulation(), Owner = selectedCity:GetOwner(), Damage = pPlayer:GetDistricts():FindID( selectedCity:GetDistrictID() ):GetDamage(), TurnsUntilGrowth = cityGrowth:GetTurnsUntilGrowth(), CurrentTurnsLeft = buildQueue:GetTurnsLeft(), FoodSurplus = cityGrowth:GetFoodSurplus(), CulturePerTurn = cityCulture:GetCultureYield(), TurnsUntilExpansion = cityCulture:GetTurnsUntilExpansion(), DistrictItems = {}, BuildingItems = {}, UnitItems = {}, ProjectItems = {}, BuildingPurchases = {}, UnitPurchases = {}, DistrictPurchases = {}, }; local currentProductionHash = buildQueue:GetCurrentProductionTypeHash(); for row in GameInfo.Districts() do if row.Hash == currentProductionHash then new_data.CurrentProduction = row.Name; end local isInPanelList :boolean = not row.InternalOnly; local bHasProducedDistrict :boolean = cityDistricts:HasDistrict( row.Index ); local isInQueue :boolean = IsHashInQueue( selectedCity, row.Hash ); local turnsLeft :number = buildQueue:GetTurnsLeft( row.DistrictType ); if (isInPanelList or isInQueue) and ( buildQueue:CanProduce( row.Hash, true ) or bHasProducedDistrict or isInQueue ) then local isCanProduceExclusion, results = buildQueue:CanProduce( row.Hash, false, true ); local isDisabled :boolean = not isCanProduceExclusion; if(isInQueue) then bHasProducedDistrict = true; turnsLeft = nil; isDisabled = true; end -- If at least one valid plot is found where the district can be built, consider it buildable. local plots :table = GetCityRelatedPlotIndexesDistrictsAlternative( selectedCity, row.Hash ); if plots == nil or table.count(plots) == 0 then -- No plots available for district. Has player had already started building it? local isPlotAllocated :boolean = false; local pDistricts :table = selectedCity:GetDistricts(); for _, pCityDistrict in pDistricts:Members() do if row.Index == pCityDistrict:GetType() then isPlotAllocated = true; break; end end -- If not, this district can't be built. Guarantee that isDisabled is set. if not isPlotAllocated then isDisabled = true; end end local allReasons :string = ComposeFailureReasonStrings( isDisabled, results ); local sToolTip :string = ToolTipHelper.GetToolTip(row.DistrictType, Game.GetLocalPlayer()) .. allReasons; local iProductionCost :number = buildQueue:GetDistrictCost( row.Index ); local iProductionProgress :number = buildQueue:GetDistrictProgress( row.Index ); sToolTip = sToolTip .. ComposeProductionCostString( iProductionProgress, iProductionCost ); table.insert( new_data.DistrictItems, { Type = row.DistrictType, Name = row.Name, ToolTip = sToolTip, Hash = row.Hash, Kind = row.Kind, TurnsLeft = turnsLeft, Disabled = isDisabled, Repair = cityDistricts:IsPillaged( row.Index ), Contaminated = cityDistricts:IsContaminated( row.Index ), Cost = iProductionCost, Progress = iProductionProgress, HasBeenBuilt = bHasProducedDistrict }); end -- Can it be purchased with gold? local isAllowed, kDistrict = ComposeDistrictForPurchase( row, selectedCity, "YIELD_GOLD", playerTreasury, "LOC_BUILDING_INSUFFICIENT_FUNDS" ); if isAllowed then table.insert( new_data.DistrictPurchases, kDistrict ); end end for row in GameInfo.Buildings() do if row.Hash == currentProductionHash then new_data.CurrentProduction = row.Name; end -- PQ: Determine if we have requirements in the queue local hasPrereqTech = row.PrereqTech == nil; local hasPrereqCivic = row.PrereqCivic == nil; local isPrereqDistrictInQueue = false; local disabledTooltip = nil; local doShow = true; if(not row.IsWonder) then local prereqTech = GameInfo.Technologies[row.PrereqTech]; local prereqCivic = GameInfo.Civics[row.PrereqCivic]; local prereqDistrict = GameInfo.Districts[row.PrereqDistrict]; if(prereqTech and pPlayer:GetTechs():HasTech(prereqTech.Index)) then hasPrereqTech = true; end if(prereqCivic and pPlayer:GetCulture():HasCivic(prereqCivic.Index)) then hasPrereqCivic = true; end if((prereqDistrict and IsHashInQueue( selectedCity, prereqDistrict.Hash)) or cityDistricts:HasDistrict(prereqDistrict.Index, true)) then isPrereqDistrictInQueue = true; if(not IsHashInQueue( selectedCity, prereqDistrict.Hash )) then if(cityDistricts:IsPillaged(prereqDistrict.Index)) then disabledTooltip = Locale.Lookup("LOC_BUILDING_CONSTRUCT_DISTRICT_IS_PILLAGED"); elseif(cityDistricts:IsContaminated(prereqDistrict.Index)) then disabledTooltip = Locale.Lookup("LOC_BUILDING_CONSTRUCT_DISTRICT_IS_CONTAMINATED"); end end end if(not isPrereqDistrictInQueue) then for replacesRow in GameInfo.DistrictReplaces() do if(row.PrereqDistrict == replacesRow.ReplacesDistrictType) then local replacementDistrict = GameInfo.Districts[replacesRow.CivUniqueDistrictType]; if((replacementDistrict and IsHashInQueue( selectedCity, replacementDistrict.Hash)) or cityDistricts:HasDistrict(replacementDistrict.Index, true)) then isPrereqDistrictInQueue = true; if(not IsHashInQueue( selectedCity, replacementDistrict.Hash )) then if(cityDistricts:IsPillaged(replacementDistrict.Index)) then disabledTooltip = Locale.Lookup("LOC_BUILDING_CONSTRUCT_DISTRICT_IS_PILLAGED"); elseif(cityDistricts:IsContaminated(replacementDistrict.Index)) then disabledTooltip = Locale.Lookup("LOC_BUILDING_CONSTRUCT_DISTRICT_IS_CONTAMINATED"); end end end break; end end end if(not isPrereqDistrictInQueue) then local canBuild, reasons = buildQueue:CanProduce(row.BuildingType, false, true); if(not canBuild and reasons) then local pFailureReasons = reasons[CityCommandResults.FAILURE_REASONS]; if pFailureReasons ~= nil and table.count( pFailureReasons ) > 0 then for i,v in ipairs(pFailureReasons) do if("LOC_BUILDING_CONSTRUCT_IS_OCCUPIED" == v) then disabledTooltip = Locale.Lookup("LOC_BUILDING_CONSTRUCT_IS_OCCUPIED"); end end end end end local civTypeName = PlayerConfigurations[playerID]:GetCivilizationTypeName(); -- Check for unique buildings for replaceRow in GameInfo.BuildingReplaces() do if(replaceRow.CivUniqueBuildingType == row.BuildingType) then local traitName = "TRAIT_CIVILIZATION_" .. row.BuildingType; local isCorrectCiv = false; for traitRow in GameInfo.CivilizationTraits() do if(traitRow.TraitType == traitName and traitRow.CivilizationType == civTypeName) then isCorrectCiv = true; break; end end if(not isCorrectCiv) then doShow = false; end end if(replaceRow.ReplacesBuildingType == row.BuildingType) then local traitName = "TRAIT_CIVILIZATION_" .. replaceRow.CivUniqueBuildingType; local isCorrectCiv = false; for traitRow in GameInfo.CivilizationTraits() do if(traitRow.TraitType == traitName and traitRow.CivilizationType == civTypeName) then isCorrectCiv = true; break; end end if(isCorrectCiv) then doShow = false; end end end -- Check for building prereqs if(buildingPrereqs[row.BuildingType]) then local prereqInQueue = false; for prereqRow in GameInfo.BuildingPrereqs() do if(prereqRow.Building == row.BuildingType) then for replaceRow in GameInfo.BuildingReplaces() do if(replaceRow.ReplacesBuildingType == prereqRow.PrereqBuilding and IsHashInQueue(selectedCity, GameInfo.Buildings[replaceRow.CivUniqueBuildingType].Hash)) then prereqInQueue = true; break; end end if(prereqInQueue or IsHashInQueue(selectedCity, GameInfo.Buildings[prereqRow.PrereqBuilding].Hash)) then prereqInQueue = true; -- Check for buildings enabled by dominant religious beliefs if(GameInfo.Buildings[row.Hash].EnabledByReligion) then doShow = false; if ((table.count(cityData.Religions) > 1) or (cityData.PantheonBelief > -1)) then local modifierIDs = {}; if cityData.PantheonBelief > -1 then local beliefType = GameInfo.Beliefs[cityData.PantheonBelief].BeliefType; for belief in GameInfo.BeliefModifiers() do if belief.BeliefType == beliefType then table.insert(modifierIDs, belief.ModifierID); break; end end end if (table.count(cityData.Religions) > 0) then for _, beliefIndex in ipairs(cityData.BeliefsOfDominantReligion) do local beliefType = GameInfo.Beliefs[beliefIndex].BeliefType; for belief in GameInfo.BeliefModifiers() do if belief.BeliefType == beliefType then table.insert(modifierIDs, belief.ModifierID); end end end end if(#modifierIDs > 0) then for i=#modifierIDs, 1, -1 do if(string.find(modifierIDs[i], "ALLOW_")) then modifierIDs[i] = string.gsub(modifierIDs[i], "ALLOW", "BUILDING"); if(row.BuildingType == string.gsub(modifierIDs[i], "ALLOW", "BUILDING")) then doShow = true; end end end end end end break; end end end if(not prereqInQueue) then doShow = false; end end -- Check for river adjacency requirement if (row.RequiresAdjacentRiver and not cityPlot:IsRiver()) then doShow = false; end -- Check for wall obsolescence if(row.OuterDefenseHitPoints and pPlayer:GetCulture():HasCivic(GameInfo.Civics["CIVIC_CIVIL_ENGINEERING"].Index)) then doShow = false; end -- Check for internal only buildings if(row.InternalOnly) then doShow = false end -- Check that the player has a government of an adequate tier if(row.GovernmentTierRequirement) then local eSelectedPlayerGovernmentId:number = pPlayer:GetCulture():GetCurrentGovernment(); if eSelectedPlayerGovernmentId ~= -1 then local selectedPlayerGovernment = GameInfo.Governments[eSelectedPlayerGovernmentId]; if(selectedPlayerGovernment.Tier) then local eSelectedPlayerGovernmentTier:number = tonumber(string.sub(selectedPlayerGovernment.Tier, 5)); local buildingGovernmentTierRequirement:number = tonumber(string.sub(row.GovernmentTierRequirement, 5)); if(eSelectedPlayerGovernmentTier < buildingGovernmentTierRequirement) then doShow = false; end else doShow = false; end else doShow = false; end end -- Check if it's been built already if(hasPrereqTech and hasPrereqCivic and isPrereqDistrictInQueue and doShow) then for _, district in ipairs(cityData.BuildingsAndDistricts) do if district.isBuilt then local match = false; for _,building in ipairs(district.Buildings) do if(building.Name == Locale.Lookup(row.Name)) then if(building.isBuilt and not building.isPillaged) then doShow = false; else doShow = true; end match = true; break; end end if(match) then break; end end end else doShow = false; end end if not row.MustPurchase and ( buildQueue:CanProduce( row.Hash, true ) or (doShow and not row.IsWonder) ) then local isCanStart, results = buildQueue:CanProduce( row.Hash, false, true ); local isDisabled :boolean = false; if(row.IsWonder or not doShow) then isDisabled = not isCanStart; end local allReasons :string = ComposeFailureReasonStrings( isDisabled, results ); local sToolTip :string = ToolTipHelper.GetBuildingToolTip( row.Hash, playerID, selectedCity ) .. allReasons; local iProductionCost :number = buildQueue:GetBuildingCost( row.Index ); local iProductionProgress :number = buildQueue:GetBuildingProgress( row.Index ); if(disabledTooltip) then isDisabled = true; if(not string.find(sToolTip, "COLOR:Red")) then sToolTip = sToolTip .. "[NEWLINE][NEWLINE][COLOR:Red]" .. disabledTooltip .. "[ENDCOLOR]"; end end sToolTip = sToolTip .. ComposeProductionCostString( iProductionProgress, iProductionCost ); local iPrereqDistrict = ""; if row.PrereqDistrict ~= nil then iPrereqDistrict = row.PrereqDistrict; end table.insert( new_data.BuildingItems, { Type = row.BuildingType, Name = row.Name, ToolTip = sToolTip, Hash = row.Hash, Kind = row.Kind, TurnsLeft = buildQueue:GetTurnsLeft( row.Hash ), Disabled = isDisabled, Repair = cityBuildings:IsPillaged( row.Hash ), Cost = iProductionCost, Progress = iProductionProgress, IsWonder = row.IsWonder, PrereqDistrict = iPrereqDistrict } ); end -- Can it be purchased with gold? if row.PurchaseYield == "YIELD_GOLD" then local isAllowed, kBldg = ComposeBldgForPurchase( row, selectedCity, "YIELD_GOLD", playerTreasury, "LOC_BUILDING_INSUFFICIENT_FUNDS" ); if isAllowed then table.insert( new_data.BuildingPurchases, kBldg ); end end -- Can it be purchased with faith? if row.PurchaseYield == "YIELD_FAITH" or cityGold:IsBuildingFaithPurchaseEnabled( row.Hash ) then local isAllowed, kBldg = ComposeBldgForPurchase( row, selectedCity, "YIELD_FAITH", playerReligion, "LOC_BUILDING_INSUFFICIENT_FAITH" ); if isAllowed then table.insert( new_data.BuildingPurchases, kBldg ); end end end for row in GameInfo.Units() do if row.Hash == currentProductionHash then new_data.CurrentProduction = row.Name; end -- Can it be built normally? if not row.MustPurchase and buildQueue:CanProduce( row.Hash, true ) then local isCanProduceExclusion, results = buildQueue:CanProduce( row.Hash, false, true ); local isDisabled :boolean = not isCanProduceExclusion; local sAllReasons :string = ComposeFailureReasonStrings( isDisabled, results ); local sToolTip :string = ToolTipHelper.GetUnitToolTip( row.Hash ) .. sAllReasons; local nProductionCost :number = buildQueue:GetUnitCost( row.Index ); local nProductionProgress :number = buildQueue:GetUnitProgress( row.Index ); sToolTip = sToolTip .. ComposeProductionCostString( nProductionProgress, nProductionCost ); local kUnit :table = { Type = row.UnitType, Name = row.Name, ToolTip = sToolTip, Hash = row.Hash, Kind = row.Kind, TurnsLeft = buildQueue:GetTurnsLeft( row.Hash ), Disabled = isDisabled, Civilian = row.FormationClass == "FORMATION_CLASS_CIVILIAN", Cost = nProductionCost, Progress = nProductionProgress, Corps = false, CorpsCost = 0, CorpsTurnsLeft = 1, CorpsTooltip = "", CorpsName = "", Army = false, ArmyCost = 0, ArmyTurnsLeft = 1, ArmyTooltip = "", ArmyName = "", ReligiousStrength = row.ReligiousStrength }; -- Should we present options for building Corps or Army versions? if results ~= nil then if results[CityOperationResults.CAN_TRAIN_CORPS] then kUnit.Corps = true; kUnit.CorpsCost = buildQueue:GetUnitCorpsCost( row.Index ); kUnit.CorpsTurnsLeft = buildQueue:GetTurnsLeft( row.Hash, MilitaryFormationTypes.CORPS_MILITARY_FORMATION ); kUnit.CorpsTooltip, kUnit.CorpsName = ComposeUnitCorpsStrings( row.Name, row.Domain, nProductionProgress, kUnit.CorpsCost ); end if results[CityOperationResults.CAN_TRAIN_ARMY] then kUnit.Army = true; kUnit.ArmyCost = buildQueue:GetUnitArmyCost( row.Index ); kUnit.ArmyTurnsLeft = buildQueue:GetTurnsLeft( row.Hash, MilitaryFormationTypes.ARMY_MILITARY_FORMATION ); kUnit.ArmyTooltip, kUnit.ArmyName = ComposeUnitArmyStrings( row.Name, row.Domain, nProductionProgress, kUnit.ArmyCost ); end end table.insert(new_data.UnitItems, kUnit ); end -- Can it be purchased with gold? if row.PurchaseYield == "YIELD_GOLD" then local isAllowed, kUnit = ComposeUnitForPurchase( row, selectedCity, "YIELD_GOLD", playerTreasury, "LOC_BUILDING_INSUFFICIENT_FUNDS" ); if isAllowed then table.insert( new_data.UnitPurchases, kUnit ); end end -- Can it be purchased with faith? if row.PurchaseYield == "YIELD_FAITH" or cityGold:IsUnitFaithPurchaseEnabled( row.Hash ) then local isAllowed, kUnit = ComposeUnitForPurchase( row, selectedCity, "YIELD_FAITH", playerReligion, "LOC_BUILDING_INSUFFICIENT_FAITH" ); if isAllowed then table.insert( new_data.UnitPurchases, kUnit ); end end end for row in GameInfo.Projects() do if row.Hash == currentProductionHash then new_data.CurrentProduction = row.Name; end if buildQueue:CanProduce( row.Hash, true ) and not (row.MaxPlayerInstances and IsHashInAnyQueue(row.Hash)) then local isCanProduceExclusion, results = buildQueue:CanProduce( row.Hash, false, true ); local isDisabled :boolean = not isCanProduceExclusion; local allReasons :string = ComposeFailureReasonStrings( isDisabled, results ); local sToolTip :string = ToolTipHelper.GetProjectToolTip( row.Hash ) .. allReasons; local iProductionCost :number = buildQueue:GetProjectCost( row.Index ); local iProductionProgress :number = buildQueue:GetProjectProgress( row.Index ); sToolTip = sToolTip .. ComposeProductionCostString( iProductionProgress, iProductionCost ); table.insert(new_data.ProjectItems, { Type = row.ProjectType, Name = row.Name, ToolTip = sToolTip, Hash = row.Hash, Kind = row.Kind, TurnsLeft = buildQueue:GetTurnsLeft( row.ProjectType ), Disabled = isDisabled, Cost = iProductionCost, Progress = iProductionProgress }); end end View(new_data, persistCollapse); ResizeQueueWindow(); SaveQueues(); end end -- =========================================================================== function ShowHideDisabled() --Controls.HideDisabled:SetSelected(showDisabled); showDisabled = not showDisabled; Refresh(); end -- =========================================================================== -- LUA Event -- =========================================================================== function OnCityPanelChooseProduction() if (ContextPtr:IsHidden()) then Refresh(); else if (m_tabs.selectedControl ~= m_productionTab) then m_tabs.SelectTab(m_productionTab); end end end -- =========================================================================== -- LUA Event -- =========================================================================== function OnNotificationPanelChooseProduction() if ContextPtr:IsHidden() then Open(); --else --TESTING TO SEE IF THIS FIXES OUR TUTORIAL BUG. -- if Controls.PauseDismissWindow:IsStopped() then -- Close(); -- else -- Controls.PauseDismissWindow:Stop(); -- Open(); -- end end end -- =========================================================================== -- LUA Event -- =========================================================================== function OnCityPanelChoosePurchase() if (ContextPtr:IsHidden()) then Refresh(); OnTabChangePurchase(); m_tabs.SelectTab(m_purchaseTab); else if (m_tabs.selectedControl ~= m_purchaseTab) then OnTabChangePurchase(); m_tabs.SelectTab(m_purchaseTab); end end end -- =========================================================================== -- LUA Event -- =========================================================================== function OnCityPanelChoosePurchaseFaith() if (ContextPtr:IsHidden()) then Refresh(); OnTabChangePurchaseFaith(); m_tabs.SelectTab(m_faithTab); else if (m_tabs.selectedControl ~= m_faithTab) then OnTabChangePurchaseFaith(); m_tabs.SelectTab(m_faithTab); end end end -- =========================================================================== -- LUA Event -- Outside source is signaling production should be closed if open. -- =========================================================================== function OnProductionClose() if not ContextPtr:IsHidden() then Close(); end end -- =========================================================================== -- LUA Event -- Production opened from city banner (anchored to world view) -- =========================================================================== function OnCityBannerManagerProductionToggle() m_isQueueMode = false; if(ContextPtr:IsHidden()) then Open(); else end end -- =========================================================================== -- LUA Event -- Production opened from city information panel -- =========================================================================== function OnCityPanelProductionOpen() m_isQueueMode = false; Open(); end -- =========================================================================== -- LUA Event -- Production opened from city information panel - Purchase with faith check -- =========================================================================== function OnCityPanelPurchaseFaithOpen() m_isQueueMode = false; Open(); m_tabs.SelectTab(m_faithTab); end -- =========================================================================== -- LUA Event -- Production opened from city information panel - Purchase with gold check -- =========================================================================== function OnCityPanelPurchaseGoldOpen() m_isQueueMode = false; Open(); m_tabs.SelectTab(m_purchaseTab); end -- =========================================================================== -- LUA Event -- Production opened from a placement -- =========================================================================== function OnStrategicViewMapPlacementProductionOpen() m_isQueueMode = false; Open(); end -- =========================================================================== -- LUA Event -- =========================================================================== function OnTutorialProductionOpen() m_isQueueMode = false; Open(); end -- =========================================================================== -- LUA Event -- =========================================================================== function OnProductionOpenForQueue() m_isQueueMode = true; Open(); end -- =========================================================================== -- LUA Event -- =========================================================================== function OnCityPanelPurchasePlot() Close(); end -- =========================================================================== -- LUA Event -- Set cached values back after a hotload. -- =========================================================================== function OnGameDebugReturn( context:string, contextTable:table ) if context ~= RELOAD_CACHE_ID then return; end m_isQueueMode = contextTable["m_isQueueMode"]; local isHidden:boolean = contextTable["isHidden"]; if not isHidden then Refresh(); end end -- =========================================================================== -- Keyboard INPUT Up Handler -- =========================================================================== function KeyUpHandler( key:number ) if (key == Keys.VK_ESCAPE) then Close(); return true; end if (key == Keys.VK_CONTROL) then m_isCONTROLpressed = false; return true; end return false; end -- =========================================================================== -- Keyboard INPUT Down Handler -- =========================================================================== function KeyDownHandler( key:number ) if (key == Keys.VK_CONTROL) then m_isCONTROLpressed = true; return true; end return false; end -- =========================================================================== -- UI Event -- =========================================================================== function OnInputHandler( pInputStruct:table ) local uiMsg = pInputStruct:GetMessageType(); if uiMsg == KeyEvents.KeyUp then return KeyUpHandler( pInputStruct:GetKey() ); end; if uiMsg == KeyEvents.KeyDown then return KeyDownHandler( pInputStruct:GetKey() ); end; return false; end -- =========================================================================== -- UI Event -- =========================================================================== function OnInit( isReload:boolean ) if isReload then LuaEvents.GameDebug_GetValues( RELOAD_CACHE_ID ); end end -- =========================================================================== -- UI Event -- =========================================================================== function OnShutdown() LuaEvents.GameDebug_AddValue(RELOAD_CACHE_ID, "m_isQueueMode", m_isQueueMode ); LuaEvents.GameDebug_AddValue(RELOAD_CACHE_ID, "prodQueue", prodQueue ); LuaEvents.GameDebug_AddValue(RELOAD_CACHE_ID, "isHidden", ContextPtr:IsHidden() ); end -- =========================================================================== -- =========================================================================== function Resize() --local contentSize = (m_maxProductionSize > m_maxPurchaseSize) and m_maxProductionSize or m_maxPurchaseSize; --contentSize = contentSize + WINDOW_HEADER_Y; --local w,h = UIManager:GetScreenSizeVal(); --local maxAllowable = h - Controls.Window:GetOffsetY() - TOPBAR_Y; --local panelSizeY = (contentSize < maxAllowable) and contentSize or maxAllowable; --Controls.Window:SetSizeY(panelSizeY); --Controls.ProductionListScroll:SetSizeY(panelSizeY-Controls.WindowContent:GetOffsetY()); --Controls.PurchaseListScroll:SetSizeY(panelSizeY-Controls.WindowContent:GetOffsetY()); --Controls.DropShadow:SetSizeY(panelSizeY+100); end -- =========================================================================== -- =========================================================================== function CreateCorrectTabs() local MAX_TAB_LABEL_WIDTH = 273; local productionLabelX = Controls.ProductionTab:GetTextControl():GetSizeX(); local purchaseLabelX = Controls.PurchaseTab:GetTextControl():GetSizeX(); local purchaseFaithLabelX = Controls.PurchaseFaithTab:GetTextControl():GetSizeX(); local tabAnimControl; local tabArrowControl; local tabSizeX; local tabSizeY; Controls.ProductionTab:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.PurchaseTab:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.PurchaseFaithTab:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.MiniProductionTab:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.MiniPurchaseTab:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.MiniPurchaseFaithTab:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.MiniProductionTab:SetHide(true); Controls.MiniPurchaseTab:SetHide(true); Controls.MiniPurchaseFaithTab:SetHide(true); Controls.ProductionTab:SetHide(true); Controls.PurchaseTab:SetHide(true); Controls.PurchaseFaithTab:SetHide(true); Controls.MiniTabAnim:SetHide(true); Controls.MiniTabArrow:SetHide(true); Controls.TabAnim:SetHide(true); Controls.TabArrow:SetHide(true); local labelWidth = productionLabelX + purchaseLabelX; if GameCapabilities.HasCapability("CAPABILITY_FAITH") then labelWidth = labelWidth + purchaseFaithLabelX; end if(labelWidth > MAX_TAB_LABEL_WIDTH) then tabSizeX = 44; tabSizeY = 44; Controls.MiniProductionTab:SetHide(false); Controls.MiniPurchaseTab:SetHide(false); Controls.MiniPurchaseFaithTab:SetHide(false); Controls.MiniTabAnim:SetHide(false); Controls.MiniTabArrow:SetHide(false); m_productionTab = Controls.MiniProductionTab; m_purchaseTab = Controls.MiniPurchaseTab; m_faithTab = Controls.MiniPurchaseFaithTab; tabAnimControl = Controls.MiniTabAnim; tabArrowControl = Controls.MiniTabArrow; else tabSizeX = 42; tabSizeY = 34; Controls.ProductionTab:SetHide(false); Controls.PurchaseTab:SetHide(false); Controls.PurchaseFaithTab:SetHide(false); Controls.TabAnim:SetHide(false); Controls.TabArrow:SetHide(false); m_productionTab = Controls.ProductionTab; m_purchaseTab = Controls.PurchaseTab; m_faithTab = Controls.PurchaseFaithTab; tabAnimControl = Controls.TabAnim; tabArrowControl = Controls.TabArrow; end m_tabs = CreateTabs( Controls.TabRow, tabSizeX, tabSizeY, 0xFF331D05 ); m_tabs.AddTab( m_productionTab, OnTabChangeProduction ); if GameCapabilities.HasCapability("CAPABILITY_GOLD") then m_tabs.AddTab( m_purchaseTab, OnTabChangePurchase ); else Controls.PurchaseTab:SetHide(true); Controls.MiniPurchaseTab:SetHide(true); end if GameCapabilities.HasCapability("CAPABILITY_FAITH") then m_tabs.AddTab( m_faithTab, OnTabChangePurchaseFaith ); else Controls.MiniPurchaseFaithTab:SetHide(true); Controls.PurchaseFaithTab:SetHide(true); end m_tabs.CenterAlignTabs(0); m_tabs.SelectTab( m_productionTab ); m_tabs.AddAnimDeco(tabAnimControl, tabArrowControl); end --- ========================================================================================================= -- ====================================== PRODUCTION QUEUE MOD FUNCTIONS =================================== --- ========================================================================================================= --- ======================================================================================================= -- === Production event handlers --- ======================================================================================================= --- =========================================================================== -- Fires when a city's current production changes --- =========================================================================== function OnCityProductionChanged(playerID:number, cityID:number) Refresh(); end function OnCityProductionUpdated( ownerPlayerID:number, cityID:number, eProductionType, eProductionObject) if(ownerPlayerID ~= Game.GetLocalPlayer()) then return end lastProductionCompletePerCity[cityID] = nil; end --- =========================================================================== -- Fires when a city's production is completed -- Note: This seems to sometimes fire more than once for a turn --- =========================================================================== function OnCityProductionCompleted(playerID, cityID, orderType, unitType, canceled, typeModifier) if (playerID ~= Game.GetLocalPlayer()) then return end; local pPlayer = Players[ playerID ]; if (pPlayer == nil) then return end; local pCity = pPlayer:GetCities():FindID(cityID); if (pCity == nil) then return end; local currentTurn = Game.GetCurrentGameTurn(); -- Only one item can be produced per turn per city if(lastProductionCompletePerCity[cityID] and lastProductionCompletePerCity[cityID] == currentTurn) then return; end if(prodQueue[cityID] and prodQueue[cityID][1]) then -- Check that the production is actually completed local productionInfo = GetProductionInfoOfCity(pCity, prodQueue[cityID][1].entry.Hash); local pDistricts = pCity:GetDistricts(); local pBuildings = pCity:GetBuildings(); local isComplete = false; if(prodQueue[cityID][1].type == PRODUCTION_TYPE.BUILDING or prodQueue[cityID][1].type == PRODUCTION_TYPE.PLACED) then if(GameInfo.Districts[prodQueue[cityID][1].entry.Hash] and pDistricts:HasDistrict(GameInfo.Districts[prodQueue[cityID][1].entry.Hash].Index, true)) then isComplete = true; elseif(GameInfo.Buildings[prodQueue[cityID][1].entry.Hash] and pBuildings:HasBuilding(GameInfo.Buildings[prodQueue[cityID][1].entry.Hash].Index)) then isComplete = true; elseif(productionInfo.PercentComplete >= 1) then isComplete = true; end if(not isComplete) then return; end end -- PQ: Experimental local productionType = prodQueue[cityID][1].type; if(orderType == 0) then if(productionType == PRODUCTION_TYPE.UNIT or productionType == PRODUCTION_TYPE.CORPS or productionType == PRODUCTION_TYPE.ARMY) then if(GameInfo.Units[prodQueue[cityID][1].entry.Hash].Index == unitType) then isComplete = true; end end elseif(orderType == 1) then -- Building/wonder if(productionType == PRODUCTION_TYPE.BUILDING or productionType == PRODUCTION_TYPE.PLACED) then local buildingInfo = GameInfo.Buildings[prodQueue[cityID][1].entry.Hash]; if(buildingInfo and buildingInfo.Index == unitType) then isComplete = true; end end -- Check if this building is in our queue at all if(not isComplete and IsHashInQueue(pCity, GameInfo.Buildings[unitType].Hash)) then local removeIndex = GetIndexOfHashInQueue(pCity, GameInfo.Buildings[unitType].Hash); RemoveFromQueue(cityID, removeIndex, true); if(removeIndex == 1) then BuildFirstQueued(pCity); else Refresh(true); end SaveQueues(); return; end elseif(orderType == 2) then -- District if(productionType == PRODUCTION_TYPE.PLACED) then local districtInfo = GameInfo.Districts[prodQueue[cityID][1].entry.Hash]; if(districtInfo and districtInfo.Index == unitType) then isComplete = true; end end elseif(orderType == 3) then -- Project if(productionType == PRODUCTION_TYPE.PROJECT) then local projectInfo = GameInfo.Projects[prodQueue[cityID][1].entry.Hash]; if(projectInfo and projectInfo.Index == unitType) then isComplete = true; end end end if(not isComplete) then Refresh(true); return; end table.remove(prodQueue[cityID], 1); if(#prodQueue[cityID] > 0) then BuildFirstQueued(pCity); end lastProductionCompletePerCity[cityID] = currentTurn; SaveQueues(); end end --- ======================================================================================================= -- === Load/Save --- ======================================================================================================= --- ========================================================================== -- Updates the PlayerConfiguration with all ProductionQueue data --- ========================================================================== function SaveQueues() PlayerConfigurations[Game.GetLocalPlayer()]:SetValue("ZenProductionQueue", DataDumper(prodQueue, "prodQueue")); end --- ========================================================================== -- Loads ProductionQueue data from PlayerConfiguration, and populates the -- queue with current production information if saved info not present --- ========================================================================== function LoadQueues() local localPlayerID = Game.GetLocalPlayer(); if(PlayerConfigurations[localPlayerID]:GetValue("ZenProductionQueue") ~= nil) then loadstring(PlayerConfigurations[localPlayerID]:GetValue("ZenProductionQueue"))(); end if(not prodQueue) then prodQueue = {}; end local player = Players[localPlayerID]; local cities = player:GetCities(); for j, city in cities:Members() do local cityID = city:GetID(); local buildQueue = city:GetBuildQueue(); local currentProductionHash = buildQueue:GetCurrentProductionTypeHash(); local plotID = -1; if(not prodQueue[cityID]) then prodQueue[cityID] = {}; end if(not prodQueue[cityID][1] and currentProductionHash ~= 0) then -- Determine the type of the item local currentType = 0; local productionInfo = GetProductionInfoOfCity(city, currentProductionHash); productionInfo.Hash = currentProductionHash; if(productionInfo.Type == "UNIT") then currentType = buildQueue:GetCurrentProductionTypeModifier() + 2; elseif(productionInfo.Type == "BUILDING") then if(GameInfo.Buildings[currentProductionHash].MaxWorldInstances == 1) then currentType = PRODUCTION_TYPE.PLACED; local pCityBuildings :table = city:GetBuildings(); local kCityPlots :table = Map.GetCityPlots():GetPurchasedPlots( city ); if (kCityPlots ~= nil) then for _,plot in pairs(kCityPlots) do local kPlot:table = Map.GetPlotByIndex(plot); local wonderType = kPlot:GetWonderType(); if(wonderType ~= -1 and GameInfo.Buildings[wonderType].BuildingType == GameInfo.Buildings[currentProductionHash].BuildingType) then plotID = plot; end end end else currentType = PRODUCTION_TYPE.BUILDING; end elseif(productionInfo.Type == "DISTRICT") then currentType = PRODUCTION_TYPE.PLACED; elseif(productionInfo.Type == "PROJECT") then currentType = PRODUCTION_TYPE.PROJECT; end if(currentType == 0) then print("Could not find production type for hash: " .. currentProductionHash); end prodQueue[cityID][1] = { entry=productionInfo, type=currentType, plotID=plotID } elseif(currentProductionHash == 0) then end end -- Populate our table for building prerequisites for prereqRow in GameInfo.BuildingPrereqs() do buildingPrereqs[prereqRow.Building] = 1; end for building in GameInfo.MutuallyExclusiveBuildings() do mutuallyExclusiveBuildings[building.Building] = 1; end end --- ======================================================================================================= -- === Queue information --- ======================================================================================================= --- =========================================================================== -- Checks if there is a specific building hash in a city's Production Queue --- =========================================================================== function IsBuildingInQueue(city, buildingHash) local cityID = city:GetID(); if(prodQueue and #prodQueue[cityID] > 0) then for _, qi in pairs(prodQueue[cityID]) do if(qi.entry and qi.entry.Hash == buildingHash) then if(qi.type == PRODUCTION_TYPE.BUILDING or qi.type == PRODUCTION_TYPE.PLACED) then return true; end end end end return false; end --- =========================================================================== -- Checks if there is a specific wonder hash in all Production Queues --- =========================================================================== function IsWonderInQueue(wonderHash) for _,city in pairs(prodQueue) do for _, qi in pairs(city) do if(qi.entry and qi.entry.Hash == wonderHash) then if(qi.type == PRODUCTION_TYPE.PLACED) then return true; end end end end return false; end --- =========================================================================== -- Checks if there is a specific hash in all Production Queues --- =========================================================================== function IsHashInAnyQueue(hash) for _,city in pairs(prodQueue) do for _, qi in pairs(city) do if(qi.entry and qi.entry.Hash == hash) then return true; end end end return false; end --- =========================================================================== -- Checks if there is a specific item hash in a city's Production Queue --- =========================================================================== function IsHashInQueue(city, hash) local cityID = city:GetID(); if(prodQueue and #prodQueue[cityID] > 0) then for i, qi in pairs(prodQueue[cityID]) do if(qi.entry and qi.entry.Hash == hash) then return true; end end end return false; end --- =========================================================================== -- Returns the first instance of a hash in a city's Production Queue --- =========================================================================== function GetIndexOfHashInQueue(city, hash) local cityID = city:GetID(); if(prodQueue and #prodQueue[cityID] > 0) then for i, qi in pairs(prodQueue[cityID]) do if(qi.entry and qi.entry.Hash == hash) then return i; end end end return nil; end --- =========================================================================== -- Get the total number of districts (requiring population) -- in a city's Production Queue still requiring placement --- =========================================================================== function GetNumDistrictsInCityQueue(city) local numDistricts = 0; local cityID = city:GetID(); local pBuildQueue = city:GetBuildQueue(); if(#prodQueue[cityID] > 0) then for _,qi in pairs(prodQueue[cityID]) do if(GameInfo.Districts[qi.entry.Hash] and GameInfo.Districts[qi.entry.Hash].RequiresPopulation) then if (not pBuildQueue:HasBeenPlaced(qi.entry.Hash)) then numDistricts = numDistricts + 1; end end end end return numDistricts; end --- ============================================================================= -- [Doing it this way is ridiculous and hacky but I am tired; Please forgive me] -- Checks the Production Queue for matching reserved plots --- ============================================================================= GameInfo.Districts['DISTRICT_CITY_CENTER'].IsPlotValid = function(pCity, plotID) local cityID = pCity:GetID(); if(#prodQueue[cityID] > 0) then for j,item in ipairs(prodQueue[cityID]) do if(item.plotID == plotID) then return false; end end end return true; end --- ======================================================================================================= -- === Drag and Drop - Highlighting --- ======================================================================================================= function HighlightActiveQueueItem_DropTarget( tTargetInstance:table ) local nTargetSlot :number = tTargetInstance and tTargetInstance.ButtonContainer.id or -1; if( nTargetSlot ~= m_PrevDropTargetSlot) then if ( m_PrevDropTargetSlot ~= -1 ) then -- m_PrevDropTargetInstance.HoverArrow:SetShow( false ); m_PrevDropTargetInstance.Draggable:SetOffsetX(0); end if ( tTargetInstance ) then -- tTargetInstance.HoverArrow:SetShow( true ); tTargetInstance.Draggable:SetOffsetX(-10); end m_PrevDropTargetSlot = nTargetSlot; m_PrevDropTargetInstance = tTargetInstance; end end --- ======================================================================================================= -- === Drag and Drop --- ======================================================================================================= function GetCurrentDragTarget( tDraggedControl:table, index:number ) local tViableDragTargets :table = {}; -- also is its own map to get parent table from specific control. local cityID = UI.GetHeadSelectedCity():GetID(); -- We now need to loop through the controls for each queue item to pass to the new Drag'n'Drop system if(#m_queueIM.m_AllocatedInstances < 1) then -- There are no queue instances... bail else for i,tQueueControl in ipairs(m_queueIM.m_AllocatedInstances[1].queueListIM.m_AllocatedInstances) do if(i ~= index) then tQueueControl.ButtonContainer.id = i; tQueueControl.ButtonContainer.Instance = tQueueControl; table.insert( tViableDragTargets, tQueueControl.ButtonContainer ); end end end local tBestTarget :table = DragSupport_GetBestOverlappingControl( tDraggedControl, tViableDragTargets ); return tBestTarget; end --- =========================================================================== -- Fires when picking up an item in the Production Queue --- =========================================================================== function OnDownInQueue( dragStruct:table, queueListing:table, index:number ) UI.PlaySound("Play_UI_Click"); HighlightActiveQueueItem_DropTarget(nil); end --- =========================================================================== -- Fires when dragging an item in the Production Queue --- =========================================================================== function OnDragInQueue( dragStruct:table, queueListing:table, index:number ) local dragControl:table = dragStruct:GetControl(); local tAcceptableTarget :table = nil; if dragControl then tAcceptableTarget = GetCurrentDragTarget( dragControl, index ); tAcceptableTarget = tAcceptableTarget and tAcceptableTarget.Instance or nil; end HighlightActiveQueueItem_DropTarget( tAcceptableTarget ); end --- =========================================================================== -- Fires when dropping an item in the Production Queue --- =========================================================================== function OnDropInQueue( dragStruct:table, queueListing:table, index:number ) local dragControl:table = dragStruct:GetControl(); local tViableDragTargets :table = {}; local city = UI.GetHeadSelectedCity(); local cityID = city:GetID(); table.insert( tViableDragTargets, Controls.ProductionQueuePanel ); local tBest :table = DragSupport_GetBestOverlappingControl( dragControl, tViableDragTargets ); if(tBest ~= nil) then local tTargetQueueItem :table = GetCurrentDragTarget(dragControl, index); if(tTargetQueueItem ~= nil and index ~= tTargetQueueItem.id) then -- If the target is valid, swap them MoveQueueIndex(cityID, index, tTargetQueueItem.id); dragControl:StopSnapBack(); if(index == 1 or tTargetQueueItem.id == 1) then BuildFirstQueued(city); else Refresh(true); end elseif(not tTargetQueueItem or index == tTargetQueueItem.id) then -- Dropped on itself, just abort end else -- Dropped off the panel entirely; remove from queue dragControl:StopSnapBack(); RemoveFromQueue(cityID, index); BuildFirstQueued(city); Refresh(); end HighlightActiveQueueItem_DropTarget(nil); UI.PlaySound("Main_Menu_Mouse_Over"); end --- ======================================================================================================= -- === Queueing/Building --- ======================================================================================================= --- ========================================================================== -- Adds unit of given type to the Production Queue and builds it if requested --- ========================================================================== function QueueUnitOfType(city, unitEntry, unitType, skipToFront) local cityID = city:GetID(); local index = 1; if(not prodQueue[cityID]) then prodQueue[cityID] = {}; end if(not skipToFront) then index = #prodQueue[cityID] + 1; end table.insert(prodQueue[cityID], index, { entry=unitEntry, type=unitType, plotID=-1 }); if(#prodQueue[cityID] == 1 or skipToFront) then BuildFirstQueued(city); else Refresh(true); end UI.PlaySound("Confirm_Production"); end --- ========================================================================== -- Adds unit to the Production Queue and builds if requested --- ========================================================================== function QueueUnit(city, unitEntry, skipToFront) QueueUnitOfType(city, unitEntry, PRODUCTION_TYPE.UNIT, skipToFront); end --- ========================================================================== -- Adds corps to the Production Queue and builds if requested --- ========================================================================== function QueueUnitCorps(city, unitEntry, skipToFront) QueueUnitOfType(city, unitEntry, PRODUCTION_TYPE.CORPS, skipToFront); end --- ========================================================================== -- Adds army to the Production Queue and builds if requested --- ========================================================================== function QueueUnitArmy(city, unitEntry, skipToFront) QueueUnitOfType(city, unitEntry, PRODUCTION_TYPE.ARMY, skipToFront); end --- ========================================================================== -- Adds building to the Production Queue and builds if requested --- ========================================================================== function QueueBuilding(city, buildingEntry, skipToFront) local building :table = GameInfo.Buildings[buildingEntry.Type]; local bNeedsPlacement :boolean = building.RequiresPlacement; local pBuildQueue = city:GetBuildQueue(); if (pBuildQueue:HasBeenPlaced(buildingEntry.Hash)) then bNeedsPlacement = false; end UI.SetInterfaceMode(InterfaceModeTypes.SELECTION); if (bNeedsPlacement) then local tParameters = {}; tParameters[CityOperationTypes.PARAM_BUILDING_TYPE] = buildingEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; UI.SetInterfaceMode(InterfaceModeTypes.BUILDING_PLACEMENT, tParameters); else local cityID = city:GetID(); local plotID = -1; local buildingType = PRODUCTION_TYPE.BUILDING; if(not prodQueue[cityID]) then prodQueue[cityID] = {}; end if(building.RequiresPlacement) then local pCityBuildings :table = city:GetBuildings(); local kCityPlots :table = Map.GetCityPlots():GetPurchasedPlots( city ); if (kCityPlots ~= nil) then for _,plot in pairs(kCityPlots) do local kPlot:table = Map.GetPlotByIndex(plot); local wonderType = kPlot:GetWonderType(); if(wonderType ~= -1 and GameInfo.Buildings[wonderType].BuildingType == building.BuildingType) then plotID = plot; buildingType = PRODUCTION_TYPE.PLACED; end end end end table.insert(prodQueue[cityID], { entry=buildingEntry, type=buildingType, plotID=plotID }); if(skipToFront) then if(MoveQueueIndex(cityID, #prodQueue[cityID], 1) ~= 0) then Refresh(true); else BuildFirstQueued(city); end elseif(#prodQueue[cityID] == 1) then BuildFirstQueued(city); else Refresh(true); end UI.PlaySound("Confirm_Production"); end end --- ========================================================================== -- Adds district to the Production Queue and builds if requested --- ========================================================================== function QueueDistrict(city, districtEntry, skipToFront) UI.SetInterfaceMode(InterfaceModeTypes.SELECTION); local district :table = GameInfo.Districts[districtEntry.Type]; local bNeedsPlacement :boolean = district.RequiresPlacement; local pBuildQueue :table = city:GetBuildQueue(); if (pBuildQueue:HasBeenPlaced(districtEntry.Hash)) then bNeedsPlacement = false; end if (bNeedsPlacement) then local tParameters = {}; tParameters[CityOperationTypes.PARAM_DISTRICT_TYPE] = districtEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; UI.SetInterfaceMode(InterfaceModeTypes.DISTRICT_PLACEMENT, tParameters); else local tParameters = {}; tParameters[CityOperationTypes.PARAM_DISTRICT_TYPE] = districtEntry.Hash; tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE; local cityID = city:GetID(); if(not prodQueue[cityID]) then prodQueue[cityID] = {}; end local index = 1; if(not skipToFront) then index = #prodQueue[cityID] + 1; end table.insert(prodQueue[cityID], index, { entry=districtEntry, type=PRODUCTION_TYPE.PLACED, plotID=-1, tParameters=tParameters }); if(#prodQueue[cityID] == 1 or skipToFront) then BuildFirstQueued(city); else Refresh(true); end UI.PlaySound("Confirm_Production"); end end --- ========================================================================== -- Adds project to the Production Queue and builds if requested --- ========================================================================== function QueueProject(city, projectEntry, skipToFront) local cityID = city:GetID(); if(not prodQueue[cityID]) then prodQueue[cityID] = {}; end local index = 1; if(not skipToFront) then index = #prodQueue[cityID] + 1; end table.insert(prodQueue[cityID], index, { entry=projectEntry, type=PRODUCTION_TYPE.PROJECT, plotID=-1 }); if(#prodQueue[cityID] == 1 or skipToFront) then BuildFirstQueued(city); else Refresh(true); end UI.PlaySound("Confirm_Production"); end --- =========================================================================== -- Check if removing an index would result in an empty queue --- =========================================================================== function CanRemoveFromQueue(cityID, index) local totalItemsToRemove = 1; if(prodQueue[cityID] and #prodQueue[cityID] > 1 and prodQueue[cityID][index]) then local destIndex = MoveQueueIndex(cityID, index, #prodQueue[cityID], true); if(destIndex > 0) then totalItemsToRemove = totalItemsToRemove + 1; CanRemoveFromQueue(cityID, destIndex + 1); end end if(totalItemsToRemove == #prodQueue[cityID]) then return false; else return true; end end --- =========================================================================== -- Remove a specific index from a city's Production Queue --- =========================================================================== function RemoveFromQueue(cityID, index, force) if(prodQueue[cityID] and (#prodQueue[cityID] > 1 or force) and prodQueue[cityID][index]) then local destIndex = MoveQueueIndex(cityID, index, #prodQueue[cityID]); if(destIndex > 0) then -- There was a conflict RemoveFromQueue(cityID, destIndex + 1); table.remove(prodQueue[cityID], destIndex); else table.remove(prodQueue[cityID], #prodQueue[cityID]); end return true; end return false; end --- ========================================================================== -- Directly requests the city to build a placed district/wonder using -- tParameters provided from the StrategicView callback event --- ========================================================================== function BuildPlaced(city, tParameters) -- Check if we still have enough population for a district we're about to place local districtHash = tParameters[CityOperationTypes.PARAM_DISTRICT_TYPE]; if(districtHash) then local pCityDistricts = city:GetDistricts(); local numDistricts = pCityDistricts:GetNumZonedDistrictsRequiringPopulation(); local numPossibleDistricts = pCityDistricts:GetNumAllowedDistrictsRequiringPopulation(); if(GameInfo.Districts[districtHash] and GameInfo.Districts[districtHash].RequiresPopulation and numDistricts <= numPossibleDistricts) then if(GetNumDistrictsInCityQueue(city) + numDistricts > numPossibleDistricts) then RemoveFromQueue(city:GetID(), 1); BuildFirstQueued(city); return; end end end CityManager.RequestOperation(city, CityOperationTypes.BUILD, tParameters); end --- ========================================================================== -- Builds the first item in the Production Queue --- ========================================================================== function BuildFirstQueued(pCity) local cityID = pCity:GetID(); if(prodQueue[cityID][1]) then if(prodQueue[cityID][1].type == PRODUCTION_TYPE.BUILDING) then BuildBuilding(pCity, prodQueue[cityID][1].entry); elseif(prodQueue[cityID][1].type == PRODUCTION_TYPE.UNIT) then BuildUnit(pCity, prodQueue[cityID][1].entry); elseif(prodQueue[cityID][1].type == PRODUCTION_TYPE.ARMY) then BuildUnitArmy(pCity, prodQueue[cityID][1].entry); elseif(prodQueue[cityID][1].type == PRODUCTION_TYPE.CORPS) then BuildUnitCorps(pCity, prodQueue[cityID][1].entry); elseif(prodQueue[cityID][1].type == PRODUCTION_TYPE.PLACED) then if(not prodQueue[cityID][1].tParameters) then if(GameInfo.Buildings[prodQueue[cityID][1].entry.Hash]) then BuildBuilding(pCity, prodQueue[cityID][1].entry); else ZoneDistrict(pCity, prodQueue[cityID][1].entry); end else BuildPlaced(pCity, prodQueue[cityID][1].tParameters); end elseif(prodQueue[cityID][1].type == PRODUCTION_TYPE.PROJECT) then AdvanceProject(pCity, prodQueue[cityID][1].entry); end else Refresh(true); end end --- ============================================================================ -- Lua Event -- This is fired when a district or wonder plot has been selected and confirmed --- ============================================================================ function OnStrategicViewMapPlacementProductionClose(tProductionQueueParameters) local cityID = tProductionQueueParameters.pSelectedCity:GetID(); local entry = GetProductionInfoOfCity(tProductionQueueParameters.pSelectedCity, tProductionQueueParameters.buildingHash); entry.Hash = tProductionQueueParameters.buildingHash; if(not prodQueue[cityID]) then prodQueue[cityID] = {}; end local index = 1; if(not nextDistrictSkipToFront) then index = #prodQueue[cityID] + 1; end table.insert(prodQueue[cityID], index, { entry=entry, type=PRODUCTION_TYPE.PLACED, plotID=tProductionQueueParameters.plotId, tParameters=tProductionQueueParameters.tParameters }); if(nextDistrictSkipToFront or #prodQueue[cityID] == 1) then BuildFirstQueued(tProductionQueueParameters.pSelectedCity); end Refresh(true); UI.PlaySound("Confirm_Production"); end --- =========================================================================== -- Move a city's queue item from one index to another --- =========================================================================== function MoveQueueIndex(cityID, sourceIndex, destIndex, noMove) local direction = -1; local actualDest = 0; local sourceInfo = prodQueue[cityID][sourceIndex]; if(sourceIndex < destIndex) then direction = 1; end for i=sourceIndex, math.max(destIndex-direction, 1), direction do -- Each time we swap, we need to check that there isn't a prereq that would break if(sourceInfo.type == PRODUCTION_TYPE.BUILDING and prodQueue[cityID][i+direction].type == PRODUCTION_TYPE.PLACED) then local buildingInfo = GameInfo.Buildings[sourceInfo.entry.Hash]; if(buildingInfo and buildingInfo.PrereqDistrict) then local districtInfo = GameInfo.Districts[prodQueue[cityID][i+direction].entry.Hash]; if(districtInfo and (districtInfo.DistrictType == buildingInfo.PrereqDistrict or (GameInfo.DistrictReplaces[prodQueue[cityID][i+direction].entry.Hash] and GameInfo.DistrictReplaces[prodQueue[cityID][i+direction].entry.Hash].ReplacesDistrictType == buildingInfo.PrereqDistrict))) then actualDest = i; break; end end elseif(sourceInfo.type == PRODUCTION_TYPE.PLACED and prodQueue[cityID][i+direction].type == PRODUCTION_TYPE.BUILDING) then local buildingInfo = GameInfo.Buildings[prodQueue[cityID][i+direction].entry.Hash]; local districtInfo = GameInfo.Districts[sourceInfo.entry.Hash]; if(buildingInfo and buildingInfo.PrereqDistrict) then if(districtInfo and (districtInfo.DistrictType == buildingInfo.PrereqDistrict or (GameInfo.DistrictReplaces[sourceInfo.entry.Hash] and GameInfo.DistrictReplaces[sourceInfo.entry.Hash].ReplacesDistrictType == buildingInfo.PrereqDistrict))) then actualDest = i; break; end end elseif(sourceInfo.type == PRODUCTION_TYPE.BUILDING and prodQueue[cityID][i+direction].type == PRODUCTION_TYPE.BUILDING) then local destInfo = GameInfo.Buildings[prodQueue[cityID][i+direction].entry.Hash]; local sourceBuildingInfo = GameInfo.Buildings[sourceInfo.entry.Hash]; if(GameInfo.BuildingReplaces[destInfo.BuildingType]) then destInfo = GameInfo.Buildings[GameInfo.BuildingReplaces[destInfo.BuildingType].ReplacesBuildingType]; end if(GameInfo.BuildingReplaces[sourceBuildingInfo.BuildingType]) then sourceBuildingInfo = GameInfo.Buildings[GameInfo.BuildingReplaces[sourceBuildingInfo.BuildingType].ReplacesBuildingType]; end local halt = false; for prereqRow in GameInfo.BuildingPrereqs() do if(prereqRow.Building == sourceBuildingInfo.BuildingType) then if(destInfo.BuildingType == prereqRow.PrereqBuilding) then halt = true; actualDest = i; break; end end if(prereqRow.PrereqBuilding == sourceBuildingInfo.BuildingType) then if(destInfo.BuildingType == prereqRow.Building) then halt = true; actualDest = i; break; end end end if(halt == true) then break; end end if(not noMove) then prodQueue[cityID][i], prodQueue[cityID][i+direction] = prodQueue[cityID][i+direction], prodQueue[cityID][i]; end end return actualDest; end --- =========================================================================== -- Check the entire queue for mandatory item upgrades --- =========================================================================== function CheckAndReplaceAllQueuesForUpgrades() local localPlayerId:number = Game.GetLocalPlayer(); local player = Players[localPlayerId]; if(player == nil) then return; end local cities = player:GetCities(); for j, city in cities:Members() do CheckAndReplaceQueueForUpgrades(city); end end --- =========================================================================== -- Check a city's queue for items that must be upgraded or removed -- as per tech/civic knowledge --- =========================================================================== function CheckAndReplaceQueueForUpgrades(city) local playerID = Game.GetLocalPlayer(); local pPlayer = Players[playerID]; local pTech = pPlayer:GetTechs(); local pCulture = pPlayer:GetCulture(); local buildQueue = city:GetBuildQueue(); local cityID = city:GetID(); local pBuildings = city:GetBuildings(); local civTypeName = PlayerConfigurations[playerID]:GetCivilizationTypeName(); local removeUnits = {}; if(not prodQueue[cityID]) then prodQueue[cityID] = {} end for i, qi in pairs(prodQueue[cityID]) do if(qi.type == PRODUCTION_TYPE.UNIT or qi.type == PRODUCTION_TYPE.CORPS or qi.type == PRODUCTION_TYPE.ARMY) then local unitUpgrades = GameInfo.UnitUpgrades[qi.entry.Hash]; if(unitUpgrades) then local upgradeUnit = GameInfo.Units[unitUpgrades.UpgradeUnit]; -- Check for unique units for unitReplaces in GameInfo.UnitReplaces() do if(unitReplaces.ReplacesUnitType == unitUpgrades.UpgradeUnit) then local match = false; for civTraits in GameInfo.CivilizationTraits() do if(civTraits.TraitType == "TRAIT_CIVILIZATION_" .. unitReplaces.CivUniqueUnitType and civTraits.CivilizationType == civTypeName) then upgradeUnit = GameInfo.Units[unitReplaces.CivUniqueUnitType]; match = true; break; end end if(match) then break; end end end if(upgradeUnit) then local canUpgrade = true; if(upgradeUnit.PrereqTech and not pTech:HasTech(GameInfo.Technologies[upgradeUnit.PrereqTech].Index)) then canUpgrade = false; end if(upgradeUnit.PrereqCivic and not pCulture:HasCivic(GameInfo.Civics[upgradeUnit.PrereqCivic].Index)) then canUpgrade = false; end local canBuildNewUnit = buildQueue:CanProduce( upgradeUnit.Hash, false, true ); -- Only auto replace if we CAN'T queue the old unit if(not buildQueue:CanProduce( qi.entry.Hash, true ) and canUpgrade and canBuildNewUnit) then local isCanProduceExclusion, results = buildQueue:CanProduce( upgradeUnit.Hash, false, true ); local isDisabled :boolean = not isCanProduceExclusion; local sAllReasons :string = ComposeFailureReasonStrings( isDisabled, results ); local sToolTip :string = ToolTipHelper.GetUnitToolTip( upgradeUnit.Hash ) .. sAllReasons; local nProductionCost :number = buildQueue:GetUnitCost( upgradeUnit.Index ); local nProductionProgress :number = buildQueue:GetUnitProgress( upgradeUnit.Index ); sToolTip = sToolTip .. ComposeProductionCostString( nProductionProgress, nProductionCost ); prodQueue[cityID][i].entry = { Type = upgradeUnit.UnitType, Name = upgradeUnit.Name, ToolTip = sToolTip, Hash = upgradeUnit.Hash, Kind = upgradeUnit.Kind, TurnsLeft = buildQueue:GetTurnsLeft( upgradeUnit.Hash ), Disabled = isDisabled, Civilian = upgradeUnit.FormationClass == "FORMATION_CLASS_CIVILIAN", Cost = nProductionCost, Progress = nProductionProgress, Corps = false, CorpsCost = 0, CorpsTurnsLeft = 1, CorpsTooltip = "", CorpsName = "", Army = false, ArmyCost = 0, ArmyTurnsLeft = 1, ArmyTooltip = "", ArmyName = "" }; if results ~= nil then if results[CityOperationResults.CAN_TRAIN_CORPS] then kUnit.Corps = true; kUnit.CorpsCost = buildQueue:GetUnitCorpsCost( upgradeUnit.Index ); kUnit.CorpsTurnsLeft = buildQueue:GetTurnsLeft( upgradeUnit.Hash, MilitaryFormationTypes.CORPS_MILITARY_FORMATION ); kUnit.CorpsTooltip, kUnit.CorpsName = ComposeUnitCorpsStrings( upgradeUnit.Name, upgradeUnit.Domain, nProductionProgress, kUnit.CorpsCost ); end if results[CityOperationResults.CAN_TRAIN_ARMY] then kUnit.Army = true; kUnit.ArmyCost = buildQueue:GetUnitArmyCost( upgradeUnit.Index ); kUnit.ArmyTurnsLeft = buildQueue:GetTurnsLeft( upgradeUnit.Hash, MilitaryFormationTypes.ARMY_MILITARY_FORMATION ); kUnit.ArmyTooltip, kUnit.ArmyName = ComposeUnitArmyStrings( upgradeUnit.Name, upgradeUnit.Domain, nProductionProgress, kUnit.ArmyCost ); end end elseif(canUpgrade and not canBuildNewUnit) then -- Can't build the old or new unit. Probably missing a resource. Remove from queue. table.insert(removeUnits, i); end end else local canBuildUnit = buildQueue:CanProduce( qi.entry.Hash, false, true ); if(not canBuildUnit) then table.insert(removeUnits, i); end end elseif(qi.type == PRODUCTION_TYPE.BUILDING or qi.type == PRODUCTION_TYPE.PLACED) then if(qi.entry.Repair == true and GameInfo.Buildings[qi.entry.Hash]) then local isPillaged = pBuildings:IsPillaged(GameInfo.Buildings[qi.entry.Hash].Index); if(not isPillaged) then -- Repair complete, remove from queue table.insert(removeUnits, i); end end -- Check if a queued wonder is still available if(GameInfo.Buildings[qi.entry.Hash] and GameInfo.Buildings[qi.entry.Hash].MaxWorldInstances == 1) then if(not buildQueue:CanProduce(qi.entry.Hash, true)) then table.insert(removeUnits, i); elseif(not IsCityPlotValidForWonderPlacement(city, qi.plotID, GameInfo.Buildings[qi.entry.Hash]) and not buildQueue:HasBeenPlaced(qi.entry.Hash)) then table.insert(removeUnits, i); end end end end if(#removeUnits > 0) then for i=#removeUnits, 1, -1 do local success = RemoveFromQueue(cityID, removeUnits[i]); if(success and removeUnits[i] == 1) then BuildFirstQueued(city); end end end end function IsCityPlotValidForWonderPlacement(city, plotID, wonder) if(not plotID or plotID == -1) then return true end if Map.GetPlotByIndex(plotID):CanHaveWonder(wonder.Index, city:GetOwner(), city:GetID()) then return true; else return false; end end --- ======================================================================================================= -- === UI handling --- ======================================================================================================= --- ========================================================================== -- Resize the Production Queue window to fit the items --- ========================================================================== function ResizeQueueWindow() Controls.QueueWindow:SetSizeY(1); local windowHeight = math.min(math.max(#prodQueue[UI.GetHeadSelectedCity():GetID()] * 32 + 38, 70), screenHeight-300); Controls.QueueWindow:SetSizeY(windowHeight); Controls.ProductionQueueListScroll:SetSizeY(windowHeight-38); Controls.ProductionQueueListScroll:CalculateSize(); end --- ========================================================================== -- Slide-in/hide the Production Queue panel --- ========================================================================== function CloseQueueWindow() Controls.QueueSlideIn:Reverse(); Controls.QueueWindowToggleDirection:SetText("<"); end --- ========================================================================== -- Slide-out/show the Production Queue panel --- ========================================================================== function OpenQueueWindow() Controls.QueueSlideIn:SetToBeginning(); Controls.QueueSlideIn:Play(); Controls.QueueWindowToggleDirection:SetText(">"); end --- ========================================================================== -- Toggle the visibility of the Production Queue panel --- ========================================================================== function ToggleQueueWindow() showStandaloneQueueWindow = not showStandaloneQueueWindow; if(showStandaloneQueueWindow) then OpenQueueWindow(); else CloseQueueWindow(); end end --- =============================================================================== -- Control Event -- Fires when the production panel has finished fading in -- Use this to, if it is toggled off, delay showing the Production Queue panel -- (and therefore toggle tab) unitl after the production panel is there to -- cover it up --- =============================================================================== function OnPanelFadeInComplete() if(not showStandaloneQueueWindow) then Controls.QueueAlphaIn:Play(); end end --- =========================================================================== -- Recenter the camera over the selected city -- This is here for the sake of middle mouse clicking on a production item -- which ordinarily recenters the map to the cursor position --- =========================================================================== function RecenterCameraToSelectedCity() local kCity:table = UI.GetHeadSelectedCity(); UI.LookAtPlot( kCity:GetX(), kCity:GetY() ); end function ResetSelectedCityQueue() local selectedCity = UI.GetHeadSelectedCity(); if(not selectedCity) then return end local cityID = selectedCity:GetID(); if(not cityID) then return end local buildQueue = selectedCity:GetBuildQueue(); local currentProductionHash = buildQueue:GetCurrentProductionTypeHash(); local plotID = -1; if(prodQueue[cityID]) then prodQueue[cityID] = {}; end if(currentProductionHash ~= 0) then -- Determine the type of the item local currentType = 0; local productionInfo = GetProductionInfoOfCity(selectedCity, currentProductionHash); productionInfo.Hash = currentProductionHash; if(productionInfo.Type == "UNIT") then currentType = buildQueue:GetCurrentProductionTypeModifier() + 2; elseif(productionInfo.Type == "BUILDING") then if(GameInfo.Buildings[currentProductionHash].MaxWorldInstances == 1) then currentType = PRODUCTION_TYPE.PLACED; local pCityBuildings :table = selectedCity:GetBuildings(); local kCityPlots :table = Map.GetCityPlots():GetPurchasedPlots( selectedCity ); if (kCityPlots ~= nil) then for _,plot in pairs(kCityPlots) do local kPlot:table = Map.GetPlotByIndex(plot); local wonderType = kPlot:GetWonderType(); if(wonderType ~= -1 and GameInfo.Buildings[wonderType].BuildingType == GameInfo.Buildings[currentProductionHash].BuildingType) then plotID = plot; end end end else currentType = PRODUCTION_TYPE.BUILDING; end elseif(productionInfo.Type == "DISTRICT") then currentType = PRODUCTION_TYPE.PLACED; elseif(productionInfo.Type == "PROJECT") then currentType = PRODUCTION_TYPE.PROJECT; end if(currentType == 0) then print("Could not find production type for hash: " .. currentProductionHash); end prodQueue[cityID][1] = { entry=productionInfo, type=currentType, plotID=plotID } end Refresh(); end --- ========================================================================================================= --- ========================================================================================================= --- ========================================================================================================= --- ========================================================================================================= -- ============================================= MODULE INITIALIZATION ===================================== --- ========================================================================================================= function Initialize() LoadQueues(); Controls.PauseCollapseList:Stop(); Controls.PauseDismissWindow:Stop(); CreateCorrectTabs(); Resize(); -- ===== Event listeners ===== Controls.CloseButton:RegisterCallback(Mouse.eLClick, OnClose); Controls.CloseButton:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.PauseCollapseList:RegisterEndCallback( OnCollapseTheList ); Controls.PauseDismissWindow:RegisterEndCallback( OnHide ); Controls.QueueWindowToggle:RegisterCallback(Mouse.eLClick, ToggleQueueWindow); Controls.AlphaIn:RegisterEndCallback( OnPanelFadeInComplete ) Controls.ProductionTabSelected:SetSpeed(100); Controls.QueueWindowReset:RegisterCallback(Mouse.eLClick, ResetSelectedCityQueue); ContextPtr:SetInitHandler( OnInit ); ContextPtr:SetInputHandler( OnInputHandler, true ); ContextPtr:SetShutdown( OnShutdown ); Events.CitySelectionChanged.Add( OnCitySelectionChanged ); Events.InterfaceModeChanged.Add( OnInterfaceModeChanged ); Events.UnitSelectionChanged.Add( OnUnitSelectionChanged ); Events.LocalPlayerChanged.Add( OnLocalPlayerChanged ); Events.PlayerTurnActivated.Add( OnPlayerTurnActivated ); LuaEvents.CityBannerManager_ProductionToggle.Add( OnCityBannerManagerProductionToggle ); LuaEvents.CityPanel_ChooseProduction.Add( OnCityPanelChooseProduction ); LuaEvents.CityPanel_ChoosePurchase.Add( OnCityPanelChoosePurchase ); LuaEvents.CityPanel_ProductionClose.Add( OnProductionClose ); LuaEvents.CityPanel_ProductionOpen.Add( OnCityPanelProductionOpen ); LuaEvents.CityPanel_PurchaseGoldOpen.Add( OnCityPanelPurchaseGoldOpen ); LuaEvents.CityPanel_PurchaseFaithOpen.Add( OnCityPanelPurchaseFaithOpen ); LuaEvents.CityPanel_ProductionOpenForQueue.Add( OnProductionOpenForQueue ); LuaEvents.CityPanel_PurchasePlot.Add( OnCityPanelPurchasePlot ); LuaEvents.GameDebug_Return.Add( OnGameDebugReturn ); LuaEvents.NotificationPanel_ChooseProduction.Add( OnNotificationPanelChooseProduction ); LuaEvents.StrageticView_MapPlacement_ProductionOpen.Add( OnStrategicViewMapPlacementProductionOpen ); LuaEvents.StrageticView_MapPlacement_ProductionClose.Add( OnStrategicViewMapPlacementProductionClose ); LuaEvents.Tutorial_ProductionOpen.Add( OnTutorialProductionOpen ); Events.CityProductionChanged.Add( OnCityProductionChanged ); Events.CityProductionCompleted.Add(OnCityProductionCompleted); Events.CityProductionUpdated.Add(OnCityProductionUpdated); Events.CityMadePurchase.Add(Refresh); end Initialize(); end
--[[--ldoc desc @module ClockCountDown @author JrueZhu Date 2018-11-01 19:21:54 Last Modified by JrueZhu Last Modified time 2018-11-01 20:43:47 ]] local ClockCountDown = class("ClockCountDown", function() local layout = ccui.Layout:create(); layout:setLayoutType(ccui.LayoutType.RELATIVE) return layout; end) local clockBgPath = "Images/JrueZhu/countdown_bg.png"; local clockProgressPath = "Images/JrueZhu/countdown_green.png"; local mkproperty = function(getFun, setFun) local instance = {property = true} instance.get = getFun instance.set = setFun setmetatable(instance, {__newIndex = function() error() end}) return instance; end local function setPeerSemetable(object) local peer = tolua.getpeer(object) local mt = getmetatable(peer) local __index = mt.__index mt.__index = function(_, k) if type(ClockCountDown[k]) == "table" and ClockCountDown[k].property == true then return ClockCountDown[k].get(object) elseif __index then if type(__index) == "table" then return __index[k] elseif type(__index) == "function" then return __index(_, k) end end end mt.__newindex = function(_, k, v) if type(ClockCountDown[k]) == "table" and ClockCountDown[k].property == true then return ClockCountDown[k].set(object, k, v) else rawset(_, k, v) end end end ClockCountDown.timer = mkproperty(function(self) return self.timeData.timer; end, function ( self, _, value ) self:updateView({timer = value}); end) function ClockCountDown:ctor(data) setPeerSemetable(self); self.timeData = { timer = 60; } self:updateView(data); local entry; local function update(dt) if self.timeData.timer > 0 then self.timeData.timer = self.timeData.timer - dt; local numLabel = self:getChildByTag(3); numLabel:setString(tostring(self.timeData.timer)) else cc.Director:getInstance():getScheduler():unscheduleScriptEntry(entry); if self.listener then self.listener(); end end end entry = cc.Director:getInstance():getScheduler():scheduleScriptFunc(update, 1, false) end function ClockCountDown:setTimeEndListener(func) self.listener = func; end local function checkLegalData(self, data) if data then if data.timer and type(data.timer) ~= "number" then error("传入的时间参数不合法!!!") else self.timeData.timer = data.timer; end end end function ClockCountDown:updateView(data) checkLegalData(self, data); local countDownBg = cc.Sprite:create(clockBgPath); countDownBg:setAnchorPoint(0.5, 0.5); self:addChild(countDownBg, 0, 1); local clockProgress = self:getChildByTag(2); if clockProgress then local to = cc.ProgressTo:create(data.timer, 0); clockProgress:runAction(cc.RepeatForever:create(to)); else local progressImg = cc.Sprite:create(clockProgressPath); clockProgress = cc.ProgressTimer:create(progressImg); clockProgress:setPercentage(100); clockProgress:setReverseProgress(true); local to = cc.ProgressTo:create(data.timer, 0); clockProgress:setType(cc.PROGRESS_TIMER_TYPE_RADIAL); clockProgress:runAction(cc.RepeatForever:create(to)); clockProgress:setAnchorPoint(0.5, 0.5); self:addChild(clockProgress, 0, 2); end local numLabel = self:getChildByTag(3); if numLabel then numLabel:setString(tostring(data.timer)); else numLabel = cc.Label:createWithSystemFont(tostring(data.timer), "Arial", 35); numLabel:setAnchorPoint(0.5, 0.5); self:addChild(numLabel, 0, 3) end end return ClockCountDown;
--- the moduler to builder the raw tags. -- @author [Alejandro Baez](https://keybase.io/baez) -- @copyright 2014-2016 -- @licence MIT (see LICENSE) -- @module raw local _CTAGS = _USERHOME .. "/modules/rust/ctags.rust" --- gets project name from **pwd** or from vcs root. -- @function get_project_name -- @return project_name, project_full_path local function get_project_name() local check = io.open("../Cargo.toml") ~= nil and (buffer.filename or ''):match('^(.+)%/.+]') or io.get_project_root() return check and check:match('^.+%/(%w+)') or nil, check end --- converts ctags.rust into correct formatting for use. -- @function parse_ctags -- @param f the path of the ctags.rust file. local function parse_ctags(f) local ctag_options = "" for line in io.input(f):lines("*l") do local _, cut = line:find("regex.Rust.") if cut then ctag_options = string.format("%s %s'%s'", ctag_options, line:sub(1,cut), line:sub(cut+1)) else ctag_options = string.format("%s %s", ctag_options, line) end end return ctag_options end --- builds raw tag for use with api/tags modules. -- @param project_full_path see @{api.build}. local function build(project_full_path) os.execute(string.format( "ctags -f %s %s --languages=Rust -R --rust-kinds=-c-d-T %s/*", project_full_path .. "/tags", parse_ctags(_CTAGS), project_full_path ), 'w') return project_full_path .. "/tags" end return { build = build, get_project_name = get_project_name }
addEvent("admin:setClipboardText", true) addEventHandler("admin:setClipboardText", resourceRoot, function(data) setClipboard(tostring(data)) end)
require "/scripts/dpxObject.lua" function init() object.setInteractive(true) dpx.init() storage.pixels = storage.pixels or 0 end function update(dt) -- Request power if storage.dpx < dpx.maxStore then -- ensure we dont just eat power for id, node in pairs(self.dpxInputConnections) do dpx.sendRequest(id, node, dpx.ALL) -- draw 5 dPx end end -- Attempt to generate pixels & update animation state if storage.dpx >= config.getParameter("dpxPixelRatio") then storage.dpx = storage.dpx - config.getParameter("dpxPixelRatio") storage.pixels = storage.pixels + 1 animator.setAnimationState("crankState", "active") else animator.setAnimationState("crankState", "idle") end end function onInteraction(args) if storage.pixels > 0 then world.spawnItem({name="money", count=storage.pixels}, entity.position()) storage.pixels = 0 else animator.playSound("error") end end
-- internationalization boilerplate local MP = minetest.get_modpath(minetest.get_current_modname()) local S, NS = dofile(MP.."/intllib.lua") -- A convenienence function that attempts to do a generic crafting operation. -- "request_stack" is an item stack that it is assumed the player has removed from a set of possible outputs, it is assumed that the contents of request_stack will be added to the destination inventory as a result of an existing inventory transfer and it will be deducted from the craft result. -- source_inv, source_listname are where the raw materials will be taken from -- destination_inv, destination_listname are where the crafting outputs will be placed. -- player_or_pos is either a player object or a pos table. This is used for logging purposes and as a place to put output in the event that destination_inv can't hold it all. simplecrafting_lib.craft_stack = function(crafting_type, request_stack, source_inv, source_listname, destination_inv, destination_listname, player_or_pos) local player local pos if type(player_or_pos) == "userdata" then player = player_or_pos elseif type(player_or_pos) == "table" then pos = player_or_pos end local craft_result = simplecrafting_lib.get_crafting_result(crafting_type, source_inv:get_list(source_listname), request_stack) if craft_result then if simplecrafting_lib.remove_items(source_inv, source_listname, craft_result.input) then -- We've successfully paid for this craft's output. -- log it if player then minetest.log("action", player:get_player_name() .. " crafts " .. craft_result.output:to_string()) elseif pos then minetest.log("action", craft_result.output:to_string() .. " was crafted at " .. minetest.pos_to_string(pos)) else minetest.log("action", craft_result.output:to_string() .. "was crafted somewhere by someone.") end local total_output = simplecrafting_lib.count_list_add( -- subtract the amount of output that the player's getting anyway (due to having taken it from the inventory of outputs) {[craft_result.output:get_name()]=craft_result.output:get_count() - request_stack:get_count()}, craft_result.returns) -- stuff the output in the target inventory, or the player's inventory if it doesn't fit, finally dropping anything that doesn't fit at the player's location local leftover = simplecrafting_lib.add_items(destination_inv, destination_listname, total_output) simplecrafting_lib.execute_post_craft(crafting_type, craft_result, request_stack, source_inv, source_listname, destination_inv, destination_listname) if player then leftover = simplecrafting_lib.add_items(player:get_inventory(), "main", leftover) simplecrafting_lib.drop_items(player:getpos(), leftover) elseif pos then simplecrafting_lib.drop_items(pos, leftover) else local still_has_leftovers = false for item, count in pairs(leftover) do still_has_leftovers = true break end if still_has_leftovers then minetest.log("error", "After crafting " .. craft_result.output:to_string() .. " some output items could not be placed into an inventory or dropped in world, and were lost.") end end return true end end return false end
ItemConfig["banana"] = { name = "Banana", type = "usable", category = "Grocery", price = 3, interactions = { use = { use_label = "Eat", sound = "sounds/eat.wav", animation = { name = "DRINKING" }, event = "EatBanana" }, }, modelid = 1622, max_use = 3, max_carry = 2, attachment = { x = -6, y = 4, z = -1, rx = -64, ry = 1, rz = 0, bone = "hand_r" } }
local IncarnateBuffs = { INCARNATE_S = { FireCursed = "INF_NECROFIRE", FrozenBlessed = "INF_BLESSED_ICE", PoisonCursed = "INF_ACID", ElectrifiedCursed = "INF_CURSED_ELECTRIC", Electrified = "INF_ELECTRIC", Fire = "INF_FIRE", Poison = "INF_POISON", Oil = "INF_OIL", Blood = "INF_BLOOD", Water = "INF_WATER", }, INCARNATE_G = { FireCursed = "INF_NECROFIRE_G", FrozenBlessed = "INF_BLESSED_ICE_G", PoisonCursed = "INF_ACID_G", ElectrifiedCursed = "INF_CURSED_ELECTRIC_G", Electrified = "INF_ELECTRIC_G", Fire = "INF_FIRE_G", Poison = "INF_POISON_G", Oil = "INF_OIL_G", Blood = "INF_BLOOD_G", Water = "INF_WATER_G", } } local function ApplyIncarnateElementalBuff(summon, owner) local surface = GetSurfaceGroundAt(summon) or "SurfaceNone" local cloud = GetSurfaceCloudAt(summon) or "SurfaceNone" if surface == "SurfaceNone" and cloud == "SurfaceNone" then return false end for tag,surfaceNames in pairs(IncarnateBuffs) do if IsTagged(summon, tag) == 1 then -- Prioritize ground surfaces for surfaceCheck,status in pairs(surfaceNames) do if string.find(surface, surfaceCheck) then ApplyStatus(summon, status, -1.0, 0, owner) return true end end -- Fallback to cloud checks for surfaceCheck,status in pairs(surfaceNames) do if string.find(cloud, surfaceCheck) then ApplyStatus(summon, status, -1.0, 0, owner) return true end end end end return false end function SetIncarnateSurfaceBuff(summon, owner) ApplyStatus(summon, "LLENEMY_INF_RANGED", -1.0, 0, owner) ApplyStatus(summon, "LLENEMY_INF_POWER", -1.0, 0, owner) if IsTagged(owner, "LLENEMY_Duplicant") == 1 then ApplyStatus(summon, "INF_SHADOW", -1.0, 0, owner) end ApplyIncarnateElementalBuff(summon, owner) end function ModifySummoningAbility(uuid) -- For allowing them to summon an Incarnate Champion if CharacterGetAbility(uuid, "Summoning") < 10 and (IsBoss(uuid) == 1 or CharacterGetLevel(uuid) >= 12) then CharacterAddAbility(uuid, "Summoning", 4) end end --Mods.EnemyUpgradeOverhaul.SummonAutomaton("08348b3a-bded-4811-92ce-f127aa4310e0") --Mods.EnemyUpgradeOverhaul.SummonAutomaton(CharacterGetHostCharacter()) function SummonAutomaton(uuid) if HasActiveStatus(uuid, "LLENEMY_SUMMONING_CAP_INCREASE") == 0 then ApplyStatus(uuid, "LLENEMY_SUMMONING_CAP_INCREASE", 54.0, 0, uuid) end local x,y,z = GetPosition(uuid) -- local combatid = CombatGetIDForCharacter(uuid) -- if combatid ~= nil then -- local combatEntries = Osi.DB_CombatCharacters:Get(nil,combatid) -- local randomEntry = LeaderLib.Common.GetRandomTableEntry(combatEntries) -- if randomEntry ~= nil then -- x,y,z = GetPosition(randomEntry[1]) -- x,y,z = FindValidPosition(x,y,z, 12.0, uuid) -- end -- end -- if x == nil or y == nil or z == nil then -- x,y,z = GetPosition(uuid) -- end local handle = NRD_CreateStorm(uuid, "Storm_LLENEMY_SpawnAutomaton", x,y,z) NRD_GameActionSetLifeTime(handle, 48.0) --local sx,sy,sz = GetPosition(uuid) --GameHelpers.ShootProjectile(uuid, {x,y,z}, "ProjectileStrike_LLENEMY_SummonAutomaton", false, {sx,sy,sz}) end function SummonSetFaction(uuid) local character = Ext.GetCharacter(uuid) if character ~= nil and character.HasOwner and character.OwnerHandle ~= nil then local owner = Ext.GetCharacter(character.OwnerHandle) if owner ~= nil then SetFaction(character, GetFaction(owner.MyGuid)) end end end
return { tag = 'vectors', summary = 'Create a new Quat.', description = 'Creates a new quaternion. This function takes the same arguments as `Quat:set`.', arguments = {}, returns = {}, related = { 'lovr.math.quat', 'Quat' } }
local Class = require("tabula.Class") local PrimitiveType = require("tabula.PrimitiveType") local StructType = require("tabula.StructType") local tableMod = require("tabula.table") local TagType = require("tabula.TagType") local lton = require("lton") local ValueType = require("tabula.ValueType") local keys = assert(tableMod.keys) local keySet = assert(tableMod.keySet) local sortedKeys = assert(tableMod.sortedKeys) local M = Class.new() function M:init() print("Adding tablet #1 for archetype {}") self.rootTablet = { index = 1, archetype = {}, shardSize = 256, shards = {}, parents = {}, children = {}, } self.tablets = {self.rootTablet} self.shards = {} self.entityType = PrimitiveType.new("int32_t") self.lifecycleType = StructType.new("lifecycle", [[ int16_t shardIndex; int16_t rowIndex; int16_t generation; ]]) self.minEntity = 1 self.maxEntity = 1024 * 1024 - 1 self.entities = self.lifecycleType:allocateArray(self.maxEntity + 1) self.nextEntity = self.minEntity self.dataTypes = {} self.componentTypes = {} self.names = {} self.eventSystems = {} self.queries = {} self:bootstrap() end function M:bootstrap() self.dataTypes.tag = TagType.new() self.dataTypes.value = ValueType.new() self.componentTypes.dataType = "value" self.componentTypes.name = "value" end function M:addEntity(components) local entity = self.nextEntity while true do local nextEntity = entity + 1 if nextEntity > self.maxEntity then nextEntity = self.minEntity end if self.entities[entity].generation <= 0 then self.nextEntity = nextEntity break end entity = nextEntity if entity == self.nextEntity then error("Too many entities") end end local archetype = keySet(components) local tablet = self:addTablet(archetype) local shard = tablet.shards[#tablet.shards] if shard == nil or shard.rowCount == tablet.shardSize then shard = self:addShard(tablet) end local rowIndex = shard.rowCount shard.rowCount = shard.rowCount + 1 shard.entities[rowIndex] = entity for component in pairs(archetype) do local column = shard.columns[component] local value = components[component] column[rowIndex] = value end self.entities[entity] = { shardIndex = shard.index, rowIndex = rowIndex, generation = 1 - self.entities[entity].generation, } return entity end function M:removeEntity(entity) local lifecycle = self.entities[entity] if lifecycle.generation <= 0 then error("No such entity: " .. entity) end local shard = self.shards[lifecycle.shardIndex] if lifecycle.rowIndex == shard.rowCount - 1 then shard.rowCount = shard.rowCount - 1 else shard.entities[lifecycle.rowIndex] = 0 shard.tombstoneCount = shard.tombstoneCount + 1 end lifecycle.generation = -lifecycle.generation end function M:addTablet(archetype) local parentTablet = self.rootTablet local sortedComponents = sortedKeys(archetype) for i, component in ipairs(sortedComponents) do local childTablet = parentTablet.children[component] if not childTablet then local childArchetype = {} for j = 1, i do local childComponent = sortedComponents[j] childArchetype[childComponent] = true end local tabletIndex = #self.tablets + 1 print("Adding tablet #" .. tabletIndex .. " for archetype {" .. table.concat(sortedKeys(childArchetype), ", ") .. "}") childTablet = { index = tabletIndex, archetype = childArchetype, shardSize = 256, shards = {}, parents = {}, children = {}, } parentTablet.children[component] = childTablet childTablet.parents[component] = parentTablet table.insert(self.tablets, childTablet) end parentTablet = childTablet end return parentTablet end function M:addShard(tablet) local shardIndex = #self.shards + 1 print("Adding shard #" .. shardIndex .. " for archetype {" .. table.concat(sortedKeys(tablet.archetype), ", ") .. "}") local entities = self.entityType:allocateArray(tablet.shardSize) local columns = {} for component in pairs(tablet.archetype) do local typeName = self.componentTypes[component] if not typeName then error("No such component: " .. component) end local dataType = self.dataTypes[typeName] columns[component] = dataType:allocateArray(tablet.shardSize) end shard = { index = shardIndex, tablet = tablet, rowCount = 0, tombstoneCount = 0, entities = entities, columns = columns, } table.insert(tablet.shards, shard) table.insert(self.shards, shard) return shard end function M:addEvent(event) if self.eventSystems[event] then error("Duplicate event: " .. event) end self.eventSystems[event] = {} end function M:addSystem(event, system) if not self.eventSystems[event] then error("No such event: " .. event) end assert(type(system) == "function", "Invalid system") table.insert(self.eventSystems[event], system) end function M:handleEvent(event, ...) local systems = self.eventSystems[event] if not systems then error("No such event: " .. event) end for _, system in ipairs(systems) do system(self, ...) end end return M
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB local S = E:GetModule('Skins') --Cache global variables --Lua functions local _G = _G --WoW API / Variables local hooksecurefunc = hooksecurefunc --Global variables that we don't cache, list them here for mikk's FindGlobals script -- GLOBALS: BattlefieldMapTab, BattlefieldMapOptions, OpacityFrame -- GLOBALS: SHOW_BATTLEFIELDMINIMAP_PLAYERS, LOCK_BATTLEFIELDMINIMAP, BATTLEFIELDMINIMAP_OPACITY_LABEL -- GLOBALS: UIDROPDOWNMENU_MENU_LEVEL, UIParent, ToggleDropDownMenu, UIDropDownMenu_Initialize local function LoadSkin() if E.private.skins.blizzard.enable ~= true or E.private.skins.blizzard.bgmap ~= true then return end local function GetOpacity() return 1 - (BattlefieldMapOptions and BattlefieldMapOptions.opacity or 1) end local oldAlpha = GetOpacity() local BattlefieldMapFrame = _G["BattlefieldMapFrame"] BattlefieldMapFrame:SetClampedToScreen(true) BattlefieldMapFrame:StripTextures() BattlefieldMapFrame:CreateBackdrop('Default') BattlefieldMapFrame:SetFrameStrata('LOW') BattlefieldMapFrame.backdrop:SetOutside(BattlefieldMapFrame.ScrollContainer) BattlefieldMapFrame.backdrop:SetBackdropColor(0, 0, 0, oldAlpha) BattlefieldMapFrame.backdrop.backdropTexture:SetTexture(nil) hooksecurefunc(BattlefieldMapFrame.backdrop.backdropTexture, "SetTexture", function(self, texture) if texture ~= nil then self:SetTexture(nil) end end) BattlefieldMapFrame:EnableMouse(true) BattlefieldMapFrame:SetMovable(true) BattlefieldMapFrame.BorderFrame:StripTextures() BattlefieldMapFrame.BorderFrame.CloseButton:SetFrameLevel(BattlefieldMapFrame.BorderFrame.CloseButton:GetFrameLevel()+1) S:HandleCloseButton(BattlefieldMapFrame.BorderFrame.CloseButton) BattlefieldMapTab:Kill() local function InitializeOptionsDropDown() BattlefieldMapTab:InitializeOptionsDropDown() end BattlefieldMapFrame.ScrollContainer:HookScript("OnMouseUp", function(_, btn) if btn == "LeftButton" then BattlefieldMapTab:StopMovingOrSizing() BattlefieldMapTab:SetUserPlaced(true) elseif btn == "RightButton" then UIDropDownMenu_Initialize(BattlefieldMapTab.OptionsDropDown, InitializeOptionsDropDown, "MENU") ToggleDropDownMenu(1, nil, BattlefieldMapTab.OptionsDropDown, BattlefieldMapFrame:GetName(), 0, -4) end if OpacityFrame:IsShown() then OpacityFrame:Hide() end end) BattlefieldMapFrame.ScrollContainer:HookScript("OnMouseDown", function(_, btn) if btn == "LeftButton" and (BattlefieldMapOptions and not BattlefieldMapOptions.locked) then BattlefieldMapTab:StartMoving() end end) local function setBackdropAlpha() if BattlefieldMapFrame.backdrop then BattlefieldMapFrame.backdrop:SetBackdropColor(0, 0, 0, GetOpacity()) end end hooksecurefunc(BattlefieldMapFrame, "SetGlobalAlpha", setBackdropAlpha) hooksecurefunc(BattlefieldMapFrame, "RefreshAlpha", function() oldAlpha = GetOpacity() end) local function setOldAlpha() if oldAlpha then BattlefieldMapFrame:SetGlobalAlpha(oldAlpha) oldAlpha = nil end end local function setRealAlpha() oldAlpha = GetOpacity() BattlefieldMapFrame:SetGlobalAlpha(1) end BattlefieldMapFrame:HookScript('OnShow', setBackdropAlpha) BattlefieldMapFrame.ScrollContainer:HookScript('OnLeave', setOldAlpha) BattlefieldMapFrame.ScrollContainer:HookScript('OnEnter', setRealAlpha) BattlefieldMapFrame.BorderFrame.CloseButton:HookScript('OnLeave', setOldAlpha) BattlefieldMapFrame.BorderFrame.CloseButton:HookScript('OnEnter', setRealAlpha) end S:AddCallbackForAddon("Blizzard_BattlefieldMap", "BattlefieldMap", LoadSkin)
local _, addon = ...; -- https://onlinetexttools.com/split-text?input=&split-by-char=false&char=%20&split-by-regex=false&regex=%2F%5Cs%2B%2F&split-by-length=true&length=110&separator=%2C%5Cn&symbol-before-chunk=%22&symbol-after-chunk=%22 table.insert(addon.officialCourses, table.concat({ "!WOP:2!0xD3E05B04!nI1xSXXrzC124MWgAjPvPvQqOtQIKDGZBV7SVl2ji568h8LGGA5AQfQisMDV5UD8T3otNz2765QkHsrcecesH)ubp5A1", "xQAfGQekbEGgjEiiOfTQ0(qRe)5ba1Ge5biQnQsLY3mZU7DN91E8KZTZUZ333VF)((9ntULFKNplwijVv1l6ZAZdjks9GYX06x(227HpATf(BU", "VW)6hs)g1w4nJFLn)EpZR8VXcbTdoSovQWr(KjUOpom0d73sw9czp0r0MgrBJ5oR0LjcR7SfNiKWIKivqYUp)R5hsWIS3(aROOQqIyzgnsHkDI", "gcir23A6peXAGwglAbPi)UmBfSPNJ6ZIoNKUb8L(c8g9opF)PXBGLs2Z5praSH8h6ruyHcHvivabDswKKi6GvmHEZ1pArHpoIua9fX(tUOGqqk", "siHZGVHRZi3Qj3AqYTLIh)97zJN87(4psTf(J)3h7VE8F7tLSRjsMOAYT7KSBNK94K8X01xIZbs2BA9uo5osUZKpXbs235t2VoRsUl(HwJmzyi", "YJ0KgzsbEiw1GPrTMOaIGSTyE)lnZZ9L(51w41XpWtDZdEZXgZzgrmN)lljMyfsQ3KirybloQo8eQ(FtWifd1KOqSifJNbnDbUD4C5FCFV0p53", "8NVmu)tn3wF2p3eJnxMDe5YlSsCechYGQnlkO1JBZ1LFEEbOcnmelKzzg8h9tJipHcjj(kklsNNMCe9vyXiGgrQECQwr2dPfxGaYcWRhdvwSsM", "9BjTor)XeSFqwXMfopIQlHez2y52Q(nVX1E5FW5GQ)DV4Rp73(pm2QVYiQ(YAMOhiPZRzzli0YrWaa3Stk4TFMZ(NUYI7hKdp77D9L(lF)XMev", "3zs8e3YNEvTqd4Eeyaa99qG6nukydpvgcWybD(AXxrV80w3O2Navb40oguf4ZG9OakwAOuieT9y6s6u1qypAivrHqp1PyXEqKplSFfqpkjQjPr", "CiAfIc0JQcOppb(rSmOaAPqGV6)GJ464Kr44qjdIdbHJ6H8IPGZuuZ8cXpKbT7zshBXaem0RzOauBCRb4ceRd8Y7Sb8T)pj9M4vNhq8t)(F1lE", "1Rowe)OJG2)cRcqNfq05ING1cezBtJNc8euDIujy9i1rANOuP(OBjVMh)RDPV5g1w4n29Uw4hFKF)yZU5gLEykJEqBfaGcaLBxomKNGLSncelJ", "B4BxxxKJZdhz0sOUS4qnwNTjyjkG2mq)3mXuAZyguSZcfPPRozcdHvy0hKgcdT5eKiWiGiWEaGU0xtVtfs7MO6nnmK11KeWleG7y9fdiq2zCzi", "yjnSxQI4J2o8AV1b)v39w)Aqz8Tw7mp9h)xowSF(rOmU3ZMR9YA7grKU(gx74V3KqKEOFXRw4o4F4r6cPdslocAExV4Q2UABjddHbDwghAzd75", "baU02JzqSiIfnfg)Y8PidJoP0a2JLIOMIWXzzMus9Som5E5qwCmNsUOLgqzKkhSeFUkX6TBtdMI6tsj6gMxqatsI5dqZPF1KkROZOvTHogmzsR", "XgmTeWy9QiCzb0z0ZJHnOLvweadH0s1btz7ceadaelxq0BWOJ6gqb8jfDBrY(wLos5Qwl0112Rb(PghHSrCUoLD7BfMP41TbzMFi9HT6cmNS)w", "Mc9moNjPkl6ZI(qcI(RCDMzySFOUYmvODBDDM19JWDwhSi0APUU2eZWqXC4uFTzA9L(ayd2w3vNAqIXeu4iq9hxBXjDVQEv9jtqsol)WBqhIgs", "5aotsnWn6cJtpow3(cUqObL4gsqNnd05hVt7wdN46uXf9WWjsn7Sg4Y3uZlzki0iROc9tMSELbgUz4plcbtESq0uyT4jFeQfQpsH(nieBKS2sf", "SO8Jht9BbG12zJb0et1NdY3v9M6JvyECOrhd93HngU5nfaCodQvearPZ(1hsdITxScL5U2nOx)vnoiPoghYI7gmGlyEypirv65RswBqdsBtm4a", "xG91TX2TToZ0Qs7OHxtR(KPekvDOHma)N7zZB8gBDbWa0j8jF(R80J3aS0i8ANCP(NKul87B)LsYPA(H9EV0N5D8p4TxBHxR4Kv)PFYF24d9Oo", "1)x))JZ9z5cg0CmKeRHUjjl1q6dsKQUwp)OtIX2DUTA6M)UI3zPNdQPMLE5d)MFW4RPrDRIVt2Tkeu7TkSk3DovOVjQv8LwQWlQ7xHu0ibGLnR", "IHQpNr0AB4CeqVOm7qBWH3b5b60rRZ6zDgOKUUVemmZxq56trW3C1Cr6PiTHTQwCKcG10XBooM1T)YitL6BHb9(qGZVjimUyrrZyPl6e24qIm3", "jLQmn8zsvOyKeRJBAv7P1v6KsQFIDpCCoPGuNQogAzAZM9EaAD(HRuU6mZwSI30ZvSmE6zl2OY0ZvYhpDrF8mvMVuv)5QI57lelvTz1PnOK61X", "WeR9xCMhS88py5sGi)yvo6XknZfAtuyynCv(94dDLqpgrCAiAaZFstrER8pv(cY1OQa7JxuUi0o2H4SfvEY0)hac2cIvdQpyx07e1Gw8K9YVVL", "h4oQaJHwwGjWTOPXT3QlRBh9f8zrRmVBr3kcFTiKj437zWWn(f4q4JMEvy2ilQo8fY)3" }))
local Colors = require(script.Parent.Colors) local CompactView = { ContainerBackgroundTransparency = 0, ContainerBackgroundColor = Colors.Carbon, UseContainerAspectRatio = false, ContainerAspectRatio = nil, MaxAssetCardsPerRow = 3, ContainerSize = UDim2.new(1, 0, 1, -36), ContainerAnchorPoint = Vector2.new(0.5, 0), ContainerPosition = UDim2.new(0.5, 0, 0, 36), AvatarHeadShotSize = 48, TopSizeY = 90, ClipsDescendants = false, PlayerViewportSize = UDim2.new(1, 0, 0.41, 0), AssetListSize = UDim2.new(1, 0, 0.59, -42), AssetListPosition = UDim2.new(0, 0, 0.41, 42), CloseButtonPosition = UDim2.new(0, 6, 0, -20), DetailsThumbnailFrameSize = UDim2.new(1, 0, 0.4, 0), DetailsThumbnailFramePosition = UDim2.new(0, 0, 0, 15), DetailsThumbnailAnchorPoint = Vector2.new(0.5, 0.5), DetailsThumbnailPosition = UDim2.new(0.5, 0, 0.5, 0), DetailsThumbnailARDominantAxis = Enum.DominantAxis.Height, DetailsFramePosition = UDim2.new(0, 15, 0.4, 15), DetailsFrameSize = UDim2.new(1, -30, 0.6, -30), AssetCardMaxSizeX = 108, AssetCardMaxSizeY = 157, DefaultCameraOffset = CFrame.new(0, 2, -5), ToolOffset = CFrame.new(0, 2, -8), TryOnPosition = UDim2.new(0, 0, 0, 15), TryOnSize = UDim2.new(1, 0, 0.4, 0), BorderPaddingSize = 20, AssetTextMaxSize = 14, } setmetatable(CompactView, { __newindex = function(t, key, index) end, __index = function(t, index) error("CompactView table has no value: " .. tostring(index)) end } ) return CompactView
IncludeDirectories = {} IncludeDirectories["yaml"] = "%{wks.location}/MangaList/vendor/yaml-cpp/include" IncludeDirectories["spdlog"] = "%{wks.location}/MangaList/vendor/spdlog/include" IncludeDirectories["debugbreak"] = "%{wks.location}/MangaList/vendor/debugbreak" IncludeDirectories["glfw"] = "%{wks.location}/GUI/vendor/glfw" IncludeDirectories["imgui"] = "%{wks.location}/GUI/vendor/imgui"
function updateRendererLayeredBSDFList(layered_bsdf) _G["__RENDERER_ELEMENTS__"]["__LAYERED_BSDF_COUNT__"] = _G["__RENDERER_ELEMENTS__"]["__LAYERED_BSDF_COUNT__"] + 1 _G["__RENDERER_ELEMENTS__"]["__LAYERED_BSDFS__"][_G["__RENDERER_ELEMENTS__"]["__LAYERED_BSDF_COUNT__"]] = layered_bsdf return _G["__RENDERER_ELEMENTS__"]["__LAYERED_BSDF_COUNT__"] end function LayeredBSDF(self) self.num_layers = #self for layer_count = 1, self.num_layers do if (not (type(self[layer_count]) == "number")) then print("Lua ERROR: Invalid layered BSDF layer. Exiting...") os.exit() end if (self[layer_count] < 1) or (self[layer_count] > _G["__RENDERER_ELEMENTS__"]["__BSDF_COUNT__"]) then print("Lua ERROR: Invalid layered BSDF layer: index out of range. Exiting...") os.exit() end end return updateRendererLayeredBSDFList(self) end
--text.lua local utils = require("euler.utils") local Widget = require("euler.widget") local Text = class(Widget) local prop = property(Text) prop:reader("scroll_view", nil) function Text:__init(id, txt) self.root = gui.get_node(id .. "/text") self.label = gui.get_node(id .. "/label") local text = gui.getlab self:set_label(txt or gui.get_text(self.label)) end function Text:setup(euler) local size = gui.get_size(self.root) local lsize = gui.get_size(self.label) local content = gui.get_node(self.id .. "/content") self.scroll_view = euler:init_scroll_view(self.id .. "/scroll_view", content) self.scroll_view:set_size(size) self.scroll_view:set_contont_size(lsize) self.scroll_view:register_vertical(function(view, percent) local csize = gui.get_size(content) local pos = gui.get_position(self.label) pos.y = (lsize.y - csize.y) * percent / 100 gui.set_position(self.label, pos) end) self.scroll_view:register_horizontal(function(view, percent) local csize = gui.get_size(content) local pos = gui.get_position(self.label) pos.x = (lsize.x - csize.x) * percent / -100 gui.set_position(self.label, pos) end) end function Text:on_label_changed(label, text) local lsize = gui.get_size(label) local metrics = utils.get_text_metrics(self.label, text) lsize.x = metrics.width lsize.y = metrics.height gui.set_size(label, lsize) if self.scroll_view then self.scroll_view:set_contont_size(lsize) end end return Text
do --this class is currently used for AWACS and Ships, at a latter date a separate class for ships could be created, currently not needed SkynetIADSAWACSRadar = {} SkynetIADSAWACSRadar = inheritsFrom(SkynetIADSAbstractRadarElement) function SkynetIADSAWACSRadar:create(radarUnit, iads) local instance = self:superClass():create(radarUnit, iads) setmetatable(instance, self) self.__index = self instance.lastUpdatePosition = nil return instance end function SkynetIADSAWACSRadar:setupElements() local unit = self:getDCSRepresentation() local radar = SkynetIADSSAMSearchRadar:create(unit) radar:setupRangeData() table.insert(self.searchRadars, radar) end function SkynetIADSAWACSRadar:getNatoName() return self:getDCSRepresentation():getTypeName() end -- AWACs will not scan for HARMS function SkynetIADSAWACSRadar:scanForHarms() end function SkynetIADSAWACSRadar:getMaxAllowedMovementForAutonomousUpdateInNM() local radarRange = mist.utils.metersToNM(self.searchRadars[1]:getMaxRangeFindingTarget()) return mist.utils.round(radarRange / 10) end function SkynetIADSAWACSRadar:isUpdateOfAutonomousStateOfSAMSitesRequired() return self:getDistanceTraveledSinceLastUpdate() > self:getMaxAllowedMovementForAutonomousUpdateInNM() end function SkynetIADSAWACSRadar:getDistanceTraveledSinceLastUpdate() local currentPosition = nil if self.lastUpdatePosition == nil and self:getDCSRepresentation():isExist() then self.lastUpdatePosition = self:getDCSRepresentation():getPosition().p end if self:getDCSRepresentation():isExist() then currentPosition = self:getDCSRepresentation():getPosition().p end return mist.utils.round(mist.utils.metersToNM(self:getDistanceToUnit(self.lastUpdatePosition, currentPosition))) end end
if not modules then modules = { } end modules ['scrp-ini'] = { version = 1.001, comment = "companion to scrp-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" } -- We need to rewrite this a bit ... rather old code ... will be done when japanese -- is finished. local tonumber, next = tonumber, next local trace_analyzing = false trackers.register("scripts.analyzing", function(v) trace_analyzing = v end) local trace_injections = false trackers.register("scripts.injections", function(v) trace_injections = v end) local trace_splitting = false trackers.register("scripts.splitting", function(v) trace_splitting = v end) local trace_splitdetail = false trackers.register("scripts.splitting.detail", function(v) trace_splitdetail = v end) local report_preprocessing = logs.reporter("scripts","preprocessing") local report_splitting = logs.reporter("scripts","splitting") local utfbyte, utfsplit = utf.byte, utf.split local gmatch = string.gmatch local attributes = attributes local nodes = nodes local context = context local texsetattribute = tex.setattribute local nodecodes = nodes.nodecodes local unsetvalue = attributes.unsetvalue local implement = interfaces.implement local glyph_code = nodecodes.glyph local glue_code = nodecodes.glue local emwidths = fonts.hashes.emwidths local exheights = fonts.hashes.exheights local a_scriptinjection = attributes.private('scriptinjection') local a_scriptsplitting = attributes.private('scriptsplitting') local a_scriptstatus = attributes.private('scriptstatus') local fontdata = fonts.hashes.identifiers local allocate = utilities.storage.allocate local setnodecolor = nodes.tracers.colors.set local setmetatableindex = table.setmetatableindex local enableaction = nodes.tasks.enableaction local disableaction = nodes.tasks.disableaction local nuts = nodes.nuts local tonut = nuts.tonut local tonode = nuts.tonode local getnext = nuts.getnext local getchar = nuts.getchar local getfont = nuts.getfont local getid = nuts.getid local getattr = nuts.getattr local setattr = nuts.setattr local isglyph = nuts.isglyph local insert_node_after = nuts.insert_after local first_glyph = nuts.first_glyph local traverse_id = nuts.traverse_id local traverse_char = nuts.traverse_char local nodepool = nuts.pool local new_glue = nodepool.glue local new_rule = nodepool.rule local new_penalty = nodepool.penalty scripts = scripts or { } local scripts = scripts scripts.hash = scripts.hash or { } local hash = scripts.hash local handlers = allocate() scripts.handlers = handlers local injectors = allocate() scripts.injectors = handlers local splitters = allocate() scripts.splitters = splitters local hash = { -- we could put these presets in char-def.lua -- -- half width opening parenthesis -- [0x0028] = "half_width_open", [0x005B] = "half_width_open", [0x007B] = "half_width_open", [0x2018] = "half_width_open", -- ‘ [0x201C] = "half_width_open", -- “ -- -- full width opening parenthesis -- [0x3008] = "full_width_open", -- 〈 Left book quote [0x300A] = "full_width_open", -- 《 Left double book quote [0x300C] = "full_width_open", -- 「 left quote [0x300E] = "full_width_open", -- 『 left double quote [0x3010] = "full_width_open", -- 【 left double book quote [0x3014] = "full_width_open", -- 〔 left book quote [0x3016] = "full_width_open", --〖 left double book quote [0x3018] = "full_width_open", -- left tortoise bracket [0x301A] = "full_width_open", -- left square bracket [0x301D] = "full_width_open", -- reverse double prime qm [0xFF08] = "full_width_open", -- ( left parenthesis [0xFF3B] = "full_width_open", -- [ left square brackets [0xFF5B] = "full_width_open", -- { left curve bracket -- -- half width closing parenthesis -- [0x0029] = "half_width_close", [0x005D] = "half_width_close", [0x007D] = "half_width_close", [0x2019] = "half_width_close", -- ’ right quote, right [0x201D] = "half_width_close", -- ” right double quote -- -- full width closing parenthesis -- [0x3009] = "full_width_close", -- 〉 book quote [0x300B] = "full_width_close", -- 》 double book quote [0x300D] = "full_width_close", -- 」 right quote, right [0x300F] = "full_width_close", -- 』 right double quote [0x3011] = "full_width_close", -- 】 right double book quote [0x3015] = "full_width_close", -- 〕 right book quote [0x3017] = "full_width_close", -- 〗 right double book quote [0x3019] = "full_width_close", -- right tortoise bracket [0x301B] = "full_width_close", -- right square bracket [0x301E] = "full_width_close", -- double prime qm [0x301F] = "full_width_close", -- low double prime qm [0xFF09] = "full_width_close", -- ) right parenthesis [0xFF3D] = "full_width_close", -- ] right square brackets [0xFF5D] = "full_width_close", -- } right curve brackets -- [0xFF62] = "half_width_open", -- left corner bracket [0xFF63] = "half_width_close", -- right corner bracket -- -- vertical opening vertical -- -- 0xFE35, 0xFE37, 0xFE39, 0xFE3B, 0xFE3D, 0xFE3F, 0xFE41, 0xFE43, 0xFE47, -- -- vertical closing -- -- 0xFE36, 0xFE38, 0xFE3A, 0xFE3C, 0xFE3E, 0xFE40, 0xFE42, 0xFE44, 0xFE48, -- -- half width opening punctuation -- -- <empty> -- -- full width opening punctuation -- -- 0x2236, -- ∶ -- 0xFF0C, -- , -- -- half width closing punctuation_hw -- [0x0021] = "half_width_close", -- ! [0x002C] = "half_width_close", -- , [0x002E] = "half_width_close", -- . [0x003A] = "half_width_close", -- : [0x003B] = "half_width_close", -- ; [0x003F] = "half_width_close", -- ? [0xFF61] = "half_width_close", -- hw full stop -- -- full width closing punctuation -- [0x3001] = "full_width_close", -- 、 [0x3002] = "full_width_close", -- 。 [0xFF0C] = "full_width_close", -- , [0xFF0E] = "full_width_close", -- -- -- depends on font -- [0xFF01] = "full_width_close", -- ! [0xFF1F] = "full_width_close", -- ? -- [0xFF1A] = "full_width_punct", -- : [0xFF1B] = "full_width_punct", -- ; -- -- non starter -- [0x3005] = "non_starter", [0x3041] = "non_starter", [0x3043] = "non_starter", [0x3045] = "non_starter", [0x3047] = "non_starter", [0x3049] = "non_starter", [0x3063] = "non_starter", [0x3083] = "non_starter", [0x3085] = "non_starter", [0x3087] = "non_starter", [0x308E] = "non_starter", [0x3095] = "non_starter", [0x3096] = "non_starter", [0x309B] = "non_starter", [0x309C] = "non_starter", [0x309D] = "non_starter", [0x309E] = "non_starter", [0x30A0] = "non_starter", [0x30A1] = "non_starter", [0x30A3] = "non_starter", [0x30A5] = "non_starter", [0x30A7] = "non_starter", [0x30A9] = "non_starter", [0x30C3] = "non_starter", [0x30E3] = "non_starter", [0x30E5] = "non_starter", [0x30E7] = "non_starter", [0x30EE] = "non_starter", [0x30F5] = "non_starter", [0x30F6] = "non_starter", [0x30FC] = "non_starter", [0x30FD] = "non_starter", [0x30FE] = "non_starter", [0x31F0] = "non_starter", [0x31F1] = "non_starter", [0x30F2] = "non_starter", [0x30F3] = "non_starter", [0x30F4] = "non_starter", [0x31F5] = "non_starter", [0x31F6] = "non_starter", [0x30F7] = "non_starter", [0x30F8] = "non_starter", [0x30F9] = "non_starter", [0x31FA] = "non_starter", [0x31FB] = "non_starter", [0x30FC] = "non_starter", [0x30FD] = "non_starter", [0x30FE] = "non_starter", [0x31FF] = "non_starter", -- -- hyphenation -- [0x2026] = "hyphen", -- … ellipsis [0x2014] = "hyphen", -- — hyphen -- [0x1361] = "ethiopic_word", [0x1362] = "ethiopic_sentence", -- } local function provide(t,k) local v if not tonumber(k) then v = false elseif (k >= 0x03040 and k <= 0x030FF) or (k >= 0x031F0 and k <= 0x031FF) or (k >= 0x032D0 and k <= 0x032FE) or (k >= 0x0FF00 and k <= 0x0FFEF) then v = "katakana" elseif (k >= 0x03400 and k <= 0x04DFF) or (k >= 0x04E00 and k <= 0x09FFF) or (k >= 0x0F900 and k <= 0x0FAFF) or (k >= 0x20000 and k <= 0x2A6DF) or (k >= 0x2F800 and k <= 0x2FA1F) then v = "chinese" elseif (k >= 0x0AC00 and k <= 0x0D7A3) then v = "korean" elseif (k >= 0x01100 and k <= 0x0115F) then v = "jamo_initial" elseif (k >= 0x01160 and k <= 0x011A7) then v = "jamo_medial" elseif (k >= 0x011A8 and k <= 0x011FF) then v = "jamo_final" elseif (k >= 0x01200 and k <= 0x0139F) then v = "ethiopic_syllable" else v = false end t[k] = v return v end setmetatableindex(hash,provide) -- should come from char-def scripts.hash = hash local numbertodataset = allocate() local numbertohandler = allocate() --~ storage.register("scripts/hash", hash, "scripts.hash") scripts.numbertodataset = numbertodataset scripts.numbertohandler = numbertohandler local defaults = { inter_char_shrink_factor = 0, inter_char_shrink_factor = 0, inter_char_stretch_factor = 0, inter_char_half_shrink_factor = 0, inter_char_half_stretch_factor = 0, inter_char_quarter_shrink_factor = 0, inter_char_quarter_stretch_factor = 0, inter_char_hangul_penalty = 0, inter_word_stretch_factor = 0, } scripts.defaults = defaults -- so we can add more function scripts.installmethod(handler) local name = handler.name handlers[name] = handler local attributes = { } local datasets = handler.datasets if not datasets or not datasets.default then report_preprocessing("missing (default) dataset in script %a",name) datasets.default = { } -- slower but an error anyway end for k, v in next, datasets do setmetatableindex(v,defaults) end setmetatable(attributes, { __index = function(t,k) local v = datasets[k] or datasets.default local a = unsetvalue if v then v.name = name -- for tracing a = #numbertodataset + 1 numbertodataset[a] = v numbertohandler[a] = handler end t[k] = a return a end } ) handler.attributes = attributes end function scripts.installdataset(specification) -- global overload local method = specification.method local name = specification.name local dataset = specification.dataset if method and name and dataset then local parent = specification.parent or "" local handler = handlers[method] if handler then local datasets = handler.datasets if datasets then local defaultset = datasets.default if defaultset then if parent ~= "" then local p = datasets[parent] if p then defaultset = p else report_preprocessing("dataset, unknown parent %a for method %a",parent,method) end end setmetatable(dataset,defaultset) local existing = datasets[name] if existing then for k, v in next, existing do existing[k] = dataset end else datasets[name] = dataset end else report_preprocessing("dataset, no default for method %a",method) end else report_preprocessing("dataset, no datasets for method %a",method) end else report_preprocessing("dataset, no method %a",method) end else report_preprocessing("dataset, invalid specification") -- maybe report table end end local injectorenabled = false local splitterenabled = false function scripts.set(name,method,preset) local handler = handlers[method] if handler then if handler.injector then if not injectorenabled then enableaction("processors","scripts.injectors.handler") injectorenabled = true end texsetattribute(a_scriptinjection,handler.attributes[preset] or unsetvalue) end if handler.splitter then if not splitterenabled then enableaction("processors","scripts.splitters.handler") splitterenabled = true end texsetattribute(a_scriptsplitting,handler.attributes[preset] or unsetvalue) end if handler.initializer then handler.initializer(handler) handler.initializer = nil end else texsetattribute(a_scriptinjection,unsetvalue) texsetattribute(a_scriptsplitting,unsetvalue) end end function scripts.reset() texsetattribute(a_scriptinjection,unsetvalue) texsetattribute(a_scriptsplitting,unsetvalue) end -- the following tables will become a proper installer (move to cjk/eth) -- -- 0=gray 1=red 2=green 3=blue 4=yellow 5=magenta 6=cyan 7=x-yellow 8=x-magenta 9=x-cyan local scriptcolors = allocate { -- todo: just named colors korean = "trace:0", chinese = "trace:0", katakana = "trace:0", hiragana = "trace:0", full_width_open = "trace:1", full_width_close = "trace:2", half_width_open = "trace:3", half_width_close = "trace:4", full_width_punct = "trace:5", hyphen = "trace:5", non_starter = "trace:6", jamo_initial = "trace:7", jamo_medial = "trace:8", jamo_final = "trace:9", ethiopic_syllable = "trace:1", ethiopic_word = "trace:2", ethiopic_sentence = "trace:3", } scripts.colors = scriptcolors local numbertocategory = allocate { -- rather bound to cjk ... will be generalized "korean", "chinese", "katakana", "hiragana", "full_width_open", "full_width_close", "half_width_open", "half_width_close", "full_width_punct", "hyphen", "non_starter", "jamo_initial", "jamo_medial", "jamo_final", "ethiopic_syllable", "ethiopic_word", "ethiopic_sentence", } local categorytonumber = allocate(table.swapped(numbertocategory)) -- could be one table scripts.categorytonumber = categorytonumber scripts.numbertocategory = numbertocategory local function colorize(start,stop) for n in traverse_id(glyph_code,start) do local kind = numbertocategory[getattr(n,a_scriptstatus)] if kind then local ac = scriptcolors[kind] if ac then setnodecolor(n,ac) end end if n == stop then break end end end local function traced_process(head,first,last,process,a) if start ~= last then local f, l = first, last local name = numbertodataset[a] name = name and name.name or "?" report_preprocessing("before %s: %s",name,nodes.tosequence(f,l)) process(head,first,last) report_preprocessing("after %s: %s", name,nodes.tosequence(f,l)) end end -- eventually we might end up with more extensive parsing -- todo: pass t[start..stop] == original -- -- one of the time consuming functions: -- we can have a fonts.hashes.originals function scripts.injectors.handler(head) head = tonut(head) local start = first_glyph(head) -- we already have glyphs here (subtype 1) if not start then return tonode(head), false else local last_a, normal_process, lastfont, originals = nil, nil, nil, nil local done, first, last, ok = false, nil, nil, false while start do local char, id = isglyph(start) if char then local a = getattr(start,a_scriptinjection) if a then if a ~= last_a then if first then if ok then if trace_analyzing then colorize(first,last) end if trace_injections then traced_process(head,first,last,normal_process,last_a) else normal_process(head,first,last) end ok, done = false, true end first, last = nil, nil end last_a = a local handler = numbertohandler[a] normal_process = handler.injector end if normal_process then -- wrong: originals are indices ! local font = getfont(start) if font ~= lastfont then originals = fontdata[font].resources if resources then originals = resources.originals else originals = nil -- can't happen end lastfont = font end if originals and type(originals) == "number" then char = originals[char] or char end local h = hash[char] if h then setattr(start,a_scriptstatus,categorytonumber[h]) if not first then first, last = start, start else last = start end -- if cjk == "chinese" or cjk == "korean" then -- we need to prevent too much ( ) processing ok = true -- end elseif first then if ok then if trace_analyzing then colorize(first,last) end if trace_injections then traced_process(head,first,last,normal_process,last_a) else normal_process(head,first,last) end ok, done = false, true end first, last = nil, nil end end elseif first then if ok then if trace_analyzing then colorize(first,last) end if trace_injections then traced_process(head,first,last,normal_process,last_a) else normal_process(head,first,last) end ok, done = false, true end first, last = nil, nil end elseif id == glue_code then if ok then -- continue elseif first then -- no chinese or korean first, last = nil, nil end elseif first then if ok then -- some chinese or korean if trace_analyzing then colorize(first,last) end if trace_injections then traced_process(head,first,last,normal_process,last_a) else normal_process(head,first,last) end first, last, ok, done = nil, nil, false, true elseif first then first, last = nil, nil end end start = getnext(start) end if ok then if trace_analyzing then colorize(first,last) end if trace_injections then traced_process(head,first,last,normal_process,last_a) else normal_process(head,first,last) end done = true end return tonode(head), done end end -- kind of experimental .. might move to it's own module -- function scripts.splitters.handler(head) -- return head, false -- end local function addwords(tree,data) if not tree then tree = { } end for word in gmatch(data,"%S+") do local root = tree local list = utfsplit(word,true) for i=1,#list do local l = utfbyte(list[i]) local r = root[l] if not r then r = { } root[l] = r end if i == #list then r.final = word -- true -- could be something else, like word in case of tracing else root = r end end end return tree end local loaded = { } function splitters.load(handler,files) local files = handler.files local tree = handler.tree or { } handler.tree = tree if not files then return elseif type(files) == "string" then files = { files } handler.files = files end if trace_splitting then report_splitting("loading splitter data for language/script %a",handler.name) end loaded[handler.name or "unknown"] = (loaded[handler.name or "unknown"] or 0) + 1 statistics.starttiming(loaded) for i=1,#files do local filename = files[i] local fullname = resolvers.findfile(filename) if fullname == "" then fullname = resolvers.findfile(filename .. ".gz") end if fullname ~= "" then if trace_splitting then report_splitting("loading file %a",fullname) end local suffix, gzipped = gzip.suffix(fullname) if suffix == "lua" then local specification = table.load(fullname,gzipped and gzip.load) if specification then local lists = specification.lists if lists then for i=1,#lists do local entry = lists[i] local data = entry.data if data then if entry.compression == "zlib" then data = zlib.decompress(data) if entry.length and entry.length ~= #data then report_splitting("compression error in file %a",fullname) end end if data then addwords(tree,data) end end end end end else local data = gzipped and io.loadgzip(fullname) or io.loaddata(fullname) if data then addwords(tree,data) end end else report_splitting("unknown file %a",filename) end end statistics.stoptiming(loaded) return tree end statistics.register("loaded split lists", function() if next(loaded) then return string.format("%s, load time: %s",table.sequenced(loaded),statistics.elapsedtime(loaded)) end end) -- function splitters.addlist(name,filename) -- local handler = scripts.handlers[name] -- if handler and filename then -- local files = handler.files -- if not files then -- files = { } -- elseif type(files) == "string" then -- files = { files } -- end -- handler.files = files -- if type(filename) == "string" then -- filename = utilities.parsers.settings_to_array(filename) -- end -- if type(filename) == "table" then -- for i=1,#filename do -- files[#files+1] = filenames[i] -- end -- end -- end -- end -- -- commands.setscriptsplitterlist = splitters.addlist local categories = characters.categories or { } -- local function hit(root,head) -- local current = getnext(head) -- local lastrun = false -- local lastfinal = false -- while current and getid(current) == glyph_code do -- local char = getchar(current) -- local newroot = root[char] -- if newroot then -- local final = newroot.final -- if final then -- lastrun = current -- lastfinal = final -- end -- root = newroot -- elseif categories[char] == "mn" then -- -- continue -- else -- return lastrun, lastfinal -- end -- current = getnext(current) -- end -- if lastrun then -- return lastrun, lastfinal -- end -- end local function hit(root,head) local current = getnext(head) local lastrun = false local lastfinal = false while current do local char = isglyph(current) if char then local newroot = root[char] if newroot then local final = newroot.final if final then lastrun = current lastfinal = final end root = newroot elseif categories[char] == "mn" then -- continue else return lastrun, lastfinal end else break end end if lastrun then return lastrun, lastfinal end end local tree, attr, proc function splitters.handler(head) -- todo: also first_glyph test head = tonut(head) local current = head local done = false while current do if getid(current) == glyph_code then local a = getattr(current,a_scriptsplitting) if a then if a ~= attr then local handler = numbertohandler[a] tree = handler.tree or { } attr = a proc = handler.splitter end if proc then local root = tree[getchar(current)] if root then -- we don't check for attributes in the hitter (yet) local last, final = hit(root,current) if last then local next = getnext(last) if next then local nextchar = isglyph(next) if not nextchar then -- we're done elseif tree[nextchar] then if trace_splitdetail then if type(final) == "string" then report_splitting("advance %s processing between <%s> and <%c>","with",final,nextchar) else report_splitting("advance %s processing between <%c> and <%c>","with",char,nextchar) end end head, current = proc(handler,head,current,last,1) done = true else if trace_splitdetail then -- could be punctuation if type(final) == "string" then report_splitting("advance %s processing between <%s> and <%c>","without",final,nextchar) else report_splitting("advance %s processing between <%c> and <%c>","without",char,nextchar) end end head, current = proc(handler,head,current,last,2) done = true end end end end end end end current = getnext(current) end return tonode(head), done end local function marker(head,current,font,color) -- could become: nodes.tracers.marker local ex = exheights[font] local em = emwidths [font] head, current = insert_node_after(head,current,new_penalty(10000)) head, current = insert_node_after(head,current,new_glue(-0.05*em)) head, current = insert_node_after(head,current,new_rule(0.05*em,1.5*ex,0.5*ex)) setnodecolor(current,color) return head, current end local last_a, last_f, last_s, last_q function splitters.insertafter(handler,head,first,last,detail) local a = getattr(first,a_scriptsplitting) local f = getfont(first) if a ~= last_a or f ~= last_f then last_s = emwidths[f] * numbertodataset[a].inter_word_stretch_factor last_a = a last_f = f end if trace_splitting then head, last = marker(head,last,f,detail == 2 and "trace:r" or "trace:g") end if ignore then return head, last else return insert_node_after(head,last,new_glue(0,last_s)) end end -- word-xx.lua: -- -- return { -- comment = "test", -- copyright = "not relevant", -- language = "en", -- timestamp = "2013-05-20 14:15:21", -- version = "1.00", -- lists = { -- { -- -- data = "we thrive information in thick worlds because of our marvelous and everyday capacity to select edit single out structure highlight group pair merge harmonize synthesize focus organize condense reduce boil down choose categorize catalog classify list abstract scan look into idealize isolate discriminate distinguish screen pigeonhole pick over sort integrate blend inspect filter lump skip smooth chunk average approximate cluster aggregate outline summarize itemize review dip into flip through browse glance into leaf through skim refine enumerate glean synopsize winnow the wheat from the chaff and separate the sheep from the goats", -- data = "abstract aggregate and approximate average because blend boil browse capacity catalog categorize chaff choose chunk classify cluster condense dip discriminate distinguish down edit enumerate everyday filter flip focus from glance glean goats group harmonize highlight idealize in information inspect integrate into isolate itemize leaf list look lump marvelous merge of organize our out outline over pair pick pigeonhole reduce refine review scan screen select separate sheep single skim skip smooth sort structure summarize synopsize synthesize the thick thrive through to we wheat winnow worlds", -- }, -- }, -- } scripts.installmethod { name = "test", splitter = splitters.insertafter, initializer = splitters.load, files = { -- "scrp-imp-word-test.lua", "word-xx.lua", }, datasets = { default = { inter_word_stretch_factor = 0.25, -- of quad }, }, } -- new plugin: local registercontext = fonts.specifiers.registercontext local mergecontext = fonts.specifiers.mergecontext local otfscripts = characters.otfscripts local report_scripts = logs.reporter("scripts","auto feature") local trace_scripts = false trackers.register("scripts.autofeature",function(v) trace_scripts = v end) local autofontfeature = scripts.autofontfeature or { } scripts.autofontfeature = autofontfeature local cache_yes = { } local cache_nop = { } setmetatableindex(cache_yes,function(t,k) local v = { } t[k] = v return v end) setmetatableindex(cache_nop,function(t,k) local v = { } t[k] = v return v end) -- beware: we need to tag a done (otherwise too many extra instances ... but how -- often unpack? wait till we have a bitmap -- -- we can consider merging this in handlers.characters(head) at some point as there -- already check for the dynamic attribute so it saves a pass, however, then we also -- need to check for a_scriptinjection there which nils the benefit -- -- we can consider cheating: set all glyphs in a word as the first one but it's not -- playing nice function autofontfeature.handler(head) for n in traverse_char(tonut(head)) do -- if getattr(n,a_scriptinjection) then -- -- already tagged by script feature, maybe some day adapt -- else local char = getchar(n) local script = otfscripts[char] if script then local dynamic = getattr(n,0) or 0 local font = getfont(n) if dynamic > 0 then local slot = cache_yes[font] local attr = slot[script] if not attr then attr = mergecontext(dynamic,name,2) slot[script] = attr if trace_scripts then report_scripts("script: %s, trigger %C, dynamic: %a, variant: %a",script,char,attr,"extended") end end if attr ~= 0 then n[0] = attr -- maybe set scriptinjection when associated end else local slot = cache_nop[font] local attr = slot[script] if not attr then attr = registercontext(font,script,2) slot[script] = attr if trace_scripts then report_scripts("script: %s, trigger %C, dynamic: %s, variant: %a",script,char,attr,"normal") end end if attr ~= 0 then setattr(n,0,attr) -- maybe set scriptinjection when associated end end end -- end end return head end function autofontfeature.enable() report_scripts("globally enabled") enableaction("processors","scripts.autofontfeature.handler") end function autofontfeature.disable() report_scripts("globally disabled") disableaction("processors","scripts.autofontfeature.handler") end implement { name = "enableautofontscript", actions = autofontfeature.enable } implement { name = "disableautofontscript", actions = autofontfeature.disable } implement { name = "setscript", actions = scripts.set, arguments = "3 strings", } implement { name = "resetscript", actions = scripts.reset }
local function create() local en = CreateEntity() en.transform = CreateComponent("transform") function en:render() self.transform:draw() end return en end return create
require 'cunn' require 'ccn2' -- Very Deep model local model = nn.Sequential() local final_mlpconv_layer = nil -- Convolution Layers model:add(nn.Transpose({1,4},{1,3},{1,2})) model:add(ccn2.SpatialConvolution(3, 64, 3, 1, 1)) model:add(nn.ReLU()) model:add(ccn2.SpatialConvolution(64, 64, 3, 1, 1)) model:add(nn.ReLU()) model:add(ccn2.SpatialMaxPooling(2, 2)) model:add(nn.Dropout(0.25)) model:add(ccn2.SpatialConvolution(64, 128, 3, 1, 1)) model:add(nn.ReLU()) model:add(ccn2.SpatialConvolution(128, 128, 3, 1, 1)) model:add(nn.ReLU()) model:add(ccn2.SpatialMaxPooling(2, 2)) model:add(nn.Dropout(0.25)) model:add(ccn2.SpatialConvolution(128, 256, 3, 1, 1)) model:add(nn.ReLU()) model:add(ccn2.SpatialConvolution(256, 256, 3, 1, 1)) model:add(nn.ReLU()) model:add(ccn2.SpatialConvolution(256, 256, 3, 1, 1)) model:add(nn.ReLU()) model:add(ccn2.SpatialConvolution(256, 256, 3, 1, 1)) model:add(nn.ReLU()) model:add(ccn2.SpatialMaxPooling(2, 2)) model:add(nn.Dropout(0.25)) -- Fully Connected Layers model:add(ccn2.SpatialConvolution(256, 1024, 3, 1, 0)) model:add(nn.ReLU()) model:add(nn.Dropout(0.5)) model:add(ccn2.SpatialConvolution(1024, 1024, 1, 1, 0)) model:add(nn.ReLU()) model:add(nn.Dropout(0.5)) model:add(nn.Transpose({4,1},{4,2},{4,3})) model:add(nn.SpatialConvolutionMM(1024, 10, 2,2)) model:add(nn.Reshape(10)) model:add(nn.LogSoftMax()) return model
util.AddNetworkString("bSecure.OpenMenu") bSecure.ConCommandAdd("menu", function(ply) if not ply:IsAdmin() then return bSecure.ChatPrint(ply, "Insufficient access") end bSecure.ChatPrint(ply, "Opening the menu...") net.Start("bSecure.OpenMenu") net.Send(ply) end)
-- Copyright (c) 2015 Pwootage -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -- THE SOFTWARE. local function main() local event = require("event") local term = require("term") local filesystem = require("filesystem") local serialization = require("serialization") term.clear() -- Add pacyak's lib to the lib path package.path = package.path .. ";/usr/share/pacyak/pacyak/lib/?.lua" local json = require("json") local libpacyak = require("libpacyak") local packageDir = "/usr/share/pacyak/" for package in filesystem.list(packageDir) do if filesystem.isDirectory(packageDir..package) and filesystem.exists(packageDir..package .. "package.json") then print("Loading package: " .. package) libpacyak.loadPackage(packageDir..package) end end -- event.pull("key_down") end -- Main entry point local status, err = pcall(main) if status then else print("Error booting") print(err) require("event").pull("key_down") end
/* NetRexx */ options replace format comments java crossref symbols nobinary ir = InetAddress addresses = InetAddress[] InetAddress.getAllByName('www.kame.net') loop ir over addresses if ir <= Inet4Address then do say 'IPv4 :' ir.getHostAddress end if ir <= Inet6Address then do say 'IPv6 :' ir.getHostAddress end end ir
local _, ADDON = ... ------------------------------------------------------------ local items = { -- Druid T2: [16897] = {boss = 617, slot = 5, xtype = 2, xclass = 1, account = 2, cost = 160}, -- Stormrage Chestguard [16898] = {boss = 612, slot = 10, xtype = 2, xclass = 1, account = 2, cost = 120}, -- Stormrage Boots [16899] = {boss = 2, slot = 7, xtype = 2, xclass = 1, account = 2, cost = 120}, -- Stormrage Handguards [16902] = {boss = 616, slot = 3, xtype = 2, xclass = 1, account = 2, cost = 160}, -- Stormrage Pauldrons [16903] = {boss = 611, slot = 8, xtype = 2, xclass = 1, account = 2, cost = 80}, -- Stormrage Belt [16904] = {boss = 610, slot = 6, xtype = 2, xclass = 1, account = 2, cost = 80}, -- Stormrage Bracers -- Hunter T2: [16935] = {boss = 610, slot = 6, xtype = 3, xclass = 2, account = 2, cost = 80}, -- Dragonstalker's Bracers [16936] = {boss = 611, slot = 8, xtype = 3, xclass = 2, account = 2, cost = 80}, -- Dragonstalker's Belt [16937] = {boss = 616, slot = 3, xtype = 3, xclass = 2, account = 2, cost = 160}, -- Dragonstalker's Spaulders [16940] = {boss = 2, slot = 7, xtype = 3, xclass = 2, account = 2, cost = 120}, -- Dragonstalker's Gauntlets [16941] = {boss = 612, slot = 10, xtype = 3, xclass = 2, account = 2, cost = 120}, -- Dragonstalker's Greaves [16942] = {boss = 617, slot = 5, xtype = 3, xclass = 2, account = 2, cost = 160}, -- Dragonstalker's Breastplate -- Mage T2: [16818] = {boss = 611, slot = 8, xtype = 1, xclass = 3, account = 2, cost = 80}, -- Netherwind Belt [16912] = {boss = 612, slot = 10, xtype = 1, xclass = 3, account = 2, cost = 120}, -- Netherwind Boots [16913] = {boss = 2, slot = 7, xtype = 1, xclass = 3, account = 2, cost = 120}, -- Netherwind Gloves [16916] = {boss = 617, slot = 5, xtype = 1, xclass = 3, account = 2, cost = 160}, -- Netherwind Robes [16917] = {boss = 616, slot = 3, xtype = 1, xclass = 3, account = 2, cost = 160}, -- Netherwind Mantle [16918] = {boss = 610, slot = 6, xtype = 1, xclass = 3, account = 2, cost = 80}, -- Netherwind Bindings -- Paladin T2: [16951] = {boss = 610, slot = 6, xtype = 4, xclass = 4, account = 2, cost = 80}, -- Judgement Bindings [16952] = {boss = 611, slot = 8, xtype = 4, xclass = 4, account = 2, cost = 80}, -- Judgement Belt [16953] = {boss = 616, slot = 3, xtype = 4, xclass = 4, account = 2, cost = 160}, -- Judgement Spaulders [16956] = {boss = 2, slot = 7, xtype = 4, xclass = 4, account = 2, cost = 120}, -- Judgement Gauntlets [16957] = {boss = 612, slot = 10, xtype = 4, xclass = 4, account = 2, cost = 120}, -- Judgement Sabatons [16958] = {boss = 617, slot = 5, xtype = 4, xclass = 4, account = 2, cost = 160}, -- Judgement Breastplate -- Priest T2: [16919] = {boss = 612, slot = 10, xtype = 1, xclass = 5, account = 2, cost = 120}, -- Boots of Transcendence [16920] = {boss = 2, slot = 7, xtype = 1, xclass = 5, account = 2, cost = 120}, -- Handguards of Transcendence [16923] = {boss = 617, slot = 5, xtype = 1, xclass = 5, account = 2, cost = 160}, -- Robes of Transcendence [16924] = {boss = 616, slot = 3, xtype = 1, xclass = 5, account = 2, cost = 160}, -- Pauldrons of Transcendence [16925] = {boss = 611, slot = 8, xtype = 1, xclass = 5, account = 2, cost = 80}, -- Belt of Transcendence [16926] = {boss = 610, slot = 6, xtype = 1, xclass = 5, account = 2, cost = 80}, -- Bindings of Transcendence -- Rogue T2: [16832] = {boss = 616, slot = 3, xtype = 2, xclass = 6, account = 2, cost = 160}, -- Bloodfang Spaulders [16905] = {boss = 617, slot = 5, xtype = 2, xclass = 6, account = 2, cost = 160}, -- Bloodfang Chestpiece [16906] = {boss = 612, slot = 10, xtype = 2, xclass = 6, account = 2, cost = 120}, -- Bloodfang Boots [16907] = {boss = 2, slot = 7, xtype = 2, xclass = 6, account = 2, cost = 120}, -- Bloodfang Gloves [16910] = {boss = 611, slot = 8, xtype = 2, xclass = 6, account = 2, cost = 80}, -- Bloodfang Belt [16911] = {boss = 610, slot = 6, xtype = 2, xclass = 6, account = 2, cost = 80}, -- Bloodfang Bracers -- Shaman T2: [16944] = {boss = 611, slot = 8, xtype = 3, xclass = 7, account = 2, cost = 80}, -- Belt of Ten Storms [16943] = {boss = 610, slot = 6, xtype = 3, xclass = 7, account = 2, cost = 80}, -- Bracers of Ten Storms [16950] = {boss = 617, slot = 5, xtype = 3, xclass = 7, account = 2, cost = 160}, -- Breastplate of Ten Storms [16945] = {boss = 616, slot = 3, xtype = 3, xclass = 7, account = 2, cost = 160}, -- Epaulets of Ten Storms [16948] = {boss = 2, slot = 7, xtype = 3, xclass = 7, account = 2, cost = 120}, -- Gauntlets of Ten Storms [16949] = {boss = 612, slot = 10, xtype = 3, xclass = 7, account = 2, cost = 120}, -- Greaves of Ten Storms -- Warlock T2: [16927] = {boss = 612, slot = 10, xtype = 1, xclass = 8, account = 2, cost = 120}, -- Nemesis Boots [16928] = {boss = 2, slot = 7, xtype = 1, xclass = 8, account = 2, cost = 120}, -- Nemesis Gloves [16931] = {boss = 617, slot = 5, xtype = 1, xclass = 8, account = 2, cost = 160}, -- Nemesis Robes [16932] = {boss = 616, slot = 3, xtype = 1, xclass = 8, account = 2, cost = 160}, -- Nemesis Spaulders [16933] = {boss = 611, slot = 8, xtype = 1, xclass = 8, account = 2, cost = 80}, -- Nemesis Belt [16934] = {boss = 610, slot = 6, xtype = 1, xclass = 8, account = 2, cost = 80}, -- Nemesis Bracers -- Warrior T2: [16959] = {boss = 610, slot = 6, xtype = 4, xclass = 9, account = 2, cost = 80}, -- Bracelets of Wrath [16960] = {boss = 611, slot = 8, xtype = 4, xclass = 9, account = 2, cost = 80}, -- Waistband of Wrath [16961] = {boss = 616, slot = 3, xtype = 4, xclass = 9, account = 2, cost = 160}, -- Pauldrons of Wrath [16964] = {boss = 2, slot = 7, xtype = 4, xclass = 9, account = 2, cost = 120}, -- Gauntlets of Wrath [16965] = {boss = 612, slot = 10, xtype = 4, xclass = 9, account = 2, cost = 120}, -- Sabatons of Wrath [16966] = {boss = 617, slot = 5, xtype = 4, xclass = 9, account = 2, cost = 160}, -- Breastplate of Wrath -- Trinkets: [19336] = {boss = 610, slot = 12, xtype = 0, xclass = 2, account = 2, cost = 20}, -- Arcane Infused Gem [19337] = {boss = 610, slot = 12, xtype = 0, xclass = 8, account = 2, cost = 20}, -- The Black Book [19339] = {boss = 611, slot = 12, xtype = 0, xclass = 3, account = 2, cost = 200}, -- Mind Quickening Gem [19340] = {boss = 611, slot = 12, xtype = 0, xclass = 1, account = 2, cost = 20}, -- Rune of Metamorphosis [19341] = {boss = 612, slot = 12, xtype = 0, xclass = 9, account = 2, cost = 80}, -- Lifegiving Gem [19342] = {boss = 612, slot = 12, xtype = 0, xclass = 6, account = 2, cost = 20}, -- Venomous Totem [19343] = {boss = 615, slot = 12, xtype = 0, xclass = 4, account = 2, cost = 80}, -- Scrolls of Blinding Light [19344] = {boss = 615, slot = 12, xtype = 0, xclass = 7, account = 2, cost = 80}, -- Natural Alignment Crystal [19345] = {boss = 614, slot = 12, xtype = 0, xclass = 5, account = 2, cost = 20}, -- Aegis of Preservation -- Razorgore: [19369] = {boss = 610, slot = 7, xtype = 1, account = 2, cost = 20, note = "Crap"}, -- Gloves of Rapid Evolution [19370] = {boss = 610, slot = 3, xtype = 1, account = 2, cost = 200, note = "Mage/WL/Shadow BiS"}, -- Mantle of the Blackwing Cabal [19335] = {boss = 610, slot = 14, xtype = 8, account = 2, cost = 120, note = "Human-Fury, whatever"}, -- Spineshatter [19334] = {boss = 610, slot = 16, xtype = 6, account = 2, cost = 200, note = "Cool Proc"}, -- The Untamed Blade -- Vaelastrasz: [19371] = {boss = 611, slot = 2, xtype = 0, account = 2, cost = 40, note = "Crap"}, -- Pendant of the Fallen Dragon [19372] = {boss = 611, slot = 1, xtype = 4, account = 2, cost = 80, note = "Tank > PvP"}, -- Helm of Endless Rage [19346] = {boss = 611, slot = 13, xtype = 5, account = 2, cost = 160, note = "Tank, Rogue, Hunter"}, -- Dragonfang Blade [19348] = {boss = 611, slot = 15, xtype = 17, account = 2, cost = 120, note = "Heal-Paladin"}, -- Red Dragonscale Protector -- Broodlord: [19373] = {boss = 612, slot = 3, xtype = 3, account = 2, cost = 20, note = "Crap"}, -- Black Brood Pauldrons [19374] = {boss = 612, slot = 6, xtype = 1, account = 2, cost = 280, note = "WL, Mage"}, -- Bracers of Arcane Accuracy [19350] = {boss = 612, slot = 17, xtype = 12, account = 2, cost = 80, note = "Whatever"}, -- Heartstriker [19351] = {boss = 612, slot = 13, xtype = 6, account = 2, cost = 280, note = "Human-Warrior/Tank"}, -- Maladath, Runed Blade of the Black Flight -- The Three Drakes: [19397] = {boss = 2, slot = 11, xtype = 0, account = 2, cost = 80, note = "Shadow > Mage, WL"}, -- Ring of Blackrock [19395] = {boss = 2, slot = 12, xtype = 0, account = 2, cost = 400, note = "Heal"}, -- Rejuvenating Gem [19353] = {boss = 2, slot = 16, xtype = 7, account = 2, cost = 20, note = "PvP"}, -- Drake Talon Cleaver [19394] = {boss = 2, slot = 3, xtype = 4, account = 2, cost = 160, note = "Fury-Prot, good until Naxx"}, -- Drake Talon Pauldrons [19396] = {boss = 2, slot = 8, xtype = 2, account = 2, cost = 80, note = "Bear"}, -- Taut Dragonhide Belt [19355] = {boss = 2, slot = 16, xtype = 10, account = 2, cost = 80, note = "Heal-Druid In-Between-Item"}, -- Shadow Wing Focus Staff -- Firemaw: [19399] = {boss = 615, slot = 5, xtype = 1, account = 2, cost = 80, note = "FR Bear"}, -- Black Ash Robe [19400] = {boss = 615, slot = 8, xtype = 1, account = 2, cost = 120, note = "Shadow"}, -- Firemaw's Clutch [19365] = {boss = 615, slot = 14, xtype = 11, account = 2, cost = 120, note = "Fury, Rogue"}, -- Claw of the Black Drake [19398] = {boss = 615, slot = 4, xtype = 0, account = 2, cost = 160, note = "Melee > Hunter"}, -- Cloak of Firemaw [19402] = {boss = 615, slot = 9, xtype = 4, account = 2, cost = 160, note = "Tank > DPS"}, -- Legguards of the Fallen Crusader [19401] = {boss = 615, slot = 9, xtype = 3, account = 2, cost = 80, note = "Shaman"}, -- Primalist's Linked Legguards -- Ebonroc: [19403] = {boss = 614, slot = 11, xtype = 0, account = 2, cost = 200, note = "Mage, WL"}, -- Band of Forced Concentration [19406] = {boss = 614, slot = 12, xtype = 0, account = 2, cost = 400, note = "Tank, Melee"}, -- Drake Fang Talisman [19407] = {boss = 614, slot = 7, xtype = 1, account = 2, cost = 120, note = "Shadow, WL"}, -- Ebony Flame Gloves [19405] = {boss = 614, slot = 5, xtype = 2, account = 2, cost = 120, note = "Bear"}, -- Malfurion's Blessed Bulwark [19368] = {boss = 614, slot = 17, xtype = 14, account = 2, cost = 80, note = "Tank first"}, -- Dragonbreath Hand Cannon -- Flamegore: [19430] = {boss = 613, slot = 4, xtype = 0, account = 2, cost = 160, note = "Heal"}, -- Shroud of Pure Thought [19432] = {boss = 613, slot = 11, xtype = 0, account = 2, cost = 120, note = "Tank/Bear first"}, -- Circle of Applied Force [19433] = {boss = 613, slot = 9, xtype = 3, account = 2, cost = 80, note = "Tank"}, -- Emberweave Leggings [19431] = {boss = 613, slot = 12, xtype = 0, account = 2, cost = 120, note = "Tank"}, -- Styleen's Impeding Scarab [19367] = {boss = 613, slot = 17, xtype = 15, account = 2, cost = 120, note = "Caster"}, -- Dragon's Touch [19357] = {boss = 613, slot = 16, xtype = 8, account = 2, cost = 20, note = "Paladin, PvP"}, -- Herald of Woe -- Chromaggus: [19388] = {boss = 616, slot = 8, xtype = 1, account = 2, cost = 200, note = "WL, Moonkin"}, -- Angelista's Grasp [19389] = {boss = 616, slot = 3, xtype = 2, account = 2, cost = 80, note = "Rogue, Feral"}, -- Taut Dragonhide Shoulderpads [19387] = {boss = 616, slot = 10, xtype = 4, account = 2, cost = 280, note = "Warrior"}, -- Chromatic Boots [19390] = {boss = 616, slot = 7, xtype = 2, account = 2, cost = 80, note = "Whatever"}, -- Taut Dragonhide Gloves [19391] = {boss = 616, slot = 10, xtype = 1, account = 2, cost = 20, note = "Whatever"}, -- Shimmering Geta [19386] = {boss = 616, slot = 4, xtype = 0, account = 2, cost = 80, note = "Tank, Feral"}, -- Elementium Threaded Cloak [19392] = {boss = 616, slot = 8, xtype = 4, account = 2, cost = 20, note = "Paladin"}, -- Girdle of the Fallen Crusader [19385] = {boss = 616, slot = 9, xtype = 1, account = 2, cost = 200, note = "Heal"}, -- Empowered Leggings [19352] = {boss = 616, slot = 13, xtype = 6, account = 2, cost = 280, note = "Warrior, Rogue, only Human/Edgemaster"}, -- Chromatically Tempered Sword [19393] = {boss = 616, slot = 8, xtype = 3, account = 2, cost = 20, note = "Shaman"}, -- Primalist's Linked Waistguard [19347] = {boss = 616, slot = 13, xtype = 5, account = 2, cost = 280, note = "Caster"}, -- Claw of Chromaggus [19361] = {boss = 616, slot = 17, xtype = 13, account = 2, cost = 80, note = "Hunter"}, -- Ashjre'thul, Crossbow of Smiting [19349] = {boss = 616, slot = 15, xtype = 17, account = 2, cost = 120, note = "Tank, Off-Tank"}, -- Elementium Reinforced Bulwark -- Nefarian: [19003] = {boss = 617, slot = 0, xtype = 0, account = 2, cost = 160, note = "Melee/Hunter Ring"}, -- Head of Nefarian [19378] = {boss = 617, slot = 4, xtype = 0, account = 2, cost = 200, note = "Shadow/Caster"}, -- Cloak of the Brood Lord [19381] = {boss = 617, slot = 10, xtype = 2, account = 2, cost = 200, note = "Bear > Rogue"}, -- Boots of the Shadow Flame [19380] = {boss = 617, slot = 8, xtype = 3, account = 2, cost = 120, note = "Whatever"}, -- Therazane's Link [19376] = {boss = 617, slot = 11, xtype = 0, account = 2, cost = 80, note = "Tank, Feral > PvP"}, -- Archimtiros' Ring of Reckoning [19382] = {boss = 617, slot = 11, xtype = 0, account = 2, cost = 400, note = "Heal"}, -- Pure Elementium Band [19379] = {boss = 617, slot = 12, xtype = 0, account = 2, cost = 400, note = "Mage, WL, Shadow"}, -- Neltharion's Tear [19375] = {boss = 617, slot = 1, xtype = 1, account = 2, cost = 280, note = "Mage, WL > Heal-Paladin"}, -- Mish'undare, Circlet of the Mind Flayer [19377] = {boss = 617, slot = 2, xtype = 0, account = 2, cost = 200, note = "Hunter > Rogue, Feral"}, -- Prestor's Talisman of Connivery [19356] = {boss = 617, slot = 16, xtype = 10, account = 2, cost = 400, note = "Mage, WL"}, -- Staff of the Shadow Flame [19364] = {boss = 617, slot = 16, xtype = 6, account = 2, cost = 400, note = "Warrior > Hunter"}, -- Ashkandi, Greatsword of the Brotherhood [19363] = {boss = 617, slot = 13, xtype = 7, account = 2, cost = 280, note = "Tank, Fury"}, -- Crul'shorukh, Edge of Chaos [19360] = {boss = 617, slot = 14, xtype = 8, account = 2, cost = 400, note = "Paladin, Druid > Priest"}, -- Lok'amir il Romathis -- Trash: [19436] = {boss = 1, slot = 4, xtype = 0, account = 2, cost = 120, note = "Fury > Tank"}, -- Cloak of Draconic Might [19439] = {boss = 1, slot = 5, xtype = 2, account = 2, cost = 20, note = "Druid In-Between-Item"}, -- Interlaced Shadow Jerkin [19437] = {boss = 1, slot = 10, xtype = 1, account = 2, cost = 200, note = "BiS Heal"}, -- Boots of Pure Thought [19438] = {boss = 1, slot = 10, xtype = 1, account = 2, cost = 120, note = "Mage"}, -- Ringo's Blizzard Boots [19434] = {boss = 1, slot = 11, xtype = 0, account = 2, cost = 120, note = "Shadow, WL"}, -- Band of Dark Dominion [19435] = {boss = 1, slot = 17, xtype = 15, account = 2, cost = 80, note = "Priest"}, -- Essence Gatherer [19362] = {boss = 1, slot = 13, xtype = 7, account = 2, cost = 160, note = "Tank > DPS, no Humans"}, -- Doom's Edge [19354] = {boss = 1, slot = 16, xtype = 7, account = 2, cost = 20, note = "Crap, maybe Hunter"}, -- Draconic Avenger [19358] = {boss = 1, slot = 16, xtype = 8, account = 2, cost = 200, note = "Feral"}, -- Draconic Maul } ------------------------------------------------------------ -- export items ADDON.InitGroup.Items = ADDON.InitGroup.Items or {} for k,v in pairs(items) do ADDON.InitGroup.Items[k] = v end items = nil
-- Copyright 2017-2019 Xingwang Liao <kuoruan@gmail.com> -- Licensed to the public under the MIT License. local m, s, o local fs = require "nixio.fs" local util = require "luci.util" local uci = require "luci.model.uci".cursor() local config_dir = uci:get("aria2", "main", "config_dir") or "/var/etc/aria2" local config_file = "%s/aria2.conf.main" % config_dir local session_file = "%s/aria2.session.main" % config_dir m = SimpleForm("aria2", "%s - %s" % { translate("Aria2"), translate("Files") }, translate("Here shows the files used by aria2.")) m.reset = false m.submit = false s = m:section(SimpleSection, nil, translatef("Content of config file: <code>%s</code>", config_file)) o = s:option(TextValue, "_config") o.rows = 20 o.readonly = true o.cfgvalue = function() local v = fs.readfile(config_file) or translate("File does not exist.") return util.trim(v) ~= "" and v or translate("Empty file.") end s = m:section(SimpleSection, nil, translatef("Content of session file: <code>%s</code>", session_file)) o = s:option(TextValue, "_session") o.rows = 20 o.readonly = true o.cfgvalue = function() local v = fs.readfile(session_file) or translate("File does not exist.") return util.trim(v) ~= "" and v or translate("Empty file.") end return m
local Class = require("CoreLib.SimpleLuaClasses.Class") local Delaunay = require("Utils.Delaunay") local AsteroidSet = Class() function AsteroidSet:init(asteroidConfig) self.config = asteroidConfig or { numPoints = 6, numInSet = 5, minVariance = -0.25, maxVariance = 0.25, arrangements = { radius = 1 } } self.asteroids = {} end function AsteroidSet:Generate() local config = self.config local arrangement = config.arrangements self.asteroids = {} --generate set of random asteroids to generate models from for aIndex=1, self.config.numInSet, 1 do local asteroid = {} local points = {} --generate random points for an asteroid starting in a circle arrangement local radius = arrangement.radius local angleInc = 360 / self.config.numPoints for pIndex=1, self.config.numPoints, 1 do local vec = Vector3() vec.x = Cos(pIndex*(angleInc))*radius+Random(config.minVariance, config.maxVariance) vec.y = Sin(pIndex*(angleInc))*radius+Random(config.minVariance, config.maxVariance) table.insert(points, vec) end asteroid.data = Delaunay(points, config.minVariance-radius, config.maxVariance+radius) table.insert(self.asteroids, asteroid) end local vertexData = {} local lastVertex = 1 local indexData = {} local lastIndex = 1 local currentIndex = 0 for aIndex, asteroid in ipairs(self.asteroids) do local data = asteroid.data local boundingBox = BoundingBox() local firstIndex = currentIndex --print("firstIndex: "..firstIndex) for vIndex, vertex in ipairs(data.vertices) do boundingBox:Merge(vertex) -- position vertexData[lastVertex] = vertex.x vertexData[lastVertex+1] = vertex.y vertexData[lastVertex+2] = vertex.z -- normal vertexData[lastVertex+3] = Random(-0.5, 0) vertexData[lastVertex+4] = Random(-0.5, 0) vertexData[lastVertex+5] = -1 -- texcoord vertexData[lastVertex+6] = vertex.x vertexData[lastVertex+7] = vertex.y lastVertex = lastVertex + 8 currentIndex = currentIndex + 1 end asteroid.boundingBox = boundingBox asteroid.startIndex = lastIndex-1 --firstIndex asteroid.shards = {} for tIndex, tri in ipairs(data.triangles) do local shardBounds = BoundingBox() local crumbs = {} shardBounds:Merge(tri.a) shardBounds:Merge(tri.b) shardBounds:Merge(tri.c) table.insert(asteroid.shards, { startIndex = lastIndex-1, boundingBox = shardBounds, a = tri.a, b = tri.b, c = tri.c, crumbs = crumbs }) indexData[lastIndex] = firstIndex+tri.ai-1 indexData[lastIndex+1] = firstIndex+tri.bi-1 indexData[lastIndex+2] = firstIndex+tri.ci-1 lastIndex = lastIndex + 3 end asteroid.indexCount = lastIndex-asteroid.startIndex print("startIndex: "..asteroid.startIndex..", indexCount: "..asteroid.indexCount) end local numVertices = lastVertex --#meshData.vertices local numIndexes = lastIndex -- #indexData --print("numVertices: "..numVertices) --print("numIndexes: "..numIndexes) --print("lastVertex: "..lastVertex) self.vBuffer = VertexBuffer:new() self.iBuffer = IndexBuffer:new() -- Shadowed buffer needed for raycasts to work, and so that data can be automatically restored on device loss self.vBuffer.shadowed = true -- We could use the "legacy" element bitmask to define elements for more compact code, but let's demonstrate -- defining the vertex elements explicitly to allow any element types and order local elements = { VertexElement(TYPE_VECTOR3, SEM_POSITION), VertexElement(TYPE_VECTOR3, SEM_NORMAL), VertexElement(TYPE_VECTOR2, SEM_TEXCOORD) } self.vBuffer:SetSize(numVertices, elements) local temp = VectorBuffer() for i = 1, numVertices * 8 do temp:WriteFloat(vertexData[i]) end self.vBuffer:SetData(temp) self.iBuffer.shadowed = true self.iBuffer:SetSize(numIndexes, false) temp:Clear() for i = 1, numIndexes do temp:WriteUShort(indexData[i]) end self.iBuffer:SetData(temp) end function AsteroidSet:GetAsteroidData(asteroidIndex) return self.asteroids[asteroidIndex] end function AsteroidSet:GetShardData(asteroidIndex, shardIndex) return self.asteroids[asteroidIndex].shards[shardIndex] end function AsteroidSet:GetCrumbData(asteroidIndex, shardIndex, crumbIndex) return self.asteroids[asteroidIndex].shards[shardIndex].crumbs[crumbIndex] end function AsteroidSet:GetRandomIndex() return RandomInt(1, #self.asteroids) end function AsteroidSet:GetWholeModel(asteroidIndex) local asteroid = self.asteroids[asteroidIndex] --if asteroid.model == nil then -- Create model, buffers and geometry without garbage collection, as they will be managed -- by the StaticModel component once assigned to it asteroid.model = Model:new() local geom = Geometry:new() geom:SetVertexBuffer(0, self.vBuffer) geom:SetIndexBuffer(self.iBuffer) geom:SetDrawRange(TRIANGLE_LIST, asteroid.startIndex, asteroid.indexCount) asteroid.model.numGeometries = 1 asteroid.model:SetGeometry(0, 0, geom) asteroid.model.boundingBox = asteroid.boundingBox -- Though not necessary to render, the vertex & index buffers must be listed in the model so that it can be saved properly local vertexBuffers = {} local indexBuffers = {} table.insert(vertexBuffers, self.vBuffer) table.insert(indexBuffers, self.iBuffer) -- Morph ranges could also be not defined. Here we simply define a zero range (no morphing) for the vertex buffer local morphRangeStarts = {} local morphRangeCounts = {} table.insert(morphRangeStarts, 0) table.insert(morphRangeCounts, 0) asteroid.model:SetVertexBuffers(vertexBuffers, morphRangeStarts, morphRangeCounts) asteroid.model:SetIndexBuffers(indexBuffers) --end return asteroid.model end function AsteroidSet:GetShardModel(asteroidIndex, shardIndex) local asteroid = self.asteroids[asteroidIndex] local shard = asteroid.shards[shardIndex] --if shard.model == nil then -- Create model, buffers and geometry without garbage collection, as they will be managed -- by the StaticModel component once assigned to it shard.model = Model:new() local geom = Geometry:new() geom:SetVertexBuffer(0, self.vBuffer) geom:SetIndexBuffer(self.iBuffer) geom:SetDrawRange(TRIANGLE_LIST, shard.startIndex, 3) shard.model.numGeometries = 1 shard.model:SetGeometry(0, 0, geom) shard.model.boundingBox = shard.boundingBox -- Though not necessary to render, the vertex & index buffers must be listed in the model so that it can be saved properly local vertexBuffers = {} local indexBuffers = {} table.insert(vertexBuffers, self.vBuffer) table.insert(indexBuffers, self.iBuffer) -- Morph ranges could also be not defined. Here we simply define a zero range (no morphing) for the vertex buffer local morphRangeStarts = {} local morphRangeCounts = {} table.insert(morphRangeStarts, 0) table.insert(morphRangeCounts, 0) shard.model:SetVertexBuffers(vertexBuffers, morphRangeStarts, morphRangeCounts) shard.model:SetIndexBuffers(indexBuffers) --end return shard.model end function AsteroidSet:GetCrumbModel(asteroidIndex, shardIndex, crumbIndex) local asteroid = self.asteroids[asteroidIndex] local shard = asteroid.shards[shardIndex] local crumb = shard.crumbs[crumbIndex] if crumb.model == nil then -- Create model, buffers and geometry without garbage collection, as they will be managed -- by the StaticModel component once assigned to it crumb.model = Model:new() local geom = Geometry:new() geom:SetVertexBuffer(0, self.vBuffer) geom:SetIndexBuffer(self.iBuffer) geom:SetDrawRange(TRIANGLE_LIST, crumb.startIndex, 3) crumb.model.numGeometries = 1 crumb.model:SetGeometry(0, 0, geom) crumb.model.boundingBox = crumb.boundingBox -- Though not necessary to render, the vertex & index buffers must be listed in the model so that it can be saved properly local vertexBuffers = {} local indexBuffers = {} table.insert(vertexBuffers, self.vBuffer) table.insert(indexBuffers, self.iBuffer) -- Morph ranges could also be not defined. Here we simply define a zero range (no morphing) for the vertex buffer local morphRangeStarts = {} local morphRangeCounts = {} table.insert(morphRangeStarts, 0) table.insert(morphRangeCounts, 0) crumb.model:SetVertexBuffers(vertexBuffers, morphRangeStarts, morphRangeCounts) crumb.model:SetIndexBuffers(indexBuffers) end return crumb.model end return AsteroidSet
--- --- Generated by EmmyLua(https://github.com/EmmyLua) --- Created by Administrator. --- DateTime: 2018/6/14 21:41 --- require("Core.class") function pTable(Lua_table) -- do -- return -- end local function define_print(_tab,str) str = str .. " " for k,v in pairs(_tab) do if type(v) == "table" then if not tonumber(k) then print(str.. k .."{") else print(str .."{") end define_print(v,str) print( str.."}") else print(str .. tostring(k) .. " " .. tostring(v)) end end end if type(Lua_table) == "table" then define_print(Lua_table," ") else print(tostring(Lua_table)) end end local ThreeEliminateScene = require("Game.ThreeEliminate.ThreeEliminateScene") local fgui = require("FGUI.FairyGUI") local YK = require("Core.YK") local Main = {} function Main.Main() print("开始") fgui.Init() YK.Init() --fgui.GRoot.inst:SetContentScaleFactor(1242, 2208) YK.YKSupportLua.GotoScene("Test",nil,ThreeEliminateScene) end function Main.OnDestroy() end function Main.OnShowExit() end return Main
------------------------------------------------------------------------------- -- Mob Framework Mod by Sapier -- -- You may copy, use, modify or do nearly anything except removing this -- copyright notice. -- And of course you are NOT allowed to pretend you have written it. -- --! @file generic_functions.lua --! @brief generic functions used in many different places --! @copyright Sapier --! @author Sapier --! @date 2012-08-09 --! -- Contact sapier a t gmx net ------------------------------------------------------------------------------- --! @defgroup gen_func Generic functions --! @brief functions for various tasks --! @ingroup framework_int --! @{ ------------------------------------------------------------------------------- -- name: mobf_get_time_ms() -- --! @brief get current time in ms -- --! @return current time in ms ------------------------------------------------------------------------------- function mobf_get_time_ms() --this fct is overwritten on init with best timesource available atm return os.clock() * 1000 end ------------------------------------------------------------------------------- -- name: mobf_contains(cur_table,element) -- --! @brief check if element is in table -- --! @param cur_table table to look in --! @param element element to look for --! @return true/false ------------------------------------------------------------------------------- function mobf_contains(cur_table,element) if cur_table == nil then return false end for i,v in ipairs(cur_table) do if v == element then return true end end return false end ------------------------------------------------------------------------------- -- name: MIN(a,b) -- --! @brief minimum of two numbers -- --! @param a number 1 --! @param b number 2 --! @return minimum ------------------------------------------------------------------------------- function MIN(a,b) mobf_assert_backtrace(type(a) == "number") mobf_assert_backtrace(type(b) == "number") if a > b then return b else return a end end ------------------------------------------------------------------------------- -- name: MAX(a,b) -- --! @brief maximum of two numbers -- --! @param a number 1 --! @param b number 2 --! @return maximum ------------------------------------------------------------------------------- function MAX(a,b) mobf_assert_backtrace(type(a) == "number") mobf_assert_backtrace(type(b) == "number") if a > b then return a else return b end end ------------------------------------------------------------------------------- -- name: DELTA(a,b) -- --! @brief delta of two numbers -- --! @param a number 1 --! @param b number 2 --! @return delta ------------------------------------------------------------------------------- function DELTA(a,b) return math.abs(a-b) end ------------------------------------------------------------------------------- -- name: mobf_is_walkable(node) -- --! @brief check if walkable flag is set for a node -- --! @param node to check --! @return true/false ------------------------------------------------------------------------------- function mobf_is_walkable(node) return (node and node.name and minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].walkable == false) end ------------------------------------------------------------------------------- -- name: mobf_get_current_time() -- --! @brief alias to get current time -- --! @return current time in seconds ------------------------------------------------------------------------------- function mobf_get_current_time() if type(minetest.get_time) == "function" then return minetest.get_time() else return os.time(os.date('*t')) end end ------------------------------------------------------------------------------- -- name: mobf_round_pos(pos) -- --! @brief calculate integer position -- --! @param pos position to be rounded --! @return rounded position ------------------------------------------------------------------------------- function mobf_round_pos(pos) if pos == nil then return pos end return { x=math.floor(pos.x + 0.5), y=math.floor(pos.y + 0.5), z=math.floor(pos.z + 0.5) } end ------------------------------------------------------------------------------- -- name: mobf_find_entity(newobject) DEPRECATED -- --! @brief find entity by object reference -- --! @param newobject r object reference --! @return entity object reference points at or nil on error ------------------------------------------------------------------------------- function mobf_find_entity(newobject) return newobject:get_luaentity() end ------------------------------------------------------------------------------- -- name: mobf_max_light_around(pos,range,daytime) -- --! @brief get maximum light level around specified position -- --! @param pos center of area to search --! @param distance radius of area --! @param daytime time of day to check --! @return highest detected light level ------------------------------------------------------------------------------- function mobf_max_light_around(pos,distance,daytime) mobf_assert_validpos(pos) local max_light = 0 for y_run=pos.y-distance,pos.y+distance,1 do for z_run=pos.z-distance,pos.z+distance,1 do for x_run=pos.x-distance,pos.x+distance,1 do local current_pos = {x=x_run,y=y_run,z=z_run } local node = minetest.get_node(current_pos) if node.name == "air" then local current_light = minetest.get_node_light(current_pos,daytime) if current_light > max_light then max_light = current_light end end end end end return max_light end ------------------------------------------------------------------------------- -- name: mobf_min_light_around(pos,range,daytime) -- --! @brief get minimum light level around specified position -- --! @param pos center of area to search --! @param distance radius of area --! @param daytime time of day to check --! @return highest detected light level ------------------------------------------------------------------------------- function mobf_min_light_around(pos,distance,daytime) mobf_assert_validpos(pos) local min_light = LIGHT_MAX+1 for y_run=pos.y-distance,pos.y+distance,1 do for z_run=pos.z-distance,pos.z+distance,1 do for x_run=pos.x-distance,pos.x+distance,1 do local current_pos = {x=x_run,y=y_run,z=z_run } local node = minetest.get_node(current_pos) if node.name == "air" then local current_light = minetest.get_node_light(current_pos,daytime) if current_light < min_light then min_light = current_light end end end end end return min_light end ------------------------------------------------------------------------------- -- name: mobf_objects_around(pos,range,ignorelist) -- --! @brief get number of objects within a certain range -- --! @param pos position to look around --! @param range range to check --! @param ignorelist list of entitynames to ignore --! @return count of objects ------------------------------------------------------------------------------- function mobf_objects_around(pos,range,ignorelist) local objectlist = minetest.get_objects_inside_radius(pos,range) local cleaned_objectcount = 0 for i=1,#objectlist,1 do local luaentity = objectlist[i]:get_luaentity() if luaentity ~= nil then if not luaentity.mobf_spawner and not mobf_contains(ignorelist,luaentity.name) then cleaned_objectcount = cleaned_objectcount + 1 end else cleaned_objectcount = cleaned_objectcount + 1 end end return cleaned_objectcount end ------------------------------------------------------------------------------- -- name: mobf_mob_around(mob_name,mob_transform_name,pos,range,) -- --! @brief get number of mobs of specified type within range of pos -- --! @param mob_name basic name of mob --! @param mob_transform secondary name of mob --! @param pos position to check --! @param range range to check --! @param ignore_playerspawned ignore mob spawned by players for check --! @return number of mob found ------------------------------------------------------------------------------- function mobf_mob_around(mob_name,mob_transform,pos,range,ignore_playerspawned) local count = 0 local objectcount = 0 mobf_assert_backtrace(range ~= nil) mobf_assert_backtrace(pos ~= nil) local objectlist = minetest.get_objects_inside_radius(pos,range) if mob_transform == nil then mob_transform = "" end local objcount = 0 if objectlist ~= nil then objcount = #objectlist end dbg_mobf.generic_lvl1("MOBF: entity at "..printpos(pos).. " looking for: "..mob_name .. " or " .. mob_transform .. " within " .. objcount .. " objects" ) for index,value in pairs(objectlist) do local entity = mobf_find_entity(value) --any mob is required to have a name so we may use this to decide --if an entity is an mob or not if entity ~= nil and entity.data ~= nil and entity.dynamic_data ~= nil then if entity.removed == false then if entity.data.modname..":"..entity.data.name == mob_name or entity.data.modname..":"..entity.data.name == mob_transform then -- oops we don't yet know if this is playerspawned, -- for performance reasons assume it isn't if entity.dynamic_data.spawning == nil then count = count + 1 else if (ignore_playerspawned and entity.dynamic_data.spawning.player_spawned) or ignore_playerspawned ~= false then dbg_mobf.generic_lvl1("MOBF: Found "..mob_name.. " or " ..mob_transform .. " within specified range of "..range) count = count + 1 end end end end end objectcount = objectcount +1 end dbg_mobf.generic_lvl2("MOBF: found " .. objectcount .. " within range " .. count .. " of them are relevant mobs ") return count end ------------------------------------------------------------------------------- -- name: mobf_spawner_around(mob_name,pos,range) -- --! @brief get number of mobs of specified type within range of pos -- --! @param mob_name basic name of mob --! @param pos position to check --! @param range range to check --! @return number of mob found ------------------------------------------------------------------------------- function mobf_spawner_around(mob_name,pos,range) mobf_assert_validpos(pos) dbg_mobf.generic_lvl2("MOBF: mobf_spawner_around param: ".. dump(mob_name) .. " "..dump(pos).. " " .. dump(range)) local count = 0 local objectcount = 0 local objectlist = minetest.get_objects_inside_radius(pos,range) for index,value in pairs(objectlist) do local entity = value:get_luaentity() dbg_mobf.generic_lvl3("MOBF: entity at: "..dump(value:getpos()).. " looking for: "..mob_name .. " " .. dump(value) .. " " .. dump(entity)) --any mob is required to have a name so we may use this to decide --if an entity is an mob or not if entity ~= nil and entity.spawner_mob_name ~= nil then if entity.spawner_mob_name == mob_name then dbg_mobf.generic_lvl2("MOBF: Found "..mob_name .. " within specified range of "..range) count = count + 1 end end objectcount = objectcount +1 end dbg_mobf.generic_lvl2("MOBF: found " .. objectcount .. " within range " .. count .. " of them are relevant spawners ") return count end ------------------------------------------------------------------------------- -- name: mobf_line_of_sight(pos1,pos2) -- --! @brief is there a line of sight between two specified positions -- --! @param pos1 start position of los check --! @param pos2 end position of los check --! @return: true/false ------------------------------------------------------------------------------- function mobf_line_of_sight(pos1,pos2) --print("Checking line of sight between "..printpos(pos1).." and "..printpos(pos2)) local distance = mobf_calc_distance(pos1,pos2) local normalized_vector = { x=(pos2.x-pos1.x)/distance, y=(pos2.y-pos1.y)/distance, z=(pos2.z-pos1.z)/distance} local line_of_sight = true for i=1,distance, 1 do local tocheck = { x=pos1.x + (normalized_vector.x * i), y=pos1.y + (normalized_vector.y *i), z=pos1.z + (normalized_vector.z *i)} local node = minetest.get_node(tocheck) if minetest.registered_nodes[node.name] == nil or minetest.registered_nodes[node.name].sunlight_propagates ~= true then line_of_sight = false break end end return line_of_sight end function mobf_line_of_sightX(pos1,pos2) return minetest.line_of_sight(pos1,pos2) end ------------------------------------------------------------------------------- -- name: mobf_pos_is_zero(pos) -- --! @brief check if position is (0,0,0) -- --! @param pos position to check --! @return true/false ------------------------------------------------------------------------------- function mobf_pos_is_zero(pos) if pos.x ~= 0 then return false end if pos.y ~= 0 then return false end if pos.z ~= 0 then return false end return true end ------------------------------------------------------------------------------- -- name: mobf_air_above(pos,height) -- --! @brief check if theres at least height air abov pos -- --! @param pos position to check --! @param height min number of air to check --! @return true/false ------------------------------------------------------------------------------- function mobf_air_above(pos,height) mobf_assert_validpos(pos) for i=0, height, 1 do local pos_above = { x = pos.x, y = pos.y + 1, z = pos.z } local node_above = minetest.get_node(pos_above) if node_above.name ~= "air" then return false end end return true end ------------------------------------------------------------------------------- -- name: mobf_ground_distance(pos,media) -- --! @brief get number of blocks above solid ground -- --! @param pos_raw position to check --! @param media table of blocks not considered to be ground --! @param max_check_height abort looking for ground after this number of nodes -- --! @return number of blocks to ground ------------------------------------------------------------------------------- function mobf_ground_distance(pos_raw,media,max_check_height) local pos = { x=pos_raw.x, y=math.floor(pos_raw.y + 0.5), z=pos_raw.z } local node_to_check = minetest.get_node(pos) local count = 0 if max_check_height == nil then max_check_height = 32 end while node_to_check ~= nil and mobf_contains(media,node_to_check.name) and count < max_check_height do count = count +1 pos = {x=pos.x,y=pos.y-1,z=pos.z}; node_to_check = minetest.get_node(pos) end return count end ------------------------------------------------------------------------------- -- name: mobf_surface_distance(pos) -- --! @brief get number of blocks above surface (solid or fluid!) -- --! @param pos position to check --! @return number of blocks to ground ------------------------------------------------------------------------------- function mobf_surface_distance(pos) local node_to_check = minetest.get_node(pos) local count = 0 while node_to_check ~= nil and node_to_check.name == "air" and count < 32 do count = count +1 pos = {x=pos.x,y=pos.y-1,z=pos.z}; node_to_check = minetest.get_node(pos) end return count end ------------------------------------------------------------------------------- -- name: mobf_air_distance(pos) -- --! @brief get number of blocks below waterline -- --! @param pos position to check --! @return number of blocks to air ------------------------------------------------------------------------------- function mobf_air_distance(pos) mobf_assert_validpos(pos) local node_to_check = minetest.get_node(pos) local count = 0 while node_to_check ~= nil and ( node_to_check.name == "default:water_source" or node_to_check.name == "default:water_flowing") do count = count +1 pos = {x=pos.x,y=pos.y+1,z=pos.z}; node_to_check = minetest.get_node(pos) end if node_to_check.name == "air" then return count else return -1 end end ------------------------------------------------------------------------------- -- name: mobf_above_water(pos) -- --! @brief check if next non-air block below mob is a water block -- --! @param pos position to check --! @return true/false ------------------------------------------------------------------------------- function mobf_above_water(pos) local node_to_check = minetest.get_node(pos) while node_to_check ~= nil and node_to_check.name == "air" do pos = {x=pos.x,y=pos.y-1,z=pos.z}; node_to_check = minetest.get_node(pos) end if node_to_check.name == "default:water_source" or node_to_check.name == "default:water_flowing" then return true end return false end ------------------------------------------------------------------------------- -- name: get_sunlight_surface(x,z, min_y, max_y) -- --! @brief get surface for x/z coordinates -- --! @param x x-coordinate --! @param z z-coordinate --! @param min_y minimum y-coordinate to consider --! @param max_y maximum y-coordinate to consider --! @return y value of surface or nil ------------------------------------------------------------------------------- function mobf_get_sunlight_surface(x,z, min_y, max_y) for runy = min_y, max_y,1 do local pos = { x=x,y=runy, z=z } local node_to_check = minetest.get_node(pos) if node_to_check.name == "default:dirt_with_grass" then return pos.y end end return nil end ------------------------------------------------------------------------------- -- name: get_surface(x,z, min_y, max_y) -- --! @brief get surface for x/z coordinates -- --! @param x x-coordinate --! @param z z-coordinate --! @param min_y minimum y-coordinate to consider --! @param max_y maximum y-coordinate to consider --! @return y value of surface (first air node) or nil ------------------------------------------------------------------------------- function mobf_get_surface(x,z, min_y, max_y) mobf_assert_backtrace(min_y ~= nil) mobf_assert_backtrace(max_y ~= nil) mobf_assert_backtrace(x ~= nil) mobf_assert_backtrace(z ~= nil) if type(minetest.get_surface) == "function" then local basepos = {x=x,y=min_y,z=z} local offset = max_y-min_y local retval = minetest.get_surface(basepos,offset) return retval end local last_node = minetest.get_node({ x=x,y=min_y, z=z }) for runy = min_y+1, max_y,1 do local pos = { x=x,y=runy, z=z } local node_to_check = minetest.get_node(pos) if node_to_check.name == "air" and last_node.name ~= "air" and last_node.mame ~= "ignore" then return pos.y end last_node = node_to_check end return nil end ------------------------------------------------------------------------------- -- name: entity_at_loaded_pos(entity.mobname) -- --! @brief check if entity is activated at already loaded pos -- --! @param pos to check --! @param mobname name of mob --! @return true/false ------------------------------------------------------------------------------- function entity_at_loaded_pos(pos,mobname) local current_node = minetest.get_node(pos) if mobname == nil then mobname = "" end if current_node ~= nil then if current_node.name == "ignore" then minetest.log(LOGLEVEL_WARNING,"MOBF: " ..mobname .. " spawned at unloaded pos! : " .. dump(pos) .. " node: " .. dump(current_node)) return false else return true end end minetest.log(LOGLEVEL_WARNING,"MOBF: spawned at invalid pos!") return false end ------------------------------------------------------------------------------- -- name: mobf_random_direction() -- --! @brief get a random (blocked) 3d direction -- --! @return 3d dir value ------------------------------------------------------------------------------- function mobf_random_direction() local retval = {} retval.x=math.random(-1,1) retval.y=math.random(-1,1) retval.z=math.random(-1,1) return retval end ------------------------------------------------------------------------------- -- name: mobf_pos_is_same(pos1,pos2) -- --! @brief check if two positions are equal -- --! @param pos1 --! @param pos2 -- --! @return true/false ------------------------------------------------------------------------------- function mobf_pos_is_same(pos1,pos2) if pos1 == nil or pos2 == nil then return false end if pos1.x ~= pos2.x or pos1.y ~= pos2.y or pos1.z ~= pos2.z or pos1.x == nil or pos1.y == nil or pos1.z == nil or pos2.x == nil or pos2.y == nil or pos2.z == nil then return false end return true end ------------------------------------------------------------------------------- -- name: mobf_is_pos(value) -- --! @brief check if a given value is a position -- --! @param value to check -- --! @return true/false ------------------------------------------------------------------------------- function mobf_is_pos(value) if value == nil or type(value) ~= "table" then return false end if value.x == nil or tonumber(value.x) == nil then return false end if value.y == nil or tonumber(value.y) == nil then return false end if value.z == nil or tonumber(value.z) == nil then return false end return true end ------------------------------------------------------------------------------- -- name: mobf_hash_to_pos(hash) -- --! @brief restore a position from a pos hash value -- --! @param hash to restore pos from -- --! @return posistion reconstructed from hash ------------------------------------------------------------------------------- function mobf_hash_to_pos(hash) local retval = {} local raw_x = (hash % 65536) local raw_y = ((hash - raw_x) % (65536*65536)) / 65536 local raw_z = ((hash - raw_x - raw_y) / 65536) / 65536 local mobpos = {} retval.x = raw_x - 32768 retval.y = raw_y - 32768 retval.z = math.floor(raw_z - 32768) return retval end --!@}
app_config = { ssid ="",passwd = "", ip={192,168,0,9}, bc_port=1999, data_port=2012, baud=115200, dhcp=true, apmode=true, cast_delay = 3000 }
--[[ tp8_grass TODO: models/props_foliage/grass3.mdl models/props_foliage/grass_cluster01.mdl models/props_foliage/grass_cluster01a.mdl models/props_foliage/swamp_grass01.mdl models/props_foliage/swamp_grass_row01.mdl Flowers: models/props_foliage/potted_plant1_p1.mdl --dirt --CS:S models/props_foliage/potted_plant2.mdl --pot --CS:S models/props_foliage/potted_plant3.mdl --pot --CS:S Bushes: models/props_foliage/urban_bigplant01.mdl models/props_foliage/mall_bigleaves_plant01_medium.mdl models/props_foliage/mall_bigleaves_plant01.mdl HAS DIRT BALL! models/props_foliage/mall_big_plant01_dirt.mdl models/props_foliage/mall_bigleaves_plant03_dirt.mdl --make bigger? possible grass replacement? models/props_foliage/mall_grass_bush01_dirt.mdl ]] AddCSLuaFile() ENT.Type = "anim" ENT.Base = "tp8_tree" ENT.seedModel = "models/hunter/plates/plate.mdl" --ENT.models = { "models/props_foliage/mall_big_plant01_dirt.mdl", "models/props_foliage/mall_bigleaves_plant03_dirt.mdl", "models/props_foliage/mall_grass_bush01_dirt.mdl"} ENT.models = { "models/props_foliage/swamp_grass01.mdl", "models/props_foliage/swamp_grass_row01.mdl"} --ENT.meme = nil function ENT:Initialize() if CLIENT then return end GLOBAL_grass = GLOBAL_grass + 1 self:SetModel(self.seedModel) self:SetMaterial("models/alyx/hairbits") self.health = 25 self.isPlanted = false --self:PhysicsInitStandard() self:SetMoveType(0) self.numberOfFruitMax = 1 self.treeLevel = 0 --self.plantTime = math.random(10, 50) self.angle1 = math.random(-3,3) --pitch self.angle2 = math.random(-179,180) --yaw self.timer = 0 self.fruitLifeExpectancy = 1 self.longTimer = 0 self.lifeExpectancy = 10 self.kids = 0 self.maxKids = 20 self.growthTime = 1 + (GLOBAL_grass / GLOBAL_grass_max)*(60 + math.random(0,60)) self.minSize = 80 self.maxSize = 160 self.entName = "tp8_grass" -- if GLOBAL_grass <= 100 then -- self.growthTime = 1 + math.random(0,9) -- self.maxKids = 100 -- end self.heightOfTree = 5 --used these rather than local variables because not sure if local variables screw things up self.testVal = 0 self.randoPos = Vector(0,0,0) self.done = false self.xDelta = 0 self.yDelta = 0 self.zDelta = 0 self.randoArray = {} self.randoPosAr = {} self.newX = 0 self.newY = 0 self.newZ = 0 self.tr = nil --grass timer local timer_name = "grass_" .. self:EntIndex() timer.Create(timer_name,self.growthTime,0, function() if IsValid(self) then if self:IsOnFire() then self:Ignite(15, 100) self:Remove() end if !self.isPlanted then if self.timer == self.fruitLifeExpectancy then self:Remove() end self.timer = self.timer + 1 end if self.isPlanted && self.longTimer >= self.lifeExpectancy then self:Remove() elseif self.isPlanted then self.longTimer = self.longTimer + 1 end --try to autoplant, otherwise if it is planted, upgrayed if !self.isPlanted then --self:Upgrayed() self:lookForAValidPlantPositionAndSendSelfThere(self:GetPos()) elseif self.isPlanted && GLOBAL_grass < GLOBAL_grass_max then self:Upgrayed() end elseif !IsValid(self) then timer.Remove(timer_name) end end) end function ENT:Upgrayed() if self.treeLevel == 0 --[[&& self:OnGroundNotStupidEdition(self:GetPos())]] then --plant the seed self.isPlanted = true local coords = self:GetPos() local xPos = math.floor(coords.x / GLOBAL_divisionsXY) local yPos = math.floor(coords.y / GLOBAL_divisionsXY) local zPos = math.floor(coords.z / GLOBAL_divisionsZ) GLOBAL_grassGrid[xPos][yPos][zPos] = GLOBAL_grassGrid[xPos][yPos][zPos] - 1 self:SetModel(self.models[math.random(#self.models)]) self:SetModelScale( 0.01, 0) --make the model really small to start self:SetMaterial() --should set the material to the model's material --rotate the thing to be upwards self:SetAngles( Angle(self.angle1,self.angle2,0)) self.treeLevel = self.treeLevel + 1 --1 --start scaling self:SetModelScale( math.random(self.minSize,self.maxSize)/100, self.growthTime) --grow the model over self.growthTime time. COOL! elseif self.treeLevel == 1 && self.longTimer < 0.75*self.lifeExpectancy then --rebroduce for i = 1,math.random(1,self.numberOfFruitMax) do newFruit = ents.Create(self.entName) if ( !IsValid( newFruit ) ) then return end newFruit:SetPos(self:GetPos() + Vector(math.random(-24,24),math.random(-24,24),self.heightOfTree)) newFruit:SetAngles(Angle(math.random(-5,5),math.random(-179,180),0)) newFruit:Spawn() self.kids = self.kids + 1 end if self.kids >= self.maxKids then self:Remove() end end end function ENT:lookForAValidPlantPositionAndSendSelfThere(coords) --follows the numpad order for i=1,27 do self.randoArray[i] = 0 self.randoPosAr[i] = Vector(0,0,0) end --get current tree pos in terms of self.globalForest local xPos = math.floor(coords.x / GLOBAL_divisionsXY) local yPos = math.floor(coords.y / GLOBAL_divisionsXY) local zPos = math.floor(coords.z / GLOBAL_divisionsZ) --check surrounding XY spots for > 0 value --can grow up/down on a slope this way... the tree would go above or below the height threshold local i = 1 for dx=-1,1 do for dy=-1,1 do for dz=-1,1 do if xPos+dx >= GLOBAL_grassXYMin && xPos+dx < GLOBAL_grassXYMax && yPos+dy >= GLOBAL_grassXYMin && yPos+dy < GLOBAL_grassXYMax && zPos+dz >= GLOBAL_grassZMin && zPos+dz < GLOBAL_grassZMax && GLOBAL_grassGrid[xPos+dx][yPos+dy][zPos+dz] > 0 && self:hasAValidPosition(dx,dy,dz, xPos, yPos, zPos) then self.randoArray[i] = 1 self.randoPosAr[i] = self.randoPos end i = i+1 end end end local containsAOne = false for i=1,27 do if (self.randoArray[i] == 1) then containsAOne = true end end --pick a random value in self.randoArray to pick the cube to plant the tree in if containsAOne then local valid = false self.testVal = 0 while !valid do self.testVal = math.random(27) if self.randoArray[self.testVal] == 1 then valid = true end end -- print("Direction going: "..self.testVal) local x = self.randoPosAr[self.testVal].x local y = self.randoPosAr[self.testVal].y local z = self.randoPosAr[self.testVal].z --plant self at the TRACE'S x, y, z self:SetPos(Vector(x, y, z)) self:Upgrayed() end end if SERVER then function ENT:OnRemove() GLOBAL_grass = GLOBAL_grass - 1 if (self.isPlanted) then local coords = self:GetPos() local xPos = math.floor(coords.x / GLOBAL_divisionsXY) local yPos = math.floor(coords.y / GLOBAL_divisionsXY) local zPos = math.floor(coords.z / GLOBAL_divisionsZ) GLOBAL_grassGrid[xPos][yPos][zPos] = GLOBAL_grassGrid[xPos][yPos][zPos] + 1 end end end
-- -- tests/base/test_tree.lua -- Automated test suite source code tree handling. -- Copyright (c) 2009-2012 Jason Perkins and the Premake project -- local suite = test.declare("base_tree") local tree = premake.tree -- -- Setup/teardown -- local tr function suite.setup() tr = tree.new() end local function prepare() tree.traverse(tr, { onnode = function(node, depth) _p(depth + 2, node.name) end }) end -- -- Tests for tree.new() -- function suite.NewReturnsObject() test.isnotnil(tr) end -- -- Tests for tree.add() -- function suite.CanAddAtRoot() tree.add(tr, "Root") prepare() test.capture [[ Root ]] end function suite.CanAddAtChild() tree.add(tr, "Root/Child") prepare() test.capture [[ Root Child ]] end function suite.CanAddAtGrandchild() tree.add(tr, "Root/Child/Grandchild") prepare() test.capture [[ Root Child Grandchild ]] end -- -- Tests for tree.getlocalpath() -- function suite.GetLocalPath_ReturnsPath_OnNoParentPath() local c = tree.add(tr, "Root/Child") c.parent.path = nil test.isequal("Root/Child", tree.getlocalpath(c)) end function suite.GetLocalPath_ReturnsName_OnParentPathSet() local c = tree.add(tr, "Root/Child") test.isequal("Child", tree.getlocalpath(c)) end -- -- Tests for tree.remove() -- function suite.Remove_RemovesNodes() local n1 = tree.add(tr, "1") local n2 = tree.add(tr, "2") local n3 = tree.add(tr, "3") tree.remove(n2) local r = "" for _, n in ipairs(tr.children) do r = r .. n.name end test.isequal("13", r) end function suite.Remove_WorksInTraversal() tree.add(tr, "Root/1") tree.add(tr, "Root/2") tree.add(tr, "Root/3") local r = "" tree.traverse(tr, { onleaf = function(node) r = r .. node.name tree.remove(node) end }) test.isequal("123", r) test.isequal(0, #tr.children[1]) end -- -- Tests for tree.sort() -- function suite.Sort_SortsAllLevels() tree.add(tr, "B/3") tree.add(tr, "B/1") tree.add(tr, "A/2") tree.add(tr, "A/1") tree.add(tr, "B/2") tree.sort(tr) prepare() test.capture [[ A 1 2 B 1 2 3 ]] end -- -- If the root of the tree contains multiple items, it should not -- be removed by trimroot() -- function suite.trimroot_onItemsAtRoot() tree.add(tr, "A/1") tree.add(tr, "B/1") tree.trimroot(tr) prepare() test.capture [[ A 1 B 1 ]] end -- -- Should trim to first level with multiple items. -- function suite.trimroot_onItemsInFirstNode() tree.add(tr, "A/1") tree.add(tr, "A/2") tree.trimroot(tr) prepare() test.capture [[ 1 2 ]] end -- -- If the tree contains only a single node, don't trim it. -- function suite.trimroot_onSingleNode() tree.add(tr, "A") tree.trimroot(tr) prepare() test.capture [[ A ]] end -- -- If the tree contains only a single node, don't trim it. -- function suite.trimroot_onSingleLeafNode() tree.add(tr, "A/1") tree.trimroot(tr) prepare() test.capture [[ 1 ]] end -- -- A ".." folder containing a single subfolder should never appear -- at the top of the source tree. -- function suite.trimroot_removesDotDot_onTopLevelSiblings() tree.add(tr, "../../tests/test_hello.c") tree.add(tr, "../src/test.c") tree.trimroot(tr) prepare() test.capture [[ tests test_hello.c src test.c ]] end function suite.trimroot_removesDotDot_onTopLevel() tree.add(tr, "../tests/test_hello.c") tree.add(tr, "src/test.c") tree.trimroot(tr) prepare() test.capture [[ tests test_hello.c src test.c ]] end function suite.trimroot_removesDotDot_onMultipleNestings() tree.add(tr, "../../../tests/test_hello.c") tree.add(tr, "../src/test.c") tree.trimroot(tr) prepare() test.capture [[ tests test_hello.c src test.c ]] end -- -- When nodes are trimmed, the paths on the remaining nodes should -- be updated to reflect the new hierarchy. -- function suite.trimroot_updatesPaths_onNodesRemoved() tree.add(tr, "A/1") tree.add(tr, "A/2") tree.trimroot(tr) test.isequal("1", tr.children[1].path) end function suite.trimroot_updatesPaths_onDotDotRemoved() tree.add(tr, "../../../tests/test_hello.c") tree.add(tr, "../src/test.c") tree.trimroot(tr) test.isequal("tests", tr.children[1].path) end -- -- Nodes with the key "trim" set to false should be removed. -- function suite.trimroot_respectsTrimFlag() local n = tree.add(tr, "A") tree.add(tr, "A/1") n.trim = false tree.trimroot(tr) prepare() test.capture [[ A 1 ]] end
local Ui = {} function Ui.devicons() return { "kyazdani42/nvim-web-devicons", opt = true } end function Ui.bufferline() return { "romgrk/barbar.nvim", wants = "nvim-web-devicons", requires = Ui.devicons(), config = require("modules.ui.bufferline")(), } end function Ui.statusline() return { "glepnir/galaxyline.nvim", wants = "nvim-web-devicons", requires = Ui.devicons(), config = require("modules.ui.statusline")(), } end function Ui.indentline() return { "lukas-reineke/indent-blankline.nvim", setup = require("modules.ui.indentline")(), } end function Ui.filemanager() return { "kyazdani42/nvim-tree.lua", wants = "nvim-web-devicons", requires = Ui.devicons(), config = require("modules.ui.filemanager")(), } end function Ui.telescope() return { "nvim-telescope/telescope.nvim", wants = "nvim-web-devicons", requires = { "nvim-lua/popup.nvim", "nvim-lua/plenary.nvim", "nvim-telescope/telescope-fzy-native.nvim", Ui.devicons(), }, config = require("modules.ui.telescope")(), } end function Ui.treesitter() return { "nvim-treesitter/nvim-treesitter", run = ":TSUpdate", wants = { "nvim-ts-rainbow", "nvim-ts-autotag", }, requires = { { "p00f/nvim-ts-rainbow", opt = true }, { "windwp/nvim-ts-autotag", opt = true }, }, config = require("modules.ui.treesitter")(), } end function Ui.colorizer() return { "norcalli/nvim-colorizer.lua", config = require("modules.ui.colorizer")(), } end function Ui.colorscheme() -- note: if you want use gruvboy.nvim please change to mnabila/gruvboy.nvim return { "rktjmp/lush.nvim", wants = "gruvboy.nvim", requires = { "~/git/gruvboy.nvim", opt = true }, } end return Ui
set_xmakever("2.2.5") -- project set_project("hikyuu") -- version set_version("1.1.5") set_configvar("USE_ASYNC_LOGGER", 0) set_configvar("SPDLOG_ACTIVE_LEVEL", 2) set_configvar("CHECK_ACCESS_BOUND", 1) set_configvar("SUPPORT_SERIALIZATION", 1) set_configvar("SUPPORT_TEXT_ARCHIVE", 0) set_configvar("SUPPORT_XML_ARCHIVE", 1) set_configvar("SUPPORT_BINARY_ARCHIVE", 1) -- set warning all as error if is_plat("windows") then set_warnings("all", "error") else set_warnings("all") end -- set language: C99, c++ standard set_languages("cxx17", "C99") add_plugindirs("./xmake_plugins") add_requires("fmt", {configs = {header_only = false, vs_runtime = "MD"}}) add_requires("spdlog", {configs = {header_only = false, vs_runtime = "MD"}}) set_objectdir("$(buildir)/$(mode)/$(plat)/$(arch)/.objs") set_targetdir("$(buildir)/$(mode)/$(plat)/$(arch)/lib") add_includedirs("hikyuu_extern_libs/inc") add_includedirs("$(env BOOST_ROOT)") add_linkdirs("$(env BOOST_LIB)") -- modifed to use boost static library, except boost.python --add_defines("BOOST_ALL_DYN_LINK") add_defines("BOOST_SERIALIZATION_DYN_LINK") if is_host("linux") then if is_arch("x86_64") then add_linkdirs("/usr/lib/x86_64-linux-gnu") end end if is_mode("debug") then set_symbols("debug") set_optimize("none") end -- is release now if is_mode("release") then if is_plat("windows") then --Unix-like systems hidden symbols will cause the link dynamic libraries to failed! set_symbols("hidden") end set_optimize("fastest") set_strip("all") end -- for the windows platform (msvc) if is_plat("windows") then add_packagedirs("./hikyuu_extern_libs/pkg") -- add some defines only for windows add_defines("NOCRYPT", "NOGDI") add_cxflags("-EHsc", "/Zc:__cplusplus") add_cxflags("-wd4819") --template dll export warning add_defines("WIN32_LEAN_AND_MEAN") if is_mode("release") then add_cxflags("-MD") elseif is_mode("debug") then add_cxflags("-Gs", "-RTC1") add_cxflags("-MDd") end end if not is_plat("windows") then -- disable some compiler errors add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing") add_cxflags("-ftemplate-depth=1023", "-pthread") add_shflags("-pthread") add_ldflags("-pthread") end add_vectorexts("sse", "sse2", "sse3", "ssse3", "mmx", "avx") if is_plat("windows") then add_subdirs("./hikyuu_extern_libs/src/sqlite3") end add_subdirs("./hikyuu_cpp/hikyuu") add_subdirs("./hikyuu_pywrap") add_subdirs("./hikyuu_cpp/unit_test") add_subdirs("./hikyuu_cpp/demo") after_build("scripts.after_build") before_install("scripts.before_install") on_install("scripts.on_install") before_run("scripts.before_run")
--[[ DEVELOPED BY BORKEDsetup LAST COMMIT: 2021/03/18 SCRIPT TESTED WITH: Synapse X Most full/near full lua executors should be able to handle it. Make sure you have a gun out while executing and throughout the entire operation. Read the README and LICENSE for more information. ]]-- print('INITIALIZED') local NighthawkTeam = game.Teams:FindFirstChild('Nighthawk') local PlayerService = game:GetService('Players') local PlayersTable = {} for i,v in pairs (PlayerService:GetChildren()) do if v.Team == NighthawkTeam then table.insert(PlayersTable, v.Name) print('ADDED PLAYER TO TABLE: '..v.Name) wait(0.05) end end print('DONE PLACING PLAYERS IN TABLES') for t,p in pairs (PlayersTable) do local args = { [1] = { ["Victim"] = game:GetService("Players"):FindFirstChild(p).Character.Humanoid, ["Amount"] = 100 } } game:GetService("ReplicatedStorage").RemoteEvents.Guns.Damage:FireServer(unpack(args)) print('Killed: '..p) wait(1) end print('COMPLETED')
local Event = require("api.Event") local I18N = require("api.I18N") local Gui = require("api.Gui") local Rand = require("api.Rand") local Chara = require("api.Chara") local Effect = require("mod.elona.api.Effect") local Log = require("api.Log") local World = require("api.World") local Ui = require("api.Ui") local Enum = require("api.Enum") local Skill = require("mod.elona_sys.api.Skill") local Const = require("api.Const") local Weather = require("mod.elona.api.Weather") local IItemFood = require("mod.elona.api.aspect.IItemFood") local function make_potion_throwable(item) if item:has_category("elona.drink") then item.can_throw = true end end Event.register("base.on_item_instantiated", "Make potion throwable", make_potion_throwable) local function make_potion_dip_sourceable(item) if item:has_category("elona.drink") then item.can_dip_source = true end end Event.register("base.on_item_instantiated", "Make potion dip sourceable", make_potion_dip_sourceable) local function on_potion_thrown(item, params, result) if result or not item:has_category("elona.drink") or item.proto.on_throw then return result end -- >>>>>>>> shade2/action.hsp:60 snd seCrush2 ... Gui.play_sound("base.crush2", params.x, params.y) -- <<<<<<<< shade2/action.hsp:60 snd seCrush2 .. -- >>>>>>>> shade2/action.hsp:62 if map(tlocX,tlocY,1)!0{ ... local chara = params.chara local map = chara:current_map() local target = Chara.at(params.x, params.y, map) if target then Gui.mes("action.throw.hits", target) Effect.get_wet(target, 25) target:interrupt_activity() -- <<<<<<<< shade2/action.hsp:65 rowAct_Check tc ... -- >>>>>>>> shade2/action.hsp:78 if tc>=maxFollower :hostileAction cc,tc ... if not chara:is_in_same_party(target) then chara:act_hostile_towards(target) end if item.proto.on_drink then local drink_params = { chara = target, item = item, triggered_by = "potion_thrown" } item.proto.on_drink(item, drink_params) else Log.warn("Potion mef '%s' missing 'on_drink' callback", item.proto._id) end return "turn_end" -- <<<<<<<< shade2/action.hsp:83 goto *turn_end .. end -- >>>>>>>> shade2/action.hsp:111 efP=50+sThrow(cc)*10 ... Effect.create_potion_puddle(params.x, params.y, item, chara) return "turn_end" -- <<<<<<<< shade2/action.hsp:115 goto *turn_end .. end Event.register("elona_sys.on_item_throw", "On potion thrown", on_potion_thrown) local function check_item_cooldown_time(item, params, result) -- >>>>>>>> shade2/action.hsp:1719 if iBit(iPeriod,ci)=true{ ... if item.cooldown_hours then assert(type(item.cooldown_hours) == "number") item.next_use_date = item.next_use_date or 0 local date_hours = World.date_hours() if date_hours < item.next_use_date then Gui.mes("action.use.useable_again_at", Ui.format_date(item.next_use_date, true)) return "player_turn_query", "blocked" end local sep = item:separate() sep.next_use_date = date_hours + (item:calc("cooldown_hours") or 0) end -- <<<<<<<< shade2/action.hsp:1723 } .. end Event.register("elona_sys.on_item_use", "Check item cooldown time and maybe prevent use", check_item_cooldown_time, { priority = 10000}) local function proc_item_eaten_is_poisoned(food, params, result) -- >>>>>>>> shade2/item.hsp:1140 if iBit(iPoisonBlend,ci)=true{ ... if not food:calc("is_mixed_with_poison") then return result end local chara = params.chara if chara:is_in_fov() then Gui.mes("food.effect.poisoned.text", chara) Gui.mes("food.effect.poisoned.dialog", chara) end chara:damage_hp(Rand.rnd(250) + 250, "elona.poison") if not Chara.is_alive(chara) then if not chara:is_player() and chara:relation_towards(Chara.player()) >= Enum.Relation.Neutral then Effect.modify_karma(Chara.player(), -1) end return result, "blocked" end -- <<<<<<<< shade2/item.hsp:1150 } .. end Event.register("elona_sys.on_item_eat", "Proc is poisoned eating effect", proc_item_eaten_is_poisoned, { priority = 120000 }) local function proc_item_eaten_is_spiked_with_love_potion(food, params, result) -- >>>>>>>> shade2/item.hsp:1152 if iBit(iLoveBlend,ci)=true{ ... if not food:calc("is_spiked_with_love_potion") then return result end local chara = params.chara if chara:is_player() then Gui.mes("food.effect.spiked.self") else Gui.mes_c("food.effect.spiked.other", "SkyBlue", chara) Skill.modify_impression(chara, 30) Effect.modify_karma(Chara.player(), -10) Effect.love_miracle(chara) end chara:apply_effect("elona.dimming", 500) chara:set_emotion_icon("elona.heart", 3) -- <<<<<<<< shade2/item.hsp:1163 } .. end Event.register("elona_sys.on_item_eat", "Proc is spiked with love potion eating effect", proc_item_eaten_is_spiked_with_love_potion, { priority = 130000 }) local function make_bed_useable(item) if item:has_category("elona.furniture_bed") then item.can_use = true end end Event.register("base.on_item_instantiated", "Make bed useable", make_bed_useable) local function use_bed(item, params) -- >>>>>>>> shade2/action.hsp:1732 if iTypeMinor(ci)=fltBed{ ... if not item:has_category("elona.furniture_bed") then return end -- <<<<<<<< shade2/action.hsp:1735 } .. if save.elona_sys.awake_hours < Const.SLEEP_THRESHOLD_LIGHT then Gui.mes("action.use.not_sleepy") return "player_turn_query" end params.chara:start_activity("elona.preparing_to_sleep", { bed = item }) end Event.register("elona_sys.on_item_use", "Use bed", use_bed, { priority = 200000 }) local function turn_to_jerky(item, params, result) local map = params.owning_map if not map then return result end if not (item._id == "elona.corpse" and map:tile(item.x, item.y).kind == Enum.TileRole.Dryground) then return result end if Weather.is("elona.sunny") then Gui.mes("misc.corpse_is_dried_up", item:build_name(), item.amount) local food = item:get_aspect_or_default(IItemFood) item.image = "elona.item_jerky" item:change_prototype("elona.jerky") food.spoilage_date = World.date_hours() + 2160 food.food_type = nil food.food_quality = 5 item:refresh_cell_on_map() end return result, Event.Result.Blocked end Event.register("elona.on_item_rot", "Turn corpses to jerky on drygrounds", turn_to_jerky, { priority = 50000 }) local function default_item_rot(item, params) if params.owning_chara then if params.owning_chara:is_in_player_party() then Gui.mes("misc.get_rotten", item:build_name(), item.amount) end end local food = item:get_aspect(IItemFood) food:rot(item) if params.owning_map then item:refresh_cell_on_map() end end Event.register("elona.on_item_rot", "Default item rot", default_item_rot, { priority = 100000 })
local pedWeps = { "WEAPON_PISTOL", "WEAPON_PUMPSHOTGUN", "WEAPON_SAWNOFFSHOTGUN", "WEAPON_MICROSMG", "WEAPON_COMPACTRIFLE", "WEAPON_COMBATPISTOL", "WEAPON_BULLPUPRIFLE", "WEAPON_ASSAULTSHOTGUN", "WEAPON_REVOLVER", "WEAPON_COMBATPDW", "WEAPON_ASSAULTSMG", "WEAPON_ASSAULTRIFLE", "weapon_Pistol_Mk2", "weapon_AssaultRifle_Mk2", "weapon_SMG_Mk2" } local pedModels = { "S_M_Y_BlackOps_01", "S_M_Y_BlackOps_02", "S_M_Y_BlackOps_03", } -- CODE -- banditcamps = {} bandits = {} Citizen.CreateThread(function() AddRelationshipGroup("bandit") SetRelationshipBetweenGroups(5, GetHashKey("bandit"), GetHashKey("PLAYER")) SetRelationshipBetweenGroups(0, GetHashKey("bandit"), GetHashKey("bandit")) SetRelationshipBetweenGroups(5, GetHashKey("bandit"), GetHashKey("zombeez")) SetRelationshipBetweenGroups(5, GetHashKey("PLAYER"), GetHashKey("bandit")) while true do Wait(100) local px,py,pz = table.unpack(GetEntityCoords(PlayerPedId(),false)) for i, camp in ipairs(banditcamps) do for i,ped in ipairs(camp.peds) do if NetworkHasControlOfEntity(ped) and #(vector3(camp.coords.x, camp.coords.y, camp.coords.z) - vector3(px,py,pz)) > 400 then DeleteEntity(ped) table.remove(camp.peds,i) elseif NetworkHasControlOfEntity(ped) and IsPedDeadOrDying(ped, true) then local pedX,pedY,pedZ=table.unpack(GetEntityCoords(ped,true) ) TriggerServerEvent("ForceCreateWeaponPickupAtLocation", pedX,pedY,pedZ) table.remove(camp.peds,i) writeLog("ped dead", 1) local cod = GetPedSourceOfDeath(ped) local weap = GetPedCauseOfDeath(ped) if cod ~= 0 and NetworkGetPlayerIndexFromPed(cod) then TriggerServerEvent("s_killedBanditPed",GetPlayerServerId(NetworkGetPlayerIndexFromPed(cod)),weap) end elseif #(vector3(camp.coords.x, camp.coords.y, camp.coords.z) - vector3(px,py,pz)) < 300 and not DoesEntityExist(ped) then table.remove(camp.peds,i) end Wait(1) end if #camp.peds == 0 then TriggerServerEvent("RemoveOldCamp", camp.id) end end end end) function GenerateBanditCamp(campinfo) x, y, z = table.unpack(GetEntityCoords(PlayerPedId(), true)) local campx,campy,campz = campinfo.coords.x, campinfo.coords.y, campinfo.coords.z _,campz = GetGroundZFor_3dCoord(campx+.0,campy+.0,9999.0, 0) for i, model in ipairs(pedModels) do RequestModel(model) while not HasModelLoaded(model) or not HasCollisionForModelLoaded(model) do Wait(200) end end campinfo.peds = {} for i=1, campinfo.pedcount do choosenPed1 = pedModels[math.random(1, #pedModels)] choosenPed1 = string.upper(choosenPed1) ped = CreatePed(4, GetHashKey(choosenPed1), campx+math.random(-3,3),campy+math.random(-3,3),campz, 0.0, true, false) Entity(ped).state:set("C8pE53jw", true, true) Entity(ped).state:set("bandit", true, true) SetPedArmour(ped, 20.0) local health = math.random(200,600) SetPedMaxHealth(ped, health) SetEntityHealth(ped, health) --SetPedAccuracy(ped, 25) SetPedSeeingRange(ped, 80.0) SetPedHearingRange(ped, 30.0) SetPedFleeAttributes(ped, 0, 0) SetPedCombatAttributes(ped, 0, 1) SetPedCombatAttributes(ped, 16, 1) SetPedCombatAttributes(ped, 46, 1) SetPedCombatAttributes(ped, 1424, 1) SetPedCombatAttributes(ped, 5, 1) SetPedCombatMovement(ped, 3) --SetPedCombatRange(ped,1) --SetPedDiesInstantlyInWater(ped,true) SetPedDropsWeaponsWhenDead(ped, false) SetPedRelationshipGroupHash(ped, GetHashKey("bandit")) TaskGuardCurrentPosition(ped, 35.0, 35.0, 1) randomWep = math.random(1, #pedWeps) GiveWeaponToPed(ped, GetHashKey(pedWeps[randomWep]), 9999, true, true) repeat Wait(500) if not NetworkGetEntityIsNetworked(ped) then NetworkRegisterEntityAsNetworked(ped) end netid = NetworkGetNetworkIdFromEntity(ped) until (netid and NetworkGetEntityFromNetworkId(netid) == ped) table.insert(campinfo.peds, NetworkGetNetworkIdFromEntity(ped)) end TriggerServerEvent("RegisterNewBanditCamp", campinfo) writeLog("\nGenerated New Bandit Camp", 1) end RegisterNetEvent("GenerateBanditCamp") AddEventHandler("GenerateBanditCamp", GenerateBanditCamp) RegisterNetEvent("RegisterNewBanditCamp") AddEventHandler("RegisterNewBanditCamp", function(data) -- {netid = netid, id = #spawnedCars+1} for i, ped in ipairs(data.peds) do data.peds[i] = NetworkGetEntityFromNetworkId(ped) writeLog("netid:"..ped, 1) end data.blip = AddBlipForRadius(data.coords.x, data.coords.y, data.coords.z, 30.0) SetBlipAsShortRange(data.blip, true) SetBlipColour(data.blip, 1) SetBlipDisplay(data.blip, 2) SetBlipAlpha(data.blip, 180) data.blip2 = AddBlipForCoord(data.coords.x, data.coords.y, data.coords.z) SetBlipAsShortRange(data.blip2, true) SetBlipColour(data.blip2, 1) SetBlipDisplay(data.blip2, 2) SetBlipSprite(data.blip2, 119) BeginTextCommandSetBlipName("STRING") AddTextComponentString("Enemy Outpost") EndTextCommandSetBlipName(data.blip2) table.insert(banditcamps, data) end) RegisterNetEvent("LoadCamps") AddEventHandler("LoadCamps", function(data) banditcamps = data end) RegisterNetEvent("RemoveOldCamp") AddEventHandler("RemoveOldCamp", function(campid) for i,camp in pairs(banditcamps) do if camp.id == campid then local playerCoords = GetEntityCoords(PlayerPedId(), false) if #(playerCoords - vector3(camp.coords.x, camp.coords.y, camp.coords.z)) < 100 then if currentQuest.active then if Quests[currentQuest.id].finishrequirements.stopCamps and not IsPlayerDead(PlayerId()) then currentQuest.progress.stopCamps = currentQuest.progress.stopCamps+1 end end end RemoveBlip(camp.blip) RemoveBlip(camp.blip2) table.remove(banditcamps,i) writeLog("camp removed", 1) end end end) -- ped assignment Citizen.CreateThread(function() while true do Wait(1500) local handle, ped = FindFirstPed() local finished = false -- FindNextPed will turn the first variable to false when it fails to find another ped in the index repeat Wait(20) if not IsPedAPlayer(ped) and NetworkHasControlOfEntity(ped) and not Entity(ped).state.zombie and not Entity(ped).state.MissionPed then local ownedByMe = false local CanNotControl = false for i,camp in pairs(banditcamps) do for i,bandit in pairs(camp.peds) do if ped == bandit then ownedByMe = true end end end for i,animal in pairs(animals) do if ped == animal then CanNotControl = true end end for i,zombie in pairs(zombies) do if ped == zombie then CanNotControl = true end end if NetworkHasControlOfEntity(ped) and not ownedByMe and not CanNotControl then TaskGuardCurrentPosition(ped, 35.0, 35.0, 1) end end finished, ped = FindNextPed(handle) -- first param returns true while entities are found until not finished EndFindPed(handle) end end)
game = {} love.filesystem.setRequirePath(love.filesystem.getRequirePath()..";lib/?.lua;lib/") love.filesystem.setCRequirePath(love.filesystem.getCRequirePath()..";lib/?.dll;lib/?/?.dll;lib/?/?.so") -- Globals (yikes) debug = false cameraController = {} inputController = {} uiController = {} animationController = {} roundController = {} audioController = {} configController = {} helpController = {} world = {} TOWER_STATS = {} function game:init() love.graphics.setFont(assets.ui.neuropoliticalRg(12)) love.graphics.setDefaultFilter('nearest') love.keyboard.setKeyRepeat(true) -- For nuklear nk.init() TOWER_STATS = require("src.tower-stats") configController = ConfigController() configController:fetchUserSettings() uiController = UiController() audioController = AudioController(settings) inputController = InputController() playerController = PlayerController() animationController = AnimationController() roundController = RoundController() helpController = HelpController(Vector(love.graphics.getWidth()*constants.UI.HELPLOG.X, love.graphics.getHeight()*constants.UI.HELPLOG.Y)) if not configController.settings.seenMazingTutorial then helpController:addText('Construct a maze of towers to defeat blobs and gain valuable resources to upgrade your towers!', 10, {0.2,0.8,0}) configController:updateSetting('seenMazingTutorial', true) end world = World(Vector(0,0), constants.GRID.ROWS, constants.GRID.COLUMNS) cameraController = CameraController(Vector(world.origin.x + constants.GRID.COLUMNS/2*constants.GRID.CELL_SIZE, world.origin.y + constants.GRID.ROWS/1.5*constants.GRID.CELL_SIZE)) end function game:update(dt) dt = math.min(dt, 0.1) -- Prevent weirdness with dragging the window. Might need to be reconsidered if roundController:isEnemyPhase() then dt = dt * playerController.timeDilation end world:update(dt) Timer.update(dt) --the global version is used mostly for tweening/small use-cases if not playerController.hasWon and not playerController.hasLost then uiController:update(dt) roundController:update(dt) inputController:update(dt) cameraController:update(dt) helpController:update(dt) end playerController:update(dt) end function game:draw() Util.l.resetColour() cameraController:attach() world:draw() playerController:draw() cameraController:detach() uiController:draw() helpController:draw() if debug then love.graphics.print("Current FPS: "..tostring(love.timer.getFPS( )), 10, love.graphics.getHeight()*0.3) inputController:draw() Util.l.resetColour() Util.l.renderStats(10, 80) end end function game:keypressed(key, scancode, isrepeat) if key == "f1" then debug = not debug end inputController:keypressed(key) nk.keypressed(key, scancode, isrepeat) end function game:resize(w, h) uiController:triggerResize() end function game:keyreleased(key, scancode) nk.keyreleased(key, scancode) end function game:mousepressed(x, y, button, istouch, presses) nk.mousepressed(x, y, button, istouch) inputController:mousepressed(Vector(x, y), button) end function game:mousereleased(x, y, button, istouch) nk.mousereleased(x, y, button, istouch) end function game:mousemoved(x, y, dx, dy, istouch) nk.mousemoved(x, y, dx, dy, istouch) end function game:textinput(text) nk.textinput(text) end function game:wheelmoved(x, y) nk.wheelmoved(x, y) end
// Wildfire Black Mesa Roleplay // File description: BMRP server-side crystal storage entity script // Copyright (c) 2022 KiwifruitDev // Licensed under the MIT License. //********************************************************************************************* // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. //********************************************************************************************* AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") util.AddNetworkString("CrystalRackUI") function ENT:Initialize() self:SetModel("models/props_generic/storage_shelf.mdl") self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) self:SetUseType(SIMPLE_USE) local phys = self:GetPhysicsObject() if phys:IsValid() then phys:Wake() end end
return { ["comment"]="% generated by mtxrun --script pattern --convert", ["exceptions"]={ ["n"]=0, }, ["metadata"]={ ["mnemonic"]="tk", ["source"]="hyph-tk", ["texcomment"]="% copyright: Copyright (c) 2010-2015 Nazar Annagurban\ % title: Hyphenation patterns for Turkmen language\ % version: 0.1 16 March 2010\ % notice: >\ % This file is part of the hyph-utf8 package.\ % See http://www.hyphenation.org for more information.\ % license:\ % name: MIT\ % url: https://opensource.org/licenses/MIT\ % text: >\ % Permission is hereby granted, free of charge, to any person obtaining a copy\ % of this software and associated documentation files (the \"Software\"), to deal\ % in the Software without restriction, including without limitation the rights\ % to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ % copies of the Software, and to permit persons to whom the Software is\ % furnished to do so, subject to the following conditions:\ % \ % The above copyright notice and this permission notice shall be included in\ % all copies or substantial portions of the Software.\ % \ % THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\ % IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\ % FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\ % AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\ % LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\ % OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\ % THE SOFTWARE.\ %\ % ", }, ["patterns"]={ ["characters"]="-abdefghijklmnoprstuwyzäçöüýňşž", ["data"]="1-4 ä1bä ä1be ä1bi ä1bö ä1bü ä1çä ä1çe ä1çi ä1çö ä1çü ä1dä ä1de ä1di ä1dö ä1dü ä1fä ä1fe ä1fi ä1fö ä1fü ä1gä ä1ge ä1gi ä1gö ä1gü ä1hä ä1he ä1hi ä1hö ä1hü ä1jä ä1je ä1ji ä1jö ä1jü ä1kä ä1ke ä1ki ä1kö ä1kü ä1lä ä1le ä1li ä1lö ä1lü ä1mä ä1me ä1mi ä1mö ä1mü ä1nä ä1ne ä1ni ä1nö ä1nü ä1pä ä1pe ä1pi ä1pö ä1pü ä1rä ä1re ä1ri ä1rö ä1rü ä1sä ä1se ä1si ä1sö ä1sü ä1tä ä1te ä1ti ä1tö ä1tü ä1wä ä1we ä1wi ä1wö ä1wü ä1ýä ä1ýe ä1ýi ä1ýö ä1ýü ä1zä ä1ze ä1zi ä1zö ä1zü ä1ňä ä1ňe ä1ňi ä1ňö ä1ňü ä1žä ä1že ä1ži ä1žö ä1žü ä1şä ä1şe ä1şi ä1şö ä1şü e1bä e1be e1bi e1bö e1bü e1çä e1çe e1çi e1çö e1çü e1dä e1de e1di e1dö e1dü e1fä e1fe e1fi e1fö e1fü e1gä e1ge e1gi e1gö e1gü e1hä e1he e1hi e1hö e1hü e1jä e1je e1ji e1jö e1jü e1kä e1ke e1ki e1kö e1kü e1lä e1le e1li e1lö e1lü e1mä e1me e1mi e1mö e1mü e1nä e1ne e1ni e1nö e1nü e1pä e1pe e1pi e1pö e1pü e1rä e1re e1ri e1rö e1rü e1sä e1se e1si e1sö e1sü e1tä e1te e1ti e1tö e1tü e1wä e1we e1wi e1wö e1wü e1ýä e1ýe e1ýi e1ýö e1ýü e1zä e1ze e1zi e1zö e1zü e1ňä e1ňe e1ňi e1ňö e1ňü e1žä e1že e1ži e1žö e1žü e1şä e1şe e1şi e1şö e1şü i1bä i1be i1bi i1bö i1bü i1çä i1çe i1çi i1çö i1çü i1dä i1de i1di i1dö i1dü i1fä i1fe i1fi i1fö i1fü i1gä i1ge i1gi i1gö i1gü i1hä i1he i1hi i1hö i1hü i1jä i1je i1ji i1jö i1jü i1kä i1ke i1ki i1kö i1kü i1lä i1le i1li i1lö i1lü i1mä i1me i1mi i1mö i1mü i1nä i1ne i1ni i1nö i1nü i1pä i1pe i1pi i1pö i1pü i1rä i1re i1ri i1rö i1rü i1sä i1se i1si i1sö i1sü i1tä i1te i1ti i1tö i1tü i1wä i1we i1wi i1wö i1wü i1ýä i1ýe i1ýi i1ýö i1ýü i1zä i1ze i1zi i1zö i1zü i1ňä i1ňe i1ňi i1ňö i1ňü i1žä i1že i1ži i1žö i1žü i1şä i1şe i1şi i1şö i1şü ö1bä ö1be ö1bi ö1bö ö1bü ö1çä ö1çe ö1çi ö1çö ö1çü ö1dä ö1de ö1di ö1dö ö1dü ö1fä ö1fe ö1fi ö1fö ö1fü ö1gä ö1ge ö1gi ö1gö ö1gü ö1hä ö1he ö1hi ö1hö ö1hü ö1jä ö1je ö1ji ö1jö ö1jü ö1kä ö1ke ö1ki ö1kö ö1kü ö1lä ö1le ö1li ö1lö ö1lü ö1mä ö1me ö1mi ö1mö ö1mü ö1nä ö1ne ö1ni ö1nö ö1nü ö1pä ö1pe ö1pi ö1pö ö1pü ö1rä ö1re ö1ri ö1rö ö1rü ö1sä ö1se ö1si ö1sö ö1sü ö1tä ö1te ö1ti ö1tö ö1tü ö1wä ö1we ö1wi ö1wö ö1wü ö1ýä ö1ýe ö1ýi ö1ýö ö1ýü ö1zä ö1ze ö1zi ö1zö ö1zü ö1ňä ö1ňe ö1ňi ö1ňö ö1ňü ö1žä ö1že ö1ži ö1žö ö1žü ö1şä ö1şe ö1şi ö1şö ö1şü ü1bä ü1be ü1bi ü1bö ü1bü ü1çä ü1çe ü1çi ü1çö ü1çü ü1dä ü1de ü1di ü1dö ü1dü ü1fä ü1fe ü1fi ü1fö ü1fü ü1gä ü1ge ü1gi ü1gö ü1gü ü1hä ü1he ü1hi ü1hö ü1hü ü1jä ü1je ü1ji ü1jö ü1jü ü1kä ü1ke ü1ki ü1kö ü1kü ü1lä ü1le ü1li ü1lö ü1lü ü1mä ü1me ü1mi ü1mö ü1mü ü1nä ü1ne ü1ni ü1nö ü1nü ü1pä ü1pe ü1pi ü1pö ü1pü ü1rä ü1re ü1ri ü1rö ü1rü ü1sä ü1se ü1si ü1sö ü1sü ü1tä ü1te ü1ti ü1tö ü1tü ü1wä ü1we ü1wi ü1wö ü1wü ü1ýä ü1ýe ü1ýi ü1ýö ü1ýü ü1zä ü1ze ü1zi ü1zö ü1zü ü1ňä ü1ňe ü1ňi ü1ňö ü1ňü ü1žä ü1že ü1ži ü1žö ü1žü ü1şä ü1şe ü1şi ü1şö ü1şü a1ba a1by a1bo a1bu a1ça a1çy a1ço a1çu a1da a1dy a1do a1du a1fa a1fy a1fo a1fu a1ga a1gy a1go a1gu a1ha a1hy a1ho a1hu a1ja a1jy a1jo a1ju a1ka a1ky a1ko a1ku a1la a1ly a1lo a1lu a1ma a1my a1mo a1mu a1na a1ny a1no a1nu a1pa a1py a1po a1pu a1ra a1ry a1ro a1ru a1sa a1sy a1so a1su a1ta a1ty a1to a1tu a1wa a1wy a1wo a1wu a1ýa a1ýy a1ýo a1ýu a1za a1zy a1zo a1zu a1ňa a1ňy a1ňo a1ňu a1ža a1žy a1žo a1žu a1şa a1şy a1şo a1şu y1ba y1by y1bo y1bu y1ça y1çy y1ço y1çu y1da y1dy y1do y1du y1fa y1fy y1fo y1fu y1ga y1gy y1go y1gu y1ha y1hy y1ho y1hu y1ja y1jy y1jo y1ju y1ka y1ky y1ko y1ku y1la y1ly y1lo y1lu y1ma y1my y1mo y1mu y1na y1ny y1no y1nu y1pa y1py y1po y1pu y1ra y1ry y1ro y1ru y1sa y1sy y1so y1su y1ta y1ty y1to y1tu y1wa y1wy y1wo y1wu y1ýa y1ýy y1ýo y1ýu y1za y1zy y1zo y1zu y1ňa y1ňy y1ňo y1ňu y1ža y1žy y1žo y1žu y1şa y1şy y1şo y1şu o1ba o1by o1bo o1bu o1ça o1çy o1ço o1çu o1da o1dy o1do o1du o1fa o1fy o1fo o1fu o1ga o1gy o1go o1gu o1ha o1hy o1ho o1hu o1ja o1jy o1jo o1ju o1ka o1ky o1ko o1ku o1la o1ly o1lo o1lu o1ma o1my o1mo o1mu o1na o1ny o1no o1nu o1pa o1py o1po o1pu o1ra o1ry o1ro o1ru o1sa o1sy o1so o1su o1ta o1ty o1to o1tu o1wa o1wy o1wo o1wu o1ýa o1ýy o1ýo o1ýu o1za o1zy o1zo o1zu o1ňa o1ňy o1ňo o1ňu o1ža o1žy o1žo o1žu o1şa o1şy o1şo o1şu u1ba u1by u1bo u1bu u1ça u1çy u1ço u1çu u1da u1dy u1do u1du u1fa u1fy u1fo u1fu u1ga u1gy u1go u1gu u1ha u1hy u1ho u1hu u1ja u1jy u1jo u1ju u1ka u1ky u1ko u1ku u1la u1ly u1lo u1lu u1ma u1my u1mo u1mu u1na u1ny u1no u1nu u1pa u1py u1po u1pu u1ra u1ry u1ro u1ru u1sa u1sy u1so u1su u1ta u1ty u1to u1tu u1wa u1wy u1wo u1wu u1ýa u1ýy u1ýo u1ýu u1za u1zy u1zo u1zu u1ňa u1ňy u1ňo u1ňu u1ža u1žy u1žo u1žu u1şa u1şy u1şo u1şu a1bi a1be y1bä y1bi y1be o1bi o1be u1bi u1be i1ba i1bo e1ba e1bo ä1bo ä1ba ö1ba a1çi a1çe y1çä y1çi y1çe o1çi o1çe u1çi u1çe i1ça i1ço e1ça e1ço ä1ço ä1ça ö1ça a1di a1de y1dä y1di y1de o1di o1de u1di u1de i1da i1do e1da e1do ä1do ä1da ö1da a1fi a1fe y1fä y1fi y1fe o1fi o1fe u1fi u1fe i1fa i1fo e1fa e1fo ä1fo ä1fa ö1fa a1gi a1ge y1gä y1gi y1ge o1gi o1ge u1gi u1ge i1ga i1go e1ga e1go ä1go ä1ga ö1ga a1hi a1he y1hä y1hi y1he o1hi o1he u1hi u1he i1ha i1ho e1ha e1ho ä1ho ä1ha ö1ha a1ji a1je y1jä y1ji y1je o1ji o1je u1ji u1je i1ja i1jo e1ja e1jo ä1jo ä1ja ö1ja a1ki a1ke y1kä y1ki y1ke o1ki o1ke u1ki u1ke i1ka i1ko e1ka e1ko ä1ko ä1ka ö1ka a1li a1le y1lä y1li y1le o1li o1le u1li u1le i1la i1lo e1la e1lo ä1lo ä1la ö1la a1mi a1me y1mä y1mi y1me o1mi o1me u1mi u1me i1ma i1mo e1ma e1mo ä1mo ä1ma ö1ma a1ni a1ne y1nä y1ni y1ne o1ni o1ne u1ni u1ne i1na i1no e1na e1no ä1no ä1na ö1na a1pi a1pe y1pä y1pi y1pe o1pi o1pe u1pi u1pe i1pa i1po e1pa e1po ä1po ä1pa ö1pa a1ri a1re y1rä y1ri y1re o1ri o1re u1ri u1re i1ra i1ro e1ra e1ro ä1ro ä1ra ö1ra a1si a1se y1sä y1si y1se o1si o1se u1si u1se i1sa i1so e1sa e1so ä1so ä1sa ö1sa a1ti a1te y1tä y1ti y1te o1ti o1te u1ti u1te i1ta i1to e1ta e1to ä1to ä1ta ö1ta a1wi a1we y1wä y1wi y1we o1wi o1we u1wi u1we i1wa i1wo e1wa e1wo ä1wo ä1wa ö1wa a1ýi a1ýe y1ýä y1ýi y1ýe o1ýi o1ýe u1ýi u1ýe i1ýa i1ýo e1ýa e1ýo ä1ýo ä1ýa ö1ýa a1zi a1ze y1zä y1zi y1ze o1zi o1ze u1zi u1ze i1za i1zo e1za e1zo ä1zo ä1za ö1za a1ňi a1ňe y1ňä y1ňi y1ňe o1ňi o1ňe u1ňi u1ňe i1ňa i1ňo e1ňa e1ňo ä1ňo ä1ňa ö1ňa a1ži a1že y1žä y1ži y1že o1ži o1že u1ži u1že i1ža i1žo e1ža e1žo ä1žo ä1ža ö1ža a1şi a1şe y1şä y1şi y1şe o1şi o1şe u1şi u1şe i1şa i1şo e1şa e1şo ä1şo ä1şa ö1şa b1b .b2b b1ç .b2ç b1d .b2d b1f .b2f b1g .b2g b1h .b2h b1j .b2j b1k .b2k b1l .b2l b1m .b2m b1n .b2n b1p .b2p b1r .b2r b1s .b2s b1t .b2t b1w .b2w b1ý .b2ý b1z .b2z b1ň .b2ň b1ž .b2ž b1ş .b2ş ç1b .ç2b ç1ç .ç2ç ç1d .ç2d ç1f .ç2f ç1g .ç2g ç1h .ç2h ç1j .ç2j ç1k .ç2k ç1l .ç2l ç1m .ç2m ç1n .ç2n ç1p .ç2p ç1r .ç2r ç1s .ç2s ç1t .ç2t ç1w .ç2w ç1ý .ç2ý ç1z .ç2z ç1ň .ç2ň ç1ž .ç2ž ç1ş .ç2ş d1b .d2b d1ç .d2ç d1d .d2d d1f .d2f d1g .d2g d1h .d2h d1j .d2j d1k .d2k d1l .d2l d1m .d2m d1n .d2n d1p .d2p d1r .d2r d1s .d2s d1t .d2t d1w .d2w d1ý .d2ý d1z .d2z d1ň .d2ň d1ž .d2ž d1ş .d2ş f1b .f2b f1ç .f2ç f1d .f2d f1f .f2f f1g .f2g f1h .f2h f1j .f2j f1k .f2k f1l .f2l f1m .f2m f1n .f2n f1p .f2p f1r .f2r f1s .f2s f1t .f2t f1w .f2w f1ý .f2ý f1z .f2z f1ň .f2ň f1ž .f2ž f1ş .f2ş g1b .g2b g1ç .g2ç g1d .g2d g1f .g2f g1g .g2g g1h .g2h g1j .g2j g1k .g2k g1l .g2l g1m .g2m g1n .g2n g1p .g2p g1r .g2r g1s .g2s g1t .g2t g1w .g2w g1ý .g2ý g1z .g2z g1ň .g2ň g1ž .g2ž g1ş .g2ş h1b .h2b h1ç .h2ç h1d .h2d h1f .h2f h1g .h2g h1h .h2h h1j .h2j h1k .h2k h1l .h2l h1m .h2m h1n .h2n h1p .h2p h1r .h2r h1s .h2s h1t .h2t h1w .h2w h1ý .h2ý h1z .h2z h1ň .h2ň h1ž .h2ž h1ş .h2ş j1b .j2b j1ç .j2ç j1d .j2d j1f .j2f j1g .j2g j1h .j2h j1j .j2j j1k .j2k j1l .j2l j1m .j2m j1n .j2n j1p .j2p j1r .j2r j1s .j2s j1t .j2t j1w .j2w j1ý .j2ý j1z .j2z j1ň .j2ň j1ž .j2ž j1ş .j2ş k1b .k2b k1ç .k2ç k1d .k2d k1f .k2f k1g .k2g k1h .k2h k1j .k2j k1k .k2k k1l .k2l k1m .k2m k1n .k2n k1p .k2p k1r .k2r k1s .k2s k1t .k2t k1w .k2w k1ý .k2ý k1z .k2z k1ň .k2ň k1ž .k2ž k1ş .k2ş l1b .l2b l1ç .l2ç l1d .l2d l1f .l2f l1g .l2g l1h .l2h l1j .l2j l1k .l2k l1l .l2l l1m .l2m l1n .l2n l1p .l2p l1r .l2r l1s .l2s l1t .l2t l1w .l2w l1ý .l2ý l1z .l2z l1ň .l2ň l1ž .l2ž l1ş .l2ş m1b .m2b m1ç .m2ç m1d .m2d m1f .m2f m1g .m2g m1h .m2h m1j .m2j m1k .m2k m1l .m2l m1m .m2m m1n .m2n m1p .m2p m1r .m2r m1s .m2s m1t .m2t m1w .m2w m1ý .m2ý m1z .m2z m1ň .m2ň m1ž .m2ž m1ş .m2ş n1b .n2b n1ç .n2ç n1d .n2d n1f .n2f n1g .n2g n1h .n2h n1j .n2j n1k .n2k n1l .n2l n1m .n2m n1n .n2n n1p .n2p n1r .n2r n1s .n2s n1t .n2t n1w .n2w n1ý .n2ý n1z .n2z n1ň .n2ň n1ž .n2ž n1ş .n2ş p1b .p2b p1ç .p2ç p1d .p2d p1f .p2f p1g .p2g p1h .p2h p1j .p2j p1k .p2k p1l .p2l p1m .p2m p1n .p2n p1p .p2p p1r .p2r p1s .p2s p1t .p2t p1w .p2w p1ý .p2ý p1z .p2z p1ň .p2ň p1ž .p2ž p1ş .p2ş r1b .r2b r1ç .r2ç r1d .r2d r1f .r2f r1g .r2g r1h .r2h r1j .r2j r1k .r2k r1l .r2l r1m .r2m r1n .r2n r1p .r2p r1r .r2r r1s .r2s r1t .r2t r1w .r2w r1ý .r2ý r1z .r2z r1ň .r2ň r1ž .r2ž r1ş .r2ş s1b .s2b s1ç .s2ç s1d .s2d s1f .s2f s1g .s2g s1h .s2h s1j .s2j s1k .s2k s1l .s2l s1m .s2m s1n .s2n s1p .s2p s1r .s2r s1s .s2s s1t .s2t s1w .s2w s1ý .s2ý s1z .s2z s1ň .s2ň s1ž .s2ž s1ş .s2ş t1b .t2b t1ç .t2ç t1d .t2d t1f .t2f t1g .t2g t1h .t2h t1j .t2j t1k .t2k t1l .t2l t1m .t2m t1n .t2n t1p .t2p t1r .t2r t1s .t2s t1t .t2t t1w .t2w t1ý .t2ý t1z .t2z t1ň .t2ň t1ž .t2ž t1ş .t2ş w1b .w2b w1ç .w2ç w1d .w2d w1f .w2f w1g .w2g w1h .w2h w1j .w2j w1k .w2k w1l .w2l w1m .w2m w1n .w2n w1p .w2p w1r .w2r w1s .w2s w1t .w2t w1w .w2w w1ý .w2ý w1z .w2z w1ň .w2ň w1ž .w2ž w1ş .w2ş ý1b .ý2b ý1ç .ý2ç ý1d .ý2d ý1f .ý2f ý1g .ý2g ý1h .ý2h ý1j .ý2j ý1k .ý2k ý1l .ý2l ý1m .ý2m ý1n .ý2n ý1p .ý2p ý1r .ý2r ý1s .ý2s ý1t .ý2t ý1w .ý2w ý1ý .ý2ý ý1z .ý2z ý1ň .ý2ň ý1ž .ý2ž ý1ş .ý2ş z1b .z2b z1ç .z2ç z1d .z2d z1f .z2f z1g .z2g z1h .z2h z1j .z2j z1k .z2k z1l .z2l z1m .z2m z1n .z2n z1p .z2p z1r .z2r z1s .z2s z1t .z2t z1w .z2w z1ý .z2ý z1z .z2z z1ň .z2ň z1ž .z2ž z1ş .z2ş ň1b .ň2b ň1ç .ň2ç ň1d .ň2d ň1f .ň2f ň1g .ň2g ň1h .ň2h ň1j .ň2j ň1k .ň2k ň1l .ň2l ň1m .ň2m ň1n .ň2n ň1p .ň2p ň1r .ň2r ň1s .ň2s ň1t .ň2t ň1w .ň2w ň1ý .ň2ý ň1z .ň2z ň1ň .ň2ň ň1ž .ň2ž ň1ş .ň2ş ž1b .ž2b ž1ç .ž2ç ž1d .ž2d ž1f .ž2f ž1g .ž2g ž1h .ž2h ž1j .ž2j ž1k .ž2k ž1l .ž2l ž1m .ž2m ž1n .ž2n ž1p .ž2p ž1r .ž2r ž1s .ž2s ž1t .ž2t ž1w .ž2w ž1ý .ž2ý ž1z .ž2z ž1ň .ž2ň ž1ž .ž2ž ž1ş .ž2ş ş1b .ş2b ş1ç .ş2ç ş1d .ş2d ş1f .ş2f ş1g .ş2g ş1h .ş2h ş1j .ş2j ş1k .ş2k ş1l .ş2l ş1m .ş2m ş1n .ş2n ş1p .ş2p ş1r .ş2r ş1s .ş2s ş1t .ş2t ş1w .ş2w ş1ý .ş2ý ş1z .ş2z ş1ň .ş2ň ş1ž .ş2ž ş1ş .ş2ş ý2t1b ý2n1b ý2d1b r2t1b ý2p1b l2p1b l2t1b g2t1b n2t1b r2k1b r2p1b k2t1b r2h1b s2t1b l2k1b w2p1b n2s1b r2s1b l2m1b ý2t1ç ý2n1ç ý2d1ç r2t1ç ý2p1ç l2p1ç l2t1ç g2t1ç n2t1ç r2k1ç r2p1ç k2t1ç r2h1ç s2t1ç l2k1ç w2p1ç n2s1ç r2s1ç l2m1ç ý2t1d ý2n1d ý2d1d r2t1d ý2p1d l2p1d l2t1d g2t1d n2t1d r2k1d r2p1d k2t1d r2h1d s2t1d l2k1d w2p1d n2s1d r2s1d l2m1d ý2t1g ý2n1g ý2d1g r2t1g ý2p1g l2p1g l2t1g g2t1g n2t1g r2k1g r2p1g k2t1g r2h1g s2t1g l2k1g w2p1g n2s1g r2s1g l2m1g ý2t1j ý2n1j ý2d1j r2t1j ý2p1j l2p1j l2t1j g2t1j n2t1j r2k1j r2p1j k2t1j r2h1j s2t1j l2k1j w2p1j n2s1j r2s1j l2m1j ý2t1k ý2n1k ý2d1k r2t1k ý2p1k l2p1k l2t1k g2t1k n2t1k r2k1k r2p1k k2t1k r2h1k s2t1k l2k1k w2p1k n2s1k r2s1k l2m1k ý2t1l ý2n1l ý2d1l r2t1l ý2p1l l2p1l l2t1l g2t1l n2t1l r2k1l r2p1l k2t1l r2h1l s2t1l l2k1l w2p1l n2s1l r2s1l l2m1l ý2t1m ý2n1m ý2d1m r2t1m ý2p1m l2p1m l2t1m g2t1m n2t1m r2k1m r2p1m k2t1m r2h1m s2t1m l2k1m w2p1m n2s1m r2s1m l2m1m ý2t1n ý2n1n ý2d1n r2t1n ý2p1n l2p1n l2t1n g2t1n n2t1n r2k1n r2p1n k2t1n r2h1n s2t1n l2k1n w2p1n n2s1n r2s1n l2m1n ý2t1p ý2n1p ý2d1p r2t1p ý2p1p l2p1p l2t1p g2t1p n2t1p r2k1p r2p1p k2t1p r2h1p s2t1p l2k1p w2p1p n2s1p r2s1p l2m1p ý2t1s ý2n1s ý2d1s r2t1s ý2p1s l2p1s l2t1s g2t1s n2t1s r2k1s r2p1s k2t1s r2h1s s2t1s l2k1s w2p1s n2s1s r2s1s l2m1s ý2t1t ý2n1t ý2d1t r2t1t ý2p1t l2p1t l2t1t g2t1t n2t1t r2k1t r2p1t k2t1t r2h1t s2t1t l2k1t w2p1t n2s1t r2s1t l2m1t ý2t1ý ý2n1ý ý2d1ý r2t1ý ý2p1ý l2p1ý l2t1ý g2t1ý n2t1ý r2k1ý r2p1ý k2t1ý r2h1ý s2t1ý l2k1ý w2p1ý n2s1ý r2s1ý l2m1ý ý2t1z ý2n1z ý2d1z r2t1z ý2p1z l2p1z l2t1z g2t1z n2t1z r2k1z r2p1z k2t1z r2h1z s2t1z l2k1z w2p1z n2s1z r2s1z l2m1z ý2t1ş ý2n1ş ý2d1ş r2t1ş ý2p1ş l2p1ş l2t1ş g2t1ş n2t1ş r2k1ş r2p1ş k2t1ş r2h1ş s2t1ş l2k1ş w2p1ş n2s1ş r2s1ş l2m1ş s2k1d l1s2k l1s2t s1t2r n2g1l n1g2r s2k1w", ["lefthyphenmin"]=1, ["length"]=13245, ["n"]=2372, ["righthyphenmax"]=1, }, ["version"]="1.001", }
--[[ A non-doc comment multi-line probably containing license information! Doesn't use module(), but module name is inferred from file name. If you have initial licence comments that look like doc comments, then set `boilerplate=true` ]] ------------ -- Test module, -- Actual blurb here! ---- local one = {} --- answer to everything. function one.answer () return 42 end return one
local M = {} function M.seconds_to_string(seconds) if seconds < 60 * 60 then -- MM:SS return string.format("%02d:%02d", math.floor(seconds / 60), seconds % 60 ) elseif seconds < 60 * 60 * 24 then -- HH:MM:SS return string.format("%02d:%02d:%02d", math.floor(seconds / 3600), math.floor(seconds / 60) % 60, seconds % 60) else -- DD:HH:MM:SS return string.format("%02d:%02d:%02d:%02d", math.floor(seconds / (3600 * 24)), math.floor(seconds / 3600) % 24, math.floor(seconds / 60) % 60, seconds % 60) end end return M
function GM:LoadClient() local data = util.JSONToTable(file.Read("rotgb_tg_data.dat", "DATA") or "") if data then local ply = LocalPlayer() ply.rtg_PreviousXP = tonumber(data.xp) or 0 local skills = data.skills net.Start("rotgb_statchanged") net.WriteUInt(RTG_STAT_INIT, 4) net.WriteDouble(ply.rtg_PreviousXP) if (skills and next(skills)) then local validatedSkills = {} local skillsToAdd = {} local skillNames = hook.Run("GetSkillNames") for k,v in pairs(skills) do local id = skillNames[k] if id then table.insert(validatedSkills, id-1) skillsToAdd[id] = v end end ply:RTG_AddSkills(skillsToAdd) net.WriteUInt(RTG_SKILL_MULTIPLE, 2) net.WriteUInt(#validatedSkills-1, 12) for k,v in pairs(validatedSkills) do net.WriteUInt(v, 12) end else net.WriteUInt(RTG_SKILL_CLEAR, 2) end local statisticAmounts = hook.Run("LoadStatistics", data.statsitics) net.WriteUInt(#statisticAmounts, 16) for k,v in pairs(statisticAmounts) do net.WriteUInt(k-1, 16) net.WriteDouble(v) end net.SendToServer() hook.Run("SetCompletedDifficulties", data.completedDifficulties or {}) end end function GM:SaveClient() local ply = LocalPlayer() local plySkills = ply:RTG_GetSkills() local data = {} data.xp = ply:RTG_GetExperience() data.skills = {} for k,v in pairs(hook.Run("GetSkillNames")) do if ply:RTG_HasSkill(v) then data.skills[k] = plySkills[v] end end data.completedDifficulties = hook.Run("GetCompletedDifficulties") data.statsitics = hook.Run("GetStatisticsSaveTable") file.Write("rotgb_tg_data.dat", util.TableToJSON(data)) end
local bit32 = require("bit") local oam = {} oam.width = 320 oam.init = function(gameboy) oam.canvas = love.graphics.newCanvas(160, 400) oam.gameboy = gameboy oam.sprite_imagedata = love.image.newImageData(8, 16) oam.sprite_image = love.graphics.newImage(oam.sprite_imagedata) oam.background_8x8_image = love.graphics.newImage("images/debug_oam_8x8_background.png") oam.background_8x16_image = love.graphics.newImage("images/debug_oam_8x16_background.png") end oam.draw_sprite = function(sprite_address, sx, sy, sprite_size) local graphics = oam.gameboy.graphics local io = oam.gameboy.io local ports = oam.gameboy.io.ports local sprite = graphics.cache.oam[(sprite_address - 0xFE00) / 4] local sprite_flags = graphics.oam[sprite_address + 3] for y = 0, (sprite_size - 1) do for x = 0, 7 do local color if y < 8 then if sprite_size == 8 then color = sprite.palette[sprite.tile[x][y]] else color = sprite.palette[sprite.upper_tile[x][y]] end else color = sprite.palette[sprite.lower_tile[x][y - 8]] end oam.sprite_imagedata:setPixel(sx + x, sy + y, color[1] / 255, color[2] / 255, color[3] / 255, 1) end end return sprite_tile, sprite.x, sprite.y, sprite_flags end oam.draw_sprites = function() -- Clear out the sprite buffer before we start oam.sprite_imagedata:mapPixel(function() return 0, 0, 0, 0 end) local cell_width = 40 local cell_height = 24 local sprites_per_row = 4 local sprite_scaling = 2 local sprite_size = 8 if oam.gameboy.graphics.registers.large_sprites then sprite_size = 16 sprite_scaling = 1 end love.graphics.setColor(1, 1, 1) if sprite_size == 8 then love.graphics.draw(oam.background_8x8_image, 0, 0) else love.graphics.draw(oam.background_8x16_image, 0, 0) end local x = 0 local y = 0 for i = 0, 39 do -- draw the sprite local tile, sprite_x, sprite_y, flags = oam.draw_sprite(0xFE00 + (i * 4), 0, 0, sprite_size) love.graphics.setCanvas(oam.canvas) love.graphics.push() love.graphics.scale(sprite_scaling, sprite_scaling) love.graphics.setColor(1, 1, 1) oam.sprite_image:replacePixels(oam.sprite_imagedata) love.graphics.draw(oam.sprite_image, ((3 + x * cell_width) / sprite_scaling), ((10 + y * cell_height) / sprite_scaling)) love.graphics.pop() -- draw info about this sprite love.graphics.setColor(0, 0, 0) love.graphics.print(string.format("X:%02X", bit32.band(sprite_x, 0xFF)), x * cell_width + cell_width - 17, y * cell_height + 9) love.graphics.print(string.format("Y:%02X", bit32.band(sprite_y, 0xFF)), x * cell_width + cell_width - 17, y * cell_height + 16) love.graphics.print(string.format("F:%02X", flags ), x * cell_width + cell_width - 17, y * cell_height + 23) x = x + 1 if x >= sprites_per_row then x = 0 y = y + 1 end end end oam.draw = function(x, y) love.graphics.setCanvas(oam.canvas) love.graphics.clear() love.graphics.setColor(0.75, 0.75, 0.75) love.graphics.rectangle("fill", 0, 0, 160, 400) oam.draw_sprites() love.graphics.setCanvas() -- reset to main FB love.graphics.setColor(1, 1, 1) love.graphics.push() love.graphics.scale(2, 2) love.graphics.draw(oam.canvas, x / 2, y / 2) love.graphics.pop() end return oam
----------------------------------- -- Area: Vunkerl Inlet [S] -- NM: Big Bang ----------------------------------- require("scripts/globals/hunts") require("scripts/globals/status") ----------------------------------- function onMobInitialize(mob) mob:setMod(tpz.mod.MOVE, 12) end function onMobDeath(mob, player, isKiller) tpz.hunts.checkHunt(mob, player, 488) end
local RunService = game:GetService("RunService") local Signal = require(script.Parent.Signal) local NoYield = require(script.Parent.NoYield) local Store = {} -- This value is exposed as a private value so that the test code can stay in -- sync with what event we listen to for dispatching the Changed event. -- It may not be Heartbeat in the future. Store._flushEvent = RunService.Heartbeat Store.__index = Store --[[ Create a new Store whose state is transformed by the given reducer function. Each time an action is dispatched to the store, the new state of the store is given by: state = reducer(state, action) Reducers do not mutate the state object, so the original state is still valid. ]] function Store.new(reducer, initialState, middlewares) assert(typeof(reducer) == "function", "Bad argument #1 to Store.new, expected function.") assert(middlewares == nil or typeof(middlewares) == "table", "Bad argument #3 to Store.new, expected nil or table.") local self = {} self._reducer = reducer self._state = reducer( initialState, { type = "@@INIT" } ) self._lastState = self._state self._mutatedSinceFlush = false self._connections = {} self.changed = Signal.new() setmetatable(self, Store) local connection = self._flushEvent:Connect( function() self:flush() end ) table.insert(self._connections, connection) if middlewares then local unboundDispatch = self.dispatch local dispatch = function(...) return unboundDispatch(self, ...) end for i = #middlewares, 1, -1 do local middleware = middlewares[i] dispatch = middleware(dispatch, self) end self.dispatch = function(self, ...) return dispatch(...) end end return self end --[[ Get the current state of the Store. Do not mutate this! ]] function Store:getState() return self._state end --[[ Dispatch an action to the store. This allows the store's reducer to mutate the state of the application by creating a new copy of the state. Listeners on the changed event of the store are notified when the state changes, but not necessarily on every Dispatch. ]] function Store:dispatch(action) if typeof(action) == "table" then if action.type == nil then error("action does not have a type field", 2) end self._state = self._reducer(self._state, action) self._mutatedSinceFlush = true else error(("actions of type %q are not permitted"):format(typeof(action)), 2) end end --[[ Marks the store as deleted, disconnecting any outstanding connections. ]] function Store:destruct() for _, connection in ipairs(self._connections) do connection:Disconnect() end self._connections = nil end --[[ Flush all pending actions since the last change event was dispatched. ]] function Store:flush() if not self._mutatedSinceFlush then return end self._mutatedSinceFlush = false -- On self.changed:fire(), further actions may be immediately dispatched, in -- which case self._lastState will be set to the most recent self._state, -- unless we cache this value first local state = self._state -- If a changed listener yields, *very* surprising bugs can ensue. -- Because of that, changed listeners cannot yield. NoYield( function() self.changed:fire(state, self._lastState) end ) self._lastState = state end return Store
require "GThieves/G_OnDismantleTimedAction" require "GThieves/G_OnPickLockTimedAction" G_OnRightClickContextMenu = {}; G_OnRightClickContextMenu.doMenu = function(player, context, worldobjects) for i,v in ipairs(worldobjects) do local checkObject = nil; local ojects = v:getSquare():getObjects(); if ojects:size() > 0 then for i2=0, ojects:size()-1 do checkObject = v:getSquare():getObjects():get(i2); local spr = checkObject:getSprite(); local sprn = spr:getName(); if string.find(sprn, "appliances_telev") then -- appliances_television G_OnRightClickContextMenu._ctxa_Dismantle(context, checkObject, player, "tv") elseif string.find(sprn, "appliances_laundry") then G_OnRightClickContextMenu._ctxa_Dismantle(context, checkObject, player, "laundry") elseif string.find(sprn, "location_shop_accessories_01") then G_OnRightClickContextMenu._ctxa_Dismantle(context, checkObject, player, "cashreg") elseif instanceof(checkObject, "IsoDoor") or (instanceof(checkObject, "IsoThumpable") and v:isDoor()) then G_OnRightClickContextMenu._ctxa_PickLock(context, checkObject, player) end end end end end G_OnRightClickContextMenu.onDismantleObject = function(object, player, kind) local playerObj = getSpecificPlayer(player); if luautils.walkToObject(playerObj, object, false) then ISTimedActionQueue.add(G_OnDismantleTimedAction:new(playerObj, object, kind)); end end G_OnRightClickContextMenu.onPickLock = function(object, player) local playerObj = getSpecificPlayer(player); local perkLvl = playerObj:getPerkLevel(Perks.Lightfoot) if luautils.walkAdj(playerObj, object:getSquare()) then local time0 = 350 - 300 * (perkLvl / 10) if playerObj:getDescriptor():getProfession() == "burglar" and time0 > 80 then time0 = 80 end ISTimedActionQueue.add(G_OnPickLockTimedAction:new(playerObj, object, time0)); end end G_OnRightClickContextMenu._ctxa_Dismantle = function(context, object, playerId, kind) local label = "Hardware" if kind == "laundry" then label = "Laundry Machine" elseif kind == "tv" then label = "TV" elseif kind == "cashreg" then label = "Cash Register" end local addedOption = context:addOption("Dismantle " .. label, object, G_OnRightClickContextMenu.onDismantleObject, playerId, kind); if addedOption and not getSpecificPlayer(playerId):getInventory():contains("Screwdriver") then addedOption.onSelect = nil; addedOption.notAvailable = true; end end G_OnRightClickContextMenu._ctxa_PickLock = function(context, object, playerId) local doorKeyId = nil if instanceof(object, "IsoDoor") then doorKeyId = object:checkKeyId() if doorKeyId == -1 then doorKeyId = nil end elseif instanceof(v, "IsoThumpable") then doorKeyId = object:getKeyId() end if doorKeyId == nil then return end local character = getSpecificPlayer(playerId) if not object:IsOpen() and not character:getInventory():haveThisKeyId(doorKeyId) and object:isLocked() then -- player doesn't have a key local addedOption = context:addOption("Pick Lock", object, G_OnRightClickContextMenu.onPickLock, playerId); if not character:getDescriptor():getProfession() == "burglar" and not character:getKnownRecipes():contains("PickLock") then addedOption.onSelect = nil; addedOption.notAvailable = true; end if not character:getInventory():contains("Paperclip") or not character:getInventory():contains("Screwdriver") then addedOption.onSelect = nil; addedOption.notAvailable = true; end end end Events.OnFillWorldObjectContextMenu.Add(G_OnRightClickContextMenu.doMenu);
require("core.lsp").run("css")
---@class CS.UnityEngine.ImageConversion ---@type CS.UnityEngine.ImageConversion CS.UnityEngine.ImageConversion = { } ---@return Byte[] function CS.UnityEngine.ImageConversion.EncodeToTGA() end ---@return Byte[] function CS.UnityEngine.ImageConversion.EncodeToPNG() end ---@overload fun(): Byte[] ---@return Byte[] ---@param quality number function CS.UnityEngine.ImageConversion.EncodeToJPG(quality) end ---@overload fun(): Byte[] ---@return Byte[] ---@param flags number function CS.UnityEngine.ImageConversion.EncodeToEXR(flags) end ---@overload fun(data:Byte[]): boolean ---@return boolean ---@param data Byte[] ---@param markNonReadable boolean function CS.UnityEngine.ImageConversion.LoadImage(data, markNonReadable) end return CS.UnityEngine.ImageConversion
require("libs.cocos.ui.experimentalUIConstants")
-- Hojicha localization strings for English (default) local AddonName = ... local L = LibStub('AceLocale-3.0'):NewLocale(AddonName, 'enUS', true) L.AddonUpgradedToVersion = "Upgraded to v%s-%s"
function getInfo() return { onNoUnits = SUCCESS, -- instant success tooltip = "Move a group of units along a path (not in any specified formation).", parameterDefs = { { name = "unitsToMove", variableType = "expression", componentType = "editBox", defaultValue = "", }, { name = "path", variableType = "expression", componentType = "editBox", defaultValue = "", }, } } end -- constants local THRESHOLD = 1024 -- speed-ups local SpringGetUnitPosition = Spring.GetUnitPosition local SpringGiveOrderToUnit = Spring.GiveOrderToUnit local SpringGetUnitHealth = Spring.GetUnitHealth commandsIssued = false function Run(self, units, parameter) local unitsToMove = parameter.unitsToMove local path = parameter.path local cmdID = CMD.MOVE if not commandsIssued then for i=1, #unitsToMove do local currUid = unitsToMove[i] for j=1, #path do SpringGiveOrderToUnit(currUid, cmdID, path[j]:AsSpringVector(), {"shift"}) end end commandsIssued = true return RUNNING end for i=1, #unitsToMove do local currUid = unitsToMove[i] local pointX, pointY, pointZ = SpringGetUnitPosition(currUid) local currUidLoc = Vec3(pointX, pointY, pointZ) if currUidLoc:Distance(path[#path]) > THRESHOLD then if SpringGetUnitHealth(currUid) ~= nil then return RUNNING end end end return SUCCESS end function Reset(self) commandsIssued = false end
--------------------------------- --! @file InPortConnectorBase.lua --! @brief InPortコネクタ基底クラス定義 --------------------------------- --[[ Copyright (c) 2017 Nobuhiko Miyamoto ]] local InPortConnector= {} --_G["openrtm.InPortConnectorBase"] = InPortConnector local ConnectorBase = require "openrtm.ConnectorBase" InPortConnector = {} -- InPortコネクタ基底オブジェクト初期化 -- @param info プロファイル -- @param buffer バッファ -- @return InPortコネクタ InPortConnector.new = function(info, buffer) local obj = {} setmetatable(obj, {__index=ConnectorBase.new()}) local Manager = require "openrtm.Manager" obj._rtcout = Manager:instance():getLogbuf("InPortConnector") obj._ReturnCode_t = Manager:instance():getORB().types:lookup("::RTC::ReturnCode_t").labelvalue obj._profile = info obj._buffer = buffer obj._dataType = nil obj._endian = true -- プロファイル取得 -- @return プロファイル function obj:profile() self._rtcout:RTC_TRACE("profile()") return self._profile end -- コネクタID取得 -- @return コネクタID function obj:id() self._rtcout:RTC_TRACE("id() = "..self:profile().id) return self:profile().id end -- コネクタ名取得 -- @return コネクタ名 function obj:name() self._rtcout:RTC_TRACE("name() = "..self:profile().name) return self:profile().name end -- コネクタ切断 -- @return リターンコード function obj:disconnect() return DataPortStatus.PORT_OK end -- バッファ取得 -- @return バッファ function obj:getBuffer() return self._buffer end -- データ読み込み -- @param data data._data:データ格納オブジェクト -- @return リターンコード function obj:read(data) return DataPortStatus.PORT_ERROR end -- プロファイル設定 -- @param profile プロファイル -- @return リターンコード function obj:setConnectorInfo(profile) self._profile = profile return self._ReturnCode_t.RTC_OK end -- データ型設定 -- @param data データ型 function obj:setDataType(data) self._dataType = data --print(self._dataType) end return obj end return InPortConnector
function Update_Drone0(CustomGroup, playerIndex, shipID) SobGroup_CreateIfNotExist("dronefrigate_temp") SobGroup_Clear("dronefrigate_temp") SobGroup_FillShipsByType("dronefrigate_temp", "Player_Ships"..playerIndex, "kus_dronefrigate") if SobGroup_FillProximitySobGroup ("temp", "dronefrigate_temp", CustomGroup, 1000) == 0 then SobGroup_TakeDamage(CustomGroup, 1) end end
----------------------------------- -- Area: Valley of Sorrows -- NPC: qm1 (???) -- Spawns Adamantoise or Aspidochelone -- !pos 0 0 -37 59 ----------------------------------- local ID = require("scripts/zones/Valley_of_Sorrows/IDs") require("scripts/globals/npc_util") require("scripts/globals/settings") require("scripts/globals/status") ----------------------------------- function onSpawn(npc) if LandKingSystem_NQ < 1 and LandKingSystem_HQ < 1 then npc:setStatus(tpz.status.DISAPPEAR) end end function onTrade(player,npc,trade) if not GetMobByID(ID.mob.ADAMANTOISE):isSpawned() and not GetMobByID(ID.mob.ASPIDOCHELONE):isSpawned() then if LandKingSystem_NQ ~= 0 and npcUtil.tradeHas(trade, 3343) and npcUtil.popFromQM(player, npc, ID.mob.ADAMANTOISE) then player:confirmTrade() elseif LandKingSystem_HQ ~= 0 and npcUtil.tradeHas(trade, 3344) and npcUtil.popFromQM(player, npc, ID.mob.ASPIDOCHELONE) then player:confirmTrade() end end end function onTrigger(player,npc) player:messageSpecial(ID.text.NOTHING_OUT_OF_ORDINARY) end function onEventUpdate(player,csid,option) end function onEventFinish(player,csid,option) end
module(..., package.seeall) function new(mainCharStatus) local group = display.newGroup() local speed = 0.5 local hostage local clickMeImage function group:spawnHostage() hasCheckedStatus = false local options = { width = 128, height = 128, numFrames = 16, sheetContentWidth = 512, sheetContentHeight = 512 } local imageSheet = graphics.newImageSheet("images/mm.png", options) local sequenceData = { {name="crying", start=1, count=4, time=400, loopCount = 0}, {name="releasing", start=5, count=4, time=1000, loopCount = 1}, {name="kissing", start=9, count=4, time=1300, loopCount = 1}, {name="laughing", start=13, count=4, time=400, loopCount = 0}, } hostage = display.newSprite(imageSheet, sequenceData) hostage:play() hostage.x = 400 hostage.y = 70 hostage.xScale = 0.35 hostage.yScale = 0.35 hostage.isClicked = false hostage.clickMeHasShown = false group:insert(hostage) end local function moveUpAndDown(target) transition.to(target, {time=500, y=target.y+10}) transition.to(target, {time=500, delay=500, y=target.y, onComplete=function() moveUpAndDown(target) end}) end local function clickMeListener(event) if event.phase == "began" and not hasCheckedStatus then if clickMeImage then clickMeImage:removeSelf() clickMeImage = nil end hostage.isClicked = true end end function group:addClickMe() clickMeImage = display.newImage("images/buttons/buttonHostage.png") clickMeImage.x = hostage.x clickMeImage.y = hostage.y -30 moveUpAndDown(clickMeImage) clickMeImage:addEventListener("touch", clickMeListener) hostage:addEventListener("touch", clickMeListener) group:insert(clickMeImage) end function group:updateHostage(collisionRectX, shouldMove) if hostage then if not hostage.clickMeHasShown and hostage.x <= collisionRectX + 120 then self.addClickMe() hostage.clickMeHasShown = true end collisionRectX = collisionRectX + 15 if shouldMove then hostage.x = hostage.x - speed if hostage.clickMeHasShown and clickMeImage then clickMeImage.x = clickMeImage.x - speed end end if hostage.x <= collisionRectX and hostage.sequence == "crying" and hostage.isClicked then hostage:setSequence("releasing") hostage:play() elseif hostage.sequence == "releasing" and not hostage.isPlaying then hostage:setSequence("kissing") hostage:play() elseif hostage.sequence == "kissing" and not hostage.isPlaying then hostage:setSequence("laughing") mainCharStatus["coins"]:increaseCoinsByN(math.random(3,5)) hostage:play() end if not hasCheckedStatus and hostage.x <= collisionRectX then hasCheckedStatus = true if clickMeImage then clickMeImage:removeSelf() clickMeImage = nil end end if hostage.x <= -100 then group:removeHostage() end if hostage then return (hostage.sequence == "releasing" or hostage.sequence == "kissing") else return nil end end end function group:isExist() if hostage then return true else return false end end function group:removeHostage() if clickMeImage then clickMeImage:removeSelf() clickMeImage = nil end hostage:removeSelf() hostage = nil end return group end
--- -- Pass a signal through, performing no operation. -- -- $$ y[n] = x[n] $$ -- -- @category Miscellaneous -- @block NopBlock -- -- @signature in:any > out:copy -- -- @usage -- local nop = radio.NopBlock() -- top:connect(src, nop, snk) local ffi = require('ffi') local block = require('radio.core.block') local NopBlock = block.factory("NopBlock") function NopBlock:instantiate() self:add_type_signature({block.Input("in", function (type) return true end)}, {block.Output("out", "copy")}) end function NopBlock:process(x) return x end return NopBlock
-- видеоскрипт для сайта https://www.youtube.com (12/3/21) -- https://github.com/Nexterr-origin/simpleTV-YouTube --[[ Copyright © 2017-2021 Nexterr Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ]] -- UTF-8 without BOM -- поиск из окна "Открыть URL" (Ctrl+N), префиксы: - (видео), -- (плейлисты), --- (каналы), -+ (прямые трансляции) -- авторизаця: файл формата "Netscape HTTP Cookie File" - cookies.txt поместить в папку 'work' -- показать на OSD плейлист / выбор качества: Ctrl+M -------------------------------------------------------------------- local infoInFile = false -------------------------------------------------------------------- if m_simpleTV.Control.ChangeAddress ~= 'No' then return end if not m_simpleTV.Control.CurrentAddress:match('^[%p%a%s]*https?://[%a.]*youtu[.combe]') and not m_simpleTV.Control.CurrentAddress:match('^https?://[%w.]*hooktube%.com') and not m_simpleTV.Control.CurrentAddress:match('^https?://[%w.]*invidio[%a]*%.') and not m_simpleTV.Control.CurrentAddress:match('^[%p%a%s]*https?://y2u%.be') and not m_simpleTV.Control.CurrentAddress_UTF8:match('^%-') then return end if infoInFile then infoInFile = os.clock() end local inAdr if m_simpleTV.Control.CurrentAddress_UTF8:match('^%-') then inAdr = m_simpleTV.Control.CurrentAddress_UTF8 else inAdr = m_simpleTV.Control.CurrentAddress end local urlAdr = inAdr m_simpleTV.Control.ChangeAddress = 'Yes' m_simpleTV.Control.CurrentAddress = 'error' if not m_simpleTV.User then m_simpleTV.User = {} end if not m_simpleTV.User.YT then m_simpleTV.User.YT = {} end if not m_simpleTV.User.YT.VersionCheck then local _, strVer = m_simpleTV.Common.GetVersion() local vlcVer = m_simpleTV.Common.GetVlcVersion() if not (strVer:match('b12%.7%.7') or strVer:match('b12%.7%.7 test') or strVer:match('b12%.7%.6')) or vlcVer < 3000 then local msg = 'simpleTV need 0.5.0 b12.7.6 (vlc 3.0.11)' local link = 'https://mega.nz/folder/G74EBKDQ#77wUEcj-IfrmghM8QVti3w/folder/C2o21LZL' m_simpleTV.Interface.MessageBox(msg, 'YouTube', 0x10) m_simpleTV.Interface.OpenLink(link) return end m_simpleTV.User.YT.VersionCheck = true end htmlEntities = require 'htmlEntities' require 'lfs' require 'asynPlsLoaderHelper' if not m_simpleTV.User then m_simpleTV.User = {} end if not m_simpleTV.User.YT then m_simpleTV.User.YT = {} end if not m_simpleTV.User.YT.logoPicFromDisk then local path = m_simpleTV.Common.GetMainPath(1) .. 'Channel/' local f = path .. 'logo/Icons/YT_logo.png' local size = lfs.attributes(f, 'size') if not size then lfs.mkdir(path) local pathL = path .. 'logo/' lfs.mkdir(pathL) local pathI = pathL .. 'Icons/' lfs.mkdir(pathI) local fhandle = io.open(f, 'w+b') if fhandle then local logo = 'iVBORw0KGgoAAAANSUhEUgAAAyAAAAJYCAMAAACtqHJCAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAMAUExURQAAAAEAAgECAAICAgEBBAQAAAUAAgUCAAUCAwUCBAUFBQkAAQkAAggCAQ0AAAwAAg4CAQwCAgkJCQ4ODhIBAREBAhICARACAxABBBUAARUAAhcCARkAAR4BAR4AAhERERQUFBkZGR0dHSABACEAAiUAACQBAikBAi8CAzEBATIAAjQBATQBAjsBAj4BAj4CACEhISUlJSoqKi0tLTIyMjU1NTk5OT09PUAAAUAAA0QAAEUAAkUCAksBAk8BAU0BBFIBAVICBFYAAFQBAlUCAFkAAFgBA1wAAV4BBGABAGAAAmICAmUBAWoBAW0BAW8BAnEAAXEAAnQAAXcBAnUCA3gBAH0BAUBAQEVFRUpKSk1NTVFRUVZWVllZWV5eXmJiYmVlZWlpaW1tbXFxcXV1dXl5eX19fYIBA4MCAoUBAoQBBIkAAYgAAosBBI0BAYwCBpEBApYBAZUBBJ0BAqABAqUBAaQAAqkBAakBBK8BAbEBA7QBAboAALoBA7oCAbsCArkBBL4BAbwBAr0CA8YBAckBAs0AAtEAANABAtECA9YBAdcBAtkAAdwAAeEAAOUAAeUCBukAAO0AAO0BAuwCAe8CA+8BBPABAfYAAPUBAvQCAfoAAPoBAvoCAfoCAvsBBP0AAP0AAvwCAPwCAv0CBPwEA/wFBfwKCv0OEP0QEf4VFfwWGfsYGfwaGv0eHv4fIP0gH/slJf4gIPwlJPwoKv0vMPwxMfw0Ofw+PvxOUPxRU/xYVf5bXfxcXf1qavt7e/15fPx/fIGBgYWFhYiIiI2NjZGRkZWVlZmZmZycnKGhoaampqmpqa2trbKysrS0tLm5ub29vfuDgf2RkfyVk/yWlvyYl/2jo/2kpPyqqfu7u/66uv7Bv8HBwcbGxsnJyc3NzdDQ0NXV1dnZ2d3d3fzDwfzFw/zJxvvPzvzR0P7d2/zc3OHh4eXl5enp6e3t7f3k4f3m5v3s7P3w7fHx8fX19fzz8fz29f349vn5+fr++/v+/P75+f39+/7+/gAAAKO0mi0AAAEAdFJOU////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wBT9wclAAAPo0lEQVR4Xu3de5yc1V0H4BkG0rog6K54wcomMQWpbQ2BEIVWsYqX2lZayzXcCVEsYpG2WLHW1gZQCzGgQgy32SDWG2rVipdWJUBKEm7eqyYhWbyWJIrZ0pF0Pr6X3/vOzO5mMrvZjWnmeT5c5py5vPnjfPOe877nnLcCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACHvmr2T/Zv8t9E9mKCqM7eHv+R6oQaOGSkocgc85ULTnjNN37T6ad/53ef9ea3v/3ss9/xQ+961zWFc85OfN9ZZ33X6Wd8y0mvffWC4449IvtWmhkJ4VB15PGv+Y63XXP9T9182+rVd6+5Z8399ftDvV6+TI1ExUjy75r716y5+67Vd/z8h9577Tu/53ULvqIWvwaHjGp1znHf+4GVd2XNf7+s+cUV7zy+WktPJwebwaEwEBXQo+orz111/wPRxvdTfe2vvOdra7XD46cPHo/sDqdGBfRowYr62rS/NCPq9bUr39CRj9pwoa3/NRBVw0NR0bvB+OYkupwd1jXD4qiAXlSrJ/5CxxBjBqz+tvax+uBoIzd2StQkrmiM5ZVPREXvnsi/OJkL4yOTeDTyISBMyZyv+rmRu2fs/JEbuePE+PXMxmiazUuiIvF0VDW7tOm92BDfnISAMNNqP1Kvj6yNlj1D1t6z4si2c8hF0TSbn46K5KyyM6p2z42a3gkIB9AJd89wOnLfXmsFZG4j2uZzUVGpnFxWTf26sIBwAF0dLXqGfaR6WBwgOUltibbZGIyaytKoaT4SFVMgIBw4R/zsAzM9RM/cd3wrIK0rSOdFRau5TuOiq4BwoFQrx62JFj3D1p4Vh0gtibbZvCoqKsU5ZUd5TumdgHDgvDEa9Iy7tv1C71g0ziejYqgYghQVU7F0edgWP9J8IiqWnxwfmYSAMA3Vc6M9z7SRD7bPNnkyGudo3MlbHOXmZXl5ejbFj7R6bl0ICNNQvSEa9Iz76BFxiNRl0Tgbw3n58ig35+Xl6REQZt3N0Z5nWn11e0AWFV2qC/JyMYzYtl+TfwWEWVY9ZmU06JlWH/m6OEZqYEe0znV5eTSKj+XFaRIQZttxd0aD7uaee+PFVIy8Pg6R+XS0zmez0nCUmudnxekSEGbbgmjO3TzwYGvtVM/qI+3XeSsXRut8Ibuse0GUxtqn8tYGBqbY4dqvgOztaLVEvKTvVb8h2nM3v/MvD099Nkq9fk4cIzNvd946G/PTUnHj8NmiKQ6ev+6pLaOjW59+9Pz2GyPDc0P+ucHhvKKYIj8uIIPZm4l4ezg+ns/26gjI0CWbnhvdsuGCcdPja4uv3Lh5y5YtTz12UVxNoM+9oYdzw0N79vzD761JMjKl80j92jhEpvZcNM+L0kJxm/DK/M2hZcXUxcTOK8vTynBx+yQudl0VpeLuybiALI9Sc2NWbH07a+xtARm4pDje1oWV1uli4KLtUZ1oPL5fF9g4RJwVzbmbj+/53+bn/uJj90ytn1V/TxwiV7TedELvULTPRn5fb1ExZA/bsrNMYj8DUlw5a2aJawVkoBgQJZ5vTSYeKmfg53YsijfoY2/todX/7p60vfznn/zq1M4g749D5E7NGl0+oXdRvH4+6+EsbDt95EajfzM0OwF5LF5kNpa9vGejprSjCCr965xozt3kAWk2//EP6/dF1b7VRz4ch8gVC0B2J43/kvxlc0P6xkDR32rzZD42mJ2AlB/LjC1M30xSUk6obHkqfYu+dk20526KgDQ//9e/HVW9uCUOEWK2SSMZIz+Rv8zvGpY31ds08hY/OwEpfzT3aPbh1gKVdqfl79G/fixaczdlQJrNFz/1az33s26OQ4RL4ycur9RizLE7bbhDL+SFpMO1/old8bK5OfvK7AQkyd/2Z8sjNbfnfayy37V52bLigkJz6uvlOcS8L1pzN20BaTb/4+G19/V20ffWo+IYuYXxAxsqc+OS75a0aZ6fv04GHslw+ZSi3Tayjs8sBWTXebXK/OejEGt+a8Wt/qeS3t3g1ijkgyT62I09D9ILez7z+71t8XDrl8YxQlxD3VaO17PFhEV3K7v+22rFV6Sl2QlI3n8rlzTmS7ZOi0J+b//iKDTntS4C05dujNbcTWdAms2X/vLXe7knctuRcYxQdGIGis5WeseunKS1K7tyVU6DzyIwOwHJLg1UhuM01mxemhaL7zayz5YDkqVpiT72kWjN3YwPyBea//WnD3Zu1zuZVUfHMULRmVr8eP7/HWn/ZWHRFEezv6sHWsWkPDsByT9cKVdbZaP04h7Ijuy98gbM8qxI/7olWnM34wOS+tdP7HOroPEBmRut7tLo4W9KK8uuTT4srxRD9kaantkJSMzFKjfrSs8oA8U99G3Ze7Xi9GKU3u96WQ4yWUCae/52X5d8xwekWIf+eLS+rGtT3BLJ41KplBeQ0pvssxqQ8r7H00mhuLdfbExUDtnzIn3rpmjN3UwakObL//Nn8f5eTAjIsvyLo3nDzaYt1so2nzfqyjNRzAbLsxqQ+NPk565y/n2alkRxQonzGn1r+gF56e9+s/tIfUJATolv5rZndeXth8ezYisg6UWtWQ1Icakg+4OcHK/HByT/Q9K/ptvFevmfPzHVMUirH5PJ72Cvj9KEgFyeFGY1IMUy+eZoUihmhwkInaY5SP/sJ++9f8oBKfc2ySzprDrgASlHP2lAymsFAkKHD0dr7mZCQF78q14mnKycEJDy/ltiZ9Zq9x6QdIu5WQ1IscYxC8h58VpA6FCd+p305p7PPBRvdHdr+wbvmXllk202n8mr9hqQ9Db7/0NANi9adMopi8oVKgLS56o/Ea25m86A/PvDa6c1FysxUN6ci7kkB19AxhGQfnd9tOZu2gPy35/q4R567qNz4hgtZSONtekCwkFuatPdP/c3H4u6Hoyb7p5qtcPtMU9WQDio9bI1bwTkC41/+oOpbJC1Ig7RptzEunzWlIBwMKu+o/dB+mf/+J4pPMqwPvKBOEa7ct138bRCAeGg9pYeAvLxJCAvv/jnva8lzNTfG4doV24ckq3+SBxsAdl6QbsL8x+mf31rNOdukoC89Pe/tXaK2yvWr4tDtOs9IFfM2nT3CEi5YqojIHEfBDLV10Vz7uahz//bH91bT/IxlYTU7//BOEa7CQEpJ52PD8is30kv52KlASmniQkI7aon9jCs+I1PPhivpqA+8rY4RrsJAYnFUxMDkk6GPzABSZeAjJ+LBblX3RUNuov6SHL+mLoz4xDtJgSkXJURl7XKgKRPG5zVgHRMd58Xr4uADA5P49mJHHqqx66K5tzVPfH/KaiPnBTHaDchIFdEuVgwVewnkjXjWQ1IWU5/bKhYQrg1f/OysbHdo9ue2XhxXqRvzbk1GvSMG5kwVzExISAXRbn4q7vcpjfdw2G6AcnDto+AlJcH1ieFwWKpb6woLHazi44f/auXXRumZdUr4gjtJgSk3MYkWmbxN/nOdA+HVkDyXa5n8gxSKzesS7eYrxVnrheyN8uen4D0uznXRXuecTe1P6OwMCEgxU4O8cD0Yne5fK1ruXdCLB7pNSD5TOHuAZlfhi/7crFwK9ssolJ5Kor794g4vvhV3xLtecbdMG6ue2ZCQGrFDoeN7GED5aWlfL1huQRxWVoaKJrtXgJS7vL7QnL6qbXuBI4LSLZZROtIY1n3rbwrkm3HO1Ts8JhebKaPVSsnRXueafUfiEN0mBCQVrtNd9gZLOfD502+HLJvS84vg63HFkwekDIRjeSEU1vcWuDbGZCxpbVKrfXMhXx70fJ0syHt25Uru7JdF+lf1cqRd07nEu6+rT0jDtFhYkDKQUjjsVOXlKeInXlPp/Wkm6cvXta2mGTygJQ3M5o7r7xkU9nBGh+QZnPr+o2tzavzjRZbf7L1S05bXnTtsr3t6G+9rCmchl8+6rA4QLuJAWlfRNUSOxqW17hC0R+bPCCdm0I0m7uKYcb4gHTIhzflc0U7GKNTedPsBOS6Wm8BqZzX9ld94YV4xFTx6M+wa0l8dvKAtMq5q4q5wx0BaXT+5nNxkpjsOT67Ws9no28ddWs6cWqmrT5xsjH6ZAGplbNNSo3y8enlVK3MpcWO03sJyOKOrG0eKAYtHQHZXN6bzJTbUy/qDE6i0fpD0r9qb8wmIs6okbVXHzZ+x4bMJAGpDGyIusLYpelAOTO/rdfUuKpSiT7WXgJSK5+lkBidX16p6gjII7VyL65EsXArcUFrXJIZK9as0NdqX3L13fUprITqRf2nxz0bpDBZQCq1y8ubdqktcas7c2r51s40NnH7ey8BqQyWNY1NSS+t2O2qIyDJr19ZPqdnffsofOHTbWegxtOnRDV9rjrnR++e4TPIz3z1pB2sSuWSdaGz9Q0u3fT8rrFGY/fObesXl6ePzPC60V1jY7u2P5INS87Pvx1TpC7OS+vWZc+jStWWbt45NrZ7x6bT0l8Zireze5Dx1eVpYe7y53bu3r3jySWdx6otemzbzt1jyTtb1p3c+Rb97JVv/qWZG4eM1Ndc++WT9q+6Ghiev3DhvOzv+nEG5i5cONx7cx2av3Devqfi1obmzp30U4Nz58+b/B361+EL3r1q7cwkpH7nj7+2NvV8wMGreli18opvPueGFbfeviba+XTcftst77/mzKOraTwkhEPQEUcfe8Lrz3zruddc/74bf3LFTR+9beXKVatW3X5nZvVdidX56zuS6lUrV952000fuvGG69/9w9//pjNOPO7LjqpWDtN151BVzWWv0n8OT17OOeboo499VebrX51YkL/+mqMT2QeT7lTy0eQUlHz4CCcO6CARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwxadS+T+1mwqMp9zWOgAAAABJRU5ErkJggg==' logo = decode64(logo) fhandle:write(logo) fhandle:close() end end m_simpleTV.User.YT.logoPicFromDisk = f end if not m_simpleTV.User.YT.playPicFromDisk then local path = m_simpleTV.Common.GetMainPath(1) .. 'Channel/' local f = path .. 'logo/Icons/YT_play.png' local size = lfs.attributes(f, 'size') if not size then lfs.mkdir(path) local pathL = path .. 'logo/' lfs.mkdir(pathL) local pathI = pathL .. 'Icons/' lfs.mkdir(pathI) local fhandle = io.open(f, 'w+b') if fhandle then local logo = 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAjdSURBVFhHlVdZbFTXGf7uOnNnPMYe22Mbg02xA9hAopCkTVBK0/YhDzVSmlZVIrV9IE2ktg+VKuUhaSXU0hdeioSiLoqqUlWFKumSpaRJiRoghEJAZUkwjk3B2Abj3Z597trvv7NglkL6y//cO8fn/N/3L+c/ZxT8H6L1fNRU12A+eu9aa2Nzo74yUBRTQeDl897U0KXC+dGxmX95w5v/w6lBecXd5e4Emo5oK9a3PdmzOvqc7eOxrg5Dt6IKVBUwDQWOG8BxgJITYHzCDZySO1DKFX539uTJ33hXvjlXsfI/5Y4EWh8Z+lJXl7W7oVFb392p44G+CBJxIsuqysqaAfpsk8TZIRunBx1MTtpzpcz8zwbff/4XKBwoVWbdIrcnsOKosWZD+85Eo/GD+/tM9bMbI9AMjiucrlLLfzeulqAHARSfDz/A0IiDd44UkFvMHxk9f+hbxZHnRsoTb5SlJsrS/bG1ujv+SlPK6O//goWGBo3J5zQCK3S+SiAkU11N4DIBDhEcol4AuxTgjffyuHgxf3lu9NATueHvnCnPui60vkSY7/ae5KupNnNr/2MWTObaIUpVbYLalWc4FixVwKX3jqhXfvrUnpU60gW1YSbb1u+6LW/52YOzFbRQbiDQsPGFHY0t5rOPb4lCYYHZUCugNMbYFn2v/J2hcMJx/p//s0nAJgFRAWaxwnbLKkW6IqViPqPWz+a6Njsz778Kf7oQAlJqBMy+gYciicieL2+Oqma0AhyCKOhuV7DtsXr0dWiYzeYxnnFhq3qZiEREVEj4ohUSEgXZIRVtb1JxeUpvL/j3qf7c3oOE5Kwage2KsWLTHzf0RVa1pjQapyEB516zlQAP9+jobDZgRTSs74jhM0kF4ws5TBWZZ02vRINpCMH5TnA7BC4/ZXd4rIn6mIKRycT9Xm7mdZQ+nhTkkIC+7ldb6pLm9g3rDHiagFIFPNQAvctVdDaZIWXaQV3MwKaVceiKjb8PLWAgrWLW0VHw1LBGXSEhwEKCPUII2MyPSVsLGdXIFlO6P7fvH2JO6hpaRHsm1aKhROZZLshyYVbeibjoKkgzrmFoCe7RUz7CHbClux57v7Ec39vooVSYxeBiEcemgfOLwJyrcr1CO1SxSc1R21gPWnzVE4CVCrGR/L1uNne93LFcY9lL2KkSBVXDAheP5gI8uBLoa4+UUatbryIqw7+h1cLXemNQnCwGrmWRYTRmc4wEAVVuUZfeO+IEVeUWnZ7X405R/TDIfzCg6k0b+3RTTdJhZDlRWOYcBZP5ANcKSpiSMK63AV8qcVPD9x9uwV+fSqG/K4fAWcB03sF42iehSmTZDwsMo8VaUOMbNnOZoSqG2adzy+VKfjhBSMyzuHIsoLABUXno3BF8qaQSBrY/3o69TyfxSFsa+Xwa0zSW5X7N0XaWOAwuFLPxHk7nflOVdoWVXmTeS9QCmUo1h17T+UCeQmCJyLeQU1XLwzdIT8rC7qe7sOvrdXDzs8gWvZBAnt3Ro31Fs5o5LSJFaMkCMSLFVS2wqihkKyefDN0MWtPqWEWXrv98byNazEV2RTfcQdKlRRRoUT4M1kjAbBOYH6K1vk6R9DO14bMGWgG5rcr/q8qPIlvhS6+dwdWFMKRh66lC+IEdnpCq4tkT7LBlcKFXmRGC60wSVeP+Fas1kOr7Uq2MywudwpvHL+DJnf/EnhM+9PqVHKZBASGWnBFw0vPyqQalhQGPeQ+k6ConmU4jES2gkgCf8r0KUAOrfl/6Tj0xfBXPvHwQu44uophcj1hzFwyD0RbHJAK073En+MWxyxwpqu6lHw96tjPtCQEmSVojE1MDFyI6i/RmoBp45f3i5Bxe/NMH2HFwDIsNa7CsYw1iiWWIGDq4ydgPxL4PlgL7ArmkD/2bI0XG5YjrlQr7HQ7KZULAJO8CbAoBrhRS0v9CwKryQ3Qmk8PuAyfxowPncSXWiebV61HX0IQo8yclLuvFIV3W00EBd3LTk0HmTbkbOJzCW2Vu/LclKUXmxyABWcCmiAjfQwLUMmCFBD8KJRv7jp7BC387iUG1CW1r70VDcyviEbMMLI6EduRJx0ICPBeKjMD80UOMgdyQAiEAb+QrR51c5pBEgU6HJCQSVSIyKQSWuazYd04N4sXXjuBkIYq2vvvQ0t6BOisKiwUroCF4Rau2hICkuZTJZr1rP/8zTfHUIJ58UHyYnxtEpPPb8XpNi9UpiFgqIrwRiWbzWXTWA4Pjk/j1e6cw7EaQXH0PlqVSiBJYZ0iIGxYZ2Mzk1PLZzXx2Pb9IzfsE9jE/xUZ0ad++IP36HzgzvBlVCYCDE4G11UAkuSXBe2CsjgQsIaCipGk4NjqDT9I24is6kexYjnjCQoSVqjM8YYTCIgu4mwScyoNHwD2qgM9OkMDIR2fdke/uJNo5zha61wlQAm92/4d+tL8XZn1vokEtk2AELMtAXWMC9c0NqFsWQyymI8pEG7wp62zVYXoI7gk4262Ae9JyCx4Kiz4mRz1MDY9dKX6y7Sfw5+U2dOuVrCwFx104/q6NR3tdZdnaOAnEEyqiPL0kEuKxPKMRJVT5YSLnVSDNheAewT2Cu/TazvlIz/gYG3IxcW5kLD/47E9hX9hPEGlANbmJAMWbLrhTf3m76D5oZfPND2iGrlr8MWKxJuSWHGFVmvQ+QtVZdGFbZcjlzHeZc9lNmTkPE5c8XDhVxMSZYyfy57ftgH3xLVqfKYNcl1sJhFIqurOvHC6kjdMLc63rFufjbS7vCCrDrdFlVdzmn7Rwm0d3PkPQeR8zVz1c5q+iwRMlXDg+Nj1z+pd77JHnd7HrHKbRGzyviqTvTkKCRqvR/sOt0bYvPpVY3v1QU0ci3timI9Go8dcSLywMfY55np90MXcl76SvDl/IX3n3sHPtpf0s/9O0MUGVPntbuRuBqjDYSEJLrtIbv7pJT6ztVc3GVkVRoz7LnufJgpcbHnMW3j4HZ/wS545SZZvxlLmzfFoCVZH5kja5IIoKMRkTD+V4FZV32ZSfQoD/AlgESWShsPObAAAAAElFTkSuQmCC' logo = decode64(logo) fhandle:write(logo) fhandle:close() end end m_simpleTV.User.YT.playPicFromDisk = f end local function inAdr_clean(inAdr) if not m_simpleTV.Common.isUTF8(inAdr) then inAdr = m_simpleTV.Common.multiByteToUTF8(inAdr) end inAdr = inAdr:gsub('^.-https?://', 'https://') inAdr = inAdr:gsub('[\'"%[%]()]+.-$', '') inAdr = m_simpleTV.Common.fromPercentEncoding(inAdr) inAdr = inAdr:gsub('[\'"]+.-$', '') inAdr = inAdr:gsub('amp;', '') inAdr = inAdr:gsub('\\', '/') inAdr = inAdr:gsub('$OPT:.-$', '') inAdr = inAdr:gsub('disable_polymer=%w+', '') inAdr = inAdr:gsub('%?pbjreload=.-$', '') inAdr = inAdr:gsub('%?action=%w+', '') inAdr = inAdr:gsub('%?sub_confirmation=%w+', '') inAdr = inAdr:gsub('flow=list', '') inAdr = inAdr:gsub('no_autoplay=%w+', '') inAdr = inAdr:gsub('start_radio=%d+', '') inAdr = inAdr:gsub('time_continue=', 't=') inAdr = inAdr:gsub('/videoseries', '/playlist') inAdr = inAdr:gsub('list_id=', 'list=') inAdr = inAdr:gsub('/feed%?', '?') inAdr = inAdr:gsub('//gaming%.', '//www.') inAdr = inAdr:gsub('/featured%?*', '') inAdr = inAdr:gsub('&nohtml5=%w+', '') inAdr = inAdr:gsub('&feature=[^&]*', '') inAdr = inAdr:gsub('&playnext=%w+', '') inAdr = inAdr:gsub('/tv%#/.-%?', '/watch?') inAdr = inAdr:gsub('&resume', '') inAdr = inAdr:gsub('&spf=%w+', '') inAdr = inAdr:gsub('/live%?.-$', '/live') inAdr = inAdr:gsub('%#t=', '&t=') inAdr = inAdr:gsub('&t=0s', '') inAdr = inAdr:gsub('&+', '&') inAdr = inAdr:gsub('%?+', '?') inAdr = inAdr:gsub('[&?/]+$', '') inAdr = inAdr:gsub('%s+', '') inAdr = inAdr:gsub('/([?=&])', '%1') if not inAdr:match('^https://[%a.]*youtu[.combe]') and not inAdr:match('^https://y[2out]*u%.be/') then inAdr = inAdr:gsub('^https://[^/]+(/.+)', 'https://www.youtube.com%1') end if not inAdr:match('music%.youtube%.com/browse') then inAdr = inAdr:gsub('//music%.', '//www.') end inAdr = inAdr:gsub('//youtube%.', '//www.youtube.') local id = inAdr:match('/playlist%?list=RD([^&]*)') if id and #id == 11 then inAdr = inAdr:gsub('/playlist%?list=RD[^&]*', '/watch?v='.. id .. '&list=RD' .. id) end return inAdr end local function SetBackground(pic, use) if m_simpleTV.Control.MainMode == 0 then use = use or 3 pic = pic or '' m_simpleTV.Interface.SetBackground({BackColor = 0, PictFileName = pic, TypeBackColor = 0, UseLogo = use, Once = 1}) end end local function infoPanelCheck() local infoPanel = tonumber(m_simpleTV.Config.GetValue('mainOsd/showTimeInfoPanel', 'simpleTVConfig') or 0) if infoPanel > 0 then return true end return false end if inAdr:match('https?://') and not inAdr:match('&is%a+=%a+') then inAdr = inAdr_clean(inAdr) end if not (inAdr:match('/user/') or inAdr:match('/channel/') or inAdr:match('/c/') or inAdr:match('&numVideo=') or inAdr:match('youtube%.com/%w+$') or inAdr:match('youtube%.com/[^/]+/playlists') or inAdr:match('&isRestart=true') or inAdr:match('/youtubei/') or inAdr:match('/watch_videos') or inAdr:match('music%.youtube%.com/browse') ) then if inAdr:match('&isPlst=') or inAdr:match('&isLogo=false') or m_simpleTV.Control.ChannelID ~= 268435455 then SetBackground() else if not inAdr:match('&isPlstsCh=true') then SetBackground(m_simpleTV.User.YT.logoPicFromDisk, 3) end end elseif inAdr:match('/videos') then SetBackground(m_simpleTV.User.YT.logoPicFromDisk, 3) elseif inAdr:match('/channel/') and inAdr:match('&isLogo=false') then SetBackground() end if not (m_simpleTV.Control.GetState() == 3 and m_simpleTV.User.YT.isVideo == false) then m_simpleTV.User.YT.isVideo = true end if not m_simpleTV.User.YT.Lng then m_simpleTV.User.YT.Lng = {} if m_simpleTV.Interface.GetLanguage() == 'ru' then m_simpleTV.User.YT.Lng.adaptiv = 'адаптивное' m_simpleTV.User.YT.Lng.desc = 'описание' m_simpleTV.User.YT.Lng.qlty = 'качество' m_simpleTV.User.YT.Lng.savePlstFolder = 'сохраненые плейлисты' m_simpleTV.User.YT.Lng.savePlst_1 = 'плейлист сохранен в файл' m_simpleTV.User.YT.Lng.savePlst_2 = 'в папку' m_simpleTV.User.YT.Lng.savePlst_3 = 'невозможно сохранить плейлист' m_simpleTV.User.YT.Lng.sub = 'субтитры' m_simpleTV.User.YT.Lng.subTr = 'перевод' m_simpleTV.User.YT.Lng.preview = 'предосмотр' m_simpleTV.User.YT.Lng.audio = 'аудио' m_simpleTV.User.YT.Lng.noAudio = 'нет аудио' m_simpleTV.User.YT.Lng.plst = 'плейлист' m_simpleTV.User.YT.Lng.error = 'ошибка' m_simpleTV.User.YT.Lng.live = 'прямая трансляция' m_simpleTV.User.YT.Lng.upLoadOnCh = 'загружено на канал' m_simpleTV.User.YT.Lng.loading = 'загрузка' m_simpleTV.User.YT.Lng.videoNotAvail = 'видео не доступно' m_simpleTV.User.YT.Lng.videoNotExst = 'видео не существует' m_simpleTV.User.YT.Lng.page = 'стр.' m_simpleTV.User.YT.Lng.hl = 'ru_RU' m_simpleTV.User.YT.Lng.hl_sub = 'ru' m_simpleTV.User.YT.Lng.camera = 'вид с видеокамеры' m_simpleTV.User.YT.Lng.camera_plst_title = 'список видеокамер' m_simpleTV.User.YT.Lng.channel = 'канал' m_simpleTV.User.YT.Lng.video = 'видео' m_simpleTV.User.YT.Lng.search = 'поиск' m_simpleTV.User.YT.Lng.notFound = 'не найдено' m_simpleTV.User.YT.Lng.started = 'начало в' m_simpleTV.User.YT.Lng.published = 'опубликовано' m_simpleTV.User.YT.Lng.duration = 'продолжительность' m_simpleTV.User.YT.Lng.relatedVideos = 'похожие видео' m_simpleTV.User.YT.Lng.link = 'открыть в браузере' m_simpleTV.User.YT.Lng.noCookies = 'ТРЕБУЕТСЯ ВХОД: используйте "cookies файл" для авторизации' m_simpleTV.User.YT.Lng.chapter = 'главы' elseif m_simpleTV.Interface.GetLanguage() == 'pt' then m_simpleTV.User.YT.Lng.adaptiv = 'adaptável' m_simpleTV.User.YT.Lng.desc = 'descrição' m_simpleTV.User.YT.Lng.qlty = 'qualidade' m_simpleTV.User.YT.Lng.savePlstFolder = 'playlists salvas' m_simpleTV.User.YT.Lng.savePlst_1 = 'lista de reprodução salva em arquivo' m_simpleTV.User.YT.Lng.savePlst_2 = 'para pasta' m_simpleTV.User.YT.Lng.savePlst_3 = 'não é possível salvar a playlist' m_simpleTV.User.YT.Lng.sub = 'legendas' m_simpleTV.User.YT.Lng.subTr = 'traduzido' m_simpleTV.User.YT.Lng.preview = 'preview' m_simpleTV.User.YT.Lng.audio = 'áudio' m_simpleTV.User.YT.Lng.noAudio = 'sem áudio' m_simpleTV.User.YT.Lng.plst = 'lista de reprodução' m_simpleTV.User.YT.Lng.error = 'erro' m_simpleTV.User.YT.Lng.live = 'em direto' m_simpleTV.User.YT.Lng.upLoadOnCh = 'uploads do canal' m_simpleTV.User.YT.Lng.loading = 'a carregar' m_simpleTV.User.YT.Lng.videoNotAvail = 'vídeo não disponível' m_simpleTV.User.YT.Lng.videoNotExst = 'vídeo não existe' m_simpleTV.User.YT.Lng.page = 'página' m_simpleTV.User.YT.Lng.hl = 'pt_PT' m_simpleTV.User.YT.Lng.hl_sub = 'pt' m_simpleTV.User.YT.Lng.camera = 'visão da câmera' m_simpleTV.User.YT.Lng.camera_plst_title = 'álternar câmera' m_simpleTV.User.YT.Lng.channel = 'chanel' m_simpleTV.User.YT.Lng.video = 'vídeo' m_simpleTV.User.YT.Lng.search = 'procurar' m_simpleTV.User.YT.Lng.notFound = 'não encontrado' m_simpleTV.User.YT.Lng.started = 'started' m_simpleTV.User.YT.Lng.published = 'published' m_simpleTV.User.YT.Lng.duration = 'duration' m_simpleTV.User.YT.Lng.relatedVideos = 'vídeos relacionados' m_simpleTV.User.YT.Lng.link = 'abra no navegador' m_simpleTV.User.YT.Lng.noCookies = 'LOGIN NECESSÁRIO: usar "cookies file" para autorização' m_simpleTV.User.YT.Lng.chapter = 'chapters' elseif m_simpleTV.Interface.GetLanguage() == 'vi' then m_simpleTV.User.YT.Lng.adaptiv = 'Thích nghi' m_simpleTV.User.YT.Lng.desc = 'Sự miêu tả' m_simpleTV.User.YT.Lng.qlty = 'Chất lượng' m_simpleTV.User.YT.Lng.savePlstFolder = 'Đã lưu danh sách phát' m_simpleTV.User.YT.Lng.savePlst_1 = 'Danh sách phát được lưu thành file' m_simpleTV.User.YT.Lng.savePlst_2 = 'vào thư mục' m_simpleTV.User.YT.Lng.savePlst_3 = 'Không thể lưu' m_simpleTV.User.YT.Lng.sub = 'Phụ đề' m_simpleTV.User.YT.Lng.subTr = 'Google dịch' m_simpleTV.User.YT.Lng.preview = 'Xem lại' m_simpleTV.User.YT.Lng.audio = 'Âm thanh' m_simpleTV.User.YT.Lng.noAudio = 'Không có âm thanh' m_simpleTV.User.YT.Lng.plst = 'Danh sách phát' m_simpleTV.User.YT.Lng.error = 'Lỗi' m_simpleTV.User.YT.Lng.live = 'Trực tiếp' m_simpleTV.User.YT.Lng.upLoadOnCh = 'Kênh' m_simpleTV.User.YT.Lng.loading = 'Đang tải' m_simpleTV.User.YT.Lng.videoNotAvail = 'Video không có sẵn' m_simpleTV.User.YT.Lng.videoNotExst = 'Video không tồn tại' m_simpleTV.User.YT.Lng.page = 'Trang.' m_simpleTV.User.YT.Lng.hl = 'vi' m_simpleTV.User.YT.Lng.hl_sub = 'vi' m_simpleTV.User.YT.Lng.camera = 'Xem camera' m_simpleTV.User.YT.Lng.camera_plst_title = 'Đổi camera' m_simpleTV.User.YT.Lng.channel = 'Kênh' m_simpleTV.User.YT.Lng.video = 'Video' m_simpleTV.User.YT.Lng.search = 'Tìm kiếm' m_simpleTV.User.YT.Lng.notFound = 'Không tìm thấy' m_simpleTV.User.YT.Lng.started = 'Bắt đầu' m_simpleTV.User.YT.Lng.published = 'Xuất bản' m_simpleTV.User.YT.Lng.duration = 'Thời lượng' m_simpleTV.User.YT.Lng.relatedVideos = 'Video liên quan' m_simpleTV.User.YT.Lng.link = 'Mở trong trình duyệt' m_simpleTV.User.YT.Lng.noCookies = 'YÊU CẦU ĐĂNG NHẬP: sử dụng "cookies file" để ủy quyền' m_simpleTV.User.YT.Lng.chapter = 'Chươngi' elseif m_simpleTV.Interface.GetLanguage() == 'pl' then m_simpleTV.User.YT.Lng.adaptiv = 'adaptacyjny' m_simpleTV.User.YT.Lng.desc = 'opis' m_simpleTV.User.YT.Lng.qlty = 'jakość' m_simpleTV.User.YT.Lng.savePlstFolder = 'zapisane listy odtwarzania' m_simpleTV.User.YT.Lng.savePlst_1 = 'lista odtwarzania zapisana do pliku' m_simpleTV.User.YT.Lng.savePlst_2 = 'do folderu' m_simpleTV.User.YT.Lng.savePlst_3 = 'nie można zapisać listy odtwarzania' m_simpleTV.User.YT.Lng.sub = 'napisy na filmie obcojęzycznym' m_simpleTV.User.YT.Lng.subTr = 'przetłumaczony' m_simpleTV.User.YT.Lng.preview = 'zapowiedź' m_simpleTV.User.YT.Lng.audio = 'audio' m_simpleTV.User.YT.Lng.noAudio = 'brak dźwięku' m_simpleTV.User.YT.Lng.plst = 'lista odtwarzania' m_simpleTV.User.YT.Lng.error = 'błąd' m_simpleTV.User.YT.Lng.live = 'relacja na żywo' m_simpleTV.User.YT.Lng.upLoadOnCh = 'przesłane z kanału' m_simpleTV.User.YT.Lng.loading = 'Ładowanie' m_simpleTV.User.YT.Lng.videoNotAvail = 'video not available' m_simpleTV.User.YT.Lng.videoNotExst = 'wideo niedostępne' m_simpleTV.User.YT.Lng.page = 'strona' m_simpleTV.User.YT.Lng.hl = 'pl' m_simpleTV.User.YT.Lng.hl_sub = 'pl' m_simpleTV.User.YT.Lng.camera = 'widok z kamery' m_simpleTV.User.YT.Lng.camera_plst_title = 'przełącz aparat' m_simpleTV.User.YT.Lng.channel = 'kanał' m_simpleTV.User.YT.Lng.video = 'wideo' m_simpleTV.User.YT.Lng.search = 'Szukaj' m_simpleTV.User.YT.Lng.notFound = 'nie znaleziono' m_simpleTV.User.YT.Lng.started = 'started' m_simpleTV.User.YT.Lng.published = 'Rozpoczęty' m_simpleTV.User.YT.Lng.duration = 'Trwanie' m_simpleTV.User.YT.Lng.relatedVideos = 'powiązane wideo' m_simpleTV.User.YT.Lng.link = 'Otwórz w przeglądarce' m_simpleTV.User.YT.Lng.noCookies = 'WYMAGANE LOGOWANIE: użyj „pliku cookie” do autoryzacji' m_simpleTV.User.YT.Lng.chapter = 'rozdziałi' else m_simpleTV.User.YT.Lng.adaptiv = 'adaptive' m_simpleTV.User.YT.Lng.desc = 'description' m_simpleTV.User.YT.Lng.qlty = 'quality' m_simpleTV.User.YT.Lng.savePlstFolder = 'saved playlists' m_simpleTV.User.YT.Lng.savePlst_1 = 'playlist saved to file' m_simpleTV.User.YT.Lng.savePlst_2 = 'to folder' m_simpleTV.User.YT.Lng.savePlst_3 = 'unable to save playlist' m_simpleTV.User.YT.Lng.sub = 'subtitles' m_simpleTV.User.YT.Lng.subTr = 'translated' m_simpleTV.User.YT.Lng.preview = 'preview' m_simpleTV.User.YT.Lng.audio = 'audio' m_simpleTV.User.YT.Lng.noAudio = 'no audio' m_simpleTV.User.YT.Lng.plst = 'playlist' m_simpleTV.User.YT.Lng.error = 'error' m_simpleTV.User.YT.Lng.live = 'live' m_simpleTV.User.YT.Lng.upLoadOnCh = 'uploads from channel' m_simpleTV.User.YT.Lng.loading = 'loading' m_simpleTV.User.YT.Lng.videoNotAvail = 'video not available' m_simpleTV.User.YT.Lng.videoNotExst = 'video does not exist' m_simpleTV.User.YT.Lng.page = 'page' m_simpleTV.User.YT.Lng.hl = 'en_US' m_simpleTV.User.YT.Lng.hl_sub = 'en' m_simpleTV.User.YT.Lng.camera = 'camera view' m_simpleTV.User.YT.Lng.camera_plst_title = 'switch camera' m_simpleTV.User.YT.Lng.channel = 'channel' m_simpleTV.User.YT.Lng.video = 'video' m_simpleTV.User.YT.Lng.search = 'search' m_simpleTV.User.YT.Lng.notFound = 'not found' m_simpleTV.User.YT.Lng.started = 'started' m_simpleTV.User.YT.Lng.published = 'published' m_simpleTV.User.YT.Lng.duration = 'duration' m_simpleTV.User.YT.Lng.relatedVideos = 'related videos' m_simpleTV.User.YT.Lng.link = 'open in browser' m_simpleTV.User.YT.Lng.noCookies = 'LOGIN REQUIRED: use "cookies file" for authorization' m_simpleTV.User.YT.Lng.chapter = 'chapters' end end if not m_simpleTV.User.YT.OpenUrlHelpCheck then if m_simpleTV.PlayList.GetOpenUrlHelp() == '' then local help_text = '<html><body><h3>🔎 ' .. m_simpleTV.User.YT.Lng.search .. '</h3><p></p><p><strong>YouTube</strong></p><table border="1"><tbody><tr><td>&nbsp;<strong>- ' .. m_simpleTV.User.YT.Lng.video .. '</strong>&nbsp;</td><td>&nbsp;<strong>-- ' .. m_simpleTV.User.YT.Lng.plst .. '</strong>&nbsp;</td></tr><tr><td>&nbsp;<strong>--- ' .. m_simpleTV.User.YT.Lng.channel .. '</strong>&nbsp;</td><td>&nbsp;<strong>-+ ' .. m_simpleTV.User.YT.Lng.live .. '</strong>&nbsp;</td></tr></tbody></table></body></html>' m_simpleTV.PlayList.SetOpenUrlHelp(help_text) end m_simpleTV.User.YT.OpenUrlHelpCheck = true end if not m_simpleTV.User.YT.cookies then local function cookiesFromFile() local f = string.format('%scookies.txt', m_simpleTV.Common.GetMainPath(1)) local fhandle = io.open(f, 'r') if not fhandle then return end local YT_Cookies = {'SID', 'HSID', 'SSID', 'SAPISID', 'APISID'} local cookie_SAPISID local t = {} for line in fhandle:lines() do local name, val = line:match('youtube%.com.+%s(%S+)%s+(%S+)') if name and val then for i = 1, #YT_Cookies do if name == YT_Cookies[i] then t[#t + 1] = string.format('%s=%s', name, val) if not cookie_SAPISID and name == 'SAPISID' then cookie_SAPISID = val end break end end end if #t == 5 then break end end fhandle:close() if #t < 5 then return end m_simpleTV.User.YT.isAuth = cookie_SAPISID return table.concat(t, ';') end m_simpleTV.User.YT.cookies = string.format('%s;PREF=hl=%s;', (cookiesFromFile() or ''), m_simpleTV.User.YT.Lng.hl) end if not m_simpleTV.User.YT.PlstsCh then m_simpleTV.User.YT.PlstsCh = {} end if not m_simpleTV.User.YT.PlstsCh.Urls then m_simpleTV.User.YT.PlstsCh.Urls = {} end if not m_simpleTV.User.YT.Plst then m_simpleTV.User.YT.Plst = {} end if not m_simpleTV.User.YT.qlty then m_simpleTV.User.YT.qlty = tonumber(m_simpleTV.Config.GetValue('YT_qlty') or '1080') end if not m_simpleTV.User.YT.qlty_live then m_simpleTV.User.YT.qlty_live = tonumber(m_simpleTV.Config.GetValue('YT_qlty_live') or '10000') end if m_simpleTV.User.YT.isPlstsCh then m_simpleTV.User.YT.isPlstsCh = nil end local userAgent = 'Mozilla/5.0 (Windows NT 10.0; rv:86.0) Gecko/20100101 Firefox/86.0' local session = m_simpleTV.Http.New(userAgent) if not session then return end m_simpleTV.Http.SetTimeout(session, 14000) m_simpleTV.User.YT.DelayedAddress = nil m_simpleTV.User.YT.isChapters = false local inf0, inf01 local isInfoPanel = infoPanelCheck() local videoId = inAdr:match('[?&/]v[=/](.+)') or inAdr:match('/embed/(.+)') or inAdr:match('/watch/(.+)') or inAdr:match('y[2out]*u%.be/(.+)') or inAdr:match('video_id=(.+)') or '' videoId = videoId:sub(1, 11) local function ShowMsg(msg, reason, qlty) if reason then msg = msg .. '\n' .. reason end local t = {} for m in msg:gmatch('[^\n]+') do t[#t + 1] = m end for j = #t, 1, -1 do local imageParam, color, id local once = true if j == 1 then imageParam = 'vSizeFactor="0.5" src="https://s.ytimg.com/yts/img/favicon_48-vfl1s0rGh.png"' color = ARGB(255, 128, 128, 255) id = 'channelName' else color = ARGB(255, 139, 135, 135) id = j - 1 end if qlty then once = false color = ARGB(255, 139, 135, 135) imageParam = 'src=""' id = 'channelName' end m_simpleTV.OSD.ShowMessageT({imageParam = imageParam, text = t[j], color = color, showTime = 1000 * 6, id = id, once = once}) end end local function lunaJson_decode(json_, pos_, nullv_, arraylen_) --[[The MIT License (MIT) Copyright (c) 2015-2017 Shunsuke Shimizu (grafi) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. https://github.com/grafi-tt/lunaJson ]] local setmetatable, tonumber, tostring = setmetatable, tonumber, tostring local floor, inf = math.floor, math.huge local mininteger, tointeger = math.mininteger or nil, math.tointeger or nil local byte, char, find, gsub, match, sub = string.byte, string.char, string.find, string.gsub, string.match, string.sub local function _decode_error(pos, errmsg) error("json parse error at " .. pos .. " pos.: " .. errmsg, 2) end local f_str_ctrl_pat if _VERSION == "Lua 5.1" then f_str_ctrl_pat = '[^\32-\255]' else f_str_ctrl_pat = '[\0-\31]' end local _ENV = nil local json, pos, nullv, arraylen, rec_depth local dispatcher, f local function decode_error(errmsg) return _decode_error(pos, errmsg) end local function f_err() decode_error('invalid value') end local function f_nul() if sub(json, pos, pos+2) == 'ull' then pos = pos+3 return nullv end decode_error('invalid value') end local function f_fls() if sub(json, pos, pos+3) == 'alse' then pos = pos+4 return false end decode_error('invalid value') end local function f_tru() if sub(json, pos, pos+2) == 'rue' then pos = pos+3 return true end decode_error('invalid value') end local radixmark = match(tostring(0.5), '[^0-9]') local fixedtonumber = tonumber if radixmark ~= '.' then if find(radixmark, '%W') then radixmark = '%' .. radixmark end fixedtonumber = function(s) return tonumber(gsub(s, '.', radixmark)) end end local function number_error() return decode_error('invalid number') end local function f_zro(mns) local num, c = match(json, '^(%.?[0-9]*)([-+.A-Za-z]?)', pos) if num == '' then if c == '' then if mns then return -0.0 end return 0 end if c == 'e' or c == 'E' then num, c = match(json, '^([^eE]*[eE][-+]?[0-9]+)([-+.A-Za-z]?)', pos) if c == '' then pos = pos + #num if mns then return -0.0 end return 0.0 end end number_error() end if byte(num) ~= 0x2E or byte(num, -1) == 0x2E then number_error() end if c ~= '' then if c == 'e' or c == 'E' then num, c = match(json, '^([^eE]*[eE][-+]?[0-9]+)([-+.A-Za-z]?)', pos) end if c ~= '' then number_error() end end pos = pos + #num c = fixedtonumber(num) if mns then c = -c end return c end local function f_num(mns) pos = pos-1 local num, c = match(json, '^([0-9]+%.?[0-9]*)([-+.A-Za-z]?)', pos) if byte(num, -1) == 0x2E then number_error() end if c ~= '' then if c ~= 'e' and c ~= 'E' then number_error() end num, c = match(json, '^([^eE]*[eE][-+]?[0-9]+)([-+.A-Za-z]?)', pos) if not num or c ~= '' then number_error() end end pos = pos + #num c = fixedtonumber(num) if mns then c = -c if c == mininteger and not find(num, '[^0-9]') then c = mininteger end end return c end local function f_mns() local c = byte(json, pos) if c then pos = pos+1 if c > 0x30 then if c < 0x3A then return f_num(true) end else if c > 0x2F then return f_zro(true) end end end decode_error('invalid number') end local f_str_hextbl = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, inf, inf, inf, inf, inf, inf, inf, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, __index = function() return inf end } setmetatable(f_str_hextbl, f_str_hextbl) local f_str_escapetbl = { ['"'] = '"', ['\\'] = '\\', ['/'] = '/', ['b'] = '\b', ['f'] = '\f', ['n'] = '\n', ['r'] = '\r', ['t'] = '\t', __index = function() decode_error("invalid escape sequence") end } setmetatable(f_str_escapetbl, f_str_escapetbl) local function surrogate_first_error() return decode_error("1st surrogate pair byte not continued by 2nd") end local f_str_surrogate_prev = 0 local function f_str_subst(ch, ucode) if ch == 'u' then local c1, c2, c3, c4, rest = byte(ucode, 1, 5) ucode = f_str_hextbl[c1-47] * 0x1000 + f_str_hextbl[c2-47] * 0x100 + f_str_hextbl[c3-47] * 0x10 + f_str_hextbl[c4-47] if ucode ~= inf then if ucode < 0x80 then if rest then return char(ucode, rest) end return char(ucode) elseif ucode < 0x800 then c1 = floor(ucode / 0x40) c2 = ucode - c1 * 0x40 c1 = c1 + 0xC0 c2 = c2 + 0x80 if rest then return char(c1, c2, rest) end return char(c1, c2) elseif ucode < 0xD800 or 0xE000 <= ucode then c1 = floor(ucode / 0x1000) ucode = ucode - c1 * 0x1000 c2 = floor(ucode / 0x40) c3 = ucode - c2 * 0x40 c1 = c1 + 0xE0 c2 = c2 + 0x80 c3 = c3 + 0x80 if rest then return char(c1, c2, c3, rest) end return char(c1, c2, c3) elseif 0xD800 <= ucode and ucode < 0xDC00 then if f_str_surrogate_prev == 0 then f_str_surrogate_prev = ucode if not rest then return '' end surrogate_first_error() end f_str_surrogate_prev = 0 surrogate_first_error() else if f_str_surrogate_prev ~= 0 then ucode = 0x10000 + (f_str_surrogate_prev - 0xD800) * 0x400 + (ucode - 0xDC00) f_str_surrogate_prev = 0 c1 = floor(ucode / 0x40000) ucode = ucode - c1 * 0x40000 c2 = floor(ucode / 0x1000) ucode = ucode - c2 * 0x1000 c3 = floor(ucode / 0x40) c4 = ucode - c3 * 0x40 c1 = c1 + 0xF0 c2 = c2 + 0x80 c3 = c3 + 0x80 c4 = c4 + 0x80 if rest then return char(c1, c2, c3, c4, rest) end return char(c1, c2, c3, c4) end decode_error("2nd surrogate pair byte appeared without 1st") end end decode_error("invalid unicode codepoint literal") end if f_str_surrogate_prev ~= 0 then f_str_surrogate_prev = 0 surrogate_first_error() end return f_str_escapetbl[ch] .. ucode end local f_str_keycache = setmetatable({}, {__mode="v"}) local function f_str(iskey) local newpos = pos local tmppos, c1, c2 repeat newpos = find(json, '"', newpos, true) if not newpos then decode_error("unterminated string") end tmppos = newpos-1 newpos = newpos+1 c1, c2 = byte(json, tmppos-1, tmppos) if c2 == 0x5C and c1 == 0x5C then repeat tmppos = tmppos-2 c1, c2 = byte(json, tmppos-1, tmppos) until c2 ~= 0x5C or c1 ~= 0x5C tmppos = newpos-2 end until c2 ~= 0x5C local str = sub(json, pos, tmppos) pos = newpos if iskey then tmppos = f_str_keycache[str] if tmppos then return tmppos end tmppos = str end if find(str, f_str_ctrl_pat) then decode_error("unescaped control string") end if find(str, '\\', 1, true) then str = gsub(str, '\\(.)([^\\]?[^\\]?[^\\]?[^\\]?[^\\]?)', f_str_subst) if f_str_surrogate_prev ~= 0 then f_str_surrogate_prev = 0 decode_error("1st surrogate pair byte not continued by 2nd") end end if iskey then f_str_keycache[tmppos] = str end return str end local function f_ary() rec_depth = rec_depth + 1 if rec_depth > 1000 then decode_error('too deeply nested json (> 1000)') end local ary = {} pos = match(json, '^[ \n\r\t]*()', pos) local i = 0 if byte(json, pos) == 0x5D then pos = pos+1 else local newpos = pos repeat i = i+1 f = dispatcher[byte(json,newpos)] pos = newpos+1 ary[i] = f() newpos = match(json, '^[ \n\r\t]*,[ \n\r\t]*()', pos) until not newpos newpos = match(json, '^[ \n\r\t]*%]()', pos) if not newpos then decode_error("no closing bracket of an array") end pos = newpos end if arraylen then ary[0] = i end rec_depth = rec_depth - 1 return ary end local function f_obj() rec_depth = rec_depth + 1 if rec_depth > 1000 then decode_error('too deeply nested json (> 1000)') end local obj = {} pos = match(json, '^[ \n\r\t]*()', pos) if byte(json, pos) == 0x7D then pos = pos+1 else local newpos = pos repeat if byte(json, newpos) ~= 0x22 then decode_error("not key") end pos = newpos+1 local key = f_str(true) f = f_err local c1, c2, c3 = byte(json, pos, pos+3) if c1 == 0x3A then if c2 ~= 0x20 then f = dispatcher[c2] newpos = pos+2 else f = dispatcher[c3] newpos = pos+3 end end if f == f_err then newpos = match(json, '^[ \n\r\t]*:[ \n\r\t]*()', pos) if not newpos then decode_error("no colon after a key") end f = dispatcher[byte(json, newpos)] newpos = newpos+1 end pos = newpos obj[key] = f() newpos = match(json, '^[ \n\r\t]*,[ \n\r\t]*()', pos) until not newpos newpos = match(json, '^[ \n\r\t]*}()', pos) if not newpos then decode_error("no closing bracket of an object") end pos = newpos end rec_depth = rec_depth - 1 return obj end dispatcher = { [0] = f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_str, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_mns, f_err, f_err, f_zro, f_num, f_num, f_num, f_num, f_num, f_num, f_num, f_num, f_num, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_ary, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_fls, f_err, f_err, f_err, f_err, f_err, f_err, f_err, f_nul, f_err, f_err, f_err, f_err, f_err, f_tru, f_err, f_err, f_err, f_err, f_err, f_err, f_obj, f_err, f_err, f_err, f_err, __index = function() decode_error("unexpected termination") end } setmetatable(dispatcher, dispatcher) json, pos, nullv, arraylen = json_, pos_, nullv_, arraylen_ rec_depth = 0 pos = match(json, '^[ \n\r\t]*()', pos) f = dispatcher[byte(json, pos)] pos = pos+1 local v = f() if pos_ then return v, pos else f, pos = find(json, '^[ \n\r\t]*', pos) if pos ~= #json then -- decode_error('json ended') end return v end return decode end local function GetApiKey() local function webApiKey() local session = m_simpleTV.Http.New(userAgent) if not session then return end m_simpleTV.Http.SetTimeout(session, 14000) local url = decode64('aHR0cHM6Ly93d3cueW91dHViZS5jb20vcy9fL2thYnVraS9fL2pzL2s9a2FidWtpLmJhc2VfemRzLmVuX1VTLi1KcDN1bDRMbzBZLk8vYW09SW9BQVFnQUUvcnQ9ai9kPTEvZGc9MC9jdD16Z21zL3JzPUFOalJoVmtmazRsbnFhWXlZX05MTzV4QmhpTGdXYkYzMGcvbT1iYXNl') local rc, answer = m_simpleTV.Http.Request(session, {url = url}) m_simpleTV.Http.Close(session) if rc ~= 200 then return end return answer:match('ya%("INNERTUBE_API_KEY","([^"]+)') end local key = webApiKey() if not key then ShowMsg(m_simpleTV.User.YT.Lng.error .. '\nAPI Key not found') m_simpleTV.Common.Sleep(2000) end m_simpleTV.User.YT.apiKey = key or '' m_simpleTV.User.YT.apiKeyHeader = decode64('UmVmZXJlcjogaHR0cHM6Ly93d3cueW91dHViZS5jb20vdHY') end local function table_reversa(t) local tbl = {} local p = #tbl for i = #t, 1, -1 do p = p + 1 tbl[p] = t[i] end return tbl end local function urls_encode(str) str = string.gsub(str, '([^%w:/=.&%-?_])', function(c) return string.format('%%%02X', string.byte(c)) end) return string.gsub(str, ' ', '+') end local function stringToHex(str) return (str:gsub('.', function (c) return string.format('\\x%02X', string.byte(c)) end)) end local function stringFromHex(str) return (str:gsub('\\x(..)', function (c) return string.char(tonumber(c, 16)) end)) end local function split_str(source, delimiters) local elements = {} local pattern if not delimiters or delimiters == '' then pattern = '.' else pattern = '([^' .. delimiters .. ']+)' end source:gsub(pattern, function(value) elements[#elements + 1] = value end) return elements end local function timeStamp(isodt) local pattern = '(%d+)%-(%d+)%-(%d+)T(%d+):(%d+)' local xyear, xmonth, xday, xhour, xminute = isodt:match(pattern) if not (xyear or xmonth or xday or xhour or xminute) then return '' end local currenttime = os.time() local datetime = os.date('!*t', currenttime) datetime.isdst = true local offset = currenttime - os.time(datetime) local convertedTimestamp = os.time({year = xyear, month = xmonth, day = xday, hour = xhour, min = xminute}) return (convertedTimestamp + offset) end local function secondsToClock(sec) if not sec or sec < 3 then return '' end sec = string.format('%01d:%02d:%02d', math.floor(sec / 3600), math.floor(sec / 60) % 60, math.floor(sec % 60)) return sec:gsub('^0[0:]+(.+:)', '%1') end local function unescape_html(str) return htmlEntities.decode(str) end local function title_clean(s) s = s:gsub('%c', ' ') s = s:gsub('%%22', '"') s = s:gsub('\\u0026', '&') s = s:gsub('\\u2060', '') s = s:gsub('\\u200%a', '') s = unescape_html(s) s = s:gsub('%s+', ' ') s = s:gsub('\\', '\\') return s end local function desc_clean(d) d = d:gsub('%%22', '"') d = d:gsub('\\u200%a', '') d = d:gsub('\\u202%a', '') d = d:gsub('\\u00ad', '') d = d:gsub('\\r', '') d = d:gsub('\r', '') d = d:gsub('\\n', '\n') d = d:gsub('\n\n[\n]+', '\n\n') d = unescape3(d) d = unescape_html(d) d = d:gsub('\\', '\\') return d end local function desc_format_text(desc, isSearch) desc = desc_clean(desc) desc = string.gsub(desc, '(https?://%S+)', function(c) c = c:gsub('#', '%%23') if c:match('%.%.%p*$') then c = string.format('<span style="color:%%23817c76; font-size:small;">%s</span>', c) else c = string.format('<a href="%s" style="color:%%23319785; font-size:small; text-decoration:none">%s</a>', c, c) end return c:gsub('([.,)]+)"', '"%1'):gsub('([.,)]+)</a>', '</a>%1') end) desc = string.gsub(desc, '(%d+[:%d+]+)', function(c) if not (c:match('%d+:%d+$') or c:match('%d+:%d+:%d+$')) or c:match('::') then return end return string.format('<span style="color:%%23e6e76d; font-size:small;">%s</span>', c) end) if not isSearch then desc = string.gsub(desc, 'none">(https?://[%a.]*youtu[.combe][^<]+)<', function(c) if c:match('sub_confirmation') or c:match('subscription_center') or c:match('/join$') then return end return string.format('none">%s</a> <a href="simpleTVLua:PlayAddressT_YT(\'%s\')"><img src="' .. m_simpleTV.User.YT.playPicFromDisk ..'" height="32" valign="top"><', c, stringToHex(c)) end) desc = string.gsub(desc, '#([^\'%s%c/#,:%-?)]+)', function(c) if c:match('%.%.$') then c = string.format('<span style="color:%%23817c76; font-size:small;">#%s</span>', c) elseif (c:match('^%d+%p*$') and #c < 6) or c:match('%.[^.]+$') then return else c = string.format('<a href="simpleTVLua:PlayAddressT_YT(\'https://www.youtube.com/hashtag/%s\')" style="color:#436FAF; font-size:small; text-decoration:none">#%s</a>', stringToHex(c:gsub('%p+$', '')), c) end return c:gsub('(%p+)</a>', '</a>%1') end) else desc = string.gsub(desc, '#([^\'%s%c/#,:%-?)]+)', function(c) if c:match('%.%.$') then c = string.format('<span style="color:%%23817c76; font-size:small;">#%s</span>', c) elseif (c:match('^%d+%p*$') and #c < 6) or c:match('%.[^.]+$') then return else c = string.format('<a href="https://www.youtube.com/hashtag/%s" style="color:%%23154C9C; font-size:small; text-decoration:none">#%s</a>', c:gsub('%p+$', ''), c) end return c:gsub('(%p+)</a>', '</a>%1') end) end desc = desc:gsub('%%23', '#') desc = desc:gsub('"+', '"') desc = desc:gsub('\n', '<br>') desc = string.format('<p>%s</p>', desc) return desc end local function desc_html(desc, logo, name, adr, isSearch) desc = desc or '' if desc ~= '' then local err, d = pcall(desc_format_text, desc, isSearch) if err == false then desc = string.format('<p style="color:#ff0000; font-size:small">%s: %s</p>', m_simpleTV.User.YT.Lng.desc, m_simpleTV.User.YT.Lng.error) else desc = d end end adr = adr:gsub('&is%a+=%a+', '') local link = string.format('<a href="%s" style="color:#154C9C; font-size:small; text-decoration:none">🌎 %s</a>', adr, m_simpleTV.User.YT.Lng.link) if m_simpleTV.User.YT.isVideo == true and m_simpleTV.User.YT.isChapters then link = string.format('%s<br><a href="simpleTVLua:m_simpleTV.Control.ExecuteAction(37) m_simpleTV.Control.ExecuteAction(116)" style="color:#436FAF; font-size: small; text-decoration:none">🕜 %s</a>', link, m_simpleTV.User.YT.Lng.chapter) end desc = string.format('<html><body bgcolor="#181818"><table width="99%%"><tr><td style="padding: 10px 10px 10px;"><a href="%s"><img src="%s"</a></td><td style="padding: 10px 10px 10px; color:#ebebeb; vertical-align:middle;"><h4><font color="#ebeb00">%s</h4><hr>%s%s</td></tr></table></body></html>', adr, logo, name, link, desc) return desc end local function ShowInfo(info, bcolor, txtparm, color) local function datScr() local f = m_simpleTV.MainScriptDir .. 'user/video/YT.lua' local fhandle = io.open(f, 'r') if not fhandle then return '' end local dat = fhandle:read(100) fhandle:close() dat = ' [' .. (dat:match('%d+[/.%-]%d+[/.%-]%d+') or '') .. ']' return decode64('WW91VHViZSBieSBOZXh0ZXJyIGVkaXRpb24') .. dat end m_simpleTV.Control.ExecuteAction(37) if not info then local function truncateUtf8(str, n) if m_simpleTV.Common.midUTF8 then return m_simpleTV.Common.midUTF8(str, 0, n) end str = m_simpleTV.Common.UTF8ToUTF16(str) str = str:sub(1, n) str = m_simpleTV.Common.UTF16ToUTF8(str) return str end color = ARGB(255, 128, 128, 255) bcolor = ARGB(144, 0, 0, 0) txtparm = 1 + 4 local codec = '' local title if #m_simpleTV.User.YT.title > 70 then title = truncateUtf8(m_simpleTV.User.YT.title, 55) .. '...' else title = m_simpleTV.User.YT.title end local ti = m_simpleTV.Control.GetCodecInfo() if ti then local codecD, typeD, resD local t, i = {}, 1 for w in dumpValue(ti):gmatch('{.-}') do t[i] = {} codecD = w:match('%["Codec"%] = ([^,}]+)') typeD = w:match('%["Type"%] = ([^,}]+)') if codecD and typeD then typeD = typeD:gsub('Video', m_simpleTV.User.YT.Lng.video .. ': ') typeD = typeD:gsub('Audio', m_simpleTV.User.YT.Lng.audio .. ': ') typeD = typeD:gsub('Subtitle', m_simpleTV.User.YT.Lng.sub .. ': ') codecD = typeD .. codecD codecD = '\n' .. codecD end resD = w:match('%["Video resolution"%] = ([^,}]+)') if resD then resD = m_simpleTV.User.YT.Lng.qlty .. ': ' .. resD resD = '\n' .. resD end t[i] = (codecD or '') .. (resD or '') i = i + 1 end codec = table.concat(t) end local dur, publishedAt, author if m_simpleTV.User.YT.isLive == true then dur = '' author = m_simpleTV.User.YT.Lng.live .. ' | ' .. m_simpleTV.User.YT.Lng.channel .. ': ' .. m_simpleTV.User.YT.author local timeSt = timeStamp(m_simpleTV.User.YT.actualStartTime) timeSt = os.date('%y %d %m %H %M', tonumber(timeSt)) local year, day, month, hour, min = timeSt:match('(%d+) (%d+) (%d+) (%d+) (%d+)') publishedAt = m_simpleTV.User.YT.Lng.started .. ': ' .. string.format('%d:%02d (%d/%d/%02d)', hour, min, day, month, year) else dur = m_simpleTV.User.YT.Lng.duration .. ': ' .. secondsToClock(m_simpleTV.User.YT.duration) author = m_simpleTV.User.YT.Lng.upLoadOnCh .. ': ' .. m_simpleTV.User.YT.author local year, month, day = m_simpleTV.User.YT.publishedAt:match('(%d+)%-(%d+)%-(%d+)') year = year:sub(2, 4) publishedAt = m_simpleTV.User.YT.Lng.published .. ': ' .. string.format('%d/%d/%02d', day, month, year) end info = title .. '\n' .. author .. '\n' .. publishedAt .. '\n' .. dur .. '\n' .. codec info = info:gsub('[%\n]+', '\n') info = info:gsub('%\n$', '') end local addElement = m_simpleTV.OSD.AddElement local removeElement = m_simpleTV.OSD.RemoveElement local q = {} q.once = 1 q.zorder = 0 q.cx = 0 q.cy = 0 q.id = 'YT_TEXT_INFO' q.class = 'TEXT' q.align = 0x0202 q.top = 0 q.color = color or ARGB(255, 255, 255, 255) q.font_italic = 0 q.font_addheight = 6 q.padding = 20 q.textparam = txtparm or (1 + 4) q.text = info q.background = 0 q.backcolor0 = bcolor or ARGB(144, 153, 0, 0) q.isInteractive = true q.color_UnderMouse = m_simpleTV.Interface.ColorBrightness(q.color, 50) addElement(q) q = {} q.id = 'YT_DIV_CR' q.cx = 200 q.cy = 200 q.class = 'DIV' q.minresx = 800 q.minresy = 600 q.align = 0x0103 q.left = 0 q.once = 1 q.zorder = 1 q.background = -1 addElement(q) q = {} q.id = 'YT_DIV_CR_TEXT' q.cx = 0 q.cy = 0 q.class = 'TEXT' q.minresx = 0 q.minresy = 0 q.align = 0x0103 q.text = datScr() q.color = ARGB(64, 250, 250, 250) q.font_height = -15 q.font_weight = 700 q.font_underline = 0 q.font_italic = 0 q.font_name = 'Arial' q.textparam = 0 q.left = 5 q.top = 5 q.glow = 1 q.glowcolor = ARGB(144, 0, 0, 0) addElement(q,'YT_DIV_CR') local function elementsRemove() removeElement('YT_TEXT_INFO') removeElement('YT_DIV_CR') if m_simpleTV.Control.GetState() == 0 then m_simpleTV.Control.ExecuteAction(108) end end if m_simpleTV.Common.WaitUserInput(5000) == 1 then elementsRemove() return end if m_simpleTV.Common.WaitUserInput(3000) == 1 then elementsRemove() return end elementsRemove() end local function StopOnErr(n, txt) if urlAdr:match('PARAMS=psevdotv') then return end if session then m_simpleTV.Http.Close(session) end m_simpleTV.Control.CurrentAddress = m_simpleTV.User.YT.logoPicFromDisk .. '$OPT:video-filter=adjust$OPT:saturation=0$OPT:video-filter=gaussianblur$OPT:image-duration=5' local mes if m_simpleTV.User.YT.isAuth and (inAdr:match('list=WL') or inAdr:match('list=LL') or inAdr:match('list=LM') or (inAdr:match('/feed/') and not inAdr:match('/feed/storefront') and not inAdr:match('/feed/trending'))) then mes = '\n' .. m_simpleTV.User.YT.Lng.noCookies m_simpleTV.Control.ExecuteAction(11) else mes = ' [' .. n .. ']\n' .. (txt or '') end mes = m_simpleTV.User.YT.Lng.error .. mes ShowMsg(mes) m_simpleTV.Control.SetTitle(m_simpleTV.User.YT.Lng.error .. ' [' .. n .. ']') end local function Search(sAdr) local types, yt, header, url local eventType = '' if sAdr:match('^%s*%-%s*%-%s*%-') then types = 'channel' header = m_simpleTV.User.YT.Lng.channel yt = 'channel/' elseif sAdr:match('^%s*%-%s*%-') then types = 'playlist' header = m_simpleTV.User.YT.Lng.plst yt = 'playlist?list=' elseif sAdr:match('^%s*%-%s*%+') then eventType = '&eventType=live' types = 'video' header = m_simpleTV.User.YT.Lng.live yt = 'watch?v=' elseif sAdr:match('^%-related=') then types = 'related' header = m_simpleTV.User.YT.Lng.relatedVideos yt = 'watch?v=' else types = 'video&videoDimension=2d' header = m_simpleTV.User.YT.Lng.video yt = 'watch?v=' end if not m_simpleTV.User.YT.apiKey then GetApiKey() end if types == 'related' then sAdr = sAdr:gsub('%-related=', '') url = 'https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=50&fields=nextPageToken,items/snippet/title,items/id/videoId,items/snippet/thumbnails/default/url,items/snippet/description,items/snippet/liveBroadcastContent,items/snippet/channelTitle&type=video&relatedToVideoId=' .. sAdr .. '&key=' .. m_simpleTV.User.YT.apiKey .. '&relevanceLanguage=' .. m_simpleTV.User.YT.Lng.hl else sAdr = sAdr:gsub('^[%-%+%s]+(.-)%s*$', '%1') if sAdr == '' then return end sAdr = m_simpleTV.Common.toPercentEncoding(sAdr) url = 'https://www.googleapis.com/youtube/v3/search?part=snippet&q=' .. sAdr .. '&type=' .. types .. '&fields=nextPageToken,items/id,items/snippet/title,items/snippet/thumbnails/default/url,items/snippet/description,items/snippet/liveBroadcastContent,items/snippet/channelTitle&maxResults=50' .. eventType .. '&key=' .. m_simpleTV.User.YT.apiKey .. '&relevanceLanguage=' .. m_simpleTV.User.YT.Lng.hl end local t = {} local k, i = 1, 1 local adrUrl = url while true do if k > 200 then break end local rc, answer = m_simpleTV.Http.Request(session, {url = adrUrl, headers = m_simpleTV.User.YT.apiKeyHeader}) if rc ~= 200 then break end if not answer:match('"id"') then break end local err, tab = pcall(lunaJson_decode, answer) if err == false or not tab.items then break end local j = 1 while true do if not tab.items[j] or k > 200 then break end if eventType == '&eventType=live' or (eventType == '' and tab.items[j].snippet and tab.items[j].snippet.liveBroadcastContent and tab.items[j].snippet.liveBroadcastContent ~= 'live') then local name = title_clean(tab.items[j].snippet.title) t[k] = {} t[k].Id = k t[k].Name = name t[k].Address = 'https://www.youtube.com/' .. yt .. (tab.items[j].id.videoId or tab.items[j].id.playlistId or tab.items[j].id.channelId) if isInfoPanel == true then if tab.items[j].snippet and tab.items[j].snippet.thumbnails and tab.items[j].snippet.thumbnails.default and tab.items[j].snippet.thumbnails.default.url then t[k].InfoPanelLogo = tab.items[j].snippet.thumbnails.default.url else t[k].InfoPanelLogo = m_simpleTV.User.YT.logoPicFromDisk end t[k].InfoPanelName = name t[k].InfoPanelShowTime = 10000 local desc = tab.items[j].snippet.description local panelDescName if desc and desc ~= '' then panelDescName = m_simpleTV.User.YT.Lng.desc .. ' | ' end t[k].InfoPanelDesc = desc_html(desc, t[k].InfoPanelLogo, name, t[k].Address, true) if tab.items[j].snippet.channelTitle then t[k].InfoPanelTitle = (panelDescName or '') .. m_simpleTV.User.YT.Lng.channel .. ': ' .. title_clean(tab.items[j].snippet.channelTitle) end end k = k + 1 end j = j + 1 end local nextPageToken = answer:match('"nextPageToken": "([^"]+)') if not nextPageToken then break end adrUrl = url .. '&pageToken=' .. nextPageToken end return t, types, header end local function header_Auth() if m_simpleTV.User.YT.isAuth then local ostime = os.time() local origin = 'https://www.youtube.com' local toHash = string.format('%s %s %s', ostime, m_simpleTV.User.YT.isAuth, origin) local hash = m_simpleTV.Common.CryptographicHash(toHash, 'Sha1', true) return string.format('\nAuthorization: SAPISIDHASH %s_%s', ostime, hash) end return '' end local function GetUrlWatchVideos(url) local session = m_simpleTV.Http.New(userAgent, nil, true) if not session then return end m_simpleTV.Http.SetTimeout(session, 14000) m_simpleTV.Http.SetRedirectAllow(session, false) m_simpleTV.Http.SetCookies(session, url, m_simpleTV.User.YT.cookies, '') m_simpleTV.Http.Request(session, {url = url}) local raw = m_simpleTV.Http.GetRawHeader(session) m_simpleTV.Http.Close(session) if not raw then return end return raw:match('Location: (.-)\n') end local function Chapters() local function chapTab(t) local tab = {} local seekp = -1 local duration = m_simpleTV.User.YT.duration for i = 1, #t do if t[i]:match('%d+:%d+') and not t[i]:match('://') then t[i] = t[i]:gsub('^(.-)([%d:]*%d+:%d+)(.-)$', ' %1 %2 %3 ') local sec = t[i]:match(':(%d+)%s') local min = t[i]:match('(%d+):%d+%s') local hour = t[i]:match('(%d+):%d+:%d+') or 0 local seekpoint = (sec + (min * 60) + (hour * 3600)) local title = t[i]:gsub('[%d:]*%d+:%d+', '') if title ~= '' and not title:match('^[%p%s]+$') and seekpoint < duration and seekp < seekpoint then table.insert(tab, {seekpoint = seekpoint, title = title}) seekp = seekpoint end if #tab == 2 and tab[1].seekpoint >= tab[2].seekpoint then table.remove(tab, 1) end end end return tab end local d = desc_clean(m_simpleTV.User.YT.desc) d = split_str(d, '\n') local t = chapTab(d) if #t < 3 then return end if t[1].seekpoint ~= 0 then table.insert(t, 1, {seekpoint = 0, title = ''}) end local chaptersT = {} chaptersT.chapters = {} for i = 1, #t do local title = t[i].title title = title:gsub('%s+', ' ') title = title:gsub('–', '-') title = title:gsub('^%s*"(.-)"%s*$', '%1') title = title:gsub('[(%[][%s%-]*[%])]', '') title = title:gsub('^[|:%s%-.]*(.-)[|:%s%-.]*$', '%1') chaptersT.chapters[i] = {} chaptersT.chapters[i].seekpoint = t[i].seekpoint * 1000 chaptersT.chapters[i].name = title end m_simpleTV.Control.SetChaptersDesc(chaptersT) m_simpleTV.User.YT.isChapters = true end local function Thumbs(storyboards) if m_simpleTV.Control.MainMode ~= 0 then return end local t = split_str(storyboards, '|') if not t or #t < 2 then return end local urlPattern = t[1] if urlPattern == '' then return end local q = split_str(t[#t], '#') if not q or #q < 8 then return end local samplingFrequency = tonumber(q[6]) or 0 local thumbsPerImage = (tonumber(q[4]) or 0) * (tonumber(q[5]) or 0) local thumbWidth = tonumber(q[1]) or 0 local thumbHeight = tonumber(q[2]) or 0 local NPattern = q[7] if samplingFrequency == 0 or thumbsPerImage == 0 or thumbWidth == 0 or thumbHeight == 0 or NPattern == nil then return end urlPattern = urlPattern:gsub('$L', #t - 2) urlPattern = urlPattern .. '&sigh=' .. m_simpleTV.Common.toPercentEncoding(q[8]) m_simpleTV.User.YT.ThumbsInfo = {} m_simpleTV.User.YT.ThumbsInfo.samplingFrequency = samplingFrequency m_simpleTV.User.YT.ThumbsInfo.thumbsPerImage = thumbsPerImage m_simpleTV.User.YT.ThumbsInfo.thumbWidth = thumbWidth m_simpleTV.User.YT.ThumbsInfo.thumbHeight = thumbHeight m_simpleTV.User.YT.ThumbsInfo.urlPattern = urlPattern m_simpleTV.User.YT.ThumbsInfo.NPattern = NPattern if not m_simpleTV.User.YT.PositionThumbsHandler then local handlerInfo = {} handlerInfo.luaFunction = 'PositionThumbs_YT' handlerInfo.regexString = '.*youtu[\.combe]|//y2u\.be|.*invidio\.|.*hooktube\.com' handlerInfo.sizeFactor = m_simpleTV.User.paramScriptForSkin_thumbsSizeFactor or 0.20 handlerInfo.backColor = m_simpleTV.User.paramScriptForSkin_thumbsBackColor or ARGB(255, 0, 0, 0) handlerInfo.textColor = m_simpleTV.User.paramScriptForSkin_thumbsTextColor or ARGB(240, 127, 255, 0) handlerInfo.glowParams = m_simpleTV.User.paramScriptForSkin_thumbsGlowParams or 'glow="7" samples="5" extent="4" color="0xB0000000"' handlerInfo.marginBottom = m_simpleTV.User.paramScriptForSkin_thumbsMarginBottom or 0 handlerInfo.showPreviewWhileSeek = true handlerInfo.clearImgCacheOnStop = false handlerInfo.minImageWidth = 80 handlerInfo.minImageHeight = 44 m_simpleTV.User.YT.PositionThumbsHandler = m_simpleTV.PositionThumbs.AddHandler(handlerInfo) end end local function title_is_no_infoPanel(title, name) if m_simpleTV.User.YT.isTrailer == true then title = title .. '\n☑ ' .. m_simpleTV.User.YT.Lng.preview end if m_simpleTV.User.YT.isChapters == true then title = title .. '\n☑ ' .. m_simpleTV.User.YT.Lng.chapter end local fps = name:match('%d+ FPS') if fps then title = title .. '\n☑ ' .. fps end return title end local function MarkWatch_YT() if m_simpleTV.User.YT.videostats and not inAdr:match('&isPlst=history') then local sessionMarkWatch = m_simpleTV.Http.New(userAgent) if not sessionMarkWatch then return end m_simpleTV.Http.SetTimeout(sessionMarkWatch, 14000) local cpn_alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_' local t = {} local math_random = math.random local cpn_l = #cpn_alphabet for i = 1, 16 do local random_d = math_random(1, cpn_l) t[i] = {} t[i] = cpn_alphabet:sub(random_d, random_d) end local url = m_simpleTV.User.YT.videostats .. '&ver=2&fs=0&volume=100&muted=0&cpn=' .. table.concat(t) m_simpleTV.Http.SetCookies(sessionMarkWatch, url, m_simpleTV.User.YT.cookies, '') m_simpleTV.Http.RequestA(sessionMarkWatch, {callback = 'MarkWatched_YT', url = url}) end end local function StreamFormat(url, isCipher) if isCipher then url = m_simpleTV.Common.fromPercentEncoding(url) url = url:gsub('(.-)url=(.+)', '%2&%1') end if not url:match('ratebypass=') then url = url:gsub('&', '&ratebypass=yes&', 1) end return url end local function GetSignScr() local sessionGetSignScr = m_simpleTV.Http.New(userAgent) if not sessionGetSignScr then return end m_simpleTV.Http.SetTimeout(sessionGetSignScr, 14000) local url = string.format('https://www.youtube.com/embed/%s', m_simpleTV.User.YT.vId) local rc, answer = m_simpleTV.Http.Request(sessionGetSignScr, {url = url}) if rc ~= 200 then return end url = answer:match('[^"\']+base%.js') if not url then return end url = string.format('https://www.youtube.com%s', url) rc, answer = m_simpleTV.Http.Request(sessionGetSignScr, {url = url}) m_simpleTV.Http.Close(sessionGetSignScr) if rc ~= 200 then return end local f, var = answer:match('split%(""%);((%a%w)%p%S+)') if not f or not var then return end f = f:gsub('%]', '') local signScr = {} for param in f:gmatch(var .. '%p([^)]+)') do local func, p = param:match('([^(]+)%(a,(%d+)') func = answer:match('[%p%s]' .. func .. ':function([^}]+)') if func:match('a%.reverse') then p = 0 elseif func:match('a%.splice') then p = '-' .. p end signScr[#signScr + 1] = tonumber(p) end m_simpleTV.User.YT.sts = answer:match('signatureTimestamp[=:](%d+)') or answer:match('[.,]sts:["]*(%d+)') m_simpleTV.User.YT.signScr = signScr end local function Subtitle(tab) local subt = {} local subtList = tostring(m_simpleTV.Config.GetValue('subtitle/lang', 'simpleTVConfig') or '') if subtList == 'none' or subtList == '' then subt[1] = m_simpleTV.User.YT.Lng.hl_sub else subtList = subtList:gsub('%s', ',') subtList = subtList:gsub('[^%d%a,%-_]', '') subtList = subtList:gsub('_', '-') subtList = subtList:gsub(',+', ',') subt = split_str(subtList, ',') if #subt == 0 then subt[1] = m_simpleTV.User.YT.Lng.hl_sub end end local r = 1 local languageCode, kind, q, subtAdr while true do if not subt[r] or subtAdr then break end q = 1 while true do if not tab.captions.playerCaptionsTracklistRenderer.captionTracks[q] then break end languageCode = tab.captions.playerCaptionsTracklistRenderer.captionTracks[q].languageCode kind = tab.captions.playerCaptionsTracklistRenderer.captionTracks[q].kind if languageCode and (not kind or kind ~= 'asr') and languageCode == subt[r] then subtAdr = '#' .. tab.captions.playerCaptionsTracklistRenderer.captionTracks[q].baseUrl .. '&fmt=vtt' break end q = q + 1 end r = r + 1 end if subtAdr then return subtAdr, '' end if not tab.captions.playerCaptionsTracklistRenderer.translationLanguages or not tab.captions.playerCaptionsTracklistRenderer.translationLanguages[1] then return end r = 1 local lngCodeTr while true do if not subt[r] or lngCodeTr then break end q = 1 while true do if not tab.captions.playerCaptionsTracklistRenderer.translationLanguages[q] then break end languageCode = tab.captions.playerCaptionsTracklistRenderer.translationLanguages[q].languageCode if languageCode and languageCode == subt[r] then lngCodeTr = languageCode break end q = q + 1 end r = r + 1 end if not lngCodeTr then return end r = 1 while true do if not tab.captions.playerCaptionsTracklistRenderer.captionTracks[r] then break end languageCode = tab.captions.playerCaptionsTracklistRenderer.captionTracks[r].languageCode kind = tab.captions.playerCaptionsTracklistRenderer.captionTracks[r].kind if languageCode and (not kind or kind ~= 'asr') and languageCode ~= 'na' then subtAdr = '#' .. tab.captions.playerCaptionsTracklistRenderer.captionTracks[r].baseUrl .. '&tlang=' .. lngCodeTr .. '&fmt=vtt' break end r = r + 1 end if not subtAdr then return end return subtAdr, ' (' .. m_simpleTV.User.YT.Lng.subTr .. ')' end local function positionToContinue(p) if m_simpleTV.User.YT.duration then if m_simpleTV.User.YT.duration < 600 and m_simpleTV.User.YT.isMusic == true then p = p .. '$OPT:POSITIONTOCONTINUE=0' elseif m_simpleTV.User.YT.duration < 300 then p = p .. '$OPT:POSITIONTOCONTINUE=0' end end return p end local function ItagRemove(z, e) for k, v in pairs(z) do if v == e then table.remove(z, k) return z end end return z end local function StreamStart(adrStart) local h = adrStart:match('(%d+)h') or 0 local m = adrStart:match('(%d+)m') or 0 local s = adrStart:match('(%d+)s') or 0 local d = adrStart:match('(%d+)') or 0 local st = (h * 3600) + (m * 60) + s if st ~= 0 then adrStart = st else adrStart = d end return '$OPT:start-time=' .. adrStart end local function StreamError(tab, title) if not tab.playabilityStatus then return nil, '⚠️ ' .. m_simpleTV.User.YT.Lng.videoNotExst end local title_err, stream_tab_err if tab.playabilityStatus.status == 'LOGIN_REQUIRED' then title_err = m_simpleTV.User.YT.Lng.noCookies elseif tab.playabilityStatus.errorScreen and tab.playabilityStatus.errorScreen.playerErrorMessageRenderer and tab.playabilityStatus.errorScreen.playerErrorMessageRenderer.subreason and tab.playabilityStatus.errorScreen.playerErrorMessageRenderer.subreason.runs and tab.playabilityStatus.errorScreen.playerErrorMessageRenderer.subreason.runs[1] then local t, i = {}, 1 for i = 1, #tab.playabilityStatus.errorScreen.playerErrorMessageRenderer.subreason.runs do t[i] = {} t[i] = tab.playabilityStatus.errorScreen.playerErrorMessageRenderer.subreason.runs[i].text end title_err = table.concat(t) elseif tab.playabilityStatus.errorScreen and tab.playabilityStatus.errorScreen.playerErrorMessageRenderer and tab.playabilityStatus.errorScreen.playerErrorMessageRenderer.subreason and tab.playabilityStatus.errorScreen.playerErrorMessageRenderer.subreason.simpleText then title_err = tab.playabilityStatus.errorScreen.playerErrorMessageRenderer.subreason.simpleText elseif tab.playabilityStatus.liveStreamability and tab.playabilityStatus.liveStreamability.liveStreamabilityRenderer and tab.playabilityStatus.liveStreamability.liveStreamabilityRenderer.offlineSlate and tab.playabilityStatus.liveStreamability.liveStreamabilityRenderer.offlineSlate.liveStreamOfflineSlateRenderer and tab.playabilityStatus.liveStreamability.liveStreamabilityRenderer.offlineSlate.liveStreamOfflineSlateRenderer.mainText and tab.playabilityStatus.liveStreamability.liveStreamabilityRenderer.offlineSlate.liveStreamOfflineSlateRenderer.mainText.runs[1] then local t, i = {}, 1 for i = 1, #tab.playabilityStatus.liveStreamability.liveStreamabilityRenderer.offlineSlate.liveStreamOfflineSlateRenderer.mainText.runs do t[i] = {} t[i] = tab.playabilityStatus.liveStreamability.liveStreamabilityRenderer.offlineSlate.liveStreamOfflineSlateRenderer.mainText.runs[i].text end title_err = table.concat(t) else title_err = tab.playabilityStatus.reason or m_simpleTV.User.YT.Lng.videoNotAvail end if not title or title == '' then title = '' end if title_err then if title ~= '' then title_err = '\nℹ️ ' .. title_err else title_err = 'ℹ️ ' .. title_err end end title_err = title .. (title_err or '') if m_simpleTV.User.YT.pic then stream_tab_err = {{Name = '', Address = m_simpleTV.User.YT.pic .. '$OPT:NO-STIMESHIFT$OPT:image-duration=6'}} end return stream_tab_err, title_err end local function DeCipherSign(adr) local function table_swap(t, a) if a >= #t then return end local c = t[1] local p = (a % #t) + 1 t[1] = t[p] t[p] = c return t end local function table_slica(tbl, first, last, step) local sliced = {} local p = #sliced for i = first or 1, last or #tbl, step or 1 do p = p + 1 sliced[p] = tbl[i] end return sliced end local function sign_decode(s, signScr) local t = split_str(s) if #t == 0 or not signScr then return s end local math_abs = math.abs for i = 1, #signScr do local a = signScr[i] if a == 0 then t = table_reversa(t) else if a > 0 then t = table_swap(t, a) else t = table_slica(t, math_abs(a) + 1) end end end return table.concat(t) end if not m_simpleTV.User.YT.signScr then ShowInfo('error DeCipherSign', ARGB(255, 153, 0, 0), nil, nil, 0x0102) return 'vlc://pause:5' end for cipherSign in adr:gmatch('&s=([^&]*)') do local signature = sign_decode(cipherSign, m_simpleTV.User.YT.signScr) adr = adr:gsub('&s=[^&]*', '&sig=' .. signature, 1) end return adr end local function StreamLive(hls, isLive, title) local session = m_simpleTV.Http.New(userAgent) if not session then return end m_simpleTV.Http.SetTimeout(session, 14000) local extOpt = '$OPT:adaptive-use-access' local rc, answer = m_simpleTV.Http.Request(session, {url = hls}) m_simpleTV.Http.Close(session) if rc ~= 200 then return nil, 'GetStreamsTab live Error 1' end local t, i = {}, 1 for name, fps, adr in answer:gmatch('RESOLUTION=(.-),.-RATE=(%d+).-\n(.-)\n') do name = tonumber(name:match('x(%d+)') or '0') local qlty if name > 240 then if tonumber(fps) > 30 then qlty = name + 6 fps = ' ' .. fps .. ' FPS' else qlty = name fps = '' end t[i] = {} t[i].Id = i t[i].Name = name .. 'p' .. fps t[i].Address = adr .. extOpt t[i].qltyLive = qlty i = i + 1 end end if #t == 0 then return nil, 'GetStreamsTab live Error 2' end t[#t + 1] = {} t[#t].Id = #t t[#t].qltyLive = 10000 t[#t].Name = '▫ ' .. m_simpleTV.User.YT.Lng.adaptiv t[#t].Address = hls .. extOpt if isLive == true and not isInfoPanel then title = title .. '\n☑ ' .. m_simpleTV.User.YT.Lng.live end return t, title end local function GetQltyIndex(t) if (m_simpleTV.User.YT.qlty < 300 and m_simpleTV.User.YT.qlty > 100) then m_simpleTV.User.YT.qlty = m_simpleTV.User.YT.qlty0 or tonumber(m_simpleTV.Config.GetValue('YT_qlty') or '1080') end local index for u = 1, #t do if t[u].qltyLive and m_simpleTV.User.YT.qlty_live < t[u].qltyLive then return index or 1 end if t[u].qlty and m_simpleTV.User.YT.qlty < t[u].qlty then break end index = u end if index == 1 and m_simpleTV.User.YT.qlty > 100 then if #t > 1 then index = 2 end end return index or 1 end local function StreamCheck(t, index) local url = t[index].Address if t[index].isCipher then url = DeCipherSign(url) end if index == 1 or (t[index].itag and t[index].itag ~= 22) then return url end local session = m_simpleTV.Http.New(userAgent, nil, true) if not session then return url end m_simpleTV.Http.SetTimeout(session, 14000) m_simpleTV.Http.Request(session, {url = url:gsub('$.+',''), method = 'head'}) local raw = m_simpleTV.Http.GetRawHeader(session) m_simpleTV.Http.Close(session) if raw:match('Content%-Length: 0') then if index > 2 then index = index - 1 elseif #t > index then index = index + 1 else return m_simpleTV.User.YT.logoPicFromDisk .. '$OPT:video-filter=adjust$OPT:saturation=0$OPT:video-filter=gaussianblur$OPT:image-duration=5' end url = t[index].Address if t[index].isCipher then url = DeCipherSign(url) end return url, index end return url end local function Stream(v, adrStart, aAdr, aItag, aAdr_opus, aItag_opus, captions) local adr = StreamFormat(v.Address, v.isCipher) .. (adrStart or '') .. '$OPT:sub-track=0$OPT:NO-STIMESHIFT$OPT:input-slave=' if v.isAdaptive == true and aItag then local extOpt_demux, adr_audio, itag_audio, adr_captions if (aItag_opus and captions) and not (v.qlty > 1080 or v.itag == 302 or v.itag == 334) then adr_audio = aAdr_opus itag_audio = aItag_opus adr_captions = captions else adr_audio = aAdr itag_audio = aItag extOpt_demux = '$OPT:demux=avcodec,any' end v.aItag = itag_audio v.Address = adr .. adr_audio .. (adr_captions or '') .. (extOpt_demux or '') else v.Address = adr .. (captions or '') end return v end local function GetStreamsTab(vId) m_simpleTV.Http.Close(session) m_simpleTV.User.YT.ThumbsInfo = nil m_simpleTV.User.YT.vId = vId m_simpleTV.User.YT.chId = '' m_simpleTV.User.YT.title = '' m_simpleTV.User.YT.publishedAt = '' m_simpleTV.User.YT.actualStartTime = '' m_simpleTV.User.YT.duration = nil m_simpleTV.User.YT.pic = nil m_simpleTV.User.YT.videostats = nil m_simpleTV.User.YT.isLive = false m_simpleTV.User.YT.isLiveContent = false m_simpleTV.User.YT.isTrailer = false m_simpleTV.User.YT.desc = '' m_simpleTV.User.YT.isMusic = false local adrStart = inAdr:match('[?&]t=[^&]*') if adrStart and videoId == m_simpleTV.User.YT.vId then adrStart = StreamStart(adrStart) else adrStart = nil end local session = m_simpleTV.Http.New(userAgent) if not session then return nil, 'GetStreamsTab session error 1' end m_simpleTV.Http.SetTimeout(session, 14000) if not m_simpleTV.User.YT.signScr then pcall(GetSignScr) end local referer = urlAdr:match('$OPT:http%-referrer=(.+)') or 'https://music.youtube.com/' local url = 'https://www.youtube.com/get_video_info?' .. 'eurl=' .. referer .. '&hl=' .. m_simpleTV.User.YT.Lng.hl .. '&sts=' .. (m_simpleTV.User.YT.sts or '') .. '&video_id=' m_simpleTV.Http.SetCookies(session, url, m_simpleTV.User.YT.cookies, '') if infoInFile then inf0 = os.clock() end local rc, answer = m_simpleTV.Http.Request(session, {url = url .. m_simpleTV.User.YT.vId}) if infoInFile then inf0 = string.format('%.3f', (os.clock() - inf0)) end answer = answer or '' local trailer = answer:match('trailerVideoId%%22%%3A%%22(.-)%%22') if trailer then m_simpleTV.User.YT.vId = trailer m_simpleTV.User.YT.isTrailer = true rc, answer = m_simpleTV.Http.Request(session, {url = url .. m_simpleTV.User.YT.vId}) answer = answer or '' end if not answer:match('status%%22%%3A%%22OK') then if m_simpleTV.User.YT.isAuth then m_simpleTV.Http.Close(session) session = m_simpleTV.Http.New(userAgent) if not session then return nil, 'GetStreamsTab session error 2' end m_simpleTV.Http.SetTimeout(session, 14000) end url = 'https://www.youtube.com/get_video_info?' .. 'el=detailpage' .. '&cco=1' .. '&eurl=' .. referer .. '&video_id=' .. m_simpleTV.User.YT.vId .. '&hl=' .. m_simpleTV.User.YT.Lng.hl .. '&sts=' .. (m_simpleTV.User.YT.sts or '') m_simpleTV.Http.SetCookies(session, url, m_simpleTV.User.YT.cookies:gsub(';$', '&gl=US;'), '') rc, answer = m_simpleTV.Http.Request(session, {url = url}) answer = answer or '' end local player_response = answer:match('player_response=([^&]*)') if not player_response then local httpErr if rc == 429 then httpErr = 'HTTP Error 429: Too Many Requests\n\n' .. m_simpleTV.User.YT.Lng.noCookies answer = httpErr end if infoInFile then debug_in_file(answer, m_simpleTV.Common.GetMainPath(2) .. 'YT_player_response.txt', true) end return nil, '⚠️ ' .. (httpErr or m_simpleTV.User.YT.Lng.videoNotExst) end if infoInFile then local response = player_response response = m_simpleTV.Common.fromPercentEncoding(response) response = m_simpleTV.Common.fromPercentEncoding(response) response = m_simpleTV.Common.fromPercentEncoding(response) response = response:gsub('\\u0026', '&') response = response:gsub('++', ' ') debug_in_file(response, m_simpleTV.Common.GetMainPath(2) .. 'YT_player_response.txt', true) end if player_response:match('drmFamilies') then return nil, '⚠️ DRM' end player_response = player_response:gsub('++', ' ') player_response = m_simpleTV.Common.fromPercentEncoding(player_response) local err, tab = pcall(lunaJson_decode, player_response) if err == false then if infoInFile then debug_in_file(answer, m_simpleTV.Common.GetMainPath(2) .. 'YT_player_response.txt', true) end return nil, 'Json decode error' end if tab.multicamera and m_simpleTV.User.YT.isVideo == true and tab.multicamera.playerLegacyMulticameraRenderer and tab.multicamera.playerLegacyMulticameraRenderer.metadataList and not inAdr:match('&isRestart=true') and not inAdr:match('&isPlst=') and not inAdr:match('list=') then local t, i = {}, 1 local metadataList = tab.multicamera.playerLegacyMulticameraRenderer.metadataList metadataList = m_simpleTV.Common.fromPercentEncoding(metadataList) for vId in metadataList:gmatch('/vi/([^/]+)') do t[i] = {} t[i] = vId i = i + 1 end if i == 1 then return nil, 'no list multicamers' end t = table.concat(t, ',') inAdr = 'https://www.youtube.com/watch_videos?video_ids=' .. t .. '&title=' .. m_simpleTV.User.YT.Lng.camera_plst_title:gsub('%s', '%+') inAdr = GetUrlWatchVideos(inAdr) m_simpleTV.Http.Close(session) if not inAdr then return nil, 'not get adrs multicamers' end inAdr = inAdr .. '&isLogo=false' return inAdr end if tab.videoDetails then if tab.videoDetails.author then m_simpleTV.User.YT.author = tab.videoDetails.author end if tab.videoDetails.channelId then m_simpleTV.User.YT.chId = tab.videoDetails.channelId end if tab.videoDetails.isLive == true then m_simpleTV.User.YT.isLive = true end if tab.videoDetails.isLiveContent == true then m_simpleTV.User.YT.isLiveContent = true end if tab.videoDetails.lengthSeconds then m_simpleTV.User.YT.duration = tonumber(tab.videoDetails.lengthSeconds) end end if tab.microformat and tab.microformat.playerMicroformatRenderer then if m_simpleTV.User.YT.isLive and tab.microformat.playerMicroformatRenderer.liveBroadcastDetails and tab.microformat.playerMicroformatRenderer.liveBroadcastDetails.startTimestamp then m_simpleTV.User.YT.isLive = true m_simpleTV.User.YT.actualStartTime = tab.microformat.playerMicroformatRenderer.liveBroadcastDetails.startTimestamp end if m_simpleTV.User.YT.duration == nil and tab.microformat.playerMicroformatRenderer.lengthSeconds then m_simpleTV.User.YT.duration = tonumber(tab.microformat.playerMicroformatRenderer.lengthSeconds) end if tab.microformat.playerMicroformatRenderer.publishDate then m_simpleTV.User.YT.publishedAt = tab.microformat.playerMicroformatRenderer.publishDate end if tab.microformat.playerMicroformatRenderer.thumbnail and tab.microformat.playerMicroformatRenderer.thumbnail.thumbnails and tab.microformat.playerMicroformatRenderer.thumbnail.thumbnails[1] and tab.microformat.playerMicroformatRenderer.thumbnail.thumbnails[1].url then m_simpleTV.User.YT.pic = tab.microformat.playerMicroformatRenderer.thumbnail.thumbnails[1].url end if tab.microformat.playerMicroformatRenderer.category == 'Music' then m_simpleTV.User.YT.isMusic = true end if tab.microformat.playerMicroformatRenderer.description and tab.microformat.playerMicroformatRenderer.description.simpleText and not tab.microformat.playerMicroformatRenderer.description.simpleText:match('^[%s%c]+$') then m_simpleTV.User.YT.desc = tab.microformat.playerMicroformatRenderer.description.simpleText end if tab.microformat.playerMicroformatRenderer.title and tab.microformat.playerMicroformatRenderer.title.simpleText then m_simpleTV.User.YT.title = tab.microformat.playerMicroformatRenderer.title.simpleText end end if tab.videoDetails then if m_simpleTV.User.YT.desc == '' and tab.videoDetails.shortDescription and not tab.videoDetails.shortDescription:match('^[%s%c]+$') then m_simpleTV.User.YT.desc = tab.videoDetails.shortDescription end if m_simpleTV.User.YT.title == '' and tab.videoDetails.title then m_simpleTV.User.YT.title = tab.videoDetails.title end end local title = title_clean(m_simpleTV.User.YT.title) if tab.multicamera and not isInfoPanel then title = title .. '\n☑ ' .. m_simpleTV.User.YT.Lng.camera end local t, i = {}, 1 if tab.storyboards and tab.storyboards.playerStoryboardSpecRenderer and tab.storyboards.playerStoryboardSpecRenderer.spec then Thumbs(tab.storyboards.playerStoryboardSpecRenderer.spec) end if tab.streamingData and tab.streamingData.hlsManifestUrl and (tab.videoDetails.isLiveContent == true or tab.videoDetails.isLive == true) then m_simpleTV.Http.Close(session) return StreamLive(tab.streamingData.hlsManifestUrl, tab.videoDetails.isLive, title) end if tab.streamingData and tab.streamingData.formats then local k = 1 while tab.streamingData.formats[k] do t[i] = {} t[i].itag = tab.streamingData.formats[k].itag t[i].fps = tab.streamingData.formats[k].fps t[i].qlty = tab.streamingData.formats[k].height t[i].width = tab.streamingData.formats[k].width t[i].Address = tab.streamingData.formats[k].url or tab.streamingData.formats[k].signatureCipher t[i].isAdaptive = false if tab.streamingData.formats[k].signatureCipher then t[i].isCipher = true end k = k + 1 i = k end end local audioTracks if tab.streamingData and tab.streamingData.adaptiveFormats then local k = 1 while tab.streamingData.adaptiveFormats[k] do if tab.streamingData.adaptiveFormats[k].contentLength then t[i] = {} t[i].itag = tab.streamingData.adaptiveFormats[k].itag t[i].qlty = tab.streamingData.adaptiveFormats[k].height t[i].width = tab.streamingData.adaptiveFormats[k].width t[i].fps = tab.streamingData.adaptiveFormats[k].fps t[i].Address = tab.streamingData.adaptiveFormats[k].url or tab.streamingData.adaptiveFormats[k].signatureCipher t[i].isAdaptive = true if tab.streamingData.adaptiveFormats[k].signatureCipher then t[i].isCipher = true end if tab.streamingData.adaptiveFormats[k].audioTrack and tab.streamingData.adaptiveFormats[k].audioTrack.audioIsDefault == true then t[i].audioIsDefault = true if not audioTracks then audioTracks = true end end i = i + 1 end k = k + 1 end end if #t == 0 then if urlAdr:match('PARAMS=psevdotv') then return end isInfoPanel = false m_simpleTV.Http.Close(session) return StreamError(tab, title) end local captions, captions_title local subtitle_config = m_simpleTV.Config.GetValue('subtitle/disableAtStart', 'simpleTVConfig') or 'true' if tab.captions and tab.captions.playerCaptionsTracklistRenderer and tab.captions.playerCaptionsTracklistRenderer.captionTracks and subtitle_config == 'true' then captions, captions_title = Subtitle(tab) end for i = 1, #t do t[i].qlty = tonumber(t[i].qlty or '0') t[i].width = tonumber(t[i].width or '0') t[i].fps = tonumber(t[i].fps or '0') t[i].itag = tonumber(t[i].itag or '0') if (t[i].qlty > 340 and t[i].qlty < 500) and t[i].width > 640 then t[i].qlty = 480 end if (t[i].qlty > 250 and t[i].qlty < 300) and t[i].width > 600 then t[i].qlty = 360 end if (t[i].qlty > 760 and t[i].qlty < 1200) and t[i].width > 1600 then t[i].qlty = 1080 end if t[i].qlty > 0 and t[i].qlty <= 180 then t[i].qlty = 144 elseif t[i].qlty > 180 and t[i].qlty <= 300 then t[i].qlty = 240 elseif t[i].qlty > 300 and t[i].qlty <= 400 then t[i].qlty = 360 elseif t[i].qlty > 400 and t[i].qlty <= 500 then t[i].qlty = 480 elseif t[i].qlty > 500 and t[i].qlty <= 780 then t[i].qlty = 720 elseif t[i].qlty > 780 and t[i].qlty <= 1200 then t[i].qlty = 1080 elseif t[i].qlty > 1200 and t[i].qlty <= 1500 then t[i].qlty = 1440 elseif t[i].qlty > 1500 and t[i].qlty <= 2800 then t[i].qlty = 2160 elseif t[i].qlty > 2160 and t[i].qlty < 5000 then t[i].qlty = 4320 else t[i].qlty = 0 end t[i].Name = t[i].qlty .. 'p' if t[i].fps > 30 then t[i].Name = t[i].Name .. ' ' .. t[i].fps .. ' FPS' if t[i].itag == 334 or t[i].itag == 335 or t[i].itag == 336 or t[i].itag == 337 then t[i].qlty = t[i].qlty + 7 t[i].Name = t[i].Name .. ' HDR' else t[i].qlty = t[i].qlty + 6 end end end local aAdr, aItag, aAdr_isCipher, aItag_opus, aAdr_opus local video_itags = { 394, 160, 278, -- 144 395, 133, 242, -- 240 18, 134, 243, -- 360 135, 244, -- 480 136, 247, 22, -- 720 298, -- 720 (60 fps) 302, 334, -- 720 (60 fps, HDR) 137, 248, -- 1080 299, 335, -- 1080 (60 fps, HDR) 271, 308, 336, -- 1440 (60 fps, HDR) 313, 315, 337, -- 2160 (60 fps, HDR) 272 -- 4320 (60 fps) } local audio_itags = { 258, -- MP4 AAC (LC) 384 Kbps Surround (5.1) 141, -- MP4 AAC (LC) 256 Kbps Stereo (2) 140, -- MP4 AAC (LC) 128 Kbps Stereo (2) 251, -- WebM Opus (VBR) ~160 Kbps Stereo (2) } if (m_simpleTV.User.YT.isVideo == true and m_simpleTV.Control.ChannelID ~= 268435455) or m_simpleTV.User.YT.isVideo == false then video_itags = ItagRemove(video_itags, 22) end if audioTracks then video_itags = ItagRemove(video_itags, 18) for i = 1, #audio_itags do for z = 1, #t do if t[z].audioIsDefault == true then if audio_itags[i] == t[z].itag then if audio_itags[i] == 251 then aAdr_opus = StreamFormat(t[z].Address, t[z].isCipher) aItag_opus = t[z].itag aAdr_isCipher = t[z].isCipher elseif not aItag then aAdr = StreamFormat(t[z].Address, t[z].isCipher) aItag = t[z].itag aAdr_isCipher = t[z].isCipher end break end end end end else for i = 1, #audio_itags do for z = 1, #t do if audio_itags[i] == t[z].itag then if audio_itags[i] == 251 then aAdr_opus = StreamFormat(t[z].Address, t[z].isCipher) aItag_opus = t[z].itag aAdr_isCipher = t[z].isCipher elseif not aItag then aAdr = StreamFormat(t[z].Address, t[z].isCipher) aItag = t[z].itag aAdr_isCipher = t[z].isCipher end break end end end end local sort = {} for i = 1, #video_itags do for z = 1, #t do if video_itags[i] == t[z].itag then sort[#sort + 1] = t[z] break end end end if #sort == 0 then sort = t end local hash, noDuplicate = {}, {} for i = 1, #sort do if not hash[sort[i].Name] then noDuplicate[#noDuplicate + 1] = sort[i] hash[sort[i].Name] = true end end t = {} for i = 1, #noDuplicate do if noDuplicate[i].qlty > 300 then t[#t + 1] = Stream(noDuplicate[i], adrStart, aAdr, aItag, aAdr_opus, aItag_opus, captions) end end if #t == 0 then for i = 1, #noDuplicate do t[#t + 1] = Stream(noDuplicate[i], adrStart, aAdr, aItag, aAdr_opus, aItag_opus, captions) end end if #t == 0 then m_simpleTV.Http.Close(session) return nil, 'GetStreamsTab Error 2' end if aAdr then local audioItag = tonumber(aAdr:match('itag=(%d+)') or 0) if audioItag == 258 then aAdr_opus = aAdr end end local aAdrName, audioId, itag_a if aAdr_opus or aAdr then aAdr = (aAdr_opus or aAdr) .. (adrStart or '') .. '$OPT:NO-STIMESHIFT' aAdrName = '🔉 ' .. m_simpleTV.User.YT.Lng.audio audioId = 99 if infoInFile then itag_a = aAdr:match('itag=(%d+)') end else aAdr = 'vlc://pause:5' aAdrName = '🔇 ' .. m_simpleTV.User.YT.Lng.noAudio audioId = 10 end t[#t + 1] = {Name = aAdrName, qlty = audioId, Address = aAdr, isCipher = aAdr_isCipher, aItag = itag_a} table.sort(t, function(a, b) return a.qlty < b.qlty end) inf01 = {} for i = 1, #t do t[i].Id = i if infoInFile then if i == 1 then inf01[1] = '[1] audio itag = ' .. tostring(t[1].aItag ) else inf01[i] = '[' .. i .. '] qlty: ' .. tostring(t[i].qlty) .. ' | video itag: ' .. tostring(t[i].itag) .. ' | audio itag: ' .. tostring(t[i].aItag) end end end if infoInFile then inf01 = table.concat(inf01, '\n') end if m_simpleTV.User.YT.qlty < 100 then if audioId == 99 and not isInfoPanel then title = title .. '\n☑ ' .. m_simpleTV.User.YT.Lng.audio else title = title .. '\n☐ ' .. m_simpleTV.User.YT.Lng.noAudio end if not m_simpleTV.User.YT.DelayedAddress then local visual = tostring(m_simpleTV.Config.GetValue('vlc/audio/visual/module', 'simpleTVConfig') or '') if visual == 'none' or visual == '' then SetBackground(m_simpleTV.User.YT.pic or m_simpleTV.User.YT.logoPicFromDisk) else SetBackground() end end elseif captions_title and not isInfoPanel then title = title .. '\n☑ ' .. m_simpleTV.User.YT.Lng.sub .. captions_title end if m_simpleTV.User.YT.isAuth and m_simpleTV.User.YT.isLive == false and m_simpleTV.User.YT.isTrailer == false and tab.playbackTracking and tab.playbackTracking.videostatsPlaybackUrl and tab.playbackTracking.videostatsPlaybackUrl.baseUrl then m_simpleTV.User.YT.videostats = tab.playbackTracking.videostatsPlaybackUrl.baseUrl end m_simpleTV.Http.Close(session) if m_simpleTV.User.YT.duration and m_simpleTV.User.YT.duration > 120 and m_simpleTV.User.YT.desc ~= '' and m_simpleTV.User.YT.desc:match('%d+:%d+') then Chapters() end return t, title end local function plst_channels(str, tab, typePlst, i) local ret = false local desc, count, count2, subCount, logo, name, adr for g in str:gmatch('"channelRenderer".-"subscribeButton"') do name = g:match('"simpleText":"([^"]+)') adr = g:match('"channelId":"([^"]+)') if name and adr then tab[i] = {} tab[i].Id = i if typePlst == 'channels' then tab[i].Address = 'https://www.youtube.com/channel/' .. adr .. '&isLogo=false' else tab[i].Address = 'https://www.youtube.com/feeds/videos.xml?channel_id=' .. adr .. '&isLogo=false&isRestart=true' end name = title_clean(name) tab[i].Name = name if isInfoPanel == true then desc = g:match('"descriptionSnippet":{"runs":%[{"text":"([^"]+)') count, count2 = g:match('"videoCountText":{"runs":%[{"text":"([^"]+)"},{"text":"([^"]+)') subCount = g:match('"subscriberCountText":{"simpleText":"([^"]+)') logo = g:match('"thumbnails":%[{"url":"[^%]]+"url":"([^"]+)') or g:match('"thumbnails":%[{"url":"([^"]+)') or '' logo = logo:gsub('^//', 'https://') tab[i].InfoPanelLogo = logo tab[i].InfoPanelShowTime = 10000 tab[i].InfoPanelName = m_simpleTV.User.YT.Lng.channel .. ': ' .. name local panelDescName if desc and desc ~= '' then panelDescName = m_simpleTV.User.YT.Lng.desc .. ' | ' end tab[i].InfoPanelDesc = desc_html(desc, logo, name, tab[i].Address) count = (count or '') .. (count2 or '') if subCount and subCount ~= '' then if count and count ~= '' then subCount = ' | ' .. subCount end else subCount = nil end tab[i].InfoPanelTitle = (panelDescName or ' ') .. (count or '') .. (subCount or '') end i = i + 1 ret = true end end return ret end local function plst_rss(str, tab, typePlst, i) local ret = false local name, published, adr, desc, panelDescName for g in str:gmatch('<entry>.-</entry>') do name = g:match('<title>([^<]+)') adr = g:match('<yt:videoId>([^<]+)') published = g:match('<published>([^<]+)') if name and adr and published then tab[i] = {} tab[i].Id = i name = title_clean(name) tab[i].Address = string.format('https://www.youtube.com/watch?v=%s&isPlst=true', adr) published = timeStamp(published) published = os.date('%y %d %m %H %M', tonumber(published)) local year, day, month, hour, min = published:match('(%d+) (%d+) (%d+) (%d+) (%d+)') published = string.format('%d/%d/%02d %d:%02d', day, month, year, hour, min) if isInfoPanel == false then tab[i].Name = name .. ' (' .. published .. ')' else tab[i].Name = name tab[i].InfoPanelName = name tab[i].InfoPanelLogo = string.format('https://i.ytimg.com/vi/%s/default.jpg', adr) tab[i].InfoPanelShowTime = 10000 panelDescName = nil desc = g:match('<media:description>([^<]+)') tab[i].InfoPanelDesc = desc_html(desc, tab[i].InfoPanelLogo, name, tab[i].Address) if desc and desc ~= '' then panelDescName = m_simpleTV.User.YT.Lng.desc end tab[i].InfoPanelTitle = (panelDescName or '') .. ' | ' .. published end i = i + 1 ret = true end end return ret end local function plst_video(str, tab, typePlst, i) local ret = false local render if typePlst == 'panel_videos' then if str:match('"twoColumnBrowseResultsRenderer"') then render = 'playlistVideo' else render = 'playlistPanelVideo' end else if str:match('"gridVideoRenderer"') and str:match('"videoRenderer"') then render = '"video' else render = '[eod]' end end if typePlst == 'main' then render = '"video' end local times, count, publis, channel, name, adr, desc, panelDescName, selected for g in str:gmatch(render .. 'Renderer".-"thumbnailOverlayNowPlayingRenderer"') do if render == 'playlistPanelVideo' then name = g:match('"title".-"simpleText":"([^"]+)') else name = g:match('"title":%s*{%s*"runs":%s*%[%s*{%s*"text":%s*"([^"]+)') or g:match('"simpleText":%s*"([^"]+)') end adr = g:match('"videoId":%s*"([^"]+)') if name and adr then times = g:match('"thumbnailOverlayTimeStatusRenderer".-"simpleText":%s*"([^"]+)') name = title_clean(name) tab[i] = {} tab[i].Id = i tab[i].Address = string.format('https://www.youtube.com/watch?v=%s&isPlst=' .. typePlst, adr) if isInfoPanel == false then if not times then times = m_simpleTV.User.YT.Lng.live end tab[i].Name = string.format('%s [%s]', name, times) else if times then tab[i].Name = name else times = m_simpleTV.User.YT.Lng.live tab[i].Name = string.format('%s [%s]', name, times) end count = g:match('"shortViewCountText":%s*{%s*"simpleText":%s*"([^"]+)') or g:match('iewCountText":%s*{%s*"simpleText":%s*"([^"]+)') publis = g:match('"publishedTimeText":%s*{%s*"simpleText":%s*"([^"]+)') if count and publis then count = publis .. ' ◽ ' .. count else count = count or publis end if count then count = ' | ' .. count else count = '' end channel = g:match('"shortBylineText":%s*{%s*"runs":%s*%[%s*{%s*"text":%s*"([^"]+)') if channel then channel = ' | ' .. title_clean(channel) else channel = '' end desc = g:match('"descriptionSnippet":%s*{%s*"runs":%s*%[%s*{%s*"text":%s*"([^"]+)') or g:match('"descriptionSnippet":%s*{%s*"simpleText":%s*"([^"]+)') if desc and desc ~= '' then panelDescName = m_simpleTV.User.YT.Lng.desc else panelDescName = '' end tab[i].InfoPanelLogo = string.format('https://i.ytimg.com/vi/%s/default.jpg', adr) tab[i].InfoPanelName = name tab[i].InfoPanelDesc = desc_html(desc, tab[i].InfoPanelLogo, name, tab[i].Address) if typePlst ~= 'panel_videos' then tab[i].InfoPanelTitle = string.format('%s%s%s | %s', panelDescName, count, channel, times) else tab[i].InfoPanelTitle = string.format('| %s', times) end tab[i].InfoPanelShowTime = 10000 end if not selected and adr == videoId then selected = true m_simpleTV.User.YT.plstPos = i end i = i + 1 ret = true end end return ret end local function AddInPl_Plst_YT(str, tab, typePlst) local i = #tab + 1 local ret = false str = str:gsub('\\"', '%%22') if typePlst == 'channels' or typePlst == 'rss_channels' then ret = plst_channels(str, tab, typePlst, i) elseif typePlst == 'rss_videos' then ret = plst_rss(str, tab, typePlst, i) else ret = plst_video(str, tab, typePlst, i) end return ret end local function AddInPl_PlstApi_YT(str, tab) local i = #tab + 1 local ret = false local selected str = str:gsub('\\"', '%%22') for name, desc, adr in str:gmatch('"title": "([^"]+).-"description": "([^"]*).-"videoId": "([^"]+)') do if name ~= 'Deleted video' and name ~= 'Private video' then name = title_clean(name) tab[i] = {} tab[i].Id = i if not selected and adr == videoId then selected = true m_simpleTV.User.YT.plstPos = i end adr = string.format('https://www.youtube.com/watch?v=%s&isPlst=true', adr) if m_simpleTV.User.YT.isPlstsCh == true then adr = adr .. '&isPlstsCh=true' end tab[i].Address = adr tab[i].Name = name if isInfoPanel == true then tab[i].InfoPanelLogo = string.format('https://i.ytimg.com/vi/%s/default.jpg', adr) tab[i].InfoPanelName = name local panelDescName if desc and desc ~= '' then panelDescName = m_simpleTV.User.YT.Lng.desc end tab[i].InfoPanelDesc = desc_html(desc, tab[i].InfoPanelLogo, name, tab[i].Address) tab[i].InfoPanelTitle = (panelDescName or ' ') tab[i].InfoPanelShowTime = 10000 end i = i + 1 ret = true end end return ret end local function PlstApi(inAdr) local plstId = inAdr:match('list=([^&]*)') m_simpleTV.User.YT.plstPos = nil m_simpleTV.User.YT.isVideo = false if not m_simpleTV.User.YT.isPlstsCh then m_simpleTV.User.YT.PlstsCh.chTitle = nil end m_simpleTV.Control.ExecuteAction(37) if not m_simpleTV.User.YT.apiKey then GetApiKey() end local url = 'https://www.googleapis.com/youtube/v3/playlists?part=snippet&fields=items/snippet/localized/title&id=' .. plstId .. '&hl=' .. m_simpleTV.User.YT.Lng.hl .. '&key=' .. m_simpleTV.User.YT.apiKey local rc, answer = m_simpleTV.Http.Request(session, {url = url, headers = m_simpleTV.User.YT.apiKeyHeader}) if rc ~= 200 then answer = '' end answer = answer:gsub('\\"', '%%22') local header = answer:match('"title": "([^"]+)') or m_simpleTV.User.YT.Lng.plst header = title_clean(header) m_simpleTV.User.YT.plstHeader = header url = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&fields=pageInfo&playlistId=' .. plstId .. '&key=' .. m_simpleTV.User.YT.apiKey rc, answer = m_simpleTV.Http.Request(session, {url = url, headers = m_simpleTV.User.YT.apiKeyHeader}) if rc ~= 200 then answer = '' end local plstTotalResults = tonumber(answer:match('"totalResults": (%d+)') or '1') if m_simpleTV.User.YT.isPlstsCh and not m_simpleTV.User.YT.is_channel_banner then SetBackground((m_simpleTV.User.YT.channel_banner or m_simpleTV.User.YT.logoPicFromDisk), 3) end m_simpleTV.User.YT.is_channel_banner = nil local t0 = {} t0.url = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&fields=nextPageToken,items(snippet/title,snippet/resourceId/videoId,snippet/description)&playlistId=' .. plstId .. '&key=' .. m_simpleTV.User.YT.apiKey t0.method = 'get' t0.headers = m_simpleTV.User.YT.apiKeyHeader local params = {} params.Message = '⇩ ' .. m_simpleTV.User.YT.Lng.loading params.Callback = AsynPlsCallb_PlstApi_YT params.ProgressColor = ARGB(128, 255, 0, 0) params.User = {} params.User.tab = {} params.User.rc = nil params.User.plstId = plstId params.User.plstTotalResults = plstTotalResults params.ProgressEnabled = true if plstTotalResults < 301 then params.delayedShow = 1500 end asynPlsLoaderHelper.Work(session, t0, params) local tab = params.User.tab rc = params.User.rc if rc == 400 or rc == - 1 then StopOnErr(8) return end if #tab == 0 and rc then if rc == 404 and not inAdr:match('&isRestart=true') then if plstId:match('^RD') then inAdr = 'https://www.youtube.com/watch?v=' .. plstId:gsub('^RD', '') ..'&list=' .. plstId else inAdr = inAdr .. '&index=1' end elseif (rc == 404 or rc == 403) and inAdr:match('&isRestart=true') then inAdr = inAdr:gsub('[?&]list=[%w_%-]+', '') end m_simpleTV.Http.Close(session) m_simpleTV.Control.ChangeAddress = 'No' inAdr = inAdr .. '&isRestart=true' if urlAdr:match('&isLogo=false') then inAdr = inAdr .. '&isLogo=false' end m_simpleTV.Control.CurrentAddress = inAdr dofile(m_simpleTV.MainScriptDir .. 'user/video/YT.lua') return end if #tab == 0 and not rc then StopOnErr(9, m_simpleTV.User.YT.Lng.videoNotAvail) if m_simpleTV.User.YT.isPlstsCh == true then m_simpleTV.Common.Sleep(2000) m_simpleTV.Control.ChangeAddress = 'No' m_simpleTV.Control.CurrentAddress = m_simpleTV.User.YT.PlstsCh.MainUrl .. '&isRestart=true' dofile(m_simpleTV.MainScriptDir .. 'user/video/YT.lua') end return end if not plstPos and videoId and inAdr:match('[?&]t=') then inAdr = inAdr:gsub('[?&]list=[%w_%-]+', '') m_simpleTV.Http.Close(session) m_simpleTV.Control.ChangeAddress = 'No' m_simpleTV.Control.CurrentAddress = inAdr .. '&isRestart=true' dofile(m_simpleTV.MainScriptDir .. 'user/video/YT.lua') return end m_simpleTV.User.YT.Plst = tab local plstPos = m_simpleTV.User.YT.plstPos or 1 local pl = 0 if plstPos > 1 or inAdr:match('[?&]t=') or #tab == 1 then pl = 32 end local FilterType, AutoNumberFormat, Random, PlayMode if #tab > 2 then if #tab < 15 then FilterType = 2 else FilterType = 1 end AutoNumberFormat = '%1. %2' else FilterType = 2 AutoNumberFormat = '' end if plstId:match('^RD') and urlAdr:match('isLogo=false') then if #tab > 2 then plstPos = math.random(3, #tab) end pl = 32 Random = 1 PlayMode = 1 else Random = - 1 PlayMode = - 1 end if m_simpleTV.User.paramScriptForSkin_buttonOptions then tab.ExtButton0 = {ButtonEnable = true, ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonOptions, ButtonScript = 'Qlty_YT()'} else tab.ExtButton0 = {ButtonEnable = true, ButtonName = '⚙', ButtonScript = 'Qlty_YT()'} end if m_simpleTV.User.YT.isPlstsCh then if m_simpleTV.User.paramScriptForSkin_buttonPlst then tab.ExtButton1 = {ButtonEnable = true, ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonPlst, ButtonScript = 'PlstsCh_YT()'} else tab.ExtButton1 = {ButtonEnable = true, ButtonName = '📋', ButtonScript = 'PlstsCh_YT()'} end else local ButtonScript1 = [[ m_simpleTV.Control.ExecuteAction(37) m_simpleTV.Control.ChangeAddress = 'No' m_simpleTV.Control.CurrentAddress = 'https://www.youtube.com/channel/' .. m_simpleTV.User.YT.chId .. '&isRestart=true' dofile(m_simpleTV.MainScriptDir .. 'user/video/YT.lua') ]] if m_simpleTV.User.paramScriptForSkin_buttonPlst then tab.ExtButton1 = {ButtonEnable = true, ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonPlst, ButtonScript = ButtonScript1} else tab.ExtButton1 = {ButtonEnable = true, ButtonName = '📋', ButtonScript = ButtonScript1} end end if m_simpleTV.User.paramScriptForSkin_buttonOk then tab.OkButton = {ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonOk} end local retAdr tab.ExtParams = {} tab.ExtParams.FilterType = FilterType tab.ExtParams.Random = Random tab.ExtParams.PlayMode = PlayMode tab.ExtParams.AutoNumberFormat = AutoNumberFormat tab.ExtParams.LuaOnCancelFunName = 'OnMultiAddressCancel_YT' tab.ExtParams.LuaOnOkFunName = 'OnMultiAddressOk_YT' tab.ExtParams.LuaOnTimeoutFunName = 'OnMultiAddressCancel_YT' local vId = tab[plstPos].Address:match('watch%?v=([^&]+)') if (#tab > 1 and plstPos == 1) or m_simpleTV.User.YT.isPlstsCh then m_simpleTV.User.YT.DelayedAddress = tab[1].Address m_simpleTV.OSD.ShowSelect_UTF8(header, 0, tab, 10000, 2) retAdr = 'wait' else m_simpleTV.OSD.ShowSelect_UTF8(header, plstPos - 1, tab, 10000, pl) end local t, title = GetStreamsTab(vId) if not t or type(t) ~= 'table' then StopOnErr(10, title) return end m_simpleTV.User.YT.QltyTab = t local index = GetQltyIndex(t) if not retAdr then m_simpleTV.Control.CurrentTitle_UTF8 = header .. ' (' .. title:gsub('\n.-$', '') .. ')' MarkWatch_YT() if infoPanelCheck() == false then title = title_is_no_infoPanel(title, t[index].Name) ShowMsg(title .. '\n☑ ' .. m_simpleTV.User.YT.Lng.plst) end end m_simpleTV.User.YT.QltyIndex = index retAdr = retAdr or StreamCheck(t, index) local plstPicId if plstId:match('^RD') then local plstPicIdRD = plstId:gsub('^RD', '') m_simpleTV.User.YT.AddToBaseUrlinAdr = 'https://www.youtube.com/embed?listType=playlist&list=' .. plstId plstPicId = plstPicIdRD m_simpleTV.User.YT.AddToBaseVideoIdPlst = plstPicIdRD else m_simpleTV.User.YT.AddToBaseUrlinAdr = 'https://www.youtube.com/playlist?list=' .. plstId plstPicId = tab[1].Address:match('watch%?v=([^&]+)') m_simpleTV.User.YT.AddToBaseVideoIdPlst = plstPicId end if #tab == 1 then retAdr = positionToContinue(retAdr) else retAdr = retAdr .. '$OPT:POSITIONTOCONTINUE=0' end m_simpleTV.Control.CurrentAddress = retAdr if m_simpleTV.User.YT.isPlstsCh then m_simpleTV.Control.SetNewAddressT({address = m_simpleTV.Control.CurrentAddress}) m_simpleTV.Control.CurrentTitle_UTF8 = '' else if m_simpleTV.Control.MainMode == 0 then if not urlAdr:match('isLogo=false') and not urlAdr:match('&isRestart=true') then m_simpleTV.Control.ChangeChannelLogo(m_simpleTV.User.paramScriptForSkin_logoYT or 'https://i.ytimg.com/vi/' .. plstPicId .. '/hqdefault.jpg' , m_simpleTV.Control.ChannelID , 'CHANGE_IF_NOT_EQUAL') end if not urlAdr:match('isLogo=false') or urlAdr:match('isSearch=true') then m_simpleTV.Control.ChangeChannelName(header, m_simpleTV.Control.ChannelID, false) end end if not urlAdr:match('isLogo=false') then m_simpleTV.Control.CurrentTitle_UTF8 = header else m_simpleTV.Control.SetTitle(header .. ' (' .. title .. ')') end end return end local function Plst(inAdr) m_simpleTV.Control.ExecuteAction(37) if not m_simpleTV.User.YT.isPlstsCh then m_simpleTV.User.YT.PlstsCh.chTitle = nil end m_simpleTV.User.YT.isVideo = false m_simpleTV.User.YT.plstPos = nil if m_simpleTV.User.YT.isPlstsCh and not m_simpleTV.User.YT.is_channel_banner then SetBackground((m_simpleTV.User.YT.channel_banner or m_simpleTV.User.YT.logoPicFromDisk), 3) end m_simpleTV.User.YT.is_channel_banner = nil local url = inAdr:gsub('&is%a+=%a+', '') local params = {} params.Message = '⇩ ' .. m_simpleTV.User.YT.Lng.loading params.Callback = AsynPlsCallb_Plst_YT params.ProgressColor = ARGB(128, 255, 0, 0) params.User = {} params.User.tab = {} params.delayedShow = 1800 params.User.Title = '' params.User.First = true params.User.setTitle = true if inAdr:match('&isPlstsCh=true') then params.User.setTitle = false videoId = m_simpleTV.User.YT.vId end if url:match('/feed/history') then params.User.typePlst = 'history' elseif url:match('/feed/channels') then params.User.typePlst = 'channels' elseif url:match('/feed/rss_channels') then params.User.typePlst = 'rss_channels' elseif url:match('/feeds/videos%.xml') then params.User.typePlst = 'rss_videos' elseif url:match('list=') and not ((url:match('list=WL') or url:match('list=LL') or url:match('list=LM')) and not url:match('index=')) then params.User.typePlst = 'panel_videos' elseif url:match('youtube%.com$') then params.User.typePlst = 'main' elseif url:match('/feed/subscriptions') then params.User.typePlst = 'subscriptions' else params.User.typePlst = 'true' end local logo if url:match('/feed/subscriptions') then url = url:gsub('^(.-/feed/subscriptions).-$', '%1?flow=2') logo = 'https://s.ytimg.com/yts/img/favicon_144-vfliLAfaB.png' elseif url:match('/feed/history') then logo = 'https://s.ytimg.com/yts/img/reporthistory/land-img-vfl_eF5BA.png' elseif url:match('/feed/rss_channels') then url = url:gsub('rss_', '') logo = 'https://s.ytimg.com/yts/img/favicon_144-vfliLAfaB.png' elseif url:match('/feed/channels') then logo = 'https://s.ytimg.com/yts/img/favicon_144-vfliLAfaB.png' elseif url:match('youtube%.com$') then logo = 'https://s.ytimg.com/yts/img/favicon_144-vfliLAfaB.png' end if url:match('list=WL') or url:match('list=LL') or url:match('list=LM') then params.ProgressEnabled = true params.ProgressColor = ARGB(128, 255, 0, 0) end local t0 = {} t0.url = url t0.method = 'get' m_simpleTV.Http.SetCookies(session, url, m_simpleTV.User.YT.cookies, '') asynPlsLoaderHelper.Work(session, t0, params) local header = params.User.Title local tab = params.User.tab if #tab == 0 then StopOnErr(1) return end if params.User.typePlst == 'channels' or params.User.typePlst == 'rss_channels' then local FilterType, SortOrder, AutoNumberFormat if #tab > 1 then FilterType = 1 SortOrder = 1 AutoNumberFormat = '%1. %2' else FilterType = 2 SortOrder = 0 AutoNumberFormat = '' end tab.ExtParams = {FilterType = FilterType, SortOrder = SortOrder, AutoNumberFormat = AutoNumberFormat} if m_simpleTV.User.paramScriptForSkin_buttonClose then tab.ExtButton1 = {ButtonEnable = true, ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonClose} else tab.ExtButton1 = {ButtonEnable = true, ButtonName = '✕'} end if m_simpleTV.User.paramScriptForSkin_buttonOk then tab.OkButton = {ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonOk} end local ret, id = m_simpleTV.OSD.ShowSelect_UTF8(header, -1, tab, 30000, 1 + 4 + 8 + 2) m_simpleTV.Control.ExecuteAction(37) if not id or ret == 3 then m_simpleTV.Control.ExecuteAction(37) m_simpleTV.Control.ExecuteAction(11) return end PlayAddressT_YT(tab[id].Address, false) if m_simpleTV.Control.MainMode == 0 then logo = m_simpleTV.User.paramScriptForSkin_logoYT or logo m_simpleTV.Control.ChangeChannelLogo(logo, m_simpleTV.Control.ChannelID, 'CHANGE_IF_NOT_EQUAL') m_simpleTV.Control.ChangeChannelName(header, m_simpleTV.Control.ChannelID, false) end return end local plstPos = m_simpleTV.User.YT.plstPos or 1 m_simpleTV.User.YT.Plst = tab m_simpleTV.User.YT.plstHeader = header if m_simpleTV.User.paramScriptForSkin_buttonOptions then tab.ExtButton0 = {ButtonEnable = true, ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonOptions, ButtonScript = 'Qlty_YT()'} else tab.ExtButton0 = {ButtonEnable = true, ButtonName = '⚙', ButtonScript = 'Qlty_YT()'} end local FilterType, AutoNumberFormat, pl if #tab > 1 then FilterType = 1 AutoNumberFormat = '%1. %2' pl = 0 else FilterType = 2 AutoNumberFormat = '' pl = 32 end if plstPos > 1 or url:match('[?&]t=') or #tab == 1 then pl = 32 end if plstPos > 1 and inAdr:match('&isPlstsCh=true') then pl = 0 end local ButtonScript1 if m_simpleTV.User.YT.isPlstsCh then if m_simpleTV.User.paramScriptForSkin_buttonPlst then tab.ExtButton1 = {ButtonEnable = true, ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonPlst, ButtonScript = 'PlstsCh_YT()'} else tab.ExtButton1 = {ButtonEnable = true, ButtonName = '📋', ButtonScript = 'PlstsCh_YT()'} end elseif not inAdr:match('&isPlstsCh=true') then local ButtonScript1 = [[ m_simpleTV.Control.ExecuteAction(37) m_simpleTV.Control.ChangeAddress = 'No' m_simpleTV.Control.CurrentAddress = 'https://www.youtube.com/channel/' .. m_simpleTV.User.YT.chId .. '&isRestart=true' dofile(m_simpleTV.MainScriptDir .. 'user/video/YT.lua') ]] if m_simpleTV.User.paramScriptForSkin_buttonPlst then tab.ExtButton1 = {ButtonEnable = true, ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonPlst, ButtonScript = ButtonScript1} else tab.ExtButton1 = {ButtonEnable = true, ButtonName = '📋', ButtonScript = ButtonScript1} end end if m_simpleTV.User.paramScriptForSkin_buttonOk then tab.OkButton = {ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonOk} end local retAdr tab.ExtParams = {} tab.ExtParams.FilterType = FilterType tab.ExtParams.AutoNumberFormat = AutoNumberFormat tab.ExtParams.LuaOnCancelFunName = 'OnMultiAddressCancel_YT' tab.ExtParams.LuaOnOkFunName = 'OnMultiAddressOk_YT' tab.ExtParams.LuaOnTimeoutFunName = 'OnMultiAddressCancel_YT' local vId = tab[plstPos].Address:match('v=([^&]+)') m_simpleTV.User.YT.AddToBaseUrlinAdr = url m_simpleTV.User.YT.AddToBaseVideoIdPlst = vId if #tab > 1 and plstPos == 1 then m_simpleTV.User.YT.DelayedAddress = tab[1].Address m_simpleTV.OSD.ShowSelect_UTF8(header, 0, tab, 10000, 2) retAdr = 'wait' else m_simpleTV.OSD.ShowSelect_UTF8(header, plstPos - 1, tab, 10000, pl) end local t, title = GetStreamsTab(vId) if not t or type(t) ~= 'table' then StopOnErr(2, title) return end m_simpleTV.User.YT.QltyTab = t local index = GetQltyIndex(t) if not retAdr then m_simpleTV.Control.CurrentTitle_UTF8 = header .. ' (' .. title:gsub('\n.-$', '') .. ')' MarkWatch_YT() if infoPanelCheck() == false then title = title_is_no_infoPanel(title, t[index].Name) ShowMsg(title .. '\n☑ ' .. m_simpleTV.User.YT.Lng.plst) end else m_simpleTV.Control.CurrentTitle_UTF8 = header end m_simpleTV.User.YT.QltyIndex = index retAdr = retAdr or StreamCheck(t, index) if #tab == 1 then retAdr = positionToContinue(retAdr) else retAdr = retAdr .. '$OPT:POSITIONTOCONTINUE=0' end m_simpleTV.Control.CurrentAddress = retAdr if m_simpleTV.User.YT.isPlstsCh then m_simpleTV.Control.SetNewAddressT({address = m_simpleTV.Control.CurrentAddress}) else if m_simpleTV.Control.MainMode == 0 then logo = m_simpleTV.User.paramScriptForSkin_logoYT or logo or 'https://i.ytimg.com/vi/' .. vId .. '/hqdefault.jpg' m_simpleTV.Control.ChangeChannelLogo(logo, m_simpleTV.Control.ChannelID, 'CHANGE_IF_NOT_EQUAL') m_simpleTV.Control.ChangeChannelName(header, m_simpleTV.Control.ChannelID, false) end end return end local function PlstsCh(inAdr) if (m_simpleTV.Control.Reason == 'Stopped' or m_simpleTV.Control.Reason == 'EndReached') and (inAdr:match('isPlstsCh=true') or (inAdr:match('&isRestart=true') and not inAdr:match('/youtubei/') and not inAdr:match('&sort=.-&isRestart=true'))) then m_simpleTV.Control.ExecuteAction(63) return end local url = inAdr url = url:gsub('%?view=1$', '?view=1&sort=dd&shelf_id=0') if url:match('/live$') or url:match('/embed/live_stream') then local rc, answer = m_simpleTV.Http.Request(session, {url = url}) if rc ~= 200 then StopOnErr(3) return end if inAdr:match('/live$') then liveId = answer:match('"liveStreamabilityRenderer":{"videoId":"([^"]+)') else liveId = answer:match('"watchEndpoint\\":{\\"videoId\\":\\"([^\\]+)') end if liveId then m_simpleTV.Http.Close(session) m_simpleTV.Control.ChangeAddress = 'No' m_simpleTV.Control.CurrentAddress = 'https://www.youtube.com/watch?v=' .. liveId .. '&isRestart=true' dofile(m_simpleTV.MainScriptDir .. 'user/video/YT.lua') return end url = url:gsub('/live$', '') url = url:gsub('embed/live_stream%?channel=', 'channel/') end if not url:match('/youtubei/') and not url:match('/playlists') then url = url:gsub('/?$', '') .. '/playlists' end if not url:match('sort=') and not url:match('/youtubei/') then url = url:gsub('^(.-/playlists).-$', '%1') .. '?view=1&sort=lad&shelf_id=0' end url = url:gsub('&is%a+=%a+', '') .. '&isRestart=true' if not m_simpleTV.User.YT.PlstsCh.MainUrl then m_simpleTV.User.YT.PlstsCh.MainUrl = url end if #m_simpleTV.User.YT.PlstsCh.Urls > 0 then if m_simpleTV.User.YT.PlstsCh.MainUrl == url then m_simpleTV.User.YT.PlstsCh.Urls = nil m_simpleTV.User.YT.PlstsCh.FirstUrl = nil m_simpleTV.User.YT.PlstsCh.Num = nil m_simpleTV.User.YT.upLoadOnCh = false end end if m_simpleTV.User.YT.PlstsCh.MainUrl ~= url then if not url:match('/youtubei/') then m_simpleTV.User.YT.PlstsCh.MainUrl = url m_simpleTV.User.YT.PlstsCh.Urls = nil m_simpleTV.User.YT.PlstsCh.FirstUrl = nil m_simpleTV.User.YT.PlstsCh.Num = nil end end if not m_simpleTV.User.YT.PlstsCh.Urls then m_simpleTV.User.YT.PlstsCh.Urls = {} end local num = 0 local method = 'get' local body = '' if url:match('/youtubei/') then method = 'post' body = m_simpleTV.User.YT.PlstsCh.body url, num = url:match('^(.-)&numVideo=(%d+)') if not url or not num then StopOnErr(3.1) return end body = url:match('body=([^&]*)') or '' body = decode64(body) end if not url:match('/youtubei/') then m_simpleTV.User.YT.PlstsCh.visitorData = nil end local headers = 'X-Origin: https://www.youtube.com\nContent-Type: application/json\nX-Youtube-Client-Name: 1\nX-YouTube-Client-Version: 2.20210302.07.01\nX-Goog-Visitor-Id: ' .. (m_simpleTV.User.YT.PlstsCh.visitorData or '') .. header_Auth() m_simpleTV.Http.SetCookies(session, url, m_simpleTV.User.YT.cookies, '') local rc, answer = m_simpleTV.Http.Request(session, {body = body, method = method, url = url:gsub('&isRestart=true', ''), headers = headers}) if rc ~= 200 then StopOnErr(4, 'cant load channal page') return end answer = answer:gsub('\\"', '%%22') answer = answer:gsub('\\/', '/') if not url:match('/youtubei/') then m_simpleTV.User.YT.PlstsCh.visitorData = answer:match('"visitorData":"([^"]+)') or '' end local chTitle = answer:match('channelMetadataRenderer.-"title":%s*"([^"]+)') or answer:match('"topicChannelDetailsRenderer":{"title":%s*{%s*"simpleText":"([^"]+)') or 'Playlists' chTitle = title_clean(chTitle) local channel_banner = answer:match('"tvBanner":{"thumbnails":%[.-:480},{"url":"(.-)%-fcrop') local channel_avatar = answer:match('"thumbnails":%[{"url":"[^%]]+"url":"([^"]+)') or answer:match('"avatar":{"thumbnails":%[{"url":"([^"]+)') if channel_banner then channel_banner = channel_banner:gsub('^//', 'https://') end if channel_avatar then channel_avatar = channel_avatar:gsub('^//', 'https://') end if not url:match('/youtubei/') and not inAdr:match('&isRestart=true') then SetBackground(channel_banner or m_simpleTV.User.YT.logoPicFromDisk) m_simpleTV.Control.SetTitle(chTitle) m_simpleTV.User.YT.is_channel_banner = true end if not url:match('/youtubei/') then m_simpleTV.User.YT.channel_banner = channel_banner end local buttonNext = false local continuation = answer:match('"continuation":%s*"([^"]+)') or answer:match('"continuationCommand":%s*{%s*"token":%s*"([^"]+)') if continuation then url = 'https://www.youtube.com/youtubei/v1/browse?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8 &body=' .. encode64('{"context":{"client":{"clientName":"WEB","clientVersion":"2.20201021.03.00","hl":"' .. m_simpleTV.User.YT.Lng.hl ..'",}},"continuation":"' .. continuation .. '"}') buttonNext = true end answer = answer:gsub('"title":%s*{%s*"simpleText"', '"text"') answer = answer:gsub('{', '') answer = answer:gsub('}', '') local chId if not inAdr:match('/youtubei/') then chId = inAdr:match('/channel/([^/]+)') or answer:match('"browseId":"([^"]+)') end local tab, i = {}, 1 local j = 1 + tonumber(num) local shelf = inAdr:match('shelf_id=(%d+)') or '0' if j == 1 and chId and shelf == '0' then if not m_simpleTV.User.YT.apiKey then GetApiKey() end if m_simpleTV.User.YT.apiKey then local function PlstTotalResults() local plstId = string.format('UU%s', chId:sub(3)) local url = string.format('https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&fields=pageInfo&playlistId=%s&key=%s', plstId, m_simpleTV.User.YT.apiKey) local rc, answer = m_simpleTV.Http.Request(session, {url = url, headers = m_simpleTV.User.YT.apiKeyHeader}) if rc ~= 200 then return end local plstTotalResults = tonumber(answer:match('"totalResults": (%d+)') or '0') if plstTotalResults > 0 then local t = {} t[1] = {} t[1].Id = 1 t[1].Address = string.format('https://www.youtube.com/playlist?list=%s&isPlstsCh=true', plstId) t[1].Name = string.format('🔺 %s (%s)', m_simpleTV.User.YT.Lng.upLoadOnCh, plstTotalResults) t[1].count = plstTotalResults if isInfoPanel == true then t[1].InfoPanelLogo = channel_avatar or channel_banner or m_simpleTV.User.YT.logoPicFromDisk t[1].InfoPanelShowTime = 10000 t[1].InfoPanelName = m_simpleTV.User.YT.Lng.channel .. ': ' .. chTitle t[1].InfoPanelDesc = desc_html(nil, t[1].InfoPanelLogo, m_simpleTV.User.YT.Lng.upLoadOnCh .. ' ' .. chTitle, t[1].Address) t[1].InfoPanelTitle = ' | ' .. m_simpleTV.User.YT.Lng.plst .. ': ' .. m_simpleTV.User.YT.Lng.upLoadOnCh .. ' (' .. plstTotalResults .. ' ' .. m_simpleTV.User.YT.Lng.video .. ')' end return t end return end local plstTotalResults = PlstTotalResults() if plstTotalResults then tab = plstTotalResults i = 2 m_simpleTV.User.YT.upLoadOnCh = true end end end if m_simpleTV.User.YT.upLoadOnCh and j > 1 then j = j - 1 end for adr, logo, name, count in answer:gmatch('PlaylistRenderer":%s*"playlistId":%s*"([^"]+).-"thumbnails":%s*%[%s*"url":%s*"([^"]+).-"text":%s*"([^"]+).-"videoCountShortText":%s*"simpleText":%s*"([^"]+)') do tab[i] = {} tab[i].Id = i tab[i].count = count or '0' name = title_clean(name) tab[i].Name = j .. '. ' .. name .. ' (' .. count .. ')' tab[i].Address = string.format('https://www.youtube.com/playlist?list=%s&isPlstsCh=true', adr) if isInfoPanel == true then logo = logo:gsub('hqdefault', 'default') logo = logo:gsub('^//', 'https://') logo = logo:gsub('/vi_webp/', '/vi/') logo = logo:gsub('movieposter%.webp', 'default.jpg') tab[i].InfoPanelLogo = logo tab[i].InfoPanelShowTime = 10000 tab[i].InfoPanelName = m_simpleTV.User.YT.Lng.channel .. ': ' .. chTitle tab[i].InfoPanelDesc = desc_html(nil, logo, name, tab[i].Address) tab[i].InfoPanelTitle = ' | ' .. m_simpleTV.User.YT.Lng.plst .. ': ' .. name .. ' (' .. count .. ' ' .. m_simpleTV.User.YT.Lng.video .. ')' end j = j + 1 i = i + 1 end if #tab == 0 then for w in answer:gmatch('"itemSectionRenderer":%s*".-"thumbnails":%s*%[%s*"url":%s*"[^"]+') do name = w:match('"title":%s*"runs":%s*%[%s*"text":%s*"([^"]+)') adr = w:match('"webCommandMetadata":%s*"url":%s*"([^"]+)') if not adr or not name then break end tab[i] = {} tab[i].Id = i name = title_clean(name) tab[i].Name = j .. '. ' .. name tab[i].Address = string.format('https://www.youtube.com%s&isPlstsCh=true', adr) if isInfoPanel == true then logo = w:match('"thumbnails":%s*%[%s*"url":%s*"([^"]+)') or '' logo = logo:gsub('hqdefault', 'default') logo = logo:gsub('^//', 'https://') logo = logo:gsub('/vi_webp/', '/vi/') logo = logo:gsub('movieposter%.webp', 'default.jpg') tab[i].InfoPanelLogo = logo tab[i].InfoPanelShowTime = 10000 tab[i].InfoPanelName = m_simpleTV.User.YT.Lng.channel .. ': ' .. chTitle tab[i].InfoPanelDesc = desc_html(nil, logo, name, tab[i].Address) tab[i].InfoPanelTitle = ' | ' .. m_simpleTV.User.YT.Lng.plst .. ': ' .. name end j = j + 1 i = i + 1 end buttonNext = false end if #tab == 0 and url:match('/youtubei/') then PrevPlstsCh_YT() return elseif #tab == 0 then inAdr = inAdr:gsub('/playlists.-$', '') .. '&isPlstsCh=true' Plst(inAdr) return end m_simpleTV.User.YT.ChTitle = chTitle m_simpleTV.User.YT.PlstsChTab = tab m_simpleTV.User.YT.isPlstsCh = true local buttonPrev = false if #m_simpleTV.User.YT.PlstsCh.Urls >= 1 then buttonPrev = true end if m_simpleTV.User.paramScriptForSkin_buttonPrev then tab.ExtButton0 = {ButtonEnable = buttonPrev, ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonPrev} else tab.ExtButton0 = {ButtonEnable = buttonPrev, ButtonName = '🢀'} end if m_simpleTV.User.paramScriptForSkin_buttonNext then tab.ExtButton1 = {ButtonEnable = buttonNext, ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonNext} else tab.ExtButton1 = {ButtonEnable = buttonNext, ButtonName = '🢂'} end if m_simpleTV.User.paramScriptForSkin_buttonOk then tab.OkButton = {ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonOk} end num = #tab + tonumber(num) local nom1PlstsChTab = tonumber(tab[1].Name:match('^(%d+)') or '1') if nom1PlstsChTab == 1 then m_simpleTV.User.YT.Nom1PlstsChTab = 1 m_simpleTV.User.YT.pagePlstsCh = 1 end if nom1PlstsChTab > m_simpleTV.User.YT.Nom1PlstsChTab then m_simpleTV.User.YT.pagePlstsCh = m_simpleTV.User.YT.pagePlstsCh + 1 end if nom1PlstsChTab < m_simpleTV.User.YT.Nom1PlstsChTab then m_simpleTV.User.YT.pagePlstsCh = m_simpleTV.User.YT.pagePlstsCh - 1 end m_simpleTV.User.YT.Nom1PlstsChTab = nom1PlstsChTab if m_simpleTV.User.YT.pagePlstsCh > 1 then m_simpleTV.User.YT.ChTitle = m_simpleTV.User.YT.ChTitle .. ' (' .. m_simpleTV.User.YT.Lng.page .. ' ' .. m_simpleTV.User.YT.pagePlstsCh .. ')' end url = url .. '&numVideo=' .. num table.insert(m_simpleTV.User.YT.PlstsCh.Urls, url) if not m_simpleTV.User.YT.PlstsCh.FirstUrl then m_simpleTV.User.YT.PlstsCh.FirstUrl = url end if not m_simpleTV.User.YT.PlstsCh.Num then m_simpleTV.User.YT.PlstsCh.Num = 0 end local index = 0 if m_simpleTV.User.YT.PlstsCh.Refresh then index = 0 end num = m_simpleTV.User.YT.PlstsCh.Num for k, v in ipairs(tab) do if tonumber(num) == tonumber(v.Name:match('^(%d+)')) then index = k end end tab.ExtParams = {FilterType = 2, LuaOnCancelFunName = 'OnMultiAddressCancel_YT'} m_simpleTV.User.YT.PlstsCh.chTitle = chTitle local ret, id = m_simpleTV.OSD.ShowSelect_UTF8('📋 ' .. m_simpleTV.User.YT.ChTitle, index - 1, tab, 30000, 1 + 4 + 8 + 2 + 128) m_simpleTV.Control.CurrentTitle_UTF8 = chTitle if m_simpleTV.Control.MainMode == 0 then if not (inAdr:match('&isRestart=true') or inAdr:match('/youtubei/')) then m_simpleTV.Control.ChangeChannelLogo(m_simpleTV.User.paramScriptForSkin_logoYT or channel_avatar or channel_banner or m_simpleTV.User.YT.logoPicFromDisk , m_simpleTV.Control.ChannelID , 'CHANGE_IF_NOT_EQUAL') m_simpleTV.Control.ChangeChannelName(m_simpleTV.User.YT.ChTitle, m_simpleTV.Control.ChannelID, false) end end if not id then m_simpleTV.Control.ExecuteAction(37) m_simpleTV.Http.Close(session) return end if ret == 1 then m_simpleTV.User.YT.PlstsCh.Num = tab[id].Name:match('^(%d+)') or tab[1].Name m_simpleTV.User.YT.PlstsCh.Header = tab[id].Name:match('^%d+%. (.+)') or tab[1].Name m_simpleTV.User.YT.PlstsCh.Refresh = false PlstApi(tab[id].Address) return end if ret == 2 then PrevPlstsCh_YT() return end if ret == 3 then NextPlstsCh_YT() return end end local function Video() local t, title = GetStreamsTab(videoId) if not t then StopOnErr(12, title) return end if type(t) ~= 'table' then PlayAddressT_YT(t) return end m_simpleTV.User.YT.QltyTab = t local index = GetQltyIndex(t) local retAdr, noItag22 = StreamCheck(t, index) m_simpleTV.User.YT.QltyIndex = index if m_simpleTV.User.YT.isVideo == true then local name = title:gsub('%c.-$', '') if not (m_simpleTV.User.YT.isLive and m_simpleTV.Control.ChannelID ~= 268435455) then if m_simpleTV.Control.MainMode == 0 then m_simpleTV.Control.ChangeChannelLogo('https://i.ytimg.com/vi/' .. m_simpleTV.User.YT.vId .. '/hqdefault.jpg' , m_simpleTV.Control.ChannelID , 'CHANGE_IF_NOT_EQUAL') m_simpleTV.Control.ChangeChannelName(name, m_simpleTV.Control.ChannelID, false) end end m_simpleTV.Control.SetTitle(name) m_simpleTV.Control.CurrentTitle_UTF8 = name local header, name_header, ap_header, desc, panelDescName local publishedAt = '' if m_simpleTV.User.YT.author and m_simpleTV.User.YT.isTrailer == false then name_header = m_simpleTV.User.YT.Lng.upLoadOnCh .. ': ' .. m_simpleTV.User.YT.author elseif m_simpleTV.User.YT.isTrailer == true then name_header = m_simpleTV.User.YT.Lng.preview else name_header = '' end if m_simpleTV.User.YT.isLive == true then if isInfoPanel == false then ap_header = ' (' .. m_simpleTV.User.YT.Lng.live .. ')' else if m_simpleTV.User.YT.actualStartTime then local timeSt = timeStamp(m_simpleTV.User.YT.actualStartTime) timeSt = os.date('%y %d %m %H %M', tonumber(timeSt)) local year, day, month, hour, min = timeSt:match('(%d+) (%d+) (%d+) (%d+) (%d+)') publishedAt = ' | ' .. m_simpleTV.User.YT.Lng.started .. ': ' .. string.format('%d:%02d (%d/%d/%02d)', hour, min, day, month, year) end end else if isInfoPanel == false then if m_simpleTV.User.YT.duration and m_simpleTV.User.YT.duration > 2 then ap_header = ' (' .. secondsToClock(m_simpleTV.User.YT.duration) .. ')' end end end local t1 = {} t1[1] = {} t1[1].Id = 1 t1[1].Address = 'https://www.youtube.com/watch?v=' .. m_simpleTV.User.YT.vId t1[1].Name = name if isInfoPanel == false then header = name_header .. (ap_header or '') else if m_simpleTV.User.YT.isTrailer == true then ap_header = m_simpleTV.User.YT.Lng.preview elseif m_simpleTV.User.YT.isLive == true then ap_header = m_simpleTV.User.YT.Lng.live else ap_header = m_simpleTV.User.YT.Lng.video end if m_simpleTV.User.YT.isLive == false then if m_simpleTV.User.YT.duration and m_simpleTV.User.YT.duration > 2 then publishedAt = ' | ' .. secondsToClock(m_simpleTV.User.YT.duration) end end header = 'YouTube - ' .. ap_header t1[1].InfoPanelLogo = 'https://i.ytimg.com/vi/' .. m_simpleTV.User.YT.vId .. '/default.jpg' t1[1].InfoPanelName = name t1[1].InfoPanelShowTime = 8000 desc = m_simpleTV.User.YT.desc panelDescName = nil if desc and desc ~= '' then panelDescName = m_simpleTV.User.YT.Lng.desc .. ' | ' end t1[1].InfoPanelDesc = desc_html(desc, t1[1].InfoPanelLogo, name, t1[1].Address) t1[1].InfoPanelTitle = (panelDescName or '') .. m_simpleTV.User.YT.Lng.channel .. ': ' .. title_clean(m_simpleTV.User.YT.author) .. publishedAt end if m_simpleTV.User.YT.isLiveContent == false and m_simpleTV.User.YT.isTrailer == false then t1[2] = {} t1[2].Id = 2 t1[2].Name = '🔎 ' .. m_simpleTV.User.YT.Lng.search .. ': ' .. m_simpleTV.User.YT.Lng.relatedVideos t1[2].Address = '-related=' .. m_simpleTV.User.YT.vId .. '&isLogo=false' if m_simpleTV.User.YT.isMusic == true then t1[3] = {} t1[3].Id = 3 t1[3].Name = '🎵🔀 Music-Mix ' .. m_simpleTV.User.YT.Lng.plst t1[3].Address = 'https://www.youtube.com/embed?listType=playlist&list=RD' .. m_simpleTV.User.YT.vId .. '&isLogo=false' m_simpleTV.User.YT.PlstsCh.chTitle = nil end end t1.ExtParams = {FilterType = 2, LuaOnCancelFunName = 'OnMultiAddressCancel_YT'} if m_simpleTV.User.paramScriptForSkin_buttonOptions then t1.ExtButton0 = {ButtonEnable = true, ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonOptions, ButtonScript = 'Qlty_YT()'} else t1.ExtButton0 = {ButtonEnable = true, ButtonName = '⚙', ButtonScript = 'Qlty_YT()'} end local ButtonScript1 = [[ m_simpleTV.Control.ExecuteAction(37) m_simpleTV.Control.ChangeAddress = 'No' m_simpleTV.Control.CurrentAddress = 'https://www.youtube.com/channel/' .. m_simpleTV.User.YT.chId .. '&isRestart=true' dofile(m_simpleTV.MainScriptDir .. 'user/video/YT.lua') ]] if m_simpleTV.User.paramScriptForSkin_buttonPlst then t1.ExtButton1 = {ButtonEnable = true, ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonPlst, ButtonScript = ButtonScript1} else t1.ExtButton1 = {ButtonEnable = true, ButtonName = '📋', ButtonScript = ButtonScript1} end if m_simpleTV.User.paramScriptForSkin_buttonOk then t1.OkButton = {ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonOk} end m_simpleTV.OSD.ShowSelect_UTF8(header, 0, t1, 8000, 32 + 64 + 128) retAdr = positionToContinue(retAdr) else if urlAdr:match('PARAMS=psevdotv') then local t = m_simpleTV.Control.GetCurrentChannelInfo() if t and t.MultiHeader then title = t.MultiHeader .. ': ' .. title end local name = title:gsub('%c.-$', '') m_simpleTV.Control.SetTitle(name) retAdr = retAdr .. '$OPT:NO-SEEKABLE' else m_simpleTV.Control.CurrentTitle_UTF8 = '' end retAdr = retAdr .. '$OPT:POSITIONTOCONTINUE=0' end MarkWatch_YT() if isInfoPanel == false then title = title_is_no_infoPanel(title, t[index].Name) ShowMsg(title) end m_simpleTV.Http.Close(session) m_simpleTV.Control.CurrentAddress = retAdr if infoInFile then local scr_time = string.format('%.3f', (os.clock() - infoInFile)) local calc = scr_time - inf0 local adr = m_simpleTV.Common.fromPercentEncoding(retAdr) local string_rep = string.rep('–', 70) .. '\n' index = noItag22 or index local qlty = t[index].qlty if qlty and qlty < 100 then qlty = nil end infoInFile = string_rep .. 'url: https://www.youtube.com/watch?v=' .. m_simpleTV.User.YT.vId .. '\n' .. string_rep .. 'qlty: ' .. tostring(qlty) .. ' | video itag: ' .. tostring(t[index].itag) .. ' | audio itag: ' .. tostring(t[index].aItag) .. '\n' .. string_rep .. 'cipher: ' .. tostring(t[index].isCipher) .. ' | sts: ' .. tostring(m_simpleTV.User.YT.sts) .. '\n' .. string_rep .. 'time: ' .. scr_time .. ' s.' .. ' | request: ' .. inf0 .. ' s.' .. ' | calc: ' .. calc .. ' s.\n' .. string_rep .. 'title: ' .. title:gsub('%c', ' ') .. '\n' .. string_rep .. 'description:\n\n' .. m_simpleTV.User.YT.desc .. '\n' .. string_rep .. 'qlty table:\n\n' .. (inf01 or '') .. '\n' .. string_rep .. 'cookies:\n\n' .. m_simpleTV.User.YT.cookies:gsub('^[;]*(.-)[;]$', '%1'):gsub(';+', '\n') .. '\n' .. string_rep .. 'address:\n\n' .. adr:gsub('%$', '\n\n$'):gsub('slave=', 'slave=\n\n'):gsub('%#', '\n\n#\n\n') .. '\n' debug_in_file(infoInFile, m_simpleTV.Common.GetMainPath(2) .. 'YT_play_info.txt', true) end return end function AsynPlsCallb_Plst_YT(session, rc, answer, userstring, params) local ret = {} if rc ~= 200 then ret.Cancel = true return ret end if params.User.First == true then answer = answer:gsub('\\"', '%%22') params.User.headers = 'X-Origin: https://www.youtube.com\nContent-Type: application/json\nX-Youtube-Client-Name: 1\nX-YouTube-Client-Version: 2.20210302.07.01' .. '\nX-Goog-Visitor-Id: ' .. (answer:match('"visitorData":"([^"]+)') or '') .. header_Auth() params.User.First = false local title if params.User.typePlst == 'rss_videos' then title = (answer:match('<title>([^<]+)') or '') else title = answer:match('MetadataRenderer":{"title":"([^"]+)') or answer:match('"playlist":{"playlist":{"title":"([^"]+)') or answer:match('"hashtagHeaderRenderer":{"hashtag":{"simpleText":"([^"]+)') or answer:match('"subFeedOptionRenderer":{"name":{"runs":%[{"text":"([^"]+)') or answer:match('HeaderRenderer":{"title":{"simpleText":"([^"]+)') or answer:match('HeaderRenderer":{"title":{"runs":%[{"text":"([^"]+)') or answer:match('HeaderRenderer":{"title":"([^"]+)') or answer:match('"topicChannelDetailsRenderer":{"title":{"simpleText":"([^"]+)') or 'not found title' end title = title_clean(title) if m_simpleTV.User.YT.isAuth and inAdr:match('list=LM') then title = title .. ' 🎵' end if params.User.typePlst ~= 'true' and params.User.typePlst ~= 'panel_videos' then if params.User.typePlst:match('rss_') then title = '[RSS Feed] ' .. title end title = 'YouTube - ' .. title end if params.User.setTitle == true then m_simpleTV.Control.SetTitle(m_simpleTV.User.YT.PlstsCh.chTitle or title) end params.User.Title = title if params.ProgressEnabled == true then params.User.plstTotalResults = answer:match('"stats":%[{"runs":%[{"text":"(%d+)') end end if not AddInPl_Plst_YT(answer, params.User.tab, params.User.typePlst) then ret.Done = true return ret end local continuation = answer:match('"continuation":%s*"([^"]+)') or answer:match('"continuationCommand":%s*{%s*"token":%s*"([^"]+)') if not continuation then ret.Done = true return ret end ret.request = {} ret.request.url = 'https://www.youtube.com/youtubei/v1/browse?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8' ret.request.method = 'post' ret.request.body = '{"context":{"client":{"clientName":"WEB","clientVersion":"2.20210302.07.01","hl":"' .. m_simpleTV.User.YT.Lng.hl ..'",}},"continuation":"' .. continuation .. '"}' ret.request.headers = params.User.headers ret.Count = #params.User.tab if params.User.plstTotalResults then ret.Progress = ret.Count / tonumber(params.User.plstTotalResults) end return ret end function AsynPlsCallb_PlstApi_YT(session, rc, answer, userstring, params) local ret = {} if rc ~= 200 then params.User.rc = rc ret.Cancel = true return ret end if not AddInPl_PlstApi_YT(answer, params.User.tab) then ret.Done = true return ret end local nextPageToken = answer:match('"nextPageToken": "([^"]+)') if not nextPageToken then ret.Done = true return ret end ret.request = {} ret.request.url = string.format('https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&fields=nextPageToken,items(snippet/title,snippet/resourceId/videoId,snippet/description)&playlistId=%s&key=%s&pageToken=%s', params.User.plstId, m_simpleTV.User.YT.apiKey, nextPageToken) ret.request.headers = m_simpleTV.User.YT.apiKeyHeader ret.Count = #params.User.tab ret.Progress = ret.Count / params.User.plstTotalResults return ret end function PositionThumbs_YT(queryType, address, forTime) if queryType == 'testAddress' then return false end if queryType == 'getThumbs' then if not m_simpleTV.User.YT.ThumbsInfo then return true end local imgLen = m_simpleTV.User.YT.ThumbsInfo.samplingFrequency * m_simpleTV.User.YT.ThumbsInfo.thumbsPerImage local index = math.floor(forTime / imgLen) local t = {} t.playAddress = address local NPattern = m_simpleTV.User.YT.ThumbsInfo.NPattern:gsub('$M', index) t.url = m_simpleTV.User.YT.ThumbsInfo.urlPattern:gsub('$N', NPattern) t.httpParams = {} t.httpParams.userAgent = userAgent t.httpParams.extHeader = 'Referer: https://www.youtube.com/' t.elementWidth = m_simpleTV.User.YT.ThumbsInfo.thumbWidth t.elementHeight = m_simpleTV.User.YT.ThumbsInfo.thumbHeight t.startTime = index * imgLen t.length = imgLen t.marginLeft = 0 t.marginRight = 3 t.marginTop = 0 t.marginBottom = 0 m_simpleTV.PositionThumbs.AppendThumb(t) return true end end function PlayAddressT_YT(address, resent) address = m_simpleTV.Common.fromPercentEncoding(address) address = stringFromHex(address) address = urls_encode(address) m_simpleTV.Control.PlayAddressT({address = address, insertInRecent = resent}) end function SavePlst_YT() if m_simpleTV.User.YT.Plst and m_simpleTV.User.YT.plstHeader then local t = m_simpleTV.User.YT.Plst local header = m_simpleTV.User.YT.plstHeader local adr, name, logo local m3ustr = '#EXTM3U $ExtFilter="YouTube" $BorpasFileFormat="1"\n' for i = 1, #t do name = t[i].Name logo = t[i].Address:match('v=([^&]*)') or '' adr = t[i].Address:gsub('&is%a+=%a+', '') m3ustr = m3ustr .. '#EXTINF:-1' .. ' group-title="' .. header .. '"' .. ' tvg-logo="https://i.ytimg.com/vi/' .. logo .. '/hqdefault.jpg"' .. ',' .. name .. '\n' .. adr .. '\n' end if m_simpleTV.User.YT.PlstsCh.chTitle then header = header .. ' [' .. m_simpleTV.User.YT.Lng.channel .. ' - ' .. m_simpleTV.User.YT.PlstsCh.chTitle .. '] ' end header = m_simpleTV.Common.UTF8ToMultiByte(header) header = header:gsub('%c', '') header = header:gsub('[\/"*:<>|?]+', ' ') header = header:gsub('%s+', ' ') header = header:gsub('^%s*(.-)%s*$', '%1') local fileEnd = ' (youtube ' .. os.date('%d.%m.%y') .. ').m3u8' local folder = m_simpleTV.Common.GetMainPath(1) .. m_simpleTV.Common.UTF8ToMultiByte(m_simpleTV.User.YT.Lng.savePlstFolder) .. '/' lfs.mkdir(folder) local folderYT = folder .. 'YouTube/' lfs.mkdir(folderYT) local filePath = folderYT .. header .. fileEnd local fhandle = io.open(filePath, 'w+') if fhandle then fhandle:write(m3ustr) fhandle:close() ShowInfo( m_simpleTV.User.YT.Lng.savePlst_1 .. '\n' .. m_simpleTV.Common.multiByteToUTF8(header .. fileEnd) .. '\n' .. m_simpleTV.User.YT.Lng.savePlst_2 .. '\n' .. m_simpleTV.Common.multiByteToUTF8(folderYT) ) else ShowInfo(m_simpleTV.User.YT.Lng.savePlst_3) end end end function Qlty_YT() local t = m_simpleTV.User.YT.QltyTab if not t or #t < 2 then m_simpleTV.Control.ExecuteAction(37) return end if m_simpleTV.User.paramScriptForSkin_buttonInfo then t.ExtButton1 = {ButtonEnable = true, ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonInfo, ButtonScript = 'Qlty_YT()'} else t.ExtButton1 = {ButtonEnable = true, ButtonName = 'ℹ️'} end t.ExtParams = {FilterType = 2} if m_simpleTV.User.paramScriptForSkin_buttonOk then t.OkButton = {ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonOk} end if not m_simpleTV.User.YT.isVideo then if m_simpleTV.User.paramScriptForSkin_buttonSave then t.ExtButton0 = {ButtonEnable = true, ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonSave} else t.ExtButton0 = {ButtonEnable = true, ButtonName = '💾'} end else if m_simpleTV.User.paramScriptForSkin_buttonSearch then t.ExtButton0 = {ButtonEnable = true, ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonSearch} else t.ExtButton0 = {ButtonEnable = true, ButtonName = '🔎'} end end m_simpleTV.Control.ExecuteAction(37) local ret, id = m_simpleTV.OSD.ShowSelect_UTF8('⚙ ' .. m_simpleTV.User.YT.Lng.qlty , m_simpleTV.User.YT.QltyIndex - 1, t, 5000, 1 + 4 + 2) if m_simpleTV.Control.GetState() == 0 and ret == 0 then m_simpleTV.Control.ExecuteAction(108) end if ret == 1 then if t[id].qltyLive then m_simpleTV.Config.SetValue('YT_qlty_live', t[id].qltyLive) m_simpleTV.User.YT.qlty_live = t[id].qltyLive else if t[id].qlty > 300 then m_simpleTV.Config.SetValue('YT_qlty', t[id].qlty) m_simpleTV.User.YT.qlty0 = t[id].qlty end if t[id].qlty < 100 then local visual = tostring(m_simpleTV.Config.GetValue('vlc/audio/visual/module', 'simpleTVConfig') or '') if visual == 'none' or visual == '' then SetBackground(m_simpleTV.User.YT.pic or m_simpleTV.User.YT.logoPicFromDisk) else SetBackground() end end m_simpleTV.User.YT.qlty = t[id].qlty end if (t[id].qlty and t[id].qlty > 100) or t[id].qltyLive then SetBackground() end m_simpleTV.User.YT.QltyIndex = id if isInfoPanel == false then ShowMsg(t[id].Name, nil, true) end local retAdr = t[id].Address:gsub('$OPT:start%-time=%d+', '') retAdr = StreamCheck(t, id) m_simpleTV.Control.SetNewAddressT({address = retAdr, position = m_simpleTV.Control.GetPosition()}) if m_simpleTV.Control.GetState() == 0 then m_simpleTV.Control.Restart(false) end end if ret == 2 and not m_simpleTV.User.YT.isVideo then SavePlst_YT() elseif ret == 2 and m_simpleTV.User.YT.isVideo and id then m_simpleTV.Control.ExecuteAction(105) end if ret == 3 then ShowInfo() end end function PlstsCh_YT() if m_simpleTV.Control.Reason == 'Stopped' or m_simpleTV.Control.Reason == 'EndReached' then m_simpleTV.Control.ExecuteAction(63) return end local tab = m_simpleTV.User.YT.PlstsChTab if not tab then return end local num = m_simpleTV.User.YT.PlstsCh.Num local index = 0 for k, v in ipairs(tab) do if tonumber(num) == tonumber(v.Name:match('^(%d+)')) then index = k end end tab.ExtParams = {FilterType = 2} if m_simpleTV.User.paramScriptForSkin_buttonOk then tab.OkButton = {ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonOk} end local ret, id = m_simpleTV.OSD.ShowSelect_UTF8('📋 ' .. m_simpleTV.User.YT.ChTitle, index - 1, tab, 30000, 1 + 4 + 2 + 128) if not id then m_simpleTV.Control.ExecuteAction(37) if m_simpleTV.Control.GetState() == 0 then m_simpleTV.Control.RestoreBackground() end end if ret == 1 then m_simpleTV.User.YT.PlstsCh.Refresh = true m_simpleTV.User.YT.PlstsCh.Num = tab[id].Name:match('^(%d+)') or tab[1].Name m_simpleTV.User.YT.PlstsCh.Header = tab[id].Name:match('^%d+%. (.+)') or tab[1].Name m_simpleTV.Control.SetNewAddressT({address = tab[id].Address}) return end if ret == 2 then PrevPlstsCh_YT() return end if ret == 3 then NextPlstsCh_YT() return end end function NextPlstsCh_YT() m_simpleTV.User.YT.PlstsCh.Refresh = true local tab = table_reversa(m_simpleTV.User.YT.PlstsCh.Urls) if #tab == 0 then tab[1] = m_simpleTV.User.YT.PlstsCh.FirstUrl end m_simpleTV.Control.ChangeAddress = 'No' m_simpleTV.Control.CurrentAddress = tab[1] .. '&isRestart=true' dofile(m_simpleTV.MainScriptDir .. 'user/video/YT.lua') end function PrevPlstsCh_YT() m_simpleTV.User.YT.PlstsCh.Refresh = false local tab = m_simpleTV.User.YT.PlstsCh.Urls if #tab > 1 then tab[#tab] = nil tab[#tab] = nil end if #tab == 0 then m_simpleTV.Control.CurrentAddress = m_simpleTV.User.YT.PlstsCh.MainUrl else m_simpleTV.Control.CurrentAddress = tab[#tab] end m_simpleTV.User.YT.PlstsCh.Urls = tab m_simpleTV.Control.ChangeAddress = 'No' dofile(m_simpleTV.MainScriptDir .. 'user/video/YT.lua') end function MarkWatched_YT(sessionMarkWatch) m_simpleTV.Http.Close(sessionMarkWatch) end function OnMultiAddressOk_YT(Object, id) if id == 0 then OnMultiAddressCancel_YT(Object) else m_simpleTV.User.YT.DelayedAddress = nil end end function OnMultiAddressCancel_YT(Object) if m_simpleTV.User.YT.DelayedAddress then if m_simpleTV.Control.GetState() == 0 then m_simpleTV.Control.SetNewAddressT({address = m_simpleTV.User.YT.DelayedAddress}) if m_simpleTV.User.YT.qlty < 100 then local visual = tostring(m_simpleTV.Config.GetValue('vlc/audio/visual/module', 'simpleTVConfig') or '') if visual == 'none' or visual == '' then SetBackground(m_simpleTV.User.YT.pic or m_simpleTV.User.YT.logoPicFromDisk) else SetBackground() end end end m_simpleTV.User.YT.DelayedAddress = nil end m_simpleTV.Control.ExecuteAction(36, 0) end if not m_simpleTV.User.YT.isAuth and (inAdr:match('list=WL') or inAdr:match('list=LL') or inAdr:match('list=LM') or (inAdr:match('/feed/') and not inAdr:match('/feed/storefront') and not inAdr:match('/feed/trending'))) then local err = '⚠️ ' .. m_simpleTV.User.YT.Lng.noCookies StopOnErr(100, err) return end if inAdr:match('isPlstsCh=true') then m_simpleTV.User.YT.isPlstsCh = true end if inAdr:match('music%.youtube%.com/browse/') then local rc, answer = m_simpleTV.Http.Request(session, {url = inAdr}) m_simpleTV.Http.Close(session) if rc ~= 200 then StopOnErr(0.4) return end local plst = answer:match('radioPlaylistMixPlaylistId\\x22:\\x22RDAMPL(.-)\\') if not plst then StopOnErr(0.5) return end plst = 'https://www.youtube.com/playlist?list=' .. plst .. '&isLogo=true' m_simpleTV.Control.ChangeAddress = 'No' m_simpleTV.Control.CurrentAddress = plst dofile(m_simpleTV.MainScriptDir .. 'user/video/YT.lua') return end if inAdr:match('/watch_videos') then inAdr = GetUrlWatchVideos(inAdr) if not inAdr then StopOnErr(0.8) return end m_simpleTV.Http.Close(session) PlayAddressT_YT(inAdr) return end if inAdr:match('^%-') then if m_simpleTV.Control.MainMode == 0 then if not inAdr:match('^%-related=') then m_simpleTV.Control.ChangeChannelLogo('https://s.ytimg.com/yts/img/reporthistory/land-img-vfl_eF5BA.png', m_simpleTV.Control.ChannelID) else m_simpleTV.Control.ExecuteAction(37) end end local t, types, header = Search(inAdr) m_simpleTV.Http.Close(session) if not t or #t == 0 then StopOnErr(5.1, m_simpleTV.User.YT.Lng.notFound) return end local title if types == 'related' then title = m_simpleTV.User.YT.title title = title_clean(title) else title = inAdr:gsub('^[%-%+%s]+(.-)%s*$', '%1') end title = m_simpleTV.User.YT.Lng.search .. ' YouTube (' .. header .. '): ' .. title m_simpleTV.Control.SetTitle(title) local FilterType, AutoNumberFormat if #t > 5 then FilterType = 1 AutoNumberFormat = '%1. %2' else FilterType = 2 AutoNumberFormat = '' end t.ExtParams = {FilterType = FilterType, AutoNumberFormat = AutoNumberFormat} if m_simpleTV.User.paramScriptForSkin_buttonClose then t.ExtButton1 = {ButtonEnable = true, ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonClose} else t.ExtButton1 = {ButtonEnable = true, ButtonName = '✕'} end if m_simpleTV.User.paramScriptForSkin_buttonOk then t.OkButton = {ButtonImageCx = 30, ButtonImageCy = 30, ButtonImage = m_simpleTV.User.paramScriptForSkin_buttonOk} end local ret, id = m_simpleTV.OSD.ShowSelect_UTF8('🔎 ' .. title, 0, t, 30000, 1 + 4 + 8 + 2) m_simpleTV.Control.ExecuteAction(37) if not id or ret == 3 then m_simpleTV.Control.ExecuteAction(11) return end t = t[id].Address .. '&isSearch=true&isLogo=false' PlayAddressT_YT(t) return end if inAdr:match('isPlst=') then m_simpleTV.User.YT.isVideo = false end if inAdr:match('/user/[^/]+/videos') or inAdr:match('/channel/[^/]+/videos') or inAdr:match('/c/[^/]+/videos') or inAdr:match('index=') or inAdr:match('/feed/') or inAdr:match('/hashtag/') or inAdr:match('youtube%.com$') or ((inAdr:match('list=RD') or inAdr:match('list=TL')) and not inAdr:match('/embed')) or inAdr:match('list=WL') or inAdr:match('list=OL') or inAdr:match('list=LM') or inAdr:match('list=LL') or inAdr:match('youtube%.com/[^/]+/videos') then Plst(inAdr) elseif inAdr:match('/user/') or inAdr:match('/channel/') or inAdr:match('/c/') or inAdr:match('/youtubei/') or inAdr:match('youtube%.com/%w+$') or inAdr:match('youtube%.com/[^/]+/playlists') or inAdr:match('/live$') or inAdr:match('/embed/live_stream') then PlstsCh(inAdr) elseif inAdr:match('list=') then PlstApi(inAdr) else Video() end
-- General settings -- Set options vim.o.clipboard = "unnamedplus" vim.o.encoding = "UTF-8" vim.o.signcolumn = "no" -- vim.o.signcolumn = "number" -- vim.o.number = true -- vim.o.relativenumber = true vim.o.numberwidth = 2 vim.o.shiftwidth = 4 vim.o.tabstop = 4 vim.o.autoindent = true vim.o.smartindent = true vim.o.cindent = true vim.o.expandtab = true vim.o.mouse = "a" vim.o.incsearch = true -- vim.o.cursorline = true vim.o.hidden = true -- vim.o.textwidth = 92 vim.o.updatetime = 300 vim.o.timeoutlen = 500 vim.o.foldenable = false vim.g.python3_host_prog = "/usr/bin/python" vim.o.splitright = true vim.o.splitbelow = true -- vim.o.winblend = 10 vim.o.autoread = true vim.o.showbreak = "↪ " vim.o.breakindent = true vim.o.linebreak = true vim.o.wrap = true -- vim.o.laststatus = 3 -- vim.cmd("set laststatus=3") vim.g.loaded_perl_provider = false -- Highlight on yank vim.cmd([[ augroup YankHighlight autocmd! autocmd TextYankPost * silent! lua vim.highlight.on_yank() augroup end ]]) -- Gitsigns require("gitsigns").setup({ -- signs = { -- add = { text = "+" }, -- change = { text = "~" }, -- delete = { text = "_" }, -- topdelete = { text = "‾" }, -- changedelete = { text = "~" }, -- }, }) -- Slime vim.g.slime_target = "tmux" -- vim.g.slime_target = "vimterminal" -- vim.g.slime_target = "x11" local function reloadconfig() for name, _ in pairs(package.loaded) do if name:match("^config") then package.loaded[name] = nil end end package.loaded["colorloaders/colors"] = nil dofile(vim.env.MYVIMRC) end WhichKey.register({ r = { reloadconfig, "Reload Neovim config" }, e = { ":edit $MYVIMRC<CR>", "Edit Neovim config" }, }, { prefix = "<leader>q", noremap = true })
aura_env.active = 0 aura_env.spellSchool = {} aura_env.currentAbsorb = {} aura_env.maxAbsorb = {} aura_env.totalAbsorb = 0 aura_env.schoolAbsorb = {0, 0, 0, 0, 0, 0, 0, 0, 0} local function improvedPowerWordShieldMultiplier() -- FIXME: GetTalentInfo(1, 5) return 1.15 end aura_env.talentMultiplier = { [ 17] = improvedPowerWordShieldMultiplier, [ 592] = improvedPowerWordShieldMultiplier, [ 600] = improvedPowerWordShieldMultiplier, [ 3747] = improvedPowerWordShieldMultiplier, [ 6065] = improvedPowerWordShieldMultiplier, [ 6066] = improvedPowerWordShieldMultiplier, [10898] = improvedPowerWordShieldMultiplier, [10899] = improvedPowerWordShieldMultiplier, [10900] = improvedPowerWordShieldMultiplier, [10901] = improvedPowerWordShieldMultiplier, } function aura_env:CalculateAbsorbValue(spellName, spellId, absorbInfo) -- FIXME: if caster != player local value = 0 local keys = self.absorbDbKeys local bonusHealing = GetSpellBonusHealing() local level = UnitLevel("player") local base = absorbInfo[keys.basePoints] local perLevel = absorbInfo[keys.pointsPerLevel] local baseLevel = absorbInfo[keys.baseLevel] local maxLevel = absorbInfo[keys.maxLevel] local spellLevel = absorbInfo[keys.spellLevel] local bonusMult = absorbInfo[keys.healingMultiplier] local baseMultFn = self.talentMultiplier[spellId] local levelPenalty = min(1, 1 - (20 - spellLevel) * .0375) local levels = max(0, min(level, maxLevel) - baseLevel) local baseMult = baseMultFn and baseMultFn() or 1 value = ( baseMult * (base + levels * perLevel) + bonusHealing * bonusMult * levelPenalty ) self:log('CalculateAbsorbValue', spellName, value, base, perLevel, levels, baseMult, bonusHealing, bonusMult, levelPenalty) return value end function aura_env:GetBuffId(spellName) local auraName, spellId for i = 1, 255 do auraName, _, _, _, _, _, _, _, _, spellId = UnitBuff("player", i) if auraName == spellName then break elseif not auraName then spellId = nil break end end return spellId end function aura_env:ApplyAura(spellName) local school = self.spellSchool[spellName] self:log('ApplyAura', spellName, school) if 0 ~= school then local spellId = self:GetBuffId(spellName) local absorbInfo = self.absorbDb[spellId] self:log('ApplyAuraAbsorbOrNew', spellId) if absorbInfo then local value = self:CalculateAbsorbValue( spellName, spellId, absorbInfo) self:log('ApplyAuraSchool', school) if nil == school then school = absorbInfo[self.absorbDbKeys.school] self.spellSchool[spellName] = school end if self.maxAbsorb[spellName] then self:log('ApplyAuraUpdateCurrent', spellName, value) self.currentAbsorb[spellName] = value else self:log('ApplyAuraSetCurrent', spellName, value) self.active = self.active + 1 -- If damage event happened before aura was removed local prevValue = self.currentAbsorb[spellName] self.currentAbsorb[spellName] = value + (prevValue or 0) end self:log('ApplyAuraSetMax', spellName, value) self.maxAbsorb[spellName] = value self:UpdateValues() end end end function aura_env:RemoveAura(spellName) self:log('RemoveAura', spellName) if self.currentAbsorb[spellName] then self.currentAbsorb[spellName] = nil self.active = self.active - 1 self:log('RemoveAuraRemaining', self.active) if self.active < 1 then self.active = 0 wipe(self.maxAbsorb) end self:UpdateValues() end end function aura_env:ApplyDamage(spellName, value) self:log('ApplyDamage', spellName, value) local newValue = (self.currentAbsorb[spellName] or 0) - value if self.maxAbsorb[spellName] then self.currentAbsorb[spellName] = max(0, newValue) self:UpdateValues() else self.currentAbsorb[spellName] = newValue end end function aura_env:ResetValues() self:log('ResetValues') local spellName wipe(self.currentAbsorb) wipe(self.maxAbsorb) self.active = 0 for i = 1, 255 do spellName = UnitBuff("player", i) if not spellName then break end self:ApplyAura(spellName) end self:UpdateValues() end function aura_env:UpdateValues() self:log('UpdateValues') local values = self.schoolAbsorb local keys = self.schoolIdx local spellSchool = self.spellSchool local current = self.currentAbsorb local total = 0 local key, value, school for i = 1, #values do values[i] = 0 end for spell, maxValue in pairs(self.maxAbsorb) do school = spellSchool[spell] key = keys[school] total = total + maxValue value = (current[spell] or 0) values[key] = values[key] + value self:log('UpdateValues', spell, school, key, maxValue, value) end self.totalAbsorb = total WeakAuras.ScanEvents("WA_NAN_SHIELD", total, unpack(values)) self:log('UpdateValues', total > 0) end
local options = { term = { position = "belowright", size = 8, }, filetype_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/code_runner.nvim/lua/code_runner/code_runner.json", filetype = {}, project_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/code_runner.nvim/lua/code_runner/project_manager.json", project = {}, } local M = {} -- set user config M.set = function(user_options) options = vim.tbl_deep_extend("force", options, user_options) end M.get = function() return options end return M
local ATTEMPTS_MAX = 40 local ignored_skills = Ext.Require("Server/BonusSkills/IgnoredSkills.lua") local ignored_skillwords = Ext.Require("Server/BonusSkills/IgnoredSkillWords.lua") local ignored_parents = { Target_SourceVampirism = true } local redirected_skills = { Rain_Oil = "Rain_LLENEMY_EnemyOil" } -- Has a mod already added to IgnoredSkills? if IgnoredSkills ~= nil then for skill,b in pairs(IgnoredSkills) do ignored_skills[skill] = b end end IgnoredSkills = ignored_skills if IgnoredWords ~= nil then for i,word in pairs(IgnoredWords) do table.insert(ignored_skillwords, word) end end IgnoredWords = ignored_skillwords ---@type SkillEntry local SkillEntry = Classes.SkillEntry ---@type SkillGroup local SkillGroup = Classes.SkillGroup ---@param ability string ---@return SkillGroup local function GetSkillGroup(self, ability) for _,v in pairs(self) do if v.ability == ability then return v end end return nil end local function IsSummmonSkill(skill) if Ext.StatGetAttribute(skill, "SkillType") == "Summon" then return true else ---@type StatProperty[] local props = Ext.StatGetAttribute(skill, "SkillProperties") if props ~= nil and #props > 0 then for i,v in pairs(props) do if v.Type == "Summon" then return true end end end end end function IgnoreSkill(skill) if IgnoredSkills[skill] == false then return false end if IgnoredSkills[skill] == true then return true end if string.sub(skill,1,1) == "_" then return true end if IsSummmonSkill(skill) then return true end local parent = Ext.StatGetAttribute(skill, "Using") if parent ~= nil and ignored_parents[parent] == true then return true end for _,word in pairs(ignored_skillwords) do if string.find(skill, word) then return true end end return false end local function IgnoreSkill_QRY(skill) if IgnoreSkill(skill) then return 1 end return 0 end Ext.NewQuery(IgnoreSkill_QRY, "LLENEMY_Ext_QRY_IgnoreSkill", "[in](STRING)_Skill, [out](INTEGER)_Ignored") local function TotalSkills_QRY(uuid) local char = Ext.GetCharacter(uuid) if char ~= nil then return #char:GetSkills() end end Ext.NewQuery(TotalSkills_QRY, "LLENEMY_Ext_QRY_GetTotalSkills", "[in](CHARACTERGUID)_Character, [out](INTEGER)_TotalSkills") local AIFLAG_CANNOT_USE = 140689826905584 local function LLENEMY_ParentSkillIsInvalid(skill) local parent = Ext.StatGetAttribute(skill, "Using") if parent ~= nil then if Ext.StatGetAttribute(parent, "SkillType") == nil then Ext.Print("[LLENEMY_BonusSkills.lua] [*ERROR*] Parent skill for '" .. tostring(skill) .. "' does not exist! Skipping!") return true end end return false end ---@param requirementsTable StatRequirement[] ---@return boolean local function HasTagRequirement(requirementsTable) for i,v in pairs(requirementsTable) do if v.Requirement == "Tag" then return true end end return false end function BuildEnemySkills() EnemySkills = { SkillGroup:Create("None", "None"), SkillGroup:Create("WarriorLore", "Warrior"), SkillGroup:Create("RangerLore", "Ranger"), SkillGroup:Create("RogueLore", "Rogue"), SkillGroup:Create("AirSpecialist", "Air"), SkillGroup:Create("EarthSpecialist", "Earth"), SkillGroup:Create("FireSpecialist", "Fire"), SkillGroup:Create("WaterSpecialist", "Water"), SkillGroup:Create("Necromancy", "Death"), SkillGroup:Create("Polymorph", "Polymorph"), SkillGroup:Create("Summoning", "Summoning"), SkillGroup:Create("Sourcery", "Source"), } local skills = Ext.GetStatEntries("SkillData") for k,skill in pairs(skills) do if redirected_skills[skill] ~= nil then local swapped_skill = redirected_skills[skill] LeaderLib.PrintDebug("[LLENEMY_BonusSkills.lua] Swapping skill '" .. tostring(skill) .. "' for '"..swapped_skill .. "'") skill = swapped_skill end local isenemy = Ext.StatGetAttribute(skill, "IsEnemySkill") local aiflags = Ext.StatGetAttribute(skill, "AIFlags") local ap = Ext.StatGetAttribute(skill, "ActionPoints") local cd = Ext.StatGetAttribute(skill, "Cooldown") if not IgnoreSkill(skill) then if aiflags ~= AIFLAG_CANNOT_USE and (isenemy == "Yes" and string.find(skill, "Enemy")) then if ap > 0 or cd > 0 then local b,invalidSkill = pcall(LLENEMY_ParentSkillIsInvalid, skill) if not b then invalidSkill = true end if not invalidSkill then local ability = Ext.StatGetAttribute(skill, "Ability") local requirement = Ext.StatGetAttribute(skill, "Requirement") local sp = Ext.StatGetAttribute(skill, "Magic Cost") if sp == nil then sp = 0 end local tier = Ext.StatGetAttribute(skill, "Tier") if IsSummmonSkill(skill) then EnemySummonSkills[skill] = SkillEntry:Create(skill, requirement, sp, tier) else local skillgroup = GetSkillGroup(EnemySkills, ability) if skillgroup ~= nil then skillgroup:Add(SkillEntry:Create(skill, requirement, sp, tier)) end end else LeaderLib.PrintDebug("[LLENEMY_BonusSkills.lua] Skill '" .. tostring(skill) .. "' is invalid? pcall (".. tostring(b) ..") invalidSkill(".. tostring(invalidSkill)..")") end end else if Ext.StatGetAttribute(skill, "ForGameMaster") == "Yes" and isenemy ~= "Yes" and Ext.StatGetAttribute(skill, "Memory Cost") > 0 then local tier = Ext.StatGetAttribute(skill, "Tier") if LeaderLib.Data.OriginalSkillTiers ~= nil and LeaderLib.Data.OriginalSkillTiers[skill] ~= nil then tier = LeaderLib.Data.OriginalSkillTiers[skill] end if tier ~= nil and tier ~= "" and tier ~= "None" then ---@type StatRequirement[] local requirements = Ext.StatGetAttribute(skill, "Requirements") ---@type StatRequirement[] local memorizationRequirements = Ext.StatGetAttribute(skill, "MemorizationRequirements") -- Skills with tag requirements tend to be special and shouldn't be randomly added if not HasTagRequirement(requirements) and not HasTagRequirement(memorizationRequirements) then local ability = Ext.StatGetAttribute(skill, "Ability") if ability ~= "" and ability ~= "None" then -- Poison skills being under the Earth Ability if ability == "Earth" then if string.find(skill, "Poison") or Ext.StatGetAttribute(skill, "DamageType") == "Poison" then ability = "Poison" end end if ItemCorruption.Boosts.BonusSkills[ability] == nil then ItemCorruption.Boosts.BonusSkills[ability] = {} end table.insert(ItemCorruption.Boosts.BonusSkills[ability], skill) end end end end end end end end local function GetHighestAbility(enemy) local last_highest_ability = "None" local last_highest_val = 0 for _,skillgroup in pairs(EnemySkills) do if skillgroup.id ~= "None" then local ability_val = CharacterGetAbility(enemy, tostring(skillgroup.id)) ---LeaderLib.PrintDebug("[LLENEMY_BonusSkills.lua:GetHighestAbility] ---- Ability (" .. tostring(skillgroup.id) .. ") = ("..tostring(ability_val)..")") if ability_val ~= nil and ability_val > 0 and ability_val > last_highest_val then last_highest_ability = skillgroup.id last_highest_val = ability_val end end end return last_highest_ability end local weapontype_requirements = { Sword = "MeleeWeapon", Club = "MeleeWeapon", Axe = "MeleeWeapon", Knife = {"DaggerWeapon", "MeleeWeapon"}, Spear = "MeleeWeapon", Staff = {"StaffWeapon", "MeleeWeapon"}, Bow = "RangedWeapon", Crossbow = "RangedWeapon", Rifle = {"RifleWeapon", "RangedWeapon"}, --Wand = {"MeleeWeapon"}, } ---@class WeaponRequirementFlag local WeaponRequirementFlag = { flag = "", requirements = "None", } WeaponRequirementFlag.__index = WeaponRequirementFlag function WeaponRequirementFlag:Create(flag, requirements) local this = { flag = flag, requirements = requirements } setmetatable(this, self) return this end local weapontype_requirements_flags = {} weapontype_requirements_flags[#weapontype_requirements_flags+1] = WeaponRequirementFlag:Create("LeaderLib_SkillRequirement_DaggerWeapon", {"DaggerWeapon", "MeleeWeapon"}) weapontype_requirements_flags[#weapontype_requirements_flags+1] = WeaponRequirementFlag:Create("LeaderLib_SkillRequirement_StaffWeapon", {"StaffWeapon", "MeleeWeapon"}) weapontype_requirements_flags[#weapontype_requirements_flags+1] = WeaponRequirementFlag:Create("LeaderLib_SkillRequirement_MeleeWeapon", "MeleeWeapon") weapontype_requirements_flags[#weapontype_requirements_flags+1] = WeaponRequirementFlag:Create("LeaderLib_SkillRequirement_RangedWeapon", "RangedWeapon") --weapontype_requirements_flags[#weapontype_requirements_flags+1] = WeaponRequirementFlag:Create("LeaderLib_SkillRequirement_WandWeapon", "WandWeapon") local function GetWeaponRequirement(enemy) for i,v in pairs(weapontype_requirements_flags) do if ObjectGetFlag(enemy, v.flag) == 1 then return v.requirements end end --[[ local weapon = CharacterGetEquippedWeapon(enemy) if weapon ~= nil then local stat = NRD_ItemGetStatsId(weapon) local weapontype = NRD_StatGetString(stat, "WeaponType") local req_entry = weapontype_requirements[weapontype] if req_entry ~= nil then return req_entry end end ]] return "None" end local function GetPreferredSkillGroup(ability,requirement,lastgroup) --LeaderLib.PrintDebug("EnemySkills count: " .. tostring(#EnemySkills) .. " | Looking for " .. ability) if ability ~= "None" and (lastgroup == nil or lastgroup ~= nil and lastgroup.id ~= ability) then for k,v in pairs(EnemySkills) do if v.id == ability or v.ability == ability then return v end end else local attempts = 0 while attempts < 20 do local rantable = LeaderLib.Common.GetRandomTableEntry(EnemySkills) if rantable ~= nil then local ranskill = LeaderLib.Common.GetRandomTableEntry(rantable.skills) if ranskill ~= nil then if ranskill.requirement == "None" then return rantable end if type(requirement) == "string" and ranskill.requirement == requirement then --LeaderLib.PrintDebug("[LLENEMY_BonusSkills.lua:GetPreferredSkillGroup] ---- Matched skill (" .. tostring(ranskill.id) .. ") to requirement ("..requirement..") for group ("..rantable.id..")") return rantable elseif type(requirement) == "table" then for k,v in pairs(requirement) do if v == ranskill.requirement then --LeaderLib.PrintDebug("[LLENEMY_BonusSkills.lua:GetPreferredSkillGroup] ---- Matched skill (" .. tostring(ranskill.id) .. ") to requirement ("..v..") for group ("..rantable.id..")") return rantable end end end else print("Failed to get random skill:") print(Ext.JsonStringify(rantable)) end end attempts = attempts + 1 end end return nil end local function SkillIsBlockedByUser(skill) local userList = Settings.Global.Variables.EnemySkillIgnoreList if userList ~= nil and #userList > 0 then for i,v in pairs(userList) do if v == skill or string.find(skill, v) then return true end end end return false end function AddBonusSkills(enemy,remainingstr,source_skills_remainingstr) local remaining = math.max(tonumber(remainingstr), 1) local source_skills_remaining = math.max(tonumber(source_skills_remainingstr), 0) local preferred_ability = GetHighestAbility(enemy) local preferred_requirement = GetWeaponRequirement(enemy) --local sp_max = CharacterGetMaxSourcePoints(enemy) local level = CharacterGetLevel(enemy) LeaderLib.PrintDebug("[LLENEMY_BonusSkills.lua] Enemy '" .. tostring(enemy) .. "' preferred Ability (".. tostring(preferred_ability) ..") Requirement (".. tostring(LeaderLib.Common.Dump(preferred_requirement)) ..") Bonus Skills ("..tostring(remaining)..") Source Skills ("..tostring(source_skills_remaining)..").") local skillgroup = GetPreferredSkillGroup(preferred_ability, preferred_requirement, nil) if skillgroup == nil then LeaderLib.PrintDebug("[LLENEMY_BonusSkills.lua] -- Can't get a skillgroup for Enemy '" .. tostring(enemy) .. "'. Skipping.") return false end local attempts = 0 while remaining > 0 and attempts < ATTEMPTS_MAX do local success = false local skill = skillgroup:GetRandomSkill(enemy, preferred_requirement, level, source_skills_remaining) if skill ~= nil and not SkillIsBlockedByUser(skill) then if skill.sp > 0 then source_skills_remaining = source_skills_remaining - 1 end LeaderLib.PrintDebug("[LLENEMY_BonusSkills.lua] -- Adding skill (".. tostring(skill.id) ..") to enemy '" .. tostring(enemy) .. "'.") CharacterAddSkill(enemy, skill.id, 0) success = true end if success == true then remaining = remaining - 1 --- Get another random skillgroup when no preference is set if remaining > 0 and preferred_ability == "None" then local nextskillgroup = GetPreferredSkillGroup(preferred_ability, preferred_requirement, skillgroup) if nextskillgroup ~= nil then skillgroup = nextskillgroup end end end attempts = attempts + 1 end if attempts >= ATTEMPTS_MAX then LeaderLib.PrintDebug("[LLENEMY_BonusSkills.lua] Enemy '" .. tostring(enemy) .. "' hit the maximum amount of random attempts when getting a skill from group ("..skillgroup.id..").") end end function AddSummonSkill(enemy, amountStr) local skills = {} for skill,v in pairs(EnemySummonSkills) do table.insert(skills, skill) end skills = Common.ShuffleTable(skills) local addSkill = Common.GetRandomTableEntry(skills) if not StringHelpers.IsNullOrEmpty(addSkill) then CharacterAddSkill(enemy, addSkill, 0) end end
local odimension, ointerior, ox, oy, oz, orot, oskin local localPlayer = getLocalPlayer() local team = 0 local factionrank local skins local skincount local curr function changeDutySkin() local factionid = getElementData(localPlayer, "faction") factionrank = getElementData(localPlayer, "factionrank") curr = 1 if (factionid==1) then team = 1 skins = { } skins[1] = { } skins[1][1] = 71 skins[1][2] = 1 skins[2] = { } skins[2][1] = 280 skins[2][2] = 2 skins[3] = { } skins[3][1] = 281 skins[3][2] = 10 skins[4] = { } skins[4][1] = 282 skins[4][2] = 12 skins[5] = { } skins[5][1] = 283 skins[5][2] = 15 skins[6] = { } skins[6][1] = 284 skins[6][2] = 2 skins[7] = { } skins[7][1] = 288 skins[7][2] = 13 skincount = 7 elseif (factionid==2) then team = 2 skins = { } skins[1] = { } skins[1][1] = 274 skins[1][2] = 1 skins[2] = { } skins[2][1] = 275 skins[2][2] = 1 skins[3] = { } skins[3][1] = 276 skins[3][2] = 1 skins[4] = { } skins[4][1] = 277 skins[4][2] = 1 skins[5] = { } skins[5][1] = 278 skins[5][2] = 1 skins[6] = { } skins[6][1] = 279 skins[6][2] = 1 skincount = 6 elseif (factionid==4) then team = 4 skins = { } skins[1] = { } skins[1][1] = 163 skins[1][2] = 1 skins[2] = { } skins[2][1] = 164 skins[2][2] = 1 skins[3] = { } skins[3][1] = 165 skins[3][2] = 1 skins[4] = { } skins[4][1] = 166 skins[4][2] = 1 skins[5] = { } skins[5][1] = 286 skins[5][2] = 1 skincount = 5 else return end odimension = getElementDimension(localPlayer) ointerior = getElementInterior(localPlayer) ox, oy, oz = getElementPosition(localPlayer) orot = getPedRotation(localPlayer) oskin = getElementModel(localPlayer) local dimension = 65000 + getElementData(localPlayer, "gameaccountid") setElementDimension(localPlayer, dimension) setElementInterior(localPlayer, 0) setElementPosition(localPlayer, 2373.1181640625, 972.830078125, 18.318904876709) setPedRotation(localPlayer, 0) setCameraMatrix(2373.0029296875, 976.880859375, 18.318904876709, 2373.1181640625, 972.830078125, 18.318904876709) bindKey("Enter", "down", finishDutySkin) addEventHandler("onClientRender", getRootElement(), displayHelpText) unbindKey("F4", "down", changeDutySkin) bindKey("arrow_l", "down", prevDutySkin) bindKey("arrow_r", "down", nextDutySkin) setElementModel(localPlayer, skins[1][1]) toggleAllControls(false, true, false) end bindKey("F4", "down", changeDutySkin) function prevDutySkin() curr = curr - 1 if (curr<1) then curr = skincount end setElementModel(localPlayer, skins[curr][1]) end function nextDutySkin() curr = curr + 1 if (curr>skincount) then curr = 1 end setElementModel(localPlayer, skins[curr][1]) end function displayHelpText() local screenWidth, screenHeight = guiGetScreenSize() dxDrawText("Use arrow keys to pick a skin. Enter to select that skin.", screenHeight-380, screenHeight-93, screenWidth-30, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown") if (skins[curr][2]>factionrank) then dxDrawText("You are not a high enough rank to use this skin.", screenHeight-380, screenHeight-120, screenWidth-30, screenHeight, tocolor ( 255, 0, 0, 255 ), 1, "pricedown") end end function finishDutySkin() if (skins[curr][2]>factionrank) then playSoundFrontEnd(7) else toggleAllControls(true, true, false) bindKey("F4", "down", changeDutySkin) unbindKey("arrow_l", "down", prevDutySkin) unbindKey("arrow_r", "down", nextDutySkin) removeEventHandler("onClientRender", getRootElement(), displayHelpText) setElementDimension(localPlayer, odimension) setElementInterior(localPlayer, ointerior) triggerServerEvent("finishDutySkin", localPlayer, ox, oy, oz, orot, odimension, ointerior, skins[curr][1]) setElementModel(localPlayer, oskin) unbindKey("Enter", "down", finishDutySkin) end end
return { uiEffect = "", name = "受伤瞬移", cd = 5, painting = 0, id = 79075, picture = "0", aniEffect = "", desc = "瞬移", effect_list = { { type = "BattleSkillTeleport", target_choise = { "TargetHarmNearest" }, arg_list = { delay = 1.6, targetRelativeRandom = { rear = 16, upper = 4, lower = 0, front = 8 } } }, { type = "BattleSkillPlayFX", target_choise = {}, arg_list = { delay = 1.5, effect = "shanshuo", casterRelativeCorrdinate = { hrz = 0, vrt = 0 } } } } }
-- choose correct ffi functions for OS -- TODO many are common and can be shared here local require, error, assert, tonumber, tostring, setmetatable, pairs, ipairs, unpack, rawget, rawset, pcall, type, table, string = require, error, assert, tonumber, tostring, setmetatable, pairs, ipairs, unpack, rawget, rawset, pcall, type, table, string local cdef = require "ffi".cdef -- common functions for BSD, OSX and and Linux -- note that some functions may not be available in all, but so long as prototype is standard they can go here cdef[[ int open(const char *pathname, int flags, mode_t mode); int close(int fd); int chdir(const char *path); int fchdir(int fd); int mkdir(const char *pathname, mode_t mode); int rmdir(const char *pathname); int unlink(const char *pathname); int rename(const char *oldpath, const char *newpath); int chmod(const char *path, mode_t mode); int fchmod(int fd, mode_t mode); int chown(const char *path, uid_t owner, gid_t group); int fchown(int fd, uid_t owner, gid_t group); int lchown(const char *path, uid_t owner, gid_t group); int link(const char *oldpath, const char *newpath); int linkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags); int symlink(const char *oldpath, const char *newpath); int chroot(const char *path); mode_t umask(mode_t mask); void sync(void); int mknod(const char *pathname, mode_t mode, dev_t dev); int mkfifo(const char *path, mode_t mode); ssize_t read(int fd, void *buf, size_t count); ssize_t readv(int fd, const struct iovec *iov, int iovcnt); ssize_t write(int fd, const void *buf, size_t count); ssize_t writev(int fd, const struct iovec *iov, int iovcnt); ssize_t pread(int fd, void *buf, size_t count, off_t offset); ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset); ssize_t preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset); ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset); int access(const char *pathname, int mode); off_t lseek(int fd, off_t offset, int whence); ssize_t readlink(const char *path, char *buf, size_t bufsiz); int fsync(int fd); int fdatasync(int fd); int fcntl(int fd, int cmd, void *arg); /* arg is long or pointer */ int stat(const char *path, struct stat *sb); int lstat(const char *path, struct stat *sb); int fstat(int fd, struct stat *sb); int truncate(const char *path, off_t length); int ftruncate(int fd, off_t length); int shm_open(const char *pathname, int flags, mode_t mode); int shm_unlink(const char *name); int flock(int fd, int operation); int socket(int domain, int type, int protocol); int socketpair(int domain, int type, int protocol, int sv[2]); int pipe2(int pipefd[2], int flags); int dup(int oldfd); int dup2(int oldfd, int newfd); int dup3(int oldfd, int newfd, int flags); ssize_t recv(int sockfd, void *buf, size_t len, int flags); ssize_t send(int sockfd, const void *buf, size_t len, int flags); ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags); ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags); int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen); int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen); int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); int listen(int sockfd, int backlog); int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); int accept4(int sockfd, void *addr, socklen_t *addrlen, int flags); int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen); int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen); int shutdown(int sockfd, int how); int pipe(int pipefd[2]); int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); int poll(struct pollfd *fds, nfds_t nfds, int timeout); int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timespec *timeout, const sigset_t *sigmask); int nanosleep(const struct timespec *req, struct timespec *rem); int getrusage(int who, struct rusage *usage); int getpriority(int which, int who); int setpriority(int which, int who, int prio); uid_t getuid(void); uid_t geteuid(void); pid_t getpid(void); pid_t getppid(void); gid_t getgid(void); gid_t getegid(void); int setuid(uid_t uid); int setgid(gid_t gid); int seteuid(uid_t euid); int setegid(gid_t egid); pid_t getsid(pid_t pid); pid_t setsid(void); int setpgid(pid_t pid, pid_t pgid); pid_t getpgid(pid_t pid); pid_t getpgrp(void); pid_t fork(void); int execve(const char *filename, const char *argv[], const char *envp[]); void exit(int status); void _exit(int status); int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); int sigprocmask(int how, const sigset_t *set, sigset_t *oldset); int sigpending(sigset_t *set); int sigsuspend(const sigset_t *mask); int kill(pid_t pid, int sig); int getgroups(int size, gid_t list[]); int setgroups(size_t size, const gid_t *list); int gettimeofday(struct timeval *tv, void *tz); int settimeofday(const struct timeval *tv, const void *tz); int getitimer(int which, struct itimerval *curr_value); int setitimer(int which, const struct itimerval *new_value, struct itimerval *old_value); int acct(const char *filename); void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset); int munmap(void *addr, size_t length); int msync(void *addr, size_t length, int flags); int madvise(void *addr, size_t length, int advice); int mlock(const void *addr, size_t len); int munlock(const void *addr, size_t len); int mlockall(int flags); int munlockall(void); int openat(int dirfd, const char *pathname, int flags, mode_t mode); int mkdirat(int dirfd, const char *pathname, mode_t mode); int unlinkat(int dirfd, const char *pathname, int flags); int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath); int fchownat(int dirfd, const char *pathname, uid_t owner, gid_t group, int flags); int symlinkat(const char *oldpath, int newdirfd, const char *newpath); int mknodat(int dirfd, const char *pathname, mode_t mode, dev_t dev); int mkfifoat(int dirfd, const char *pathname, mode_t mode); int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags); int readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz); int faccessat(int dirfd, const char *pathname, int mode, int flags); int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags); int futimens(int fd, const struct timespec times[2]); int utimensat(int dirfd, const char *pathname, const struct timespec times[2], int flags); int lchmod(const char *path, mode_t mode); int fchroot(int fd); int utimes(const char *filename, const struct timeval times[2]); int futimes(int, const struct timeval times[2]); int lutimes(const char *filename, const struct timeval times[2]); pid_t wait4(pid_t wpid, int *status, int options, struct rusage *rusage); int posix_openpt(int oflag); int clock_getres(clockid_t clk_id, struct timespec *res); int clock_gettime(clockid_t clk_id, struct timespec *tp); int clock_settime(clockid_t clk_id, const struct timespec *tp); int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *request, struct timespec *remain); ssize_t listxattr(const char *path, char *list, size_t size); ssize_t llistxattr(const char *path, char *list, size_t size); ssize_t flistxattr(int fd, char *list, size_t size); ssize_t getxattr(const char *path, const char *name, void *value, size_t size); ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size); ssize_t fgetxattr(int fd, const char *name, void *value, size_t size); int setxattr(const char *path, const char *name, const void *value, size_t size, int flags); int lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags); int fsetxattr(int fd, const char *name, const void *value, size_t size, int flags); int removexattr(const char *path, const char *name); int lremovexattr(const char *path, const char *name); int fremovexattr(int fd, const char *name); ]]
target("quark-base") set_symbols("debug") set_kind("static") --add_includedirs("$(projectdir)/deps/easyloggingpp") add_links("uring") add_linkdirs("$(projectdir)/deps/liburing/lib") add_files("*.cpp") add_files("$(projectdir)/deps/easyloggingpp/easylogging++.cc")
--[[----------------------------------------------------------------------------- * Infected Wars, an open source Garry's Mod game-mode. * * Infected Wars is the work of multiple authors, * a full list can be found in CONTRIBUTORS.md. * For more information, visit https://github.com/JarnoVgr/InfectedWars * * Infected Wars is free software: you can redistribute it and/or modify * it under the terms of the MIT License. * * A full copy of the MIT License can be found in LICENSE.txt. -----------------------------------------------------------------------------]] include('shared.lua') local matPentagram = Material( "infectedwars/pentagram" ) function ENT:Name() return "< Sacrifical Baby >" end function ENT:Team() return TEAM_UNDEAD end function ENT:Initialize() self.emitter = ParticleEmitter( self.Entity:GetPos() ) end function ENT:Think() self.endpos = self.Entity:GetDTVector( 0 ) if not self.Entity:GetDTBool( 0 ) then return end local hp = self.Entity:GetDTFloat( 0 ) -- Particle timer self.ParticleTimer = self.ParticleTimer or (CurTime()+0.01) if ( self.ParticleTimer <= CurTime() ) then self.ParticleTimer = CurTime() + 0.01 + 0.02/hp -- Smoke effects local spawnPos = self.endpos+((math.random(0,25)/math.random(1,2))*(Vector(math.Rand(-1,1),math.Rand(-1,1),0):Normalize())) if self.emitter then -- make sure that the emitter was created local particle = self.emitter:Add( "particle/fire", spawnPos ) particle:SetVelocity( Vector(0,0,15+math.random(0,10)) ) particle:SetDieTime( 0.5 + math.Rand(0,0.5) + (hp/100) ) particle:SetStartAlpha( math.Rand( 100, 150 ) ) particle:SetEndAlpha( 0 ) particle:SetStartSize( math.Rand( 5, 10 ) ) particle:SetEndSize( math.Rand( 5, 10 ) ) particle:SetRoll( math.Rand( -0.2, 0.2 ) ) local ran = math.random(0,20) particle:SetColor( 255, 20+ran, 20+ran ) end end end function ENT:OnRemove() self.emitter:Finish() end function ENT:Draw() self.Entity:DrawModel() if not self.Entity:GetDTBool( 1 ) or not self.endpos then return end render.SetMaterial( matPentagram ) local Size = 50 + 10*math.sin(CurTime()) render.DrawQuadEasy( self.endpos, Vector(0,0,1), Size, Size, Color(255,255,255,255), 0 ) local Jump = CurTime()%5*4 render.DrawQuadEasy( self.endpos+Vector(0,0,Jump*1.5), Vector(0,0,1), 40, 40, Color(255,255,255,math.max(10-Jump,0)*(255/20)), 0 ) end
Script.Load("lua/%__MODNAME__%/ModFramework/Modules/FrameworkModule.lua") class 'EnumUtilitiesModule' (FrameworkModule) function EnumUtilitiesModule:Initialize(framework) FrameworkModule.Initialize(self, "enumutilities", framework, false) end --[[ Append key to enum tbl: Enum key: Key ]] function EnumUtilitiesModule:AppendToEnum(tbl, key) fw_assert_not_nil(tbl, "Enum cannot be nil", self) fw_assert_type(tbl, "table", "Enum", self) fw_assert_not_nil(key, "Key cannot be nil", self) fw_assert_nil(rawget(tbl,key), "Key already exists in enum.") local maxVal if tbl == kTechId then maxVal = tbl.Max -- Delete old max rawset(tbl, rawget(tbl, maxVal), nil) rawset(tbl, maxVal, nil) -- Move max down rawset(tbl, 'Max', maxVal + 1) rawset(tbl, maxVal + 1, 'Max') else maxVal = -1 for k, v in next, tbl do if type(v) == "number" and v > maxVal then maxVal = v end end maxVal = maxVal + 1 end fw_assert_not_nil(maxVal, "Failed to get next value for enum") rawset(tbl, key, maxVal) rawset(tbl, maxVal, key) end --[[ Delete key from enum tbl: Enum key: Key ]] function EnumUtilitiesModule:RemoveFromEnum(tbl, key) fw_assert_not_nil(tbl, "Enum cannot be nil", self) fw_assert_type(tbl, "table", "Enum", self) fw_assert_not_nil(key, "Key cannot be nil", self) fw_assert_not_nil(rawget(tbl, key), "Key doesn't exist in enum", self) -- Delete enum entry rawset(tbl, rawget(tbl, key), nil) rawset(tbl, key, nil) -- If we modified the kTechId eunm, we need to update kTechId.Max too. if tbl == kTechId then local maxVal = tbl.Max -- delete old max rawset(tbl, rawget(tbl, maxVal), nil) rawset(tbl, maxVal, nil) -- move max down rawset(tbl, 'Max', maxVal - 1) rawset(tbl, maxVal - 1, 'Max') end end
-- WIP Hashed Queue local function NtoZ_c(x, y) return (x >= 0 and x or (-0.5 - x)), (y >= 0 and y or (-0.5 - y)) end local function cantorPair_v7(pos) local x, y = NtoZ_c(math.floor(pos.x), math.floor(pos.y)) local s = x + y local h = s * (s + 0.5) + x return h + h end local Queue = {} function Queue.new() return {_hash={}} end function Queue.set_hash(t, data) local index = data.entity.unit_number or cantorPair_v7(data.entity.position) local hash = t._hash hash[index] = hash[index] or {} hash[index].count = (hash[index].count or 0) + 1 hash[index][data.hash] = data.hash return index end function Queue.get_hash(t, entity) local index = entity.unit_number or cantorPair_v7(entity.position) return t._hash[index] end function Queue.insert(t, data, tick, count) data.hash = Queue.set_hash(t, data) t[tick] = t[tick] or {} t[tick][#t[tick] + 1] = data return t, count end function Queue.next(t, _next_tick, tick_spacing, dont_combine) tick_spacing = tick_spacing or 1 local count = 0 local tick = (_next_tick and _next_tick >= game.tick and _next_tick) or game.tick local next_tick = function(really_dont_combine) tick = tick + tick_spacing while (dont_combine or really_dont_combine) and t[tick] do tick = tick + 1 end count = count + 1 return tick, count end local queue_count = function(num) count = count + (num or 0) return count end return next_tick, queue_count end --Tick handler, handles executing multiple data tables in a queue function Queue.execute(event, queue) if queue[event.tick] then for _, data in ipairs(queue[event.tick]) do local hash, index = queue._hash, data.hash if Queue[data.action] then Queue[data.action](data) end hash[index][data.action] = nil hash[index].count = hash[index].count - 1 if hash[index].count <= 0 then hash[index] = nil end end queue[event.tick] = nil end end return Queue
target("CoreTest") set_kind("binary") set_group("Test") add_files("**.cpp") add_headerfiles("**.hpp") add_deps("Core") add_packages("gtest", {public = true}) add_includedirs("$(projectdir)/test/core_test", {public = true}) target_end()
require "keycodes" --- org author mafins function SetupText() ui.SET_TEXT_FONT(0) ui.SET_TEXT_SCALE(0.4, 0.4) ui.SET_TEXT_COLOUR(255, 255, 255, 255) ui.SET_TEXT_WRAP(0.0, 1.0) ui.SET_TEXT_CENTRE(0) ui.SET_TEXT_DROPSHADOW(0, 0, 0, 0, 0) ui.SET_TEXT_EDGE(0, 0, 0, 0, 0) ui.SET_TEXT_OUTLINE() end function DrawString(text, x, y) ui._SET_TEXT_ENTRY("STRING") ui._ADD_TEXT_COMPONENT_STRING(text) ui._DRAW_TEXT(x, y) end local grav_target_locked = false local grav_entity = 0 local grav_partfx = 0 function GetCoordsFromCam(distance) local rot = cam.GET_GAMEPLAY_CAM_ROT(2) local coord = cam.GET_GAMEPLAY_CAM_COORD() local tZ = rot.z * 0.0174532924; local tX = rot.x * 0.0174532924; local num = math.abs(math.cos(tX)); coord.x = coord.x + (-math.sin(tZ)) * (num + distance) coord.y = coord.y + (math.cos(tZ)) * (num + distance) coord.z = coord.z + math.sin(tX) * 8 return coord end function GetDirectionFromCam() local rot = cam.GET_GAMEPLAY_CAM_ROT(2) local coord = cam.GET_GAMEPLAY_CAM_COORD() local tZ = rot.z * 0.0174532924; local tX = rot.x * 0.0174532924; local num = math.abs(math.cos(tX)); coord.x = (-math.sin(tZ)) * (num) coord.y = (math.cos(tZ)) * (num) coord.z = math.sin(tX) return coord end function RequestControlEntity(entity) local tick = 0 while network.NETWORK_HAS_CONTROL_OF_ENTITY(entity) == false and tick <= 12 do network.NETWORK_REQUEST_CONTROL_OF_ENTITY(entity) tick = tick + 1 end return entity end local spawn_car = "ambulance" function OnScriptTick() if ped.IS_PED_SHOOTING(player.PLAYER_PED_ID()) == 1 then local id = player.PLAYER_PED_ID() local hash = gameplay.GET_HASH_KEY(spawn_car) if hash > 0 and id > 0 then streaming.REQUEST_MODEL(hash) if streaming.HAS_MODEL_LOADED(hash) then local coords = GetCoordsFromCam(6) local vehicle_id = vehicle.CREATE_VEHICLE(hash, coords.x, coords.y, coords.z, 0, 1, 0) local net_id = network.VEH_TO_NET(vehicle_id) network.SET_NETWORK_ID_EXISTS_ON_ALL_MACHINES(net_id, 1) audio.PLAY_SOUND_FROM_ENTITY(-1, "Foot_Swish", vehicle_id, "docks_heist_finale_2a_sounds", 0, 0) entity.SET_ENTITY_HEADING(vehicle_id, entity.GET_ENTITY_HEADING(player.PLAYER_PED_ID())) if network.NETWORK_HAS_CONTROL_OF_ENTITY(RequestControlEntity(vehicle_id)) == false then return end local direction = GetDirectionFromCam() entity.APPLY_FORCE_TO_ENTITY(vehicle_id, 1, 0, 150 + math.abs(direction.y) * 50, direction.z * 130, 0, 0, 0, 0, 1, 1, 1, 0, 1) system.WAIT(10) end end end end function OnDrawTick() end function Initialize() end
local instances = {} return instances
victorQuestpSlumsConvoTemplate = ConvoTemplate:new { initialScreen = "", templateType = "Lua", luaClassHandler = "victorQuestpSlumsConvoHandler", screens = {} } init_joined_victor = ConvoScreen:new { id = "init_joined_victor", leftDialog = "@conversation/victor_questp_slums:s_f25283c7", -- I knew you'd come. The story should be told to everyone. It has a good moral to it, I think. stopConversation = "false", options = { {"@conversation/victor_questp_slums:s_8611417a", "tuskens_came"}, -- What story? } } victorQuestpSlumsConvoTemplate:addScreen(init_joined_victor); tuskens_came = ConvoScreen:new { id = "tuskens_came", leftDialog = "@conversation/victor_questp_slums:s_222d159b", -- Listen closely. The Sand People have been attacking the outskirts of the city. For some reason, the Empire has hidden this fact from those who do not live in the slums... not to panic everyone else, I guess. It's hard to live here. One particular night, a couple of months back, the Tuskens came. They killed several of us here. They took my son. I--I just don't want to think about it... about what could have happened that night. stopConversation = "false", options = { {"@conversation/victor_questp_slums:s_540ac7e9", "poor_woman"}, -- Continue. } } victorQuestpSlumsConvoTemplate:addScreen(tuskens_came); poor_woman = ConvoScreen:new { id = "poor_woman", leftDialog = "@conversation/victor_questp_slums:s_41e66644", -- I'm just a poor woman. I'm not significant in this life, or to this city. But Victor Visalis heard of my misfortune and took pity on me. He took his own soldiers and destroyed the Tuskens. He returned my son to me! Can you believe that? I'm so grateful. stopConversation = "false", options = { {"@conversation/victor_questp_slums:s_d5f19466", "would_do_anything"}, -- I need your help. } } victorQuestpSlumsConvoTemplate:addScreen(poor_woman); would_do_anything = ConvoScreen:new { id = "would_do_anything", leftDialog = "@conversation/victor_questp_slums:s_41330c9c", -- I will help you as well as I can. What do you need? Oh? I would do anything for Victor. I'd be happy to write my account of the happenings for you. Luckily, I know how to write. Victor funded my education as well. He's done so much for us. Give me a second.. stopConversation = "false", options = { --{"@conversation/victor_questp_slums:s_67e6df55", ""}, -- Okay. } } victorQuestpSlumsConvoTemplate:addScreen(would_do_anything); give_evidence = ConvoScreen:new { id = "give_evidence", leftDialog = "@conversation/victor_questp_slums:s_22977a6d", -- Done! Please take this written testimony. I hope it helps you and, most of all, helps Victor. I hope you have a good day. stopConversation = "true", options = {} } victorQuestpSlumsConvoTemplate:addScreen(give_evidence); inv_full = ConvoScreen:new { id = "inv_full", leftDialog = "@conversation/victor_questp_slums:s_4f9d0087", -- Please take this written testimony--oh wait. You don't have enough room to accept it. Hmm... you should come back when you do. stopConversation = "true", options = {} } victorQuestpSlumsConvoTemplate:addScreen(inv_full); init_office_phase = ConvoScreen:new { id = "init_office_phase", leftDialog = "@conversation/victor_questp_slums:s_f8cdce4", -- I can barely go outside anymore to do my chores. I fear for my child. I don't want him to be kidnapped again. An election should be coming up soon. I'd choose Victor Visalis. He would keep us poor citizens safe. stopConversation = "true", options = {} } victorQuestpSlumsConvoTemplate:addScreen(init_office_phase); init_election_phase = ConvoScreen:new { id = "init_election_phase", leftDialog = "@conversation/victor_questp_slums:s_dcb207ac", -- I don't recognize you. You don't belong in this part of town. I hear there's a lot of commotion at the capitol. Something about an election. You should go and see what it's all about. stopConversation = "true", options = {} } victorQuestpSlumsConvoTemplate:addScreen(init_election_phase); init_already_has_evidence = ConvoScreen:new { id = "init_already_has_evidence", leftDialog = "@conversation/victor_questp_slums:s_4117e563", -- Why are you back? I've already given you my testimony. Why haven't you shown it to the governor? What are you waiting for? She needs to know this. stopConversation = "true", options = {} } victorQuestpSlumsConvoTemplate:addScreen(init_already_has_evidence); init_inv_was_full = ConvoScreen:new { id = "init_inv_was_full", leftDialog = "@conversation/victor_questp_slums:s_b6d2944c", -- I'm glad you've returned. Did you want your evidence now? I hope you have enough room. stopConversation = "false", options = { --{"@conversation/victor_questp_slums:s_ee6997ba", "great_man"}, -- I do, thank you. --{"@conversation/victor_questp_slums:s_76cc19da", "come_back_later"}, -- No, I still don't have room. } } victorQuestpSlumsConvoTemplate:addScreen(init_inv_was_full); was_full_give_evidence = ConvoScreen:new { id = "was_full_give_evidence", leftDialog = "@conversation/victor_questp_slums:s_b8dac377", -- I'm so glad! Please take this testimony. I wish you well in your life! stopConversation = "true", options = {} } victorQuestpSlumsConvoTemplate:addScreen(was_full_give_evidence); inv_still_full = ConvoScreen:new { id = "inv_still_full", leftDialog = "@conversation/victor_questp_slums:s_585b9214", -- Oh no. You don't have enough room again. Please come back when you do. I hope to see you soon. stopConversation = "true", options = {} } victorQuestpSlumsConvoTemplate:addScreen(inv_still_full); come_back_later = ConvoScreen:new { id = "come_back_later", leftDialog = "@conversation/victor_questp_slums:s_6ec1e03e", -- Okay then, come back later when you have more room. stopConversation = "true", options = {} } victorQuestpSlumsConvoTemplate:addScreen(come_back_later); addConversationTemplate("victorQuestpSlumsConvoTemplate", victorQuestpSlumsConvoTemplate);
local pcall, dofile, _G = pcall, dofile, _G module "luci.version" if pcall(dofile, "/etc/openwrt_release") and _G.DISTRIB_DESCRIPTION then distname = "" distversion = _G.DISTRIB_DESCRIPTION if _G.DISTRIB_REVISION then distrevision = _G.DISTRIB_REVISION if not distversion:find(distrevision,1,true) then distversion = distversion .. " " .. distrevision end end else distname = "OpenWrt" distversion = "Development Snapshot" end luciname = "LuCI lede-17.01 branch" luciversion = "git-17.051.53299-a100738"
local core = require 'core' local parser = require 'parser' local buildVM = require 'vm' local function catch_target(script) local list = {} local cur = 1 while true do local start, finish = script:find('<[!?].-[!?]>', cur) if not start then break end list[#list+1] = { start + 2, finish - 2 } cur = finish + 1 end return list end local function founded(targets, results) if #targets ~= #results then return false end for _, target in ipairs(targets) do for _, result in ipairs(results) do if target[1] == result[1] and target[2] == result[2] then goto NEXT end end do return false end ::NEXT:: end return true end function TEST(script) local target = catch_target(script) local start = script:find('<?', 1, true) local finish = script:find('?>', 1, true) local pos = (start + finish) // 2 + 1 local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ') local ast = parser:ast(new_script, 'lua', 'Lua 5.3') assert(ast) local vm = buildVM(ast) assert(vm) local positions = core.definition(vm, pos, 'reference') if positions then assert(founded(target, positions)) else assert(#target == 0) end end TEST [[ local <?a?> = 1 <!a!> = <!a!> ]] TEST [[ t.<?a?> = 1 t.<!a!> = t.<!a!> ]] TEST [[ :: <!LABEL!> :: goto <?LABEL?> ]] TEST [[ local a = 1 local <?a?> = 1 <!a!> = <!a!> ]] TEST [[ local t = { <?a?> = 1 } print(t.<!a!>) ]] TEST [[ local <!mt!> = {} function <!mt!>:a() <?self?>:remove() end ]] TEST [[ local function f() return <?function () end?> end local <!f2!> = f() ]] TEST [[ table.<!dump!>() function table.<?dump?>() end ]] TEST [[ ---@class <!Class!> ---@type <?Class?> ---@type <!Class!> ]] TEST [[ ---@class <?Class?> ---@type <!Class!> ---@type <!Class!> ]]
object_tangible_tcg_series3_decorative_jango_fett_memorial_statue = object_tangible_tcg_series3_shared_decorative_jango_fett_memorial_statue:new { } ObjectTemplates:addTemplate(object_tangible_tcg_series3_decorative_jango_fett_memorial_statue, "object/tangible/tcg/series3/decorative_jango_fett_memorial_statue.iff")
local URL = require('url') local qs = require('querystring') -- helper to find elements by its values local function _indexOf (target, field) if type(target) == 'string' then return target:find(field, 1, true) end for index, value in pairs(target) do if value == field then return index end end return nil end -- list of supported methods to override local function _supportMethod (method) local methods = { 'get', 'post', 'put', 'head', 'delete', 'options', 'trace', 'copy', 'lock', 'mkcol', 'move', 'propfind', 'proppatch', 'unlock', 'report', 'mkactivity', 'checkout', 'merge', 'm-search', 'notify', 'subscribe', 'unsubscribe', 'patch' } return _indexOf(methods, method) ~= nil end -- create a getter for a given string local function _createGetter (key) return function (req, res) if _indexOf(key:upper(), 'X-') == 1 then return req.headers[key:lower()] or '' else local parsedURL = URL.parse(req.url) if parsedURL.query and parsedURL.query ~= '' then local query = qs.parse(parsedURL.query) return query[key] end return '' end end end -- provides faux http method support -- pass optional key param to use when checking for a method override, defaults to '_method' local function methodOverride (key) key = key or 'X-HTTP-Method-Override' return function (req, res, nxt) req.originalMethod = req.originalMethod or req.method local get = _createGetter(key) local method = get(req, res) if _supportMethod(method:lower()) then req.method = method:upper() end nxt() end end return methodOverride
local args = ... local player = args.player local af = Def.ActorFrame{ --Name="Pane2_SideP1", InitCommand=function(self) self:visible(false) end } af[#af+1] = LoadActor(THEME:GetPathB("ScreenEvaluation", "common/Panes/Pane1"), {player, args.player}) local position = player == "PlayerNumber_P1" and (_screen.cx - 155 + WideScale(115,0)) or -330 af[#af+1] = LoadActor("./ExperimentPercents.lua", player)..{InitCommand=function(self) self:x(position) end} return af
include("/scripts/includes/consts.lua") name = "" level = 20 itemIndex = 11 creatureState = CREATURESTATE_IDLE function onInit() -- Player collides with BB. Make it a bit larget than the default BB. self:SetBoundingSize({1.0, 2.0, 2.0}) self:SetUndestroyable(true) -- Even when the collision mask is zero, it still calls the trigger even self:SetCollisionMask(0) -- Will call onTrigger() when it collides self:SetTrigger(true) return true end function onTrigger(creature) local player = creature:AsPlayer() if (player ~= nil) then local party = player:GetParty() if (party ~= nil) then party:ChangeInstance(self:GetVarString("destination")) end end end
Heresy = class("Heresy") function Heresy:init(data) local heresyTable = loadjson(".\\tables\\heresy.JSON") self.founder = choice(heresyTable["founder"]) self.major_heresy = choice(heresyTable["major_heresy"]) self.attitude = choice(heresyTable["attitude"]) self.quirk = choice(heresyTable["quirk"]) if(debug)then logger("Heresy:") logger("Founder: "..self.founder) logger("Major Heresy: "..self.major_heresy) logger("Attitude: "..self.attitude) logger("Quirk: "..self.quirk) end end function Heresy:Serialize() return self.element end --= Return Factory return Heresy
-- It's possible for players to edit their Simply Love UserPrefs.ini file -- in various ways that might break the theme. Also, sometimes theme-specific mods -- are deprecated or change their internal name, leaving old values behind in player profiles -- that might break the theme as well. Use this table to validate settings read in -- from and written out to player profiles. -- -- For now, this table is local to this file, but might be moved into the SL table (or something) -- in the future to facilitate type checking in ./Scripts/SL-PlayerOptions.lua and elsewhere. local permitted_profile_settings = { ---------------------------------- -- "Main Modifiers" -- OptionRows that appear in SL's first page of PlayerOptions SpeedModType = "string", SpeedMod = "number", Mini = "string", NoteSkin = "string", JudgmentGraphic = "string", ComboFont = "string", HoldJudgment = "string", BackgroundFilter = "string", BackgroundColor = "string", ---------------------------------- -- "Advanced Modifiers" -- OptionRows that appear in SL's second page of PlayerOptions HideTargets = "boolean", HideSongBG = "boolean", HideCombo = "boolean", HideLifebar = "boolean", HideScore = "boolean", HideDanger = "boolean", HideComboExplosions = "boolean", LifeMeterType = "string", DataVisualizations = "string", TargetScore = "number", ActionOnMissedTarget = "string", MeasureCounter = "string", MeasureCounterLeft = "boolean", MeasureCounterUp = "boolean", HideLookahead = "boolean", ColumnFlashOnMiss = "boolean", SubtractiveScoring = "boolean", Pacemaker = "boolean", MissBecauseHeld = "boolean", NPSGraphAtTop = "boolean", JudgmentTilt = "boolean", ColumnCues = "boolean", DisplayScorebox = "boolean", ErrorBar = "string", ErrorBarUp = "boolean", ErrorBarMultiTick = "boolean", ShowFaPlusWindow = "boolean", ShowEXScore = "boolean", HideFaPlusPane = "boolean", ReceptorArrowsPosition = "string", ---------------------------------- -- Profile Settings without OptionRows -- these settings are saved per-profile, but are transparently managed by the theme -- they have no player-facing OptionRows PlayerOptionsString = "string", EvalPanePrimary = "number", EvalPaneSecondary = "number", } -- ----------------------------------------------------------------------- local theme_name = THEME:GetThemeDisplayName() local filename = theme_name .. " UserPrefs.ini" LoadVirtualProfileCustom = function(p, index) local id = PROFILEMAN:GetLocalProfileIDFromIndex(index) local profile = PROFILEMAN:GetLocalProfileFromIndex(index) local dir = PROFILEMAN:LocalProfileIDToDir(id) local path = dir .. filename local player, pn, filecontents player = p pn = ToEnumShortString(p) if pn and FILEMAN:DoesFileExist(path) then filecontents = IniFile.ReadFile(path)[theme_name] -- for each key/value pair read in from the player's profile for k,v in pairs(filecontents) do -- ensure that the key has a corresponding key in permitted_profile_settings if permitted_profile_settings[k] -- ensure that the datatype of the value matches the datatype specified in permitted_profile_settings and type(v)==permitted_profile_settings[k] then -- if the datatype is string and this key corresponds with an OptionRow in ScreenPlayerOptions -- ensure that the string read in from the player's profile -- is a valid value (or choice) for the corresponding OptionRow if type(v) == "string" and CustomOptionRow(k) and FindInTable(v, CustomOptionRow(k).Values or CustomOptionRow(k).Choices) or type(v) ~= "string" then SL[pn].ActiveModifiers[k] = v end -- special-case PlayerOptionsString for now -- it is saved to and read from profile as a string, but doesn't have a corresponding -- OptionRow in ScreenPlayerOptions, so it will fail validation above -- we want engine-defined mods (e.g. dizzy) to be applied as well, not just SL-defined mods if k=="PlayerOptionsString" and type(v)=="string" then -- v here is the comma-delimited set of modifiers the engine's PlayerOptions interface understands -- update the SL table so that this PlayerOptionsString value is easily accessible throughout the theme SL[pn].PlayerOptionsString = v -- use the engine's SetPlayerOptions() method to set a whole bunch of mods in the engine all at once GAMESTATE:GetPlayerState(player):SetPlayerOptions("ModsLevel_Preferred", v) -- However! It's quite likely that a FailType mod could be in that^ string, meaning a player could -- have their own setting for FailType saved to their profile. I think it makes more sense to let -- machine operators specify a default FailType at a global/machine level, so use this opportunity to -- use the PlayerOptions interface to set FailSetting() using the default FailType setting from -- the operator menu's Advanced Options GAMESTATE:GetPlayerState(player):GetPlayerOptions("ModsLevel_Preferred"):FailSetting( GetDefaultFailType() ) end if k=="EvalPaneSecondary" and type(v)==permitted_profile_settings.EvalPaneSecondary then SL[pn].EvalPaneSecondary = v elseif k=="EvalPanePrimary" and type(v)==permitted_profile_settings.EvalPanePrimary then SL[pn].EvalPanePrimary = v end end end end return true end -- function assigned to "CustomLoadFunction" under [Profile] in metrics.ini LoadProfileCustom = function(profile, dir) local path = dir .. filename local player, pn, filecontents -- we've been passed a profile object as the variable "profile" -- see if it matches against anything returned by PROFILEMAN:GetProfile(player) for p in ivalues( GAMESTATE:GetHumanPlayers() ) do if profile == PROFILEMAN:GetProfile(p) then player = p pn = ToEnumShortString(p) break end end if pn then ParseGrooveStatsIni(player) end if pn and FILEMAN:DoesFileExist(path) then filecontents = IniFile.ReadFile(path)[theme_name] -- for each key/value pair read in from the player's profile for k,v in pairs(filecontents) do -- ensure that the key has a corresponding key in permitted_profile_settings if permitted_profile_settings[k] -- ensure that the datatype of the value matches the datatype specified in permitted_profile_settings and type(v)==permitted_profile_settings[k] then -- if the datatype is string and this key corresponds with an OptionRow in ScreenPlayerOptions -- ensure that the string read in from the player's profile -- is a valid value (or choice) for the corresponding OptionRow if type(v) == "string" and CustomOptionRow(k) and FindInTable(v, CustomOptionRow(k).Values or CustomOptionRow(k).Choices) or type(v) ~= "string" then SL[pn].ActiveModifiers[k] = v end -- special-case PlayerOptionsString for now -- it is saved to and read from profile as a string, but doesn't have a corresponding -- OptionRow in ScreenPlayerOptions, so it will fail validation above -- we want engine-defined mods (e.g. dizzy) to be applied as well, not just SL-defined mods if k=="PlayerOptionsString" and type(v)=="string" then -- v here is the comma-delimited set of modifiers the engine's PlayerOptions interface understands -- update the SL table so that this PlayerOptionsString value is easily accessible throughout the theme SL[pn].PlayerOptionsString = v -- use the engine's SetPlayerOptions() method to set a whole bunch of mods in the engine all at once GAMESTATE:GetPlayerState(player):SetPlayerOptions("ModsLevel_Preferred", v) -- However! It's quite likely that a FailType mod could be in that^ string, meaning a player could -- have their own setting for FailType saved to their profile. I think it makes more sense to let -- machine operators specify a default FailType at a global/machine level, so use this opportunity to -- use the PlayerOptions interface to set FailSetting() using the default FailType setting from -- the operator menu's Advanced Options GAMESTATE:GetPlayerState(player):GetPlayerOptions("ModsLevel_Preferred"):FailSetting( GetDefaultFailType() ) end end end end return true end -- function assigned to "CustomSaveFunction" under [Profile] in metrics.ini SaveProfileCustom = function(profile, dir) local path = dir .. filename for player in ivalues( GAMESTATE:GetHumanPlayers() ) do if profile == PROFILEMAN:GetProfile(player) then local pn = ToEnumShortString(player) local output = {} for k,v in pairs(SL[pn].ActiveModifiers) do if permitted_profile_settings[k] and type(v)==permitted_profile_settings[k] then output[k] = v end end -- these values are saved outside the SL[pn].ActiveModifiers tables -- and thus won't be handled in the loop above output.PlayerOptionsString = SL[pn].PlayerOptionsString IniFile.WriteFile( path, {[theme_name]=output} ) -- Write to the ITL file if we need to. -- The ITLData table will only contain data for memory cards. if #SL[pn].ITLData ~= 0 then WriteItlFile(dir, table.concat(SL[pn].ITLData, "")) end break end end return true end -- ----------------------------------------------------------------------- -- returns a path to a profile avatar, or nil if none is found GetAvatarPath = function(profileDirectory, displayName) if type(profileDirectory) ~= "string" then return end local path = nil -- sequence matters here -- prefer png first, then jpg, then jpeg, etc. -- (note that SM5 does not support animated gifs at this time, so SL doesn't either) -- TODO: investigate effects (memory footprint, fps) of allowing movie files as avatars in SL local extensions = { "png", "jpg", "jpeg", "bmp", "gif", "mp4" } -- prefer an avatar named: -- "avatar" in the player's profile directory (preferred by Simply Love) -- then "profile picture" in the player's profile directory (used by Digital Dance) -- then (whatever the profile's DisplayName is) in /Appearance/Avatars/ (used in OutFox?) local paths = { ("%savatar"):format(profileDirectory), ("%sprofile picture"):format(profileDirectory), ("/Appearance/Avatars/%s"):format(displayName) } for _, path in ipairs(paths) do for _, extension in ipairs(extensions) do local avatar_path = ("%s.%s"):format(path, extension) if FILEMAN:DoesFileExist(avatar_path) and (ActorUtil.GetFileType(avatar_path) == "FileType_Bitmap" or ActorUtil.GetFileType(avatar_path) == "FileType_Movie") then -- return the first valid avatar path that is found return avatar_path end end end -- or, return nil if no avatars were found in any of the permitted paths return nil end -- ----------------------------------------------------------------------- -- returns a path to a player's profile avatar, or nil if none is found GetPlayerAvatarPath = function(player) if not player then return end local profile_slot = { [PLAYER_1] = "ProfileSlot_Player1", [PLAYER_2] = "ProfileSlot_Player2" } if not profile_slot[player] then return end local dir = PROFILEMAN:GetProfileDir(profile_slot[player]) local name = PROFILEMAN:GetProfile(player):GetDisplayName() return GetAvatarPath(dir, name) end GetScreenshotsPath = function(profileDirectory, displayName) if type(profileDirectory) ~= "string" then return end local path = nil -- sequence matters here -- prefer png first, then jpg, then jpeg, etc. -- (note that SM5 does not support animated gifs at this time, so SL doesn't either) -- TODO: investigate effects (memory footprint, fps) of allowing movie files as avatars in SL local extensions = { "png", "jpg", "jpeg", "bmp", "gif", "mp4" } -- prefer an avatar named: -- "avatar" in the player's profile directory (preferred by Simply Love) -- then "profile picture" in the player's profile directory (used by Digital Dance) -- then (whatever the profile's DisplayName is) in /Appearance/Avatars/ (used in OutFox?) local dascreens = {} path = ("%s/Screenshots/Simply_love/"):format(profileDirectory) local pathos = " " local year = FILEMAN:GetDirListing(path.."/", true, true) if year then for _, monthInYear in ipairs(year) do local months = FILEMAN:GetDirListing(monthInYear.."/", true, true) if months then for _, month in ipairs(months) do local screenies = FILEMAN:GetDirListing(month.."/", false, true) if screenies then for _, screenshot in ipairs(screenies) do table.insert(dascreens, screenshot) end end end end end end return dascreens -- or, return nil if no avatars were found in any of the permitted paths --return pathos end GetPlayerScreenshotsPath = function(player) if not player then return end local profile_slot = { [PLAYER_1] = "ProfileSlot_Player1", [PLAYER_2] = "ProfileSlot_Player2" } if not profile_slot[player] then return end local dir = PROFILEMAN:GetProfileDir(profile_slot[player]) local name = PROFILEMAN:GetProfile(player):GetDisplayName() return GetScreenshotsPath(dir, name) end
return function(location, pattern) return location == pattern and location or nil end
-- title: entity.lua -- author: Samy Bencherif -- desc: Parent class of all game entities Object = require "libraries/classic/classic" assets = require("libraries/cargo/cargo").init("assets") Entity = Object:extend() function Entity:new() self.t = 0 end function Entity:update(dt) self.t = self.t + dt end function Entity:draw() love.graphics.draw( assets.entity, --[[ x-pos ]] 100, --[[ y-pos ]] 100, self.t * 6 ) end
package.path = "../?.lua;"..package.path; require("p5") function setup() background(0xff, 0x20, 0x20) clear(); end go()
local _M = {} _M.__index = _M function _M.new(cookieString) local self = setmetatable({}, _M) self.data = {} self.flags = {} if cookieString ~= nil then for keyValue in string.gmatch(cookieString, "([^;]+)") do key, value = string.match(keyValue, " *([^=]+)=(.+)") if key == nil or value == nil then self.flags[string.match(keyValue, " *([^=]+)")] = true else self.data[key] = value end end end return self end function _M:toString() local first = true local buffer = {} for key, value in pairs(self.data) do if first then first = false else table.insert(buffer, "; ") end table.insert(buffer, key .. "=" .. value) end for key, value in pairs(self.flags) do if value == true then if first then first = false else table.insert(buffer, "; ") end table.insert(buffer, key) end end return table.concat(buffer) end return _M
-- Function Availability FileWriteLineFast("test/output.txt", "Function Availability", FM_WRITE); local fa = dofile("test/common/function_availability.lua"); fa.FunctionSupported(MouseInit, "MTR_MouseInit", MouseFunctionSupported); fa.FunctionSupported(MouseRefresh, "MTR_MouseRefresh", MouseFunctionSupported); fa.FunctionSupported(MousePress, "MTR_MousePress", MouseFunctionSupported); fa.FunctionSupported(MouseRelease, "MTR_MouseRelease", MouseFunctionSupported); fa.FunctionSupported(MousePressed, "MTR_MousePressed", MouseFunctionSupported); fa.FunctionSupported(MouseGetWheelRelative, "MTR_MouseGetWheelRelative", MouseFunctionSupported); fa.FunctionSupported(MouseMoving, "MTR_MouseMoving", MouseFunctionSupported); fa.FunctionSupported(MouseGetX, "MTR_MouseGetX", MouseFunctionSupported); fa.FunctionSupported(MouseGetY, "MTR_MouseGetY", MouseFunctionSupported); fa.FunctionSupported(MouseGetXY, "MTR_MouseGetXY", MouseFunctionSupported); fa.FunctionSupported(MouseGetDeltaX, "MTR_MouseGetDeltaX", MouseFunctionSupported); fa.FunctionSupported(MouseGetDeltaY, "MTR_MouseGetDeltaY", MouseFunctionSupported); fa.FunctionSupported(MouseGetDeltaXY, "MTR_MouseGetDeltaXY", MouseFunctionSupported); fa.FunctionSupported(MouseCursorShow, "MTR_MouseCursorShow", MouseFunctionSupported); fa.FunctionSupported(MouseCursorHide, "MTR_MouseCursorHide", MouseFunctionSupported);
local on_attach = require('lsp.on_attach') local lsp = vim.lsp -- config that activates keymaps and enables snippet support local function base_config() local capabilities = require('cmp_nvim_lsp').update_capabilities( vim.lsp.protocol.make_client_capabilities() ) capabilities.textDocument.completion.completionItem.snippetSupport = true capabilities.textDocument.completion.completionItem.resolveSupport = { properties = { 'documentation', 'detail', 'additionalTextEdits' }, } return { -- enable snippet support capabilities = capabilities, -- map buffer local keybindings when the language server attaches on_attach = on_attach, } end local function set_sign(type, icon) local sign = string.format('DiagnosticSign%s', type) local texthl = string.format('DiagnosticDefault%s', type) vim.fn.sign_define(sign, { text = icon, texthl = texthl }) end set_sign('Hint', '') set_sign('Information', '') set_sign('Warning', '') set_sign('Error', '') lsp.set_log_level('error') lsp.handlers['textDocument/publishDiagnostics'] = lsp.with(lsp.diagnostic.on_publish_diagnostics, { underline = { severity_limit = 'Warning' }, virtual_text = { prefix = '●', spacing = 2, severity_limit = 'Warning' }, signs = { severity_limit = 'Warning' }, }) return base_config