content
stringlengths
0
1.05M
origin
stringclasses
2 values
type
stringclasses
2 values
local class = require('src.Utils.MiddleClass'); local Logger = require('src.Utils.Logger'); local Node = require('src.Node'); --- The transition node is used in the State node to define the set of transitions from/to --- other states in the same StateMachine node. ---@class Transition: Node ---@field onEvent string The behavior tree event which triggers the transition. ---@field to string The name of the State node to transition to. local Transition = class('Transition', Node); function Transition:_parseXmlNode(node, context) if node._name ~= self.class.name then Logger.error('Tried to parse an invalid node as a ' .. self.class.name .. ' node.'); end if node._children.n ~= 0 then Logger.error('The Transition node cannot have children.'); end if not node._attr or not node._attr.onEvent then Logger.error('The Transition node must have a onEvent attribute.'); end if not node._attr or not node._attr.to then Logger.error('The Transition node must have a to attribute.'); end self.onEvent = node._attr.onEvent; self.to = node._attr.to; end return Transition;
nilq/small-lua-stack
null
return { background_node_range={ 0, 1 }, desc="Custom preset 2. Your world, your rules!", hideminimap=false, id="CUSTOM_PRESET_2", location="cave", max_playlist_position=999, min_playlist_position=0, name="Custom Preset 2", numrandom_set_pieces=0, override_level_string=false, overrides={ banana="often", bats="default", berrybush="often", boons="often", branching="never", bunnymen="default", cave_ponds="default", cave_spiders="default", cavelight="fast", chess="default", disease_delay="long", earthquakes="rare", fern="often", fissure="default", flint="often", flower_cave="often", grass="often", layout_mode="RestrictNodesByKey", lichen="often", liefs="default", loop="never", marshbush="often", monkey="default", mushroom="often", mushtree="often", petrification="few", prefabswaps_start="default", reeds="often", regrowth="fast", roads="never", rock="often", rocky="default", sapling="often", season_start="default", slurper="default", slurtles="default", start_location="caves", task_set="cave_default", tentacles="default", touchstone="often", trees="often", weather="rare", world_size="small", wormattacks="default", wormhole_prefab="tentacle_pillar", wormlights="often", worms="default" }, required_prefabs={ "multiplayer_portal" }, substitutes={ }, version=3 }
nilq/small-lua-stack
null
local Text = surface.GetTextureID("gui/gradient") function DrawBoxGradient(x,y,w,h,extw,color, linecolor) surface.SetDrawColor( color.r, color.g, color.b, color.a ) surface.DrawRect( x, y, w, h ) surface.SetTexture(Text) surface.DrawTexturedRectRotated( x-extw/2, y+h/2, extw, h, 180 ) surface.SetDrawColor( linecolor.r, linecolor.g, linecolor.b, linecolor.a ) surface.DrawLine(x-extw,y-1,x+w,y-1) surface.DrawLine(x-extw,y+h,x+w,y+h) end local Text2 = surface.GetTextureID("gui/gradient_down") function DrawBoxGradientDown(x,y,w,h,color, gradcolor) surface.SetDrawColor( color.r, color.g, color.b, color.a ) surface.DrawRect( x, y, w, h ) surface.SetDrawColor( gradcolor.r, gradcolor.g, gradcolor.b, gradcolor.a ) surface.SetTexture(Text2) surface.DrawTexturedRect( x, y, w, h/2 ) end
nilq/small-lua-stack
null
local gauntlet_data = require "gauntlet_data" local CHIP_DATA = require "defs.chip_data_defs" local CHIP_ID = require "defs.chip_id_defs" local CHIP_ID_LAST = require "defs.chip_id_defs_last_chip" local CHIP_CODE = require "defs.chip_code_defs" local CHIP_NAMES = require "defs.chip_name_defs" local CHIP_NAME_ADDRESSES = require "defs.chip_name_address_defs" local io_utils = require "io_utils.io_utils" local CHIP = require "defs.chip_defs" local ELEMENT_DEFS = require "defs.entity_element_defs" local GENERIC_DEFS = require "defs.generic_defs" local LEVEL_UP = { NAME = "Level Up!", } local NUMBER_OF_CHIPS_UPGRADED = {2, 2, 2, 2, 3} function shuffle(tbl) size = #tbl for i = size, 1, -1 do local rand = gauntlet_data.math.random_buff_activation(size) tbl[i], tbl[rand] = tbl[rand], tbl[i] end return tbl end function upgrade_chip(chip) -- Replace chip with upgraded chip local new_chip_id = chip.ID + 1 if chip.ID == CHIP_ID.DynaWave then new_chip_id = CHIP_ID.BigWave elseif chip.ID == CHIP_ID.LavaCan3 then new_chip_id = CHIP_ID.Volcano elseif chip.ID == CHIP_ID.LongSwrd then new_chip_id = CHIP_ID.CustSwrd elseif chip.ID == CHIP_ID.Burner then new_chip_id = CHIP_ID.Burning elseif chip.ID == CHIP_ID.DashAtk then new_chip_id = CHIP_ID.Condor elseif chip.ID == CHIP_ID.Aura then new_chip_id = CHIP_ID.LifeAura elseif chip.ID == CHIP_ID.LavaStge or chip.ID == CHIP_ID.IceStage or chip.ID == CHIP_ID.GrassStg or chip.ID == CHIP_ID.SandStge or chip.ID == CHIP_ID.MetlStge then new_chip_id = CHIP_ID.Snctuary elseif chip.ID == CHIP_ID.AtkPlus10 then new_chip_id = CHIP_ID.AtkPlus30 elseif chip.ID == CHIP_ID.StandOut then new_chip_id = CHIP_ID.Salamndr elseif chip.ID == CHIP_ID.WatrLine then new_chip_id = CHIP_ID.Fountain elseif chip.ID == CHIP_ID.Ligtning then new_chip_id = CHIP_ID.Bolt elseif chip.ID == CHIP_ID.GaiaSwrd then new_chip_id = CHIP_ID.GaiaBlad elseif chip.ID == CHIP_ID.NaviPlus20 then new_chip_id = CHIP_ID.NaviPlus40 elseif chip.ID == CHIP_ID.GutsManV4 then new_chip_id = CHIP_ID.GutsManV5 elseif chip.ID == CHIP_ID.ProtoMnV4 then new_chip_id = CHIP_ID.ProtoMnV5 elseif chip.ID == CHIP_ID.FlashMnV4 then new_chip_id = CHIP_ID.FlashMnV5 elseif chip.ID == CHIP_ID.BeastMnV4 then new_chip_id = CHIP_ID.BeastMnV5 elseif chip.ID == CHIP_ID.BubblMnV4 then new_chip_id = CHIP_ID.BubblMnV5 elseif chip.ID == CHIP_ID.DesrtMnV4 then new_chip_id = CHIP_ID.DesrtMnV5 elseif chip.ID == CHIP_ID.PlantMnV4 then new_chip_id = CHIP_ID.PlantMnV5 elseif chip.ID == CHIP_ID.FlamManV4 then new_chip_id = CHIP_ID.FlamManV5 elseif chip.ID == CHIP_ID.DrillMnV4 then new_chip_id = CHIP_ID.DrillMnV5 elseif chip.ID == CHIP_ID.MetalMnV4 then new_chip_id = CHIP_ID.MetalMnV5 elseif chip.ID == CHIP_ID.KingMnV4 then new_chip_id = CHIP_ID.KingMnV5 elseif chip.ID == CHIP_ID.MistMnV4 then new_chip_id = CHIP_ID.MistMnV5 elseif chip.ID == CHIP_ID.BowlManV4 then new_chip_id = CHIP_ID.BowlManV5 elseif chip.ID == CHIP_ID.DarkManV4 then new_chip_id = CHIP_ID.DarkManV5 elseif chip.ID == CHIP_ID.JapanMnV4 then new_chip_id = CHIP_ID.JapanMnV5 elseif chip.ID == CHIP_ID.Bass then new_chip_id = CHIP_ID.BassPlus end return CHIP.new_chip_with_code(new_chip_id, chip.CODE) end function is_chip_id_last_chip(chip_id) for k, v in pairs(CHIP_ID_LAST) do --print("id = " .. tostring(chip_id) .. ", v = " .. tostring(v) .. " eq = " .. tostring(v == chip_id)) if v == chip_id then return true end end return false end function LEVEL_UP:activate(current_round) self.old_folder = deepcopy(gauntlet_data.current_folder) local shuffle_indices = {} for i = 1,#gauntlet_data.current_folder do shuffle_indices[i] = i end shuffle_indices = shuffle(deepcopy(shuffle_indices)) self.replaced_chips_string = "" self.num_replaced_chips = 0 for chip_idx = 1,#gauntlet_data.current_folder do local chip = gauntlet_data.current_folder[shuffle_indices[chip_idx]] -- Check if chip is not the last of its range if not is_chip_id_last_chip(chip.ID) then self.num_replaced_chips = self.num_replaced_chips + 1 if self.num_replaced_chips ~= NUMBER_OF_CHIPS_UPGRADED[current_round] then self.replaced_chips_string = self.replaced_chips_string .. gauntlet_data.current_folder[shuffle_indices[chip_idx]].PRINT_NAME .. ", " else self.replaced_chips_string = self.replaced_chips_string .. gauntlet_data.current_folder[shuffle_indices[chip_idx]].PRINT_NAME end gauntlet_data.current_folder[shuffle_indices[chip_idx]] = upgrade_chip(chip)--CHIP.new_chip_with_code(chip.ID, CHIP_CODE.Asterisk) if self.num_replaced_chips >= NUMBER_OF_CHIPS_UPGRADED[current_round] then break end end end self.current_round = current_round end function LEVEL_UP:deactivate(current_round) gauntlet_data.current_folder = deepcopy(self.old_folder) end function LEVEL_UP:get_description(current_round) if NUMBER_OF_CHIPS_UPGRADED[current_round] ~= 1 then return "Upgrade " .. tostring(NUMBER_OF_CHIPS_UPGRADED[current_round]) .. " Chips in Folder!" else return "Upgrade " .. tostring(NUMBER_OF_CHIPS_UPGRADED[current_round]) .. " Chip in Folder!" end end function LEVEL_UP:get_brief_description() if self.num_replaced_chips >= 3 then return LEVEL_UP.NAME .. ": Upgrade ->\n " .. self.replaced_chips_string elseif self.num_replaced_chips > 0 then return LEVEL_UP.NAME .. ": Upgrade -> " .. self.replaced_chips_string else return LEVEL_UP.NAME .. ": Upgrade -> nothing!" end end function LEVEL_UP.new() local new_buff = deepcopy(LEVEL_UP) new_buff.DESCRIPTION = new_buff:get_description(1) return deepcopy(new_buff) end return LEVEL_UP
nilq/small-lua-stack
null
local ui = {} local utils = require 'utils' do local cache = {} function ui.rgb(str) if cache[str] then return cache[str] end local out = {} for i = 1, 6, 2 do local tmp = str:sub(i, i+1) local val = utils.fromBase(tmp, 16) / 255 table.insert(out, val) end cache[str] = out return out end end local widthCache = {} function ui.centerText(text, x, y, ...) local f = love.graphics.getFont() local w = 0 local c = {} if not widthCache[f] then widthCache[f] = c else c = widthCache[f] end if not c[text] then w = f:getWidth(text) c[text] = w else w = c[text] end love.graphics.print(text, utils.round(x-w/2), y, ...) end ui.buttons = require 'ui/buttons' ui.colors = { white = {1, 1, 1}, bg = {0.2, 0.2, 0.2}, black = {0, 0, 0}, selected1 = ui.rgb("ff6e6e"), selected2 = ui.rgb("ad2222"), notselected1 = ui.rgb("b2b2b2"), notselected2 = ui.rgb("7a7a7a") } return ui
nilq/small-lua-stack
null
return function() local bindArgs = require(script.Parent) it("should properly bind arguments to a function", function() expect(function() bindArgs(function(a, b, c) assert(a == 1, b == 2, c == 3) end, 1, 2, 3)(4) end).never.throw() end) end
nilq/small-lua-stack
null
function FileExists(filename) local filehandle=io.open(filename,"r") if filehandle~=nil then io.close(filehandle) return true else return false end end project "Premake" kind "Utility" targetdir ("%{wks.location}/bin/" .. outputdir .. "/%{prj.name}") objdir ("%{wks.location}/bin-int/" .. outputdir .. "/%{prj.name}") files { "%{wks.location}/**premake5.lua" } if FileExists("bin/premake5.exe") then postbuildmessage "Regenerating project files with Premake5!" postbuildcommands { "\"%{prj.location}bin/premake5\" %{_ACTION} --file=\"%{wks.location}premake5.lua\"" } end
nilq/small-lua-stack
null
portalprojectile = class("portalprojectile") function portalprojectile:init(x, y, tx, ty, color, hit, payload, mirror, mirrored, bounces) self.x = x self.y = y self.startx = x self.starty = y self.endx = tx self.endy = ty self.bounces = bounces or portalbouncethreshold self.color = color self.hit = hit self.payload = payload self.payloaddelivered = false self.mirror = mirror self.sinestart = math.random(math.pi*10)/10 if mirrored then self.timer = 0 else self.timer = 0.005 end self.length = math.sqrt((tx-x)^2 + (ty-y)^2) self.time = self.length/portalprojectilespeed self.angle = math.atan2(tx-x, ty-y) self.particles = {} self.lastparticle = math.floor(self.timer/portalprojectileparticledelay) end function portalprojectile:update(dt) self.timer = self.timer + dt if self.timer < self.time then self.x = self.startx + (self.endx-self.startx)*(self.timer/self.time) self.y = self.starty + (self.endy-self.starty)*(self.timer/self.time) local currentparticle = math.floor(self.timer/portalprojectileparticledelay) for i = self.lastparticle+1, currentparticle do local t = i*portalprojectileparticledelay local tx = self.startx + (self.endx-self.startx)*(t/self.time) local ty = self.starty + (self.endy-self.starty)*(t/self.time) --INNER LINE local r, g, b = unpack(self.color) table.insert(self.particles, portalprojectileparticle:new(tx, ty, {r, g, b})) --OUTER LINES local r, g, b = unpack(self.color) r, g, b = r/2, g/2, b/2 --Sine local x = tx + math.sin(self.angle+math.pi/2)*(math.sin(t*portalprojectilesinemul+self.sinestart))*portalprojectilesinesize local y = ty + math.cos(self.angle+math.pi/2)*(math.sin(t*portalprojectilesinemul+self.sinestart))*portalprojectilesinesize table.insert(self.particles, portalprojectileparticle:new(x, y, {r, g, b})) --Sine local x = tx + math.sin(self.angle-math.pi/2)*(math.sin(t*portalprojectilesinemul+self.sinestart))*portalprojectilesinesize local y = ty + math.cos(self.angle-math.pi/2)*(math.sin(t*portalprojectilesinemul+self.sinestart))*portalprojectilesinesize table.insert(self.particles, portalprojectileparticle:new(x, y, {r, g, b})) end self.lastparticle = currentparticle end --Update particles local delete = {} for i, v in pairs(self.particles) do if v:update(dt) == true then table.insert(delete, i) end end table.sort(delete, function(a,b) return a>b end) for i, v in pairs(delete) do table.remove(self.particles, v) end if (self.timer >= self.time and self.timer-dt < self.time) or (self.time <= 0.005 and self.payloaddelivered == false) then self:createportal() self.payloaddelivered = true end if self.timer >= self.time + portalprojectiledelay then return true end return false end function portalprojectile:draw() for i, v in pairs(self.particles) do v:draw() end if self.timer < self.time then love.graphics.setColor(unpack(self.color)) love.graphics.draw(portalprojectileimg, math.floor((self.x-xscroll)*16*scale), math.floor((self.y-yscroll-0.5)*16*scale), 0, scale, scale, 6, 6) end end portalprojectileparticle = class("portalprojectileparticle") function portalprojectileparticle:init(x, y, color, r, g, b) self.x = x self.y = y self.color = color self.speedx = math.random(-10, 10)/70 self.speedy = math.random(-10, 10)/70 self.alpha = 150 self.timer = 0 end function portalprojectileparticle:update(dt) self.timer = self.timer + dt self.speedx = self.speedx + math.random(-10, 10)/70 self.speedy = self.speedy + math.random(-10, 10)/70 self.x = self.x + self.speedx*dt self.y = self.y + self.speedy*dt self.alpha = self.alpha - dt*300 if self.alpha < 0 then self.alpha = 0 return true end end function portalprojectileparticle:draw() local r, g, b = unpack(self.color) love.graphics.setColor(r, g, b, self.alpha) love.graphics.draw(portalprojectileparticleimg, math.floor((self.x-xscroll)*16*scale), math.floor((self.y-yscroll-.5)*16*scale), 0, scale, scale, 2, 2) end function portalprojectile:createportal() if self.mirror then local portal, i, cox, coy, side, tendency, x, y = unpack(self.payload) portaldelay[portal.number] = 0 local angle if side == "up" or side == "down" then angle = -math.atan2(self.endx-self.startx, self.endy-self.starty) else angle = math.atan2(self.endx-self.startx, self.starty-self.endy) end if self.bounces > 0 then shootportal(portal.number, i, self.endx, self.endy, angle, true, self.bounces-1) end else portal.createportal(unpack(self.payload)) end end
nilq/small-lua-stack
null
local models = {} local dpnn = require( 'dpnn') local nn = require( 'nn') local rnn = require( 'rnn') local loadcaffe = require('loadcaffe') -- Load pretrained 16-layer VGG model and freeze layers function models.load_vgg(backend) --local model = loadcaffe.load('VGG/VGG_ILSVRC_19_layers_deploy.prototxt','VGG/vgg_normalised.caffemodel',backend) local base_path = 'VGG/' local model = loadcaffe.load(paths.concat(base_path,'VGG_ILSVRC_16_layers_deploy.prototxt'),paths.concat(base_path,'VGG_ILSVRC_16_layers.caffemodel'),backend) for i=38,#model do model:remove() end --assert(model:get(#model).name == 'relu4_2','VGG Model is loaded incorrectly') for i=1,#model do model:get(i).accGradParameters = function() end end return model end function models.rnn_model(vocabSize,embedLen) local lstm = nn.SeqLSTM(embedLen,1024) lstm:maskZero(1) lstm.batchfirst=true local lookup = nn.LookupTableMaskZero(vocabSize,embedLen) --local rnn = nn.Sequential():add(lookup):add(nn.Dropout(0.5)):add(nn.Transpose({1,2})):add(fastlstm) -- :add(nn.MaskZero(nn.Linear(1024,2048),1)):add(nn.ReLU(true)) local rnn = nn.Sequential():add(lookup):add(nn.Dropout(0.5)):add(lstm) :add(nn.Sequencer(nn.MaskZero(nn.Linear(1024,2048),1))):add(nn.Sequencer(nn.ReLU(true))) local rnn_cnn = nn.ParallelTable() -- Add the RNN to parallel table rnn_cnn:add(rnn) --Add the Visual input to parallel table after embedding in multimodal space. Use fc6 layer rnn_cnn:add(nn.Sequential():add(nn.Replicate(1)) :add(nn.Sequencer(nn.Sequential():add(nn.Linear(4096,2048)):add(nn.ReLU(true))))) --Share weights and grads. use dpnn extension to save memory as compared to just share local shared_lin = nn.Linear(embedLen,vocabSize) shared_lin.bias = false shared_lin.weight:set(lookup.weight); shared_lin.gradWeight:set(lookup.gradWeight); --local model = nn.Sequential():add(rnn_cnn):add(nn.CAddTable()):add(nn.Sequencer(nn.Sequential():add(nn.Dropout(0.25)) -- :add(nn.MaskZero(nn.Linear(2048,embedLen),1)) -- :add(nn.MaskZero(shared_lin,1)))) local model = nn.Sequential():add(rnn_cnn):add(nn.CAddTable()):add(nn.Sequencer(nn.Sequential():add(nn.Dropout(0.25)) :add(nn.Linear(2048,embedLen)) :add(shared_lin))) collectgarbage() collectgarbage() --print( shared_lin.weight:size(),lookup.weight:size()) return model end return models
nilq/small-lua-stack
null
#!/usr/bin/env wsapi.cgi require "orbit" require "orbit.cache" require "markdown" -- -- Declares that this is module is an Orbit app -- module("blog", package.seeall, orbit.new) -- -- Loads configuration data -- require "blog_config" -- -- Initializes DB connection for Orbit's default model mapper -- require("luasql." .. database.driver) local env = luasql[database.driver]() mapper.conn = env:connect(unpack(database.conn_data)) mapper.driver = database.driver -- Initializes page cache local cache = orbit.cache.new(blog, cache_path) -- -- Models for this application. Orbit calls mapper:new for each model, -- so if you want to replace Orbit's default ORM mapper by another -- one (file-based, for example) just redefine the mapper global variable -- posts = blog:model "post" function posts:find_comments() return comments:find_all_by_post_id{ self.id } end function posts:find_recent() return self:find_all("published_at is not null", { order = "published_at desc", count = recent_count }) end function posts:find_by_month_and_year(month, year) local s = os.time({ year = year, month = month, day = 1 }) local e = os.time({ year = year + math.floor(month / 12), month = (month % 12) + 1, day = 1 }) return self:find_all("published_at >= ? and published_at < ?", { s, e, order = "published_at desc" }) end function posts:find_months() local months = {} local previous_month = {} local posts = self:find_all({ order = "published_at desc" }) for _, post in ipairs(posts) do local date = os.date("*t", post.published_at) if previous_month.month ~= date.month or previous_month.year ~= date.year then previous_month = { month = date.month, year = date.year, date_str = os.date("%Y/%m", post.published_at) } months[#months + 1] = previous_month end end return months end comments = blog:model "comment" function comments:make_link() local author = self.author or strings.anonymous_author if self.url and self.url ~= "" then return "<a href=\"" .. self.url .. "\">" .. author .. "</a>" elseif self.email and self.email ~= "" then return "<a href=\"mailto:" .. self.email .. "\">" .. author .. "</a>" else return author end end pages = blog:model "page" -- -- Controllers for this application -- function index(web) local ps = posts:find_recent() local ms = posts:find_months() local pgs = pgs or pages:find_all() return render_index(web, { posts = ps, months = ms, recent = ps, pages = pgs }) end blog:dispatch_get(cache(index), "/", "/index") function view_post(web, post_id, comment_missing) local post = posts:find(tonumber(post_id)) if post then local recent = posts:find_recent() local pgs = pages:find_all() post.comments = post:find_comments() local months = posts:find_months() return render_post(web, { post = post, months = months, recent = recent, pages = pgs, comment_missing = comment_missing }) else return not_found(web) end end blog:dispatch_get(cache(view_post), "/post/(%d+)") function add_comment(web, post_id) local input = web.input if string.find(input.comment, "^%s*$") then return view_post(web, post_id, true) else local comment = comments:new() comment.post_id = tonumber(post_id) comment.body = markdown(input.comment) if not string.find(input.author, "^%s*$") then comment.author = input.author end if not string.find(input.email, "^%s*$") then comment.email = input.email end if not string.find(input.url, "^%s*$") then comment.url = input.url end comment:save() local post = posts:find(tonumber(post_id)) post.n_comments = (post.n_comments or 0) + 1 post:save() cache:invalidate("/") cache:invalidate("/post/" .. post_id) cache:invalidate("/archive/" .. os.date("%Y/%m", post.published_at)) return web:redirect(web:link("/post/" .. post_id)) end end blog:dispatch_post(add_comment, "/post/(%d+)/addcomment") function view_archive(web, year, month) local ps = posts:find_by_month_and_year(tonumber(month), tonumber(year)) local months = posts:find_months() local recent = posts:find_recent() local pgs = pages:find_all() return render_index(web, { posts = ps, months = months, recent = recent, pages = pgs }) end blog:dispatch_get(cache(view_archive), "/archive/(%d%d%d%d)/(%d%d)") blog:dispatch_static("/head%.jpg", "/style%.css") function view_page(web, page_id) local page = pages:find(tonumber(page_id)) if page then local recent = posts:find_recent() local months = posts:find_months() local pgs = pages:find_all() return render_page(web, { page = page, months = months, recent = recent, pages = pgs }) else not_found(web) end end blog:dispatch_get(cache(view_page), "/page/(%d+)") -- -- Views for this application -- function layout(web, args, inner_html) return html{ head{ title(blog_title), meta{ ["http-equiv"] = "Content-Type", content = "text/html; charset=utf-8" }, link{ rel = 'stylesheet', type = 'text/css', href = web:static_link('/style.css'), media = 'screen' } }, body{ div{ id = "container", div{ id = "header", title = "sitename" }, div{ id = "mainnav", _menu(web, args) }, div{ id = "menu", _sidebar(web, args) }, div{ id = "contents", inner_html }, div{ id = "footer", copyright_notice } } } } end function _menu(web, args) local res = { li(a{ href= web:link("/"), strings.home_page_name }) } for _, page in pairs(args.pages) do res[#res + 1] = li(a{ href = web:link("/page/" .. page.id), page.title }) end return ul(res) end function _blogroll(web, blogroll) local res = {} for _, blog_link in ipairs(blogroll) do res[#res + 1] = li(a{ href=blog_link[1], blog_link[2] }) end return ul(res) end function _sidebar(web, args) return { h3(strings.about_title), ul(li(about_blurb)), h3(strings.last_posts), _recent(web, args), h3(strings.blogroll_title), _blogroll(web, blogroll), h3(strings.archive_title), _archives(web, args) } end function _recent(web, args) local res = {} for _, post in ipairs(args.recent) do res[#res + 1] = li(a{ href=web:link("/post/" .. post.id), post.title }) end return ul(res) end function _archives(web, args) local res = {} for _, month in ipairs(args.months) do res[#res + 1] = li(a{ href=web:link("/archive/" .. month.date_str), blog.month(month) }) end return ul(res) end function render_index(web, args) if #args.posts == 0 then return layout(web, args, p(strings.no_posts)) else local res = {} local cur_time for _, post in pairs(args.posts) do local str_time = date(post.published_at) if cur_time ~= str_time then cur_time = str_time res[#res + 1] = h2(str_time) end res[#res + 1] = h3(post.title) res[#res + 1] = _post(web, post) end return layout(web, args, div.blogentry(res)) end end function _post(web, post) return { markdown(post.body), p.posted{ strings.published_at .. " " .. os.date("%H:%M", post.published_at), " | ", a{ href = web:link("/post/" .. post.id .. "#comments"), strings.comments .. " (" .. (post.n_comments or "0") .. ")" } } } end function _comment(web, comment) return { p(comment.body), p.posted{ strings.written_by .. " " .. comment:make_link(), " " .. strings.on_date .. " " .. time(comment.created_at) } } end function render_page(web, args) return layout(web, args, div.blogentry(markdown(args.page.body))) end function render_post(web, args) local res = { h2(span{ style="position: relative; float:left", args.post.title } .. "&nbsp;"), h3(date(args.post.published_at)), _post(web, args.post) } res[#res + 1] = a{ name = "comments" } if #args.post.comments > 0 then res[#res + 1] = h2(strings.comments) for _, comment in pairs(args.post.comments) do res[#res + 1 ] = _comment(web, comment) end end res[#res + 1] = h2(strings.new_comment) local err_msg = "" if args.comment_missing then err_msg = span{ style="color: red", strings.no_comment } end res[#res + 1] = form{ method = "post", action = web:link("/post/" .. args.post.id .. "/addcomment"), p{ strings.form_name, br(), input{ type="text", name="author", value = web.input.author }, br(), br(), strings.form_email, br(), input{ type="text", name="email", value = web.input.email }, br(), br(), strings.form_url, br(), input{ type="text", name="url", value = web.input.url }, br(), br(), strings.comments .. ":", br(), err_msg, textarea{ name="comment", rows="10", cols="60", web.input.comment }, br(), em(" *" .. strings.italics .. "* "), strong(" **" .. strings.bold .. "** "), " [" .. a{ href="/url", strings.link } .. "](http://url) ", br(), br(), input.button{ type="submit", value=strings.send } } } return layout(web, args, div.blogentry(res)) end -- Adds html functions to the view functions orbit.htmlify(blog, "layout", "_.+", "render_.+")
nilq/small-lua-stack
null
local present1, lspconfig = pcall(require, "lspconfig") local present2, lspinstall = pcall(require, "lspinstall") if not (present1 or present2) then return end local tbl_utils = require("nvdope.utils.tbls") local function on_attach(client, bufnr) vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") local opts = {noremap = true, silent = true} local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end -- Mappings. buf_set_keymap("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts) buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts) buf_set_keymap("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts) buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts) buf_set_keymap("n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts) buf_set_keymap("n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts) buf_set_keymap("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts) buf_set_keymap("n", "<space>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts) buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts) buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) buf_set_keymap("n", "<space>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts) buf_set_keymap("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts) buf_set_keymap("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts) buf_set_keymap("n", "<space>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts) -- Set some keybinds conditional on server capabilities if client.resolved_capabilities.document_formatting then buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts) elseif client.resolved_capabilities.document_range_formatting then buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts) end end local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true local servers_prefix = "nvdope.initialization.lsp.language_servers_configs." local function setup_servers() lspinstall.setup() local installed_servers = lspinstall.installed_servers() for _, lang in pairs(Cfg.nvdope.language_servers) do if (tbl_utils.has_value(installed_servers, lang)) then local exit_status = pcall(require, servers_prefix .. lang) if (exit_status == false) then -- false = error lspconfig[lang].setup({ on_attach = require("nvdope.initialization.lsp.attachments").commmon, capabilities = require("nvdope.initialization.lsp.capabilities").common(), root_dir = vim.loop.cwd }) end else print("NVDope [E1]: The language server '" .. lang .. "' does not exist or it is not installed!") end end end setup_servers() lspinstall.post_install_hook = function() setup_servers() -- reload installed servers vim.cmd("bufdo e") -- triggers FileType autocmd that starts the server end -- replace the default lsp diagnostic letters with prettier symbols vim.fn.sign_define("LspDiagnosticsSignError", {text = "", numhl = "LspDiagnosticsDefaultError"}) vim.fn.sign_define("LspDiagnosticsSignWarning", {text = "", numhl = "LspDiagnosticsDefaultWarning"}) vim.fn.sign_define("LspDiagnosticsSignInformation", {text = "", numhl = "LspDiagnosticsDefaultInformation"}) vim.fn.sign_define("LspDiagnosticsSignHint", {text = "", numhl = "LspDiagnosticsDefaultHint"}) vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( vim.lsp.diagnostic.on_publish_diagnostics, { virtual_text = { -- prefix = "", prefix = "", spacing = 0 }, signs = true, underline = true, update_in_insert = true } ) -- suppress error messages from lang servers vim.notify = function(msg, log_level, _opts) if msg:match("exit code") then return end if log_level == vim.log.levels.ERROR then vim.api.nvim_err_writeln(msg) else vim.api.nvim_echo({{msg}}, true, {}) end end
nilq/small-lua-stack
null
Concess = {} Concess.webhooks = "TON WEEBHOOK ICI" Concess.jeveuxmarker = true --- true = Oui | false = Non Concess.jeveuxblips = true --- true = Oui | false = Non Concess.pos = { menu = { position = {x = -56.7, y = -1098.77, z = 26.42} }, boss = { position = {x = -29.91, y = -1107.04, z = 26.42} }, serrurier = { position = {x = -50.23, y = -1089.45, z = 26.42} }, spawnvoiture = { position = {x = -51.38, y = -1094.05, z = 26.42, h = 251.959} }, }
nilq/small-lua-stack
null
return { gok_claw = { acceleration = 0, buildangle = 8192, buildcostenergy = 1712, buildcostmetal = 205, builder = false, buildpic = "gok_claw.dds", buildtime = 5000, canattack = true, canstop = 1, category = "ALL SURFACE", cloakcost = 5, corpse = "dead", --damagemodifier = 0.15, defaultmissiontype = "GUARD_NOMOVE", description = "Melee Turret", digger = 1, downloadable = 1, explodeas = "MEDIUM_BUILDINGEX", firestandorders = 1, footprintx = 2, footprintz = 2, hidedamage = true, icontype = "building", idleautoheal = 5, idletime = 1800, losemitheight = 45, mass = 205, maxdamage = 2045, maxslope = 10, maxwaterdepth = 0, mincloakdistance = 25, name = "Cloakable Dragon's Cut", noautofire = false, objectname = "gok_claw", radaremitheight = 44, seismicsignature = 0, selfdestructas = "MEDIUM_BUILDING", sightdistance = 270, standingfireorder = 2, stealth = true, turnrate = 0, unitname = "gok_claw", upright = true, yardmap = "oooo", customparams = { buildpic = "gok_claw.dds", faction = "GOK", }, featuredefs = { dead = { autoreclaimable = 0, blocking = true, category = "corpses", collisionvolumeoffsets = "0.0 2.37060546837e-06 -0.0625", collisionvolumescales = "32.0 17.7499847412 31.375", collisionvolumetype = "Box", damage = 540, description = "Dragon's Claw Wreckage", energy = 0, featuredead = "rockteeth", featurereclamate = "SMUDGE01", footprintx = 2, footprintz = 2, height = 20, hitdensity = 100, metal = 205, nodrawundergray = true, object = "GOK_DRAG", reclaimable = true, seqnamereclamate = "TREE1RECLAMATE", world = "All Worlds", customparams = { fromunit = 1, }, }, rockteeth = { animating = 0, animtrans = 0, blocking = false, damage = 500, description = "Rubble", footprintx = 2, footprintz = 2, height = 20, hitdensity = 100, metal = 2, object = "2X2A", reclaimable = true, shadtrans = 1, world = "greenworld", customparams = { fromunit = 1, }, }, }, sfxtypes = { explosiongenerators = { [1] = "custom:tllroaster1_muzzle", }, pieceexplosiongenerators = { [1] = "piecetrail0", [2] = "piecetrail1", [3] = "piecetrail2", [4] = "piecetrail3", [5] = "piecetrail4", [6] = "piecetrail6", }, }, sounds = { canceldestruct = "cancel2", cloak = "kloak1", uncloak = "kloak1un", underattack = "warning1", cant = { [1] = "cantdo4", }, count = { [1] = "count6", [2] = "count5", [3] = "count4", [4] = "count3", [5] = "count2", [6] = "count1", }, ok = { [1] = "servmed2", }, select = { [1] = "servmed2", }, }, weapondefs = { saw = { areaofeffect = 64, beamtime = 0.10, craterareaofeffect = 0, craterboost = 0, cratermult = 0, --explosiongenerator = "custom:BEAMWEAPON_HIT_ORANGE", firestarter = 30, impactonly = 1, name = "Saw", noselfdamage = true, range = 55, reloadtime = 0.1, rgbcolor = "0.0 0.0 0.0", rgbcolor2= "0.0 0.0 0.0", --soundhitdry = "armgunhit", soundstart = "goksaw", soundtrigger = 1, turret = true, weapontype = "LaserCannon", weaponvelocity = 2000, damage = { commanders = 100, default = 75, subs = 5, }, }, }, weapons = { [1] = { def = "SAW", onlytargetcategory = "SURFACE", }, }, }, }
nilq/small-lua-stack
null
CodexDB["professions"]["frFR-tbc"]={ [6]="Givre", [8]="Feu", [26]="Armes", [38]="Combat", [39]="Finesse", [40]="Poisons", [43]="Epées", [44]="Haches", [45]="Arcs", [46]="Armes à feu", [50]="Maîtrise des bêtes", [51]="Survie", [54]="Masse", [55]="Epées à deux mains", [56]="Sacré", [78]="Magie de l\'ombre", [95]="Défense", [98]="Langue : commun", [101]="Raciale nain", [109]="Langue : orc", [111]="Langue : nain", [113]="Langue : darnassien", [115]="Langue : taurahe", [118]="Ambidextrie", [124]="Raciale tauren", [125]="Raciale orc", [126]="Raciale elfe de la nuit", [129]="Secourisme", [134]="Combat farouche", [136]="Bâtons", [137]="Langue : thalassien", [138]="Langue : draconique", [139]="Langue : démoniaque", [140]="Langue : titan", [141]="Langue : langue ancienne", [142]="Survie", [148]="Equitation", [149]="Monte de loup", [150]="Monte de tigre", [152]="Monte de bélier", [155]="Natation", [160]="Masses à deux mains", [162]="Mains nues", [163]="Précision", [164]="Forge", [165]="Travail du cuir", [171]="Alchimie", [172]="Haches à deux mains", [173]="Dagues", [176]="Armes de jet", [182]="Herboristerie", [183]="GENERIQUE (DND)", [184]="Vindicte", [185]="Cuisine", [186]="Minage", [188]="Familier - diablotin", [189]="Familier – Chasseur corrompu", [197]="Couture", [202]="Ingénierie", [203]="Familier - araignée", [204]="Familier - Marcheur du Vide", [205]="Familier - Succube", [206]="Familier - Infernal", [207]="Familier - garde funeste", [208]="Familier - loup", [209]="Familier - félin", [210]="Familier - ours", [211]="Familier - sanglier", [212]="Familier - crocilisque", [213]="Familier - charognard", [214]="Familier - crabe", [215]="Familier - gorille", [217]="Familier - raptor", [218]="Familier - haut-trotteur", [220]="Racial - morts-vivants", [226]="Arbalètes", [228]="Baguettes", [229]="Armes d\'hast", [236]="Familier - scorpide", [237]="Arcane", [251]="Familier - tortue", [253]="Assassinat", [256]="Fureur", [257]="Protection", [261]="Dressage des bêtes", [267]="Protection", [270]="Familier - générique", [293]="Armure en plaques", [313]="Langue : gnome", [315]="Langue : troll", [333]="Enchantement", [354]="Démonologie", [355]="Affliction", [356]="Pêche", [373]="Amélioration", [374]="Restauration", [375]="Combat élémentaire", [393]="Dépeçage", [413]="Mailles", [414]="Cuir", [415]="Tissu", [433]="Bouclier", [473]="Armes de pugilat", [533]="Monte de raptor", [553]="Pilotage de mécanotrotteur", [554]="Monte de cheval squelette", [573]="Restauration", [574]="Equilibre", [593]="Destruction", [594]="Sacré", [613]="Discipline", [633]="Crochetage", [653]="Familier - chauve-souris", [654]="Familier - hyène", [655]="Familier - chouette", [656]="Familier - serpent des vents", [673]="Langue : bas-parler", [713]="Monte de kodo", [733]="Racial - troll", [753]="Racial - gnome", [754]="Racial - humain", [755]="Joaillerie", [756]="Raciale elfe de sang", [758]="Familier - Evénement - Télécommande", [759]="Langue : draeneï", [760]="Raciale draeneï", [761]="Familier - Gangregarde", [762]="Monte", [763]="Familier - Faucon-dragon", [764]="Familier - Raie du Néant", [765]="Familier - Sporoptère", [766]="Familier - Traqueur dimensionnel", [767]="Familier - Ravageur", [768]="Familier - serpent", [769]="Interne", }
nilq/small-lua-stack
null
return require('packer').startup(function() ----------------------------- -- Editor plugins use 'wbthomason/packer.nvim' use {'tjdevries/express_line.nvim', requires = {'nvim-lua/plenary.nvim'}, config = function() require'config.expressline' end } use {'kyazdani42/nvim-tree.lua', requires = {'kyazdani42/nvim-web-devicons'}, config = function() require'config.tree' end } use {'junegunn/goyo.vim', requires = {'junegunn/limelight.vim'}, ft = {'markdown', 'rst'}, config = function() require'config.goyo' end } use {'sotte/presenting.vim', as = 'presenting', opt = true } use {'neovim/nvim-lspconfig', requires = {'weilbith/nvim-code-action-menu'}, config = function() require'config.lsp' end } use {'hrsh7th/nvim-cmp', requires = { {'onsails/lspkind-nvim'}, {'hrsh7th/cmp-buffer'}, {'hrsh7th/cmp-nvim-lsp'} }, config = function() require'config.cmp' end } use {'mfussenegger/nvim-dap', requires = { {'theHamsta/nvim-dap-virtual-text'} }, config = function() require'config.dap' end } use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make'} use {'nvim-telescope/telescope.nvim', requires = { {'nvim-telescope/plenary.nvim'} }, config = function() require'config.telescope' end } ----------------------------- -- Linters use 'editorconfig/editorconfig-vim' use {'dense-analysis/ale', config = function() require'config.ale' end } ----------------------------- -- Languages use {'chr4/nginx.vim', ft = {'nginx'} } use {'robbles/logstash.vim', ft = {'logstash'} } use {'nvim-treesitter/nvim-treesitter', requires = {'nvim-treesitter/playground', 'nvim-treesitter/nvim-treesitter-textobjects'}, run = ':TSUpdate', config = function() require'config.treesitter' end } end)
nilq/small-lua-stack
null
SKILL.name = "Iceshard Blizzard" SKILL.LevelReq = 2 SKILL.SkillPointCost = 1 SKILL.Incompatible = { } SKILL.RequiredSkills = { } SKILL.icon = "vgui/skills/spell_frost_ice-shards.png" SKILL.category = "Lore of Heavens"-- Common Passives, Warrior, Lore of Light, Lore of Life SKILL.slot = "RANGED" -- ULT, RANGED, MELEE, AOE, PASSIVE SKILL.class = { "celestial_wizard" } SKILL.desc = [[ Razor-sharp shards of ice hurl from the chill skies to blind and dishearten the foe. Ability Slot: 2 Class Restriction: Bright Wizard Level Requirement: ]] .. SKILL.LevelReq .. [[ Skill Point Cost:]] .. SKILL.SkillPointCost .. [[ ]] SKILL.coolDown = 5 local function ability(SKILL, ply ) local nospam = ply:GetNWBool( "nospamRanged" ) if (nospam) then if timer.Exists(ply:SteamID().."nospamRanged") then return end timer.Create(ply:SteamID().."nospamRanged", SKILL.coolDown, 1, function() ply:SetNWBool( "nospamRanged", false ) end) return end local mana = ply:getLocalVar("mana", 0) if mana < 20 then return end ply:setLocalVar("mana", mana - 20) local BoneID = ply:LookupBone( "ValveBiped.Bip01_R_Hand" ) local MainPos = ply:GetBonePosition(BoneID) local Positions = {} Positions[1] = MainPos Positions[2] = (MainPos - ply:GetRight()*math.random(1, 100)) - ply:GetAimVector() * math.random(1, 100) + ply:GetUp()*math.random(1, 50) Positions[3] = (MainPos - ply:GetRight()*math.random(1, 100)) + ply:GetAimVector() * math.random(1, 100) - ply:GetUp()*math.random(1, 50) Positions[4] = (MainPos + ply:GetRight()*math.random(1, 100)) - ply:GetAimVector() * math.random(1, 100) + ply:GetUp()*math.random(1, 50) Positions[5] = (MainPos + ply:GetRight()*math.random(1, 100)) + ply:GetAimVector() * math.random(1, 100) - ply:GetUp()*math.random(1, 50) Positions[6] = (MainPos - ply:GetRight()*math.random(1, 100)) - ply:GetAimVector() * math.random(1, 100) + ply:GetUp()*math.random(1, 50) Positions[7] = (MainPos - ply:GetRight()*math.random(1, 100)) + ply:GetAimVector() * math.random(1, 100) - ply:GetUp()*math.random(1, 50) Positions[8] = (MainPos + ply:GetRight()*math.random(1, 100)) - ply:GetAimVector() * math.random(1, 100) + ply:GetUp()*math.random(1, 50) Positions[9] = (MainPos - ply:GetRight()*math.random(1, 100)) + ply:GetAimVector() * math.random(1, 100) - ply:GetUp()*math.random(1, 50) Positions[10] = (MainPos + ply:GetRight()*math.random(1, 100)) - ply:GetAimVector() * math.random(1, 100) + ply:GetUp()*math.random(1, 50) for i = 1, 10 do local Ent = ents.Create("sent_zad_iceshard") local OwnerPos = ply:GetShootPos() local OwnerAng = ply:GetAimVector():Angle() OwnerPos = OwnerPos + OwnerAng:Forward()*-20 + OwnerAng:Up()*-9 + OwnerAng:Right()*10 if ply:IsPlayer() then Ent:SetAngles(OwnerAng) else Ent:SetAngles(ply:GetAngles()) end local BoneID = ply:LookupBone( "ValveBiped.Bip01_R_Hand" ) Ent:SetPos(Positions[i]) local ent = nil if ply:GetEyeTrace().Entity:IsPlayer() or ply:GetEyeTrace().Entity:IsNPC() then ent = ply:GetEyeTrace().Entity else local Ents = ents.FindInCone(ply:EyePos(), ply:GetAimVector(), 500, math.cos(math.rad(120))) for k, v in pairs(Ents) do if ((v:IsPlayer() and v != ply) or v:IsNPC()) then ent = v end end end Ent:SetOwner(ply) Ent:Spawn() Ent.InitialTarget = ent end if (SERVER) then ply:SetNWBool( "nospamRanged", true ) print("Cdstart") net.Start( "RangedActivated" ) net.Send( ply ) if timer.Exists(ply:SteamID().."nospamRanged") then return end timer.Create(ply:SteamID().."nospamRanged", SKILL.coolDown, 1, function() ply:SetNWBool( "nospamRanged", false ) end) end end SKILL.ability = ability
nilq/small-lua-stack
null
HLHUD.Hook:Post(HUDStatsScreen, "recreate_right", function(self) self._hl_tm_panel = HLHUD:make_panel(self._right, "extra_teammates_info", { h = 320, x = 10, bottom = self._right:h() - 10 - tweak_data.menu.pd2_small_font_size }) local font_size = 20 local prev local prev_t local function make_text(name, text, color, next_to_and_offset) local t = prev:text({name = name, text = tostring(text), color = color, font = "fonts/font_medium_mf", font_size = font_size}) managers.hud:make_fine_text(t) if prev_t then if next_to_and_offset then t:set_y(prev_t:y()) t:set_x(prev_t:right() + next_to_and_offset) else t:set_y(prev_t:bottom()) end end prev_t = t return t end for i,tm in pairs(managers.hud._teammate_panels) do prev = HLHUD:make_panel(self._hl_tm_panel, tostring(i), {h = self._hl_tm_panel:h() / HUDManager.PLAYER_PANEL, y = prev and prev:bottom() or 0}) prev_t = nil make_text("name", tm._hl_name:text(), tm._hl_name:color()) local health = tm._hl_health:child("text") if not tm._ai then make_text("health", health:text(), health:color()) if not tm._hl_in_custody then make_text("primary_total", tm._hl_ammo.primary.total, nil, 20) make_text("secondary_total", "| " .. tm._hl_ammo.secondary.total, nil, 2) end end HLHUD:make_panel(prev, "equipment", {y = prev_t:bottom() + 2}) tm:hl_request_equipment(self) end self._hl_tm_panel:animate(function() wait(1) if managers.hud and managers.hud._showing_stats_screen then self:recreate_right() end end) end) function HUDStatsScreen:hl_align_equipment() for _, pnl in pairs(self._hl_tm_panel:children()) do local prev for _, equip in pairs(pnl:child("equipment"):children()) do local x = prev and prev:right() + 6 or 0 local next_right = x + equip:w() if next_right <= pnl:w() then equip:set_x(x) else equip:set_y(prev and prev:bottom() or 0) equip:set_x(0) end prev = equip end end end function HUDStatsScreen:hl_add_equipment(i, id, icon, value, from_string) local white = tweak_data.screen_colors.text local pnl = self._hl_tm_panel:child(tostring(i)) if pnl then local icon, rect = tweak_data.hud_icons:get_icon_data(icon) local equipment = pnl:child("equipment") local np = HLHUD:make_panel(equipment, id) local icon = np:bitmap({ name = name, color = color, texture = icon, texture_rect = rect }) local amount = np:text({ name = "amount", center_y = icon:center_y(), x = icon:right() + 4, text = tostring(value) or "--", font = "fonts/font_medium_mf", font_size = 16, color = white }) if from_string then local amounts, zero_ranges = HUDTeammate:hl_get_amounts_and_range(value) amount:set_text(amounts) for _, range in ipairs(zero_ranges) do amount:set_range_color(range[1], range[2], white:with_alpha(0.5)) end end managers.hud:make_fine_text(amount) np:set_h(amount:h()) icon:set_size(np:h(), np:h()) amount:set_x(icon:right() + 10) np:set_w(amount:right()) end self:hl_align_equipment() end
nilq/small-lua-stack
null
return PlaceObj("ModDef", { "title", "Omega Unlocks All", "version", 1, "version_major", 0, "version_minor", 1, "saved", 0, "image", "Preview.png", "id", "ChoGGi_OmegaUnlocksAll", "pops_any_uuid", "694072ce-c6b9-4cf9-b20e-4fd60ce3adef", "author", "ChoGGi", "lua_revision", 249143, "code", { "Code/Script.lua", }, "description", [[Omega Telescope will unlock all breakthroughs instead of three. Requested by Griffdy04.]], })
nilq/small-lua-stack
null
local function add(a, b) return a+b end return add(add(2,6), add(1,9))
nilq/small-lua-stack
null
local BaseInstance = import("./BaseInstance") return BaseInstance:extend("ReplicatedStorage")
nilq/small-lua-stack
null
ffi = require "ffi" require "LDYOM.Scripts.baseNode" class = require "LDYOM.Scripts.middleclass" Node = bitser.registerClass(class("NodeAttachCamToVehicle", BaseNode)); Node.static.name = imgui.imnodes.getNodeIcon("func")..' '..ldyom.langt("CoreNodeAttachCamToVehicle"); Node.static.mission = true; function Node:initialize(id) BaseNode.initialize(self,id); self.type = 4; self.pointPos = ffi.new("bool[1]",false); self.Pins = { [self.id+1] = BasePin:new(self.id+1,imgui.imnodes.PinType.void, 0), [self.id+2] = BasePin:new(self.id+2,imgui.imnodes.PinType.number, 0, ffi.new("int[1]")), [self.id+3] = BasePin:new(self.id+3,imgui.imnodes.PinType.number, 0, ffi.new("float[1]")), [self.id+4] = BasePin:new(self.id+4,imgui.imnodes.PinType.number, 0, ffi.new("float[1]")), [self.id+5] = BasePin:new(self.id+5,imgui.imnodes.PinType.number, 0, ffi.new("float[1]")), [self.id+6] = BasePin:new(self.id+6,imgui.imnodes.PinType.number, 0, ffi.new("float[1]")), [self.id+7] = BasePin:new(self.id+7,imgui.imnodes.PinType.number, 0, ffi.new("float[1]")), [self.id+8] = BasePin:new(self.id+8,imgui.imnodes.PinType.number, 0, ffi.new("float[1]")), [self.id+9] = BasePin:new(self.id+9,imgui.imnodes.PinType.boolean, 0, ffi.new("bool[1]")), [self.id+11] = BasePin:new(self.id+11,imgui.imnodes.PinType.void, 1), }; end function attachToVehicle() ldyom.attachCameraToEntity(0, currNodeStaticCamera.Pins[currNodeStaticCamera.id+2].value[0], 0, currNodeStaticCamera.Pins[currNodeStaticCamera.id+3].value, currNodeStaticCamera.Pins[currNodeStaticCamera.id+4].value, currNodeStaticCamera.Pins[currNodeStaticCamera.id+5].value, currNodeStaticCamera.Pins[currNodeStaticCamera.id+6].value, currNodeStaticCamera.Pins[currNodeStaticCamera.id+7].value, currNodeStaticCamera.Pins[currNodeStaticCamera.id+8].value); end function Node:draw() imgui.imnodes.BeginNode(self.id,self.type) imgui.imnodes.BeginNodeTitleBar(); imgui.Text(self.class.static.name); if ldyom.getLastNode() == self.id then imgui.SameLine(0,0); imgui.TextColored(imgui.ImVec4.new(1.0,0.0,0.0,1.0)," \xef\x86\x88"); end imgui.imnodes.EndNodeTitleBar(); imgui.imnodes.BeginInputAttribute(self.id+1); imgui.Dummy(imgui.ImVec2:new(0,10)); imgui.imnodes.EndInputAttribute(); imgui.imnodes.BeginStaticAttribute(self.id+2); local names = ldyom.namesCars; imgui.Text(ldyom.langt("car")); imgui.SetNextItemWidth(150); imgui.ComboVecChars("",self.Pins[self.id+2].value,names); imgui.imnodes.EndStaticAttribute(); imgui.imnodes.BeginInputAttribute(self.id+3); imgui.Text("x"); if not self.Pins[self.id+3].link then imgui.SetNextItemWidth(200); imgui.InputFloat("", self.Pins[self.id+3].value); end imgui.imnodes.EndInputAttribute(); imgui.imnodes.BeginInputAttribute(self.id+4); imgui.Text("y"); if not self.Pins[self.id+4].link then imgui.SetNextItemWidth(200); imgui.InputFloat("", self.Pins[self.id+4].value); end imgui.imnodes.EndInputAttribute(); imgui.imnodes.BeginInputAttribute(self.id+5); imgui.Text("z"); if not self.Pins[self.id+5].link then imgui.SetNextItemWidth(200); imgui.InputFloat("", self.Pins[self.id+5].value); end imgui.imnodes.EndInputAttribute(); imgui.imnodes.BeginStaticAttribute(self.id+12); imgui.ToggleButton(ldyom.langt("turn"), self.pointPos); imgui.imnodes.EndStaticAttribute(); if (self.pointPos[0]) then imgui.imnodes.BeginInputAttribute(self.id+6); imgui.Text(ldyom.langt("rotate").." x"); if not self.Pins[self.id+6].link then imgui.SetNextItemWidth(200); imgui.InputFloat("", self.Pins[self.id+6].value); end imgui.imnodes.EndInputAttribute(); imgui.imnodes.BeginInputAttribute(self.id+7); imgui.Text(ldyom.langt("rotate").." y"); if not self.Pins[self.id+7].link then imgui.SetNextItemWidth(200); imgui.InputFloat("", self.Pins[self.id+7].value); end imgui.imnodes.EndInputAttribute(); imgui.imnodes.BeginInputAttribute(self.id+8); imgui.Text(ldyom.langt("rotate").." z"); if not self.Pins[self.id+8].link then imgui.SetNextItemWidth(200); imgui.InputFloat("", self.Pins[self.id+8].value); end imgui.imnodes.EndInputAttribute(); imgui.imnodes.BeginInputAttribute(self.id+9); if not self.Pins[self.id+8].link then imgui.ToggleButton(ldyom.langt("movecam"), self.Pins[self.id+9].value); else imgui.Text(ldyom.langt("")); end imgui.imnodes.EndInputAttribute(); end imgui.imnodes.BeginStaticAttribute(self.id+10); if imgui.Button(ldyom.langt("edithand"), imgui.ImVec2:new(200,20)) and #names > 0 then callOpcode(0x01B4, {{0,"int"}, {0,"int"}}); currNodeStaticCamera = self; ldyom.set_off_gui(true); addThread(attachToVehicle); end imgui.imnodes.EndStaticAttribute(); imgui.imnodes.BeginOutputAttribute(self.id+11); imgui.Dummy(imgui.ImVec2:new(0,10)); imgui.imnodes.EndOutputAttribute(); imgui.imnodes.EndNode(); end function Node:play(data, mission) local car = self:getPinValue(self.id+2,data,mission)[0]; local x = self:getPinValue(self.id+3,data,mission)[0]; local y = self:getPinValue(self.id+4,data,mission)[0]; local z = self:getPinValue(self.id+5,data,mission)[0]; local rot_x = self:getPinValue(self.id+6,data,mission)[0]; local rot_y = self:getPinValue(self.id+7,data,mission)[0]; local rot_z = self:getPinValue(self.id+8,data,mission)[0]; local movecam = self:getPinValue(self.id+9,data,mission)[0]; assert(mission.list_cars[car+1].missionCar, "The car is not yet established or has already disappeared."); ldyom.setLastNode(self.id); local carRef = getCarRef(mission.list_cars[car+1].missionCar); if not self.pointPos then rot_x, rot_y, rot_z = 0,0,0; end callOpcode(0x0679, {{carRef,"int"}, {x,"float"}, {y,"float"}, {z,"float"}, {rot_x,"float"}, {rot_y,"float"}, {rot_z,"float"}, {0.0,"float"}, {fif(movecam,1,2),"int"}}); self:callOutputLinks(data, mission, self.id+11); end ldyom.nodeEditor.addNodeClass("Camera",Node);
nilq/small-lua-stack
null
--[=[ Debug drawing library useful for debugging 3D abstractions. One of the more useful utility libraries. These functions are incredibly easy to invoke for quick debugging. This can make debugging any sort of 3D geometry really easy. ```lua -- A sample of a few API uses Draw.point(Vector3.new(0, 0, 0)) Draw.terrainCell(Vector3.new(0, 0, 0)) Draw.cframe(CFrame.new(0, 10, 0)) Draw.text(Vector3.new(0, -10, 0), "Testing!") ``` :::tip This library should not be used to render things in production for normal players, as it is optimized for debug experience over performance. ::: @class Draw ]=] local Workspace = game:GetService("Workspace") local RunService = game:GetService("RunService") local TextService = game:GetService("TextService") local Terrain = Workspace.Terrain local ORIGINAL_DEFAULT_COLOR = Color3.new(1, 0, 0) local Draw = {} Draw._defaultColor = ORIGINAL_DEFAULT_COLOR --[=[ Sets the Draw's drawing color. @param color Color3 -- The color to set ]=] function Draw.setColor(color) Draw._defaultColor = color end --[=[ Resets the drawing color. ]=] function Draw.resetColor() Draw._defaultColor = ORIGINAL_DEFAULT_COLOR end --[=[ Sets the Draw library to use a random color. ]=] function Draw.setRandomColor() Draw.setColor(Color3.fromHSV(math.random(), 0.5+0.5*math.random(), 1)) end --[=[ Draws a ray for debugging. ```lua local ray = Ray.new(Vector3.new(0, 0, 0), Vector3.new(0, 10, 0)) Draw.ray(ray) ``` @param ray Ray @param color Color3? -- Optional color to draw in @param parent Instance? -- Optional parent @param diameter number? -- Optional diameter @param meshDiameter number? -- Optional mesh diameter @return BasePart ]=] function Draw.ray(ray, color, parent, meshDiameter, diameter) assert(typeof(ray) == "Ray", "Bad typeof(ray) for Ray") color = color or Draw._defaultColor parent = parent or Draw.getDefaultParent() meshDiameter = meshDiameter or 0.2 diameter = diameter or 0.2 local rayCenter = ray.Origin + ray.Direction/2 local part = Instance.new("Part") part.Material = Enum.Material.ForceField part.Anchored = true part.Archivable = false part.CanCollide = false part.CastShadow = false part.CFrame = CFrame.new(rayCenter, ray.Origin + ray.Direction) * CFrame.Angles(math.pi/2, 0, 0) part.Color = color part.Name = "DebugRay" part.Shape = Enum.PartType.Cylinder part.Size = Vector3.new(diameter, ray.Direction.Magnitude, diameter) part.TopSurface = Enum.SurfaceType.Smooth part.Transparency = 0.5 local rotatedPart = Instance.new("Part") rotatedPart.Name = "RotatedPart" rotatedPart.Anchored = true rotatedPart.Archivable = false rotatedPart.CanCollide = false rotatedPart.CastShadow = false rotatedPart.CFrame = CFrame.new(ray.Origin, ray.Origin + ray.Direction) rotatedPart.Transparency = 1 rotatedPart.Size = Vector3.new(1, 1, 1) rotatedPart.Parent = part local lineHandleAdornment = Instance.new("LineHandleAdornment") lineHandleAdornment.Name = "DrawRayLineHandleAdornment" lineHandleAdornment.Length = ray.Direction.Magnitude lineHandleAdornment.Thickness = 5*diameter lineHandleAdornment.ZIndex = 3 lineHandleAdornment.Color3 = color lineHandleAdornment.AlwaysOnTop = true lineHandleAdornment.Transparency = 0 lineHandleAdornment.Adornee = rotatedPart lineHandleAdornment.Parent = rotatedPart local mesh = Instance.new("SpecialMesh") mesh.Name = "DrawRayMesh" mesh.Scale = Vector3.new(0, 1, 0) + Vector3.new(meshDiameter, 0, meshDiameter) / diameter mesh.Parent = part part.Parent = parent return part end --[=[ Updates the rendered ray to the new color and position. Used for certain scenarios when updating a ray on renderstepped would impact performance, even in debug mode. ```lua local ray = Ray.new(Vector3.new(0, 0, 0), Vector3.new(0, 10, 0)) local drawn = Draw.ray(ray) RunService.RenderStepped:Connect(function() local newRay = Ray.new(Vector3.new(0, 0, 0), Vector3.new(0, 10*math.sin(os.clock()), 0)) Draw.updateRay(drawn, newRay Color3.new(1, 0.5, 0.5)) end) ``` @param part Ray part @param ray Ray @param color Color3 ]=] function Draw.updateRay(part, ray, color) color = color or part.Color local diameter = part.Size.x local rayCenter = ray.Origin + ray.Direction/2 part.CFrame = CFrame.new(rayCenter, ray.Origin + ray.Direction) * CFrame.Angles(math.pi/2, 0, 0) part.Size = Vector3.new(diameter, ray.Direction.Magnitude, diameter) part.Color = color local rotatedPart = part:FindFirstChild("RotatedPart") if rotatedPart then rotatedPart.CFrame = CFrame.new(ray.Origin, ray.Origin + ray.Direction) end local lineHandleAdornment = rotatedPart and rotatedPart:FindFirstChild("DrawRayLineHandleAdornment") if lineHandleAdornment then lineHandleAdornment.Length = ray.Direction.Magnitude lineHandleAdornment.Thickness = 5*diameter lineHandleAdornment.Color3 = color end end --[=[ Render text in 3D for debugging. The text container will be sized to fit the text. ```lua Draw.text(Vector3.new(0, 10, 0), "Point") ``` @param adornee Instance | Vector3 -- Adornee to rener on @param text string -- Text to render @param color Color3? -- Optional color to render @return Instance ]=] function Draw.text(adornee, text, color) if typeof(adornee) == "Vector3" then local attachment = Instance.new("Attachment") attachment.WorldPosition = adornee attachment.Parent = Terrain attachment.Name = "DebugTextAttachment" Draw._textOnAdornee(attachment, text, color) return attachment elseif typeof(adornee) == "Instance" then return Draw._textOnAdornee(adornee, text, color) else error("Bad adornee") end end function Draw._textOnAdornee(adornee, text, color) local TEXT_HEIGHT_STUDS = 2 local PADDING_PERCENT_OF_LINE_HEIGHT = 0.5 local billboardGui = Instance.new("BillboardGui") billboardGui.Name = "DebugBillboardGui" billboardGui.SizeOffset = Vector2.new(0, 0.5) billboardGui.ExtentsOffset = Vector3.new(0, 1, 0) billboardGui.AlwaysOnTop = true billboardGui.Adornee = adornee billboardGui.StudsOffset = Vector3.new(0, 0, 0.01) local background = Instance.new("Frame") background.Name = "Background" background.Size = UDim2.new(1, 0, 1, 0) background.Position = UDim2.new(0.5, 0, 1, 0) background.AnchorPoint = Vector2.new(0.5, 1) background.BackgroundTransparency = 0.3 background.BorderSizePixel = 0 background.BackgroundColor3 = color or Draw._defaultColor background.Parent = billboardGui local textLabel = Instance.new("TextLabel") textLabel.Text = tostring(text) textLabel.TextScaled = true textLabel.TextSize = 32 textLabel.BackgroundTransparency = 1 textLabel.BorderSizePixel = 0 textLabel.TextColor3 = Color3.new(1, 1, 1) textLabel.Size = UDim2.new(1, 0, 1, 0) textLabel.Parent = background if tonumber(text) then textLabel.Font = Enum.Font.Code else textLabel.Font = Enum.Font.GothamSemibold end local textSize = TextService:GetTextSize( textLabel.Text, textLabel.TextSize, textLabel.Font, Vector2.new(1024, 1e6)) local lines = textSize.y/textLabel.TextSize local paddingOffset = textLabel.TextSize*PADDING_PERCENT_OF_LINE_HEIGHT local paddedHeight = textSize.y + 2*paddingOffset local paddedWidth = textSize.x + 2*paddingOffset local aspectRatio = paddedWidth/paddedHeight local uiAspectRatio = Instance.new("UIAspectRatioConstraint") uiAspectRatio.AspectRatio = aspectRatio uiAspectRatio.Parent = background local uiPadding = Instance.new("UIPadding") uiPadding.PaddingBottom = UDim.new(paddingOffset/paddedHeight, 0) uiPadding.PaddingTop = UDim.new(paddingOffset/paddedHeight, 0) uiPadding.PaddingLeft = UDim.new(paddingOffset/paddedWidth, 0) uiPadding.PaddingRight = UDim.new(paddingOffset/paddedWidth, 0) uiPadding.Parent = background local uiCorner = Instance.new("UICorner") uiCorner.CornerRadius = UDim.new(paddingOffset/paddedHeight/2, 0) uiCorner.Parent = background local height = lines*TEXT_HEIGHT_STUDS * TEXT_HEIGHT_STUDS*PADDING_PERCENT_OF_LINE_HEIGHT billboardGui.Size = UDim2.new(height*aspectRatio, 0, height, 0) billboardGui.Parent = adornee return billboardGui end --[=[ Renders a sphere at the given point in 3D space. ```lua Draw.sphere(Vector3.new(0, 10, 0), 10) ``` Great for debugging explosions and stuff. @param position Vector3 -- Position of the sphere @param radius number -- Radius of the sphere @param color Color3? -- Optional color @param parent Instance? -- Optional parent @return BasePart ]=] function Draw.sphere(position, radius, color, parent) return Draw.point(position, color, parent, radius*2) end --[=[ Draws a point for debugging in 3D space. ```lua Draw.point(Vector3.new(0, 25, 0), Color3.new(0.5, 1, 0.5)) ``` @param position Vector3 | CFrame -- Point to Draw @param color Color3? -- Optional color @param parent Instance? -- Optional parent @param diameter number? -- Optional diameter @return BasePart ]=] function Draw.point(position, color, parent, diameter) if typeof(position) == "CFrame" then position = position.p end assert(typeof(position) == "Vector3", "Bad position") color = color or Draw._defaultColor parent = parent or Draw.getDefaultParent() diameter = diameter or 1 local part = Instance.new("Part") part.Material = Enum.Material.ForceField part.Anchored = true part.Archivable = false part.BottomSurface = Enum.SurfaceType.Smooth part.CanCollide = false part.CastShadow = false part.CFrame = CFrame.new(position) part.Color = color part.Name = "DebugPoint" part.Shape = Enum.PartType.Ball part.Size = Vector3.new(diameter, diameter, diameter) part.TopSurface = Enum.SurfaceType.Smooth part.Transparency = 0.5 local sphereHandle = Instance.new("SphereHandleAdornment") sphereHandle.Archivable = false sphereHandle.Radius = diameter/4 sphereHandle.Color3 = color sphereHandle.AlwaysOnTop = true sphereHandle.Adornee = part sphereHandle.ZIndex = 2 sphereHandle.Parent = part part.Parent = parent return part end --[=[ Renders a point with a label in 3D space. ```lua Draw.labelledPoint(Vector3.new(0, 10, 0), "AI target") ``` @param position Vector3 | CFrame -- Position to render @param label string -- Label to render on the point @param color Color3? -- Optional color @param parent Instance? -- Optional parent @return BasePart ]=] function Draw.labelledPoint(position, label, color, parent) if typeof(position) == "CFrame" then position = position.p end local part = Draw.point(position, color, parent) Draw.text(part, label, color) return part end --[=[ Renders a CFrame in 3D space. Includes each axis. ```lua Draw.cframe(CFrame.Angles(0, math.pi/8, 0)) ``` @param cframe CFrame @return Model ]=] function Draw.cframe(cframe) local model = Instance.new("Model") model.Name = "DebugCFrame" local position = cframe.Position Draw.point(position, nil, model, 0.1) local xRay = Draw.ray(Ray.new( position, cframe.XVector ), Color3.new(0.75, 0.25, 0.25), model, 0.1) xRay.Name = "XVector" local yRay = Draw.ray(Ray.new( position, cframe.YVector ), Color3.new(0.25, 0.75, 0.25), model, 0.1) yRay.Name = "YVector" local zRay = Draw.ray(Ray.new( position, cframe.ZVector ), Color3.new(0.25, 0.25, 0.75), model, 0.1) zRay.Name = "ZVector" model.Parent = Draw.getDefaultParent() return model end --[=[ Renders a box in 3D space. Great for debugging bounding boxes. ```lua Draw.box(Vector3.new(0, 5, 0), Vector3.new(10, 10, 10)) ``` @param cframe CFrame | Vector3 -- CFrame of the box @param size Vector3 -- Size of the box @param color Color3 -- Optional Color3 @return BasePart ]=] function Draw.box(cframe, size, color) assert(typeof(size) == "Vector3", "Bad size") color = color or Draw._defaultColor cframe = typeof(cframe) == "Vector3" and CFrame.new(cframe) or cframe local part = Instance.new("Part") part.Color = color part.Material = Enum.Material.ForceField part.Name = "DebugPart" part.Anchored = true part.CanCollide = false part.CastShadow = false part.Archivable = false part.BottomSurface = Enum.SurfaceType.Smooth part.TopSurface = Enum.SurfaceType.Smooth part.Transparency = 0.75 part.Size = size part.CFrame = cframe local boxHandleAdornment = Instance.new("BoxHandleAdornment") boxHandleAdornment.Adornee = part boxHandleAdornment.Size = size boxHandleAdornment.Color3 = color boxHandleAdornment.AlwaysOnTop = true boxHandleAdornment.Transparency = 0.75 boxHandleAdornment.ZIndex = 1 boxHandleAdornment.Parent = part part.Parent = Draw.getDefaultParent() return part end --[=[ Renders a region3 in 3D space. ```lua Draw.region3(Region3.new(Vector3.new(0, 0, 0), Vector3.new(10, 10, 10))) ``` @param region3 Region3 -- Region3 to render @param color Color3? -- Optional color3 @return BasePart ]=] function Draw.region3(region3, color) return Draw.box(region3.CFrame, region3.Size, color) end --[=[ Renders a terrain cell in 3D space. Snaps the position to the nearest position. ```lua Draw.terrainCell(Vector3.new(0, 0, 0)) ``` @param position Vector3 -- World space position @param color Color3? -- Optional color to render @return BasePart ]=] function Draw.terrainCell(position, color) local size = Vector3.new(4, 4, 4) local solidCell = Terrain:WorldToCell(position) local terrainPosition = Terrain:CellCenterToWorld(solidCell.x, solidCell.y, solidCell.z) local part = Draw.box(CFrame.new(terrainPosition), size, color) part.Name = "DebugTerrainCell" return part end --[=[ Draws a vector in 3D space. ```lua Draw.vector(Vector3.new(0, 0, 0), Vector3.new(0, 1, 0)) ``` @param position Vector3 -- Position of the vector @param direction Vector3 -- Direction of the vector. Determines length. @param color Color3? -- Optional color @param parent Instance? -- Optional instance @param meshDiameter number? -- Optional diameter @return BasePart ]=] function Draw.vector(position, direction, color, parent, meshDiameter) return Draw.ray(Ray.new(position, direction), color, parent, meshDiameter) end --[=[ Retrieves the default parent for the current execution context. @return Instance ]=] function Draw.getDefaultParent() if not RunService:IsRunning() then return Workspace.CurrentCamera end if RunService:IsServer() then return Workspace else return Workspace.CurrentCamera end end return Draw
nilq/small-lua-stack
null
require "keybow" -- Key mappings -- function handle_key_00(pressed) keybow.set_key(keybow.KP0, pressed) end function handle_key_01(pressed) keybow.set_key(keybow.KP1, pressed) end function handle_key_02(pressed) keybow.set_key(keybow.KP2, pressed) end function handle_key_03(pressed) keybow.set_key(keybow.KP3, pressed) end function handle_key_04(pressed) keybow.set_key(keybow.KP4, pressed) end function handle_key_05(pressed) keybow.set_key(keybow.KP5, pressed) end function handle_key_06(pressed) keybow.set_key(keybow.KP6, pressed) end function handle_key_07(pressed) keybow.set_key(keybow.KP7, pressed) end function handle_key_08(pressed) keybow.set_key(keybow.KP8, pressed) end function handle_key_09(pressed) keybow.set_key(keybow.KP9, pressed) end function handle_key_10(pressed) keybow.set_key(keybow.KPDOT, pressed) end function handle_key_11(pressed) keybow.set_key(keybow.KPEQUAL, pressed) end
nilq/small-lua-stack
null
local player = game.Players.LocalPlayer local plrGui = player:WaitForChild("PlayerGui") local HTPGUI = plrGui:WaitForChild("HowToPlayGui") HTPGUI.Frame.Visible = true HTPGUI.Frame.TextButton.MouseButton1Click:Connect(function() HTPGUI:Destroy() end)
nilq/small-lua-stack
null
-------------------------------------------------------------- -- direct_access.lua -- -------------------------------------------------------------- -- -- -- This file provides the 2 public modder-facing functions -- -- for accessing game_doc data. These are: -- -- -- -- <> game_doc.get_doc_data() -- -- <> game_doc.get_hidden_data(player_name) -- -- -- -- Use the above functions to access and possibly make -- -- changes to the backend data in game_doc -- -------------------------------------------------------------- game_doc.get_doc_data = function() return game_doc.doc_data end game_doc.get_hidden_data = function(player_name) return game_doc.player_data[player_name] --can be nil end -- Simple, right?
nilq/small-lua-stack
null
--[[ Original textures from GeMinecraft http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/1440575-1-2-5-generation-minecraft-beta-1-2-farming-and ]] local S = farming.intllib -- corn minetest.register_craftitem("farming:corn", { description = S("Corn"), inventory_image = "farming_corn.png", on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:corn_1") end, on_use = minetest.item_eat(3), }) -- corn on the cob (texture by TenPlus1) minetest.register_craftitem("farming:corn_cob", { description = S("Corn on the Cob"), inventory_image = "farming_corn_cob.png", on_use = minetest.item_eat(5), }) minetest.register_craft({ type = "cooking", cooktime = 10, output = "farming:corn_cob", recipe = "farming:corn" }) -- ethanol (thanks to JKMurray for this idea) minetest.register_craftitem("farming:bottle_ethanol", { description = S("Bottle of Ethanol"), inventory_image = "farming_bottle_ethanol.png", }) minetest.register_craft( { output = "farming:bottle_ethanol", recipe = { { "vessels:glass_bottle", "farming:corn", "farming:corn"}, { "farming:corn", "farming:corn", "farming:corn"}, } }) minetest.register_craft({ type = "fuel", recipe = "farming:bottle_ethanol", burntime = 240, replacements = {{ "farming:bottle_ethanol", "vessels:glass_bottle"}} }) -- corn definition local crop_def = { drawtype = "plantlike", tiles = {"farming_corn_1.png"}, paramtype = "light", sunlight_propagates = true, walkable = false, buildable_to = true, drop = "", selection_box = farming.select, groups = { snappy = 3, flammable = 2, plant = 1, attached_node = 1, not_in_creative_inventory = 1, growing = 1 }, sounds = default.node_sound_leaves_defaults() } -- stage 1 minetest.register_node("farming:corn_1", table.copy(crop_def)) -- stage 2 crop_def.tiles = {"farming_corn_2.png"} minetest.register_node("farming:corn_2", table.copy(crop_def)) -- stage 3 crop_def.tiles = {"farming_corn_3.png"} minetest.register_node("farming:corn_3", table.copy(crop_def)) -- stage 4 crop_def.tiles = {"farming_corn_4.png"} minetest.register_node("farming:corn_4", table.copy(crop_def)) -- stage 5 crop_def.tiles = {"farming_corn_5.png"} minetest.register_node("farming:corn_5", table.copy(crop_def)) -- stage 6 crop_def.tiles = {"farming_corn_6.png"} crop_def.visual_scale = 1.45 minetest.register_node("farming:corn_6", table.copy(crop_def)) -- stage 7 crop_def.tiles = {"farming_corn_7.png"} crop_def.drop = { items = { {items = {'farming:corn'}, rarity = 1}, {items = {'farming:corn'}, rarity = 2}, {items = {'farming:corn'}, rarity = 3}, } } minetest.register_node("farming:corn_7", table.copy(crop_def)) -- stage 8 (final) crop_def.tiles = {"farming_corn_8.png"} crop_def.groups.growing = 0 crop_def.drop = { items = { {items = {'farming:corn 2'}, rarity = 1}, {items = {'farming:corn 2'}, rarity = 2}, {items = {'farming:corn 2'}, rarity = 2}, } } minetest.register_node("farming:corn_8", table.copy(crop_def))
nilq/small-lua-stack
null
-- sprint_controller -- ArkhieDev -- 6/9/2021 -- Services local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local ContextActionService = game:GetService("ContextActionService") local SoundService = game:GetService("SoundService") local TweenService = game:GetService("TweenService") local sprint_controller = {} local xf = require(ReplicatedStorage:WaitForChild("xeno")) local network = xf.network local player = Players.LocalPlayer local SPRINT_TWEEN_SPEED = .3 local NORMAL_WALKSPEED = 16 local SPRINT_WALKSPEED = NORMAL_WALKSPEED + 8 local STAMINA_LOST_PER_SEC = 10 local STAMINA_REGEN_PER_SEC = 10 local STAMINA_INT_REGEN = 2 local STAMINA_UI_FADE_INT = 2 local OPTIMAL_TWEEN_INFO = TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out) local tweenSprintBar = function(ui, val) local newVal = string.format("%.2f", val) if newVal == val then return; end local tween = TweenService:Create(ui.OutBar.BarContainer.Bar, OPTIMAL_TWEEN_INFO, { Size = UDim2.fromScale(1, newVal), Position = UDim2.fromScale(0.5, 1 - newVal) }); tween:Play() task.spawn(function() tween.Completed:Wait() tween:Destroy() end) end local CreateTween = function(propertyTable, tweeninfo, obj) local isObjTable = false for class in pairs(propertyTable) do if type(class) == "userdata" then isObjTable = true break end end if isObjTable then local list = {} for ins, t in pairs(propertyTable) do table.insert(list, TweenService:Create(ins, tweeninfo or OPTIMAL_TWEEN_INFO, t)) end return setmetatable({ _list = list }, { __index = function(tbl, index) return ({ Play = function() for _, tween in pairs(tbl._list) do tween:Play() end end, Cancel = function() for _, tween in pairs(tbl._list) do tween:Cancel() end end, Pause = function() for _, tween in pairs(tbl._list) do tween:Pause() end end, Destroy = function() for _, tween in pairs(tbl._list) do tween:Destroy() end end, })[index] end, }); else return TweenService:Create(obj, tweeninfo or OPTIMAL_TWEEN_INFO, propertyTable); end end local setupCharacter = function() local characterData = xf.getModule("character_controller").getCharacter() local statusController = xf.getModule("status_controller") local camera = workspace.CurrentCamera local sprintStamina = player:WaitForChild("PlayerGui"):WaitForChild("Interface").SprintStamina local tweens = { PLAYER_SPRINT_STARTED = TweenService:Create(characterData._humanoid, TweenInfo.new( SPRINT_TWEEN_SPEED, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out ), { WalkSpeed = SPRINT_WALKSPEED }); PLAYER_SPRINT_ENDED = TweenService:Create(characterData._humanoid, TweenInfo.new( SPRINT_TWEEN_SPEED, Enum.EasingStyle.Sine, Enum.EasingDirection.Out ), { WalkSpeed = NORMAL_WALKSPEED }); PLAYER_SPRINT_CANCEL = TweenService:Create(characterData._humanoid, TweenInfo.new( SPRINT_TWEEN_SPEED, Enum.EasingStyle.Sine, Enum.EasingDirection.Out ), { WalkSpeed = 0 }); SPRINT_UI_LOW_STAMINA_F1 = TweenService:Create(sprintStamina.OutBar.BarContainer.Bar, TweenInfo.new( 0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out ), { BackgroundColor3 = Color3.fromRGB(255, 76, 76) }); SPRINT_UI_LOW_STAMINA_F2 = TweenService:Create(sprintStamina.OutBar.BarContainer.Bar, TweenInfo.new( 1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out ), { BackgroundColor3 = Color3.fromRGB(255, 56, 56) }); SPRINT_UI_NORMAL = TweenService:Create(sprintStamina.OutBar.BarContainer.Bar, TweenInfo.new( 1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out ), { BackgroundColor3 = Color3.fromRGB(255, 245, 96) }); SPRINT_UI_FADE_OUT = CreateTween({ [sprintStamina.OutBar] = { BackgroundTransparency = 1, Position = UDim2.fromScale(-0.5, 0.5) }; [sprintStamina.OutBar.BarContainer.Bar] = { BackgroundTransparency = 1, }; }); SPRINT_UI_FADE_IN = CreateTween({ [sprintStamina.OutBar] = { BackgroundTransparency = 0, Position = UDim2.fromScale(0.5, 0.5) }; [sprintStamina.OutBar.BarContainer.Bar] = { BackgroundTransparency = 0, }; }) } local cacheTickLastSprint = tick() local cacheTickRegenStart = tick() local cacheTickNextFadeOut = tick() characterData._stamina = 100 characterData._isLowStamina = false sprintStamina.OutBar.BarContainer.Bar.BackgroundColor3 = Color3.fromRGB(255, 245, 96) characterData.exhausted = function() statusController.newStatus("Tired", Color3.fromRGB(135, 135, 135), Color3.fromRGB(22, 22, 22)) end characterData.sprint = function() characterData._isSprintDown = true if characterData._stamina <= 20 then return characterData.exhausted(); end if not characterData._canSprint then return; end characterData.showStaminaBar() tweens.PLAYER_SPRINT_STARTED:Play() characterData._isSprinting = true end characterData.setCanSprint = function(state) if state then characterData._canSprint = true characterData._humanoid.WalkSpeed = NORMAL_WALKSPEED else characterData._canSprint = false tweens.PLAYER_SPRINT_STARTED:Cancel() tweens.PLAYER_SPRINT_ENDED:Cancel() tweens.PLAYER_SPRINT_CANCEL:Play() characterData._isSprinting = false end end characterData.stopSprint = function(notKey) if notKey then characterData._isSprintDown = false end tweens.PLAYER_SPRINT_STARTED:Cancel() tweens.PLAYER_SPRINT_ENDED:Play() characterData._isSprinting = false end characterData.lowStamina = function() -- yes, very cool // ArkhieDev local combo = 1 local function playCombo(val) if not characterData._isLowStamina then return; end if combo == 1 then tweens.SPRINT_UI_LOW_STAMINA_F1:Play() combo = 2 else tweens.SPRINT_UI_LOW_STAMINA_F2:Play() combo = 1 end wait(1) playCombo() end tweens.SPRINT_UI_LOW_STAMINA_F1:Play() tweens.SPRINT_UI_NORMAL:Cancel() characterData._isLowStamina = true --playCombo() end characterData.hideStaminaBar = function() characterData._isStaminaBarShowing = false tweens.SPRINT_UI_FADE_OUT:Play() end characterData.showStaminaBar = function() characterData._isStaminaBarShowing = true tweens.SPRINT_UI_FADE_IN:Play() end characterData.normalStamina = function() characterData._isLowStamina = false tweens.SPRINT_UI_LOW_STAMINA_F1:Cancel() tweens.SPRINT_UI_LOW_STAMINA_F2:Cancel() tweens.SPRINT_UI_NORMAL:Play() end characterData._isSprinting = false characterData._humanoid.WalkSpeed = NORMAL_WALKSPEED for _, tween in pairs(tweens) do characterData._maid:Add(tween) end characterData.hideStaminaBar() characterData._maid:Add(characterData._humanoid.Running:Connect(function(speed) if speed <= 18 then characterData._runAnim:Stop() else local normal = 8 if not characterData._runAnim.IsPlaying then characterData._runAnim:Play() end characterData._runAnim:AdjustSpeed(math.max((speed - normal)/NORMAL_WALKSPEED, 0)) end end)) characterData._maid:Add(characterData._humanoid.Jumping:Connect(function(active) if active then characterData._runAnim:Stop() end end)) characterData._maid:Add(RunService.RenderStepped:Connect(function(delta) local camRightVec = camera.CFrame.RightVector * 3 local humRightVec = characterData._rootPart.CFrame.RightVector * 3 local tarPos = (characterData._rootPart.Position + Vector3.new(0, 1, 0)) + camRightVec local screenPointOfChar = camera:WorldToScreenPoint(tarPos) local jitterCheck = math.abs(screenPointOfChar.Y - sprintStamina.Position.Y.Offset) <= .01 and true sprintStamina.Position = UDim2.fromOffset(screenPointOfChar.X, jitterCheck and sprintStamina.Position.Y.Offset or screenPointOfChar.Y) if characterData._isSprinting then if characterData._stamina > 0 then if xf.getMagnitude(characterData._rootPart.Velocity - Vector3.new(0, characterData._rootPart.Velocity.Y, 0)) > 5 then characterData._stamina -= STAMINA_LOST_PER_SEC * delta cacheTickLastSprint = tick() else if tick() - cacheTickLastSprint > STAMINA_INT_REGEN and characterData._stamina < characterData._staminaMax then characterData._stamina += STAMINA_REGEN_PER_SEC * delta end end cacheTickNextFadeOut = tick() + STAMINA_UI_FADE_INT else task.spawn(characterData.exhausted) characterData.stopSprint(true) end else if tick() - cacheTickLastSprint > STAMINA_INT_REGEN and characterData._stamina < characterData._staminaMax then characterData._stamina += STAMINA_REGEN_PER_SEC * delta cacheTickNextFadeOut = tick() + STAMINA_UI_FADE_INT end end local p = characterData._stamina / characterData._staminaMax if p < 0.3 then if not characterData._isLowStamina then characterData.lowStamina() end else if characterData._isLowStamina then characterData.normalStamina() end end if tick() > cacheTickNextFadeOut then if characterData._isStaminaBarShowing then characterData.hideStaminaBar() end end tweenSprintBar(sprintStamina, p) end)) end sprint_controller.init = function(new) sprint_controller = new UserInputService.InputBegan:Connect(function(input, processed) if processed then return; end if input.KeyCode == Enum.KeyCode.LeftShift then local charcterData = xf.getModule("character_controller").getCharacter() if charcterData and charcterData.sprint then charcterData.sprint() end end end) UserInputService.InputEnded:Connect(function(input, processed) if processed then return; end if input.KeyCode == Enum.KeyCode.LeftShift then local charcterData = xf.getModule("character_controller").getCharacter() if charcterData and charcterData.stopSprint then charcterData.stopSprint() end end end) network.getSignal("characterAddedSignal"):Connect(setupCharacter) end return sprint_controller;
nilq/small-lua-stack
null
local function time(f, times) collectgarbage() local gettime = os.clock local ok, socket = pcall(require, 'socket') if ok then gettime = socket.gettime end local start = gettime() for _=0,times do f() end local stop = gettime() return stop - start end local function readfile(file) local f = io.open(file) if not f then return nil end local d = f:read('*a') f:close() return d end local function profile(jsonfile, times) times = times or 10000 print(jsonfile..': (x'..times..')') print('', 'module', ' decoding', ' encoding') local d = readfile(jsonfile) local rapidjson = require('rapidjson') local cjson = require('cjson') local dkjson = require('dkjson') local modules = { {'dkjson', dkjson.decode, dkjson.encode}, {'cjson', cjson.decode, cjson.encode}, {'rapidjson', rapidjson.decode, rapidjson.encode}, } for _, m in ipairs(modules) do local name, dec, enc = m[1], m[2], m[3] local td = time(function() dec(d) end, times) local t = dec(d) local te = time(function() enc(t) end, times) print(string.format('\t%6s\t% 13.10f\t% 13.10f', name, td, te)) end end local function main() profile('performance/nulls.json') profile('performance/booleans.json') profile('performance/guids.json') profile('performance/paragraphs.json') profile('performance/floats.json') profile('performance/integers.json') profile('performance/mixed.json') end local r, m = pcall(main) if not r then print(m) end return 0
nilq/small-lua-stack
null
return { source = "sounds/footsteps/grassright.wav", volume = 0.25 }
nilq/small-lua-stack
null
local lastX = nil local lastY = nil local canvas = nil local lineWidth = 1 local HEIGHT = 600 local WIDTH = 800 local TOP = 0 local LEFT = 0 local color = {0.0, 0.0, 0.0, 1.0} local cui = castle.ui local log = require("https://raw.githubusercontent.com/ccheever/castle-utils/c5a150bf783bfcaf24bbcf8cbe0824fae34a8198/log.lua") local cursorWidth local cursorHeight function love.load() -- love.mouse.setVisible(true) love.mouse.setVisible(false) -- make default mouse invisible img = love.graphics.newImage("cross-black.png") -- load in a custom mouse image cursorWidth = img:getWidth() cursorHeight = img:getHeight() canvas = love.graphics.newCanvas(WIDTH, HEIGHT) lastX, lastY = love.mouse.getPosition() end function love.draw() love.graphics.setColor(1.0, 1.0, 1.0, 1.0) love.graphics.rectangle("fill", LEFT, TOP, WIDTH, HEIGHT, 0, 0) -- love.graphics.print("Hello World", 400, 300) local x, y = love.mouse.getPosition() -- get the position of the mouse -- print("x,y = ",x,y) love.graphics.draw(img, x - ((cursorWidth - 1) / 2), y - ((cursorHeight - 1) / 2)) -- draw the custom mouse image love.graphics.draw(canvas, LEFT, TOP) end function love.update() local x, y = love.mouse.getPosition() if love.mouse.isDown(1) then love.graphics.setCanvas(canvas) love.graphics.setColor(color[1], color[2], color[3], color[4]) love.graphics.setLineWidth(lineWidth) love.graphics.line(lastX, lastY, x, y) love.graphics.setCanvas() end lastX, lastY = x, y end function clearScreen() love.graphics.setCanvas(canvas) love.graphics.setColor(1.0, 1.0, 1.0, 1.0) love.graphics.rectangle("fill", 0, 0, WIDTH, HEIGHT) love.graphics.setCanvas() end function love.keypressed(key, scancode, isrepeat) if key == "space" then clearScreen() end end function castle.uiupdate() if cui.button("red") then color = {1.0, 0.0, 0.0, 1.0} end if cui.button("green") then color = {0.0, 1.0, 0.0, 1.0} end if cui.button("blue") then color = {0.0, 0.0, 1.0, 1.0} end if cui.button("gold") then color = {1.0, 0.8, 0.0, 1.0} end if cui.button("light gray") then color = {0.8, 0.8, 0.8, 1.0} end if cui.button("dark gray") then color = {0.3, 0.3, 0.3, 1.0} end if cui.button("purple") then color = {0.7, 0.0, 0.7, 1.0} end if cui.button("black") then color = {0.0, 0.0, 0.0, 1.0} end if cui.button("white") then color = {1.0, 1.0, 1.0, 1.0} end cui.text("stroke width") lineWidth = cui.rangeInput("stroke width", lineWidth, 0.1, 10, 0.1) if cui.button("erase everything") then clearScreen() end end
nilq/small-lua-stack
null
local cache = require "luv.cache.backend" local TestCase = require "luv.dev.unittest".TestCase module(...) local Memcached = TestCase:extend{ __tag = .....".Memcached"; setUp = function (self) self.memcached = cache.Memcached() self.memcached:clear() end; tearDown = function (self) self.memcached:clear() end; testGetSet = function (self) local m = self.memcached m:set("testKey", 5) self.assertEquals(m:get "testKey", 5) m:set("testKey", "hello") self.assertEquals(m:get "testKey", "hello") m:set("testKey", false) self.assertEquals(m:get "testKey", false) m:set("testKey", nil) self.assertNil(m:get "testKey") m:set("testKey", {a={10;false};["abc"]={"ef";["da"]=144}}) self.assertEquals(m:get "testKey".a[1], 10) self.assertEquals(m:get "testKey".a[2], false) self.assertNil(m:get "testKey".a[3]) self.assertEquals(m:get "testKey".abc[1], "ef") self.assertEquals(m:get "testKey".abc.da, 144) local str = [[multiple lines string]] m:set("testKey", str) self.assertEquals(m:get "testKey", str) end; testNamespaceWrapper = function (self) local one, two = cache.NamespaceWrapper(self.memcached, "One"), cache.NamespaceWrapper(self.memcached, "Two") one:set("key", 55) two:set("key", 66) self.assertEquals(one:get "key", 55) self.assertEquals(two:get "key", 66) end; testTagEmuWrapper = function (self) local m = cache.TagEmuWrapper(self.memcached) m:set("key", "value", {"tag1";"tag2"}) self.assertEquals(m:get "key", "value") m:clearTags {"tag1"} self.assertNil(m:get "key") end; testMultipleKeys = function (self) local m = cache.NamespaceWrapper(cache.TagEmuWrapper(self.memcached), "testNamespace") m:set("key1", "value1", {"tag1";"tag2"}) m:set("key2", "value2", {"tag1"}) m:set("key3", "value3") self.assertEquals(m:get("key1", "key2", "key3").key1, "value1") self.assertEquals(m:get("key1", "key2", "key3").key2, "value2") self.assertEquals(m:get("key1", "key2", "key3").key3, "value3") m:clearTags{"tag1"} self.assertNil(m:get "key1") self.assertNil(m:get "key2") self.assertEquals(m:get ("key1", "key2", "key3").key3, "value3") end; } return {Memcached=Memcached}
nilq/small-lua-stack
null
-- Generated by CSharp.lua Compiler local System = System System.namespace("Slipe.Shared.Exports", function (namespace) namespace.class("ExportAttribute", function (namespace) local __ctor__ __ctor__ = function (this, name, isHttp) System.base(this).__ctor__(this) this.Name = name this.IsHttp = isHttp end return { __inherits__ = function (out) return { System.Attribute } end, IsHttp = false, __ctor__ = __ctor__, __metadata__ = function (out) return { properties = { { "IsHttp", 0x6, System.Boolean }, { "Name", 0x6, System.String } }, methods = { { ".ctor", 0x206, nil, System.String, System.Boolean } }, class = { 0x6 } } end } end) end)
nilq/small-lua-stack
null
local Class = require 'lib.hump.class' local MapBuilder = getClass 'wyx.map.MapBuilder' -- MapDirector local MapDirector = Class{name='MapDirector'} -- generate a standard roguelike map with rooms connected via hallways. function MapDirector:generateStandard(builder) assert(isClass(MapBuilder, builder)) builder:createMap() builder:addFeatures() builder:addPortals() builder:postProcess() builder:verifyMap() return builder:getMap() end -- the class return MapDirector
nilq/small-lua-stack
null
local mexico = require "mexico" -- -- Mexico wrapper for a corona rounded rectangle. -- local RoundedRect = mexico.class(mexico.DisplayObject) -- -- Magic new function, since corona creates the object -- and not we. -- RoundedRect.new = function(styles) local l = styles.left or 0 local t = styles.top or 0 local w = styles.width or display.contentWidth local h = styles.height or display.contentHeight local r = styles.cornerRadius or h / 2 return display.newRoundedRect(l, t, w, h, r) end -- -- Constructor -- function RoundedRect:init(styles) local styles = table.mexico.clone(styles) styles["left"] = nil styles["top"] = nil styles["width"] = nil styles["height"] = nil styles["cornerRadius"] = nil mexico.DisplayObject.init(self, styles) end return RoundedRect
nilq/small-lua-stack
null
-- Matter recipes for Krastorio2 if mods["Krastorio2"] then local util = require("__bzlead__.data-util"); local matter = require("__Krastorio2__/lib/public/data-stages/matter-util") data:extend( { { type = "technology", name = "lead-matter-processing", icons = { { icon = util.k2assets().."/technologies/matter-stone.png", icon_size = 256, }, { icon = "__bzlead__/graphics/icons/lead-ore.png", icon_size = 64, icon_mipmaps = 3, scale = 1.25, } }, prerequisites = {"kr-matter-processing"}, unit = { count = 350, ingredients = { {"production-science-pack", 1}, {"utility-science-pack", 1}, {"matter-tech-card", 1} }, time = 45 } }, }) local lead_ore_matter = { item_name = "lead-ore", minimum_conversion_quantity = 10, matter_value = 5, energy_required = 1, need_stabilizer = false, unlocked_by_technology = "lead-matter-processing" } matter.createMatterRecipe(lead_ore_matter) local lead_plate_matter = { item_name = "lead-plate", minimum_conversion_quantity = 10, matter_value = 7.5, energy_required = 2, only_deconversion = true, need_stabilizer = true, unlocked_by_technology = "lead-matter-processing" } matter.createMatterRecipe(lead_plate_matter) end
nilq/small-lua-stack
null
-- Color reference local Color = { white = {1, 1, 1}, teal = { 2 / 255, 132 / 255, 130 / 255 }, red = { 204 / 255, 0, 0 }, yellow = { 2, 204 / 255, 0}, blue = { 51 / 255, 102 / 255, 153 / 255 }, gray = { 102 / 255, 102 / 255, 102 / 255 }, lightGray = { 153 / 255, 153 / 255, 153 / 255 }, green = { 128 / 255, 1, 0}, black = {0, 0, 0} } return Color
nilq/small-lua-stack
null
-- Older versions of ACF will conflict due to the new file loading system we implemented. -- If the server has an older version installed simultaneously, we'll let the players know. if ACF.Version then net.Receive("ACF_VersionConflict", function() hook.Add("CreateMove", "ACF Version Conflict", function(Move) if Move:GetButtons() ~= 0 then ACF.PrintToChat("Warning", "An older version of ACF was detected. Please contact the server owner as it will conflict with ACF-3") hook.Remove("CreateMove", "ACF Version Conflict") end end) end) end
nilq/small-lua-stack
null
local ffi = require 'ffi' local senna = require 'senna.env' local C = senna.C local SRL = {} local mt = {__index=SRL} function SRL.new(hashtype, verbtype) hashtype = hashtype or 'IOBES' verbtype = verbtype or 'VBS' local self = {verbtype=verbtype} self.hash = senna.Hash(senna.path, "hash/srl.lst") if hashtype == 'IOBES' then elseif hashtype == 'IOB' then self.hash:IOBES2IOB() elseif hashtype == 'BRK' then self.hash:IOBES2BRK() else error('hashtype must be IOBES, IOB or BRK') end if verbtype == 'VBS' then self.cvbs = C.SENNA_VBS_new(senna.path, "data/vbs.dat") ffi.gc(self.cvbs, C.SENNA_VBS_free) elseif verbtype ~= 'POS' and verbtype ~= 'USR' then error('verbtype must be VBS, POS or USR') end self.cpt0 = C.SENNA_PT0_new(senna.path, "data/pt0.dat") ffi.gc(self.cpt0, C.SENNA_PT0_free) self.csrl = C.SENNA_SRL_new(senna.path, "data/srl.dat") ffi.gc(self.csrl, C.SENNA_SRL_free) setmetatable(self, mt) return self end function SRL:forward(tokens, pos_labels, usr_vbs_labels) assert(pos_labels, 'POS tags expected') local vbs_labels if self.verbtype == 'VBS' then -- find verbs ourself vbs_labels = C.SENNA_VBS_forward(self.cvbs, tokens.c.word_idx, tokens.c.caps_idx, pos_labels.__raw, tokens.c.n) -- overwrite, who cares? you? you want to complain? for i=0,tokens.c.n-1 do vbs_labels[i] = vbs_labels[i] ~= 22 and 1 or 0 end elseif self.verbtype == 'POS' then -- POS verbs -- it is GC'ed vbs_labels = ffi.new('int[?]', tokens.c.n) for i=0,tokens.c.n-1 do print('dude', pos_labels[i+1], pos_labels[i+1]:match('^V') and 1 or 0) vbs_labels[i] = pos_labels[i+1]:match('^V') and 1 or 0 end else -- the user is maniac -- it is GC'ed assert(type(usr_vbs_labels) == 'table' and #usr_vbs_labels == tokens.c.n, 'provide user verbs with a boolean table (size: number of tokens)') vbs_labels = ffi.new('int[?]', tokens.c.n) for i=0,tokens.c.n-1 do vbs_labels[i] = usr_vbs_labels[i+1] and 1 or 0 end end local n_verbs = 0 for i=0,tokens.c.n-1 do n_verbs = n_verbs + vbs_labels[i] end local pt0_labels = C.SENNA_PT0_forward(self.cpt0, tokens.c.word_idx, tokens.c.caps_idx, pos_labels.__raw, tokens.c.n) local srl_labels = C.SENNA_SRL_forward(self.csrl, tokens.c.word_idx, tokens.c.caps_idx, pt0_labels, vbs_labels, tokens.c.n) local tags = {__raw=srl_labels, verb={}} for j=0,tokens.c.n-1 do table.insert(tags.verb, vbs_labels[j] == 1) end for i=0,n_verbs-1 do local level_tags = {} for j=0,tokens.c.n-1 do table.insert(level_tags, self.hash:key(srl_labels[i][j])) end table.insert(tags, level_tags) end return tags end senna.SRL = {} setmetatable(senna.SRL, {__call= function(self, ...) return SRL.new(...) end, __index=SRL, __newindex=SRL}) return SRL
nilq/small-lua-stack
null
function setDestination ( player, x, y, z, locationDesc, blip, settings ) if player and x and y and z and locationDesc then triggerClientEvent ( player, "gps_setDestination", player, x, y, z, locationDesc, blip, settings ) end end function setDestinationToPlayer(gpsClient,targetPlayer,desc,blip,settings) triggerClientEvent(gpsClient,"GPSrecDestToPlayer",gpsClient,targetPlayer,desc,blip,settings) end function setDestinationCmd ( cmd, pSource, x, y, z, desc ) if pSource and x and y and z and desc then setDestination ( pSource, x, y, z, desc ) end end addCommandHandler ( "addgps", setDestinationCmd ) function resetDestination ( player ) if player then triggerClientEvent ( player, "gps_resetDestination", player ) end end function getDestination ( player ) if player then triggerClientEvent ( player, "gps_getDestination", player ) end end addEvent ( 'GPS_showMap', true ) function forceMap() outputChatBox ( "forceMap" ) if isPlayerMapForced(source) then forcePlayerMap(source, false) else forcePlayerMap(source, true) end end addEventHandler ( 'GPS_showMap', root, forceMap )
nilq/small-lua-stack
null
require 'tests.e2.undead' require 'tests.e2.shiplanding' require 'tests.e2.e2features' require 'tests.e2.movement' require 'tests.e2.destroy' require 'tests.e2.guard' require 'tests.e2.spells' require 'tests.e2.stealth' require 'tests.orders' require 'tests.common' require 'tests.storage' require 'tests.magicbag' require 'tests.process' require 'tests.xmas'
nilq/small-lua-stack
null
object_mobile_outbreak_undead_scientist_m_hum_08 = object_mobile_shared_outbreak_undead_scientist_m_hum_08:new { } ObjectTemplates:addTemplate(object_mobile_outbreak_undead_scientist_m_hum_08, "object/mobile/outbreak_undead_scientist_m_hum_08.iff")
nilq/small-lua-stack
null
-- Jettison replacement: Eject ejectable drives on sleep local logger = hs.logger.new("Jettison") logger.i("Loading Jettison sleep watcher") M = {} log = require('utilities.log').new(logger) M._jettison_causing_sleep = false function M.isAnExternalDrivePresent() local output, status, return_type, return_code = hs.execute("diskutil list | grep external") return status == true end function M.isAnExternalDriveMounted() local output, status, return_type, return_code = hs.execute("for i in $(diskutil list | grep 'external, virtual' | \z cut -d' ' -f1); do diskutil info $i | \z grep -q 'Mounted.*Yes' && echo $i; done") return output ~= "" end function M.ejectExternalDrivesAndSleep() if M._jettison_causing_sleep == true then log.and_alert("Asked to sleep while Jettison still trying to cause sleep… aborting.") return nil end log.and_alert("Ejecting drives before sleep…") local output, status, return_type, return_code = hs.execute("~/code/utilities/Scripts/eject-external-drives") if status then log.and_alert("… drives ejected.") M._jettison_causing_sleep = true hs.caffeinate.systemSleep() M._jettison_causing_sleep = false else log.warning_and_alert("… but the drives didn't eject: ".. tostring(output) .. " - return code: " .. tostring(return_code)) end end function M.mountExternalDrives() if M.isAnExternalDrivePresent() then local output, status, return_type, return_code = hs.execute("~/code/utilities/Scripts/mount-external-drives") if status then log.and_alert("Drives remounted after sleep.") else log.warning_and_alert("Drives failed to remount after sleep: ".. tostring(output) .." - return code: " .. tostring(return_code)) end end end function M.sleepWatcherCallback(event) if (event == hs.caffeinate.watcher.systemWillSleep) and (not M._jettison_causing_sleep) then if M.isAnExternalDriveMounted() then hs.caffeinate.declareUserActivity() -- prevent sleep to give us time to eject drives M.ejectExternalDrivesAndSleep() end elseif event == hs.caffeinate.watcher.systemDidWake then M.mountExternalDrives() -- else do nothing end end M.sleepWatcher = hs.caffeinate.watcher.new(M.sleepWatcherCallback) function M:start() logger.i("Starting Jettison sleep watcher") self.sleepWatcher:start() end return M
nilq/small-lua-stack
null
print ("==================================== BLOCKCHAIN DEMO ====================================") MINERS = 100 nonce = {0} function inc_nonce(n) for i = 1, #n do if n[i] < 255 then n[i] = n[i] + 1 break else n[i] = 0 if i == #n then table.insert(n, 1) return end end end end function nonce_str(n) s = {} for i = 1, #n do table.insert(s, string.char(n[i])) end return table.concat(s) end t = os.clock() for i = 1, ITERATIONS do inc_nonce(nonce) end print(hex(nonce_str(nonce))) t = os.clock() - t print(string.format("nonce inc [%.3f M/s]", ITERATIONS / t / 1000000)) function miner_update() inc_nonce(nonce) for m = 1, MINERS do end end print ("=========================================================================================")
nilq/small-lua-stack
null
local sprFilter = { ["materials/play_assist/pa_ammo_shelfover.vmt"] = true, } local mdlFilter = { "oildrum", "props_battle" } local nameFilter = { ["point_ammo_smg1"] = true, ["point_ammo_smg2"] = true, ["point_ammo_smg3"] = true, ["point_ammo_ar1"] = true, ["point_ammo_ar2"] = true, ["point_ammo_smg1_1"] = true, ["point_ammo_smg2_1"] = true, ["point_ammo_smg3_1"] = true, ["point_ammo_ar1_1"] = true, ["point_ammo_ar2_1"] = true, ["point_ammo_smg1_2"] = true, ["point_ammo_smg2_2"] = true, ["point_ammo_smg3_2"] = true, ["point_ammo_ar1_2"] = true, ["point_ammo_ar2_2"] = true, ["brush01"] = true, ["brush02"] = true, ["brush03"] = true, ["brush04"] = true, ["hmbrush01"] = true, ["hmbrush02"] = true, ["teleport_assist"] = true, } function PLUGIN:InitPostEntity() for k, v in ipairs(ents.GetAll()) do if (v and v.IsValid and v:IsValid()) then local class = v:GetClass():lower() if (class == "env_sprite") then local spr = v:GetModel():lower() if (sprFilter[spr]) then v:Remove() end end if (class:find("item_")) then v:Remove() end local mdl = v:GetModel() if (mdl and mdl != "") then mdl = mdl:lower() for _, key in ipairs(mdlFilter) do if (mdl:find(key)) then v:Remove() end end end local name = v:GetName() if (name and name != "") then print(name) if (nameFilter[name]) then v:Remove() end end end end end for k, v in ipairs(ents.GetAll()) do if (v and v.IsValid and v:IsValid()) then local class = v:GetClass():lower() if (class == "env_sprite") then local spr = v:GetModel():lower() if (sprFilter[spr]) then v:Remove() end end if (class:find("item_")) then v:Remove() end local mdl = v:GetModel() if (mdl and mdl != "") then mdl = mdl:lower() for _, key in ipairs(mdlFilter) do if (mdl:find(key)) then v:Remove() end end end local name = v:GetName() if (name and name != "") then if (nameFilter[name]) then v:Remove() end end end end
nilq/small-lua-stack
null
object_mobile_outbreak_undead_civilian_21 = object_mobile_shared_outbreak_undead_civilian_21:new { } ObjectTemplates:addTemplate(object_mobile_outbreak_undead_civilian_21, "object/mobile/outbreak_undead_civilian_21.iff")
nilq/small-lua-stack
null
local PANEL = class.create("ColorPicker", "Panel") function PANEL:ColorPicker() self:super() -- Initialize our baseclass self.m_txtColorValue = self:Add("TextEntry") self.m_txtColorValue:Dock(DOCK_TOP) self.m_txtColorValue:SetHoveredInput(true) self.m_txtColorValue.OnTextChanged = function(this, text, add) if text:match("(#%x%x%x%x%x%x)") then self:SetColor(color(text)) end end self.m_pColorShade = self:Add("ColorShade") self.m_pColorShade:Dock(DOCK_FILL) self.m_pColorShade.OnColorChanged = function(this, col) -- col will be our final color self.m_txtColorValue:SetText(string.format("#%06X", col:hex())) self.m_txtColorValue:SelectAll() end self.m_pColorHue = self:Add("ColorHue") self.m_pColorHue:Dock(DOCK_RIGHT) self.m_pColorHue.OnHueChanged = function(this, hue) -- Set the hue of our shade picker self.m_pColorShade:SetHue(hue) end self:SetColor(color(0, 255, 255)) end function PANEL:SetColor(c) local hue, saturation, value = ColorToHSV(c) if saturation > 0 then -- Only update hue if we aren't achromatic self.m_pColorHue:SetHue(hue) end self.m_pColorShade:SetColor(c) end function PANEL:GetColor() return self.m_pColorShade:GetColor() end
nilq/small-lua-stack
null
EA_Config = { ["SCD_NocombatStillKeep"] = true, ["ShowTimer"] = true, ["DoAlertSound"] = true, ["ChangeTimer"] = true, ["SpecPowerCheck"] = { ["DarkForce"] = false, ["Mana"] = false, ["BurningEmbers"] = false, ["LifeBloom"] = false, ["Focus"] = false, ["RunicPower"] = false, ["Runes"] = false, ["LunarPower"] = false, ["LightForce"] = false, ["Fury"] = false, ["SoulShards"] = false, ["ComboPoint"] = false, ["DemonicFury"] = false, ["ArcaneCharges"] = false, ["HolyPower"] = false, ["Rage"] = false, ["Insanity"] = false, ["Maelstrom"] = false, ["Energy"] = false, ["Pain"] = false, }, ["ICON_APPEND_SPELL_TIP"] = true, ["ShareSettings"] = true, ["ShowFlash"] = false, ["TimerFontSize"] = 18, ["IconSize"] = 45, ["ShowAuraValueWhenOver"] = 1000, ["AllowESC"] = false, ["OPTION_ICON"] = true, ["AlertSound"] = "Sound\\Spells\\ShaysBell.ogg", ["ShowFrame"] = true, ["SNameFontSize"] = 13.5, ["NewLineByIconCount"] = 0, ["HUNTER_GlowPetFocus"] = 50, ["Target_MyDebuff"] = true, ["AllowAltAlerts"] = false, ["AlertSoundValue"] = 1, ["StackFontSize"] = 13.5, ["ShowName"] = true, ["Version"] = "8.0.1.20180903", ["EA_SPELL_ITEM"] = { [304699] = 170186, [278712] = 163073, [204192] = 133882, [303378] = 170159, [303993] = 170153, [202594] = 133999, [303112] = 169610, [304545] = 169694, [304372] = 170204, [303992] = 170152, [304673] = 170194, [304672] = 170193, [304373] = 170198, [302499] = 169590, [299554] = 168944, [290183] = 166782, [55884] = 166776, [303634] = 169949, [303541] = 170161, [307281] = 168215, [304675] = 170200, [298280] = 168538, [304000] = 170158, [303856] = 170079, [303998] = 170157, [274914] = 169952, [304660] = 170172, [303857] = 170081, [304692] = 170179, [302933] = 169687, [291514] = 167059, [298869] = 168824, [304504] = 170199, [303591] = 170101, [304662] = 170192, [295858] = 168161, [304505] = 170196, [274911] = 167739, [304663] = 170174, [302348] = 169774, [304502] = 170177, [304701] = 170180, [304668] = 170181, [208883] = 136605, [304696] = 170178, [274913] = 169119, [304665] = 170182, [293404] = 167893, [300539] = 167077, [303579] = 170162, [308599] = 169491, [295610] = 168099, [307596] = 168496, [304370] = 170187, [304037] = 170170, [304620] = 170476, [308844] = 172204, }, ["LockFrame"] = false, ["UseFloatSec"] = 1, ["SCD_RemoveWhenCooldown"] = true, ["SCD_GlowWhenUsable"] = true, } EA_Position = { ["Execution"] = 0, ["GreenDebuff"] = 0.5, ["xOffset"] = -40, ["TarAnchor"] = "TOP", ["yOffset"] = 0, ["PlayerLv2BOSS"] = true, ["relativePoint"] = "BOTTOM", ["Anchor"] = "BOTTOM", ["yLoc"] = 194.0670318603516, ["SCD_UseCooldown"] = false, ["Tar_yOffset"] = -163.6135559082031, ["RedDebuff"] = 0.5, ["Tar_xOffset"] = -52.59965515136719, ["xLoc"] = 321.6692810058594, ["TarrelativePoint"] = "TOP", ["Tar_NewLine"] = true, ["ScdAnchor"] = "BOTTOM", ["Scd_xOffset"] = -311.5534362792969, ["Scd_yOffset"] = 214.0284118652344, } EA_Items = { ["DEATHKNIGHT"] = { [207127] = { ["enable"] = true, ["self"] = true, }, [57330] = { ["enable"] = true, ["self"] = true, }, [81256] = { ["enable"] = true, ["self"] = true, }, [212552] = { ["enable"] = true, ["self"] = true, }, [48707] = { ["enable"] = true, ["self"] = true, }, [55233] = { ["enable"] = true, ["self"] = true, }, [81141] = { ["enable"] = true, ["self"] = true, }, [51124] = { ["enable"] = true, ["self"] = true, }, [59052] = { ["enable"] = true, ["self"] = true, }, [48792] = { ["enable"] = true, ["self"] = true, }, [194879] = { ["enable"] = true, ["self"] = true, }, [196770] = { ["enable"] = true, ["self"] = true, }, }, ["WARRIOR"] = { [207982] = { ["enable"] = true, ["overgrow"] = 3, ["self"] = true, }, [202164] = { ["enable"] = true, ["self"] = true, }, [85739] = { ["enable"] = true, ["self"] = true, }, [188923] = { ["enable"] = true, ["overgrow"] = 2, ["self"] = true, }, [871] = { ["enable"] = true, ["self"] = true, }, [118038] = { ["enable"] = true, ["self"] = true, }, [206333] = { ["enable"] = true, ["overgrow"] = 6, ["self"] = true, }, [215572] = { ["enable"] = true, ["self"] = true, }, [46924] = { ["enable"] = true, ["self"] = true, }, [184364] = { ["enable"] = true, ["self"] = true, }, [107574] = { ["enable"] = true, ["self"] = true, }, [202539] = { ["enable"] = true, ["overgrow"] = 3, ["self"] = true, }, [184362] = { ["enable"] = true, ["self"] = true, }, [23920] = { ["enable"] = true, ["self"] = true, }, }, ["MAGE"] = { [12042] = { ["enable"] = true, }, [44544] = { ["enable"] = true, }, [12051] = { ["enable"] = true, }, [36032] = { ["enable"] = true, }, [48108] = { ["enable"] = true, }, [87023] = { ["enable"] = true, }, }, ["OTHER"] = { [47788] = { ["enable"] = true, ["name"] = "守護聖靈", ["self"] = false, }, [64901] = { ["enable"] = true, ["name"] = "希望象徵", }, [228600] = { ["enable"] = true, ["self"] = false, }, [29166] = { ["enable"] = true, }, [5211] = { ["enable"] = true, ["self"] = false, }, [102342] = { ["enable"] = true, ["name"] = "鐵樹皮術", }, [1022] = { ["enable"] = true, ["name"] = "保護祝福", ["self"] = false, }, [127797] = { ["enable"] = true, ["self"] = false, }, [53563] = { ["enable"] = true, ["name"] = "聖光信標", }, [33786] = { ["enable"] = true, ["self"] = false, }, [28271] = { ["enable"] = true, ["self"] = false, }, [2825] = { ["enable"] = true, ["name"] = "嗜血", }, [10060] = { ["enable"] = true, }, [6940] = { ["enable"] = true, ["name"] = "犧牲祝福", ["self"] = false, }, [81782] = { ["enable"] = true, }, [163505] = { ["enable"] = true, ["self"] = false, }, [33206] = { ["enable"] = true, }, [48707] = { ["enable"] = true, ["self"] = false, }, [32182] = { ["enable"] = true, }, [82691] = { ["enable"] = true, ["self"] = false, }, [98007] = { ["enable"] = true, }, [45438] = { ["enable"] = true, ["self"] = false, }, [146555] = { ["enable"] = true, ["name"] = "憤怒之鼓", ["self"] = false, }, [80353] = { ["enable"] = true, }, [90355] = { ["enable"] = true, }, [186265] = { ["enable"] = true, ["self"] = false, }, [159234] = { ["enable"] = true, ["self"] = true, }, [1850] = { ["enable"] = true, ["name"] = "突進", ["self"] = false, }, [64844] = { ["enable"] = true, ["name"] = "神聖禮頌", }, }, ["WARLOCK"] = { }, ["DEMONHUNTER"] = { [163073] = { ["enable"] = true, ["self"] = true, }, [188501] = { ["enable"] = true, }, }, ["DRUID"] = { [106951] = { ["enable"] = true, }, [145152] = { ["enable"] = true, }, [5215] = { ["enable"] = true, }, [774] = { ["enable"] = true, }, [164547] = { ["enable"] = true, }, [93622] = { ["enable"] = true, }, [194223] = { ["enable"] = true, }, [5217] = { ["enable"] = true, }, [137452] = { ["enable"] = true, }, [164545] = { ["enable"] = true, }, [192081] = { ["enable"] = true, }, [16870] = { ["enable"] = true, }, [69369] = { ["enable"] = true, }, [135700] = { ["enable"] = true, }, [102543] = { ["enable"] = true, }, [22812] = { ["enable"] = true, }, [1850] = { ["enable"] = true, }, [158792] = { ["enable"] = true, }, }, ["MONK"] = { [120954] = { ["enable"] = true, }, [119611] = { ["enable"] = true, }, [115175] = { ["enable"] = true, }, }, ["HUNTER"] = { [95712] = { ["enable"] = true, }, [34477] = { ["enable"] = true, }, [118455] = { ["enable"] = true, }, [193530] = { ["enable"] = true, }, [186257] = { ["enable"] = true, }, [70728] = { ["enable"] = true, }, [186265] = { ["enable"] = true, }, [61684] = { ["enable"] = true, }, [186254] = { ["enable"] = true, }, [185791] = { ["enable"] = true, }, [217200] = { ["enable"] = true, }, }, } EA_AltItems = { ["HUNTER"] = { }, ["WARRIOR"] = { }, ["WARLOCK"] = { }, ["DEMONHUNTER"] = { }, ["MAGE"] = { }, ["DRUID"] = { }, ["MONK"] = { }, ["DEATHKNIGHT"] = { }, } EA_TarItems = { ["HUNTER"] = { [5116] = { ["enable"] = true, ["self"] = true, }, [117405] = { ["enable"] = true, ["self"] = false, }, [131894] = { ["enable"] = true, ["self"] = false, }, [54680] = { ["enable"] = true, ["self"] = true, }, [132951] = { ["enable"] = true, ["self"] = false, }, }, ["WARRIOR"] = { [12975] = { ["enable"] = true, ["self"] = false, }, [118038] = { ["enable"] = true, ["self"] = false, }, [1715] = { ["enable"] = true, ["self"] = true, }, [208086] = { ["enable"] = true, ["self"] = true, }, [871] = { ["enable"] = true, ["self"] = false, }, [215537] = { ["enable"] = true, ["self"] = true, }, [132169] = { ["enable"] = true, ["self"] = false, }, [113344] = { ["enable"] = true, ["self"] = true, }, [147833] = { ["enable"] = true, ["self"] = true, }, [5246] = { ["enable"] = true, ["self"] = false, }, [46924] = { ["enable"] = true, ["self"] = false, }, [23920] = { ["enable"] = true, ["self"] = false, }, [115804] = { ["enable"] = true, ["self"] = true, }, [132168] = { ["enable"] = true, ["self"] = false, }, [772] = { ["enable"] = true, ["self"] = true, }, [12323] = { ["enable"] = true, ["self"] = true, }, }, ["WARLOCK"] = { [1490] = { ["enable"] = true, ["self"] = true, }, [48181] = { ["enable"] = true, ["self"] = true, }, [603] = { ["enable"] = true, ["self"] = true, }, [980] = { ["enable"] = true, ["self"] = true, }, [172] = { ["enable"] = true, ["self"] = true, }, [686] = { ["enable"] = true, ["self"] = true, }, [30108] = { ["enable"] = true, ["self"] = true, }, [348] = { ["enable"] = true, ["self"] = true, }, [29722] = { ["enable"] = true, ["self"] = true, }, [80240] = { ["enable"] = true, ["self"] = true, }, }, ["DEMONHUNTER"] = { }, ["MAGE"] = { [31589] = { ["enable"] = true, ["self"] = true, }, [44457] = { ["enable"] = true, ["self"] = true, }, [12654] = { ["enable"] = true, ["self"] = true, }, }, ["DRUID"] = { [93402] = { ["enable"] = true, ["self"] = true, }, [155625] = { ["enable"] = true, ["self"] = true, }, [192090] = { ["enable"] = true, ["self"] = true, }, [202347] = { ["enable"] = true, ["self"] = true, }, [8921] = { ["enable"] = true, ["self"] = true, }, [774] = { ["enable"] = true, ["self"] = true, }, [164815] = { ["enable"] = true, ["self"] = true, }, [197637] = { ["enable"] = true, ["self"] = true, }, [164812] = { ["enable"] = true, ["self"] = true, }, [1079] = { ["enable"] = true, ["self"] = true, }, [33763] = { ["enable"] = true, ["self"] = true, }, [1822] = { ["enable"] = true, ["self"] = true, }, [155722] = { ["enable"] = true, ["self"] = true, }, }, ["MONK"] = { [115078] = { ["enable"] = true, ["self"] = true, }, [115175] = { ["enable"] = true, ["self"] = true, }, [119611] = { ["enable"] = true, ["self"] = true, }, }, ["DEATHKNIGHT"] = { [194310] = { ["enable"] = true, ["self"] = true, }, [55095] = { ["enable"] = true, ["self"] = true, }, [206940] = { ["enable"] = true, ["self"] = true, }, [55078] = { ["enable"] = true, ["self"] = true, }, [191587] = { ["enable"] = true, ["self"] = true, }, }, } EA_ScdItems = { ["HUNTER"] = { [16827] = { ["enable"] = true, }, [217200] = { ["enable"] = true, }, [54644] = { ["enable"] = true, }, [19574] = { ["enable"] = true, }, [54680] = { ["enable"] = true, }, [90361] = { ["enable"] = true, }, [109304] = { ["enable"] = true, }, [92380] = { ["enable"] = true, }, [55709] = { ["enable"] = true, }, [109248] = { ["enable"] = true, }, [160065] = { ["enable"] = true, }, [781] = { ["enable"] = true, }, [131894] = { ["enable"] = true, }, [193530] = { ["enable"] = true, }, [186257] = { ["enable"] = true, }, [17253] = { ["enable"] = true, }, [61684] = { ["enable"] = true, }, [147362] = { ["enable"] = true, }, }, ["WARRIOR"] = { [12294] = { ["enable"] = true, }, [34428] = { ["enable"] = true, }, [1719] = { ["enable"] = true, }, [1160] = { ["enable"] = true, }, [6544] = { ["enable"] = true, }, [228920] = { ["enable"] = true, }, [46924] = { ["enable"] = true, }, [107570] = { ["enable"] = true, }, [107574] = { ["enable"] = true, }, [2565] = { ["enable"] = true, }, [85288] = { ["enable"] = true, }, [207982] = { ["enable"] = true, }, [18499] = { ["enable"] = true, }, [198304] = { ["enable"] = true, }, [23920] = { ["enable"] = true, }, [23922] = { ["enable"] = true, }, [46968] = { ["enable"] = true, }, [100] = { ["enable"] = true, }, [167105] = { ["enable"] = true, }, [845] = { ["enable"] = true, }, [152277] = { ["enable"] = true, }, [118038] = { ["enable"] = true, }, [23881] = { ["enable"] = true, }, [184367] = { ["enable"] = true, }, [871] = { ["enable"] = true, }, [5308] = { ["enable"] = true, }, [163201] = { ["enable"] = true, }, [6572] = { ["enable"] = true, }, [12292] = { ["enable"] = true, }, [6552] = { ["enable"] = true, }, [202168] = { ["enable"] = true, }, [6343] = { ["enable"] = true, }, [12975] = { ["enable"] = true, }, }, ["WARLOCK"] = { [17962] = { ["enable"] = true, }, }, ["DEMONHUNTER"] = { [131347] = { ["enable"] = true, }, [202644] = { ["enable"] = true, }, [192611] = { ["enable"] = true, }, [178740] = { ["enable"] = true, }, [207684] = { ["enable"] = true, }, [203720] = { ["enable"] = true, }, [204021] = { ["enable"] = true, }, [204157] = { ["enable"] = true, }, [185245] = { ["enable"] = true, }, [187827] = { ["enable"] = true, }, [162794] = { ["enable"] = true, }, [204596] = { ["enable"] = true, }, [195072] = { ["enable"] = true, }, [189110] = { ["enable"] = true, }, [188501] = { ["enable"] = true, }, }, ["MAGE"] = { [12042] = { ["enable"] = true, }, [122] = { ["enable"] = true, }, [12051] = { ["enable"] = true, }, [1953] = { ["enable"] = true, }, [45438] = { ["enable"] = true, }, }, ["DRUID"] = { [6807] = { ["enable"] = true, }, [61336] = { ["enable"] = true, }, [22842] = { ["enable"] = true, }, [102280] = { ["enable"] = true, }, [80313] = { ["enable"] = true, }, [78674] = { ["enable"] = true, }, [5215] = { ["enable"] = true, }, [1850] = { ["enable"] = true, }, [102793] = { ["enable"] = true, }, [52610] = { ["enable"] = true, }, [194223] = { ["enable"] = true, }, [155835] = { ["enable"] = true, }, [77758] = { ["enable"] = true, }, [106951] = { ["enable"] = true, }, [204066] = { ["enable"] = true, }, [48438] = { ["enable"] = true, }, [202028] = { ["enable"] = true, }, [192081] = { ["enable"] = true, }, [22812] = { ["enable"] = true, }, [33917] = { ["enable"] = true, }, [102543] = { ["enable"] = true, }, [78675] = { ["enable"] = true, }, [18562] = { ["enable"] = true, }, [29166] = { ["enable"] = true, }, }, ["MONK"] = { [115203] = { ["enable"] = true, }, [115151] = { ["enable"] = true, }, [116705] = { ["enable"] = true, }, [122783] = { ["enable"] = true, }, [115008] = { ["enable"] = true, }, [119381] = { ["enable"] = true, }, [115078] = { ["enable"] = true, }, [115080] = { ["enable"] = true, }, [113656] = { ["enable"] = true, }, [109132] = { ["enable"] = true, }, [122278] = { ["enable"] = true, }, [101545] = { ["enable"] = true, }, [122470] = { ["enable"] = true, }, [116847] = { ["enable"] = true, }, [115098] = { ["enable"] = true, }, [123904] = { ["enable"] = true, }, [115288] = { ["enable"] = true, }, [115399] = { ["enable"] = true, }, }, ["DEATHKNIGHT"] = { [108199] = { ["enable"] = true, }, [47528] = { ["enable"] = true, }, [194844] = { ["enable"] = true, }, [48792] = { ["enable"] = true, }, [194679] = { ["enable"] = true, }, [45524] = { ["enable"] = true, }, [49184] = { ["enable"] = true, }, [219809] = { ["enable"] = true, }, [51271] = { ["enable"] = true, }, [49576] = { ["enable"] = true, }, [47568] = { ["enable"] = true, }, [77575] = { ["enable"] = true, }, [47476] = { ["enable"] = true, }, [49998] = { ["enable"] = true, }, [196770] = { ["enable"] = true, }, [55233] = { ["enable"] = true, }, [43265] = { ["enable"] = true, }, [152279] = { ["enable"] = true, }, [47541] = { ["enable"] = true, }, [206977] = { ["enable"] = true, }, [194913] = { ["enable"] = true, }, [206930] = { ["enable"] = true, }, [207127] = { ["enable"] = true, }, [221562] = { ["enable"] = true, }, [55090] = { ["enable"] = true, }, [49143] = { ["enable"] = true, }, [207167] = { ["enable"] = true, }, [49020] = { ["enable"] = true, }, [48707] = { ["enable"] = true, }, [207256] = { ["enable"] = true, }, [212552] = { ["enable"] = true, }, [195292] = { ["enable"] = true, }, [85948] = { ["enable"] = true, }, [195182] = { ["enable"] = true, }, [221699] = { ["enable"] = true, }, }, } EA_GrpItems = { ["HUNTER"] = { }, ["WARRIOR"] = { }, ["WARLOCK"] = { }, ["DEMONHUNTER"] = { }, ["MAGE"] = { { ["IconAlpha"] = 0.5, ["GroupIconID"] = 0, ["enable"] = false, ["Spells"] = { { ["SpellIconPath"] = 136075, ["Checks"] = { { ["SubChecks"] = { { ["CheckCD"] = 12051, ["EventType"] = "UNIT_POWER_UPDATE", ["SubCheckResult"] = false, ["PowerType"] = "MANA", ["UnitType"] = "player", ["PowerTypeNum"] = 0, ["SubCheckAndOp"] = true, ["PowerLessThanPercent"] = 40, ["PowerCompType"] = 2, }, -- [1] }, ["CheckResult"] = false, ["CheckAndOp"] = true, }, -- [1] }, ["SpellResult"] = false, ["SpellIconID"] = 12051, ["SpellName"] = "唤醒", }, -- [1] }, ["LocX"] = 0, ["GroupResult"] = false, ["LocY"] = -200, ["IconSize"] = 80, ["IconPoint"] = "Top", ["GroupIndex"] = 1, ["IconRelatePoint"] = "Top", }, -- [1] }, ["DRUID"] = { { ["IconPoint"] = "Top", ["GroupIconID"] = 0, ["enable"] = false, ["LocY"] = -200, ["LocX"] = 0, ["ActiveTalentGroup"] = 1, ["GroupResult"] = false, ["GroupIndex"] = 1, ["IconSize"] = 80, ["Spells"] = { { ["SpellIconPath"] = 132242, ["Checks"] = { { ["SubChecks"] = { { ["CheckCD"] = 5217, ["EventType"] = "UNIT_POWER_UPDATE", ["SubCheckResult"] = false, ["PowerType"] = "ENERGY", ["PowerTypeNum"] = 3, ["SubCheckAndOp"] = true, ["UnitType"] = "player", ["PowerLessThanValue"] = 40, ["PowerCompType"] = 2, }, -- [1] }, ["CheckResult"] = false, ["CheckAndOp"] = true, }, -- [1] }, ["SpellResult"] = false, ["SpellIconID"] = 5217, ["SpellName"] = "猛虎之怒", }, -- [1] }, ["IconAlpha"] = 0.5, ["IconRelatePoint"] = "Top", }, -- [1] { ["IconPoint"] = "Top", ["GroupIconID"] = 0, ["enable"] = false, ["LocY"] = -200, ["LocX"] = 0, ["ActiveTalentGroup"] = 2, ["GroupResult"] = false, ["GroupIndex"] = 2, ["IconSize"] = 80, ["Spells"] = { { ["SpellIconPath"] = 236153, ["Checks"] = { { ["SubChecks"] = { { ["CheckCD"] = 48438, ["EventType"] = "UNIT_POWER_UPDATE", ["SubCheckResult"] = false, ["PowerType"] = "MANA", ["PowerTypeNum"] = 0, ["SubCheckAndOp"] = true, ["UnitType"] = "player", ["PowerLessThanValue"] = 5000, ["PowerCompType"] = 4, }, -- [1] }, ["CheckResult"] = false, ["CheckAndOp"] = true, }, -- [1] }, ["SpellResult"] = false, ["SpellIconID"] = 48438, ["SpellName"] = "野性成长", }, -- [1] }, ["IconAlpha"] = 0.5, ["IconRelatePoint"] = "Top", }, -- [2] { ["IconPoint"] = "Top", ["GroupIconID"] = 0, ["enable"] = false, ["LocY"] = -200, ["LocX"] = 80, ["ActiveTalentGroup"] = 2, ["GroupResult"] = false, ["GroupIndex"] = 3, ["IconSize"] = 80, ["Spells"] = { { ["SpellIconPath"] = 136048, ["Checks"] = { { ["SubChecks"] = { { ["CheckCD"] = 29166, ["EventType"] = "UNIT_POWER_UPDATE", ["SubCheckResult"] = false, ["PowerType"] = "MANA", ["UnitType"] = "player", ["PowerTypeNum"] = 0, ["SubCheckAndOp"] = true, ["PowerLessThanPercent"] = 80, ["PowerCompType"] = 2, }, -- [1] }, ["CheckResult"] = false, ["CheckAndOp"] = true, }, -- [1] }, ["SpellResult"] = false, ["SpellIconID"] = 29166, ["SpellName"] = "激活", }, -- [1] }, ["IconAlpha"] = 0.5, ["IconRelatePoint"] = "Top", }, -- [3] { ["IconPoint"] = "Top", ["GroupIconID"] = 0, ["enable"] = false, ["LocY"] = -200, ["LocX"] = -80, ["ActiveTalentGroup"] = 2, ["GroupResult"] = false, ["GroupIndex"] = 4, ["IconSize"] = 80, ["Spells"] = { { ["SpellIconPath"] = 134914, ["Checks"] = { { ["SubChecks"] = { { ["CheckCD"] = 18562, ["EventType"] = "UNIT_POWER_UPDATE", ["SubCheckResult"] = false, ["PowerType"] = "MANA", ["PowerTypeNum"] = 0, ["SubCheckAndOp"] = true, ["UnitType"] = "player", ["PowerLessThanValue"] = 1700, ["PowerCompType"] = 4, }, -- [1] }, ["CheckResult"] = false, ["CheckAndOp"] = true, }, -- [1] }, ["SpellResult"] = false, ["SpellIconID"] = 18562, ["SpellName"] = "迅捷治愈", }, -- [1] }, ["IconAlpha"] = 0.5, ["IconRelatePoint"] = "Top", }, -- [4] { ["IconPoint"] = "Top", ["GroupIconID"] = 0, ["enable"] = false, ["LocY"] = -200, ["LocX"] = -80, ["ActiveTalentGroup"] = 1, ["GroupResult"] = false, ["GroupIndex"] = 5, ["IconSize"] = 80, ["Spells"] = { { ["SpellResult"] = false, ["SpellIconID"] = 33878, ["Checks"] = { { ["SubChecks"] = { { ["CheckCD"] = 33878, ["EventType"] = "UNIT_POWER_UPDATE", ["SubCheckResult"] = false, ["PowerType"] = "RAGE", ["PowerTypeNum"] = 1, ["SubCheckAndOp"] = true, ["UnitType"] = "player", ["PowerLessThanValue"] = 15, ["PowerCompType"] = 4, }, -- [1] }, ["CheckResult"] = false, ["CheckAndOp"] = true, }, -- [1] }, }, -- [1] { ["SpellResult"] = false, ["SpellIconID"] = 33745, ["Checks"] = { { ["SubChecks"] = { { ["CheckCD"] = 33745, ["EventType"] = "UNIT_POWER_UPDATE", ["SubCheckResult"] = false, ["PowerType"] = "RAGE", ["PowerTypeNum"] = 1, ["SubCheckAndOp"] = true, ["UnitType"] = "player", ["PowerLessThanValue"] = 15, ["PowerCompType"] = 4, }, -- [1] }, ["CheckResult"] = false, ["CheckAndOp"] = true, }, -- [1] { ["SubChecks"] = { { ["SubCheckResult"] = false, ["UnitType"] = "target", ["SubCheckAndOp"] = true, ["CheckAuraNotExist"] = 33745, ["CastByPlayer"] = true, ["EventType"] = "UNIT_AURA", }, -- [1] { ["SubCheckResult"] = false, ["CheckAuraExist"] = 33745, ["UnitType"] = "target", ["SubCheckAndOp"] = false, ["EventType"] = "UNIT_AURA", ["CastByPlayer"] = true, ["StackCompType"] = 2, ["StackLessThanValue"] = 2, }, -- [2] { ["TimeLessThanValue"] = 3, ["TimeCompType"] = 2, ["UnitType"] = "target", ["SubCheckAndOp"] = false, ["SubCheckResult"] = false, ["CastByPlayer"] = true, ["EventType"] = "UNIT_AURA", ["CheckAuraExist"] = 33745, }, -- [3] }, ["CheckResult"] = false, ["CheckAndOp"] = true, }, -- [2] }, }, -- [2] { ["SpellIconPath"] = 1033490, ["Checks"] = { { ["SubChecks"] = { { ["CheckCD"] = 80313, ["EventType"] = "UNIT_POWER_UPDATE", ["SubCheckResult"] = false, ["PowerType"] = "RAGE", ["PowerTypeNum"] = 1, ["SubCheckAndOp"] = true, ["UnitType"] = "player", ["PowerLessThanValue"] = 15, ["PowerCompType"] = 4, }, -- [1] { ["SubCheckResult"] = false, ["UnitType"] = "target", ["SubCheckAndOp"] = true, ["CastByPlayer"] = true, ["EventType"] = "UNIT_AURA", ["CheckAuraExist"] = 33745, }, -- [2] }, ["CheckResult"] = false, ["CheckAndOp"] = true, }, -- [1] { ["SubChecks"] = { { ["TimeLessThanValue"] = 3, ["TimeCompType"] = 2, ["UnitType"] = "player", ["SubCheckAndOp"] = true, ["SubCheckResult"] = false, ["EventType"] = "UNIT_AURA", ["CheckAuraExist"] = 80951, }, -- [1] { ["SubCheckResult"] = false, ["UnitType"] = "player", ["SubCheckAndOp"] = false, ["CheckAuraNotExist"] = 80951, ["EventType"] = "UNIT_AURA", }, -- [2] }, ["CheckResult"] = false, ["CheckAndOp"] = true, }, -- [2] }, ["SpellResult"] = false, ["SpellIconID"] = 80313, ["SpellName"] = "粉碎", }, -- [3] { ["SpellIconPath"] = 451161, ["Checks"] = { { ["SubChecks"] = { { ["CheckCD"] = 77758, ["EventType"] = "UNIT_POWER_UPDATE", ["SubCheckResult"] = false, ["PowerType"] = "RAGE", ["PowerTypeNum"] = 1, ["SubCheckAndOp"] = true, ["UnitType"] = "player", ["PowerLessThanValue"] = 25, ["PowerCompType"] = 4, }, -- [1] }, ["CheckResult"] = false, ["CheckAndOp"] = true, }, -- [1] }, ["SpellResult"] = false, ["SpellIconID"] = 77758, ["SpellName"] = "痛击", }, -- [4] { ["SpellResult"] = false, ["SpellIconID"] = 779, ["Checks"] = { { ["SubChecks"] = { { ["CheckCD"] = 779, ["EventType"] = "UNIT_POWER_UPDATE", ["SubCheckResult"] = false, ["PowerType"] = "RAGE", ["PowerTypeNum"] = 1, ["SubCheckAndOp"] = true, ["UnitType"] = "player", ["PowerLessThanValue"] = 15, ["PowerCompType"] = 4, }, -- [1] }, ["CheckResult"] = false, ["CheckAndOp"] = true, }, -- [1] }, }, -- [5] }, ["IconAlpha"] = 0.5, ["IconRelatePoint"] = "Top", }, -- [5] }, ["MONK"] = { }, ["DEATHKNIGHT"] = { { ["IconAlpha"] = 0.5, ["GroupIconID"] = 0, ["enable"] = false, ["Spells"] = { { ["SpellIconPath"] = 134228, ["Checks"] = { { ["SubChecks"] = { { ["SubCheckResult"] = false, ["UnitType"] = "player", ["SubCheckAndOp"] = true, ["CheckAuraNotExist"] = 57330, ["EventType"] = "UNIT_AURA", ["CheckCD"] = 57330, }, -- [1] { ["SubCheckResult"] = false, ["UnitType"] = "player", ["SubCheckAndOp"] = true, ["CheckAuraNotExist"] = 6673, ["EventType"] = "UNIT_AURA", }, -- [2] }, ["CheckResult"] = false, ["CheckAndOp"] = true, }, -- [1] }, ["SpellResult"] = false, ["SpellIconID"] = 57330, ["SpellName"] = "寒冬号角", }, -- [1] }, ["LocX"] = 0, ["GroupResult"] = false, ["LocY"] = -200, ["IconSize"] = 80, ["IconPoint"] = "Top", ["GroupIndex"] = 1, ["IconRelatePoint"] = "Top", }, -- [1] { ["IconPoint"] = "Top", ["GroupIconID"] = 0, ["enable"] = false, ["LocY"] = -200, ["LocX"] = 80, ["ActiveTalentGroup"] = 1, ["GroupResult"] = false, ["IconAlpha"] = 0.5, ["IconSize"] = 80, ["Spells"] = { { ["SpellResult"] = false, ["Checks"] = { { ["SubChecks"] = { { ["SubCheckResult"] = false, ["UnitType"] = "player", ["SubCheckAndOp"] = true, ["CheckAuraNotExist"] = 49222, ["EventType"] = "UNIT_AURA", ["CheckCD"] = 49222, }, -- [1] }, ["CheckResult"] = false, ["CheckAndOp"] = true, }, -- [1] }, ["SpellIconID"] = 49222, }, -- [1] }, ["GroupIndex"] = 2, ["IconRelatePoint"] = "Top", }, -- [2] }, } EA_Pos = { ["DEATHKNIGHT"] = { ["Execution"] = 0, ["GreenDebuff"] = 0.5, ["xOffset"] = -40, ["TarAnchor"] = "CENTER", ["yOffset"] = 0, ["PlayerLv2BOSS"] = true, ["relativePoint"] = "CENTER", ["Anchor"] = "CENTER", ["yLoc"] = -140, ["SCD_UseCooldown"] = false, ["Tar_yOffset"] = -220, ["RedDebuff"] = 0.5, ["Tar_xOffset"] = 0, ["xLoc"] = 0, ["TarrelativePoint"] = "CENTER", ["Tar_NewLine"] = true, ["ScdAnchor"] = "CENTER", ["Scd_xOffset"] = 0, ["Scd_yOffset"] = 80, }, ["WARRIOR"] = { ["Execution"] = 0, ["GreenDebuff"] = 0.5, ["xOffset"] = -40, ["TarAnchor"] = "CENTER", ["yOffset"] = 0, ["PlayerLv2BOSS"] = true, ["relativePoint"] = "CENTER", ["Anchor"] = "CENTER", ["yLoc"] = -140, ["SCD_UseCooldown"] = false, ["Tar_yOffset"] = -220, ["RedDebuff"] = 0.5, ["Tar_xOffset"] = 0, ["xLoc"] = 0, ["TarrelativePoint"] = "CENTER", ["Tar_NewLine"] = true, ["ScdAnchor"] = "CENTER", ["Scd_xOffset"] = 0, ["Scd_yOffset"] = 80, }, ["PALADIN"] = { ["Execution"] = 0, ["GreenDebuff"] = 0.5, ["xOffset"] = -40, ["TarAnchor"] = "CENTER", ["yOffset"] = 0, ["PlayerLv2BOSS"] = true, ["relativePoint"] = "CENTER", ["Anchor"] = "CENTER", ["yLoc"] = -140, ["SCD_UseCooldown"] = false, ["Tar_yOffset"] = -220, ["RedDebuff"] = 0.5, ["Tar_xOffset"] = 0, ["xLoc"] = 0, ["TarrelativePoint"] = "CENTER", ["Tar_NewLine"] = true, ["ScdAnchor"] = "CENTER", ["Scd_xOffset"] = 0, ["Scd_yOffset"] = 80, }, ["MAGE"] = { ["Execution"] = 0, ["GreenDebuff"] = 0.5, ["xOffset"] = -40, ["TarAnchor"] = "CENTER", ["yOffset"] = 0, ["PlayerLv2BOSS"] = true, ["relativePoint"] = "CENTER", ["Anchor"] = "CENTER", ["yLoc"] = -140, ["SCD_UseCooldown"] = false, ["Tar_yOffset"] = -220, ["RedDebuff"] = 0.5, ["Tar_xOffset"] = 0, ["xLoc"] = 0, ["TarrelativePoint"] = "CENTER", ["Tar_NewLine"] = true, ["ScdAnchor"] = "CENTER", ["Scd_xOffset"] = 0, ["Scd_yOffset"] = 80, }, ["PRIEST"] = { ["Execution"] = 0, ["GreenDebuff"] = 0.5, ["xOffset"] = -40, ["TarAnchor"] = "CENTER", ["yOffset"] = 0, ["PlayerLv2BOSS"] = true, ["relativePoint"] = "CENTER", ["Anchor"] = "CENTER", ["yLoc"] = -140, ["SCD_UseCooldown"] = false, ["Tar_yOffset"] = -220, ["RedDebuff"] = 0.5, ["Tar_xOffset"] = 0, ["xLoc"] = 0, ["TarrelativePoint"] = "CENTER", ["Tar_NewLine"] = true, ["ScdAnchor"] = "CENTER", ["Scd_xOffset"] = 0, ["Scd_yOffset"] = 80, }, ["ROGUE"] = { ["Execution"] = 0, ["GreenDebuff"] = 0.5, ["xOffset"] = -40, ["TarAnchor"] = "CENTER", ["yOffset"] = 0, ["PlayerLv2BOSS"] = true, ["relativePoint"] = "CENTER", ["Anchor"] = "CENTER", ["yLoc"] = -140, ["SCD_UseCooldown"] = false, ["Tar_yOffset"] = -220, ["RedDebuff"] = 0.5, ["Tar_xOffset"] = 0, ["xLoc"] = 0, ["TarrelativePoint"] = "CENTER", ["Tar_NewLine"] = true, ["ScdAnchor"] = "CENTER", ["Scd_xOffset"] = 0, ["Scd_yOffset"] = 80, }, ["WARLOCK"] = { ["Execution"] = 0, ["GreenDebuff"] = 0.5, ["xOffset"] = -40, ["TarAnchor"] = "CENTER", ["yOffset"] = 0, ["PlayerLv2BOSS"] = true, ["relativePoint"] = "CENTER", ["Anchor"] = "CENTER", ["yLoc"] = -140, ["SCD_UseCooldown"] = false, ["Tar_yOffset"] = -220, ["RedDebuff"] = 0.5, ["Tar_xOffset"] = 0, ["xLoc"] = 0, ["TarrelativePoint"] = "CENTER", ["Tar_NewLine"] = true, ["ScdAnchor"] = "CENTER", ["Scd_xOffset"] = 0, ["Scd_yOffset"] = 80, }, ["DEMONHUNTER"] = { ["Execution"] = 0, ["GreenDebuff"] = 0.5, ["xOffset"] = -40, ["TarAnchor"] = "CENTER", ["yOffset"] = 0, ["PlayerLv2BOSS"] = true, ["relativePoint"] = "CENTER", ["Anchor"] = "CENTER", ["yLoc"] = -140, ["SCD_UseCooldown"] = false, ["Tar_yOffset"] = -220, ["RedDebuff"] = 0.5, ["Tar_xOffset"] = 0, ["xLoc"] = 0, ["TarrelativePoint"] = "CENTER", ["Tar_NewLine"] = true, ["ScdAnchor"] = "CENTER", ["Scd_xOffset"] = 0, ["Scd_yOffset"] = 80, }, ["HUNTER"] = { ["Execution"] = 0, ["GreenDebuff"] = 0.5, ["xOffset"] = -40, ["TarAnchor"] = "CENTER", ["yOffset"] = 0, ["PlayerLv2BOSS"] = true, ["relativePoint"] = "CENTER", ["Anchor"] = "CENTER", ["yLoc"] = -140, ["SCD_UseCooldown"] = false, ["Tar_yOffset"] = -220, ["RedDebuff"] = 0.5, ["Tar_xOffset"] = 0, ["xLoc"] = 0, ["TarrelativePoint"] = "CENTER", ["Tar_NewLine"] = true, ["ScdAnchor"] = "CENTER", ["Scd_xOffset"] = 0, ["Scd_yOffset"] = 80, }, ["DRUID"] = { ["Execution"] = 0, ["GreenDebuff"] = 0.5, ["xOffset"] = -40, ["TarAnchor"] = "CENTER", ["yOffset"] = 0, ["PlayerLv2BOSS"] = true, ["relativePoint"] = "CENTER", ["Anchor"] = "CENTER", ["yLoc"] = -140, ["SCD_UseCooldown"] = false, ["Tar_yOffset"] = -220, ["RedDebuff"] = 0.5, ["Tar_xOffset"] = 0, ["xLoc"] = 0, ["TarrelativePoint"] = "CENTER", ["Tar_NewLine"] = true, ["ScdAnchor"] = "CENTER", ["Scd_xOffset"] = 0, ["Scd_yOffset"] = 80, }, ["MONK"] = { ["Execution"] = 0, ["GreenDebuff"] = 0.5, ["xOffset"] = -40, ["TarAnchor"] = "CENTER", ["yOffset"] = 0, ["PlayerLv2BOSS"] = true, ["relativePoint"] = "CENTER", ["Anchor"] = "CENTER", ["yLoc"] = -140, ["SCD_UseCooldown"] = false, ["Tar_yOffset"] = -220, ["RedDebuff"] = 0.5, ["Tar_xOffset"] = 0, ["xLoc"] = 0, ["TarrelativePoint"] = "CENTER", ["Tar_NewLine"] = true, ["ScdAnchor"] = "CENTER", ["Scd_xOffset"] = 0, ["Scd_yOffset"] = 80, }, ["SHAMAN"] = { ["Execution"] = 0, ["GreenDebuff"] = 0.5, ["xOffset"] = -40, ["TarAnchor"] = "CENTER", ["yOffset"] = 0, ["PlayerLv2BOSS"] = true, ["relativePoint"] = "CENTER", ["Anchor"] = "CENTER", ["yLoc"] = -140, ["SCD_UseCooldown"] = false, ["Tar_yOffset"] = -220, ["RedDebuff"] = 0.5, ["Tar_xOffset"] = 0, ["xLoc"] = 0, ["TarrelativePoint"] = "CENTER", ["Tar_NewLine"] = true, ["ScdAnchor"] = "CENTER", ["Scd_xOffset"] = 0, ["Scd_yOffset"] = 80, }, }
nilq/small-lua-stack
null
local moduleName = "http" evalPath[moduleName] = function (path) if path:match("^http://") then return httpget(path) else return nil end end
nilq/small-lua-stack
null
local research = trinium.research local S = research.S local api = trinium.api local M = trinium.materials.materials minetest.register_on_joinplayer(function(player) local data = research.dp2[player:get_player_name()] data.aspects = data.aspects or {} data.ink = data.ink or 0 data.paper = data.paper or 0 data.warp = data.warp or 0 end) local function get_book_fs(pn) local buttons = "" for k, v in pairs(research.chapters) do if table.every(v.requirements, function(_, a) return research.check(pn, a) end) then buttons = buttons .. ([=[ item_image_button[${x},${y};1,1;${texture};open_chapter~${chapter_id};] tooltip[open_chapter~${chapter_id};${description}] ]=]):from_table{ x = v.x, y = v.y, texture = v.texture, chapter_id = k, description = v.name, } end end return buttons end local function cut_coordinates(x1, x2, y1, y2) if y1 == y2 then return math.min(math.max(x1, x2), 8), math.max(math.min(x1, x2), -0.5), y1, y1 end if x1 == x2 then return x1, x1, math.min(math.max(y1, y2), 8), math.max(math.min(y1, y2), -0.5) end --[[ define line (x1,y1) => (x2,y2) as y = kx + b then, kx1 + b = y1 and kx2 + b = y2 k(x2-x1) = (y2-y1) k = (y2-y1)/(x2-x1) b = y1 - kx1 = (x2y1 - x1y2)/(x2-x1) ]]-- local k, b = (y2 - y1) / (x2 - x1), (x2 * y1 - x1 * y2) / (x2 - x1) -- then, intersect y = kx + b with line x = -0.5, then y = -0.5k + b if x1 < -0.5 then x1 = -0.5; y1 = -0.5 * k + b end if x2 < -0.5 then x2 = -0.5; y2 = -0.5 * k + b end -- then, with x = 8, then y = 8k + b if x1 > 8 then x1 = 8; y1 = 8 * k + b end if x2 > 8 then x2 = 8; y2 = 8 * k + b end -- then, with y = -0.5, then x = -(b+0.5)/k if y1 < -0.5 then y1 = -0.5; x1 = -(b + 0.5) / k end if y2 < -0.5 then y2 = -0.5; x2 = -(b + 0.5) / k end -- finally, with y = 8, then x = (8-b)/k if y1 > 8 then y1 = 8; x1 = (8 - b) / k end if y2 > 8 then y2 = 8; x2 = (8 - b) / k end return x1, x2, y1, y2 end local function draw_connection(x1, y1, x2, y2) -- some strange thing if x1 == x2 and y1 == y2 then return "" end -- both outside of screen if ((x1 < 0 or x1 > 7) and (x2 < 0 or x2 > 7)) or ((y1 < 0 or y1 > 7) and (y2 < 0 or y2 > 7)) then return "" end x1, x2, y1, y2 = cut_coordinates(x1, x2, y1, y2) if x1 == x2 then if y1 > y2 then y1, y2 = y2, y1 end return ("background[%s,%s;1,%s;trinium_research_gui.connector_vertical.png]"):format(x1, y1 + 0.5, y2 - y1) elseif y1 == y2 then if x1 > x2 then x1, x2 = x2, x1 end return ("background[%s,%s;%s,1;trinium_research_gui.connector_horizontal.png]"):format(x1 + 0.5, y1, x2 - x1) elseif (x1 > x2) == (y1 > y2) then if x1 > x2 then x1, x2, y1, y2 = x2, x1, y2, y1 end return ("background[%s,%s;%s,%s;trinium_research_gui.connector_normal.png]") :format(x1 + 0.5, y1 + 0.5, x2 - x1, y2 - y1) else if x1 > x2 then x1, x2 = x2, x1 y1, y2 = y2, y1 end return ("background[%s,%s;%s,%s;trinium_research_gui.connector_reverse.png]") :format(x1 + 0.5, y2 + 0.5, x2 - x1, y1 - y2) end end local function get_book_chapter_fs(chapter_id, pn, cx, cy) local buttons = ("button[7,8;1,1;open_book;%s]"):format(trinium.api.S"Back") if research.chapters[chapter_id].create_map then buttons = buttons .. ("button[5,8;2,1;research~get_map;%s]tooltip[research~get_map;%s]") :format(buttons, S"Get Research Map", S"This chapter uses Secret researches discovered via Sheet Infuser") end if not research.researches_by_chapter[chapter_id] then return end local frc = table.filter(research.researches_by_chapter[chapter_id], function(v) return v.x - cx >= 0 and v.x - cx <= 7 and v.y - cy >= 0 and v.y - cy <= 7 end) local enable for k, v in pairs(research.researches_by_chapter[chapter_id]) do local desc = v.name if v.warp then desc = desc .. "\n" .. minetest.colorize("#CC33FF", S("Forbidden Knowledge: Level @1", v.warp)) end enable = false if v.pre_unlock or research.check(pn, k) then -- Research available for v1 in pairs(v.requirements) do if research.researches_by_chapter[chapter_id][v1] then local v2 = research.researches[v1] buttons = buttons .. draw_connection(v.x - cx, v.y - cy, v2.x - cx, v2.y - cy) end end if frc[k] then buttons = buttons .. ([=[ item_image_button[${x},${y};1,1;${texture};open_research~${research_id};] tooltip[open_research~${research_id};${description}] ]=]):from_table{ x = v.x - cx, y = v.y - cy, texture = v.texture, research_id = k, description = v.name, } enable = true end elseif table.every(v.requirements, function(_, a) return not research.researches[a] or research.researches[a].pre_unlock or research.check(pn, a) end) and not v.hidden then -- Obtainable research sheet for v1 in pairs(v.requirements) do if research.researches_by_chapter[chapter_id][v1] then local v2 = research.researches[v1] buttons = buttons .. draw_connection(v.x - cx, v.y - cy, v2.x - cx, v2.y - cy) end end if frc[k] then buttons = buttons .. ([=[ background[${x},${y};1,1;trinium_research_gui.glowing.png] item_image_button[${x},${y};1,1;${texture};get_sheet~${research_id};] tooltip[get_sheet~${research_id};${description}] ]=]):from_table{ x = v.x - cx, y = v.y - cy, texture = v.texture, research_id = k, description = v.name, } enable = true end end if enable and v.important then buttons = buttons .. ([=[ background[%s,%s;1.5,1.5;trinium_research_gui.important.png] ]=]):format(v.x - cx - 0.25, v.y - cy - 0.25) end end return buttons end -- Returns text, size local function get_book_research_fs(pn, context) local split = context.book:split "~" local res, key = split[2], tonumber(split[3]) local def = research.researches[res] local text = def.text[key] if type(text) == "string" then text = {form = "textarea[0.25,1;7.75,7;;;" .. text .. "]", w = 8, h = 8, locked = false} end if type(text[1]) == "table" then for k, v in pairs(text[1]) do if not text[k] then text[k] = v end end end if text.text and not text.form then text.form = "textarea[0.25,1;7.75,7;;;" .. (text.text) .. "]" end if text.requirements and not table.every(text.requirements, function(_, k) return research.check(pn, k) end) then -- has requirement return ([=[ label[0,8.2;${page_num}] button[6,0.25;1,0.5;turn_backward;<] button[7,0.25;1,0.5;turn_forward;>] textarea[0,1;8,7;;;${not_found}] button[7,8;1,1;open_chapter~${chapter};${chapter_button}] ]=]):from_table{ page_num = S("@1 - page @2/@3", def.name, key, #def.text), not_found = S"This page is not found yet", chapter = def.chapter, chapter_button = S"Back", } elseif text.locked and not research.check(pn, res .. "-" .. key) then local good = true local r = 0 local reqs = table.f_concat(table.map(text.required_aspects, function(v, k) if not research.dp2[pn].aspects[k] then research.dp2[pn].aspects[k] = 0 end local amount = research.dp2[pn].aspects[k] local color = amount >= v and "#00CC00" or "#CC0000" if amount < v then good = false end r = r + 1 local k1 = api.string_capitalization(k) return ("label[0,%s;%s]"):format((2 + r) / 3, minetest.colorize(color, S("@1 aspect (@2 needed, @3 available)", k1, v, amount))) end)) return ([=[ label[0,8.2;${page_num}] button[6,0.25;1,0.5;turn_backward;<] button[7,0.25;1,0.5;turn_forward;>] ${requirement_string} button[7,8;1,1;open_chapter~${chapter};${chapter_button}] button[0,7;8,1;${unlock};${unlock_button}] ]=]):from_table{ page_num = S("@1 - page @2/@3", def.name, key, #def.text), requirement_string = reqs, chapter = def.chapter, chapter_button = S"Back", unlock = good and "unlock" or "", unlock_button = S"Unlock", } else local w, h = math.max(text.w, 8), math.max(text.h, 8) + 0.6 return ([=[ label[0,${page_num_y};${page_num}] button[${back_button},0.25;1,0.5;turn_backward;<] button[${forward_button},0.25;1,0.5;turn_forward;>] ${form} button[${forward_button},${chapter_y};1,1;open_chapter~${chapter};${chapter_button}] ]=]):from_table{ page_num_y = h - 0.4, page_num = S("@1 - page @2/@3", def.name, key, #def.text), back_button = w - 2, forward_button = w - 1, form = text.form, chapter_y = h - 0.6, chapter = def.chapter, chapter_button = S"Back", }, {x = w, y = h} end end local function get_book_bg(pn) local w = research.dp1[pn] return ("background[0,0;1,1;trinium_research_gui.background_%s.png;true]") :format(w.CognFission and 4 or w.CognVoid and 3 or w.CognWarp and 2 or 1) end local function get_book_chapter_bg(chapter_id) local w = research.chapters[chapter_id] return ("background[0,0;1,1;trinium_research_gui.background_%s.png;true]"):format(w.tier) end local book = {description = S"Research Book"} function book.getter(player, context) local pn = player:get_player_name() context.book = context.book or "default_bg" context.book_y = context.book_y or 0 local split = context.book:split"~" if split[1] == "default_bg" then return betterinv.generate_formspec(player, get_book_fs(pn), false, get_book_bg(pn), false) elseif split[1] == "chapter" then local fs = get_book_chapter_fs(split[2], pn, 0, context.book_y) return betterinv.generate_formspec(player, fs, false, get_book_chapter_bg(split[2]), false) elseif split[1] == "research" then -- research~SomeTestResearch~3 (3rd page) local fs, s = get_book_research_fs(pn, context) return betterinv.generate_formspec(player, fs, s, false, false) end end function book.processor(player, context, fields) if fields.quit then return end local pn = player:get_player_name() local inv = player:get_inventory() context.book = context.book or "default_bg" for k in pairs(fields) do if k == "key_up" and context.book:split"~"[1] == "chapter" then context.book_y = context.book_y - 1 elseif k == "key_down" and context.book:split"~"[1] == "chapter" then context.book_y = context.book_y + 1 else local k_split = k:split"~" -- Module, action, parameters local a = k_split[1] if a == "open_chapter" then context.book = "chapter~" .. k_split[2] elseif a == "open_book" then context.book = "default_bg" context.book_y = 0 elseif a == "open_research" then context.book = ("research~%s~1"):format(k_split[2]) elseif a == "turn_forward" then local cs = context.book:split("~") local res = research.researches[cs[2]] cs[3] = tonumber(cs[3]) context.book = ("research~%s~%s"):format(cs[2], math.min(cs[3] + 1, #res.text)) elseif a == "turn_backward" then local cs = context.book:split("~") cs[3] = tonumber(cs[3]) context.book = ("research~%s~%s"):format(cs[2], math.max(cs[3] - 1, 1)) elseif a == "unlock" then local cs = context.book:split("~") local res = research.researches[cs[2]] cs[3] = tonumber(cs[3]) table.walk(res.text[cs[3]].required_aspects, function(v1, k1) research.dp2[pn].aspects[k1] = research.dp2[pn].aspects[k1] - v1 end) research.dp1[pn][cs[2] .. "-" .. cs[3]] = 1 elseif a == "get_sheet" then local stack = ItemStack("trinium_research:notes_2") local meta = stack:get_meta() local res = research.researches[k_split[2]] meta:set_string("description", S("Research Notes - @1", res.name)) meta:set_string("research_id", k_split[2]) if inv:contains_item("main", stack, true) or research.check(pn, k_split[2]) then cmsg.push_message_player(player, S"You already have this research!") return elseif research.dp2[pn].ink < 3 then cmsg.push_message_player(player, S"Insufficient Ink!") return elseif research.dp2[pn].paper < 1 then cmsg.push_message_player(player, S"Insufficient Paper!") return end research.dp2[pn].ink = research.dp2[pn].ink - 3 research.dp2[pn].paper = research.dp2[pn].paper - 1 inv:add_item("main", stack) elseif a == "get_map" then local stack = ItemStack("trinium_research:notes_3") local meta = stack:get_meta() local cs = context.book:split("~") local res = research.researches[cs[2]] meta:set_string("description", S("Research Map - @1", research.chapters[res.chapter].name)) meta:set_string("chapter_id", cs[2]) if inv:contains_item("main", stack, true) then cmsg.push_message_player(player, S"You already have this research map!") return elseif research.dp2[pn].ink < 500 then cmsg.push_message_player(player, S"Insufficient Ink!") return end if not inv:contains_item("main", M.diamond:get("dust", 16)) then cmsg.push_message_player(player, S"Insufficient Diamond Dust!") return end inv:remove_item("main", M.diamond:get("dust", 16)) research.dp2[pn].ink = research.dp2[pn].ink - 500 inv:add_item("main", stack) end end end end betterinv.register_tab("research_book", book)
nilq/small-lua-stack
null
return { source = { type = 'dist', location = 'ftp://ftp.cwru.edu/pub/bash/readline-6.3.tar.gz', sha256sum = '56ba6071b9462f980c5a72ab0023893b65ba6debb4eeb475d7a563dc65cafd43' }, patches = { { "${pkg_name}-5.0-no_rpath.patch", 0 }, { "${pkg_name}-6.2-rlfe-tgoto.patch", 1 }, { "${pkg_name}-6.3-fix-long-prompt-vi-search.patch", 1 }, { "${pkg_name}-6.3-read-eof.patch", 2 }, }, build = { type = 'gnu', options = { '--disable-static', '--without-curses', '--without-purify', } } }
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 -- ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- -- Summary: metalua parser, miscellaneous utility functions. -- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- -- Exported API: -- * [mlp.fget()] -- * [mlp.id()] -- * [mlp.opt_id()] -- * [mlp.id_list()] -- * [mlp.string()] -- * [mlp.opt_string()] -- * [mlp.id2string()] -- -------------------------------------------------------------------------------- local pp = require 'metalua.pprint' local gg = require 'metalua.grammar.generator' -- TODO: replace splice-aware versions with naive ones, move etensions in ./meta return function(M) local _M = gg.future(M) -------------------------------------------------------------------------------- -- Try to read an identifier (possibly as a splice), or return [false] if no -- id is found. -------------------------------------------------------------------------------- function M.opt_id (lx) local a = lx:peek(); if lx:is_keyword (a, "-{") then local v = M.meta.splice(lx) if v.tag ~= "Id" and v.tag ~= "Splice" then gg.parse_error(lx, "Bad id splice") end return v elseif a.tag == "Id" then return lx:next() else return false end end -------------------------------------------------------------------------------- -- Mandatory reading of an id: causes an error if it can't read one. -------------------------------------------------------------------------------- function M.id (lx) return M.opt_id (lx) or gg.parse_error(lx,"Identifier expected") end -------------------------------------------------------------------------------- -- Common helper function -------------------------------------------------------------------------------- M.id_list = gg.list { primary = _M.id, separators = "," } -------------------------------------------------------------------------------- -- Converts an identifier into a string. Hopefully one day it'll handle -- splices gracefully, but that proves quite tricky. -------------------------------------------------------------------------------- function M.id2string (id) --print("id2string:", disp.ast(id)) if id.tag == "Id" then id.tag = "String"; return id elseif id.tag == "Splice" then error ("id2string on splice not implemented") -- Evaluating id[1] will produce `Id{ xxx }, -- and we want it to produce `String{ xxx }. -- The following is the plain notation of: -- +{ `String{ `Index{ `Splice{ -{id[1]} }, `Number 1 } } } return { tag="String", { tag="Index", { tag="Splice", id[1] }, { tag="Number", 1 } } } else error ("Identifier expected: "..pp.tostring(id, 'nohash')) end end -------------------------------------------------------------------------------- -- Read a string, possibly spliced, or return an error if it can't -------------------------------------------------------------------------------- function M.string (lx) local a = lx:peek() if lx:is_keyword (a, "-{") then local v = M.meta.splice(lx) if v.tag ~= "String" and v.tag ~= "Splice" then gg.parse_error(lx,"Bad string splice") end return v elseif a.tag == "String" then return lx:next() else error "String expected" end end -------------------------------------------------------------------------------- -- Try to read a string, or return false if it can't. No splice allowed. -------------------------------------------------------------------------------- function M.opt_string (lx) return lx:peek().tag == "String" and lx:next() end -------------------------------------------------------------------------------- -- Chunk reader: block + Eof -------------------------------------------------------------------------------- function M.skip_initial_sharp_comment (lx) -- Dirty hack: I'm happily fondling lexer's private parts -- FIXME: redundant with lexer:newstream() lx :sync() local i = lx.src:match ("^#.-\n()", lx.i) if i then lx.i = i lx.column_offset = i lx.line = lx.line and lx.line + 1 or 1 end end local function chunk (lx) if lx:peek().tag == 'Eof' then return { } -- handle empty files else M.skip_initial_sharp_comment (lx) local chunk = M.block (lx) if lx:peek().tag ~= "Eof" then gg.parse_error(lx, "End-of-file expected") end return chunk end end -- chunk is wrapped in a sequence so that it has a "transformer" field. M.chunk = gg.sequence { chunk, builder = unpack } return M end
nilq/small-lua-stack
null
local plugin_status = require("utils").load_config().plugin_status local present, _ = pcall(require, "packerInit") local packer if present then packer = require("packer") else return false end vim.cmd([[ augroup packer_user_config autocmd! autocmd BufWritePost pluginList.lua luafile <afile> | PackerSync augroup END ]]) local use = packer.use return packer.startup(function() use({ "wbthomason/packer.nvim", event = "VimEnter", }) use({ "jdhao/better-escape.vim", disable = not plugin_status.better_esc, event = "InsertEnter", config = function() require("plugins.others").escape() end, }) use({ "feline-nvim/feline.nvim", after = "nvim-base16.lua", config = function() require("plugins.statusline") end, }) use({ "akinsho/bufferline.nvim", after = "feline.nvim", disable = not plugin_status.nvim_bufferline, config = function() require("plugins.bufferline") end, setup = function() require("mappings").bufferline() end, }) -- color related stuff use({ "NvChad/nvim-base16.lua", after = "packer.nvim", config = function() require("theme") end, }) use({ "norcalli/nvim-colorizer.lua", disable = not plugin_status.nvim_colorizer, event = "BufRead", config = function() require("plugins.others").colorizer() end, }) -- lsp stuff use({ "nvim-treesitter/nvim-treesitter", event = "BufRead", config = function() require("plugins.treesitter") end, }) use({ "JoosepAlviste/nvim-ts-context-commentstring", after = "nvim-treesitter", }) use({ "rafamadriz/friendly-snippets", }) use({ "mfussenegger/nvim-dap", after = "telescope.nvim", config = function() require("plugins.dapconf") end, setup = function() require("mappings").dap() end, }) use({ "rcarriga/nvim-dap-ui", after = "nvim-dap", config = function() require("plugins.dapuiconf") end, }) use({ "theHamsta/nvim-dap-virtual-text", after = { "nvim-dap" }, config = function() require("nvim-dap-virtual-text").setup() end, }) use({ "leoluz/nvim-dap-go", after = "nvim-dap", config = function() require("plugins.dapgo") end, }) use({ "L3MON4D3/LuaSnip", config = function() require("plugins.luasnip") end, }) -- file managing , picker etc use({ "kyazdani42/nvim-tree.lua", cmd = "NvimTreeToggle", config = function() require("plugins.nvimtree") end, setup = function() require("mappings").nvimtree() end, }) use({ "kyazdani42/nvim-web-devicons", after = "nvim-base16.lua", config = function() require("plugins.icons") end, }) use({ "nvim-lua/plenary.nvim", }) use({ "nvim-lua/popup.nvim", after = "plenary.nvim", }) use({ "liuchengxu/vista.vim", config = function() require("plugins.vista") end, }) use({ "nvim-telescope/telescope.nvim", after = "plenary.nvim", requires = { { "nvim-telescope/telescope-fzf-native.nvim", run = "make", }, { "nvim-telescope/telescope-media-files.nvim", disable = not plugin_status.telescope_media, setup = function() require("mappings").telescope_media() end, }, { "sudormrfbin/cheatsheet.nvim", disable = not plugin_status.cheatsheet, event = "VimEnter", after = "telescope.nvim", config = function() require("plugins.chadsheet") end, setup = function() require("mappings").chadsheet() end, }, }, config = function() require("plugins.telescope") end, setup = function() require("mappings").telescope() end, }) use({ "mhinz/vim-startify", run = "mkdir -p $HOME/.local/share/nvim/session/", requires = { "itchyny/vim-gitbranch", }, config = function() require("plugins.startify") end, }) -- git stuff use({ "lewis6991/gitsigns.nvim", disable = not plugin_status.gitsigns, after = "plenary.nvim", config = function() require("plugins.gitsigns") end, }) use({ "andymass/vim-matchup", disable = not plugin_status.vim_matchup, event = "CursorMoved", }) use({ "terrortylor/nvim-comment", disable = not plugin_status.nvim_comment, cmd = "CommentToggle", config = function() require("plugins.others").comment() end, setup = function() require("mappings").comment_nvim() end, }) -- load autosave only if its globally enabled use({ disable = not plugin_status.autosave_nvim, "Pocco81/AutoSave.nvim", config = function() require("plugins.autosave") end, cond = function() return vim.g.auto_save == true end, }) -- smooth scroll use({ "karb94/neoscroll.nvim", disable = not plugin_status.neoscroll_nvim, event = "WinScrolled", config = function() require("plugins.others").neoscroll() end, }) use({ "lukas-reineke/indent-blankline.nvim", disable = not plugin_status.blankline, event = "BufRead", setup = function() require("plugins.others").blankline() end, }) use({ "tpope/vim-fugitive", disable = not plugin_status.vim_fugitive, cmd = { "Git", }, setup = function() require("mappings").fugitive() end, }) use({ "akinsho/toggleterm.nvim", run = "pip3 install neovim-remote", config = function() require("plugins.term") end, }) use({ "phaazon/hop.nvim", config = function() require("hop").setup() end, setup = function() require("mappings").hop() end, }) use({ "neovim/nvim-lspconfig", requires = { "williamboman/nvim-lsp-installer", "ray-x/lsp_signature.nvim", "MunifTanjim/nui.nvim", }, config = function() require("plugins.lspconfig") end, }) use({ "jose-elias-alvarez/null-ls.nvim", config = function() require("plugins.nullls") end, }) -- cmp stuff use({ "hrsh7th/nvim-cmp", after = { "nvim-lspconfig", "LuaSnip", "plenary.nvim", }, requires = { "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "hrsh7th/cmp-cmdline", "saadparwaiz1/cmp_luasnip", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lua", }, config = function() require("plugins.nvimcmp") end, setup = function() require("mappings").lsp() end, }) use({ "windwp/nvim-autopairs", after = "nvim-cmp", config = function() require("plugins.autopairs") end, }) use({ "iamcco/markdown-preview.nvim", run = "cd app && yarn install", config = function() vim.g.mkdp_open_ip = vim.fn.hostname() vim.g.mkdp_echo_preview_url = 1 end, }) use({ "folke/which-key.nvim", config = function() require("which-key").setup({ triggers = { "<leader>" }, }) end, }) end)
nilq/small-lua-stack
null
-- A basic Enemy Entity you can copy and modify for your own creations. comments = { "Smells like the work of an enemy stand.[w:5]\nAnd shady deals.", "Poseur is posing like his money depends on it.", "Poseur's limbs shouldn't be contorting in this way." } randomdialogue = { { "Check it [[out\nat my store!]", "Please" }, { "Check it out\nagain.", "...", "For real now" }, { "I'll show you [[THE LIGHT].", "Trust me." }, { "Keep [[track of\nyour chickens]!", }, "It's [[Everyone's\nFavorite Marvel\nCharacter]." } -- Act name, act description, TP cost, party members required, party members viewable from --AddAct("Check", "", 0) AddAct("Talk", "", 0, {}) AddAct("Mock", "", 10, { "susie" }) AddAct("Dance", "", 30, { "ralsei" }) sprite = "Idle/0" name = "Poseur" hp = 250 attack = 10 defense = 2 immortal = false dialogbubble = "automatic" -- Chapter 2's automatic dialogue bubble, very similar to CYF's targetables = "heroes" -- "Hero", "Enemy", or "Entity". targettype = 1 -- If a number, at most that many targets based off of targetables. If a string / table of strings, target those entities. statuses = {} mercy = 0 -- From 0 to 1, the value of the mercy bar. cancheck = true -- Inserts the default CHECK behavior into the commands canspare = true -- Can this enemy be spared? checkmessage = "This poor mannequin has\rbeen subject to all sorts\rof cruel tests." talks = 0 mocks = 0 dance = 0 -- The animations table -- -- KROMER searches "Enemies/<enemy name>/<animation name or refer><addition>/<frame name>" -- The first argument is the name of the frames -- The second argument is the speed of the animation (Seconds per frame) -- The third argument contains various miscellaneous information -- loopmode - The animation's loop mode -- next - Queues an animation after the current one -- immediate - If the animation doesn't loop, the queued animation plays immediately after -- offset - The X & Y offset of the animation -- addition - An additional string added to the search path of the animation, after the animation name. supply a function, and it's run every time the animation switches -- refer - Replaces the animation name portion of the search path, if supplied -- onselect - If supplied, this animation will play when the hero selects the supplied action. local s = {} local r = math.random(1,4) for i = 1, r do s[i] = 0 end local r2 = math.random(2,10) for i = r, r+r2 do s[i] = math.random(1,4) end s[#s+1] = 5 local t = {} local r = math.random(5,15) for i = 1, r do t[i] = 0 end for i = r, r+2 do t[i] = i-r+1 if i == r+2 then t[i] = 1 end end animations = { Intro = { s, 1/15, { loopmode = "ONESHOT", next = "Idle", offset = {0,0}, } }, Idle = { t, 1/12, { offset = {0,0}, } }, Hurt = { "Auto", 1, { next = "Idle", offset = {0,0}, } }, Flee = { "Auto", 1, { offset = {0,0} } }, } -- Triggered just before computing an attack on this target function BeforeDamageCalculation(attacker, damageCoeff) -- Good location to set the damage dealt to this enemy using self.SetDamage() if damageCoeff > 0 then --SetDamage(666) end end -- Triggered when a Hero attacks (or misses) this enemy in the ATTACKING state function HandleAttack(attacker, attackstatus) if currentdialogue == nil then currentdialogue = { } end if attackstatus == -1 then -- Player pressed fight but didn't press Z afterwards table.insert(currentdialogue, "Do no [DRUGS], " .. attacker.name .. ".\n") else -- Player did actually attack if attackstatus < 50 then table.insert(currentdialogue, "You're strong, " .. attacker.name .. "!\n") else table.insert(currentdialogue, "Too strong, " .. attacker.name .. "...\n") end end end function OnDeath(hero) end function OnSpare(hero) end -- Triggered when a Hero uses an Act on this enemy. -- You don't need an all-caps version of the act commands here. function HandleCustomCommand(hero, command) if command == "Standard" then if hero == "noelle" then AddMercy(0.15) BattleDialogue({"Noelle compliments Poseur's\rforeboding posture."}) elseif hero == "ralsei" then AddMercy(0.15) BattleDialogue({"Ralsei offers tips on being\rcute and/or adorable to Poseur."}) elseif hero == "susie" then if not GetStatus("Tired") then AddStatus("Tired") end BattleDialogue({"Susie cracks her neck so loudly,\rPoseur's bones tremble in fear.","Poseur became [highlight:00B4FF]TIRED[endhighlight]!"}) end end if command == "Talk" then talks = talks + 1 if talks == 1 then AddMercy(0.50) BattleDialogue({"You try to strike up a\rconversation with Poseur.", "He seems a little out of it."}) currentdialogue = "[[CONGRATS! YOUR ARE OUR 100TH]" elseif talks == 2 then AddMercy(0.50) BattleDialogue({"You mention bullets.", "Poseur seems to remember something."}) currentdialogue = "...[[LET'S GET MOVING!!]" end end end -- Function called whenever this entity's animation is changed. -- Make it return true if you want the animation to be changed like normal, otherwise do your own stuff here! function HandleAnimationChange(oldAnim, newAnim) return true end
nilq/small-lua-stack
null
local skynet = require "skynet.manager" local codecache = require "skynet.codecache" local cluster = require "skynet.cluster" local clusterMonitor = require "utils/clusterMonitor" local TAG = "AllocServiceMgr" local AllocServiceMgr = {} function AllocServiceMgr:init(pGameCode, pIdentify) local pServerConfig = require(onGetServerConfigFile(pGameCode)) self.m_pGameCode = pGameCode self.m_pHallServiceMgr = nil self.m_pGameServerMgrTable = {} self.m_pFriendBattleRoomIdMap = {} self.m_pGoldFieldIdRoomMap = {} self.m_pCurGoldFieldId = 0xFFFFFFF -- 俱乐部房间个数表 self.m_pClubRoomCountTable = {} -- 启动BillServer self.m_pBillServerTable = {} local pBillServer = skynet.newservice("billServer") table.insert(self.m_pBillServerTable, pBillServer) skynet.send(pBillServer, "lua", "init", pGameCode) -- 启动reportServer self.m_pReportServerTable = {} local pReportServer = skynet.newservice("reportServer") table.insert(self.m_pReportServerTable, pReportServer) skynet.send(pReportServer, "lua", "init", pGameCode) -- self:onMakeRoomIdList() self:onMakeSixRoomIdList() -- 启动计时器 self.m_pScheduleMgr = require('utils/schedulerMgr') self.m_pScheduleMgr:init() local pCallback = self.onReportOnlineAndPlay self.m_pReportTimer = self.m_pScheduleMgr:register(pCallback, 5 * 60 * 1000, -1, 10 * 1000, self) -- 确保自身数据初始化完毕再开启结点间链接 clusterMonitor:onSubscribeNode(self.onConnectChange) clusterMonitor:onStart(pServerConfig.iClusterConfig) clusterMonitor:onOpen() end function AllocServiceMgr:onMakeSixRoomIdList() self.m_pRoomIdList = {} for i = 100000, 999999 do self.m_pRoomIdList[#self.m_pRoomIdList + 1] = { iRoomId = i, iIsInGame = false, } self.m_pFriendBattleRoomIdMap[i] = { iClusterId = 0, iGameServer = 0, iIndex = 0, } end math.randomseed(tostring(os.time()):reverse():sub(1, 6)) for i = 100000, 999999 do local pIndex1 = math.random(1, #self.m_pRoomIdList) local pIndex2 = math.random(1, #self.m_pRoomIdList) local pTemp = self.m_pRoomIdList[pIndex1] self.m_pRoomIdList[pIndex1] = self.m_pRoomIdList[pIndex2] self.m_pRoomIdList[pIndex2] = pTemp end self.m_pCurRoomIndex = 0 -- Log.dump(TAG, self.m_pRoomIdList, "self.m_pRoomIdList") end function AllocServiceMgr:onCreateOneRoomId(pClusterId, pGameServer, pClubId, pPlayId) while(true) do if self.m_pCurRoomIndex >= #self.m_pRoomIdList then self.m_pCurRoomIndex = 0 end self.m_pCurRoomIndex = self.m_pCurRoomIndex + 1 if self.m_pRoomIdList[self.m_pCurRoomIndex] and not self.m_pRoomIdList[self.m_pCurRoomIndex].iIsInGame then self.m_pRoomIdList[self.m_pCurRoomIndex].iIsInGame = true local pRoomId = self.m_pRoomIdList[self.m_pCurRoomIndex].iRoomId self.m_pFriendBattleRoomIdMap[pRoomId].iPalyId = pPlayId or 0 self.m_pFriendBattleRoomIdMap[pRoomId].iClusterId = pClusterId self.m_pFriendBattleRoomIdMap[pRoomId].iGameServer = pGameServer self.m_pFriendBattleRoomIdMap[pRoomId].iIndex = self.m_pCurRoomIndex if pClubId and pClubId > 0 then if not self.m_pClubRoomCountTable[pClubId] then self.m_pClubRoomCountTable[pClubId] = {} end table.insert(self.m_pClubRoomCountTable[pClubId], pRoomId) end return pRoomId end end end function AllocServiceMgr:onDeleteOneRoomId(pRoomId, pClubId) if pRoomId and self.m_pFriendBattleRoomIdMap[pRoomId] then local pIndex = self.m_pFriendBattleRoomIdMap[pRoomId].iIndex or 0 self.m_pFriendBattleRoomIdMap[pRoomId].iClusterId = 0 self.m_pFriendBattleRoomIdMap[pRoomId].iGameServer = 0 self.m_pFriendBattleRoomIdMap[pRoomId].iIndex = 0 self.m_pFriendBattleRoomIdMap[pRoomId].iPalyId = 0 if pIndex > 0 and self.m_pRoomIdList[pIndex] then if self.m_pRoomIdList[pIndex].iIsInGame then self.m_pRoomIdList[pIndex].iIsInGame = false end end end if pClubId and pClubId > 0 and pRoomId and pRoomId > 0 then if self.m_pClubRoomCountTable[pClubId] and #self.m_pClubRoomCountTable[pClubId] > 0 then for kIndex, kRoomId in pairs(self.m_pClubRoomCountTable[pClubId]) do if pRoomId == kRoomId then table.remove(self.m_pClubRoomCountTable[pClubId], kIndex) break end end end end end function AllocServiceMgr:onGameTableStartGame(pRoomId, pClubId) if pClubId and pClubId > 0 and pRoomId and pRoomId > 0 then if self.m_pClubRoomCountTable[pClubId] and #self.m_pClubRoomCountTable[pClubId] > 0 then for kIndex, kRoomId in pairs(self.m_pClubRoomCountTable[pClubId]) do if pRoomId == kRoomId then table.remove(self.m_pClubRoomCountTable[pClubId], kIndex) break end end end end end function AllocServiceMgr:onCreateOneTableId() self.m_pCurGoldFieldId = self.m_pCurGoldFieldId + 1 if self.m_pCurGoldFieldId == 0x8FFFFFFF then self.m_pCurGoldFieldId = 0xFFFFFFF end return self.m_pCurGoldFieldId end function AllocServiceMgr:onGetClubRoomCount(pClubId, pPlayId) if pClubId and pClubId > 0 then if not pPlayId then return self.m_pClubRoomCountTable[pClubId] and #self.m_pClubRoomCountTable[pClubId] or 0 else local pRoomCount = 0 if not self.m_pClubRoomCountTable[pClubId] then return pRoomCount end for _, kRoomId in pairs(self.m_pClubRoomCountTable[pClubId]) do local kRoomInfo = self.m_pFriendBattleRoomIdMap[kRoomId] if kRoomInfo and kRoomInfo.iPalyId == pPlayId then pRoomCount = pRoomCount + 1 end end return pRoomCount end end return 0 end function AllocServiceMgr:onGetGameServerByRoomId(pRoomId) if pRoomId and self.m_pFriendBattleRoomIdMap[pRoomId] then return self.m_pFriendBattleRoomIdMap[pRoomId].iClusterId, self.m_pFriendBattleRoomIdMap[pRoomId].iGameServer end return nil end function AllocServiceMgr:onPackLookbackTable(pLookbackTable) if self.m_pHallServiceMgr then return pcall(skynet.call, self.m_pHallServiceMgr, "lua", "onPackLookbackTable", pLookbackTable) else Log.e(TAG, "hallservice disconnect error ") end end ---------------------------BillServer------------------------------- function AllocServiceMgr:onGetBillServer() return self.m_pBillServerTable[#self.m_pBillServerTable] end function AllocServiceMgr:onSetLookbackId(pLookbackId) self.m_pLookbackId = pLookbackId or 0 end function AllocServiceMgr:onGetANewLookbackId() self.m_pLookbackId = self.m_pLookbackId + 1 if self.m_pLookbackId < 10000000 then self.m_pLookbackId = 10000000 elseif self.m_pLookbackId >= 99999999 then self.m_pLookbackId = 10000000 end -- 给billserver设置 skynet.send(self:onGetBillServer(), "lua", "onSetLookbackId", self.m_pLookbackId) return self.m_pLookbackId end function AllocServiceMgr:onServerSetBillGoldFieldDetail(pInfoStr) skynet.send(self:onGetBillServer(), "lua", "onServerSetBillGoldFieldDetail", pInfoStr) end function AllocServiceMgr:onServerUpdateOneBattleBillInfo(pBattleId, pInfoStr) skynet.send(self:onGetBillServer(), "lua", "onServerUpdateOneBattleBillInfo", pBattleId, pInfoStr) end function AllocServiceMgr:onServerUserSetBillDetail(pBattleId, pInfoStr) skynet.send(self:onGetBillServer(), "lua", "onServerUserSetBillDetail", pBattleId, pInfoStr) end function AllocServiceMgr:onServerUserSetBillLookback(pLookbackId, pLookbackTable) if pLookbackId and pLookbackTable then local status ,pIsAllOk, pInfoStr = self:onPackLookbackTable(pLookbackTable) Log.d(TAG,"onServerUserSetBillLookback status[%s] pIsAllOk[%s] pInfoStr[%s] ",status ,pIsAllOk, pInfoStr) if status and pIsAllOk then skynet.send(self:onGetBillServer(), "lua", "onServerUserSetBillLookback", pLookbackId, pInfoStr) end end end -------------------------------------------------------------------- ---------------------------reportServer------------------------------ function AllocServiceMgr:onGetReportServer() return self.m_pReportServerTable[#self.m_pReportServerTable] end function AllocServiceMgr:onReportOnlineAndPlay() local pOnlineAndPlay = { iOnlineCount = 0, iPlayCount = 0, iTimeStamp = os.time(), } for k,v in pairs(self.m_pGameServerMgrTable) do local pStatus,pTempOnlineAndPlay = pcall(cluster.call, k, v, "onGetGameServiceOnlineAndPlay") if pStatus then pOnlineAndPlay.iOnlineCount = pOnlineAndPlay.iOnlineCount + pTempOnlineAndPlay.iOnlineCount pOnlineAndPlay.iPlayCount = pOnlineAndPlay.iPlayCount + pTempOnlineAndPlay.iPlayCount end end local pReportServer = self:onGetReportServer() if pReportServer then skynet.send(pReportServer, "lua", "onDealOnlineAndPlay", pOnlineAndPlay) end end ---------------------------------------------------------------------- function AllocServiceMgr:onGameServerDisconnect(pClusterId) for k,v in pairs(self.m_pFriendBattleRoomIdMap) do if v.iClusterId == pClusterId then local pIndex = v.iIndex or 0 v.iClusterId = 0 v.iGameServer = 0 v.iIndex = 0 if pIndex > 0 and self.m_pRoomIdList[pIndex] then if self.m_pRoomIdList[pIndex].iIsInGame then self.m_pRoomIdList[pIndex].iIsInGame = false end end if k and k > 0 then for kClub, kRoomList in pairs(self.m_pClubRoomCountTable) do for kIndex, kRoomId in pairs(kRoomList) do if k == kRoomId then table.remove(self.m_pClubRoomCountTable[kClub], kIndex) break end end end end end end end --------------------------------deal gameserver retire -------------------------------- function AllocServiceMgr:onRetireGameServer(pClusterId) if self.m_pGameServerMgrTable[pClusterId] then local pServerConfig = require(onGetServerConfigFile(self.m_pGameCode)) for k,v in pairs(pServerConfig.iClusterConfig) do if v.nodename == pClusterId then -- 删掉将要退休的结点 pServerConfig.iClusterConfig[k] = nil break end end --reload clusterMonitor:onReLoad(pServerConfig.iClusterConfig) else Log.e(TAG, "onRetireGameServer pClusterId[%s] error", pClusterId) end end --------------------------------------------------------------------------------------- function AllocServiceMgr:onConnectChange( conf ) Log.dump(TAG,conf,"onConnectChange") if conf.isonline == 1 then if conf.servertype == 2 then self.m_pHallServiceMgr = cluster.proxy(conf.nodename, conf.clustername) else self.m_pGameServerMgrTable[conf.nodename] = conf.clustername end else if conf.servertype == 2 then self.m_pHallServiceMgr = nil else self:onGameServerDisconnect(conf.nodename) self.m_pGameServerMgrTable[conf.nodename] = nil end end end function AllocServiceMgr:onMonitorNodeChange(conf) Log.dump(TAG,conf,"onMonitorNodeChange") if not conf then return end if not conf.nodename then return end local callback = clusterMonitor:onGetSubcribeCallback() if not callback then return end return callback(AllocServiceMgr, conf) end function AllocServiceMgr:onReLoad() local modulename = onGetServerConfigFile(self.m_pGameCode) package.loaded[modulename] = nil codecache.clear() local pServerConfig = require(modulename) clusterMonitor:onReLoad(pServerConfig.iClusterConfig) end skynet.start(function() skynet.dispatch("lua", function(_, _, command, ...) Log.d(TAG, "dispatch command[%s]", command ) skynet.ret(skynet.pack(AllocServiceMgr[command](AllocServiceMgr, ...))) end) end)
nilq/small-lua-stack
null
local class = require("common/middleclass") local fw_command = class("fw_command") function fw_command:initialize() end function fw_command:execute(msg) end return fw_command
nilq/small-lua-stack
null
-- =========================================================================== -- Cached Base Functions -- =========================================================================== BASE_CQUI_OnWonderCompleted = OnWonderCompleted; -- =========================================================================== -- CQUI Members -- =========================================================================== BASE_CQUI_LateInitialize = LateInitialize; -- =========================================================================== -- "Modular Screen" mod by Astog -- =========================================================================== function OnAddScreenHook(hookInfo:table) -- print("Build hook") local tButtonEntry:table = {}; ContextPtr:BuildInstanceForControl("HookIconInstance", tButtonEntry, Controls.ButtonStack); local textureOffsetX = hookInfo.IconTexture.OffsetX; local textureOffsetY = hookInfo.IconTexture.OffsetY; local textureSheet = hookInfo.IconTexture.Sheet; -- Update Icon Info if (textureOffsetX ~= nil and textureOffsetY ~= nil and textureSheet ~= nil) then tButtonEntry.Icon:SetTexture(textureOffsetX, textureOffsetY, textureSheet); end if (hookInfo.IconTexture.Color ~= nil) then tButtonEntry.Icon:SetColor(hookInfo.IconTexture.Color); end if (hookInfo.Tooltip ~= nil) then tButtonEntry.Button:SetToolTipString(hookInfo.Tooltip); end textureOffsetX = hookInfo.BaseTexture.OffsetX; textureOffsetY = hookInfo.BaseTexture.OffsetY; textureSheet = hookInfo.BaseTexture.Sheet; local stateOffsetX = hookInfo.BaseTexture.HoverOffsetX; local stateOffsetY = hookInfo.BaseTexture.HoverOffsetY; if (textureOffsetX ~= nil and textureOffsetY ~= nil and textureSheet ~= nil) then tButtonEntry.Base:SetTexture(textureOffsetX, textureOffsetY, textureSheet); if (hookInfo.BaseTexture.Color ~= nil) then tButtonEntry.Base:SetColor(hookInfo.BaseTexture.Color); end -- Setup behaviour on hover if (stateOffsetX ~= nil and stateOffsetY ~= nil) then local OnMouseOver = function() tButtonEntry.Base:SetTextureOffsetVal(stateOffsetX, stateOffsetY); UI.PlaySound("Main_Menu_Mouse_Over"); end local OnMouseExit = function() tButtonEntry.Base:SetTextureOffsetVal(textureOffsetX, textureOffsetY); end tButtonEntry.Button:RegisterMouseEnterCallback( OnMouseOver ); tButtonEntry.Button:RegisterMouseExitCallback( OnMouseExit ); end end if (hookInfo.Callback ~= nil) then tButtonEntry.Button:RegisterCallback( Mouse.eLClick, hookInfo.Callback ); end Realize(); end function LateInitialize() BASE_CQUI_LateInitialize(); LuaEvents.PartialScreenHooks_AddHook.Add( OnAddScreenHook ); -- TESTS ----------------------------- --[[ local hookInfo1:table = { -- ICON TEXTURE IconTexture = { OffsetX = 0; OffsetY = 0; Sheet = "MapPins24.dds"; Color = UI.GetColorValue("COLOR_PLAYER_GOLDENROD") }; -- BUTTON TEXTURE BaseTexture = { OffsetX = 0; OffsetY = 0; Sheet = "LaunchBar_Hook_ButtonSmall"; -- Offset to have when hovering HoverOffsetX = 0; HoverOffsetY = 40; }; Callback = function() print("Damascus steel!") end; Tooltip = "ATTACK!"; }; LuaEvents.PartialScreenHooks_AddHook(hookInfo1); ]]-- end
nilq/small-lua-stack
null
-------------------------------------------------------------------------------- -- -------------------------------------------------------------------------------- RESOURCE_PATH = "" DOCUMENT_PATH = "" ---- Core = {} function Core.init(resourcePath, documentPath) -- seed lua's own random and iterate it over a few passes math.randomseed(os.time()) for i=0,10 do local rand = math.random() end RESOURCE_PATH = resourcePath DOCUMENT_PATH = documentPath IMPORT(Script.CLASS) IMPORT(Script.GAME) IMPORT(Script.UTILS) end Core._imported = {} Core._benchmarkLabel = "" Core._benchmarkTime = 0 ---- Script = {} Script._map = { CLASS = "core/class.lua", GAME = "core/game.lua", BLENDMODE = 'display/blendmode.lua', COLOR = 'display/color.lua', GRAPHICS = 'display/graphics.lua', STAGE = 'display/stage.lua', VIEWOBJECT = 'display/viewobject.lua', VIEWOBJECTCOLLECTION = 'display/viewobjectcollection.lua', TRI = 'draw/tri.lua', POINT = 'geom/point.lua', PENNER = 'transitions/penner.lua', TRANSITION = 'transitions/transition.lua', TWEEN = 'transitions/tweener.lua', TWEENABLES = 'transitions/tweenables.lua', VALUETWEEN = 'transitions/valuetweener.lua', UTILS = 'util/utils.lua', GLOBALS = 'template/globals.lua', TRANSITIONHELPER = 'template/transitionhelper.lua', TRAIN_RADBALL = 'train/radball.lua', TRAIN_GROUP = 'train/group.lua', TRAIN_CURSOR = 'train/cursor.lua', TRAIN_BEATWAVE = 'train/beatwave.lua', TRAIN_DIALOG = 'train/dialog.lua', TRAIN_DIRECTIVE = 'train/directive.lua', TRAIN_PANEL = 'train/panel.lua', TRAIN_METER = 'train/meter.lua', _END_MAP = '_end_map' } Script.CLASS = Script._map.CLASS Script.GAME = Script._map.GAME Script.BLENDMODE = Script._map.BLENDMODE Script.COLOR = Script._map.COLOR Script.GRAPHICS = Script._map.GRAPHICS Script.STAGE = Script._map.STAGE Script.VIEWOBJECT = Script._map.VIEWOBJECT Script.VIEWOBJECTCOLLECTION = Script._map.VIEWOBJECTCOLLECTION Script.TRI = Script._map.TRI Script.POINT = Script._map.POINT Script.PENNER = Script._map.PENNER Script.TRANSITION = Script._map.TRANSITION Script.TWEEN = Script._map.TWEEN Script.TWEENABLES = Script._map.TWEENABLES Script.VALUETWEEN = Script._map.VALUETWEEN Script.UTILS = Script._map.UTILS Script.GLOBALS = Script._map.GLOBALS Script.TRANSITIONHELPER = Script._map.TRANSITIONHELPER Script.TRAIN_RADBALL = Script._map.TRAIN_RADBALL Script.TRAIN_GROUP = Script._map.TRAIN_GROUP Script.TRAIN_CURSOR = Script._map.TRAIN_CURSOR Script.TRAIN_BEATWAVE = Script._map.TRAIN_BEATWAVE Script.TRAIN_DIALOG = Script._map.TRAIN_DIALOG Script.TRAIN_DIRECTIVE = Script._map.TRAIN_DIRECTIVE Script.TRAIN_PANEL = Script._map.TRAIN_PANEL Script.TRAIN_METER = Script._map.TRAIN_METER Script.isValid = function(prop) for k, v in pairs(Script._map) do if (v == prop) then return true end end return false end ---- Import a script into the lua context. Validates, and minimizes redundant imports. function IMPORT(script) if (Script.isValid(script) == false) then LuaBridge.print("Script: '" .. script .. "' is not valid.") return end FORCE_IMPORT(script) end ---- Import a script into the lua context (without validation). function FORCE_IMPORT(script) -- find a better way to do this 'contains key' thing... for i, v in ipairs(Core._imported) do if (script == v) then LuaBridge.print("Script: '" .. script .. "' was already imported.") return end end LuaBridge.print("Importing Script: '" .. script .. "'") table.insert(Core._imported, script) dofile(RESOURCE_PATH .. "skins/levels/common/lua/" .. script) end ---- Print a message, or a generic ping with a timestamp function PRINT(message) if (message == nil) then message = ">> PING " .. os.clock() end LuaBridge.print(message) end ---- Simple inline benchmark function BENCHMARK(label) if (label == nil) then label = Core._benchmarkLabel end local currentTime = os.clock() if (Core._benchmarkTime == 0 or label ~= Core._benchmarkLabel) then PRINT("LUA BENCHMARK: " .. label .. " start time: " .. currentTime) else PRINT("LUA BENCHMARK: " .. label .. " cycle time: " .. currentTime - Core._benchmarkTime) end Core._benchmarkLabel = label Core._benchmarkTime = currentTime end
nilq/small-lua-stack
null
-- Usage -- GETDEL key -- -- Parameters -- Key - string key -- expectedValue - value that you application expects to be stored in key -- -- Operation performed -- Get the value of the key. If expected and stored values are the same -- delete the key. -- -- Returns -- value of key -- error if key does not exist -- -- Author: Pedro Paixao local cmd = 'GETDEL' -- Test parameters if #KEYS ~= 1 then return { err = "Err '" .. cmd .. "' command needs one key. Got " .. #KEYS } end if #ARGV ~= 1 then return { err = "ERR wrong number of arguments for '" .. cmd .. "' command. Usage: " .. cmd.. " key expectedValue" } end local key = KEYS[1] local expected = ARGV[1] -- Test for none in case the key does not exist local type = redis.call('type', key) if type.ok == 'none' then return { err = key .. ' does not exist.' } end if type.ok ~= 'string' then return { err = key .. ' must be a string.' } end -- Get the value local value = redis.call('get', key) if value == expected then -- Delete the key -- Only delete the key if the value matches what the caller expected -- to avoid denial of service attacks where by brute forcing the keys -- someone could delete them and impact other users. redis.call('del', key) else return { err = "Unexpected value" } end -- Nothing more to do... return value
nilq/small-lua-stack
null
local _, private = ... --[[ Lua Globals ]] -- luacheck: globals select ipairs --[[ Core ]] local Aurora = private.Aurora local Base = Aurora.Base local Hook, Skin = Aurora.Hook, Aurora.Skin local Color, Util = Aurora.Color, Aurora.Util do --[[ FrameXML\MailFrame.lua ]] function Hook.MailFrame_UpdateTrialState(self) local isTrialOrVeteran = _G.GameLimitedMode_IsActive() _G.InboxTitleText:SetShown(not isTrialOrVeteran) end function Hook.InboxFrame_Update() local numItems, totalItems = _G.GetInboxNumItems() local index = ((_G.InboxFrame.pageNum - 1) * _G.INBOXITEMS_TO_DISPLAY) + 1 for i = 1, _G.INBOXITEMS_TO_DISPLAY do local name = "MailItem"..i local item = _G[name] if index <= numItems then local _, _, _, _, _, _, _, _, wasRead, _, _, _, _, firstItemQuantity, _, firstItemLink = _G.GetInboxHeaderInfo(index) if not firstItemQuantity then item.Button._auroraIconBorder:SetBackdropBorderColor(Color.frame, 1) end if wasRead then -- We need to call this in case the item is a relic, to ensure that the relic border color is updated. Hook.SetItemButtonQuality(item.Button, private.Enum.ItemQuality.Standard, firstItemLink) end else item.Button._auroraIconBorder:SetBackdropBorderColor(Color.frame, 1) end index = index + 1 end _G.InboxTitleText:SetShown(not (totalItems > numItems)) --MailFrame_UpdateTrialState(_G.MailFrame) end function Hook.SendMailFrame_Update() local numAttachments = 0 for i = 1, _G.ATTACHMENTS_MAX_SEND do local button = _G.SendMailFrame.SendMailAttachments[i] if i == 1 then button:SetPoint("TOPLEFT", _G.SendMailScrollFrame, "BOTTOMLEFT", 3, -10) else if (i % _G.ATTACHMENTS_PER_ROW_SEND) == 1 then button:SetPoint("TOPLEFT", _G.SendMailFrame.SendMailAttachments[i - _G.ATTACHMENTS_PER_ROW_SEND], "BOTTOMLEFT", 23, -9) else button:SetPoint("TOPLEFT", _G.SendMailFrame.SendMailAttachments[i - 1], "TOPRIGHT", 9, 0) end end local icon = button:GetNormalTexture() if icon then Base.CropIcon(icon) end if _G.HasSendMailItem(i) then numAttachments = numAttachments + 1 end end local scrollHeight = 218 if numAttachments >= _G.ATTACHMENTS_PER_ROW_SEND then scrollHeight = 173 end _G.SendMailScrollFrame:SetHeight(scrollHeight) _G.SendMailScrollChildFrame:SetHeight(scrollHeight) end function Hook.OpenMail_Update() if ( not _G.InboxFrame.openMailID ) then return end local _, _, _, _, isInvoice = _G.GetInboxText(_G.InboxFrame.openMailID) if isInvoice then local invoiceType = _G.GetInboxInvoiceInfo(_G.InboxFrame.openMailID) if invoiceType then if invoiceType == "buyer" then _G.OpenMailArithmeticLine:SetPoint("TOP", _G.OpenMailInvoicePurchaser, "BOTTOMLEFT", 125, -5) elseif invoiceType == "seller" then _G.OpenMailArithmeticLine:SetPoint("TOP", _G.OpenMailInvoiceHouseCut, "BOTTOMRIGHT", -114, -22) elseif invoiceType == "seller_temp_invoice" then _G.OpenMailArithmeticLine:SetPoint("TOP", _G.OpenMailInvoicePurchaser, "BOTTOMLEFT", 125, -5) end end end _G.OpenMailAttachmentText:SetPoint("TOPLEFT", _G.OpenMailScrollFrame, "BOTTOMLEFT", 5, -10) for i, button in ipairs(_G.OpenMailFrame.activeAttachmentButtons) do if i == 1 then button:SetPoint("TOPLEFT", _G.OpenMailAttachmentText, "BOTTOMLEFT", -5, -5) else if (i % _G.ATTACHMENTS_PER_ROW_RECEIVE) == 1 then button:SetPoint("TOPLEFT", _G.OpenMailFrame.activeAttachmentButtons[i - _G.ATTACHMENTS_PER_ROW_RECEIVE], "BOTTOMLEFT", 23, -9) else button:SetPoint("TOPLEFT", _G.OpenMailFrame.activeAttachmentButtons[i - 1], "TOPRIGHT", 9, 0) end end end local scrollHeight = 238 if #_G.OpenMailFrame.activeAttachmentButtons >= _G.ATTACHMENTS_PER_ROW_RECEIVE then scrollHeight = 192 end _G.OpenMailScrollFrame:SetHeight(scrollHeight) _G.OpenMailScrollChildFrame:SetHeight(scrollHeight) end end do --[[ FrameXML\MailFrame.xml ]] function Skin.SendMailRadioButtonTemplate(CheckButton) Skin.UIRadioButtonTemplate(CheckButton) end function Skin.MailItemTemplate(Frame) local name = Frame:GetName() local left, right, div = Frame:GetRegions() left:Hide() right:Hide() div:Hide() local button = Frame.Button button:SetPoint("TOPLEFT", 2, -2) button:SetSize(39, 39) _G[name.."ButtonSlot"]:Hide() local bg = _G.CreateFrame("Frame", nil, Frame) bg:SetFrameLevel(button:GetFrameLevel() - 1) bg:SetPoint("TOPLEFT", button, -1, 1) bg:SetPoint("BOTTOMRIGHT", button, 1, -1) Base.CreateBackdrop(bg, { bgFile = [[Interface\PaperDoll\UI-Backpack-EmptySlot]], tile = false, insets = {left = 1, right = 1, top = 1, bottom = 1}, edgeSize = 1, }) Base.CropIcon(bg:GetBackdropTexture("bg")) bg:SetBackdropColor(1, 1, 1, 0.75) bg:SetBackdropBorderColor(Color.frame, 1) button._auroraIconBorder = bg Base.CropIcon(button.Icon) button.Icon:SetPoint("BOTTOMRIGHT") Base.CropIcon(button:GetHighlightTexture()) Base.CropIcon(button:GetCheckedTexture()) end function Skin.SendMailAttachment(Button) Button:GetRegions():Hide() local bg = _G.CreateFrame("Frame", nil, Button) bg:SetFrameLevel(Button:GetFrameLevel() - 1) bg:SetPoint("TOPLEFT", -1, 1) bg:SetPoint("BOTTOMRIGHT", 1, -1) Base.CreateBackdrop(bg, { bgFile = [[Interface\PaperDoll\UI-Backpack-EmptySlot]], tile = false, insets = {left = 1, right = 1, top = 1, bottom = 1}, edgeSize = 1, }) Base.CropIcon(bg:GetBackdropTexture("bg")) bg:SetBackdropColor(1, 1, 1, 0.75) bg:SetBackdropBorderColor(Color.frame, 1) Button._auroraIconBorder = bg Base.CropIcon(Button:GetHighlightTexture()) end function Skin.OpenMailAttachment(ItemButton) Skin.FrameTypeItemButton(ItemButton) end --[[ Fake template ]]-- function Skin.SendMailInputBox(EditBox) Skin.FrameTypeEditBox(EditBox) EditBox:SetHeight(22) local name = EditBox:GetName() _G[name.."Left"]:Hide() _G[name.."Middle"]:Hide() _G[name.."Right"]:Hide() local bg = EditBox:GetBackdropTexture("bg") bg:SetPoint("TOPLEFT", -8, -1) bg:SetPoint("BOTTOMRIGHT", 8, 1) end end function private.FrameXML.MailFrame() _G.hooksecurefunc("MailFrame_UpdateTrialState", Hook.MailFrame_UpdateTrialState) _G.hooksecurefunc("InboxFrame_Update", Hook.InboxFrame_Update) _G.hooksecurefunc("SendMailFrame_Update", Hook.SendMailFrame_Update) _G.hooksecurefunc("OpenMail_Update", Hook.OpenMail_Update) --------------- -- MailFrame -- --------------- Skin.ButtonFrameTemplate(_G.MailFrame) -- BlizzWTF: The portrait in the template is not being used. if private.isRetail then _G.select(6, _G.MailFrame:GetRegions()):Hide() else _G.select(18, _G.MailFrame:GetRegions()):Hide() end _G.MailFrame.trialError:ClearAllPoints() _G.MailFrame.trialError:SetPoint("TOPLEFT", _G.MailFrame.TitleText, 50, -5) _G.MailFrame.trialError:SetPoint("BOTTOMRIGHT", _G.MailFrame.TitleText, -50, -6) ---------------- -- InboxFrame -- ---------------- _G.InboxFrame:SetPoint("BOTTOMRIGHT") _G.InboxFrameBg:Hide() _G.InboxTitleText:ClearAllPoints() _G.InboxTitleText:SetAllPoints(_G.MailFrame.TitleText) _G.InboxTooMuchMail:ClearAllPoints() _G.InboxTooMuchMail:SetAllPoints(_G.MailFrame.trialError) for index = 1, _G.INBOXITEMS_TO_DISPLAY do local name = "MailItem"..index local item = _G[name] Skin.MailItemTemplate(item) if index == 1 then item:SetPoint("TOPLEFT", 13, -(private.FRAME_TITLE_HEIGHT + 5)) else item:SetPoint("TOPLEFT", _G["MailItem"..(index - 1)], "BOTTOMLEFT", 0, -7) end end Skin.NavButtonPrevious(_G.InboxPrevPageButton) _G.InboxPrevPageButton:ClearAllPoints() _G.InboxPrevPageButton:SetPoint("BOTTOMLEFT", 14, 10) Skin.NavButtonNext(_G.InboxNextPageButton) _G.InboxNextPageButton:ClearAllPoints() _G.InboxNextPageButton:SetPoint("BOTTOMRIGHT", -17, 10) Skin.UIPanelButtonTemplate(_G.OpenAllMail) _G.OpenAllMail:ClearAllPoints() _G.OpenAllMail:SetPoint("BOTTOM", 0, 14) ------------------- -- SendMailFrame -- ------------------- _G.SendMailFrame:SetPoint("BOTTOMRIGHT") _G.SendMailTitleText:ClearAllPoints() _G.SendMailTitleText:SetAllPoints(_G.MailFrame.TitleText) for i = 4, 7 do select(i, _G.SendMailFrame:GetRegions()):Hide() end Skin.UIPanelScrollFrameTemplate(_G.SendMailScrollFrame) _G.SendMailScrollFrame:SetPoint("TOPLEFT", 10, -83) _G.SendMailScrollFrame:SetWidth(298) _G.SendStationeryBackgroundLeft:Hide() _G.SendStationeryBackgroundRight:Hide() _G.SendScrollBarBackgroundTop:Hide() select(4, _G.SendMailScrollFrame:GetRegions()):Hide() -- SendScrollBarBackgroundBottom local sendScrollBG = _G.CreateFrame("Frame", nil, _G.SendMailScrollFrame) sendScrollBG:SetFrameLevel(_G.SendMailScrollFrame:GetFrameLevel() - 1) sendScrollBG:SetPoint("TOPLEFT", 0, 2) sendScrollBG:SetPoint("BOTTOMRIGHT", 20, -2) Base.SetBackdrop(sendScrollBG, Color.frame) _G.SendMailScrollChildFrame:SetSize(298, 257) _G.SendMailBodyEditBox:SetPoint("TOPLEFT", 2, -2) _G.SendMailBodyEditBox:SetWidth(298) -- BlizzWTF: these should use InputBoxTemplate Skin.SendMailInputBox(_G.SendMailNameEditBox) Skin.SmallMoneyFrameTemplate(_G.SendMailCostMoneyFrame) _G.SendMailCostMoneyFrame:SetPoint("TOPRIGHT", -5, -34) Skin.SendMailInputBox(_G.SendMailSubjectEditBox) for i = 1, _G.ATTACHMENTS_MAX_SEND do Skin.SendMailAttachment(_G.SendMailFrame.SendMailAttachments[i]) end _G.SendMailMoneyButton:SetPoint("BOTTOMLEFT", 15, 38) _G.SendMailMoneyButton:SetSize(31, 31) _G.SendMailMoneyText:SetPoint("TOPLEFT", _G.SendMailMoneyButton) Skin.MoneyInputFrameTemplate(_G.SendMailMoney) _G.SendMailMoney:ClearAllPoints() _G.SendMailMoney:SetPoint("BOTTOMLEFT", _G.SendMailMoneyButton, 5, 0) Skin.SendMailRadioButtonTemplate(_G.SendMailSendMoneyButton) Skin.SendMailRadioButtonTemplate(_G.SendMailCODButton) Skin.InsetFrameTemplate(_G.SendMailMoneyInset) Skin.ThinGoldEdgeTemplate(_G.SendMailMoneyBg) _G.SendMailMoneyBg:SetPoint("TOPRIGHT", _G.SendMailFrame, "BOTTOMLEFT", 165, 27) _G.SendMailMoneyBg:SetPoint("BOTTOMLEFT", 5, 5) Skin.SmallMoneyFrameTemplate(_G.SendMailMoneyFrame) _G.SendMailMoneyFrame:SetPoint("BOTTOMRIGHT", _G.SendMailMoneyBg, 7, 5) Skin.UIPanelButtonTemplate(_G.SendMailCancelButton) Skin.UIPanelButtonTemplate(_G.SendMailMailButton) Util.PositionRelative("BOTTOMRIGHT", _G.SendMailFrame, "BOTTOMRIGHT", -5, 5, 1, "Left", { _G.SendMailCancelButton, _G.SendMailMailButton, }) _G.SendMailFrameLockSendMail:SetPoint("TOPLEFT", "SendMailAttachment1", -12, 12) _G.SendMailFrameLockSendMail:SetPoint("BOTTOMRIGHT", "SendMailCancelButton", 5, -5) ------------------- -- OpenMailFrame -- ------------------- Skin.ButtonFrameTemplate(_G.OpenMailFrame) _G.OpenMailFrame:SetPoint("TOPLEFT", _G.InboxFrame, "TOPRIGHT", 5, 0) _G.OpenMailFrameIcon:Hide() _G.OpenMailTitleText:ClearAllPoints() _G.OpenMailTitleText:SetAllPoints(_G.OpenMailFrame.TitleText) _G.OpenMailHorizontalBarLeft:Hide() if private.isRetail then select(13, _G.OpenMailFrame:GetRegions()):Hide() -- HorizontalBarRight else select(25, _G.OpenMailFrame:GetRegions()):Hide() -- HorizontalBarRight end Skin.UIPanelButtonTemplate(_G.OpenMailReportSpamButton) Skin.UIPanelScrollFrameTemplate(_G.OpenMailScrollFrame) _G.OpenMailScrollFrame:SetPoint("TOPLEFT", 10, -83) _G.OpenMailScrollFrame:SetWidth(298) _G.OpenScrollBarBackgroundTop:Hide() select(2, _G.OpenMailScrollFrame:GetRegions()):Hide() -- OpenScrollBarBackgroundBottom _G.OpenStationeryBackgroundLeft:Hide() _G.OpenStationeryBackgroundRight:Hide() local openScrollBG = _G.CreateFrame("Frame", nil, _G.OpenMailScrollFrame) openScrollBG:SetFrameLevel(_G.OpenMailScrollFrame:GetFrameLevel() - 1) openScrollBG:SetPoint("TOPLEFT", 0, 2) openScrollBG:SetPoint("BOTTOMRIGHT", 20, -2) Base.SetBackdrop(openScrollBG, Color.frame) _G.OpenMailScrollChildFrame:SetSize(298, 257) _G.OpenMailBodyText:SetPoint("TOPLEFT", 2, -2) _G.OpenMailBodyText:SetWidth(298) _G.OpenMailArithmeticLine:SetColorTexture(Color.grayLight:GetRGB()) _G.OpenMailArithmeticLine:SetSize(256, 1) _G.OpenMailInvoiceAmountReceived:SetPoint("TOPRIGHT", _G.OpenMailArithmeticLine, "BOTTOMRIGHT", -14, -5) Skin.FrameTypeItemButton(_G.OpenMailLetterButton) for i = 1, _G.ATTACHMENTS_MAX_RECEIVE do Skin.OpenMailAttachment(_G.OpenMailFrame.OpenMailAttachments[i]) end Skin.FrameTypeItemButton(_G.OpenMailMoneyButton) Skin.UIPanelButtonTemplate(_G.OpenMailCancelButton) Skin.UIPanelButtonTemplate(_G.OpenMailDeleteButton) Skin.UIPanelButtonTemplate(_G.OpenMailReplyButton) Util.PositionRelative("BOTTOMRIGHT", _G.OpenMailFrame, "BOTTOMRIGHT", -5, 5, 1, "Left", { _G.OpenMailCancelButton, _G.OpenMailDeleteButton, _G.OpenMailReplyButton, }) Skin.FriendsFrameTabTemplate(_G.MailFrameTab1) Skin.FriendsFrameTabTemplate(_G.MailFrameTab2) Util.PositionRelative("TOPLEFT", _G.MailFrame, "BOTTOMLEFT", 20, -1, 1, "Right", { _G.MailFrameTab1, _G.MailFrameTab2, }) end
nilq/small-lua-stack
null
require('bufferline').setup({ options = { numbers = function (opts) return opts.ordinal end, -- LSP diagnostics diagnostics = "nvim_lsp", diagnostics_indicator = function(count, level, diagnostics_dict, context) local s = " " for e, n in pairs(diagnostics_dict) do local sym = e == "error" and " " or (e == "warning" and " " or "ⓘ" ) s = s .. n .. sym end return s end, enforce_regular_tabs = true, always_show_bufferline = true, separator_style = 'slant', show_tab_indicators = true, offsets = { { filetype = 'NvimTree', text = 'File explorer', highlight = 'Directory', text_align = 'left' } } } })
nilq/small-lua-stack
null
local customCommandHooks = {} local specialCharacter = "/" customCommandHooks.commands = {} customCommandHooks.aliases = {} customCommandHooks.rankRequirement = {} customCommandHooks.nameRequirement = {} function customCommandHooks.registerCommand(cmd, callback) customCommandHooks.commands[cmd] = callback end function customCommandHooks.registerAlias(alias, cmd) customCommandHooks.aliases[alias] = cmd end function customCommandHooks.removeCommand(cmd) customCommandHooks.commands[cmd] = nil customCommandHooks.rankRequirement[cmd] = nil customCommandHooks.nameRequirement[cmd] = nil end function customCommandHooks.getCallback(cmd) return customCommandHooks.commands[cmd] end function customCommandHooks.setRankRequirement(cmd, rank) if customCommandHooks.commands[cmd] ~= nil then customCommandHooks.rankRequirement[cmd] = rank end end function customCommandHooks.removeRankRequirement(cmd) customCommandHooks.rankRequirement[cmd] = nil end function customCommandHooks.setNameRequirement(cmd, names) if customCommandHooks.commands[cmd] ~= nil then customCommandHooks.nameRequirement[cmd] = names end end function customCommandHooks.addNameRequirement(cmd, name) if customCommandHooks.commands[cmd] ~= nil then if customCommandHooks.nameRequirement[cmd] == nil then customCommandHooks.nameRequirement[cmd] = {} end table.insert(customCommandHooks.nameRequirement[cmd], name) end end function customCommandHooks.removeNameRequirement(cmd) customCommandHooks.nameRequirement[cmd] = nil end function customCommandHooks.checkName(cmd, pid) return customCommandHooks.nameRequirement[cmd] == nil or tableHelper.containsValue(customCommandHooks.nameRequirement[cmd], Players[pid].accountName) end function customCommandHooks.checkRank(cmd, pid) return customCommandHooks.rankRequirement[cmd] == nil or Players[pid].data.settings.staffRank >= customCommandHooks.rankRequirement[cmd] end function customCommandHooks.invalidCommand(pid) local message = "Not a valid command. Type /help for more info.\n" tes3mp.SendMessage(pid, color.Error .. message .. color.Default, false) end function customCommandHooks.emptyCommand(pid) local message = "Please use a command after the / symbol.\n" tes3mp.SendMessage(pid, color.Error .. message .. color.Default, false) end function customCommandHooks.mergeQuotedArguments(cmd) local merged = {} local quoted = {} local quotedStatus = false for i, chunk in ipairs(cmd) do if not quotedStatus and chunk:sub(1, 1) == '"' then quotedStatus = true chunk = chunk:sub(2, -1) end if quotedStatus and chunk:sub(-1, -1) == '"' then chunk = chunk:sub(1, -2) table.insert(quoted, chunk) table.insert(merged, table.concat(quoted)) quoted = {} quotedStatus = false elseif quotedStatus then table.insert(quoted, chunk .. " ") else table.insert(merged, chunk) end end return merged end function customCommandHooks.validator(eventStatus, pid, message) if eventStatus.validDefaultHandler then if message:sub(1,1) == specialCharacter then local cmd = (message:sub(2, #message)):split(" ") if cmd[1] == nil then customCommandHooks.emptyCommand(pid) return customEventHooks.makeEventStatus(false, nil) else cmd[1] = string.lower(cmd[1]) local callback = customCommandHooks.getCallback(cmd[1]) local alias = customCommandHooks.aliases[cmd[1]] if callback == nil and alias ~= nil then callback = customCommandHooks.getCallback(alias) end if callback ~= nil then local passedRequirements = customCommandHooks.checkName(cmd[1], pid) and customCommandHooks.checkRank(cmd[1], pid) if passedRequirements then callback(pid, customCommandHooks.mergeQuotedArguments(cmd), cmd) else customCommandHooks.invalidCommand(pid) end return customEventHooks.makeEventStatus(false, nil) end end end end end customEventHooks.registerValidator("OnPlayerSendMessage", customCommandHooks.validator) return customCommandHooks
nilq/small-lua-stack
null
-- Test file to demonstrate Lua fold machinery incorrect behavior, details: -- https://github.com/LuaJIT/LuaJIT/issues/505 jit.opt.start("hotloop=1", 'jitcat', 'jitstr') for _ = 1, 20 do local value = "abc" local pos_c = string.find(value, "c", 1, true) local value2 = string.sub(value, 1, pos_c - 1) local pos_b = string.find(value2, "b", 2, true) assert(pos_b == 2, "FAIL: position of 'b' is " .. pos_b) end
nilq/small-lua-stack
null
----------------------------------------------------------------------------------------- -- -- helper.lua -- ----------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------- -- CONSTANTS ----------------------------------------------------------------------------------------- local base_score = 10 local json = require 'json' local M = { -- set to false when building for release DEBUG = false, BASE_WIDTH = 320, BASE_HEIGHT = 480, CONTENT_WIDTH = display.actualContentWidth, CONTENT_HEIGHT = display.actualContentHeight, SMALL_FACTOR = .75, TIME_FACTOR = 1000, -- set to 250 for faster testing touch_enabled = true, -- TODO: rename to something more appropriate current_level = 1, levels = { 1, 2, 7, 8, 13, 14, 3, 4, 9, 10, 15, 16, 5, 6, 11, 12, 17, 18, }, level_targets = { 1, 1, 4, 4, 7, 7, 2, 2, 5, 5, 8, 8, 3, 3, 6, 6, 9, 9, }, score = 0, } function M.p(...) if M.DEBUG then print(unpack(arg)) end end function M.get_file(filename, base) if not base then base = system.ResourceDirectory; end local path = system.pathForFile(filename, base) local contents local file = io.open(path, 'r') if file then contents = file:read('*a') io.close(file) -- close the file after using it else assert(filename .. ' not found') end return contents end local function get_user_settings() local base = system.DocumentsDirectory local path = system.pathForFile('settings.json', base) local contents local file = io.open(path, 'r') if file then contents = file:read('*a') io.close(file) -- close the file after using it else contents = M.get_file('settings.json') file = io.open(path, 'w') file:write( contents ) io.close( file ) end M.settings = json.decode(contents) end get_user_settings() -- mute/unmute if M.settings.is_mute then audio.setVolume(0) end -- check for new properties if M.settings.timed_current_score == nil then M.settings.timed_current_score = 0 end function M.save_user_settings() local base = system.DocumentsDirectory local path = system.pathForFile('settings.json', base) local contents = json.encode( M.settings ) local file = io.open(path, 'w') file:write( contents ) io.close(file) end function M.max_shapes() return M.current_level + 1 end function M.scale_delta(width, height) return (width / height) * .85 end function M.scale_factor() return 1.0 end function M.shuffle_table(t) for i = #t, 2, -1 do local j = math.random(i) t[i], t[j] = t[j], t[i] end end function M.reduce_score() if M.score > 1 then M.score = M.score - 1 end end function M.reset_score(current_level) current_level = current_level or M.current_level level = M.levels[current_level] local multiplier = M.level_targets[level] M.score = base_score * multiplier end function M.stars() local level = M.levels[M.current_level] local multiplier = M.level_targets[level] local perfect_score = base_score * multiplier local percent = M.score / perfect_score if percent >= .98 then stars = 3 elseif percent >= .92 then stars = 2 else stars = 1 end return stars end function M.targets_remaining() return M.level_targets[M.levels[M.current_level]] end return M
nilq/small-lua-stack
null
--- MaterialField module. SB.Include(SB_VIEW_FIELDS_DIR .. "asset_field.lua") --- MaterialField class. -- @type MaterialField MaterialField = AssetField:extends{} --- MaterialField constructor. -- @function MaterialField() -- @see asset_field.AssetField -- @tparam table opts Table -- @usage --function MaterialField:init(field) end function MaterialField:GetCaption() local fname = Path.ExtractFileName(self.value.diffuse or "") local index = fname:find("_diffuse") if index then local texName = fname:sub(1, fname:find("_diffuse") - 1) return texName else return "" end end function MaterialField:GetPath() return self.value.diffuse end function MaterialField:MakePickerWindow(tbl) return MaterialPickerWindow(tbl) end
nilq/small-lua-stack
null
local assets = { Asset("ANIM", "anim/glasshammer.zip"), } local function onattack_moonglass(inst, attacker, target) inst.components.weapon.attackwear = target and target:IsValid() and (target:HasTag("shadow") or target:HasTag("shadowminion") or target:HasTag("shadowchesspiece") or target:HasTag("stalker") or target:HasTag("stalkerminion")) and TUNING.MOONGLASSHAMMER.SHADOW_WEAR or TUNING.MOONGLASSHAMMER.ATTACKWEAR end local function onequip(inst, owner) owner.AnimState:OverrideSymbol("swap_object", "glasshammer", "swap_glasshammer") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end local function onunequip(inst, owner) owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank("glasshammer") inst.AnimState:SetBuild("glasshammer") inst.AnimState:PlayAnimation("idle") inst:AddTag("hammer") MakeInventoryFloatable(inst, "med", 0.05, {0.7, 0.4, 0.7}, true, -13, {sym_build = "glasshammer", sym_name = "swap_glasshammer",bank = "glasshammer"}) --tool (from tool component) added to pristine state for optimization inst:AddTag("tool") --weapon (from weapon component) added to pristine state for optimization inst:AddTag("weapon") inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("weapon") inst.components.weapon:SetDamage(TUNING.MOONGLASSHAMMER.DAMAGE) inst.components.weapon:SetOnAttack(onattack_moonglass) inst:AddComponent("inventoryitem") inst:AddComponent("tool") inst.components.tool:SetAction(ACTIONS.HAMMER, TUNING.MOONGLASSHAMMER.EFFECTIVENESS) inst:AddComponent("finiteuses") inst.components.finiteuses:SetMaxUses(TUNING.MOONGLASSHAMMER.USES) inst.components.finiteuses:SetUses(TUNING.MOONGLASSHAMMER.USES) inst.components.finiteuses:SetOnFinished(inst.Remove) inst.components.finiteuses:SetConsumption(ACTIONS.HAMMER, TUNING.MOONGLASSHAMMER.CONSUMPTION) MakeHauntableLaunch(inst) inst:AddComponent("inspectable") inst:AddComponent("equippable") inst.components.equippable:SetOnEquip(onequip) inst.components.equippable:SetOnUnequip(onunequip) return inst end return Prefab("moonglasshammer", fn, assets)
nilq/small-lua-stack
null
InputEvent = {} ---@type number InputEvent.Released = 1 ---@type number InputEvent.Pressed = 0
nilq/small-lua-stack
null
local Indicator = require'skkeleton_indicator.indicator' local snake_case_dict = require'skkeleton_indicator.util'.snake_case_dict local M = {} function M.setup(opts) M.instance = Indicator.new( snake_case_dict( vim.tbl_extend('keep', opts or {}, { moduleName = 'skkeleton_indicator', eijiHlName = 'SkkeletonIndicatorEiji', hiraHlName = 'SkkeletonIndicatorHira', kataHlName = 'SkkeletonIndicatorKata', hankataHlName = 'SkkeletonIndicatorHankata', zenkakuHlName = 'SkkeletonIndicatorZenkaku', eijiText = '英字', hiraText = 'ひら', kataText = 'カタ', hankataText = '半カタ', zenkakuText = '全英', alwaysShown = true, fadeOutMs = 3000, ignoreFt = {}, bufFilter = function() return true end, }) ) ) end return M
nilq/small-lua-stack
null
local Ship = {} local img, pos, rotation,quad = nil, {}, 0 local elapsedTime, framerate = 0, 15/1000 local Bullet = require 'model.bullet' function Ship:new(nick) local o = {} setmetatable(o, self) self.__index = self self.vel = 1 -- self.rotation = 0 o.nick = nick o.bullets = { Bullet:new(), Bullet:new(), Bullet:new(), Bullet:new(), Bullet:new() } o.nextBullet = 1 return o end function Ship:setImage(imgSrc) self.img = lg.newImage(imgSrc) self.quad = lg.newQuad(0,0,16,16, self.img:getDimensions()) end -- function Ship.move(x, y) -- pos.x = pos.x + x -- pos.y = pos.y + y -- end function Ship:setposition(x, y) self.x = x self.y = y end function Ship:update(t) if self.rotation then self.x = self.x + ( math.cos(self.rotation) * self.vel) self.y = self.y + ( math.sin(self.rotation) * self.vel) end for i=1, #self.bullets do self.bullets[i]:update(t) end end function Ship:setrotation(r) -- print("set rotation " .. r) self.rotation = r end function Ship:setnick(nick) self.nick = nick end function Ship:shoot() print('Ship mousereleased') self.bullets[self.nextBullet]:shoot(self.x, self.y, self.rotation) self.nextBullet = self.nextBullet + 1 if self.nextBullet > #self.bullets then self.nextBullet = 1 end end function Ship:draw() for i=1, #self.bullets do self.bullets[i]:draw() end love.graphics.draw(self.img, self.quad, self.x, self.y, self.rotation, 1,1, 8,8) love.graphics.print(self.nick, self.x - (self.nick:len()/2)*10, self.y + 10) end return Ship
nilq/small-lua-stack
null
local helper = require("filetypext.lib.testlib.helper") local filetypext = helper.require("filetypext") describe("filetypext", function() before_each(helper.before_each) after_each(helper.after_each) for _, c in ipairs({ { ctx = { filetype = "python" }, expected = { "scratch.py" } }, { ctx = { filetype = "make" }, expected = { "Makefile", "scratch.mk" } }, { ctx = { filetype = "make" }, opts = { mapping = { make = { "%s.mk" } } }, expected = { "scratch.mk" } }, { ctx = { filetype = "go" }, expected = { "scratch.go" } }, { ctx = {}, expected = { "scratch.md" } }, { expected = { "scratch.md" } }, { opts = { base_name = "test" }, expected = { "test.md" } }, }) do local ctx = vim.inspect(c.ctx, { newline = "", indent = "" }) local opts = vim.inspect(c.opts, { newline = "", indent = "" }) local expected = vim.inspect(c.expected, { newline = "", indent = "" }) local case_name = ([[detect(%s, %s) == %s]]):format(ctx, opts, expected) it(case_name, function() local actual = filetypext.detect(c.ctx, c.opts) assert.is_same(c.expected, actual) end) end for _, c in ipairs({ { ctx = { bufnr = 0 }, expected = { "scratch.py" }, filetype = "python" }, { ctx = { bufnr = 0, filetype = "go" }, expected = { "scratch.go" }, filetype = "python" }, { ctx = { bufnr = 0 }, expected = { "scratch.md" }, filetype = "" }, { ctx = { bufnr = 0 }, opts = { fallback_filetype = "text" }, expected = { "scratch.txt" }, filetype = "", }, }) do local ctx = vim.inspect(c.ctx, { newline = "", indent = "" }) local opts = vim.inspect(c.opts, { newline = "", indent = "" }) local expected = vim.inspect(c.expected, { newline = "", indent = "" }) local case_name = ([[detect(%s, %s) == %s if filetype == `%s`]]):format(ctx, opts, expected, c.filetype) it(case_name, function() vim.bo.filetype = c.filetype local actual = filetypext.detect(c.ctx, c.opts) assert.is_same(c.expected, actual) end) end end)
nilq/small-lua-stack
null
Debug = {} Debug.MaxBinCount = 512 if USE_NETWORK_PLUGIN then debugPlugin = Sushi.LoadPlugin( "SuNetworkDebugPlugin"..ComputePluginSuffix() ) if debugPlugin == nil then error("Debug plugin load failed") else debugPlugin:SetNumMsgPerFrame(100) --debugPlugin:StartWebServer("../html"); debugPlugin:StartTCPIPServer() print("Debug plugin loaded.") end end function Initialize() DebugBuffer = {} DebugBuffer.StructCount = 10 + Debug.MaxBinCount DebugBuffer.Buffer = Sushi.CreateStructuredBuffer { Name="DebugBuffer", StructSize = 4, StructCount = DebugBuffer.StructCount, Fetchable = true, UnorderedAccess = true, NumMaxStagingBuffers = 10 } if not DebugBuffer.Buffer then error( "Unable to create Debug Buffer" ) end DebugBuffer.ClearBuffer = SuMemoryBuffer:Allocate( DebugBuffer.StructCount * 4 ) tolua.takeownership(DebugBuffer.ClearBuffer) for i = 0,DebugBuffer.StructCount-1 do DebugBuffer.ClearBuffer:SetUINT32(0, i, 0) end end function Debug.Clear() DebugBuffer.Buffer:Transition( SuGPUResource.STATE_UNORDERED_ACCESS, SuGPUResource.STATE_COPY_DEST ) DebugBuffer.Buffer:UpdateBufferRange( DebugBuffer.ClearBuffer, 0, DebugBuffer.StructCount ) DebugBuffer.Buffer:Transition( SuGPUResource.STATE_COPY_DEST, SuGPUResource.STATE_UNORDERED_ACCESS ) end function Debug.DebugValues() local readbackPtr = DebugBuffer.Buffer:ReadbackBuffer() local readback = readbackPtr:get() local PixelCount = readback:GetUINT32(0,0) print("pixels = ", PixelCount) local FragmentCount = readback:GetUINT32(0,1) print("fragment count=",FragmentCount) local TailFragmentCount = readback:GetUINT32(0,2) print("tail fragment count=",TailFragmentCount) local MaxFragmentCount = readback:GetUINT32(0,3) print("max fragment count=", MaxFragmentCount) local EarlyRejects = readback:GetUINT32(0,4) print("Early Rejects=", EarlyRejects) local binOffset = 10 -- if DisplayModes[iDisplayMode]=="CountFragments" then -- for i = 1, math.min(Debug.MaxBinCount, MaxFragmentCount) do -- local binCount = readback:GetUINT32(0,binOffset + i - 1) -- print("bin",i,binCount) -- end -- end end function KarlPrint(a) if Sushi.Config.Karl then print(a) end end
nilq/small-lua-stack
null
-- GENERATED CODE -- Node Box Editor, version 0.9.0 position1 = nil position2 = nil minetest.register_node("scifi_nodes:alienslope", { description = "Alien Platform", tiles = { "scifi_nodes_alnslp_top2.png", "scifi_nodes_alnslp_top.png", "scifi_nodes_alnslp.png", "scifi_nodes_alnslp.png", "scifi_nodes_alnslp_top.png", "scifi_nodes_alnslp_top.png" }, drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", groups = {cracky=1}, node_box = { type = "fixed", fixed = { {0, -0.5, -0.5, 0.5, 0.5, 0.5}, -- NodeBox10 {-0.5, -0.5, -0.5, 0, -0.25, 0.5}, -- NodeBox11 {-0.4375, -0.25, -0.5, 0, -0.125, 0.5}, -- NodeBox12 {-0.375, -0.125, -0.5, 0, 0, 0.5}, -- NodeBox13 {-0.3125, 0, -0.5, 0, 0.125, 0.5}, -- NodeBox14 {-0.25, 0.125, -0.5, 0, 0.25, 0.5}, -- NodeBox15 {-0.1875, 0.25, -0.5, 0.0625, 0.375, 0.5}, -- NodeBox16 {-0.125, 0.375, -0.5, 0.5, 0.5, 0.5}, -- NodeBox17 } }, sounds = default.node_sound_wood_defaults(), on_place = minetest.rotate_node }) minetest.register_node("scifi_nodes:wallpipe", { description = "Alien wall pipe", tiles = { "scifi_nodes_wallpipe.png", "scifi_nodes_wallpipe.png", "scifi_nodes_wallpipe.png", "scifi_nodes_wallpipe.png", "scifi_nodes_wallpipe.png", "scifi_nodes_wallpipe.png" }, drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", groups = {cracky=1}, node_box = { type = "fixed", fixed = { {-0.5, -0.5, 0.125, 0.5, 0.5, 0.5}, -- NodeBox18 {-0.1875, -0.5, -0.0625, 0.1875, 0.5, 0.125}, -- NodeBox19 {-0.125, -0.5, -0.125, 0.125, 0.5, 0.125}, -- NodeBox20 {0.3125, -0.5, 0.0625, 0.4375, 0.5, 0.125}, -- NodeBox21 {-0.4375, -0.5, 0.0625, -0.3125, 0.5, 0.125}, -- NodeBox22 {-0.5, 0.0625, 0, 0.5, 0.1875, 0.0625}, -- NodeBox23 {-0.5, -0.125, 0, 0.5, 0, 0.0625}, -- NodeBox24 } }, sounds = default.node_sound_wood_defaults() }) minetest.register_node("scifi_nodes:plant_trap", { description = "Hanging Trap Plant", tiles = { "scifi_nodes_traplant_top.png", "scifi_nodes_traplant_side.png", "scifi_nodes_traplant_side.png", "scifi_nodes_traplant_side.png", "scifi_nodes_traplant_side.png", "scifi_nodes_traplant_side.png" }, drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", light_source = 5, walkable = false, sunlight_propagates = false, groups = {snappy=1, oddly_breakable_by_hand=1}, node_box = { type = "fixed", fixed = { {-0.125, -0.4375, -0.125, 0.125, 0.125, 0.125}, -- NodeBox25 {-0.1875, 0.125, -0.1875, 0.1875, 0.1875, 0.1875}, -- NodeBox26 {-0.0625, -0.5, -0.0625, 0, -0.4375, 0.375}, -- NodeBox27 {-0.0625, -0.5, 0.3125, 0, 0.5, 0.375}, -- NodeBox28 } }, sounds = default.node_sound_wood_defaults(), }) minetest.register_node("scifi_nodes:egg", { description = "Alien Egg", tiles = { "scifi_nodes_egg_top.png", "scifi_nodes_egg_top.png", "scifi_nodes_egg_side.png", "scifi_nodes_egg_side.png", "scifi_nodes_egg_side.png", "scifi_nodes_egg_side.png" }, sunlight_propagates = false, drawtype = "nodebox", paramtype = "light", groups = {cracky=1, oddly_breakable_by_hand=1, dig_immediate=2, falling_node=1}, light_source = 5, node_box = { type = "fixed", fixed = { {-0.25, -0.5, -0.25, 0.25, -0.4375, 0.25}, -- NodeBox1 {-0.375, -0.4375, -0.375, 0.375, -0.3125, 0.375}, -- NodeBox2 {-0.4375, -0.3125, -0.375, 0.4375, 0.3125, 0.375}, -- NodeBox3 {-0.375, 0.3125, -0.375, 0.375, 0.4375, 0.375}, -- NodeBox4 {-0.3125, 0.4375, -0.3125, 0.3125, 0.5625, 0.3125}, -- NodeBox5 {-0.25, 0.5625, -0.25, 0.25, 0.6875, 0.25}, -- NodeBox6 {-0.1875, 0.6875, -0.1875, 0.1875, 0.75, 0.1875}, -- NodeBox7 {-0.125, 0.75, -0.125, 0.125, 0.8125, 0.125}, -- NodeBox8 {-0.375, -0.3125, -0.4375, 0.375, 0.3125, 0.4375}, -- NodeBox9 }, sounds = default.node_sound_wood_defaults() } }) if minetest.get_modpath("scifi_mobs") then minetest.register_abm({ nodenames = {"scifi_nodes:egg"}, interval = 30, chance = 10, action = function(pos, node, _, _) minetest.env:add_entity(pos, "scifi_mobs:xenomorph") minetest.env:remove_node(pos) end }) end minetest.register_node("scifi_nodes:pad", { description = "teleport pad", tiles = { "scifi_nodes_pad.png", "scifi_nodes_pad.png", "scifi_nodes_pad.png", "scifi_nodes_pad.png", "scifi_nodes_pad.png", "scifi_nodes_pad.png" }, drawtype = "nodebox", paramtype = "light", groups = {cracky=1, oddly_breakable_by_hand=1}, light_source = 5, on_construct = function(pos, node, placer) local meta = minetest.get_meta(pos) if position1 == nil then position1 = pos meta:set_int("type", 1) elseif position2 == nil then position2 = pos meta:set_int("type", 2) else minetest.chat_send_all("There can only be two teleportation pads at a time!") end end, on_rightclick = function(pos, node, clicker) local meta = minetest.get_meta(pos) if meta:get_int("type") == 1 and position2 ~= nil and position1 ~= nil then minetest.add_particlespawner( 25, --amount 1.5, --time {x=pos.x-0.9, y=pos.y-0.3, z=pos.z-0.9}, --minpos {x=pos.x+0.9, y=pos.y-0.3, z=pos.z+0.9}, --maxpos {x=0, y=0, z=0}, --minvel {x=0, y=0, z=0}, --maxvel {x=-0,y=1,z=-0}, --minacc {x=0,y=2,z=0}, --maxacc 0.5, --minexptime 1, --maxexptime 2, --minsize 5, --maxsize false, --collisiondetection "scifi_nodes_tp_part.png" --texture ) minetest.after(1, function() local ppos = clicker:getpos() if minetest.get_node({x=ppos.x, y=ppos.y, z=ppos.z}).name == "scifi_nodes:pad" then clicker:setpos(position2) else --minetest.chat_send_all("Nothing to teleport!") end local objs = minetest.env:get_objects_inside_radius(pos, 3) for _, obj in pairs(objs) do if obj:get_luaentity() and not obj:is_player() then if obj:get_luaentity().name == "__builtin:item" then local item1 = obj:get_luaentity().itemstring local obj2 = minetest.env:add_entity(position2, "__builtin:item") obj2:get_luaentity():set_item(item1) obj:remove() end end end end) elseif meta:get_int("type") == 2 and position1 ~= nil and position2 ~= nil then minetest.add_particlespawner( 25, --amount 1.5, --time {x=pos.x-0.9, y=pos.y-0.3, z=pos.z-0.9}, --minpos {x=pos.x+0.9, y=pos.y-0.3, z=pos.z+0.9}, --maxpos {x=0, y=0, z=0}, --minvel {x=0, y=0, z=0}, --maxvel {x=-0,y=1,z=-0}, --minacc {x=0,y=2,z=0}, --maxacc 0.5, --minexptime 1, --maxexptime 2, --minsize 5, --maxsize false, --collisiondetection "scifi_nodes_tp_part.png" --texture ) minetest.after(1, function() local ppos = clicker:getpos() if minetest.get_node({x=ppos.x, y=ppos.y, z=ppos.z}).name == "scifi_nodes:pad" then clicker:setpos(position1) else --minetest.chat_send_all("No-one to teleport!") end local objs = minetest.env:get_objects_inside_radius(pos, 3) for _, obj in pairs(objs) do if obj:get_luaentity() and not obj:is_player() then if obj:get_luaentity().name == "__builtin:item" then local item1 = obj:get_luaentity().itemstring local obj2 = minetest.env:add_entity(position1, "__builtin:item") obj2:get_luaentity():set_item(item1) obj:remove() end end end end) elseif position1 == nil and meta:get_int("type") ~= 2 then position1 = pos meta:set_int("type", 1) minetest.chat_send_all("Teleporter 1 connected at "..minetest.pos_to_string(pos)) elseif position2 == nil and meta:get_int("type") ~= 1 then position2 = pos meta:set_int("type", 2) minetest.chat_send_all("Teleporter 2 connected at "..minetest.pos_to_string(pos)) else minetest.chat_send_all("Teleporter error!") end end, on_destruct = function(pos, oldnode, placer) local meta = minetest.get_meta(pos) if meta:get_int("type") == 1 then position1 = nil meta:set_int("type", 0) elseif meta:get_int("type") == 2 then position2 = nil meta:set_int("type", 0) end end, node_box = { type = "fixed", fixed = { {-0.9375, -0.5, -0.75, 0.875, -0.375, 0.75}, -- NodeBox1 {-0.8125, -0.5, -0.875, 0.75, -0.375, 0.875}, -- NodeBox2 {-0.875, -0.5, -0.8125, 0.8125, -0.375, 0.8125}, -- NodeBox3 {-0.8125, -0.5, -0.75, 0.75, -0.3125, 0.75}, -- NodeBox4 }, sounds = default.node_sound_wood_defaults() } }) minetest.register_node("scifi_nodes:pplwndw", { description = "Purple Window", tiles = { "scifi_nodes_purple.png", "scifi_nodes_purple.png", "scifi_nodes_purple.png", "scifi_nodes_purple.png", "scifi_nodes_pplwndw.png", "scifi_nodes_pplwndw.png" }, drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", use_texture_alpha = true, groups = {cracky=3}, sounds = default.node_sound_glass_defaults(), node_box = { type = "fixed", fixed = { {-0.5, -0.5, -0.0625, 0.5, 0.5, 0.0625}, -- NodeBox1 } } }) minetest.register_node("scifi_nodes:gloshroom", { description = "Gloshroom", tiles = { "scifi_nodes_gloshroom.png", "scifi_nodes_gloshroom_under.png", "scifi_nodes_gloshroom.png", "scifi_nodes_gloshroom.png", "scifi_nodes_gloshroom.png", "scifi_nodes_gloshroom.png" }, drawtype = "nodebox", paramtype = "light", light_source = default.LIGHT_MAX, walkable = false, buildable_to = true, sunlight_propagates = false, use_texture_alpha = true, groups = {fleshy=1, oddly_breakable_by_hand=1, dig_immediate=3}, node_box = { type = "fixed", fixed = { {-0.05, -0.5, -0.05, 0.05, 0.0625, 0.05}, -- NodeBox1 {-0.4375, -0.0625, -0.375, 0.4375, 0, 0.375}, -- NodeBox2 {-0.375, 0, -0.375, 0.375, 0.0625, 0.375}, -- NodeBox3 {-0.3125, 0.0625, -0.3125, 0.3125, 0.125, 0.3125}, -- NodeBox4 {-0.1875, 0.125, -0.1875, 0.1875, 0.1875, 0.1875}, -- NodeBox5 {-0.375, -0.0625, -0.4375, 0.375, 0, 0.4375}, -- NodeBox6 } } }) minetest.register_node("scifi_nodes:pot_lid", { description = "plant pot lid(place above plant)", tiles = { "scifi_nodes_glass2.png", "scifi_nodes_glass2.png", "scifi_nodes_glass2.png", "scifi_nodes_glass2.png", "scifi_nodes_glass2.png", "scifi_nodes_glass2.png" }, inventory_image = "scifi_nodes_pod_inv.png", wield_image = "scifi_nodes_pod_inv.png", use_texture_alpha = true, drawtype = "nodebox", paramtype = "light", groups = {cracky=1, not_in_creative_inventory=1}, sunlight_propagates = true, selection_box = { type = "fixed", fixed = {0, 0, 0, 0, 0, 0} }, collision_box = { type = "fixed", fixed = {-0.5, -1.5, -0.5, 0.5, -0.5, 0.5} }, node_box = { type = "fixed", fixed = { {-0.1875, -0.5625, -0.1875, 0.1875, -0.5, 0.1875}, -- NodeBox13 {-0.25, -0.625, -0.25, 0.25, -0.5625, 0.25}, -- NodeBox14 {-0.3125, -0.6875, -0.3125, 0.3125, -0.625, 0.3125}, -- NodeBox15 {-0.375, -0.75, -0.375, 0.375, -0.6875, 0.375}, -- NodeBox16 {-0.4375, -0.75, 0.375, 0.4375, -1.5, 0.4375}, -- NodeBox17 {-0.4375, -0.75, -0.4375, 0.4375, -1.5, -0.375}, -- NodeBox18 {0.375, -0.75, -0.4375, 0.4375, -1.5, 0.4375}, -- NodeBox19 {-0.4375, -0.75, -0.4375, -0.375, -1.5, 0.4375}, -- NodeBox20 } }, sounds = default.node_sound_glass_defaults() }) minetest.register_node("scifi_nodes:pot", { description = "metal plant pot (right click for lid, shift+rightclick to plant)", tiles = { "scifi_nodes_pot.png", "scifi_nodes_greybolts.png", "scifi_nodes_greybolts.png", "scifi_nodes_greybolts.png", "scifi_nodes_greybolts.png", "scifi_nodes_greybolts.png" }, drawtype = "nodebox", paramtype = "light", groups = {cracky=1, soil=1, sand=1}, node_box = { type = "fixed", fixed = { {-0.5, -0.25, -0.5, 0.5, 0.5, 0.5}, -- NodeBox1 {0.1875, -0.5, 0.1875, 0.5, -0.25, 0.5}, -- NodeBox2 {-0.5, -0.5, -0.5, -0.1875, -0.25, -0.1875}, -- NodeBox3 {-0.5, -0.5, 0.1875, -0.1875, -0.25, 0.5}, -- NodeBox4 {0.1875, -0.5, -0.5, 0.5, -0.25, -0.1875}, -- NodeBox5 } }, on_rightclick = function(pos, node, clicker, item, _) local node = minetest.get_node({x=pos.x, y=pos.y+2, z=pos.z}) if node.name == "scifi_nodes:pot_lid" then minetest.set_node({x=pos.x, y=pos.y+2, z=pos.z}, {name="air", param2=node.param2}) elseif node.name ~= "scifi_nodes:pot_lid" and node.name == "air" then minetest.set_node({x=pos.x, y=pos.y+2, z=pos.z}, {name="scifi_nodes:pot_lid", param2=node.param2}) end end, on_destruct = function(pos, node, _) minetest.remove_node({x=pos.x, y=pos.y+2, z=pos.z}) end }) minetest.register_node("scifi_nodes:pot2", { description = "metal wet plant pot(right click for lid, shift+rightclick to plant)", tiles = { "scifi_nodes_pot.png^[colorize:black:100", "scifi_nodes_greybolts.png", "scifi_nodes_greybolts.png", "scifi_nodes_greybolts.png", "scifi_nodes_greybolts.png", "scifi_nodes_greybolts.png" }, drawtype = "nodebox", paramtype = "light", groups = {cracky=1, soil=3, wet=1}, node_box = { type = "fixed", fixed = { {-0.5, -0.25, -0.5, 0.5, 0.5, 0.5}, -- NodeBox1 {0.1875, -0.5, 0.1875, 0.5, -0.25, 0.5}, -- NodeBox2 {-0.5, -0.5, -0.5, -0.1875, -0.25, -0.1875}, -- NodeBox3 {-0.5, -0.5, 0.1875, -0.1875, -0.25, 0.5}, -- NodeBox4 {0.1875, -0.5, -0.5, 0.5, -0.25, -0.1875}, -- NodeBox5 } }, on_rightclick = function(pos, node, clicker, item, _) local node = minetest.get_node({x=pos.x, y=pos.y+2, z=pos.z}) if node.name == "scifi_nodes:pot_lid" then minetest.set_node({x=pos.x, y=pos.y+2, z=pos.z}, {name="air", param2=node.param2}) elseif node.name ~= "scifi_nodes:pot_lid" and node.name == "air" then minetest.set_node({x=pos.x, y=pos.y+2, z=pos.z}, {name="scifi_nodes:pot_lid", param2=node.param2}) end end, on_destruct = function(pos, node, _) minetest.remove_node({x=pos.x, y=pos.y+2, z=pos.z}) end }) minetest.register_node("scifi_nodes:lightbar", { description = "ceiling light", tiles = { "scifi_nodes_white2.png", }, drawtype = "nodebox", paramtype = "light", paramtype2 = "wallmounted", sunlight_propagates = true, light_source = default.LIGHT_MAX, node_box = { type = "fixed", fixed = { {-0.125, -0.5, -0.5, 0.125, -0.375, 0.5}, -- NodeBox1 } }, selection_box = { type = "wallmounted", wallmounted = { {-0.125, -0.5, -0.5, 0.125, -0.375, 0.5}, -- NodeBox1 } }, groups = {cracky=1}, sounds = default.node_sound_glass_defaults() }) minetest.register_node("scifi_nodes:light_dynamic", { description = "Wall light", tiles = { "scifi_nodes_lightoverlay.png", }, inventory_image = "scifi_nodes_lightoverlay.png", wield_image = "scifi_nodes_lightoverlay.png", drawtype = "signlike", paramtype = "light", selection_box = { type = "wallmounted", fixed = {-0.5, -0.5, -0.5, -0.45, 0.5, 0.5} }, paramtype2 = "wallmounted", light_source = default.LIGHT_MAX, groups = {cracky=1, oddly_breakable_by_hand=1}, sounds = default.node_sound_glass_defaults() }) minetest.register_node("scifi_nodes:ladder", { description = "Metal Ladder", tiles = { "scifi_nodes_ladder.png", }, drawtype = "nodebox", paramtype = "light", selection_box = { type = "wallmounted", fixed = {-0.5, -0.5, -0.5, -0.45, 0.5, 0.5} }, node_box = { type = "fixed", fixed = { {0.3125, -0.5, -0.4375, 0.4375, -0.375, -0.3125}, -- NodeBox12 {-0.4375, -0.5, -0.4375, -0.3125, -0.375, -0.3125}, -- NodeBox13 {-0.375, -0.375, -0.4375, 0.375, -0.3125, -0.3125}, -- NodeBox14 {-0.375, -0.375, 0.3125, 0.375, -0.3125, 0.4375}, -- NodeBox18 {-0.375, -0.375, 0.0625, 0.375, -0.3125, 0.1875}, -- NodeBox19 {-0.375, -0.375, -0.1875, 0.375, -0.3125, -0.0625}, -- NodeBox20 {-0.4375, -0.5, -0.1875, -0.3125, -0.375, -0.0625}, -- NodeBox21 {-0.4375, -0.5, 0.0625, -0.3125, -0.375, 0.1875}, -- NodeBox22 {-0.4375, -0.5, 0.3125, -0.3125, -0.375, 0.4375}, -- NodeBox23 {0.3125, -0.5, 0.3125, 0.4375, -0.375, 0.4375}, -- NodeBox24 {0.3125, -0.5, 0.0625, 0.4375, -0.375, 0.1875}, -- NodeBox25 {0.3125, -0.5, -0.1875, 0.4375, -0.375, -0.0625}, -- NodeBox26 }, sounds = default.node_sound_metal_defaults() }, paramtype2 = "wallmounted", walkable = false, climbable = true, groups = {cracky=1, oddly_breakable_by_hand=1}, }) minetest.register_node("scifi_nodes:lightbars", { description = "orange lightbars", tiles = { "scifi_nodes_orange2.png", }, drawtype = "nodebox", paramtype = "light", use_texture_alpha = true, light_source = default.LIGHT_MAX, node_box = { type = "fixed", fixed = { {0.125, -0.5, 0.125, 0.375, 0.5, 0.375}, -- NodeBox1 {-0.375, -0.5, 0.125, -0.125, 0.5, 0.375}, -- NodeBox2 {-0.375, -0.5, -0.375, -0.125, 0.5, -0.125}, -- NodeBox3 {0.125, -0.5, -0.375, 0.375, 0.5, -0.125}, -- NodeBox4 } }, groups = {cracky=1}, sounds = default.node_sound_glass_defaults() }) minetest.register_node("scifi_nodes:liquid_pipe", { description = "Liquid pipe", tiles = {{ name = "scifi_nodes_liquid.png", animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 1.00}, }}, use_texture_alpha = true, light_source = default.LIGHT_MAX, drawtype = "nodebox", sunlight_propagates = true, paramtype = "light", node_box = { type = "fixed", fixed = { {-0.375, -0.5, -0.375, 0.375, 0.5, 0.375}, -- NodeBox1 } }, groups = {cracky=1, oddly_breakable_by_hand=1}, sounds = default.node_sound_glass_defaults() }) minetest.register_node("scifi_nodes:liquid_pipe2", { description = "Liquid pipe 2", tiles = { "scifi_nodes_orange.png", }, use_texture_alpha = true, light_source = default.LIGHT_MAX, drawtype = "nodebox", sunlight_propagates = true, paramtype = "light", node_box = { type = "fixed", fixed = { {-0.375, -0.5, -0.375, 0.375, 0.5, 0.375}, -- NodeBox1 } }, groups = {cracky=1, oddly_breakable_by_hand=1}, sounds = default.node_sound_glass_defaults() }) minetest.register_node("scifi_nodes:powered_stand", { description = "powered stand", tiles = { "scifi_nodes_pwrstnd_top.png", "scifi_nodes_pwrstnd_top.png", "scifi_nodes_pwrstnd_side.png", "scifi_nodes_pwrstnd_side.png", "scifi_nodes_pwrstnd_side.png", "scifi_nodes_pwrstnd_side.png" }, drawtype = "nodebox", paramtype = "light", node_box = { type = "fixed", fixed = { {-0.375, 0.25, -0.3125, 0.375, 0.4375, 0.3125}, -- NodeBox1 {-0.3125, 0.25, -0.375, 0.3125, 0.4375, 0.375}, -- NodeBox2 {-0.3125, 0.4375, -0.3125, 0.3125, 0.5, 0.3125}, -- NodeBox3 {-0.5, -0.5, -0.125, 0.5, 0.125, 0.125}, -- NodeBox4 {-0.125, -0.5, -0.5, 0.125, 0.125, 0.5}, -- NodeBox5 {-0.4375, 0.125, -0.125, 0.4375, 0.25, 0.125}, -- NodeBox6 {-0.125, 0.125, -0.4375, 0.125, 0.25, 0.4375}, -- NodeBox7 {-0.3125, -0.5, -0.375, 0.3125, 0.0625, 0.3125}, -- NodeBox8 {-0.25, 0.0625, -0.3125, 0.25, 0.125, 0.3125}, -- NodeBox9 } }, groups = {cracky=1, oddly_breakable_by_hand=1}, on_rightclick = function(pos, node, clicker, item, _) local wield_item = clicker:get_wielded_item():get_name() local taken = item:take_item() if taken and not taken:is_empty() then minetest.add_item({x=pos.x, y=pos.y+1, z=pos.z}, wield_item) return item end end, }) minetest.register_node("scifi_nodes:cover", { description = "Metal cover", tiles = { "scifi_nodes_pwrstnd_top.png", "scifi_nodes_pwrstnd_top.png", "scifi_nodes_pwrstnd_top.png", "scifi_nodes_pwrstnd_top.png", "scifi_nodes_pwrstnd_top.png", "scifi_nodes_pwrstnd_top.png" }, drawtype = "nodebox", paramtype = "light", node_box = { type = "fixed", fixed = { {-0.375, -0.5, -0.3125, 0.375, -0.375, 0.3125}, -- NodeBox1 {-0.3125, -0.5, -0.375, 0.3125, -0.375, 0.375}, -- NodeBox5 {-0.3125, -0.375, -0.3125, 0.3125, -0.3125, 0.3125}, -- NodeBox6 } }, sounds = default.node_sound_wood_defaults(), groups = {cracky=1, oddly_breakable_by_hand=1} }) minetest.register_node("scifi_nodes:computer", { description = "computer", tiles = { "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_blackvent.png", "scifi_nodes_black.png", "scifi_nodes_mesh2.png", "scifi_nodes_pc.png" }, drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", sunlight_propagates = true, node_box = { type = "fixed", fixed = { {-0.4375, -0.5, -0.5, 0.0625, 0.5, 0.5}, -- NodeBox1 } }, groups = {cracky=1, oddly_breakable_by_hand=1} }) minetest.register_node("scifi_nodes:keysmonitor", { description = "Keyboard and monitor", tiles = { "scifi_nodes_keyboard.png", "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_monitor.png" }, drawtype = "nodebox", paramtype = "light", sunlight_propagates = true, paramtype2 = "facedir", node_box = { type = "fixed", fixed = { {-0.5, -0.5, -0.4375, 0.5, -0.4375, -0.0625}, -- NodeBox1 {-0.125, -0.5, 0.375, 0.125, 0.0625, 0.4375}, -- NodeBox2 {-0.25, -0.5, 0.125, 0.25, -0.4375, 0.5}, -- NodeBox3 {-0.5, -0.3125, 0.25, 0.5, 0.5, 0.375}, -- NodeBox4 } }, groups = {cracky=1, oddly_breakable_by_hand=1} }) minetest.register_node("scifi_nodes:microscope", { description = "Microscope", tiles = { "scifi_nodes_white.png", "scifi_nodes_black.png", "scifi_nodes_white_vent.png", "scifi_nodes_white_vent.png", "scifi_nodes_white_vent.png", "scifi_nodes_white_vent.png" }, drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", sunlight_propagates = true, node_box = { type = "fixed", fixed = { {-0.25, -0.5, -0.3125, 0.25, -0.375, 0.3125}, -- NodeBox1 {-0.0625, -0.5, 0.125, 0.0625, 0.3125, 0.25}, -- NodeBox2 {-0.0625, -0.0625, -0.0625, 0.0625, 0.5, 0.0625}, -- NodeBox3 {-0.0625, 0.0625, 0.0625, 0.0625, 0.25, 0.125}, -- NodeBox4 {-0.125, -0.25, -0.125, 0.125, -0.1875, 0.1875}, -- NodeBox5 } }, groups = {cracky=1, oddly_breakable_by_hand=1} }) minetest.register_node("scifi_nodes:table", { description = "Metal table", tiles = { "scifi_nodes_grey.png", "scifi_nodes_grey.png", "scifi_nodes_grey.png", "scifi_nodes_grey.png", "scifi_nodes_grey.png", "scifi_nodes_grey.png" }, drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", node_box = { type = "fixed", fixed = { {-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5}, -- NodeBox1 {-0.0625, -0.5, 0.125, 0.0625, 0.5, 0.3125}, -- NodeBox2 {-0.0625, -0.5, 0.375, 0.0625, 0.5, 0.4375}, -- NodeBox3 {-0.0625, -0.375, 0.0625, 0.0625, 0.4375, 0.125}, -- NodeBox4 {-0.0625, -0.1875, 0, 0.0625, 0.4375, 0.0625}, -- NodeBox5 {-0.0625, 0.0625, -0.0625, 0.0625, 0.4375, 0}, -- NodeBox6 {-0.0625, 0.25, -0.125, 0.0625, 0.4375, -0.0625}, -- NodeBox7 } }, sounds = default.node_sound_metal_defaults(), groups = {cracky=1} }) minetest.register_node("scifi_nodes:laptop_open", { description = "laptop", tiles = { "scifi_nodes_lapkey.png", "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_laptop.png" }, drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", sunlight_propagates = true, node_box = { type = "fixed", fixed = { {-0.4375, -0.5, -0.4375, 0.4375, -0.375, 0.3125}, -- NodeBox1 {-0.4375, -0.375, 0.3125, 0.4375, 0.4375, 0.4375}, -- NodeBox11 } }, groups = {cracky=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1}, on_rightclick = function(pos, node, clicker, item, _) minetest.set_node(pos, {name="scifi_nodes:laptop_closed", param2=node.param2}) end, }) minetest.register_node("scifi_nodes:laptop_closed", { description = "laptop", tiles = { "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_black.png" }, drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", sunlight_propagates = true, node_box = { type = "fixed", fixed = { {-0.4375, -0.5, -0.4375, 0.4375, -0.25, 0.3125}, -- NodeBox1 } }, groups = {cracky=1, oddly_breakable_by_hand=1}, on_rightclick = function(pos, node, clicker, item, _) minetest.set_node(pos, {name="scifi_nodes:laptop_open", param2=node.param2}) end, }) minetest.register_node("scifi_nodes:pipen", { description = "pipe(nodebox)", tiles = { "scifi_nodes_blacktile2.png", "scifi_nodes_blacktile2.png", "scifi_nodes_pipen.png", "scifi_nodes_pipen.png", "scifi_nodes_pipen.png", "scifi_nodes_pipen.png" }, drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", node_box = { type = "fixed", fixed = { {-0.4375, -0.5, -0.4375, 0.4375, 0.5, 0.4375}, -- NodeBox1 {-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5}, -- NodeBox2 {-0.5, 0.3125, -0.5, 0.5, 0.375, 0.5}, -- NodeBox3 {-0.5, 0.1875, -0.5, 0.5, 0.25, 0.5}, -- NodeBox4 {-0.5, 0.0625, -0.5, 0.5, 0.125, 0.5}, -- NodeBox5 {-0.5, -0.0625, -0.5, 0.5, 0, 0.5}, -- NodeBox6 {-0.5, -0.1875, -0.5, 0.5, -0.125, 0.5}, -- NodeBox7 {-0.5, -0.3125, -0.5, 0.5, -0.25, 0.5}, -- NodeBox8 {-0.5, -0.4375, -0.5, 0.5, -0.375, 0.5}, -- NodeBox9 } }, groups = {cracky=1}, on_place = minetest.rotate_node }) minetest.register_node("scifi_nodes:windowcorner", { description = "strong window corner", tiles = { "scifi_nodes_glassstrngsd2.png", "scifi_nodes_white.png", "scifi_nodes_glassstrngcrnr.png", "scifi_nodes_glassstrngcrnr2.png", "scifi_nodes_white.png", "scifi_nodes_glassstrngsd.png" }, drawtype = "nodebox", paramtype = "light", use_texture_alpha = true, sunlight_propagates = true, paramtype2 = "facedir", node_box = { type = "fixed", fixed = { {-0.3125, -0.5, -0.5, 0.3125, -0.25, 0.5}, -- NodeBox1 {-0.3125, -0.25, 0.25, 0.3125, -0.1875, 0.5}, -- NodeBox7 {-0.3125, -0.25, 0.3125, 0.3125, -0.125, 0.375}, -- NodeBox8 {-0.3125, -0.3125, 0.25, 0.3125, -0.1875, 0.3125}, -- NodeBox9 {-0.3125, -0.5, 0.375, 0.3125, 0.5, 0.5}, -- NodeBox10 {-0.0625, -0.5, -0.5, 0.0625, 0.5, 0.5}, -- NodeBox11 } }, groups = {cracky=1}, on_place = minetest.rotate_node, sounds = default.node_sound_glass_defaults(), }) minetest.register_node("scifi_nodes:windowstraight", { description = "strong window", tiles = { "scifi_nodes_glassstrngsd2.png", "scifi_nodes_white.png", "scifi_nodes_glassstrng.png", "scifi_nodes_glassstrng.png", "scifi_nodes_glassstrngsd.png", "scifi_nodes_glassstrngsd.png" }, drawtype = "nodebox", paramtype = "light", use_texture_alpha = true, sunlight_propagates = true, paramtype2 = "facedir", node_box = { type = "fixed", fixed = { {-0.3125, -0.5, -0.5, 0.3125, -0.25, 0.5}, -- NodeBox10 {-0.0625, -0.5, -0.5, 0.0625, 0.5, 0.5}, -- NodeBox11 } }, groups = {cracky=1}, on_place = minetest.rotate_node, sounds = default.node_sound_glass_defaults(), }) minetest.register_node("scifi_nodes:windowcorner2", { description = "strong window corner(black)", tiles = { "scifi_nodes_glassstrngsd4.png", "scifi_nodes_black.png", "scifi_nodes_glassstrngcrnr3.png", "scifi_nodes_glassstrngcrnr4.png", "scifi_nodes_black.png", "scifi_nodes_glassstrngsd3.png" }, drawtype = "nodebox", paramtype = "light", use_texture_alpha = true, sunlight_propagates = true, paramtype2 = "facedir", node_box = { type = "fixed", fixed = { {-0.3125, -0.5, -0.5, 0.3125, -0.25, 0.5}, -- NodeBox1 {-0.3125, -0.25, 0.25, 0.3125, -0.1875, 0.5}, -- NodeBox7 {-0.3125, -0.25, 0.3125, 0.3125, -0.125, 0.375}, -- NodeBox8 {-0.3125, -0.3125, 0.25, 0.3125, -0.1875, 0.3125}, -- NodeBox9 {-0.3125, -0.5, 0.375, 0.3125, 0.5, 0.5}, -- NodeBox10 {-0.0625, -0.5, -0.5, 0.0625, 0.5, 0.5}, -- NodeBox11 } }, groups = {cracky=1}, on_place = minetest.rotate_node, sounds = default.node_sound_glass_defaults(), }) minetest.register_node("scifi_nodes:windowstraight2", { description = "strong window(black)", tiles = { "scifi_nodes_glassstrngsd4.png", "scifi_nodes_black.png", "scifi_nodes_glassstrng2.png", "scifi_nodes_glassstrng2.png", "scifi_nodes_glassstrngsd3.png", "scifi_nodes_glassstrngsd3.png" }, drawtype = "nodebox", paramtype = "light", use_texture_alpha = true, sunlight_propagates = true, paramtype2 = "facedir", node_box = { type = "fixed", fixed = { {-0.3125, -0.5, -0.5, 0.3125, -0.25, 0.5}, -- NodeBox10 {-0.0625, -0.5, -0.5, 0.0625, 0.5, 0.5}, -- NodeBox11 } }, groups = {cracky=1}, on_place = minetest.rotate_node, sounds = default.node_sound_glass_defaults(), }) minetest.register_node("scifi_nodes:capsule", { description = "sample capsule", tiles = { "scifi_nodes_capsule.png", "scifi_nodes_capsule.png", "scifi_nodes_box_top.png", "scifi_nodes_box_top.png", "scifi_nodes_capsule.png", "scifi_nodes_capsule.png" }, use_texture_alpha = true, drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", sunlight_propagates = true, node_box = { type = "fixed", fixed = { {0.3125, -0.5, -0.25, 0.5, 0, 0.25}, -- NodeBox1 {-0.5, -0.5, -0.25, -0.3125, 0, 0.25}, -- NodeBox2 {-0.3125, -0.4375, -0.1875, 0.3125, -0.0625, 0.1875}, -- NodeBox3 } }, groups = {cracky=1, oddly_breakable_by_hand=1}, sounds = default.node_sound_glass_defaults(), on_rightclick = function(pos, node, clicker, item, _) minetest.set_node(pos, {name="scifi_nodes:capsule2", param2=node.param2}) end, }) minetest.register_node("scifi_nodes:capsule3", { description = "sample capsule", tiles = { "scifi_nodes_capsule3.png", "scifi_nodes_capsule3.png", "scifi_nodes_box_top.png", "scifi_nodes_box_top.png", "scifi_nodes_capsule3.png", "scifi_nodes_capsule3.png" }, use_texture_alpha = true, drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", sunlight_propagates = true, node_box = { type = "fixed", fixed = { {0.3125, -0.5, -0.25, 0.5, 0, 0.25}, -- NodeBox1 {-0.5, -0.5, -0.25, -0.3125, 0, 0.25}, -- NodeBox2 {-0.3125, -0.4375, -0.1875, 0.3125, -0.0625, 0.1875}, -- NodeBox3 } }, groups = {cracky=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1}, sounds = default.node_sound_glass_defaults(), on_rightclick = function(pos, node, clicker, item, _) minetest.set_node(pos, {name="scifi_nodes:capsule", param2=node.param2}) end, }) minetest.register_node("scifi_nodes:capsule2", { description = "sample capsule", tiles = { "scifi_nodes_capsule2.png", "scifi_nodes_capsule2.png", "scifi_nodes_box_top.png", "scifi_nodes_box_top.png", "scifi_nodes_capsule2.png", "scifi_nodes_capsule2.png" }, use_texture_alpha = true, drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", sunlight_propagates = true, node_box = { type = "fixed", fixed = { {0.3125, -0.5, -0.25, 0.5, 0, 0.25}, -- NodeBox1 {-0.5, -0.5, -0.25, -0.3125, 0, 0.25}, -- NodeBox2 {-0.3125, -0.4375, -0.1875, 0.3125, -0.0625, 0.1875}, -- NodeBox3 } }, groups = {cracky=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1}, sounds = default.node_sound_glass_defaults(), on_rightclick = function(pos, node, clicker, item, _) minetest.set_node(pos, {name="scifi_nodes:capsule3", param2=node.param2}) end, }) minetest.register_node("scifi_nodes:itemholder", { description = "item holder", tiles = { "scifi_nodes_box_top.png", "scifi_nodes_box_top.png", "scifi_nodes_box_top.png", "scifi_nodes_box_top.png", "scifi_nodes_box_top.png", "scifi_nodes_box_top.png" }, drawtype = "nodebox", paramtype = "light", sunlight_propagates = true, node_box = { type = "fixed", fixed = { {-0.3125, -0.5, -0.3125, 0.3125, -0.25, 0.3125}, -- NodeBox1 {-0.0625, -0.5, 0.1875, 0.0625, -0.0625, 0.25}, -- NodeBox2 {-0.0625, -0.5, -0.25, 0.0625, -0.0625, -0.1875}, -- NodeBox3 {0.1875, -0.5, -0.0625, 0.25, -0.0625, 0.0625}, -- NodeBox4 {-0.25, -0.5, -0.0625, -0.1875, -0.0625, 0.0625}, -- NodeBox5 } }, groups = {cracky=1}, on_rotate = screwdriver.disallow, after_place_node = function(pos, placer, itemstack) local meta = minetest.get_meta(pos) meta:set_string("owner",placer:get_player_name()) meta:set_string("infotext", "Itemholder (owned by " .. meta:get_string("owner") .. ")") end, on_rightclick = function(pos, node, clicker, item, _) local name = clicker and clicker:get_player_name() local meta = minetest.get_meta(pos) if name == meta:get_string("owner") or minetest.check_player_privs(name, "protection_bypass") then local wield_item = clicker:get_wielded_item():get_name() local taken = item:take_item() if taken and not taken:is_empty() then minetest.add_item(pos, wield_item) return item end end end, can_dig = function(pos,player) if not player then return end local name = player and player:get_player_name() local meta = minetest.get_meta(pos) return name == meta:get_string("owner") or minetest.check_player_privs(name, "protection_bypass") end, on_destruct = function(pos) local meta = minetest.get_meta(pos) local node = minetest.get_node(pos) if meta:get_string("item") ~= "" then drop_item(pos, node) end end, }) minetest.register_node("scifi_nodes:glassscreen", { description = "glass screen", tiles = { "scifi_nodes_glscrn.png", "scifi_nodes_glscrn.png", "scifi_nodes_glscrn.png", "scifi_nodes_glscrn.png", "scifi_nodes_glscrn.png", "scifi_nodes_glscrn.png" }, use_texture_alpha = true, drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", light_source = default.LIGHT_MAX, sunlight_propagates = true, node_box = { type = "fixed", fixed = { {-0.4375, -0.5, -0.125, 0.4375, -0.1875, 0.0625}, -- NodeBox1 {-0.375, -0.5, -0.0625, 0.375, 0.5, 0}, -- NodeBox10 } }, groups = {cracky=1, oddly_breakable_by_hand=1}, sounds = default.node_sound_glass_defaults(), }) minetest.register_node("scifi_nodes:widescreen", { description = "widescreen", tiles = { "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_widescreen.png" }, drawtype = "nodebox", paramtype = "light", light_source = 5, paramtype2 = "facedir", sunlight_propagates = true, node_box = { type = "fixed", fixed = { {-0.375, -0.3125, 0.4375, 0.375, 0.3125, 0.5}, -- NodeBox1 {-0.5, -0.375, 0.375, -0.375, 0.375, 0.5}, -- NodeBox2 {0.375, -0.375, 0.375, 0.5, 0.375, 0.5}, -- NodeBox3 {-0.3125, 0.25, 0.375, 0.3125, 0.375, 0.5}, -- NodeBox4 {-0.3125, -0.375, 0.375, 0.25, -0.25, 0.5}, -- NodeBox5 {-0.5, -0.3125, 0.375, 0.5, -0.25, 0.5}, -- NodeBox6 {-0.5, 0.25, 0.375, 0.5, 0.3125, 0.5}, -- NodeBox7 } }, groups = {cracky=1, oddly_breakable_by_hand=1} }) minetest.register_node("scifi_nodes:tallscreen", { description = "tallscreen", tiles = { "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_black.png", "scifi_nodes_tallscreen.png" }, drawtype = "nodebox", light_source = 5, paramtype = "light", paramtype2 = "facedir", sunlight_propagates = true, node_box = { type = "fixed", fixed = { {-0.3125, -0.375, 0.4375, 0.3125, 0.375, 0.5}, -- NodeBox1 {-0.375, 0.375, 0.375, 0.375, 0.5, 0.5}, -- NodeBox2 {-0.375, -0.5, 0.375, 0.375, -0.375, 0.5}, -- NodeBox3 {0.25, -0.3125, 0.375, 0.375, 0.3125, 0.5}, -- NodeBox4 {-0.375, -0.25, 0.375, -0.25, 0.3125, 0.5}, -- NodeBox5 {-0.3125, -0.5, 0.375, -0.25, 0.5, 0.5}, -- NodeBox6 {0.25, -0.5, 0.375, 0.3125, 0.5, 0.5}, -- NodeBox7 } }, groups = {cracky=1, oddly_breakable_by_hand=1} }) -- https://forum.minetest.net/viewtopic.php?f=10&t=13125&p=261481#p261481 minetest.register_node("scifi_nodes:windowpanel", { description = "strong window panel", tiles = { "scifi_nodes_glass.png", }, drawtype = "nodebox", paramtype = "light", use_texture_alpha = true, sunlight_propagates = true, paramtype2 = "facedir", node_box = { type = "fixed", fixed = { {-0.0625, -0.5, -0.5, 0.0625, 0.5, 0.5}, -- NodeBox11 } }, groups = {cracky=1}, on_place = minetest.rotate_node, sounds = default.node_sound_glass_defaults(), }) -------------- -- Switches -- -------------- local function get_switch_rules(param2) -- param2 = 2 local rules = { {x=1, y=-1, z=-1}, {x=1, y=-1, z=1}, {x=0, y=-1, z=-1}, {x=0, y=-1, z=1}, } -- Left and right when looking to +y ? if param2 == 3 then rules = mesecon.rotate_rules_right(mesecon.rotate_rules_right (rules)) elseif param2 == 4 then rules = mesecon.rotate_rules_right(rules) elseif param2 == 5 then rules = mesecon.rotate_rules_left(rules) end return rules end local function toggle_switch(pos) local node = minetest.get_node(pos) local name = node.name if name == "scifi_nodes:switch_on" then minetest.sound_play("scifi_nodes_switch", {max_hear_distance = 8, pos = pos}) minetest.set_node(pos, {name = "scifi_nodes:switch_off", param2 = node.param2}) mesecon.receptor_off(pos, get_switch_rules(node.param2)) elseif name == "scifi_nodes:switch_off" then minetest.sound_play("scifi_nodes_switch", {max_hear_distance = 8, pos = pos}) minetest.set_node(pos, {name = "scifi_nodes:switch_on", param2 = node.param2}) mesecon.receptor_on(pos, get_switch_rules(node.param2)) minetest.get_node_timer(pos):start(2) end end minetest.register_node("scifi_nodes:switch_on", { description = "Wall switch", sunlight_propagates = true, buildable_to = false, tiles = {"scifi_nodes_switch_on.png",}, inventory_image = "scifi_nodes_switch_on.png", wield_image = "scifi_nodes_switch_on.png", drawtype = "signlike", node_box = {type = "wallmounted",}, selection_box = {type = "wallmounted",}, paramtype = "light", paramtype2 = "wallmounted", light_source = 5, groups = {cracky=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1, mesecon_needs_receiver = 1}, mesecons = {receptor = {state = mesecon.state.on,}}, sounds = default.node_sound_glass_defaults(), on_rightclick = toggle_switch, on_timer = toggle_switch }) minetest.register_node("scifi_nodes:switch_off", { description = "Wall switch", tiles = {"scifi_nodes_switch_off.png",}, inventory_image = "scifi_nodes_switch_on.png", wield_image = "scifi_nodes_switch_on.png", drawtype = "signlike", sunlight_propagates = true, buildable_to = false, node_box = {type = "wallmounted",}, selection_box = {type = "wallmounted",}, paramtype = "light", paramtype2 = "wallmounted", groups = {cracky=1, oddly_breakable_by_hand=1, mesecon_needs_receiver = 1}, mesecons = {receptor = {state = mesecon.state.off,}}, sounds = default.node_sound_glass_defaults(), on_rightclick = toggle_switch }) minetest.register_craft({ output = "scifi_nodes:switch_off 2", recipe = {{"mesecons_button:button_off", "scifi_nodes:grey", ""}} }) -------------- -- Digicode -- -------------- local secret_code = "1234" local allowed_chars = "0123456789" local code_length = 4 local digicode_context = {} -- after_place_node, use by digicode and palm_scanner -- placer is a player object local function set_owner(pos, placer, itemstack, pointed_thing) local meta = minetest.get_meta(pos) meta:set_string("owner", placer:get_player_name()) meta:set_string("code", secret_code) end local function toggle_digicode(pos) local node = minetest.get_node(pos) local name = node.name if name == "scifi_nodes:digicode_off" then minetest.swap_node(pos, {name="scifi_nodes:digicode_on", param2=node.param2}) mesecon.receptor_on(pos, get_switch_rules(node.param2)) minetest.get_node_timer(pos):start(2) elseif name == "scifi_nodes:digicode_on" then minetest.swap_node(pos, {name="scifi_nodes:digicode_off", param2=node.param2}) mesecon.receptor_off(pos, get_switch_rules(node.param2)) end end local function code_is_valid(code) local valid = false if type(code) == "string" and #code == code_length then valid = true end for i=1, #code do if not string.find(allowed_chars, string.sub(code,i,i)) then valid = false end end return valid end local function update_code(pos, code) local meta = minetest.get_meta(pos) meta:set_string("code", code) end local function show_digicode_formspec(pos, node, player, itemstack, pointed_thing) local meta = minetest.get_meta(pos) local owner = meta:get_string("owner") local current_code = meta:get_string("code") local current_player = player:get_player_name() -- Gathering datas that will be used by callback function digicode_context[current_player] = {code = current_code, pos = pos} if current_player == owner then minetest.show_formspec(current_player, "digicode_formspec", "size[6,3]".. "field[1,1;3,1;code;Code;]".. -- type, position, size, name, label "button_exit[1,2;2,1;change;Change code]".. "button_exit[3,2;2,1;open;Open door]") else minetest.show_formspec(current_player, "digicode_formspec", "size[6,3]".. "field[2,1;3,1;code;Code;]".. "button_exit[2,2;3,1;open;Open door]") end end -- Process datas from digicode_formspec minetest.register_on_player_receive_fields(function(player, formname, fields) if formname ~= "digicode_formspec" then return false end local sounds = {"scifi_nodes_scanner_granted","scifi_nodes_scanner_refused", "scifi_nodes_digicode_granted","scifi_nodes_digicode_refused" } local sound_index -- We have the right formspec so we can proceed it. -- Let's retrieve the datas we need : local context = digicode_context[player:get_player_name()] if fields.change and code_is_valid(fields.code) then update_code(context.pos, fields.code) sound_index = 1 elseif fields.change and not code_is_valid(fields.code) then sound_index = 2 elseif fields.open and fields.code == context.code then toggle_digicode(context.pos) sound_index = 3 elseif fields.open and fields.code ~= context.code then sound_index = 4 end -- play sound at context position minetest.sound_play(sounds[sound_index], { pos = context.pos, max_hear_distance = 10 }) context[player:get_player_name()] = nil -- we don't need it anymore end) minetest.register_node("scifi_nodes:digicode_on", { description = "Digicode", sunlight_propagates = true, buildable_to = false, tiles = {"scifi_nodes_digicode_on.png",}, inventory_image = "scifi_nodes_digicode_on.png", wield_image = "scifi_nodes_digicode_on.png", drawtype = "signlike", node_box = {type = "wallmounted",}, selection_box = {type = "wallmounted",}, paramtype = "light", paramtype2 = "wallmounted", light_source = 5, groups = {cracky=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1, mesecon_needs_receiver = 1}, drop = {items = {"scifi_nodes:digicode_off"}}, mesecons = {receptor = {state = mesecon.state.on,}}, on_timer = toggle_digicode, sounds = default.node_sound_glass_defaults(), }) minetest.register_node("scifi_nodes:digicode_off", { description = "Digicode", tiles = {"scifi_nodes_digicode_off.png",}, inventory_image = "scifi_nodes_digicode_off.png", wield_image = "scifi_nodes_digicode_off.png", drawtype = "signlike", sunlight_propagates = true, buildable_to = false, node_box = {type = "wallmounted",}, selection_box = {type = "wallmounted",}, paramtype = "light", paramtype2 = "wallmounted", groups = {cracky=1, oddly_breakable_by_hand=1, mesecon_needs_receiver = 1}, mesecons = {receptor = {state = mesecon.state.off,}}, after_place_node = set_owner, on_rightclick = show_digicode_formspec, sounds = default.node_sound_glass_defaults(), }) minetest.register_craft({ output = "scifi_nodes:digicode_off 2", recipe = {{"mesecons_switch:mesecon_switch_off", "scifi_nodes:grey", ""}} }) ----------------------------------------------- -- Palm scanner -- ----------------------------------------------- -- /!\ When "overriding" a callback function -- -- re-use all the parameters in same order ! -- ----------------------------------------------- -- after_place_node -- placer is a player object local function set_scanner_owner(pos, placer, itemstack, pointed_thing) local meta = minetest.get_meta(pos) meta:set_string("owner", placer:get_player_name()) end local function toggle_palm_scanner(pos, node, player, itemstack, pointed_thing) -- Some calling function don't send node param, but everybody sends a pos, so : local node = minetest.get_node(pos) if node.name == "scifi_nodes:palm_scanner_off" then local meta = minetest.get_meta(pos) meta:set_string("clicker", player:get_player_name()) -- need to keep it somewhere minetest.swap_node(pos, {name = "scifi_nodes:palm_scanner_checking", param2 = node.param2}) minetest.sound_play("scifi_nodes_palm_scanner", {max_hear_distance = 8, pos = pos, gain = 1.0}) minetest.chat_send_player(player:get_player_name(), "Checking : please wait.") minetest.get_node_timer(pos):start(2) elseif node.name == "scifi_nodes:palm_scanner_checking" then minetest.swap_node(pos,{name = "scifi_nodes:palm_scanner_on", param2 = node.param2}) mesecon.receptor_on(pos, get_switch_rules(node.param2)) minetest.get_node_timer(pos):start(2) elseif node.name == "scifi_nodes:palm_scanner_on" then minetest.sound_play("scifi_nodes_switch", {max_hear_distance = 8, pos = pos, gain = 1.0}) minetest.swap_node(pos, {name = "scifi_nodes:palm_scanner_off", param2 = node.param2}) mesecon.receptor_off (pos, get_switch_rules(node.param2)) end end -- palm_scanner_checking.on_timer local function check_owner(pos, elapsed) local meta = minetest.get_meta(pos) local owner = meta:get_string("owner") local clicker = meta:get_string("clicker") local node = minetest.get_node(pos) if clicker == owner then minetest.sound_play("scifi_nodes_scanner_granted", {max_hear_distance = 8, pos = pos, gain = 1.0}) minetest.chat_send_player(clicker, "Access granted !") toggle_palm_scanner (pos) else minetest.chat_send_player(clicker, "Access refused !") minetest.sound_play("scifi_nodes_scanner_refused", {max_hear_distance = 8, pos = pos, gain = 1.0}) minetest.swap_node(pos, {name = "scifi_nodes:palm_scanner_off", param2 = node.param2}) mesecon.receptor_off(pos, get_switch_rules(node.param2)) end end minetest.register_node("scifi_nodes:palm_scanner_off", { description = "Palm scanner", tiles = {"scifi_nodes_palm_scanner_off.png",}, inventory_image = "scifi_nodes_palm_scanner_off.png", wield_image = "scifi_nodes_palm_scanner_on.png", drawtype = "signlike", sunlight_propagates = true, buildable_to = false, node_box = {type = "wallmounted",}, selection_box = {type = "wallmounted",}, paramtype = "light", paramtype2 = "wallmounted", groups = {cracky=1, oddly_breakable_by_hand=1, mesecon_needs_receiver = 1}, mesecons = {receptor = {state = mesecon.state.off,}}, after_place_node = set_scanner_owner, on_rightclick = toggle_palm_scanner, sounds = default.node_sound_glass_defaults(), }) minetest.register_node("scifi_nodes:palm_scanner_checking", { description = "Palm scanner", tiles = {{ name = "scifi_nodes_palm_scanner_checking.png", animation = {type = "vertical_frames",aspect_w = 16,aspect_h = 16,length = 1.5} }}, drawtype = "signlike", sunlight_propagates = true, buildable_to = false, node_box = {type = "wallmounted",}, selection_box = {type = "wallmounted",}, paramtype = "light", paramtype2 = "wallmounted", groups = {cracky=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1, mesecon_needs_receiver = 1}, drop = "scifi_nodes:palm_scanner_off", sounds = default.node_sound_glass_defaults(), on_timer = check_owner, }) minetest.register_node("scifi_nodes:palm_scanner_on", { description = "Palm scanner", sunlight_propagates = true, buildable_to = false, tiles = {"scifi_nodes_palm_scanner_on.png",}, inventory_image = "scifi_nodes_palm_scanner_on.png", wield_image = "scifi_nodes_palm_scanner_on.png", drawtype = "signlike", node_box = {type = "wallmounted",}, selection_box = {type = "wallmounted",}, paramtype = "light", paramtype2 = "wallmounted", light_source = 5, groups = {cracky=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1, mesecon_needs_receiver = 1}, drop = "scifi_nodes:palm_scanner_off", mesecons = {receptor = {state = mesecon.state.on,}}, on_timer = toggle_palm_scanner, sounds = default.node_sound_glass_defaults(), }) minetest.register_craft({ output = "scifi_nodes:palm_scanner_off 2", recipe = {{"mesecons_powerplant:power_plant", "scifi_nodes:grey", ""}} })
nilq/small-lua-stack
null
-- this is an invalid image saved by PVR texture tool, make sure we fail the load local bad_ignore, shouldfail = image.load("input/bad_pvtt_ARGB1555_16x16.ktx") if shouldfail == true then print("bad_pvtt_ARGB1555_16x16.ktx is an invalid file, we shouldn't load it but we did!") end -- load a png check size etc, save it as a bunch of different formats do local test, okay = image.load("input/simple.png") if okay ~= true then print("test_imageload.png unable to be loaded") else local w = test:width(); local h = test:height(); local d = test:depth(); local s = test:slices(); local format = test:format(); local flags = test:flags() if w ~= 884 then print("simple.png is " .. w .. " wide it should be 884") end if h ~= 406 then print("simple.png is " .. h .. " high it should be 406") end if d ~= 1 then print("simple.png is " .. d .. " depth it should be 1") end if s ~= 1 then print("simple.png is " .. s .. " slices it should be 1") end if format ~= "R8G8B8A8_UNORM" then print("simple.png is " .. format .. " and should be R8G8B8A8_UNORM") end if flags.Cubemap == true then print("simple.png marked as a Cubemaps and shouldn't be") end if flags.HeaderOnly == true then print("simple.png marked as a header only and shouldn't be") end test:saveAsDDS("artifacts/simple.dds") test:saveAsTGA("artifacts/simple.tga") test:saveAsBMP("artifacts/simple.bmp") test:saveAsPNG("artifacts/simple.png") test:saveAsJPG("artifacts/simple.jpg") test:saveAsKTX("artifacts/simple.ktx") local test, okay = image.load("artifacts/simple.ktx") if okay ~= true then print("load artifacts/simple.ktx fail") test:saveAsKTX("artifacts/simple_load_save.ktx") end end end -- create a non pow 2 image, check its okay save as png do local test, okay = image.create(88, 46, 1, 1, "R8G8B8A8_UNORM") if okay ~= true then error("unable to be create image") else local w = test:width(); local h = test:height(); local d = test:depth(); local s = test:slices(); local format = test:format(); local flags = test:flags() if w ~= 88 then print("create image is " .. w .. " wide it should be 88") end if h ~= 46 then print("create image is " .. h .. " high it should be 46") end if d ~= 1 then print("create image is " .. d .. " depth it should be 1") end if s ~= 1 then print("create image is " .. s .. " slices it should be 1") end if format ~= "R8G8B8A8_UNORM" then print("create image is " .. format .. " and should be R8G8B8A8_UNORM") end if flags.Cubemap == true then print("create image marked as a Cubemaps and shouldn't be") end if flags.HeaderOnly == true then print("create image marked as a header only and shouldn't be") end -- should be a completely black with 0 alpha image test:saveAsPNG("artifacts/create_rgba8_88x46.png") end end
nilq/small-lua-stack
null
local Sprite = {} Sprite.__index = Sprite function Sprite.create() local sprite = {} setmetatable(sprite, Sprite) sprite.id = ch2d.sprite.create() return sprite end function Sprite:remove() return ch2d.sprite.remove(self.id) end function Sprite:draw() return ch2d.window.draw(self.id) end function Sprite:remove() return ch2d.sprite.remove(self.id) end function Sprite:setPosition(_x, _y) return ch2d.sprite.setPosition(self.id, _x, _y) end function Sprite:setOrigin(_x, _y) return ch2d.sprite.setOrigin(self.id, _x, _y) end function Sprite:setRotation(_degrees) return ch2d.sprite.setRotation(self.id, _degrees) end function Sprite:setScale(_x, _y) return ch2d.sprite.setScale(self.id, _x, _y) end function Sprite:setTexture(_textureId) return ch2d.sprite.setTexture(self.id, _textureId) end function Sprite:setTextureRect(_top, _left, _width, _height) return ch2d.sprite.setTextureRect(self.id, _top, _left, _width, _height) end function Sprite:getPosition() return ch2d.sprite.getPosition(self.id) end function Sprite:getOrigin() return ch2d.sprite.getOrigin(self.id) end function Sprite:getRotation() return ch2d.sprite.getRotation(self.id) end function Sprite:getScale() return ch2d.sprite.getScale(self.id) end return Sprite
nilq/small-lua-stack
null
--====================================== --javastg players --====================================== ---------------------------------------- --JavaStage jstg.players={} jstg.worldcount=1 jstg.worlds={} jstg.worlds[1]=lstg.world lstg.world.world=7 jstg.currentworld=1 --{l=-192,r=192,b=-224,t=224,boundl=-224,boundr=224,boundb=-256,boundt=256,scrl=32,scrr=416,scrb=16,scrt=464,pl=-192,pr=192,pb=-224,pt=224} function jstg.SetWorldCount(cnt) jstg.worldcount=cnt end function SetLuaSTGWorld(world,width,height,boundout,sl,sr,sb,st) world.l=-width/2 world.pl=-width/2 world.boundl=-width/2-boundout world.r=width/2 world.pr=width/2 world.boundr=width/2+boundout world.b=-height/2 world.pb=-height/2 world.boundb=-height/2-boundout world.t=height/2 world.pt=height/2 world.boundt=height/2+boundout world.scrl=sl world.scrr=sl+width world.scrb=sb world.scrt=sb+height --world.scrl=16 --world.scrr=304 --world.scrb=16 --world.scrt=464 end function SetLuaSTGWorld2(world,width,height,boundout,sl,sb,m) world.l=-width/2 world.pl=-width/2 world.boundl=-width/2-boundout world.r=width/2 world.pr=width/2 world.boundr=width/2+boundout world.b=-height/2 world.pb=-height/2 world.boundb=-height/2-boundout world.t=height/2 world.pt=height/2 world.boundt=height/2+boundout world.scrl=sl world.scrr=sl+width world.scrb=sb world.scrt=sb+height world.world=m end function jstg.UpdateWorld() local a={0,0,0,0} for i=1,jstg.worldcount do a[i]=jstg.worlds[i].world or 0 end ActiveWorlds(a[1],a[2],a[3],a[4]) end function jstg.SetWorld(index,world,mask) world.world=mask jstg.worlds[index]=world end function jstg.GetWorld(index) return jstg.worlds[index] end function jstg.SwitchWorld(index) jstg.currentworld=index lstg.world=jstg.GetWorld(index) SetBound(lstg.world.boundl,lstg.world.boundr,lstg.world.boundb,lstg.world.boundt) end function jstg.ApplyWorld(world) --jstg.currentworld=index lstg.world=world SetBound(lstg.world.boundl,lstg.world.boundr,lstg.world.boundb,lstg.world.boundt) end function jstg.TestWorld(a) jstg.SetWorldCount(2) local w1={} SetLuaSTGWorld(w1,288,448,32,16,288+16,16,16+448); jstg.SetWorld(1,w1,1+2) local w2={} SetLuaSTGWorld(w2,288,448,32,320+16,288+320+16,16,16+448); jstg.SetWorld(2,w2,1+4) end function ran:List(list) return list[ran:Int(1,#list)] end function ran:Player(o) return ran:List(Players(o)) end --通过world掩码获取player数组 function jstg.GetObjectByWorld(list,world) local w={} local j=1 for i=1,#list do if IsInWorld(world,list[i].world) then w[j]=list[i] j=j+1 end end return w end function jstg.GetObjectByObject(list,world) local w={} local j=1 for i=1,#list do if IsSameWorld(world,list[i].world) then w[j]=list[i] j=j+1 end end return w end function jstg.GetPlayersByWorld(world) return jstg.GetObjectByWorld(jstg.players,world) end --通过world掩码获取worlds对象数组 function jstg.GetWorldsByWorld(world) return jstg.GetObjectByWorld(jstg.worlds,world) end --计算在当前多场地多玩家情况下,玩家应该在哪里出现 function jstg:GetPlayerBirthPos() --Get players that may be in a same world local ps=jstg.GetPlayersByWorld(self.world) local n=#ps local p=1 for i=1,n do if self==ps[i] then p=i break end end if n==0 then n=1 end --the player is not actually in game --Get worlds local ws=jstg.GetWorldsByWorld(self.world) --if this player is in no world,abandon if #ws==0 then return 0,-24 end --just use the first one ws=ws[1] return (ws.r-ws.l)/n*0.5*(2*i-1)+ws.r,ws.b-24 end --替换xxx==player function IsPlayer(obj) for i=1,#jstg.players do if obj==jstg.players[i] then jstg._player=player player=obj return true end end return false end function IsPlayerEnd() if jstg._player then player=jstg._player jstg._player=nil end end function SetPlayer(p) jstg.current_player=p end --替换editor中的player(单体) function _Player(o) if jstg.current_player then return jstg.current_player end return Player(o) end --替换player(单体),不使用随机数 function Player(o) if o==nil then o=GetCurrentObject() end if o then local w=jstg.GetPlayersByWorld(o.world) if #w==0 then return player end --no player in same world,return a random one if #w==1 then return w[1] end return w[ex.stageframe%#w+1] end return player end function Players(o) if o==nil then o=GetCurrentObject() end if o then local w=jstg.GetObjectByObject(jstg.players,o.world) return w end return jstg.players end function ListSet(l,a,v) for i=1,#l do l[i][a]=v end end
nilq/small-lua-stack
null
--[[----------------------------------------------------------- -- *-- DeChunk v1.0 --* -- *-- Written by --* -- *-- EternalV3@github --* --]]----------------------------------------------------------- --[[----------------------------------------------------------- -- Resulting structure { header = { signature, version, relVersion, endianness, intSz, sizetSz, instructionSz, numberSz, integral, }, f = { source, linedefined, lastlinedefined, nups, numparams, is_vararg, maxstacksize, code = [...] { instruction, opcode, opmode, A, B, C, Bx, sBx, }, sizecode, k = [...] { tt, value, }, sizek, p = [...] f, sizep, lineinfo = [...], sizelineinfo, locvars = [...] { varname, startpc, endpc, }, upvalues = [...], sizeupvalues, } } --]]----------------------------------------------------------- --[[----------------------------------------------------------- -- Default definitions for Lua 5.1 --]]----------------------------------------------------------- --------------------------------------------------------------- -- Constant TValue types --------------------------------------------------------------- local LUA_TNIL = 0 local LUA_TBOOLEAN = 1 local LUA_TNUMBER = 3 local LUA_TSTRING = 4 --------------------------------------------------------------- -- Instruction data -- - As for now, static register offsets/sizes are used --------------------------------------------------------------- --- iABC = 0 | iABx = 1 | iAsBx = 2 -- local opmodes = { [0] = 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 1, 0, } --------------------------------------------------------------- -- Maximum call depth for a proto --------------------------------------------------------------- local LUAI_MAXCCALLS = 200 --------------------------------------------------------------- -- Misc. header information --------------------------------------------------------------- local LUAC_FORMAT = 0 -- Official local LUAC_VERSION = 0x51 -- 5.1 local LUA_SIGNATURE = "\27Lua" -- <esc>Lua local LUA_DEFAULTHEADER = { signature = LUA_SIGNATURE, -- Lua signature (<esc>Lua) version = LUAC_VERSION, -- Lua version number (5.1) relVersion = LUAC_FORMAT, -- Binary header endianness = 1, -- Endianness (little endian by default) intSz = 4, -- sizeof(int) sizetSz = 4, -- sizeof(size_t) instructionSz = 4, -- sizeof(Instruction) (uint32 by default) numberSz = 8, -- sizeof(lua_Number) (double by default) integral = 0, -- Is integral? (non-fractional) } --[[----------------------------------------------------------- -- Bit manipulation --]]----------------------------------------------------------- --------------------------------------------------------------- -- shiftLeft -- Params: num<lua_Number>, amount<uint> -- Desc: shifts left n times, replicates this: -- num >>= amount --------------------------------------------------------------- local function shiftLeft(num, amount) return math.ldexp(num, amount) end --------------------------------------------------------------- -- shiftRight -- Params: num<lua_Number>, amount<uint> -- Desc: shifts right n times, replicates this: -- num <<= amount --------------------------------------------------------------- local function shiftRight(num, amount) return math.floor(num / (2 ^ amount)) end --------------------------------------------------------------- -- negateBts -- Params: num<lua_Number> -- Desc: Performs a logical negation, replicates this: -- ~num --------------------------------------------------------------- local function negateBits(num) local res = 0 for n = 0, 31 do local bit = shiftRight(num, n) bit = bit % 2 res = res + shiftLeft(0 ^ bit, n) end return res end --------------------------------------------------------------- -- clearBits -- Params: num<lua_Number>, start<uint>, end<uint> -- Desc: Clears bits start-end, replicates this: -- num &= ~(((~0) << end) << start) --------------------------------------------------------------- local function clearBits(num, startBit, endBit) local res = num for i = startBit, endBit do local curBit = 2 ^ i res = res % (curBit + curBit) >= curBit and res - curBit or res -- &= ~(1 << i) end return res end --[[----------------------------------------------------------- -- Reading IEEE754 floating point types --]]----------------------------------------------------------- --------------------------------------------------------------- -- readSPFloat -- Params: data<String> -- Desc: Unpack a 4 byte IEEE754-Single-Precision floating -- point value from a string --------------------------------------------------------------- local function readSPFloat(data) local number = 0.0 for i = 4, 1, -1 do number = shiftLeft(number, 8) + string.byte(data, i) end local isNormal = 1 local signed = shiftRight(number, 31) local exponent = shiftRight(number, 23) exponent = clearBits(exponent, 8, 9) local mantissa = clearBits(number, 23, 31) local sign = ((-1) ^ signed) if (exponent == 0) then if (mantissa == 0) then return sign * 0 -- +-0 else exponent = 1 isNormal = 0 end elseif (exponent == 255) then if (mantissa == 0) then return sign * (1 / 0) -- +-Inf else return sign * 0 / 0 -- +-Q/NaN end end -- sign * 2**e-127 * isNormal.mantissa return math.ldexp(sign, exponent - 127) * (isNormal + (mantissa / (2 ^ 23))) end --------------------------------------------------------------- -- readSPFloat -- Params: data<String> -- Desc: Unpack a 8 byte IEEE754-Double-Precision floating -- point value from a string --------------------------------------------------------------- local function readDPFloat(data) local upper, lower = 0.0, 0.0 for i = 8, 5, -1 do upper = shiftLeft(upper, 8) + string.byte(data, i) end for i = 4, 1, -1 do lower = shiftLeft(lower, 8) + string.byte(data, i) end local isNormal = 1 local signed = shiftRight(upper, 31) local exponent = shiftRight(upper, 20) exponent = clearBits(exponent, 11, 12) local mantissa = shiftLeft(clearBits(upper, 20, 31), 32) + lower local sign = ((-1) ^ signed) if (exponent == 0) then if (mantissa == 0) then return sign * 0 -- +-0 else exponent = 1 isNormal = 0 end elseif (exponent == 2047) then if (mantissa == 0) then return sign * (1 / 0) -- +-Inf else return sign * (0 / 0) -- +-Q/Nan end end -- sign * 2**e-1023 * isNormal.mantissa return math.ldexp(sign, exponent - 1023) * (isNormal + (mantissa / (2 ^ 52))) end --[[----------------------------------------------------------- -- Chunk data loading functions -- - Recreation of Lua's native loading system --]]----------------------------------------------------------- --------------------------------------------------------------- -- loadError -- Params: msg<String> -- Desc: Errors with the provided message --------------------------------------------------------------- local function loadError(msg) local fmt = string.format("%s in precompiled chunk", msg) error(fmt) end --------------------------------------------------------------- -- loadBlock -- Params: chunkData, size<uint> -- Desc: Attempts to load data with the given size from the -- chunk at the current working position --------------------------------------------------------------- local function loadBlock(chunkData, size) local currentPos = chunkData.currentPos local chunk = chunkData.chunk local offset = currentPos + size if (#chunk < offset - 1) then loadError("unexpected end") else local data = chunk:sub(currentPos, offset) -- If chunk is big endian -- if (chunkData.endianness == 0) then data = data:reverse() end chunkData.currentPos = currentPos + size return data end end --------------------------------------------------------------- -- loadChar -- Params: chunkData -- Desc: Attempts to load a character value from the given -- chunk --------------------------------------------------------------- local function loadChar(chunkData) return loadBlock(chunkData, 1):byte() end --------------------------------------------------------------- -- loadInt -- Params: chunkData -- Desc: Attempts to load an integer value from the given chunk -- - Integer must be positive --------------------------------------------------------------- local function loadInt(chunkData) local sz = chunkData.header.intSz local intBytes = loadBlock(chunkData, sz) local int = 0 for i = sz, 1, -1 do int = shiftLeft(int, 8) + string.byte(intBytes, i) end -- If signed, negate and add one -- if (intBytes:byte(sz) > 127) then int = negateBits(int) + 1 int = -int end if (int < 0) then loadError("bad integer") end return int end --------------------------------------------------------------- -- loadSizet -- Params: chunkData -- Desc: Attempts to load a size_t value from the given chunk -- - size_t *should* be positive, but it will not error --------------------------------------------------------------- local function loadSizet(chunkData) local sz = chunkData.header.sizetSz local intBytes = loadBlock(chunkData, sz) local sizet = 0 for i = sz, 1, -1 do sizet = shiftLeft(sizet, 8) + string.byte(intBytes, i) end return sizet end --------------------------------------------------------------- -- loadNumber -- Params: chunkData -- Desc: Attempts to load a lua_Number value from the given -- chunk --------------------------------------------------------------- local function loadNumber(chunkData) local sz = chunkData.header.numberSz local numberBytes = loadBlock(chunkData, sz) local number if (sz == 4) then number = readSPFloat(numberBytes) elseif (sz == 8) then number = readDPFloat(numberBytes) else loadError("number size mismatch") end return number end --------------------------------------------------------------- -- loadString -- Params: chunkData -- Desc: Attempts to load a string from the given chunk (- nul) --------------------------------------------------------------- local function loadString(chunkData, forceSize) local sz = forceSize or loadSizet(chunkData) if (sz == 0) then return nil end -- Remove trailing nul -- local str = loadBlock(chunkData, sz):sub(1, -3) return {len = #str, data = str} end --------------------------------------------------------------- -- loadFunction -- Params: chunkData, chunkName<String> -- Desc: Attempts to load a string from the given chunk --------------------------------------------------------------- local function loadFunction(chunkData, chunkName) --------------------------------------------------------------- -- loadCode -- Params: nil -- Desc: Loads the code from the given chunk, not decoded yet --------------------------------------------------------------- local function loadCode() local sizecode = loadInt(chunkData) local code = {} for i = 1, sizecode do local sz = chunkData.header.instructionSz local instrBytes = loadBlock(chunkData, sz) local rawInstruction = 0 for i = sz, 1, -1 do rawInstruction = shiftLeft(rawInstruction, 8) + string.byte(instrBytes, i) end local opcode = clearBits(rawInstruction, 6, 31) local opmode = opmodes[opcode] local A = shiftRight(rawInstruction, 6) A = clearBits(A, 7, 31) local B = shiftRight(rawInstruction, 23) local C = shiftRight(rawInstruction, 14) C = clearBits(C, 9, 17) local Bx = shiftLeft(B, 9) + C local sBx = Bx - 0x1ffff table.insert(code, { instruction = rawInstruction, opcode = opcode, opmode = opmode, A = A, B = B, C = C, Bx = Bx, sBx = sBx }) end return code, sizecode end --------------------------------------------------------------- -- loadCode -- Params: nil -- Desc: Loads constants from the given chunk --------------------------------------------------------------- local function loadConstants(source) local sizek = loadInt(chunkData) local k = {} for i = 1, sizek do local tt = loadChar(chunkData) local value if (tt == LUA_TNIL) then value = nil elseif (tt == LUA_TBOOLEAN) then value = loadChar(chunkData) ~= 0 -- 0 = false -- elseif (tt == LUA_TNUMBER) then value = loadNumber(chunkData) elseif (tt == LUA_TSTRING) then value = loadString(chunkData) else error("bad constant") end table.insert(k, { tt = tt, value = value }) end -- Load protos -- local sizep = loadInt(chunkData) local p = {} for i = 1, sizep do table.insert(p, loadFunction(chunkData, source)) end return k, sizek, p, sizep end --------------------------------------------------------------- -- loadDebug -- Params: nil -- Desc: Loads debug information from the given chunk --------------------------------------------------------------- local function loadDebug() -- Load line position info -- local sizelineinfo = loadInt(chunkData) local lineinfo = {} for i = 1, sizelineinfo do table.insert(lineinfo, loadInt(chunkData)) end -- Load local variable info -- local sizelocvars = loadInt(chunkData) local locvars = {} for i = 1, sizelocvars do table.insert(locvars, { varname = loadString(chunkData), startpc = loadInt(chunkData), endpc = loadInt(chunkData), }) end -- Load upvalue names -- local sizeupvalues = loadInt(chunkData) local upvalues = {} for i = 1, sizeupvalues do table.insert(upvalues, loadString(chunkData)) end return lineinfo, sizelineinfo, locvars, sizelocvars, upvalues, sizeupvalues end -- Actual loadFunction routine -- local depth = chunkData.depth + 1 chunkData.depth = depth if (depth > LUAI_MAXCCALLS) then loadError("code too deep") end local f = { source = loadString(chunkData) or chunkName, linedefined = loadInt(chunkData), lastlinedefined = loadInt(chunkData), nups = loadChar(chunkData), numparams = loadChar(chunkData), is_vararg = loadChar(chunkData), maxstacksize = loadChar(chunkData), } f.code, f.sizecode = loadCode() f.k, f.sizek, f.p, f.sizep = loadConstants(f.source) f.lineinfo, f.sizelineinfo, f.locvars, f.sizelocvars, f.upvalues, f.sizeupvalues = loadDebug() chunkData.depth = depth - 1 return f end local function loadHeader(chunkData, forceDefault) local header = { signature = loadString(chunkData, #LUA_SIGNATURE), version = loadChar(chunkData), relVersion = loadChar(chunkData), endianness = loadChar(chunkData), intSz = loadChar(chunkData), sizetSz = loadChar(chunkData), instructionSz = loadChar(chunkData), numberSz = loadChar(chunkData), integral = loadChar(chunkData), } if (forceDefault) then header = LUA_DEFAULTHEADER end return header end local function DeChunk(chunk) local str local tt = type(chunk) if (tt == "function") then str = string.dump(chunk) elseif (tt == "string") then str = chunk else error("Invalid chunk"); end local chunkData = { depth = 0, -- Function depth -- currentPos = 1, -- Chunk reading position -- chunk = str, -- Actual binary chunk -- } local header = loadHeader(chunkData) chunkData.header = header local f = loadFunction(chunkData) chunkData.f = f return {header = header, f = f} end return DeChunk(...)
nilq/small-lua-stack
null
local OS=os.get() local definitions = { dir = { linux = "ls", windows = "dir" }, BOOST = { linux = "/home/dled/src/boost_1_51_0/", windows = os.getenv("BOOST") }, BOOST_LIB = { linux = path.join("/home/dled/src/boost_1_51_0/","stage/lib"), windows = path.join(os.getenv("BOOST"),"stage/lib") } } local cfg={} for i,v in pairs(definitions) do cfg[i]=definitions[i][OS] end -- Apply to current "filter" (solution/project) function DefaultConfig() location "Build" configuration "Debug" defines { "DEBUG", "_DEBUG" } objdir "Build/obj" targetdir "Build/Debug" flags { "Symbols" } configuration "Release" defines { "RELEASE" } objdir "Build/obj" targetdir "Build/Release" flags { "Optimize" } configuration "*" -- to reset configuration filter end function CompilerSpecificConfiguration() configuration {"xcode*" } -- postbuildcommands {"$TARGET_BUILD_DIR/$TARGET_NAME"} configuration {"gmake"} -- postbuildcommands { "$(TARGET)" } buildoptions { "-std=gnu++11" } configuration {"codeblocks" } -- postbuildcommands { "$(TARGET_OUTPUT_FILE)"} configuration { "vs*"} -- postbuildcommands { "\"$(TargetPath)\"" } end ---------------------------------------------------------------------------------------------------------------- -- A solution contains projects, and defines the available configurations local sln=solution "g2log-dll" location "Build" sln.absbasedir=path.getabsolute(sln.basedir) configurations { "Debug", "Release" } platforms { "native" } libdirs { cfg.BOOST_LIB } includedirs { [[../src]], cfg.BOOST } vpaths { ["Headers"] = {"**.h","**.hpp"}, ["Sources"] = {"**.c", "**.cpp"}, } ---------------------------------------------------------------------------------------------------------------- local dll=project "g2log" location "Build" kind "SharedLib" CompilerSpecificConfiguration() DefaultConfig() language "C++" files { "../src/active.h", "../src/active.cpp", "../src/crashhandler.h", "../src/crashhandler_unix.cpp",--todo configurable "../src/g2future.h", "../src/g2log.h", "../src/g2log.cpp", "../src/g2logworker.h", "../src/g2logworker.cpp", "../src/g2time.h", "../src/g2time.cpp", "../src/shared_queue.h", "g2log_dll.h", "g2log_dll.cpp" } if (OS=='linux') then links { "lua" } else links { "lua5.1" } end local simpletest=project "simpletest" local basedir="vs11test" kind "ConsoleApp" DefaultConfig() language "C++" files { path.join(basedir,"test.cpp") } uses { "g2log" } links { "g2log", "boost_timer", "boost_chrono", "boost_system", "boost_thread" } -- CompilerSpecificConfiguration() -- ConfigureGtestTuple()
nilq/small-lua-stack
null
local Option = {} Option.__index = Option Option.default = { unique = false, nargs_max = 0, default_args = {}, } function Option.new(raw_opts) vim.validate({ raw_opts = { raw_opts, "table", true } }) raw_opts = raw_opts or {} local tbl = vim.tbl_deep_extend("force", Option.default, raw_opts) return setmetatable(tbl, Option) end function Option.need_args(self) return self.nargs_max > 0 end function Option.args_string(self) local args = vim.fn["repeat"]({ "nil" }, self.nargs_max) for i, v in ipairs(self.default_args) do args[i] = vim.inspect(v, { newline = " ", indent = "" }) end return table.concat(args, ", ") end return Option
nilq/small-lua-stack
null
function love.conf(t) t.window.title = "Tower Deffense" t.window.width = 1100 t.window.height = 600 end
nilq/small-lua-stack
null
local ffi = require "ffi" local ffi_cdef = ffi.cdef local ffi_load = ffi.load local ffi_gc = ffi.gc local ffi_new = ffi.new local ffi_str = ffi.string local ffi_typeof = ffi.typeof local ffi_cast = ffi.cast local select = select local setmetatable = setmetatable local tonumber = tonumber ffi_cdef[[ struct macaroon; struct macaroon_verifier; enum macaroon_returncode { MACAROON_SUCCESS = 2048, MACAROON_OUT_OF_MEMORY = 2049, MACAROON_HASH_FAILED = 2050, MACAROON_INVALID = 2051, MACAROON_TOO_MANY_CAVEATS = 2052, MACAROON_CYCLE = 2053, MACAROON_BUF_TOO_SMALL = 2054, MACAROON_NOT_AUTHORIZED = 2055, MACAROON_NO_JSON_SUPPORT = 2056 }; struct macaroon* macaroon_create(const unsigned char* location, size_t location_sz, const unsigned char* key, size_t key_sz, const unsigned char* id, size_t id_sz, enum macaroon_returncode* err); void macaroon_destroy(struct macaroon* M); int macaroon_validate(const struct macaroon* M); struct macaroon* macaroon_add_first_party_caveat(const struct macaroon* M, const unsigned char* predicate, size_t predicate_sz, enum macaroon_returncode* err); struct macaroon* macaroon_add_third_party_caveat(const struct macaroon* M, const unsigned char* location, size_t location_sz, const unsigned char* key, size_t key_sz, const unsigned char* id, size_t id_sz, enum macaroon_returncode* err); unsigned macaroon_num_third_party_caveats(const struct macaroon* M); int macaroon_third_party_caveat(const struct macaroon* M, unsigned which, const unsigned char** location, size_t* location_sz, const unsigned char** identifier, size_t* identifier_sz); struct macaroon* macaroon_prepare_for_request(const struct macaroon* M, const struct macaroon* D, enum macaroon_returncode* err); struct macaroon_verifier* macaroon_verifier_create(); void macaroon_verifier_destroy(struct macaroon_verifier* V); int macaroon_verifier_satisfy_exact(struct macaroon_verifier* V, const unsigned char* predicate, size_t predicate_sz, enum macaroon_returncode* err); int macaroon_verifier_satisfy_general(struct macaroon_verifier* V, int (*general_check)(void* f, const unsigned char* pred, size_t pred_sz), void* f, enum macaroon_returncode* err); int macaroon_verify(const struct macaroon_verifier* V, const struct macaroon* M, const unsigned char* key, size_t key_sz, struct macaroon** MS, size_t MS_sz, enum macaroon_returncode* err); void macaroon_location(const struct macaroon* M, const unsigned char** location, size_t* location_sz); void macaroon_identifier(const struct macaroon* M, const unsigned char** identifier, size_t* identifier_sz); void macaroon_signature(const struct macaroon* M, const unsigned char** signature, size_t* signature_sz); size_t macaroon_serialize_size_hint(const struct macaroon* M); int macaroon_serialize(const struct macaroon* M, char* data, size_t data_sz, enum macaroon_returncode* err); struct macaroon* macaroon_deserialize(const char* data, enum macaroon_returncode* err); size_t macaroon_inspect_size_hint(const struct macaroon* M); int macaroon_inspect(const struct macaroon* M, char* data, size_t data_sz, enum macaroon_returncode* err); struct macaroon* macaroon_copy(const struct macaroon* M, enum macaroon_returncode* err); int macaroon_cmp(const struct macaroon* M, const struct macaroon* N); ]] local lib = ffi_load "macaroons" local rc = ffi_new "enum macaroon_returncode[1]" local cp = ffi_new "const unsigned char*[1]" local ip = ffi_new "const unsigned char*[1]" local sz = ffi_new "size_t[1]" local iz = ffi_new "size_t[1]" local cb = ffi_typeof "bool(*)(const char*, size_t pred_sz)" local mcrn_t = ffi_typeof "struct macaroon*[?]" local char_t = ffi_typeof "char[?]" local errors = {} errors[lib.MACAROON_OUT_OF_MEMORY] = "Out of memory" errors[lib.MACAROON_HASH_FAILED] = "Hash failed" errors[lib.MACAROON_INVALID] = "Invalid" errors[lib.MACAROON_TOO_MANY_CAVEATS] = "Too many caveats" errors[lib.MACAROON_CYCLE] = "Cycle" errors[lib.MACAROON_BUF_TOO_SMALL] = "Buffer too small" errors[lib.MACAROON_NOT_AUTHORIZED] = "Not authorized" errors[lib.MACAROON_NO_JSON_SUPPORT] = "No JSON support" local function callback(func) return ffi_cast(cb, function(pred, pred_sz) return func(ffi_str(pred, pred_sz), tonumber(pred_sz)) end) end local function general_check(f, pred, pred_sz) local f = ffi_cast(cb, f) return f(pred, pred_sz) and 0 or -1 end local verifier = {} verifier.__index = verifier function verifier:verify(macaroon, key, ...) local n = select("#", ...) if n == 0 then local s = lib.macaroon_verify(self.context, macaroon.context, key, #key, nil, 0, rc) local r = tonumber(rc[0]) rc[0] = lib.MACAROON_SUCCESS if s ~= 0 then if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or "Verify failed" else return nil, "Verify failed" end end if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or r end else local ms = ffi_new(mcrn_t, n) for i=1, n do ms[i-1] = select(i, ...).context end local s = lib.macaroon_verify(self.context, macaroon.context, key, #key, ms, n, rc) local r = tonumber(rc[0]) rc[0] = lib.MACAROON_SUCCESS if s ~= 0 then if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or "Verify failed" else return nil, "Verify failed" end end if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or r end end return true end function verifier:satisfy_exact(predicate) local s = lib.macaroon_verifier_satisfy_exact(self.context, predicate, #predicate, rc) local r = tonumber(rc[0]) rc[0] = lib.MACAROON_SUCCESS if s ~= 0 then if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or "Verifier unsatisfied error" else return nil, "Verifier unsatisfied error" end end if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or r end return self end function verifier:satisfy_general(func) local s = lib.macaroon_verifier_satisfy_general(self.context, general_check, callback(func), rc) local r = tonumber(rc[0]) rc[0] = lib.MACAROON_SUCCESS if s ~= 0 then if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or "General verifier unsatisfied error" else return nil, "General verifier unsatisfied error" end end if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or r end return self end local macaroons = {} function macaroons:__eq(macaroon) return self:compare(macaroon) == 0 end function macaroons:compare(macaroon) return lib.macaroon_cmp(self.context, macaroon.context) end function macaroons:__index(k) if k == "location" then lib.macaroon_location(self.context, cp, sz) return ffi_str(cp[0], sz[0]) elseif k == "identifier" then lib.macaroon_identifier(self.context, cp, sz) return ffi_str(cp[0], sz[0]) elseif k == "signature" then lib.macaroon_signature(self.context, cp, sz) return ffi_str(cp[0], sz[0]) elseif k == "third_party_caveats" then local n = lib.macaroon_num_third_party_caveats(self.context) local t = {} if n > 0 then for i = 0, n - 1 do local s = lib.macaroon_third_party_caveat(self.context, i, cp, sz, ip, iz) if s ~= 0 then return nil, errors[s] or s end t[i+1] = { location = ffi_str(cp[0], sz[0]), id = ffi_str(ip[0], iz[0]) } end end return t else return macaroons[k] end end function macaroons.create(location, key, id) local context = lib.macaroon_create(location, #location, key, #key, id, #id, rc) local r = tonumber(rc[0]) rc[0] = 0 if context == nil then if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or "Unable to create macaroon" else return nil, "Unable to create macaroon" end end if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or r end return setmetatable({ context = ffi_gc(context, lib.macaroon_destroy) }, macaroons) end function macaroons.deserialize(data) local context = lib.macaroon_deserialize(data, rc) local r = tonumber(rc[0]) rc[0] = lib.MACAROON_SUCCESS if context == nil then if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or "Deserialize failed" else return nil, "Deserialize failed" end end if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or r end return setmetatable({ context = ffi_gc(context, lib.macaroon_destroy) }, macaroons) end function macaroons.verifier() local context = lib.macaroon_verifier_create() if context == nil then return nil, "Unable to create verifier" end return setmetatable({ context = ffi_gc(context, lib.macaroon_verifier_destroy) }, verifier) end function macaroons:serialize() local n = lib.macaroon_serialize_size_hint(self.context) local b = ffi_new(char_t, n) local s = lib.macaroon_serialize(self.context, b, n, rc) local r = tonumber(rc[0]) rc[0] = lib.MACAROON_SUCCESS if s ~= 0 then if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or "Serialize failed" else return nil, "Serialize failed" end end if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or r end return ffi_str(b) end function macaroons:inspect() local n = lib.macaroon_inspect_size_hint(self.context) local b = ffi_new(char_t, n) local s = lib.macaroon_inspect(self.context, b, n, rc) local r = tonumber(rc[0]) rc[0] = lib.MACAROON_SUCCESS if s ~= 0 then if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or "Inspect failed" else return nil, "Inspect failed" end end if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or r end return ffi_str(b) end function macaroons:add_first_party_caveat(predicate) local context = lib.macaroon_add_first_party_caveat(self.context, predicate, #predicate, rc) local r = tonumber(rc[0]) rc[0] = lib.MACAROON_SUCCESS if context == nil then if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or "Unable to add first party caveat" else return nil, "Unable to add first party caveat" end end if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or r end return setmetatable({ context = ffi_gc(context, lib.macaroon_destroy) }, macaroons) end function macaroons:add_third_party_caveat(location, key, id) local context = lib.macaroon_add_third_party_caveat(self.context, location, #location, key, #key, id, #id, rc) local r = tonumber(rc[0]) rc[0] = lib.MACAROON_SUCCESS if context == nil then if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or "Unable to add third party caveat" else return nil, "Unable to add third party caveat" end end if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or r end return setmetatable({ context = ffi_gc(context, lib.macaroon_destroy) }, macaroons) end function macaroons:prepare_for_request(d) local context = lib.macaroon_prepare_for_request(self.context, d.context, rc) local r = tonumber(rc[0]) rc[0] = lib.MACAROON_SUCCESS if context == nil then if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or "Unable to prepare for request" else return nil, "Unable to prepare for request" end end if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or r end return setmetatable({ context = ffi_gc(context, lib.macaroon_destroy) }, macaroons) end function macaroons:copy() local context = lib.macaroon_copy(self.context, rc) local r = tonumber(rc[0]) rc[0] = lib.MACAROON_SUCCESS if context == nil then if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or "Unable to copy macaroon" else return nil, "Unable to copy macaroon" end end if r ~= 0 and r ~= lib.MACAROON_SUCCESS then return nil, errors[r] or r end return setmetatable({ context = ffi_gc(context, lib.macaroon_destroy) }, macaroons) end function macaroons:validate() return lib.macaroon_validate(self.context) == 0 end return macaroons
nilq/small-lua-stack
null
-- Example configuations here: https://github.com/mattn/efm-langserver -- TODO this file needs to be refactored eache lang should be it's own file -- python local python_arguments = {} -- TODO replace with path argument local flake8 = { LintCommand = "flake8 --ignore=E501 --stdin-display-name ${INPUT} -", lintStdin = true, lintFormats = {"%f:%l:%c: %m"} } local isort = {formatCommand = "isort --quiet -", formatStdin = true} local yapf = {formatCommand = "yapf --quiet", formatStdin = true} local black = {formatCommand = "black --quiet -", formatStdin = true} if O.lang.python.linter == 'flake8' then table.insert(python_arguments, flake8) end if O.lang.python.isort then table.insert(python_arguments, isort) end if O.lang.python.formatter == 'yapf' then table.insert(python_arguments, yapf) elseif O.lang.python.formatter == 'black' then table.insert(python_arguments, black) end -- lua local lua_arguments = {} local luaFormat = { formatCommand = "lua-format -i --no-keep-simple-function-one-line --column-limit=80", formatStdin = true } local lua_fmt = { formatCommand = "luafmt --indent-count 2 --line-width 120 --stdin", formatStdin = true } if O.lang.lua.formatter == 'lua-format' then table.insert(lua_arguments, luaFormat) elseif O.lang.lua.formatter == 'lua-fmt' then table.insert(lua_arguments, lua_fmt) end -- sh local sh_arguments = {} local shfmt = {formatCommand = 'shfmt -ci -s -bn', formatStdin = true} local shellcheck = { LintCommand = 'shellcheck -f gcc -x', lintFormats = {'%f:%l:%c: %trror: %m', '%f:%l:%c: %tarning: %m', '%f:%l:%c: %tote: %m'} } if O.lang.sh.formatter == 'shfmt' then table.insert(sh_arguments, shfmt) end if O.lang.sh.linter == 'shellcheck' then table.insert(sh_arguments, shellcheck) end -- tsserver/web javascript react, vue, json, html, css, yaml local prettier = {formatCommand = "prettier --stdin-filepath ${INPUT}", formatStdin = true} -- You can look for project scope Prettier and Eslint with e.g. vim.fn.glob("node_modules/.bin/prettier") etc. If it is not found revert to global Prettier where needed. -- local prettier = {formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}", formatStdin = true} local eslint = { lintCommand = "./node_modules/.bin/eslint -f unix --stdin --stdin-filename ${INPUT}", lintIgnoreExitCode = true, lintStdin = true, lintFormats = {"%f:%l:%c: %m"}, formatCommand = "./node_modules/.bin/eslint --fix-to-stdout --stdin --stdin-filename=${INPUT}", formatStdin = true } local tsserver_args = {} if O.lang.tsserver.formatter == 'prettier' then table.insert(tsserver_args, prettier) end if O.lang.tsserver.linter == 'eslint' then table.insert(tsserver_args, eslint) end -- local markdownlint = { -- -- TODO default to global lintrc -- -- lintcommand = 'markdownlint -s -c ./markdownlintrc', -- lintCommand = 'markdownlint -s', -- lintStdin = true, -- lintFormats = {'%f:%l %m', '%f:%l:%c %m', '%f: %l: %m'} -- } local markdownPandocFormat = {formatCommand = 'pandoc -f markdown -t gfm -sp --tab-stop=2', formatStdin = true} require"lspconfig".efm.setup { -- init_options = {initializationOptions}, cmd = {DATA_PATH .. "/lspinstall/efm/efm-langserver"}, init_options = {documentFormatting = true, codeAction = false}, filetypes = {"lua", "python", "javascriptreact", "javascript", "typescript","typescriptreact","sh", "html", "css", "json", "yaml", "markdown", "vue"}, settings = { rootMarkers = {".git/"}, languages = { python = python_arguments, lua = lua_arguments, sh = sh_arguments, javascript = tsserver_args, javascriptreact = tsserver_args, typescript = tsserver_args, typescriptreact = tsserver_args, html = {prettier}, css = {prettier}, json = {prettier}, yaml = {prettier}, markdown = {markdownPandocFormat} -- javascriptreact = {prettier, eslint}, -- javascript = {prettier, eslint}, -- markdown = {markdownPandocFormat, markdownlint}, } } } -- Also find way to toggle format on save -- maybe this will help: https://superuser.com/questions/439078/how-to-disable-autocmd-or-augroup-in-vim
nilq/small-lua-stack
null
local Native = require('lib.native.native') ---@class Button : Agent local Button = class('Button', assert(require('lib.oop.agent'))) return Button
nilq/small-lua-stack
null
-- Copyright 2019 (c) superfunc -- See LICENSE file for conditions of usage. -- -- This file provides a simple prune function (with basic perf tests below) -- for fast removal from an array, when order doesn't matter -- Since order of elements doesn't matter to us, we can efficiently -- remove by using heap-style deletion. We swap 'dead' entites with the -- end element (which is cheap, its just a few numbers), and then trim -- the end element off with table:remove, avoiding sliding all elements down. function remove(t, i) t[i], t[#t] = t[#t], t[i] table.remove(t, #t) end function prune(t, shouldPrune) local i = 1 while i <= #t do if shouldPrune(t[i]) then remove(t, i) else i = i + 1 end end end function traditionalPrune(t, shouldPrune) local i = 1 while i <= #t do if shouldPrune(t[i]) then table.remove(t, i) else i = i + 1 end end end function pruneFn(n) return n < 5 end function printArray(t) print("Array of length: " .. #t) local str = "" for i=1,#t do str = str .. "[" .. t[i] .. "]" end print(str) end function testRemovals(N) local ts1 = {} local ts2 = {} --print("Testing for array of size N: " .. N) -- Fill the arrays with identical data for i=1,N do k = math.random(10) ts1[i] = k ts2[i] = k end -- Time traditional pruning local t0 = os.clock() traditionalPrune(ts1, pruneFn) local t1 = os.clock() --print("traditional prune removal: ", (t1-t0)) -- Time swapping based pruning t2 = os.clock() prune(ts2, pruneFn) t3 = os.clock() --print("swapping prune removal: ", (t3-t2)) -- Ensure the overall contents remain the same --print("length_1: " .. #ts1) --print("length_2: " .. #ts2) assert(#ts1==#ts2) table.sort(ts1) table.sort(ts2) for i=1,#ts1 do assert(ts1[i] == ts2[i]) end --print("contents equal") return t3-t2, t1-t0 end function testAverage(N) local sumPrune, sumTraditional = 0, 0 for _=1,5 do p, t = testRemovals(N) sumPrune = sumPrune + p sumTraditional = sumTraditional + t end print("[prune] Average time for size " .. N .. ": " .. sumPrune/10.0) print("[traditional] Average time for size " .. N .. ": " .. sumTraditional/10.0) end print("Testing small sizes") testAverage(50) testAverage(100) testAverage(250) testAverage(500) testAverage(1000) print("Testing moderate sizes") testAverage(2500) testAverage(5000) testAverage(10000) testAverage(25000) testAverage(50000)
nilq/small-lua-stack
null
return {'aha'}
nilq/small-lua-stack
null
AddCSLuaFile() AddCSLuaFile("sh_sounds.lua") include("sh_sounds.lua") if CLIENT then SWEP.DrawCrosshair = false SWEP.PrintName = "FN P90" SWEP.CSMuzzleFlashes = true SWEP.ViewModelMovementScale = 1.15 SWEP.IconLetter = "m" killicon.AddFont("cw_p90", "CW_KillIcons", SWEP.IconLetter, Color(255, 80, 0, 150)) SWEP.MuzzleEffect = "muzzleflash_6" SWEP.PosBasedMuz = true SWEP.SnapToGrip = true SWEP.ShellScale = 0.7 SWEP.ShellOffsetMul = 1 SWEP.ShellPosOffset = {x = 0, y = 0, z = 0} SWEP.ForeGripOffsetCycle_Draw = 0 SWEP.ForeGripOffsetCycle_Reload = 0.65 SWEP.ForeGripOffsetCycle_Reload_Empty = 0.9 SWEP.CustomizePos = Vector(-2.980, -3.666, -0.195) SWEP.CustomizeAng = Vector(19.351, -29.664, -10) SWEP.IronsightPos = Vector(3.855, -3, 0.810) SWEP.IronsightAng = Vector(2, 0, 0) SWEP.EoTechPos = Vector(3.83, -7, 0.5) SWEP.EoTechAng = Vector(0, 0, 0) SWEP.AimpointPos = Vector(3.86, -7, 0.71) --LOL 69 xD SWEP.AimpointAng = Vector(0, 0, 0) SWEP.CmorePos = Vector(3.855, -7.3, 0.74) SWEP.CmoreAng = Vector(0, 0, 0) SWEP.MicroT1Pos = Vector(3.855, -2, 0.835) SWEP.MicroT1Ang = Vector(0, 0, 0) SWEP.ReflexPos = Vector(3.848, -8, 0.85) SWEP.ReflexAng = Vector(0, 0, 0) SWEP.AlternativePos = Vector(1.20, 0.795, -0.12) SWEP.AlternativeAng = Vector(0, 0, 0) SWEP.SprintPos = Vector(-1.359, -1.962, 0) SWEP.SprintAng = Vector(-7.702, -28.283, 0) SWEP.CustomizationMenuScale = 0.012 SWEP.BaseArm = "Bip01 L Clavicle" SWEP.BaseArmBoneOffset = Vector(-50, 0, 0) SWEP.AttachmentModelsVM = { ["md_aimpoint"] = {model = "models/wystan/attachments/aimpoint.mdl", bone = "Body", rel = "", pos = Vector(-2.38, -4.255, -7.04), angle = Angle(0, 180, 0), size = Vector(0.9, 0.9, 0.9)}, ["md_eotech"] = {model = "models/wystan/attachments/2otech557sight.mdl", bone = "Body", rel = "", pos = Vector(-2.9, 1.332, -13), angle = Angle(2, 90, 0), size = Vector(1, 1, 1)}, ["md_cmore"] = { type = "Model", model = "models/attachments/cmore.mdl", bone = "Body", rel = "", pos = Vector(-2.61, -10.061, -2), angle = Angle(0, 180, 0), size = Vector(0.7, 0.7, 0.7), color = Color(255, 255, 255, 0), surpresslightning = false, material = "", skin = 0, bodygroup = {} }, ["md_reflex"] = { type = "Model", model = "models/attachments/kascope.mdl", bone = "Body", rel = "", pos = Vector(-2.6, -12.519, -1.735), angle = Angle(0, 180, 0), size = Vector(0.7, 0.7, 0.7), color = Color(255, 255, 255, 255)}, ["md_tundra9mm"] = {model = "models/cw2/attachments/9mmsuppressor.mdl", bone = "Body", pos = Vector(-2.6, -18.668, -6.14), angle = Angle(0, 0, 0), size = Vector(1.2, 1.2, 1.2)}, ["md_microt1"] = {model = "models/cw2/attachments/microt1.mdl", bone = "Body", pos = Vector(-2.62, -10.057, -1.82), angle = Angle(0, 0, 0), size = Vector(0.38, 0.38, 0.38)}, ["md_anpeq15"] = {model = "models/cw2/attachments/anpeq15.mdl", bone = "Body", pos = Vector(-3.15, -12, -2.5), angle = Angle(0, -90, 90), size = Vector(0.4, 0.4, 0.4)} } SWEP.LaserPosAdjust = Vector(0, 0, 0) SWEP.LaserAngAdjust = Angle(0, 180, 0) end SWEP.SightBGs = {main = 1, none = 1} SWEP.LuaViewmodelRecoil = true SWEP.Attachments = {[1] = {header = "Sight", offset = {500, -450}, atts = {"md_microt1", "md_cmore", "md_reflex", "md_eotech", "md_aimpoint"}}, [2] = {header = "Barrel", offset = {-500, -450}, atts = {"md_tundra9mm"}}, [3] = {header = "Rail", offset = {-500, 50}, atts = {"md_anpeq15"}}, ["+reload"] = {header = "Ammo", offset = {700, 0}, atts = {"am_hollowpoint", "am_armorpiercing"}}} SWEP.Animations = {fire = {"shoot1", "shoot2", "shoot3"}, reload = "reload", idle = "idle", draw = "draw"} SWEP.Sounds = {draw = {{time = 0, sound = "CW_P90_DRAW"}}, reload = {[1] = {time = 0.4, sound = "CW_P90_MAGRELEASE"}, [2] = {time = 0.6, sound = "CW_P90_MAGOUT"}, [3] = {time = 1.75, sound = "CW_P90_MAGIN"}, [4] = {time = 2.6, sound = "CW_P90_BOLT"}}} SWEP.SpeedDec = 20 SWEP.Slot = 3 SWEP.SlotPos = 0 SWEP.NormalHoldType = "smg" SWEP.HoldType = "smg" SWEP.RunHoldType = "crossbow" SWEP.FireModes = {"auto", "semi"} SWEP.Base = "cw_base" SWEP.Category = "STALKER Weapons" SWEP.Author = "gumlefar & verne" SWEP.Contact = "" SWEP.Purpose = "" SWEP.Instructions = "" SWEP.ViewModelFOV = 70 SWEP.ViewModelFlip = true SWEP.ViewModel = "models/weapons/therambotnic09/v_cst_p90.mdl" SWEP.WorldModel = "models/weapons/therambotnic09/w_cst_p90.mdl" SWEP.DrawTraditionalWorldModel = false SWEP.WM = "models/weapons/therambotnic09/w_cst_p90.mdl" SWEP.WMPos = Vector(-1, 0, -2) SWEP.WMAng = Vector(-10, 0, 180) SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.Primary.ClipSize = 50 SWEP.Primary.DefaultClip = 0 SWEP.Primary.Automatic = true SWEP.Primary.Ammo = "5.7x28MM" SWEP.WearDamage = 0.1 SWEP.WearEffect = 0.05 SWEP.FireDelay = 0.07 SWEP.FireSound = "CW_P90_FIRE" SWEP.FireSoundSuppressed = "CW_P90_FIRE_SUPPRESSED" SWEP.Recoil = 1.2 SWEP.HipSpread = 0.1 SWEP.AimSpread = 0.015 SWEP.VelocitySensitivity = 1 SWEP.MaxSpreadInc = 0.4 SWEP.SpreadPerShot = 0.007 SWEP.SpreadCooldown = 0.4 SWEP.Shots = 1 SWEP.Damage = 47 SWEP.DeployTime = 0.6 SWEP.ReloadSpeed = 0.93 SWEP.ReloadTime = 2.5 SWEP.ReloadTime_Empty = 3.3 SWEP.ReloadHalt = 2.5 SWEP.ReloadHalt_Empty = 3.3 SWEP.SnapToIdlePostReload = true
nilq/small-lua-stack
null
--[[---------------------------------------------------------------------------- Copyright (c) 2016-present, Facebook, Inc. All rights reserved. This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree. An additional grant of patent rights can be found in the PATENTS file in the same directory. ------------------------------------------------------------------------------]] -- script to run the python coco tester on the saved results file from run_test.lua -- local testCoco = {} local Coco = require 'testCoco.coco' local loader = require 'loaders.dataloader' require 'xlua' local function getAboxes(res, class) if type(res) == 'string' then -- res_folder return torch.load(('%s/%.2d.t7'):format(res, class)) elseif type(res) == 'table' or type(res) == 'cdata' then -- table or tds.hash return res[class] else error("Unknown res object: type " .. type(res)) end end local annotations_path = 'data/annotations/' function testCoco.evaluate(dataset_name, res) local annFile if dataset_name == 'coco_val2014' then annFile = 'instances_val2014.json' elseif dataset_name == 'pascal_test2007' then annFile = 'pascal_test2007.json' end annFile = paths.concat(annotations_path, annFile) local dataset = loader(dataset_name) print("Loading COCO image ids...") local image_ids = {} for i = 1, dataset:nImages() do if i % 10000 == 0 then print(" "..i..'/'..dataset:nImages()) end image_ids[i] = dataset:getImage(i).id end print('#image_ids',#image_ids) local nClasses = dataset:nCategories() print("Loading files to calculate sizes...") local nboxes = 0 for class = 1, nClasses do local aboxes = getAboxes(res, class) for _,u in pairs(aboxes) do if u:nDimension() > 0 then nboxes = nboxes + u:size(1) end end -- xlua.progress(class, nClasses) end print("Total boxes: " .. nboxes) local boxt = torch.FloatTensor(nboxes, 7) print("Loading files to create giant tensor...") local offset = 1 for class = 1, nClasses do local aboxes = getAboxes(res, class) for img,t in pairs(aboxes) do if t:nDimension() > 0 then local sub = boxt:narrow(1,offset,t:size(1)) sub:select(2, 1):fill(image_ids[img]) -- image ID sub:select(2, 2):copy(t:select(2, 1) - 1) -- x1 0-indexed sub:select(2, 3):copy(t:select(2, 2) - 1) -- y1 0-indexed sub:select(2, 4):copy(t:select(2, 3) - t:select(2, 1)) -- w sub:select(2, 5):copy(t:select(2, 4) - t:select(2, 2)) -- h sub:select(2, 6):copy(t:select(2, 5)) -- score sub:select(2, 7):fill(dataset.data.categories.id[class]) -- class offset = offset + t:size(1) end end -- xlua.progress(class, nClasses) end local coco = Coco(annFile) return coco:evaluate(boxt) end return testCoco
nilq/small-lua-stack
null
require("ai.actions.movebase") function WalkCreaturePet:checkConditions(pAgent) if (pAgent ~= nil) then local agent = AiAgent(pAgent) local creature = CreatureObject(pAgent) if (creature:getPosture() == UPRIGHT and agent:getFollowState() == PATROLLING) then agent:setDestination() return true end end return false end function WalkDroidPet:checkConditions(pAgent) if (pAgent ~= nil) then local agent = AiAgent(pAgent) local creature = CreatureObject(pAgent) if (creature:getPosture() == UPRIGHT and agent:getFollowState() == PATROLLING) then agent:setDestination() return true end end return false end function WalkFactionPet:checkConditions(pAgent) if (pAgent ~= nil) then local agent = AiAgent(pAgent) local creature = CreatureObject(pAgent) if (creature:getPosture() == UPRIGHT and agent:getFollowState() == PATROLLING) then agent:setDestination() return true end end return false end
nilq/small-lua-stack
null
function SpawnRegions() return { { name = "East Bridge", file = "media/maps/East Bridge/spawnpoints.lua" }, } end
nilq/small-lua-stack
null
local mail_config = {} mail_config['from'] = "<zhoulipeng@svi-tech.com.cn>" mail_config['rcpt'] = "<zlpayqiong@163.com>" mail_config['server'] = "smtp.qiye.163.com" mail_config['domain'] = "qiye.163.com" mail_config['user'] = "zhoulipeng@svi-tech.com.cn" mail_config['password'] = "dafault" return mail_config
nilq/small-lua-stack
null
-- https://github.com/Yggdroot/indentLine use 'Yggdroot/indentLine' --Beautiful indent lines let g:indentLine_enabled = 1 let g:indentLine_char='│' let g:indentLine_conceallevel = 2 let g:indentLine_color_term = 239 let g:indentLine_concealcursor = '' let g:indentLine_color_gui = '#A4E57E' let g:indentLine_color_tty_light = 7 -- (default: 4) let g:indentLine_color_dark = 1 -- (default: 2) let g:indentLine_maxLines = 1000 let g:indentLine_fileTypeExclude = ['json', 'md'] -- let g:indentLine_setConceal = 0 --0->Show quotes; 1or2->Hide quotes -- --let g:indentLine_setColors = 0 -- let g:indentLine_bgcolor_term = 202 -- let g:indentLine_bgcolor_gui = '#FF5F00' -- BUGS FOR JSON FORMAT --> It hdie/conceal quotes for JSON !!! -- autocmd FileType json set conceallevel = 0 --Manually -- autocmd FileType json let g:indentLine_enabled=0 -- let g:vim_json_syntax_conceal=0 -- If none is working, make sure there's no other JSON plugins, -- then edit the `json.vim` ---> -- :e $VIMRUNTIME/syntax/json.vim -- :g/if has('conceal')/s//& \&\& 0/ -- :wq
nilq/small-lua-stack
null
object_draft_schematic_dance_prop_prop_combat_fan_l = object_draft_schematic_dance_prop_shared_prop_combat_fan_l:new { } ObjectTemplates:addTemplate(object_draft_schematic_dance_prop_prop_combat_fan_l, "object/draft_schematic/dance_prop/prop_combat_fan_l.iff")
nilq/small-lua-stack
null
-- This also define the namespace and should be the first file loaded local A, GreyHandling = ... GreyHandling.frame = CreateFrame("Frame") GreyHandling.loot_frame = CreateFrame("Frame") GreyHandling.chat_frame = CreateFrame("Frame") GreyHandling.member_leave_frame = CreateFrame("Frame") GreyHandling.functions = {} GreyHandling.db = {} GreyHandling.SELL_PRICE_TEXT = format("%s:", SELL_PRICE) GreyHandling.IS_CLASSIC = true GreyHandling.NAME = "GreyHandling" GreyHandling.SHORT_NAME = "GH" GreyHandling.DISPLAY_NAME = "Grey Handling" GreyHandling.MAX_CHAR_IN_CHAT_LOOT_MESSAGE = 255 GreyHandling.DEVELOPMENT_VERSION = false -- /console scriptErrors 1 GreyHandling.DEV_TRADE_ONLY = true GreyHandling.DESCRIPTION = GetAddOnMetadata(GreyHandling.NAME, "NOTES") GreyHandling.options = {} GreyHandling.options.frame = CreateFrame("FRAME") GreyHandling.CHAT_COMMAND = "/gh" GreyHandling.options.DEFAULT_TALKATIVE = true GreyHandling.options.DEFAULT_VERBOSE = true GreyHandling.options.DEFAULT_SHOW_PRICE = true GreyHandling.options.DEFAULT_SHOW_API_FAIL = false GreyHandling.options.DEFAULT_WHAT_IS_JUNK = "Grey items" GreyHandling.options.DEFAULT_DEACTIVATE_DEFAULT_KEYBIND = false GreyHandling.options.DEFAULT_SHOW_CHEAPEST_ALWAYS = true GreyHandling.redPrint = "ff4d4d" GreyHandling.greyPrint = "a0a0a0" GreyHandling.bluePrint = "6699ff" local numberOfTries = 0 while not C_ChatInfo.RegisterAddonMessagePrefix(GreyHandling.NAME) and numberOfTries < 10 do GreyHandling.print(format(GreyHandling["Failed to create communication channel (%s))"], numberOfTries)) numberOfTries = numberOfTries + 1 end function GreyHandling.print(str) -- |cff is a wow keyword print("|cff"..GreyHandling.greyPrint..tostring(GreyHandling.SHORT_NAME).."|r: "..str) end
nilq/small-lua-stack
null
-- Used to retarget VS solution and projects. -- Returns version of Windows SDK. edge.getWindowsSDKVersion = function() local reg_arch = iif( os.is64bit(), "\\Wow6432Node\\", "\\" ) local sdk_version = os.getWindowsRegistry( "HKLM:SOFTWARE" .. reg_arch .."Microsoft\\Microsoft SDKs\\Windows\\v10.0\\ProductVersion" ) if sdk_version ~= nil then return sdk_version end end
nilq/small-lua-stack
null
Bartender4DB = { ["namespaces"] = { ["StatusTrackingBar"] = { ["profiles"] = { ["Nevaar - Thrall"] = { ["enabled"] = true, ["version"] = 3, ["position"] = { ["scale"] = 1.264999985694885, ["x"] = -515, ["point"] = "BOTTOM", ["y"] = 62, }, }, ["Ischozar - Thrall"] = { ["enabled"] = true, ["version"] = 3, ["position"] = { ["scale"] = 1.264999985694885, ["x"] = -515, ["point"] = "BOTTOM", ["y"] = 62, }, }, ["Drâon - Thrall"] = { ["enabled"] = true, ["version"] = 3, ["position"] = { ["scale"] = 1.264999985694885, ["x"] = -515, ["point"] = "BOTTOM", ["y"] = 62, }, }, }, }, ["ActionBars"] = { ["profiles"] = { ["Nevaar - Thrall"] = { ["actionbars"] = { { ["padding"] = 6, ["version"] = 3, ["position"] = { ["y"] = 41.75, ["x"] = -510, ["point"] = "BOTTOM", }, }, -- [1] { ["enabled"] = false, ["version"] = 3, ["position"] = { ["y"] = -227.4998474121094, ["x"] = -231.5001831054688, ["point"] = "CENTER", }, }, -- [2] { ["padding"] = 5, ["rows"] = 12, ["version"] = 3, ["position"] = { ["y"] = 610, ["x"] = -82, ["point"] = "BOTTOMRIGHT", }, }, -- [3] { ["padding"] = 5, ["rows"] = 12, ["version"] = 3, ["position"] = { ["y"] = 610, ["x"] = -42, ["point"] = "BOTTOMRIGHT", }, }, -- [4] { ["padding"] = 6, ["version"] = 3, ["position"] = { ["y"] = 110, ["x"] = 3, ["point"] = "BOTTOM", }, }, -- [5] { ["padding"] = 6, ["version"] = 3, ["position"] = { ["y"] = 110, ["x"] = -510, ["point"] = "BOTTOM", }, }, -- [6] { }, -- [7] { }, -- [8] [10] = { }, }, }, ["RealUI-Healing"] = { ["actionbars"] = { { ["version"] = 3, ["position"] = { ["y"] = -199.5, ["x"] = -171.5, ["point"] = "CENTER", }, ["flyoutDirection"] = "DOWN", ["hidemacrotext"] = true, ["visibility"] = { ["custom"] = true, ["customdata"] = "[mod:ctrl][@focus,exists][harm,nodead][combat][group:party][group:raid][vehicleui]][overridebar][cursor]show;hide", }, ["padding"] = -9, }, -- [1] { ["version"] = 3, ["position"] = { ["y"] = 89, ["x"] = -171.5, ["point"] = "BOTTOM", }, ["padding"] = -9, ["visibility"] = { ["custom"] = true, ["customdata"] = "[petbattle][overridebar][vehicleui][possessbar,@vehicle,exists]hide;[mod:ctrl][@focus,exists][harm,nodead][combat][group:party][group:raid][vehicleui][cursor]show;hide", }, ["hidemacrotext"] = true, }, -- [2] { ["version"] = 3, ["position"] = { ["y"] = 62, ["x"] = -171.5, ["point"] = "BOTTOM", }, ["padding"] = -9, ["visibility"] = { ["custom"] = true, ["customdata"] = "[petbattle][overridebar][vehicleui][possessbar,@vehicle,exists]hide;[mod:ctrl][@focus,exists][harm,nodead][combat][group:party][group:raid][vehicleui][cursor]show;hide", }, ["hidemacrotext"] = true, }, -- [3] { ["flyoutDirection"] = "LEFT", ["hidemacrotext"] = true, ["version"] = 3, ["position"] = { ["y"] = 334.5, ["x"] = -36, ["point"] = "RIGHT", }, ["padding"] = -9, ["rows"] = 12, ["visibility"] = { ["custom"] = true, ["customdata"] = "[petbattle][overridebar][vehicleui][possessbar,@vehicle,exists]hide;[mod:ctrl][cursor]show;fade", }, ["fadeoutalpha"] = 0, }, -- [4] { ["flyoutDirection"] = "LEFT", ["hidemacrotext"] = true, ["version"] = 3, ["position"] = { ["y"] = 10.5, ["x"] = -36, ["point"] = "RIGHT", }, ["padding"] = -9, ["rows"] = 12, ["visibility"] = { ["custom"] = true, ["customdata"] = "[petbattle][overridebar][vehicleui][possessbar,@vehicle,exists]hide;[mod:ctrl][cursor]show;fade", }, ["fadeoutalpha"] = 0, }, -- [5] { ["enabled"] = false, }, -- [6] }, }, ["RealUI"] = { ["actionbars"] = { { ["flyoutDirection"] = "DOWN", ["version"] = 3, ["position"] = { ["y"] = -250.5, ["x"] = -171.5, ["point"] = "CENTER", }, ["padding"] = -9, ["hidemacrotext"] = true, ["visibility"] = { ["custom"] = true, ["customdata"] = "[mod:ctrl][@focus,exists][harm,nodead][combat][group:party][group:raid][vehicleui]][overridebar][cursor]show;hide", }, }, -- [1] { ["flyoutDirection"] = "DOWN", ["hidemacrotext"] = true, ["version"] = 3, ["position"] = { ["y"] = -277.5, ["x"] = -171.5, ["point"] = "CENTER", }, ["padding"] = -9, ["visibility"] = { ["custom"] = true, ["customdata"] = "[petbattle][overridebar][vehicleui][possessbar,@vehicle,exists]hide;[mod:ctrl][@focus,exists][harm,nodead][combat][group:party][group:raid][vehicleui][cursor]show;hide", }, }, -- [2] { ["padding"] = -9, ["version"] = 3, ["position"] = { ["y"] = 60, ["x"] = -171.5, ["point"] = "BOTTOM", }, ["hidemacrotext"] = true, ["visibility"] = { ["custom"] = true, ["customdata"] = "[petbattle][overridebar][vehicleui][possessbar,@vehicle,exists]hide;[mod:ctrl][@focus,exists][harm,nodead][combat][group:party][group:raid][vehicleui][cursor]show;hide", }, }, -- [3] { ["flyoutDirection"] = "LEFT", ["rows"] = 12, ["version"] = 3, ["fadeoutalpha"] = 0, ["position"] = { ["y"] = 334.5, ["x"] = -36, ["point"] = "RIGHT", }, ["padding"] = -9, ["hidemacrotext"] = true, ["visibility"] = { ["custom"] = true, ["customdata"] = "[petbattle][overridebar][vehicleui][possessbar,@vehicle,exists]hide;[mod:ctrl][cursor]show;fade", }, }, -- [4] { ["flyoutDirection"] = "LEFT", ["rows"] = 12, ["version"] = 3, ["fadeoutalpha"] = 0, ["position"] = { ["y"] = 10.5, ["x"] = -36, ["point"] = "RIGHT", }, ["padding"] = -9, ["hidemacrotext"] = true, ["visibility"] = { ["custom"] = true, ["customdata"] = "[petbattle][overridebar][vehicleui][possessbar,@vehicle,exists]hide;[mod:ctrl][cursor]show;fade", }, }, -- [5] { ["enabled"] = false, }, -- [6] { }, -- [7] { }, -- [8] nil, -- [9] { }, -- [10] }, }, ["Ischozar - Thrall"] = { ["actionbars"] = { { ["padding"] = 6, ["version"] = 3, ["position"] = { ["y"] = 41.75, ["x"] = -510, ["point"] = "BOTTOM", }, }, -- [1] { ["enabled"] = false, ["version"] = 3, ["position"] = { ["y"] = -227.4998474121094, ["x"] = -231.5001831054688, ["point"] = "CENTER", }, }, -- [2] { ["padding"] = 5, ["rows"] = 12, ["version"] = 3, ["position"] = { ["y"] = 610, ["x"] = -82, ["point"] = "BOTTOMRIGHT", }, }, -- [3] { ["padding"] = 5, ["rows"] = 12, ["version"] = 3, ["position"] = { ["y"] = 610, ["x"] = -42, ["point"] = "BOTTOMRIGHT", }, }, -- [4] { ["padding"] = 6, ["version"] = 3, ["position"] = { ["y"] = 110, ["x"] = 3, ["point"] = "BOTTOM", }, }, -- [5] { ["padding"] = 6, ["version"] = 3, ["position"] = { ["y"] = 110, ["x"] = -510, ["point"] = "BOTTOM", }, }, -- [6] { }, -- [7] { }, -- [8] [10] = { }, }, }, ["Drâon - Thrall"] = { ["actionbars"] = { { ["padding"] = 6, ["version"] = 3, ["position"] = { ["y"] = 41.75, ["x"] = -510, ["point"] = "BOTTOM", }, }, -- [1] { ["enabled"] = false, ["version"] = 3, ["position"] = { ["y"] = -227.4998474121094, ["x"] = -231.5001831054688, ["point"] = "CENTER", }, }, -- [2] { ["rows"] = 12, ["padding"] = 5, ["version"] = 3, ["position"] = { ["y"] = 610, ["x"] = -82, ["point"] = "BOTTOMRIGHT", }, }, -- [3] { ["rows"] = 12, ["padding"] = 5, ["version"] = 3, ["position"] = { ["y"] = 610, ["x"] = -42, ["point"] = "BOTTOMRIGHT", }, }, -- [4] { ["padding"] = 6, ["version"] = 3, ["position"] = { ["y"] = 110, ["x"] = 3, ["point"] = "BOTTOM", }, }, -- [5] { ["padding"] = 6, ["version"] = 3, ["position"] = { ["y"] = 110, ["x"] = -510, ["point"] = "BOTTOM", }, }, -- [6] { }, -- [7] { }, -- [8] [10] = { }, }, }, }, }, ["LibDualSpec-1.0"] = { ["char"] = { ["Nevaar - Thrall"] = { "RealUI-Healing", -- [1] "RealUI", -- [2] "RealUI", -- [3] ["enabled"] = true, }, ["Ischozar - Thrall"] = { "RealUI", -- [1] "RealUI", -- [2] "RealUI", -- [3] ["enabled"] = true, }, ["Drâon - Thrall"] = { "RealUI", -- [1] "RealUI", -- [2] "RealUI", -- [3] ["enabled"] = true, }, }, }, ["ExtraActionBar"] = { ["profiles"] = { ["Nevaar - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = 223.0000305175781, ["x"] = -31.50006103515625, ["point"] = "BOTTOM", }, }, ["RealUI-Healing"] = { ["version"] = 3, ["position"] = { ["y"] = 86, ["x"] = 157.5, ["point"] = "BOTTOM", ["scale"] = 0.985, }, }, ["RealUI"] = { ["position"] = { ["y"] = 84, ["x"] = 157.5, ["point"] = "BOTTOM", ["scale"] = 0.985, }, ["version"] = 3, }, ["Ischozar - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = 223.0000305175781, ["x"] = -31.50006103515625, ["point"] = "BOTTOM", }, }, ["Drâon - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = 223.0000305175781, ["x"] = -31.50006103515625, ["point"] = "BOTTOM", }, }, }, }, ["MicroMenu"] = { ["profiles"] = { ["Nevaar - Thrall"] = { ["padding"] = -2, ["version"] = 3, ["position"] = { ["scale"] = 1, ["x"] = 37.5, ["point"] = "BOTTOM", ["y"] = 41.75, }, }, ["RealUI-Healing"] = { ["enabled"] = false, }, ["RealUI"] = { ["enabled"] = false, }, ["Ischozar - Thrall"] = { ["padding"] = -2, ["version"] = 3, ["position"] = { ["scale"] = 1, ["x"] = 37.5, ["point"] = "BOTTOM", ["y"] = 41.75, }, }, ["Drâon - Thrall"] = { ["padding"] = -2, ["version"] = 3, ["position"] = { ["scale"] = 1, ["x"] = 37.5, ["point"] = "BOTTOM", ["y"] = 41.75, }, }, }, }, ["BagBar"] = { ["profiles"] = { ["Nevaar - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = 38.5, ["x"] = 345, ["point"] = "BOTTOM", }, }, ["RealUI-Healing"] = { ["enabled"] = false, }, ["RealUI"] = { ["enabled"] = false, }, ["Ischozar - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = 38.5, ["x"] = 345, ["point"] = "BOTTOM", }, }, ["Drâon - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = 38.5, ["x"] = 345, ["point"] = "BOTTOM", }, }, }, }, ["BlizzardArt"] = { ["profiles"] = { ["Nevaar - Thrall"] = { ["enabled"] = true, ["version"] = 3, ["position"] = { ["y"] = 47, ["x"] = -512, ["point"] = "BOTTOM", }, }, ["Ischozar - Thrall"] = { ["enabled"] = true, ["version"] = 3, ["position"] = { ["y"] = 47, ["x"] = -512, ["point"] = "BOTTOM", }, }, ["Drâon - Thrall"] = { ["enabled"] = true, ["version"] = 3, ["position"] = { ["y"] = 47, ["x"] = -512, ["point"] = "BOTTOM", }, }, }, }, ["Vehicle"] = { ["profiles"] = { ["Nevaar - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = 42.50006103515625, ["x"] = 104.5, ["point"] = "CENTER", }, }, ["RealUI-Healing"] = { ["version"] = 3, ["position"] = { ["y"] = -59.5, ["x"] = -36, ["point"] = "TOPRIGHT", ["scale"] = 0.84, }, }, ["RealUI"] = { ["position"] = { ["y"] = -59.5, ["x"] = -36, ["point"] = "TOPRIGHT", ["scale"] = 0.84, }, ["version"] = 3, }, ["Ischozar - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = 42.50006103515625, ["x"] = 104.5, ["point"] = "CENTER", }, }, ["Drâon - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = 42.50006103515625, ["x"] = 104.5, ["point"] = "CENTER", }, }, }, }, ["StanceBar"] = { ["profiles"] = { ["Nevaar - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = -14.99996185302734, ["x"] = -82.5, ["point"] = "CENTER", }, }, ["RealUI-Healing"] = { ["version"] = 3, ["position"] = { ["y"] = 49, ["x"] = -157.5, ["point"] = "BOTTOM", ["scale"] = 1, ["growHorizontal"] = "LEFT", }, ["padding"] = -7, ["visibility"] = { ["custom"] = true, ["customdata"] = "[petbattle][overridebar][vehicleui][possessbar,@vehicle,exists]hide;[mod:ctrl]show;fade", }, ["fadeoutalpha"] = 0, }, ["RealUI"] = { ["version"] = 3, ["position"] = { ["y"] = 49, ["x"] = -157.5, ["point"] = "BOTTOM", ["scale"] = 1, ["growHorizontal"] = "LEFT", }, ["fadeoutalpha"] = 0, ["padding"] = -7, ["visibility"] = { ["custom"] = true, ["customdata"] = "[petbattle][overridebar][vehicleui][possessbar,@vehicle,exists]hide;[mod:ctrl]show;fade", }, }, ["Ischozar - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = -14.99996185302734, ["x"] = -82.5, ["point"] = "CENTER", }, }, ["Drâon - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = -14.99996185302734, ["x"] = -82.5, ["point"] = "CENTER", }, }, }, }, ["PetBar"] = { ["profiles"] = { ["Nevaar - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = 143, ["x"] = -460, ["point"] = "BOTTOM", }, }, ["RealUI-Healing"] = { ["version"] = 3, ["position"] = { ["y"] = 124.5, ["x"] = -8, ["point"] = "LEFT", }, ["padding"] = -7, ["rows"] = 10, ["visibility"] = { ["custom"] = true, ["customdata"] = "[nopet][petbattle][overridebar][vehicleui][possessbar,@vehicle,exists]hide;[mod:ctrl]show;fade", }, ["fadeoutalpha"] = 0, }, ["RealUI"] = { ["rows"] = 10, ["version"] = 3, ["position"] = { ["y"] = 124.5, ["x"] = -8, ["point"] = "LEFT", }, ["padding"] = -7, ["visibility"] = { ["custom"] = true, ["customdata"] = "[nopet][petbattle][overridebar][vehicleui][possessbar,@vehicle,exists]hide;[mod:ctrl]show;fade", }, ["fadeoutalpha"] = 0, }, ["Ischozar - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = 143, ["x"] = -460, ["point"] = "BOTTOM", }, }, ["Drâon - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = 143, ["x"] = -460, ["point"] = "BOTTOM", }, }, }, }, ["ZoneAbilityBar"] = { ["profiles"] = { ["Nevaar - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = 223.0000457763672, ["x"] = -31.50006103515625, ["point"] = "BOTTOM", }, }, ["RealUI-Healing"] = { ["version"] = 3, ["position"] = { ["y"] = 86, ["x"] = -157.5, ["point"] = "BOTTOM", ["scale"] = 0.985, }, }, ["RealUI"] = { ["position"] = { ["y"] = 84, ["x"] = -221.5, ["point"] = "BOTTOM", ["scale"] = 0.985, }, ["version"] = 3, }, ["Ischozar - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = 223.0000457763672, ["x"] = -31.50006103515625, ["point"] = "BOTTOM", }, }, ["Drâon - Thrall"] = { ["version"] = 3, ["position"] = { ["y"] = 223.0000457763672, ["x"] = -31.50006103515625, ["point"] = "BOTTOM", }, }, }, }, }, ["profileKeys"] = { ["Nevaar - Thrall"] = "RealUI", ["Ischozar - Thrall"] = "RealUI", ["Drâon - Thrall"] = "RealUI", }, ["profiles"] = { ["Nevaar - Thrall"] = { ["focuscastmodifier"] = false, ["blizzardVehicle"] = true, ["outofrange"] = "hotkey", }, ["RealUI-Healing"] = { ["minimapIcon"] = { ["hide"] = true, }, }, ["RealUI"] = { ["minimapIcon"] = { ["hide"] = true, }, ["onkeydown"] = true, }, ["Ischozar - Thrall"] = { ["focuscastmodifier"] = false, ["blizzardVehicle"] = true, ["outofrange"] = "hotkey", }, ["Drâon - Thrall"] = { ["focuscastmodifier"] = false, ["blizzardVehicle"] = true, ["outofrange"] = "hotkey", }, }, }
nilq/small-lua-stack
null
object_building_kashyyyk_thm_kash_house_ground_sm_s01 = object_building_kashyyyk_shared_thm_kash_house_ground_sm_s01:new { } ObjectTemplates:addTemplate(object_building_kashyyyk_thm_kash_house_ground_sm_s01, "object/building/kashyyyk/thm_kash_house_ground_sm_s01.iff")
nilq/small-lua-stack
null
Citizen.CreateThread(function() Citizen.Wait(1000) local refresh = config.RefreshTime local ped = PlayerPedId() local pos = GetEntityCoords(ped) while true do Citizen.Wait(refresh) ped = PlayerPedId() pos = GetEntityCoords(ped) SendNUIMessage({ status = "position", x = pos.x, y = pos.y, z = pos.z }) end end)
nilq/small-lua-stack
null
function love.conf(t) t.identity = "MoonBox" t.version = "11.1" t.window.title = "MoonBox" -- t.console = true end
nilq/small-lua-stack
null
-- Manifest data fx_version 'bodacious' games {'gta5'} -- Resource stuff name 'ragdoll' description 'Simple ragdoll that allows you to set your own keybind' version '1.0' author 'FSSynthetic and VikingTheDev' client_script 'src/ragdoll-c.js'
nilq/small-lua-stack
null
local Players = GAMESTATE:GetHumanPlayers() local NumPanes = SL.Global.GameMode=="Casual" and 1 or 6 if SL.Global.GameMode == "Experiment" then if GetStepsType() == "StepsType_Dance_Double" or GAMESTATE:IsCourseMode() then NumPanes = 4 elseif #GAMESTATE:GetHumanPlayers() == 1 then NumPanes = 5 end end local altPanes = {'ExperimentPane1_Alt','ExperimentPane5_Alt'} local hash local t = Def.ActorFrame{} if SL.Global.GameMode ~= "Casual" then -- add a lua-based InputCallback to this screen so that we can navigate -- through multiple panes of information; pass a reference to this ActorFrame -- and the number of panes there are to InputHandler.lua t.OnCommand=function(self) if SL.Global.GameMode ~= "Casual" then SCREENMAN:GetTopScreen():AddInputCallback( LoadActor("./InputHandler.lua", {self, NumPanes, altPanes}) ) end end t.OffCommand=function(self) for player in ivalues(GAMESTATE:GetHumanPlayers()) do if SL.Global.GameMode == "Experiment" then AddScore(player, hash) end end end end -- ----------------------------------------------------------------------- -- Player-specific actors. for player in ivalues(Players) do -- store player stats for later retrieval on EvaluationSummary and NameEntryTraditional -- this doesn't draw anything to the screen, it just runs some code t[#t+1] = LoadActor("./PerPlayer/Storage.lua", player) -- the per-player upper half of ScreenEvaluation, including: letter grade, nice -- stepartist, difficulty text, difficulty meter, machine/personal HighScore text t[#t+1] = LoadActor("./PerPlayer/Upper/default.lua", player) -- the per-player lower half of ScreenEvaluation, including: judgment scatterplot, -- modifier list, disqualified text, and panes 1-6 t[#t+1] = LoadActor("./PerPlayer/Lower/default.lua", player) -- Generate a hash once here if we're in Experiment mode and use it for any pane that needs it. -- If it doesn't match with what we think it should be then the steps have changed and old scores -- are invalid. if SL.Global.GameMode == "Experiment" then local pn = ToEnumShortString(player) local stepsType = ToEnumShortString(GetStepsType()):gsub("_","-"):lower() local difficulty = ToEnumShortString(GAMESTATE:GetCurrentSteps(pn):GetDifficulty()) hash = GenerateHash(GAMESTATE:GetCurrentSteps(player),stepsType, difficulty) if hash ~= GetCurrentHash(player) then AddCurrentHash() end if not SL[ToEnumShortString(player)]["ParsedSteps"] then TechParser = LoadActor(THEME:GetPathB("","_modules/TechParser.lua")) local tech = TechParser(GAMESTATE:GetCurrentSteps(player),"dance-single",ToEnumShortString(GAMESTATE:GetCurrentSteps(player):GetDifficulty())) if tech then SL[ToEnumShortString(player)]["ParsedSteps"] = tech.parsedSteps end end end end -- ----------------------------------------------------------------------- -- Shared actors -- code for triggering a screenshot and animating a "screenshot" texture t[#t+1] = LoadActor("./Shared/ScreenshotHandler.lua") -- the title of the song and its graphical banner, if there is one t[#t+1] = LoadActor("./Shared/TitleAndBanner.lua") -- text to display BPM range (and ratemod if ~= 1.0) immediately under the banner t[#t+1] = LoadActor("./Shared/BPM_RateMod.lua") -- store some attributes of this playthrough of this song in the global SL table -- for later retrieval on ScreenEvaluationSummary t[#t+1] = LoadActor("./Shared/GlobalStorage.lua") -- help text that appears if we're in Casual gamemode t[#t+1] = LoadActor("./Shared/CasualHelpText.lua") -- ----------------------------------------------------------------------- -- Character if there's only one player if #GAMESTATE:GetHumanPlayers() == 1 then t[#t+1] = LoadActor("./Character.lua", GAMESTATE:GetMasterPlayerNumber()) end t[#t+1] = LoadActor("./Panes/default.lua", {NumPanes = NumPanes,hash = hash, AltPanes = altPanes}) t[#t+1] = Def.Sprite{ Name="cursor", Texture=THEME:GetPathG("FF","finger.png"), InitCommand=function(self) self:zoom(.15):visible(false) end, } t[#t+1] = Def.Sound{ Name="accept", File=THEME:GetPathS("FF","accept.ogg"), PlayStartSoundMessageCommand=function(self) self:play() end, OnCommand=function(self) local rageSound = self:get() rageSound:volume(ThemePrefs.Get("MenuSoundVolume")) end } t[#t+1] = Def.Sound{ Name="move", File=THEME:GetPathS("FF","move.ogg"), PlayMove1SoundMessageCommand=function(self) self:play() end, OnCommand=function(self) local rageSound = self:get() rageSound:volume(ThemePrefs.Get("MenuSoundVolume")) end } t[#t+1] = Def.Sound{ Name="select", File=THEME:GetPathS("FF", "select.ogg"), PlayMove2SoundMessageCommand=function(self) self:play() end, OnCommand=function(self) local rageSound = self:get() rageSound:volume(ThemePrefs.Get("MenuSoundVolume")) end } t[#t+1] = Def.Sound{ Name="cancel", File=THEME:GetPathS("FF","cancel.ogg"), PlayCancelSoundMessageCommand=function(self) self:play() end, OnCommand=function(self) local rageSound = self:get() rageSound:volume(ThemePrefs.Get("MenuSoundVolume")) end } return t
nilq/small-lua-stack
null
local MODULE = PAW_MODULE('lib') local Colors = MODULE.Config.Colors local PANEL = {} function PANEL:Init() self:TDLib() end function PANEL:Create(text, font) self:ClearPaint() :Background(Colors.Button) :FadeHover(Colors.ButtonHover) :Text(text, font) return self end function PANEL:SetClose(p) self:ClearPaint() :Background(Colors.Button) :FadeHover(Colors.CloseHover) :SetRemove(p) :Text('Закрыть', 'font_sans_16') return self end vgui.Register('Paws.Button', PANEL, 'DButton')
nilq/small-lua-stack
null
---------------------------------------------------------------------------------- -- Total RP 3 -- XRP API for profile importing -- --------------------------------------------------------------------------- -- Copyright 2014 Renaud Parize (Ellypse) (ellypse@totalrp3.info) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ---------------------------------------------------------------------------------- TRP3_API.events.listenToEvent(TRP3_API.events.WORKFLOW_ON_LOAD, function() if not xrpSaved then return; end local tcopy, getDefaultProfile = TRP3_API.utils.table.copy, TRP3_API.profile.getDefaultProfile; local loc = TRP3_API.locale.getText; local XRP = {}; local importableData = { HH = XRP_HH, HI = XRP_HI, DE = XRP_DE, AE = XRP_AE, FC = XRP_FC, HB = XRP_HB, AH = XRP_AH, NA = XRP_NA, RA = XRP_RA, AW = XRP_AW, NT = XRP_NT, FR = XRP_FR, NH = XRP_NH, NI = XRP_NI, RC = XRP_RC, MO = XRP_MO, AG = XRP_AG, CU = XRP_CU } local profilesList; local function initProfilesList() profilesList = {}; for name, profile in pairs(xrpSaved.profiles) do if name == "Default" then name = TRP3_API.globals.player_id; end local profileName = XRP.addOnVersion().."-"..name; profilesList[profileName] = { name = name }; local infoTemp = {}; for k, v in pairs(profile.fields) do infoTemp[k] = v; end profilesList[profileName].info = infoTemp; end end XRP.isAvailable = function() return xrpSaved.profiles ~= nil; end XRP.addOnVersion = function() return "XRP - " .. GetAddOnMetadata("xrp", "Version"); end XRP.getProfile = function(profileID) return profilesList[profileID]; end XRP.getFormatedProfile = function(profileID) assert(profilesList[profileID], "Given profileID does not exist."); local profile = {}; local importedProfile = profilesList[profileID].info; tcopy(profile, getDefaultProfile()); profile.player.characteristics.FN = importedProfile.NA; profile.player.characteristics.FT = importedProfile.NT; profile.player.characteristics.RA = importedProfile.RA; profile.player.characteristics.CL = importedProfile.CL; profile.player.characteristics.AG = importedProfile.AG; profile.player.characteristics.RE = importedProfile.HH; profile.player.characteristics.BP = importedProfile.HB; profile.player.characteristics.EC = importedProfile.AE; profile.player.characteristics.HE = importedProfile.AH; profile.player.characteristics.WE = importedProfile.AW; if importedProfile.MO then tinsert(profile.player.characteristics.MI, { NA = loc("REG_PLAYER_MSP_MOTTO"); VA = "\"" .. importedProfile.MO .. "\""; IC = "INV_Inscription_ScrollOfWisdom_01"; }); end if importedProfile.NI then tinsert(profile.player.characteristics.MI, { NA = loc("REG_PLAYER_MSP_NICK"); VA = importedProfile.NI; IC = "Ability_Hunter_BeastCall"; }); end if importedProfile.NH then tinsert(profile.player.characteristics.MI, { NA = loc("REG_PLAYER_MSP_HOUSE"); VA = importedProfile.NH; IC = "inv_misc_kingsring1"; }); end profile.player.character.CU = importedProfile.CU; profile.player.about.T3.PH.TX = importedProfile.DE; profile.player.about.T3.HI.TX = importedProfile.HI; profile.player.about.TE = 3; -- TODO Custom RP styles return profile; end XRP.listAvailableProfiles = function() initProfilesList() local list = {}; for key, _ in pairs(profilesList) do list[key] = XRP.addOnVersion(); end return list; end XRP.getImportableData = function() return importableData; end TRP3_API.importer.addAddOn(XRP.addOnVersion(), XRP); end);
nilq/small-lua-stack
null