content
stringlengths
0
1.05M
origin
stringclasses
2 values
type
stringclasses
2 values
--[[ Name: "sh_shawn_thompson_glock.lua". Product: "HL2 RP". --]] local ITEM = {}; -- Set some information. ITEM.base = "weapon_base"; ITEM.name = "Shawn Thompson's Glock"; ITEM.model = "models/weapons/w_pist_glock18.mdl"; ITEM.weight = 1.5; ITEM.uniqueID = "shawn_thompson_glock"; ITEM.weaponClass = "weapon_glock"; ITEM.description = "A small pistol with Shawn Thompson engraved into the side."; -- Register the item. kuroScript.item.Register(ITEM);
nilq/small-lua-stack
null
local dlt = require('dlt._env') local M,parent = torch.class('dlt.Model',dlt) function M:__init(modelCreate,name,save) self.name = name or 'model' self.shouldSave = (save == nil) and true or save if torch.type(self.name) ~= 'string' then dlt.log:error('Model name must be a string.') end self.name = self.name:gsub("^%l", string.upper) dlt.log:section(self.name .. ' initialization') dlt.parse(self) dlt.configure(self) if torch.type(modelCreate) == 'string' then modelCreate = dlt.help.checkHomePath(modelCreate) if not paths.filep(modelCreate) then dlt.log:error('Could not find model ' .. modelCreate) end self.model = torch.load(modelCreate) dlt.log:yell('Loaded ' .. self.name .. ' from file.'); elseif torch.type(modelCreate) == 'function' then self.model = modelCreate() dlt.log:yell('Created ' .. self.name .. '.') else dlt.log:error('dlt.Model parameter (modelCreate)' .. ' must be a string or a function.') end self:processModel() if self.parameters:size():size() ~= 0 then dlt.log:yell(string.format('%s parameters: %d.', self.name, self.parameters:size(1))) end collectgarbage() dlt.log:endSection() end function M:getCleanModel() -- Clear State self.model:clearState() -- Remove DataParallelTable self.model = torch.type(self.model) == 'nn.DataParallelTable' and self.model:get(1) or self.model -- Remove cudnn if self.useCudnn then cudnn.convert(self.model,nn) cutorch.synchronizeAll() end -- Return CPU model return self:cpu() end function M:cpu() return self.model:type('torch.' .. dlt.help.tensorList.cpu[self.tensorType]) end function M:gpu() return self.model:type('torch.' .. dlt.help.tensorList.gpu[self.tensorType]) end function M:processModel() -- First cast to cpu self:cpu() if self.nGPU > 0 then -- Convert to cudnn if self.useCudnn then cudnn.fastest = self.cudnnFastest cudnn.benchmark = self.cudnnBenchmark cudnn.verbose = self.cudnnVerbose cudnn.convert(self.model,cudnn) self:sync() end -- Transfer to gpu self:gpu() -- If multiple GPUs wrap in DataParallelTable if self.nGPU > 1 then local dpt = nn.DataParallelTable(1, self.dptFlatten,self.dptNccl) :add(self.model, torch.range(1, self.nGPU):totable()) self.model = dpt self:sync() end end -- Default to training mode self:training() -- Reflatten parameters self.parameters, self.gradParameters = self.model:getParameters() end function M:sync() if self.nGPU > 0 then cutorch.synchronizeAll() end end function M:save(filename) if self.shouldSave then torch.save(filename, self:getCleanModel()) self:processModel() end end function M:training() self.model:training() end function M:evaluate() self.model:evaluate() end function M:zeroGradParameters() self.model:zeroGradParameters() end function M:forward(input) return self.model:forward(input) end function M:backward(input,gradOutput) return self.model:backward(input,gradOutput) end function M:updateGradInput(input,gradOutput) return self.model:updateGradInput(input,gradOutput) end function M:__tostring__() return self.name .. '\n' .. self.model:__tostring() end
nilq/small-lua-stack
null
class 'platform' local AI_FALLING = 0 local AI_RIDING = 1 local ST_OFF = -1 local ST_ON = 1 local DIR_AUTO = -1 local DIR_LEFT = 1 local DIR_LEFT_UP = 2 local DIR_UP = 3 local DIR_UP_RIGHT = 4 local DIR_RIGHT = 5 local DIR_RIGHT_DOWN = 6 local DIR_DOWN = 7 local DIR_DOWN_LEFT = 8 local RAIL_DIAGONAL_1 = 74 --left-top, bottom-right local RAIL_DIAGONAL_2 = 73 --left-bottom, top-right local RAIL_HORIZONTAL = 71 local RAIL_VERTICAL = 72 local REVERSER_1 = 70 local REVERSER_2 = 100 local CHECK_DELAY = 24 function platform:initProps() self.direction = DIR_AUTO self.speed = 2 self.state = self.npc_obj.direction self.npc_obj.speedX = 0 self.npc_obj.speedY = 0 self.wasSpawned = false self.npc_obj.gravity = 0 if(self.state == ST_ON)then if(self.npc_obj.spawnedGenType ~= BaseNPC.SPAWN_APPEAR) then self.wasSpawned = true if self.npc_obj.spawnedGenDirection == BaseNPC.SPAWN_UP then self.direction = DIR_UP elseif self.npc_obj.spawnedGenDirection == BaseNPC.SPAWN_LEFT then self.direction = DIR_LEFT elseif self.npc_obj.spawnedGenDirection == BaseNPC.SPAWN_RIGHT then self.direction = DIR_RIGHT elseif self.npc_obj.spawnedGenDirection == BaseNPC.SPAWN_DOWN then self.direction = DIR_DOWN end end end self.found = false self.needCorrection = false self.lead = nil self.oldSpeedX = 0 self.oldSpeedY = 0 self.check_time_left = 0 self.watchForMaxHeight = true --Until path will be catched self.maxHeight = self.npc_obj.y self.RecentMaxHeight = self.npc_obj.y end function platform:__init(npc_obj) self.npc_obj = npc_obj self.npc_obj.maxVelX = 0.0 self.npc_obj.maxVelY = 0.0 self.contacts = npc_obj:installContactDetector() self:initProps() end function platform:onActivated() self:initProps() end function platform:findXfromY( blk, y ) local ratio = blk.width / blk.height return blk.left + ((y - blk.top) * ratio) end function platform:findYfromX( blk, x ) local ratio = blk.height / blk.width return blk.top + ((x - blk.left) * ratio) end function platform:findXfromY_R( blk, y ) local ratio = blk.width / blk.height return blk.left + blk.width - ((y - blk.top) * ratio) end function platform:lookForCorrection( blk ) self.oldSpeedX = self.npc_obj.speedX self.oldSpeedY = self.npc_obj.speedY if(blk.id==RAIL_DIAGONAL_1)then local diagonal = self:findXfromY(blk, self.npc_obj.center_y) if( self.npc_obj.center_x < diagonal)then self.npc_obj.speedX = self.npc_obj.speedX+diagonal-self.npc_obj.center_x self.needCorrection = true elseif( self.npc_obj.center_x > diagonal)then self.npc_obj.speedX = self.npc_obj.speedX+diagonal-self.npc_obj.center_x self.needCorrection = true end elseif(blk.id==RAIL_DIAGONAL_2)then local diagonal = self:findXfromY_R(blk, self.npc_obj.center_y) if( self.npc_obj.center_x < diagonal)then self.npc_obj.speedX = self.npc_obj.speedX+diagonal-self.npc_obj.center_x self.needCorrection = true elseif( self.npc_obj.center_x > diagonal)then self.npc_obj.speedX = self.npc_obj.speedX+diagonal-self.npc_obj.center_x self.needCorrection = true end elseif(blk.id==RAIL_HORIZONTAL)then if(self.npc_obj.center_y < blk.center_y)then self.npc_obj.speedY = blk.center_y-self.npc_obj.center_y self.needCorrection = true elseif(self.npc_obj.center_y > blk.center_y)then self.npc_obj.speedY = blk.center_y-self.npc_obj.center_y self.needCorrection = true end elseif(blk.id==RAIL_VERTICAL)then if(self.npc_obj.center_x < blk.center_x)then self.npc_obj.speedX = blk.center_x-self.npc_obj.center_x self.needCorrection = true elseif(self.npc_obj.center_x > blk.center_x)then self.npc_obj.speedX = blk.center_x-self.npc_obj.center_x self.needCorrection = true end end end function platform:isCollidesCenter(blk) if(blk==nil)then return false; end local speedLeft = -1 local speedRight = -1 local speedTop = -1 local speedBottom = -1 if(self.npc_obj.speedX > 0)then speedRight = 4 -- Renderer.printText("111111!", 10, 10) elseif(self.npc_obj.speedX < 0)then speedLeft = 4 -- Renderer.printText("222222!", 10, 10) else speedLeft = 4 speedRight = 4 -- Renderer.printText("333333!", 10, 10) end if(self.npc_obj.speedY > 0)then speedBottom = 4 elseif(self.npc_obj.speedY < 0)then speedTop = 4 else speedTop = 4 speedBottom = 4 end if(self.npc_obj.center_x-speedLeft > blk.right)then return false; elseif(self.npc_obj.center_x+speedRight < blk.left)then return false; elseif(self.npc_obj.center_y-speedTop > blk.bottom)then return false; elseif(self.npc_obj.center_y+speedBottom < blk.top)then return false; else return true; end end function platform:getRelativePositionH( blk ) if(self.npc_obj.center_x < blk.center_x)then return 1.0 else return -1.0 end end function platform:getRelativePositionV( blk ) if(self.npc_obj.center_y < blk.center_y)then return 1.0 else return -1.0 end end function platform:atEdge( blk, dir ) if(blk==nil)then return true end if( self.check_time_left>=0 )then return false end local radius = 4.0 if(dir == DIR_LEFT)then if(self.npc_obj.center_x < blk.left+radius and self.npc_obj.center_x >= blk.left-radius)then return true end elseif(dir == DIR_RIGHT)then if(self.npc_obj.center_x > blk.right-radius and self.npc_obj.center_x <= blk.right+radius)then return true end elseif(dir == DIR_UP)then if(self.npc_obj.center_y < blk.top-radius and self.npc_obj.center_y <= blk.top-radius)then return true end elseif(dir == DIR_DOWN)then if(self.npc_obj.center_y > blk.bottom-radius and self.npc_obj.center_y >= blk.bottom+radius)then return true end elseif(dir == DIR_LEFT_UP)then if(self.npc_obj.center_x < blk.left+radius and self.npc_obj.center_x >= blk.left-radius and self.npc_obj.center_y < blk.top-radius and self.npc_obj.center_y <= blk.top-radius )then return true end elseif(dir == DIR_UP_RIGHT)then if(self.npc_obj.center_x > blk.right-radius and self.npc_obj.center_x <= blk.right+radius and self.npc_obj.center_y < blk.top-radius and self.npc_obj.center_y <= blk.top-radius )then return true end elseif(dir == DIR_RIGHT_DOWN)then if(self.npc_obj.center_x > blk.right-radius and self.npc_obj.center_x <= blk.right+radius and self.npc_obj.center_y > blk.bottom-radius and self.npc_obj.center_y >= blk.bottom+radius )then return true end elseif(dir == DIR_DOWN_LEFT)then if(self.npc_obj.center_x < blk.left+radius and self.npc_obj.center_x >= blk.left-radius and self.npc_obj.center_y > blk.bottom-radius and self.npc_obj.center_y >= blk.bottom+radius )then return true end end return false end function platform:sameAsLead(blk) if(self.lead == nil)then return false; elseif( self.lead.id == blk.id )then -- Ignore elements of same ID return false; elseif( self.lead.center_x == blk.center_x and self.lead.center_y == blk.center_y )then return true; end return false; end function platform:isCrossesWith(blk, tbl, id) if(self.lead ~= nil)then if( self.lead.id == blk.id )then return false; end end for K,Elm in pairs(tbl) do if( ( Elm.id == id) and (Elm.center_x == blk.center_x) ) then return true; end end return false; end function platform:onLoop(tickTime) if(self.state==ST_ON)then if(self.found or self.wasSpawned)then self.wasSpawned = false if(self.needCorrection)then self.npc_obj.speedX = self.oldSpeedX self.npc_obj.speedY = self.oldSpeedY end if(self.direction==DIR_LEFT) then self.npc_obj.speedX=-self.speed self.npc_obj.speedY=0 elseif(self.direction==DIR_LEFT_UP) then self.npc_obj.speedX=-self.speed self.npc_obj.speedY=-self.speed elseif(self.direction==DIR_UP) then self.npc_obj.speedX=0 self.npc_obj.speedY=-self.speed elseif(self.direction==DIR_UP_RIGHT) then self.npc_obj.speedX=self.speed self.npc_obj.speedY=-self.speed elseif(self.direction==DIR_RIGHT) then self.npc_obj.speedX=self.speed self.npc_obj.speedY=0 elseif(self.direction==DIR_RIGHT_DOWN) then self.npc_obj.speedX=self.speed self.npc_obj.speedY=self.speed elseif(self.direction==DIR_DOWN) then self.npc_obj.speedX=0 self.npc_obj.speedY=self.speed elseif(self.direction==DIR_DOWN_LEFT) then self.npc_obj.speedX=-self.speed self.npc_obj.speedY=self.speed else self.npc_obj.gravity = 1.0 end end if( self.check_time_left>=0 )then self.check_time_left = self.check_time_left-tickTime else -- self.check_time_left=CHECK_DELAY local RecentDirection = self.direction if(self.contacts:detected())then local bgos= self.contacts:getBGOs() local usefulBGOs = {} local byTypes = {} byTypes[RAIL_DIAGONAL_1] = 0 byTypes[RAIL_DIAGONAL_2] = 0 byTypes[RAIL_HORIZONTAL] = 0 byTypes[RAIL_VERTICAL] = 0 byTypes[REVERSER_1] = 0 byTypes[REVERSER_2] = 0 local isAtEdge = false self.found=false local countOfUSeful = 0 for K,Blk in pairs(bgos) do if( self:isCollidesCenter(Blk) and ( Blk.id == RAIL_DIAGONAL_1 or Blk.id == RAIL_DIAGONAL_2 or Blk.id == RAIL_HORIZONTAL or Blk.id == RAIL_VERTICAL or Blk.id == REVERSER_1 or Blk.id == REVERSER_2 ) ) then countOfUSeful = countOfUSeful+1 usefulBGOs[countOfUSeful] = Blk byTypes[Blk.id] = byTypes[Blk.id] + 1 end end if(self.lead~=nil)then isAtEdge = (self:atEdge(self.lead, self.direction) and countOfUSeful <= 2) -- Renderer.printText("Count Of elements: "..tostring(self.lead.id), 10, 40) end -- Renderer.printText("Count Of elements: "..tostring(countOfUSeful).. " "..tostring(isAtEdge), 10, 10) for K,Blk in pairs(usefulBGOs) do -- if(self:isCollidesCenter(Blk)) then countOfUSeful = countOfUSeful+1 local isNSameAsLead = not self:sameAsLead(Blk); if(Blk.id==RAIL_DIAGONAL_1 and isNSameAsLead and self.direction~=DIR_UP_RIGHT and self.direction~=DIR_DOWN_LEFT )then self.found=true self.lead = Blk -- X<0 if( (self.npc_obj.speedX < 0) and (self.npc_obj.speedY == 0) )then self.direction = DIR_LEFT_UP -- X>0 elseif( (self.npc_obj.speedX > 0) and (self.npc_obj.speedY == 0) )then self.direction = DIR_RIGHT_DOWN -- Y<0 elseif( (self.npc_obj.speedX == 0) and (self.npc_obj.speedY < 0) )then self.direction = DIR_LEFT_UP -- Y>0 elseif( (self.npc_obj.speedX == 0) and (self.npc_obj.speedY > 0) )then self.direction = DIR_RIGHT_DOWN -- X<0 Y<0 elseif( (self.npc_obj.speedX < 0) and (self.npc_obj.speedY < 0) )then self.direction = DIR_LEFT_UP -- X>0 Y>0 elseif( (self.npc_obj.speedX > 0) and (self.npc_obj.speedY > 0) )then self.direction = DIR_RIGHT_DOWN -- X>0 Y<0 elseif( (self.npc_obj.speedX > 0) and (self.npc_obj.speedY < 0) and ( math.abs(self.npc_obj.speedY) > math.abs(self.npc_obj.speedX) ) )then self.direction = DIR_LEFT_UP elseif( (self.npc_obj.speedX > 0) and (self.npc_obj.speedY < 0) and ( math.abs(self.npc_obj.speedY) < math.abs(self.npc_obj.speedX) ) )then self.direction = DIR_RIGHT_DOWN -- X<0 Y>0 elseif( (self.npc_obj.speedX < 0) and (self.npc_obj.speedY > 0) and ( math.abs(self.npc_obj.speedY) < math.abs(self.npc_obj.speedX) ) )then self.direction = DIR_LEFT_UP elseif( (self.npc_obj.speedX < 0) and (self.npc_obj.speedY > 0) and ( math.abs(self.npc_obj.speedY) > math.abs(self.npc_obj.speedX) ) )then self.direction = DIR_RIGHT_DOWN else self.direction = DIR_RIGHT_DOWN end self:lookForCorrection(Blk) elseif(Blk.id==RAIL_DIAGONAL_2 and isNSameAsLead and self.direction~=DIR_LEFT_UP and self.direction~=DIR_RIGHT_DOWN)then self.found=true self.lead = Blk -- X<0 if( (self.npc_obj.speedX < 0) and (self.npc_obj.speedY == 0) )then self.direction = DIR_DOWN_LEFT -- X>0 elseif( (self.npc_obj.speedX > 0) and (self.npc_obj.speedY == 0) )then self.direction = DIR_UP_RIGHT -- Y<0 elseif( (self.npc_obj.speedX == 0) and (self.npc_obj.speedY < 0) )then self.direction = DIR_UP_RIGHT -- Y>0 elseif( (self.npc_obj.speedX == 0) and (self.npc_obj.speedY > 0) )then self.direction = DIR_DOWN_LEFT -- X<0 Y>0 elseif( (self.npc_obj.speedX < 0) and (self.npc_obj.speedY > 0) )then self.direction = DIR_DOWN_LEFT -- X>0 Y<0 elseif( (self.npc_obj.speedX > 0) and (self.npc_obj.speedY < 0) )then self.direction = DIR_UP_RIGHT -- X<0 Y<0 elseif( (self.npc_obj.speedX < 0) and (self.npc_obj.speedY < 0) and ( math.abs(self.npc_obj.speedY) > math.abs(self.npc_obj.speedX) ) )then self.direction = DIR_UP_RIGHT elseif( (self.npc_obj.speedX < 0) and (self.npc_obj.speedY < 0) and ( math.abs(self.npc_obj.speedY) < math.abs(self.npc_obj.speedX) ) )then self.direction = DIR_DOWN_LEFT -- X>0 Y>0 elseif( (self.npc_obj.speedX > 0) and (self.npc_obj.speedY > 0) and ( math.abs(self.npc_obj.speedY) > math.abs(self.npc_obj.speedX) ) )then self.direction = DIR_DOWN_LEFT elseif( (self.npc_obj.speedX > 0) and (self.npc_obj.speedY > 0) and ( math.abs(self.npc_obj.speedY) < math.abs(self.npc_obj.speedX) ) )then self.direction = DIR_UP_RIGHT else self.direction = DIR_UP_RIGHT end self:lookForCorrection(Blk) elseif(Blk.id==RAIL_HORIZONTAL and (not self:isCrossesWith(Blk, usefulBGOs, RAIL_VERTICAL) ) and ((self.direction~=DIR_UP and self.direction~=DIR_DOWN) or (isNSameAsLead and isAtEdge --or (self:atEdge(Blk, DIR_LEFT) or self:atEdge(Blk, DIR_RIGHT) and byTypes[RAIL_HORIZONTAL]<=1 and byTypes[RAIL_VERTICAL]<=1 ) ) )then self.found=true self.lead = Blk if( self.npc_obj.speedX > 0 ) then self.direction=DIR_RIGHT elseif(self.npc_obj.speedX < 0)then self.direction=DIR_LEFT else if( self:getRelativePositionH( Blk ) == 1 )then self.direction=DIR_RIGHT else self.direction=DIR_LEFT end end self:lookForCorrection(Blk) elseif(Blk.id==RAIL_VERTICAL and (not self:isCrossesWith(Blk, usefulBGOs, RAIL_HORIZONTAL) ) and ((self.direction~=DIR_LEFT and self.direction~=DIR_RIGHT) or (isNSameAsLead and isAtEdge --or (self:atEdge(Blk, DIR_UP) or self:atEdge(Blk, DIR_DOWN) and byTypes[RAIL_HORIZONTAL]<=1 and byTypes[RAIL_VERTICAL]<=1 ) ) )then self.found=true self.lead = Blk if(self.npc_obj.speedY>0)then self.direction=DIR_DOWN elseif(self.npc_obj.speedY<0)then self.direction=DIR_UP else if( self:getRelativePositionV( Blk ) == 1 )then self.direction=DIR_DOWN else self.direction=DIR_UP end end self:lookForCorrection(Blk) elseif(Blk.id==REVERSER_1 or Blk.id==REVERSER_2)then -- self.found=true if(self.direction==DIR_LEFT) then self.direction=DIR_RIGHT elseif(self.direction==DIR_LEFT_UP) then self.direction=DIR_RIGHT_DOWN elseif(self.direction==DIR_UP) then self.direction=DIR_DOWN elseif(self.direction==DIR_UP_RIGHT) then self.direction=DIR_DOWN_LEFT elseif(self.direction==DIR_RIGHT) then self.direction=DIR_LEFT elseif(self.direction==DIR_RIGHT_DOWN) then self.direction=DIR_LEFT_UP elseif(self.direction==DIR_DOWN) then self.direction=DIR_UP elseif(self.direction==DIR_DOWN_LEFT) then self.direction=DIR_UP_RIGHT end self.npc_obj.speedX = -self.npc_obj.speedX --math.abs(Blk.top-self.npc_obj.bottom) if(self.watchForMaxHeight)then if(self.RecentMaxHeight < self.maxHeight)then self.npc_obj.speedY = -self.npc_obj.speedY+(math.abs(Blk.top-self.npc_obj.bottom)+math.abs(self.npc_obj.speedY))/65.42 else self.npc_obj.speedY = -self.npc_obj.speedY end self.RecentMaxHeight = self.npc_obj.y else self.npc_obj.speedY = -self.npc_obj.speedY +(math.abs(self.npc_obj.speedY))/(1000.0/15.285) end if(self.direction~=DIR_AUTO)then self.check_time_left = CHECK_DELAY else self.check_time_left = CHECK_DELAY/math.abs(self.npc_obj.speedY) end end -- end end if(self.found)then self.npc_obj.gravity = 0.0 self.watchForMaxHeight = false else self.npc_obj.gravity = 1.0 self.direction=DIR_AUTO self.lead = nil end end if(self.watchForMaxHeight)then if(self.npc_obj.y<self.RecentMaxHeight)then self.RecentMaxHeight = self.npc_obj.y end end if(RecentDirection ~= self.direction)then self.check_time_left=CHECK_DELAY end end else self.npc_obj.speedX=0 self.npc_obj.speedY=0 if(self.contacts:detected())then local plrs = self.contacts:getPlayers() for K,Plr in pairs(plrs) do if(Plr.bottom == self.npc_obj.top and Plr.onGround)then self.state=ST_ON end end end end -- Renderer.printText("PF:".." I:"..tostring(self.found).." X: "..tostring(self.npc_obj.speedX).." Y: "..tostring(self.npc_obj.speedY), 10, 80) end return platform
nilq/small-lua-stack
null
-- --[[ ---> 插件处理器基础类 -------------------------------------------------------------------------- ---> 参考文献如下 -----> / -- from https://github.com/Mashape/kong/blob/master/kong/plugins/base_plugin.lua ----------------------------------------------------------------------------------------------------------------- --[[ ---> 统一函数指针 --]] local require = require local s_format = string.format local n_var = ngx.var local n_err = ngx.ERR local n_info = ngx.INFO local n_debug = ngx.DEBUG -------------------------------------------------------------------------- --[[ ---> 统一引用导入APP-LIBS --]] -------------------------------------------------------------------------- -----> 基础库引用 local r_http = require("resty.http") -----> 工具引用 local m_base = require("app.model.base_model") local u_request = require("app.utils.request") local u_context = require("app.utils.context") -----> 外部引用 -- -----> 必须引用 -- -----> 业务引用 local r_plugin = require("app.model.repository.plugin_repo") -------------------------------------------------------------------------- --[[ ---> 实例信息及配置 --]] local handler = m_base:extend() -------------------------------------------------------------------------- handler.utils.handle = require("app.utils.handle") handler.utils.judge = require("app.utils.judge") handler.utils.extractor = require("app.utils.extractor") -------------------------------------------------------------------------- --[[ ---> 实例构造器 ------> 子类构造器中,必须实现 handler.super.new(self, self._name) or handler.super.new(self, self._conf, self.store, self._name) --]] function handler:new(conf, store, name, opts) if type(conf) == "string" and not store and not name then name = conf conf = nil store = nil end -- 传导值进入父类 handler.super.new(self, conf, store, name, opts) -- 重新转向缓存 self._cache_using = self._store.cache.using -- 当前缓存构造器 self._cache = self._store.plugin -- 获取基本请求信息抓取对象 self._request = u_request(self._name) -- 引用 self.model = { current_repo = r_plugin(conf, store, self._source), ref_repo = { } } end -------------------------------------------------------------------------- -- 加载下游配置文件 function handler:_load_remote(node, method, headers, url, args) -- local content_type = ngx.req.get_headers(0)["Content-Type"] -- ngx.req.set_header("Content-Type", "application/x-www-form-urlencoded") -- local res, err = ngx.location.capture("/capture_proxy", { -- method = ngx.HTTP_POST, -- body = args, -- vars = { -- capture_proxy_host = host, -- capture_proxy_uri = uri -- } -- }) -- ngx.req.set_header("Content-Type", content_type) -- local body = res.status == ngx.HTTP_OK and res.body local http = r_http.new() args = self.utils.json.encode(args) -- args = u_json.to_url_param(args) headers["content-length"] = string.len(args) local res, err = http:request_uri(url, { method = method, body = args, headers = headers }) local body = "" if res then body = res.body ngx.status = res.status end if not self.utils.object.check(body) or err then self._log.err("[%s-match-%s:error]communication -> url: %s, args: %s, status: %s, err: %s, resp: %s", self._name, node, url, args, res and res.status, err, body) return { res = false, status = ngx.status, node = node, msg = err, ec = self.utils.ex.error.EVENT_CODE.api_err } end local resp_body = self.utils.json.decode(body) if not self.utils.object.check(resp_body) then self._log.err("[%s-match-%s:error]parse json from url: '%s' faild, maybe the url is wrong or the resp it's not formated -> refer to resp: %s", self._name, node, url, body) return { res = false, status = ngx.status, node = node, msg = "body can't decode", ec = self.utils.ex.error.EVENT_CODE.api_err } end return resp_body end -- 通过响应配置文件,获取打印信息 function handler:_get_print_from_ctrl(ctrl_conf, else_conf, ignore_event_code) if self.utils.object.check(ctrl_conf.res) then return nil end -- 请求状态错误,直接转换显示 if ctrl_conf.status then return { res = false, ec = self.utils.ex.error.EVENT_CODE.api_err, msg = "服务器升级中,请稍后再试", desc = ctrl_conf.msg, status = ctrl_conf.status } end -- 业务逻辑错误,直接转换成print if not ignore_event_code and (ctrl_conf.ec and ctrl_conf.ec ~= 0) then self._log.err("remote ctrl raise error: %s, uri: %s, request_uri: %s", self.utils.json.encode(ctrl_conf), n_var.uri, n_var.request_uri) return ctrl_conf end -- 未被授权 return else_conf end -------------------------------------------------------------------------- -- 覆写日志函数 function handler:check_rule_log(rule) rule = (type(rule) == "boolean" and { handle = { log = rule } }) or rule return rule and self.utils.object.check(rule.handle.log) end function handler:rule_log_err(rule, text) if self:check_rule_log(rule) then return self._log.err("=====[%s][%s] -> %s", self._name, self._request.get_client_type(), text) end end function handler:rule_log_info(rule, text) if self:check_rule_log(rule) then return self._log.info("=====[%s][%s] -> %s", self._name, self._request.get_client_type(), text) end end function handler:rule_log_debug(rule, text) if self:check_rule_log(rule) then return self._log.debug("=====[%s][%s] -> %s", self._name, self._request.get_client_type(), text) end end -------------------------------------------------------------------------- function handler:_rule_action(rule, pass_func, rule_failure_func) local pass, conditions_matched = false, {} if rule.enable then -- judge阶段 pass, conditions_matched = self.utils.judge.judge_rule(rule, self._name) -- extract阶段 local variables = self.utils.extractor.extract_variables(rule.extractor) local is_log = rule.handle.log == true -- handle阶段 if pass then self:rule_log_info(is_log, s_format("*****[%s-MATCH-RULE] %s*****: conditions_matched: %s, host: %s, uri: %s", self._name, rule.name, self.utils.json.encode(conditions_matched), n_var.host, n_var.request_uri)) if pass_func then pass_func(self, rule, variables, conditions_matched) else self:rule_log_err(is_log, s_format("*****[%s-MATCH-RULE] %s*****: not contains [action], host: %s, uri: %s", self._name, rule.name, n_var.host, n_var.request_uri)) end else self:rule_log_debug(is_log, s_format("*****[%s-NOT_MATCH-RULE]*****: host: %s, uri: %s", self._name, rule.name, n_var.host, n_var.request_uri)) end end return pass, conditions_matched end --[[ ---> 当前插件具备一定特殊性,重写父类规则 --]] function handler:_stop_check(continue, check_passed) if type(continue) ~= "boolean" then local switch = { -- 匹配则略过后续规则 [0] = function ( ) return check_passed end } local _switch_stop_check = switch[continue or 0] if _switch_stop_check then return _switch_stop_check() end end return not continue --handler.super._stop_check(self, rule, check_passed) end -------------------------------------------------------------------------- function handler:get_name() return self._name end function handler:combine_micro_handle_by_rule(rule, variables) local n_var_uri = n_var.uri local n_var_host = n_var.host local handle = rule.handle if rule.type == 1 then if handle.micro then local micro = self.model.current_repo:get_rule("micros", handle.micro) if not micro or not micro.value then self:rule_log_err(rule, self.format("[%s-%s] can not find micro '%s'. host: %s, uri: %s", self._name, rule.name, handle.micro, n_var_host, n_var_uri)) return end local micro_value = self.utils.json.decode(micro.value) if not micro_value or not micro_value.handle then self:rule_log_err(rule, self.format("[%s-%s] can not parser micro '%s' from value '%s'. host: %s, uri: %s", self._name, rule.name, handle.micro, micro_value, n_var_host, n_var_uri)) return end handle = micro_value.handle else handle = {} end end local extractor_type = rule.extractor.type local handle_host = handle.host if not handle_host or handle_host == "" then -- host默认取请求的host handle_host = n_var_host else handle_host = self.utils.handle.build_upstream_host(extractor_type, handle_host, variables, self._name) end handle.host = handle_host handle.url = self.utils.handle.build_upstream_url(extractor_type, handle.url, variables, self._name) self:rule_log_info(rule, self.format("[%s-%s] extractor_type: %s, host: %s, url: %s", self._name, rule.name, extractor_type, handle.host, handle.url)) return handle end function handler:check_exec_rule( rules, rule_pass_func) local rule_stop = false local rule_passed, conditions_matched = false self.utils.each.array_action(rules, function ( _, rule ) -- 指示规则验证通过 rule_passed, conditions_matched = self:_rule_action(rule, rule_pass_func) rule_stop = self:_stop_check(rule.handle.continue, rule_passed) -- 匹配到插件 或 略过后续规则时跳出 return not rule_stop -- 循环跳出,each接受false时才会跳出 end) return rule_stop or rule_passed end function handler:exec_action( rule_pass_func, rule_failure_func ) if not rule_pass_func then return end local enable = ngx.ctx[s_format("_plugin_%s.enable", self._name)] local meta = ngx.ctx[s_format("_plugin_%s.meta", self._name)] local selectors = ngx.ctx[s_format("_plugin_%s.selectors", self._name)] local ordered_selectors = meta and meta.selectors if not self.utils.object.check(enable) or not meta or not ordered_selectors or not selectors then return end self.utils.each.array_action(ordered_selectors, function ( i, sid ) self:rule_log_debug(is_log, s_format("[CHECK THROUGH SELECTOR: %s]", sid)) local selector = selectors[sid] if selector and selector.enable == true then local selector_pass if selector.type == 0 then -- 全流量选择器 selector_pass = true else selector_pass = self.utils.judge.judge_selector(selector, self._name)-- selector judge end local rule_stop = false local is_log = selector.handle and selector.handle.log == true if selector_pass then self:rule_log_info(is_log, s_format("[PASS-SELECTOR: %s(%s)] uri: %s", selector.name, sid, n_var.uri)) local rules = ngx.ctx[s_format("_plugin_%s.selector.%s.rules", self._name, sid)] if rules and type(rules) == "table" and #rules > 0 then rule_stop = self:check_exec_rule(rules, rule_pass_func) -- 不再执行此插件其他逻辑 return not rule_stop end else self:rule_log_debug(is_log, s_format("[NOT-PASS-SELECTOR: %s] %s", sid, n_var.uri)) end -- if continue or break the loop return not self:_stop_check(selector.handle and selector.handle.continue, rule_stop) -- 跳过当前插件的后续选择器 end end) end -------------------------------------------------------------------------- function handler:exec_filter(filter_action) if not filter_action or not u_request:check_context_content_type_can_be_filter() then return end local chunk, eof = ngx.arg[1] or "", ngx.arg[2] -- 获取当前的流 和是否时结束 local info = ngx.ctx.tmp_body if info then ngx.ctx.tmp_body = info .. chunk -- 这个可以将原本的内容记录下来 else ngx.ctx.tmp_body = chunk end if eof then filter_action(ngx.ctx.tmp_body) else ngx.arg[1] = nil -- 这里是为了将原本的输出不显示 end end -------------------------------------------------------------------------- -- 该函数解决在执行阶段上下文不适配REDIS缓存的问题 function handler:_init_cache_to_ctx() local enable_cache_name = s_format("%s.enable", self._name) local enable = self._cache:get_bool(enable_cache_name) ngx.ctx["_plugin_"..enable_cache_name] = enable local meta_cache_name = s_format("%s.meta", self._name) local meta = self._cache:get_json(meta_cache_name) ngx.ctx["_plugin_"..meta_cache_name] = meta local selectors_cache_name = s_format("%s.selectors", self._name) local selectors = self._cache:get_json(selectors_cache_name) ngx.ctx["_plugin_"..selectors_cache_name] = selectors local ordered_selectors = meta and meta.selectors if not self.utils.object.check(enable) or not meta or not ordered_selectors or not selectors then return end for i, sid in ipairs(ordered_selectors) do self:rule_log_debug(is_log, s_format("[PASS THROUGH SELECTOR: %s]", sid)) local selector = selectors[sid] if selector and selector.enable == true then local rules_cache_name = s_format("%s.selector.%s.rules", self._name, sid) local rules = self._cache:get_json(rules_cache_name) ngx.ctx["_plugin_"..rules_cache_name] = rules end end end function handler:init_worker() self._slog.debug("executing plugin %s: init_worker", self._name) end function handler:redirect() self._log.debug("executing plugin %s: redirect", self._name) end function handler:rewrite() self._log.debug("executing plugin %s: rewrite", self._name) end function handler:access() self._log.debug("executing plugin %s: access", self._name) end function handler:header_filter() self._log.debug("executing plugin %s: header_filter", self._name) end function handler:body_filter() --[[ Nginx 的 upstream 相关模块,以及 OpenResty 的 content_by_lua,会单独发送一个设置了 last_buf 的空 buffer来表示流的结束。 这算是一个约定俗成的惯例,所以有必要在运行相关逻辑之前,检查 ngx.arg[1] 是否为空。 当然反过来不一定成立,ngx.arg[2] == true 并不代表 ngx.arg[1] 一定为空。 严格意义上,如果只希望 body_filter_by_lua* 修改响应给客户端的内容,需要额外用 ngx.is_subrequest 判断下 ]]-- local is_normal_request = self.utils.object.check(ngx.arg[1]) and not ngx.is_subrequest if not is_normal_request then return end self._log.debug("executing plugin %s: body_filter", self._name) end function handler:log() self._log.debug("executing plugin %s: log", self._name) end -------------------------------------------------------------------------- return handler
nilq/small-lua-stack
null
require 'pl' local __FILE__ = (function() return string.gsub(debug.getinfo(2, 'S').source, "^@", "") end)() package.path = path.join(path.dirname(__FILE__), "..", "lib", "?.lua;") .. package.path require 'sys' require 'w2nn' local iproc = require 'iproc' local reconstruct = require 'reconstruct' local image_loader = require 'image_loader' local CONV_LAYERS = {"nn.SpatialConvolutionMM", "cudnn.SpatialConvolution", "nn.SpatialFullConvolution", "cudnn.SpatialFullConvolution" } local ACTIVATION_LAYERS = {"nn.ReLU", "nn.LeakyReLU", "w2nn.LeakyReLU", "cudnn.ReLU", "nn.SoftMax", "cudnn.SoftMax" } local function includes(s, a) for i = 1, #a do if s == a[i] then return true end end return false end local function count_conv_layers(seq) local count = 0 for k = 1, #seq.modules do local mod = seq.modules[k] local name = torch.typename(mod) if name == "nn.ConcatTable" or includes(name, CONV_LAYERS) then count = count + 1 end end return count end local function strip_conv_layers(seq, limit) local new_seq = nn.Sequential() local count = 0 for k = 1, #seq.modules do local mod = seq.modules[k] local name = torch.typename(mod) if name == "nn.ConcatTable" or includes(name, CONV_LAYERS) then new_seq:add(mod) count = count + 1 if count == limit then if seq.modules[k+1] ~= nil and includes(torch.typename(seq.modules[k+1]), ACTIVATION_LAYERS) then new_seq:add(seq.modules[k+1]) end return new_seq end else new_seq:add(mod) end end return new_seq end local function save_layer_outputs(x, model, out) local count = count_conv_layers(model) print("conv layer count", count) local output_file = path.join(out, string.format("layer-%d.png", 0)) image.save(output_file, x) print("* save layer output " .. 0 .. ": " .. output_file) for i = 1, count do output_file = path.join(out, string.format("layer-%d.png", i)) print("* save layer output " .. i .. ": " .. output_file) local test_model = strip_conv_layers(model, i) test_model:cuda() test_model:evaluate() local z = test_model:forward(x:reshape(1, x:size(1), x:size(2), x:size(3)):cuda()):float() z = z:reshape(z:size(2), z:size(3), z:size(4)) -- drop batch dim z = image.toDisplayTensor({input=z, padding=2}) image.save(output_file, z) collectgarbage() end end local cmd = torch.CmdLine() cmd:text() cmd:text("waifu2x - visualize layer output") cmd:text("Options:") cmd:option("-i", "images/miku_small.png", 'path to input image') cmd:option("-scale", 2, 'scale factor') cmd:option("-o", "./layer_outputs", 'path to output dir') cmd:option("-model_dir", "./models/upconv_7/art", 'path to model directory') cmd:option("-name", "user", 'model name for user method') cmd:option("-m", "noise_scale", 'method (noise|scale|noise_scale|user)') cmd:option("-noise_level", 1, '(1|2|3)') cmd:option("-force_cudnn", 0, 'use cuDNN backend (0|1)') cmd:option("-gpu", 1, 'Device ID') local opt = cmd:parse(arg) cutorch.setDevice(opt.gpu) opt.force_cudnn = opt.force_cudnn == 1 opt.model_path = path.join(opt.model_dir, string.format("%s_model.t7", opt.name)) local x, meta = image_loader.load_float(opt.i) if x:size(2) > 256 or x:size(3) > 256 then error(string.format("input image is too large: %dx%d", x:size(3), x:size(2))) end local model = nil local new_x = nil if opt.m == "noise" then local model_path = path.join(opt.model_dir, ("noise%d_model.t7"):format(opt.noise_level)) model = w2nn.load_model(model_path, opt.force_cudnn) if not model then error("Load Error: " .. model_path) end elseif opt.m == "scale" then local model_path = path.join(opt.model_dir, ("scale%.1fx_model.t7"):format(opt.scale)) model = w2nn.load_model(model_path, opt.force_cudnn) if not model then error("Load Error: " .. model_path) end elseif opt.m == "noise_scale" then local model_path = path.join(opt.model_dir, ("noise%d_scale%.1fx_model.t7"):format(opt.noise_level, opt.scale)) model = w2nn.load_model(model_path, opt.force_cudnn) elseif opt.m == "user" then local model_path = opt.model_path model = w2nn.load_model(model_path, opt.force_cudnn) if not model then error("Load Error: " .. model_path) end else error("undefined method:" .. opt.method) end assert(model ~= nil) assert(x ~= nil) dir.makepath(opt.o) save_layer_outputs(x, model, opt.o)
nilq/small-lua-stack
null
#!/bin/sh _=[[ exec lua "$0" "$@" ]] --[[============================================================ --= --= LuaPreprocess command line program --= by Marcus 'ReFreezed' Thunström --= --= Requires preprocess.lua to be in the same folder! --= --= License: MIT (see the bottom of this file) --= Website: http://luapreprocess.refreezed.com/ --= --= Tested with Lua 5.1, 5.2, 5.3 and 5.4. --= --============================================================== Script usage: lua preprocess-cl.lua [options] [--] filepath1 [filepath2 ...] OR lua preprocess-cl.lua --outputpaths [options] [--] inputpath1 outputpath1 [inputpath2 outputpath2 ...] Examples: lua preprocess-cl.lua --saveinfo=logs/info.lua --silent src/main.lua2p src/network.lua2p lua preprocess-cl.lua --debug src/main.lua2p src/network.lua2p lua preprocess-cl.lua --outputpaths --linenumbers src/main.lua2p output/main.lua src/network.lua2p output/network.lua Options: --backtickstrings Enable the backtick (`) to be used as string literal delimiters. Backtick strings don't interpret any escape sequences and can't contain other backticks. --data|-d="Any data." A string with any data. If this option is present then the value will be available through the global 'dataFromCommandLine' in the processed files (and any message handler). Otherwise, 'dataFromCommandLine' is nil. --faststrings Force fast serialization of string values. (Non-ASCII characters will look ugly.) --handler|-h=pathToMessageHandler Path to a Lua file that's expected to return a function or a table of functions. If it returns a function then it will be called with various messages as it's first argument. If it's a table, the keys should be the message names and the values should be functions to handle the respective message. (See 'Handler messages' and tests/testHandler.lua) The file shares the same environment as the processed files. --jitsyntax Allow LuaJIT-specific syntax, specifically literals for 64-bit integers and complex numbers. (https://luajit.org/ext_ffi_api.html#literals) --linenumbers Add comments with line numbers to the output. --meta Output the metaprogram to a temporary file (*.meta.lua). Useful if an error happens when the metaprogram runs. This file is removed if there's no error and --debug isn't enabled. --nogc Stop the garbage collector. This may speed up the preprocessing. --nonil Disallow !(...) and outputValue(...) from outputting nil. --novalidate Disable validation of outputted Lua. --outputextension=fileExtension Specify what file extension generated files should have. The default is "lua". If any input files end in .lua then you must specify another file extension with this option. (It's suggested that you use .lua2p (as in "Lua To Process") as extension for unprocessed files.) --outputpaths|-o This flag makes every other specified path be the output path for the previous path. --saveinfo|-i=pathToSaveProcessingInfoTo Processing information includes what files had any preprocessor code in them, and things like that. The format of the file is a lua module that returns a table. Search this file for 'SavedInfo' to see what information is saved. --silent Only print errors to the console. --debug Enable some preprocessing debug features. Useful if you want to inspect the generated metaprogram (*.meta.lua). (This also enables the --meta option.) -- Stop options from being parsed further. Needed if you have paths starting with "-". ---------------------------------------------------------------- Handler messages: "init" Sent before any other message. Arguments: inputPaths: Array of file paths to process. Paths can be added or removed freely. outputPaths: If the --outputpaths option is present this is an array of output paths for the respective path in inputPaths, otherwise it's nil. "insert" Sent for each @insert"name" statement. The handler is expected to return a Lua code string. Arguments: path: The file being processed. name: The name of the resource to be inserted (could be a file path or anything). "beforemeta" Sent before a file's metaprogram runs. Arguments: path: The file being processed. "aftermeta" Sent after a file's metaprogram has produced output (before the output is written to a file). Arguments: path: The file being processed. luaString: The produced Lua code. You can modify this and return the modified string. "filedone" Sent after a file has finished processing and the output written to file. Arguments: path: The file being processed. outputPath: Where the output of the metaprogram was written. info: Info about the processed file. (See 'ProcessInfo' in preprocess.lua) "fileerror" Sent if an error happens while processing a file (right before the program exits). Arguments: path: The file being processed. error: The error message. --============================================================]] local startTime = os.time() local startClock = os.clock() local args = arg local major, minor = _VERSION:match"Lua (%d+)%.(%d+)" if not major then io.stderr:write("[LuaPreprocess] Warning: Could not detect Lua version.\n") -- Note: This line does not obey the --silent option. else major = tonumber(major) minor = tonumber(minor) end local IS_LUA_51 = (major == 5 and minor == 1) local IS_LUA_52 = (major == 5 and minor == 2) local IS_LUA_53 = (major == 5 and minor == 3) local IS_LUA_51_OR_LATER = (major == 5 and minor >= 1) or (major ~= nil and major > 5) local IS_LUA_52_OR_LATER = (major == 5 and minor >= 2) or (major ~= nil and major > 5) local IS_LUA_53_OR_LATER = (major == 5 and minor >= 3) or (major ~= nil and major > 5) if not args[0] then error("Expected to run from the Lua interpreter.") end local pp = dofile((args[0]:gsub("[^/\\]+$", "preprocess.lua"))) -- From args: local addLineNumbers = false local allowBacktickStrings = false local allowJitSyntax = false local canOutputNil = true local customData = nil local fastStrings = false local hasOutputExtension = false local hasOutputPaths = false local isDebug = false local outputExtension = "lua" local outputMeta = false local processingInfoPath = "" local silent = false local validate = true --============================================================== --= Local Functions ============================================ --============================================================== local errorLine local F, formatBytes, formatInt local loadLuaFile local printf, printfNoise, printError, printfError F = string.format function formatBytes(n) if n >= 1024*1024*1024 then return F("%.2f GiB", n/(1024*1024*1024)) elseif n >= 1024*1024 then return F("%.2f MiB", n/(1024*1024)) elseif n >= 1024 then return F("%.2f KiB", n/(1024)) elseif n == 1 then return F("1 byte", n) else return F("%d bytes", n) end end -- function formatInt(n) -- return -- F("%.0f", n) -- :reverse() -- :gsub("%d%d%d", "%0,") -- :gsub(",$", ""):gsub(",%-$", "-") -- :reverse() -- end function printf(s, ...) print(s:format(...)) end printfNoise = printf function printError(s) io.stderr:write(s, "\n") end function printfError(s, ...) io.stderr:write(s:format(...), "\n") end function errorLine(err) printError(pp.tryToFormatError(err)) os.exit(1) end if IS_LUA_52_OR_LATER then function loadLuaFile(path, env) return loadfile(path, "bt", env) end else function loadLuaFile(path, env) local mainChunk, err = loadfile(path) if not mainChunk then return mainChunk, err end if env then setfenv(mainChunk, env) end return mainChunk end end --============================================================== --= Preprocessor Script ======================================== --============================================================== io.stdout:setvbuf("no") io.stderr:setvbuf("no") math.randomseed(os.time()) -- In case math.random() is used anywhere. math.random() -- Must kickstart... local processOptions = true local messageHandlerPath = "" local pathsIn = {} local pathsOut = {} for _, arg in ipairs(args) do if not (processOptions and arg:find"^%-") then local paths = (hasOutputPaths and #pathsOut < #pathsIn and pathsOut or pathsIn) table.insert(paths, arg) elseif arg == "--" then processOptions = false elseif arg:find"^%-%-data=" or arg:find"^%-d=" then customData = arg:match"^%-%-data=(.*)$" or arg:match"^%-d=(.*)$" elseif arg == "--backtickstrings" then allowBacktickStrings = true elseif arg == "--debug" then isDebug = true outputMeta = true elseif arg:find"^%-%-handler=" or arg:find"^%-h=" then messageHandlerPath = arg:match"^%-%-handler=(.*)$" or arg:match"^%-h=(.*)$" elseif arg == "--jitsyntax" then allowJitSyntax = true elseif arg == "--linenumbers" then addLineNumbers = true elseif arg == "--meta" then outputMeta = true elseif arg == "--nonil" then canOutputNil = false elseif arg == "--novalidate" then validate = false elseif arg:find"^%-%-outputextension=" then if hasOutputPaths then errorLine("Cannot specify both --outputextension and --outputpaths") end hasOutputExtension = true outputExtension = arg:match"^%-%-outputextension=(.*)$" elseif arg == "--outputpaths" or arg == "-o" then if hasOutputExtension then errorLine("Cannot specify both --outputpaths and --outputextension") elseif pathsIn[1] then errorLine(arg.." must appear before any path.") end hasOutputPaths = true elseif arg:find"^%-%-saveinfo=" or arg:find"^%-i=" then processingInfoPath = arg:match"^%-%-saveinfo=(.*)$" or arg:match"^%-i=(.*)$" elseif arg == "--silent" then silent = true elseif arg == "--faststrings" then fastStrings = true elseif arg == "--nogc" then collectgarbage("stop") else errorLine("Unknown option '"..arg:gsub("=.*", "").."'.") end end if silent then printfNoise = function()end end local header = "= LuaPreprocess v"..pp.VERSION..os.date(", %Y-%m-%d %H:%M:%S =", startTime) printfNoise(("="):rep(#header)) printfNoise("%s", header) printfNoise(("="):rep(#header)) if hasOutputPaths and #pathsOut < #pathsIn then errorLine("Missing output path for "..pathsIn[#pathsIn]) end -- Prepare metaEnvironment. pp.metaEnvironment.dataFromCommandLine = customData -- May be nil. -- Load message handler. local messageHandler = nil local function hasMessageHandler(message) if not messageHandler then return false elseif type(messageHandler) == "function" then return true elseif type(messageHandler) == "table" then return messageHandler[message] ~= nil else assert(false) end end local function sendMessage(message, ...) if not messageHandler then return elseif type(messageHandler) == "function" then local returnValues = pp.pack(messageHandler(message, ...)) return unpack(returnValues, 1, returnValues.n) elseif type(messageHandler) == "table" then local _messageHandler = messageHandler[message] if not _messageHandler then return end local returnValues = pp.pack(_messageHandler(...)) return unpack(returnValues, 1, returnValues.n) else assert(false) end end if messageHandlerPath ~= "" then -- Make the message handler and the metaprogram share the same environment. -- This way the message handler can easily define globals that the metaprogram uses. local mainChunk, err = loadLuaFile(messageHandlerPath, pp.metaEnvironment) if not mainChunk then errorLine("Could not load message handler...\n"..pp.tryToFormatError(err)) end messageHandler = mainChunk() if type(messageHandler) == "function" then -- void elseif type(messageHandler) == "table" then for message, _messageHandler in pairs(messageHandler) do if type(message) ~= "string" then errorLine(messageHandlerPath..": Table of handlers must only contain messages as keys.") elseif type(_messageHandler) ~= "function" then errorLine(messageHandlerPath..": Table of handlers must only contain functions as values.") end end else errorLine(messageHandlerPath..": File did not return a table or a function.") end end -- Init stuff. sendMessage("init", pathsIn, (hasOutputPaths and pathsOut or nil)) if not hasOutputPaths then for i, pathIn in ipairs(pathsIn) do pathsOut[i] = pathIn:gsub("%.%w+$", "").."."..outputExtension end end if not pathsIn[1] then errorLine("No path(s) specified.") elseif #pathsIn ~= #pathsOut then errorLine(F("Number of input and output paths differ. (%d in, %d out)", #pathsIn, #pathsOut)) end local pathsSetIn = {} local pathsSetOut = {} for i = 1, #pathsIn do if pathsSetIn [pathsIn [i]] then errorLine("Duplicate input path: " ..pathsIn [i]) end if pathsSetOut[pathsOut[i]] then errorLine("Duplicate output path: "..pathsOut[i]) end pathsSetIn [pathsIn [i]] = true pathsSetOut[pathsOut[i]] = true if pathsSetOut[pathsIn [i]] then errorLine("Path is both input and output: "..pathsIn [i]) end if pathsSetIn [pathsOut[i]] then errorLine("Path is both input and output: "..pathsOut[i]) end end -- Process files. -- :SavedInfo local processingInfo = { date = os.date("%Y-%m-%d %H:%M:%S", startTime), files = {}, } local byteCount = 0 local lineCount = 0 local lineCountCode = 0 local tokenCount = 0 for i, pathIn in ipairs(pathsIn) do local startClockForPath = os.clock() printfNoise("Processing '%s'...", pathIn) local pathOut = pathsOut[i] local pathMeta = pathOut:gsub("%.%w+$", "")..".meta.lua" if not outputMeta then pathMeta = nil end local info, err = pp.processFile{ pathIn = pathIn, pathMeta = pathMeta, pathOut = pathOut, debug = isDebug, addLineNumbers = addLineNumbers, backtickStrings = allowBacktickStrings, jitSyntax = allowJitSyntax, canOutputNil = canOutputNil, fastStrings = fastStrings, validate = validate, onInsert = (hasMessageHandler("insert") or nil) and function(name) local lua = sendMessage("insert", pathIn, name) -- onInsert() is expected to return a Lua code string and so is the message -- handler. However, if the handler is a single catch-all function we allow -- the message to not be handled and we fall back to the default behavior of -- treating 'name' as a path to a file to be inserted. If we didn't allow this -- then it would be required for the "insert" message to be handled. I think -- it's better if the user can choose whether to handle a message or not! -- if lua == nil and type(messageHandler) == "function" then return assert(pp.getFileContents(name)) end return lua end, onBeforeMeta = messageHandler and function() sendMessage("beforemeta", pathIn) end, onAfterMeta = messageHandler and function(lua) local luaModified = sendMessage("aftermeta", pathIn, lua) if type(luaModified) == "string" then lua = luaModified elseif luaModified ~= nil then error(F( "%s: Message handler did not return a string for 'aftermeta'. (Got %s)", messageHandlerPath, type(luaModified) )) end return lua end, onDone = messageHandler and function(info) sendMessage("filedone", pathIn, pathOut, info) end, onError = function(err) xpcall(function() sendMessage("fileerror", pathIn, err) end, function(err) printfError("Additional error in 'fileerror' message handler...\n%s", pp.tryToFormatError(err)) end) os.exit(1) end, } assert(info, err) -- The onError() handler above should have been called and we should have exited already. byteCount = byteCount + info.processedByteCount lineCount = lineCount + info.lineCount lineCountCode = lineCountCode + info.linesOfCode tokenCount = tokenCount + info.tokenCount if processingInfoPath ~= "" then -- :SavedInfo table.insert(processingInfo.files, info) -- See 'ProcessInfo' in preprocess.lua for what more 'info' contains. end printfNoise("Processing '%s' successful! (%.3fs)", pathIn, os.clock()-startClockForPath) printfNoise(("-"):rep(#header)) end -- Finalize stuff. if processingInfoPath ~= "" then printfNoise("Saving processing info to '%s'.", processingInfoPath) local luaParts = {"return"} assert(pp.serialize(luaParts, processingInfo)) local lua = table.concat(luaParts) local file = assert(io.open(processingInfoPath, "wb")) file:write(lua) file:close() end printfNoise( "All done! (%.3fs, %.0f file%s, %.0f LOC, %.0f line%s, %.0f token%s, %s)", os.clock()-startClock, #pathsIn, #pathsIn == 1 and "" or "s", lineCountCode, lineCount, lineCount == 1 and "" or "s", tokenCount, tokenCount == 1 and "" or "s", formatBytes(byteCount) ) --[[!=========================================================== Copyright © 2018-2021 Marcus 'ReFreezed' Thunström 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. ==============================================================]]
nilq/small-lua-stack
null
--this = SceneNode() function create() -- local islands = this:getRootNode():findAllNodeByNameTowardsLeaf("*island*") -- -- for i=0, islands:size()-1, 1 do -- generateFallingDustAndGravel(islands:item(i)) -- end return false end function generateFallingDustAndGravel(island) local list = island:findAllNodeByNameTowardsLeaf("*worldedge*") for i=0, list:size()-1, 1 do if math.randomFloat()>0.5 then list:item(i):loadLuaScript("Enviromental/fallingDustAndGravel.lua") end end end function update() return false end
nilq/small-lua-stack
null
local self = {} GLib.Resources.ResourceCache = GLib.MakeConstructor (self) function self:ctor () self.LastAccessTimes = {} self.NeedsSaving = false self:LoadLastAccessTimes () timer.Create ("GLib.Resources.ResourceCache.PruneCache", 300, 1, function () self:PruneCache () end ) concommand.Add ("glib_flush_resource_cache_" .. (SERVER and "sv" or "cl"), function (ply, _, args) if SERVER then if ply and ply:IsValid () and not ply:IsAdmin () then return end end self:ClearCache () end ) concommand.Add ("glib_prune_resource_cache_" .. (SERVER and "sv" or "cl"), function (ply, _, args) if SERVER then if ply and ply:IsValid () and not ply:IsAdmin () then return end end self:PruneCache () end ) end function self:dtor () timer.Destroy ("GLib.Resources.ResourceCache.PruneCache") timer.Destroy ("GLib.Resources.ResourceCache.SaveLastAccessTimes") end function self:CacheResource (namespace, id, versionHash, data) file.CreateDir ("glib") file.CreateDir ("glib/resourcecache") file.CreateDir ("glib/resourcecache/" .. string.lower (namespace)) local f = file.Open (self:GetCachePath (namespace, id, versionHash), "wb", "DATA") if not f then return end f:Write (data) f:Close () self:UpdateLastAccessTime (namespace, id, versionHash) end function self:ClearCache () local _, folders = file.Find ("data/glib/resourcecache/*", "GAME") for _, folderName in ipairs (folders) do local files = file.Find ("data/glib/resourcecache/" .. folderName .. "/*", "GAME") for _, fileName in ipairs (files) do self.LastAccessTimes ["glib/resourcecache/" .. folderName .. "/" .. fileName] = nil self:FlagSaveNeeded () file.Delete ("glib/resourcecache/" .. folderName .. "/" .. fileName) print ("GLib.Resources : Flushing cached resource glib/resourcecache/" .. folderName .. "/" .. fileName .. "...") end end end function self:GetCachePath (namespace, id, versionHash) return "glib/resourcecache/" .. string.lower (namespace) .. "/" .. string.lower (id) .. "_" .. versionHash .. ".txt" end function self:IsResourceCached (namespace, id, versionHash) return file.Exists ("data/" .. self:GetCachePath (namespace, id, versionHash), "GAME") and string.format ("%08x", tonumber (util.CRC (file.Read ("data/" .. self:GetCachePath (namespace, id, versionHash), "GAME"))) or 0) == versionHash end function self:PruneCache () local _, folders = file.Find ("data/glib/resourcecache/*", "GAME") for _, folderName in ipairs (folders) do local files = file.Find ("data/glib/resourcecache/" .. folderName .. "/*", "GAME") for _, fileName in ipairs (files) do local lastAccessTime = self.LastAccessTimes ["glib/resourcecache/" .. folderName .. "/" .. fileName] or 0 if os.time () - lastAccessTime > 7 * 86400 then -- Older than 1 week, delete it self.LastAccessTimes ["glib/resourcecache/" .. folderName .. "/" .. fileName] = nil self:FlagSaveNeeded () file.Delete ("glib/resourcecache/" .. folderName .. "/" .. fileName) print ("GLib.Resources : Cached resource glib/resourcecache/" .. folderName .. "/" .. fileName .. " has expired, deleting...") end end end -- Remove nonexistant files from the last access times table for dataPath, _ in pairs (self.LastAccessTimes) do if not file.Exists ("data/" .. dataPath, "GAME") then self.LastAccessTimes [dataPath] = nil self:FlagSaveNeeded () end end end function self:UpdateLastAccessTime (namespace, id, versionHash) self.LastAccessTimes [self:GetCachePath (namespace, id, versionHash)] = os.time () self:FlagSaveNeeded () end -- Internal, do not call function self:FlagSaveNeeded () self.NeedsSaving = true timer.Create ("GLib.Resources.ResourceCache.SaveLastAccessTimes", 1, 1, function () self:SaveLastAccessTimes () end ) end function self:LoadLastAccessTimes () local inBuffer = GLib.StringInBuffer (file.Read ("data/glib/resourcecache/lastaccesstimes.txt", "GAME") or "") local path = inBuffer:String () while path ~= "" do self.LastAccessTimes [path] = inBuffer:UInt32 () inBuffer:Bytes (1) -- Discard newline path = inBuffer:String () end self.NeedsSaving = false end function self:SaveLastAccessTimes () local outBuffer = GLib.StringOutBuffer () for path, timestamp in pairs (self.LastAccessTimes) do outBuffer:String (path) outBuffer:UInt32 (timestamp) outBuffer:Bytes ("\n") end outBuffer:String ("") file.CreateDir ("glib") file.CreateDir ("glib/resourcecache") file.Write ("glib/resourcecache/lastaccesstimes.txt", outBuffer:GetString ()) self.NeedsSaving = false end GLib.Resources.ResourceCache = GLib.Resources.ResourceCache ()
nilq/small-lua-stack
null
local app_helpers = require "lapis.application" return { { name = "2018-09-28_init_group_names", up = [[ CREATE TABLE IF NOT EXISTS group_names( id uuid, "group" text, created_at timestamp without time zone default (CURRENT_TIMESTAMP(0) at time zone 'utc'), PRIMARY KEY (id), CONSTRAINT group_names_group_key UNIQUE("group") ); DO $$ BEGIN IF (SELECT to_regclass('group_names_group')) IS NULL THEN CREATE INDEX group_names_group ON group_names("group"); END IF; END$$; ]], down = [[ DROP TABLE group_names; ]] },{ name = "2018-09-28_init_group_names_data", up = function(db, _, dao) local rows, err = db:query("SELECT distinct group FROM acls") if err then return err else local group_map = { gwa_admin = { group = 'gwa_admin' }, gwa_api_owner = { group = 'gwa_api_owner' } } for _, row in ipairs(rows) do if not group_map[row.group] then group_map[row.group] = { group = row.group } end end group_names = {} for group_name in pairs(group_map) do table.insert(group_names, group_name) end for i,group_name in ipairs(group_names) do local group = group_map[group_name]; dao.group_names:insert(group) end end end, down = function() end } }
nilq/small-lua-stack
null
local module = require(4631311072) local password = 4312 module.MainFunction(password)
nilq/small-lua-stack
null
mappings = { { name = "value", device="Logitech RumblePad 2 USB", control="X"}, }
nilq/small-lua-stack
null
-- Setup vars that are user-dependent. Can override this function in a sidecar file. function user_setup() state.OffenseMode:options('Normal', 'Acc', 'Hybrid') state.HybridMode:options('Normal', 'Evasion', 'PDT') state.WeaponskillMode:options('Normal', 'Acc', 'Mod') state.CastingMode:options('Normal', 'Resistant') state.PhysicalDefenseMode:options('PDT', 'Evasion') gear.MovementFeet = {name="Danzo Sune-ate"} gear.DayFeet = "Danzo Sune-ate" gear.NightFeet = "Hachiya Kyahan" gear.rings={} gear.rings.left={name="Stikini Ring +1", bag="wardrobe"} gear.rings.right={name="Stikini Ring +1", bag="wardrobe4"} send_command('bind !` eh cycle') select_movement_feet() end -- Define sets and vars used by this job file. function init_gear_sets() -------------------------------------- -- Precast sets -------------------------------------- -- Precast sets to enhance JAs sets.precast.JA['Mijin Gakure'] = {legs="Mochizuki Hakama"} sets.precast.JA['Futae'] = {legs="Hattori Tekko +1"} sets.precast.JA['Sange'] = {legs="Mochizuki Chainmail +1"} -- Waltz set (chr and vit) sets.precast.Waltz = { body="Mochi. Chainmail +1",hands="Adhemar Wristbands +1", back="Solemnity Cape",feet="Herculean Boots"} -- Don't need any special gear for Healing Waltz. sets.precast.Waltz['Healing Waltz'] = {} -- Set for acc on steps, since Yonin drops acc a fair bit sets.precast.Step = { neck="Combatant's Torque", body="Mochi. Chainmail +1",hands="Adhemar Wristbands +1",ring1="Cacoethic Ring +1",ring2="Patricius Ring", back="Andartia's Mantle",waist="Chaac Belt",feet="Herculean Boots"} sets.precast.Flourish1 = {waist="Chaac Belt"} -- Fast cast sets for spells sets.precast.FC = { head="Herculean Helm",neck="Baetyl Pendant",ear1="Etiolation Earring", body="Dread Jupon",hands="Leyline Gloves",ring1="Kishar Ring", legs="Gyve Trousers"} sets.precast.FC.Utsusemi = set_combine(sets.precast.FC, {neck="Magoraga Beads",body="Mochizuki Chainmail +1",back="Andartia's Mantle",feet="Hattori Kyahan +1"}) -- Snapshot for ranged sets.precast.RA = {} -- Weaponskill sets -- Default set for any weaponskill that isn't any more specifically defined sets.precast.WS = { head="Mpaca's Cap",neck="Fotia Gorget",ear1="Telos Earring",ear2="Moonshade Earring", body="Adhemar Jacket +1",hands="Adhemar Wristbands +1",ring1="Ilabrat Ring",ring2="Regal Ring", back="Andartia's Mantle",waist="Fotia Belt",legs="Samnuha Tights",feet="Herculean Boots"} sets.precast.WS.Acc = set_combine(sets.precast.WS, { head="Malignance Chapeau",ear1="Telos Earring",ear1="Dignitary's Earring", body="Malignance Tabard",hands="Malignance Gloves",ring1="Regal Ring",ring2="Ilabrat Ring" }) sets.precast.WS["Blade: Shun"] = set_combine(sets.precast.WS, { ear1="Odr Earring",legs="Jokushu Haidate" }) sets.precast.WS["Blade: Hi"] = set_combine(sets.precast.WS, { ear1="Odr Earring",ring2="Begrudging Ring",legs="Kendatsuba Hakama +1" }) sets.precast.WS['Aeolian Edge'] = set_combine(sets.precast.WS, {head="Herculean Helm",neck="Baetyl Pendant",ear1="Friomisi Earring",ear2="Crematio Earring", body="Samnuha Coat",ring1="Ilabrat Ring",ring2="Regal Ring", back="Toro Cape",waist="Orpheus's Sash"}) sets.precast.WS["Blade: Chi"] = sets.precast.WS['Aeolian Edge'] sets.precast.WS["Blade: Teki"] = sets.precast.WS['Aeolian Edge'] sets.precast.WS["Blade: To"] = sets.precast.WS['Aeolian Edge'] sets.precast.WS["Blade: Yu"] = sets.precast.WS['Aeolian Edge'] -------------------------------------- -- Midcast sets -------------------------------------- sets.midcast.FastRecast = {head="Herculean Helm",neck="Baetyl Pendant",hands="Leyline Gloves",ring1="Kishar Ring",feet="Herculean Boots"} sets.midcast.Utsusemi = set_combine(sets.midcast.FastRecast, {neck="Incanter's Torque",hands="Mochizuki Tekko",back="Andartia's Mantle",feet="Hattori Kyahan +1"}) sets.midcast.ElementalNinjutsu = set_combine(sets.midcast.FastRecast, { head="Herculean Helm",neck="Baetyl Pendant",ear1="Friomisi Earring",ear2="Crematio Earring", body="Samnuha Coat",hands="Hattori Tekko +1",ring1=gear.rings.left,ring2=gear.rings.right, back="Toro Cape",waist="Eschan Stone",legs="Gyve Trousers",feet="Hachiya Kyahan"}) sets.midcast.ElementalNinjutsu.Resistant = set_combine(sets.midcast.ElementalNinjutsu, {}) sets.midcast.NinjutsuDebuff = sets.midcast.ElementalNinjutsu.Resistant sets.midcast.NinjutsuBuff = set_combine(sets.midcast.FastRecast, {hands="Mochizuki Tekko"}) -------------------------------------- -- Idle/resting/defense/etc sets -------------------------------------- sets.acc = {head="Kendatsuba Jinpachi +1",neck="Combatant's Torque",ear1="Telos Earring",ear2="Odr Earring", body="Tatenashi Haramaki +1",hands="Kendatsuba Tekko +1",ring1="Ramuh Ring +1",ring2="Regal Ring", back="Andartia's Mantle",waist="Eschan Stone",legs="Kendatsuba Hakama +1",feet="Kendatsuba Sune-Ate +1"} sets.engaged = { head="Kendatsuba Jinpachi +1",neck="Combatant's Torque",ear1="Telos Earring",ear2="Cessance Earring", body="Tatenashi Haramaki +1",hands="Kendatsuba Tekko +1",ring1="Gere Ring",ring2="Epona's Ring", back="Andartia's Mantle",waist="Windbuffet Belt +1",legs="Kendatsuba Hakama +1",feet="Kendatsuba Sune-Ate +1"} sets.engaged.Trivial = set_combine(sets.engaged, {}) sets.engaged.Acc = set_combine(sets.engaged, sets.acc) sets.idle = set_combine(sets.engaged, { head="Malignance Chapeau",neck="Bathy Choker +1",ear1="Infused Earring", body="Hizamaru Haramaki +2",hands="Malignance Gloves",ring1="Sheltered Ring",ring2="Defending Ring", back="Moonlight Cape",waist="Flume Belt +1",legs="Rao Haidate",feet=gear.MovementFeet}) sets.idle.Town = set_combine(sets.idle, {}) sets.idle.Weak = sets.idle -- Resting sets sets.resting = sets.idle -- Defense sets sets.defense.Evasion = { head="Malignance Chapeau",neck="Loricate Torque +1", body="Malignance Tabard",hands="Malignance Gloves",ring1="Patricius Ring",ring2="Defending Ring", back="Andartia's Mantle",waist="Flume Belt +1",legs="Malignance Tights",feet="Malignance Boots"} sets.defense.PDT = {ammo="Staunch Tathlum +1", head="Malignance Chapeau", body="Malignance Tabard",hands="Malignance Gloves",ring2="Defending Ring", back="Andartia's Mantle",legs="Malignance Tights",feet="Malignance Boots"} sets.defense.MDT = set_combine(sets.defense.PDT, { ear1="Etiolation Earring",ear2="Tuisto Earring",ring1="Purity Ring" }) sets.Kiting = {feet=gear.MovementFeet} -------------------------------------- -- Engaged sets -------------------------------------- -- Variations for TP weapon and (optional) offense/defense modes. Code will fall back on previous -- sets if more refined versions aren't defined. -- If you create a set with both offense and defense modes, the offense mode should be first. -- EG: sets.engaged.Dagger.Accuracy.Evasion -- Normal melee group sets.engaged.Hybrid = set_combine(sets.engaged, { head="Malignance Chapeau",body="Malignance Tabard",hands="Malignance Gloves",ring2="Defending Ring",legs="Malignance Tights",feet="Malignance Boots" }) sets.engaged.Evasion = set_combine(sets.engaged, sets.defense.Evasion) sets.engaged.Acc.Evasion = set_combine(sets.engaged.Acc, sets.defense.Evasion) sets.engaged.PDT = set_combine(sets.engaged, sets.defense.PDT) sets.engaged.Acc.PDT = set_combine(sets.engaged.Acc, sets.defense.PDT) sets.engaged.MDT = set_combine(sets.engaged, sets.defense.MDT) sets.engaged.Acc.MDT = set_combine(sets.engaged.Acc, sets.defense.MDT) -------------------------------------- -- Custom buff sets -------------------------------------- sets.buff.Migawari = {body="Hattori Ningi +1",back="Andartia's Mantle"} sets.buff.Doom = {ring2="Saida Ring"} sets.buff.Yonin = {} sets.buff.Innin = {} end function job_post_precast(spell, action, spellMap, eventArgs) end
nilq/small-lua-stack
null
if not SYSPATH then return end local meta = class("BagActor", Yi.Actor) function meta:listInterests() return { Event.EVENT_BAG_OPEN, self.action_open_bag, } end function meta:onRegister() end function meta:action_open_bag(msg) puts("title: open bag") puts(msg) puts(__("role bag initilize %s", "grid 8*8")) local pane = go.bag.newview('grid') pane:cleanup() end return meta
nilq/small-lua-stack
null
-- the first program in every language print("Hello world, from ".._VERSION.."!\n")
nilq/small-lua-stack
null
local numbered_stages= { Stage_1st= true, Stage_2nd= true, Stage_3rd= true, Stage_4th= true, Stage_5th= true, Stage_6th= true, Stage_Next= true, } function thified_curstage_index(on_eval) local cur_stage= GAMESTATE:GetCurrentStage() local adjust= 1 -- hack: ScreenEvaluation shows the current stage, but it needs to show -- the last stage instead. Adjust the amount. if on_eval then adjust= 0 end if numbered_stages[cur_stage] then return FormatNumberAndSuffix(GAMESTATE:GetCurrentStageIndex() + adjust) else return ToEnumShortString(cur_stage) end end function check_stop_course_early() return course_stopped_by_pause_menu end
nilq/small-lua-stack
null
--- testMqtt -- @module testMqtt -- @author ?? -- @license MIT -- @copyright openLuat.com -- @release 2017.10.24 require "mqtt" module(..., package.seeall) -- 这里请填写修改为自己的IP和端口 local host, port = "lbsmqtt.airm2m.com", 1884 -- 测试MQTT的任务代码 sys.taskInit(function() while true do while not socket.isReady() do sys.wait(1000) end local mqttc = mqtt.client(misc.getImei(), 300, "user", "password") while not mqttc:connect(host, port) do sys.wait(2000) end if mqttc:subscribe(string.format("/device/%s/req", misc.getImei())) then if mqttc:publish(string.format("/device/%s/report", misc.getImei()), "test publish " .. os.time()) then while true do local r, data, param = mqttc:receive(120000, "pub_msg") if r then log.info("这是收到了服务器下发的消息:", data.payload or "nil") elseif data == "pub_msg" then log.info("这是收到了订阅的消息和参数显示:", data, param) mqttc:publish(string.format("/device/%s/resp", misc.getImei()), "response " .. param) elseif data == "timeout" then log.info("这是等待超时主动上报数据的显示!") mqttc:publish(string.format("/device/%s/report", misc.getImei()), "test publish " .. os.time()) else -- 网络链接被断开 break end end end end mqttc:disconnect() end end) -- 测试代码,用于发送消息给socket sys.taskInit(function() while true do sys.publish("pub_msg", "11223344556677889900AABBCCDDEEFF" .. os.time()) sys.wait(100) end end)
nilq/small-lua-stack
null
platform "Windows" option("msvconfiguration", "CharacterSet", "NotSet") --4996 'stricmp': The POSIX name for this item is deprecated. TODO - fix this option("msvccompile", "DisableSpecificWarnings", "4996") defines { MB_DLMALLOC, } files { "../external/dlmalloc-2.8.6/dlmalloc.cpp", "src/platform/windows/platform_windows.cpp", } --Can't use this unless dlmalloc is moved into its own library, which I should probably do. --pch "metabuilder_pch" platform_end()
nilq/small-lua-stack
null
local lute = require("lute.lute") -- Some default/example runners --lua -- Doesn't use write_command bc lua code can just be ran w/in nvim -- If a lua runtime is intalled on your system, -- There's no reason that lua can't be run using write_command lute.new_runner( "lua", "%.lua$", function (filename) return "luafile " .. filename end) --python lute.new_runner( "python", "%.py$", function (filename) return lute.write_command("python3", filename) end) --js lute.new_runner( "javascript", "%.js$", function (filename) return lute.write_command("node", filename) end) --ts lute.new_runner( "typecript", "%.ts$", function (filename) return lute.write_command("ts-node", filename) end) --jest js testing framework lute.new_runner( "js/ts-test", {"%.test%.js$", "%.spec%.js$", "%.test%.ts$", "%.spec%.ts$"}, function (filename) return lute.write_command("jest", filename) end) --This will just compile the current file. --For languages like rust, a project configuration is more useful. lute.new_runner( "rust", "%.rs$", function (filename) return lute.write_command("rustc", filename) end) return lute
nilq/small-lua-stack
null
OfflinePunishment = { edit = {}, button = {}, window = {}, label = {}, radiobutton = {} } OfflinePunishment.window[1] = guiCreateWindow(111, 49, 573, 511, "", false) guiWindowSetSizable(OfflinePunishment.window[1], false) guiSetVisible(OfflinePunishment.window[1],false) OfflinePunishment.label[1] = guiCreateLabel(16, 27, 547, 35, "Account Finder : \nYou must get the Account first", false, OfflinePunishment.window[1]) guiSetFont(OfflinePunishment.label[1], "default-bold-small") guiLabelSetHorizontalAlign(OfflinePunishment.label[1], "center", false) OfflinePunishment.label[2] = guiCreateLabel(16, 147, 112, 15, "Bans Punishment", false, OfflinePunishment.window[1]) guiSetFont(OfflinePunishment.label[2], "default-bold-small") OfflinePunishment.label[3] = guiCreateLabel(16, 333, 149, 24, "Account punishments", false, OfflinePunishment.window[1]) guiSetFont(OfflinePunishment.label[3], "default-bold-small") guiLabelSetVerticalAlign(OfflinePunishment.label[3], "center") OfflinePunishment.label[4] = guiCreateLabel(16, 125, 547, 15, "--------------------------------------------------------------------------------------------------------------------------------------------", false, OfflinePunishment.window[1]) guiSetFont(OfflinePunishment.label[4], "default-bold-small") OfflinePunishment.label[5] = guiCreateLabel(16, 67, 126, 25, "Target Account :?", false, OfflinePunishment.window[1]) guiSetFont(OfflinePunishment.label[5], "default-bold-small") guiLabelSetColor(OfflinePunishment.label[5], 244, 170, 10) guiLabelSetVerticalAlign(OfflinePunishment.label[5], "center") OfflinePunishment.edit[1] = guiCreateEdit(16, 99, 383, 23, "Target Serial", false, OfflinePunishment.window[1]) OfflinePunishment.button[1] = guiCreateButton(409, 99, 142, 23, "Get Account By Serial", false, OfflinePunishment.window[1]) guiSetProperty(OfflinePunishment.button[1], "NormalTextColour", "FFAAAAAA") OfflinePunishment.label[6] = guiCreateLabel(16, 170, 66, 25, "Account :", false, OfflinePunishment.window[1]) guiSetFont(OfflinePunishment.label[6], "default-bold-small") guiLabelSetColor(OfflinePunishment.label[6], 244, 170, 10) guiLabelSetVerticalAlign(OfflinePunishment.label[6], "center") OfflinePunishment.label[7] = guiCreateLabel(16, 205, 66, 25, "Serial :", false, OfflinePunishment.window[1]) guiSetFont(OfflinePunishment.label[7], "default-bold-small") guiLabelSetColor(OfflinePunishment.label[7], 244, 170, 10) guiLabelSetVerticalAlign(OfflinePunishment.label[7], "center") OfflinePunishment.label[8] = guiCreateLabel(16, 304, 547, 19, "--------------------------------------------------------------------------------------------------------------------------------------------", false, OfflinePunishment.window[1]) guiSetFont(OfflinePunishment.label[8], "default-bold-small") OfflinePunishment.label[9] = guiCreateLabel(16, 240, 66, 25, "Time : (Sec)", false, OfflinePunishment.window[1]) guiSetFont(OfflinePunishment.label[9], "default-bold-small") guiLabelSetColor(OfflinePunishment.label[9], 244, 170, 10) guiLabelSetVerticalAlign(OfflinePunishment.label[9], "center") OfflinePunishment.label[10] = guiCreateLabel(16, 275, 66, 25, "Reason :", false, OfflinePunishment.window[1]) guiSetFont(OfflinePunishment.label[10], "default-bold-small") guiLabelSetColor(OfflinePunishment.label[10], 244, 170, 10) guiLabelSetVerticalAlign(OfflinePunishment.label[10], "center") OfflinePunishment.edit[2] = guiCreateEdit(88, 170, 312, 25, "Target Account", false, OfflinePunishment.window[1]) OfflinePunishment.edit[3] = guiCreateEdit(88, 205, 312, 25, "Target Serial", false, OfflinePunishment.window[1]) OfflinePunishment.edit[4] = guiCreateEdit(88, 240, 312, 25, "300", false, OfflinePunishment.window[1]) OfflinePunishment.edit[5] = guiCreateEdit(88, 275, 312, 25, "Reason", false, OfflinePunishment.window[1]) OfflinePunishment.button[2] = guiCreateButton(411, 170, 142, 25, "Account Ban", false, OfflinePunishment.window[1]) guiSetProperty(OfflinePunishment.button[2], "NormalTextColour", "FFAAAAAA") OfflinePunishment.radiobutton[1] = guiCreateRadioButton(188, 333, 134, 24, "Jail punishment", false, OfflinePunishment.window[1]) OfflinePunishment.radiobutton[2] = guiCreateRadioButton(306, 333, 134, 24, "Mute punishment", false, OfflinePunishment.window[1]) OfflinePunishment.radiobutton[3] = guiCreateRadioButton(426, 333, 134, 24, "Global Mute", false, OfflinePunishment.window[1]) OfflinePunishment.label[11] = guiCreateLabel(16, 376, 66, 25, "Account :", false, OfflinePunishment.window[1]) guiSetFont(OfflinePunishment.label[11], "default-bold-small") guiLabelSetColor(OfflinePunishment.label[11], 244, 170, 10) guiLabelSetVerticalAlign(OfflinePunishment.label[11], "center") OfflinePunishment.button[3] = guiCreateButton(410, 205, 142, 25, "Serial Ban", false, OfflinePunishment.window[1]) guiSetProperty(OfflinePunishment.button[3], "NormalTextColour", "FFAAAAAA") OfflinePunishment.label[12] = guiCreateLabel(16, 411, 66, 25, "Time: (Sec)", false, OfflinePunishment.window[1]) guiSetFont(OfflinePunishment.label[12], "default-bold-small") guiLabelSetColor(OfflinePunishment.label[12], 244, 170, 10) guiLabelSetVerticalAlign(OfflinePunishment.label[12], "center") OfflinePunishment.label[13] = guiCreateLabel(16, 446, 66, 25, "Reason :", false, OfflinePunishment.window[1]) guiSetFont(OfflinePunishment.label[13], "default-bold-small") guiLabelSetColor(OfflinePunishment.label[13], 244, 170, 10) guiLabelSetVerticalAlign(OfflinePunishment.label[13], "center") OfflinePunishment.edit[6] = guiCreateEdit(88, 376, 312, 25, "Account", false, OfflinePunishment.window[1]) OfflinePunishment.edit[7] = guiCreateEdit(88, 411, 312, 25, "300", false, OfflinePunishment.window[1]) OfflinePunishment.edit[8] = guiCreateEdit(88, 446, 312, 25, "Reason", false, OfflinePunishment.window[1]) OfflinePunishment.button[4] = guiCreateButton(423, 376, 120, 27, "Punish him", false, OfflinePunishment.window[1]) guiSetProperty(OfflinePunishment.button[4], "NormalTextColour", "FFAAAAAA") OfflinePunishment.button[5] = guiCreateButton(423, 471, 120, 27, "Close panel", false, OfflinePunishment.window[1]) guiSetProperty(OfflinePunishment.button[5], "NormalTextColour", "FFAAAAAA") addEventHandler("onClientGUIClick",root,function() if source == OfflinePunishment.button[5] then guiSetVisible(OfflinePunishment.window[1],false) showCursor(false) elseif source == OfflinePunishment.button[4] then if guiRadioButtonGetSelected(OfflinePunishment.radiobutton[1]) then local AccountName = guiGetText(OfflinePunishment.edit[6]) local theTime = guiGetText(OfflinePunishment.edit[7]) local reason = guiGetText(OfflinePunishment.edit[8]) triggerServerEvent("offlineJail",localPlayer,AccountName,theTime,reason) elseif guiRadioButtonGetSelected(OfflinePunishment.radiobutton[2]) then local AccountName = guiGetText(OfflinePunishment.edit[6]) local theTime = guiGetText(OfflinePunishment.edit[7]) local reason = guiGetText(OfflinePunishment.edit[8]) triggerServerEvent("offlineMute",localPlayer,AccountName,theTime,reason) elseif guiRadioButtonGetSelected(OfflinePunishment.radiobutton[3]) then local AccountName = guiGetText(OfflinePunishment.edit[6]) local theTime = guiGetText(OfflinePunishment.edit[7]) local reason = guiGetText(OfflinePunishment.edit[8]) triggerServerEvent("offlineGOMute",localPlayer,AccountName,theTime,reason) end elseif source == OfflinePunishment.button[3] then local AccountName = guiGetText(OfflinePunishment.edit[2]) local serial = guiGetText(OfflinePunishment.edit[3]) local theTime = guiGetText(OfflinePunishment.edit[4]) local reason = guiGetText(OfflinePunishment.edit[5]) triggerServerEvent("banOfflineSerial",localPlayer,AccountName,serial,theTime,reason) elseif source == OfflinePunishment.button[2] then local AccountName = guiGetText(OfflinePunishment.edit[2]) local theTime = guiGetText(OfflinePunishment.edit[4]) local reason = guiGetText(OfflinePunishment.edit[5]) triggerServerEvent("banOfflineAccount",localPlayer,AccountName,theTime,reason) elseif source == OfflinePunishment.button[1] then local AccountFiner = guiGetText(OfflinePunishment.edit[1]) triggerServerEvent("getPlayerAccountBySerial",localPlayer,AccountFiner) end end) addCommandHandler("offline",function() if exports.CSGstaff:isPlayerStaff(localPlayer) and exports.CSGstaff:getPlayerAdminLevel(localPlayer) >= 2 then guiSetVisible(OfflinePunishment.window[1],true) showCursor(true) end end) addEvent("foundSerial",true) addEventHandler("foundSerial",root,function(Account) guiSetText(OfflinePunishment.label[5],Account) end)
nilq/small-lua-stack
null
local states = {} states.menu = require("src/states/MenuState") states.controls = require("src/states/ControlsState") states.battle = require("src/states/BattleState") states.level = require("src/states/LevelState") states.gameOver = require("src/states/GameOverState") return states
nilq/small-lua-stack
null
AddCSLuaFile("cl_init.lua") AddCSLuaFile("sh_playerweight.lua") AddCSLuaFile("sh_weightmanager.lua") include("sv_database.lua") include("sh_weightmanager.lua") include("sh_playerweight.lua") include("sv_message.lua") CreateConVar("ttt_karma_increase_weight", "0", FCVAR_ARCHIVE + FCVAR_NOTIFY, "Enables karma increased weight. Set ttt_karma_increase_weight_threshold for the minimum karma needed.") CreateConVar("ttt_karma_increase_weight_threshold", "950", FCVAR_ARCHIVE + FCVAR_NOTIFY, "Minimum karma for giving very little bonus weight to the player. Has a chance to give 0 extra weight. (default 950, based off of default max karma)") CreateConVar("ttt_show_traitor_chance", "1", FCVAR_ARCHIVE, "At the beginning of every round it will show the chance of the player being traitor in the next round (default 1)") CreateConVar("ttt_weight_system_fun_mode", "0", FCVAR_ARCHIVE + FCVAR_NOTIFY, "Sets the players player model scale to the players weight, physically making them their weight. Would not suggest this to be active on serious games. (Default 0)") CreateConVar("ttt_ws_show_round_statistics", "1", FCVAR_ARCHIVE, "At the beginning of every round, it will show the statistics of a player's rounds and role counts (default 1)") function AddWeightForGroups() if WeightSystem.GroupWeight ~= nil then for i = 1, #WeightSystem.GroupWeight do for k,v in pairs(player.GetAll()) do if not v:IsSpec() and IsValid(v) then local groupName = WeightSystem.GroupWeight[i].GroupName if v:IsUserGroup( groupName ) then local minWeight = WeightSystem.GroupWeight[i].MinWeight local maxWeight = WeightSystem.GroupWeight[i].MaxWeight local weight = math.random(minWeight, maxWeight) if not (weight == 0) then v:AddWeight( weight ) Message( v:GetName() .. " was given extra weight for being in group: " .. groupName ) end end end end end end end function findLowestGroupWeight(v) local lowest = 999999 if WeightSystem.GroupWeight ~= nil then for i = 1, #WeightSystem.GroupWeight do if not v:IsSpec() and IsValid(v) then local groupName = WeightSystem.GroupWeight[i].GroupName if v:IsUserGroup( groupName ) then local groupCap = WeightSystem.GroupWeight[i].cappedWeight if groupCap < lowest then lowest = groupCap end end end end end return lowest end math.randomseed( os.time() ) local function shuffleTable( t ) local rand = math.random local iterations = #t local j for i = iterations, 2, -1 do j = rand(i) t[i], t[j] = t[j], t[i] end end hook.Add("TTTBeginRound", "TTTWS_BeginRound", function() -- Set players role count for k,v in pairs(player.GetAll()) do -- Send weight info to all players (Only admins will be able to get right message). SendWeightInfo( v, "WeightSystem_WeightInfoUpdated") TellPlayersTraitorChance( v ) SetFunModeScaleAllPlayers() -- Will only happen if the convar is set. end end) hook.Add("PlayerSay", "TTTWS_PlayerSay", function(ply, text, teamOnly) if string.find(string.lower(text), string.lower(WeightSystem.TraitorChanceCommand)) then TellPlayersTraitorChance(ply) end end) function SelectPlayerForTraitor( choices, prev_roles ) local totalWeight = 0 --local minimumWeight = math.floor((totalWeight * .2)) for k, v in pairs(choices) do totalWeight = totalWeight + v:GetWeight() end print( "Total Weight: " .. totalWeight ) local r = math.random(1, totalWeight) print( "Amount to beat: " .. r) local defaultT local lastChance for k,v in pairs(choices) do -- Sets the currently being validated player as the default T to be returned. defaultT = v -- Check to see if the randomly selected number minus the current players weight is less then 0 it means they win the role. print( v:GetName() .. ": " .. r .. " - " .. v:GetWeight() .. " = " .. r - v:GetWeight()) if (r - v:GetWeight()) <= 0 then -- Set the last chance player to current player, if it ends up not accepting a player to return it will return the last known person in loop. lastChance = v if IsValid(v) and ( (not table.HasValue(prev_roles[ROLE_TRAITOR], v)) or ( math.random(1, 3) == 2) ) then return v end end r = r - v:GetWeight() end if lastChance ~= nil then return lastChance end return defaultT end -- Overwrite functions GetTraitorCount = nil GetDetectiveCount = nil hook.Add( "Initialize", "TTTWS_Initialize", function () -- Find the GetTraitorCount and GetDetectiveCount functions for i = 1, math.huge do local k, v = debug.getupvalue( SelectRoles, i ) if k == "GetTraitorCount" then GetTraitorCount = v end if k == "GetDetectiveCount" then GetDetectiveCount = v end if GetTraitorCount ~= nil and GetDetectiveCount ~= nil or k == nil then break end end -- Select Roles function SelectRoles() local choices = {} local prev_roles = { [ROLE_INNOCENT] = {}, [ROLE_TRAITOR] = {}, [ROLE_DETECTIVE] = {} } if not GAMEMODE.LastRole then GAMEMODE.LastRole = {} end -- Get Choices and set to innocent for k,v in pairs(player.GetAll()) do -- if IsValid(v) and (not v:IsSpec()) and (not v:IsBot()) then if IsValid(v) and (not v:IsSpec()) then -- save previous role and sign up as possible traitor/detective local r = GAMEMODE.LastRole[v:UniqueID()] or v:GetRole() or ROLE_INNOCENT table.insert(prev_roles[r], v) table.insert(choices, v) v:SetRoundsPlayed( v:GetRoundsPlayed() + 1) end -- Set everyone to innocent. v:SetRole(ROLE_INNOCENT) end -- determine how many of each role we want local choice_count = #choices local traitor_count = GetTraitorCount(choice_count) local det_count = GetDetectiveCount(choice_count) if choice_count == 0 then return end print("Choice Count: " .. choice_count) print("Traitor Count: " .. traitor_count) print("Detective Count: " .. det_count) -- first select traitors local ts = 0 while ts < traitor_count do shuffleTable(choices) selectedPlayer = SelectPlayerForTraitor( choices, prev_roles ) selectedPlayer:SetRole( ROLE_TRAITOR ) selectedPlayer:SetWeight( DefaultWeight() ) table.RemoveByValue( choices, selectedPlayer ) ts = ts + 1 selectedPlayer:SetTraitorCount( selectedPlayer:GetTraitorCount() + 1 ) -- Phantom139: Added selectedPlayer:SetRoundsSinceTraitorCount( 0 ) end -- now select detectives, explicitly choosing from players who did not get -- traitor, so becoming detective does not mean you lost a chance to be -- traitor local ds = 0 local min_karma = GetConVarNumber("ttt_detective_karma_min") or 0 while (ds < det_count) and (#choices >= 1) do -- sometimes we need all remaining choices to be detective to fill the -- roles up, this happens more often with a lot of detective-deniers if #choices <= (det_count - ds) then for k, pply in pairs(choices) do if IsValid(pply) then pply:SetRole(ROLE_DETECTIVE) pply:SetDetectiveCount( pply:GetDetectiveCount() + 1 ) pply:SetRoundsSinceTraitorCount( pply:GetRoundsSinceTraitorCount() + 1 ) end end break -- out of while end local pick = math.random(1, #choices) local pply = choices[pick] -- we are less likely to be a detective unless we were innocent last round if (IsValid(pply) and ((pply:GetBaseKarma() > min_karma and table.HasValue(prev_roles[ROLE_INNOCENT], pply)) or math.random(1,3) == 2)) then -- if a player has specified he does not want to be detective, we skip -- him here (he might still get it if we don't have enough -- alternatives) if not pply:GetAvoidDetective() then pply:SetRole(ROLE_DETECTIVE) pply:SetDetectiveCount( pply:GetDetectiveCount() + 1 ) pply:SetRoundsSinceTraitorCount( pply:GetRoundsSinceTraitorCount() + 1 ) ds = ds + 1 end table.remove(choices, pick) end end -- Update all innocent players to have increased weight for k,v in pairs(choices) do if IsValid(v) and (not v:IsSpec()) and v:GetRole() == ROLE_INNOCENT then -- Phantom139: Update the player role stats v:SetInnocentCount( v:GetInnocentCount() + 1 ) v:SetRoundsSinceTraitorCount( v:GetRoundsSinceTraitorCount() + 1 ) -- If the players karma is greater then the server threshold add weight to him. if GetConVar("ttt_karma_increase_weight"):GetBool() and v:GetBaseKarma() > GetConVar("ttt_karma_increase_weight_threshold"):GetInt() then local extra = math.random(0, 2) v:AddWeight( extra ) print(v:GetName() .. " was given " .. extra .. " extra weight for having good karma.") end -- Phantom139: Added this block of code here to restrict players chances if they are in a group to the group's cap. if v:GetTraitorChance() > findLowestGroupWeight(v) then print(v:GetName() .. " is capped by a group restriction, no additional weight granted.") else -- Give normal amount of weight v:AddWeight( math.random(6, 10) ) -- Phantom139: Added a block here to add additional weight for "streaks" of not being a traitor. if v:GetRoundsSinceTraitorCount() >= math.random(3, 5) then local bonusWeight = math.floor(math.pow(1.75, v:GetRoundsSinceTraitorCount())) v:AddWeight( bonusWeight ) print(v:GetName() .. " was given " .. bonusWeight .. " extra weight for being on a streak of not being the traitor. ( " .. v:GetRoundsSinceTraitorCount() .. " rounds)") end end end end AddWeightForGroups() -- Phantom139: Move the update DB statement here to address the bug where the table doesn't save on the last round of a match. UpdatePlayerDbWeights() -- Update the Database weights. GAMEMODE.LastRole = {} for _, ply in pairs(player.GetAll()) do -- initialize credit count for everyone based on their role ply:SetDefaultCredits() -- store a uid -> role map GAMEMODE.LastRole[ply:UniqueID()] = ply:GetRole() end end -- End of SelectRoles() end)
nilq/small-lua-stack
null
local _HYPER = {'cmd,ctrl,alt,shift,f19'} -- local _HYPER = {'f19'} local log = hs.logger.new('hyper.lua', 'debug') hs.hotkey.bind(_HYPER, '=', hs.caffeinate.startScreensaver) -- Launch apps with Hyper key hyperModeAppMappings = { { 'b', 'Google Chrome' }, -- B-rowser { 'c', 'Slack' }, -- C-hat { 'e', '/Applications/Emacs.app' }, -- text E-ditor { 't', 'iTerm' }, -- T-erminal { ';', 'Safari' }, -- { 'm', 'Airmail 3' }, -- e-M-ail { 'z', 'zoom.us' }, -- video chat { 'd', 'Things3'}, -- to-D-o { 'v', 'Visual Studio Code' } } -- { ';', 'Firefox.app' }, -- -- { ';', 'Firefox Developer Edition.app' }, -- -- { 'm', 'Canary Mail' }, -- e-M-ail -- { 'd', 'OmniFocus' }, -- to-D-o for i, mapping in ipairs(hyperModeAppMappings) do local key = mapping[1] local appName = mapping[2] hs.hotkey.bind( _HYPER, key, function() log.d('Switching to:', appName) hs.application.launchOrFocus(appName) end) end -- hs.loadSpoon("MiroWindowsManager") -- hs.window.animationDuration = 0 -- spoon.MiroWindowsManager:bindHotkeys({ -- up = {_HYPER, "up"}, -- right = {_HYPER, "]"}, -- down = {_HYPER, "down"}, -- left = {_HYPER, "["}, -- fullscreen = {_HYPER, "space"} -- })
nilq/small-lua-stack
null
--- String operation extensions -- @module string.lua local metafuncs = {} ---- Add strings together with `+` operator -- @within Metatable functions -- @string s a thing -- @string other athing -- @usage "abc" + "cde" => "abccde" function metafuncs.add(s, other) return s .. other end ---- Slice a string into a smaller string. -- (see http://lua-users.org/wiki/StringIndexing) -- @within Metatable functions -- @usage x = 'abcde' --- x(2, 4) => 'bcd' --- x{1, -2, 3} => 'adc' function metafuncs.call(s,i,j) if isType(i, 'number') then return string.sub(s, i, j or rawlen(s)) elseif isType(i, 'table') then local t = {} for k, v in ipairs(i) do t[k] = string.sub(s, v, v) end return table.concat(t) end end ---- Index a single character in a string. -- (see http://lua-users.org/wiki/StringIndexing) -- @within Metatable functions -- @usage x = 'abcde' --- x[3] == x[-3] == 'c' --- x.<command> == function or nil function metafuncs.index(s, i) if isType(i, 'number') then if i < 0 then i = rawlen(s) + 1 + i end return string.sub(s, i, i) end return string[i] end ---- Multiply a string to repeat it -- @within Metatable functions -- @usage "ab" * 3 => "ababab" function metafuncs.mul(s, other) local t = {} for i=1, other do t[i] = s end return table.concat(t) end ---- Iterate over the characters in a string -- @within Metatable functions -- @usage x = 'ab' --- for i, v in pairs(x) do print(i, v) end --- prints -> --- 1, a --- 2, b function metafuncs.pairs(s) local function _iter(s, idx) if idx < rawlen(s) then return idx + 1, s[idx + 1] end end return _iter, s, 0 end ---- Check if a string ends with a value -- @string s -- @string value -- @treturn boolean function string.endswith(s, value) return s(-rawlen(value), -1) == value end ---- Concatenate a list/table of strings with another string as the delimiter -- @string s -- @param other -- @treturn string function string.join(s, other) return table.concat(other, s) end ---- Replace occurrences of a substring in a string -- @string s -- @string sub -- @param rep -- @int limit -- @treturn string function string.replace(s, sub, rep, limit) -- local _s, n = string.gsub(s, sub, rep, limit) -- return _s return string.gsub(s, sub, rep, limit) end ---- Split a string by a delimiter into a table of strings -- @string s -- @string delim -- @treturn list function string.split(s, delim) local i = 1 local idx = 1 local values = {} while i <= rawlen(s) do if is.Nil(delim) then values[i] = s[i]; i = i + 1 else if s(i, i + rawlen(delim) - 1) == delim then idx = idx + 1; i = i + rawlen(delim) - 1 else if is.Nil(values[idx]) then values[idx] = '' end values[idx] = values[idx] .. s[i] end i = i + 1 end end for i, v in pairs(values) do if is.Nil(v) then values[i] = '' end end return list(values) end ---- Check if a string starts with a value -- @string s -- @string value -- @treturn boolean function string.startswith(s, value) return s(1, rawlen(value)) == value end ---- Strip characters from the beginning and end of a string -- @string s -- @string remove -- @treturn string function string.strip(s, remove) local start=1 local _end = rawlen(s) for i=1, rawlen(s) do if isnotin(s[i], remove) then start = i break end end for i=rawlen(s), start, -1 do if isnotin(s[i], remove) then _end = i break end end return s(start, _end) end -- Metatable patching getmetatable('').__add = metafuncs.add getmetatable('').__call = metafuncs.call getmetatable('').__ipairs = metafuncs.pairs getmetatable('').__mul = metafuncs.mul getmetatable('').__pairs = metafuncs.pairs getmetatable('').__index = metafuncs.index
nilq/small-lua-stack
null
HTM.BarWidth = 198; -- Creates the GUI function HTM:CreateGui() -- Main Frame do self.frame = CreateFrame("Frame", "HTMFrame", UIParent); self.frame:SetPoint("CENTER", UIParent, "CENTER"); self.frame:SetWidth(225); self.frame:SetHeight(141); self.frame:EnableMouse(true); self.frame:SetMovable(true); self.frame:RegisterForDrag("LeftButton"); self.frame:SetScript("OnDragStart", self.frame.StartMoving); self.frame:SetScript("OnDragStop", self.frame.StopMovingOrSizing); self.frame:SetBackdrop({ bgFile = "Interface\\DialogFrame\\UI-DialogBox-Gold-Background", tile = true, tileSize = 32, edgeSize = 32, insets = {left=11,right=12,top=12,bottom=11} }); self.frame:SetBackdropColor(0,0,0); end -- Bars do self.frame.bar1 = HTM:CreateBar(); self.frame.bar1:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 13, -14); self:UpdateBarData(1, nil); self.frame.bar2 = HTM:CreateBar(); self.frame.bar2:SetPoint("TOPLEFT", self.frame.bar1, "BOTTOMLEFT", 0, -2); self:UpdateBarData(2, nil); self.frame.bar3 = HTM:CreateBar(); self.frame.bar3:SetPoint("TOPLEFT", self.frame.bar2, "BOTTOMLEFT", 0, -2); self:UpdateBarData(3, nil); self.frame.bar4 = HTM:CreateBar(); self.frame.bar4:SetPoint("TOPLEFT", self.frame.bar3, "BOTTOMLEFT", 0, -2); self:UpdateBarData(4, nil); end end local CLASS_COLORS = { DRUID = {r=1.00, g=0.49, b=0.04}, HUNTER = {r=0.67, g=0.83, b=0.45}, MAGE = {r=0.41, g=0.80, b=0.94}, PALADIN = {r=0.96, g=0.55, b=0.73}, PRIEST = {r=1.00, g=1.00, b=1.00}, ROGUE = {r=1.00, g=0.96, b=0.41}, SHAMAN = {r=0.00, g=0.44, b=0.87}, WARLOCK = {r=0.58, g=0.51, b=0.79}, WARRIOR = {r=0.78, g=0.61, b=0.43}, }; -- Creates a Bar that represents an entry in the threat list function HTM:CreateBar() local bg = CreateFrame("Frame", nil, self.frame); bg:SetHeight(27); bg:SetWidth(HTM.BarWidth); local bar = CreateFrame("Frame", nil, bg); bar:SetHeight(27); bar:SetWidth(HTM.BarWidth); bar:SetPoint("TOPLEFT", bg, "TOPLEFT"); bar:SetBackdrop({ bgFile = "Interface\\BUTTONS\\WHITE8X8", tile = true, tileSize = 32, }); bar.playerName = bar:CreateFontString(nil, nil, "GameFontNormal"); bar.playerName:SetPoint("LEFT", bar, "LEFT", 2, 0); bar.percentage = bar:CreateFontString(nil, nil, "GameFontNormal"); bar.percentage:SetPoint("RIGHT", bg, "RIGHT", -2, 0); bar.threatValue = bar:CreateFontString(nil, nil, "GameFontNormal"); bar.threatValue:SetPoint("RIGHT", bar.percentage, "LEFT", -20, 0); bg.bar = bar; return bg; end function HTM:UpdateBarData(barNumber, data, maxThreat) local bar = self.frame["bar"..barNumber].bar; if not data or not data.threat then bar:Hide(); return; else bar:Show(); end if not data.unit then bar:SetBackdropColor(0, 0, 1, 0.5); else local _, class = UnitClass(data.unit); local color = CLASS_COLORS[class]; if color then bar:SetBackdropColor(color.r, color.g, color.b, 0.5); end end bar.playerName:SetText(data.name); bar.threatValue:SetText(math.floor(data.threat+0.5)); local percentage = 100 / maxThreat * data.threat; bar:SetWidth(HTM.BarWidth / 100 * percentage); bar.percentage:SetText(math.floor(percentage+0.5).."%"); end
nilq/small-lua-stack
null
table.insert(_G.test_loadorder, "FANCY")
nilq/small-lua-stack
null
--https://github.com/narc0tiq/evoGUI/blob/master/evoGUI.lua require "clone" if not cssa_gui then cssa_gui = {} end if not cssa_clone then cssa_clone = {} end -- EVENTS function cssa_gui.new_player(event) local player = game.players[event.player_index] cssa_gui.create_menu_icon(player) end function cssa_gui.on_gui_click(event) local player = game.players[event.player_index] local color_red = {r = 1, g = 0, b = 0, a = 1} local color_green = {0, 1, 0, 1} if (event.element.name == "cssa_gui_root") then cssa_gui.create_menu(player) return end if(event.element.name == "close-menu") then local menu = player.gui.screen.cssa_gui_menu if(menu ~= nil) then menu.destroy() end return end if (event.element.name == "teams-menu-new-force-button") then local text = event.element.parent["teams-menu-new-force-textfield"].text if(text == nil or text == '') then player.print("New force must not be empty!", color_red) return end if(game.forces[text] ~= nil) then player.print("Force '" .. text .. "' already exists!", color_red) return end local created_force = game.create_force(text) local player_force = game.forces["player"] -- default local neutral_force = game.forces["neutral"] local enemy_force = game.forces["enemy"] -- biter created_force.set_friend(player_force, false) created_force.set_friend(neutral_force, false) created_force.set_friend(enemy_force, false) created_force.set_cease_fire(player_force, true) created_force.set_cease_fire(neutral_force, true) created_force.set_cease_fire(enemy_force, false) player.print("Force '" .. text .. "' created.", color_green) local menu = player.gui.screen.cssa_gui_menu if(menu ~= nil) then menu.destroy() cssa_gui.create_menu(player) end return end if(event.element.name == "teams-menu-join-force-button") then local dropdown = event.element.parent["teams-menu-join-force-drop-down"] local selected_force = dropdown.items[dropdown.selected_index] if(selected_force == nil or selected_force == '') then player.print("Unable to join 'undefined' force!", color_red) return end if(game.forces[selected_force] == nil) then player.print("Force '" .. selected_force .. "' does not exists!", color_red) return end player.force = selected_force player.force.set_friend(player.force, true) player.force.set_cease_fire(player.force, true) player.print("Force '" .. selected_force .. "' joined.", color_green) local menu = player.gui.screen.cssa_gui_menu if(menu ~= nil) then menu.destroy() cssa_gui.create_menu(player) end return end if(event.element.type == "checkbox") then local checkbox = event.element local force = game.forces[checkbox.caption] if(string.find(checkbox.name, "allies")) then player.force.set_friend(force, checkbox.state) player.force.set_cease_fire(force, checkbox.state) force.set_friend(player.force, checkbox.state) force.set_cease_fire(player.force, checkbox.state) end if(string.find(checkbox.name, "neutrals")) then player.force.set_friend(force, not checkbox.state) player.force.set_cease_fire(force, checkbox.state) force.set_friend(player.force, not checkbox.state) force.set_cease_fire(player.force, checkbox.state) end if(string.find(checkbox.name, "enemies")) then player.force.set_friend(force, not checkbox.state) player.force.set_cease_fire(force, not checkbox.state) force.set_friend(player.force, not checkbox.state) force.set_cease_fire(player.force, not checkbox.state) end local menu = player.gui.screen.cssa_gui_menu if(menu ~= nil) then menu.destroy() cssa_gui.create_menu(player) end return end if (event.element.name == "teams-menu-table-frame-" .. player.force.name .. "-row-spawn-button") then for key, entry in pairs(global.spawns) do if(player.force.name == entry.force_name and entry.spawn_created) then player.print("There already was a new spawn created for '" .. player.force.name .. "'!", color_red) return end end local button = player.gui.screen.cssa_gui_menu["teams-menu-table"]["teams-menu-table-frame-" .. player.force.name .. "-row-spawn-button"] cssa_clone.clone_area(player) button.enabled = false return end end -- -- -- FUNCTIONS -- -- function cssa_gui.create_menu_icon(player) local root = player.gui.top.cssa_gui_root local destroyed = false if root then player.gui.top.cssa_gui_root.destroy() destroyed = true end if not root or destroyed or not root.valid then local root = player.gui.top.add{ type = "sprite-button", name = "cssa_gui_root", sprite = "cssa-main-sprite-button" } end end function cssa_gui.create_menu(player) local menu = player.gui.screen.cssa_gui_menu if menu then player.gui.screen.cssa_gui_menu.destroy() return end if not menu or not menu.valid then local menu = player.gui.screen.add { type = "frame", name = "cssa_gui_menu", direction = "vertical", caption = "Forces" } menu.force_auto_center() local empty_drag_widget = menu.add { type = "empty-widget", style = "draggable_space" } empty_drag_widget.drag_target = menu menu.add{type="sprite-button", name="close-menu", sprite = "utility/close_white", style="frame_action_button"} local gui_table = menu.add { type = "table", name = "teams-menu-table", column_count = 6, draw_vertical_lines = false, draw_horizontal_lines = false, draw_horizontal_line_after_headers = true, vertical_centering = true } -- first table row contains 5 elements as the headers gui_table.add { type = "label", name = "teams-menu-table-frame-first-row-name", caption = "Name" } gui_table.add { type = "label", name = "teams-menu-table-frame-first-row-allies", caption = "Allies" } gui_table.add { type = "label", name = "teams-menu-table-frame-first-row-neutral", caption = "Neutrals" } gui_table.add { type = "label", name = "teams-menu-table-frame-first-row-enemies", caption = "Enemies" } gui_table.add { type = "label", name = "teams-menu-table-frame-first-row-spawn", caption = "Starting Area" } gui_table.add { type = "label", name = "teams-menu-table-frame-first-row-players", caption = "Players" } cssa_gui.create_entry_for_forces(player, gui_table) menu.add { type = "textfield", name = "teams-menu-new-force-textfield", caption = "Insert force name.." } menu.add { type = "button", name = "teams-menu-new-force-button", caption = "New Force" } cssa_gui.create_join_force(menu) end end function cssa_gui.create_entry_for_forces(player, gui_table) for key, force in pairs(game.forces) do local hide_default_forces = settings.startup["hide-default-forces"].value if(hide_default_forces) then if(force.name == "neutral" or force.name == "enemy") then goto continue end end game.print("create_entry_for_forces executed as " .. force.name .. " as player " .. player.name) -- second table row contains 5 elements gui_table.add { type = "label", name = "teams-menu-table-frame-" .. force.name .. "-name", caption = force.name } local allies_check = player.force.get_friend(force) local neutral_check = not player.force.get_friend(force) and player.force.get_cease_fire(force) local enemies_check = not player.force.get_friend(force) and not player.force.get_cease_fire(force) gui_table.add { type = "checkbox", name = "teams-menu-table-frame-" .. force.name .. "-row-allies", caption = force.name, -- use caption for on gui click, to know the force state = allies_check, enabled = player.force.name ~= force.name } gui_table.add { type = "checkbox", name = "teams-menu-table-frame-" .. force.name .. "-row-neutrals", caption = force.name, -- use caption for on gui click, to know the force state = neutral_check, enabled = player.force.name ~= force.name } gui_table.add { type = "checkbox", name = "teams-menu-table-frame-" .. force.name .. "-row-enemies", caption = force.name, -- use caption for on gui click, to know the force state = enemies_check, enabled = player.force.name ~= force.name } local enable_new_spawn = true if(global.spawns[force.name] ~= nil) then enable_new_spawn = not global.spawns[force.name].spawn_created end gui_table.add { type = "sprite-button", name = "teams-menu-table-frame-" .. force.name .. "-row-spawn-button", sprite = "utility/add", style = "frame_action_button", enabled = enable_new_spawn } local players_flow = gui_table.add { type = "flow", name = "teams-menu-table-frame-" .. force.name .. "-row-players", direction = "horizontal" } for key, player in pairs(force.players) do players_flow.add { type = "label", name = player.name, caption = player.name } end ::continue:: end end function cssa_gui.create_join_force(menu) local forces_string = {} local forces_string_key = 0 for key, force in pairs(game.forces) do local hide_default_forces = settings.startup["hide-default-forces"].value if(hide_default_forces) then -- player should be still able to join the default player force -- therefore exclude "player" in the if if(force.name == "neutral" or force.name == "enemy") then goto continue2 end end forces_string_key = forces_string_key + 1 table.insert(forces_string, forces_string_key, force.name) ::continue2:: end menu.add { type = "drop-down", name = "teams-menu-join-force-drop-down", default_value = forces_string[1], items = forces_string } menu.add { type = "button", name = "teams-menu-join-force-button", caption = "Join selected force" } end
nilq/small-lua-stack
null
-------------------------------------------------------------------------------- -- Copyright (c) 2006-2013 Fabien Fleutot and others. -- -- All rights reserved. -- -- This program and the accompanying materials are made available -- under the terms of the Eclipse Public License v1.0 which -- accompanies this distribution, and is available at -- http://www.eclipse.org/legal/epl-v10.html -- -- This program and the accompanying materials are also made available -- under the terms of the MIT public license which accompanies this -- distribution, and is available at http://www.lua.org/license.html -- -- Contributors: -- Fabien Fleutot - API and implementation -- -------------------------------------------------------------------------------- --*-lua-*----------------------------------------------------------------------- -- Override Lua's default compilation functions, so that they support Metalua -- rather than only plain Lua -------------------------------------------------------------------------------- local mlc = require 'metalua.compiler' local M = { } -- Original versions local original_lua_versions = { load = load, loadfile = loadfile, loadstring = loadstring, dofile = dofile } local lua_loadstring = loadstring local lua_loadfile = loadfile function M.loadstring(str, name) if type(str) ~= 'string' then error 'string expected' end if str:match '^\027LuaQ' then return lua_loadstring(str) end local n = str:match '^#![^\n]*\n()' if n then str=str:sub(n, -1) end -- FIXME: handle erroneous returns (return nil + error msg) return mlc.new():src_to_function(str, name) end function M.loadfile(filename) local f, err_msg = io.open(filename, 'rb') if not f then return nil, err_msg end local success, src = pcall( f.read, f, '*a') pcall(f.close, f) if success then return M.loadstring (src, '@'..filename) else return nil, src end end function M.load(f, name) local acc = { } while true do local x = f() if not x then break end assert(type(x)=='string', "function passed to load() must return strings") table.insert(acc, x) end return M.loadstring(table.concat(acc)) end function M.dostring(src) local f, msg = M.loadstring(src) if not f then error(msg) end return f() end function M.dofile(name) local f, msg = M.loadfile(name) if not f then error(msg) end return f() end -- Export replacement functions as globals for name, f in pairs(M) do _G[name] = f end -- To be done *after* exportation M.lua = original_lua_versions return M
nilq/small-lua-stack
null
local dlmenu = {} local term = require("term") local palette = require("palette") local fs = require("filesystem") local event = require("event") local w, h = term.gpu().getResolution() local xoffset = math.floor(w/8) local yoffset = math.floor(h/8) -- actual window width & height local ww, wh = math.floor(w-xoffset-w/8), math.floor(h-yoffset-h/8) local program = {} local version = nil local dlstring = "Descargar a: " local installstring = "Instalar" local defaultdlpath = "" -- set on dlmenu.show local exit = false local function setToNormalColors() term.gpu().setBackground(palette.monochrome and 0 or palette.colors.winbg, not palette.monochrome) term.gpu().setForeground(0xffffff) end local function setToTitleColors() term.gpu().setBackground(palette.monochrome and 0xffffff or palette.colors.title, not palette.monochrome) term.gpu().setForeground(0) end local function setToInputColors() term.gpu().setBackground(palette.monochrome and 0 or palette.colors.bg, not palette.monochrome) term.gpu().setForeground(0xffffff) end local function setToProgressColors() term.gpu().setBackground(palette.monochrome and 0xffffff or palette.colors.status, not palette.monochrome) term.gpu().setForeground(palette.monochrome and 0 or 0xffffff) end local function drawTitle() setToNormalColors() term.gpu().fill(xoffset, yoffset, ww, wh, " ") setToTitleColors() term.gpu().fill(xoffset, yoffset, ww, 1, " ") local title = "Descargar "..program.name term.setCursor(w/2-#title/2, yoffset) term.write(title) term.setCursor(xoffset,yoffset) term.write("X") end -- Inputboxes have x, y, w, value and scroll local inputboxes = {} local inputboxselected = nil local function createInputBoxes() inputboxes = {} table.insert(inputboxes, {x=xoffset+2+#dlstring, y=yoffset+2, w=ww-(#dlstring+4), value = defaultdlpath, scroll = 1}) end local function redrawInputBox(inputbox) setToInputColors() term.gpu().fill(inputbox.x, inputbox.y, inputbox.w, 1, " ") term.setCursor(inputbox.x, inputbox.y) term.write(inputbox.value:sub(inputbox.scroll, inputbox.scroll + inputbox.w)) if inputbox == inputboxselected then term.setCursor(inputbox.x + #inputbox.value, inputbox.y) term.write("_") end end -- Draws a progress bar on the bottom of the window. -- Progress must be out of 100. local function drawProgressBar(progress) local barwidth = ww - 2 setToProgressColors() term.gpu().fill(xoffset+1, yoffset+wh-2, math.floor(progress/100*barwidth), 1, " ") setToInputColors() term.gpu().fill(math.floor(xoffset+1+progress/100*barwidth), yoffset+wh-2, math.floor((100-progress)/100)*barwidth, 1, " ") end local function installButton_press() local dlprogram = require("dlprogram") local currentFileBytes = 0 for state, arg in dlprogram.download(program.serveraddr, program.uid, version.name, inputboxes[1].value) do setToNormalColors() term.setCursor(xoffset+1, yoffset+wh-3) if state == dlprogram.states.sentfirstpacket then term.write("Esperando al servidor...") elseif state == dlprogram.states.newfile then term.write("Descargando "..arg.."...") currentFileBytes = 0 elseif state == dlprogram.states.dlfile then currentFileBytes = currentFileBytes + arg term.write("Descargando "..dlprogram.currentfile.."... ("..currentFileBytes.."B)") elseif state == dlprogram.states.iderror then term.write("ERROR! Parando descarga...") break elseif state == dlprogram.states.fileerror then term.write("Error de archivo!") break else term.write(state) end drawProgressBar(dlprogram.downloadedbytes/version.size*100) end term.setCursor(xoffset+1,yoffset+wh-2) setToProgressColors() term.write("Terminado!") require("os").sleep(3) exit = true end -- buttons have x, y, content, callback local buttons = {} local function createButtons() buttons = {} table.insert(buttons, {x=xoffset+ww-#installstring-1, y=yoffset+wh-2, content=installstring, callback=installButton_press}) end local function drawContents() setToNormalColors() term.setCursor(xoffset + 2, yoffset + 2) term.write(dlstring) setToInputColors() for i, inputbox in ipairs(inputboxes) do redrawInputBox(inputbox) end setToTitleColors() for i, button in ipairs(buttons) do term.setCursor(button.x, button.y) term.write(button.content) end end local function processEvents(name, ...) local args = table.pack(...) if name == "touch" then local x, y = math.floor(args[2]), math.floor(args[3]) if x == xoffset and y == yoffset then -- Exit button return true end for i, button in ipairs(buttons) do if x >= button.x and x-button.x < #button.content and y == button.y then button.callback() end end for i, inputbox in ipairs(inputboxes) do if x >= inputbox.x and x-inputbox.x < inputbox.w and y == inputbox.y then inputboxselected = inputbox term.setCursor(inputbox.x + #inputbox.value, inputbox.y) -- term.setCursorBlink(true) doesn't work... let's do our own variation setToInputColors() term.write("_") -- Done! return end end if inputboxselected ~= nil then inputboxselected.value = fs.canonical(inputboxselected.value).."/" do local lastselection = inputboxselected inputboxselected = nil -- Reset inputboxselected if clicked away redrawInputBox(lastselection) end end elseif name == "key_down" then if inputboxselected == nil then return end local code, char = args[3], string.char(args[2]) if args[2] == 0 or char == "\n" or char == "\t" or char == "\r" then return end -- Do not allow special characters (Shift, control, etc) -- The `char` argument actually returns characters already uppercased or shifted when neccesary, so we don't have -- to check for any special keys! if args[2] == 8 then -- Backspace inputboxselected.value = inputboxselected.value:sub(1, -2) else inputboxselected.value = inputboxselected.value .. char end redrawInputBox(inputboxselected) end end function dlmenu.show(prg, ver) program = prg version = ver defaultdlpath = "/prg/"..prg.uid.."/" createInputBoxes() createButtons() drawTitle() drawContents() while true do if processEvents(event.pull()) == true or exit then return end end end return dlmenu
nilq/small-lua-stack
null
local ipairs = ipairs local table_insert = table.insert local table_sort = table.sort local pcall = pcall local require = require require("orange.lib.globalpatches")() local ck = require("orange.lib.cookie") local utils = require("orange.utils.utils") local config_loader = require("orange.utils.config_loader") local dao = require("orange.store.dao") local dns_client = require("resty.dns.client") local HEADERS = { PROXY_LATENCY = "X-Orange-Proxy-Latency", UPSTREAM_LATENCY = "X-Orange-Upstream-Latency", } local loaded_plugins = {} local function load_node_plugins(config, store) ngx.log(ngx.DEBUG, "Discovering used plugins") local sorted_plugins = {} local plugins = config.plugins for _, v in ipairs(plugins) do local loaded, plugin_handler = utils.load_module_if_exists("orange.plugins." .. v .. ".handler") if not loaded then ngx.log(ngx.WARN, "The following plugin is not installed or has no handler: " .. v) else ngx.log(ngx.DEBUG, "Loading plugin: " .. v) table_insert(sorted_plugins, { name = v, handler = plugin_handler(store), }) end end table_sort(sorted_plugins, function(a, b) local priority_a = a.handler.PRIORITY or 0 local priority_b = b.handler.PRIORITY or 0 return priority_a > priority_b end) return sorted_plugins end -- ms local function now() return ngx.now() * 1000 end -- ########################### Orange ############################# local Orange = {} -- 执行过程: -- 加载配置 -- 实例化存储store -- 加载插件 -- 插件排序 function Orange.init(options) options = options or {} local store, config local status, err = pcall(function() local conf_file_path = options.config config = config_loader.load(conf_file_path) store = require("orange.store.mysql_store")(config.store_mysql) loaded_plugins = load_node_plugins(config, store) ngx.update_time() config.orange_start_at = ngx.now() end) if not status or err then ngx.log(ngx.ERR, "Startup error: " .. err) os.exit(1) end Orange.data = { store = store, config = config, } -- init dns_client assert(dns_client.init()) return config, store end function Orange.init_worker() -- 仅在 init_worker 阶段调用,初始化随机因子,仅允许调用一次 math.randomseed() -- 初始化定时器,清理计数器等 if Orange.data and Orange.data.store and Orange.data.config.store == "mysql" then local ok, err = ngx.timer.at(0, function(premature, store, config) local available_plugins = config.plugins for _, v in ipairs(available_plugins) do local load_success = dao.load_data_by_mysql(store, v) if not load_success then os.exit(1) end end end, Orange.data.store, Orange.data.config) if not ok then ngx.log(ngx.ERR, "failed to create the timer: ", err) return os.exit(1) end end for _, plugin in ipairs(loaded_plugins) do plugin.handler:init_worker() end end function Orange.init_cookies() ngx.ctx.__cookies__ = nil local COOKIE, err = ck:new() if not err and COOKIE then ngx.ctx.__cookies__ = COOKIE end end function Orange.redirect() ngx.ctx.ORANGE_REDIRECT_START = now() for _, plugin in ipairs(loaded_plugins) do plugin.handler:redirect() end local now_time = now() ngx.ctx.ORANGE_REDIRECT_TIME = now_time - ngx.ctx.ORANGE_REDIRECT_START ngx.ctx.ORANGE_REDIRECT_ENDED_AT = now_time end function Orange.rewrite() ngx.ctx.ORANGE_REWRITE_START = now() for _, plugin in ipairs(loaded_plugins) do plugin.handler:rewrite() end local now_time = now() ngx.ctx.ORANGE_REWRITE_TIME = now_time - ngx.ctx.ORANGE_REWRITE_START ngx.ctx.ORANGE_REWRITE_ENDED_AT = now_time end function Orange.access() ngx.ctx.ORANGE_ACCESS_START = now() for _, plugin in ipairs(loaded_plugins) do plugin.handler:access() end local now_time = now() ngx.ctx.ORANGE_ACCESS_TIME = now_time - ngx.ctx.ORANGE_ACCESS_START ngx.ctx.ORANGE_ACCESS_ENDED_AT = now_time ngx.ctx.ORANGE_PROXY_LATENCY = now_time - ngx.req.start_time() * 1000 ngx.ctx.ACCESSED = true end function Orange.balancer() for _, plugin in ipairs(loaded_plugins) do plugin.handler:balancer() end end function Orange.header_filter() if ngx.ctx.ACCESSED then local now_time = now() ngx.ctx.ORANGE_WAITING_TIME = now_time - ngx.ctx.ORANGE_ACCESS_ENDED_AT -- time spent waiting for a response from upstream ngx.ctx.ORANGE_HEADER_FILTER_STARTED_AT = now_time end for _, plugin in ipairs(loaded_plugins) do plugin.handler:header_filter() end if ngx.ctx.ACCESSED then ngx.header[HEADERS.UPSTREAM_LATENCY] = ngx.ctx.ORANGE_WAITING_TIME ngx.header[HEADERS.PROXY_LATENCY] = ngx.ctx.ORANGE_PROXY_LATENCY end end function Orange.body_filter() for _, plugin in ipairs(loaded_plugins) do plugin.handler:body_filter() end if ngx.ctx.ACCESSED then if ngx.ctx.ORANGE_HEADER_FILTER_STARTED_AT == nil then ngx.ctx.ORANGE_HEADER_FILTER_STARTED_AT = 0 end ngx.ctx.ORANGE_RECEIVE_TIME = now() - ngx.ctx.ORANGE_HEADER_FILTER_STARTED_AT end end function Orange.log() for _, plugin in ipairs(loaded_plugins) do plugin.handler:log() end end return Orange
nilq/small-lua-stack
null
object_intangible_vehicle_walker_at_st_walker_pcd = object_intangible_vehicle_shared_walker_at_st_walker_pcd:new { } ObjectTemplates:addTemplate(object_intangible_vehicle_walker_at_st_walker_pcd, "object/intangible/vehicle/walker_at_st_walker_pcd.iff")
nilq/small-lua-stack
null
local nmap = require "nmap" local coroutine = require "coroutine" local stdnse = require "stdnse" local table = require "table" local packet = require "packet" local ipOps = require "ipOps" local string = require "string" local target = require "target" local knx = require "knx" description = [[ Discovers KNX gateways by sending a KNX Search Request to the multicast address 224.0.23.12 including a UDP payload with destination port 3671. KNX gateways will respond with a KNX Search Response including various information about the gateway, such as KNX address and supported services. Further information: * DIN EN 13321-2 * http://www.knx.org/ ]] author = {"Niklaus Schiess <[email protected]>", "Dominik Schneider <[email protected]>"} license = "Same as Nmap--See https://nmap.org/book/man-legal.html" categories = {"discovery", "safe", "broadcast"} --- --@args timeout Max time to wait for a response. (default 3s) -- --@usage -- nmap --script knx-gateway-discover -e eth0 -- --@output -- Pre-scan script results: -- | knx-gateway-discover: -- | 192.168.178.11: -- | Body: -- | HPAI: -- | Port: 3671 -- | DIB_DEV_INFO: -- | KNX address: 15.15.255 -- | Decive serial: 00ef2650065c -- | Multicast address: 0.0.0.0 -- | Device MAC address: 00:05:26:50:06:5c -- | Device friendly name: IP-Viewer -- | DIB_SUPP_SVC_FAMILIES: -- | KNXnet/IP Core version 1 -- | KNXnet/IP Device Management version 1 -- | KNXnet/IP Tunnelling version 1 -- |_ KNXnet/IP Object Server version 1 -- prerule = function() if not nmap.is_privileged() then stdnse.verbose1("Not running due to lack of privileges.") return false end return true end --- Sends a knx search request -- @param query KNX search request message -- @param mcat Multicast destination address -- @param port Port to sent to local knxSend = function(query, mcast, mport) -- Multicast IP and UDP port local sock = nmap.new_socket() local status, err = sock:connect(mcast, mport, "udp") if not status then stdnse.debug1("%s", err) return end sock:send(query) sock:close() end local fam_meta = { __tostring = function (self) return ("%s version %d"):format( knx.knxServiceFamilies[self.service_id] or self.service_id, self.Version ) end } --- Parse a Search Response -- @param knxMessage Payload of captures UDP packet local knxParseSearchResponse = function(ips, results, knxMessage) local knx_header_length, knx_protocol_version, knx_service_type, knx_total_length, pos = knx.parseHeader(knxMessage) if not knx_header_length then stdnse.debug1("KNX header error: %s", knx_protocol_version) return end local message_format = '>B c1 c4 I2 BBB c1 I2 c2 c6 c4 c6 c30 BB' if #knxMessage - pos + 1 < string.packlen(message_format) then stdnse.debug1("Message too short for KNX message") return end local knx_hpai_structure_length, knx_hpai_protocol_code, knx_hpai_ip_address, knx_hpai_port, knx_dib_structure_length, knx_dib_description_type, knx_dib_knx_medium, knx_dib_device_status, knx_dib_knx_address, knx_dib_project_install_ident, knx_dib_dev_serial, knx_dib_dev_multicast_addr, knx_dib_dev_mac, knx_dib_dev_friendly_name, knx_supp_svc_families_structure_length, knx_supp_svc_families_description, pos = string.unpack(message_format, knxMessage, pos) knx_hpai_ip_address = ipOps.str_to_ip(knx_hpai_ip_address) knx_dib_description_type = knx.knxDibDescriptionTypes[knx_dib_description_type] knx_dib_knx_medium = knx.knxMediumTypes[knx_dib_knx_medium] knx_dib_dev_multicast_addr = ipOps.str_to_ip(knx_dib_dev_multicast_addr) knx_dib_dev_mac = stdnse.format_mac(knx_dib_dev_mac) local knx_supp_svc_families = {} knx_supp_svc_families_description = knx.knxDibDescriptionTypes[knx_supp_svc_families_description] or knx_supp_svc_families_description for i=0,(knx_total_length - pos),2 do local family = {} family.service_id, family.Version, pos = string.unpack('BB', knxMessage, pos) setmetatable(family, fam_meta) knx_supp_svc_families[#knx_supp_svc_families+1] = family end local search_response = stdnse.output_table() if nmap.debugging() > 0 then search_response.Header = stdnse.output_table() search_response.Header["Header length"] = knx_header_length search_response.Header["Protocol version"] = knx_protocol_version search_response.Header["Service type"] = "SEARCH_RESPONSE (0x0202)" search_response.Header["Total length"] = knx_total_length search_response.Body = stdnse.output_table() search_response.Body.HPAI = stdnse.output_table() search_response.Body.HPAI["Protocol code"] = stdnse.tohex(knx_hpai_protocol_code) search_response.Body.HPAI["IP address"] = knx_hpai_ip_address search_response.Body.HPAI["Port"] = knx_hpai_port search_response.Body.DIB_DEV_INFO = stdnse.output_table() search_response.Body.DIB_DEV_INFO["Description type"] = knx_dib_description_type search_response.Body.DIB_DEV_INFO["KNX medium"] = knx_dib_knx_medium search_response.Body.DIB_DEV_INFO["Device status"] = stdnse.tohex(knx_dib_device_status) search_response.Body.DIB_DEV_INFO["KNX address"] = knx.parseKnxAddress(knx_dib_knx_address) search_response.Body.DIB_DEV_INFO["Project installation identifier"] = stdnse.tohex(knx_dib_project_install_ident) search_response.Body.DIB_DEV_INFO["Decive serial"] = stdnse.tohex(knx_dib_dev_serial) search_response.Body.DIB_DEV_INFO["Multicast address"] = knx_dib_dev_multicast_addr search_response.Body.DIB_DEV_INFO["Device MAC address"] = knx_dib_dev_mac search_response.Body.DIB_DEV_INFO["Device friendly name"] = knx_dib_dev_friendly_name search_response.Body.DIB_SUPP_SVC_FAMILIES = knx_supp_svc_families else search_response.Body = stdnse.output_table() search_response.Body.HPAI = stdnse.output_table() search_response.Body.HPAI["Port"] = knx_hpai_port search_response.Body.DIB_DEV_INFO = stdnse.output_table() search_response.Body.DIB_DEV_INFO["KNX address"] = knx.parseKnxAddress(knx_dib_knx_address) search_response.Body.DIB_DEV_INFO["Decive serial"] = stdnse.tohex(knx_dib_dev_serial) search_response.Body.DIB_DEV_INFO["Multicast address"] = knx_dib_dev_multicast_addr search_response.Body.DIB_DEV_INFO["Device MAC address"] = knx_dib_dev_mac search_response.Body.DIB_DEV_INFO["Device friendly name"] = knx_dib_dev_friendly_name search_response.Body.DIB_SUPP_SVC_FAMILIES = knx_supp_svc_families end ips[#ips+1] = knx_hpai_ip_address results[knx_hpai_ip_address] = search_response end --- Listens for knx search responses -- @param interface Network interface to listen on. -- @param timeout Maximum time to listen. -- @param ips Table to put IP addresses into. -- @param result Table to put responses into. local knxListen = function(interface, timeout, ips, results) local condvar = nmap.condvar(results) local start = nmap.clock_ms() local listener = nmap.new_socket() local threads = {} local status, l3data, _ local filter = 'dst host ' .. interface.address .. ' and udp src port 3671' listener:set_timeout(100) listener:pcap_open(interface.device, 1024, true, filter) while (nmap.clock_ms() - start) < timeout do status, _, _, l3data = listener:pcap_receive() if status then local p = packet.Packet:new(l3data, #l3data) -- Skip IP and UDP headers local knxMessage = string.sub(l3data, p.ip_hl*4 + 8 + 1) local co = stdnse.new_thread(knxParseSearchResponse, ips, results, knxMessage) threads[co] = true; end end repeat for thread in pairs(threads) do if coroutine.status(thread) == "dead" then threads[thread] = nil end end if ( next(threads) ) then condvar "wait" end until next(threads) == nil; condvar("signal") end --- Returns the network interface used to send packets to a target host. -- @param target host to which the interface is used. -- @return interface Network interface used for target host. local getInterface = function(target) -- First, create dummy UDP connection to get interface local sock = nmap.new_socket() local status, err = sock:connect(target, "12345", "udp") if not status then stdnse.verbose1("%s", err) return end local status, address, _, _, _ = sock:get_info() if not status then stdnse.verbose1("%s", err) return end for _, interface in pairs(nmap.list_interfaces()) do if interface.address == address then return interface end end end --- Make a dummy connection and return a free source port -- @param target host to which the interface is used. -- @return lport Local port which can be used in KNX messages. local getSourcePort = function(target) local socket = nmap.new_socket() local _, _ = socket:connect(target, "12345", "udp") local _, _, lport, _, _ = socket:get_info() return lport end action = function() local timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) timeout = (timeout or 3) * 1000 local ips, results = {}, {} local mcast = "224.0.23.12" local mport = 3671 local lport = getSourcePort(mcast) -- Check if a valid interface was provided local interface = nmap.get_interface() if interface then interface = nmap.get_interface_info(interface) else interface = getInterface(mcast) end if not interface then return ("\n ERROR: Couldn't get interface for %s"):format(mcast) end -- Launch listener thread stdnse.new_thread(knxListen, interface, timeout, ips, results) -- Craft raw query local query = knx.query(0x0201, interface.address, lport) -- Small sleep so the listener doesn't miss the response stdnse.sleep(0.5) -- Send query knxSend(query, mcast, mport) -- Wait for listener thread to finish local condvar = nmap.condvar(results) condvar("wait") -- Check responses if #ips > 0 then local sort_by_ip = function(a, b) return ipOps.compare_ip(a, "lt", b) end table.sort(ips, sort_by_ip) local output = stdnse.output_table() for i=1, #ips do local ip = ips[i] output[ip] = results[ip] if target.ALLOW_NEW_TARGETS then target.add(ip) end end return output end end
nilq/small-lua-stack
null
x = dofile('wheel.lc') ws2812.set_brightness(1) tmr.alarm(1,100,1,function () x.single() end) --tmr.alarm(1,100,1,function () x.wave(0.1) end) --tmr.stop(1) --r,g,b=ws2812.hsv2rgb(0.334,1,1);print(r,g,b) --r,g,b=ws2812.hsv2rgb(1,1,1);print(r,g,b) --r,g,b=ws2812.hsv2rgb(0.5,1,1);print(r,g,b) --ws2812.write(4,string.char(255,0,0):rep(10))
nilq/small-lua-stack
null
object_tangible_collection_beetle_young_cave = object_tangible_collection_shared_beetle_young_cave:new { gameObjectType = 8211,} ObjectTemplates:addTemplate(object_tangible_collection_beetle_young_cave, "object/tangible/collection/beetle_young_cave.iff")
nilq/small-lua-stack
null
return { map_id = 10001, id = 1335001, stages = { { stageIndex = 1, failCondition = 1, timeCount = 300, passCondition = 1, backGroundStageID = 1, totalArea = { -80, 20, 90, 70 }, playerArea = { -80, 20, 45, 68 }, enemyArea = {}, fleetCorrdinate = { -80, 0, 75 }, waves = { { triggerType = 1, waveIndex = 100, preWaves = {}, triggerParams = { timeout = 0.5 } }, { triggerType = 10, waveIndex = 105, conditionType = 1, preWaves = { 100 }, triggerParam = {}, spawn = { { delay = 9, prefab = "hanbingquyu", life_time = 13, behaviours = 10014, coordinate = { 40, 0, 30 }, cld_data = { 40 } }, { delay = 9, prefab = "hanbingquyu", life_time = 13, behaviours = 10015, coordinate = { -80, 0, 80 }, cld_data = { 40 } }, { delay = 57, prefab = "hanbingquyu", life_time = 13, behaviours = 10014, coordinate = { 40, 0, 30 }, cld_data = { 40 } }, { delay = 57, prefab = "hanbingquyu", life_time = 13, behaviours = 10015, coordinate = { -80, 0, 80 }, cld_data = { 40 } }, { delay = 105, prefab = "hanbingquyu", life_time = 13, behaviours = 10014, coordinate = { 40, 0, 30 }, cld_data = { 40 } }, { delay = 105, prefab = "hanbingquyu", life_time = 13, behaviours = 10015, coordinate = { -80, 0, 80 }, cld_data = { 40 } }, { delay = 153, prefab = "hanbingquyu", life_time = 13, behaviours = 10014, coordinate = { 40, 0, 30 }, cld_data = { 40 } }, { delay = 153, prefab = "hanbingquyu", life_time = 13, behaviours = 10015, coordinate = { -80, 0, 80 }, cld_data = { 40 } }, { delay = 201, prefab = "hanbingquyu", life_time = 13, behaviours = 10014, coordinate = { 40, 0, 30 }, cld_data = { 40 } }, { delay = 201, prefab = "hanbingquyu", life_time = 13, behaviours = 10015, coordinate = { -80, 0, 80 }, cld_data = { 40 } }, { delay = 249, prefab = "hanbingquyu", life_time = 13, behaviours = 10014, coordinate = { 40, 0, 30 }, cld_data = { 40 } }, { delay = 249, prefab = "hanbingquyu", life_time = 13, behaviours = 10015, coordinate = { -80, 0, 80 }, cld_data = { 40 } } } }, { triggerType = 0, key = true, waveIndex = 101, conditionType = 1, preWaves = { 100 }, triggerParam = {}, spawn = { { monsterTemplateID = 13100601, moveCast = true, delay = 0, corrdinate = { -5, 0, 55 }, bossData = { hpBarNum = 100, icon = "jinghuazhe" }, buffList = { 8001, 8007 }, phase = { { switchType = 1, switchTo = 1, index = 0, switchParam = 0.5, setAI = 20006, addWeapon = {}, removeWeapon = {} }, { index = 1, switchParam = 2.5, switchTo = 2, switchType = 1, addWeapon = { 619504, 619505 }, removeWeapon = {} }, { index = 2, switchParam = 2.5, switchTo = 3, switchType = 1, addWeapon = { 619506, 619501 }, removeWeapon = { 619504, 619505 } }, { index = 3, switchParam = 1, switchTo = 4, switchType = 1, addWeapon = { 619502, 619503 }, removeWeapon = { 619501 } }, { index = 4, switchParam = 4, switchTo = 5, switchType = 1, addWeapon = { 619501 }, removeWeapon = {} }, { index = 5, switchParam = 9, switchTo = 6, switchType = 1, addWeapon = { 619508, 619509 }, removeWeapon = { 619501, 619502, 619503 } }, { index = 6, switchParam = 4.5, switchTo = 8, switchType = 1, addWeapon = { 619507 }, removeWeapon = { 619508, 619509 } }, { index = 8, switchParam = 3.5, switchTo = 9, switchType = 1, addWeapon = { 619510 }, removeWeapon = {} }, { index = 9, switchParam = 2, switchTo = 10, switchType = 1, addWeapon = { 619511 }, removeWeapon = { 619507, 619510 } }, { index = 10, switchParam = 1, switchTo = 11, switchType = 1, addWeapon = {}, removeWeapon = { 619506, 619511 } }, { index = 11, switchParam = 3, switchTo = 12, switchType = 1, addWeapon = { 619512 }, removeWeapon = {} }, { index = 12, switchParam = 1.6, switchTo = 13, switchType = 1, addWeapon = { 619513 }, removeWeapon = { 619512 } }, { index = 13, switchParam = 9, switchTo = 14, switchType = 1, addWeapon = { 619514 }, removeWeapon = { 619513 } }, { index = 14, switchParam = 3, switchTo = 15, switchType = 1, addWeapon = { 619501, 619502, 619503 }, removeWeapon = { 619514 } }, { index = 15, switchParam = 0.2, switchTo = 0, switchType = 1, addWeapon = {}, removeWeapon = { 619501, 619502, 619503 } } } } } }, { triggerType = 8, waveIndex = 900, preWaves = { 101 }, triggerParams = {} } } } }, fleet_prefab = {} }
nilq/small-lua-stack
null
local json = require("cjson") local kongPathWhitelist = {} kongPathWhitelist.PRIORITY = 2400 local kong = kong local ngx = ngx local function match(source,target, regex) if regex then local from = ngx.re.find(source, target) if from == 1 then return true end end if not regex and source == target then return true end return false end local function get_path() local path = kong.request.get_path() local route = ngx.ctx.route if false == route.strip_path then return path end local from, to,req_path for _, prefix in ipairs(route.paths) do from, to = ngx.re.find(path, prefix, "jo") if from == 1 then req_path = string.sub(path, to+1, #path) from = ngx.re.find(req_path, "/", "jo") if not from then req_path = '/' .. req_path end return req_path end end return "" end function kongPathWhitelist:access(config) local white_paths = config.white_paths local regex = config.regex local target_path = get_path() for _, path in ipairs(white_paths) do if match(target_path, path, regex) then return end end kong.response.exit(403, json.encode({message = "path not allowed"}), { ["Content-Type"] = "application/json"}) end return kongPathWhitelist
nilq/small-lua-stack
null
------------------------------------------------------------------------------- -- Coordinate transformation ------------------------------------------------------------------------------- function getTransform(center, scale, rot, res) local h = 200 * scale local t = torch.eye(3) -- Scaling t[1][1] = res / h t[2][2] = res / h -- Translation t[1][3] = res * (-center[1] / h + .5) t[2][3] = res * (-center[2] / h + .5) -- Rotation if rot ~= 0 then rot = -rot local r = torch.eye(3) local ang = rot * math.pi / 180 local s = math.sin(ang) local c = math.cos(ang) r[1][1] = c r[1][2] = -s r[2][1] = s r[2][2] = c -- Need to make sure rotation is around center local t_ = torch.eye(3) t_[1][3] = -res/2 t_[2][3] = -res/2 local t_inv = torch.eye(3) t_inv[1][3] = res/2 t_inv[2][3] = res/2 t = t_inv * r * t_ * t end return t end function transform(pt, center, scale, rot, res, invert) local pt_ = torch.ones(3) pt_[1],pt_[2] = pt[1]-1,pt[2]-1 local t = getTransform(center, scale, rot, res) if invert then t = torch.inverse(t) end local new_point = (t*pt_):sub(1,2):add(1e-4) return new_point:int():add(1) end function crop(img, center, scale, rot, res) local ul = transform({1,1}, center, scale, 0, res, true) local br = transform({res+1,res+1}, center, scale, 0, res, true) local pad = math.floor(torch.norm((ul - br):float())/2 - (br[1]-ul[1])/2) if rot ~= 0 then ul = ul - pad br = br + pad end local newDim,newImg,ht,wd if img:size():size() > 2 then newDim = torch.IntTensor({img:size(1), br[2] - ul[2], br[1] - ul[1]}) newImg = torch.zeros(newDim[1],newDim[2],newDim[3]) ht = img:size(2) wd = img:size(3) else newDim = torch.IntTensor({br[2] - ul[2], br[1] - ul[1]}) newImg = torch.zeros(newDim[1],newDim[2]) ht = img:size(1) wd = img:size(2) end local newX = torch.Tensor({math.max(1, -ul[1] + 2), math.min(br[1], wd+1) - ul[1]}) local newY = torch.Tensor({math.max(1, -ul[2] + 2), math.min(br[2], ht+1) - ul[2]}) local oldX = torch.Tensor({math.max(1, ul[1]), math.min(br[1], wd+1) - 1}) local oldY = torch.Tensor({math.max(1, ul[2]), math.min(br[2], ht+1) - 1}) if newDim:size(1) > 2 then newImg:sub(1,newDim[1],newY[1],newY[2],newX[1],newX[2]):copy(img:sub(1,newDim[1],oldY[1],oldY[2],oldX[1],oldX[2])) else newImg:sub(newY[1],newY[2],newX[1],newX[2]):copy(img:sub(oldY[1],oldY[2],oldX[1],oldX[2])) end if rot ~= 0 then newImg = image.rotate(newImg, rot * math.pi / 180, 'bilinear') if newDim:size(1) > 2 then newImg = newImg:sub(1,newDim[1],pad,newDim[2]-pad,pad,newDim[3]-pad) else newImg = newImg:sub(pad,newDim[1]-pad,pad,newDim[2]-pad) end end newImg = image.scale(newImg,res,res) return newImg end local magic_gaussian = image.gaussian(7) function drawGaussian(img, pt, sigma) -- Check if the gaussian is in-bounds local ul = {math.floor(pt[1] - 3 * sigma), math.floor(pt[2] - 3 * sigma)} local br = {math.floor(pt[1] + 3 * sigma), math.floor(pt[2] + 3 * sigma)} -- return the image otherwise if (ul[1] > img:size(2) or ul[2] > img:size(1) or br[1] < 1 or br[2] < 1) then return img end -- Generate gaussian local size = 6 * sigma + 1 -- Avoid the need of generating the gaussian for each sample local g = magic_gaussian:clone()--image.gaussian(size) -- , 1 / size, 1) -- Usable gaussian range local g_x = {math.max(1, -ul[1]), math.min(br[1], img:size(2)) - math.max(1, ul[1]) + math.max(1, -ul[1])} local g_y = {math.max(1, -ul[2]), math.min(br[2], img:size(1)) - math.max(1, ul[2]) + math.max(1, -ul[2])} -- Image range local img_x = {math.max(1, ul[1]), math.min(br[1], img:size(2))} local img_y = {math.max(1, ul[2]), math.min(br[2], img:size(1))} assert(g_x[1] > 0 and g_y[1] > 0) img:sub(img_y[1], img_y[2], img_x[1], img_x[2]):add(g:sub(g_y[1], g_y[2], g_x[1], g_x[2])) img[img:gt(1)] = 1 return img end function shuffleLR(x) local dim if x:nDimension() == 4 then dim = 2 else assert(x:nDimension() == 3) dim = 1 end -- Keypoints pairs for 300W_LP, 300VW, 300W and LS3D-W datasets local matchedParts = { {1,17}, {2,16}, {3,15}, {4,14}, {5,13}, {6,12}, {7,11}, {8,10}, {18,27},{19,26},{20,25},{21,24},{22,23}, {37,46},{38,45},{39,44},{40,43}, {42,47},{41,48}, {32,36},{33,35}, {51,53},{50,54},{49,55},{62,64},{61,65},{68,66},{60,56}, {59,57} } for i = 1,#matchedParts do local idx1, idx2 = unpack(matchedParts[i]) local tmp = x:narrow(dim, idx1, 1):clone() x:narrow(dim, idx1, 1):copy(x:narrow(dim, idx2, 1)) x:narrow(dim, idx2, 1):copy(tmp) end return x end function flip(x) require 'image' local y = torch.FloatTensor(x:size()) for i = 1, x:size(1) do image.hflip(y[i], x[i]:float()) end return y:typeAs(x) end
nilq/small-lua-stack
null
local ArkadiusTradeToolsSales = ArkadiusTradeTools.Modules.Sales local MASTER_WRIT_TYPE_BLACKSMITHING = 1 local MASTER_WRIT_TYPE_TAILORING = 2 local MASTER_WRIT_TYPE_WOODWORKING = 3 local MASTER_WRIT_TYPE_ENCHANTING = 4 local MASTER_WRIT_TYPE_ALCHEMY = 5 local MASTER_WRIT_TYPE_PROVISIONING = 6 local MASTER_WRIT_TYPE_JEWELRY = 7 local MASTER_WRIT_TYPES = { [119563] = MASTER_WRIT_TYPE_BLACKSMITHING, [119680] = MASTER_WRIT_TYPE_BLACKSMITHING, [121527] = MASTER_WRIT_TYPE_BLACKSMITHING, [121529] = MASTER_WRIT_TYPE_BLACKSMITHING, [119694] = MASTER_WRIT_TYPE_TAILORING, [119695] = MASTER_WRIT_TYPE_TAILORING, [121532] = MASTER_WRIT_TYPE_TAILORING, [121533] = MASTER_WRIT_TYPE_TAILORING, [119681] = MASTER_WRIT_TYPE_WOODWORKING, [119682] = MASTER_WRIT_TYPE_WOODWORKING, [121530] = MASTER_WRIT_TYPE_WOODWORKING, [121531] = MASTER_WRIT_TYPE_WOODWORKING, [119564] = MASTER_WRIT_TYPE_ENCHANTING, [121528] = MASTER_WRIT_TYPE_ENCHANTING, [119696] = MASTER_WRIT_TYPE_ALCHEMY, [119698] = MASTER_WRIT_TYPE_ALCHEMY, [119705] = MASTER_WRIT_TYPE_ALCHEMY, [119818] = MASTER_WRIT_TYPE_ALCHEMY, [119820] = MASTER_WRIT_TYPE_ALCHEMY, [119704] = MASTER_WRIT_TYPE_ALCHEMY, [119701] = MASTER_WRIT_TYPE_ALCHEMY, [119702] = MASTER_WRIT_TYPE_ALCHEMY, [119699] = MASTER_WRIT_TYPE_ALCHEMY, [119703] = MASTER_WRIT_TYPE_ALCHEMY, [119700] = MASTER_WRIT_TYPE_ALCHEMY, [119819] = MASTER_WRIT_TYPE_ALCHEMY, [119693] = MASTER_WRIT_TYPE_PROVISIONING, [138798] = MASTER_WRIT_TYPE_JEWELRY, [138799] = MASTER_WRIT_TYPE_JEWELRY, [153737] = MASTER_WRIT_TYPE_JEWELRY, [153738] = MASTER_WRIT_TYPE_JEWELRY, [153739] = MASTER_WRIT_TYPE_JEWELRY, } local MASTER_WRIT_BASE_MATERIAL = { [188] = "|H0:item:64489:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Rubedite Ignots [190] = "|H0:item:64506:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Rubedo Leather [192] = "|H0:item:64502:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Ruby Ash [194] = "|H0:item:64504:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Ancient Silk [255] = "|H0:item:135146:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Platinum } local MASTER_WRIT_BASE_MATERIAL_QUANTITY = { [18] = 15, -- Neck [24] = 10, -- Ring [26] = 13, -- Helmet, Light -- [27] = -- Neck, Light [28] = 15, -- Chest, Light [29] = 13, -- Shoulder, Light [30] = 13, -- Belt, Light [31] = 14, -- Legs, Light [32] = 13, -- Feet, Light -- [33] = -- Ring, Light [34] = 13, -- Gloves, Light [35] = 13, -- Helmet, Medium -- [36] = -- Neck, Medium [37] = 15, -- Chest, Medium [38] = 13, -- Shoulder, Medium [39] = 13, -- Belt, Medium [40] = 14, -- Legs, Medium [41] = 13, -- Feet, Medium -- [42] = -- Ring, Medium [43] = 13, -- Gloves, Medium [44] = 13, -- Helmet, Heavy -- [45] = -- Neck, Heavy [46] = 15, -- Chest, Heavy [47] = 13, -- Shoulder, Heavy [48] = 13, -- Belt, Heavy [49] = 14, -- Legs, Heavy [50] = 13, -- Feet, Heavy -- [51] = -- Ring, Heavy [52] = 13, -- Gloves, Heavy [53] = 11, -- 1H Axe [56] = 11, -- 1H Mace [59] = 11, -- 1H Sword [62] = 11, -- Dagger [65] = 14, -- Shield -- [66] = -- Rune/Off-Hand [67] = 14, -- 2H Sword [68] = 14, -- 2H Axe [69] = 14, -- 2H Maul [70] = 12, -- Bow [71] = 12, -- Restoration Staff [72] = 12, -- Inferno Staff [73] = 12, -- Frost Staff [74] = 12, -- Lightning Staff } local MASTER_WRIT_TEMPERS = { [MASTER_WRIT_TYPE_BLACKSMITHING] = { [2] = "|H0:item:54170:31:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Honing Stone [3] = "|H0:item:54171:32:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Dwarven Oil [4] = "|H0:item:54172:33:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Grain Solvent [5] = "|H0:item:54173:34:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Tempering Alloy }, [MASTER_WRIT_TYPE_TAILORING] = { [2] = "|H0:item:54174:31:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Hemming [3] = "|H0:item:54175:32:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Embroidery [4] = "|H0:item:54176:33:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Elegent Lining [5] = "|H0:item:54177:34:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Dreugh Wax }, [MASTER_WRIT_TYPE_WOODWORKING] = { [2] = "|H0:item:54178:31:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Pitch [3] = "|H0:item:54179:32:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Turpen [4] = "|H0:item:54180:33:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Mastic [5] = "|H0:item:54181:34:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Rosin }, [MASTER_WRIT_TYPE_JEWELRY] = { [2] = "|H0:item:135147:31:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Terne [3] = "|H0:item:135148:32:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Iridium [4] = "|H0:item:135149:33:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Zircon [5] = "|H0:item:135150:34:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Chromium }, } local MASTER_WRIT_TEMPERS_QUANTITY = { [MASTER_WRIT_TYPE_BLACKSMITHING] = { [2] = 2, [3] = 3, [4] = 4, [5] = 8, }, [MASTER_WRIT_TYPE_TAILORING] = { [2] = 2, [3] = 3, [4] = 4, [5] = 8, }, [MASTER_WRIT_TYPE_WOODWORKING] = { [2] = 2, [3] = 3, [4] = 4, [5] = 8, }, [MASTER_WRIT_TYPE_JEWELRY] = { [2] = 1, [3] = 2, [4] = 3, [5] = 4, }, } local MASTER_WRIT_TRAITS = { [1] = "|H0:item:23203:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Powered, Chysolite [2] = "|H0:item:23204:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Charged, Amethyst [3] = "|H0:item:4486:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Precise, Ruby [4] = "|H0:item:810:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Infused, Jade [5] = "|H0:item:813:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Defending, Turquoise [6] = "|H0:item:23165:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Training, Carnelian [7] = "|H0:item:23149:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Sharpened, Fire Opal [8] = "|H0:item:16291:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Decisive, Citrine [11] = "|H0:item:4456:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Sturdy, Quartz [12] = "|H0:item:23219:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Impenetrable, Diamond [13] = "|H0:item:30221:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Reinforced, Sardonyx [14] = "|H0:item:23221:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Well-Fitted, Almandine [15] = "|H0:item:4442:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Training, Emerald [16] = "|H0:item:30219:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Infused, Bloodstone [17] = "|H0:item:23171:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Invigorating, Garnet [18] = "|H0:item:23173:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Divines, Sapphire [21] = "|H0:item:135156:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Healthy, Antimony [22] = "|H0:item:135155:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Arcane, Cobalt [23] = "|H0:item:135157:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Robust, Zinc [25] = "|H0:item:56862:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Nirnhoned, Fortified Nirncrux [26] = "|H0:item:56863:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Nirnhoned, Potent Nirncrux [28] = "|H0:item:139412:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Swift, Gilding Wax [29] = "|H0:item:139413:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Harmony, Dibellium [30] = "|H0:item:139409:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Triune, Dawn-Prism [31] = "|H0:item:139414:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Bloodthirsty, Slaughterstone [32] = "|H0:item:139410:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Protective, Titanium [33] = "|H0:item:139411:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", -- Infused, Aurbic Amber } function ArkadiusTradeToolsSales:GetMasterWritComponents(itemLink) if ((not self:IsItemLink(itemLink) or (GetItemLinkItemType(itemLink) ~= ITEMTYPE_MASTER_WRIT))) then return {} end local itemId, writ1, writ2, quality, writ4, trait, style = itemLink:match(".+:item:(%d+):%d+:%d+:%d+:%d+:%d+:(%d+):(%d+):(%d+):(%d+):(%d+):(%d+):") itemId = tonumber(itemId) writ1 = tonumber(writ1) writ2 = tonumber(writ2) quality = tonumber(quality) writ4 = tonumber(writ4) trait = tonumber(trait) style = tonumber(style) local writType = MASTER_WRIT_TYPES[itemId] if (writType == nil) then -- CHAT_ROUTER:AddSystemMessage("ATT: Unknown master writ item id " .. itemId) return {} end local components = {} local component if ((writType == MASTER_WRIT_TYPE_BLACKSMITHING) or (writType == MASTER_WRIT_TYPE_TAILORING) or (writType == MASTER_WRIT_TYPE_WOODWORKING) or (writType == MASTER_WRIT_TYPE_JEWELRY)) then --- writ1 = item type --- --- writ2 = item class --- component = { itemLink = MASTER_WRIT_BASE_MATERIAL[writ2], quantity = MASTER_WRIT_BASE_MATERIAL_QUANTITY[writ1] } table.insert(components, component) if (writType ~= MASTER_WRIT_TYPE_JEWELRY) then component = { itemLink = GetItemStyleMaterialLink(style), quantity = 1 } table.insert(components, component) end component = { itemLink = MASTER_WRIT_TRAITS[trait], quantity = 1 } table.insert(components, component) for i = 2, quality do component = { itemLink = MASTER_WRIT_TEMPERS[writType][i], quantity = MASTER_WRIT_TEMPERS_QUANTITY[writType][i] } table.insert(components, component) end end --- validate all components --- for i = 1, #components do if ((components[i].itemLink == nil) or (components[i].quantity == nil)) then return {} end end return components end
nilq/small-lua-stack
null
ESX = nil TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) RegisterNetEvent('esx_policedog:hasClosestDrugs') AddEventHandler('esx_policedog:hasClosestDrugs', function(playerId) local target = ESX.GetPlayerFromId(playerId) local src = source local inventory = target.inventory for i = 1, #inventory do for k, v in pairs(Config.Drugs) do if inventory[i].name == v and inventory[i].count > 0 then TriggerClientEvent('esx_policedog:hasDrugs', src, true) return end end end TriggerClientEvent('esx_policedog:hasDrugs', src, false) end)
nilq/small-lua-stack
null
if SERVER then function NPCOTHER(ply) cinemaCast() end util.AddNetworkString("Instructeur") util.AddNetworkString("NPCACT") resource.AddSingleFile("materials/icon.png") player_manager.AddValidModel( "Zeldris", 'adiris' ); list.Set( "PlayerOptionsModel", "Zeldris", 'adiris' ); hook.Add("PlayerSay", "MenuPrimaire", function(ply, text) if text == "/menu" then cinemaCast() end end) function cinemaCast() net.Start("MenuTest") net.Send(ply) end hook.Add("PlayerSay", "Instructeur", function(ply,text) if text == "/inst" then local players = {} for _, entity in pairs(ents.FindInSphere(ply:GetPos(), 250)) do if entity:IsPlayer() then table.insert(players, entity) end end net.Start("Instructeur") net.WriteString(ply:Nick()) net.Send(players) end end) end if CLIENT then net.Receive("MenuTest", function() local liyi = vgui.Create("DFrame") liyi:SetSize(ScrW()-200, ScrH()-200) liyi:SetPos(100, 100) liyi:MakePopup() liyi:SetDraggable(true) liyi:SetSizable(true) liyi:SetMinHeight(100) liyi:SetMinWidth(100) liyi:SetTitle("Test2") local nott = vgui.Create("DButton", liyi) nott:SetParent(liyi) nott:SetText("Fermer") nott:SetPos(200,200) nott.DoClick = function() liyi:Close() end end) hook.Add("Think", "CinemaOpen", function() if input.IsKeyDown(KEY_PAD_PLUS) then local rose = vgui.Create("DFrame") rose:SetSize(ScrW(), ScrH()) rose:SetPos(0,0) rose:SetDraggable(false) rose:SetScreenLock(false) rose.Paint = function(s,w,h) draw.RoundedBox(0,0,0,w,h,Color(0,0,0,0)) end local arac = vgui.Create("DPanel", rose) arac:SetSize(ScrW(), ScrH()/6) arac:SetPos(0,0) arac.Paint = function(s,w,h) draw.RoundedBox(0,0,0,w,h,Color(0,0,0)) end local acra = vgui.Create("DPanel", rose) acra:SetSize(ScrW(), ScrH()/6) acra:SetPos(0,ScrH()-ScrH()/6) acra.Paint = function(s,w,h) draw.RoundedBox(0,0,0,w,h,Color(0,0,0)) end local alme = Material("materials/icon.png") local cass = vgui.Create("DImageButton", rose) cass:SetImage("materials/icon.png") cass:SetSize(30,30) cass:SetPos(ScrW()-30,0) cass.DoClick = function() rose:Remove() end hook.Add("Think", "CinemaClose", function() if input.IsKeyDown(KEY_PAD_MINUS) then rose:Remove() end end) end end) net.Receive("Instructeur", function(len, ply) local ara = net.ReadString() chat.AddText( Color(0,77,124), "[Instructeur] ", Color(255, 255, 255), ara .. " cherche un instructeur.") end) end
nilq/small-lua-stack
null
function module(modname,...) end require "util" util = {} util.table = {} util.table.deepcopy = table.deepcopy util.multiplystripes = multiplystripes
nilq/small-lua-stack
null
local path = string.sub(..., 1, string.len(...) - string.len(".hooks.onUpdate")) local context = require(path.. ".core.stack") ---Sets a callback on any updatefor the current element (can have multiple) ---Use this to get logic outside of rendering function ---@param callback function return function (callback) local activeContext = context.getContext() if not activeContext.element.callbacks['onUpdate'] then activeContext.element.callbacks.onUpdate = {} end activeContext.element.callbacks.onUpdate[#activeContext.element.callbacks.onUpdate+1] = callback end
nilq/small-lua-stack
null
return {'dek','dekbed','dekbedje','dekbedovertrek','dekbeplating','dekblad','dekbord','dekdoorvoer','deken','dekenaal','dekenaat','dekenij','dekenkist','dekgeld','dekglaasje','dekhengst','dekhut','dekken','dekker','dekking','dekkingsaankoop','dekkingsfout','dekkingsgebied','dekkingsgraad','dekkingspakket','dekkingspercentage','dekkingsplan','dekkingsstelsel','dekkist','dekkisten','dekkleed','dekkleur','dekknecht','deklaag','deklading','deklanding','deklast','deklat','dekleiding','dekmantel','deknaam','dekolonisatie','dekolonisatiegeschiedenis','dekolonisatieproces','dekoloniseren','dekolonisering','dekplaat','dekpunt','dekschaal','dekschild','dekschub','dekschuit','deksel','deksels','dekstation','deksteen','dekstier','dekstoel','dekstro','dekstuk','dektijd','dekuitrusting','dekverf','dekverlichting','dekvloer','dekwasslang','dekwassysteem','dekzeil','dekzwabber','dekzand','dekdoorvoering','dekvrucht','dekhuis','dekzandrug','dekbedhoes','dekdienst','dekkingsmiddel','dekkingstekort','deklicentie','dekseizoen','dekzool','dekkingsvoorstel','dekglas','dekmatras','dekweefsel','dekan','dekker','dekbedden','dekbedovertrekken','dekbladen','dekborden','dekdoorvoeringen','dekenijen','dekens','dekentje','dekentjes','dekhengsten','dekkend','dekkende','dekkers','dekkingen','dekkingsaankopen','dekkingsvoorschriften','dekkleden','dekkleuren','dekknechten','deklagen','deklasten','dekleidingen','dekmantels','deknamen','dekplaten','dekschalen','dekschilden','dekschubben','dekselse','dekseltje','dekseltjes','dekstenen','dekstoelen','dekstukken','dekt','dekte','dekten','dekverven','dekwerktuigen','dekenale','dekenaten','dekenkisten','dekhutten','dekkingsfouten','dekkingspercentages','dekkingsplannen','dekknechts','dekladingen','deklatten','dekoloniseerde','dekschuiten','dekstieren','dekzeilen','dekzwabbers','dekvloeren','dekje','dekzandruggen','dekjes','dekkingsgraden','dekkingsmiddelen','deklaagje','dekpunten','dekkingstekorten','dekmanteltje','dekmatrassen','dekbedjes','dekplaatje','dekbedhoesje'}
nilq/small-lua-stack
null
-- This web page shows relevant configuration for the Conquest - OpenClinica link -- mvh 20120826 -- To let this work put this in dicom.ini in the cgi-bin folder --[[ # DefaultPage [DefaultPage] source = *.lua [OpenClinica] Source=(local) PatientIDkeep=cookie AnonymizeOn=transmission [email protected]: password=XXXXXXXXXXX ]]-- local source = gpps('OpenClinica', 'Source', '(local)'); local patientidwhere = gpps('OpenClinica', 'PatientIDkeep', 'cookie'); local anonymizeon = gpps('OpenClinica', 'AnonymizeOn', 'transmission'); local targetserver = gpps('OpenClinica', 'TargetServer', '[email protected]:'); local password = gpps('OpenClinica', 'Password', 'XXXXXXXXXXX'); local serverversion = servercommand('display_status:'); if serverversion==nil then HTML('Content-type: text/html\n\n'); print([[ <HEAD><TITLE>OpenClinica Conquest Link Configuration</TITLE> </HEAD> <BODY BGCOLOR='FFCFCF'> <H3>The web server is up, but the DICOM server is not accessible</H3> </BODY> ]]) return end serverversion = string.sub(serverversion, string.find(serverversion, 'version........')); HTML('Content-type: text/html\n\n'); print([[ <HEAD><TITLE>OpenClinica Conquest Link Configuration</TITLE> </HEAD> <BODY BGCOLOR='CFDFCF'> <H3>Conquest ]]..version..[[ OpenClinica Conquest Link Configuration</H3> <TABLE border="1"> <TR> <TH>Item</TH><TH>Value</TH><TH>Location</TH><TH>Section</TH> </TR> <TR> <TD>CGI version</TD><TD>]]..version..[[</TD><TD>cgi-bin/dgate</TD><TD>n/a</TD> </TR> <TR> <TD>Source</TD><TD>]]..source..[[</TD><TD>cgi-bin/dicom.ini</TD><TD>OpenClinica</TD> </TR> <TR> <TD>Patient ID stored in</TD><TD>]]..patientidwhere..[[</TD><TD>cgi-bin/dicom.ini</TD><TD>OpenClinica</TD> </TR> <TR> <TR> <TD>Anonymize on</TD><TD>]]..anonymizeon..[[</TD><TD>cgi-bin/dicom.ini</TD><TD>OpenClinica</TD> </TR> <TR> <TD>SFTP target server</TD><TD>]]..targetserver..[[</TD><TD>cgi-bin/dicom.ini</TD><TD>OpenClinica</TD> </TR> <TR> <TD>SFTP password</TD><TD>]]..'#######'..[[</TD><TD>cgi-bin/dicom.ini</TD><TD>OpenClinica</TD> </TR> <TR> <TR> </TR> <TR> </TR> <TD>Server Version</TD><TD>]]..serverversion..[[</TD><TD>dicomserver/dgate</TD><TD>n/a</TD> </TR> </TR> <TD>Server AE</TD><TD>]]..servercommand('get_param:MyACRNema')..[[</TD><TD>dicomserver/dicom.ini</TD><TD>sscscp</TD> </TR> <TR> <TD>Server Port</TD><TD>]]..servercommand('get_param:TCPPort')..[[</TD><TD>dicomserver/dicom.ini</TD><TD>sscscp</TD> </TR> <TR> </TR> <TR> </TR> ]]) local i=1; repeat local a = servercommand('get_amap:'..i); if a~=nil then print([[ <TR> <TD>Known DICOM ]]..i..[[</TD><TD>]]..a..[[</TD><TD>dicomserver/acrnema.map</TD><TD>n/a</TD> ]]) end; i = i+1; until a==nil; print([[ <TABLE> </BODY> ]])
nilq/small-lua-stack
null
Talk(22, "小兄弟,我看你武功不错,你我二人一起称霸这江湖,如何?", "talkname22", 0); Talk(0, "你武功那么差,我看你还是安份一点.", "talkname0", 1); Talk(22, "上回是老朽是太轻敌了,你还想试试看吗?", "talkname22", 0); if AskBattle() == true then goto label0 end; do return end; ::label0:: if TryBattle(38) == true then goto label1 end; Dead(); do return end; ::label1:: LightScence(); do return end;
nilq/small-lua-stack
null
local _stringformat = string.format local _unpack = unpack --create single hexastore local createHexastore = function(subject,predicate,object) return { 0,_stringformat("spo||%s||%s||%s",subject,predicate,object), 0,_stringformat("sop||%s||%s||%s",subject,object,predicate), 0,_stringformat("osp||%s||%s||%s",object,subject,predicate), 0,_stringformat("ops||%s||%s||%s",object,predicate,subject), 0,_stringformat("pos||%s||%s||%s",predicate,object,subject), 0,_stringformat("pso||%s||%s||%s",predicate,subject,object) } end return redis.call('zadd',KEYS[1],_unpack(createHexastore(ARGV[1], ARGV[2], ARGV[3])))
nilq/small-lua-stack
null
local lanes = require "lanes" lanes.configure{ with_timers = false} -- Lua 5.1/5.2 compatibility local table_unpack = unpack or table.unpack -- this lane eats items in the linda one by one local eater = function( l, loop) -- wait for start signal l:receive( "go") -- eat data one by one for i = 1, loop do local val, key = l:receive( "key") --print( val) end -- print "loop is over" key, val = l:receive( "done") -- print( val) end -- this lane eats items in the linda in batches local batched = function( l, loop, batch) -- wait for start signal l:receive( "go") -- eat data in batches for i = 1, loop/batch do l:receive( l.batched, "key", batch) end print "loop is over" key, val = l:receive( "done") print( val) end local lane_eater_gen = lanes.gen( "*", {priority = 3}, eater) local lane_batched_gen = lanes.gen( "*", {priority = 3}, batched) -- main thread writes data while a lane reads it local function ziva( preloop, loop, batch) -- prefill the linda a bit to increase fifo stress local top = math.max( preloop, loop) local l, lane = lanes.linda() local t1 = lanes.now_secs() for i = 1, preloop do l:send( "key", i) end print( "stored " .. l:count( "key") .. " items in the linda before starting consumer lane") if batch > 0 then if l.batched then lane = lane_batched_gen( l, top, batch) else print "no batch support in this version of Lanes" lane = lane_eater_gen( l, top) end else lane = lane_eater_gen( l, top) end -- tell the consumer lane it can start eating data l:send( "go", true) -- send the remainder of the elements while they are consumed -- create a function that can send several values in one shot batch = math.max( batch, 1) local batch_values = {} for i = 1, batch do table.insert( batch_values, i) end local batch_send = function() l:send( "key", table_unpack( batch_values)) end if loop > preloop then for i = preloop + 1, loop, batch do batch_send() end end l:send( "done" ,"are you happy?") lane:join() return lanes.now_secs() - t1 end local tests1 = { --[[ { 10000, 2000000, 0}, { 10000, 2000000, 1}, { 10000, 2000000, 2}, { 10000, 2000000, 3}, { 10000, 2000000, 5}, { 10000, 2000000, 8}, { 10000, 2000000, 13}, { 10000, 2000000, 21}, { 10000, 2000000, 44}, --]] } print "############################################\ntests #1" for k, v in pairs( tests1) do local pre, loop, batch = v[1], v[2], v[3] print( "testing", pre, loop, batch) print( pre, loop, batch, "duration = " .. ziva( pre, loop, batch) .. "\n") end --[[ V 2.1.0: ziva( 20000, 0) -> 4s ziva( 10000, 20000) -> 3s ziva( 30000, 0) -> 8s ziva( 20000, 30000) -> 7s ziva( 40000, 0) -> 15s ziva( 30000, 40000) -> 15s ziva( 50000, 0) -> 24s ziva( 40000, 50000) -> 23s ziva( 60000, 0) -> 34s ziva( 50000, 60000) -> 33s SIMPLIFIED: ziva( 20000, 0) -> 4s ziva( 10000, 20000) -> 3s ziva( 30000, 0) -> 9s ziva( 20000, 30000) -> 8s ziva( 40000, 0) -> 15s ziva( 30000, 40000) -> 15s ziva( 50000, 0) -> 25s ziva( 40000, 50000) -> 24s ziva( 60000, 0) -> 35s ziva( 50000, 60000) -> 35s FIFO: ziva( 2000000, 0) -> 9s ziva( 1000000, 2000000) -> 33s ziva( 3000000, 0) -> 14s ziva( 2000000, 3000000) -> 40s ziva( 4000000, 0) -> 20s ziva( 3000000, 4000000) -> 27s ziva( 5000000, 0) -> 24s ziva( 4000000, 5000000) -> 42s ziva( 6000000, 0) -> 29s ziva( 5000000, 6000000) -> 55s FIFO BATCHED: ziva( 4000000, 0, 1) -> 20s ziva( 4000000, 0, 2) -> 11s ziva( 4000000, 0, 3) -> 7s ziva( 4000000, 0, 5) -> 5s ziva( 4000000, 0, 8) -> 3s ziva( 4000000, 0, 13) -> 3s ziva( 4000000, 0, 21) -> 3s ziva( 4000000, 0, 44) -> 2s ]] -- sequential write/read (no parallelization involved) local function ziva2( preloop, loop, batch) local l = lanes.linda() -- prefill the linda a bit to increase fifo stress local top, step = math.max( preloop, loop), (l.batched and batch) and batch or 1 local batch_send, batch_read if l.batched and batch then local batch_values = {} for i = 1, batch do table.insert( batch_values, i) end -- create a function that can send several values in one shot batch_send = function() l:send( "key", table_unpack( batch_values)) end batch_read = function() l:receive( l.batched, "key", batch) end else -- not batched batch_send = function() l:send( "key", top) end batch_read = function() l:receive( "key") end end local t1 = lanes.now_secs() -- first, prime the linda with some data for i = 1, preloop, step do batch_send() end print( "stored " .. (l:count( "key") or 0) .. " items in the linda before starting consumer lane") -- loop that alternatively sends and reads data off the linda if loop > preloop then for i = preloop + 1, loop, step do batch_send() batch_read() end end -- here, we have preloop elements still waiting inside the linda for i = 1, preloop, step do batch_read() end return lanes.now_secs() - t1 end local tests2 = { -- prefill, then consume everything --[[ { 4000000, 0}, { 4000000, 0, 1}, { 4000000, 0, 2}, { 4000000, 0, 3}, { 4000000, 0, 5}, { 4000000, 0, 8}, { 4000000, 0, 13}, { 4000000, 0, 21}, { 4000000, 0, 44}, --]] -- alternatively fill and consume { 0, 4000000}, { 0, 4000000, 1}, { 0, 4000000, 2}, { 0, 4000000, 3}, { 0, 4000000, 5}, { 0, 4000000, 8}, { 0, 4000000, 13}, { 0, 4000000, 21}, { 0, 4000000, 44}, } print "\n############################################\ntests #2" for k, v in pairs( tests2) do local pre, loop, batch = v[1], v[2], v[3] print( "testing", pre, loop, batch) print( pre, loop, batch, "duration = " .. ziva2( pre, loop, batch) .. "\n") end
nilq/small-lua-stack
null
{ pass = { files = {"SolidColorMesh.vsh", "SolidColorMesh.fsh"} } }
nilq/small-lua-stack
null
---------------------------------------- -- Sassilization -- http://sassilization.com -- By Sassafrass / Spacetech / LuaPineapple ---------------------------------------- UNIT.Name = "Catapult" UNIT.Model = "models/mrgiggles/sassilization/catapult.mdl" UNIT.Iron = 38 UNIT.Food = 50 UNIT.Gold = 5 UNIT.Supply = 2 UNIT.AttackDelay = 6 UNIT.AttackMoveDelay = 2 UNIT.Range = 120 UNIT.SightRange = 140 UNIT.Speed = 12 -- 20 UNIT.Require = {city = 0,workshop = 2} UNIT.Spawnable = true UNIT.HP = 35 UNIT.AttackDamage = 15 UNIT.OBBMins = Vector(-8, -8, -1) UNIT.OBBMaxs = Vector(8, 8, 8) UNIT.Size = 10 UNIT.Creed = 1 UNIT.camPos = Vector(-207.945709, -174.530258, 97.833298) UNIT.angle = Angle(18.841, 40.027, 0.000) UNIT.fov = 4.86 function UNIT:GetAttackSound() return "SASS_Catapult.Fire" end
nilq/small-lua-stack
null
if mods["Krastorio2"] then -- allow nuclear fuel in kr-nuclear-locomotive data.raw.locomotive["kr-nuclear-locomotive"].burner.fuel_categories = {"uranium-mix", "plutonium-mix", "thorium-mix"} nuclear.recipe.disable({"nuclear-fuel-cell"}) -- overwrite uranium processing according to NO data.raw.recipe["uranium-processing"] = { type = "recipe", name = "uranium-processing", energy_required = 8, -- changed from 12 to 15 of K2 to 8 enabled = false, category = "chemistry", ingredients = { { type = "item", name = "uranium-ore", amount = 10}, { type = "fluid", name = "sulfuric-acid", amount = 5} }, icon = no_path_g_icons .. "uranium-powder.png", icon_size = 64, icon_mipmaps = 4, subgroup = "raw-material", order = "k[uranium-processing-1]", results = { { name = "yellowcake", amount = 2 }, { name = "stone", amount = 6 }, { name = "iron-ore", -- add iron-ore byproduct of K2 amount = 2 } }, crafting_machine_tint = { primary = {r = 1.000, g = 0.642, b = 0.261, a = 1.000}, -- #ffa342ff secondary = {r = 1.000, g = 0.722, b = 0.376, a = 1.000}, -- #ffb85fff tertiary = {r = 0.854, g = 0.659, b = 0.576, a = 1.000}, -- #d9a892ff quaternary = {r = 1.000, g = 0.494, b = 0.271, a = 1.000}, -- #ff7e45ff } } -- rewrite nuclear-fuel-reprocessing to suit K2 tritium generation data.raw.recipe["uranium-mox-reprocessing"] = { type = "recipe", name = "uranium-mox-reprocessing", energy_required = 120, enabled = false, category = "centrifuging", ingredients = {{"used-uranium-mox", 1}}, icon = no_path_g_icons .. "nuclear-fuel-reprocessing-1.png", icon_size = 64, icon_mipmaps = 4, subgroup = "radioactive-products", order = "f[reprocessing]-a[rep-uranium-mox]", results = { { name = "uranium-235", amount = 1 }, { name = "uranium-237", amount = 5 }, { name = "uranium-238", amount = 88 }, { name = "stone", amount = 4 }, { name = "plutonium-238", probability = 0.35, amount = 1 }, { name = "plutonium-239", probability = 0.65, amount = 1 }, { name = "tritium", probability = 0.15, amount = 1 } } } -- disable extra recipes of NO local disable_recipes = { "uranium-rounds-magazine-u236", "uranium-rounds-magazine-pu238", "atomic-bomb-u236", "atomic-bomb-pu238" } nuclear.recipe.disable(disable_recipes) nuclear.technology.removeUnlockEffects("uranium-ammo", disable_recipes) nuclear.technology.removeUnlockEffects("atomic-bomb", disable_recipes) -- create new ammo recipes for K2 items local kr_ammo_recipes = { "uranium-rifle-magazine", "uranium-anti-material-rifle-magazine" } nuclear.ammo.addRecipeVariation(kr_ammo_recipes, nuclear.ammo.extensions) local effects = nuclear.ammo.getRecipeNames(kr_ammo_recipes, nuclear.ammo.extensions) nuclear.technology.addUnlockEffects("uranium-ammo", effects) -- create new bomb recipes for K2 items local kr_bomb_recipes = { "nuclear-artillery-shell", "atomic-bomb", } nuclear.ammo.addRecipeVariation(kr_bomb_recipes, nuclear.ammo.extensions) local effects = nuclear.ammo.getRecipeNames(kr_bomb_recipes, nuclear.ammo.extensions) nuclear.technology.setUnlockEffects("atomic-bomb", effects) -- create new nuclear recipes for K2 items local kr_bomb_recipes = { "nuclear-turret-rocket" } nuclear.ammo.addRecipeVariation(kr_bomb_recipes, nuclear.ammo.extensions) local effects = nuclear.ammo.getRecipeNames(kr_bomb_recipes, nuclear.ammo.extensions) nuclear.technology.addUnlockEffects("kr-rocket-turret", effects) -- adjust technologies cost nuclear.technology.setCount("uranium-processing", 200) nuclear.technology.setCount("uranium-processing-2", 500) nuclear.technology.setCount("advanced-nuclear-power-2", 1000) nuclear.technology.setCount("advanced-nuclear-power-2", 1200) nuclear.technology.setCount("nuclear-fuel-reprocessing-1", 250) nuclear.technology.setCount("nuclear-fuel-reprocessing-2", 250) nuclear.technology.setCount("nuclear-fuel-reprocessing-3", 250) -- adjust technologies dependencies nuclear.technology.removePrerequisite("kr-nuclear-locomotive", {"nuclear-power"}) nuclear.technology.addPrerequisite("kr-nuclear-locomotive", {"advanced-nuclear-power"}) nuclear.technology.removePrerequisite("uranium-ammo", {"uranium-processing"}) nuclear.technology.addPrerequisite("uranium-ammo", {"uranium-processing-2"}) nuclear.technology.removePrerequisite("production-science-pack", {"uranium-processing"}) nuclear.technology.addPrerequisite("production-science-pack", {"uranium-processing-2"}) nuclear.technology.removePrerequisite("uranium-processing", {"concrete"}) nuclear.technology.removePrerequisite("kr-nuclear-reactor-equipment", {"nuclear-power"}) nuclear.technology.addPrerequisite("kr-nuclear-reactor-equipment", {"advanced-nuclear-power"}) end
nilq/small-lua-stack
null
local ns, queue, id = ARGV[1], ARGV[2], ARGV[3] local count = redis.call('LREM', ns..':'..queue..':receiving', 1, id) if redis.call('SISMEMBER', ns..':'..queue..':consuming', id) == 1 then if count == 1 and redis.call('SISMEMBER', ns..':'..queue..':queued_ids', id) == 0 then redis.call('SADD', ns..':'..queue..':queued_ids', id) redis.call('LPUSH', ns..':'..queue..':queue', id) end return nil end if count == 1 then redis.call('SREM', ns..':'..queue..':queued_ids', id) redis.call('SADD', ns..':'..queue..':consuming', id) return redis.call('HGET', ns..':'..queue..':messages', id) end
nilq/small-lua-stack
null
local na = #ARGV local cnt = 10 local level = redis.LOG_NOTICE local m = nil local table_exists = function(t) if (1 == redis.call('sismember', '_T_N_', t)) then return true end return false end local find_pk = function(t) local pkd = string.format('_T_[%s]_C_PK_', t) local cd = redis.call('get', pkd) if (nil == cd) then return nil end local d = string.format('_T_[%s]_C_[%s]_', t, cd) local v = redis.call('hmget', d, 'PRIMARY_KEY', 'TYPE') if (nil == v) then return nil end return {n=cd, pk=v[1], t=v[2]} end local to_int = function(n) local i = tonumber(n) if i then return math.floor(i) end return nil end if (5 > na) then m = "should provides enough arguments(>=5)" return {-1, m} end local t = ARGV[1] if (not table_exists(t)) then m = string.format('table: %s does not exist', t) return {-00942, m} end local i = to_int(ARGV[2]) if (not i) then m = string.format('invalid cursor [%s]', ARGV[2]) redis.log(level, m) return {-01001, m} end local pk = find_pk(t) local c = ARGV[4] if (nil == pk) or (c ~= pk['n']) then m = string.format('%s is not the primary key in table:%s', c, t) redis.log(level, m) return {-02270, m} end local op = ARGV[3] local v = ARGV[5] local zop = nil if ('>' == op) then zop = {l='('..v, r='+'} elseif ('>=' == op) then zop = {l='['..v, r='+'} elseif ('<' == op) then zop = {l='-', r='('..v} elseif ('<=' == op) then zop = {l='-', r='['..v} else m = string.format('unsupported operator: %s', op) redis.log(level, m) return {-30462, m} end local pkd = string.format('_T_[%s]:[%s]_', t, pk['n']) local pks = redis.call('zrangebylex', pkd, zop['l'], zop['r'], 'limit', i, cnt) local rows = {} rows[#rows+1] = {i, #pks} for j=1,#pks do local rid = string.format('_T_[%s]:[%s]:<%s>_', t, pk['n'], pks[j]) rows[#rows+1] = redis.call('hgetall', rid) end redis.log(level, string.format('retrived [%s %s]', i, #pks)) return rows;
nilq/small-lua-stack
null
project "Freetype-GL" language "C" kind "StaticLib" staticruntime "on" targetdir ("%{prj.location}/bin/" .. outputdir) objdir ("%{prj.location}/bin-int/" .. outputdir) files { "src/**.c", "src/**.h", } includedirs { "%{wks.location}/TerranEngine/vendor/freetype/include/", "%{wks.location}/TerranEngine/vendor/GLAD/include/" } links { "GLAD", "opengl32.lib", "Freetype" } filter "system:windows" systemversion "latest" filter "configurations:Debug" runtime "Debug" symbols "on" filter "configurations:Release" runtime "Release" optimize "on"
nilq/small-lua-stack
null
-- Highlight the active buffer/view. local line_number_back = buffer.style_back[_SCINTILLA.constants.STYLE_LINENUMBER] local current_line_back = buffer.caret_line_back local function active() local buffer = buffer buffer.style_back[33] = current_line_back buffer:set_fold_margin_colour(1, current_line_back) buffer:set_fold_margin_hi_colour(1, current_line_back) end local function inactive() local buffer = buffer buffer.style_back[33] = line_number_back buffer:set_fold_margin_colour(true, line_number_back) buffer:set_fold_margin_hi_colour(true, line_number_back) end events.connect(events.VIEW_BEFORE_SWITCH, function() inactive() end) events.connect(events.VIEW_AFTER_SWITCH, function() active() end) events.connect(events.BUFFER_AFTER_SWITCH, function() active() end) events.connect(events.BUFFER_NEW, function() active() end) events.connect(events.FILE_OPENED, function() active() end) events.connect(events.RESET_AFTER, function() active() end) events.connect(events.BUFFER_AFTER_SWITCH, function() local buffer = buffer if buffer._textredux then buffer.style_fore[33] = current_line_back buffer:set_fold_margin_colour(1, line_number_back) buffer:set_fold_margin_hi_colour(1, line_number_back) end end)
nilq/small-lua-stack
null
--[[ ExtendedManager.lua --]] local ExtendedManager, dbg = Manager:newClass{ className='ExtendedManager' } --[[ Constructor for extending class. --]] function ExtendedManager:newClass( t ) return Manager.newClass( self, t ) end --[[ Constructor for new instance object. --]] function ExtendedManager:new( t ) return Manager.new( self, t ) end --- Static function to initialize plugin preferences (not framework preferences) - both global and non-global. -- function ExtendedManager.initPrefs() -- Init global prefs: -- Init local prefs: app:initPref( 'saveMetadata', false ) app:setPref( 'background', false ) -- true to support on-going background processing, after async init (auto-update most-sel photo). -- Init base prefs: Manager.initPrefs() end --- Start of plugin manager dialog. -- function ExtendedManager:startDialogMethod( props ) Manager.startDialogMethod( self, props ) -- adds observer to all props. end --- Preference change handler. -- -- @usage Handles preference changes. -- <br>Preferences not handled are forwarded to base class handler. -- @usage Handles changes that occur for any reason, one of which is user entered value when property bound to preference, -- <br>another is preference set programmatically - recursion guarding is essential. -- function ExtendedManager:prefChangeHandlerMethod( _props, _prefs, key, value ) Manager.prefChangeHandlerMethod( self, _props, _prefs, key, value ) end --- Property change handler. -- -- @usage Properties handled by this method, are either temporary, or -- should be tied to named setting preferences. -- function ExtendedManager:propChangeHandlerMethod( props, name, value, call ) if app.prefMgr and (app:getPref( name ) == value) then -- eliminate redundent calls. -- Note: in managed cased, raw-pref-key is always different than name. -- Note: if preferences are not managed, then depending on binding, -- app-get-pref may equal value immediately even before calling this method, in which case -- we must fall through to process changes. return end -- *** Instructions: strip this if not using background processing: if name == 'blah' then else -- Note: preference key is different than name. Manager.propChangeHandlerMethod( self, props, name, value, call ) end end --- Sections for bottom of plugin manager dialog. -- function ExtendedManager:sectionsForBottomOfDialogMethod( vf, props) local appSection = {} if app.prefMgr then appSection.bind_to_object = props else appSection.bind_to_object = prefs end appSection.title = app:getAppName() .. " Settings" appSection.synopsis = bind{ key='presetName', object=prefs } appSection.spacing = vf:label_spacing() appSection[#appSection + 1] = vf:row { vf:checkbox { title = "Automatically save metadata after exporting, to avoid metadata conflict flags...", --width = share 'label_width', value = bind 'saveMetadata', tooltip = "If checked, will emit keystroke to save metadata of exported photos - click 'Edit Advanced Settings' to tweak, if necessary." }, } if not app:isRelease() then appSection[#appSection + 1] = vf:spacer{ height = 20 } appSection[#appSection + 1] = vf:static_text{ title = 'For plugin author only below this line:' } appSection[#appSection + 1] = vf:separator{ fill_horizontal = 1 } appSection[#appSection + 1] = vf:row { vf:edit_field { value = bind( "testData" ), }, vf:static_text { title = str:format( "Test data" ), }, } appSection[#appSection + 1] = vf:row { vf:push_button { title = "Test", action = function( button ) app:call( Call:new{ name='Test', main = function( call ) app:show( { info="^1: ^2" }, str:to( app:getGlobalPref( 'presetName' ) or 'Default' ), app:getPref( 'testData' ) ) end } ) end }, vf:static_text { title = str:format( "Perform tests." ), }, } end local sections = Manager.sectionsForBottomOfDialogMethod ( self, vf, props ) -- fetch base manager sections. if #appSection > 0 then tab:appendArray( sections, { appSection } ) -- put app-specific prefs after. end return sections end return ExtendedManager -- the end.
nilq/small-lua-stack
null
better_caves = {} better_caves.schematics = {} better_caves.biomes = {} better_caves.settings = {} dofile(minetest.get_modpath("better_caves_api") .. "/settings.lua") --API functions better_caves.register_biome = function(biomedef) table.insert(better_caves.biomes, biomedef) end better_caves.register_node_id = function(name, id) better_caves[name] = minetest.get_content_id(id) end better_caves.register_schematic = function(pathname, schpath, schname) local building = minetest.get_modpath(pathname) .. schpath local str = minetest.serialize_schematic(building, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return(schematic)" better_caves.schematics[schname] = loadstring(str)() end --Defining perlin noise parameters for biome distribution local np_terrain = { offset = better_caves.settings.offset, scale = better_caves.settings.scale, spread = {x = 512 * better_caves.settings.spread_x, y = 512 * better_caves.settings.spread_y, z = 512 * better_caves.settings.spread_z}, seed = better_caves.settings.seed, octaves = 1, persist = 0.7, lacunarity = 2.0, } local nobj_terrain = nil local nvals_terrain = {} local data = {} --Reserved values needed for generation better_caves.c_stone = minetest.get_content_id("default:stone") better_caves.c_air = minetest.get_content_id("air") --Main function that's called on every chunk generation minetest.register_on_generated(function(minp, maxp, seed) --Return if outside of global limits or biomes table is empty if minp.y <= better_caves.settings.lowlimit or maxp.y >= better_caves.settings.highlimit or next(better_caves.biomes) == nil then return end --Debug variables local t0 = os.clock() local highval = 0 local lowval = 0 local sidelen = maxp.x - minp.x + 1 local permapdims3d = {x = sidelen, y = sidelen, z = sidelen} nobj_terrain = nobj_terrain or minetest.get_perlin_map(np_terrain, permapdims3d) nobj_terrain:get3dMap_flat(minp, nvals_terrain) local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax}) vm:get_data(data) local cache = {} local biome = {} local ni = 1 local nv = 0 local tempnode = 0 local biome_n = #better_caves.biomes --Iterating over nodes in vm for z = minp.z, maxp.z do for y = minp.y, maxp.y do local vi = area:index(minp.x, y, z) for x = minp.x, maxp.x do nv = nvals_terrain[ni] --Generating only on noise values of 0-1 if not (nv <= 0) then if nv > 1 then nv = 1 end --Determining a biome, biomes are mapped to the range of perlin values of 0 < x < 1 for k = 0, biome_n do if k/biome_n >= nv then -- Blending biomes towards biome threshold values local grad = k/biome_n - nv if grad <= better_caves.settings.blend_threshold and math.random(1 + (math.floor(300 * grad) ^ (0.5/3)) ) == 1 and k ~= biome_n then biome = better_caves.biomes[k + 1] else biome = better_caves.biomes[k] end break end end -- Biome specific height check if minp.y <= biome.lowlimit or maxp.y >= biome.highlimit then return end -- Floor nodes population if data[vi] == better_caves.c_stone and data[vi + area.ystride] == better_caves.c_air and math.random(biome.floor_node_chance) == 1 then -- Checking for additional n nodes below specified in a biome definition for v = 0, biome.floor_depth - 1 do if data[vi - v * area.ystride] == better_caves.c_stone then data[vi - v * area.ystride] = biome.floor_node end end --Floor decoration population if math.random(biome.floor_decoration_chance) == 1 then if math.random(biome.floor_rare_decoration_chance) == 1 then --Assigning current decoration node to a temp var to check for that node when spawning a schematic tempnode = biome.floor_rare_decoration[math.random(#biome.floor_rare_decoration)] data[vi + area.ystride] = tempnode else --Assigning current decoration node to a temp var to check for that node when spawning a schematic tempnode = biome.floor_decoration[math.random(#biome.floor_decoration)] data[vi + area.ystride] = tempnode end end end -- Ceiling nodes population if data[vi] == better_caves.c_stone and data[vi - area.ystride] == better_caves.c_air and math.random(biome.ceiling_node_chance) == 1 then for v = 0, biome.ceiling_depth - 1 do if data[vi + v * area.ystride] == better_caves.c_stone then data[vi + v * area.ystride] = biome.ceiling_node end end --Ceiling decoration population if math.random(biome.ceiling_decoration_chance) == 1 then if math.random(biome.ceiling_rare_decoration_chance) == 1 then --Assigning current decoration node to a temp var to check for that node when spawning a schematic tempnode = biome.ceiling_rare_decoration[math.random(#biome.ceiling_rare_decoration)] data[vi - area.ystride] = tempnode else --Assigning current decoration node to a temp var to check for that node when spawning a schematic tempnode = biome.ceiling_decoration[math.random(#biome.ceiling_decoration)] data[vi - area.ystride] = tempnode end end end --Wall nodes population if data[vi] == better_caves.c_stone and (data[vi + area.zstride] == better_caves.c_air or data[vi - area.zstride] == better_caves.c_air or data[vi + 1] == better_caves.c_air or data[vi - 1] == better_caves.c_air) then data[vi] = biome.wall_node end --Floor schematics if data[vi] == biome.floor_node and (data[vi + area.ystride] == better_caves.c_air or data[vi + area.ystride] == tempnode) and math.random(biome.floor_schematic_chance) == 1 then --Selecting either normal or rare schematic local schemkey = 0 if math.random(biome.floor_rare_schematic_chance) == 1 then schemkey = biome.floor_rare_schematics[math.random(#biome.floor_rare_schematics)] else schemkey = biome.floor_schematics[math.random(#biome.floor_schematics)] end --Loading the schematic local schematic = better_caves.schematics[schemkey] --Checking if the schematic fits in height local air_count = 0 for h = 0, schematic.size.y do if data[vi + h * area.ystride] == better_caves.c_air then air_count = air_count + 1 end end --Checking if the node below is a decoration, changing it to air and increasing air count to allow schematic to fit if data[vi + area.ystride] == tempnode and air_count + 1 == schematic.size.y then data[vi + area.ystride] = better_caves.c_air air_count = air_count + 1 end --Adding schematic to the cache if it fits if air_count == schematic.size.y then table.insert(cache, {x=x, y=y + 1, z=z, schematic=schemkey, overwrite=false}) end end --Ceiling schematics if data[vi] == biome.floor_node and (data[vi - area.ystride] == better_caves.c_air or data[vi - area.ystride] == tempnode) and math.random(biome.ceiling_schematic_chance) == 1 then --Selecting either normal or rare schematic local schemkey = 0 if math.random(biome.ceiling_rare_schematic_chance) == 1 then schemkey = biome.ceiling_rare_schematics[math.random(#biome.ceiling_rare_schematics)] else schemkey = biome.ceiling_schematics[math.random(#biome.ceiling_schematics)] end --Loading the schematic local schematic = better_caves.schematics[schemkey] --Checking if the schematic fits in height local air_count = 0 for h = 0, schematic.size.y do if data[vi - h * area.ystride] == better_caves.c_air then air_count = air_count + 1 end end --Checking if the node below is a decoration, changing it to air and increasing air count to allow schematic to fit if data[vi - area.ystride] == tempnode and air_count + 1 == schematic.size.y then data[vi - area.ystride] = better_caves.c_air air_count = air_count + 1 end -- Adding schematic to the cache if it fits if air_count == schematic.size.y then table.insert(cache, {x=x, y=y - schematic.size.y, z=z, schematic=schemkey, overwrite=false}) end end end --Recording lowest and highest perlin values in this chunk if better_caves.settings.debug then if nv > highval then highval = nv elseif nv < lowval then lowval = nv end end --Increase noise and node indexes ni = ni + 1 vi = vi + 1 end end end vm:set_data(data) --Placing schematics from a cache created before for k,v in pairs(cache) do local schem = better_caves.schematics[v.schematic] local schem_offset = {x=math.floor(schem.size.x/2), y=0, z=math.floor(schem.size.z/2)} minetest.place_schematic_on_vmanip(vm, { x = v.x - schem_offset.x, y = v.y, z = v.z - schem_offset.z}, schem, "random", nil, v.overwrite) end vm:calc_lighting() vm:write_to_map() vm:update_liquids() --Print debug info if better_caves.settings.debug then local chugent = math.ceil((os.clock() - t0) * 1000) print ("[better_caves_api] chunk gen time:" .. chugent .. " ms. Noise high val:" .. highval .. " Low val:" .. lowval) end end )
nilq/small-lua-stack
null
-- @description Save Stretch Markers -- @author Aaron Cendan -- @version 1.0 -- @metapackage -- @provides -- [main] . > acendan_Save stretch markers in selected items as named project markers.lua -- @link https://aaroncendan.me -- @about -- * This script goes hand-in-hand with acendan_Restore stretch markers in selected items from named project markers.lua -- * Select items with stretch markers then run this to convert them into project markers with a specific naming convention -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~~~~~~~~~~ GLOBAL VARS ~~~~~~~~~~ -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Get this script's name and directory local script_name = ({reaper.get_action_context()})[2]:match("([^/\\_]+)%.lua$") local script_directory = ({reaper.get_action_context()})[2]:sub(1,({reaper.get_action_context()})[2]:find("\\[^\\]*$")) -- Load lua utilities acendan_LuaUtils = reaper.GetResourcePath()..'/scripts/ACendan Scripts/Development/acendan_Lua Utilities.lua' if reaper.file_exists( acendan_LuaUtils ) then dofile( acendan_LuaUtils ); if not acendan or acendan.version() < 4.5 then acendan.msg('This script requires a newer version of ACendan Lua Utilities. Please run:\n\nExtensions > ReaPack > Synchronize Packages',"ACendan Lua Utilities"); return end else reaper.ShowConsoleMsg("This script requires ACendan Lua Utilities! Please install them here:\n\nExtensions > ReaPack > Browse Packages > 'ACendan Lua Utilities'"); return end -- Init tables local proj_markers = {} local init_items = {} -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~~~~~~~~~~~ FUNCTIONS ~~~~~~~~~~~ -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function main() -- Check item(s) selected local num_sel_items = reaper.CountSelectedMediaItems(0) if num_sel_items > 0 then -- Save selected items to table acendan.saveSelectedItems(init_items) -- Create proj markers for stretch markers in items for i=1, num_sel_items do local item = init_items[i] local item_guid = reaper.BR_GetMediaItemGUID(item) -- Create proj markers for item stretch markers local ret, num_markers, num_regions = reaper.CountProjectMarkers( 0 ) local num_total = num_markers + num_regions if num_markers > 0 then -- Clear marker table, store stretch markers as markers if #proj_markers > 0 then acendan.clearTable(proj_markers) end proj_markers = acendan.saveProjectMarkersTable() acendan.setOnlyItemSelected(item) reaper.Main_OnCommand(reaper.NamedCommandLookup("_BR_STRETCH_MARKERS_TO_MARKERS"),0) -- SWS/BR: Create project markers from stretch markers in selected items -- Rename new markers local ret, num_markers, num_regions = reaper.CountProjectMarkers( 0 ) local num_total = num_markers + num_regions local j = 0 while j < num_total do local retval, isrgn, pos, rgnend, name, markrgnindexnumber, color = reaper.EnumProjectMarkers3( 0, j ) if not isrgn then -- If project marker not found in saved table of indexes, then rename it and color yellow if not acendan.tableContainsVal(proj_markers, markrgnindexnumber) then reaper.SetProjectMarkerByIndex( 0, j, isrgn, pos, rgnend, markrgnindexnumber, item_guid .. ";" .. j, 25231359 ) end end j = j + 1 end else -- No markers in project yet acendan.setOnlyItemSelected(item) reaper.Main_OnCommand(reaper.NamedCommandLookup("_BR_STRETCH_MARKERS_TO_MARKERS"),0) -- SWS/BR: Create project markers from stretch markers in selected items -- Rename markers local ret, num_markers, num_regions = reaper.CountProjectMarkers( 0 ) local num_total = num_markers + num_regions local j = 0 while j < num_total do local retval, isrgn, pos, rgnend, name, markrgnindexnumber, color = reaper.EnumProjectMarkers3( 0, j ) if not isrgn then reaper.SetProjectMarkerByIndex( 0, j, isrgn, pos, rgnend, markrgnindexnumber, item_guid .. ";" .. j, 25231359 ) end j = j + 1 end end -- Remove item's stretch markers reaper.Main_OnCommand(41844, 0) -- Item: Remove all stretch markers end else acendan.msg("No items selected!") end end -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~~~~~~~~~~~~~ MAIN ~~~~~~~~~~~~~~ -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ reaper.PreventUIRefresh(1) reaper.Undo_BeginBlock() main() if #init_items > 0 then acendan.restoreSelectedItems(init_items) end reaper.Undo_EndBlock(script_name,-1) reaper.PreventUIRefresh(-1) reaper.UpdateArrange()
nilq/small-lua-stack
null
#!/usr/bin/env lua local abort_on_error = false local loadstring = loadstring or load local tlast = require "typedlua.tlast" local tlparser = require "typedlua.tlparser" local tltype = require "typedlua.tltype" local tlchecker = require "typedlua.tlchecker" local tlcode = require "typedlua.tlcode" local typedlua = require "typedlua" -- For the module loader -- expected result, result, subject local e, r, s local filename = "test.lua" local function parse (my_s) local t,m = tlparser.parse(my_s,filename,false,false) local my_r if not t then my_r = m else my_r = tlast.tostring(t) end return my_r .. "\n" end local function typecheck (my_s) local t,m = tlparser.parse(my_s,filename,false,false) local my_r if not t then error(m) os.exit(1) end m = tlchecker.typecheck(t,my_s,filename,false,false,false) m = tlchecker.error_msgs(m,false) if m then my_r = m else my_r = tlast.tostring(t) end return my_r .. "\n" end local function generate (my_s) local t,m = tlparser.parse(my_s,filename,false,false) if not t then error(m) os.exit(1) end m = tlchecker.typecheck(t,my_s,filename,false,false,false) m = tlchecker.error_msgs(m,false) if m then return m .. "\n" else return tlcode.generate(t) end end local function test_loader (s) local ok, ret1, ret2 = pcall(loadstring, s, "test.tl") if not ok then return ret1 else if ret1 then return ret1() else return ret2 .. "\n" end end end local passed_tests = 0 local failed_tests = 0 local function check (e, r) r = r or e if type(e) == "string" then e = e:gsub("%s+(%s)", "%1"):gsub("([^%w]) ([%w{(\"\'])", "%1%2") end if type(r) == "string" then r = r:gsub("%s+(%s)", "%1"):gsub("([^%w]) ([%w{(\"\'])", "%1%2") end if e == r then passed_tests = passed_tests + 1 else failed_tests = failed_tests + 1 print("AT LINE: ", debug.getinfo(2, "l").currentline) print("e:") print(e) print("r:") print(r) end if abort_on_error then assert(e == r) end end local function fixint (s) return _VERSION < "Lua 5.3" and s:gsub("%.0","") or s end print("> testing lexer...") -- syntax ok -- empty files s = [=[ ]=] e = [=[ { } ]=] r = parse(s) check(e, r) s = [=[ -- testing empty file ]=] e = [=[ { } ]=] r = parse(s) check(e, r) -- expressions s = [=[ local _nil,_false,_true,_dots = nil,false,true,... ]=] e = [=[ { `Local{ { `Id "_nil", `Id "_false", `Id "_true", `Id "_dots" }, { `Nil, `False, `True, `Dots } } } ]=] r = parse(s) check(e, r) -- floating points s = [=[ local f1 = 1. local f2 = 1.1 ]=] e = [=[ { `Local{ { `Id "f1" }, { `Number "1.0" } }, `Local{ { `Id "f2" }, { `Number "1.1" } } } ]=] r = parse(s) check(fixint(e), r) s = [=[ local f1 = 1.e-1 local f2 = 1.e1 ]=] e = [=[ { `Local{ { `Id "f1" }, { `Number "0.1" } }, `Local{ { `Id "f2" }, { `Number "10.0" } } } ]=] r = parse(s) check(fixint(e), r) s = [=[ local f1 = 1.1e+1 local f2 = 1.1e1 ]=] e = [=[ { `Local{ { `Id "f1" }, { `Number "11.0" } }, `Local{ { `Id "f2" }, { `Number "11.0" } } } ]=] r = parse(s) check(fixint(e), r) s = [=[ local f1 = .1 local f2 = .1e1 ]=] e = [=[ { `Local{ { `Id "f1" }, { `Number "0.1" } }, `Local{ { `Id "f2" }, { `Number "1.0" } } } ]=] r = parse(s) check(fixint(e), r) s = [=[ local f1 = 1E1 local f2 = 1e-1 ]=] e = [=[ { `Local{ { `Id "f1" }, { `Number "10.0" } }, `Local{ { `Id "f2" }, { `Number "0.1" } } } ]=] r = parse(s) check(fixint(e), r) -- integers s = [=[ local i = 1 local h = 0xff ]=] e = [=[ { `Local{ { `Id "i" }, { `Number "1" } }, `Local{ { `Id "h" }, { `Number "255" } } } ]=] r = parse(s) check(e, r) s = [=[ local h = 0x76c local i = 4294967296 -- 2^32 ]=] e = [=[ { `Local{ { `Id "h" }, { `Number "1900" } }, `Local{ { `Id "i" }, { `Number "4294967296" } } } ]=] r = parse(s) check(e, r) -- long comments s = [=[ --[======[ testing long comment [==[ one ]==] [===[ more ]===] [====[ time ]====] bye ]======] ]=] e = [=[ { } ]=] r = parse(s) check(e, r) -- long strings s = [=[ --[[ testing long string1 begin ]] local ls1 = [[ testing long string ]] --[[ testing long string1 end ]] ]=] e = [=[ { `Local{ { `Id "ls1" }, { `String "testing long string\n" } } } ]=] r = parse(s) check(e, r) s = [=[ --[==[ testing long string2 begin ]==] local ls2 = [==[ testing \n [[ long ]] \t [===[ string ]===] \a ]==] --[==[ [[ testing long string2 end ]] ]==] ]=] e = [=[ { `Local{ { `Id "ls2" }, { `String " testing \\n [[ long ]] \\t [===[ string ]===]\n\\a " } } } ]=] r = parse(s) check(e, r) -- short strings s = [=[ -- short string test begin local ss1_a = "ola mundo\a" local ss1_b = 'ola mundo\a' -- short string test end ]=] e = [=[ { `Local{ { `Id "ss1_a" }, { `String "ola mundo\a" } }, `Local{ { `Id "ss1_b" }, { `String "ola mundo\a" } } } ]=] r = parse(s) check(e, r) s = [=[ -- short string test begin local ss2_a = "testando,\tteste\n1\n2\n3 --> \"tchau\"" local ss2_b = 'testando,\tteste\n1\n2\n3 --> \'tchau\'' -- short string test end ]=] e = [=[ { `Local{ { `Id "ss2_a" }, { `String "testando,\tteste\n1\n2\n3 --> \"tchau\"" } }, `Local{ { `Id "ss2_b" }, { `String "testando,\tteste\n1\n2\n3 --> 'tchau'" } } } ]=] r = parse(s) check(e, r) s = [=[ -- short string test begin local ss3_a = "ola \ 'mundo'!" local ss3_b = 'ola \ "mundo"!' -- short string test end ]=] e = [=[ { `Local{ { `Id "ss3_a" }, { `String "ola \n'mundo'!" } }, `Local{ { `Id "ss3_b" }, { `String "ola \n\"mundo\"!" } } } ]=] r = parse(s) check(e, r) s = [=[ -- short string test begin local ss4_a = "C:\\Temp/" local ss4_b = 'C:\\Temp/' -- short string test end ]=] e = [=[ { `Local{ { `Id "ss4_a" }, { `String "C:\\Temp/" } }, `Local{ { `Id "ss4_b" }, { `String "C:\\Temp/" } } } ]=] r = parse(s) check(e, r) s = [=[ -- short string test begin local ss5_a = "ola \ mundo \\ \ cruel" local ss5_b = 'ola \ mundo \\ \ cruel' -- short string test end ]=] e = [=[ { `Local{ { `Id "ss5_a" }, { `String "ola \nmundo \\ \ncruel" } }, `Local{ { `Id "ss5_b" }, { `String "ola \nmundo \\ \ncruel" } } } ]=] r = parse(s) check(e, r) -- syntax error -- floating points s = [=[ local f = 9e ]=] e = [=[ test.lua:2:1: syntax error, unexpected 'EOF', expecting '=', ',', 'String', '{', '(', ':', '[', '.' ]=] r = parse(s) check(e, r) s = [=[ local f = 5.e ]=] e = [=[ test.lua:2:1: syntax error, unexpected 'EOF', expecting '=', ',', 'String', '{', '(', ':', '[', '.' ]=] r = parse(s) check(e, r) s = [=[ local f = .9e- ]=] e = [=[ test.lua:1:14: syntax error, unexpected '-', expecting '=', ',', 'String', '{', '(', ':', '[', '.' ]=] r = parse(s) check(e, r) s = [=[ local f = 5.9e+ ]=] e = [=[ test.lua:1:15: syntax error, unexpected '+', expecting '=', ',', 'String', '{', '(', ':', '[', '.' ]=] r = parse(s) check(e, r) -- integers s = [=[ -- invalid hexadecimal number local hex = 0xG ]=] e = [=[ test.lua:4:1: syntax error, unexpected 'EOF', expecting '=', ',', 'String', '{', '(', ':', '[', '.' ]=] r = parse(s) check(e, r) -- long strings s = [=[ --[==[ testing long string3 begin ]==] local ls3 = [===[ testing unfinised long string ]==] --[==[ [[ testing long string3 end ]] ]==] ]=] e = [=[ test.lua:5:13: syntax error, unexpected '[', expecting '(', 'Name', '{', 'function', '...', 'true', 'false', 'nil', 'String', 'Number', '#', '~', '-', 'not' ]=] r = parse(s) check(e, r) -- short strings s = [=[ -- short string test begin local ss6 = "testing unfinished string -- short string test end ]=] e = [=[ test.lua:3:13: syntax error, unexpected '"', expecting '(', 'Name', '{', 'function', '...', 'true', 'false', 'nil', 'String', 'Number', '#', '~', '-', 'not' ]=] r = parse(s) check(e, r) s = [=[ -- short string test begin local ss7 = 'testing \\ unfinished \\ string' -- short string test end ]=] e = [=[ ]=] r = parse(s) --check(e, r) -- unfinished comments s = [=[ --[[ testing unfinished comment ]=] e = [=[ test.lua:3:1: syntax error, unexpected 'comment', expecting '=', ',', 'String', '{', '(', ':', '[', '.' ]=] r = parse(s) check(e, r) print("> testing parser...") -- syntax ok -- anonymous functions s = [=[ local a,b,c = function () end ]=] e = [=[ { `Local{ { `Id "a", `Id "b", `Id "c" }, { `Function{ { }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local test = function ( a , b , ... ) end ]=] e = [=[ { `Local{ { `Id "test" }, { `Function{ { `Id "a", `Id "b", `Dots }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local test = function (...) return ...,0 end ]=] e = [=[ { `Local{ { `Id "test" }, { `Function{ { `Dots }, { `Return{ `Dots, `Number "0" } } } } } } ]=] r = parse(s) check(e, r) -- arithmetic expressions s = [=[ local arithmetic = 1 - 2 * 3 + 4 ]=] e = [=[ { `Local{ { `Id "arithmetic" }, { `Op{ "add", `Op{ "sub", `Number "1", `Op{ "mul", `Number "2", `Number "3" } }, `Number "4" } } } } ]=] r = parse(s) check(e, r) s = [=[ local pow = -3^-2^2 ]=] e = [=[ { `Local{ { `Id "pow" }, { `Op{ "unm", `Op{ "pow", `Number "3", `Op{ "unm", `Op{ "pow", `Number "2", `Number "2" } } } } } } } ]=] r = parse(s) check(e, r) s = [=[ q, r, f = 3//2, 3%2, 3/2 ]=] e = [=[ { `Set{ { `Index{ `Id "_ENV", `String "q" }, `Index{ `Id "_ENV", `String "r" }, `Index{ `Id "_ENV", `String "f" } }, { `Op{ "idiv", `Number "3", `Number "2" }, `Op{ "mod", `Number "3", `Number "2" }, `Op{ "div", `Number "3", `Number "2" } } } } ]=] r = parse(s) check(e, r) -- assignments s = [=[ a = f()[1] ]=] e = [=[ { `Set{ { `Index{ `Id "_ENV", `String "a" } }, { `Index{ `Call{ `Index{ `Id "_ENV", `String "f" } }, `Number "1" } } } } ]=] r = parse(s) check(e, r) s = [=[ a()[1] = 1; ]=] e = [=[ { `Set{ { `Index{ `Call{ `Index{ `Id "_ENV", `String "a" } }, `Number "1" } }, { `Number "1" } } } ]=] r = parse(s) check(e, r) s = [=[ i = a.f(1) ]=] e = [=[ { `Set{ { `Index{ `Id "_ENV", `String "i" } }, { `Call{ `Index{ `Index{ `Id "_ENV", `String "a" }, `String "f" }, `Number "1" } } } } ]=] r = parse(s) check(e, r) s = [=[ i = a[f(1)] ]=] e = [=[ { `Set{ { `Index{ `Id "_ENV", `String "i" } }, { `Index{ `Index{ `Id "_ENV", `String "a" }, `Call{ `Index{ `Id "_ENV", `String "f" }, `Number "1" } } } } } ]=] r = parse(s) check(e, r) s = [=[ a[f()] = sub i = i + 1 ]=] e = [=[ { `Set{ { `Index{ `Index{ `Id "_ENV", `String "a" }, `Call{ `Index{ `Id "_ENV", `String "f" } } } }, { `Index{ `Id "_ENV", `String "sub" } } }, `Set{ { `Index{ `Id "_ENV", `String "i" } }, { `Op{ "add", `Index{ `Id "_ENV", `String "i" }, `Number "1" } } } } ]=] r = parse(s) check(e, r) s = [=[ a:b(1)._ = some_value ]=] e = [=[ { `Set{ { `Index{ `Invoke{ `Index{ `Id "_ENV", `String "a" }, `String "b", `Number "1" }, `String "_" } }, { `Index{ `Id "_ENV", `String "some_value" } } } } ]=] r = parse(s) check(e, r) -- bitwise expressions s = [=[ b = 1 & 0 | 1 ~ 1 ]=] e = [=[ { `Set{ { `Index{ `Id "_ENV", `String "b" } }, { `Op{ "bor", `Op{ "band", `Number "1", `Number "0" }, `Op{ "bxor", `Number "1", `Number "1" } } } } } ]=] r = parse(s) check(e, r) s = [=[ b = 1 & 0 | 1 >> 1 ~ 1 ]=] e = [=[ { `Set{ { `Index{ `Id "_ENV", `String "b" } }, { `Op{ "bor", `Op{ "band", `Number "1", `Number "0" }, `Op{ "bxor", `Op{ "shr", `Number "1", `Number "1" }, `Number "1" } } } } } ]=] r = parse(s) check(e, r) -- break s = [=[ while 1 do break end ]=] e = [=[ { `While{ `Number "1", { `Break } } } ]=] r = parse(s) check(e, r) s = [=[ while 1 do while 1 do break end break end ]=] e = [=[ { `While{ `Number "1", { `While{ `Number "1", { `Break } }, `Break } } } ]=] r = parse(s) check(e, r) s = [=[ repeat if 2 > 1 then break end until 1 ]=] e = [=[ { `Repeat{ { `If{ `Op{ "lt", `Number "1", `Number "2" }, { `Break } } }, `Number "1" } } ]=] r = parse(s) check(e, r) s = [=[ for i=1,10 do do break break return end end ]=] e = [=[ { `Fornum{ `Id "i", `Number "1", `Number "10", { `Do{ `Break, `Break, `Return } } } } ]=] r = parse(s) check(e, r) -- block statements s = [=[ do local var = 2+2; return end ]=] e = [=[ { `Do{ `Local{ { `Id "var" }, { `Op{ "add", `Number "2", `Number "2" } } }, `Return } } ]=] r = parse(s) check(e, r) -- calls s = [=[ f() t:m() ]=] e = [=[ { `Call{ `Index{ `Id "_ENV", `String "f" } }, `Invoke{ `Index{ `Id "_ENV", `String "t" }, `String "m" } } ]=] r = parse(s) check(e, r) -- concatenation expressions s = [=[ local concat1 = 1 .. 2^3 ]=] e = [=[ { `Local{ { `Id "concat1" }, { `Op{ "concat", `Number "1", `Op{ "pow", `Number "2", `Number "3" } } } } } ]=] r = parse(s) check(e, r) -- empty files s = [=[ ; ]=] e = [=[ { } ]=] r = parse(s) check(e, r) -- for generic s = [=[ for k,v in pairs(t) do print (k,v) end ]=] e = [=[ { `Forin{ { `Id "k", `Id "v" }, { `Call{ `Index{ `Id "_ENV", `String "pairs" }, `Index{ `Id "_ENV", `String "t" } } }, { `Call{ `Index{ `Id "_ENV", `String "print" }, `Id "k", `Id "v" } } } } ]=] r = parse(s) check(e, r) -- for numeric s = [=[ for i = 1 , 10 , 2 do end ]=] e = [=[ { `Fornum{ `Id "i", `Number "1", `Number "10", `Number "2", { } } } ]=] r = parse(s) check(e, r) s = [=[ for i=1,10 do end ]=] e = [=[ { `Fornum{ `Id "i", `Number "1", `Number "10", { } } } ]=] r = parse(s) check(e, r) -- global functions s = [=[ function test(a , b , ...) end ]=] e = [=[ { `Set{ { `Index{ `Id "_ENV", `String "test" } }, { `Function{ { `Id "a", `Id "b", `Dots }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ function test (...) end ]=] e = [=[ { `Set{ { `Index{ `Id "_ENV", `String "test" } }, { `Function{ { `Dots }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ function t.a:b() end ]=] e = [=[ { `Set{ { `Index{ `Index{ `Index{ `Id "_ENV", `String "t" }, `String "a" }, `String "b" } }, { `Function{ { `Id "self" }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ function t.a() end ]=] e = [=[ { `Set{ { `Index{ `Index{ `Id "_ENV", `String "t" }, `String "a" } }, { `Function{ { }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ function testando . funcao . com : espcacos ( e, com , parametros, ... ) end ]=] e = [=[ { `Set{ { `Index{ `Index{ `Index{ `Index{ `Id "_ENV", `String "testando" }, `String "funcao" }, `String "com" }, `String "espcacos" } }, { `Function{ { `Id "self", `Id "e", `Id "com", `Id "parametros", `Dots }, { } } } } } ]=] r = parse(s) check(e, r) -- goto s = [=[ goto label :: label :: return ]=] e = [=[ { `Goto{ "label" }, `Label{ "label" }, `Return } ]=] r = parse(s) check(e, r) s = [=[ ::label:: goto label ]=] e = [=[ { `Label{ "label" }, `Goto{ "label" } } ]=] r = parse(s) check(e, r) s = [=[ goto label ::label:: ]=] e = [=[ { `Goto{ "label" }, `Label{ "label" } } ]=] r = parse(s) check(e, r) s = [=[ ::label:: do ::label:: goto label end ]=] e = [=[ { `Label{ "label" }, `Do{ `Label{ "label" }, `Goto{ "label" } } } ]=] r = parse(s) check(e, r) s = [=[ ::label:: do goto label ; ::label:: end ]=] e = [=[ { `Label{ "label" }, `Do{ `Goto{ "label" }, `Label{ "label" } } } ]=] r = parse(s) check(e, r) s = [=[ ::label:: do goto label end ]=] e = [=[ { `Label{ "label" }, `Do{ `Goto{ "label" } } } ]=] r = parse(s) check(e, r) s = [=[ do goto label end ::label:: ]=] e = [=[ { `Do{ `Goto{ "label" } }, `Label{ "label" } } ]=] r = parse(s) check(e, r) s = [=[ do do do do do goto label end end end end end ::label:: ]=] e = [=[ { `Do{ `Do{ `Do{ `Do{ `Do{ `Goto{ "label" } } } } } }, `Label{ "label" } } ]=] r = parse(s) check(e, r) -- if-else s = [=[ if a then end ]=] e = [=[ { `If{ `Index{ `Id "_ENV", `String "a" }, { } } } ]=] r = parse(s) check(e, r) s = [=[ if a then return a else return end ]=] e = [=[ { `If{ `Index{ `Id "_ENV", `String "a" }, { `Return{ `Index{ `Id "_ENV", `String "a" } } }, { `Return } } } ]=] r = parse(s) check(e, r) s = [=[ if a then return a else local c = d d = d + 1 return d end ]=] e = [=[ { `If{ `Index{ `Id "_ENV", `String "a" }, { `Return{ `Index{ `Id "_ENV", `String "a" } } }, { `Local{ { `Id "c" }, { `Index{ `Id "_ENV", `String "d" } } }, `Set{ { `Index{ `Id "_ENV", `String "d" } }, { `Op{ "add", `Index{ `Id "_ENV", `String "d" }, `Number "1" } } }, `Return{ `Index{ `Id "_ENV", `String "d" } } } } } ]=] r = parse(s) check(e, r) s = [=[ if a then return a elseif b then return b elseif c then return c end ]=] e = [=[ { `If{ `Index{ `Id "_ENV", `String "a" }, { `Return{ `Index{ `Id "_ENV", `String "a" } } }, `Index{ `Id "_ENV", `String "b" }, { `Return{ `Index{ `Id "_ENV", `String "b" } } }, `Index{ `Id "_ENV", `String "c" }, { `Return{ `Index{ `Id "_ENV", `String "c" } } } } } ]=] r = parse(s) check(e, r) s = [=[ if a then return a elseif b then return else ; end ]=] e = [=[ { `If{ `Index{ `Id "_ENV", `String "a" }, { `Return{ `Index{ `Id "_ENV", `String "a" } } }, `Index{ `Id "_ENV", `String "b" }, { `Return }, { } } } ]=] r = parse(s) check(e, r) s = [=[ if a then return elseif c then end ]=] e = [=[ { `If{ `Index{ `Id "_ENV", `String "a" }, { `Return }, `Index{ `Id "_ENV", `String "c" }, { } } } ]=] r = parse(s) check(e, r) -- interfaces s = [=[ local interface Empty end ]=] e = [=[ { `Interface{ Empty, `TTable{ } } } ]=] r = parse(s) check(e, r) s = [=[ local interface X x, y, z:number end ]=] e = [=[ { `Interface{ X, `TTable{ `TLiteral x:`TBase number, `TLiteral y:`TBase number, `TLiteral z:`TBase number } } } ]=] r = parse(s) check(e, r) s = [=[ local interface Person firstname:string lastname:string end ]=] e = [=[ { `Interface{ Person, `TTable{ `TLiteral firstname:`TBase string, `TLiteral lastname:`TBase string } } } ]=] r = parse(s) check(e, r) s = [=[ local interface Element info:number next:Element? end ]=] e = [=[ { `Interface{ Element, `TRecursive{ Element, `TTable{ `TLiteral info:`TBase number, `TLiteral next:`TUnion{ `TVariable Element, `TNil } } } } } ]=] r = parse(s) check(e, r) -- labels s = [=[ ::label:: do ::label:: end ::other_label:: ]=] e = [=[ { `Label{ "label" }, `Do{ `Label{ "label" } }, `Label{ "other_label" } } ]=] r = parse(s) check(e, r) -- locals s = [=[ local a ]=] e = [=[ { `Local{ { `Id "a" }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local a,b,c ]=] e = [=[ { `Local{ { `Id "a", `Id "b", `Id "c" }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local a = 1 , 1 + 2, 5.1 ]=] e = [=[ { `Local{ { `Id "a" }, { `Number "1", `Op{ "add", `Number "1", `Number "2" }, `Number "5.1" } } } ]=] r = parse(s) check(e, r) s = [=[ local a,b,c = 1.9 ]=] e = [=[ { `Local{ { `Id "a", `Id "b", `Id "c" }, { `Number "1.9" } } } ]=] r = parse(s) check(e, r) s = [=[ local function test() end ]=] e = [=[ { `Localrec{ { `Id "test" }, { `Function{ { }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function test ( a , b , c , ... ) end ]=] e = [=[ { `Localrec{ { `Id "test" }, { `Function{ { `Id "a", `Id "b", `Id "c", `Dots }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function test(...) return ... end ]=] e = [=[ { `Localrec{ { `Id "test" }, { `Function{ { `Dots }, { `Return{ `Dots } } } } } } ]=] r = parse(s) check(e, r) -- relational expressions s = [=[ local relational = 1 < 2 >= 3 == 4 ~= 5 < 6 <= 7 ]=] e = [=[ { `Local{ { `Id "relational" }, { `Op{ "le", `Op{ "lt", `Op{ "not", `Op{ "eq", `Op{ "eq", `Op{ "le", `Number "3", `Op{ "lt", `Number "1", `Number "2" } }, `Number "4" }, `Number "5" } }, `Number "6" }, `Number "7" } } } } ]=] r = parse(s) check(e, r) -- repeat s = [=[ repeat local a,b,c = 1+1,2+2,3+3 break until a < 1 ]=] e = [=[ { `Repeat{ { `Local{ { `Id "a", `Id "b", `Id "c" }, { `Op{ "add", `Number "1", `Number "1" }, `Op{ "add", `Number "2", `Number "2" }, `Op{ "add", `Number "3", `Number "3" } } }, `Break }, `Op{ "lt", `Index{ `Id "_ENV", `String "a" }, `Number "1" } } } ]=] r = parse(s) check(e, r) -- return s = [=[ return ]=] e = [=[ { `Return } ]=] r = parse(s) check(e, r) s = [=[ return 1 ]=] e = [=[ { `Return{ `Number "1" } } ]=] r = parse(s) check(e, r) s = [=[ return 1,1-2*3+4,"alo" ]=] e = [=[ { `Return{ `Number "1", `Op{ "add", `Op{ "sub", `Number "1", `Op{ "mul", `Number "2", `Number "3" } }, `Number "4" }, `String "alo" } } ]=] r = parse(s) check(e, r) s = [=[ return; ]=] e = [=[ { `Return } ]=] r = parse(s) check(e, r) s = [=[ return 1; ]=] e = [=[ { `Return{ `Number "1" } } ]=] r = parse(s) check(e, r) s = [=[ return 1,1-2*3+4,"alo"; ]=] e = [=[ { `Return{ `Number "1", `Op{ "add", `Op{ "sub", `Number "1", `Op{ "mul", `Number "2", `Number "3" } }, `Number "4" }, `String "alo" } } ]=] r = parse(s) check(e, r) -- tables s = [=[ local t = { [1] = "alo", alo = 1, 2; } ]=] e = [=[ { `Local{ { `Id "t" }, { `Table{ `Pair{ `Number "1", `String "alo" }, `Pair{ `String "alo", `Number "1" }, `Number "2" } } } } ]=] r = parse(s) check(e, r) s = [=[ local t = { 1.5 } ]=] e = [=[ { `Local{ { `Id "t" }, { `Table{ `Number "1.5" } } } } ]=] r = parse(s) check(e, r) s = [=[ local t = {1,2; 3, 4, 5} ]=] e = [=[ { `Local{ { `Id "t" }, { `Table{ `Number "1", `Number "2", `Number "3", `Number "4", `Number "5" } } } } ]=] r = parse(s) check(e, r) s = [=[ local t = {[1]=1,[2]=2; [3]=3, [4]=4, [5]=5} ]=] e = [=[ { `Local{ { `Id "t" }, { `Table{ `Pair{ `Number "1", `Number "1" }, `Pair{ `Number "2", `Number "2" }, `Pair{ `Number "3", `Number "3" }, `Pair{ `Number "4", `Number "4" }, `Pair{ `Number "5", `Number "5" } } } } } ]=] r = parse(s) check(e, r) s = [=[ local t = {{{}}, {"alo"}} ]=] e = [=[ { `Local{ { `Id "t" }, { `Table{ `Table{ `Table }, `Table{ `String "alo" } } } } } ]=] r = parse(s) check(e, r) -- vararg s = [=[ local f = function (...) return ... end ]=] e = [=[ { `Local{ { `Id "f" }, { `Function{ { `Dots }, { `Return{ `Dots } } } } } } ]=] r = parse(s) check(e, r) s = [=[ local f = function () local g = function (x, y, ...) return ...,...,... end end ]=] e = [=[ { `Local{ { `Id "f" }, { `Function{ { }, { `Local{ { `Id "g" }, { `Function{ { `Id "x", `Id "y", `Dots }, { `Return{ `Dots, `Dots, `Dots } } } } } } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function f (x, ...) return ... end ]=] e = [=[ { `Localrec{ { `Id "f" }, { `Function{ { `Id "x", `Dots }, { `Return{ `Dots } } } } } } ]=] r = parse(s) check(e, r) s = [=[ local f = function (x, ...) return ... end ]=] e = [=[ { `Local{ { `Id "f" }, { `Function{ { `Id "x", `Dots }, { `Return{ `Dots } } } } } } ]=] r = parse(s) check(e, r) -- while s = [=[ local i = 0 while (i < 10) do i = i + 1 end ]=] e = [=[ { `Local{ { `Id "i" }, { `Number "0" } }, `While{ `Paren{ `Op{ "lt", `Id "i", `Number "10" } }, { `Set{ { `Id "i" }, { `Op{ "add", `Id "i", `Number "1" } } } } } } ]=] r = parse(s) check(e, r) -- type annotations s = [=[ local x:nil ]=] e = [=[ { `Local{ { `Id "x":`TNil }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:false, y:true ]=] e = [=[ { `Local{ { `Id "x":`TLiteral false, `Id "y":`TLiteral true }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:1, y:1.1 ]=] e = [=[ { `Local{ { `Id "x":`TLiteral 1, `Id "y":`TLiteral 1.1 }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:"hello", y:'world' ]=] e = [=[ { `Local{ { `Id "x":`TLiteral hello, `Id "y":`TLiteral world }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:boolean, y:number, z:string ]=] e = [=[ { `Local{ { `Id "x":`TBase boolean, `Id "y":`TBase number, `Id "z":`TBase string }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:any ]=] e = [=[ { `Local{ { `Id "x":`TAny }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:number? ]=] e = [=[ { `Local{ { `Id "x":`TUnion{ `TBase number, `TNil } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:number|nil ]=] e = [=[ { `Local{ { `Id "x":`TUnion{ `TBase number, `TNil } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:number|string|nil ]=] e = [=[ { `Local{ { `Id "x":`TUnion{ `TBase number, `TBase string, `TNil } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:number|nil|nil|nil|nil ]=] e = [=[ { `Local{ { `Id "x":`TUnion{ `TBase number, `TNil } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:number|nil|string|nil|number|boolean|string ]=] e = [=[ { `Local{ { `Id "x":`TUnion{ `TNil, `TBase number, `TBase boolean, `TBase string } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:number|string? ]=] e = [=[ { `Local{ { `Id "x":`TUnion{ `TBase number, `TBase string, `TNil } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:(number) -> (number) ]=] e = [=[ { `Local{ { `Id "x":`TFunction{ `TTuple{ `TBase number, `TVararg{ `TValue } }, `TTuple{ `TBase number, `TVararg{ `TNil } } } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:(value*) -> (nil*) ]=] e = [=[ { `Local{ { `Id "x":`TFunction{ `TTuple{ `TVararg{ `TValue } }, `TTuple{ `TVararg{ `TNil } } } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:(number,string,boolean) -> (string,number,boolean) ]=] e = [=[ { `Local{ { `Id "x":`TFunction{ `TTuple{ `TBase number, `TBase string, `TBase boolean, `TVararg{ `TValue } }, `TTuple{ `TBase string, `TBase number, `TBase boolean, `TVararg{ `TNil } } } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:(number,string,value*) -> (string,number,nil*) ]=] e = [=[ { `Local{ { `Id "x":`TFunction{ `TTuple{ `TBase number, `TBase string, `TVararg{ `TValue } }, `TTuple{ `TBase string, `TBase number, `TVararg{ `TNil } } } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:{} ]=] e = [=[ { `Local{ { `Id "x":`TTable{ } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:{{{{{}}}}} ]=] e = [=[ { `Local{ { `Id "x":`TTable{ `TBase number:`TUnion{ `TTable{ `TBase number:`TUnion{ `TTable{ `TBase number:`TUnion{ `TTable{ `TBase number:`TUnion{ `TTable{ }, `TNil } }, `TNil } }, `TNil } }, `TNil } } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:{string} ]=] e = [=[ { `Local{ { `Id "x":`TTable{ `TBase number:`TUnion{ `TBase string, `TNil } } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:{string:number} ]=] e = [=[ { `Local{ { `Id "x":`TTable{ `TBase string:`TUnion{ `TBase number, `TNil } } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:{'firstname':string, 'lastname':string} ]=] e = [=[ { `Local{ { `Id "x":`TTable{ `TLiteral firstname:`TBase string, `TLiteral lastname:`TBase string } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:{'tag':string, number:string} ]=] e = [=[ { `Local{ { `Id "x":`TTable{ `TLiteral tag:`TBase string, `TBase number:`TUnion{ `TBase string, `TNil } } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local x:{'f':(number) -> (number), 't':{number:number}} ]=] e = [=[ { `Local{ { `Id "x":`TTable{ `TLiteral f:`TFunction{ `TTuple{ `TBase number, `TVararg{ `TValue } }, `TTuple{ `TBase number, `TVararg{ `TNil } } }, `TLiteral t:`TTable{ `TBase number:`TUnion{ `TBase number, `TNil } } } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ for k:number, v:string in ipairs({"hello", "world"}) do end ]=] e = [=[ { `Forin{ { `Id "k":`TBase number, `Id "v":`TBase string }, { `Call{ `Index{ `Id "_ENV", `String "ipairs" }, `Table{ `String "hello", `String "world" } } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ for k:string, v in pairs({}) do end ]=] e = [=[ { `Forin{ { `Id "k":`TBase string, `Id "v" }, { `Call{ `Index{ `Id "_ENV", `String "pairs" }, `Table } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ for k, v:boolean in pairs({}) do end ]=] e = [=[ { `Forin{ { `Id "k", `Id "v":`TBase boolean }, { `Call{ `Index{ `Id "_ENV", `String "pairs" }, `Table } }, { } } } ]=] r = parse(s) check(e, r) s = [=[ local function f (x:any) end ]=] e = [=[ { `Localrec{ { `Id "f" }, { `Function{ { `Id "x":`TAny }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function f (x:any):(any) end ]=] e = [=[ { `Localrec{ { `Id "f" }, { `Function{ { `Id "x":`TAny }:`TTuple{ `TAny, `TVararg{ `TNil } }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function f (...:any) end ]=] e = [=[ { `Localrec{ { `Id "f" }, { `Function{ { `Dots:`TAny }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function f (x:any, ...:any) end ]=] e = [=[ { `Localrec{ { `Id "f" }, { `Function{ { `Id "x":`TAny, `Dots:`TAny }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function f (x, ...:any) end ]=] e = [=[ { `Localrec{ { `Id "f" }, { `Function{ { `Id "x", `Dots:`TAny }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function f (x:any, ...) end ]=] e = [=[ { `Localrec{ { `Id "f" }, { `Function{ { `Id "x":`TAny, `Dots }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function f (x:any, ...:any):(any) end ]=] e = [=[ { `Localrec{ { `Id "f" }, { `Function{ { `Id "x":`TAny, `Dots:`TAny }:`TTuple{ `TAny, `TVararg{ `TNil } }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function f (x:(any) -> (any)):((any) -> (any)) end ]=] e = [=[ { `Localrec{ { `Id "f" }, { `Function{ { `Id "x":`TFunction{ `TTuple{ `TAny, `TVararg{ `TValue } }, `TTuple{ `TAny, `TVararg{ `TNil } } } }:`TTuple{ `TFunction{ `TTuple{ `TAny, `TVararg{ `TValue } }, `TTuple{ `TAny, `TVararg{ `TNil } } }, `TVararg{ `TNil } }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function f (x:(number, number) -> (number, nil*)):(number*) end ]=] e = [=[ { `Localrec{ { `Id "f" }, { `Function{ { `Id "x":`TFunction{ `TTuple{ `TBase number, `TBase number, `TVararg{ `TValue } }, `TTuple{ `TBase number, `TVararg{ `TNil } } } }:`TTuple{ `TVararg{ `TBase number } }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function f ():(number, nil*) end ]=] e = [=[ { `Localrec{ { `Id "f" }, { `Function{ { }:`TTuple{ `TBase number, `TVararg{ `TNil } }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function f ():number end ]=] e = [=[ { `Localrec{ { `Id "f" }, { `Function{ { }:`TTuple{ `TBase number, `TVararg{ `TNil } }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function f ():number? end ]=] e = [=[ { `Localrec{ { `Id "f" }, { `Function{ { }:`TTuple{ `TUnion{ `TBase number, `TNil }, `TVararg{ `TNil } }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function f ():(number) | (nil,string) end ]=] e = [=[ { `Localrec{ { `Id "f" }, { `Function{ { }:`TUnionlist{ `TTuple{ `TBase number, `TVararg{ `TNil } }, `TTuple{ `TNil, `TBase string, `TVararg{ `TNil } } }, { } } } } } ]=] r = parse(s) check(e, r) s = [=[ local function f ():(number)? end ]=] e = [=[ { `Localrec{ { `Id "f" }, { `Function{ { }:`TUnionlist{ `TTuple{ `TBase number, `TVararg{ `TNil } }, `TTuple{ `TNil, `TBase string, `TVararg{ `TNil } } }, { } } } } } ]=] r = parse(s) check(e, r) -- syntax error -- anonymous functions s = [=[ a = function (a,b,) end ]=] e = [=[ test.lua:1:19: syntax error, unexpected ')', expecting '...', 'Name' ]=] r = parse(s) check(e, r) s = [=[ a = function (...,a) end ]=] e = [=[ test.lua:1:18: syntax error, unexpected ',', expecting ')', ':' ]=] r = parse(s) check(e, r) s = [=[ local a = function (1) end ]=] e = [=[ test.lua:1:21: syntax error, unexpected '1', expecting ')', '...', 'Name' ]=] r = parse(s) check(e, r) s = [=[ local test = function ( a , b , c , ... ) ]=] e = [=[ test.lua:2:1: syntax error, unexpected 'EOF', expecting 'end', 'return', '(', 'Name', 'typealias', 'interface', 'goto', 'break', '::', 'local', 'function', 'const', 'repeat', 'for', 'do', 'while', 'if', ';', ':' ]=] r = parse(s) check(e, r) -- arithmetic expressions s = [=[ a = 3 / / 2 ]=] e = [=[ test.lua:1:9: syntax error, unexpected '/', expecting '(', 'Name', '{', 'function', '...', 'true', 'false', 'nil', 'String', 'Number', '#', '~', '-', 'not' ]=] r = parse(s) check(e, r) -- bitwise expressions s = [=[ b = 1 && 1 ]=] e = [=[ test.lua:1:8: syntax error, unexpected '&', expecting '(', 'Name', '{', 'function', '...', 'true', 'false', 'nil', 'String', 'Number', '#', '~', '-', 'not' ]=] r = parse(s) check(e, r) s = [=[ b = 1 <> 0 ]=] e = [=[ test.lua:1:8: syntax error, unexpected '>', expecting '(', 'Name', '{', 'function', '...', 'true', 'false', 'nil', 'String', 'Number', '#', '~', '-', 'not' ]=] r = parse(s) check(e, r) s = [=[ b = 1 < < 0 ]=] e = [=[ test.lua:1:9: syntax error, unexpected '<', expecting '(', 'Name', '{', 'function', '...', 'true', 'false', 'nil', 'String', 'Number', '#', '~', '-', 'not' ]=] r = parse(s) check(e, r) -- break s = [=[ break ]=] e = [=[ test.lua:1:1: syntax error, <break> not inside a loop ]=] r = parse(s) check(e, r) s = [=[ function f (x) if 1 then break end end ]=] e = [=[ test.lua:2:13: syntax error, <break> not inside a loop ]=] r = parse(s) check(e, r) s = [=[ while 1 do end break ]=] e = [=[ test.lua:3:1: syntax error, <break> not inside a loop ]=] r = parse(s) check(e, r) -- concatenation expressions s = [=[ concat2 = 2^3..1 ]=] e = [=[ test.lua:1:15: syntax error, unexpected '.1', expecting 'return', '(', 'Name', 'typealias', 'interface', 'goto', 'break', '::', 'local', 'function', 'const', 'repeat', 'for', 'do', 'while', 'if', ';', ',', 'or', 'and', '>', '<', '>=', '<=', '==', '~=', '|', '~', '&', '>>', '<<', '..', '-', '+', '%', '/', '//', '*', '^' ]=] r = parse(s) check(e, r) -- for generic s = [=[ for k;v in pairs(t) do end ]=] e = [=[ test.lua:1:6: syntax error, unexpected ';', expecting 'in', ',', ':', '=' ]=] r = parse(s) check(e, r) s = [=[ for k,v in pairs(t:any) do end ]=] e = [=[ test.lua:1:23: syntax error, unexpected ')', expecting 'String', '{', '(' ]=] r = parse(s) check(e, r) -- for numeric s = [=[ for i=1,10, do end ]=] e = [=[ test.lua:1:13: syntax error, unexpected 'do', expecting '(', 'Name', '{', 'function', '...', 'true', 'false', 'nil', 'String', 'Number', '#', '~', '-', 'not' ]=] r = parse(s) check(e, r) s = [=[ for i=1,n:number do end ]=] e = [=[ test.lua:1:18: syntax error, unexpected 'do', expecting 'String', '{', '(' ]=] r = parse(s) check(e, r) -- global functions s = [=[ function func(a,b,c,) end ]=] e = [=[ test.lua:1:21: syntax error, unexpected ')', expecting '...', 'Name' ]=] r = parse(s) check(e, r) s = [=[ function func(...,a) end ]=] e = [=[ test.lua:1:18: syntax error, unexpected ',', expecting ')', ':' ]=] r = parse(s) check(e, r) s = [=[ function a.b:c:d () end ]=] e = [=[ test.lua:1:15: syntax error, unexpected ':', expecting '(' ]=] r = parse(s) check(e, r) -- goto s = [=[ :: label :: return goto label ]=] e = [=[ test.lua:2:1: syntax error, unexpected 'goto', expecting ';', '(', 'Name', '{', 'function', '...', 'true', 'false', 'nil', 'String', 'Number', '#', '~', '-', 'not' ]=] r = parse(s) check(e, r) s = [=[ goto label ]=] e = [=[ test.lua:1:1: syntax error, no visible label 'label' for <goto> ]=] r = parse(s) check(e, r) s = [=[ goto label ::other_label:: ]=] e = [=[ test.lua:1:1: syntax error, no visible label 'label' for <goto> ]=] r = parse(s) check(e, r) s = [=[ ::other_label:: do do do goto label end end end ]=] e = [=[ test.lua:2:10: syntax error, no visible label 'label' for <goto> ]=] r = parse(s) check(e, r) -- if-else s = [=[ if a then ]=] e = [=[ test.lua:2:1: syntax error, unexpected 'EOF', expecting 'end', 'else', 'elseif', 'return', '(', 'Name', 'typealias', 'interface', 'goto', 'break', '::', 'local', 'function', 'const', 'repeat', 'for', 'do', 'while', 'if', ';' ]=] r = parse(s) check(e, r) s = [=[ if a then else ]=] e = [=[ test.lua:2:1: syntax error, unexpected 'EOF', expecting 'end', 'return', '(', 'Name', 'typealias', 'interface', 'goto', 'break', '::', 'local', 'function', 'const', 'repeat', 'for', 'do', 'while', 'if', ';' ]=] r = parse(s) check(e, r) s = [=[ if a then return a elseif b then return b elseif end ]=] e = [=[ test.lua:7:1: syntax error, unexpected 'end', expecting '(', 'Name', '{', 'function', '...', 'true', 'false', 'nil', 'String', 'Number', '#', '~', '-', 'not' ]=] r = parse(s) check(e, r) s = [=[ if a:any then else end ]=] e = [=[ test.lua:1:10: syntax error, unexpected 'then', expecting 'String', '{', '(' ]=] r = parse(s) check(e, r) -- interfaces s = [=[ local interface X x:number y:number z:number x:number end ]=] e = [=[ test.lua:1:7: syntax error, attempt to redeclare field 'x' ]=] r = parse(s) check(e, r) s = [=[ local interface X x, y, z, x:number end ]=] e = [=[ test.lua:1:7: syntax error, attempt to redeclare field 'x' ]=] r = parse(s) check(e, r) s = [=[ local interface boolean end ]=] e = [=[ test.lua:1:7: syntax error, attempt to redeclare type 'boolean' ]=] r = parse(s) check(e, r) s = [=[ local interface number end ]=] e = [=[ test.lua:1:7: syntax error, attempt to redeclare type 'number' ]=] r = parse(s) check(e, r) s = [=[ local interface string end ]=] e = [=[ test.lua:1:7: syntax error, attempt to redeclare type 'string' ]=] r = parse(s) check(e, r) s = [=[ local interface value end ]=] e = [=[ test.lua:1:7: syntax error, attempt to redeclare type 'value' ]=] r = parse(s) check(e, r) s = [=[ local interface any end ]=] e = [=[ test.lua:1:7: syntax error, attempt to redeclare type 'any' ]=] r = parse(s) check(e, r) s = [=[ local interface self end ]=] e = [=[ test.lua:1:7: syntax error, attempt to redeclare type 'self' ]=] r = parse(s) check(e, r) s = [=[ local interface const end ]=] e = [=[ test.lua:1:7: syntax error, attempt to redeclare type 'const' ]=] r = parse(s) check(e, r) -- labels s = [=[ :: blah :: :: not :: ]=] e = [=[ test.lua:2:4: syntax error, unexpected 'not', expecting 'Name' ]=] r = parse(s) check(e, r) s = [=[ ::label:: ::other_label:: ::label:: ]=] e = [=[ test.lua:3:1: syntax error, label 'label' already defined ]=] r = parse(s) check(e, r) -- locals s = [=[ local a = ]=] e = [=[ test.lua:2:1: syntax error, unexpected 'EOF', expecting '(', 'Name', '{', 'function', '...', 'true', 'false', 'nil', 'String', 'Number', '#', '~', '-', 'not' ]=] r = parse(s) check(e, r) s = [=[ local function t.a() end ]=] e = [=[ test.lua:1:17: syntax error, unexpected '.', expecting '(' ]=] r = parse(s) check(e, r) s = [=[ local function test (a,) end ]=] e = [=[ test.lua:1:24: syntax error, unexpected ')', expecting '...', 'Name' ]=] r = parse(s) check(e, r) s = [=[ local function test(...,a) end ]=] e = [=[ test.lua:1:24: syntax error, unexpected ',', expecting ')', ':' ]=] r = parse(s) check(e, r) s = [=[ local function (a, b, c, ...) end ]=] e = [=[ test.lua:1:16: syntax error, unexpected '(', expecting 'Name' ]=] r = parse(s) check(e, r) -- repeat s = [=[ repeat a,b,c = 1+1,2+2,3+3 break ]=] e = [=[ test.lua:4:1: syntax error, unexpected 'EOF', expecting 'until', 'return', '(', 'Name', 'typealias', 'interface', 'goto', 'break', '::', 'local', 'function', 'const', 'repeat', 'for', 'do', 'while', 'if', ';' ]=] r = parse(s) check(e, r) -- return s = [=[ return return 1 return 1,1-2*3+4,"alo" return; return 1; return 1,1-2*3+4,"alo"; ]=] e = [=[ test.lua:2:1: syntax error, unexpected 'return', expecting ';', '(', 'Name', '{', 'function', '...', 'true', 'false', 'nil', 'String', 'Number', '#', '~', '-', 'not' ]=] r = parse(s) check(e, r) -- tables s = [=[ t = { , } ]=] e = [=[ test.lua:1:7: syntax error, unexpected ',', expecting '}', '(', '{', 'function', '...', 'true', 'false', 'nil', 'String', 'Number', '#', '~', '-', 'not', 'Name', '[', 'const' ]=] r = parse(s) check(e, r) -- vararg s = [=[ function f () return ... end ]=] e = [=[ test.lua:2:10: syntax error, cannot use '...' outside a vararg function ]=] r = parse(s) check(e, r) s = [=[ function f () function g (x, y) return ...,...,... end end ]=] e = [=[ test.lua:3:12: syntax error, cannot use '...' outside a vararg function ]=] r = parse(s) check(e, r) s = [=[ local function f (x) return ... end ]=] e = [=[ test.lua:2:10: syntax error, cannot use '...' outside a vararg function ]=] r = parse(s) check(e, r) s = [=[ local f = function (x) return ... end ]=] e = [=[ test.lua:2:10: syntax error, cannot use '...' outside a vararg function ]=] r = parse(s) check(e, r) -- while s = [=[ i = 0 while (i < 10) i = i + 1 end ]=] e = [=[ test.lua:3:3: syntax error, unexpected 'i', expecting 'do', 'or', 'and', '>', '<', '>=', '<=', '==', '~=', '|', '~', '&', '>>', '<<', '..', '-', '+', '%', '/', '//', '*', '^', 'String', '{', '(', ':', '[', '.' ]=] r = parse(s) check(e, r) -- type annotations s = [=[ t[x:any] = 1 ]=] e = [=[ test.lua:1:8: syntax error, unexpected ']', expecting 'String', '{', '(' ]=] r = parse(s) check(e, r) s = [=[ x:number, y, z:boolean = 1, nil, true ]=] e = [=[ test.lua:1:9: syntax error, unexpected ',', expecting 'String', '{', '(' ]=] r = parse(s) check(e, r) s = [=[ x = x:any ]=] e = [=[ test.lua:2:1: syntax error, unexpected 'EOF', expecting 'String', '{', '(' ]=] r = parse(s) check(e, r) s = [=[ x = ...:any ]=] e = [=[ test.lua:1:8: syntax error, unexpected ':', expecting 'return', '(', 'Name', 'typealias', 'interface', 'goto', 'break', '::', 'local', 'function', 'const', 'repeat', 'for', 'do', 'while', 'if', ';', ',', 'or', 'and', '>', '<', '>=', '<=', '==', '~=', '|', '~', '&', '>>', '<<', '..', '-', '+', '%', '/', '//', '*', '^' ]=] r = parse(s) check(e, r) s = [=[ f(x:any) ]=] e = [=[ test.lua:1:8: syntax error, unexpected ')', expecting 'String', '{', '(' ]=] r = parse(s) check(e, r) s = [=[ f(...:any) ]=] e = [=[ test.lua:1:6: syntax error, unexpected ':', expecting ')', ',', 'or', 'and', '>', '<', '>=', '<=', '==', '~=', '|', '~', '&', '>>', '<<', '..', '-', '+', '%', '/', '//', '*', '^' ]=] r = parse(s) check(e, r) s = [=[ local x:number* ]=] e = [=[ test.lua:1:15: syntax error, unexpected '*', expecting 'return', '(', 'Name', 'typealias', 'interface', 'goto', 'break', '::', 'local', 'function', 'const', 'repeat', 'for', 'do', 'while', 'if', ';', '=', ',', '?', '|' ]=] r = parse(s) check(e, r) s = [=[ local x:number| ]=] e = [=[ test.lua:2:1: syntax error, unexpected 'EOF', expecting '{', '(', 'Type' ]=] r = parse(s) check(e, r) s = [=[ local x:number?|string? ]=] e = [=[ test.lua:1:16: syntax error, unexpected '|', expecting 'return', '(', 'Name', 'typealias', 'interface', 'goto', 'break', '::', 'local', 'function', 'const', 'repeat', 'for', 'do', 'while', 'if', ';', '=', ',' ]=] r = parse(s) check(e, r) s = [=[ local x:() -> number ]=] e = [=[ test.lua:1:15: syntax error, unexpected 'number', expecting '(' ]=] r = parse(s) check(e, r) s = [=[ local x:() -> (number)? | (string)? ]=] e = [=[ test.lua:1:35: syntax error, unexpected '?', expecting '->' ]=] r = parse(s) check(e, r) s = [=[ local x:{()->():string} ]=] e = [=[ test.lua:1:16: syntax error, unexpected ':', expecting '}', '?', '|' ]=] r = parse(s) check(e, r) s = [=[ local x:{string:t 1} ]=] e = [=[ test.lua:1:19: syntax error, unexpected '1', expecting '}', '?', '|' ]=] r = parse(s) check(e, r) s = [=[ local x:{{{{{}}}} ]=] e = [=[ test.lua:2:1: syntax error, unexpected 'EOF', expecting '}', '?', '|' ]=] r = parse(s) check(e, r) print("> testing types...") -- literal types local False = tltype.False() local True = tltype.True() local Double = tltype.Literal(1.1) local Integer = tltype.Literal(1) local Word = tltype.Literal("w") -- base types local Boolean = tltype.Boolean() local Number = tltype.Number() local String = tltype.String() -- nil type local Nil = tltype.Nil() -- top type local Value = tltype.Value() -- dynamic type local Any = tltype.Any() -- test types local t, t1, t2, t3, t4 -- type equality check(tltype.isLiteral(False)) check(tltype.isFalse(False)) check(tltype.isLiteral(True)) check(tltype.isTrue(True)) check(tltype.isLiteral(Double)) check(tltype.isNum(Double)) check(tltype.isLiteral(Integer)) check(tltype.isNum(Integer)) check(tltype.isLiteral(Word)) check(tltype.isStr(Word)) check(tltype.isBase(Boolean)) check(tltype.isBoolean(Boolean)) check(tltype.isBase(Number)) check(tltype.isNumber(Number)) check(tltype.isBase(String)) check(tltype.isString(String)) check(tltype.isNil(Nil)) check(tltype.isValue(Value)) check(tltype.isAny(Any)) check(tltype.isUnion(tltype.Union(Number,Nil))) check(tltype.isUnion(tltype.Union(tltype.Union(Number,String),Nil))) check(tltype.isUnion(tltype.Union(tltype.Union(Number,Nil),String))) check(tltype.isUnion(tltype.Union(tltype.Union(Nil,Number),String))) check(tltype.isUnion(tltype.Union(Number,Nil),Nil)) check(tltype.isUnion(tltype.Union(Number,String,Nil),Nil)) check(tltype.isUnion(tltype.Union(Number,Nil,String),Nil)) check(tltype.isUnion(tltype.Union(Nil,Number,String),Nil)) check(not tltype.isUnion(tltype.Union(Number,Boolean),Nil)) check(not tltype.isUnion(tltype.Union(tltype.Union(Number,String),Boolean),Nil)) check(not tltype.isUnion(tltype.Union(tltype.Union(Number,Boolean),String),Nil)) check(not tltype.isUnion(tltype.Union(tltype.Union(Boolean,Number),String),Nil)) t1 = tltype.Vararg(Value) t2 = tltype.Vararg(Nil) check(tltype.isFunction(tltype.Function(tltype.Tuple(t1), tltype.Tuple(t2)))) check(tltype.isTuple(tltype.Tuple(t1))) check(tltype.isTuple(tltype.Tuple(t2))) check(tltype.isVararg(t1)) check(tltype.isVararg(t2)) check(not tltype.isFunction(Nil)) check(not tltype.isTuple(t1)) check(not tltype.isTuple(t2)) check(not tltype.isVararg(tltype.Tuple(t1))) check(not tltype.isVararg(tltype.Tuple(t2))) -- subtyping check(tltype.subtype(False,False)) check(tltype.subtype(True,True)) check(tltype.subtype(Double,Double)) check(tltype.subtype(Integer,Integer)) check(tltype.subtype(Word,Word)) check(tltype.subtype(False,Boolean)) check(tltype.subtype(True,Boolean)) check(tltype.subtype(Double,Number)) check(tltype.subtype(Integer,Number)) check(tltype.subtype(Word,String)) check(not tltype.subtype(Nil,False)) check(not tltype.subtype(False,True)) check(not tltype.subtype(True,Double)) check(not tltype.subtype(Double,Integer)) check(not tltype.subtype(Integer,Word)) check(not tltype.subtype(Word,Nil)) check(tltype.subtype(Nil,Nil)) check(tltype.subtype(Boolean,Boolean)) check(tltype.subtype(Number,Number)) check(tltype.subtype(String,String)) check(not tltype.subtype(Boolean,False)) check(not tltype.subtype(Boolean,True)) check(not tltype.subtype(Number,Double)) check(not tltype.subtype(Number,Integer)) check(not tltype.subtype(String,Word)) check(tltype.subtype(False,Value)) check(tltype.subtype(True,Value)) check(tltype.subtype(Double,Value)) check(tltype.subtype(Integer,Value)) check(tltype.subtype(Word,Value)) check(tltype.subtype(Nil,Value)) check(tltype.subtype(Boolean,Value)) check(tltype.subtype(Number,Value)) check(tltype.subtype(String,Value)) check(tltype.subtype(Value,Value)) check(tltype.subtype(Any,Value)) check(tltype.subtype(tltype.Union(Number,Nil),Value)) check(not tltype.subtype(Value,False)) check(not tltype.subtype(Value,True)) check(not tltype.subtype(Value,Double)) check(not tltype.subtype(Value,Integer)) check(not tltype.subtype(Value,Word)) check(not tltype.subtype(Value,Nil)) check(not tltype.subtype(Value,Boolean)) check(not tltype.subtype(Value,Number)) check(not tltype.subtype(Value,String)) check(not tltype.subtype(Value,Any)) check(not tltype.subtype(Value,tltype.Union(Number,Nil))) check(tltype.subtype(Any,Any)) check(not tltype.subtype(Nil,Any)) check(not tltype.subtype(False,Any)) check(not tltype.subtype(True,Any)) check(not tltype.subtype(Double,Any)) check(not tltype.subtype(Integer,Any)) check(not tltype.subtype(Word,Any)) check(not tltype.subtype(Boolean,Any)) check(not tltype.subtype(Number,Any)) check(not tltype.subtype(String,Any)) check(not tltype.subtype(Any,Nil)) check(not tltype.subtype(Any,False)) check(not tltype.subtype(Any,True)) check(not tltype.subtype(Any,Double)) check(not tltype.subtype(Any,Integer)) check(not tltype.subtype(Any,Word)) check(not tltype.subtype(Any,Boolean)) check(not tltype.subtype(Any,Number)) check(not tltype.subtype(Any,String)) t = tltype.Union(Number,Nil) check(tltype.subtype(Number,t)) check(tltype.subtype(Nil,t)) check(tltype.subtype(t,t)) check(not tltype.subtype(t,Number)) check(not tltype.subtype(t,Nil)) t = tltype.Union(Number,Any) check(tltype.subtype(Any,t)) check(tltype.subtype(t,Any)) check(tltype.subtype(t,t)) check(not tltype.subtype(String,t)) check(not tltype.subtype(Number,t)) t1 = tltype.Recursive("Element", tltype.Table(tltype.Field(false, tltype.Literal("info"), tltype.Number()), tltype.Field(false, tltype.Literal("next"), tltype.Union(tltype.Variable("Element", tltype.Nil()))))) t2 = tltype.Recursive("List", tltype.Table(tltype.Field(false, tltype.Literal("info"), tltype.Number()), tltype.Field(false, tltype.Literal("next"), tltype.Union(tltype.Variable("List", tltype.Nil()))))) t3 = tltype.Recursive("Node", tltype.Table(tltype.Field(false, tltype.Literal("info"), tltype.Number()), tltype.Field(false, tltype.Literal("left"), tltype.Union(tltype.Variable("Node", tltype.Nil()))), tltype.Field(false, tltype.Literal("right"), tltype.Union(tltype.Variable("Node", tltype.Nil()))))) t4 = tltype.Recursive("Tree", tltype.Table(tltype.Field(false, tltype.Literal("info"), tltype.Number()), tltype.Field(false, tltype.Literal("left"), tltype.Union(tltype.Variable("Tree", tltype.Nil()))), tltype.Field(false, tltype.Literal("right"), tltype.Union(tltype.Variable("Tree", tltype.Nil()))))) check(tltype.subtype( t1, t1)) check(tltype.subtype(t2, t2)) check(tltype.subtype(t3, t3)) check(tltype.subtype(t4, t4)) check(not tltype.subtype(t1, t3)) check(not tltype.subtype(t1, t4)) check(not tltype.subtype(t2, t3)) check(not tltype.subtype(t2, t4)) t1 = tltype.Tuple({ Value }, true) t2 = tltype.Tuple({ Nil }, true) check(tltype.subtype(tltype.Function(t1,t2), tltype.Function(t1,t2))) check(tltype.subtype(tltype.Function(t1,t2), tltype.Function(t2,t1))) check(tltype.subtype(tltype.Function(t2,t1), tltype.Function(t2,t1))) check(not tltype.subtype(tltype.Function(t2,t1), tltype.Function(t1,t2))) t1 = tltype.Tuple({ Number }, true) check(tltype.subtype(tltype.Function(t1,t2), tltype.Function(t1,t2))) check(tltype.subtype(tltype.Function(t1,t2), tltype.Function(t2,t1))) check(tltype.subtype(tltype.Function(t2,t1), tltype.Function(t2,t1))) check(not tltype.subtype(tltype.Function(t2,t1), tltype.Function(t1,t2))) t3 = tltype.Vararg(Nil) t4 = tltype.Tuple({ Number, Number, t3 }) check(tltype.subtype(tltype.Function(t1,t2), tltype.Function(t2,t2))) check(not tltype.subtype(tltype.Function(t3,t2), tltype.Function(t1,t2))) t3 = tltype.Vararg(Number) t4 = tltype.Tuple({ Number, Number, Number, t3 }) check(tltype.subtype(tltype.Function(t1,t1), tltype.Function(t4,t1))) check(not tltype.subtype(tltype.Function(t4,t1), tltype.Function(t1,t1))) -- consistent-subtyping check(tltype.consistent_subtype(False,False)) check(tltype.consistent_subtype(True,True)) check(tltype.consistent_subtype(Double,Double)) check(tltype.consistent_subtype(Integer,Integer)) check(tltype.consistent_subtype(Word,Word)) check(tltype.consistent_subtype(False,Boolean)) check(tltype.consistent_subtype(True,Boolean)) check(tltype.consistent_subtype(Double,Number)) check(tltype.consistent_subtype(Integer,Number)) check(tltype.consistent_subtype(Word,String)) check(not tltype.consistent_subtype(Nil,False)) check(not tltype.consistent_subtype(False,True)) check(not tltype.consistent_subtype(True,Double)) check(not tltype.consistent_subtype(Double,Integer)) check(not tltype.consistent_subtype(Integer,Word)) check(not tltype.consistent_subtype(Word,Nil)) check(tltype.consistent_subtype(Nil,Nil)) check(tltype.consistent_subtype(Boolean,Boolean)) check(tltype.consistent_subtype(Number,Number)) check(tltype.consistent_subtype(String,String)) check(not tltype.consistent_subtype(Boolean,False)) check(not tltype.consistent_subtype(Boolean,True)) check(not tltype.consistent_subtype(Number,Double)) check(not tltype.consistent_subtype(Number,Integer)) check(not tltype.consistent_subtype(String,Word)) check(tltype.consistent_subtype(False,Value)) check(tltype.consistent_subtype(True,Value)) check(tltype.consistent_subtype(Double,Value)) check(tltype.consistent_subtype(Integer,Value)) check(tltype.consistent_subtype(Word,Value)) check(tltype.consistent_subtype(Nil,Value)) check(tltype.consistent_subtype(Boolean,Value)) check(tltype.consistent_subtype(Number,Value)) check(tltype.consistent_subtype(String,Value)) check(tltype.consistent_subtype(Value,Value)) check(tltype.consistent_subtype(tltype.Union(Number,Nil),Value)) check(not tltype.consistent_subtype(Value,False)) check(not tltype.consistent_subtype(Value,True)) check(not tltype.consistent_subtype(Value,Double)) check(not tltype.consistent_subtype(Value,Integer)) check(not tltype.consistent_subtype(Value,Word)) check(not tltype.consistent_subtype(Value,Nil)) check(not tltype.consistent_subtype(Value,Boolean)) check(not tltype.consistent_subtype(Value,Number)) check(not tltype.consistent_subtype(Value,String)) check(not tltype.consistent_subtype(Value,tltype.Union(Number,Nil))) check(tltype.consistent_subtype(Any,Any)) check(tltype.consistent_subtype(Any,Value)) check(tltype.consistent_subtype(Value,Any)) check(tltype.consistent_subtype(Nil,Any)) check(tltype.consistent_subtype(False,Any)) check(tltype.consistent_subtype(True,Any)) check(tltype.consistent_subtype(Double,Any)) check(tltype.consistent_subtype(Integer,Any)) check(tltype.consistent_subtype(Word,Any)) check(tltype.consistent_subtype(Boolean,Any)) check(tltype.consistent_subtype(Number,Any)) check(tltype.consistent_subtype(String,Any)) check(tltype.consistent_subtype(Any,Nil)) check(tltype.consistent_subtype(Any,False)) check(tltype.consistent_subtype(Any,True)) check(tltype.consistent_subtype(Any,Double)) check(tltype.consistent_subtype(Any,Integer)) check(tltype.consistent_subtype(Any,Word)) check(tltype.consistent_subtype(Any,Boolean)) check(tltype.consistent_subtype(Any,Number)) check(tltype.consistent_subtype(Any,String)) t = tltype.Union(Number,Nil) check(tltype.consistent_subtype(Number,t)) check(tltype.consistent_subtype(Nil,t)) check(tltype.consistent_subtype(t,t)) check(not tltype.consistent_subtype(t,Number)) check(not tltype.consistent_subtype(t,Nil)) t = tltype.Union(Number,Any) check(tltype.consistent_subtype(Number,t)) check(tltype.consistent_subtype(Any,t)) check(tltype.consistent_subtype(t,t)) check(tltype.consistent_subtype(String,t)) check(tltype.consistent_subtype(t,Any)) check(tltype.consistent_subtype(t,String)) t1 = tltype.Tuple({ Any }, true) t2 = tltype.Tuple({ Nil }, true) check(tltype.consistent_subtype(tltype.Function(t1,t2), tltype.Function(t1,t2))) check(tltype.consistent_subtype(tltype.Function(t1,t2), tltype.Function(t2,t1))) check(tltype.consistent_subtype(tltype.Function(t2,t1), tltype.Function(t2,t1))) check(tltype.consistent_subtype(tltype.Function(t2,t1), tltype.Function(t1,t2))) t2 = tltype.Tuple({ Number }, true) check(tltype.consistent_subtype(tltype.Function(t1,t2), tltype.Function(t1,t2))) check(tltype.consistent_subtype(tltype.Function(t1,t2), tltype.Function(t2,t1))) check(tltype.consistent_subtype(tltype.Function(t2,t1), tltype.Function(t2,t1))) check(tltype.consistent_subtype(tltype.Function(t2,t1), tltype.Function(t1,t2))) t3 = tltype.Vararg(Any) t4 = tltype.Tuple({ Any, Any, t3 }, false) check(tltype.consistent_subtype(tltype.Function(t1,t2), tltype.Function(t2,t1))) check(tltype.consistent_subtype(tltype.Function(t4,t2), tltype.Function(t1,t2))) check(tltype.consistent_subtype(tltype.Function(t1,t2), tltype.Function(t4,t2))) print("> testing type checker...") -- type check s = [=[ local x:value, y:value, z:value = 1, "foo" ]=] e = [=[ { `Local{ { `Id "x":`TValue, `Id "y":`TValue, `Id "z":`TValue }, { `Number "1", `String "foo" } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x, y, z = 1, "foo", false ]=] e = [=[ { `Local{ { `Id "x", `Id "y", `Id "z" }, { `Number "1", `String "foo", `False } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:number, y:string, z:boolean = 1, "foo", false ]=] e = [=[ { `Local{ { `Id "x":`TBase number, `Id "y":`TBase string, `Id "z":`TBase boolean }, { `Number "1", `String "foo", `False } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:boolean, y:nil = true, nil ]=] e = [=[ { `Local{ { `Id "x":`TBase boolean, `Id "y":`TNil }, { `True, `Nil } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:number?, y:number|nil = 1 ]=] e = [=[ { `Local{ { `Id "x":`TUnion{ `TBase number, `TNil }, `Id "y":`TUnion{ `TBase number, `TNil } }, { `Number "1" } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:number = 1 + 1 ]=] e = [=[ { `Local{ { `Id "x":`TBase number }, { `Op{ "add", `Number "1", `Number "1" } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:string = "hello" .. "world" ]=] e = [=[ { `Local{ { `Id "x":`TBase string }, { `Op{ "concat", `String "hello", `String "world" } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:boolean, y:boolean = nil == false, false == true ]=] e = [=[ { `Local{ { `Id "x":`TBase boolean, `Id "y":`TBase boolean }, { `Op{ "eq", `Nil, `False }, `Op{ "eq", `False, `True } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:boolean, y:boolean = 1 == 2, "foo" == "bar" ]=] e = [=[ { `Local{ { `Id "x":`TBase boolean, `Id "y":`TBase boolean }, { `Op{ "eq", `Number "1", `Number "2" }, `Op{ "eq", `String "foo", `String "bar" } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:boolean, y:boolean = 1 < 2, "foo" < "bar" ]=] e = [=[ { `Local{ { `Id "x":`TBase boolean, `Id "y":`TBase boolean }, { `Op{ "lt", `Number "1", `Number "2" }, `Op{ "lt", `String "foo", `String "bar" } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:nil, y:boolean = nil and 1, false and 1 ]=] e = [=[ { `Local{ { `Id "x":`TNil, `Id "y":`TBase boolean }, { `Op{ "and", `Nil, `Number "1" }, `Op{ "and", `False, `Number "1" } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:number, y:string? = 1 and 2, "foo" and nil ]=] e = [=[ { `Local{ { `Id "x":`TBase number, `Id "y":`TUnion{ `TBase string, `TNil } }, { `Op{ "and", `Number "1", `Number "2" }, `Op{ "and", `String "foo", `Nil } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:number, y:number = nil or 1, false or 1 ]=] e = [=[ { `Local{ { `Id "x":`TBase number, `Id "y":`TBase number }, { `Op{ "or", `Nil, `Number "1" }, `Op{ "or", `False, `Number "1" } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:number, y:string? = 1 or 2, "foo" or nil ]=] e = [=[ { `Local{ { `Id "x":`TBase number, `Id "y":`TUnion{ `TBase string, `TNil } }, { `Op{ "or", `Number "1", `Number "2" }, `Op{ "or", `String "foo", `Nil } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:number? local y:number = x or 0 ]=] e = [=[ { `Local{ { `Id "x":`TUnion{ `TBase number, `TNil } }, { } }, `Local{ { `Id "y":`TBase number }, { `Op{ "or", `Id "x", `Number "0" } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:boolean, y:boolean = not nil, not false ]=] e = [=[ { `Local{ { `Id "x":`TBase boolean, `Id "y":`TBase boolean }, { `Op{ "not", `Nil }, `Op{ "not", `False } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:number = -1 ]=] e = [=[ { `Local{ { `Id "x":`TBase number }, { `Op{ "unm", `Number "1" } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:number = #"foo" ]=] e = [=[ { `Local{ { `Id "x":`TBase number }, { `Op{ "len", `String "foo" } } } } ]=] r = typecheck(s) check(e, r) s = [=[ while 1 do break end ]=] e = [=[ { `While{ `Number "1", { `Break } } } ]=] r = typecheck(s) check(e, r) s = [=[ repeat break until 1 ]=] e = [=[ { `Repeat{ { `Break }, `Number "1" } } ]=] r = typecheck(s) check(e, r) s = [=[ if 1 then local x = 1 end ]=] e = [=[ { `If{ `Number "1", { `Local{ { `Id "x" }, { `Number "1" } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ if 1 then local x = 1 else local x = "foo" end ]=] e = [=[ { `If{ `Number "1", { `Local{ { `Id "x" }, { `Number "1" } } }, { `Local{ { `Id "x" }, { `String "foo" } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ if 1 then local x = 1 elseif 2 then local x = 2 elseif 3 then local x = 3 elseif 4 then local x = 4 else local x = "foo" end ]=] e = [=[ { `If{ `Number "1", { `Local{ { `Id "x" }, { `Number "1" } } }, `Number "2", { `Local{ { `Id "x" }, { `Number "2" } } }, `Number "3", { `Local{ { `Id "x" }, { `Number "3" } } }, `Number "4", { `Local{ { `Id "x" }, { `Number "4" } } }, { `Local{ { `Id "x" }, { `String "foo" } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ function f(x:number?) if x then x = x + 1 else print("x is nil") end end ]=] e = [=[ { `Set{{ `Index{ `Id "_ENV", `String "f" } },{ `Function{{ `Id "x":`TUnion{ `TBase number, `TNil } },{ `If{ `Id "x",{ `Set{{ `Id "x" },{ `Op{"add", `Id "x", `Number "1" } } } },{ `Call{ `Index{ `Id "_ENV", `String "print" }, `String "x is nil" } } } } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ function f(x:number?) if not x then print("x is nil") else x = x + 1 end end ]=] e = [=[ { `Set{{ `Index{ `Id "_ENV", `String "f" } },{ `Function{{ `Id "x":`TUnion{ `TBase number, `TNil } },{ `If{ `Op{"not", `Id "x" },{ `Call{ `Index{ `Id "_ENV", `String "print" }, `String "x is nil" } },{ `Set{{ `Id "x" },{ `Op{"add", `Id "x", `Number "1" } } } } } } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ function f(x:number?) if type(x) == "number" then x = x + 1 else print("x is nil") end end ]=] e = [=[ { `Set{{ `Index{ `Id "_ENV", `String "f" } },{ `Function{{ `Id "x":`TUnion{ `TBase number, `TNil } },{ `If{ `Op{"eq", `Call{ `Index{ `Id "_ENV", `String "type" }, `Id "x" }, `String "number" },{ `Set{{ `Id "x" },{ `Op{"add", `Id "x", `Number "1" } } } },{ `Call{ `Index{ `Id "_ENV", `String "print" }, `String "x is nil" } } } } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ function f(x:number?) if type(x) ~= "number" then print("x is nil") else x = x + 1 end end ]=] e = [=[ { `Set{{ `Index{ `Id "_ENV", `String "f" } },{ `Function{{ `Id "x":`TUnion{ `TBase number, `TNil } },{ `If{ `Op{"not", `Op{"eq", `Call{ `Index{ `Id "_ENV", `String "type" }, `Id "x" }, `String "number" } },{ `Call{ `Index{ `Id "_ENV", `String "print" }, `String "x is nil" } },{ `Set{{ `Id "x" },{ `Op{"add", `Id "x", `Number "1" } } } } } } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local function f(x:number|string?) local y = x if type(x) == "number" then x = x + 1 elseif type(y) == "string" then y = y .. "hello" elseif type(x) == "string" then x = x .. "hello" elseif type(y) == "number" then y = y + 1 end x = y y = x end ]=] e = [=[ { `Localrec{{ `Id "f":`TFunction{ `TTuple{ `TUnion{ `TBase number, `TBase string, `TNil }, `TVararg{ `TValue } }, `TTuple{ `TVararg{ `TNil } } } },{ `Function{{ `Id "x":`TUnion{ `TBase number, `TBase string, `TNil } },{ `Local{{ `Id "y" },{ `Id "x" } }, `If{ `Op{"eq", `Call{ `Index{ `Id "_ENV", `String "type" }, `Id "x" }, `String "number" },{ `Set{{ `Id "x" },{ `Op{"add", `Id "x", `Number "1" } } } }, `Op{"eq", `Call{ `Index{ `Id "_ENV", `String "type" }, `Id "y" }, `String "string" },{ `Set{{ `Id "y" },{ `Op{"concat", `Id "y", `String "hello" } } } }, `Op{"eq", `Call{ `Index{ `Id "_ENV", `String "type" }, `Id "x" }, `String "string" },{ `Set{{ `Id "x" },{ `Op{"concat", `Id "x", `String "hello" } } } }, `Op{"eq", `Call{ `Index{ `Id "_ENV", `String "type" }, `Id "y" }, `String "number" },{ `Set{{ `Id "y" },{ `Op{"add", `Id "y", `Number "1" } } } } }, `Set{{ `Id "x" },{ `Id "y" } }, `Set{{ `Id "y" },{ `Id "x" } } } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:number|string? local y = x if type(x) == "nil" then print("x is nil") elseif type(y) == "nil" then print("y is nil") elseif type(x) == "string" then x = x .. "hello" elseif type(y) == "number" then y = y + 1 else x = x + 1 y = y .. "hello" end x = y y = x ]=] e = [=[ { `Local{ { `Id "x":`TUnion{ `TBase number, `TBase string, `TNil } }, { } }, `Local{ { `Id "y" }, { `Id "x" } }, `If{ `Op{ "eq", `Call{ `Index{ `Id "_ENV", `String "type" }, `Id "x" }, `String "nil" }, { `Call{ `Index{ `Id "_ENV", `String "print" }, `String "x is nil" } }, `Op{ "eq", `Call{ `Index{ `Id "_ENV", `String "type" }, `Id "y" }, `String "nil" }, { `Call{ `Index{ `Id "_ENV", `String "print" }, `String "y is nil" } }, `Op{ "eq", `Call{ `Index{ `Id "_ENV", `String "type" }, `Id "x" }, `String "string" }, { `Set{ { `Id "x" }, { `Op{ "concat", `Id "x", `String "hello" } } } }, `Op{ "eq", `Call{ `Index{ `Id "_ENV", `String "type" }, `Id "y" }, `String "number" }, { `Set{ { `Id "y" }, { `Op{ "add", `Id "y", `Number "1" } } } }, { `Set{ { `Id "x" }, { `Op{ "add", `Id "x", `Number "1" } } }, `Set{ { `Id "y" }, { `Op{ "concat", `Id "y", `String "hello" } } } } }, `Set{ { `Id "x" }, { `Id "y" } }, `Set{ { `Id "y" }, { `Id "x" } } } ]=] r = typecheck(s) check(e, r) s = [=[ for i = 1, 10 do local x = i end ]=] e = [=[ { `Fornum{ `Id "i", `Number "1", `Number "10", { `Local{ { `Id "x" }, { `Id "i" } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ for i = 10, 1, -1 do local x = i end ]=] e = [=[ { `Fornum{ `Id "i", `Number "10", `Number "1", `Op{ "unm", `Number "1" }, { `Local{ { `Id "x" }, { `Id "i" } } } } } ]=] r = typecheck(s) check(e, r) -- do not type check s = [=[ local v:value local a:boolean, b:number, c:string = v, v, v ]=] e = [=[ test.lua:2:7: type error, attempt to assign 'value' to 'boolean' test.lua:2:18: type error, attempt to assign 'value' to 'number' test.lua:2:28: type error, attempt to assign 'value' to 'string' ]=] r = typecheck(s) check(e, r) s = [=[ local x:boolean, y:boolean, z:number = 1, "foo" z = 10 z = nil ]=] e = [=[ test.lua:1:7: type error, attempt to assign '1' to 'boolean' test.lua:1:18: type error, attempt to assign '"foo"' to 'boolean' test.lua:3:1: type error, attempt to assign '(nil)' to '(number,value*)' ]=] r = typecheck(s) check(e, r) s = [=[ local x:number, y:number, z:string = false, true z = "foo" z = nil ]=] e = [=[ test.lua:1:7: type error, attempt to assign 'false' to 'number' test.lua:1:17: type error, attempt to assign 'true' to 'number' test.lua:3:1: type error, attempt to assign '(nil)' to '(string,value*)' ]=] r = typecheck(s) check(e, r) s = [=[ local x, y = 1 + "foo", "foo" + 1 local a:any a = a + 1 a = 1 + a ]=] e = [=[ test.lua:1:18: type error, attempt to perform arithmetic on a 'string' test.lua:1:25: type error, attempt to perform arithmetic on a 'string' ]=] r = typecheck(s) check(e, r) s = [=[ local x, y = "foo" .. 1, 1 .. "foo" local a:any a = a .. "foo" a = "foo" .. a ]=] e = [=[ test.lua:1:23: type error, attempt to concatenate a 'number' test.lua:1:26: type error, attempt to concatenate a 'number' ]=] r = typecheck(s) check(e, r) s = [=[ local x, y = 1 < "foo", "foo" < 1 local a:any a = a < 1 a = 1 < a ]=] e = [=[ test.lua:1:14: type error, attempt to compare 'number' with 'string' test.lua:1:25: type error, attempt to compare 'string' with 'number' ]=] r = typecheck(s) check(e, r) s = [=[ local x, y = nil < 1, true < "false" ]=] e = [=[ test.lua:1:14: type error, attempt to compare 'nil' with 'number' test.lua:1:23: type error, attempt to compare 'boolean' with 'string' ]=] r = typecheck(s) check(e, r) s = [=[ local x:number, y:number = nil and 1, false and 1 local a:number?, b:number|false = 1, 1 a = a and 1 b = b and 1 ]=] e = [=[ test.lua:1:17: type error, attempt to assign 'false' to 'number' ]=] r = typecheck(s) check(e, r) s = [=[ local x:string, y:number|string = 1 and 2, "foo" and nil ]=] e = [=[ test.lua:1:7: type error, attempt to assign '1 | 2' to 'string' test.lua:1:17: type error, attempt to assign '"foo"?' to 'number | string' ]=] r = typecheck(s) check(e, r) s = [=[ local x:nil, y:boolean = nil or 1, false or 1 local a:number?, b:number|false = 1, 1 a = a or 1 b = b or 1 ]=] e = [=[ test.lua:1:7: type error, attempt to assign '1' to 'nil' test.lua:1:14: type error, attempt to assign '1' to 'boolean' ]=] r = typecheck(s) check(e, r) s = [=[ local x:string, y:number|string = 1 or 2, "foo" or nil ]=] e = [=[ test.lua:1:7: type error, attempt to assign '1 | 2' to 'string' test.lua:1:17: type error, attempt to assign '"foo"?' to 'number | string' ]=] r = typecheck(s) check(e, r) s = [=[ local x:number? local y:number = x or nil y = 10 y = nil ]=] e = [=[ test.lua:4:1: type error, attempt to assign '(nil)'to '(number,value*)' ]=] r = typecheck(s) check(e, r) s = [=[ local x:number, y:string = not nil, not false ]=] e = [=[ test.lua:1:7: type error, attempt to assign 'boolean' to 'number' test.lua:1:17: type error, attempt to assign 'boolean' to 'string' ]=] r = typecheck(s) check(e, r) s = [=[ local x:number, y:string = not 1, not "foo" ]=] e = [=[ test.lua:1:7: type error, attempt to assign 'boolean' to 'number' test.lua:1:17: type error, attempt to assign 'boolean' to 'string' ]=] r = typecheck(s) check(e, r) s = [=[ local x = -"foo" local a:any a = -a ]=] e = [=[ test.lua:1:12: type error, attempt to perform arithmetic on a 'string' ]=] r = typecheck(s) check(e, r) s = [=[ local x = #1 local a:any a = #a ]=] e = [=[ test.lua:1:12: type error, attempt to get length of a 'number' ]=] r = typecheck(s) check(e, r) s = [=[ while 1 + "foo" do break end ]=] e = [=[ test.lua:1:11: type error, attempt to perform arithmetic on a 'string' ]=] r = typecheck(s) check(e, r) s = [=[ repeat break until 1 + nil ]=] e = [=[ test.lua:1:24: type error, attempt to perform arithmetic on a 'nil' ]=] r = typecheck(s) check(e, r) s = [=[ if 1 then local x:string = 1 end ]=] e = [=[ test.lua:1:17: type error, attempt to assign '1' to 'string' ]=] r = typecheck(s) check(e, r) s = [=[ if 1 then local x:number = 1 else local x:number = "foo" end ]=] e = [=[ test.lua:1:41: type error, attempt to assign '"foo"' to 'number' ]=] r = typecheck(s) check(e, r) s = [=[ if 1 then local x = 1 elseif 2 then local x = 2 elseif 3 then local x:string = 3 elseif 4 then local x:boolean = 4 else local x = "foo" end ]=] e = [=[ test.lua:6:9: type error, attempt to assign '3' to 'string' test.lua:8:9: type error, attempt to assign '4' to 'boolean' ]=] r = typecheck(s) check(e, r) s = [=[ function f(x:number?, y:string?) if type(x) == "number" then x = x + 1 elseif type(y) == "string" then y = y .. "hello" else x = x + 1 y = y + 1 end x = x + 1 y = y .. "hello" end ]=] e = [=[ test.lua:9:7: type error, attempt to perform arithmetic on a 'nil' test.lua:10:7: type error, attempt to perform arithmetic on a 'nil' test.lua:13:5: type error, attempt to perform arithmetic on a 'number?' test.lua:14:5: type error, attempt to concatenate a 'string?' ]=] r = typecheck(s) check(e, r) s = [=[ function f(x:boolean|number|string?) if type(x) == "number" then x = x + 1 elseif type(x) == "string" then x = x .. "hello" elseif type(x) == "boolean" then x = false elseif math.random() > 0.5 then error("break") end x = x + 1 end ]=] e = [=[ test.lua:13:5: type error, attempt to perform arithmetic on a 'boolean | number | string | nil' ]=] r = typecheck(s) check(e, r) s = [=[ local x:number? if type(y) == "number" then print("y is number") else print("y is nil") end ]=] e = [=[ test.lua:3:9: type error, attempt to access undeclared global 'y' ]=] r = typecheck(s) check(e, r) s = [=[ for i = nil, 10 do local x = i end ]=] e = [=[ test.lua:1:9: type error, 'for' initial value must be a number ]=] r = typecheck(s) check(e, r) s = [=[ for i = 1, "foo" do local x = i end ]=] e = [=[ test.lua:1:12: type error, 'for' limit must be a number ]=] r = typecheck(s) check(e, r) s = [=[ for i = 10, 1, false do local x = i end ]=] e = [=[ test.lua:1:16: type error, 'for' step must be a number ]=] r = typecheck(s) check(e, r) -- new tests s = [=[ local x = setmetatable({}, {}) local y = setmetatable() local z = require(x) local w = require() ]=] e = [=[ test.lua:2:11: type error, attempt to pass '()' to global 'setmetatable' of input type '({any:any},{any:any}?,value*)' test.lua:3:11: type error, attempt to pass '({any:any})' to global 'require' of input type '(string,value*)' test.lua:4:11: type error, attempt to pass '()' to global 'require' of input type '(string,value*)' ]=] r = typecheck(s) check(e, r) s = [=[ local function f ():(number, number) return 1, 2 end local x:number, y:number, z:number = f() z = 10 z = nil ]=] e = [=[ test.lua:4:1: type error, attempt to assign '(nil)'to '(number,value*)' ]=] r = typecheck(s) check(e, r) s = [=[ local function f ():(number) end ]=] e = [=[ test.lua:1:18: type error, return type '()' does not match '(number)' ]=] r = typecheck(s) check(e, r) s = [=[ local function f ():(any) return 1 end ]=] e = [=[ { `Localrec{ { `Id "f":`TFunction{ `TTuple{ `TVararg{ `TValue } }, `TTuple{ `TAny, `TVararg{ `TNil } } } }, { `Function{ { }:`TTuple{ `TAny, `TVararg{ `TNil } }, { `Return{ `Number "1" } } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x:number? local t = { [function () end] = 1, [x] = 2 } ]=] e = [=[ test.lua:2:37: type error, table index can be nil ]=] r = typecheck(s) check(e, r) s = [=[ local x:number = 1 local x:string = "foo" ]=] e = [=[ { `Local{ { `Id "x":`TBase number }, { `Number "1" } }, `Local{ { `Id "x":`TBase string }, { `String "foo" } } } ]=] r = typecheck(s) check(e, r) s = [=[ local function fib (n:number) if n == 0 then return 0 elseif n == 1 then return 1 else return fib(n - 1) + fib(n - 2) end end ]=] e = [=[ test.lua:7:12: type error, attempt to perform arithmetic on a 'nil' ]=] r = typecheck(s) check(e, r) s = [=[ local function fib (n:number):number if n == 0 then return 0 elseif n == 1 then return 1 else return fib(n - 1) + fib(n - 2) end end ]=] e = [=[ { `Localrec{ { `Id "fib":`TFunction{ `TTuple{ `TBase number, `TVararg{ `TValue } }, `TTuple{ `TBase number, `TVararg{ `TNil } } } }, { `Function{ { `Id "n":`TBase number }:`TTuple{ `TBase number, `TVararg{ `TNil } }, { `If{ `Op{ "eq", `Id "n", `Number "0" }, { `Return{ `Number "0" } }, `Op{ "eq", `Id "n", `Number "1" }, { `Return{ `Number "1" } }, { `Return{ `Op{ "add", `Call{ `Id "fib", `Op{ "sub", `Id "n", `Number "1" } }, `Call{ `Id "fib", `Op{ "sub", `Id "n", `Number "2" } } } } } } } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ for i,j,k in 1,2,3 do end for w in string.gmatch("foo bar", "(%w+)") do w = w .. "foo" end for w in ("foo bar"):gmatch("(%w+)") do w = w .. "foo" end ]=] e = [=[ test.lua:1:5: type error, attempt to iterate over '1' ]=] r = typecheck(s) check(e, r) s = [=[ for k, v in pairs({ foo = 1, bar = 2}) do print(k .. "1", v) end for k, v in ipairs({1,2,3}) do print(k + 1, v) end for k, v in ipairs({ foo = 1, bar = 2}) do print(k .. "1", v) end ]=] e = [=[ test.lua:10:9: type error, attempt to concatenate a 'number' ]=] r = typecheck(s) check(e, r) s = [=[ local x:any = 1 for n = x, x, x do end for k in x do end ]=] e = [=[ { `Local{ { `Id "x":`TAny }, { `Number "1" } }, `Fornum{ `Id "n", `Id "x", `Id "x", `Id "x", { } }, `Forin{ { `Id "k" }, { `Id "x" }, { } } } ]=] r = typecheck(s) check(e, r) s = [=[ local x local y = x.z, y.z x.z = 1 z.z = 2 ]=] e = [=[ test.lua:2:11:type error,attempt to index 'nil'with '"z"' test.lua:2:16: type error, attempt to access undeclared global 'y' test.lua:2:16: type error, attempt to index 'nil' with '"z"' test.lua:3:1:type error,attempt to index 'nil'with '"z"' test.lua:3:1:type error,attempt to assign '(1)'to '(nil,value*)' test.lua:4:1: type error, attempt to access undeclared global 'z' test.lua:4:1: type error, attempt to index 'nil' with '"z"' test.lua:4:1: type error, attempt to assign '(2)' to '(nil, value*)' ]=] r = typecheck(s) check(e, r) s = [=[ local x local y = 1 x() y() ]=] e = [=[ test.lua:3:1:type error,attempt to call local 'x'of type 'nil' test.lua:4:1: type error, attempt to call local 'y' of type 'number' ]=] r = typecheck(s) check(e, r) s = [=[ local t:{"x":any} = {} local x:any local y:number = 1 t:x() t:y() x:y() y:x() ]=] e = [=[ test.lua:5:1: type error, attempt to call method 'y' of type 'nil' test.lua:7:1: type error, attempt to index 'number' with '"x"' ]=] r = typecheck(s) check(e, r) s = [=[ local o = { x = 1 } const function o:set_x (x:number) self.x = x end local x = o.set_x x(5, 1) -- first parameter has 'any' type x(5) -- force error ]=] e = [=[ test.lua:5:1: type error, attempt to pass '(5)' to local 'x' of input type '(any, number, value*)' ]=] r = typecheck(s) check(e, r) s = [=[ local function f ():() return end local function g (x:number):(number)? if x < 0 then return nil, "negative" else return x end end local function h (x:number):(number)? if x > 0 then return x else return g(x) end end ]=] e = [=[ { `Localrec{ { `Id "f":`TFunction{ `TTuple{ `TVararg{ `TValue } }, `TTuple{ `TVararg{ `TNil } } } }, { `Function{ { }:`TTuple{ `TVararg{ `TNil } }, { `Return } } } }, `Localrec{ { `Id "g":`TFunction{ `TTuple{ `TBase number, `TVararg{ `TValue } }, `TUnionlist{ `TTuple{ `TBase number, `TVararg{ `TNil } }, `TTuple{ `TNil, `TBase string, `TVararg{ `TNil } } } } }, { `Function{ { `Id "x":`TBase number }:`TUnionlist{ `TTuple{ `TBase number, `TVararg{ `TNil } }, `TTuple{ `TNil, `TBase string, `TVararg{ `TNil } } }, { `If{ `Op{ "lt", `Id "x", `Number "0" }, { `Return{ `Nil, `String "negative" } }, { `Return{ `Id "x" } } } } } } }, `Localrec{ { `Id "h":`TFunction{ `TTuple{ `TBase number, `TVararg{ `TValue } }, `TUnionlist{ `TTuple{ `TBase number, `TVararg{ `TNil } }, `TTuple{ `TNil, `TBase string, `TVararg{ `TNil } } } } }, { `Function{ { `Id "x":`TBase number }:`TUnionlist{ `TTuple{ `TBase number, `TVararg{ `TNil } }, `TTuple{ `TNil, `TBase string, `TVararg{ `TNil } } }, { `If{ `Op{ "lt", `Number "0", `Id "x" }, { `Return{ `Id "x" } }, { `Return{ `Call{ `Id "g", `Id "x" } } } } } } } } } ]=] r = typecheck(s) check(e, r) -- paper dyla s = [=[ local function factorial(n:number):number if n == 0 then return 1 else return n * factorial(n - 1) end end local x = 5 print(factorial(x)) ]=] e = [=[ { `Localrec{ { `Id "factorial":`TFunction{ `TTuple{ `TBase number, `TVararg{ `TValue } }, `TTuple{ `TBase number, `TVararg{ `TNil } } } }, { `Function{ { `Id "n":`TBase number }:`TTuple{ `TBase number, `TVararg{ `TNil } }, { `If{ `Op{ "eq", `Id "n", `Number "0" }, { `Return{ `Number "1" } }, { `Return{ `Op{ "mul", `Id "n", `Call{ `Id "factorial", `Op{ "sub", `Id "n", `Number "1" } } } } } } } } } }, `Local{ { `Id "x" }, { `Number "5" } }, `Call{ `Index{ `Id "_ENV", `String "print" }, `Call{ `Id "factorial", `Id "x" } } } ]=] r = typecheck(s) check(e, r) s = [=[ local function abs(n:number) if n < 0 then return -n else return n end end local function distance(x, y) return abs(x - y) end ]=] e = [=[ { `Localrec{ { `Id "abs":`TFunction{ `TTuple{ `TBase number, `TVararg{ `TValue } }, `TTuple{ `TBase number, `TVararg{ `TNil } } } }, { `Function{ { `Id "n":`TBase number }, { `If{ `Op{ "lt", `Id "n", `Number "0" }, { `Return{ `Op{ "unm", `Id "n" } } }, { `Return{ `Id "n" } } } } } } }, `Localrec{ { `Id "distance":`TFunction{ `TTuple{ `TAny, `TAny, `TVararg{ `TValue } }, `TTuple{ `TBase number, `TVararg{ `TNil } } } }, { `Function{ { `Id "x":`TAny, `Id "y":`TAny }, { `Return{ `Call{ `Id "abs", `Op{ "sub", `Id "x", `Id "y" } } } } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local function multiple () return 2, "foo" end local function sum(x:number, y:number) return x + y end local x, y, z = multiple(), multiple() print(sum(multiple(), multiple())) ]=] e = [=[ { `Localrec{ { `Id "multiple":`TFunction{ `TTuple{ `TVararg{ `TValue } }, `TTuple{ `TBase number, `TBase string, `TVararg{ `TNil } } } }, { `Function{ { }, { `Return{ `Number "2", `String "foo" } } } } }, `Localrec{ { `Id "sum":`TFunction{ `TTuple{ `TBase number, `TBase number, `TVararg{ `TValue } }, `TTuple{ `TBase number, `TVararg{ `TNil } } } }, { `Function{ { `Id "x":`TBase number, `Id "y":`TBase number }, { `Return{ `Op{ "add", `Id "x", `Id "y" } } } } } }, `Local{ { `Id "x", `Id "y", `Id "z" }, { `Call{ `Id "multiple" }, `Call{ `Id "multiple" } } }, `Call{ `Index{ `Id "_ENV", `String "print" }, `Call{ `Id "sum", `Call{ `Id "multiple" }, `Call{ `Id "multiple" } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local function message (name:string, greeting:string?) local greeting = greeting or "Hello " return greeting .. name end print(message("Lua")) print(message("Lua", "Hi")) ]=] e = [=[ { `Localrec{ { `Id "message":`TFunction{ `TTuple{ `TBase string, `TUnion{ `TBase string, `TNil }, `TVararg{ `TValue } }, `TTuple{ `TBase string, `TVararg{ `TNil } } } }, { `Function{ { `Id "name":`TBase string, `Id "greeting":`TUnion{ `TBase string, `TNil } }, { `Local{ { `Id "greeting" }, { `Op{ "or", `Id "greeting", `String "Hello " } } }, `Return{ `Op{ "concat", `Id "greeting", `Id "name" } } } } } }, `Call{ `Index{ `Id "_ENV", `String "print" }, `Call{ `Id "message", `String "Lua" } }, `Call{ `Index{ `Id "_ENV", `String "print" }, `Call{ `Id "message", `String "Lua", `String "Hi" } } } ]=] r = typecheck(s) check(e, r) s = [=[ local function message (name:string, greeting:string?) greeting = greeting or "Hello " return greeting .. name end ]=] e = [=[ { `Localrec{ { `Id "message":`TFunction{ `TTuple{ `TBase string, `TUnion{ `TBase string, `TNil }, `TVararg{ `TValue } }, `TTuple{ `TBase string, `TVararg{ `TNil } } } }, { `Function{ { `Id "name":`TBase string, `Id "greeting":`TUnion{ `TBase string, `TNil } }, { `Set{ { `Id "greeting" }, { `Op{ "or", `Id "greeting", `String "Hello " } } }, `Return{ `Op{ "concat", `Id "greeting", `Id "name" } } } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local function f (s:string?) local function f () s = nil end s = s or "hi" s = s .. "hello" end ]=] e = [=[ test.lua:6:7: type error, attempt to concatenate a 'string?' ]=] r = typecheck(s) check(e, r) s = [=[ function f(s:string?) while true do s = s or "foo" end s = s .. "bar" end ]=] e = [=[ test.lua:7:5: type error, attempt to concatenate a 'string?' ]=] r = typecheck(s) check(e, r) s = [=[ local function rep (s:string, n:number, sep:string?):string sep = sep or "" local r = "" for i = 1, n - 1 do r = r .. s .. sep end return r .. s end local function overload (s1:string, s2:string|number) if type(s2) == "string" then return s1 .. s2 else return rep(s1, s2) end end ]=] e = [=[ { `Localrec{ { `Id "rep":`TFunction{ `TTuple{ `TBase string, `TBase number, `TUnion{ `TBase string, `TNil }, `TVararg{ `TValue } }, `TTuple{ `TBase string, `TVararg{ `TNil } } } }, { `Function{ { `Id "s":`TBase string, `Id "n":`TBase number, `Id "sep":`TUnion{ `TBase string, `TNil } }:`TTuple{ `TBase string, `TVararg{ `TNil } }, { `Set{ { `Id "sep" }, { `Op{ "or", `Id "sep", `String "" } } }, `Local{ { `Id "r" }, { `String "" } }, `Fornum{ `Id "i", `Number "1", `Op{ "sub", `Id "n", `Number "1" }, { `Set{ { `Id "r" }, { `Op{ "concat", `Id "r", `Op{ "concat", `Id "s", `Id "sep" } } } } } }, `Return{ `Op{ "concat", `Id "r", `Id "s" } } } } } }, `Localrec{ { `Id "overload":`TFunction{ `TTuple{ `TBase string, `TUnion{ `TBase string, `TBase number }, `TVararg{ `TValue } }, `TTuple{ `TBase string, `TVararg{ `TNil } } } }, { `Function{ { `Id "s1":`TBase string, `Id "s2":`TUnion{ `TBase string, `TBase number } }, { `If{ `Op{ "eq", `Call{ `Index{ `Id "_ENV", `String "type" }, `Id "s2" }, `String "string" }, { `Return{ `Op{ "concat", `Id "s1", `Id "s2" } } }, { `Return{ `Call{ `Id "rep", `Id "s1", `Id "s2" } } } } } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local function overload (s1:string, s2:string|number) if type(s2) == "string" then return s1 .. s2 else return string.rep(s1, s2) end end ]=] e = [=[ { `Localrec{ { `Id "overload":`TFunction{ `TTuple{ `TBase string, `TUnion{ `TBase string, `TBase number }, `TVararg{ `TValue } }, `TTuple{ `TBase string, `TVararg{ `TNil } } } }, { `Function{ { `Id "s1":`TBase string, `Id "s2":`TUnion{ `TBase string, `TBase number } }, { `If{ `Op{ "eq", `Call{ `Index{ `Id "_ENV", `String "type" }, `Id "s2" }, `String "string" }, { `Return{ `Op{ "concat", `Id "s1", `Id "s2" } } }, { `Return{ `Call{ `Index{ `Index{ `Id "_ENV", `String "string" }, `String "rep" }, `Id "s1", `Id "s2" } } } } } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local function idiv (d1:number, d2:number):(number, number) | (nil, string) if d2 == 0 then return nil, "division by zero" else local r = d1 % d2 local q = (d1 - r) / d2 return q, r end end local n1, n2 = 4, 4 local q, r = idiv(n1, n2) local x:number, msg:string = 0, "" if q then x = q + r else msg = r end ]=] e = [=[ { `Localrec{ { `Id "idiv":`TFunction{ `TTuple{ `TBase number, `TBase number, `TVararg{ `TValue } }, `TUnionlist{ `TTuple{ `TBase number, `TBase number, `TVararg{ `TNil } }, `TTuple{ `TNil, `TBase string, `TVararg{ `TNil } } } } }, { `Function{ { `Id "d1":`TBase number, `Id "d2":`TBase number }:`TUnionlist{ `TTuple{ `TBase number, `TBase number, `TVararg{ `TNil } }, `TTuple{ `TNil, `TBase string, `TVararg{ `TNil } } }, { `If{ `Op{ "eq", `Id "d2", `Number "0" }, { `Return{ `Nil, `String "division by zero" } }, { `Local{ { `Id "r" }, { `Op{ "mod", `Id "d1", `Id "d2" } } }, `Local{ { `Id "q" }, { `Op{ "div", `Paren{ `Op{ "sub", `Id "d1", `Id "r" } }, `Id "d2" } } }, `Return{ `Id "q", `Id "r" } } } } } } }, `Local{ { `Id "n1", `Id "n2" }, { `Number "4", `Number "4" } }, `Local{ { `Id "q", `Id "r" }, { `Call{ `Id "idiv", `Id "n1", `Id "n2" } } }, `Local{ { `Id "x":`TBase number, `Id "msg":`TBase string }, { `Number "0", `String "" } }, `If{ `Id "q", { `Set{ { `Id "x" }, { `Op{ "add", `Id "q", `Id "r" } } } }, { `Set{ { `Id "msg" }, { `Id "r" } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ function x() : (number, boolean)|(string, number) if 0 > 1 then return 1, true else return "wat", 9 end end local foo, bar = x() if foo then local bla = foo .. " world" end ]=] e = [=[ test.lua:11:16: type error, attempt to concatenate a 'number | string' ]=] r = typecheck(s) check(e, r) s = [=[ local t:{string:number} = { foo = 1 } local x:number? = t.foo local y:number = t["bar"] or 0 ]=] e = [=[ { `Local{ { `Id "t":`TTable{ `TBase string:`TUnion{ `TBase number, `TNil } } }, { `Table{ `Pair{ `String "foo", `Number "1" } } } }, `Local{ { `Id "x":`TUnion{ `TBase number, `TNil } }, { `Index{ `Id "t", `String "foo" } } }, `Local{ { `Id "y":`TBase number }, { `Op{ "or", `Index{ `Id "t", `String "bar" }, `Number "0" } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local t:{string:number?} = { foo = 1 or nil } local x:number = t.foo local y:number = t.bar or 0 local z:number? = t["bar"] ]=] e = [=[ test.lua:2:7: type error, attempt to assign 'number?' to 'number' ]=] r = typecheck(s) check(e, r) s = [=[ local t1:{"foo":number} = { foo = 1, bar = "foo" } local t2:{string:number} = t1 ]=] e = [=[ test.lua:2:7: type error, attempt to assign '{"foo":number}' to '{string:number?}' ]=] r = typecheck(s) check(e, r) s = [=[ local days:{string} = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } local x = days[1] local y = days[8] ]=] e = [=[ { `Local{ { `Id "days":`TTable{ `TBase number:`TUnion{ `TBase string, `TNil } } }, { `Table{ `String "Sunday", `String "Monday", `String "Tuesday", `String "Wednesday", `String "Thursday", `String "Friday", `String "Saturday" } } }, `Local{ { `Id "x" }, { `Index{ `Id "days", `Number "1" } } }, `Local{ { `Id "y" }, { `Index{ `Id "days", `Number "8" } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local days = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } ]=] e = [=[ { `Local{ { `Id "days" }, { `Table{ `String "Sunday", `String "Monday", `String "Tuesday", `String "Wednesday", `String "Thursday", `String "Friday", `String "Saturday" } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local days = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } local t1:{string} = days local t2:{string?} = days t2 = t1 ]=] e = [=[ test.lua:3:7: type error, attempt to assign '{1:string, 2:string, 3:string, 4:string, 5:string, 6:string, 7:string}' to '{number:string?}' test.lua:4:7: type error, attempt to assign '{1:string, 2:string, 3:string, 4:string, 5:string, 6:string, 7:string}' to '{number:string?}' ]=] r = typecheck(s) check(e, r) s = [=[ local t1:{{string}} = { { "foo", "bar", "z" }, { "z", "bar", "foo" }, 4 } local t2:{string} = { "foo", "bar", "z", function () end } local t3:{"foo":number, number:string} = { foo = 1, [1] = true } ]=] e = [=[ test.lua:1:7: type error, attempt to assign '{1:{1:string, 2:string, 3:string}, 2:{1:string, 2:string, 3:string}, 3:number}' to '{number:{number:string?}?}' test.lua:2:7: type error, attempt to assign '{1:string, 2:string, 3:string, 4:(value*) -> ()}' to '{number:string?}' test.lua:3:7: type error, attempt to assign '{"foo":number, 1:boolean}' to '{"foo":number, number:string?}' ]=] r = typecheck(s) check(e, r) s = [=[ local t:{const "foo":string?} = { const foo = "foo" or nil } local s:{const "foo":string} = { const foo = "foo" } local r:{"foo":string?} = { foo = "foo" or nil } t = s r = t r.foo = nil ]=] e = [=[ test.lua:6:1: type error, attempt to assign '({const "foo":string?})' to '({"foo":string?}, value*)' ]=] r = typecheck(s) check(e, r) s = [=[ local t = { ... } for i = 1, #t do print(t[i]) end ]=] e = [=[ { `Local{ { `Id "t" }, { `Table{ `Dots } } }, `Fornum{ `Id "i", `Number "1", `Op{ "len", `Id "t" }, { `Call{ `Index{ `Id "_ENV", `String "print" }, `Index{ `Id "t", `Id "i" } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local t = { ... } t[1] = 1 ]=] e = [=[ test.lua:2:1: type error, attempt to assign '(1)' to '(string?, value*)' ]=] r = typecheck(s) check(e, r) s = [=[ local t = { ... } t[1] = "foo" t.foo = 1 ]=] e = [=[ { `Local{ { `Id "t" }, { `Table{ `Dots } } }, `Set{ { `Index{ `Id "t", `Number "1" } }, { `String "foo" } }, `Set{ { `Index{ `Id "t", `String "foo" } }, { `Number "1" } } } ]=] r = typecheck(s) check(e, r) s = [=[ local t1:{"foo":number, number:string|nil} = { foo = 1, ... } local t2:{"foo":number, 2:string|nil, "bar":number} = { foo = 1, ..., bar = 2 } local t3:{1:string|nil, "foo":number} = { ..., foo = 1 } local t4:{"foo":number, "bar":number, number:string|nil} = { foo = 1, bar = 2, ... } local t5:{"foo":number, "bar":number, 3:string|nil, 2:number} = { foo = 1, bar = 2, ..., 3 } ]=] e = [=[ { `Local{ { `Id "t1":`TTable{ `TLiteral foo:`TBase number, `TBase number:`TUnion{ `TBase string, `TNil } } }, { `Table{ `Pair{ `String "foo", `Number "1" }, `Dots } } }, `Local{ { `Id "t2":`TTable{ `TLiteral foo:`TBase number, `TLiteral 2:`TUnion{ `TBase string, `TNil }, `TLiteral bar:`TBase number } }, { `Table{ `Pair{ `String "foo", `Number "1" }, `Dots, `Pair{ `String "bar", `Number "2" } } } }, `Local{ { `Id "t3":`TTable{ `TLiteral 1:`TUnion{ `TBase string, `TNil }, `TLiteral foo:`TBase number } }, { `Table{ `Dots, `Pair{ `String "foo", `Number "1" } } } }, `Local{ { `Id "t4":`TTable{ `TLiteral foo:`TBase number, `TLiteral bar:`TBase number, `TBase number:`TUnion{ `TBase string, `TNil } } }, { `Table{ `Pair{ `String "foo", `Number "1" }, `Pair{ `String "bar", `Number "2" }, `Dots } } }, `Local{ { `Id "t5":`TTable{ `TLiteral foo:`TBase number, `TLiteral bar:`TBase number, `TLiteral 3:`TUnion{ `TBase string, `TNil }, `TLiteral 2:`TBase number } }, { `Table{ `Pair{ `String "foo", `Number "1" }, `Pair{ `String "bar", `Number "2" }, `Dots, `Number "3" } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local person:{"firstname":string, "lastname":string} = { firstname = "Lou", lastname = "Reed" } ]=] e = [=[ { `Local{ { `Id "person":`TTable{ `TLiteral firstname:`TBase string, `TLiteral lastname:`TBase string } }, { `Table{ `Pair{ `String "firstname", `String "Lou" }, `Pair{ `String "lastname", `String "Reed" } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local person:Person = { firstname = "Lou", lastname = "Reed" } ]=] e = [=[ test.lua:1:7: type error, type alias 'Person' is not defined test.lua:1:7: type error, attempt to assign '{"firstname":string, "lastname":string}' to 'nil' ]=] r = typecheck(s) check(e, r) s = [=[ local interface Person firstname:string lastname:string end local function greet (person:Person) return "Hello, " .. person.firstname .. " " .. person.lastname end local user1 = { firstname = "Lewis", middlename = "Allan", lastname = "Reed" } local user2 = { firstname = "Lou" } local user3 = { lastname = "Reed", firstname = "Lou" } local user4 = { "Lou", "Reed" } print(greet(user1)) print(greet(user2)) print(greet(user3)) print(greet(user4)) ]=] e = [=[ test.lua:14:7: type error, attempt to pass '({"firstname":string})' to local 'greet' of input type '(Person, value*)' test.lua:16:7: type error, attempt to pass '({1:string, 2:string})' to local 'greet' of input type '(Person, value*)' ]=] r = typecheck(s) check(e, r) s = [=[ local interface Person firstname:string middlename:string? lastname:string end local user1:Person = { firstname = "Lewis", middlename = "Allan", lastname = "Reed" } local user2:Person = { lastname = "Reed", firstname = "Lou" } ]=] e = [=[ { `Interface{ Person, `TTable{ `TLiteral firstname:`TBase string, `TLiteral middlename:`TUnion{ `TBase string, `TNil }, `TLiteral lastname:`TBase string } }, `Local{ { `Id "user1":`TVariable Person }, { `Table{ `Pair{ `String "firstname", `String "Lewis" }, `Pair{ `String "middlename", `String "Allan" }, `Pair{ `String "lastname", `String "Reed" } } } }, `Local{ { `Id "user2":`TVariable Person }, { `Table{ `Pair{ `String "lastname", `String "Reed" }, `Pair{ `String "firstname", `String "Lou" } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local interface Person firstname:string middlename:string? lastname:string end local user1:Person = { firstname = "Lewis", middlename = "Allan" or nil, lastname = "Reed" } local user2:Person = { lastname = "Reed", firstname = "Lou" } ]=] e = [=[ { `Interface{ Person, `TTable{ `TLiteral firstname:`TBase string, `TLiteral middlename:`TUnion{ `TBase string, `TNil }, `TLiteral lastname:`TBase string } }, `Local{ { `Id "user1":`TVariable Person }, { `Table{ `Pair{ `String "firstname", `String "Lewis" }, `Pair{ `String "middlename", `Op{ "or", `String "Allan", `Nil } }, `Pair{ `String "lastname", `String "Reed" } } } }, `Local{ { `Id "user2":`TVariable Person }, { `Table{ `Pair{ `String "lastname", `String "Reed" }, `Pair{ `String "firstname", `String "Lou" } } } } } ]=] r = typecheck(s) check(e, r) s = [=[ local interface Person firstname:string middlename:string? lastname:string end local interface Person end ]=] e = [=[ test.lua:7:7: type error, attempt to redeclare interface 'Person' ]=] r = typecheck(s) check(e, r) s = [=[ interface Test a: string b: boolean c: number? end local function fn(x: Test): number return 44 end fn{a="", b = false, c = 33} ]=] e = [=[ { `Interface{ Test, `TTable{ `TLiteral a:`TBase string, `TLiteral b:`TBase boolean, `TLiteral c:`TUnion{ `TBase number, `TNil } } }, `Localrec{ { `Id "fn":`TFunction{ `TTuple{ `TTable{ `TLiteral a:`TBase string, `TLiteral b:`TBase boolean, `TLiteral c:`TUnion{ `TBase number, `TNil } }, `TVararg{ `TValue } }, `TTuple{ `TBase number, `TVararg{ `TNil } } } }, { `Function{ { `Id "x":`TTable{ `TLiteral a:`TBase string, `TLiteral b:`TBase boolean, `TLiteral c:`TUnion{ `TBase number, `TNil } } }:`TTuple{ `TBase number, `TVararg{ `TNil } }, { `Return{ `Number "44" } } } } }, `Call{ `Id "fn", `Table{ `Pair{ `String "a", `String "" }, `Pair{ `String "b", `False }, `Pair{ `String "c", `Number "33" } } } } ]=] r = typecheck(s) check(e, r) s = [=[ interface Attribute name: string value: string namespace: string? end interface Element tag: string tag_namespace: string? attr: {Attribute?} end local elem: Element = { tag = "html", attr = { { name = "lang", value = "en" } } } ]=] e = [=[ { `Interface{ Attribute, `TTable{ `TLiteral name:`TBase string, `TLiteral value:`TBase string, `TLiteral namespace:`TUnion{ `TBase string, `TNil } } }, `Interface{ Element, `TTable{ `TLiteral tag:`TBase string, `TLiteral tag_namespace:`TUnion{ `TBase string, `TNil }, `TLiteral attr:`TTable{ `TBase number:`TUnion{ `TTable{ `TLiteral name:`TBase string, `TLiteral value:`TBase string, `TLiteral namespace:`TUnion{ `TBase string, `TNil } }, `TNil } } } }, `Local{ { `Id "elem":`TVariable Element }, { `Table{ `Pair{ `String "tag", `String "html" }, `Pair{ `String "attr", `Table{ `Table{ `Pair{ `String "name", `String "lang" }, `Pair{ `String "value", `String "en" } } } } } } } } ]=] r = typecheck(s) check(e, r) --[[ FAILING TEST s = [=[ local interface Element info:number next:Elment? end ]=] e = [=[ { `Interface{ Element, `TTable{ `TLiteral info:`TBase number, `TLiteral next:`TUnion{ `TGlobalVariable Elment, `TNil } } } } ]=] r = typecheck(s) check(e, r) --]] s = [=[ local person = {} person.firstname = "Lou" person.lastname = "Reed" ]=] e = [=[ { `Local{ { `Id "person" }, { `Table } }, `Set{ { `Index{ `Id "person", `String "firstname" } }, { `String "Lou" } }, `Set{ { `Index{ `Id "person", `String "lastname" } }, { `String "Reed" } } } ]=] r = typecheck(s) check(e, r) s = [=[ local bogus = { firstname = 1 } local person:{} = bogus person.firstname = "Lou" person.lastname = "Reed" ]=] e = [=[ test.lua:3:1: type error, attempt to use '"firstname"' to index closed table test.lua:3:1: type error, attempt to assign '("Lou")' to '(nil, value*)' test.lua:4:1: type error, attempt to use '"lastname"' to index closed table test.lua:4:1: type error, attempt to assign '("Reed")' to '(nil, value*)' ]=] r = typecheck(s) check(e, r) s = [=[ local person = {} local bogus = person bogus.firstname = 1 person.firstname = "Lou" person.lastname = "Reed" ]=] e = [=[ test.lua:3:1: type error, attempt to use '"firstname"' to index closed table test.lua:3:1: type error, attempt to assign '(1)' to '(nil, value*)' ]=] r = typecheck(s) check(e, r) s = [=[ local person = {} local bogus = { firstname = 1 } do person.firstname = 1 bogus = person end do person.firstname = "Lou" end ]=] e = [=[ test.lua:4:3: type error, attempt to use '"firstname"' to index closed table test.lua:4:3: type error, attempt to assign '(1)' to '(nil, value*)' test.lua:5:3: type error, attempt to assign '({})' to '({"firstname":number}, value*)' test.lua:8:3: type error, attempt to use '"firstname"' to index closed table test.lua:8:3: type error, attempt to assign '("Lou")' to '(nil, value*)' ]=] r = typecheck(s) check(e, r) s = [=[ local t = {} c = { 1 } t.c = { 1 } local a = c[1] local b = t.c[1] local x = c[2] local y = t.c[2] local z = g ]=] e = [=[ test.lua:6:11: type error, attempt to index '{1:number}' with '2' test.lua:7:11: type error, attempt to index '{1:number}' with '2' test.lua:8:11: type error, attempt to access undeclared global 'g' ]=] r = typecheck(s) check(e, r) s = [=[ local interface Person firstname:string middlename:string? lastname:string end local user = {} user.firstname = "Lou" user.lastname = "Reed" local person:Person = user ]=] e = [=[ { `Interface{ Person, `TTable{ `TLiteral firstname:`TBase string, `TLiteral middlename:`TUnion{ `TBase string, `TNil }, `TLiteral lastname:`TBase string } }, `Local{ { `Id "user" }, { `Table } }, `Set{ { `Index{ `Id "user", `String "firstname" } }, { `String "Lou" } }, `Set{ { `Index{ `Id "user", `String "lastname" } }, { `String "Reed" } }, `Local{ { `Id "person":`TVariable Person }, { `Id "user" } } } ]=] r = typecheck(s) check(e, r) s = [=[ local interface Person firstname:string middlename:string? lastname:string end local user = {} user.firstname = "Lewis" user.middlename = "Allan" user.lastname = "Reed" local person:Person = user ]=] e = [=[ test.lua:11:7: type error, attempt to assign '{"firstname":string, "middlename":string, "lastname":string}' to 'Person' ]=] r = typecheck(s) check(e, r) s = [=[ local interface Person firstname:string middlename:string? lastname:string end local user = {} user.firstname = "Lewis" user.middlename = "Allan" or nil user.lastname = "Reed" local person:Person = user ]=] e = [=[ { `Interface{ Person, `TTable{ `TLiteral firstname:`TBase string, `TLiteral middlename:`TUnion{ `TBase string, `TNil }, `TLiteral lastname:`TBase string } }, `Local{ { `Id "user" }, { `Table } }, `Set{ { `Index{ `Id "user", `String "firstname" } }, { `String "Lewis" } }, `Set{ { `Index{ `Id "user", `String "middlename" } }, { `Op{ "or", `String "Allan", `Nil } } }, `Set{ { `Index{ `Id "user", `String "lastname" } }, { `String "Reed" } }, `Local{ { `Id "person":`TVariable Person }, { `Id "user" } } } ]=] r = typecheck(s) check(e, r) s = [=[ local str = "foo" print(str:byte()) print(("foo"):byte()) ]=] e = [=[ { `Local{ { `Id "str" }, { `String "foo" } }, `Call{ `Index{ `Id "_ENV", `String "print" }, `Invoke{ `Id "str", `String "byte" } }, `Call{ `Index{ `Id "_ENV", `String "print" }, `Invoke{ `Paren{ `String "foo" }, `String "byte" } } } ]=] r = typecheck(s) check(e, r) s = [=[ local str = "foo" print(str:char()) ]=] e = [=[ test.lua:2:7: type error, attempt to pass '(string)' to field of input type '(number*)' ]=] r = typecheck(s) check(e, r) s = [=[ local function f (...:{1:string}) local t:{string} = {...} end f = function (...:number):(string*) return ... end ]=] e = [=[ test.lua:2:9: type error, attempt to assign '{number:{1:string}?}' to '{number:string?}' test.lua:4:1: type error, attempt to assign '((number*) -> (string*))' to '(({1:string}*) -> (), value*)' test.lua:4:14: type error, return type '(number*)' does not match '(string*)' ]=] r = typecheck(s) check(e, r) s = [=[ interface Shape x, y:number const new:(number, number) => (self) const move:(number, number) => () end local Shape = { x = 0, y = 0 } const function Shape:new (x:number, y:number) local s = setmetatable({}, { __index = self }) s.x = x s.y = y return s end const function Shape:move (dx:number, dy:number) self.x = self.x + dx self.y = self.y + dy end local shape1 = Shape:new(0, 5) local shape2:Shape = Shape:new(10, 10) interface Circle x, y, radius:number const new:(number, number, value) => (self) const move:(number, number) => () const area:() => (number) end local Circle = setmetatable({}, { __index = Shape }) Circle.radius = 0 const function Circle:new (x:number, y:number, radius:value) local c = setmetatable(Shape:new(x, y), { __index = self }) c.radius = tonumber(radius) or 0 return c end const function Circle:area () return 3.14 * self.radius * self.radius end local circle1 = Circle:new(0, 5, 10) local circle2:Circle = Circle:new(10, 10, 15) ]=] e = [=[ { `Interface{ Shape, `TTable{ `TLiteral x:`TBase number, `TLiteral y:`TBase number, `TLiteral new:`TFunction{ `TTuple{ `TSelf, `TBase number, `TBase number, `TVararg{ `TValue } }, `TTuple{ `TSelf, `TVararg{ `TNil } } }, `TLiteral move:`TFunction{ `TTuple{ `TSelf, `TBase number, `TBase number, `TVararg{ `TValue } }, `TTuple{ `TVararg{ `TNil } } } } }, `Local{ { `Id "Shape" }, { `Table{ `Pair{ `String "x", `Number "0" }, `Pair{ `String "y", `Number "0" } } } }, `Set{ { `Index{ `Id "Shape", `String "new" } }, { `Function{ { `Id "self":`TSelf, `Id "x":`TBase number, `Id "y":`TBase number }, { `Local{ { `Id "s" }, { `Call{ `Index{ `Id "_ENV", `String "setmetatable" }, `Table, `Table{ `Pair{ `String "__index", `Id "self" } } } } }, `Set{ { `Index{ `Id "s", `String "x" } }, { `Id "x" } }, `Set{ { `Index{ `Id "s", `String "y" } }, { `Id "y" } }, `Return{ `Id "s" } } } } }, `Set{ { `Index{ `Id "Shape", `String "move" } }, { `Function{ { `Id "self":`TSelf, `Id "dx":`TBase number, `Id "dy":`TBase number }, { `Set{ { `Index{ `Id "self", `String "x" } }, { `Op{ "add", `Index{ `Id "self", `String "x" }, `Id "dx" } } }, `Set{ { `Index{ `Id "self", `String "y" } }, { `Op{ "add", `Index{ `Id "self", `String "y" }, `Id "dy" } } } } } } }, `Local{ { `Id "shape1" }, { `Invoke{ `Id "Shape", `String "new", `Number "0", `Number "5" } } }, `Local{ { `Id "shape2":`TVariable Shape }, { `Invoke{ `Id "Shape", `String "new", `Number "10", `Number "10" } } }, `Interface{ Circle, `TTable{ `TLiteral x:`TBase number, `TLiteral y:`TBase number, `TLiteral radius:`TBase number, `TLiteral new:`TFunction{ `TTuple{ `TSelf, `TBase number, `TBase number, `TValue, `TVararg{ `TValue } }, `TTuple{ `TSelf, `TVararg{ `TNil } } }, `TLiteral move:`TFunction{ `TTuple{ `TSelf, `TBase number, `TBase number, `TVararg{ `TValue } }, `TTuple{ `TVararg{ `TNil } } }, `TLiteral area:`TFunction{ `TTuple{ `TSelf, `TVararg{ `TValue } }, `TTuple{ `TBase number, `TVararg{ `TNil } } } } }, `Local{ { `Id "Circle" }, { `Call{ `Index{ `Id "_ENV", `String "setmetatable" }, `Table, `Table{ `Pair{ `String "__index", `Id "Shape" } } } } }, `Set{ { `Index{ `Id "Circle", `String "radius" } }, { `Number "0" } }, `Set{ { `Index{ `Id "Circle", `String "new" } }, { `Function{ { `Id "self":`TSelf, `Id "x":`TBase number, `Id "y":`TBase number, `Id "radius":`TValue }, { `Local{ { `Id "c" }, { `Call{ `Index{ `Id "_ENV", `String "setmetatable" }, `Invoke{ `Id "Shape", `String "new", `Id "x", `Id "y" }, `Table{ `Pair{ `String "__index", `Id "self" } } } } }, `Set{ { `Index{ `Id "c", `String "radius" } }, { `Op{ "or", `Call{ `Index{ `Id "_ENV", `String "tonumber" }, `Id "radius" }, `Number "0" } } }, `Return{ `Id "c" } } } } }, `Set{ { `Index{ `Id "Circle", `String "area" } }, { `Function{ { `Id "self":`TSelf }, { `Return{ `Op{ "mul", `Op{ "mul", `Number "3.14", `Index{ `Id "self", `String "radius" } }, `Index{ `Id "self", `String "radius" } } } } } } }, `Local{ { `Id "circle1" }, { `Invoke{ `Id "Circle", `String "new", `Number "0", `Number "5", `Number "10" } } }, `Local{ { `Id "circle2":`TVariable Circle }, { `Invoke{ `Id "Circle", `String "new", `Number "10", `Number "10", `Number "15" } } } } ]=] r = typecheck(s) check(e, r) -- filter20.tl s = [=[ local x: number | string | nil = 10 local y: number | string = 20 if type(x) == "number" and type(y) ~= "number" then -- dead print(x + 10) print(x + y) local function f() x = 10 end print(x .. "foo") print(y .. "bar") elseif x then print(x + 10) -- ok if type(x) == "string" then -- dead print(x .. "foo") end print(x .. "foo") -- error, x integer else -- dead print(x .. "foo") print(y + 10) end x = x + 10 -- ok ]=] e = [=[ test.lua:4:4: type error, this arm of the 'if' is unreacheable test.lua:14:6: type error, this arm of the 'if' is unreacheable test.lua:17:9: type error, attempt to concatenate a 'number' test.lua:19:3: type error, 'else' block is unreacheable ]=] r = typecheck(s) check(e, r) -- filter12.tl s = [=[ local A = assert -- now works! local function double_number(x: number?) if not x then error("Not giving p1 to double_number is deprecated") end return 2 * x -- x is filtered to number end local x: number? = 10 A(x) x = x + 10 x = nil x = x + 10 -- error, x mil if type(x) == "number" then -- dead print(x + 10) end ]=] e = [=[ test.lua:14:5: type error, attempt to perform arithmetic on a 'nil' test.lua:16:4: type error, this arm of the 'if' is unreacheable ]=] r = typecheck(s) check(e, r) -- filter17.tl s = [=[ local x: number | string | nil = 10 local y: number | string = 20 if x then while type(x) == "number" and type(y) ~= "number" do -- while body unreacheable print(x + 10) print(x + y) print(x .. "foo") print(y .. "bar") x = "foo" x = nil print(x + 10) end print(x .. "foo") -- error, x is integer end x = x + 10 -- ok ]=] e = [=[ test.lua:5:3: type error, 'while' body is unreacheable test.lua:14:9: type error, attempt to concatenate a 'number' ]=] r = typecheck(s) check(e, r) -- filter14.tl s = [=[ local x: number|string|nil = 10 -- x is actually integer local y: number|string = 20 -- y is actually integer if type(x) == "number" and type(y) ~= "number" then -- this arm is dead print(x + 10) print(x + y) print(x .. "foo") print(y .. "bar") elseif x then print(x + 10) -- ok if type(x) == "string" then -- this arm is dead print(x .. "foo") end print(x .. "foo") -- error, x integer else -- else block is dead print(x .. "foo") print(y + 10) end x = x + 10 -- ok ]=] e = [=[ test.lua:4:4: type error, this arm of the 'if' is unreacheable test.lua:11:6: type error, this arm of the 'if' is unreacheable test.lua:14:9: type error, attempt to concatenate a 'number' test.lua:16:3: type error, 'else' block is unreacheable ]=] r = typecheck(s) check(e, r) -- filter22.tl s = [=[ local x: number | string | nil = 10 local y: number | string = 20 local function f() x = 10 end -- the previous function makes x unfilterable if type(x) == "number" and type(y) ~= "number" then -- dead because of y print(x + 10) print(x + y) print(x .. "foo") print(y .. "bar") elseif x then print(x + 10) -- error, x: number|string|nil if type(x) == "string" then print(x .. "foo") -- error, x: number|string|nil end print(x .. "foo") -- error, x: number|string|nil else print(x .. "foo") -- error, x: number|string|nil print(y + 10) -- ok end x = x + 10 -- error, x: number|string|nil ]=] e = [=[ test.lua:10:4: type error, this arm of the 'if' is unreacheable test.lua:16:9: type error, attempt to perform arithmetic on a 'number | string | nil' test.lua:18:11: type error, attempt to concatenate a 'number | string | nil' test.lua:20:9: type error, attempt to concatenate a 'number | string | nil' test.lua:22:9: type error, attempt to concatenate a 'number | string | nil' test.lua:26:5: type error, attempt to perform arithmetic on a 'number | string | nil' ]=] r = typecheck(s) check(e, r) -- filter9.tl s = [=[ local function f(x: number | string | nil, y: number | string) local function f() x = 10 end -- the previous function makes x unfilterable if type(x) == "number" and type(y) ~= "number" then print(x + 10) -- error, x: number|string|nil print(x + y) -- error, x: number|string|nil print(x .. "foo") -- error, x: number|string|nil print(y .. "bar") -- ok elseif x then print(x + 10) -- error, x: number|string|nil if type(x) == "string" then print(x .. "foo") -- error, x: number|string|nil end print(x .. "foo") -- error, x: number|string|nil else print(x .. "foo") -- error, x: number|string|nil print(y + 10) -- error, y: number|string end x = x + 10 -- error, x: number|string|nil end ]=] e = [=[ test.lua:10:9: type error, attempt to perform arithmetic on a 'number | string | nil' test.lua:11:9: type error, attempt to perform arithmetic on a 'number | string | nil' test.lua:12:9: type error, attempt to concatenate a 'number | string | nil' test.lua:15:9: type error, attempt to perform arithmetic on a 'number | string | nil' test.lua:17:11: type error, attempt to concatenate a 'number | string | nil' test.lua:19:9: type error, attempt to concatenate a 'number | string | nil' test.lua:21:9: type error, attempt to concatenate a 'number | string | nil' test.lua:22:9: type error, attempt to perform arithmetic on a 'number | string' test.lua:25:5: type error, attempt to perform arithmetic on a 'number | string | nil' ]=] r = typecheck(s) check(e, r) -- filter18.tl s = [=[ local x: number | string | nil = 10 local y: number | string = 20 while type(x) == "number" do print(x + 10) -- ok if type(y) == "string" then -- dead print(x + y) print(x .. "foo") print(y .. "bar") end end x = x + 10 -- ok ]=] e = [=[ test.lua:6:6: type error, this arm of the 'if' is unreacheable ]=] r = typecheck(s) check(e, r) -- filter3.tl s = [=[ local x:number? -- we know that x is actually nil local y:string? -- ditto for y if type(x) == "number" then -- dead x = x + 1 elseif type(y) == "string" then -- dead y = y .. "hello" else x = x + 1 -- error, x nil y = y + 1 -- error, y nil end x = x + 1 -- error, x nil y = y .. "hello" -- ditto ]=] e = [=[ test.lua:4:4: type error, this arm of the 'if' is unreacheable test.lua:6:8: type error, this arm of the 'if' is unreacheable test.lua:9:7: type error, attempt to perform arithmetic on a 'nil' test.lua:10:7: type error, attempt to perform arithmetic on a 'nil' test.lua:13:5: type error, attempt to perform arithmetic on a 'nil' test.lua:14:5: type error, attempt to concatenate a 'nil' ]=] r = typecheck(s) check(e, r) -- filter21.tl s = [=[ local x: number | string | nil = 10 local y: number | string = 20 if type(x) == "number" and type(y) ~= "number" then -- dead print(x + 10) print(x + y) local function f() print(x + 10) end print(x .. "foo") print(y .. "bar") elseif x then print(x + 10) -- ok if type(x) == "string" then -- dead print(x .. "foo") end print(x .. "foo") -- error, x integer else -- dead print(x .. "foo") -- error, x: nil print(y + 10) -- error, y: number|string end x = x + 10 -- ok ]=] e = [=[ test.lua:4:4: type error, this arm of the 'if' is unreacheable test.lua:14:6: type error, this arm of the 'if' is unreacheable test.lua:17:9: type error, attempt to concatenate a 'number' test.lua:19:3: type error, 'else' block is unreacheable ]=] r = typecheck(s) check(e, r) -- filter24.tl s = [=[ local x: number|string|nil = 10 if math.random() > 10 then print(x+10) -- ok elseif math.random() > 10 then error("is a number") elseif type(x) == "number" then error("is a number") end x = x + 10 -- ok if not x then -- dead print(x+10) -- error, x is nil elseif type(x) == "number" then error("is a number") end -- dead code x = x .. "foo" ]=] e = [=[ test.lua:13:8: type error, this arm of the 'if' is unreacheable test.lua:20:1: type error, unreacheable statement ]=] r = typecheck(s) check(e, r) -- filter8.tl s = [=[ local function f(x: number | string | nil, y: number | string) if type(x) == "number" and type(y) ~= "number" then print(x + 10) -- ok print(x + y) -- error, y: string local function f() print(x + 10) -- error, x n|s|nil end print(x .. "foo") -- error, x: number print(y .. "bar") -- ok elseif x then print(x + 10) -- error, x: number|string if type(x) == "string" then print(x .. "foo") -- ok end print(x .. "foo") -- error, x: number|string else print(x .. "foo") -- error, x: nil print(y + 10) -- error, y: number|string end x = x + 10 -- error, x: number|string|nil end ]=] e = [=[ test.lua:5:13: type error, attempt to perform arithmetic on a 'string' test.lua:7:11: type error, attempt to perform arithmetic on a 'number | string | nil' test.lua:9:9: type error, attempt to concatenate a 'number' test.lua:12:9: type error, attempt to perform arithmetic on a 'number | string' test.lua:16:9: type error, attempt to concatenate a 'number | string' test.lua:18:9: type error, attempt to concatenate a 'nil' test.lua:19:9: type error, attempt to perform arithmetic on a 'number | string' test.lua:22:5: type error, attempt to perform arithmetic on a 'number | string | nil' ]=] r = typecheck(s) check(e, r) -- filter1.tl s = [=[ local function foo(x: number|string|nil, y: number|string) if type(x) == "number" and type(y) ~= "number" then print(x + 10) -- ok print(x + y) -- error, y: string print(x .. "foo") -- error, x: number print(y .. "bar") -- ok elseif x then print(x + 10) -- error, x: number|string if type(x) == "string" then print(x .. "foo") -- ok end print(x .. "foo") -- error, x: number|string else print(x .. "foo") -- error, x: nil print(y + 10) -- error, y: number|string end x = x + 10 -- error, x: number|string|nil end ]=] e = [=[ test.lua:5:13: type error, attempt to perform arithmetic on a 'string' test.lua:6:9: type error, attempt to concatenate a 'number' test.lua:9:9: type error, attempt to perform arithmetic on a 'number | string' test.lua:13:9: type error, attempt to concatenate a 'number | string' test.lua:15:9: type error, attempt to concatenate a 'nil' test.lua:16:9: type error, attempt to perform arithmetic on a 'number | string' test.lua:19:5: type error, attempt to perform arithmetic on a 'number | string | nil' ]=] r = typecheck(s) check(e, r) -- filter6.tl s = [=[ local function f(x: number | string | nil, y: number | string) local f = function () end while type(x) == "number" do f() print(x + 10) -- ok f = function () x = "foo" -- error, cannot revert across loop end if type(y) == "string" then print(x + y) -- error, x n|s|nil print(x .. "foo") -- error, x n|s|nil print(y .. "bar") -- ok end end x = x + 10 -- error, x: number|string|nil end ]=] e = [=[ test.lua:9:5: type error, attempt to assign to filtered upvalue 'x' across a loop test.lua:12:11: type error, attempt to perform arithmetic on a 'number | string | nil' test.lua:13:11: type error, attempt to concatenate a 'number | string | nil' test.lua:18:5: type error, attempt to perform arithmetic on a 'number | string | nil' ]=] r = typecheck(s) check(e, r) -- filter5.tl s = [=[ local function f(x: number | string | nil, y: number | string) while type(x) == "number" do print(x + 10) -- ok if type(y) == "string" then print(x + y) -- error, y: string print(x .. "foo") -- error, x: number print(y .. "bar") -- ok end end x = x + 10 -- error, x: number|string|nil end ]=] e = [=[ test.lua:6:15: type error, attempt to perform arithmetic on a 'string' test.lua:7:11: type error, attempt to concatenate a 'number' test.lua:12:5: type error, attempt to perform arithmetic on a 'number | string | nil' ]=] r = typecheck(s) check(e, r) -- filter4.tl s = [=[ local function f(x: number | string | nil, y: number | string) if x then while type(x) == "number" and type(y) ~= "number" do print(x + 10) -- ok print(x + y) -- error, y: string print(x .. "foo") -- error, x: number print(y .. "bar") -- ok local function g() print(x+10) end -- error, x string|number|nil x = "foo" -- x now is string print(x + 10) -- error, x string x = nil -- error, x was string|number when entered loop print(x + 10) -- error end end x = x + 10 -- error, x: number|string|nil end ]=] e = [=[ test.lua:6:15: type error, attempt to perform arithmetic on a 'string' test.lua:7:11: type error, attempt to concatenate a 'number' test.lua:9:30: type error, attempt to perform arithmetic on a 'number | string | nil' test.lua:11:11: type error, attempt to perform arithmetic on a 'string' test.lua:12:5: type error,variable 'x' is looping back with type 'nil' incompatible with type 'number | string' that it entered loop test.lua:13:11: type error, attempt to perform arithmetic on a 'nil' test.lua:16:5: type error, attempt to perform arithmetic on a 'number | string | nil' ]=] r = typecheck(s) check(e, r) -- filter7.tl s = [=[ local function f(x: number | string | nil, y: number | string) if type(x) == "number" and type(y) ~= "number" then print(x + 10) -- ok print(x + y) -- error, y: string local function f() x = 10 -- ok, x is now n|s|nil end print(x .. "foo") -- error, x is n|s|nil print(y .. "bar") -- ok elseif x then -- x cannot downcast anymore because of f print(x + 10) -- error, x: number|string|nil if type(x) == "string" then print(x .. "foo") -- error, x: number|string|nil end print(x .. "foo") -- error, x: number|string|nil else print(x .. "foo") -- error, x: number|string|nil print(y + 10) -- error, y: number|string end x = x + 10 -- error, x: number|string|nil end ]=] e = [=[ test.lua:5:13: type error, attempt to perform arithmetic on a 'string' test.lua:9:9: type error, attempt to concatenate a 'number | string | nil' test.lua:12:9: type error, attempt to perform arithmetic on a 'number | string | nil' test.lua:14:11: type error, attempt to concatenate a 'number | string | nil' test.lua:16:9: type error, attempt to concatenate a 'number | string | nil' test.lua:18:9: type error, attempt to concatenate a 'number | string | nil' test.lua:19:9: type error, attempt to perform arithmetic on a 'number | string' test.lua:22:5: type error, attempt to perform arithmetic on a 'number | string | nil' ]=] r = typecheck(s) check(e, r) -- filter16.tl s = [=[ local function f(x:number?, y:string?) if type(x) == "number" then x = x + 1 elseif type(y) == "string" then y = y .. "hello" else x = x + 1 -- error, x nil y = y + 1 -- error, y nil end x = x + 1 -- error, x number? y = y .. "hello" -- error, y string? end ]=] e = [=[ test.lua:8:7: type error, attempt to perform arithmetic on a 'nil' test.lua:9:7: type error, attempt to perform arithmetic on a 'nil' test.lua:12:5: type error, attempt to perform arithmetic on a 'number?' test.lua:13:5: type error, attempt to concatenate a 'string?' ]=] r = typecheck(s) check(e, r) -- filter13.tl s = [=[ local function f(x: number|string|nil) if math.random() > 0.5 then print(x+10) -- error, x number|string|nil elseif math.random() > 0.5 then error("random") elseif type(x) == "number" then error("is a number") end x = x + 10 -- error, x n|s|nil (math.random > 0.5) if not x then print(x+10) -- error, x is nil elseif type(x) == "number" then error("is a number") end -- x cannot be number here x = x + 10 -- error, x string? end ]=] e = [=[ test.lua:4:9: type error, attempt to perform arithmetic on a 'number | string | nil' test.lua:11:5: type error, attempt to perform arithmetic on a 'number | string | nil' test.lua:14:9: type error, attempt to perform arithmetic on a 'nil' test.lua:21:5: type error, attempt to perform arithmetic on a 'string?' ]=] r = typecheck(s) check(e, r) -- filter2.tl s = [=[ local function foo(x: number|string|nil, y: number|string) while type(x) == "number" and type(y) ~= "number" do print(x + 10) -- ok print(x + y) -- error, y is string print(x .. "foo") -- error, x is number print(y .. "bar") -- ok x = "foo" -- ok, x is now string print(x + 10) -- error, x is string end x = x + 10 -- error, x is number|string|nil end ]=] e = [=[ test.lua:5:13: type error, attempt to perform arithmetic on a 'string' test.lua:6:9: type error, attempt to concatenate a 'number' test.lua:9:9: type error, attempt to perform arithmetic on a 'string' test.lua:12:5: type error, attempt to perform arithmetic on a 'number | string | nil' ]=] r = typecheck(s) check(e, r) -- filter23.tl s = [=[ local x: number | string | nil = 10 local y: number | string = 20 while type(x) == "number" and type(y) ~= "number" do -- dead print(x + 10) -- ok print(x + y) -- error, y: string print(x .. "foo") -- error, x: number print(y .. "bar") -- ok end x = x + 10 -- ok ]=] e = [=[ test.lua:4:1: type error, 'while' body is unreacheable ]=] r = typecheck(s) check(e, r) -- filter15.tl s = [=[ local x: number | string | nil = 10 -- x is actually integer local y: number | string = 20 -- y is actually integer while type(x) == "number" and type(y) ~= "number" do -- while block unreacheable print(x + 10) print(x + y) print(x .. "foo") print(y .. "bar") x = "foo" print(x + 10) end x = x + 10 -- ok ]=] e = [=[ test.lua:4:1: type error, 'while' body is unreacheable ]=] r = typecheck(s) check(e, r) -- filter11.tl s = [=[ local function idiv (d1:number, d2:number):(number, number) | (nil, string) if d2 == 0 then return nil, "division by zero" else local r = d1 % d2 local q = (d1 - r) / d2 return q, r end end local n1, n2 = 4, 4 local q, r = idiv(n1, n2) local x:number, msg:string = 0, "" if q then x = q + r print(r .. "foo") -- error, r number else msg = r print(r + 10) -- error, r string end ]=] e = [=[ test.lua:16:9: type error, attempt to concatenate a 'number' test.lua:19:9: type error, attempt to perform arithmetic on a 'string' ]=] r = typecheck(s) check(e, r) -- filter10.tl s = [=[ local function f(x: number | string | nil, y: number | string) while type(x) == "number" and type(y) ~= "number" do print(x + 10) -- ok print(x + y) -- error, y: string print(x .. "foo") -- error, x: number print(y .. "bar") -- ok end x = x + 10 -- error, x: number|string|nil end ]=] e = [=[ test.lua:5:13: type error, attempt to perform arithmetic on a 'string' test.lua:6:9: type error, attempt to concatenate a 'number' test.lua:10:5: type error, attempt to perform arithmetic on a 'number | string | nil' ]=] r = typecheck(s) check(e, r) -- filter19.tl s = [=[ local x: number | string | nil = 10 local y: number | string = 20 while type(x) == "number" do local function f() x = 10 -- error, assigning to filtered upvalue across loop end print(x + 10) -- error, x n|s|nil if type(y) == "string" then -- dead print(x + y) print(x .. "foo") print(y .. "bar") end end x = x + 10 -- error, x n|s|nil because of f ]=] e = [=[ test.lua:4:7: type error,variable 'x' is looping back with type 'number | string | nil' incompatible with type 'number'that it entered loop test.lua:6:5: type error, attempt to assign to filtered upvalue 'x' across a loop test.lua:8:9: type error, attempt to perform arithmetic on a 'number | string | nil' test.lua:9:6: type error, this arm of the 'if' is unreacheable test.lua:16:5: type error, attempt to perform arithmetic on a 'number | string | nil' ]=] r = typecheck(s) check(e, r) -- filter25.tl s = [=[ local function f(t: { "foo": string }?) local x: string = t and t.foo or "bar" print(x + 10) local t = t or error("nil!") print(t.foo + 10) end ]=] e = [=[ test.lua:3:9: type error, attempt to perform arithmetic on a 'string' test.lua:5:9: type error, attempt to perform arithmetic on a 'string' ]=] r = typecheck(s) check(e, r) -- filter26.tl s = [=[ local function f(x: boolean?) if x then print(x + 10) else print(x .. "foo") end end ]=] e = [=[ test.lua:3:11:type error,attempt to perform arithmetic on a 'boolean' test.lua:5:11:type error,attempt to concatenate a 'boolean?' ]=] r = typecheck(s) check(e, r) -- issue96.tl s = [=[ local function double_number(x: number?) if not x then error("Not giving p1 to double_number is deprecated") end print(x .. "foo") -- error, x number return 2 * x -- x is filtered to number end ]=] e = [=[ test.lua:5:9: type error, attempt to concatenate a 'number' ]=] r = typecheck(s) check(e, r) -- issue58.tl s = [=[ typealias Cmd = string|{string} function f(cmd:Cmd) -- if I change to cmd:string|{string}, it works local c: {string} = {} if type(cmd) == "string" then table.insert(c, cmd) print(cmd + 10) -- error, cmd is string else c = cmd print(cmd + 10) -- error, cmd is array end end ]=] e = [=[ test.lua:7:13: type error, attempt to perform arithmetic on a 'string' test.lua:10:13: type error, attempt to perform arithmetic on a '{number: string?}' ]=] r = typecheck(s) check(e, r) -- issue55.tl s = [=[ interface ELEM x: number end interface OBJ parent: OBJ? atr: ELEM -- if you comment this line or change ELEM to a base type like string, it works end local function f(o:OBJ) local parent = o.parent if parent then print(parent + 10) -- just to supress generation of .lua f(parent) end end ]=] e = [=[ test.lua:13:13: type error, attempt to perform arithmetic on a '{"parent": OBJ?, "atr": {"x": number}}' ]=] r = typecheck(s) check(e, r) -- issue68.tl s = [=[ -- The following two mutually recursive types are the same structurally interface Tree1 label: number left: Tree2? right: Tree2? end interface Tree2 label: number left: Tree1? right: Tree1? end -- the following type has a forward reference interface OBJ parent: OBJ? atr: ELEM end interface ELEM x: number end local function f(o:OBJ) local t1: Tree1 = { label = 2 } local t2: Tree2 = { label = 3 } t1 = t2 t2 = t1 local parent = o.parent if parent then f({atr={x=2}}) -- isn't this structurally equivalent to OBJ? print(parent + 10) -- just to supress generation of .lua file end end ]=] e = [=[ test.lua:33:13: type error, attempt to perform arithmetic on a '{"parent": OBJ?, "atr": ELEM}' ]=] r = typecheck(s) check(e, r) -- issue16.tl s = [=[ interface SubA subaname: string end local A = {} A.aname = '<class A proto>' A.child = {subaname='the subaname'} function A:new(): self local t = {} t.aname = '<class A>' t.child = {subaname='the subaname'} local s = setmetatable(t, {__index = self}) return s end function A:afoo(): self local s: string = self.aname print('Hello ' .. s) return self end function A:arun(name: string) print('arun', name) end function A:awrong(x: self) -- error, self cannot appear here! end function A:abar(obj: SubA) self:arun(obj.subaname) -- Does not compile cleanly. -- This works: local s = obj.subaname self:arun(s) -- This also works: self.arun(self, obj.subaname) end return A ]=] e = [=[ test.lua:28:18: type error, self type appearing in a place that is not a first parameter or a return type inside type '(self, self, value*) -> ()' ]=] r = typecheck(s) check(e, r) -- issue98.tl s = [=[ local function f(i: number?) -- to force i to be number? print(1 + (i or 0)) -- ok print(i .. "foo") -- error, i number? end ]=] e = [=[ test.lua:3:9: type error, attempt to concatenate a 'number?' ]=] r = typecheck(s) check(e, r) -- issue99.tl s = [=[ local f, err = io.open("wednesday") do f = f or io.stdin -- breaks f out of the projection print(f + 10) -- f is a file print(err + 10) -- err is string? if type(err) == "string" then print(f + 10) -- f is still file end end print(f + 10) -- f is file print(err + 10) -- err is string? if f then print(err + 10) -- err is still string? end ]=] e = [=[ test.lua:4:9: type error, attempt to perform arithmetic on a 'file' test.lua:5:9: type error, attempt to perform arithmetic on a 'string?' test.lua:7:11: type error, attempt to perform arithmetic on a 'file' test.lua:10:7: type error, attempt to perform arithmetic on a 'file' test.lua:11:7: type error, attempt to perform arithmetic on a 'string?' test.lua:13:9: type error, attempt to perform arithmetic on a 'string?' ]=] r = typecheck(s) check(e, r) -- issue76.tl s = [=[ local Shape = { x = 0.0, y = 0.0 } const function Shape:new (x:number, y:number):self local s = setmetatable({}, { __index = self }) s.x = x s.y = y return s end const function Shape:move (dx:number, dy:number):() self.x = self.x + dx self.y = self.y + dy end local s = Shape:new(3,2) s:move(20,25) print(s + 10) -- to supress generation of .lua ]=] e = [=[ test.lua:17:7: type error, attempt to perform arithmetic on a '{"x": number, "y": number, const "new": (self, number, number, value*) -> (self), const "move": (self, number, number, value*) -> ()}' ]=] r = typecheck(s) check(e, r) -- issue45.tl s = [=[ -- bug45driver.tl local bug45 = require("examples.issues.bug45") local r = bug45.makeR() local s, err = bug45.makeS() if r then if s then s = r:makeT(s) -- crashes setting s, or a new global. Doesn't crash if using `local` end end print(nil + 5) -- just to supress generation of .lua ]=] e = [=[ test.lua:12:7: type error, attempt to perform arithmetic on a 'nil' ]=] r = typecheck(s) check(e, r) -- issue69.tl s = [=[ local person:Person = { firstname = "Lou", lastname = "Reed" } ]=] e = [=[ test.lua:1:7: type error, type alias 'Person' is not defined test.lua:1:7: type error, attempt to assign '{"firstname": string, "lastname": string}' to 'nil' ]=] r = typecheck(s) check(e, r) -- issue84.tl s = [=[ local input = io.open("test") if input then local stuff = input:read("a") input:close() print(input + 10) -- error, input is file end ]=] e = [=[ test.lua:6:9: type error, attempt to perform arithmetic on a 'file' ]=] r = typecheck(s) check(e, r) -- issue88.tl s = [=[ local diag_test: {number: string|number|nil} = {"HI", 1, {"another table"}} ]=] e = [=[ test.lua:1:7: type error, attempt to assign '{1: string, 2: number, 3: {1: string}}' to '{number: number | string | nil}' ]=] r = typecheck(s) check(e, r) -- issue87.tl s = [=[ local my_lambda: () -> () = function () end my_lambda() print(my_lambda + 10) -- just to force an error ]=] e = [=[ test.lua:4:7: type error, attempt to perform arithmetic on a '(value*) -> ()' ]=] r = typecheck(s) check(e, r) -- pr82.tl s = [=[ local function factorial(n: number): number if n == 0 then return 1 else return n * factorial(n - 1) end end local x = 5 print(factorial(x)) print(factorial(x, nil)) print(factorial(x, 5)) print(factorial + 10) -- just to force an error ]=] e = [=[ test.lua:15:7: type error, attempt to perform arithmetic on a '(number, value*) -> (number)' ]=] r = typecheck(s) check(e, r) -- issue50.tl s = [=[ interface IStackOverflow const my_method: (IStackOverflow) -> () end function new(): IStackOverflow local obj: IStackOverflow = {} obj.my_method = my_method return obj end ]=] e = [=[ test.lua:5:13: type error, return type '({})' does not match '(IStackOverflow)' test.lua:6:10: type error, attempt to assign '{}' to '{const "my_method": (IStackOverflow, value*) -> ()}' test.lua:7:4: type error, attempt to use '"my_method"' to index closed table test.lua:7:20: type error, attempt to access undeclared global 'my_method' ]=] r = typecheck(s) check(e, r) -- issue52.tl s = [=[ function x() : (number, boolean)|(string, number) if 0 > 1 then return 1, true else return "wat", 9 end end local baz, foo, bar = 10, x() if foo then local bla = foo .. " world" -- error, foo is i|s end baz = baz + 10 ]=] e = [=[ test.lua:11:16: type error, attempt to concatenate a 'number | string' ]=] r = typecheck(s) check(e, r) -- pr56.tl s = [=[ interface ELEM x: number end interface OBJ parent: OBJ? atr: ELEM -- if I change ELEM to {"x":number}, I no longer get an error end local function f(o:OBJ) local parent = o.parent if parent then f({atr={x=2}}) -- isn't this structurally equivalent to OBJ? print(parent + 10) -- just to force an error end end ]=] e = [=[ test.lua:14:13: type error, attempt to perform arithmetic on a '{"parent": OBJ?, "atr": {"x": number}}' ]=] r = typecheck(s) check(e, r) -- issue47.tl s = [=[ local bug47 = require("examples.issues.bug47") local function main() local maybe_u, rerr = bug47.foo() print(maybe_u + 10) -- maybe_u is U? if type(maybe_u) == "nil" then print(maybe_u + 10) -- maybe_u is nil print(rerr .. "foo") if type(rerr) == "string" then error("error - "..rerr, nil) end return -- unreacheable end -- maybe_u is a U here local u = maybe_u print(u + 10) end main() ]=] e = [=[ test.lua:4:10: type error, attempt to perform arithmetic on a 'U?' test.lua:6:13: type error, attempt to perform arithmetic on a 'nil' test.lua:11:7: type error, unreacheable statement test.lua:15:10: type error, attempt to perform arithmetic on a 'U' ]=] r = typecheck(s) check(e, r) -- issue108.tl s = [=[ local function w (filename:string, data:string):boolean local scratch = filename .. "~" local fh, open_err = io.open(scratch, "w") if not fh then return false end local write_ok, write_err = fh:write(data) if not write_ok then return false end local close_ok, close_err = fh:close() if not close_ok then return false end return true end ]=] e = [=[ { `Localrec{{ `Id "w":`TFunction{ `TTuple{ `TBase string, `TBase string, `TVararg{ `TValue } }, `TTuple{ `TBase boolean, `TVararg{ `TNil } } } },{ `Function{{ `Id "filename":`TBase string, `Id "data":`TBase string }:`TTuple{ `TBase boolean, `TVararg{ `TNil } },{ `Local{{ `Id "scratch" },{ `Op{"concat", `Id "filename", `String "~" } } }, `Local{{ `Id "fh", `Id "open_err" },{ `Call{ `Index{ `Index{ `Id "_ENV", `String "io" }, `String "open" }, `Id "scratch", `String "w" } } }, `If{ `Op{"not", `Id "fh" },{ `Return{ `False } } }, `Local{{ `Id "write_ok", `Id "write_err" },{ `Invoke{ `Id "fh", `String "write", `Id "data" } } }, `If{ `Op{"not", `Id "write_ok" },{ `Return{ `False } } }, `Local{{ `Id "close_ok", `Id "close_err" },{ `Invoke{ `Id "fh", `String "close" } } }, `If{ `Op{"not", `Id "close_ok" },{ `Return{ `False } } }, `Return{ `True } } } } } } ]=] r = typecheck(s) check(e, r) -- issue71 s = [=[ require "examples.issues.bug71.a" ]=] e = [=[ ./examples/issues/bug71/b.tl:1:1: type error, circular require ]=] r = typecheck(s) check(e, r) s = [=[ require "examples.issues.bug71.testfile1" ]=] e = [=[ ./examples/issues/bug71/testfile3.tl:1:1: type error, circular require ]=] r = typecheck(s) check(e, r) s = [=[ require "examples.issues.bug71.ok1" ]=] e = [=[ { `Call{ `Index{ `Id "_ENV", `String "require" }, `String "examples.issues.bug71.ok1" } } ]=] r = typecheck(s) check(e, r) -- issue66 s = [=[ require "examples.issues.issue66.point" require "examples.issues.issue66.colorpoint" local a:Point local b:ColorPoint ]=] e = [=[ { `Call{ `Index{ `Id "_ENV", `String "require" }, `String "examples.issues.issue66.point" }, `Call{ `Index{ `Id "_ENV", `String "require" }, `String "examples.issues.issue66.colorpoint" }, `Local{{ `Id "a":`TVariable Point },{ } }, `Local{{ `Id "b":`TVariable ColorPoint },{ } } } ]=] r = typecheck(s) check(e, r) s = [=[ require "examples.issues.issue66.3dpoint" local p:Ponto3D ]=] e = [=[ test.lua:3:7: type error, type alias 'Ponto3D' is not defined ]=] r = typecheck(s) check(e, r) print("> testing code generation...") -- assignments s = [=[ zero,um = false,true ]=] e = [=[ zero, um = false, true ]=] r = generate(s) check(e, r) s = [=[ n,s = 1, "alo" ]=] e = [=[ n, s = 1, "alo" ]=] r = generate(s) check(e, r) s = [=[ t = ...,nil ]=] e = [=[ t = ..., nil ]=] r = generate(s) check(e, r) s = [=[ a = 2 * 3 + 5 ]=] e = [=[ a = 2 * 3 + 5 ]=] r = generate(s) check(e, r) s = [=[ a = (2 * 3) + 5 ]=] e = [=[ a = (2 * 3) + 5 ]=] r = generate(s) check(e, r) s = [=[ a = 1 - 2 / 3 % 4 ^ 5 ]=] e = [=[ a = 1 - 2 / 3 % 4 ^ 5 ]=] r = generate(s) check(e, r) s = [=[ c = "alo" .. "mundo" ]=] e = [=[ c = "alo" .. "mundo" ]=] r = generate(s) check(e, r) s = [=[ a = 1 == 2 b = 1 ~= 2 c = 1 < 2 d = 1 <= 2 e = 1 > 2 f = 1 >= 2 ]=] e = [=[ a = 1 == 2 b = not (1 == 2) c = 1 < 2 d = 1 <= 2 e = 2 < 1 f = 2 <= 1 ]=] r = generate(s) check(e, r) s = [=[ a = not 1 and 2 or 3 ]=] e = [=[ a = not (1) and 2 or 3 ]=] r = generate(s) check(e, r) s = [=[ t = { 1, 2, 3 } ]=] e = [=[ t = {1, 2, 3} ]=] r = generate(s) check(e, r) -- do s = [=[ do do do do do end end end end end ]=] e = [=[ do do do do do end end end end end ]=] r = generate(s) check(e, r) -- for s = [=[ for i=1, 10 do break end ]=] e = [=[ for i = 1, 10 do break end ]=] r = generate(s) check(e, r) s = [=[ for i=1,10,-1 do break end ]=] e = [=[ for i = 1, 10, -(1) do break end ]=] r = generate(s) check(e, r) s = [=[ for k,v in pairs({}) do end ]=] e = [=[ for k, v in pairs({}) do end ]=] r = generate(s) check(e, r) -- function s = [=[ function f ():() end ]=] e = [=[ f = function () end ]=] r = generate(s) check(e, r) s = [=[ function f () end ]=] e = [=[ f = function () end ]=] r = generate(s) check(e, r) s = [=[ function f (a) return a end ]=] e = [=[ f = function (a) return a end ]=] r = generate(s) check(e, r) s = [=[ function f (a, b, c) end ]=] e = [=[ f = function (a, b, c) end ]=] r = generate(s) check(e, r) s = [=[ function f (a, b, c, ...) end ]=] e = [=[ f = function (a, b, c, ...) end ]=] r = generate(s) check(e, r) s = [=[ function f (...) end ]=] e = [=[ f = function (...) end ]=] r = generate(s) check(e, r) s = [=[ local function f () end ]=] e = [=[ local function f () end ]=] r = generate(s) check(e, r) s = [=[ local function f (a) return a end ]=] e = [=[ local function f (a) return a end ]=] r = generate(s) check(e, r) s = [=[ local function f (a, b, c) end ]=] e = [=[ local function f (a, b, c) end ]=] r = generate(s) check(e, r) s = [=[ local function f (a, b, c, ...) end ]=] e = [=[ local function f (a, b, c, ...) end ]=] r = generate(s) check(e, r) s = [=[ local function f (...) end ]=] e = [=[ local function f (...) end ]=] r = generate(s) check(e, r) -- goto s = [=[ do goto eof end :: eof :: ]=] e = [=[ do goto eof end ::eof:: ]=] r = generate(s) check(e, r) -- if s = [=[ if 1 then return 1 end ]=] e = [=[ if 1 then return 1 end ]=] r = generate(s) check(e, r) s = [=[ if 1 then return 1 else return 2 end ]=] e = [=[ if 1 then return 1 else return 2 end ]=] r = generate(s) check(e, r) s = [=[ if 1 then return 1 elseif 2 then return 2 elseif 3 then return 3 elseif 4 then return 4 end ]=] e = [=[ if 1 then return 1 elseif 2 then return 2 elseif 3 then return 3 elseif 4 then return 4 end ]=] r = generate(s) check(e, r) s = [=[ if 1 then return 1 elseif 2 then return 2 elseif 3 then return 3 elseif 4 then return 4 else return 5 end ]=] e = [=[ if 1 then return 1 elseif 2 then return 2 elseif 3 then return 3 elseif 4 then return 4 else return 5 end ]=] r = generate(s) check(e, r) s = [=[ if 1 then if "hello" then return "hello" end return 1 elseif 2 then return 2 elseif 3 then if "foo" then return "foo" end return 3 elseif 4 then return 4 else if "bar" then return "bar" end return 5 end ]=] e = [=[ if 1 then if "hello" then return "hello" end return 1 elseif 2 then return 2 elseif 3 then if "foo" then return "foo" end return 3 elseif 4 then return 4 else if "bar" then return "bar" end return 5 end ]=] r = generate(s) check(e, r) s = [=[ local function f(x:number?) if not x then print("error") else x = x + 1 end if type(x) == "nil" then print("error") else x = x + 1 end end ]=] e = [=[ local function f (x) if not (x) then print("error") else x = x + 1 end if type(x) == "nil" then print("error") else x = x + 1 end end ]=] r = generate(s) check(e, r) -- local s = [=[ local a:any? ]=] e = [=[ local a ]=] r = generate(s) check(e, r) s = [=[ local a:any?, b:any?, c:any? ]=] e = [=[ local a, b, c ]=] r = generate(s) check(e, r) s = [=[ local a = 1 ]=] e = [=[ local a = 1 ]=] r = generate(s) check(e, r) s = [=[ local a, b:any? = 1 ]=] e = [=[ local a, b = 1 ]=] r = generate(s) check(e, r) -- repeat s = [=[ repeat break until true ]=] e = [=[ repeat break until true ]=] r = generate(s) check(e, r) -- while s = [=[ while 1 do break end ]=] e = [=[ while 1 do break end ]=] r = generate(s) check(e, r) -- complete examples s = [=[ local interface Element info:number next:Element? end local function insert_s (e:Element?, v:number):Element return { info = v, next = e } end local function insert_f (e:Element?, v:number):Element if e then e.next = insert_f(e.next, v) return e end return { info = v, next = e } end local function print_l (e:Element?) if e then print(e.info) print_l(e.next) end end local e:Element? e = insert_s(e, 2) e = insert_s(e, 1) e = insert_s(e, 3) e = insert_s(e, 4) e = insert_s(e, 0) print_l(e) e = nil e = insert_f(e, 2) e = insert_f(e, 1) e = insert_f(e, 3) e = insert_f(e, 4) e = insert_f(e, 0) print_l(e) ]=] e = [=[ local function insert_s (e, v) return {info = v, next = e} end local function insert_f (e, v) if e then e.next = insert_f(e.next,v) return e end return {info = v, next = e} end local function print_l (e) if e then print(e.info) print_l(e.next) end end local e e = insert_s(e,2) e = insert_s(e,1) e = insert_s(e,3) e = insert_s(e,4) e = insert_s(e,0) print_l(e) e = nil e = insert_f(e,2) e = insert_f(e,1) e = insert_f(e,3) e = insert_f(e,4) e = insert_f(e,0) print_l(e) ]=] r = generate(s) check(e, r) s = [=[ local interface NoArv info:string left, right: NoArv? end local function create (v:string, l:NoArv?, r:NoArv?):NoArv return { info = v, left = l, right = r } end local function print_tree (t:NoArv?) if t then print(t.info) print_tree(t.left) print_tree(t.right) end end local a1 = create("d") local a2 = create("b", nil, a1) local a3 = create("e") local a4 = create("f") local a5 = create("c", a3, a4) local a = create("a", a2, a5) print_tree(a) ]=] e = [=[ local function create (v, l, r) return {info = v, left = l, right = r} end local function print_tree (t) if t then print(t.info) print_tree(t.left) print_tree(t.right) end end local a1 = create("d") local a2 = create("b",nil,a1) local a3 = create("e") local a4 = create("f") local a5 = create("c",a3,a4) local a = create("a",a2,a5) print_tree(a) ]=] r = generate(s) check(e, r) s = [=[ interface Shape x, y:number const new:(number, number) => (self) const move:(number, number) => () end local Shape = { x = 0, y = 0 } const function Shape:new (x:number, y:number) local s = setmetatable({}, { __index = self }) s.x = x s.y = y return s end const function Shape:move (dx:number, dy:number) self.x = self.x + dx self.y = self.y + dy end local shape1 = Shape:new(0, 5) local shape2:Shape = Shape:new(10, 10) interface Circle x, y, radius:number const new:(number, number, value) => (self) const move:(number, number) => () const area:() => (number) end local Circle = setmetatable({}, { __index = Shape }) Circle.radius = 0 const function Circle:new (x:number, y:number, radius:value) local c = setmetatable(Shape:new(x, y), { __index = self }) c.radius = tonumber(radius) or 0 return c end const function Circle:area () return 3.14 * self.radius * self.radius end local circle1 = Circle:new(0, 5, 10) local circle2:Circle = Circle:new(10, 10, 15) circle1:area() circle2:area() ]=] e = [=[ local Shape = {x = 0, y = 0} Shape.new = function (self, x, y) local s = setmetatable({},{__index = self}) s.x = x s.y = y return s end Shape.move = function (self, dx, dy) self.x = self.x + dx self.y = self.y + dy end local shape1 = Shape:new(0,5) local shape2 = Shape:new(10,10) local Circle = setmetatable({},{__index = Shape}) Circle.radius = 0 Circle.new = function (self, x, y, radius) local c = setmetatable(Shape:new(x,y),{__index = self}) c.radius = tonumber(radius) or 0 return c end Circle.area = function (self) return 3.14 * self.radius * self.radius end local circle1 = Circle:new(0,5,10) local circle2 = Circle:new(10,10,15) circle1:area() circle2:area() ]=] r = generate(s) check(e, r) print("> testing module loader...") s = [=[1]=] e = [=[ test.tl:1:1: syntax error, unexpected '1', expecting 'return', '(', 'Name', 'typealias', 'interface', 'goto', 'break', '::', 'local', 'function', 'const', 'repeat', 'for', 'do', 'while', 'if', ';' ]=] r = test_loader(s) check(r == e) s = [=[return 1]=] e = 1 r = test_loader(s) check(r == e) s = [=[ local function a(b: string, c: string) : string return end return a("b", 2) ]=] e = [=[ test.tl:1:17: type error, return type '()' does not match '(string)' test.tl:1:18: warning, unused local 'b' test.tl:1:29: warning, unused local 'c' test.tl:5:8: type error, attempt to pass '(b, 2)' to local 'a' of input type '(string, string)' ]=] r = test_loader(s) check(r == e) s = [=[ local function a(b: string, c: string) : (string, nil*) return b .. "-" .. c end return a("b", "c") ]=] e = [=[b-c]=] r = test_loader(s) check(r == e) if failed_tests == 0 then print("OK: " .. passed_tests .. " PASSED TESTS") os.exit(0) else print(failed_tests .. " FAILED TESTS, " .. passed_tests .. " PASSED TESTS") os.exit(1) end
nilq/small-lua-stack
null
#!/usr/bin/env tarantool local t = require('luatest') local g = t.group('websocket.handshake') local handshake = require('websocket.handshake') g.test_checksum = function() local sec_websocket_key = "dGhlIHNhbXBsZSBub25jZQ==" local accept = handshake.sec_websocket_accept(sec_websocket_key) t.assert_equals(accept, "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=") end g.test_accept = function() local request = {} request.headers = { ['host'] = 'server.example.com', ['upgrade'] = 'websocket', ['connection'] = 'Upgrade', ['sec-websocket-key'] = 'dGhlIHNhbXBsZSBub25jZQ==', ['sec-websocket-protocol'] = 'chat, superchat', ['sec-websocket-version'] = '13', ['origin'] = 'http://example.com', } local response = handshake.accept_upgrade(request) t.assert_equals(type(response), 'table') t.assert_equals(response.version, 'HTTP/1.1') t.assert_equals(response.code, '101') end
nilq/small-lua-stack
null
local t = Def.ActorFrame{ GainFocusCommand=function(s) MESSAGEMAN:Broadcast("EASY") end; -- Information panel LoadActor(THEME:GetPathG("","_shared2ndMIX/GameMode/speaker"))..{ GainFocusCommand=cmd(linear,0.2;zoom,1;diffuse,color("1,1,1,1")); LoseFocusCommand=cmd(stoptweening;linear,0.2;zoom,0.75;diffuse,color("0.75,0.75,0.75,1")); }; LoadActor(THEME:GetPathG("","_shared2ndMIX/GameMode/cone"))..{ InitCommand=cmd(visible,false;zoom,0.9); GainFocusCommand=cmd(visible,true;heartbeat;effectperiod,0.2); LoseFocusCommand=cmd(stoptweening;stopeffect;visible,false); }; Def.Sprite{ InitCommand=cmd(y,-14;pause;); Texture="label"; GainFocusCommand=function(self) self:setstate(0) self:linear(0.2) self:zoom(1) end; LoseFocusCommand=function(self) self:setstate(1) self:stoptweening():linear(0.2):zoom(0.65); end; }; Def.Sprite{ Texture = "../../_shared2ndMIX/GameMode/stages"; InitCommand=cmd(y,84;pause); GainFocusCommand=cmd(linear,0.2;zoom,1); LoseFocusCommand=cmd(stoptweening;linear,0.2;zoom,0.55); SetCommand=function(self) local stages = PREFSMAN:GetPreference("SongsPerPlay") local event = PREFSMAN:GetPreference("EventMode") if stages == 1 then self:setstate(0) elseif stages == 2 then self:setstate(1) elseif stages == 3 then self:setstate(2) elseif stages == 4 then self:setstate(3) elseif stages >= 5 then self:setstate(4) elseif event == 1 then self:visible(false) end; end; }; }; return t;
nilq/small-lua-stack
null
local text_original = LocalizationManager.text function LocalizationManager:text(string_id, ...) return string_id == "PBC_NAME" and "PBC" or string_id == "PBC_DESC" and "Decreases your recoil, increases your fire rate and your overall durability. Speed is greatly reduced though." or string_id == "PBC_NAME_PK1" and "Armor Boost" or string_id == "PBC_DESC_PK1" and "Armor increased to ##400%##" or string_id == "PBC_NAME_PK2" and "Adrenaline to go" or string_id == "PBC_DESC_PK2" and "Health increased to ##300%## and makes your health ##regenerate##" or string_id == "PBC_NAME_PK3" and "Ammo Pouch" or string_id == "PBC_DESC_PK3" and "Total Ammo increased to ##350%##, increases your ammo pickup to ##200%## and increases your ammo pickup range to ##300%##" or string_id == "PBC_NAME_PK4" and "Shotgun Expert" or string_id == "PBC_DESC_PK4" and "##Decreases shotgun recoil##, increases the fire rate to ##200%## and ##doubles## the reloads speed" or string_id == "PBC_NAME_PK5" and "War Veteran" or string_id == "PBC_DESC_PK5" and "##Decreases LMG recoil##, increases the fire rate to ##200%## and ##doubles## the reloads speed" or string_id == "PBC_NAME_PK6" and "Personal defense weapon" or string_id == "PBC_DESC_PK6" and "##Decreases SMG recoil##, increases the fire rate to ##200%## and ##doubles## the reloads speed" or string_id == "PBC_NAME_PK7" and "Hitman" or string_id == "PBC_DESC_PK7" and "##Decreases pistol recoil##, increases the fire rate to ##200%## and ##doubles## the reloads speed" or string_id == "PBC_NAME_PK8" and "Professional Rifler" or string_id == "PBC_DESC_PK8" and "##Decreases assault rifle recoil##, increases the fire rate to ##200%## and ##doubles## the reloads speed" or string_id == "PBC_NAME_PK9" and "Heavy armor penalty" or string_id == "PBC_DESC_PK9" and "##Decreases movement speed##" or string_id == "DD_NAME" and "derDude" or string_id == "DD_DESC" and "One hit your enemies using your melee weapon, get more jokers, be swift and carry bags around quickly. Just like Eric does. | To be able to have more jokers at the same time, make sure to not use Confident Aced! A bug currently prevents the joker effect from this perk deck to work with Confident Aced." or string_id == "DD_NAME_PK1" and "Swiftness" or string_id == "DD_DESC_PK1" and "Movement speed increased to ##150%##" or string_id == "DD_NAME_PK2" and "Futuristic armor" or string_id == "DD_DESC_PK2" and "Armor increased to ##1300%##" or string_id == "DD_NAME_PK3" and "Energy pull" or string_id == "DD_DESC_PK3" and "Max HP set to ##0##" or string_id == "DD_NAME_PK4" and "Efficiency" or string_id == "DD_DESC_PK4" and "Ammo pickup increased to ##200%##" or string_id == "DD_NAME_PK5" and "Mechanic arm" or string_id == "DD_DESC_PK5" and "All melee hits ##one hit##" or string_id == "DD_NAME_PK6" and "Ninja-like" or string_id == "DD_DESC_PK6" and "Dodge increased by ##10%##" or string_id == "DD_NAME_PK7" and "Vegan lifestyle" or string_id == "DD_DESC_PK7" and "Stamina increased to ##200%##" or string_id == "DD_NAME_PK8" and "Influencer" or string_id == "DD_DESC_PK8" and "Max Joker amount increased to ##4## | To be able to have more jokers at the same time, make sure to not use Confident Aced! A bug currently prevents the joker effect from this perk deck to work with Confident Aced." or string_id == "DD_NAME_PK9" and "Heavy training" or string_id == "DD_DESC_PK9" and "Bag carrying speed increased to ##200%##" or text_original(self, string_id, ...) end
nilq/small-lua-stack
null
function event_combat(e) if (e.joined == true) then e.self:Emote("become submerged in the murky waters below."); eq.depop_with_timer(); end end
nilq/small-lua-stack
null
local bin = vim.fn.stdpath("data") .. "/lspinstall/cpp/clangd/bin/clangd" local lsp_config = require("lsp") if vim.fn.filereadable(bin) == 0 then require("lspinstall").install_server("cpp") end require'lspconfig'.clangd.setup { cmd = { bin, "--background-index" }, on_attach = lsp_config.common_on_attach }
nilq/small-lua-stack
null
local students = {} function addStudent(studentName, studentClass) table.insert( students, { name = studentName, class = studentClass, times_late = 0 } ) end addStudent("Nicole", "H1")
nilq/small-lua-stack
null
local action_utils = require('code_action_menu.utility_functions.actions') local StackingWindow = require('code_action_menu.windows.stacking_window') local function format_summary_for_action(action, index) vim.validate({ ['action to format summary for'] = { action, 'table' } }) local formatted_index = ' [' .. index .. ']' local kind = '(' .. action:get_kind() .. ')' local title = action:get_title() local disabled = action:is_disabled() and ' [disabled]' or '' return formatted_index .. ' ' .. kind .. ' ' .. title .. disabled end local MenuWindow = StackingWindow:new() function MenuWindow:new(all_actions) vim.validate({ ['all code actions'] = { all_actions, 'table' } }) local instance = StackingWindow:new({ all_actions = all_actions }) setmetatable(instance, self) self.__index = self self.focusable = true self.filetype = 'code-action-menu-menu' return instance end function MenuWindow:get_content() local content = {} for index, action in action_utils.iterate_actions_ordered(self.all_actions) do local line = format_summary_for_action(action, index) table.insert(content, line) end return content end function MenuWindow:get_selected_action() if self.window_number == -1 then error('Can not retrieve selected action when menu is not open!') else local cursor = vim.api.nvim_win_get_cursor(self.window_number) local line = cursor[1] return action_utils.get_action_at_index_ordered(self.all_actions, line) end end return MenuWindow
nilq/small-lua-stack
null
--------------------------------------------------------------------------------------------------- -- User story: https://github.com/smartdevicelink/sdl_requirements/issues/10 -- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/resource_allocation.md -- Item: Use Case 3: Alternative Flow 1 -- -- Requirement summary: -- [SDL_RC] Resource allocation based on access mode -- -- Description: -- In case: -- SDL received OnExitApplication (either user exits RC_app_1 vis HMI or due to driver distraction violation) -- -- SDL must: -- 1) SDL assigns HMILevel NONE to RC_app_1 and releases module_1 from RC_app_1 control --------------------------------------------------------------------------------------------------- --[[ Required Shared libraries ]] local runner = require('user_modules/script_runner') local commonRC = require('test_scripts/RC/commonRC') --[[ Test Configuration ]] runner.testSettings.isSelfIncluded = false --[[ Local Variables ]] local exitAppReasons = {"USER_EXIT", "DRIVER_DISTRACTION_VIOLATION"} --[[ Local Functions ]] local function PTUfunc(tbl) tbl.policy_table.app_policies[config.application1.registerAppInterfaceParams.fullAppID] = commonRC.getRCAppConfig() tbl.policy_table.app_policies[config.application2.registerAppInterfaceParams.fullAppID] = commonRC.getRCAppConfig() table.insert(tbl.policy_table.functional_groupings.RemoteControl.rpcs.OnInteriorVehicleData.hmi_levels, "NONE") end local function exitApp(pReason, pAppId) local hmiAppId = commonRC.getHMIAppId(pAppId) local mobSession = commonRC.getMobileSession(pAppId) commonRC.getHMIConnection():SendNotification("BasicCommunication.OnExitApplication", { appID = hmiAppId, reason = pReason }) mobSession:ExpectNotification("OnHMIStatus", { hmiLevel = "NONE", audioStreamingState = "NOT_AUDIBLE", systemContext = "MAIN" }) end --[[ Scenario ]] runner.Title("Preconditions") runner.Step("Clean environment", commonRC.preconditions, { false }) runner.Step("Start SDL, HMI, connect Mobile, start Session", commonRC.start) runner.Step("RAI1", commonRC.registerApp) runner.Step("PTU", commonRC.policyTableUpdate, { PTUfunc }) runner.Step("RAI2", commonRC.registerAppWOPTU, { 2 }) runner.Title("Test") runner.Step("Enable RC from HMI with AUTO_DENY access mode", commonRC.defineRAMode, { true, "AUTO_DENY"}) for _, reason in pairs(exitAppReasons) do runner.Title("Exit reason " .. reason) runner.Step("Activate App2", commonRC.activateApp, { 2 }) runner.Step("Activate App1", commonRC.activateApp) -- App1: FULL, App2: BACKGROUND runner.Step("Module CLIMATE App1 ButtonPress allowed", commonRC.rpcAllowed, { "CLIMATE", 1, "ButtonPress" }) runner.Step("Subscribe App1 to CLIMATE", commonRC.subscribeToModule, { "CLIMATE", 1 }) runner.Step("Send notification OnInteriorVehicleData CLIMATE. App1 is subscribed", commonRC.isSubscribed, { "CLIMATE", 1 }) runner.Step("Module CLIMATE App2 SetInteriorVehicleData denied", commonRC.rpcDenied, { "CLIMATE", 2, "SetInteriorVehicleData", "REJECTED" }) runner.Step("Exit App1 with reason " .. reason, exitApp, { reason, 1}) -- App1: NONE, App2: BACKGROUND runner.Step("Send notification OnInteriorVehicleData CLIMATE. App1 is unsubscribed", commonRC.isUnsubscribed, { "CLIMATE", 1 }) runner.Step("Module CLIMATE App2 SetInteriorVehicleData allowed", commonRC.rpcAllowed, { "CLIMATE", 2, "SetInteriorVehicleData"}) runner.Step("Exit App2 with reason " .. reason, exitApp, { reason, 2}) end runner.Title("Postconditions") runner.Step("Stop SDL", commonRC.postconditions)
nilq/small-lua-stack
null
----------------------------------------------------------------------------------------------------------------------- -- BATTERY -- ----------------------------------------------------------------------------------------------------------------------- -- Load modules ----------------------------------------------------------------------------------------------------------------------- local wibox = require("wibox") local beautiful = require("beautiful") local util = require("utilities") local watch = require("awful.widget.watch") -- Initialize taVLes and variaVLes for module ----------------------------------------------------------------------------------------------------------------------- local BAT_CAP = 'bash -c "cat /sys/class/power_supply/BAT0/capacity"' local BAT_WIDGET = util.bar() watch(BAT_CAP,20,function(widget, stdout, _, _, _) local level = tonumber(stdout) / 100 widget:set_value(level) end,BAT_WIDGET) return BAT_WIDGET
nilq/small-lua-stack
null
-- Global variables outputdir = "%{cfg.buildcfg}_%{cfg.system}_%{cfg.architecture}" inputdir = "%{prj.name}/src" -- Workspace definition (applies to all projects) workspace "MoteEmu" configurations { "Debug", "Release" } platforms { "x86", "x64" } language "C++" targetdir ("bin/" .. outputdir .. "/%{prj.name}") objdir ("obj/" .. outputdir .. "/%{prj.name}") files { inputdir .. "/*.h", inputdir .. "/*.cpp" } vpaths { ["Header Files"] = { "**.hpp", "**.h" }, ["Source Files"] = { "**.cpp", "**.cc", "**.c" } } filter "platforms:x86" architecture "x86" filter "platforms:x64" architecture "x64" filter "configurations:Debug" kind "ConsoleApp" defines { "DEBUG" } optimize "Debug" filter "configurations:Release" kind "WindowedApp" defines { "NDEBUG" } optimize "Full" filter "system:windows" cppdialect "C++17" systemversion "latest" -- Project definitions project "MoteEmu" location "MoteEmu" includedirs { "vendor/SDL2/include" } links { "SDL2", "SDL2main" } filter "platforms:x86" libdirs { "vendor/SDL2/lib/x86" } filter "platforms:x64" libdirs { "vendor/SDL2/lib/x64" }
nilq/small-lua-stack
null
require('keyboard') -- Load Hammerspoon bits from https://github.com/jasonrudolph/keyboard -- Make Hammerspoon accessible via the command line -- http://www.hammerspoon.org/docs/hs.ipc.html require("hs.ipc") -------------------------------------------------------------------------------- -- Load Hammerspoon bits from https://github.com/jasonrudolph/dotfiles -------------------------------------------------------------------------------- require('do-not-disturb') require('night-shift') require('layout') require('screen-sharing') require('wifi') -- TODO Consider auto-generating an HTML bookmarks file containing all of URLs -- that are bound to Hammerspoon functions, so that LaunchBar can automatically -- add those URLs to its index.
nilq/small-lua-stack
null
sc0tt_lucky_driveby = {} sc0tt_lucky_driveby.ped = GetPlayerPed(-1) --Please dont edit sc0tt_lucky_driveby.player = PlayerId() --Please dont edit sc0tt_lucky_driveby.kmh = 100 -- Up to wich speed you can shoot
nilq/small-lua-stack
null
local val,err = nyagos.commonprefix{ "ABC123" , "ABCCCC" } if not val or val ~= "ABC" then os.exit(1) end local val,err = nyagos.commonprefix() if val then os.exit(1) end local val,err = nyagos.commonprefix(1) if val then os.exit(1) end
nilq/small-lua-stack
null
----------------------------------------------------------------------- -- FILE: luaotfload-init.lua -- DESCRIPTION: part of luaotfload / font loader initialization -- REQUIREMENTS: luatex v.0.80 or later; packages lualibs -- AUTHOR: Philipp Gesang (Phg), <[email protected]>, Marcel Krüger ----------------------------------------------------------------------- local ProvidesLuaModule = { name = "luaotfload-init", version = "2.991", --TAGVERSION date = "2019-08-11", --TAGDATE description = "luaotfload submodule / initialization", license = "GPL v2.0" } if luatexbase and luatexbase.provides_module then luatexbase.provides_module (ProvidesLuaModule) end ----------------------------------------------------------------------- local setmetatable = setmetatable local kpsefind_file = kpse.find_file local lfsisdir = lfs.isdir --[[doc-- Initialization phases: - Load Lualibs from package - Set up the logger routines - Load Fontloader - as package specified in configuration - from Context install - (optional: from raw unpackaged files distributed with Luaotfload) The initialization of the Lualibs may be made configurable in the future as well allowing to load both the files and the merged package depending on a configuration setting. However, this would require separating out the configuration parser into a self-contained package, which might be problematic due to its current dependency on the Lualibs itself. --doc]]-- local log --- filled in after loading the log module local logreport --- filled in after loading the log module --[[doc-- \subsection{Preparing the Font Loader} We treat the fontloader as a semi-black box so behavior is consistent between formats. We load the fontloader code directly in the same fashion as the Plain format \identifier{luatex-fonts} that is part of Context. How this is executed depends on the presence on the \emphasis{merged font loader code}. In \identifier{luaotfload} this is contained in the file \fileent{luaotfload-merged.lua}. If this file cannot be found, the original libraries from \CONTEXT of which the merged code was composed are loaded instead. Since these files are not shipped with Luaotfload, an installation of Context is required. (Since we pull the fontloader directly from the Context minimals, the necessary Context version is likely to be more recent than that of other TeX distributions like Texlive.) The imported font loader will call \luafunction{callback.register} once while reading \fileent{font-def.lua}. This is unavoidable unless we modify the imported files, but harmless if we make it call a dummy instead. However, this problem might vanish if we decide to do the merging ourselves, like the \identifier{lualibs} package does. With this step we would obtain the freedom to load our own overrides in the process right where they are needed, at the cost of losing encapsulation. The decision on how to progress is currently on indefinite hold. --doc]]-- local init_early = function () local store = { } config = config or { } --- global config.luaotfload = config.luaotfload or { } config.lualibs = config.lualibs or { } config.lualibs.verbose = false config.lualibs.prefer_merged = true config.lualibs.load_extended = true fonts = fonts or { } require "lualibs" if not lualibs then error "this module requires Luaotfload" end if not luaotfload then error "this module requires Luaotfload" end --[[doc-- The logger needs to be in place prior to loading the fontloader due to order of initialization being crucial for the logger functions that are swapped. --doc]]-- luaotfload.loaders.luaotfload "log" log = luaotfload.log logreport = log.report log.set_loglevel (default_log_level) logreport ("log", 4, "init", "Concealing callback.register().") store.trapped_register = callback.register callback.register = function (id) logreport ("log", 4, "init", "Dummy callback.register() invoked on %s.", id) end --[[doc-- By default, the fontloader requires a number of \emphasis{private attributes} for internal use. These must be kept consistent with the attribute handling methods as provided by \identifier{luatexbase}. Our strategy is to override the function that allocates new attributes before we initialize the font loader, making it a wrapper around \luafunction{luatexbase.new_attribute}.\footnote{% Many thanks, again, to Hans Hagen for making this part configurable! } The attribute identifiers are prefixed “\fileent{luaotfload@}” to avoid name clashes. --doc]]-- local new_attribute = luatexbase.new_attribute local the_attributes = luatexbase.attributes attributes = attributes or { } --- this writes a global, sorry attributes.private = function (name) local attr = "luaotfload@" .. name --- used to be: “otfl@” local number = the_attributes[attr] if not number then number = new_attribute(attr) end return number end luaotfload.loaders.fontloader "basics-gen" return store end --- [init_early] --[[doc-- These next lines replicate the behavior of \fileent{luatex-fonts.lua}. --doc]]-- local push_namespaces = function () logreport ("log", 4, "init", "push namespace for font loader") local normalglobal = { } for k, v in next, _G do normalglobal[k] = v end return normalglobal end local pop_namespaces = function (normalglobal, isolate, context_environment) if normalglobal then local _G = _G local mode = "non-destructive" if isolate then mode = "destructive" end logreport ("log", 4, "init", "pop namespace from font loader -- " .. mode) for k, v in next, _G do if not normalglobal[k] then context_environment[k] = v if isolate then _G[k] = nil end end end for k, v in next, normalglobal do _G[k] = v end -- just to be sure: setmetatable(context_environment, _G) else logreport ("both", 0, "init", "irrecoverable error during pop_namespace: no globals to restore") os.exit () end end --- below paths are relative to the texmf-context local ltx = "tex/generic/context/luatex" local ctx = { "tex/context/base/mkiv", "tex/context/base" } local context_modules = { --- Since 2.6 those are directly provided by the Lualibs package. { false, "l-lua" }, { false, "l-lpeg" }, { false, "l-function" }, { false, "l-string" }, { false, "l-table" }, { false, "l-io" }, { false, "l-file" }, { false, "l-boolean" }, { false, "l-math" }, { false, "l-unicode" }, -- NEW UF 19.09.2018 { false, "util-str" }, { false, "util-fil" }, --- These constitute the fontloader proper. { ltx, "luatex-basics-gen" }, { ctx, "data-con" }, { ltx, "luatex-basics-nod" }, { ltx, "luatex-basics-chr" }, -- NEW UF 14.12.2018 { ctx, "font-ini" }, { ltx, "luatex-fonts-mis" }, -- NEW UF 19.09.2018 { ctx, "font-con" }, { ltx, "luatex-fonts-enc" }, { ctx, "font-cid" }, { ctx, "font-map" }, -- { ltx, "luatex-fonts-syn" }, -- ignore?? { ctx, "font-vfc" }, -- NEW UF 19.09.2018 { ctx, "font-oti" }, { ctx, "font-otr" }, { ctx, "font-ott" }, { ctx, "font-cff" }, { ctx, "font-ttf" }, { ctx, "font-dsp" }, { ctx, "font-oup" }, { ctx, "font-otl" }, { ctx, "font-oto" }, { ctx, "font-otj" }, { ctx, "font-ota" }, { ctx, "font-ots" }, { ctx, "font-osd" }, { ctx, "font-ocl" }, { ctx, "font-otc" }, { ctx, "font-onr" }, { ctx, "font-one" }, { ctx, "font-afk" }, { ctx, "luatex-fonts-tfm" }, { ctx, "font-lua" }, { ctx, "font-def" }, { ltx, "luatex-fonts-def" }, { ltx, "luatex-fonts-ext" }, { ctx, "font-imp-tex" }, { ctx, "font-imp-ligatures"}, { ctx, "font-imp-italics" }, { ctx, "font-imp-effects" }, { ltx, "luatex-fonts-lig" }, { ltx, "luatex-fonts-gbn" }, } --[[context_modules]] local load_context_modules = function (pth) local load_module = luaotfload.loaders.context local ignore_module = luaotfload.loaders.ignore logreport ("both", 2, "init", "Loading fontloader components from context.") local n = #context_modules for i = 1, n do local sub, spec = unpack (context_modules [i]) if sub == false then ignore_module (spec) else local tsub = type (sub) if not pth then load_module (spec) elseif tsub == "string" then load_module (spec, file.join (pth, sub)) elseif tsub == "table" then local pfx local nsub = #sub for j = 1, nsub do local full = file.join (pth, sub [j]) if lfsisdir (full) then --- pick the first real one pfx = full break end end if pfx then load_module (spec, pfx) else logreport ("both", 0, "init", "None of the %d search paths for module %q exist; \z falling back to default path.", nsub, tostring (spec)) load_module (spec) --- maybe we’ll get by after all? end else logreport ("both", 0, "init", "Internal error, please report. \z This is not your fault.") os.exit (-1) end end end end local init_adapt = function () local context_environment = { } local our_environment = push_namespaces () --[[doc-- The font loader requires that the attribute with index zero be zero. We happily oblige. (Cf. \fileent{luatex-fonts-nod.lua}.) --doc]]-- tex.attribute[0] = 0 return our_environment, context_environment end --- [init_adapt] --[[doc-- In Context, characters.data is where the data from char-def.lua resides. The file is huge (>4.4 MB as of 2016) and only a stripped down version is part of the isolated font loader. Nevertheless, we include an excerpt generated by the mkcharacters script that contains a subset of the fields of each character defined and some extra metadata. Currently, these are (compare the mkcharacters script!) · "direction" · "mirror" · "category" · "textclass" The directional information is required for packages like Simurgh [0] to work correctly. In an early stage [1] it was necessary to load further files from Context directly, including the full blown version of char-def. Since we have no use for most of the so imported functionality, the required parts have been isolated and are now instated along with luaotfload-characters.lua. We can extend the set of imported features easily should it not be enough. [0] https://github.com/persian-tex/simurgh [1] http://tex.stackexchange.com/a/132301/14066 --doc]]-- --[[--14.12.2018disable characters --characters = characters or { } --- should be created in basics-gen --characters.data = nil --local chardef = "luaotfload-characters" -- --do -- local setmetatableindex = function (t, f) -- local mt = getmetatable (t) -- if mt then -- mt.__index = f -- else -- setmetatable (t, { __index = f }) -- end -- end -- -- --- there are some special tables for each field that provide access -- --- to fields of the character table by means of a metatable -- -- local mkcharspecial = function (characters, tablename, field) -- -- local chardata = characters.data -- -- if chardata then -- local newspecial = { } -- characters [tablename] = newspecial --> e.g. “characters.data.mirrors” -- -- local idx = function (t, char) -- local c = chardata [char] -- if c then -- local m = c [field] --> e.g. “mirror” -- if m then -- t [char] = m -- return m -- end -- end -- newspecial [char] = false -- return char -- end -- -- setmetatableindex (newspecial, idx) -- end -- -- end -- -- local mkcategories = function (characters) -- different from the others -- -- local chardata = characters.data -- local categories = characters.categories or { } -- characters.categories = categories -- -- setmetatable (categories, { __index = function (t, char) -- if char then -- local c = chardata [char] -- c = c.category or char -- t [char] = c -- return c -- end -- end}) -- -- end -- -- local load_failed = false -- local chardata --> characters.data; loaded on demand -- -- local load_chardef = function () -- -- logreport ("both", 1, "aux", "Loading character metadata from %s.", chardef) -- chardata = dofile (kpse.find_file (chardef, "lua")) -- -- if chardata == nil then -- logreport ("both", 0, "aux", -- "Could not load %s; continuing with empty character table.", -- chardef) -- chardata = { } -- load_failed = true -- end -- -- characters = { } --- nuke metatable -- characters.data = chardata -- characters.classifiers = chardata.classifiers -- chardata.classifiers = nil -- -- --- institute some of the functionality from char-ini.lua -- -- mkcharspecial (characters, "mirrors", "mirror") -- mkcharspecial (characters, "directions", "direction") -- mkcharspecial (characters, "textclasses", "textclass") -- mkcategories (characters) -- -- end -- -- local charindex = function (t, k) -- if chardata == nil and load_failed ~= true then -- load_chardef () -- end -- -- return rawget (characters, k) -- end -- -- setmetatableindex (characters, charindex) -- --end --]] --14.12.2018disable characters local init_main = function () local load_fontloader_module = luaotfload.loaders.fontloader local ignore_module = luaotfload.loaders.ignore --[[doc-- Now that things are sorted out we can finally load the fontloader. --doc]]-- local fontloader = config.luaotfload and config.luaotfload.run.fontloader or "reference" fontloader = tostring (fontloader) if fontloader == "reference" then logreport ("log", 0, "init", "Using reference fontloader.") load_fontloader_module (luaotfload.fontloader_package) elseif fontloader == "default" then --- Same as above but loader name not correctly replaced by the file name --- of our fontloader package. Perhaps something’s wrong with the status --- file which contains the datestamped filename? In any case, it can’t --- hurt reporting it as a bug. logreport ("both", 0, "init", "Fontloader substitution failed, got “default”.") logreport ("log", 4, "init", "Falling back to reference fontloader.") load_fontloader_module (luaotfload.fontloader_package) elseif fontloader == "unpackaged" then logreport ("log", 0, "init", "Loading fontloader components individually.") --- The loading sequence is known to change, so this might have to be --- updated with future updates. Do not modify it though unless there is --- a change to the upstream package! --- Since 2.6 those are directly provided by the Lualibs package. ignore_module "l-lua" ignore_module "l-lpeg" ignore_module "l-function" ignore_module "l-string" ignore_module "l-table" ignore_module "l-io" ignore_module "l-file" ignore_module "l-boolean" ignore_module "l-math" ignore_module "util-str" ignore_module "util-fil" ignore_module "luatex-basics-gen" load_fontloader_module "data-con" load_fontloader_module "basics-nod" load_fontloader_module "basics-chr" load_fontloader_module "font-ini" load_fontloader_module "fonts-mis" load_fontloader_module "font-con" load_fontloader_module "fonts-enc" load_fontloader_module "font-cid" load_fontloader_module "font-map" -- load_fontloader_module "fonts-syn" -- ignore? load_fontloader_module "font-vfc" load_fontloader_module "font-otr" load_fontloader_module "font-oti" load_fontloader_module "font-ott" load_fontloader_module "font-cff" load_fontloader_module "font-ttf" load_fontloader_module "font-dsp" load_fontloader_module "font-oup" load_fontloader_module "font-otl" load_fontloader_module "font-oto" load_fontloader_module "font-otj" load_fontloader_module "font-ota" load_fontloader_module "font-ots" load_fontloader_module "font-osd" load_fontloader_module "font-ocl" load_fontloader_module "font-otc" load_fontloader_module "font-onr" load_fontloader_module "font-one" load_fontloader_module "font-afk" load_fontloader_module "fonts-tfm" load_fontloader_module "font-lua" load_fontloader_module "font-def" load_fontloader_module "fonts-def" load_fontloader_module "fonts-ext" load_fontloader_module "font-imp-tex" load_fontloader_module "font-imp-ligatures" load_fontloader_module "font-imp-italics" load_fontloader_module "font-imp-effects" load_fontloader_module "fonts-lig" load_fontloader_module "fonts-gbn" elseif fontloader == "context" then logreport ("log", 0, "init", "Loading Context modules in lookup path.") load_context_modules () elseif lfsisdir (fontloader) then logreport ("log", 0, "init", "Loading Context files under prefix “%s”.", fontloader) load_context_modules (fontloader) elseif lfs.isfile (fontloader) then logreport ("log", 0, "init", "Loading fontloader from absolute path “%s”.", fontloader) local _void = require (fontloader) elseif kpsefind_file (fontloader) then local path = kpsefind_file (fontloader) logreport ("log", 0, "init", "Loading fontloader “%s” from kpse-resolved path “%s”.", fontloader, path) local _void = require (path) elseif kpsefind_file (("fontloader-%s.lua"):format(fontloader)) then logreport ("log", 0, "init", "Using predefined fontloader “%s”.", fontloader) load_fontloader_module (fontloader) else logreport ("both", 0, "init", "No match for requested fontloader “%s”.", fontloader) fontloader = luaotfload.fontloader_package logreport ("both", 0, "init", "Defaulting to predefined fontloader “%s”.", fontloader) load_fontloader_module (fontloader) end ---load_fontloader_module "font-odv.lua" --- <= Devanagari support from Context logreport ("log", 0, "init", "Context OpenType loader version “%s”", fonts.handlers.otf.version) end --- [init_main] local init_cleanup = function (store) --- reinstate all the stuff we had to move out of the way to --- accomodate the loader --[[doc-- Here we adjust the globals created during font loader initialization. If the second argument to \luafunction{pop_namespaces()} is \verb|true| this will restore the state of \luafunction{_G}, eliminating every global generated since the last call to \luafunction{push_namespaces()}. At the moment we see no reason to do this, and since the font loader is considered an essential part of \identifier{luatex} as well as a very well organized piece of code, we happily concede it the right to add to \luafunction{_G} if needed. --doc]]-- pop_namespaces (store.our_environment, false, store.context_environment) --[[doc-- \subsection{Callbacks} After the fontloader is ready we can restore the callback trap from \identifier{luatexbase}. --doc]]-- logreport ("log", 4, "init", "Restoring original callback.register().") callback.register = store.trapped_register end --- [init_cleanup] local init_post_install_callbacks = function () --[[doc-- we do our own callback handling with the means provided by luatexbase. note: \luafunction{pre_linebreak_filter} and \luafunction{hpack_filter} are coupled in \context in the concept of \emphasis{node processor}. --doc]]-- -- MK Pass current text direction to simple_font_handler local handler = nodes.simple_font_handler local callback = function(head, groupcode, _, _, direction) return handler(head, groupcode, nil, nil, direction or tex.get'textdir') end luatexbase.add_to_callback("pre_linebreak_filter", callback, "luaotfload.node_processor", 1) luatexbase.add_to_callback("hpack_filter", callback, "luaotfload.node_processor", 1) -- /MK end local init_post_load_agl = function () --[[doc-- Adobe Glyph List. ----------------------------------------------------------------- Context provides a somewhat different font-age.lua from an unclear origin. Unfortunately, the file name it reads from is hard-coded in font-enc.lua, so we have to replace the entire table. This shouldn’t cause any complications. Due to its implementation the glyph list will be loaded upon loading a OTF or TTF for the first time during a TeX run. (If one sticks to TFM/OFM then it is never read at all.) For this reason we can install a metatable that looks up the file of our choosing and only falls back to the Context one in case it cannot be found. --doc]]-- local encodings = fonts.encodings if not encodings then --- Might happen during refactoring; we continue graciously but in --- a somewhat defect state. logreport ("log", 0, "init", "preconditions unmet, skipping the Adobe Glyph List; " .. "this is a Luaotfload bug.") return end if next (fonts.encodings.agl) then --- unnecessary because the file shouldn’t be loaded at this time --- but we’re just making sure fonts.encodings.agl = nil collectgarbage"collect" end local agl_init = { } --- start out empty, fill on demand encodings.agl = agl_init --- ugh, replaced again later setmetatable (agl_init, { __index = function (t, k) if k ~= "unicodes" then return nil end local glyphlist = kpsefind_file "luaotfload-glyphlist.lua" if glyphlist then logreport ("log", 1, "init", "loading the Adobe glyph list") else glyphlist = kpsefind_file "font-age.lua" logreport ("both", 0, "init", "loading the extended glyph list from ConTeXt") end if not glyphlist then logreport ("both", 4, "init", "Adobe glyph list not found, please check your installation.") return nil end logreport ("both", 4, "init", "found Adobe glyph list file at ``%s``, using that.", glyphlist) local unicodes = dofile(glyphlist) encodings.agl = { unicodes = unicodes } return unicodes end }) end --- (unit -> unit) list local init_post_actions = { init_post_install_callbacks, init_post_load_agl, } --- unit -> size_t local init_post = function () --- hook for actions that need to take place after the fontloader is --- installed local n = #init_post_actions for i = 1, n do local action = init_post_actions[i] local taction = type (action) if not action or taction ~= "function" then logreport ("both", 1, "init", "post hook WARNING: action %d not a function but %s/%s; ignoring.", i, action, taction) else --- call closure action () end end return n end --- [init_post] return { early = init_early, main = function (store) local starttime = os.gettimeofday () store.our_environment, store.context_environment = init_adapt () init_main () init_cleanup (store) logreport ("both", 1, "init", "fontloader loaded in %0.3f seconds", os.gettimeofday() - starttime) local n = init_post () logreport ("both", 5, "init", "post hook terminated, %d actions performed", n) return true end } -- vim:tw=79:sw=2:ts=2:expandtab
nilq/small-lua-stack
null
--[[ This file was extracted by 'EsoLuaGenerator' at '2021-09-04 16:42:27' using the latest game version. NOTE: This file should only be used as IDE support; it should NOT be distributed with addons! **************************************************************************** CONTENTS OF THIS FILE IS COPYRIGHT ZENIMAX MEDIA INC. **************************************************************************** ]] do local POINT_ACTION_TEXTURES = { [ZO_SKILL_POINT_ACTION.PURCHASE] = "EsoUI/Art/Progression/Gamepad/gp_purchase.dds", [ZO_SKILL_POINT_ACTION.SELL] = "EsoUI/Art/Buttons/Gamepad/gp_minus.dds", [ZO_SKILL_POINT_ACTION.INCREASE_RANK] = "EsoUI/Art/Progression/Gamepad/gp_purchase.dds", [ZO_SKILL_POINT_ACTION.DECREASE_RANK] = "EsoUI/Art/Buttons/Gamepad/gp_minus.dds", [ZO_SKILL_POINT_ACTION.MORPH] = "EsoUI/Art/Progression/Gamepad/gp_morph.dds", [ZO_SKILL_POINT_ACTION.UNMORPH] = "EsoUI/Art/Buttons/Gamepad/gp_minus.dds", [ZO_SKILL_POINT_ACTION.REMORPH] = "EsoUI/Art/Progression/Gamepad/gp_remorph.dds", } function ZO_Skills_GetGamepadSkillPointActionIcon(skillPointAction) return POINT_ACTION_TEXTURES[skillPointAction] end end function ZO_GamepadSkillLineXpBar_Setup(skillLineData, xpBar, nameControl, noWrap) local formattedName = skillLineData:GetFormattedName() local advised = skillLineData:IsAdvised() local lastXP, nextXP, currentXP = skillLineData:GetRankXPValues() if skillLineData:IsAvailable() then local skillLineRank = skillLineData:GetCurrentRank() ZO_SkillInfoXPBar_SetValue(xpBar, skillLineRank, lastXP, nextXP, currentXP, noWrap) elseif skillLineData:IsAdvised() then local RANK_NOT_SHOWN = 1 local CURRENT_XP_NOT_SHOWN = 0 ZO_SkillInfoXPBar_SetValue(xpBar, RANK_NOT_SHOWN, lastXP, nextXP, CURRENT_XP_NOT_SHOWN, noWrap) end if nameControl then nameControl:SetText(formattedName) end end function ZO_GamepadSkillLineEntryTemplate_Setup(control, skillLineEntry, selected, activated) local skillLineData = skillLineEntry.skillLineData local xpBar = control.barContainer.xpBar local noWrap = false if xpBar.skillLineData ~= skillLineData then xpBar.skillLineData = skillLineData xpBar:Reset() noWrap = true end local NO_NAME_CONTROL = nil ZO_GamepadSkillLineXpBar_Setup(skillLineData, xpBar, NO_NAME_CONTROL, noWrap) control.barContainer:SetHidden(not selected) end function ZO_GamepadSkillLineEntryTemplate_OnLevelChanged(xpBar, rank) xpBar:GetControl():GetParent().rank:SetText(rank) end function ZO_GamepadSkillEntryTemplate_SetEntryInfoFromAllocator(skillEntry) local skillData = skillEntry.skillData --Derive the progression specific info from the point allocator progression. This is done here so we can just do a RefreshVisible when the point allocator changes. local skillPointAllocator = skillData:GetPointAllocator() local skillProgressionData = skillPointAllocator:GetProgressionData() skillEntry:SetText(skillProgressionData:GetDetailedGamepadName()) skillEntry:ClearIcons() skillEntry:AddIcon(skillProgressionData:GetIcon()) if skillEntry.isPreview then local color = skillPointAllocator:IsPurchased() and ZO_SELECTED_TEXT or ZO_DISABLED_TEXT skillEntry:SetNameColors(color, color) end end do local function SetupAbilityIconFrame(control, isPassive, isActive, isAdvised) local iconTexture = control.icon local DOUBLE_FRAME_THICKNESS = 9 local SINGLE_FRAME_THICKNESS = 5 --Circle Frame (Passive) local circleFrameTexture = control.circleFrame if circleFrameTexture then if isPassive then circleFrameTexture:SetHidden(false) local frameOffsetFromIcon if isAdvised then frameOffsetFromIcon = DOUBLE_FRAME_THICKNESS circleFrameTexture:SetTexture("EsoUI/Art/SkillsAdvisor/gamepad/gp_passiveDoubleFrame_64.dds") else frameOffsetFromIcon = SINGLE_FRAME_THICKNESS circleFrameTexture:SetTexture("EsoUI/Art/Miscellaneous/Gamepad/gp_passiveFrame_64.dds") end circleFrameTexture:ClearAnchors() circleFrameTexture:SetAnchor(TOPLEFT, iconTexture, TOPLEFT, -frameOffsetFromIcon, -frameOffsetFromIcon) circleFrameTexture:SetAnchor(BOTTOMRIGHT, iconTexture, BOTTOMRIGHT, frameOffsetFromIcon, frameOffsetFromIcon) else control.circleFrame:SetHidden(true) end end --Edge Frame (Active) local SKILLS_ADVISOR_ACTIVE_DOUBLE_FRAME_WIDTH = 128 local SKILLS_ADVISOR_ACTIVE_DOUBLE_FRAME_HEIGHT = 16 local edgeFrameBackdrop = control.edgeFrame if isActive then edgeFrameBackdrop:SetHidden(false) local frameOffsetFromIcon if isAdvised then frameOffsetFromIcon = DOUBLE_FRAME_THICKNESS edgeFrameBackdrop:SetEdgeTexture("EsoUI/Art/SkillsAdvisor/gamepad/edgeDoubleframeGamepadBorder.dds", SKILLS_ADVISOR_ACTIVE_DOUBLE_FRAME_WIDTH, SKILLS_ADVISOR_ACTIVE_DOUBLE_FRAME_HEIGHT) else frameOffsetFromIcon = SINGLE_FRAME_THICKNESS edgeFrameBackdrop:SetEdgeTexture("EsoUI/Art/Miscellaneous/Gamepad/edgeframeGamepadBorder.dds", SKILLS_ADVISOR_ACTIVE_DOUBLE_FRAME_WIDTH, SKILLS_ADVISOR_ACTIVE_DOUBLE_FRAME_HEIGHT) end edgeFrameBackdrop:ClearAnchors() edgeFrameBackdrop:SetAnchor(TOPLEFT, iconTexture, TOPLEFT, -frameOffsetFromIcon, -frameOffsetFromIcon) edgeFrameBackdrop:SetAnchor(BOTTOMRIGHT, iconTexture, BOTTOMRIGHT, frameOffsetFromIcon, frameOffsetFromIcon) else edgeFrameBackdrop:SetHidden(true) end end local function SetBindingTextForSkill(keybindLabel, skillData) local hasBinding = false local keybindWidth = 0 --The spot where the keybind goes is occupied by the decrease button in the respec modes if SKILLS_AND_ACTION_BAR_MANAGER:GetSkillPointAllocationMode() == SKILL_POINT_ALLOCATION_MODE_PURCHASE_ONLY and skillData:IsActive() then local slot = skillData:GetSlotOnCurrentHotbar() if slot then hasBinding = true local hotbarCategory = ACTION_BAR_ASSIGNMENT_MANAGER:GetCurrentHotbarCategory() local GAMEPAD_MODE = true local actionName = ACTION_BAR_ASSIGNMENT_MANAGER:GetActionNameForSlot(slot, hotbarCategory, GAMEPAD_MODE) local bindingText = "" if actionName then bindingText = ZO_Keybindings_GetHighestPriorityBindingStringFromAction(actionName, KEYBIND_TEXT_OPTIONS_FULL_NAME, KEYBIND_TEXTURE_OPTIONS_EMBED_MARKUP, GAMEPAD_MODE) local layerIndex, categoryIndex, actionIndex = GetActionIndicesFromName(actionName) if layerIndex then local key = GetActionBindingInfo(layerIndex, categoryIndex, actionIndex, 1) if IsKeyCodeChordKey(key) then keybindWidth = 90 --width minus double keybind width (RB+LB) else keybindWidth = 50 --width minus single keybind end end else bindingText = zo_iconFormat("EsoUI/Art/Inventory/Gamepad/gp_inventory_icon_equipped.dds", "100%", "100%") keybindWidth = 50 --width minus single keybind end keybindLabel:SetText(bindingText) end end if hasBinding then keybindLabel:SetHidden(false) else keybindLabel:SetHidden(true) -- other controls depend on the keybind width for layout so let's reset its size too keybindLabel:SetText("") end return keybindWidth end local function SetupIndicatorsForSkill(leftIndicator, rightIndicator, skillData, showIncrease, showDecrease, showNew) local indicatorRightWidth = 0 --If we don't have a left indicator then we aren't going to have a right indicator either, so exit the function if not leftIndicator then return indicatorRightWidth end local skillPointAllocator = skillData:GetPointAllocator() local increaseMultiIcon local decreaseMultiIcon if rightIndicator == nil then increaseMultiIcon = leftIndicator decreaseMultiIcon = leftIndicator leftIndicator:ClearIcons() elseif SKILLS_AND_ACTION_BAR_MANAGER:DoesSkillPointAllocationModeBatchSave() then increaseMultiIcon = rightIndicator decreaseMultiIcon = leftIndicator leftIndicator:ClearIcons() rightIndicator:ClearIcons() else increaseMultiIcon = leftIndicator decreaseMultiIcon = rightIndicator leftIndicator:ClearIcons() rightIndicator:ClearIcons() end --Increase (Morph, Purchase, Increase Rank) Icon local increaseAction = ZO_SKILL_POINT_ACTION.NONE if showIncrease then increaseAction = skillPointAllocator:GetIncreaseSkillAction() elseif isMorph then -- this is used more as an indicator that this skill has been morphed, than an indicator that you _should_ morph it increaseAction = ZO_SKILL_POINT_ACTION.MORPH end if increaseAction ~= ZO_SKILL_POINT_ACTION.NONE then increaseMultiIcon:AddIcon(ZO_Skills_GetGamepadSkillPointActionIcon(increaseAction)) end --Decrease (Unmorph, Sell, Decrease Rank) if showDecrease then local decreaseAction = skillPointAllocator:GetDecreaseSkillAction() if decreaseAction ~= ZO_SKILL_POINT_ACTION.NONE then decreaseMultiIcon:AddIcon(ZO_Skills_GetGamepadSkillPointActionIcon(decreaseAction)) end --Always carve out space for the decrease icon even if it isn't active so the name doesn't dance around as it appears and disappears indicatorRightWidth = 40 end --New Indicator if showNew then if skillData:HasUpdatedStatus() then leftIndicator:AddIcon("EsoUI/Art/Inventory/newItem_icon.dds") end end leftIndicator:Show() if rightIndicator then rightIndicator:Show() end return indicatorRightWidth end local SKILL_ENTRY_LABEL_WIDTH = 289 function ZO_GamepadSkillEntryTemplate_Setup(control, skillEntry, selected, activated, displayView) --Some skill entries want to target a specific progression data (such as the morph dialog showing two specific morphs). Otherwise they use the skill progression that matches the current point spending. local skillData = skillEntry.skillData or skillEntry.skillProgressionData:GetSkillData() local skillProgressionData = skillEntry.skillProgressionData or skillData:GetPointAllocatorProgressionData() local skillPointAllocator = skillData:GetPointAllocator() local isUnlocked = skillProgressionData:IsUnlocked() local isMorph = skillData:IsActive() and skillProgressionData:IsMorph() local isPurchased = skillPointAllocator:IsPurchased() local isInSkillBuild = skillProgressionData:IsAdvised() --Icon local iconTexture = control.icon if displayView == ZO_SKILL_ABILITY_DISPLAY_INTERACTIVE then if isPurchased then iconTexture:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) else iconTexture:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) end end SetupAbilityIconFrame(control, skillData:IsPassive(), skillData:IsActive(), isInSkillBuild) --Label Color if displayView == ZO_SKILL_ABILITY_DISPLAY_INTERACTIVE then if not skillEntry.isPreview and isPurchased then control.label:SetColor((selected and PURCHASED_COLOR or PURCHASED_UNSELECTED_COLOR):UnpackRGBA()) end else control.label:SetColor(PURCHASED_COLOR:UnpackRGBA()) end --Lock Icon if control.lock then control.lock:SetHidden(isUnlocked) end local labelWidth = SKILL_ENTRY_LABEL_WIDTH local showIncrease = (displayView == ZO_SKILL_ABILITY_DISPLAY_INTERACTIVE) local showDecrease = SKILLS_AND_ACTION_BAR_MANAGER:DoesSkillPointAllocationModeAllowDecrease() local showNew = (displayView == ZO_SKILL_ABILITY_DISPLAY_INTERACTIVE) local indicatorWidth = SetupIndicatorsForSkill(control.leftIndicator, control.rightIndicator, skillData, showIncrease, showDecrease, showNew) labelWidth = labelWidth - indicatorWidth if displayView == ZO_SKILL_ABILITY_DISPLAY_INTERACTIVE then --Current Binding Text if control.keybind then local keybindWidth = SetBindingTextForSkill(control.keybind, skillData) labelWidth = labelWidth - keybindWidth end end --Size the label to allow space for the keybind and decrease icon control.label:SetWidth(labelWidth) end function ZO_GamepadCompanionSkillEntryTemplate_Setup(control, skillEntry, selected, activated, displayView) local skillData = skillEntry.skillData local skillProgressionData = skillData:GetPointAllocatorProgressionData() local skillPointAllocator = skillData:GetPointAllocator() local isUnlocked = skillProgressionData:IsUnlocked() local isPurchased = skillPointAllocator:IsPurchased() --Icon local iconTexture = control.icon if displayView == ZO_SKILL_ABILITY_DISPLAY_INTERACTIVE then if isPurchased then iconTexture:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) else iconTexture:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) end end local NOT_ADVISED = false SetupAbilityIconFrame(control, skillData:IsPassive(), skillData:IsActive(), NOT_ADVISED) --Label Color if displayView == ZO_SKILL_ABILITY_DISPLAY_INTERACTIVE then if not skillEntry.isPreview and isPurchased then control.label:SetColor((selected and PURCHASED_COLOR or PURCHASED_UNSELECTED_COLOR):UnpackRGBA()) end else control.label:SetColor(PURCHASED_COLOR:UnpackRGBA()) end --Lock Icon if control.lock then control.lock:SetHidden(isUnlocked) end local labelWidth = SKILL_ENTRY_LABEL_WIDTH local DONT_SHOW_INCREASE = false local DONT_SHOW_DECREASE = false local SHOW_NEW = true local indicatorWidth = SetupIndicatorsForSkill(control.leftIndicator, control.rightIndicator, skillData, DONT_SHOW_INCREASE, DONT_SHOW_DECREASE, SHOW_NEW) labelWidth = labelWidth - indicatorWidth if displayView == ZO_SKILL_ABILITY_DISPLAY_INTERACTIVE then --Current Binding Text if control.keybind then local keybindWidth = SetBindingTextForSkill(control.keybind, skillData) labelWidth = labelWidth - keybindWidth end end --Size the label to allow space for the keybind and decrease icon control.label:SetWidth(labelWidth) end function ZO_GamepadSkillEntryPreviewRow_Setup(control, skillData) local skillProgressionData = skillData:GetPointAllocatorProgressionData() local skillPointAllocator = skillData:GetPointAllocator() local isUnlocked = skillProgressionData:IsUnlocked() local isPurchased = skillPointAllocator:IsPurchased() local isMorph = skillData:IsPlayerSkill() and skillData:IsActive() and skillProgressionData:IsMorph() --Icon local iconTexture = control.icon iconTexture:SetTexture(skillProgressionData:GetIcon()) if isPurchased then iconTexture:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) else iconTexture:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) end SetupAbilityIconFrame(control, skillData:IsPassive(), skillData:IsActive(), skillProgressionData:IsAdvised()) --Label control.label:SetText(skillProgressionData:GetDetailedGamepadName()) local color = skillPointAllocator:IsPurchased() and ZO_SELECTED_TEXT or ZO_DISABLED_TEXT control.label:SetColor(color:UnpackRGBA()) --Lock Icon control.lock:SetHidden(isUnlocked) -- indicator local labelWidth = SKILL_ENTRY_LABEL_WIDTH local NO_RIGHT_INDICATOR = nil local SHOW_INCREASE = true local showDecrease = SKILLS_AND_ACTION_BAR_MANAGER:DoesSkillPointAllocationModeAllowDecrease() local SHOW_NEW = true local indicatorWidth = SetupIndicatorsForSkill(control.leftIndicator, NO_RIGHT_INDICATOR, skillData, SHOW_INCREASE, showDecrease, SHOW_NEW) labelWidth = labelWidth - indicatorWidth local keybindWidth = SetBindingTextForSkill(control.keybind, skillData) labelWidth = labelWidth - keybindWidth --Size the label to allow space for the keybind and decrease icon control.label:SetWidth(labelWidth) end end
nilq/small-lua-stack
null
StartState = Class{__includes = BaseState} function StartState:init(params) self.name = "StartState" self.background = params.background or Background(MENU_BACKGROUND) gSounds['music-title-screen']:setLooping(true) gSounds['music-title-screen']:play() self.menu = Menu { y = VIRTUAL_HEIGHT / 2, texts = { "Play", "Highscore", "Quit" }, callbacks = { function() gStateStack:pop() gStateStack:push(SelectShipState({background = self.background})) end, function() gStateStack:pop() gStateStack:push(HighscoreState({background = self.background})) end, function() love.event.quit() end } } end function StartState:update(dt) self.menu:update(dt) self.background:update(dt) end function StartState:render() self.background:render() love.graphics.setColor(1, 1, 1, 1) love.graphics.setFont(gFonts['large']) love.graphics.printf('Space Love', 0, VIRTUAL_HEIGHT / 2 - 120, VIRTUAL_WIDTH, 'center') self.menu:render() end
nilq/small-lua-stack
null
ESX = nil TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) ESX.RegisterServerCallback('NB:getUsergroup', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) local group = xPlayer.getGroup() cb(group) end) function getMaximumGrade(jobname) local result = MySQL.Sync.fetchAll("SELECT * FROM job_grades WHERE job_name=@jobname ORDER BY `grade` DESC ;", { ['@jobname'] = jobname }) if result[1] ~= nil then return result[1].grade end return nil end -------------------------------------------------------------------------------Admin Menu RegisterServerEvent("AdminMenu:giveCash") AddEventHandler("AdminMenu:giveCash", function(money) local _source = source local xPlayer = ESX.GetPlayerFromId(_source) local total = money xPlayer.addMoney((total)) local item = ' $ d\'argent !' local message = 'Tu t\'est GIVE ' TriggerClientEvent('esx:showNotification', _source, message.." "..total.." "..item) end) RegisterServerEvent("AdminMenu:giveBank") AddEventHandler("AdminMenu:giveBank", function(money) local _source = source local xPlayer = ESX.GetPlayerFromId(_source) local total = money xPlayer.addAccountMoney('bank', total) local item = ' $ en banque.' local message = 'Tu t\'es octroyé ' TriggerClientEvent('esx:showNotification', _source, message.." "..total.." "..item) end) RegisterServerEvent("AdminMenu:giveDirtyMoney") AddEventHandler("AdminMenu:giveDirtyMoney", function(money) local _source = source local xPlayer = ESX.GetPlayerFromId(_source) local total = money xPlayer.addAccountMoney('black_money', total) local item = ' $ d\'argent sale.' local message = 'Tu t\'es octroyé ' TriggerClientEvent('esx:showNotification', _source, message.." "..total.." "..item) end) -------------------------------------------------------------------------------Grade Menu RegisterServerEvent('NB:promouvoirplayer') AddEventHandler('NB:promouvoirplayer', function(target) local _source = source local sourceXPlayer = ESX.GetPlayerFromId(_source) local targetXPlayer = ESX.GetPlayerFromId(target) local maximumgrade = tonumber(getMaximumGrade(sourceXPlayer.job.name)) -1 if(targetXPlayer.job.grade == maximumgrade)then TriggerClientEvent('esx:showNotification', _source, "Vous devez demander une autorisation du ~r~Gouvernement~w~.") else if(sourceXPlayer.job.name == targetXPlayer.job.name)then local grade = tonumber(targetXPlayer.job.grade) + 1 local job = targetXPlayer.job.name targetXPlayer.setJob(job, grade) TriggerClientEvent('esx:showNotification', _source, "Vous avez ~g~promu "..targetXPlayer.name.."~w~.") TriggerClientEvent('esx:showNotification', target, "Vous avez été ~g~promu par ".. sourceXPlayer.name.."~w~.") else TriggerClientEvent('esx:showNotification', _source, "Vous n'avez pas ~r~l'autorisation~w~.") end end end) RegisterServerEvent('NB:destituerplayer') AddEventHandler('NB:destituerplayer', function(target) local _source = source local sourceXPlayer = ESX.GetPlayerFromId(_source) local targetXPlayer = ESX.GetPlayerFromId(target) if(targetXPlayer.job.grade == 0)then TriggerClientEvent('esx:showNotification', _source, "Vous ne pouvez pas plus ~r~rétrograder~w~ davantage.") else if(sourceXPlayer.job.name == targetXPlayer.job.name)then local grade = tonumber(targetXPlayer.job.grade) - 1 local job = targetXPlayer.job.name targetXPlayer.setJob(job, grade) TriggerClientEvent('esx:showNotification', _source, "Vous avez ~r~rétrogradé "..targetXPlayer.name.."~w~.") TriggerClientEvent('esx:showNotification', target, "Vous avez été ~r~rétrogradé par ".. sourceXPlayer.name.."~w~.") else TriggerClientEvent('esx:showNotification', _source, "Vous n'avez pas ~r~l'autorisation~w~.") end end end) RegisterServerEvent('NB:recruterplayer') AddEventHandler('NB:recruterplayer', function(target, job, grade) local _source = source local sourceXPlayer = ESX.GetPlayerFromId(_source) local targetXPlayer = ESX.GetPlayerFromId(target) targetXPlayer.setJob(job, grade) TriggerClientEvent('esx:showNotification', _source, "Vous avez ~g~recruté "..targetXPlayer.name.."~w~.") TriggerClientEvent('esx:showNotification', target, "Vous avez été ~g~embauché par ".. sourceXPlayer.name.."~w~.") end) RegisterServerEvent('NB:virerplayer') AddEventHandler('NB:virerplayer', function(target) local _source = source local sourceXPlayer = ESX.GetPlayerFromId(_source) local targetXPlayer = ESX.GetPlayerFromId(target) local job = "unemployed" local grade = "0" if(sourceXPlayer.job.name == targetXPlayer.job.name)then targetXPlayer.setJob(job, grade) TriggerClientEvent('esx:showNotification', _source, "Vous avez ~r~viré "..targetXPlayer.name.."~w~.") TriggerClientEvent('esx:showNotification', target, "Vous avez été ~g~viré par ".. sourceXPlayer.name.."~w~.") else TriggerClientEvent('esx:showNotification', _source, "Vous n'avez pas ~r~l'autorisation~w~.") end end)
nilq/small-lua-stack
null
-- grabbed from the rojo plugin: https://github.com/rojo-rbx/rojo/blob/master/plugin/src/Components/FitGrid.lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local common = ReplicatedStorage.common local lib = ReplicatedStorage.lib local util = common.util local Roact = require(lib.Roact) local Dictionary = require(util.Dictionary) local getAppliedScale = require(util.getAppliedScale) local e = Roact.createElement local FitGrid = Roact.PureComponent:extend("FitGrid") function FitGrid:init() self.sizeBinding, self.setSize = Roact.createBinding(UDim2.new()) self.layoutRef = Roact.createRef() end function FitGrid:refit(instance) local fitAxes = self.props.fitAxes or "Y" local minSize = self.props.minSize local containerProps = self.props.containerProps local paddingProps = self.props.paddingProps local sizeUpdated = self.props.sizeUpdated if paddingProps ~= nil then paddingProps = Dictionary.merge({ PaddingTop = UDim.new(0,0), PaddingBottom = UDim.new(0,0), PaddingLeft = UDim.new(0,0), PaddingRight = UDim.new(0,0), }, paddingProps) end local scale = getAppliedScale(instance) local contentSize = instance.AbsoluteContentSize / scale if paddingProps ~= nil then contentSize = contentSize + Vector2.new( paddingProps.PaddingLeft.Offset + paddingProps.PaddingRight.Offset, paddingProps.PaddingTop.Offset + paddingProps.PaddingBottom.Offset ) end if minSize then contentSize = Vector2.new( math.max(contentSize.X + 1, minSize.X), math.max(contentSize.Y + 1, minSize.Y) ) end local combinedSize if fitAxes == "X" then combinedSize = UDim2.new(0, contentSize.X, containerProps.Size.Y.Scale, containerProps.Size.Y.Offset) elseif fitAxes == "Y" then combinedSize = UDim2.new(containerProps.Size.X.Scale, containerProps.Size.X.Offset, 0, contentSize.Y) -- elseif fitAxes == "XY" then -- combinedSize = UDim2.new(0, contentSize.X, 0, contentSize.Y) else error("Invalid fitAxes value") end self.setSize(combinedSize) if typeof(sizeUpdated) == "function" then sizeUpdated(combinedSize) end end function FitGrid:didMount() local instance = self.layoutRef:getValue() self:refit(instance) end function FitGrid:render() local containerKind = self.props.containerKind or "Frame" local containerProps = self.props.containerProps local layoutProps = self.props.layoutProps local paddingProps = self.props.paddingProps local padding if paddingProps ~= nil then paddingProps = Dictionary.merge({ PaddingTop = UDim.new(0,0), PaddingBottom = UDim.new(0,0), PaddingLeft = UDim.new(0,0), PaddingRight = UDim.new(0,0), }, paddingProps) padding = e("UIPadding", paddingProps) end local children = Dictionary.merge(self.props[Roact.Children], { ["$Layout"] = e("UIGridLayout", Dictionary.merge({ SortOrder = Enum.SortOrder.LayoutOrder, [Roact.Change.AbsoluteContentSize] = function(instance) self:refit(instance) end, [Roact.Ref] = self.layoutRef }, layoutProps)), ["$Padding"] = padding, }) local fullContainerProps = Dictionary.merge(containerProps, { Size = self.sizeBinding, }) return e(containerKind, fullContainerProps, children) end return FitGrid
nilq/small-lua-stack
null
#!/usr/bin/env tarantool local tap = require('tap') local uri = require('uri') local function test_parse(test) -- Tests for uri.parse() Lua bindings. -- Parser itself is tested by test/unit/uri_parser unit test. test:plan(56) local u u = uri.parse("scheme://login:password@host:service".. "/path1/path2/path3?q1=v1&q2=v2&q3=v3:1|v3:2#fragment") test:is(u.scheme, "scheme", "scheme") test:is(u.login, "login", "login") test:is(u.password, "password", "password") test:is(u.host, "host", "host") test:is(u.service, "service", "service") test:is(u.path, "/path1/path2/path3", "path") test:is(u.query, "q1=v1&q2=v2&q3=v3:1|v3:2", "query") test:is(u.fragment, "fragment", "fragment") u = uri.parse("scheme://login:@host:service".. "/path1/path2/path3?q1=v1&q2=v2&q3=v3:1|v3:2#fragment") test:is(u.scheme, "scheme", "scheme") test:is(u.login, "login", "login") test:is(u.password, "", "password") test:is(u.host, "host", "host") test:is(u.service, "service", "service") test:is(u.path, "/path1/path2/path3", "path") test:is(u.query, "q1=v1&q2=v2&q3=v3:1|v3:2", "query") test:is(u.fragment, "fragment", "fragment") u = uri.parse('login@host') test:is(u.login, "login", "login") test:is(u.password, nil, "password") test:is(u.host, "host", "host") u = uri.parse('127.0.0.1') test:is(u.host, '127.0.0.1', 'host') test:is(u.ipv4, '127.0.0.1', 'ipv4') u = uri.parse('[2a00:1148:b0ba:2016:12bf:48ff:fe78:fd10]') test:is(u.host, '2a00:1148:b0ba:2016:12bf:48ff:fe78:fd10', 'host') test:is(u.ipv6, '2a00:1148:b0ba:2016:12bf:48ff:fe78:fd10', 'ipv6') u = uri.parse('/tmp/unix.sock') test:is(u.host, 'unix/', 'host') test:is(u.service, '/tmp/unix.sock', 'service') test:is(u.unix, '/tmp/unix.sock', 'unix') u = uri.parse("/tmp/unix.sock?q1=v1&q2=v2#fragment") test:is(u.host, 'unix/', 'host') test:is(u.service, '/tmp/unix.sock', 'service') test:is(u.unix, '/tmp/unix.sock', 'unix') test:is(u.query, 'q1=v1&q2=v2', 'query') test:is(u.fragment, 'fragment', 'fragment') u = uri.parse("/tmp/unix.sock:/path1/path2/path3?q1=v1&q2=v2#fragment") test:is(u.host, 'unix/', 'host') test:is(u.service, '/tmp/unix.sock', 'service') test:is(u.unix, '/tmp/unix.sock', 'unix') test:is(u.path, '/path1/path2/path3', 'path') test:is(u.query, 'q1=v1&q2=v2', 'query') test:is(u.fragment, 'fragment', 'fragment') u = uri.parse("login:password@/tmp/unix.sock:" .. "/path1/path2/path3?q1=v1#fragment") test:is(u.login, 'login', 'login') test:is(u.password, 'password', 'password') test:is(u.host, 'unix/', 'host') test:is(u.service, '/tmp/unix.sock', 'service') test:is(u.unix, '/tmp/unix.sock', 'unix') test:is(u.path, '/path1/path2/path3', 'path') test:is(u.query, 'q1=v1', 'query') test:is(u.fragment, 'fragment', 'fragment') u = uri.parse("scheme://login:password@/tmp/unix.sock:/path1/path2/path3") test:is(u.scheme, 'scheme', 'scheme') test:is(u.login, 'login', 'login') test:is(u.password, 'password', 'password') test:is(u.host, 'unix/', 'host') test:is(u.service, '/tmp/unix.sock', 'service') test:is(u.unix, '/tmp/unix.sock', 'unix') test:is(u.path, '/path1/path2/path3', 'path') local error, expected_errmsg expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" u, error = uri.parse("") test:isnil(u, "invalid uri", u) test:is(tostring(error), expected_errmsg, "error message") u, error = uri.parse("://") test:isnil(u, "invalid uri", u) test:is(tostring(error), expected_errmsg, "error message") end local function test_format(test) test:plan(13) local u = uri.parse("user:password@localhost") test:is(uri.format(u), "user@localhost", "password removed") test:is(uri.format(u, false), "user@localhost", "password removed") test:is(uri.format(u, true), "user:password@localhost", "password kept") -- URI with empty query u = uri.parse({"/tmp/unix.sock?"}) test:is(uri.format(u), "unix/:/tmp/unix.sock", "URI format") -- URI with one empty parameter u = uri.parse({"/tmp/unix.sock?q1"}) test:is(uri.format(u), "unix/:/tmp/unix.sock?q1", "URI format") -- All parameters passed in "params" table. u = uri.parse({"/tmp/unix.sock", params = {q1 = "v1", q2 = "v2"}}) test:is(uri.format(u), "unix/:/tmp/unix.sock?q1=v1&q2=v2", "URI format") -- Empty parameter in URI string. u = uri.parse({"/tmp/unix.sock?q1", params = {q2 = "v2", q3 = "v3"}}) test:is(uri.format(u), "unix/:/tmp/unix.sock?q1&q2=v2&q3=v3", "URI format") -- Parameter without value in URI string. u = uri.parse({"/tmp/unix.sock?q1=", params = {q2 = "v2", q3 = "v3"}}) test:is(uri.format(u), "unix/:/tmp/unix.sock?q1=&q2=v2&q3=v3", "URI format") -- Some parameters passed in URI string and some different -- parameters passed in "params" table. u = uri.parse({"/tmp/unix.sock?q1=v1", params = {q2 = "v2"}}) test:is(uri.format(u), "unix/:/tmp/unix.sock?q1=v1&q2=v2", "URI format") -- Same as previous but each parameter has several values. u = uri.parse({ "/tmp/unix.sock?q1=v11&q1=v12", params = {q2 = {"v21", "v22"}} }) test:is(uri.format(u), "unix/:/tmp/unix.sock?q1=v11&q1=v12&q2=v21&q2=v22", "URI format") -- One of parameters in "param" table has empty value u = uri.parse({ "/tmp/unix.sock?q1=v11&q1=v12", params = {q2 = {""}} }) test:is(uri.format(u), "unix/:/tmp/unix.sock?q1=v11&q1=v12&q2=", "URI format") -- Parameter from "params" table overwrite -- parameter from URI string. u = uri.parse({ "/tmp/unix.sock?q1=v11&q1=v12", params = {q1 = {"v13", "v14"}, q2 = "v2"} }) test:is(uri.format(u), "unix/:/tmp/unix.sock?q1=v13&q1=v14&q2=v2", "URI format") test:is(uri.format{host = "unix/", service = "/tmp/unix.sock"}, "unix/:/tmp/unix.sock", "URI format") end local function test_parse_uri_query_params(test) -- Tests for uri.parse() Lua bindings (URI with query parameters). -- Parser itself is tested by test/unit/uri unit test. test:plan(55) local u u = uri.parse("/tmp/unix.sock?q1=v1") test:is(u.host, 'unix/', 'host') test:is(u.service, '/tmp/unix.sock', 'service') test:is(u.unix, '/tmp/unix.sock', 'unix') test:is(type(u.params["q1"]), "table", "name") test:is(#u.params["q1"], 1, "value count") test:is(u.params["q1"][1], "v1", "param value") u = uri.parse("/tmp/unix.sock?q1=v1&q1=v2") test:is(u.host, 'unix/', 'host') test:is(u.service, '/tmp/unix.sock', 'service') test:is(u.unix, '/tmp/unix.sock', 'unix') test:is(type(u.params["q1"]), "table", "name") test:is(#u.params["q1"], 2, "value count") test:is(u.params["q1"][1], "v1", "param value") test:is(u.params["q1"][2], "v2", "param value") u = uri.parse("/tmp/unix.sock?q1=v11&q1=v12&q2=v21&q2=v22") test:is(u.host, 'unix/', 'host') test:is(u.service, '/tmp/unix.sock', 'service') test:is(u.unix, '/tmp/unix.sock', 'unix') test:is(type(u.params["q1"]), "table", "name") test:is(#u.params["q1"], 2, "value count") test:is(u.params["q1"][1], "v11", "param value") test:is(u.params["q1"][2], "v12", "param value") test:is(type(u.params["q2"]), "table", "name") test:is(#u.params["q2"], 2, "value count") test:is(u.params["q2"][1], "v21", "param value") test:is(u.params["q2"][2], "v22", "param value") u = uri.parse("/tmp/unix.sock?q1=v1&q1=&q2") test:is(u.host, 'unix/', 'host') test:is(u.service, '/tmp/unix.sock', 'service') test:is(u.unix, '/tmp/unix.sock', 'unix') test:is(type(u.params["q1"]), "table", "name") test:is(#u.params["q1"], 2, "value count") test:is(u.params["q1"][1], "v1", "param value") test:is(u.params["q1"][2], "", "param value") test:is(type(u.params["q2"]), "table", "name") test:is(#u.params["q2"], 0, "value count") -- Parse URI passed in table format, parameter values -- from "params" table, overwrite values from string. u = uri.parse({ "/tmp/unix.sock?q1=v11", params = { q1 = "v12", q2 = "v21" } }) test:is(u.host, 'unix/', 'host') test:is(u.service, '/tmp/unix.sock', 'service') test:is(u.unix, '/tmp/unix.sock', 'unix') test:is(type(u.params["q1"]), "table", "name") test:is(#u.params["q1"], 1, "value count") test:is(u.params["q1"][1], "v12", "param value") test:is(type(u.params["q2"]), "table", "name") test:is(#u.params["q2"], 1, "value count") test:is(u.params["q2"][1], "v21", "param value") -- Same as previous but "uri=" syntax u = uri.parse({ uri = "/tmp/unix.sock?q1=v11", params = { q1 = "v12", q2 = "v21" } }) test:is(u.host, 'unix/', 'host') test:is(u.service, '/tmp/unix.sock', 'service') test:is(u.unix, '/tmp/unix.sock', 'unix') test:is(type(u.params["q1"]), "table", "name") test:is(#u.params["q1"], 1, "value count") test:is(u.params["q1"][1], "v12", "param value") test:is(type(u.params["q2"]), "table", "name") test:is(#u.params["q2"], 1, "value count") test:is(u.params["q2"][1], "v21", "param value") local error, expected_errmsg -- "defult_params" is not allowed for single URI. expected_errmsg = "Default URI parameters are not allowed for single URI" u, error = uri.parse({ "/tmp/unix.sock", default_params = {q = "v"} }) test:isnil(u, "invalid uri", u) test:is(tostring(error), expected_errmsg, "error message") -- Multiple URIs is not allowed in `parse` method, -- use `parse_many` instead. expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" u, error = uri.parse({ "/tmp/unix.sock, /tmp/unix.sock"}) test:isnil(u, "invalid uri", u) test:is(tostring(error), expected_errmsg, "error message") end local function test_parse_uri_set_with_query_params(test) -- Tests for uri.parse_many() Lua bindings (several URIs with query parameters). -- Parser itself is tested by test/unit/uri unit test. test:plan(57) local uri_set -- The new method can work fine with both one and several URIs. uri_set = uri.parse_many("/tmp/unix.sock?q=v") test:is(#uri_set, 1, "uri count") test:is(uri_set[1].host, 'unix/', 'host') test:is(uri_set[1].service, '/tmp/unix.sock', 'service') test:is(uri_set[1].unix, '/tmp/unix.sock', 'unix') test:is(type(uri_set[1].params["q"]), "table", "name") test:is(#uri_set[1].params["q"], 1, "value count") test:is(uri_set[1].params["q"][1], "v", "param value") uri_set = uri.parse_many("/tmp/unix.sock?q=1, /tmp/unix.sock?q=2") test:is(#uri_set, 2, "uri count") for i = 1, #uri_set do test:is(uri_set[i].host, 'unix/', 'host') test:is(uri_set[i].service, '/tmp/unix.sock', 'service') test:is(uri_set[i].unix, '/tmp/unix.sock', 'unix') test:is(type(uri_set[i].params["q"]), "table", "name") test:is(#uri_set[i].params["q"], 1, "value count") test:is(uri_set[i].params["q"][1], tostring(i), "param value") end uri_set = uri.parse_many("/tmp/unix.sock?q1=1&q1=&q2&q3=" .. "," .. "/tmp/unix.sock?q1=1&q1=&q2&q3=") test:is(#uri_set, 2, "uri count") for i = 1, #uri_set do test:is(uri_set[i].host, 'unix/', 'host') test:is(uri_set[i].service, '/tmp/unix.sock', 'service') test:is(uri_set[i].unix, '/tmp/unix.sock', 'unix') test:is(type(uri_set[i].params["q1"]), "table", "name") test:is(#uri_set[i].params["q1"], 2, "value count") test:is(uri_set[i].params["q1"][1], "1", "param value") test:is(uri_set[i].params["q1"][2], "", "param value") test:is(type(uri_set[i].params["q2"]), "table", "name") test:is(#uri_set[i].params["q2"], 0, "value count") test:is(type(uri_set[i].params["q3"]), "table", "name") test:is(#uri_set[i].params["q3"], 1, "value count") test:is(uri_set[i].params["q3"][1], "", "value") end -- Empty string means empty uri_set uri_set = uri.parse_many("") test:is(#uri_set, 0, "uri_set") local error, expected_errmsg -- Check that uri.parse_many return nil for invalid URIs string uri_set = uri.parse_many("tmp/unix.sock, ://") test:isnil(uri_set, "invalid uri", uri_set) -- Extra ',' is not allowed expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" uri_set , error= uri.parse_many("/tmp/unix.sock,,/tmp/unix.sock") test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") uri_set, error = uri.parse_many("/tmp/unix.sock, ,/tmp/unix.sock") test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") uri_set, error = uri.parse_many("/tmp/unix.sock,, /tmp/unix.sock") test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") uri_set, error = uri.parse_many("/tmp/unix.sock ,,/tmp/unix.sock") test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- Check that we can't parse string with multiple URIs, -- using old method. expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" local u, error = uri.parse("/tmp/unix.sock, /tmp/unix.sock") test:isnil(u, "invalid uri", u) test:is(tostring(error), expected_errmsg, "error message") end local function test_parse_uri_set_from_lua_table(test) -- Tests for uri.parse_many() Lua bindings. -- (Several URIs with parameters, passed in different ways). test:plan(134) local uri_set -- Array with one string address and one parameter uri_set = uri.parse_many({"/tmp/unix.sock?q1=v1"}) test:is(#uri_set, 1, "uri count") test:is(uri_set[1].host, 'unix/', 'host') test:is(uri_set[1].service, '/tmp/unix.sock', 'service') test:is(uri_set[1].unix, '/tmp/unix.sock', 'unix') test:is(type(uri_set[1].params["q1"]), "table", "name") test:is(#uri_set[1].params["q1"], 1, "value count") test:is(uri_set[1].params["q1"][1], "v1", "param value") -- Array with one string address and several parameters. -- One of them passed in URI string, one separately as a string, -- one separately as a table with two values. uri_set = uri.parse_many({ "/tmp/unix.sock?q1=v1", params = {q2 = "v2", q3 = {"v31", "v32"}} }) test:is(#uri_set, 1, "uri count") test:is(uri_set[1].host, 'unix/', 'host') test:is(uri_set[1].service, '/tmp/unix.sock', 'service') test:is(uri_set[1].unix, '/tmp/unix.sock', 'unix') test:is(type(uri_set[1].params["q1"]), "table", "name") test:is(#uri_set[1].params["q1"], 1, "value count") test:is(uri_set[1].params["q1"][1], "v1", "param value") test:is(type(uri_set[1].params["q2"]), "table", "name") test:is(#uri_set[1].params["q2"], 1, "value count") test:is(uri_set[1].params["q2"][1], "v2", "param value") test:is(type(uri_set[1].params["q3"]), "table", "name") test:is(#uri_set[1].params["q3"], 2, "value count") test:is(uri_set[1].params["q3"][1], "v31", "param value") test:is(uri_set[1].params["q3"][2], "v32", "param value") -- Same as previous but use "uri=" syntax to save URI value. uri_set = uri.parse_many({ uri = "/tmp/unix.sock?q1=v1", params = {q2 = "v2", q3 = {"v31", "v32"}} }) test:is(#uri_set, 1, "uri count") test:is(uri_set[1].host, 'unix/', 'host') test:is(uri_set[1].service, '/tmp/unix.sock', 'service') test:is(uri_set[1].unix, '/tmp/unix.sock', 'unix') test:is(type(uri_set[1].params["q1"]), "table", "name") test:is(#uri_set[1].params["q1"], 1, "value count") test:is(uri_set[1].params["q1"][1], "v1", "param value") test:is(type(uri_set[1].params["q2"]), "table", "name") test:is(#uri_set[1].params["q2"], 1, "value count") test:is(uri_set[1].params["q2"][1], "v2", "param value") test:is(type(uri_set[1].params["q3"]), "table", "name") test:is(#uri_set[1].params["q3"], 2, "value count") test:is(uri_set[1].params["q3"][1], "v31", "param value") test:is(uri_set[1].params["q3"][2], "v32", "param value") -- Check that URI parameter value from "params" table -- overwrite parameter value from the string. uri_set = uri.parse_many({ "/tmp/unix.sock?q1=v1", params = {q1 = {"v2", "v3"}} }) test:is(#uri_set, 1, "uri count") test:is(uri_set[1].host, 'unix/', 'host') test:is(uri_set[1].service, '/tmp/unix.sock', 'service') test:is(uri_set[1].unix, '/tmp/unix.sock', 'unix') test:is(type(uri_set[1].params["q1"]), "table", "name") test:is(#uri_set[1].params["q1"], 2, "value count") -- "v1" value was overwriten by values from "params" table test:is(uri_set[1].params["q1"][1], "v2", "param value") test:is(uri_set[1].params["q1"][2], "v3", "param value") -- Most common way: several URIs passed as array of strings -- and objects with different parameters and default parameters. uri_set = uri.parse_many({ "/tmp/unix.sock?q1=v11", { "/tmp/unix.sock?q2=v21", params = { q2 = "v22", q3 = "v31" } }, { "/tmp/unix.sock", params = { q1 = 1, q2 = { 2, 3, 4}, q3 = 5 } }, { uri = "/tmp/unix.sock?q2&q3=v31", params = { q3 = {"v33", "v34"} } }, default_params = { q1 = {"v12", "v13"}, q2 = {"v21", "v22"}, q3 = {"v32"}, q4 = 6 } }) test:is(#uri_set, 4, "uri count") -- First URI from uri_set test:is(uri_set[1].host, 'unix/', 'host') test:is(uri_set[1].service, '/tmp/unix.sock', 'service') test:is(uri_set[1].unix, '/tmp/unix.sock', 'unix') test:is(type(uri_set[1].params["q1"]), "table", "name") test:is(#uri_set[1].params["q1"], 1, "value count") -- As previously values from "default_params" table are -- ignored if there is some values for this URI parameter -- from URI string or "params" table. test:is(uri_set[1].params["q1"][1], "v11", "param value") test:is(type(uri_set[1].params["q2"]), "table", "name") test:is(#uri_set[1].params["q2"], 2, "value count") -- Values was added from "default_params" table. test:is(uri_set[1].params["q2"][1], "v21", "param value") test:is(uri_set[1].params["q2"][2], "v22", "param value") test:is(type(uri_set[1].params["q3"]), "table", "name") test:is(#uri_set[1].params["q3"], 1, "value count") -- Value was added from "params" table. test:is(uri_set[1].params["q3"][1], "v32", "param value") test:is(type(uri_set[1].params["q4"]), "table", "name") test:is(#uri_set[1].params["q4"], 1, "value count") -- Numerical value, saved as a string. test:is(uri_set[1].params["q4"][1], "6", "param value") -- Second URI from uri_set test:is(uri_set[2].host, 'unix/', 'host') test:is(uri_set[2].service, '/tmp/unix.sock', 'service') test:is(uri_set[2].unix, '/tmp/unix.sock', 'unix') test:is(type(uri_set[2].params["q1"]), "table", "name") test:is(#uri_set[2].params["q1"], 2, "value count") -- Values from "default_params" table for "q1" parameter -- are added, because there is no such parameter in URI -- string and in "params" table. test:is(uri_set[2].params["q1"][1], "v12", "param value") test:is(uri_set[2].params["q1"][1], "v12", "param value") test:is(type(uri_set[2].params["q2"]), "table", "name") test:is(#uri_set[2].params["q2"], 1, "value count") -- "q2" parameter value from URI string overwritten by -- value from "params" table, values from "defaul_params" -- table are ignored. test:is(uri_set[2].params["q2"][1], "v22", "param value") test:is(type(uri_set[2].params["q3"]), "table", "name") test:is(#uri_set[2].params["q3"], 1, "value count") -- "q3" parameter value added from from "params" table, -- values from "defaul_params" table are ignored. test:is(uri_set[2].params["q3"][1], "v31", "param value") test:is(type(uri_set[2].params["q4"]), "table", "name") test:is(#uri_set[2].params["q4"], 1, "value count") -- Numerical value, saved as a string. test:is(uri_set[2].params["q4"][1], "6", "param value") -- Third URI from uri_set -- All values are taken from "params" table, just check -- how we parse numerical parameter values. test:is(uri_set[3].host, 'unix/', 'host') test:is(uri_set[3].service, '/tmp/unix.sock', 'service') test:is(uri_set[3].unix, '/tmp/unix.sock', 'unix') test:is(type(uri_set[3].params["q1"]), "table", "name") test:is(#uri_set[3].params["q1"], 1, "value count") test:is(uri_set[3].params["q1"][1], "1", "param value") test:is(type(uri_set[3].params["q2"]), "table", "name") test:is(#uri_set[3].params["q2"], 3, "value count") test:is(uri_set[3].params["q2"][1], "2", "param value") test:is(uri_set[3].params["q2"][2], "3", "param value") test:is(uri_set[3].params["q2"][3], "4", "param value") test:is(type(uri_set[3].params["q3"]), "table", "name") test:is(#uri_set[3].params["q3"], 1, "value count") test:is(uri_set[3].params["q3"][1], "5", "param value") -- Fourth URI from uri_set test:is(uri_set[4].host, 'unix/', 'host') test:is(uri_set[4].service, '/tmp/unix.sock', 'service') test:is(uri_set[4].unix, '/tmp/unix.sock', 'unix') test:is(type(uri_set[4].params["q1"]), "table", "name") test:is(#uri_set[4].params["q1"], 2, "value count") -- As previous values was added from "default_params" table test:is(uri_set[4].params["q1"][1], "v12", "param value") test:is(uri_set[4].params["q1"][2], "v13", "param value") test:is(type(uri_set[4].params["q2"]), "table", "name") test:is(#uri_set[4].params["q2"], 2, "value count") -- Values from "default_params" table for "q2" parameter -- are added, because there is no values for this parameter -- in URI string and there is no such paramater in "params -- table. test:is(uri_set[4].params["q2"][1], "v21", "param value") test:is(uri_set[4].params["q2"][2], "v22", "param value") test:is(type(uri_set[4].params["q3"]), "table", "name") test:is(#uri_set[4].params["q3"], 2, "value count") -- Value from URI string was overwritten by values from -- "params" table. Values from "default_params" table are -- ignored. test:is(uri_set[4].params["q3"][1], "v33", "param value") test:is(uri_set[4].params["q3"][2], "v34", "param value") test:is(type(uri_set[4].params["q4"]), "table", "name") test:is(#uri_set[4].params["q4"], 1, "value count") -- Numerical value, saved as a string. test:is(uri_set[4].params["q4"][1], "6", "param value") -- If some URI parameter is a table in "params" -- or "default_params" table, all keys in this -- table should be numerical, otherwise silently -- ignored uri_set = uri.parse_many({ { "/tmp/unix.sock", params = {q1 = { x = "y"}} }, "/tmp/unix.sock", default_params = {q2 = {x = "y"}} }) test:is(#uri_set, 2, "uri count") -- First URI from uri_set test:is(uri_set[1].host, 'unix/', 'host') test:is(uri_set[1].service, '/tmp/unix.sock', 'service') test:is(uri_set[1].unix, '/tmp/unix.sock', 'unix') test:is(type(uri_set[1].params["q1"]), "nil", "name") test:is(type(uri_set[1].params["q2"]), "nil", "name") test:is(uri_set[2].host, 'unix/', 'host') test:is(uri_set[2].service, '/tmp/unix.sock', 'service') test:is(uri_set[2].unix, '/tmp/unix.sock', 'unix') test:is(type(uri_set[2].params["q1"]), "nil", "name") test:is(type(uri_set[2].params["q2"]), "nil", "name") -- URI table without URI uri_set = uri.parse_many({ params = {q = "v"}, default_params = {} }) test:is(#uri_set, 0, "uri count") -- URI table with one URI in table format uri_set = uri.parse_many{{"/tmp/unix.sock"}, default_params = {q = "v"}} test:is(#uri_set, 1, "uri count") test:is(uri_set[1].host, 'unix/', 'host') test:is(uri_set[1].service, '/tmp/unix.sock', 'service') test:is(uri_set[1].unix, '/tmp/unix.sock', 'unix') test:is(type(uri_set[1].params["q"]), "table", "name") test:is(#uri_set[1].params["q"], 1, "value count") test:is(uri_set[1].params["q"][1], "v", "param value") -- Same as previous but with "uri=" syntax uri_set = uri.parse_many{{uri = "/tmp/unix.sock"}, default_params = {q = "v"}} test:is(#uri_set, 1, "uri count") test:is(uri_set[1].host, 'unix/', 'host') test:is(uri_set[1].service, '/tmp/unix.sock', 'service') test:is(uri_set[1].unix, '/tmp/unix.sock', 'unix') test:is(type(uri_set[1].params["q"]), "table", "name") test:is(#uri_set[1].params["q"], 1, "value count") test:is(uri_set[1].params["q"][1], "v", "param value") end local function test_parse_invalid_uri_set_from_lua_table(test) -- Tests for uri.parse_many() Lua bindings. -- (Several invalid URIs with parameters, passed in different ways). test:plan(50) local uri_set, error, expected_errmsg -- Invalid type passed to "parse_many" expected_errmsg = "Incorrect type for URI: should be string, number or table" uri_set, error = uri.parse_many(function() end) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- Invalid type of value for numerical key expected_errmsg = "Incorrect type for URI: should be string, number or table" uri_set, error = uri.parse_many({"/tmp/unix.sock", function() end}) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- Invalid type of value for string keys expected_errmsg = "Invalid URI table: expected " .. "{uri = string, params = table}" .. " or " .. "{string, params = table}" uri_set, error = uri.parse_many({"/tmp/unix.sock", uri = function() end}) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") expected_errmsg = "Incorrect type for URI parameters: should be a table" uri_set, error = uri.parse_many({"/tmp/unix.sock", params = function() end}) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") expected_errmsg = "Incorrect type for URI parameters: should be a table" uri_set, error = uri.parse_many({"/tmp/unix.sock", params = ""}) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") expected_errmsg = "Default URI parameters are not allowed for single URI" uri_set, error = uri.parse_many({"/tmp/unix.sock", default_params = ""}) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") expected_errmsg = "Default URI parameters are not allowed for single URI" uri_set, error = uri.parse_many({"/tmp/unix.sock", default_params = ""}) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- Mix "uri=" and numerical keys is banned expected_errmsg = "Invalid URI table: expected " .. "{uri = string, params = table}" .. " or " .. "{string, params = table}" uri_set, error = uri.parse_many({"/tmp/unix.sock", uri = "/tmp/unix.sock"}) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- Several URIs in one string is allowed only when the -- passed as a single string. expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" uri_set, error = uri.parse_many({"/tmp/unix.sock, /tmp/unix.sock"}) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- "params" table is allowed only for single URI expected_errmsg = "URI parameters are not allowed for multiple URIs" uri_set, error = uri.parse_many({ "/tmp/unix.sock", "/tmp/unix.sock", params = {q1 = "v1"} }) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- "params" table is not allowed with nested tables expected_errmsg = "URI parameters are not allowed for multiple URIs" uri_set, error = uri.parse_many({ {"/tmp/unix.sock"}, params = {q1 = "v1"} }) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- "default_params" table is not allowed in nested URI tables expected_errmsg = "Default URI parameters are not allowed for single URI" uri_set, error = uri.parse_many({{"/tmp/unix.sock", default_params = {}}}) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- "default_params" table is not allowed for single URI expected_errmsg = "Default URI parameters are not allowed for single URI" uri_set, error = uri.parse_many({"/tmp/unix.sock", default_params = {}}) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- Only one URI is allowed in nested tables expected_errmsg = "Invalid URI table: expected " .. "{uri = string, params = table}" .. " or " .. "{string, params = table}" uri_set, error = uri.parse_many({ {"/tmp/unix.sock", "/tmp/unix.sock"}, default_params = {q = "v"} }) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- Nested URI tables is not allowed in nested tables expected_errmsg = "Invalid URI table: expected ".. "{uri = string, params = table}" .. " or " .. "{string, params = table}" uri_set, error = uri.parse_many({ {"/tmp/unix.sock", {}} }) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- Nested URI table without URI is now allowed expected_errmsg = "Invalid URI table: expected ".. "{uri = string, params = table}" .. " or " .. "{string, params = table}" uri_set, error = uri.parse_many({ "/tmp/unix.sock", { params = {q = "v"} } }) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- Only string key types are allowed in "params" and -- "default_params" table expected_errmsg = "Incorrect type for URI parameter name: " .. "should be a string" uri_set, error = uri.parse_many({ "/tmp/unix.sock", params = {"v"}, }) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") expected_errmsg = "Default URI parameters are not allowed for single URI" uri_set, error = uri.parse_many({ "/tmp/unix.sock", default_params = {"v"}, }) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- Invalid type of values in "params" and -- "default_params" table expected_errmsg = "Incorrect type for URI parameter value: " .. "should be string, number or table" uri_set, error = uri.parse_many({ "/tmp/unix.sock", params = {q = function() end}, }) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") expected_errmsg = "Default URI parameters are not allowed for single URI" uri_set, error = uri.parse_many({ "/tmp/unix.sock", default_params = {q = function() end}, }) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") expected_errmsg = "Incorrect type for URI parameter value: ".. "should be string or number" uri_set, error = uri.parse_many({ "/tmp/unix.sock", params = {q = {function() end}}, }) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") expected_errmsg = "Default URI parameters are not allowed for single URI" uri_set, error = uri.parse_many({ "/tmp/unix.sock", default_params = {q = {function() end}}, }) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- Invalid uri string in URIs table expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" uri_set, error = uri.parse_many({ "/tmp/unix.sock", "://" }) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- Invalid uri in nested URI table expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" uri_set, error = uri.parse_many({ "/tmp/unix.sock", {"://"} }) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") -- Same as previous but with "uri=" syntax expected_errmsg = "Incorrect URI: expected host:service or /unix.socket" uri_set, error = uri.parse_many({ "/tmp/unix.sock", {uri = "://"} }) test:isnil(uri_set, "invalid uri", uri_set) test:is(tostring(error), expected_errmsg, "error message") end tap.test("uri", function(test) test:plan(6) test:test("parse", test_parse) test:test("parse URI query params", test_parse_uri_query_params) test:test("parse URIs with query params", test_parse_uri_set_with_query_params) test:test("parse URIs from lua table", test_parse_uri_set_from_lua_table) test:test("parse invalid URIs from lua table", test_parse_invalid_uri_set_from_lua_table) test:test("format", test_format) end)
nilq/small-lua-stack
null
table.insert(emojichatHTML, [===["flag","nation","country","banner"],char:"🇺🇿",fitzpatrick_scale:!1,category:"flags"},vanuatu:{keywords:["vu","flag","nation","country","banner"],char:"🇻🇺",fitzpatrick_scale:!1,category:"flags"},vatican_city:{keywords:["vatican","city","flag","nation","country","banner"],char:"🇻🇦",fitzpatrick_scale:!1,category:"flags"},venezuela:{keywords:["ve","bolivarian","republic","flag","nation","country","banner"],char:"🇻🇪",fitzpatrick_scale:!1,category:"flags"},vietnam:{keywords:["viet","nam","flag","nation","country","banner"],char:"🇻🇳",fitzpatrick_scale:!1,category:"flags"},wallis_futuna:{keywords:["wallis","futuna","flag","nation","country","banner"],char:"🇼🇫",fitzpatrick_scale:!1,category:"flags"},western_sahara:{keywords:["western","sahara","flag","nation","country","banner"],char:"🇪🇭",fitzpatrick_scale:!1,category:"flags"},yemen:{keywords:["ye","flag","nation","country","banner"],char:"🇾🇪",fitzpatrick_scale:!1,category:"flags"},zambia:{keywords:["zm","flag","nation","country","banner"],char:"🇿🇲",fitzpatrick_scale:!1,category:"flags"},zimbabwe:{keywords:["zw","flag","nation","country","banner"],char:"🇿🇼",fitzpatrick_scale:!1,category:"flags"},united_nations:{keywords:["un","flag","banner"],char:"🇺🇳",fitzpatrick_scale:!1,category:"flags"},pirate_flag:{keywords:["skull","crossbones","flag","banner"],char:"🏴‍☠️",fitzpatrick_scale:!1,category:"flags"}}},function(e){e.exports=["grinning","smiley","smile","grin","laughing","sweat_smile","joy","rofl","relaxed","blush","innocent","slightly_smiling_face","upside_down_face","wink","relieved","heart_eyes","smiling_face_with_three_hearts","kissing_heart","kissing","kissing_smiling_eyes","kissing_closed_eyes","yum","stuck_out_tongue","stuck_out_tongue_closed_eyes","stuck_out_tongue_winking_eye","zany","raised_eyebrow","monocle","nerd_face","sunglasses","star_struck","partying","smirk","unamused","disappointed","pensive","worried","confused","slightly_frowning_face","frowning_face","persevere","confounded","tired_face","weary","pleading","cry","sob","triumph","angry","rage","symbols_over_mouth","exploding_head","flushed","hot","cold","scream","fearful","cold_sweat","disappointed_relieved","sweat","hugs","thinking","hand_over_mouth","shushing","lying_face","no_mouth","neutral_face","expressionless","grimacing","roll_eyes","hushed","frowning","anguished","open_mouth","astonished","sleeping","drooling_face","sleepy","dizzy_face","zipper_mouth_face","woozy","nauseated_face","vomiting","sneezing_face","mask","face_with_thermometer","face_with_head_bandage","money_mouth_face","cowboy_hat_face","smiling_imp","imp","japanese_ogre","japanese_goblin","clown_face","poop","ghost","skull","skull_and_crossbones","alien","space_invader","robot","jack_o_lantern","smiley_cat","smile_cat","joy_cat","heart_eyes_cat","smirk_cat","kissing_cat","scream_cat","crying_cat_face","pouting_cat","palms_up","open_hands","raised_hands","clap","handshake","+1","-1","facepunch","fist","fist_left","fist_right","crossed_fingers","v","love_you","metal","ok_hand","point_left","point_right","point_up","point_down","point_up_2","raised_hand","raised_back_of_hand","raised_hand_with_fingers_splayed","vulcan_salute","wave","call_me_hand","muscle","fu","writing_hand","pray","foot","leg","ring","lipstick","kiss","lips","tooth","tongue","ear","nose","footprints","eye","eyes","brain","speaking_head","bust_in_silhouette","busts_in_silhouette","baby","girl","child","boy","woman","adult","man","blonde_woman","blonde_man","bearded_person","older_woman","older_adult","older_man","man_with_gua_pi_mao","woman_with_headscarf","woman_with_turban","man_with_turban","policewoman","policeman","construction_worker_woman","construction_worker_man","guardswoman","guardsman","female_detective","male_detective","woman_health_worker","man_health_worker","woman_farmer","man_farmer","woman_cook","man_cook","woman_student","man_student","woman_singer","man_singer","woman_teacher","man_teacher","woman_factory_worker","man_factory_worker","woman_technologist","man_technologist","woman_office_worker","man_office_worker","woman_mechanic","man_mechanic","woman_scientist","man_scientist","woman_artist","man_artist","woman_firefighter","man_firefighter","woman_pilot","man_pilot","woman_astronaut","man_astronaut","woman_judge","man_judge","bride_with_veil","man_in_tuxedo","princess","prince","woman_superhero","man_superhero","woman_supervillain","man_supervillain","mrs_claus","santa","sorceress","wizard","woman_elf","man_elf","woman_vampire","man_vampire","woman_zombie","man_zombie","woman_genie","man_genie","mermaid","merman","woman_fairy","man_fairy","angel","pregnant_woman","breastfeeding","bowing_woman","bowing_man","tipping_hand_woman","tipping_hand_man","no_good_woman","no_good_man","ok_woman","ok_man","raising_hand_woman","raising_hand_man","woman_facepalming","man_facepalming","woman_shrugging","man_shrugging","pouting_woman","pouting_man","frowning_woman","frowning_man","haircut_woman","haircut_man","massage_woman","massage_man","woman_in_steamy_room","man_in_steamy_room","nail_care","selfie","dancer","man_dancing","dancing_women","dancing_men","business_suit_levitating","walking_woman","walking_man","running_woman","running_man","couple","two_women_holding_hands","two_men_holding_hands","couple_with_heart_woman_man","couple_with_heart_woman_woman","couple_with_heart_man_man","couplekiss_man_woman","couplekiss_woman_woman","couplekiss_man_man","family_man_woman_boy","family_man_woman_girl","family_man_woman_girl_boy","family_man_woman_boy_boy","family_man_woman_girl_girl","family_woman_woman_boy","family_woman_woman_girl","family_woman_woman_girl_boy","family_woman_woman_boy_boy","family_woman_woman_girl_girl","family_man_man_boy","family_man_man_girl","family_man_man_girl_boy","family_man_man_boy_boy","family_man_man_girl_girl","family_woman_boy","family_woman_girl","family_woman_girl_boy","family_woman_boy_boy","family_woman_girl_girl","family_man_boy","family_man_girl","family_man_girl_boy","family_man_boy_boy","family_man_girl_girl","yarn","thread","coat","labcoat","womans_clothes","tshirt","jeans","necktie","dress","bikini","kimono","flat_shoe","high_heel","sandal","boot","mans_shoe","athletic_shoe","hiking_boot","socks","gloves","scarf","tophat","billed_hat","womans_hat","mortar_board","rescue_worker_helmet","crown","pouch","purse","handbag","briefcase","school_satchel","luggage","eyeglasses","dark_sunglasses","goggles","closed_umbrella","dog","cat","mouse","hamster","rabbit","fox_face","bear","panda_face","koala","tiger","lion","cow","pig","pig_nose","frog","monkey_face","see_no_evil","hear_no_evil","speak_no_evil","monkey","chicken","penguin","bird","baby_chick","hatching_chick","hatched_chick","duck","eagle","owl","bat","wolf","boar","horse","unicorn","honeybee","bug","butterfly","snail","shell","beetle","ant","mosquito","grasshopper","spider","spider_web","scorpion","turtle","snake","lizard","t-rex","sauropod","octopus","squid","shrimp","lobster","crab","blowfish","tropical_fish","fish","dolphin","whale","whale2","shark","crocodile","tiger2","leopard","zebra","gorilla","elephant","hippopotamus","rhinoceros","dromedary_camel","giraffe","kangaroo","camel","water_buffalo","ox","cow2","racehorse","pig2","ram","sheep","llama","goat","deer","dog2","poodle","cat2","rooster","turkey","peacock","parrot","swan","dove","rabbit2","raccoon","badger","rat","mouse2","chipmunk","hedgehog","paw_prints","dragon","dragon_face","cactus","christmas_tree","evergreen_tree","deciduous_tree","palm_tree","seedling","herb","shamrock","four_leaf_clover","bamboo","tanabata_tree","leaves","fallen_leaf","maple_leaf","ear_of_rice","hibiscus","sunflower","rose","wilted_flower","tulip","blossom","cherry_blossom","bouquet","mushroom","earth_americas","earth_africa","earth_asia","full_moon","waning_gibbous_moon","last_quarter_moon","waning_crescent_moon","new_moon","waxing_crescent_moon","first_quarter_moon","waxing_gibbous_moon","new_moon_with_face","full_moon_with_face","first_quarter_moon_with_face","last_quarter_moon_with_face","sun_with_face","crescent_moon","star","star2","dizzy","sparkles","comet","sunny","sun_behind_small_cloud","partly_sunny","sun_behind_large_cloud","sun_behind_rain_cloud","cloud","cloud_with_rain","cloud_with_lightning_and_rain","cloud_with_lightning","zap","fire","boom","snowflake","cloud_with_snow","snowman","snowman_with_snow","wind_face","dash","tornado","fog","open_umbrella","umbrella","droplet","sweat_drops","ocean","green_apple","apple","pear","tangerine","lemon","banana","watermelon","grapes","strawberry","melon","cherries","peach","mango","pineapple","coconut","kiwi_fruit","tomato","eggplant","avocado","broccoli","leafy_greens","cucumber","hot_pepper","corn","carrot","potato","sweet_potato","croissant","bagel","bread","baguette_bread","pretzel","cheese","egg","fried_egg","pancakes","bacon","steak","poultry_leg","meat_on_bone","bone","hotdog","hamburger","fries","pizza","sandwich","stuffed_flatbread","taco","burrito","green_salad","shallow_pan_of_food","canned_food","spaghetti","ramen","stew","curry","sushi","bento","fried_shrimp","rice_ball","rice","rice_cracker","fish_cake","fortune_cookie","moon_cake","oden","dango","shaved_ice","ice_cream","icecream","pie","cupcake","cake","birthday","custard","lollipop","candy","chocolate_bar","popcorn","doughnut","dumpling","cookie","chestnut","peanuts","honey_pot","milk_glass","baby_bottle","coffee","tea","cup_with_straw","sake","beer","beers","clinking_glasses","wine_glass","tumbler_glass","cocktail","tropical_drink","champagne","spoon","fork_and_knife","plate_with_cutlery","bowl_with_spoon","takeout_box","chopsticks","salt","soccer","basketball","football","baseball","softball","tennis","volleyball","rugby_football","flying_disc","8ball","golf","golfing_woman","golfing_man","ping_pong","badminton","goal_net","ice_hockey","field_hockey","lacrosse","cricket","ski","skier","snowboarder","person_fencing","women_wrestling","men_wrestling","woman_cartwheeling","man_cartwheeling","woman_playing_handball","man_playing_handball","ice_skate","curling_stone","skateboard","sled","bow_and_arrow","fishing_pole_and_fish","boxing_glove","martial_arts_uniform","rowing_woman","rowing_man","climbing_woman","climbing_man","swimming_woman","swimming_man","woman_playing_water_polo","man_playing_water_polo","woman_in_lotus_position","man_in_lotus_position","surfing_woman","surfing_man","basketball_woman","basketball_man","weight_lifting_woman","weight_lifting_man","biking_woman","biking_man","mountain_biking_woman","mountain_biking_man","horse_racing","trophy","running_shirt_with_sash","medal_sports","medal_military","1st_place_medal","2nd_place_medal","3rd_place_medal","reminder_ribbon","rosette","ticket","tickets","performing_arts","art","circus_tent","woman_juggling","man_juggling","microphone","headphones","musical_score","musical_keyboard","drum","saxophone","trumpet","guitar","violin","clapper","video_game","dart","game_die","chess_pawn","slot_machine","jigsaw","bowling","red_car","taxi","blue_car","bus","trolleybus","racing_car","police_car","ambulance","fire_engine","minibus","truck","articulated_lorry","tractor","kick_scooter","motorcycle","bike","motor_scooter","rotating_light","oncoming_police_car","oncoming_bus","oncoming_automobile","oncoming_taxi","aerial_tramway","mountain_cableway","suspension_railway","railway_car","train","monorail","bullettrain_side","bullettrain_front","light_rail","mountain_railway","steam_locomotive","train2","metro","tram","station","flying_saucer","helicopter","small_airplane","airplane","flight_departure","flight_arrival","sailboat","motor_boat","speedboat","ferry","passenger_ship","rocket","artificial_satellite","seat","canoe","anchor","construction","fuelpump","busstop","vertical_traffic_light","traffic_light","ship","ferris_wheel","roller_coaster","carousel_horse","building_construction","foggy","tokyo_tower","factory","fountain","rice_scene","mountain","mountain_snow","mount_fuji","volcano","japan","camping","tent","national_park","motorway","railway_track","sunrise","sunrise_over_mountains","desert","beach_umbrella","desert_island","city_sunrise","city_sunset","cityscape","night_with_stars","bridge_at_night","milky_way","stars","sparkler","fireworks","rainbow","houses","european_castle","japanese_castle","stadium","statue_of_liberty","house","house_with_garden","derelict_house","office","department_store","post_office","european_post_office","hospital","bank","hotel","convenience_store","school","love_hotel","wedding","classical_building","church","mosque","synagogue","kaaba","shinto_shrine","watch","iphone","calling","computer","keyboard","desktop_computer","printer","computer_mouse","trackball","joystick","clamp","minidisc","floppy_disk","cd","dvd","vhs","camera","camera_flash","video_camera","movie_camera","film_projector","film_strip","telephone_receiver","phone","pager","fax","tv","radio","studio_microphone","level_slider","control_knobs","compass","stopwatch","timer_clock","alarm_clock","mantelpiece_clock","hourglass_flowing_sand","hourglass","satellite","battery","electric_plug","bulb","flashlight","candle","fire_extinguisher","wastebasket","oil_drum","money_with_wings","dollar","yen","euro","pound","moneybag","credit_card","gem","balance_scale","toolbox","wrench","hammer","hammer_and_pick","hammer_and_wrench","pick","nut_and_bolt","gear","brick","chains","magnet","gun","bomb","firecracker","hocho","dagger","crossed_swords","shield","smoking","coffin","funeral_urn","amphora","crystal_ball","prayer_beads","nazar_amulet","barber","alembic","telescope","microscope","hole","pill","syringe","dna","microbe","petri_dish","test_tube","thermometer","broom","basket","toilet_paper","label","bookmark","toilet","shower","bathtub","bath","soap","sponge","lotion_bottle","key","old_key","couch_and_lamp","sleeping_bed","bed","door","bellhop_bell","teddy_bear","framed_picture","world_map","parasol_on_ground","moyai","shopping","shopping_cart","balloon","flags","ribbon","gift","confetti_ball","tada","dolls","wind_chime","crossed_flags","izakaya_lantern","red_envelope","email","envelope_with_arrow","incoming_envelope","e-mail","love_letter","postbox","mailbox_closed","mailbox","mailbox_with_mail","mailbox_with_no_mail","package","postal_horn","inbox_tray","outbox_tray","scroll","page_with_curl","bookmark_tabs","receipt","bar_chart","chart_with_upwards_trend","chart_with_downwards_trend","page_facing_up","date","calendar","spiral_calendar","card_index","card_file_box","ballot_box","file_cabinet","clipboard","spiral_notepad","file_folder","open_file_folder","card_index_dividers","newspaper_roll","newspaper","notebook","closed_book","green_book","blue_book","orange_book","notebook_with_decorative_cover","ledger","books","open_book","safety_pin","link","paperclip","paperclips","scissors","triangular_ruler","straight_ruler","abacus","pushpin","round_pushpin","closed_lock_with_key","lock","unlock","lock_with_ink_pen","pen","fountain_pen","black_nib","memo","pencil2","crayon","paintbrush","mag","mag_right","heart","orange_heart","yellow_heart","green_heart","blue_heart","purple_heart","black_heart","broken_heart","heavy_heart_exclamation","two_hearts","revolving_hearts","heartbeat","heartpulse","sparkling_heart","cupid","gift_heart","heart_decoration","peace_symbol","latin_cross","star_and_crescent","om","wheel_of_dharma","star_of_david","six_pointed_star","menorah","yin_yang","orthodox_cross","place_of_worship","ophiuchus","aries","taurus","gemini","cancer","leo","virgo","libra","scorpius","sagittarius","capricorn","aquarius","pisces","id","atom_symbol","u7a7a","u5272","radioactive","biohazard","mobile_phone_off","vibration_mode","u6709","u7121","u7533","u55b6","u6708","eight_pointed_black_star","vs","accept","white_flower","ideograph_advantage","secret","congratulations","u5408","u6e80","u7981","a","b","ab","cl","o2","sos","no_entry","name_badge","no_entry_sign","x","o","stop_sign","anger","hotsprings","no_pedestrians","do_not_litter","no_bicycles","non-potable_water","underage","no_mobile_phones","exclamation","grey_exclamation","question","grey_question","bangbang","interrobang","100","low_brightness","high_brightness","trident","fleur_de_lis","part_alternation_mark","warning","children_crossing","beginner","recycle","u6307","chart","sparkle","eight_spoked_asterisk","negative_squared_cross_mark","white_check_mark","diamond_shape_with_a_dot_inside","cyclone","loop","globe_with_meridians","m","atm","zzz","sa","passport_control","customs","baggage_claim","left_luggage","wheelchair","no_smoking","wc","parking","potable_water","mens","womens","baby_symbol","restroom","put_litter_in_its_place","cinema","signal_strength","koko","ng","ok","up","cool","new","free","zero","one","two","three","four","five","six","seven","eight","nine","keycap_ten","asterisk","1234","eject_button","arrow_forward","pause_button","next_track_button","stop_button","record_button","play_or_pause_button","previous_track_button","fast_forward","rewind","twisted_rightwards_arrows","repeat","repeat_one","arrow_backward","arrow_up_small","arrow_down_small","arrow_double_up","arrow_double_down","arrow_right","arrow_left","arrow_up","arrow_down","arrow_upper_right","arrow_lower_right","arrow_lower_left","arrow_upper_left","arrow_up_down","left_right_arrow","arrows_counterclockwise","arrow_right_hook","leftwards_arrow_with_hook","arrow_heading_up","arrow_heading_down","hash","information_source","abc","abcd","capital_abcd","symbols","musical_note","notes","wavy_dash","curly_loop","heavy_check_mark","arrows_clockwise","heavy_plus_sign","heavy_minus_sign","heavy_division_sign","heavy_multiplication_x","infinity","heavy_dollar_sign","currency_exchange","copyright","registered","tm","end","back","on","top","soon","ballot_box_with_check","radio_button","white_circle","black_circle","red_circle","large_blue_circle","small_orange_diamond","small_blue_diamond","large_orange_diamond","large_blue_diamond","small_red_triangle","black_small_square","white_small_square","black_large_square","white_large_square","small_red_triangle_down","black_medium_square","white_medium_square","black_medium_small_square","white_medium_small_square","black_square_button","white_square_button","speaker","sound","loud_sound","mute","mega","loudspeaker","bell","no_bell","black_joker","mahjong","spades","clubs","hearts","diamonds","flower_playing_cards","thought_balloon","right_anger_bubble","speech_balloon","left_speech_bubble","clock1","clock2","clock3","clock4","clock5","clock6","clock7","clock8","clock9","clock10","clock11","clock12","clock130","clock230","clock330","clock430","clock530","clock630","clock730","clock830","clock930","clock1030","clock1130","clock1230","white_flag","black_flag","pirate_flag","checkered_flag","triangular_flag_on_post","rainbow_flag","united_nations","afghanistan","aland_islands","albania","algeria","american_samoa","andorra","angola","anguilla","antarctica","antigua_barbuda","argentina","armenia","aruba","australia","austria","azerbaijan","bahamas","bahrain","bangladesh","barbados","belarus","belgium","belize","benin","bermuda","bhutan","bolivia","caribbean_netherlands","bosnia_herzegovina","botswana","brazil","british_indian_ocean_territory","british_virgin_islands","brunei","bulgaria","burkina_faso","burundi","cape_verde","cambodia","cameroon","canada","canary_islands","cayman_islands","central_african_republic","chad","chile","cn","christmas_island","cocos_islands","colombia","comoros","congo_brazzaville","congo_kinshasa","cook_islands","costa_rica","croatia","cuba","curacao","cyprus","czech_republic","denmark","djibouti","dominica","dominican_republic","ecuador","egypt","el_salvador","equatorial_guinea","eritrea","estonia","ethiopia","eu","falkland_islands","faroe_islands","fiji","finland","fr","french_guiana","french_polynesia","french_southern_territories","gabon","gambia","georgia","de","ghana","gibraltar","greece","greenland","grenada","guadeloupe","guam","guatemala","guernsey","guinea","guinea_bissau","guyana","haiti","honduras","hong_kong","hungary","iceland","india","indonesia","iran","iraq","ireland","isle_of_man","israel","it","cote_divoire","jamaica","jp","jersey","jordan","kazakhstan","kenya","kiribati","kosovo","kuwait","kyrgyzstan","laos","latvia","lebanon","lesotho","liberia","libya","liechtenstein","lithuania","luxembourg","macau","macedonia","madagascar","malawi","malaysia","maldives","mali","malta","marshall_islands","martinique","mauritania","mauritius","mayotte","mexico","micronesia","moldova","monaco","mongolia","montenegro","montserrat","morocco","mozambique","myanmar","namibia","nauru","nepal","netherlands","new_caledonia","new_zealand","nicaragua","niger","nigeria","niue","norfolk_island","northern_mariana_islands","north_korea","norway","oman","pakistan","palau","palestinian_territories","panama","papua_new_guinea","paraguay","peru","philippines","pitcairn_islands","poland","portugal","puerto_rico","qatar","reunion","romania","ru","rwanda","st_barthelemy","st_helena","st_kitts_nevis","st_lucia","st_pierre_miquelon","st_vincent_grenadines","samoa","san_marino","sao_tome_principe","saudi_arabia","senegal","serbia","seychelles","sierra_leone","singapore","sint_maarten","slovakia","slovenia","solomon_islands","somalia","south_africa","south_georgia_south_sandwich_islands","kr","south_sudan","es","sri_lanka","sudan","suriname","swaziland","sweden","switzerland","syria","taiwan","tajikistan","tanzania","thailand","timor_leste","togo","tokelau","tonga","trinidad_tobago","tunisia","tr","turkmenistan","turks_caicos_islands","tuvalu","uganda","ukraine","united_arab_emirates","uk","england","scotland","wales","us","us_virgin_islands","uruguay","uzbekistan","vanuatu","vatican_city","venezuela","vietnam","wallis_futuna","western_sahara","yemen","zambia","zimbabwe"]},function(e,a,r){(function(e,t){var c; /** * @license * Lodash <https://lodash.com/> * Copyright JS Foundation and other contributors <https://js.foundation/> * Released under MIT license <https://lodash.com/license> * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */(function(){var o,n=200,i="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",l="__lodash_hash_undefined__",u=500,d="__lodash_placeholder__",f=1,y=2,p=4,_=1,g=2,h=1,k=2,m=4,w=8,b=16,z=32,v=64,j=128,x=256,q=512,S=30,E="...",C=800,A=16,I=1,O=2,L=1/0,M=9007199254740991,P=1.7976931348623157e308,T=NaN,R=4294967295,N=R-1,B=R>>>1,U=[["ary",j],["bind",h],["bindKey",k],["curry",w],["curryRight",b],["flip",q],["partial",z],["partialRight",v],["rearg",x]],D="[object Arguments]",W="[object Array]",F="[object AsyncFunction]",H="[object Boolean]",$="[object Date]",G="[object DOMException]",Z="[object Error]",V="[object Function]",K="[object GeneratorFunction]",J="[object Map]",Y="[object Number]",X="[object Null]",Q="[object Object]",ee="[object Proxy]",ae="[object RegExp]",re="[object Set]",te="[object String]",ce="[object Symbol]",oe="[object Undefined]",ne="[object WeakMap]",ie="[object WeakSet]",se="[object ArrayBuffer]",le="[object DataView]",ue="[object Float32Array]",de="[object Float64Array]",fe="[object Int8Array]",ye="[object Int16Array]",pe="[object Int32Array]",_e="[object Uint8Array]",ge="[object Uint8ClampedArray]",he="[object Uint16Array]",ke="[object Uint32Array]",me=/\b__p \+= '';/g,we=/\b(__p \+=) '' \+/g,be=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ze=/&(?:amp|lt|gt|quot|#39);/g,ve=/[&<>"']/g,je=RegExp(ze.source),xe=RegExp(ve.source),qe=/<%-([\s\S]+?)%>/g,Se=/<%([\s\S]+?)%>/g,Ee=/<%=([\s\S]+?)%>/g,Ce=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ae=/^\w*$/,Ie=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Oe=/[\\^$.*+?()[\]{}|]/g,Le=RegExp(Oe.source),Me=/^\s+|\s+$/g,Pe=/^\s+/,Te=/\s+$/,Re=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ne=/\{\n\/\* \[wrapped with (.+)\] \*/,Be=/,? & /,Ue=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,De=/\\(\\)?/g,We=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Fe=/\w*$/,He=/^[-+]0x[0-9a-f]+$/i,$e=/^0b[01]+$/i,Ge=/^\[object .+?Constructor\]$/,Ze=/^0o[0-7]+$/i,Ve=/^(?:0|[1-9]\d*)$/,Ke=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Je=/($^)/,Ye=/['\n\r\u2028\u2029\\]/g,Xe="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Qe="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",ea="[\\ud800-\\udfff]",aa="["+Qe+"]",ra="["+Xe+"]",ta="\\d+",ca="[\\u2700-\\u27bf]",oa="[a-z\\xdf-\\xf6\\xf8-\\xff]",na="[^\\ud800-\\udfff"+Qe+ta+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",ia="\\ud83c[\\udffb-\\udfff]",sa="[^\\ud800-\\udfff]",la="(?:\\ud83c[\\udde6-\\uddff]){2}",ua="[\\ud800-\\udbff][\\udc00-\\udfff]",da="[A-Z\\xc0-\\xd6\\xd8-\\xde]",fa="(?:"+oa+"|"+na+")",ya="(?:"+da+"|"+na+")",pa="(?:"+ra+"|"+ia+")"+"?",_a="[\\ufe0e\\ufe0f]?"+pa+("(?:\\u200d(?:"+[sa,la,ua].join("|")+")[\\ufe0e\\ufe0f]?"+pa+")*"),ga="(?:"+[ca,la,ua].join("|")+")"+_a,ha="(?:"+[sa+ra+"?",ra,la,ua,ea].join("|")+")",ka=RegExp("['’]","g"),ma=RegExp(ra,"g"),wa=RegExp(ia+"(?="+ia+")|"+ha+_a,"g"),ba=RegExp([da+"?"+oa+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[aa,da,"$"].join("|")+")",ya+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[aa,da+fa,"$"].join("|")+")",da+"?"+fa+"+(?:['’](?:d|ll|m|re|s|t|ve))?",da+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ta,ga].join("|"),"g"),za=RegExp("[\\u200d\\ud800-\\udfff"+Xe+"\\ufe0e\\ufe0f]"),va=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ja=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],xa=-1,qa={};qa[ue]=qa[de]=qa[fe]=qa[ye]=qa[pe]=qa[_e]=qa[ge]=qa[he]=qa[ke]=!0,qa[D]=qa[W]=qa[se]=qa[H]=qa[le]=qa[$]=qa[Z]=qa[V]=qa[J]=qa[Y]=qa[Q]=qa[ae]=qa[re]=qa[te]=qa[ne]=!1;var Sa={};Sa[D]=Sa[W]=Sa[se]=Sa[le]=Sa[H]=Sa[$]=Sa[ue]=Sa[de]=Sa[fe]=Sa[ye]=Sa[pe]=Sa[J]=Sa[Y]=Sa[Q]=Sa[ae]=Sa[re]=Sa[te]=Sa[ce]=Sa[_e]=Sa[ge]=Sa[he]=Sa[ke]=!0,Sa[Z]=Sa[V]=Sa[ne]=!1;var Ea={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ca=parseFloat,Aa=parseInt,Ia="object"==typeof e&&e&&e.Object===Object&&e,Oa="object"==typeof self&&self&&self.Object===Object&&self,La=Ia||Oa||Function("return this")(),Ma=a&&!a.nodeType&&a,Pa=Ma&&"object"==typeof t&&t&&!t.nodeType&&t,Ta=Pa&&Pa.exports===Ma,Ra=Ta&&Ia.process,Na=function(){try{var e=Pa&&Pa.require&&Pa.require("util").types;return e||Ra&&Ra.binding&&Ra.binding("util")}catch(e){}}(),Ba=Na&&Na.isArrayBuffer,Ua=Na&&Na.isDate,Da=Na&&Na.isMap,Wa=Na&&Na.isRegExp,Fa=Na&&Na.isSet,Ha=Na&&Na.isTypedArray;function $a(e,a,r){switch(r.length){case 0:return e.call(a);case 1:return e.call(a,r[0]);case 2:return e.call(a,r[0],r[1]);case 3:return e.call(a,r[0],r[1],r[2])}return e.apply(a,r)}function Ga(e,a,r,t){for(var c=-1,o=null==e?0:e.length;++c<o;){var n=e[c];a(t,n,r(n),e)}return t}function Za(e,a){for(var r=-1,t=null==e?0:e.length;++r<t&&!1!==a(e[r],r,e););return e}function Va(e,a){for(var r=null==e?0:e.length;r--&&!1!==a(e[r],r,e););return e}function Ka(e,a){for(var r=-1,t=null==e?0:e.length;++r<t;)if(!a(e[r],r,e))return!1;return!0}function Ja(e,a){for(var r=-1,t=null==e?0:e.length,c=0,o=[];++r<t;){var n=e[r];a(n,r,e)&&(o[c++]=n)}return o}function Ya(e,a){return!!(null==e?0:e.length)&&ir(e,a,0)>-1}function Xa(e,a,r){for(var t=-1,c=null==e?0:e.length;++t<c;)if(r(a,e[t]))return!0;return!1}function Qa(e,a){for(var r=-1,t=null==e?0:e.length,c=Array(t);++r<t;)c[r]=a(e[r],r,e);return c}function er(e,a){for(var r=-1,t=a.length,c=e.length;++r<t;)e[c+r]=a[r];return e}function ar(e,a,r,t){var c=-1,o=null==e?0:e.length;for(t&&o&&(r=e[++c]);++c<o;)r=a(r,e[c],c,e);return r}function rr(e,a,r,t){var c=null==e?0:e.length;for(t&&c&&(r=e[--c]);c--;)r=a(r,e[c],c,e);return r}function tr(e,a){for(var r=-1,t=null==e?0:e.length;++r<t;)if(a(e[r],r,e))return!0;return!1}var cr=dr("length");function or(e,a,r){var t;return r(e,function(e,r,c){if(a(e,r,c))return t=r,!1}),t}function nr(e,a,r,t){for(var c=e.length,o=r+(t?1:-1);t?o--:++o<c;)if(a(e[o],o,e))return o;return-1}function ir(e,a,r){return a==a?function(e,a,r){var t=r-1,c=e.length;for(;++t<c;)if(e[t]===a)return t;return-1}(e,a,r):nr(e,lr,r)}function sr(e,a,r,t){for(var c=r-1,o=e.length;++c<o;)if(t(e[c],a))return c;return-1}function lr(e){return e!=e}function ur(e,a){var r=null==e?0:e.length;return r?pr(e,a)/r:T}function dr(e){return function(a){return null==a?o:a[e]}}function fr(e){return function(a){return null==e?o:e[a]}}function yr(e,a,r,t,c){return c(e,function(e,c,o){r=t?(t=!1,e):a(r,e,c,o)}),r}function pr(e,a){for(var r,t=-1,c=e.length;++t<c;){var n=a(e[t]);n!==o&&(r=r===o?n:r+n)}return r}function _r(e,a){for(var r=-1,t=Array(e);++r<e;)t[r]=a(r);return t}function gr(e){return function(a){return e(a)}}function hr(e,a){return Qa(a,function(a){return e[a]})}function kr(e,a){return e.has(a)}function mr(e,a){for(var r=-1,t=e.length;++r<t&&ir(a,e[r],0)>-1;);return r}function wr(e,a){for(var r=e.length;r--&&ir(a,e[r],0)>-1;);return r}var br=fr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),zr=fr({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function vr(e){return"\\"+Ea[e]}function jr(e){return za.test(e)}function xr(e){var a=-1,r=Array(e.size);return e.forEach(function(e,t){r[++a]=[t,e]}),r}function qr(e,a){return function(r){return e(a(r))}}function Sr(e,a){for(var r=-1,t=e.length,c=0,o=[];++r<t;){var n=e[r];n!==a&&n!==d||(e[r]=d,o[c++]=r)}return o}function Er(e){var a=-1,r=Array(e.size);return e.forEach(function(e){r[++a]=e}),r}function Cr(e){var a=-1,r=Array(e.size);return e.forEach(function(e){r[++a]=[e,e]}),r}function Ar(e){return jr(e)?function(e){var a=wa.lastIndex=0;for(;wa.test(e);)++a;return a}(e):cr(e)}function Ir(e){return jr(e)?function(e){return e.match(wa)||[]}(e):function(e){return e.split("")}(e)}var Or=fr({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"});var Lr=function e(a){var r,t=(a=null==a?La:Lr.defaults(La.Object(),a,Lr.pick(La,ja))).Array,c=a.Date,Xe=a.Error,Qe=a.Function,ea=a.Math,aa=a.Object,ra=a.RegExp,ta=a.String,ca=a.TypeError,oa=t.prototype,na=Qe.prototype,ia=aa.prototype,sa=a["__core-js_shared__"],la=na.toString,ua=ia.hasOwnProperty,da=0,fa=(r=/[^.]+$/.exec(sa&&sa.keys&&sa.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",ya=ia.toString,pa=la.call(aa),_a=La._,ga=ra("^"+la.call(ua).replace(Oe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ha=Ta?a.Buffer:o,wa=a.Symbol,za=a.Uint8Array,Ea=ha?ha.allocUnsafe:o,Ia=qr(aa.getPrototypeOf,aa),Oa=aa.create,Ma=ia.propertyIsEnumerable,Pa=oa.splice,Ra=wa?wa.isConcatSpreadable:o,Na=wa?wa.iterator:o,cr=wa?wa.toStringTag:o,fr=function(){try{var e=No(aa,"defineProperty");return e({},"",{}),e}catch(e){}}(),Mr=a.clearTimeout!==La.clearTimeout&&a.clearTimeout,Pr=c&&c.now!==La.Date.now&&c.now,Tr=a.setTimeout!==La.setTimeout&&a.setTimeout,Rr=ea.ceil,Nr=ea.floor,Br=aa.getOwnPropertySymbols,Ur=ha?ha.isBuffer:o,Dr=a.isFinite,Wr=oa.join,Fr=qr(aa.keys,aa),Hr=ea.max,$r=ea.min,Gr=c.now,Zr=a.parseInt,Vr=ea.random,Kr=oa.reverse,Jr=No(a,"DataView"),Yr=No(a,"Map"),Xr=No(a,"Promise"),Qr=No(a,"Set"),et=No(a,"WeakMap"),at=No(aa,"create"),rt=et&&new et,tt={},ct=dn(Jr),ot=dn(Yr),nt=dn(Xr),it=dn(Qr),st=dn(et),lt=wa?wa.prototype:o,ut=lt?lt.valueOf:o,dt=lt?lt.toString:o;function ft(e){if(Ei(e)&&!hi(e)&&!(e instanceof gt)){if(e instanceof _t)return e;if(ua.call(e,"__wrapped__"))return fn(e)}return new _t(e)}var yt=function(){function e(){}return function(a){if(!Si(a))return{};if(Oa)return Oa(a);e.prototype=a;var r=new e;return e.prototype=o,r}}();function pt(){}function _t(e,a){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!a,this.__index__=0,this.__values__=o}function gt(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=R,this.__views__=[]}function ht(e){var a=-1,r=null==e?0:e.length;for(this.clear();++a<r;){var t=e[a];this.set(t[0],t[1])}}function kt(e){var a=-1,r=null==e?0:e.length;for(this.clear();++a<r;){var t=e[a];this.set(t[0],t[1])}}function mt(e){var a=-1,r=null==e?0:e.length;for(this.clear();++a<r;){var t=e[a];this.set(t[0],t[1])}}function wt(e){var a=-1,r=null==e?0:e.length;for(this.__data__=new mt;++a<r;)this.add(e[a])}function bt(e){var a=this.__data__=new kt(e);this.size=a.size}function zt(e,a){var r=hi(e),t=!r&&gi(e),c=!r&&!t&&bi(e),o=!r&&!t&&!c&&Ti(e),n=r||t||c||o,i=n?_r(e.length,ta):[],s=i.length;for(var l in e)!a&&!ua.call(e,l)||n&&("length"==l||c&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||$o(l,s))||i.push(l);return i}function vt(e){var a=e.length;return a?e[wc(0,a-1)]:o}function jt(e,a){return sn(ao(e),Lt(a,0,e.length))}function xt(e){return sn(ao(e))}function qt(e,a,r){(r===o||yi(e[a],r))&&(r!==o||a in e)||It(e,a,r)}function St(e,a,r){var t=e[a];ua.call(e,a)&&yi(t,r)&&(r!==o||a in e)||It(e,a,r)}function Et(e,a){for(var r=e.length;r--;)if(yi(e[r][0],a))return r;return-1}function Ct(e,a,r,t){return Nt(e,function(e,c,o){a(t,e,r(e),o)}),t}function At(e,a){return e&&ro(a,cs(a),e)}function It(e,a,r){"__proto__"==a&&fr?fr(e,a,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[a]=r}function Ot(e,a){for(var r=-1,c=a.length,n=t(c),i=null==e;++r<c;)n[r]=i?o:Qi(e,a[r]);return n}function Lt(e,a,r){return e==e&&(r!==o&&(e=e<=r?e:r),a!==o&&(e=e>=a?e:a)),e}function Mt(e,a,r,t,c,n){var i,s=a&f,l=a&y,u=a&p;if(r&&(i=c?r(e,t,c,n):r(e)),i!==o)return i;if(!Si(e))return e;var d=hi(e);if(d){if(i=function(e){var a=e.length,r=new e.constructor(a);return a&&"string"==typeof e[0]&&ua.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(e),!s)return ao(e,i)}else{var _=Do(e),g=_==V||_==K;if(bi(e))return Kc(e,s);if(_==Q||_==D||g&&!c){if(i=l||g?{}:Fo(e),!s)return l?function(e,a){return ro(e,Uo(e),a)}(e,function(e,a){return e&&ro(a,os(a),e)}(i,e)):function(e,a){return ro(e,Bo(e),a)}(e,At(i,e))}else{if(!Sa[_])return c?e:{};i=function(e,a,r){var t,c,o,n=e.constructor;switch(a){case se:return Jc(e);case H:case $:return new n(+e);case le:return function(e,a){var r=a?Jc(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case ue:case de:case fe:case ye:case pe:case _e:case ge:case he:case ke:return Yc(e,r);case J:return new n;case Y:case te:return new n(e);case ae:return(o=new(c=e).constructor(c.source,Fe.exec(c))).lastIndex=c.lastIndex,o;case re:return new n;case ce:return t=e,ut?aa(ut.call(t)):{}}}(e,_,s)}}n||(n=new bt);var h=n.get(e);if(h)return h;if(n.set(e,i),Li(e))return e.forEach(function(t){i.add(Mt(t,a,r,t,e,n))}),i;if(Ci(e))return e.forEach(function(t,c){i.set(c,Mt(t,a,r,c,e,n))}),i;var k=d?o:(u?l?Io:Ao:l?os:cs)(e);return Za(k||e,function(t,c){k&&(t=e[c=t]),St(i,c,Mt(t,a,r,c,e,n))}),i}function Pt(e,a,r){var t=r.length;if(null==e)return!t;for(e=aa(e);t--;){var c=r[t],n=a[c],i=e[c];if(i===o&&!(c in e)||!n(i))return!1}return!0}function Tt(e,a,r){if("function"!=typeof e)throw new ca(s);return tn(function(){e.apply(o,r)},a)}function Rt(e,a,r,t){var c=-1,o=Ya,i=!0,s=e.length,l=[],u=a.length;if(!s)return l;r&&(a=Qa(a,gr(r))),t?(o=Xa,i=!1):a.length>=n&&(o=kr,i=!1,a=new wt(a));e:for(;++c<s;){var d=e[c],f=null==r?d:r(d);if(d=t||0!==d?d:0,i&&f==f){for(var y=u;y--;)if(a[y]===f)continue e;l.push(d)}else o(a,f,t)||l.push(d)}return l}ft.templateSettings={escape:qe,evaluate:Se,interpolate:Ee,variable:"",imports:{_:ft}},ft.prototype=pt.prototype,ft.prototype.constructor=ft,_t.prototype=yt(pt.prototype),_t.prototype.constructor=_t,gt.prototype=yt(pt.prototype),gt.prototype.constructor=gt,ht.prototype.clear=function(){this.__data__=at?at(null):{},this.size=0},ht.prototype.delete=function(e){var a=this.has(e)&&delete this.__data__[e];return this.size-=a?1:0,a},ht.prototype.get=function(e){var a=this.__data__;if(at){var r=a[e];return r===l?o:r}return ua.call(a,e)?a[e]:o},ht.prototype.has=function(e){var a=this.__data__;return at?a[e]!==o:ua.call(a,e)},ht.prototype.set=function(e,a){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=at&&a===o?l:a,this},kt.prototype.clear=function(){this.__data__=[],this.size=0},kt.prototype.delete=function(e){var a=this.__data__,r=Et(a,e);return!(r<0||(r==a.length-1?a.pop():Pa.call(a,r,1),--this.size,0))},kt.prototype.get=function(e){var a=this.__data__,r=Et(a,e);return r<0?o:a[r][1]},kt.prototype.has=function(e){return Et(this.__data__,e)>-1},kt.prototype.set=function(e,a){var r=this.__data__,t=Et(r,e);return t<0?(++this.size,r.push([e,a])):r[t][1]=a,this},mt.prototype.clear=function(){this.size=0,this.__data__={hash:new ht,map:new(Yr||kt),string:new ht}},mt.prototype.delete=function(e){var a=To(this,e).delete(e);return this.size-=a?1:0,a},mt.prototype.get=function(e){return To(this,e).get(e)},mt.prototype.has=function(e){return To(this,e).has(e)},mt.prototype.set=function(e,a){var r=To(this,e),t=r.size;return r.set(e,a),this.size+=r.size==t?0:1,this},wt.prototype.add=wt.prototype.push=function(e){return this.__data__.set(e,l),this},wt.prototype.has=function(e){return this.__data__.has(e)},bt.prototype.clear=function(){this.__data__=new kt,this.size=0},bt.prototype.delete=function(e){var a=this.__data__,r=a.delete(e);return this.size=a.size,r},bt.prototype.get=function(e){return this.__data__.get(e)},bt.prototype.has=function(e){return this.__data__.has(e)},bt.prototype.set=function(e,a){var r=this.__data__;if(r instanceof kt){var t=r.__data__;if(!Yr||t.length<n-1)return t.push([e,a]),this.size=++r.size,this;r=this.__data__=new mt(t)}return r.set(e,a),this.size=r.size,this};var Nt=oo(Gt),Bt=oo(Zt,!0);function Ut(e,a){var r=!0;return Nt(e,function(e,t,c){return r=!!a(e,t,c)}),r}function Dt(e,a,r){for(var t=-1,c=e.length;++t<c;){var n=e[t],i=a(n);if(null!=i&&(s===o?i==i&&!Pi(i):r(i,s)))var s=i,l=n}return l}function Wt(e,a){var r=[];return Nt(e,function(e,t,c){a(e,t,c)&&r.push(e)}),r}function Ft(e,a,r,t,c){var o=-1,n=e.length;for(r||(r=Ho),c||(c=[]);++o<n;){var i=e[o];a>0&&r(i)?a>1?Ft(i,a-1,r,t,c):er(c,i):t||(c[c.length]=i)}return c}var Ht=no(),$t=no(!0);function Gt(e,a){return e&&Ht(e,a,cs)}function Zt(e,a){return e&&$t(e,a,cs)}function Vt(e,a){return Ja(a,function(a){return ji(e[a])})}function Kt(e,a){for(var r=0,t=(a=$c(a,e)).length;null!=e&&r<t;)e=e[un(a[r++])];return r&&r==t?e:o}function Jt(e,a,r){var t=a(e);return hi(e)?t:er(t,r(e))}function Yt(e){return null==e?e===o?oe:X:cr&&cr in aa(e)?function(e){var a=ua.call(e,cr),r=e[cr];try{e[cr]=o;var t=!0}catch(e){}var c=ya.call(e);return t&&(a?e[cr]=r:delete e[cr]),c}(e):function(e){return ya.call(e)}(e)}function Xt(e,a){return e>a}function Qt(e,a){return null!=e&&ua.call(e,a)}function ec(e,a){return null!=e&&a in aa(e)}function ac(e,a,r){for(var c=r?Xa:Ya,n=e[0].length,i=e.length,s=i,l=t(i),u=1/0,d=[];s--;){var f=e[s];s&&a&&(f=Qa(f,gr(a))),u=$r(f.length,u),l[s]=!r&&(a||n>=120&&f.length>=120)?new wt(s&&f):o}f=e[0];var y=-1,p=l[0];e:for(;++y<n&&d.length<u;){var _=f[y],g=a?a(_):_;if(_=r||0!==_?_:0,!(p?kr(p,g):c(d,g,r))){for(s=i;--s;){var h=l[s];if(!(h?kr(h,g):c(e[s],g,r)))continue e}p&&p.push(g),d.push(_)}}return d}function rc(e,a,r){var t=null==(e=en(e,a=$c(a,e)))?e:e[un(vn(a))];return null==t?o:$a(t,e,r)}function tc(e){return Ei(e)&&Yt(e)==D}function cc(e,a,r,t,c){return e===a||(null==e||null==a||!Ei(e)&&!Ei(a)?e!=e&&a!=a:function(e,a,r,t,c,n){var i=hi(e),s=hi(a),l=i?W:Do(e),u=s?W:Do(a),d=(l=l==D?Q:l)==Q,f=(u=u==D?Q:u)==Q,y=l==u;if(y&&bi(e)){if(!bi(a))return!1;i=!0,d=!1}if(y&&!d)return n||(n=new bt),i||Ti(e)?Eo(e,a,r,t,c,n):function(e,a,r,t,c,o,n){switch(r){case le:if(e.byteLength!=a.byteLength||e.byteOffset!=a.byteOffset)return!1;e=e.buffer,a=a.buffer;case se:return!(e.byteLength!=a.byteLength||!o(new za(e),new za(a)));case H:case $:case Y:return yi(+e,+a);case Z:return e.name==a.name&&e.message==a.message;case ae:case te:return e==a+"";case J:var i=xr;case re:var s=t&_;if(i||(i=Er),e.size!=a.size&&!s)return!1;var l=n.get(e);if(l)return l==a;t|=g,n.set(e,a);var u=Eo(i(e),i(a),t,c,o,n);return n.delete(e),u;case ce:if(ut)return ut.call(e)==ut.call(a)}return!1}(e,a,l,r,t,c,n);if(!(r&_)){var p=d&&ua.call(e,"__wrapped__"),h=f&&ua.call(a,"__wrapped__");if(p||h){var k=p?e.value():e,m=h?a.value():a;return n||(n=new bt),c(k,m,r,t,n)}}return!!y&&(n||(n=new bt),function(e,a,r,t,c,n){var i=r&_,s=Ao(e),l=s.length,u=Ao(a).length;if(l!=u&&!i)return!1;for(var d=l;d--;){var f=s[d];if(!(i?f in a:ua.call(a,f)))return!1}var y=n.get(e);if(y&&n.get(a))return y==a;var p=!0;n.set(e,a),n.set(a,e);for(var g=i;++d<l;){f=s[d];var h=e[f],k=a[f];if(t)var m=i?t(k,h,f,a,e,n):t(h,k,f,e,a,n);if(!(m===o?h===k||c(h,k,r,t,n):m)){p=!1;break}g||(g="constructor"==f)}if(p&&!g){var w=e.constructor,b=a.constructor;w!=b&&"constructor"in e&&"constructor"in a&&!("function"==typeof w&&w instanceof w&&"function"==typeof b&&b instanceof b)&&(p=!1)}return n.delete(e),n.delete(a),p}(e,a,r,t,c,n))}(e,a,r,t,cc,c))}function oc(e,a,r,t){var c=r.length,n=c,i=!t;if(null==e)return!n;for(e=aa(e);c--;){var s=r[c];if(i&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++c<n;){var l=(s=r[c])[0],u=e[l],d=s[1];if(i&&s[2]){if(u===o&&!(l in e))return!1}else{var f=new bt;if(t)var y=t(u,d,l,e,a,f);if(!(y===o?cc(d,u,_|g,t,f):y))return!1}}return!0}function nc(e){return!(!Si(e)||(a=e,fa&&fa in a))&&(ji(e)?ga:Ge).test(dn(e));var a}function ic(e){return"function"==typeof e?e:null==e?As:"object"==typeof e?hi(e)?yc(e[0],e[1]):fc(e):Bs(e)}function sc(e){if(!Jo(e))return Fr(e);var a=[];for(var r in aa(e))ua.call(e,r)&&"constructor"!=r&&a.push(r);return a}function lc(e){if(!Si(e))return function(e){var a=[];if(null!=e)for(var r in aa(e))a.push(r);return a}(e);var a=Jo(e),r=[];for(var t in e)("constructor"!=t||!a&&ua.call(e,t))&&r.push(t);return r}function uc(e,a){return e<a}function dc(e,a){var r=-1,c=mi(e)?t(e.length):[];return Nt(e,function(e,t,o){c[++r]=a(e,t,o)}),c}function fc(e){var a=Ro(e);return 1==a.length&&a[0][2]?Xo(a[0][0],a[0][1]):function(r){return r===e||oc(r,e,a)}}function yc(e,a){return Zo(e)&&Yo(a)?Xo(un(e),a):function(r){var t=Qi(r,e);return t===o&&t===a?es(r,e):cc(a,t,_|g)}}function pc(e,a,r,t,c){e!==a&&Ht(a,function(n,i){if(Si(n))c||(c=new bt),function(e,a,r,t,c,n,i){var s=an(e,r),l=an(a,r),u=i.get(l);if(u)qt(e,r,u);else{var d=n?n(s,l,r+"",e,a,i):o,f=d===o;if(f){var y=hi(l),p=!y&&bi(l),_=!y&&!p&&Ti(l);d=l,y||p||_?hi(s)?d=s:wi(s)?d=ao(s):p?(f=!1,d=Kc(l,!0)):_?(f=!1,d=Yc(l,!0)):d=[]:Ii(l)||gi(l)?(d=s,gi(s)?d=Hi(s):Si(s)&&!ji(s)||(d=Fo(l))):f=!1}f&&(i.set(l,d),c(d,l,t,n,i),i.delete(l)),qt(e,r,d)}}(e,a,i,r,pc,t,c);else{var s=t?t(an(e,i),n,i+"",e,a,c):o;s===o&&(s=n),qt(e,i,s)}},os)}function _c(e,a){var r=e.length;if(r)return $o(a+=a<0?r:0,r)?e[a]:o}function gc(e,a,r){var t=-1;return a=Qa(a.length?a:[As],gr(Po())),function(e,a){var r=e.length;for(e.sort(a);r--;)e[r]=e[r].value;return e}(dc(e,function(e,r,c){return{criteria:Qa(a,function(a){return a(e)}),index:++t,value:e}}),function(e,a){return function(e,a,r){for(var t=-1,c=e.criteria,o=a.criteria,n=c.length,i=r.length;++t<n;){var s=Xc(c[t],o[t]);if(s){if(t>=i)return s;var l=r[t];return s*("desc"==l?-1:1)}}return e.index-a.index}(e,a,r)})}function hc(e,a,r){for(var t=-1,c=a.length,o={};++t<c;){var n=a[t],i=Kt(e,n);r(i,n)&&xc(o,$c(n,e),i)}return o}function kc(e,a,r,t){var c=t?sr:ir,o=-1,n=a.length,i=e;for(e===a&&(a=ao(a)),r&&(i=Qa(e,gr(r)));++o<n;)for(var s=0,l=a[o],u=r?r(l):l;(s=c(i,u,s,t))>-1;)i!==e&&Pa.call(i,s,1),Pa.call(e,s,1);return e}function mc(e,a){for(var r=e?a.length:0,t=r-1;r--;){var c=a[r];if(r==t||c!==o){var o=c;$o(c)?Pa.call(e,c,1):Rc(e,c)}}return e}function wc(e,a){return e+Nr(Vr()*(a-e+1))}function bc(e,a){var r="";if(!e||a<1||a>M)return r;do{a%2&&(r+=e),(a=Nr(a/2))&&(e+=e)}while(a);return r}function zc(e,a){return cn(Qo(e,a,As),e+"")}function vc(e){return vt(ys(e))}function jc(e,a){var r=ys(e);return sn(r,Lt(a,0,r.length))}function xc(e,a,r,t){if(!Si(e))return e;for(var c=-1,n=(a=$c(a,e)).length,i=n-1,s=e;null!=s&&++c<n;){var l=un(a[c]),u=r;if(c!=i){var d=s[l];(u=t?t(d,l,s):o)===o&&(u=Si(d)?d:$o(a[c+1])?[]:{})}St(s,l,u),s=s[l]}return e}var qc=rt?function(e,a){return rt.set(e,a),e}:As,Sc=fr?function(e,a){return fr(e,"toString",{configurable:!0,enumerable:!1,value:Ss(a),writable:!0})}:As;function Ec(e){return sn(ys(e))}function Cc(e,a,r){var c=-1,o=e.length;a<0&&(a=-a>o?0:o+a),(r=r>o?o:r)<0&&(r+=o),o=a>r?0:r-a>>>0,a>>>=0;for(var n=t(o);++c<o;)n[c]=e[c+a];return n}function Ac(e,a){var r;return Nt(e,function(e,t,c){return!(r=a(e,t,c))}),!!r}function Ic(e,a,r){var t=0,c=null==e?t:e.length;if("number"==typeof a&&a==a&&c<=B){for(;t<c;){var o=t+c>>>1,n=e[o];null!==n&&!Pi(n)&&(r?n<=a:n<a)?t=o+1:c=o}return c}return Oc(e,a,As,r)}function Oc(e,a,r,t){a=r(a);for(var c=0,n=null==e?0:e.length,i=a!=a,s=null===a,l=Pi(a),u=a===o;c<n;){var d=Nr((c+n)/2),f=r(e[d]),y=f!==o,p=null===f,_=f==f,g=Pi(f);if(i)var h=t||_;else h=u?_&&(t||y):s?_&&y&&(t||!p):l?_&&y&&!p&&(t||!g):!p&&!g&&(t?f<=a:f<a);h?c=d+1:n=d}return $r(n,N)}function Lc(e,a){for(var r=-1,t=e.length,c=0,o=[];++r<t;){var n=e[r],i=a?a(n):n;if(!r||!yi(i,s)){var s=i;o[c++]=0===n?0:n}}return o}function Mc(e){return"number"==typeof e?e:Pi(e)?T:+e}function Pc(e){if("string"==typeof e)return e;if(hi(e))return Qa(e,Pc)+"";if(Pi(e))return dt?dt.call(e):"";var a=e+"";return"0"==a&&1/e==-L?"-0":a}function Tc(e,a,r){var t=-1,c=Ya,o=e.length,i=!0,s=[],l=s;if(r)i=!1,c=Xa;else if(o>=n){var u=a?null:zo(e);if(u)return Er(u);i=!1,c=kr,l=new wt}else l=a?[]:s;e:for(;++t<o;){var d=e[t],f=a?a(d):d;if(d=r||0!==d?d:0,i&&f==f){for(var y=l.length;y--;)if(l[y]===f)continue e;a&&l.push(f),s.push(d)}else c(l,f,r)||(l!==s&&l.push(f),s.push(d))}return s}function Rc(e,a){return null==(e=en(e,a=$c(a,e)))||delete e[un(vn(a))]}function Nc(e,a,r,t){return xc(e,a,r(Kt(e,a)),t)}function Bc(e,a,r,t){for(var c=e.length,o=t?c:-1;(t?o--:++o<c)&&a(e[o],o,e););return r?Cc(e,t?0:o,t?o+1:c):Cc(e,t?o+1:0,t?c:o)}function Uc(e,a){var r=e;return r instanceof gt&&(r=r.value()),ar(a,function(e,a){return a.func.apply(a.thisArg,er([e],a.args))},r)}function Dc(e,a,r){var c=e.length;if(c<2)return c?Tc(e[0]):[];for(var o=-1,n=t(c);++o<c;)for(var i=e[o],s=-1;++s<c;)s!=o&&(n[o]=Rt(n[o]||i,e[s],a,r));return Tc(Ft(n,1),a,r)}function Wc(e,a,r){for(var t=-1,c=e.length,n=a.length,i={};++t<c;){var s=t<n?a[t]:o;r(i,e[t],s)}return i}function Fc(e){return wi(e)?e:[]}function Hc(e){return"function"==typeof e?e:As}function $c(e,a){return hi(e)?e:Zo(e,a)?[e]:ln($i(e))}var Gc=zc;function Zc(e,a,r){var t=e.length;return r=r===o?t:r,!a&&r>=t?e:Cc(e,a,r)}var Vc=Mr||function(e){return La.clearTimeout(e)};function Kc(e,a){if(a)return e.slice();var r=e.length,t=Ea?Ea(r):new e.constructor(r);return e.copy(t),t}function Jc(e){var a=new e.constructor(e.byteLength);return new za(a).set(new za(e)),a}function Yc(e,a){var r=a?Jc(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function Xc(e,a){if(e!==a){var r=e!==o,t=null===e,c=e==e,n=Pi(e),i=a!==o,s=null===a,l=a==a,u=Pi(a);if(!s&&!u&&!n&&e>a||n&&i&&l&&!s&&!u||t&&i&&l||!r&&l||!c)return 1;if(!t&&!n&&!u&&e<a||u&&r&&c&&!t&&!n||s&&r&&c||!i&&c||!l)return-1}return 0}function Qc(e,a,r,c){for(var o=-1,n=e.length,i=r.length,s=-1,l=a.length,u=Hr(n-i,0),d=t(l+u),f=!c;++s<l;)d[s]=a[s];for(;++o<i;)(f||o<n)&&(d[r[o]]=e[o]);for(;u--;)d[s++]=e[o++];return d}function eo(e,a,r,c){for(var o=-1,n=e.length,i=-1,s=r.length,l=-1,u=a.length,d=Hr(n-s,0),f=t(d+u),y=!c;++o<d;)f[o]=e[o];for(var p=o;++l<u;)f[p+l]=a[l];for(;++i<s;)(y||o<n)&&(f[p+r[i]]=e[o++]);return f}function ao(e,a){var r=-1,c=e.length;for(a||(a=t(c));++r<c;)a[r]=e[r];return a}function ro(e,a,r,t){var c=!r;r||(r={});for(var n=-1,i=a.length;++n<i;){var s=a[n],l=t?t(r[s],e[s],s,r,e):o;l===o&&(l=e[s]),c?It(r,s,l):St(r,s,l)}return r}function to(e,a){return function(r,t){var c=hi(r)?Ga:Ct,o=a?a():{};return c(r,e,Po(t,2),o)}}function co(e){return zc(function(a,r){var t=-1,c=r.length,n=c>1?r[c-1]:o,i=c>2?r[2]:o;for(n=e.length>3&&"function"==typeof n?(c--,n):o,i&&Go(r[0],r[1],i)&&(n=c<3?o:n,c=1),a=aa(a);++t<c;){var s=r[t];s&&e(a,s,t,n)}return a})}function oo(e,a){return function(r,t){if(null==r)return r;if(!mi(r))return e(r,t);for(var c=r.length,o=a?c:-1,n=aa(r);(a?o--:++o<c)&&!1!==t(n[o],o,n););return r}}function no(e){return function(a,r,t){for(var c=-1,o=aa(a),n=t(a),i=n.length;i--;){var s=n[e?i:++c];if(!1===r(o[s],s,o))break}return a}}function io(e){return function(a){var r=jr(a=$i(a))?Ir(a):o,t=r?r[0]:a.charAt(0),c=r?Zc(r,1).join(""):a.slice(1);return t[e]()+c}}function so(e){return function(a){return ar(js(gs(a).replace(ka,"")),e,"")}}function lo(e){return function(){var a=arguments;switch(a.length){case 0:return new e;case 1:return new e(a[0]);case 2:return new e(a[0],a[1]);case 3:return new e(a[0],a[1],a[2]);case 4:return new e(a[0],a[1],a[2],a[3]);case 5:return new e(a[0],a[1],a[2],a[3],a[4]);case 6:return new e(a[0],a[1],a[2],a[3],a[4],a[5]);case 7:return new e(a[0],a[1],a[2],a[3],a[4],a[5],a[6])}var r=yt(e.prototype),t=e.apply(r,a);return Si(t)?t:r}}function uo(e){return function(a,r,t){var c=aa(a);if(!mi(a)){var n=Po(r,3);a=cs(a),r=function(e){return n(c[e],e,c)}}var i=e(a,r,t);return i>-1?c[n?a[i]:i]:o}}function fo(e){return Co(function(a){var r=a.length,t=r,c=_t.prototype.thru;for(e&&a.reverse();t--;){var n=a[t];if("function"!=typeof n)throw new ca(s);if(c&&!i&&"wrapper"==Lo(n))var i=new _t([],!0)}for(t=i?t:r;++t<r;){var l=Lo(n=a[t]),u="wrapper"==l?Oo(n):o;i=u&&Vo(u[0])&&u[1]==(j|w|z|x)&&!u[4].length&&1==u[9]?i[Lo(u[0])].apply(i,u[3]):1==n.length&&Vo(n)?i[l]():i.thru(n)}return function(){var e=arguments,t=e[0];if(i&&1==e.length&&hi(t))return i.plant(t).value();for(var c=0,o=r?a[c].apply(this,e):t;++c<r;)o=a[c].call(this,o);return o}})}function yo(e,a,r,c,n,i,s,l,u,d){var f=a&j,y=a&h,p=a&k,_=a&(w|b),g=a&q,m=p?o:lo(e);return function h(){for(var k=arguments.length,w=t(k),b=k;b--;)w[b]=arguments[b];if(_)var z=Mo(h),v=function(e,a){for(var r=e.length,t=0;r--;)e[r]===a&&++t;return t}(w,z);if(c&&(w=Qc(w,c,n,_)),i&&(w=eo(w,i,s,_)),k-=v,_&&k<d){var j=Sr(w,z);return wo(e,a,yo,h.placeholder,r,w,j,l,u,d-k)}var x=y?r:this,q=p?x[e]:e;return k=w.length,l?w=function(e,a){for(var r=e.length,t=$r(a.length,r),c=ao(e);t--;){var n=a[t];e[t]=$o(n,r)?c[n]:o}return e}(w,l):g&&k>1&&w.reverse(),f&&u<k&&(w.length=u),this&&this!==La&&this instanceof h&&(q=m||lo(q)),q.apply(x,w)}}function po(e,a){return function(r,t){return function(e,a,r,t){return Gt(e,function(e,c,o){a(t,r(e),c,o)}),t}(r,e,a(t),{})}}function _o(e,a){return function(r,t){var c;if(r===o&&t===o)return a;if(r!==o&&(c=r),t!==o){if(c===o)return t;"string"==typeof r||"string"==typeof t?(r=Pc(r),t=Pc(t)):(r=Mc(r),t=Mc(t)),c=e(r,t)}return c}}function go(e){return Co(function(a){return a=Qa(a,gr(Po())),zc(function(r){var t=this;return e(a,function(e){return $a(e,t,r)})})})}function ho(e,a){var r=(a=a===o?" ":Pc(a)).length;if(r<2)return r?bc(a,e):a;var t=bc(a,Rr(e/Ar(a)));return jr(a)?Zc(Ir(t),0,e).join(""):t.slice(0,e)}function ko(e){return function(a,r,c){return c&&"number"!=typeof c&&Go(a,r,c)&&(r=c=o),a=Ui(a),r===o?(r=a,a=0):r=Ui(r),function(e,a,r,c){for(var o=-1,n=Hr(Rr((a-e)/(r||1)),0),i=t(n);n--;)i[c?n:++o]=e,e+=r;return i}(a,r,c=c===o?a<r?1:-1:Ui(c),e)}}function mo(e){return function(a,r){return"string"==typeof a&&"string"==typeof r||(a=Fi(a),r=Fi(r)),e(a,r)}}function wo(e,a,r,t,c,n,i,s,l,u){var d=a&w;a|=d?z:v,(a&=~(d?v:z))&m||(a&=~(h|k));var f=[e,a,c,d?n:o,d?i:o,d?o:n,d?o:i,s,l,u],y=r.apply(o,f);return Vo(e)&&rn(y,f),y.placeholder=t,on(y,e,a)}function bo(e){var a=ea[e];return function(e,r){if(e=Fi(e),r=null==r?0:$r(Di(r),292)){var t=($i(e)+"e").split("e");return+((t=($i(a(t[0]+"e"+(+t[1]+r)))+"e").split("e"))[0]+"e"+(+t[1]-r))}return a(e)}}var zo=Qr&&1/Er(new Qr([,-0]))[1]==L?function(e){return new Qr(e)}:Ps;function vo(e){return function(a){var r=Do(a);return r==J?xr(a):r==re?Cr(a):function(e,a){return Qa(a,function(a){return[a,e[a]]})}(a,e(a))}}function jo(e,a,r,c,n,i,l,u){var f=a&k;if(!f&&"function"!=typeof e)throw new ca(s);var y=c?c.length:0;if(y||(a&=~(z|v),c=n=o),l=l===o?l:Hr(Di(l),0),u=u===o?u:Di(u),y-=n?n.length:0,a&v){var p=c,_=n;c=n=o}var g=f?o:Oo(e),q=[e,a,r,c,n,p,_,i,l,u];if(g&&function(e,a){var r=e[1],t=a[1],c=r|t,o=c<(h|k|j),n=t==j&&r==w||t==j&&r==x&&e[7].length<=a[8]||t==(j|x)&&a[7].length<=a[8]&&r==w;if(!o&&!n)return e;t&h&&(e[2]=a[2],c|=r&h?0:m);var i=a[3];if(i){var s=e[3];e[3]=s?Qc(s,i,a[4]):i,e[4]=s?Sr(e[3],d):a[4]}(i=a[5])&&(s=e[5],e[5]=s?eo(s,i,a[6]):i,e[6]=s?Sr(e[5],d):a[6]),(i=a[7])&&(e[7]=i),t&j&&(e[8]=null==e[8]?a[8]:$r(e[8],a[8])),null==e[9]&&(e[9]=a[9]),e[0]=a[0],e[1]=c}(q,g),e=q[0],a=q[1],r=q[2],c=q[3],n=q[4],!(u=q[9]=q[9]===o?f?0:e.length:Hr(q[9]-y,0))&&a&(w|b)&&(a&=~(w|b)),a&&a!=h)S=a==w||a==b?function(e,a,r){var c=lo(e);return function n(){for(var i=arguments.length,s=t(i),l=i,u=Mo(n);l--;)s[l]=arguments[l];var d=i<3&&s[0]!==u&&s[i-1]!==u?[]:Sr(s,u);return(i-=d.length)<r?wo(e,a,yo,n.placeholder,o,s,d,o,o,r-i):$a(this&&this!==La&&this instanceof n?c:e,this,s)}}(e,a,u):a!=z&&a!=(h|z)||n.length?yo.apply(o,q):function(e,a,r,c){var o=a&h,n=lo(e);return function a(){for(var i=-1,s=arguments.length,l=-1,u=c.length,d=t(u+s),f=this&&this!==La&&this instanceof a?n:e;++l<u;)d[l]=c[l];for(;s--;)d[l++]=arguments[++i];return $a(f,o?r:this,d)}}(e,a,r,c);else var S=function(e,a,r){var t=a&h,c=lo(e);return function a(){return(this&&this!==La&&this instanceof a?c:e).apply(t?r:this,arguments)}}(e,a,r);return on((g?qc:rn)(S,q),e,a)}function xo(e,a,r,t){return e===o||yi(e,ia[r])&&!ua.call(t,r)?a:e}function qo(e,a,r,t,c,n){return Si(e)&&Si(a)&&(n.set(a,e),pc(e,a,o,qo,n),n.delete(a)),e}function So(e){return Ii(e)?o:e}function Eo(e,a,r,t,c,n){var i=r&_,s=e.length,l=a.length;if(s!=l&&!(i&&l>s))return!1;var u=n.get(e);if(u&&n.get(a))return u==a;var d=-1,f=!0,y=r&g?new wt:o;for(n.set(e,a),n.set(a,e);++d<s;){var p=e[d],h=a[d];if(t)var k=i?t(h,p,d,a,e,n):t(p,h,d,e,a,n);if(k!==o){if(k)continue;f=!1;break}if(y){if(!tr(a,function(e,a){if(!kr(y,a)&&(p===e||c(p,e,r,t,n)))return y.push(a)})){f=!1;break}}else if(p!==h&&!c(p,h,r,t,n)){f=!1;break}}return n.delete(e),n.delete(a),f}function Co(e){return cn(Qo(e,o,kn),e+"")}function Ao(e){return Jt(e,cs,Bo)}function Io(e){return Jt(e,os,Uo)}var Oo=rt?function(e){return rt.get(e)}:Ps;function Lo(e){for(var a=e.name+"",r=tt[a],t=ua.call(tt,a)?r.length:0;t--;){var c=r[t],o=c.func;if(null==o||o==e)return c.name}return a}function Mo(e){return(ua.call(ft,"placeholder")?ft:e).placeholder}function Po(){var e=ft.iteratee||Is;return e=e===Is?ic:e,arguments.length?e(arguments[0],arguments[1]):e}function To(e,a){var r,t,c=e.__data__;return("string"==(t=typeof(r=a))||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==r:null===r)?c["string"==typeof a?"string":"hash"]:c.map}function Ro(e){for(var a=cs(e),r=a.length;r--;){var t=a[r],c=e[t];a[r]=[t,c,Yo(c)]}return a}function No(e,a){var r=function(e,a){return null==e?o:e[a]}(e,a);return nc(r)?r:o}var Bo=Br?function(e){return null==e?[]:(e=aa(e),Ja(Br(e),function(a){return Ma.call(e,a)}))}:Ws,Uo=Br?function(e){for(var a=[];e;)er(a,Bo(e)),e=Ia(e);return a}:Ws,Do=Yt;function Wo(e,a,r){for(var t=-1,c=(a=$c(a,e)).length,o=!1;++t<c;){var n=un(a[t]);if(!(o=null!=e&&r(e,n)))break;e=e[n]}return o||++t!=c?o:!!(c=null==e?0:e.length)&&qi(c)&&$o(n,c)&&(hi(e)||gi(e))}function Fo(e){return"function"!=typeof e.constructor||Jo(e)?{}:yt(Ia(e))}function Ho(e){return hi(e)||gi(e)||!!(Ra&&e&&e[Ra])}function $o(e,a){var r=typeof e;return!!(a=null==a?M:a)&&("number"==r||"symbol"!=r&&Ve.test(e))&&e>-1&&e%1==0&&e<a}function Go(e,a,r){if(!Si(r))return!1;var t=typeof a;return!!("number"==t?mi(r)&&$o(a,r.length):"string"==t&&a in r)&&yi(r[a],e)}function Zo(e,a){if(hi(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!Pi(e))||Ae.test(e)||!Ce.test(e)||null!=a&&e in aa(a)}function Vo(e){var a=Lo(e),r=ft[a];if("function"!=typeof r||!(a in gt.prototype))return!1;if(e===r)return!0;var t=Oo(r);return!!t&&e===t[0]}(Jr&&Do(new Jr(new ArrayBuffer(1)))!=le||Yr&&Do(new Yr)!=J||Xr&&"[object Promise]"!=Do(Xr.resolve())||Qr&&Do(new Qr)!=re||et&&Do(new et)!=ne)&&(Do=function(e){var a=Yt(e),r=a==Q?e.constructor:o,t=r?dn(r):"";if(t)switch(t){case ct:return le;case ot:return J;case nt:return"[object Promise]";case it:return re;case st:return ne}return a});var Ko=sa?ji:Fs;function Jo(e){var a=e&&e.constructor;return e===("function"==typeof a&&a.prototype||ia)}function Yo(e){return e==e&&!Si(e)}function Xo(e,a){return function(r){return null!=r&&r[e]===a&&(a!==o||e in aa(r))}}function Qo(e,a,r){return a=Hr(a===o?e.length-1:a,0),function(){for(var c=arguments,o=-1,n=Hr(c.length-a,0),i=t(n);++o<n;)i[o]=c[a+o];o=-1;for(var s=t(a+1);++o<a;)s[o]=c[o];return s[a]=r(i),$a(e,this,s)}}function en(e,a){return a.length<2?e:Kt(e,Cc(a,0,-1))}function an(e,a){if("__proto__"!=a)return e[a]}var rn=nn(qc),tn=Tr||function(e,a){return La.setTimeout(e,a)},cn=nn(Sc);function on(e,a,r){var t=a+"";return cn(e,function(e,a){var r=a.length;if(!r)return e;var t=r-1;return a[t]=(r>1?"& ":"")+a[t],a=a.join(r>2?", ":" "),e.replace(Re,"{\n/* [wrapped with "+a+"] */\n")}(t,function(e,a){return Za(U,function(r){var t="_."+r[0];a&r[1]&&!Ya(e,t)&&e.push(t)}),e.sort()}(function(e){var a=e.match(Ne);return a?a[1].split(Be):[]}(t),r)))}function nn(e){var a=0,r=0;return function(){var t=Gr(),c=A-(t-r);if(r=t,c>0){if(++a>=C)return arguments[0]}else a=0;return e.apply(o,arguments)}}function sn(e,a){var r=-1,t=e.length,c=t-1;for(a=a===o?t:a;++r<a;){var n=wc(r,c),i=e[n];e[n]=e[r],e[r]=i}return e.length=a,e}var ln=function(e){var a=ii(e,function(e){return r.size===u&&r.clear(),e}),r=a.cache;return a}(function(e){var a=[];return 46===e.charCodeAt(0)&&a.push(""),e.replace(Ie,function(e,r,t,c){a.push(t?c.replace(De,"$1"):r||e)}),a});function un(e){if("string"==typeof e||Pi(e))return e;var a=e+"";return"0"==a&&1/e==-L?"-0":a}function dn(e){if(null!=e){try{return la.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function fn(e){if(e instanceof gt)return e.clone();var a=new _t(e.__wrapped__,e.__chain__);return a.__actions__=ao(e.__actions__),a.__index__=e.__index__,a.__values__=e.__values__,a}var yn=zc(function(e,a){return wi(e)?Rt(e,Ft(a,1,wi,!0)):[]}),pn=zc(function(e,a){var r=vn(a);return wi(r)&&(r=o),wi(e)?Rt(e,Ft(a,1,wi,!0),Po(r,2)):[]}),_n=zc(function(e,a){var r=vn(a);return wi(r)&&(r=o),wi(e)?Rt(e,Ft(a,1,wi,!0),o,r):[]});function gn(e,a,r){var t=null==e?0:e.length;if(!t)return-1;var c=null==r?0:Di(r);return c<0&&(c=Hr(t+c,0)),nr(e,Po(a,3),c)}function hn(e,a,r){var t=null==e?0:e.length;if(!t)return-1;var c=t-1;return r!==o&&(c=Di(r),c=r<0?Hr(t+c,0):$r(c,t-1)),nr(e,Po(a,3),c,!0)}function kn(e){return null!=e&&e.length?Ft(e,1):[]}function mn(e){return e&&e.length?e[0]:o}var wn=zc(function(e){var a=Qa(e,Fc);return a.length&&a[0]===e[0]?ac(a):[]}),bn=zc(function(e){var a=vn(e),r=Qa(e,Fc);return a===vn(r)?a=o:r.pop(),r.length&&r[0]===e[0]?ac(r,Po(a,2)):[]}),zn=zc(function(e){var a=vn(e),r=Qa(e,Fc);return(a="function"==typeof a?a:o)&&r.pop(),r.length&&r[0]===e[0]?ac(r,o,a):[]});function vn(e){var a=null==e?0:e.length;return a?e[a-1]:o}var jn=zc(xn);function xn(e,a){return e&&e.length&&a&&a.length?kc(e,a):e}var qn=Co(function(e,a){var r=null==e?0:e.length,t=Ot(e,a);return mc(e,Qa(a,function(e){return $o(e,r)?+e:e}).sort(Xc)),t});function Sn(e){return null==e?e:Kr.call(e)}var En=zc(function(e){return Tc(Ft(e,1,wi,!0))}),Cn=zc(function(e){var a=vn(e);return wi(a)&&(a=o),Tc(Ft(e,1,wi,!0),Po(a,2))}),An=zc(function(e){var a=vn(e);return a="function"==typeof a?a:o,Tc(Ft(e,1,wi,!0),o,a)});function In(e){if(!e||!e.length)return[];var a=0;return e=Ja(e,function(e){if(wi(e))return a=Hr(e.length,a),!0}),_r(a,function(a){return Qa(e,dr(a))})}function On(e,a){if(!e||!e.length)return[];var r=In(e);return null==a?r:Qa(r,function(e){return $a(a,o,e)})}var Ln=zc(function(e,a){return wi(e)?Rt(e,a):[]}),Mn=zc(function(e){return Dc(Ja(e,wi))}),Pn=zc(function(e){var a=vn(e);return wi(a)&&(a=o),Dc(Ja(e,wi),Po(a,2))}),Tn=zc(function(e){var a=vn(e);return a="function"==typeof a?a:o,Dc(Ja(e,wi),o,a)}),Rn=zc(In);var Nn=zc(function(e){var a=e.length,r=a>1?e[a-1]:o;return r="function"==typeof r?(e.pop(),r):o,On(e,r)});function Bn(e){var a=ft(e);return a.__chain__=!0,a}function Un(e,a){return a(e)}var Dn=Co(function(e){var a=e.length,r=a?e[0]:0,t=this.__wrapped__,c=function(a){return Ot(a,e)};return!(a>1||this.__actions__.length)&&t instanceof gt&&$o(r)?((t=t.slice(r,+r+(a?1:0))).__actions__.push({func:Un,args:[c],thisArg:o}),new _t(t,this.__chain__).thru(function(e){return a&&!e.length&&e.push(o),e})):this.thru(c)});var Wn=to(function(e,a,r){ua.call(e,r)?++e[r]:It(e,r,1)});var Fn=uo(gn),Hn=uo(hn);function $n(e,a){return(hi(e)?Za:Nt)(e,Po(a,3))}function Gn(e,a){return(hi(e)?Va:Bt)(e,Po(a,3))}var Zn=to(function(e,a,r){ua.call(e,r)?e[r].push(a):It(e,r,[a])});var Vn=zc(function(e,a,r){var c=-1,o="function"==typeof a,n=mi(e)?t(e.length):[];return Nt(e,function(e){n[++c]=o?$a(a,e,r):rc(e,a,r)}),n}),Kn=to(function(e,a,r){It(e,r,a)});function Jn(e,a){return(hi(e)?Qa:dc)(e,Po(a,3))}var Yn=to(function(e,a,r){e[r?0:1].push(a)},function(){return[[],[]]});var Xn=zc(function(e,a){if(null==e)return[];var r=a.length;return r>1&&Go(e,a[0],a[1])?a=[]:r>2&&Go(a[0],a[1],a[2])&&(a=[a[0]]),gc(e,Ft(a,1),[])}),Qn=Pr||function(){return La.Date.now()};function ei(e,a,r){return a=r?o:a,a=e&&null==a?e.length:a,jo(e,j,o,o,o,o,a)}function ai(e,a){var r;if("function"!=typeof a)throw new ca(s);return e=Di(e),function(){return--e>0&&(r=a.apply(this,arguments)),e<=1&&(a=o),r}}var ri=zc(function(e,a,r){var t=h;if(r.length){var c=Sr(r,Mo(ri));t|=z}return jo(e,t,a,r,c)}),ti=zc(function(e,a,r){var t=h|k;if(r.length){var c=Sr(r,Mo(ti));t|=z}return jo(a,t,e,r,c)});function ci(e,a,r){var t,c,n,i,l,u,d=0,f=!1,y=!1,p=!0;if("function"!=typeof e)throw new ca(s);function _(a){var r=t,n=c;return t=c=o,d=a,i=e.apply(n,r)}function g(e){var r=e-u;return u===o||r>=a||r<0||y&&e-d>=n}function h(){var e=Qn();if(g(e))return k(e);l=tn(h,function(e){var r=a-(e-u);return y?$r(r,n-(e-d)):r}(e))}function k(e){return l=o,p&&t?_(e):(t=c=o,i)}function m(){var e=Qn(),r=g(e);if(t=arguments,c=this,u=e,r){if(l===o)return function(e){return d=e,l=tn(h,a),f?_(e):i}(u);if(y)return l=tn(h,a),_(u)}return l===o&&(l=tn(h,a)),i}return a=Fi(a)||0,Si(r)&&(f=!!r.leading,n=(y="maxWait"in r)?Hr(Fi(r.maxWait)||0,a):n,p="trailing"in r?!!r.trailing:p),m.cancel=function(){l!==o&&Vc(l),d=0,t=u=c=l=o},m.flush=function(){return l===o?i:k(Qn())},m}var oi=zc(function(e,a){return Tt(e,1,a)}),ni=zc(function(e,a,r){return Tt(e,Fi(a)||0,r)});function ii(e,a){if("function"!=typeof e||null!=a&&"function"!=typeof a)throw new ca(s);var r=function(){var t=arguments,c=a?a.apply(this,t):t[0],o=r.cache;if(o.has(c))return o.get(c);var n=e.apply(this,t);return r.cache=o.set(c,n)||o,n};return r.cache=new(ii.Cache||mt),r}function si(e){if("function"!=typeof e)throw new ca(s);return function(){var a=arguments;switch(a.length){case 0:return!e.call(this);case 1:return!e.call(this,a[0]);case 2:return!e.call(this,a[0],a[1]);case 3:return!e.call(this,a[0],a[1],a[2])}return!e.apply(this,a)}}ii.Cache=mt;var li=Gc(function(e,a){var r=(a=1==a.length&&hi(a[0])?Qa(a[0],gr(Po())):Qa(Ft(a,1),gr(Po()))).length;return zc(function(t){for(var c=-1,o=$r(t.length,r);++c<o;)t[c]=a[c].call(this,t[c]);return $a(e,this,t)})}),ui=zc(function(e,a){var r=Sr(a,Mo(ui));return jo(e,z,o,a,r)}),di=zc(function(e,a){var r=Sr(a,Mo(di));return jo(e,v,o,a,r)}),fi=Co(function(e,a){return jo(e,x,o,o,o,a)});function yi(e,a){return e===a||e!=e&&a!=a}var pi=mo(Xt),_i=mo(function(e,a){return e>=a}),gi=tc(function(){return arguments}())?tc:function(e){return Ei(e)&&ua.call(e,"callee")&&!Ma.call(e,"callee")},hi=t.isArray,ki=Ba?gr(Ba):function(e){return Ei(e)&&Yt(e)==se};function mi(e){return null]===])
nilq/small-lua-stack
null
#!/usr/bin/lua if arg[ 1 ] ~= "L" then package.path = "" end local finally = require( "finally" ) local function create_a( raise ) if raise then error( "error in create a" ) end local name local o = { close = function() print( "-", "close a", name ) end } name = tostring( o ) print( "+", "create a", name ) return o end local function create_b( raise ) if raise then error( "error in create b" ) end local name local o = { clear = function() print( "-", "clear b", name ) end } name = tostring( o ) print( "+", "create b", name ) return o end local function create_c( raise ) if raise then error( "error in create c" ) end local name local o = { destroy = function() print( "-", "destroy c", name ) end } name = tostring( o ) print( "+", "create c", name ) return o end local function wastememory( n ) local a, b, c, d, e, f, g, h, i, j, k, l, m if n <= 0 then return 0 else return 1+wastememory( n-1 ) end end local function main1( r1, r2, r3, r4, stack, calls, dbg ) print( r1, r2, r3, r4, stack, calls, dbg ) local a, b, c return finally( function() a = create_a( r1 ) b = create_b( r2 ) c = create_c( r3 ) print( "ok" ) return 1, 2, 3 end, function( ... ) print( "error?", ... ) wastememory( 5 ) if c then c:destroy() end if r4 then error( "error in finally cleanup function" ) end if b then b:clear() end if a then a:close() end end, stack, calls, dbg ) end if _VERSION == "Lua 5.1" then local xpcall, unpack, select = xpcall, unpack, select function _G.xpcall( f, msgh, ... ) local args, n = { ... }, select( '#', ... ) return xpcall( function() return f( unpack( args, 1, n ) ) end, msgh ) end end local x = ("="):rep( 70 ) local function ___() print( x ) end local tb = debug.traceback print( xpcall( main1, tb, false, false, false, false, 80, 6, true ) ) ___() print( xpcall( main1, tb, false, false, false, false, nil, nil, true ) ) ___() print( xpcall( main1, tb, false, false, true, false, nil, nil, true ) ) ___() print( xpcall( main1, tb, false, true, false, false, nil, nil, true ) ) ___() print( xpcall( main1, tb, true, false, false, false, nil, nil, true ) ) ___() print( xpcall( main1, tb, false, false, false, true ) ) ___() print( xpcall( main1, tb, false, false, true, true ) ) ___() print( xpcall( main1, tb, false, false, false, false, 30, 6, true ) ) ___() print( xpcall( main1, tb, false, false, false, false, 80, 3, true ) ) ___() print( xpcall( main1, tb, false, false, false, false, 1000001, 6, true ) )
nilq/small-lua-stack
null
local Keys = { ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, ["LEFT"] = 174, ["RIGHT"] = 175, ["UP"] = 27, ["DOWN"] = 173, ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 } ESX = nil Citizen.CreateThread(function() while ESX == nil do TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) Citizen.Wait(0) end while ESX.GetPlayerData().job == nil do Citizen.Wait(10) end PlayerData = ESX.GetPlayerData() end) local color_white = {255, 255, 255} local color_black = {0, 0, 0} local defaultHeader = {"commonmenu", "interaction_bgd"} local defaultMenu = { { name = "Vide" } } local _intX, _intY = .23, .175 local _intW, _intH = .225, .035 local spriteW, spriteH = .225, .0675 local PMenu = {} local parentSliderSize = .25 local drawSprite = DrawSprite local BeginTextCommandWidth = BeginTextCommandWidth local AddTextComponentSubstringPlayerName = AddTextComponentSubstringPlayerName local SetTextFont = SetTextFont local SetTextScale = SetTextScale local EndTextCommandGetWidth = EndTextCommandGetWidth local GetControlNormal = GetControlNormal local RequestStreamedTextureDict = RequestStreamedTextureDict local SetStreamedTextureDictAsNoLongerNeeded = SetStreamedTextureDictAsNoLongerNeeded local IsInputDisabled = IsInputDisabled local IsControlPressed = IsControlPressed local IsDisabledControlPressed = IsDisabledControlPressed local IsControlJustPressed = IsControlJustPressed local UpdateOnscreenKeyboard = UpdateOnscreenKeyboard local SetTextDropShadow = SetTextDropShadow local SetTextEdge = SetTextEdge local SetTextColour = SetTextColour local SetTextJustification = SetTextJustification local SetTextWrap = SetTextWrap local SetTextEntry = SetTextEntry local AddTextComponentString = AddTextComponentString local DrawText = DrawText local DrawRect = DrawRect local AddTextEntry = AddTextEntry local DisplayOnscreenKeyboard = DisplayOnscreenKeyboard local GetOnscreenKeyboardResult = GetOnscreenKeyboardResult local ShowCursorThisFrame = ShowCursorThisFrame local DisableControlAction = DisableControlAction local function MeasureStringWidth(str, font, scale) BeginTextCommandWidth("STRING") AddTextComponentSubstringPlayerName(str) SetTextFont(font or 0) SetTextScale(1.0, scale or 0) return EndTextCommandGetWidth(true) end function IsMouseInBounds(X, Y, Width, Height) local MX, MY = GetControlNormal(0, 239) + Width / 2, GetControlNormal(0, 240) + Height / 2 return (MX >= X and MX <= X + Width) and (MY > Y and MY < Y + Height) end function PMenu:resetMenu() self.Data = { back = {}, currentMenu = "", intY = _intY, intX = _intX } self.Pag = { 1, 10, 1, 1 } self.Base = { Header = defaultHeader, Color = color_black, HeaderColor = color_white, Title = CCore and CCore.user and CCore.user.name or "Menu", Checkbox = { Icon = { [0] = {"commonmenu", "shop_box_blank"}, [1] = {"commonmenu", "shop_box_tickb"} } } } self.Menu = {} self.Events = {} self.tempData = {} self.IsVisible = false end function PMenu:stringsplit(inputstr, sep) if not inputstr then return end if sep == nil then sep = "%s" end local t = {} ; i = 1 for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do t[i] = str i = i + 1 end return t end local IsVisible = false function IsMenuOpened() return IsVisible end function SetMenuVisible(bool) IsVisible = bool end function PMenu:CloseMenu(bypass) if self.IsVisible and (not self.Base.Blocked or bypass) then self.IsVisible = false if self.Events["onExited"] then self.Events["onExited"](self.Data, self) end SetMenuVisible(false) self:resetMenu() end end function PMenu:GetButtons(customMenu) local menu = customMenu or self.Data.currentMenu local menuData = self.Menu and self.Menu[menu] local allButtons = menuData and menuData.b if not allButtons then return {} end local tblFilter = {} allButtons = type(allButtons) == "function" and allButtons(self) or allButtons if not allButtons or type(allButtons) ~= "table" then return {} end if self.Events and self.Events["onLoadButtons"] then allButtons = self.Events["onLoadButtons"](self, menu, allButtons) or allButtons end for _,v in pairs(allButtons) do if v and type(v) == "table" and (v.canSee and (type(v.canSee) == "function" and v.canSee() or v.canSee == true) or v.canSee == nil) and (not menuData.filter or string.find(string.lower(v.name), menuData.filter)) then if v.customSlidenum then v.slidenum = type(v.customSlidenum) == "function" and v.customSlidenum() or v.customSlidenum end local max = type(v.slidemax) == "function" and v.slidemax(v, self) or v.slidemax if type(max) == "number" then local tbl = {} for i = 0, max do tbl[#tbl + 1] = i end max = tbl end if max then v.slidenum = v.slidenum or 1 local slideName = max[v.slidenum] if slideName then v.slidename = slideName and type(slideName) == "table" and slideName.name or tostring(slideName) end end tblFilter[#tblFilter + 1] = v end end if #tblFilter <= 0 then tblFilter = defaultMenu end self.tempData = { tblFilter, #tblFilter } return tblFilter, #tblFilter end function PMenu:OpenMenu(stringName, boolBack) if stringName and not self.Menu[stringName] then print("[PMenu] " .. stringName .. " cannot be opened, the menu doesn't exist.") return end local newButtons, currentButtonsCount = self:GetButtons(stringName) --if not boolBack and (newButtons and newButtons[self.Pag[3]] and newButtons[self.Pag[3]].name ~= string.lower(stringName)) then if not boolBack and self.Data and self.Data.back then self.Data.back[#self.Data.back + 1] = self.Data.currentMenu end if boolBack then self.Data.back[#self.Data.back] = nil end local intSelect = boolBack and self.Pag[4] or 1 local max = math.max(10, math.min(intSelect)) self.Pag = { max - 9, max, intSelect, self.Pag[3] or 1 } -- min, max, current, ancien menu self.tempData = { newButtons, currentButtonsCount } self.Data.currentMenu = stringName if self.Events and self.Events["onButtonSelected"] then self.Events["onButtonSelected"](self.Data.currentMenu, self.Pag[3], self.Data.back, newButtons[1] or {}, self) end end function PMenu:Back() local historyCount = #self.Data.back if historyCount == 1 and not self.Base.Blocked then self:CloseMenu() elseif historyCount > 1 and not self.Base.BackBlocked then self:OpenMenu(self.Data.back[#self.Data.back], true) if self.Events["onBack"] then self.Events["onBack"](self.Data, self) end end end function PMenu:CreateMenu(tableMenu, tempData) if (self.Base and self.Base.Blocked and self.IsVisible and IsMenuOpened()) or not tableMenu then return end if not self.IsVisible and tableMenu then self:resetMenu() tableMenu.Base = tableMenu.Base or {} for k,v in pairs(tableMenu.Base) do if k == "Header" then RequestStreamedTextureDict(v[1]) SetStreamedTextureDictAsNoLongerNeeded(v[1]) end self.Base[k] = v end tableMenu.Data = tableMenu.Data or {} for k,v in pairs(tableMenu.Data) do self.Data[k] = v end tableMenu.Events = tableMenu.Events or {} for k,v in pairs(tableMenu.Events) do self.Events[k] = v end tableMenu.Menu = tableMenu.Menu or {} for k,v in pairs(tableMenu.Menu) do self.Menu[k] = v end self.Data.temp = tempData self.Base.CustomHeader = self.Base.Header and self.Base.Header[2] ~= "interaction_bgd" _intY = self.Base.CustomHeader and .205 or .17 if self.Events["onButtonSelected"] then -- maybe get buttons local allButtons, count = self:GetButtons() self.tempData = { allButtons, count } self.Events["onButtonSelected"](self.Data.currentMenu, 1, {}, allButtons[1] or {}, self) end self:OpenMenu(self.Data.currentMenu) local boolVisible = self.Base and self.Base.Blocked or not self.IsVisible self.IsVisible = boolVisible SetMenuVisible(boolVisible) if self.IsVisible and self.Events and self.Events["onOpened"] then self.Events["onOpened"](self.Data, self) end else self:CloseMenu(true) end end function PMenu:ProcessControl() local keyT = IsInputDisabled and IsInputDisabled(2) and 0 or 1 local boolUP, boolDOWN, boolRIGHT, boolLEFT = IsControlPressed(1, Keys["UP"]), IsControlPressed(1, Keys["DOWN"]), IsControlPressed(1, Keys["RIGHT"]), IsControlPressed(1, Keys["LEFT"]) local currentMenu = self.Menu and self.Menu[self.Data.currentMenu] local currentButtons, currentButtonsCount = table.unpack(self.tempData) local currentBtn = currentButtons and currentButtons[self.Pag[3]] if currentMenu and currentMenu.refresh then self:GetButtons() end if (boolUP or boolDOWN) and currentButtonsCount and self.Pag[3] then if boolDOWN and (self.Pag[3] < currentButtonsCount) or boolUP and (self.Pag[3] > 1) then self.Pag[3] = self.Pag[3] + (boolDOWN and 1 or -1) if currentButtonsCount > 10 and (boolUP and (self.Pag[3] < self.Pag[1]) or (boolDOWN and (self.Pag[3] > self.Pag[2]))) then self.Pag[1] = self.Pag[1] + (boolDOWN and 1 or -1) self.Pag[2] = self.Pag[2] + (boolDOWN and 1 or -1) end else self.Pag = { boolUP and currentButtonsCount - 9 or 1, boolUP and currentButtonsCount or 10, boolDOWN and 1 or currentButtonsCount, self.Pag[4] or 1 } if currentButtonsCount > 10 and (boolUP and (self.Pag[3] > self.Pag[2]) or (boolDOWN and (self.Pag[3] < self.Pag[1]))) then self.Pag[1] = self.Pag[1] + (boolDOWN and -1 or 1) self.Pag[2] = self.Pag[2] + (boolDOWN and -1 or 1) end end if self.Events["onButtonSelected"] then self.Events["onButtonSelected"](self.Data.currentMenu, self.Pag[3], self.Data.back, currentButtons[self.Pag[3]] or {}, self) end Citizen.Wait(125) end if (boolRIGHT or boolLEFT) and currentBtn then local slide = currentBtn.slide or currentMenu.slide or self.Events["onSlide"] if currentMenu.slidemax or currentBtn and currentBtn.slidemax or self.Events["onSlide"] or slide then local changeTo = currentMenu.slidemax and currentMenu or currentBtn.slidemax and currentBtn if changeTo and not changeTo.slidefilter or changeTo and not tableHasValue(changeTo.slidefilter, self.Pag[3]) then currentBtn.slidenum = currentBtn.slidenum or 0 local max = type(changeTo.slidemax) == "function" and (changeTo.slidemax(currentBtn, self) or 0) or changeTo.slidemax if type(max) == "number" then local tbl = {} for i = 0, max do tbl[#tbl + 1] = i end max = tbl end currentBtn.slidenum = currentBtn.slidenum + (boolRIGHT and 1 or -1) if (boolRIGHT and (currentBtn.slidenum > #max) or boolLEFT and (currentBtn.slidenum < 1)) then currentBtn.slidenum = boolRIGHT and 1 or #max end local slideName = max[currentBtn.slidenum] currentBtn.slidename = slideName and type(slideName) == "table" and slideName.name or tostring(slideName) local Offset = MeasureStringWidth(currentBtn.slidename, 0, 0.35) currentBtn.offset = Offset if slide then slide(self.Data, currentBtn, self.Pag[3], self) end Citizen.Wait(currentMenu.slidertime or 175) end end if currentBtn.parentSlider ~= nil and ((boolLEFT and currentBtn.parentSlider < 1.5 + parentSliderSize) or (boolRIGHT and currentBtn.parentSlider > .5 - parentSliderSize)) then currentBtn.parentSlider = boolLEFT and currentBtn.parentSlider + .01 or currentBtn.parentSlider - .01 if self.Events["onSlider"] then self.Events["onSlider"](self, self.Data, currentBtn, self.Pag[3], allButtons, currentBtn.parentSlider - parentSliderSize) end Citizen.Wait(10) end end if currentMenu and currentMenu.extra or currentBtn and currentBtn.opacity or currentBtn.advSlider then if currentBtn.advSlider and IsDisabledControlPressed(0, 24) then local x, y, w = table.unpack(self.Data.advSlider) local left, right = IsMouseInBounds(x - 0.01, self.Height, .015, .03), IsMouseInBounds(x - w + 0.01, self.Height, .015, .03) if left or right then local advPadding = 1 currentBtn.advSlider[3] = math.max(currentBtn.advSlider[1], math.min(currentBtn.advSlider[2], right and currentBtn.advSlider[3] - advPadding or left and currentBtn.advSlider[3] + advPadding )) self.Events["onAdvSlide"](self, self.Data, currentBtn, self.Pag[3], currentButtons) end Citizen.Wait(75) end end if IsControlJustPressed(1, 202) and UpdateOnscreenKeyboard() ~= 0 then self:Back() Citizen.Wait(100) end if self.Pag[3] and currentButtonsCount and self.Pag[3] > currentButtonsCount then self.Pag = { 1, 10, 1, self.Pag[4] or 1 } end end function DrawText2(intFont, stirngText, floatScale, intPosX, intPosY, color, boolShadow, intAlign, addWarp) SetTextFont(intFont) SetTextScale(floatScale, floatScale) if boolShadow then SetTextDropShadow(0, 0, 0, 0, 0) SetTextEdge(0, 0, 0, 0, 0) end SetTextColour(color[1], color[2], color[3], 255) if intAlign == 0 then SetTextCentre(true) else SetTextJustification(intAlign or 1) if intAlign == 2 then SetTextWrap(.0, addWarp or intPosX) end end SetTextEntry("STRING") AddTextComponentString(stirngText) DrawText(intPosX, intPosY) end function PMenu:canUseButton(button) if not button.role then return true end -- Only used in 'gtalife' if not State or not State.user or not GetLinkedRoles then return false end if button.role then local userRole = State.user.group return userRole and tableHasValue(GetLinkedRoles(userRole), button.role) end return false end function PMenu:drawMenuButton(button, intX, intY, boolSelected, intW, intH, intID) local tableColor, add, currentMenuData = boolSelected and (button.colorSelected or { 255, 255, 255, 255 }) or (button.colorFree or { 0, 0, 0, 100 }), .0, self.Menu[self.Data.currentMenu] DrawRect(intX, intY, intW, intH, tableColor[1], tableColor[2], tableColor[3], tableColor[4]) tableColor = boolSelected and color_black or color_white local stringPrefix = (((button.r and (((GM and GM.State.JobRank < button.r) or (button.rfunc and not button.rfunc())) and "~r~" or "")) or "") .. (self.Events["setPrefix"] and self.Events["setPrefix"](button, self.Data) or "")) or "" DrawText2(0, (button.price and "" or "") .. stringPrefix .. (button.name or ""), .275, intX - intW / 2 + .005, intY - intH / 2 + .0025, tableColor) local unkCheckbox = currentMenuData and currentMenuData.checkbox or button.checkbox ~= nil and button.checkbox local slide = button.slidemax and button or currentMenuData local slideExist = slide and slide.slidemax and (not slide.slidefilter or not tableHasValue(slide.slidefilter, intID)) local canUse = self:canUseButton(button) if canUse then if button.name and self.Menu[string.lower(button.name)] and not currentMenuData.item and not slideExist then drawSprite("commonmenutu", "arrowright", intX + (intW / 2.2), intY, .009, .018, 0.0, tableColor[1], tableColor[2], tableColor[3], 255) add = .0125 end if unkCheckbox ~= nil and (button.checkbox ~= nil or currentMenuData and currentMenuData.checkbox ~= nil) then local bool = unkCheckbox ~= nil and (type(unkCheckbox) == "function" and unkCheckbox(GetPlayerPed(-1), button, self.Base.currentMenu, self)) or unkCheckbox if (button.locked) then bool = bool and bool == true and 2 or 0 else bool = bool and bool == true and 1 or 0 end if not self.Base.Checkbox["Icon"] or self.Base.Checkbox["Icon"][bool] then local successIcon = self.Base.Checkbox["Icon"] and self.Base.Checkbox["Icon"][bool] if successIcon and successIcon[1] and successIcon[2] then local checkboxColor = boolSelected and bool == 0 and color_black or color_white drawSprite(successIcon[1], successIcon[2], intX + (intW / 2.2), intY, .023, .045, 0.0, checkboxColor[1], checkboxColor[2], checkboxColor[3], 255) return end end elseif slideExist or button.ask or button.slidename then local max = slideExist and slide and (type(slide.slidemax) == "function" and slide.slidemax(button, self) or slide.slidemax) if (max and type(max) == "number" and max > 0 or type(max) == "table" and #max > 0) or not slideExist then local defaultIndex = slideExist and button.slidenum or 1 local slideText = button.ask and (type(button.ask) == "function" and button.ask(self) or button.askValue or button.ask) or (button.slidename or (type(max) == "number" and (defaultIndex - 1) or type(max[defaultIndex]) == "table" and max[defaultIndex].name or tostring(max[defaultIndex]))) slideText = tostring(slideText) if boolSelected and slideExist then drawSprite("commonmenu", "arrowright", intX + (intW / 2) - .01025, intY + 0.0004, .009, .018, 0.0, tableColor[1], tableColor[2], tableColor[3], 255) button.offset = MeasureStringWidth(slideText, 0, .275) drawSprite("commonmenu", "arrowleft", intX + (intW / 2) - button.offset - .016, intY + 0.0004, .009, .018, 0.0, tableColor[1], tableColor[2], tableColor[3], 255) end local textX = (not boolSelected or button.ask) and -.004 or - .0135 DrawText2(0, slideText, .275, intX + intW / 2 + textX, intY - intH / 2 + .00375, tableColor, false, 2) intX = boolSelected and intX - .0275 or intX - .0125 end end if button.parentSlider ~= nil then local rectX, rectY = intX + .0925, intY + 0.005 local proW, proH = .1, 0.01 drawSprite("mpleaderboard", "leaderboard_female_icon", intX + (intW / 2) - .01025, intY + 0.0004, .0156, .0275, 0.0, tableColor[1], tableColor[2], tableColor[3], 255) drawSprite("mpleaderboard", "leaderboard_male_icon", intX - .015, intY + 0.0004, .0156, .0275, 0.0, tableColor[1], tableColor[2], tableColor[3], 255) local slideW = proW * button.parentSlider DrawRect(rectX - proW / 2, rectY - proH / 2, proW, proH, 4, 32, 57, 255) DrawRect(rectX - slideW / 2, rectY - proH / 2, proW * parentSliderSize, proH, 57, 116, 200, 255) DrawRect(rectX - proW / 2, rectY - proH / 2, .002, proH + 0.005, tableColor[1], tableColor[2], tableColor[3], 255) end local textBonus = (self.Events["setBonus"] and self.Events["setBonus"](button, self.Data.currentMenu, self)) or (button.amount and button.amount) or (button.price and "~g~" .. math.floor(button.price) .. "$") if textBonus and string.len(textBonus) > 0 then DrawText2(0, textBonus, .275, intX + (intW / 2) - .005 - add, intY - intH / 2 + .00375, tableColor, true, 2) end ----ammo local Ammo = (self.Events["setAmmo"] and self.Events["setAmmo"](button, self.Data.currentMenu, self)) or (button.ammo and button.ammo) if Ammo and string.len(Ammo) > 0 then drawSprite("commonmenu", "shop_ammo_icon_b", intX + (intW / 2.15), intY, .02, .034, 0.0, 255, 255, 255, 255) end else drawSprite("commonmenu", "shop_lock", intX + (intW / 2.15), intY, .02, .034, 0.0, tableColor[1], tableColor[2], tableColor[3], 255) end end local function MultilineFormat(str, size) if tostring(str) then local PixelPerLine = _intW + .025 local AggregatePixels = 0 local output = "" local words = stringsplit(tostring(str), " ") for i = 1, #words do local offset = MeasureStringWidth(words[i], 0, size) AggregatePixels = AggregatePixels + offset if AggregatePixels > PixelPerLine then output = output .. "\n" .. words[i] .. " " AggregatePixels = offset + 0.003 else output = output .. words[i] .. " " AggregatePixels = AggregatePixels + 0.003 end end return output end end function PMenu:DrawButtons(tableButtons) local padding, pd = 0.0175, 0.0475 for intID, data in ipairs(tableButtons) do local shouldDraw = intID >= self.Pag[1] and intID <= self.Pag[2] if shouldDraw then local boolSelected = intID == self.Pag[3] self:drawMenuButton(data, self.Width - _intW / 2, self.Height, boolSelected, _intW, _intH - 0.005, intID) self.Height = self.Height + pd - padding if boolSelected and IsControlJustPressed(1, 201) and data.name ~= "Vide" then if self.Events["setCheckbox"] then self.Events["setCheckbox"](self.Data, data) end local slideEvent = data.slide or self.Events["onSlide"] if slideEvent or data.checkbox ~= nil then if not slideEvent then data.checkbox = not data.checkbox else slideEvent(self.Data, data, intID, self) end end local selectFunc, shouldContinue = self.Events["onSelected"], false if selectFunc then if data.slidemax and not data.slidenum and type(data.slidemax) == "table" then data.slidenum = 1 data.slidename = data.slidemax[1] end data.slidenum = data.slidenum or 1 if data.ask and not data.askX then data.askValue = nil if data.name then AddTextEntry('FMMC_KEY_TIP8', data.askTitle or data.name) end local askValue = type(data.ask) == "function" and data.ask(self) or data.ask DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", askValue or "", "", "", "", 60) while UpdateOnscreenKeyboard() == 0 do Citizen.Wait(50) if UpdateOnscreenKeyboard() == 1 and GetOnscreenKeyboardResult() and string.len(GetOnscreenKeyboardResult()) >= 1 then data.askValue = GetOnscreenKeyboardResult() end end end shouldContinue = selectFunc(self, self.Data, data, self.Pag[3], tableButtons) end if not shouldContinue and self.Menu[string.lower(data.name)] then self:OpenMenu(string.lower(data.name)) end end end end end function PMenu:DrawHeader(intCount) local parentHeader, childHeader = table.unpack(self.Base.Header) local boolHeader = parentHeader and string.len(parentHeader) > 0 local currentMenu = self.Menu[self.Data.currentMenu] local stringCounter = currentMenu and currentMenu["customSub"] and currentMenu["customSub"]() or string.format("%s/%s", self.Pag[3], intCount) if boolHeader then local intH = self.Base.CustomHeader and 0.1025 or spriteH drawSprite(parentHeader, childHeader, self.Width - spriteW / 2, self.Height - intH / 2, spriteW, intH, .0, self.Base.HeaderColor[1], self.Base.HeaderColor[2], self.Base.HeaderColor[3], 215) self.Height = self.Height - 0.03 if not self.Base.CustomHeader then DrawText2(1, self.Base.Title, .7, self.Width - spriteW / 2, self.Height - intH / 2 + .0125, color_white, false, 0) end end self.Height = self.Height + 0.06 local rectW, rectH = _intW, _intH - .005 DrawRect(self.Width - rectW / 2, self.Height - rectH / 2, rectW, rectH, self.Base.Color[1], self.Base.Color[2], self.Base.Color[3], 255) self.Height = self.Height + 0.005 DrawText2(0, firstToUpper(self.Data.currentMenu), .275, self.Width - rectW + .005, self.Height - rectH - 0.0015, color_white, true) self.Height = self.Height + 0.005 DrawText2(0, stringCounter, .275, self.Width - rectW / 2 + .11, self.Height - _intH, color_white, true, 2) if currentMenu and currentMenu.charCreator then local spriteW, spriteH = .225, .21 self.Height = self.Height + spriteH - 0.01 drawSprite("pause_menu_pages_char_mom_dad", "mumdadbg", self.Width - spriteW / 2, self.Height - spriteH / 2, spriteW, spriteH, .0, 255, 255, 255, 255) drawSprite("pause_menu_pages_char_mom_dad", "vignette", self.Width - spriteW / 2, self.Height - spriteH / 2, spriteW, spriteH, .0, 255, 255, 255, 255) if currentMenu.father then spriteW, spriteH = .11875, .2111 drawSprite("char_creator_portraits", currentMenu.father, self.Width - spriteW / 2, self.Height - spriteH / 2, spriteW, spriteH, .0, 255, 255, 255, 255) end if currentMenu.mother then spriteW, spriteH = .11875, .2111 local customX = self.Width - .1 drawSprite("char_creator_portraits", currentMenu.mother, customX - spriteW / 2, self.Height - spriteH / 2, spriteW, spriteH, 0.0, 255, 255, 255, 255) self.Height = self.Height + 0.01 end end self.Height = self.Height + 0.005 end function PMenu:DrawHelpers(tableButtons) local hasHelp = self.Base.Description or self.Menu[self.Data.currentMenu] and self.Menu[self.Data.currentMenu].Description or tableButtons[self.Pag[3]] and tableButtons[self.Pag[3]].Description if hasHelp then local intH, scale = 0.0275, 0.275 self.Height = self.Height - 0.015 DrawRect(self.Width - _intW / 2, self.Height, _intW, 0.0025, 0, 0, 0, 255) local descText = MultilineFormat(hasHelp, scale) local Linecount = #stringsplit(descText, "\n") local nwintH = intH + (Linecount == 1 and 0 or ( (Linecount + 1) * 0.0075)) self.Height = self.Height + intH / 2 DrawSprite("commonmenu", "gradient_bgd", self.Width - _intW / 2, self.Height + nwintH / 2 - 0.015, _intW, nwintH, .0, 255, 255, 255, 255) DrawText2(0, descText, scale, self.Width - _intW + .005, self.Height - 0.01, color_white) end end function stringsplit(inputstr, sep) if not inputstr then return end if sep == nil then sep = "%s" end local t = {} ; i = 1 for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do t[i] = str i = i + 1 end return t end function PMenu:DrawExtra(tableButtons) ShowCursorThisFrame() DisableControlAction(0, 1, true) DisableControlAction(0, 2, true) DisableControlAction(0, 24, true) DisableControlAction(0, 25, true) local button = tableButtons[self.Pag[3]] if button and button.opacity ~= nil then local proW, proH = _intW, 0.055 self.Height = self.Height - 0.01 drawSprite("commonmenu", "gradient_bgd", self.Width - proW / 2, self.Height + proH / 2, proW, proH, 0.0, 255, 255, 255, 255) self.Height = self.Height + 0.005 DrawText2(0, "0%", 0.275, self.Width - _intW + .005, self.Height, color_white, false, 1) DrawText2(0, "Opacité", 0.275, self.Width - _intW / 2, self.Height, color_white, false, 0) DrawText2(0, "100%", 0.275, self.Width - 0.005, self.Height, color_white, false, 2) self.Height = self.Height + .033 local rectW, rectH = .215, 0.015 local customW = rectW * ( 1 - button.opacity ) local rectX, rectY = self.Width - rectW / 2 - 0.005, self.Height local customX = self.Width - customW / 2 - 0.005 DrawRect(rectX, rectY, rectW, rectH, 245, 245, 245, 255) DrawRect(customX, rectY, customW, rectH, 87, 87, 87, 255) if IsDisabledControlPressed(0, 24) and IsMouseInBounds(rectX, rectY, rectW, rectH) then local mouseXPos = GetControlNormal(0, 239) - proH / 2 --print(round(math.max(0.0, math.min(1.0, mouseXPos / rectW)*10),2)) button.opacity = math.max(0.0, math.min(1.0, mouseXPos / rectW + 0.081)) self.Events["onSlide"](self.Data, button, self.Pag[3], self) end self.Height = self.Height + 0.025 end if button and button.advSlider ~= nil then local proW, proH = _intW, 0.055 drawSprite("commonmenu", "gradient_bgd", self.Width - proW / 2, self.Height + proH / 2, proW, proH, 0.0, 255, 255, 255, 255) self.Height = self.Height + 0.005 button.advSlider[3] = button.advSlider[3] or 0 DrawText2(0, tostring(button.advSlider[1]), 0.275, self.Width - _intW + .005, self.Height, color_white, false, 1) DrawText2(0, "Variations disponibles", 0.275, self.Width - _intW / 2, self.Height, color_white, false, 0) DrawText2(0, tostring(button.advSlider[2]), 0.275, self.Width - 0.005, self.Height, color_white, false, 2) self.Height = self.Height + .03 drawSprite("commonmenu", "arrowright", self.Width - 0.01, self.Height, .015, .03, 0.0, 255, 255, 255, 255) drawSprite("commonmenu", "arrowleft", self.Width - proW + 0.01, self.Height, .015, .03, 0.0, 255, 255, 255, 255) local rectW, rectH = .19, 0.015 local rectX, rectY = self.Width - proW / 2, self.Height DrawRect(rectX, rectY, rectW, rectH, 87, 87, 87, 255) local sliderW = rectW / (button.advSlider[2] + 1) local sliderWFocus = button.advSlider[2] * (sliderW / 2) local customX = rectX - sliderWFocus + (sliderW * ( button.advSlider[3] / button.advSlider[2] )) * button.advSlider[2] DrawRect(customX, rectY, sliderW, rectH, 245, 245, 245, 255) self.Data.advSlider = { self.Width, self.Height, proW } end end function PMenu:Draw() local tableButtons, intCount = table.unpack(self.tempData) self.Height = self.Base and self.Base.intY or _intY self.Width = self.Base and self.Base.intX or _intX if tableButtons and intCount and not self.Invisible then self:DrawHeader(intCount) -- 0.03ms self:DrawButtons(tableButtons) -- 0.04ms self:DrawHelpers(tableButtons) -- 0.00ms local currentMenu, currentButton = self.Menu[self.Data.currentMenu], self.Pag[3] and tableButtons and tableButtons[self.Pag[3]] if currentMenu and (currentMenu.extra or currentButton and currentButton.opacity or currentButton.advSlider) then self:DrawExtra(tableButtons) end if currentMenu and currentMenu.useFilter then --local keyFilter = Keys[0]["F"] DisableControlAction(1, 23, true) if IsDisabledControlJustPressed(1, 23) then AskEntry(function(n) currentMenu.filter = n and string.len(n) > 0 and string.lower(n) or false self:GetButtons() end, "Filtre", 30, currentMenu.filter) end end -- 0.00ms end if self.Events and self.Events["onRender"] then self.Events["onRender"](self, tableButtons, tableButtons[self.Pag[3]], self.Pag[3]) end end function CloseMenu(force) return PMenu:CloseMenu(force) end function CreateMenu(arrayMenu, tempData) return PMenu:CreateMenu(arrayMenu, tempData) end function OpenMenu(stringName) return PMenu:OpenMenu(stringName) end function AskEntry(callback, name, lim, default) AddTextEntry('FMMC_KEY_TIP8', name or "Montant") DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", default, "", "", "", lim or 60) while UpdateOnscreenKeyboard() == 0 do Citizen.Wait(10) if UpdateOnscreenKeyboard() >= 1 then callback(GetOnscreenKeyboardResult()) break end end end Citizen.CreateThread(function() while true do Citizen.Wait(0) if PMenu.IsVisible then PMenu:Draw() end end end) Citizen.CreateThread(function() while true do Citizen.Wait(0) if PMenu.IsVisible and not PMenu.Invisible then PMenu:ProcessControl() end end end) function firstToUpper(str) return (str:gsub("^%l", string.upper)) end -- Qui fais le malin tombe dans le ravin ^^
nilq/small-lua-stack
null
AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) AddCSLuaFile( "player_spawn.lua" ) include( "shared.lua" ) include( "player_spawn.lua" ) ---------------------- ---------------------- function GM:ShowTeam() local ply = player.GetAll()[1] net.Start("Spawn_Menu") net.Send(ply) end function GM:ShowHelp() local ply = player.GetAll()[1] ply:Spawn() ply:UnSpectate() ply:SetTeam( 1 ) end function GM:PlayerInitialSpawn( ply ) Msg("Player "..ply:Nick().." has entered the server.\n") if ply:IsBot() then ply:SetTeam( math.random(1,6) ) ply:SetModel( "models/player/gman_high.mdl" ) ply:SetPlayerColor( Vector( math.Rand(0,1), math.Rand(0,1), math.Rand(0,1) ) ) else timer.Simple(0,function() GAMEMODE:PlayerSpawnAsSpectator( ply ) ply:SetTeam( TEAM_SPECTATOR ) ply:Spectate( OBS_MODE_ROAMING ) ply:SetPos( ply:GetPos() + Vector(0,0,50) ) end) end net.Start("Spawn_Menu") net.Send(ply) end function GM:PlayerSpawn( ply ) ply:SetModel( "models/player/gman_high.mdl" ) ply:SetPlayerColor( Vector( math.Rand(0,1), math.Rand(0,1), math.Rand(0,1) ) ) ply:SetupHands() end function GM:PlayerSetHandsModel( ply, ent ) local simplemodel = player_manager.TranslateToPlayerModelName( ply:GetModel() ) local info = player_manager.TranslatePlayerHands( simplemodel ) if ( info ) then ent:SetModel( info.model ) ent:SetSkin( info.skin ) ent:SetBodyGroups( info.body ) end end --------------------NET.RECEIVE----------------------- net.Receive( "player_spawn_class", Spawn_Classes ) ------------------------------------------------------- function GM:CanPlayerSuicide( ply ) if ply:Team() == TEAM_SPECTATOR then return false end return true end function GM:PlayerDeath( ply, ent, att ) timer.Simple( 0, function() if ply:IsValid() then ply:SetTeam( TEAM_SPECTATOR ) ply:Spectate( OBS_MODE_ROAMING ) if team.NumPlayers( TEAM_SPECTATOR ) == #player.GetAll() then PrintMessage( HUD_PRINTTALK, "Everyone is dead! Changing Map\n" ) end end end) //----------------------------// timer.Create( "DeathTimer"..ply:UserID(), 10, 1, function() if ply:IsValid() and !ply:Alive() then ply:UnSpectate() ply:SetTeam( 1 ) ply:Spawn() net.Start( "Spawn_Menu" ) net.Send( ply ) end end) net.Start("player_death") net.WriteFloat( 10 ) net.WriteFloat( math.Round( CurTime() ) ) net.Send(ply) end function GM:PlayerDisconnected( ply ) if team.NumPlayers( TEAM_SPECTATOR ) == #player.GetAll() then PrintMessage( HUD_PRINTTALK, "Everyone is dead! Changing Map\n" ) end end function GM:PlayerShouldTakeDamage( ply, attacker ) /*if attacker:IsPlayer() then return false end*/ return true end function GM:PlayerDeathThink() return false end function GM:GetFallDamage( ply, speed ) return ( speed / 12 ) end function GM:PlayerSwitchFlashlight(ply, SwitchOn) if ply:Team() == TEAM_SPECTATOR then return false end return true end function Broadcast(Text) for k, v in pairs(player.GetAll()) do v:ChatPrint(Text) end end function ChangeMap( maps ) game.ConsoleCommand("changelevel " ..table.Random(maps).. "\n") end
nilq/small-lua-stack
null
local log = require('lib.bussiness.log') local userLib =require('lib.bussiness.user') local config = require('lib.config.config') local levelAction = {} levelAction.typeLevel = nil levelAction.levelNumber = nil levelAction.user = nil levelAction.isStarted = false levelAction.game = {} levelAction.game.hp = 0 levelAction.game.totalHp = 1000 * 30 * 1 --config.gameProgression.levels[levelAction.typeLevel].maxTime levelAction.game.bonus = 0 levelAction.game.totalBonus = 0 levelAction.game.initalTime = nil levelAction.game.totalTime = nil levelAction.game.prevFrameTime = 0 levelAction.game.deltaFrameTime = 0 levelAction.events = {} levelAction.events.finishLevel =nil -- 1. call START -> To start all the timers and counter -- 2. call STOP -> To stop all the timer finish all logic and other things -- 3. if user leave the level call clear -- 4. call FINISH -> calc all the timer check if user beat the best time -- params : { -- initalTime : -- } function levelAction.start(type,level,params,funcs) if levelAction.isStarted then log.info('level is already started') else levelAction.typeLevel = type levelAction.levelNumber = level levelAction.game.initalTime = 0 --define the duration of level levelAction.game.hp = levelAction.game.totalHp --config.gameProgression.levels[levelAction.typeLevel].maxTime levelAction.isStarted = true levelAction.events.finishLevel = funcs.finishLevel end end function levelAction.updateTime(type,level,params,delta) local leftHp = 0 levelAction.game.hp = levelAction.game.hp - delta leftHp = levelAction.game.totalHp - levelAction.game.hp if levelAction.game.hp <= 0 then if levelAction.events.finishLevel then levelAction.events.finishLevel() end end return levelAction.game.hp,leftHp end -- percentage you to know on this level lets say 33% or 66% function levelAction.TotalLevelPossibleInPercentage(percentageValue) -- totalLevelPossibleValue = TotalTime + TotalBonus -- on this version i'm counting the bonus value local totalLevelPossibleValue = levelAction.game.totalHp + 0 totalLevelPossibleValue = totalLevelPossibleValue * (percentageValue / 100) return totalLevelPossibleValue end function levelAction.getClassification() local totalPontuation = (levelAction.game.hp ) + (levelAction.game.bonus ) local remaingPontuation = (levelAction.game.totalHp - levelAction.game.hp ) + ( levelAction.game.totalBonus - levelAction.game.bonus ) local numberOfStars = 0 local _1StarPerc = levelAction.TotalLevelPossibleInPercentage(33) local _2StarPerc = levelAction.TotalLevelPossibleInPercentage(66) if totalPontuation < _1StarPerc then numberOfStars = 1 end if totalPontuation > _1StarPerc and totalPontuation < _2StarPerc then numberOfStars = 2 end if totalPontuation > _2StarPerc then numberOfStars = 3 end return totalPontuation, numberOfStars end function levelAction.stop(type,level,params) if levelAction.isStarted == true then levelAction.game.initalTime = 0 local total , stars = levelAction.getClassification() print("stars " ..stars.. "/3 total : "..total) local user = userLib.getUser() local levelData = user.data.gameProgression.levels[levelAction.typeLevel].data[levelAction.levelNumber] if params.params.winner == true then if levelData == nil then levelData = {} levelData.stars = 3 levelData.topScore = 0 levelData.numberWinners = 1 levelData.id = levelAction.levelNumber end print("total : ") print(total) print("top score : ") print(levelData.topScore) if total > levelData.topScore then levelData.topScore = total levelData.stars = stars end if user.data.gameProgression.levels[levelAction.typeLevel].data[levelAction.levelNumber +1 ] == nil then user.data.gameProgression.levels[levelAction.typeLevel].data[levelAction.levelNumber +1 ] = {} user.data.gameProgression.levels[levelAction.typeLevel].data[levelAction.levelNumber +1 ].numberWinners = 1 user.data.gameProgression.levels[levelAction.typeLevel].data[levelAction.levelNumber +1 ].topScore = 0 user.data.gameProgression.levels[levelAction.typeLevel].data[levelAction.levelNumber +1 ].stars = 0 user.data.gameProgression.levels[levelAction.typeLevel].data[levelAction.levelNumber +1 ].id = levelAction.levelNumber end levelData.numberWinners = levelData.numberWinners + 1 print("updat user data object :: ") print(levelData) user.data.gameProgression.levels[levelAction.typeLevel].data[levelAction.levelNumber] = levelData log.debug(levelData) userLib.saveUser() end -- put that on clear in the future levelAction.isStarted = false end end function levelAction.clear(type,level,params) levelAction.game.hp = levelAction.game.totalHp --config.gameProgression.levels[levelAction.typeLevel].maxTime levelAction.events.finishLevel = nil levelAction.isStarted = false end function levelAction.finish(type,level,params) end function levelAction.userHit(type,level,params) end function levelAction.userHitByEnemy(type,level,params) end function levelAction.pause(type,level,params) end return levelAction
nilq/small-lua-stack
null
float=script() float.spos=vec3() float.Init=function() float.spos=ent.pos end float.Update=function() ent.pos=float.spos+vec3(0,1*math.sin(Time.time),0) end speechrate=8 player=script() speeches={} player.Init=function() stime=0 cam=findEntity('camera');speech=findEntity('speech') ent.rigidBody.linearDamping=0.999 by=speech.button.y end player.Update=function() dt=Time.deltaTime stime=stime+dt*speechrate local lv=ent.rigidBody.linearVelocity cam.pos=ent.pos+vec3(0,20,14) local vel=vec3();local speed=160*dt if getKey(keys.w) then vel.z=vel.z-speed end if getKey(keys.s) then vel.z=vel.z+speed end if getKey(keys.a) then vel.x=vel.x-speed end if getKey(keys.d) then vel.x=vel.x+speed end if getKeyDown(keys.space) then vel.y=30+vel.y end if mag(lv) < 60 then ent.rigidBody.applyImpulse(vel) end speech.button.y=by+math.sin(Time.time*2)*60 if #speeches[1]>1+math.floor(stime) then speech.button.text=string.sub( speeches[1],1,math.min(1+math.floor(stime),#speeches[1]) ) end printf('position = '..math.floor(ent.pos.x).." , "..math.floor(ent.pos.y),0,300) end speeches[1]="I don't think I remember how to make this work " --[[ tplayer=script() tplayer.Update=function() print('pushing'..inp.y) cam= findEntity('cam') --local cdir=norm(cam.pos-ent.pos) local cdir=norm(vec3(0,3,0)+ rotate(euler(0,-getScrMousePos().x*0,0),vec3(0,0,2)) ) pmesh= findEntity('pmesh') ent.rb.linearDamping=0.9999 zoom=zoom-getMouseScroll()*dt*240 zoom=math.min(50,zoom);zoom=math.max(30,zoom) cam.rot=lookAt(cam.pos,ent.pos) cam.pos=ent.pos+cdir*zoom forward=norm(-1*cdir*vec3(1,0,1));right=cross(-1*up,forward) imp=inp.x*right+inp.y*forward ent.rb.applyImpulse((imp)*dt*180) local to=norm(vec3(inp.x,0,-inp.y+0.001))--+ent.pos pmesh.rot= quat(vec3(0,0,1),to) end tplayer.OnCollisionEnter=function(col) if col.other.name=="portal" then trans=0;tolevel='next';trandir=1 --loadScene('next') end end ]]
nilq/small-lua-stack
null
local key = ModPath .. ' ' .. RequiredScript if _G[key] then return else _G[key] = true end local max_players = tweak_data.max_players function BaseNetworkSession:amount_of_alive_players() local count = 0 local peers_all = self._peers_all for i = 1, max_players do local peer = peers_all[i] if peer and alive(peer:unit()) then count = count + 1 end end return count end function BaseNetworkSession:peer_by_ip(ip) local peers_all = self._peers_all for i = 1, max_players do local peer = peers_all[i] if peer and peer:ip() == ip then return peer end end end function BaseNetworkSession:peer_by_user_id(user_id) local peers_all = self._peers_all for i = 1, max_players do local peer = peers_all[i] if peer and peer:user_id() == user_id then return peer end end end
nilq/small-lua-stack
null
local A = {} A.defaults = { def1 = "Default 1 for A", def2 = 7, def3 = 9 } A.event_types = { } function A:testA() return "Function called that is defined in A." end return A
nilq/small-lua-stack
null
--[[ TheNexusAvenger Handles the server-side broom. --]] local Players = game:GetService("Players") local Debris = game:GetService("Debris") local TweenService = game:GetService("TweenService") local Tool = script.Parent local Handle = Tool:WaitForChild("Handle") local SwingSound = Handle:WaitForChild("SwingSound") local WhackSound = Handle:WaitForChild("WhackSound") local RemoteEventCreator = require(Tool:WaitForChild("RemoteEventCreator")) local PlayerDamager = require(Tool:WaitForChild("PlayerDamager")) local Modifiers = require(Tool:WaitForChild("Modifiers")) local Configuration = require(Tool:WaitForChild("Configuration")) local WALK_SPEED_BUFF = Configuration.WALK_SPEED_BUFF local BROOM_DAMAGE = Configuration.BROOM_DAMAGE local BROOM_COOLDOWN = Configuration.BROOM_COOLDOWN local BLOWBACK_VELOCITY = Configuration.BLOWBACK_VELOCITY local BLOWBACK_TIME = Configuration.BLOWBACK_TIME local BROOM_WHACK_SPEED = Configuration.BROOM_WHACK_SPEED local SwingBroomEvent = RemoteEventCreator:CreateRemoteEvent("SwingBroom") local CurrentPlayer,CurrentCharacter,CurrentHumanoid local HitCharacters local Equipped = false local ToolEnabled = true --[[ Registers a hit with the broom. --]] function BroomHit(TouchPart) --Check if there is a current character and the hit exists. if not TouchPart.Parent then return end if not CurrentPlayer then return end if not CurrentCharacter then return end if not CurrentHumanoid then return end --Check if it is curringly being swinged. if HitCharacters then local HitCharacter = TouchPart.Parent local HitHumanoid = HitCharacter:FindFirstChildOfClass("Humanoid") --If the hit character isn't the weilder, damage the character. if HitHumanoid and HitCharacter and HitCharacter ~= CurrentCharacter and CurrentHumanoid.Health > 0 and not HitCharacters[HitCharacter] then if PlayerDamager:CanDamageHumanoid(CurrentPlayer,HitHumanoid) then HitCharacters[HitCharacter] = true PlayerDamager:DamageHumanoid(CurrentPlayer,HitHumanoid,BROOM_DAMAGE,"Broom") WhackSound:Play() --Force the character back if it has a HumanoidRootPart. local HumanoidRootPart = HitCharacter:FindFirstChild("HumanoidRootPart") local CurrentHumanoidRootPart = CurrentCharacter:FindFirstChild("HumanoidRootPart") if HumanoidRootPart and CurrentHumanoidRootPart and not HitCharacter:FindFirstChildOfClass("ForceField") then local BodyVelocity = Instance.new("BodyVelocity") BodyVelocity.MaxForce = Vector3.new(50000, 50000, 50000) BodyVelocity.P = 25000 BodyVelocity.Velocity = (CurrentHumanoidRootPart.CFrame * CFrame.Angles(-math.pi * 0.25,math.pi * 0.25,0)).lookVector * BLOWBACK_VELOCITY Debris:AddItem(BodyVelocity,BLOWBACK_TIME) BodyVelocity.Parent = HumanoidRootPart end end end end end --Set up broom swing. SwingBroomEvent.OnServerEvent:Connect(function(Player) if Player == CurrentPlayer and ToolEnabled then --Disable the tool. ToolEnabled = false Tool.Enabled = false HitCharacters = {[Player.Character] = true} --Play the swing sound. SwingSound.Pitch = 1.2 + (math.random() * 0.2) SwingSound:Play() spawn(function() --Extend and retract the broom. TweenService:Create(Tool,TweenInfo.new(1/BROOM_WHACK_SPEED),{ GripPos = Vector3.new(0,2,0) }):Play() wait(0.5/BROOM_WHACK_SPEED) TweenService:Create(Tool,TweenInfo.new(1/BROOM_WHACK_SPEED),{ GripPos = Vector3.new(0,0,0) }):Play() end) wait(0.15 + BROOM_COOLDOWN) --enable the tool. HitCharacters = nil ToolEnabled = true Tool.Enabled = true end end) --Set up tool equipping and unequipping. Tool.Equipped:Connect(function() if not Equipped then Equipped = true --Set current player and increase walkspeed. CurrentCharacter = Tool.Parent CurrentHumanoid = CurrentCharacter:FindFirstChildOfClass("Humanoid") CurrentPlayer = Players:GetPlayerFromCharacter(CurrentCharacter) Modifiers:Add("BroomSpeed","Speed",WALK_SPEED_BUFF) end end) Tool.Unequipped:Connect(function() if Equipped then Equipped = false --Reset current player and reset walkspeed buff. Modifiers:Remove("BroomSpeed") CurrentCharacter = nil CurrentHumanoid = nil CurrentPlayer = nil SwingSound:Stop() WhackSound:Stop() end end) Handle.Touched:connect(BroomHit)
nilq/small-lua-stack
null
-- -- Definitions for buttons in NewTaskbar and right click menus for custom commands. -- --This table defines a list of custom command ID's, NewTaskbar button names, and right click menu display names for all custom commands in the game. --NOTE: commandID must be a number between 0 and 31 and must match the number used with the CustomCommand add ability on a ship definition. --The following values are defined for the control commandID: -- --INFO_CMD_Move --INFO_CMD_Attack --INFO_CMD_AttackMove --INFO_CMD_Guard --INFO_CMD_Dock --INFO_CMD_Stop --INFO_CMD_Waypoints --INFO_CMD_Harvest --INFO_CMD_Hyperspace --INFO_CMD_Retire --INFO_CMD_SensorPing --INFO_CMD_EMP --INFO_CMD_DefenseField --INFO_CMD_Cloak --INFO_CMD_Repair --INFO_CMD_Mines --INFO_CMD_RallyPoint --INFO_CMD_RallyObject --INFO_CMD_Scuttle --INFO_CMD_Capture --INFO_CMD_Salvage --INFO_CMD_SalCap --INFO_CMD_Kamikaze --INFO_CustomStart --Add 0 to 31 to this value to define one of 32 possible custom commands --INFO_SpecialAttackStart --Add 0 to 15 to this value to define one of 16 possible special attacks --INFO_FormationsStart --Add 0 to 15 to this value to define one of 16 possible formations --INFO_TacticsStart --Add 0 to 15 to this value to define one of 16 possible tactics --INFO_TaskbarTypes_MAX --Maximum number of commandID's (any command with an ID set to this or higher will be ignored) --This table defines a list of values mainUIDefine can be set to to map a command info record to a main UI command. --MUI_CancelCommand = 0, --MUI_WaypointCommand, --MUI_WaypointModeCommand, --MUI_DeleteCommand, --MUI_FocusCommand, --MUI_NextFocusCommand, --MUI_PreviousFocusCommand, --MUI_AttackCommand, --MUI_MoveCommand, --MUI_StopCommand, --MUI_CreateGroupCommand, --MUI_SelectGroupCommand, --MUI_SetSelectionCommand, --MUI_TacticalOverlayToggleCommand, --MUI_DockCommand, --MUI_GuardCommand, --MUI_ParadeCommand, --MUI_HarvestCommand, --MUI_ShiftModifierCommand, --MUI_ControlModifierCommand, --MUI_FocusModifierCommand, --MUI_ZoomCommand, --MUI_SensorsManagerToggleCommand, --MUI_OrderFeedbackCommand, --MUI_SelectAllVisibleCommand, --MUI_FocusHomeCommand, --MUI_HyperspaceCommand, --MUI_RepairCommand, --MUI_SpecialAttackCommand, --MUI_SetRallyPoint, --MUI_SetRallyObject, --MUI_RetireCommand, --MUI_DropMinesCommand, --MUI_MoveAttackCommand, --MUI_MilitaryCommand, --MUI_DefenseFieldCommand, --MUI_CloakCommand, --MUI_CaptureCommand, --MUI_SensorPingCommand, --MUI_DeployMinesCommand, --MUI_ScuttleCommand, --MUI_TempWaypointCommand, --MUI_HW1SPHyperspaceCommand, --MUI_SalvageCommand, // GBX:pdeupree - Added for support of ships that have this command --MUI_SalCapCommand, // GBX:pdeupree - Support for Homeworld 1 SalCap Corvette --MUI_CustomCommand, // GBX:pdeupree - Added to support custom defined commands --MUI_KamikazeCommand, // GBX:pdeupree - Adding user control hooks for existing Kamikaze order CustomCommandDefinitions = { { commandID = INFO_CMD_Move, activateButtonName = "btnMove", rightClickDisplayName = "$3151", mainUIDefine = MUI_MoveCommand, }, { commandID = INFO_CMD_Attack, activateButtonName = "btnAttack", rightClickDisplayName = "$3152", mainUIDefine = MUI_AttackCommand, }, { commandID = INFO_CMD_AttackMove, activateButtonName = "btnAttackMove", }, { commandID = INFO_CMD_Guard, activateButtonName = "btnGuard", rightClickDisplayName = "$3153", mainUIDefine = MUI_GuardCommand, }, { commandID = INFO_CMD_Dock, activateButtonName = "btnDock", rightClickDisplayName = "$3154", mainUIDefine = MUI_DockCommand, }, { commandID = INFO_CMD_Stop, activateButtonName = "btnCancelOrders", rightClickDisplayName = "$3156", mainUIDefine = MUI_StopCommand, }, { commandID = INFO_CMD_Waypoints, activateButtonName = "btnWaypoint", rightClickDisplayName = "$3155", mainUIDefine = MUI_WaypointCommand, }, { commandID = INFO_CMD_Harvest, activateButtonName = "btnResource", rightClickDisplayName = "$3172", mainUIDefine = MUI_HarvestCommand, }, { commandID = INFO_CMD_Hyperspace, activateButtonName = "btnHyperspace", mainUIDefine = MUI_HyperspaceCommand, }, { commandID = INFO_CMD_Retire, activateButtonName = "btnRetire", rightClickDisplayName = "$3157", mainUIDefine = MUI_RetireCommand, }, { commandID = INFO_CMD_SensorPing, activateButtonName = "btnPing", rightClickDisplayName = "$3177", mainUIDefine = MUI_SensorPingCommand, }, { commandID = INFO_CMD_DefenseField, activateButtonName = "btnDefenseField", rightClickDisplayName = "$3173", mainUIDefine = MUI_DefenseFieldCommand; }, { commandID = INFO_CMD_Cloak, activateButtonName = "btnCloak", rightClickDisplayName = "$3174", mainUIDefine = MUI_CloakCommand, }, { commandID = INFO_CMD_Repair, activateButtonName = "btnRepair", rightClickDisplayName = "$3189", mainUIDefine = MUI_RepairCommand, }, { commandID = INFO_CMD_Mines, activateButtonName = "btnMines", rightClickDisplayName = "$3180", mainUIDefine = MUI_DeployMinesCommand, }, { commandID = INFO_CMD_RallyPoint, activateButtonName = "btnRally", mainUIDefine = MUI_SetRallyPoint, }, { commandID = INFO_CMD_RallyObject, activateButtonName = "btnRallyObject", mainUIDefine = MUI_SetRallyObject, }, { commandID = INFO_CMD_Scuttle, activateButtonName = "btnScuttle", rightClickDisplayName = "$3181", mainUIDefine = MUI_ScuttleCommand, }, { commandID = INFO_CMD_Capture, activateButtonName = "btnCapture", rightClickDisplayName = "$3175", mainUIDefine = MUI_CaptureCommand, }, { commandID = INFO_CMD_Salvage, rightClickDisplayName = "$3176", mainUIDefine = MUI_SalvageCommand, }, { commandID = INFO_CMD_SalCap, activateButtonName = "btnSalCap", rightClickDisplayName = "$3178", mainUIDefine = MUI_SalCapCommand, }, { commandID = INFO_CMD_Kamikaze, activateButtonName = "btnKamikaze", rightClickDisplayName = "$5307", mainUIDefine = MUI_KamikazeCommand, }, { commandID = INFO_CustomStart + 0, activateButtonName = "btnCustomActivate", rightClickDisplayName = "$4941", }, { commandID = INFO_CustomStart + 1, activateButtonName = "btnGravWellActivate", rightClickDisplayName = "$90107", }, { commandID = INFO_CustomStart + 2, activateButtonName = "btnDronesActivate", rightClickDisplayName = "$90109", }, { commandID = INFO_CustomStart + 3, activateButtonName = "btnSpeedActivate", rightClickDisplayName = "$5518", }, { commandID = INFO_CustomStart + 4, activateButtonName = "btnSwitch", rightClickDisplayName = "$90100", }, { commandID = INFO_CustomStart + 5, activateButtonName = "btnDeliver", rightClickDisplayName = "$90101", }, { commandID = INFO_CustomStart + 6, activateButtonName = "btnRelease", rightClickDisplayName = "$90105", }, -- SpecialAttacks have an unused "sentinel" at the beginning of the list, so these start at 1, not 0. { commandID = INFO_SpecialAttackStart + 1, activateButtonName = "btnEMP", rightClickDisplayName = "$2400", }, { commandID = INFO_SpecialAttackStart + 2, activateButtonName = "btnTrack", rightClickDisplayName = "$90126", }, { commandID = INFO_SpecialAttackStart + 3, rightClickDisplayName = "$2402", }, { commandID = INFO_SpecialAttackStart + 4, rightClickDisplayName = "$2403", }, { commandID = INFO_SpecialAttackStart + 5, activateButtonName = "btnMissileVolley", rightClickDisplayName = "$4941", }, { commandID = INFO_SpecialAttackStart + 6, activateButtonName = "btnBurstAttack", rightClickDisplayName = "$4942", }, }
nilq/small-lua-stack
null
-------------------------------------------------------------------------------- -- 表示オブジェクトの位置やサイズのレイアウトを更新する為のクラスです. -- このクラスでは、Box形式のオブジェクトを水平、垂直方向に配置する事が可能です. -------------------------------------------------------------------------------- -- import local table = require "hp/lang/table" local class = require "hp/lang/class" local BaseLayout = require "hp/layout/BaseLayout" -- class local super = BaseLayout local M = class(super) -- constraints -- Horizotal Align M.HORIZOTAL_LEFT = "left" M.HORIZOTAL_CENTER = "center" M.HORIZOTAL_RIGHT = "right" -- Vertical Align M.VERTICAL_TOP = "top" M.VERTICAL_CENTER = "center" M.VERTICAL_BOTTOM = "bottom" -- Direction M.DIRECTION_VERTICAL = "vertical" M.DIRECTION_HORIZOTAL = "horizotal" -------------------------------------------------------------------------------- -- 内部変数の初期化処理です. -------------------------------------------------------------------------------- function M:initInternal(params) self._horizotalAlign = M.HORIZOTAL_LEFT self._horizotalGap = 5 self._verticalAlign = M.VERTICAL_TOP self._verticalGap = 5 self._paddingTop = 0 self._paddingBottom = 0 self._paddingLeft = 0 self._paddingRight = 0 self._direction = M.DIRECTION_VERTICAL self._parentResizable = true end -------------------------------------------------------------------------------- -- 指定した親コンポーネントのレイアウトを更新します. -------------------------------------------------------------------------------- function M:update(parent) if self._direction == M.DIRECTION_VERTICAL then self:updateVertical(parent) elseif self._direction == M.DIRECTION_HORIZOTAL then self:updateHorizotal(parent) end end -------------------------------------------------------------------------------- -- 垂直方向に子オブジェクトを配置します. -------------------------------------------------------------------------------- function M:updateVertical(parent) local children = parent:getChildren() local childrenWidth, childrenHeight = self:getVerticalLayoutSize(children) local parentWidth, parentHeight = parent:getSize() local parentWidth = parentWidth > childrenWidth and parentWidth or childrenWidth local parentHeight = parentHeight > childrenHeight and parentHeight or childrenHeight if self._parentResizable then parent:setSize(parentWidth, parentHeight) end local childY = self:getChildY(parentHeight, childrenHeight) for i, child in ipairs(children) do if child.isIncludeLayout == nil or child:isIncludeLayout() then local childWidth, childHeight = child:getSize() local childX = self:getChildX(parentWidth, childWidth) child:setPos(childX, childY) childY = childY + childHeight + self._verticalGap end end end -------------------------------------------------------------------------------- -- 水平方向に子オブジェクトを配置します. -------------------------------------------------------------------------------- function M:updateHorizotal(parent) local children = parent:getChildren() local childrenWidth, childrenHeight = self:getHorizotalLayoutSize(children) local parentWidth, parentHeight = parent:getSize() local parentWidth = parentWidth > childrenWidth and parentWidth or childrenWidth local parentHeight = parentHeight > childrenHeight and parentHeight or childrenHeight if self._parentResizable then parent:setSize(parentWidth, parentHeight) end local childX = self:getChildX(parentWidth, childrenWidth) for i, child in ipairs(children) do if child.isIncludeLayout == nil or child:isIncludeLayout() then local childWidth, childHeight = child:getSize() local childY = self:getChildY(parentHeight, childHeight) child:setPos(childX, childY) childX = childX + childWidth + self._horizotalGap end end end -------------------------------------------------------------------------------- -- 上下左右の余白を設定します. -------------------------------------------------------------------------------- function M:setPadding(left, top, right, bottom) self._paddingLeft = left or self._paddingTop self._paddingTop = top or self._paddingTop self._paddingRight = right or self._paddingRight self._paddingBottom = bottom or self._paddingBottom end -------------------------------------------------------------------------------- -- 上下左右の余白を設定します. -------------------------------------------------------------------------------- function M:getPadding() return self._paddingLeft, self._paddingTop, self._paddingRight, self._paddingBottom end -------------------------------------------------------------------------------- -- アラインを設定します. -------------------------------------------------------------------------------- function M:setAlign(horizotalAlign, verticalAlign) self._horizotalAlign = horizotalAlign self._verticalAlign = verticalAlign end -------------------------------------------------------------------------------- -- アラインを返します. -------------------------------------------------------------------------------- function M:getAlign() return self._horizotalAlign, self._verticalAlign end -------------------------------------------------------------------------------- -- コンポーネントを配置する方向を設定します. -------------------------------------------------------------------------------- function M:setDirection(direction) self._direction = direction end -------------------------------------------------------------------------------- -- コンポーネントを配置する方向を返します. -------------------------------------------------------------------------------- function M:getDirection() return self._direction end -------------------------------------------------------------------------------- -- コンポーネントの間隔を設定します. -------------------------------------------------------------------------------- function M:setGap(horizotalGap, verticalGap) self._horizotalGap = horizotalGap self._verticalGap = verticalGap end -------------------------------------------------------------------------------- -- コンポーネントの間隔を返します.. -------------------------------------------------------------------------------- function M:getGap() return self._horizotalGap, self._verticalGap end -------------------------------------------------------------------------------- -- 子オブジェクトのX座標を返します. -------------------------------------------------------------------------------- function M:getChildX(parentWidth, childWidth) local diffWidth = parentWidth - childWidth local x = 0 if self._horizotalAlign == M.HORIZOTAL_LEFT then x = self._paddingLeft elseif self._horizotalAlign == M.HORIZOTAL_CENTER then x = math.floor((diffWidth + self._paddingLeft - self._paddingRight) / 2) elseif self._horizotalAlign == M.HORIZOTAL_RIGHT then x = diffWidth - self._paddingRight else error("Not found direction!") end return x end -------------------------------------------------------------------------------- -- 子オブジェクトのY座標を返します. -------------------------------------------------------------------------------- function M:getChildY(parentHeight, childHeight) local diffHeight = parentHeight - childHeight local y = 0 if self._verticalAlign == M.VERTICAL_TOP then y = self._paddingTop elseif self._verticalAlign == M.VERTICAL_CENTER then y = math.floor((diffHeight + self._paddingTop - self._paddingBottom) / 2) elseif self._verticalAlign == M.VERTICAL_BOTTOM then y = diffHeight - self._paddingBottom else error("Not found direction!") end return y end -------------------------------------------------------------------------------- -- 垂直方向に子オブジェクトを配置した時の -- 全体のレイアウトサイズを返します. -------------------------------------------------------------------------------- function M:getVerticalLayoutSize(children) local width = self._paddingLeft + self._paddingRight local height = self._paddingTop + self._paddingBottom local count = 0 for i, child in ipairs(children) do if child.isIncludeLayout == nil or child:isIncludeLayout() then local cWidth, cHeight = child:getSize() height = height + cHeight + self._verticalGap width = math.max(width, cWidth) count = count + 1 end end if count > 1 then height = height - self._verticalGap end return width, height end -------------------------------------------------------------------------------- -- 水平方向に子オブジェクトを配置した時の -- 全体のレイアウトサイズを返します. -------------------------------------------------------------------------------- function M:getHorizotalLayoutSize(children) local width = self._paddingLeft + self._paddingRight local height = self._paddingTop + self._paddingBottom local count = 0 for i, child in ipairs(children) do if child.isIncludeLayout == nil or child:isIncludeLayout() then local cWidth, cHeight = child:getSize() width = width + cWidth + self._horizotalGap height = math.max(height, cHeight) count = count + 1 end end if count > 1 then width = width - self._horizotalGap end return width, height end return M
nilq/small-lua-stack
null
function genTransportBelts(inputs) --Set name local transportBeltName = inputs.copy.name.preName .. "transport-belt" .. inputs.copy.name.postName local undergroundName = inputs.copy.name.preName .. "underground-belt" .. inputs.copy.name.postName local splitterName = inputs.copy.name.preName .. "splitter" .. inputs.copy.name.postName local loaderName = inputs.copy.name.preName .. "loader" .. inputs.copy.name.postName -- Technology local tech = table.deepcopy(data.raw.technology[inputs.copy.tech]) local loaderTech = table.deepcopy(data.raw.technology[inputs.copy.tech]) -- Copy transport belt local itemTransportBelt = table.deepcopy(data.raw.item[transportBeltName]) local recipeTransportBelt = table.deepcopy(data.raw.recipe[transportBeltName]) local entityTransportBelt = table.deepcopy(data.raw["transport-belt"][transportBeltName]) --Items -- transport belt if inputs.new then itemTransportBelt.name = "5d-transport-belt-" .. inputs.number end itemTransportBelt.icon = "__5dim_transport__/graphics/icon/transport-belt/transport-belt-icon-" .. inputs.number .. ".png" itemTransportBelt.subgroup = "transport-belt" itemTransportBelt.order = inputs.order itemTransportBelt.place_result = itemTransportBelt.name --Recipe recipeTransportBelt.name = itemTransportBelt.name recipeTransportBelt.icon = itemTransportBelt.icon recipeTransportBelt.result = itemTransportBelt.name recipeTransportBelt.icon_size = 64 if recipeTransportBelt.normal == nil then recipeTransportBelt.ingredients = inputs.ingredients.transportBelt recipeTransportBelt.result = itemTransportBelt.name if inputs.new then recipeTransportBelt.enabled = false end else if inputs.new then recipeTransportBelt.enabled = false end recipeTransportBelt.enabled = false if inputs.new then recipeTransportBelt.ingredients = inputs.ingredients.transportBelt recipeTransportBelt.result = itemTransportBelt.name recipeTransportBelt.normal = nil recipeTransportBelt.expensive = nil else recipeTransportBelt.normal.ingredients = inputs.ingredients.transportBelt recipeTransportBelt.normal.result = itemTransportBelt.name end end --Entity entityTransportBelt.name = itemTransportBelt.name entityTransportBelt.next_upgrade = inputs.nextUpdate.transportBelt or nil entityTransportBelt.icon = itemTransportBelt.icon entityTransportBelt.minable.result = itemTransportBelt.name entityTransportBelt.speed = inputs.speed -- East if inputs.number ~= "01" then entityTransportBelt.belt_animation_set.animation_set.hr_version.filename = "__5dim_transport__/graphics/entities/transport-belt/transport-belt-" .. inputs.number .. ".png" end data:extend({entityTransportBelt, recipeTransportBelt, itemTransportBelt}) -- Copy underground transport belt local itemUndergroundBelt = table.deepcopy(data.raw.item[undergroundName]) local recipeUndergroundBelt = table.deepcopy(data.raw.recipe[undergroundName]) local entityUndergroundBelt = table.deepcopy(data.raw["underground-belt"][undergroundName]) -- underground transport belt if inputs.new then itemUndergroundBelt.name = "5d-underground-belt-" .. inputs.number end itemUndergroundBelt.icon = "__5dim_transport__/graphics/icon/underground-belt/underground-belt-icon-" .. inputs.number .. ".png" itemUndergroundBelt.subgroup = "transport-ground" itemUndergroundBelt.order = inputs.order itemUndergroundBelt.place_result = itemUndergroundBelt.name --Recipe recipeUndergroundBelt.name = itemUndergroundBelt.name recipeUndergroundBelt.icon = itemUndergroundBelt.icon recipeUndergroundBelt.icon_size = 64 if recipeUndergroundBelt.normal == nil then recipeUndergroundBelt.ingredients = inputs.ingredients.groundBelt recipeUndergroundBelt.result = itemUndergroundBelt.name recipeUndergroundBelt.enabled = false else recipeUndergroundBelt.enabled = false if inputs.new then recipeUndergroundBelt.ingredients = inputs.ingredients.groundBelt recipeUndergroundBelt.result = itemUndergroundBelt.name recipeUndergroundBelt.normal = nil recipeUndergroundBelt.expensive = nil else recipeUndergroundBelt.normal.ingredients = inputs.ingredients.groundBelt recipeUndergroundBelt.normal.result = itemUndergroundBelt.name end end --Entity entityUndergroundBelt.name = itemUndergroundBelt.name entityUndergroundBelt.next_upgrade = inputs.nextUpdate.groundBelt or nil entityUndergroundBelt.icon = itemUndergroundBelt.icon entityUndergroundBelt.minable.result = itemUndergroundBelt.name entityUndergroundBelt.speed = inputs.speed if inputs.number ~= "01" then entityUndergroundBelt.belt_animation_set.animation_set.hr_version.filename = "__5dim_transport__/graphics/entities/transport-belt/transport-belt-" .. inputs.number .. ".png" end entityUndergroundBelt.structure.direction_in.sheet.hr_version.filename = "__5dim_transport__/graphics/entities/underground-belt/underground-belt-" .. inputs.number .. ".png" entityUndergroundBelt.structure.direction_out.sheet.hr_version.filename = "__5dim_transport__/graphics/entities/underground-belt/underground-belt-" .. inputs.number .. ".png" entityUndergroundBelt.structure.direction_in_side_loading.sheet.hr_version.filename = "__5dim_transport__/graphics/entities/underground-belt/underground-belt-" .. inputs.number .. ".png" entityUndergroundBelt.structure.direction_out_side_loading.sheet.hr_version.filename = "__5dim_transport__/graphics/entities/underground-belt/underground-belt-" .. inputs.number .. ".png" data:extend({entityUndergroundBelt, recipeUndergroundBelt, itemUndergroundBelt}) -- Copy underground transport belt x30 local itemUndergroundBelt30 = table.deepcopy(data.raw.item[undergroundName]) local recipeUndergroundBelt30 = table.deepcopy(data.raw.recipe[undergroundName]) local entityUndergroundBelt30 = table.deepcopy(data.raw["underground-belt"][undergroundName]) -- underground transport belt itemUndergroundBelt30.name = "5d-" .. inputs.name.preName .. "underground-belt-30-" .. inputs.number itemUndergroundBelt30.icon = "__5dim_transport__/graphics/icon/underground-belt-30/underground-belt-icon-" .. inputs.number .. "-30.png" itemUndergroundBelt30.subgroup = "transport-ground-30" itemUndergroundBelt30.order = inputs.order itemUndergroundBelt30.place_result = itemUndergroundBelt30.name --Recipe recipeUndergroundBelt30.name = itemUndergroundBelt30.name recipeUndergroundBelt30.icon = itemUndergroundBelt30.icon recipeUndergroundBelt30.result = itemUndergroundBelt30.name recipeUndergroundBelt30.icon_size = 64 recipeUndergroundBelt30.enabled = false if recipeUndergroundBelt30.normal == nil then recipeUndergroundBelt30.ingredients = inputs.ingredients.groundBelt30 recipeUndergroundBelt30.result = itemUndergroundBelt30.name recipeUndergroundBelt30.enabled = false else recipeUndergroundBelt30.enabled = false if inputs.new then recipeUndergroundBelt30.ingredients = inputs.ingredients.groundBelt30 recipeUndergroundBelt30.result = itemUndergroundBelt30.name recipeUndergroundBelt30.normal = nil recipeUndergroundBelt30.expensive = nil else recipeUndergroundBelt30.normal.ingredients = inputs.ingredients.groundBelt30 recipeUndergroundBelt30.normal.result = itemUndergroundBelt30.name end end --Entity entityUndergroundBelt30.name = itemUndergroundBelt30.name entityUndergroundBelt30.next_upgrade = inputs.nextUpdate.groundBelt30 or nil entityUndergroundBelt30.icon = itemUndergroundBelt30.icon entityUndergroundBelt30.minable.result = itemUndergroundBelt30.name entityUndergroundBelt30.max_distance = 30 entityUndergroundBelt30.speed = inputs.speed if inputs.number ~= "01" then entityUndergroundBelt30.belt_animation_set.animation_set.hr_version.filename = "__5dim_transport__/graphics/entities/transport-belt/transport-belt-" .. inputs.number .. ".png" end entityUndergroundBelt30.structure.direction_in.sheet.hr_version.filename = "__5dim_transport__/graphics/entities/underground-belt/underground-belt-" .. inputs.number .. ".png" entityUndergroundBelt30.structure.direction_out.sheet.hr_version.filename = "__5dim_transport__/graphics/entities/underground-belt/underground-belt-" .. inputs.number .. ".png" entityUndergroundBelt30.structure.direction_in_side_loading.sheet.hr_version.filename = "__5dim_transport__/graphics/entities/underground-belt/underground-belt-" .. inputs.number .. ".png" entityUndergroundBelt30.structure.direction_out_side_loading.sheet.hr_version.filename = "__5dim_transport__/graphics/entities/underground-belt/underground-belt-" .. inputs.number .. ".png" data:extend({entityUndergroundBelt30, recipeUndergroundBelt30, itemUndergroundBelt30}) -- Copy underground transport belt x50 local itemUndergroundBelt50 = table.deepcopy(data.raw.item[undergroundName]) local recipeUndergroundBelt50 = table.deepcopy(data.raw.recipe[undergroundName]) local entityUndergroundBelt50 = table.deepcopy(data.raw["underground-belt"][undergroundName]) -- underground transport belt itemUndergroundBelt50.name = "5d-" .. inputs.name.preName .. "underground-belt-50-" .. inputs.number itemUndergroundBelt50.icon = "__5dim_transport__/graphics/icon/underground-belt-50/underground-belt-icon-" .. inputs.number .. "-50.png" itemUndergroundBelt50.subgroup = "transport-ground-50" itemUndergroundBelt50.order = inputs.order itemUndergroundBelt50.place_result = itemUndergroundBelt50.name --Recipe recipeUndergroundBelt50.name = itemUndergroundBelt50.name recipeUndergroundBelt50.icon = itemUndergroundBelt50.icon recipeUndergroundBelt50.result = itemUndergroundBelt50.name recipeUndergroundBelt50.icon_size = 64 if recipeUndergroundBelt50.normal == nil then recipeUndergroundBelt50.ingredients = inputs.ingredients.groundBelt50 recipeUndergroundBelt50.result = itemUndergroundBelt50.name recipeUndergroundBelt50.enabled = false else recipeUndergroundBelt50.enabled = false if inputs.new then recipeUndergroundBelt50.ingredients = inputs.ingredients.groundBelt50 recipeUndergroundBelt50.result = itemUndergroundBelt50.name recipeUndergroundBelt50.normal = nil recipeUndergroundBelt50.expensive = nil else recipeUndergroundBelt50.normal.ingredients = inputs.ingredients.groundBelt50 recipeUndergroundBelt50.normal.result = itemUndergroundBelt50.name end end --Entity entityUndergroundBelt50.name = itemUndergroundBelt50.name entityUndergroundBelt50.next_upgrade = inputs.nextUpdate.groundBelt50 or nil entityUndergroundBelt50.icon = itemUndergroundBelt50.icon entityUndergroundBelt50.minable.result = itemUndergroundBelt50.name entityUndergroundBelt50.max_distance = 50 entityUndergroundBelt50.speed = inputs.speed if inputs.number ~= "01" then entityUndergroundBelt50.belt_animation_set.animation_set.hr_version.filename = "__5dim_transport__/graphics/entities/transport-belt/transport-belt-" .. inputs.number .. ".png" end entityUndergroundBelt50.structure.direction_in.sheet.hr_version.filename = "__5dim_transport__/graphics/entities/underground-belt/underground-belt-" .. inputs.number .. ".png" entityUndergroundBelt50.structure.direction_out.sheet.hr_version.filename = "__5dim_transport__/graphics/entities/underground-belt/underground-belt-" .. inputs.number .. ".png" entityUndergroundBelt50.structure.direction_in_side_loading.sheet.hr_version.filename = "__5dim_transport__/graphics/entities/underground-belt/underground-belt-" .. inputs.number .. ".png" entityUndergroundBelt50.structure.direction_out_side_loading.sheet.hr_version.filename = "__5dim_transport__/graphics/entities/underground-belt/underground-belt-" .. inputs.number .. ".png" data:extend({entityUndergroundBelt50, recipeUndergroundBelt50, itemUndergroundBelt50}) -- Copy splitter transport belt local itemSplitter = table.deepcopy(data.raw.item[splitterName]) local recipeSplitter = table.deepcopy(data.raw.recipe[splitterName]) local entitySplitter = table.deepcopy(data.raw["splitter"][splitterName]) -- underground transport belt if inputs.new then itemSplitter.name = "5d-splitter-" .. inputs.number end itemSplitter.icon = "__5dim_transport__/graphics/icon/splitter/splitter-icon-" .. inputs.number .. ".png" itemSplitter.subgroup = "transport-splitters" itemSplitter.order = inputs.order itemSplitter.place_result = itemSplitter.name --Recipe recipeSplitter.name = itemSplitter.name recipeSplitter.icon = itemSplitter.icon recipeSplitter.result = itemSplitter.name recipeSplitter.icon_size = 64 if recipeSplitter.normal == nil then recipeSplitter.ingredients = inputs.ingredients.splitter recipeSplitter.result = itemSplitter.name recipeSplitter.enabled = false else recipeSplitter.enabled = false if inputs.new then recipeSplitter.ingredients = inputs.ingredients.splitter recipeSplitter.result = itemSplitter.name recipeSplitter.normal = nil recipeSplitter.expensive = nil else recipeSplitter.normal.ingredients = inputs.ingredients.splitter recipeSplitter.normal.result = itemSplitter.name end end --Entity entitySplitter.name = itemSplitter.name entitySplitter.next_upgrade = inputs.nextUpdate.splitter or nil entitySplitter.icon = itemSplitter.icon entitySplitter.minable.result = itemSplitter.name entitySplitter.speed = inputs.speed entitySplitter.belt_animation_set.animation_set.hr_version.filename = "__5dim_transport__/graphics/entities/transport-belt/transport-belt-" .. inputs.number .. ".png" entitySplitter.structure.north.hr_version.filename = "__5dim_transport__/graphics/entities/splitter/splitter-north/splitter-north-" .. inputs.number .. ".png" entitySplitter.structure.east.hr_version.filename = "__5dim_transport__/graphics/entities/splitter/splitter-east/splitter-east-" .. inputs.number .. ".png" entitySplitter.structure.south.hr_version.filename = "__5dim_transport__/graphics/entities/splitter/splitter-south/splitter-south-" .. inputs.number .. ".png" entitySplitter.structure.west.hr_version.filename = "__5dim_transport__/graphics/entities/splitter/splitter-west/splitter-west-" .. inputs.number .. ".png" entitySplitter.structure_patch.east.hr_version.filename = "__5dim_transport__/graphics/entities/splitter/splitter-east-top_patch/splitter-east-top_patch-" .. inputs.number .. ".png" entitySplitter.structure_patch.west.hr_version.filename = "__5dim_transport__/graphics/entities/splitter/splitter-west-top_patch/splitter-west-top_patch-" .. inputs.number .. ".png" if inputs.number == "01" or inputs.number == "02" then entitySplitter.structure.west.hr_version.width = 94 entitySplitter.structure_patch.west.hr_version.width = 94 end data:extend({entitySplitter, recipeSplitter, itemSplitter}) -- Copy loader transport belt local itemLoader = table.deepcopy(data.raw.item[loaderName]) local recipeLoader = table.deepcopy(data.raw.recipe[loaderName]) local entityLoader = table.deepcopy(data.raw["loader"][loaderName]) -- underground transport belt if inputs.new then itemLoader.name = "5d-loader-" .. inputs.number end itemLoader.icon = "__5dim_transport__/graphics/icon/loader/loader-icon-" .. inputs.number .. ".png" itemLoader.icon_size = 64 itemLoader.subgroup = "transport-loader" itemLoader.order = inputs.order itemLoader.flags = nil itemLoader.place_result = itemLoader.name --Recipe recipeLoader.name = itemLoader.name recipeLoader.icon = itemLoader.icon recipeLoader.result = itemLoader.name recipeLoader.icon_size = 64 if recipeLoader.normal == nil then recipeLoader.ingredients = inputs.ingredients.loader recipeLoader.result = itemLoader.name recipeLoader.enabled = false else recipeLoader.enabled = false if inputs.new then recipeLoader.ingredients = inputs.ingredients.loader recipeLoader.result = itemLoader.name recipeLoader.normal = nil recipeLoader.expensive = nil else recipeLoader.normal.ingredients = inputs.ingredients.loader recipeLoader.normal.result = itemLoader.name end end recipeLoader.hidden = false --Entity entityLoader.name = itemLoader.name entityLoader.next_upgrade = inputs.nextUpdate.loader or nil entityLoader.icon = itemLoader.icon entityLoader.minable.result = itemLoader.name entityLoader.speed = inputs.speed if inputs.number ~= "01" then entityLoader.belt_animation_set.animation_set.hr_version.filename = "__5dim_transport__/graphics/entities/transport-belt/transport-belt-" .. inputs.number .. ".png" end entityLoader.structure.direction_in.sheet.filename = "__5dim_transport__/graphics/entities/loader/loader-" .. inputs.number .. ".png" entityLoader.structure.direction_in.sheet.width = 128 entityLoader.structure.direction_in.sheet.height = 128 entityLoader.structure.direction_out.sheet.filename = "__5dim_transport__/graphics/entities/loader/loader-" .. inputs.number .. ".png" entityLoader.structure.direction_out.sheet.width = 128 entityLoader.structure.direction_out.sheet.height = 128 entityLoader.structure.direction_out.sheet.y = 128 entityLoader.flags = {"placeable-neutral", "player-creation", "fast-replaceable-no-build-while-moving"} if inputs.number ~= "09" and inputs.number ~= "10" then data:extend({entityLoader, recipeLoader, itemLoader}) end -- Technology if inputs.tech then tech.name = "logistics-" .. inputs.tech.number -- tech.icon = itemTransportBelt.icon -- tech.icon_size = 64 tech.unit.count = inputs.tech.count tech.unit.ingredients = inputs.tech.packs tech.prerequisites = inputs.tech.prerequisites if inputs.number ~= "09" and inputs.number ~= "10" then tech.effects = { { type = "unlock-recipe", recipe = itemTransportBelt.name }, { type = "unlock-recipe", recipe = itemUndergroundBelt.name }, { type = "unlock-recipe", recipe = itemSplitter.name }, { type = "unlock-recipe", recipe = itemUndergroundBelt30.name }, { type = "unlock-recipe", recipe = itemUndergroundBelt50.name }, { type = "unlock-recipe", recipe = entityLoader.name } } else tech.effects = { { type = "unlock-recipe", recipe = itemTransportBelt.name }, { type = "unlock-recipe", recipe = itemUndergroundBelt.name }, { type = "unlock-recipe", recipe = itemSplitter.name }, { type = "unlock-recipe", recipe = itemUndergroundBelt30.name }, { type = "unlock-recipe", recipe = itemUndergroundBelt50.name } } end data:extend({tech}) end end
nilq/small-lua-stack
null
mineunit("core") local protected_nodes = {} function mineunit:protect(pos, name_or_player) assert(type(name_or_player) == "string" or type(name_or_player) == "userdata", "mineunit:protect name_or_player should be string or userdata") local name = type(name_or_player) == "userdata" and name_or_player:get_player_name() or name_or_player protected_nodes[minetest.hash_node_position(pos)] = name end minetest.is_protected = function(pos, name) local nodeid = minetest.hash_node_position(pos) if protected_nodes[nodeid] == nil or protected_nodes[nodeid] == name then return false end return true end minetest.record_protection_violation = function(...) print("minetest.record_protection_violation", ...) end
nilq/small-lua-stack
null
local Color = require("Lib/StdLib/ConsoleColor"); local Route = require("Lib/Toolkit/Route"); local Style = require("Lib/Toolkit/Stylesheet"); local Package = obe.Package; local Functions = {}; function getPackageList() local parser = Vili.ViliParser.new(); parser:parseFile("Package/Packages.vili"); local allPackages = {}; for _, key in pairs(parser:root():getAll(Vili.NodeType.ComplexNode)) do table.insert(allPackages, key:getId()); end return allPackages; end function getUninstalledPackageList() local fileList = obe.Filesystem.getFileList("Package/"); local opaqueFiles = {}; local extension = ".opaque"; for _, file in pairs(fileList) do if file:sub(-extension:len()) == extension then table.insert(opaqueFiles, file:sub(1, #file - #extension)); end end return opaqueFiles; end function Functions.install(packageName) Color.print({ { text = "Installing Package '", color = Style.Execute}, { text = packageName, color = Style.Package}, { text = "' ...", color = Style.Execute}, }, 1) if Package.Install(packageName) then Color.print({ { text = "Package '", color = Style.Success}, { text = packageName, color = Style.Package}, { text = "' has been successfully installed", color = Style.Success} }, 2); local parser = Vili.ViliParser.new(); parser:parseFile("Package/Opaque.vili"); local tPackageName = parser:root():at("Meta"):getDataNode("name"):getString(); if parser:hasFlag("Mount") then obe.Filesystem.copy(Package.GetPackageLocation(tPackageName) .. "/Mount.vili", "Mount.vili"); end else Color.print({ { text = "Package '", color = Style.Error}, { text = packageName, color = Style.Package}, { text = "' has not been installed (Already installed ?)", color = Style.Error} }, 2); end end function Functions.mount(packageName) Color.print({ { text = "Mounting Package '", color = Style.Execute}, { text = packageName, color = Style.Package}, { text = "' ...", color = Style.Execute}, }, 1) if Package.PackageExists(packageName) then obe.Filesystem.copy(Package.GetPackageLocation(packageName) .. "/Mount.vili", "Mount.vili"); Color.print({ { text = "Package '", color = Style.Success}, { text = packageName, color = Style.Package}, { text = "' has been successfully mounted", color = Style.Success} }, 2); obe.MountPaths(); else Color.print({ { text = "Package '", color = Style.Error}, { text = packageName, color = Style.Package}, { text = "' does not exists", color = Style.Error} }, 2); end end function Functions.list() local allPackages = getPackageList(); Color.print({ { text = "All Registered Packages : ", color = Style.Execute} }, 1); for _, key in pairs(allPackages) do Color.print({ { text = "- Package : ", color = Style.Default}, { text = key, color = Style.Package} }, 2); end end return { Functions = Functions, Routes = { Route.Help("Commands to work with Packages"); install = Route.Node { Route.Help("Installs a Package"); packageName = Route.Arg { Route.Help("Name of the .opaque package file you want to install"); Route.Call("install"); Route.Autocomplete(getUninstalledPackageList); }; }; mount = Route.Node { Route.Help("Mount a Package"); packageName = Route.Arg { Route.Help("Name of the package you want to mount"); Route.Call("mount"); }; Route.Autocomplete(getPackageList) }; list = Route.Node { Route.Help("Lists all Packages"); Route.Call("list"); } } };
nilq/small-lua-stack
null
export type Spring = { Target: Vector3; Position: Vector3; Velocity: Vector3; Mass: number; Force: number; Damping: number; Speed: number; Shove: (self: Spring, force: Vector3) -> (); Update: (self: Spring, deltaTime: number) -> (); new: (mass: number, force: number, damping: number, speed: number) -> (Spring); } local ITERATIONS = 8 -- GOTTA GO FAST local v3 = Vector3.new local min, _ = math.min, math.max local huge = math.huge local Spring = {} Spring.__index = Spring local function unmathhuge(num: number) if num == huge or num == -huge then return 0 end return num end function Spring.Shove(self: Spring, force: Vector3): Spring local x = unmathhuge(force.X) local y = unmathhuge(force.Y) local z = unmathhuge(force.Z) self.Velocity = self.Velocity + v3(x, y, z) return self end function Spring.Update(self: Spring, deltaTime: number): Spring local scaledDeltaTime = min(deltaTime, 1) * self.Speed / ITERATIONS for _ = 1, ITERATIONS do local iterationForce = self.Target - self.Position local acceleration = (iterationForce * self.Force) / self.Mass acceleration = acceleration - self.Velocity * self.Damping self.Velocity = self.Velocity + acceleration * scaledDeltaTime self.Position = self.Position + self.Velocity * scaledDeltaTime end return self end function Spring.new(mass: number, force: number, damping: number, speed: number) local self = { Target = v3(); Position = v3(); Velocity = v3(); Mass = mass or 5; Force = force or 50; Damping = damping or 4; Speed = speed or 4; } return setmetatable(self, Spring) end return Spring
nilq/small-lua-stack
null
--[[ Mark a mailbox as set up in the database. ]] -- Mailbox info. mailbox = args(1) domain = args(2) return { { action = "data_update", handler = "odbc", config = profile.db_config_mailbox, fields = { mailbox_setup_complete = "yes", }, filters = { mailbox = mailbox, domain = domain, }, update_type = "update", }, }
nilq/small-lua-stack
null
local const = {} --сила трения воздуха const.K_FORCE_SKY = 10 --сила трения о поверхность const.K_FORCE_GROUNG = 100 --"потолок" мира const.WORLD_LIMITY = -10000 const.BG_COLOR = { 0.62, 0.85, 0.9, 1.0 } --силушка дефолтной поняши в лошадиных силах const.FORCE_PONY = 1000 --todo --const.PONIES = { -- default = { -- FORCE = 1000 -- } --} --различные коэффициенты const.K_PONY_FORCE_FLY_Y = 0.3 const.K_PONY_FORCE_FLY_DJITTING = 0.05 const.K_PONY_JUMP = 0.5 const.K_PONY_R = math.pi * 0.5 const.K_PONY_ROTATE = 1000 const.K_PONY_P = 1.5 const.K_PONY_I = 100 --todo --const.SPRITE_KEY_POINTS_GROUND = { 0.0, 0.25, 0.8, 1.0 } --const.SPRITE_KEY_POINTS_FLY = { 0.0, 0.25, 0.8, 1.0 } --высота половины полоски хитпойнтов const.UI_HP_H_HALF = 4 const.UI_HP_KEY_POINTS = { 0.0, 0.25, 0.8, 1.0 } const.UI_HP_COLOR_GREEN = { 0.0, 0.7, 0.0, 1.0 } const.UI_HP_COLOR2 = { 0.7, 0.7, 0.0, 1.0 } const.UI_HP_COLOR_RED = { 1.0, 0.0, 0.0, 1.0 } const.UI_FORCE_X0 = 40 const.UI_FORCE_SIZE = 8 const.UI_FORCE_COLOR = { 0.8, 0.0, 0.0, 0.7 } const.UI_SPEED_X0 = 40 const.UI_SPEED_STEP = 15 const.UI_SPEED_SIZE = 8 const.UI_SPEED_COLOR = { 0.0, 0.0, 0.0, 0.7 } const.UI_SPEED_K = 0.05 --безопасная скорость, удары об другие объекты при которой не причиняют урон const.DAMAGE_SAFE_SPEED = 5 --коэффициент в формуле кинетической энергии const.K_DAMAGE = 0.01 --штраф за полёты на слишком большой высоте. HP/sec const.DAMAGE_OVERFLY = 5 --автовосстановление const.DAMAGE_NONE = 0.2 assert(#const.UI_HP_KEY_POINTS == 4) return const
nilq/small-lua-stack
null
local haslualine, lualine = pcall(require, 'lualine') local theme='OceanicNext' if haslualine then lualine.setup{ options={ theme = theme, }, sections = { lualine_a = {'mode'}, lualine_b = {'branch'}, lualine_c = {'filename'}, lualine_x = {'encoding', 'fileformat', 'filetype'}, lualine_y = {'progress'}, lualine_z = {'location'} }, inactive_sections = { lualine_a = {}, lualine_b = {}, lualine_c = {'filename'}, lualine_x = {'encoding', 'fileformat', 'filetype'}, lualine_y = {}, lualine_z = {} }, extensions = {'fzf'} } end
nilq/small-lua-stack
null
-- This file is subject to copyright - contact [email protected] for more information. function EntityCount(class) _CacheEntityCount(class) return _entity_counts[class] end _entity_counts = _entity_counts or {} function _CacheEntityCount(class) if _entity_counts[class] == nil then _entity_counts[class] = #ents.FindByClass(class) return false end return true end hook.Add("OnEntityCreated", "_entity_counts_add", function(ent) local class = ent:GetClass() -- It seems to already be added to ents.FindByClass if _CacheEntityCount(class) then _entity_counts[class] = _entity_counts[class] + 1 end end) hook.Add("EntityRemoved", "_entity_counts_subtract", function(ent) local class = ent:GetClass() -- It seems to already be removed from ents.FindByClass if _CacheEntityCount(class) then _entity_counts[class] = _entity_counts[class] - 1 end end) function _AssertEntityCounts() for k, v in pairs(ents.GetAll()) do assert(EntityCount(v:GetClass()) == #ents.FindByClass(v:GetClass())) end end
nilq/small-lua-stack
null
project "lua_fenestra" language "C++" files { "code/**.cpp" , "code/**.c" , "code/**.h" , "all.h" } includedirs { "../lib_freetype/freetype/include/" } includedirs { "../lib_sx/src/" } links { "lib_lua" } defines { "LUA_LIB" } if WINDOWS then links { "opengl32" , "glu32" } else -- nix links { "GL" , "GLU" } --[[ local fp=assert(io.popen("pkg-config --cflags libsx")) local s=assert(fp:read("*l")) buildoptions { s } fp:close() local fp=assert(io.popen("pkg-config --libs libsx")) local s=assert(fp:read("*l")) linkoptions { s } fp:close() ]] end includedirs { "." } KIND{kind="lua",dir="fenestra",name="core",luaname="fenestra.core",luaopen="fenestra_core"}
nilq/small-lua-stack
null
-- title: Raycast Engine Demo -- author: Wojciech Graj -- desc: Demo of a WolfenStein3D-style raycast engine with variable-height walls. -- script: lua -- input: gamepad Entity = { pos_x = 0, pos_y = 0, dir_x = -1, dir_y = 0, plane_x = 0, plane_y = 0.8, speed_rot = 0, speed_move = 0, } Entity.__index = Entity function Entity.new(pos_x, pos_y, speed_rot, speed_move) local self = setmetatable({}, Entity) self.pos_x = pos_x self.pos_y = pos_y self.speed_rot = speed_rot self.speed_move = speed_move return self end function Entity:rotate(delta) local speed = self.speed_rot * delta local old_dir_x = self.dir_x local math_cos = math.cos local math_sin = math.sin self.dir_x = self.dir_x * math_cos(speed) - self.dir_y * math_sin(speed) self.dir_y = old_dir_x * math_sin(speed) + self.dir_y * math_cos(speed) local old_plane_x = self.plane_x self.plane_x = self.plane_x * math_cos(speed) - self.plane_y * math_sin(speed) self.plane_y = old_plane_x * math_sin(speed) + self.plane_y * math_cos(speed) end function Entity:move(delta) local speed = self.speed_move * delta local math_floor = math.floor if mget(math_floor(self.pos_x + self.dir_x * speed), math_floor(self.pos_y)) == 0 then self.pos_x = self.pos_x + self.dir_x * speed end if mget(math_floor(self.pos_x), math_floor(self.pos_y + self.dir_y * speed)) == 0 then self.pos_y = self.pos_y + self.dir_y * speed end end Player = { } Player.__index = Player setmetatable(Player, Entity) function Player.new(pos_x, pos_y, speed_rot, speed_move) local self = setmetatable({}, Player) self.pos_x = pos_x self.pos_y = pos_y self.speed_rot = speed_rot self.speed_move = speed_move return self end function Player:process(delta) if btn(2) then self:rotate(delta) elseif btn(3) then self:rotate(-delta) end if btn(0) then self:move(delta) elseif btn(1) then self:move(-delta) end end Sprite = { pos_x = 0, pos_y = 0, tex_id = 0, scl_horiz = 1, scl_vert = 1, offset_vert = 0, --from 0.5 (floor) to -0.5 (ceiling) screen_offset_vert = 0, dist = 0, --Distance to player (negative if not in viewing triangle) screen_x = 0, SCREEN_WIDTH = 0, SCREEN_HEIGHT = 0, draw_start_y = 0, draw_end_y = 0, draw_start_x = 0, draw_end_x = 0, } Sprite.__index = Sprite function Sprite.new(pos_x, pos_y, tex_id, scl_horiz, scl_vert, offset_vert) local self = setmetatable({}, Sprite) self.pos_x = pos_x self.pos_y = pos_y self.tex_id = tex_id self.scl_horiz = scl_horiz self.scl_vert = scl_vert self.offset_vert = offset_vert return self end function Sprite:process(inv_det) local SCREEN_WIDTH = g_SCREEN_WIDTH local SCREEN_HEIGHT = g_SCREEN_HEIGHT local SCREEN_HALF_HEIGHT = SCREEN_HEIGHT / 2 local player = g_player local math_abs = math.abs local rel_x = self.pos_x - player.pos_x local rel_y = self.pos_y - player.pos_y self.dist = math.sqrt(rel_x * rel_x + rel_y * rel_y) local trans_y = inv_det * (player.plane_x * rel_y - player.plane_y * rel_x) if trans_y <= 0 then self.dist = -self.dist return end local trans_x = inv_det * (player.dir_y * rel_x - player.dir_x * rel_y) self.screen_x = math.floor((SCREEN_WIDTH * 0.5) * (1 + trans_x / trans_y)) self.SCREEN_WIDTH = math_abs(SCREEN_HEIGHT // trans_y) // self.scl_horiz self.draw_start_x = self.screen_x - self.SCREEN_WIDTH // 2 if self.draw_start_x < 0 then self.draw_start_x = 0 elseif self.draw_start_x >= SCREEN_WIDTH then self.dist = -self.dist return end self.draw_end_x = self.screen_x + self.SCREEN_WIDTH // 2 if self.draw_end_x >= SCREEN_WIDTH then self.draw_end_x = SCREEN_WIDTH - 1 elseif self.draw_end_x < 0 then self.dist = -self.dist return end self.SCREEN_HEIGHT = math_abs(SCREEN_HEIGHT // trans_y) // self.scl_vert self.screen_offset_vert = SCREEN_HALF_HEIGHT * self.offset_vert // trans_y self.draw_start_y = SCREEN_HALF_HEIGHT - self.SCREEN_HEIGHT // 2 + self.screen_offset_vert if self.draw_start_y < 0 then self.draw_start_y = 0 end self.draw_end_y = SCREEN_HALF_HEIGHT + self.SCREEN_HEIGHT // 2 + self.screen_offset_vert if self.draw_end_y >= SCREEN_HEIGHT then self.draw_end_y = SCREEN_HEIGHT - 1 end end function get_tex_pixel(offset, id, x, y) return peek4(offset + 0x40 * (id + 16 * (y // 8) + x // 8) + 0x8 * (y % 8) + (x % 8)) end function init() g_SCREEN_WIDTH = 240 g_SCREEN_HEIGHT = 136 g_DEBUG = true g_TEX_WIDTH = 16 g_TEX_HEIGHT = 16 g_SPRITE_SIZES = { [0]={16,16}, [2]={16,16}, } g_TEX_MAP = { [1]=1, [2]=3, [3]=5, [4]=7, [5]=9, } g_player = Player.new(22, 12, 0.001, 0.003) g_prev_time = 0 g_sprites = { Sprite.new(12, 13, 0, 2, 2, 0.5), Sprite.new(12.5, 12.5, 0, 2, 2, 0.5), Sprite.new(13, 13, 0, 2, 2, 0.5), Sprite.new(18.5, 6.5, 2, 2, 1, 0.125), } g_settings = { floor_ceil = true, interlace = 2, --disabled=g_interlace>=2 } end init() function TIC() local t = time() local delta = t - g_prev_time --msec since last frame g_prev_time = t local SCREEN_WIDTH = g_SCREEN_WIDTH local SCREEN_HEIGHT = g_SCREEN_HEIGHT local SCREEN_HALF_HEIGHT = SCREEN_HEIGHT // 2 local TEX_WIDTH = g_TEX_WIDTH local TEX_HEIGHT = g_TEX_HEIGHT local SPRITE_SIZES = g_SPRITE_SIZES local TEX_MAP = g_TEX_MAP local player = g_player local sprites = g_sprites local settings = g_settings local math_floor = math.floor local math_abs = math.abs local start_vline local step_vline if settings.interlace >= 2 then start_vline = 0 step_vline = 1 cls(0) else start_vline = (settings.interlace + 1) % 2 settings.interlace = start_vline step_vline = 2 for x=start_vline,SCREEN_WIDTH-1,step_vline do for y=0,SCREEN_HEIGHT-1 do pix(x, y, 0) end end end -- game logic t = time() player:process(delta) if btnp(4) then if settings.interlace >= 2 then settings.interlace = 0 else settings.interlace = 2 end end if btnp(5) then settings.floor_ceil = not settings.floor_ceil end local t_temp = time() local t_logic = t_temp - t t = t_temp -- drawing local inv_det = 1 / (player.plane_x * player.dir_y - player.dir_x * player.plane_y) local visible_sprites = {} for key,sprite in pairs(sprites) do sprite:process(inv_det) if sprite.dist > 0 then visible_sprites[#visible_sprites+1] = sprite end end table.sort(visible_sprites, function(a,b) return a.dist < b.dist end) local num_visible_sprites = #visible_sprites -- draw walls and sprites for x=start_vline,SCREEN_WIDTH-1,step_vline do local camera_x = 2 * x / SCREEN_WIDTH - 1 local ray_dir_x = player.dir_x + player.plane_x * camera_x local ray_dir_y = player.dir_y + player.plane_y * camera_x local map_x = math_floor(player.pos_x) local map_y = math_floor(player.pos_y) local delta_dist_x = math_abs(1 / ray_dir_x) local delta_dist_y = math_abs(1 / ray_dir_y) local step_x local side_dist_x if ray_dir_x < 0 then step_x = -1 side_dist_x = (player.pos_x - map_x) * delta_dist_x else step_x = 1 side_dist_x = (map_x + 1.0 - player.pos_x) * delta_dist_x end local step_y local side_dist_y if ray_dir_y < 0 then step_y = -1 side_dist_y = (player.pos_y - map_y) * delta_dist_y else step_y = 1 side_dist_y = (map_y + 1.0 - player.pos_y) * delta_dist_y end local current_sprite = 1 local not_hit_full_wall = true local prev_draw_start = SCREEN_HEIGHT while not_hit_full_wall do -- Get next wall tile using DDA local side local tile_data while true do if side_dist_x < side_dist_y then side_dist_x = side_dist_x + delta_dist_x map_x = map_x + step_x side = 0 else side_dist_y = side_dist_y + delta_dist_y map_y = map_y + step_y side = 1 end tile_data = mget(map_x, map_y) if tile_data > 0 then break end end local perp_wall_dist if side == 0 then perp_wall_dist = (map_x - player.pos_x + (1 - step_x) * 0.5) / ray_dir_x else perp_wall_dist = (map_y - player.pos_y + (1 - step_y) * 0.5) / ray_dir_y end --draw sprites for sprite_idx=current_sprite,num_visible_sprites do local sprite = visible_sprites[sprite_idx] if sprite.dist >= perp_wall_dist then break end current_sprite = sprite_idx + 1 if x >= sprite.draw_start_x and x <= sprite.draw_end_x then local sprite_size = SPRITE_SIZES[sprite.tex_id] local a = sprite_size[2] / sprite.SCREEN_HEIGHT local sprite_tex_x = math_floor((x - (sprite.screen_x - sprite.SCREEN_WIDTH / 2)) * sprite_size[1] / sprite.SCREEN_WIDTH) % sprite_size[1] for y=sprite.draw_start_y,sprite.draw_end_y do local tex_y = math_floor((y - sprite.screen_offset_vert - SCREEN_HALF_HEIGHT + sprite.SCREEN_HEIGHT / 2) * a) % sprite_size[2] local color = get_tex_pixel(0xC000, sprite.tex_id, sprite_tex_x, tex_y) if color > 0 and pix(x, y) == 0 then pix(x, y, color) end end end end --draw wall local tile_height = tile_data // 16 / 16 -- 0=full height, 1=no height if tile_height == 0 then not_hit_full_wall = false end local line_height = SCREEN_HEIGHT // perp_wall_dist local draw_start = SCREEN_HALF_HEIGHT + math_floor(line_height * (tile_height - 0.5)) + 1 if draw_start < 0 then draw_start = 0 elseif draw_start >= SCREEN_HEIGHT then draw_start = SCREEN_HEIGHT - 1 end local draw_end = SCREEN_HALF_HEIGHT + line_height // 2 - 1 if draw_end > prev_draw_start then draw_end = prev_draw_start elseif draw_end >= SCREEN_HEIGHT then draw_end = SCREEN_HEIGHT - 1 end local wall_x if side == 0 then wall_x = player.pos_y + perp_wall_dist * ray_dir_y else wall_x = player.pos_x + perp_wall_dist * ray_dir_x end wall_x = wall_x - math_floor(wall_x) local tex_id = TEX_MAP[tile_data % 16] local tex_x = math_floor(wall_x * TEX_WIDTH) local step_tex = TEX_HEIGHT / line_height local testart_vline = (draw_start - SCREEN_HALF_HEIGHT + line_height * 0.5) * step_tex for y=draw_start,draw_end do if pix(x, y) == 0 then local tex_y = math_floor(testart_vline + step_tex * (y - draw_start)) % TEX_HEIGHT pix(x, y, get_tex_pixel(0x8000, tex_id, tex_x, tex_y)) end end --draw top of variable-height walls if tile_height > 0.5 then if side_dist_x < side_dist_y then perp_wall_dist = (map_x + step_x - player.pos_x + (1 - step_x) * 0.5) / ray_dir_x else perp_wall_dist = (map_y + step_y - player.pos_y + (1 - step_y) * 0.5) / ray_dir_y end line_height = SCREEN_HEIGHT // perp_wall_dist local top_draw_start = SCREEN_HALF_HEIGHT + math_floor(line_height * (tile_height - 0.5)) if top_draw_start >= SCREEN_HEIGHT then top_draw_start = SCREEN_HEIGHT - 1 end local row_distance_part = (2 * tile_height - 1) * SCREEN_HALF_HEIGHT for y=top_draw_start,draw_start - 1 do if pix(x, y) == 0 then local row_distance = row_distance_part / (y - SCREEN_HALF_HEIGHT) local floor_x = player.pos_x + row_distance * ray_dir_x local floor_y = player.pos_y + row_distance * ray_dir_y local tex_x = math_floor(TEX_WIDTH * floor_x) % TEX_WIDTH local tex_y = math_floor(TEX_HEIGHT * floor_y) % TEX_HEIGHT pix(x, y, get_tex_pixel(0x8000, tex_id, tex_x, tex_y)) end end prev_draw_start = top_draw_start else prev_draw_start = draw_start end end end t_temp = time() local t_wall_sprite = t_temp - t t = t_temp --draw floor + ceiling if settings.floor_ceil then local ray_dir_x0 = player.dir_x - player.plane_x local ray_dir_y0 = player.dir_y - player.plane_y local ray_dir_x1 = player.dir_x + player.plane_x local ray_dir_y1 = player.dir_y + player.plane_y for y=SCREEN_HALF_HEIGHT,SCREEN_HEIGHT do local row_distance = SCREEN_HALF_HEIGHT / (y - SCREEN_HALF_HEIGHT) local floor_step_x = row_distance * (ray_dir_x1 - ray_dir_x0) / SCREEN_WIDTH local floor_step_y = row_distance * (ray_dir_y1 - ray_dir_y0) / SCREEN_WIDTH local floor_x = player.pos_x + row_distance * ray_dir_x0 + start_vline * floor_step_x local floor_y = player.pos_y + row_distance * ray_dir_y0 + start_vline * floor_step_y floor_step_x = floor_step_x * step_vline floor_step_y = floor_step_y * step_vline for x=start_vline,SCREEN_WIDTH-1,step_vline do local tex_x = math_floor(TEX_WIDTH * floor_x) % TEX_WIDTH local tex_y = math_floor(TEX_HEIGHT * floor_y) % TEX_HEIGHT --draw floor if pix(x, y) == 0 then pix(x, y, get_tex_pixel(0x8000, 3, tex_x, tex_y)) --[CONST] end --draw ceiling if pix(x, SCREEN_HEIGHT - y - 1) == 0 then pix(x, SCREEN_HEIGHT - y - 1, get_tex_pixel(0x8000, 5, tex_x, tex_y)) --[CONST] end floor_x = floor_x + floor_step_x floor_y = floor_y + floor_step_y end end end t_temp = time() local t_floor = t_temp - t if g_DEBUG then print(string.format("FPS %d\n#SPR %d\nLOGIC %.1f\nWALL&SPR %.1f\nFLR&CEIL %.1f", math_floor(1000 / delta), num_visible_sprites, t_logic, t_wall_sprite, t_floor), 0, 0, 5) end end -- <TILES> -- 001:ffffffffccedfccceeeefceeefeffeeffffffffffccddeeefceeeeeefeeeefef -- 002:ffffffffdcdefcdceeeefceeefeffeeefffffffffcccdcedfceeeeeefeeeefef -- 003:aaaaaaaaa8989989a99aaaa9a8aa8aaaa9a898aaa9aa8aaaa8aaaaaaa99aaaaa -- 004:aaaaaaaa9899898a9aaaa99aaaa8aa8aaa898a9aaaa8aa9aaaaaaa8aaaaaa99a -- 005:fffffeeefffeefffffeffffffefffffffeffffffefffffffefffffffefffffff -- 006:eeeffffffffeeffffffffeffffffffefffffffeffffffffefffffffefffffffe -- 007:3444444433444444333444443333444433333444333333443333333433333333 -- 008:4444444344444433444443334444333344433333443333334333333333333333 -- 009:7777777777666677766666677666666776666667766666677766667777777777 -- 010:7777777777666677766666677666666776666667766666677766667777777777 -- 016:0000000000000000000000000001100000011000000000000000000000000000 -- 017:ffffffffccedfccceeeefceeefeffeeffffffffffccddeeefceeeeeefeeeefef -- 018:ffffffffdcdefcdceeeefceeefeffeeefffffffffcccdcedfceeeeeefeeeefef -- 019:a99aaaaaa8aaaaaaa9aa8aaaa9a898aaa8aa8aaaa99aaaa9a8989989aaaaaaaa -- 020:aaaaa99aaaaaaa8aaaa8aa9aaa898a9aaaa8aa8a9aaaa99a9899898aaaaaaaaa -- 021:efffffffefffffffeffffffffefffffffeffffffffeffffffffeeffffffffeee -- 022:fffffffefffffffefffffffeffffffefffffffeffffffefffffeefffeeefffff -- 023:3333333333333334333333443333344433334444333444443344444434444444 -- 024:3333333343333333443333334443333344443333444443334444443344444443 -- 025:7777777777666677766666677666666776666667766666677766667777777777 -- 026:7777777777666677766666677666666776666667766666677766667777777777 -- 027:0000000000000000000000000001100000011000000000000000000000000000 -- 028:0000000000000000000000000001100000011000000000000000000000000000 -- 029:0000000000000000000000000001100000011000000000000000000000000000 -- 030:0000000000000000000000000001100000011000000000000000000000000000 -- 031:0000000000000000000000000001100000011000000000000000000000000000 -- 032:0000000000000000000000000002200000022000000000000000000000000000 -- 033:0000000000000000000000000002200000022000000000000000000000000000 -- 034:0000000000000000000000000002200000022000000000000000000000000000 -- 035:0000000000000000000000000002200000022000000000000000000000000000 -- 036:0000000000000000000000000002200000022000000000000000000000000000 -- 037:0000000000000000000000000002200000022000000000000000000000000000 -- 038:0000000000000000000000000002200000022000000000000000000000000000 -- 039:0000000000000000000000000002200000022000000000000000000000000000 -- 040:0000000000000000000000000002200000022000000000000000000000000000 -- 041:0000000000000000000000000002200000022000000000000000000000000000 -- 042:0000000000000000000000000002200000022000000000000000000000000000 -- 043:0000000000000000000000000002200000022000000000000000000000000000 -- 044:0000000000000000000000000002200000022000000000000000000000000000 -- 045:0000000000000000000000000002200000022000000000000000000000000000 -- 046:0000000000000000000000000002200000022000000000000000000000000000 -- 047:0000000000000000000000000002200000022000000000000000000000000000 -- 048:0000000000000000000000000003300000033000000000000000000000000000 -- 049:0000000000000000000000000003300000033000000000000000000000000000 -- 050:0000000000000000000000000003300000033000000000000000000000000000 -- 051:0000000000000000000000000003300000033000000000000000000000000000 -- 052:0000000000000000000000000003300000033000000000000000000000000000 -- 053:0000000000000000000000000003300000033000000000000000000000000000 -- 054:0000000000000000000000000003300000033000000000000000000000000000 -- 055:0000000000000000000000000003300000033000000000000000000000000000 -- 056:0000000000000000000000000003300000033000000000000000000000000000 -- 057:0000000000000000000000000003300000033000000000000000000000000000 -- 058:0000000000000000000000000003300000033000000000000000000000000000 -- 059:0000000000000000000000000003300000033000000000000000000000000000 -- 060:0000000000000000000000000003300000033000000000000000000000000000 -- 061:0000000000000000000000000003300000033000000000000000000000000000 -- 062:0000000000000000000000000003300000033000000000000000000000000000 -- 063:0000000000000000000000000003300000033000000000000000000000000000 -- 064:0000000000000000000000000004400000044000000000000000000000000000 -- 065:0000000000000000000000000004400000044000000000000000000000000000 -- 066:0000000000000000000000000004400000044000000000000000000000000000 -- 067:0000000000000000000000000004400000044000000000000000000000000000 -- 068:0000000000000000000000000004400000044000000000000000000000000000 -- 069:0000000000000000000000000004400000044000000000000000000000000000 -- 070:0000000000000000000000000004400000044000000000000000000000000000 -- 071:0000000000000000000000000004400000044000000000000000000000000000 -- 072:0000000000000000000000000004400000044000000000000000000000000000 -- 073:0000000000000000000000000004400000044000000000000000000000000000 -- 074:0000000000000000000000000004400000044000000000000000000000000000 -- 075:0000000000000000000000000004400000044000000000000000000000000000 -- 076:0000000000000000000000000004400000044000000000000000000000000000 -- 077:0000000000000000000000000004400000044000000000000000000000000000 -- 078:0000000000000000000000000004400000044000000000000000000000000000 -- 079:0000000000000000000000000004400000044000000000000000000000000000 -- 080:0000000000000000000000000005500000055000000000000000000000000000 -- 081:0000000000000000000000000005500000055000000000000000000000000000 -- 082:0000000000000000000000000005500000055000000000000000000000000000 -- 083:0000000000000000000000000005500000055000000000000000000000000000 -- 084:0000000000000000000000000005500000055000000000000000000000000000 -- 085:0000000000000000000000000005500000055000000000000000000000000000 -- 086:0000000000000000000000000005500000055000000000000000000000000000 -- 087:0000000000000000000000000005500000055000000000000000000000000000 -- 088:0000000000000000000000000005500000055000000000000000000000000000 -- 089:0000000000000000000000000005500000055000000000000000000000000000 -- 090:0000000000000000000000000005500000055000000000000000000000000000 -- 091:0000000000000000000000000005500000055000000000000000000000000000 -- 092:0000000000000000000000000005500000055000000000000000000000000000 -- 093:0000000000000000000000000005500000055000000000000000000000000000 -- 094:0000000000000000000000000005500000055000000000000000000000000000 -- 095:0000000000000000000000000005500000055000000000000000000000000000 -- 096:0000000000000000000000000006600000066000000000000000000000000000 -- 097:0000000000000000000000000006600000066000000000000000000000000000 -- 098:0000000000000000000000000006600000066000000000000000000000000000 -- 099:0000000000000000000000000006600000066000000000000000000000000000 -- 100:0000000000000000000000000006600000066000000000000000000000000000 -- 101:0000000000000000000000000006600000066000000000000000000000000000 -- 102:0000000000000000000000000006600000066000000000000000000000000000 -- 103:0000000000000000000000000006600000066000000000000000000000000000 -- 104:0000000000000000000000000006600000066000000000000000000000000000 -- 105:0000000000000000000000000006600000066000000000000000000000000000 -- 106:0000000000000000000000000006600000066000000000000000000000000000 -- 107:0000000000000000000000000006600000066000000000000000000000000000 -- 108:0000000000000000000000000006600000066000000000000000000000000000 -- 109:0000000000000000000000000006600000066000000000000000000000000000 -- 110:0000000000000000000000000006600000066000000000000000000000000000 -- 111:0000000000000000000000000006600000066000000000000000000000000000 -- 112:0000000000000000000000000007700000077000000000000000000000000000 -- 113:0000000000000000000000000007700000077000000000000000000000000000 -- 114:0000000000000000000000000007700000077000000000000000000000000000 -- 115:0000000000000000000000000007700000077000000000000000000000000000 -- 116:0000000000000000000000000007700000077000000000000000000000000000 -- 117:0000000000000000000000000007700000077000000000000000000000000000 -- 118:0000000000000000000000000007700000077000000000000000000000000000 -- 119:0000000000000000000000000007700000077000000000000000000000000000 -- 120:0000000000000000000000000007700000077000000000000000000000000000 -- 121:0000000000000000000000000007700000077000000000000000000000000000 -- 122:0000000000000000000000000007700000077000000000000000000000000000 -- 123:0000000000000000000000000007700000077000000000000000000000000000 -- 124:0000000000000000000000000007700000077000000000000000000000000000 -- 125:0000000000000000000000000007700000077000000000000000000000000000 -- 126:0000000000000000000000000007700000077000000000000000000000000000 -- 127:0000000000000000000000000007700000077000000000000000000000000000 -- 128:0000000000000000000000000008800000088000000000000000000000000000 -- 129:0000000000000000000000000008800000088000000000000000000000000000 -- 130:0000000000000000000000000008800000088000000000000000000000000000 -- 131:0000000000000000000000000008800000088000000000000000000000000000 -- 132:0000000000000000000000000008800000088000000000000000000000000000 -- 133:0000000000000000000000000008800000088000000000000000000000000000 -- 134:0000000000000000000000000008800000088000000000000000000000000000 -- 135:0000000000000000000000000008800000088000000000000000000000000000 -- 136:0000000000000000000000000008800000088000000000000000000000000000 -- 137:0000000000000000000000000008800000088000000000000000000000000000 -- 138:0000000000000000000000000008800000088000000000000000000000000000 -- 139:0000000000000000000000000008800000088000000000000000000000000000 -- 140:0000000000000000000000000008800000088000000000000000000000000000 -- 141:0000000000000000000000000008800000088000000000000000000000000000 -- 142:0000000000000000000000000008800000088000000000000000000000000000 -- 143:0000000000000000000000000008800000088000000000000000000000000000 -- 144:0000000000000000000000000009900000099000000000000000000000000000 -- 145:0000000000000000000000000009900000099000000000000000000000000000 -- 146:0000000000000000000000000009900000099000000000000000000000000000 -- 147:0000000000000000000000000009900000099000000000000000000000000000 -- 148:0000000000000000000000000009900000099000000000000000000000000000 -- 149:0000000000000000000000000009900000099000000000000000000000000000 -- 150:0000000000000000000000000009900000099000000000000000000000000000 -- 151:0000000000000000000000000009900000099000000000000000000000000000 -- 152:0000000000000000000000000009900000099000000000000000000000000000 -- 153:0000000000000000000000000009900000099000000000000000000000000000 -- 154:0000000000000000000000000009900000099000000000000000000000000000 -- 155:0000000000000000000000000009900000099000000000000000000000000000 -- 156:0000000000000000000000000009900000099000000000000000000000000000 -- 157:0000000000000000000000000009900000099000000000000000000000000000 -- 158:0000000000000000000000000009900000099000000000000000000000000000 -- 159:0000000000000000000000000009900000099000000000000000000000000000 -- 160:000000000000000000000000000aa000000aa000000000000000000000000000 -- 161:000000000000000000000000000aa000000aa000000000000000000000000000 -- 162:000000000000000000000000000aa000000aa000000000000000000000000000 -- 163:000000000000000000000000000aa000000aa000000000000000000000000000 -- 164:000000000000000000000000000aa000000aa000000000000000000000000000 -- 165:000000000000000000000000000aa000000aa000000000000000000000000000 -- 166:000000000000000000000000000aa000000aa000000000000000000000000000 -- 167:000000000000000000000000000aa000000aa000000000000000000000000000 -- 168:000000000000000000000000000aa000000aa000000000000000000000000000 -- 169:000000000000000000000000000aa000000aa000000000000000000000000000 -- 170:000000000000000000000000000aa000000aa000000000000000000000000000 -- 171:000000000000000000000000000aa000000aa000000000000000000000000000 -- 172:000000000000000000000000000aa000000aa000000000000000000000000000 -- 173:000000000000000000000000000aa000000aa000000000000000000000000000 -- 174:000000000000000000000000000aa000000aa000000000000000000000000000 -- 175:000000000000000000000000000aa000000aa000000000000000000000000000 -- 176:000000000000000000000000000bb000000bb000000000000000000000000000 -- 177:000000000000000000000000000bb000000bb000000000000000000000000000 -- 178:000000000000000000000000000bb000000bb000000000000000000000000000 -- 179:000000000000000000000000000bb000000bb000000000000000000000000000 -- 180:000000000000000000000000000bb000000bb000000000000000000000000000 -- 181:000000000000000000000000000bb000000bb000000000000000000000000000 -- 182:000000000000000000000000000bb000000bb000000000000000000000000000 -- 183:000000000000000000000000000bb000000bb000000000000000000000000000 -- 184:000000000000000000000000000bb000000bb000000000000000000000000000 -- 185:000000000000000000000000000bb000000bb000000000000000000000000000 -- 186:000000000000000000000000000bb000000bb000000000000000000000000000 -- 187:000000000000000000000000000bb000000bb000000000000000000000000000 -- 188:000000000000000000000000000bb000000bb000000000000000000000000000 -- 189:000000000000000000000000000bb000000bb000000000000000000000000000 -- 190:000000000000000000000000000bb000000bb000000000000000000000000000 -- 191:000000000000000000000000000bb000000bb000000000000000000000000000 -- 192:000000000000000000000000000cc000000cc000000000000000000000000000 -- 193:000000000000000000000000000cc000000cc000000000000000000000000000 -- 194:000000000000000000000000000cc000000cc000000000000000000000000000 -- 195:000000000000000000000000000cc000000cc000000000000000000000000000 -- 196:000000000000000000000000000cc000000cc000000000000000000000000000 -- 197:000000000000000000000000000cc000000cc000000000000000000000000000 -- 198:000000000000000000000000000cc000000cc000000000000000000000000000 -- 199:000000000000000000000000000cc000000cc000000000000000000000000000 -- 200:000000000000000000000000000cc000000cc000000000000000000000000000 -- 201:000000000000000000000000000cc000000cc000000000000000000000000000 -- 202:000000000000000000000000000cc000000cc000000000000000000000000000 -- 203:000000000000000000000000000cc000000cc000000000000000000000000000 -- 204:000000000000000000000000000cc000000cc000000000000000000000000000 -- 205:000000000000000000000000000cc000000cc000000000000000000000000000 -- 206:000000000000000000000000000cc000000cc000000000000000000000000000 -- 207:000000000000000000000000000cc000000cc000000000000000000000000000 -- 208:000000000000000000000000000dd000000dd000000000000000000000000000 -- 209:000000000000000000000000000dd000000dd000000000000000000000000000 -- 210:000000000000000000000000000dd000000dd000000000000000000000000000 -- 211:000000000000000000000000000dd000000dd000000000000000000000000000 -- 212:000000000000000000000000000dd000000dd000000000000000000000000000 -- 213:000000000000000000000000000dd000000dd000000000000000000000000000 -- 214:000000000000000000000000000dd000000dd000000000000000000000000000 -- 215:000000000000000000000000000dd000000dd000000000000000000000000000 -- 216:000000000000000000000000000dd000000dd000000000000000000000000000 -- 217:000000000000000000000000000dd000000dd000000000000000000000000000 -- 218:000000000000000000000000000dd000000dd000000000000000000000000000 -- 219:000000000000000000000000000dd000000dd000000000000000000000000000 -- 220:000000000000000000000000000dd000000dd000000000000000000000000000 -- 221:000000000000000000000000000dd000000dd000000000000000000000000000 -- 222:000000000000000000000000000dd000000dd000000000000000000000000000 -- 223:000000000000000000000000000dd000000dd000000000000000000000000000 -- 224:000000000000000000000000000ee000000ee000000000000000000000000000 -- 225:000000000000000000000000000ee000000ee000000000000000000000000000 -- 226:000000000000000000000000000ee000000ee000000000000000000000000000 -- 227:000000000000000000000000000ee000000ee000000000000000000000000000 -- 228:000000000000000000000000000ee000000ee000000000000000000000000000 -- 229:000000000000000000000000000ee000000ee000000000000000000000000000 -- 230:000000000000000000000000000ee000000ee000000000000000000000000000 -- 231:000000000000000000000000000ee000000ee000000000000000000000000000 -- 232:000000000000000000000000000ee000000ee000000000000000000000000000 -- 233:000000000000000000000000000ee000000ee000000000000000000000000000 -- 234:000000000000000000000000000ee000000ee000000000000000000000000000 -- 235:000000000000000000000000000ee000000ee000000000000000000000000000 -- 236:000000000000000000000000000ee000000ee000000000000000000000000000 -- 237:000000000000000000000000000ee000000ee000000000000000000000000000 -- 238:000000000000000000000000000ee000000ee000000000000000000000000000 -- 239:000000000000000000000000000ee000000ee000000000000000000000000000 -- 240:000000000000000000000000000ff000000ff000000000000000000000000000 -- 241:000000000000000000000000000ff000000ff000000000000000000000000000 -- 242:000000000000000000000000000ff000000ff000000000000000000000000000 -- 243:000000000000000000000000000ff000000ff000000000000000000000000000 -- 244:000000000000000000000000000ff000000ff000000000000000000000000000 -- 245:000000000000000000000000000ff000000ff000000000000000000000000000 -- 246:000000000000000000000000000ff000000ff000000000000000000000000000 -- 247:000000000000000000000000000ff000000ff000000000000000000000000000 -- 248:000000000000000000000000000ff000000ff000000000000000000000000000 -- 249:000000000000000000000000000ff000000ff000000000000000000000000000 -- 250:000000000000000000000000000ff000000ff000000000000000000000000000 -- 251:000000000000000000000000000ff000000ff000000000000000000000000000 -- 252:000000000000000000000000000ff000000ff000000000000000000000000000 -- 253:000000000000000000000000000ff000000ff000000000000000000000000000 -- 254:000000000000000000000000000ff000000ff000000000000000000000000000 -- 255:000000000000000000000000000ff000000ff000000000000000000000000000 -- </TILES> -- <SPRITES> -- 000:0000eeee00ff22220f222c2202ff22220222eeee0f2222220ff2222202ffeeee -- 001:eeee00002222dd00222222d02222dd20eeee2220222222d022222dd0eeeedd20 -- 002:0000000002200000020000020c00000c0c00000c0c00000c4440003404000003 -- 003:000000002200000220000022c00000c0c00000c0c00000c04400044440000040 -- 016:022feeee0f2222220ff2222202ffeeee022feeee0f22222200ff22220000eeee -- 017:eeeed220222222d022222dd0eeeedd20eeeed220222222d02222dd00eeee0000 -- 018:0400000303440003000344430000000300000003000000030000033400003444 -- 019:4000004040004430444430004000000040000000400000004440000044440000 -- </SPRITES> -- <MAP> -- 000:101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 001:100000000000000000000000000000001010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 002:100000000000000000000000000000001000000000001010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 003:100000000000000000000000000000001010001010001010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 004:100000000000000000000000000000001000000010001010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 005:1000005d1d5d1d5d1d5d0000000000001000000010001010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 006:1000001d5a1a5a1a5a1d0000000000001000000010001010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 007:1000005d1a5616561a5d0000000000001000000010001010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 008:1000001d5a1650165a1d00000000000010181c1810001010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 009:1000005d1a5616561a5d0000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 010:1000001d5a1a5a1a5a1d0000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 011:1000005d1d5d1d5d1d5d0000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 012:100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 013:100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 014:100000500050005000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 015:100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 016:100000500050005000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 017:100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 018:100000500050005000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 019:100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 020:10000000000000004f4e4d4c4b4a49484746454443424110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 021:100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 022:100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 023:101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- </MAP> -- <SCREEN> -- 000:eeeeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffeeffffffffffffffffffffffffffffffffffffeeeeefffffffeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffffff -- 001:eeeeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffeeeeeefffffffffffffffffffffffffffffffeeeeeeeeeeffeeeeeeeeeeeeeeeeeeeeeeeeefffffffffffffffffffffffffffffff -- 002:eeeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeeeeeeeeeeeeeefffeeeeeeeeeeffffffffffffffffffffffffffeeeeeeeeeeeeffeeeeeeeeeeeeeeeeeeeeeefffffffffffffffffffffffffffffffffff -- 003:eeeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeeeeeeeeeeeefeeeeeeeeeeeeefffffffffeeeeefffffffeeeeeeeeeeeefffffffeeeeeeeeeeeeeeeeeffffffffffffffffffffffffffffffffffffff -- 004:eeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeeeeeefffffffeeeeeeeeeeeeeffffeeeeeeeeeffeeeeeeeeeeeeffffffffffffeeeeeeeeeeeefffffffffffffffffffffffffffffffffffffffff -- 005:eeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeefffffffffffeeeeeeeeeeeefeeeeeeeeeeeffeeeeeeeeeffffffffffffffffeeeeeeefffffffffffffffffffffffffffffffffffffffffffff -- 006:eeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeefffffffffffffffeeeeeeeffffffeeeeeefffffffeeeefffffffffffffffffffffeeffffffffffffffffffffffffffffffffffffffffffffffff -- 007:eeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeffffffffffffffffffffeeffffffffffefffffffffffffffffffffffffffffffffeeefffffffffffffffffffffffffffffffffffffffffffffffff -- 008:eeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffff -- 009:ffffeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffff -- 010:ffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffff -- 011:ffffffffeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffff -- 012:ffffffffeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -- 013:ffffffffeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -- 014:fffffffeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffffffffffffffffffffffffffffffffffffffffffffffeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -- 015:fffffffffffeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeefffffffffffffffffffffffffffffffffffffffffffeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -- 016:ffffffffffffffffefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeefffffffffffffffffffffffffffffffffffffffffffffeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -- 017:fffffffffffffffeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffffffffffffffffffffffffffffffffffffffffffffeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -- 018:fffffffffffffffffeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeefffffffffffffffffffffffffffffffffffffffffeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -- 019:fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeefffffffffffffffffffffffffffffffffffffffffeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -- 020:ffffffffffffffffffffffeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -- 021:ffffffffffffffffffffffffeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -- 022:ffffffffffffffffffffffffffffffeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeefffffffffffffffeeefffffeeeeffffeeeeeefffffffffffeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -- 023:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeffffffffeeeeeeeeffeeeeeeeffeeeeeeeeefffffeeeeeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -- 024:fffeeefffffeeeeffffeeeeefffffffffffeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeefeeeeeeeefffffffffffffffffeeeeeeeffeeeeeeeeeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffff -- 025:fffeeeeeeefffeeeeefffeeeeeeeeeffffeeeeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeeffffffeefffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffeee -- 026:eeeeeeeeeefffffffffffffffffeeeeeefffeeeeeeeeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffeeeeeeeee -- 027:eeffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeeefffffeeefffffffffffffffffffeeeeeeffeeeeeeeeeeeeeef -- 028:efffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeeefffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeefffeeeeeeeefffeeeeeffeeeeeeeeffffffeeeeeeeefffffff -- 029:efffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeeeffeeeeeefffffffffffffffeeeeeeefeeeeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeefffffffffffeeeeffffeeefffffeefffffffffffffefffffffffffff -- 030:efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeefffffffeeeeeeeeeeeeeefeeeeeefffffffffeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeffffffffffffffffffffffffffffffffffffffeeeeeeefffffffffffff -- 031:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeffffffffffffffffffffffffffffffeeeeeefffffffffffffffffff -- 032:effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeefffffffffffffffffffffffffffffffeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffeeefffffffffffffffffffffff -- 033:eeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeffffffffffffffffffffffffffffffeeffffffffffffffffffffffffff -- 034:fffeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeefffffffffffffffffffffffffffeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeefffffffffffffffffffffffffffeeeeeeeffffffffffffffffffffffffff -- 035:fffffeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeefffffffffffffffffffffffffffeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeffffffffffffffffffffffffffffffffeeeffffffffffffffffffffffffffff -- 036:ffffffffffeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeefffffffffffffffffffffffffffffffeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeffffffffeeeeffeeeeefeeeeeffffffeeeeeeeffffffffffffffffffffffffffff -- 037:fffffffffffffffffeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffeefffffffffeeeefeeeeefeeeeeffffffeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeefeeeefffffffffffffffeeffffeeeeeeeeeeeeffffffffffffffffffffffffff -- 038:eefeeeeeeeeeeefffffeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeffeeeeffffffffffffffeeffffeeeeeeeeeeeeffffffffffffffffffffffffffffffffffffffeeeeeeeeeeefffffffffffffffffffffffffffffffffffeeeeeeeeeeeefffffffffffffffffffffff -- 039:eefffffffffffffffefffffeeeeeeeeeeeefffffffffffffffffffffffffffffffffffeeeeeeeeeefffffffffffffffffffffffffffffffffffeeeeeeeeeeeefffffefffffffffffffffeefffeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffeeeeeeeffffeeeeeefeeeeeeeeeeffff -- 040:fffffffffffffffffffffffffffffffffeeeeeeeeeeeffeeefffffffffffffeeeefeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffeeeeeffffffeeeefeeeeffeeeffffffffeeffffffffffffffffffffffffffffffffffffffffffffffffffeeefffffffffffffffffffffffffffeee -- 041:ffffffffffffffffffffffffffffffffffffffffffeefffffffffeffffeffffefffffffffeffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeffffffffffffffffffffffeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeefffff -- 042:ffffffffffffffffffffffffffffffffffffffffffffffeeeeefffffffffffffffffffffeeffffffffffffffffffffffffffffffffffffffffffffffffffffeeeffffffffffffffffffffeeeefffffffffffffffffffffffffffffffffffffffffffffffffffeeffffffffffffffffffffffeeeeffffffff -- 043:eefffffffffffffffffffffffffffffffffffffffffffffffffeeffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffeeeeefffffffffffffffffffffeeeeeffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffeffffffffeefffffffffff -- 044:ffffeeeeeffffffffffffffffffffffffffffffffffffffffffeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeffffeeeeefeeefeeeeeffeeeeeeeffffffffffffffffffffffffffffffffffffeeeeeeeeefffeffffffffffffffffffeeeeeeeeefffffffff -- 045:eefeeeeffffeeeeefffffffffffffffffffffffffffffffffffeeeeeeeeeffeefffffffffffeffffeeeeeeeeeffffffffffffffffffffffffffffeeeeeeeefffffffffffffffffffffffffffeeeeeeeeefffffffffffffffffefffeeeeeeeefffffffffffffffffffffffffffffffffffeeeeeefffeeeefe -- 046:ffffffffffffffffffffeeeeeeeeeffffffffffffffffeffeeeeeeeefffffffffffffffffffffffffffffffffeeeeeefffeeeefeeefeeeeffffeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeefffffffffffffffffffffffffffffffffffffffeeeefffffffffffff -- 047:fffffffffffffffffffffffffffffffeeffffffffffffffffffffeeeefffffffffffffffffffffffffffffffffffffeeeffffffffffffffffffefffffffffffffffffffffffffffffffffffffffffeeefffffffffffffffffeefffffffffffffffffffffffffffffffffffffffffeefffffffffffffffffe -- 048:ffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeefffffffffffffffffeeeeffffffffffffffffffffffffffffffffffffffffffefffeffefffffffeffffffffffffffffffffffffffffffffffeeeeeffeeefffefffeeeeeeeeeee -- 049:fffffffffffffffffffffffffffffffffffffffeeeefffeeeffeefeeeefeeeeeeffffffffffffffffffffffffffffeeeeeeefffffffffffffffffeeeeeeeefffffffffffffffffffffeeeeeeeffffffffffffffffffffffffeeeeeeeffeefffffffffeefeeeeeeefffffffffffffffffffffffffffffeeee -- 050:fffffffffffffffeeeeeeeffeffffffffeeeeeeeeeeffffffffffffffffffffffffffffeeeffffeeeeeefeefffffeffffffffffffffffffffffffffffffffeefffffffffffffffffeeeffffffffffffffffffffffffffffffffeeeffffffffffffffffffffffffffffffffffffffffffffffffffeeefffff -- 051:fffffffffffffffffffffffffffeffffffffffffffeefffffffffffffffffffffffffffffffffefffffffffffffffffffffffffffffffffffffffffffffffeeefffffffffffffffeeefffffffffffffffffffffffffffffffffffffffeffefffffefffffffffffffffffffffffffffffeeeefeeeffffffee -- 052:ffeeffffffffffffffffffffffffffeeeeffeeefffffeeeeeeeeeffffffffffffffffffffffeeeeeffffffffffffffffeeeeeeffffffffffffffffffeeeeefffffffffffffffffffffeeeeeefeeffffffeeeeeeeeefffffffffffffffffffffffffeeefffeefeefeeffffeffffffffffffffffffffffffff -- 053:fffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffeeefffffffffffeeeffffffffffffffffffffffffffffeffffffffffffeefffffffffffffffffffffffffffffefffffffffffffefffffffffffffffffffffffffffeeefffffffffffffeeffffffffffffffffffffffffffeffff -- 054:ffffffffffffffffffffffffeffffeefefeefffeeffffffffffffffffffffffeeeeeeeffffffeffeeeeeffffffffffffffffffeeeeffffffffffffffffeeeeefffffffffffffeeeeefffffffffffffffffffeeeeefeeffefeeefeeeefffffffffffffffffffffffeffffffffffffffefffffffffffffffff -- 055:fffffffffffffeeeffffffffffeeffffffffffffffffffffffffffffffffffffefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeefffffffffffeeeffffffffffffffffffffffffffeffffefffeefffffffffffffffffffffeeefeeffeffeeeeeeefffffffffffffffffeeeee -- 056:ffeeeeefffffffffffeeeeffffffffffffffffeeeeeeeffffeefeeeffffffffffffffffffffffffefeffffffffffffffffffffffffffeeefffffffffeefffffffffffffffffffffffffffffffffefffffffffffffffffffffffeffffffffffffffffffffffffffffffffeeffffffffffeeffffffffffffff -- 057:fffffffffffffffeeeefefffffffeeeefffffffffffffeeeeffffffffffffeeeeffffffffffeeeffffffffffffffffeeefeefefeffeeffffffffffffffffffffffffffffffefffffffffffffffffffeeffffffffefffffffffffffffffffffeffffffffeeffffffffffffffffffffffffffffffeffffffff -- 058:ffffffffffffeeeeffffffffeeeefffffffffffeeeffffffff77ffeeeeffffffefeeeffffffffffffffeeefeeeeefffefffffffffffffffffffffffffffefffffffffffffffffeefffffffeffffffffffffffffffeefffffffefffffffffffffffffffffffffffeefffffffffffffffffefffffffffeffff -- 059:feefeeefeffeffffffffffffffffffffffffefffffff77777777777777777777777777777ffffffffffffeffffffffffffffffffffffffeffffffffffffffffeffffffffefffffffffffffffffffefeffeffffffffffffffeefefffeeeeefffffffffffeeefffffffffeeeeffffffffeeeffffffffffffee -- 060:ffffffeefeffefeefffffffffffeeeffffffee777fff66776777766666677777766666777ffffffffffefeee777777777ffffffffefffffffefffffffffffffeffffffeffffffffffffffeffffffeffffffffffffffeffffffefffffffffffffefffffffffffffffffffffeffeeeefeefffffffffffeeeef -- 061:fffeeffffffffeeffffffeeffffffffffe676777766666766677666666666776666666677ffffeffff7667766677766667777666677ffffffffffffffffffffeffffffefffffffffffffeeeffeffffffffffeeeffffeefffffffffeefffffffeeffffffeeeffffffffeeeeffefefffffffffffefffffffff -- 062:eefffffffeeeffeeefffffffff776777666766766666667666776666666667766666666777776666776666766677666666776666667fff776777667776667776667fffeefffffeeffffffeeffffffeeffffeefffffffffefeefffffffffffffffffefffffffffffffffffffffccdcccedffcccddcdeffcdc -- 063:efcdcccedfcccdffffffffffff766676666766766666667666776666666667766666666776766666676666766677666666776666667766766676666776666766667ffffffffffeeeefffffffeffffeefffffeffffffffffffffffffcdecdcccefcccdcdefcdcccedfcccdcdefcceeeeeeffceeeeeeeffcee -- 064:efceeeeeefceeeeeefceeeeeef766676666766766666667666776666666667766666666776766666676666766677666666776666667666666676666776666766666fffffffffffffffffffddfdccdfcdcefdccefceeeefceeeefceeeeeceeeeefceeeeeffeeeefeffeefefeffeeeeefefffeefeefefffeee -- 065:fffffffffffffffeffeeeefeff766676666766766666667666776666666667766666666776766666676666766677666666776666667666666676666776666766666eceeeeeefeeefeeeeceeefeefffeefffeefefefefffeeefffefefffffffffffffffffffffffffffffffffffffffffffffffffffffffff -- 066:cdcedfccddeeefcccdcedfccdd766676666767777666667767777666666777777666667776766666677667766677766667777666677666666676666776666766666fffffffffffffffffffffffffffffffffffcdeefccdcdfcddeefccccedfccdeeefcccdcedfccddeeefcccdccedfccdddeeeffcccddced -- 067:eeeeefceeeeeefceeeeeefceee766777667777777777777777777777777777777777777777776666777777777777777777777777777766766777667776667776667eeeceefeeefeeeeceeefeeeeceeefceeeeceeeefceeeefceeeefceeeeefceeeeefceeeeeefceeeeeefceeeeeeefceeeeeeeffceeeeeee -- 068:eefeffeeeefeffffffffffffff777777eeeeeeeeeeeeeeee77777777eeeeeeeeeeee77777777777777eeeeeeeeeeeeeeeee77777777777777777777777777777777ffffffffffffffffffffffffffffffffffffffffffffffffffffeeefeffeeefeffeefffffffffffffffffffffffffffffffffffffffff -- 069:efcdcccedfcccdcdefcdcccedf766777eeeeeeeeeeeeeeee77777777eeeeeeeeeeee77777777666677eeeeeeeeeeeeeeeee77666677766766777667776667776667ecccedcefcddfdccdccddfdccdfcdcefdccefccdcefccccdfccdcdecdcccefcccdcdefcdcccedfcccdcdefccdcccedffcccddcdeffcdc -- 070:efceeeeeefceeeeeefceeeeeef76ffff2222222222222222dddd7fff222222222222ddd7767666ffff22222222222222222dddd6667666666676666776666766666fffffeeefeeefeeffefeefeefffeefffeefefceeeefceeeefceeeeeceeeeefceeeeeefceeeeeefceeeeeefcceeeeeeff4444333333333 -- 071:ffffffffffffffffffffffffff76ffff2222222222222222ddddf22222c222222222222dd67666ffff22222222222222222dddd6667666666676666776666766666eeeccefcdefcdedcdeefffffffffffffffffffffffffffffffffffff33333333334444ee4443333333333333344444443333333333344 -- 072:cdcedfccddeeefcccdcedfccddff222222cc2222222222222222dd2222c222222222222dd676ff222222cc22222222222222222dd67666666676666776666766666a9aaaaa98a898a89a8afee333444444443333333444444444333333333333333444444443333333444444444333333333333333334444 -- 073:eeeeefceeeeeef9aa99aaaaaa9ff222222cc2222222222222222ddff222222222222ddd22676ff222222cc22222222222222222dd67766766676666776666766667aa9aa9aaa8333333334444333333333444443334444444444443333344444444444333333333334444444444443333333333333444444 -- 074:8a8aa98a88aa9aa99aaa9aa99a22ffff2222222222222222dddd2222eeeeeeeeeeee2222277722ffff22222222222222222dddd22778a9aa6777667776667776668aaa9aaaaaaaaaa9aa898aa334444444444333344444444444433333444444444444433333333444444444444444333333333333444444 -- 075:aaaa98aaa8aa8aaa899aa88aa922ffff2222222222222222dddd2222eeeeeeeeeeee222229a822ffff22222222222222222dddd2277a98aaa9aaaaaaaaaaaaa89aaaaa8a8a8aaaaaaa88a998aaa89a89aaaaaaaa88a89aaaa444443334444444444444443333334444444444444444333333333344444444 -- 076:8aaa989a8aaa889aaaaaaaaaa8222222eeeeeeeeeeeeeeee22222222222222222222222dd888222222eeeeeeeeeeeeeeeee222222aaaa98aaa8aaaaaaaaaaaa8aaa8aaaa9aaaaaaaaaaaaa89aaa9998aaa889aaa8aaaa998aaa9aaa99aaa999aa99aaa9aa433444444444444444444443333334444444444 -- 077:99aa888aa999aaaa9aaaaa99aa222222eeeeeeeeeeeeeeee222222f222222222222222ddda88222222eeeeeeeeeeeeeeeee222222aaaaaa99aaaa98aaaa9aaaaaaaaaaaaaaaaa88aaaaaa98aa888aaaaaaaaa898a998aaaa889aa89aaaaaaaaaa8a8aa9aaaaaaa88aaaaaaaaaaaaaaaaa333344444444444 -- 078:999aaa8a8aaa999aaaa99aaaaaff222222222222222222222222ddf222222222222222ddd99aff2222222222222222222222222ddaaa8899aaaaaaaaaaaaa99aaaa989aaaa99aaaaaaaaaaaaaaaaaa88aaaaaaaa8aa8a8aaaaaaaaaa8888aa998aaaa8899aa99aaaaaaaaaaa898aa99aaaaaaa98aaaaaaaa -- 079:88aaaaa89aa8a8aa99aaaa999aff222222222222222222222222ddffeeeeeeeeeeeeddd2299aff2222222222222222222222222ddaaa998aaaa8aaaa88aaaaaaaaaaaaaaaaa8a8aaa99aaaaaa899aa899aaaaaaaaaaaaa99aaa998aaaaaa99aa88a8aaaaaaaaaaaaaaaa98aaaa8aaaaa89aaaaaaaaaaaaaa -- 080:aaaaaaaaaaaaa998aaaaaaaaaaffff22222222222222222222dddd2feeeeeeeeeeeedd222aaaffff222222222222222222222dddd8a8aaaaaaaaaaaaaaaaaa98aaaaa8aaaaa999aaaaaaaaaaaaaaaaaaaa99aaaa899998aaaaa98a99aaaa8aaaaaa99988aaaa99aa9aa99aaaaa9999aaaa998aaaa99aaaaa -- 081:9aaaaaaaaaaaaaaaaaa9aa89aaffff22222222222222222222dddd2feeeeeeeeeeeedd222aaaffff222222222222222222222dddda889aa88888aaa889aaaaa899aa8aaaaa99aaaaa999aaaa8898aaaa9999aaaaaa99aa9a889aaaaa88999aaaaaaaaaaaaa9a899aaaaaa9999aaaaa999aaaaaaaaaaaaaaa -- 082:aaaaaaaaaaa9aa999aaaaa999922ffffeeeeeeeeeeeeeeeedddd2222222222222222222dda8822ffffeeeeeeeeeeeeeeeeedddd229998aaaaaaa8899aaa899aaaaaaaaaaaaaaaa8988aaa999aaaaaaaaa998aa88a8aaaaaaaaaaaaaaaaaaaaa988aaaaa88aaaaaa999aaaaaaaaaaaaaaaaaaaaaaa99aaaaa -- 083:aaaa988a99aaaaaaaaaaaaaaa922ffffeeeeeeeeeeeeeeeedddd22f222222222222222ddd99a22ffffeeeeeeeeeeeeeeeeedddd22aaaa88a88aaa988aaaaa998aaaaa999aaaaaa9999aaaaaa999aaaaaa999aaaaaa99999aaaaa8aa8aaaaa999888aaaaaa88999988aaaaa999aaaaaaaaaaaaaaaaaaaaaaa -- 084:aaaaaaaaaaaaaaaaaaa88888aa2222ffeeeeeeeeeeeeeeeedd2222f222222222222222ddd8aa2222ffeeeeeeeeeeeeeeeeedd2222aaaaaaaaaaaaaaaaaaaa988aaaaaa88aaaaaaa999aaaaaaaaaaaaaaaaaaaaaaaaaaa999aaaaaa9999998aaaaaa9988a99aaaaaaaaaaaaaaaa999988aaaaa999aaaaaa99 -- 085:a8998aaaaaa9999aaaaaaa999a2222ffeeeeeeeeeeeeeeeedd2222ffeeeeeeeeeeeeddd22aaa2222ffeeeeeeeeeeeeeeeeedd2222aaaaaaaaaaaaaaaaaa9999aaaaaaa888aaaaaaa999aaaaaaaaaaaaaaaaaaaaaaaaaaaa8aaa8889aaaaaaaaaaa999aaaa888888aaaaaaaaaaaaaaaaaa8998aaa999888aa -- 086:aaaaaa9998aaa9aaaaaaaaaaaaff222222222222222222222222dd2feeeeeeeeeeeedd222aaa2222ffeeeeeeeeeeeeeeeeedd2222aaaaaaaaa998aaaaaaaa988aaaaa8888888aaa888aaaaaaa988aaaaaa8998aaaaaaa9999aaaaaaa9999aaaaaaaaa999aaaaaaa999999aaaa888a88aaaaa99999888aaaa -- 087:aa88998aaaaaaaaaaaaaaaaaaaff222222222222222222222222dd2feeeeeeeeeeeedd222aaaff2222222222222222222222222dda88aaaaaaaa8999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa999aaaaaaa89999998aaaaaaaa9988aa99aaaaaaaaaaaaaaaaaaa9999988aaaaaaa998aaa9aaa9999aaaaaaa -- 088:9aaaaaaaaaaaaaaaaaaaaaaaaaffff22222222222222222222dddd22222222222222222ddaaaff2222222222222222222222222ddaaaaaaa9998aaaa8888888aaaaaaaaaaaaaaaaaaaaa89998aaaa9999888aaaaaaaaa889999aaaa889988aaaaaaaaaaaaaaaaaaaaa888a88aaaa8899aaaaaaaaaaaaaa98 -- 089:aaa888988aaaaaaa8999aaaaaaffff22222222222222222222ddddff222222222222ddd88888ffff222222222222222222222dddd9a8888aaaaaaaa8888a99aaaaaaaaaaaaaaaaaaaaaaaaaaaa9999aaaaaaaaa998899aaaaaaaa9999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9888aaaaaaaaaaaaa -- 090:99a8888aaaaaaaaa888999999a22ffffeeeeeeeeeeeeeeeedddd22ff222222222222dddaaaa9ffff222222222222222222222dddd88aaaaaa8889aaaaaaaa8888aaaaa8889988aaaaaaa8899aaaaaaaaa89999aaaaaaaaaaaa9999aaaaaaaa9999999aaaaaa88898888aaaa9999999988aaaaaaaaa9888a9 -- 091:aaaa88899aaaaaaaaaaaaaaaaa22ffffeeeeeeeeeeeeeeeedddd22aaeeeeeeeeeeee99aaaaaa22ffffeeeeeeeeeeeeeeeeedddd22aaaaaaaaa9999a8889aaaaaaaa98888a999a88899aaaaaaaaa8899999999aaaaa88888888aaaaaa9999999aaaaaaaaa9999aaaaaaaaaaaaa99998aaaaaaaaa99988aaaa -- 092:99aaaaa899988aaaaaaaaaaaaa2222ffeeeeeeeeeeeeeeeedd222299eeeeeeeeeeeeaaa9999822ffffeeeeeeeeeeeeeeeeedddd22aaaaaaaaaaaaaaaaaaa98888aaaaaaaaa88aaaaaaaaaa89999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9999aaaaaaaaa9999999998aaaaaaaaaa99888aa999a -- 093:aaaaaaaaaaaaaaaaaaaaaaaaaa2222ffeeeeeeeeeeeeeeeedd2222aaaaaaaaaaaaaaaa9988aa2222ffeeeeeeeeeeeeeeeeedd2222aaaaaaaa88899888aaaaa99998888aaaaaaaaaa888889999aaaaa8999988aaaaaaaaaaaaaaaaaaaaaaaaaa888888888aaaa88999aaaaaaaaaaaaaaaaa998888aaaaaaaa -- 094:999999aaaaaaaaaaaaaaaaaaaaff222222222222222222222222dd9999999998aaaaaaaaa9992222ffeeeeeeeeeeeeeeeeedd2222aaaaaaaaaaaaaaaaa999988aaaaaaaaaa888aaaaaaaaa88889aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa888aa8888aaaaa99999aaaaaaaaaaaaaaa8999999aaaaa -- 095:8aaaaaaaaa899999aaaaaaaaaaff222222222222222222222222ddaaaaaaaa99999aaaaaaaaaff2222222222222222222222222ddaaaaa999999988888aaaaaaaaaaa88889999999888aaaaaaaaaa99988aaaa9aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa99999aaaaaaaaaaaa88888aaaaaaaaaa899 -- 096:99aaaaaaaaaaaaaaa999999aaaaaffff2222222222222222dddd998888aaaaaa888889aaaaaaff2222222222222222222222222ddaaaaa89999aaaaaaaaaaaa999999aaaaaaaaaaaaaaa99999aaaaaaaaaa9999999999aaaaaa88888a8888aaaaaaa999999999888aaaaaaaaaaa988888a9999988888aaaa -- 097:88999999888889aaaaaaaaaaaa88ffff2222222222222222dddd8888aaaaaa99999999999aaaaaffff22222222222222222dddd999999aaaaaaaaaaaa999998aaaaaaaaaa88999988aaaaaaaa888899aaaaaaaaaaa88888aaaaaa8888898888aaaaaaaa888999aaaaaaaaaaaa899999aaaaaaaaaaaaaaaaa -- 098:8889aaaaaaaaaaaaa999999aaaaaaaaaeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaa99aaaa889999aaffff22222222222222222ddddaaaaaaaaaaaaa888899999999aaaaaaaaa888aa8888aaaaaaaa99999999999aaaaaaaaaaa99999aaaaaaaaaaaaaaa999999aaaaaaaaaaaa999999aaaaaaaaaaaa8999988a -- 099:aaaaaaaa998888aaaaaaaaaaaaaaaaaaeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaa999998aaaeeeeeeeeeeeeeeeeeaaaaaaaaaaa999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa99aaaa889999aaaaaaaaaaa88889999999988888aaaaaaaaaaaaa8888899999999aaaaaaaaa888aaa -- 100:8888999999aaaaaa888999888aaaaaaaeeeeeeeeeeeeeeeeaaaaaaaaaa888888a88888aaaaaa889999eeeeeeeeeeeeeeeeeaaaaa9888888aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa999999aaaaaaaaaaaa9888889aaaaaaaaaaaaa9999999aaaaaaaaaaaaaaaaaaaaaaaa -- 101:99988aaaaaa888888888888aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa88999988aaaaaa9999999888888aaaaaaaaaaaaa88888999999aaaaaa88889988888aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8888aa8888aaaaaaa888999aaaaaaaaaaaaaaaaaaaaaaaa8888889aaaaaaaaaaaaaaaaaaaaaaaaaa -- 102:889999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa88aaaa888aaaaaaa8889999aaaaaaaaaaaaaaaaaaaaa9999999aaaaaaa888889988888aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9999999aaaaaaa999999988888aaaaaaaaaaaaaaaa888999999aaaaaa8888889888888aaaaaaa -- 103:999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa99999988aaaaaaaaaaaaaa8888aaaaaaaaaaaaa888889aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8888aaa8888aaaaaaaa8999999aaaaaaaaaaaaaaaaaaaa899999999aaaaaaa8889999888aaaaaa -- 104:8888888999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa99aaaaa8999999aaaaaaaaaaaaaaa9999998899999aaaaaaaaaaaaa9999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9998888aaaaaaaaaaaaaaa8aaaaaaaaaaaaa9888888aaaaaa88aaaaa888aaa -- 105:a9999999999999aaaaaaaa888888aa88888aaaaaaaaaa999999999988888aaaaaaaaaaaaaaaa888888899999999888888aaaaaaaaaaaaa9999888aaaa999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9999999aaaaaaaaaaaaaaa9998888899aaaaaaaaaaaaa9999999aaaaaaaaaaaaa -- 106:a9999998aaaaaaaaaaaaaa899999988aaaaaaaaaaaa99999999999aaaaaaaaaaaaaaaa99999999aaaaaaaaaaaaaaa9999999aaaaaaaaaaaaaa88899999999999aaaaaaaaaaaa88aaaaaa8aaaaaaaaaaaaaaa999999aa8888899aaaaaaaaaaaaaaaa888899999999999988aaaaaaaaaaaaaa9999999aaaaaa -- 107:a88888889aaaaaaa88888889888888aaaaaaaaaa88888999aaaaaaaaaaaaaaaa88899999aaaaaaaa8aaaaaaaaaaaaaaa9999999aaaaaaaaaaaaaa99999999999aaaaaaaaaaa8888899888888aaaaaaaaa9999999999999988aaaaaaaaaaaaaaaa99998888aaa99999aa88888899aaaaaaaaaaaaaa8888888 -- 108:aa9999999aaaaaaaaaaaaaaa88aaaaaaaa99999888aaaaaaaaaaaaaaaa999888888aaaaaaaaa888888888888888aaaaaaa99888888aaaaaaaaaaaaaaa9998888aaaaaaaaaaaaa889999998aaaaaaaaaaaaaaa999999999aaaaaaaaaaaaaaaa99999999aaaaaaaaaaaaaaaaaaa99999999aaaaaaaaaaaaaa8 -- 109:aa99999999aaaaaaaaaaaaaaaaa999999999aaaaaaaaaaaaaaaaa9999999999aaaaaaaaaaaaaaa999999998aaaaaaaaaaaaaa88999999aaaaaaaaaaaaaaa88888999aaaaaaa8888888a8888888aaaaaaaa888888889aaaaaaaaaaaaaaaaa88888999aaaaaaaaa888aaaaa88aaaaaaaa99999998aaaaaaaaa -- 110:aaa9888888aaa99999aaa888889999aaaaaaaaaaaaaaaaa88999999999999999aaaaaaaaa888888889888888aaaaaaaaaaa9999999999999aaaaaaaaaaaaaaa99999999aaaaaaaaaaaaaaaaaaaaaaaa999999988aaaaaaaaaaaaaaaaa999998888aaaaaaaaaaa888888998888888aaaaaaaaa88888888aaa -- 111:aaa888999999999999988888aaaaaaaaaaaaaaaaa998888888a99999999aaaaaaaaaaaaaaaa88aaaaaa888aaaaaaaaaaaaa9999999999999888aaaaaaaaaaaaaaaa99999999aaaaaaaaaaaaaaaaa999999999aaaaaaaaaaaaaaaaaa999999999999aaaaaaaaaaaaaa8899999998aaaaaaaaaaaaaaaa89999 -- 112:aaa999998888999999aaaaaaaaaaaaaaaaaa999999998aaaaaaa99aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9999999aa88888889aaaaaaaaaaaaaaaa98888888aa9999999aa888888999aaaaaaaaaaaaaaaaaaa889999999999999999aaaaaaaaa8888888898888888aaaaaaaaaaa99999 -- 113:aaaa8888888aaaaaaaaaaaaaaaaaaa999999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa899999999aaaaaaaaaaaaaaaaa8889999999999999888888aaaaaaaaaaaaaaaaaa988888888a999999999aaaaaaaaaaaaaaaa88aaaaaa888aaaaaaaaaaaaaa99 -- 114:aaaa8aaaaaaaaaaaaaaaaaaa8888889999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa999999999aaaaaaaaaaaaaaaaa9999998899999999aaaaaaaaaaaaaaaaaaa999999998aaaaaaa999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 115:aaaaaaaaaaaaaaaaaaa999888888aaaaaaaaaa88aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa999999988aaaaaaaaaaaaaaaaa8888888889aaaaaaaaaaaaaaaaaaa9999999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 116:aaaaaaaaaaaaa8999999999aaaaaaaaaa88888888a88888888aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8aaaaaaaaaaaaaaaaaa888888888aaaaaaaaaaaaaaaaaa888aaaaaaaaaaaaaaaaaaaa8889999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 117:aaaaaaa88888888999999999aaaaaaaaa88889999988888aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa88888888aa8888888aaaaaaaaa888899999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa98888888889aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 118:aaaaaa8888889999999999aaaaaaaaaa88999999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8888899998888888aaaaaaaaaa99999999998aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9999999888aaaaaaaaaaa88888aaaaa8888aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 119:aaaaaa99999999999aaaaaaaaaa88888888999888888aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9999999999aaaaaaaaaaa99999999998888888aaaaaaaaaaaaaaaaaaaaaaaaa8889999999999aaaaaaaaa8888888889888888888aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 120:aaaaaaa999988888aaaaaaaaaa8888888aaa88888888aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8888889999988888aaaaaaaaaa99999999988888888aaaaaaaaaaaaaaaaaaaaa88888888889999999999aaaaaaaaa88899999998888aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 121:aaaaaaa8888888888aaaaaaaaaa8aaaaaaaaa88aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa88888888aa888888888aaaaaaaaaa999999999988aaaaaaaaaaaaaaaaaaaaaaaaaaaa8888899999999999aaaaaaaaaaa889999999988aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 122:aaaaaaaa8888999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa888aaaaaaa8888aaaaaaaaaaa88888999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa99999999999aaaaaaaaaaa888888889998888888aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 123:aaaaaaaa9999999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa88888888888aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa99999988888aaaaaaaaaa8888888aaa888888888aaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 124:aaaaaaaa99999999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa999999888888aaaaaaaaaaaaaaaaaaaaaaa88aaaaaaaaaaaaaaaaaaaaa8888888888aaaaaaaaaaa88aaaaaaaa888aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 125:aaaaaaaaa9999999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa999999999998aaaaaaaaaaaaaaaaaaaaaaa88888888aaaaaaaaaaaaaaaaaaaaa88888899999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 126:aaaaaaaaa99999988888aaaaaaa9999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa999999999999aaaaaaaaaaaaaaaaaaaaaaaa9988888888889aaaaaaaaaaaaaaaaaaaaaa8999999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 127:aaaaaaaaaa98888888888aa999999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9aaaaaaaaaaa999999999999aaaaaaaaaaaaaaaaaaaaaaaa9999999988889999999aaaaaaaaaaaaaaaaaaaaaa99999999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 128:aaaaaaaaaa8888888899999999999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa999999aaaaaa888889999999aaaaaaaaaaaaaaaaaaaaaaaaa889999999999999999999999aaaaaaaaaaaaaaaaaaaaaa999999999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 129:aaaaaaaaaaa8889999999999999999999aaaaaaaaaaaaaaaaaaa8888aaaaaaaa888aaaaaaaaaaaaaaaaaaaaaa999999999999a888888888899aaaaaaaaaaaaaaaaaaaaaaaaa888888899999999999999999998888aaaaaaaaaaaaaaaaaaaaaaa99999999998aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -- 130:aaaaaaaaaaa99999999999999999999999aaaaaaaaaaaaaa888888888aaaa8888888aaaaaaaaaaaaaaaaaa99999999999999999888888888aaaaaaaaaaaaaaaaaaaaaaaaa98888888888899999999999999888888888aaaaaaaaaaaaaaaaaaaaaaa999999888888aaaaaaa9999aaaaaaaaaaaaaaaaaaaaaa -- 131:aaaaaaaaaaa99999999999999999999aaaaaaaaaaaaaaa888888888889888888888888aaaaaaaaaaaaa99999999999999999999998888aaaaaaaaaaaaaaaaaaaaaaaaaa9999988888888aaaa999999999aa888888888889aaaaaaaaaaaaaaaaaaaaaaaa88888888888aa9999999999aaaaaaaaaaaaaaaaaa -- 132:aaaaaaaaaaaa999999999999999aaaaaaaaaaaaaaaaaaaa8888889999998888888aaaaaaaaaaaaaaaaa99999999999999999999999aaaaaaaaaaaaaaaaaaaaaaaaaa9999999999988aaaaaaaaa99999aaaaaaa888888999999aaaaaaaaaaaaaaaaaaaaaaaa888888888999999999999999aaaaaaaaaaaaaa -- 133:aaaaaaaaaaaa999999999998aaaaaaaaaaaaaaaaaaaaaaaa889999999999888aaaaaaaaaaaaaaaaaaaaaa999999999999999999aaaaaaaaaaaaaaaaaaaaaaaaaaa9999999999999aaaaaaaaaaaaaaaaaaaaaaaaaa899999999999aaaaaaaaaaaaaaaaaaaaaaaa888889999999999999999999aaaaaaaaaaa -- 134:aaaaaaaaaaaaa999999888888aaaaaaaaaaaaaaaaaaaaa8889999999999988aaaaaaaaaaaaaaaaaaaaaaaa99999999999999aaaaaaaaaaaaaaaaaaaaaaaaaaa99999999999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa999999999999aaaaaaaaaaaaaaaaaaaaaaaaa999999999999999999999999aaaaaaa -- 135:aaaaaaaaaaaaa998888888888aaaaaaaaaaaaaaaaa888888889999998888888aaaaaaaaaaaaaaaaaaaaa8888999999999aaaaaaaaaaaaaaaaaaaaaaaaaaaa99999999999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa999999999999aaaaaaaaaaaaaaaaaaaaaaaaa99999999999999999999999aaaaa -- </SCREEN> -- <PALETTE> -- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57 -- </PALETTE>
nilq/small-lua-stack
null
object_tangible_component_structure_mustafar_must_transthermal_padding = object_tangible_component_structure_mustafar_shared_must_transthermal_padding:new { } ObjectTemplates:addTemplate(object_tangible_component_structure_mustafar_must_transthermal_padding, "object/tangible/component/structure/mustafar/must_transthermal_padding.iff")
nilq/small-lua-stack
null
---@class CS.FairyEditor.View.HierarchyView : CS.FairyGUI.GComponent ---@type CS.FairyEditor.View.HierarchyView CS.FairyEditor.View.HierarchyView = { } ---@return CS.FairyEditor.View.HierarchyView function CS.FairyEditor.View.HierarchyView.New() end return CS.FairyEditor.View.HierarchyView
nilq/small-lua-stack
null
if fs.exists("SydsoftOS") then shell.run("rm SydsoftOS") end shell.run("pastebin get puhxzeDi SydsoftOS") shell.run("SydsoftOS")
nilq/small-lua-stack
null