content
stringlengths
5
1.05M
AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include('shared.lua') include('schedules.lua') include('tasks.lua') -- Variables ENT.m_fMaxYawSpeed = 200 -- Max turning speed ENT.m_iClass = CLASS_CITIZEN_REBEL -- NPC Class AccessorFunc( ENT, "m_iClass", "NPCClass" ) AccessorFunc( ENT, "m_fMaxYawSpeed", "MaxYawSpeed" ) --[[--------------------------------------------------------- Name: OnTakeDamage Desc: Entity takes damage -----------------------------------------------------------]] function ENT:OnTakeDamage( dmginfo ) --[[ Msg( tostring(dmginfo) .. "\n" ) Msg( "Inflictor:\t" .. tostring(dmginfo:GetInflictor()) .. "\n" ) Msg( "Attacker:\t" .. tostring(dmginfo:GetAttacker()) .. "\n" ) Msg( "Damage:\t" .. tostring(dmginfo:GetDamage()) .. "\n" ) Msg( "Base Damage:\t" .. tostring(dmginfo:GetBaseDamage()) .. "\n" ) Msg( "Force:\t" .. tostring(dmginfo:GetDamageForce()) .. "\n" ) Msg( "Position:\t" .. tostring(dmginfo:GetDamagePosition()) .. "\n" ) Msg( "Reported Pos:\t" .. tostring(dmginfo:GetReportedPosition()) .. "\n" ) -- ?? --]] return true end --[[--------------------------------------------------------- Name: Use -----------------------------------------------------------]] function ENT:Use( activator, caller, type, value ) end --[[--------------------------------------------------------- Name: StartTouch -----------------------------------------------------------]] function ENT:StartTouch( entity ) end --[[--------------------------------------------------------- Name: EndTouch -----------------------------------------------------------]] function ENT:EndTouch( entity ) end --[[--------------------------------------------------------- Name: Touch -----------------------------------------------------------]] function ENT:Touch( entity ) end --[[--------------------------------------------------------- Name: GetRelationship Return the relationship between this NPC and the passed entity. If you don't return anything then the default disposition will be used. -----------------------------------------------------------]] function ENT:GetRelationship( entity ) --return D_NU; end --[[--------------------------------------------------------- Name: ExpressionFinished Called when an expression has finished. Duh. -----------------------------------------------------------]] function ENT:ExpressionFinished( strExp ) end --[[--------------------------------------------------------- Name: Think -----------------------------------------------------------]] function ENT:Think() end --[[--------------------------------------------------------- Name: GetAttackSpread How good is the NPC with this weapon? Return the number of degrees of inaccuracy for the NPC to use. -----------------------------------------------------------]] function ENT:GetAttackSpread( Weapon, Target ) return 0.1 end
local M = {} -- Check if nvim-treesitter is available -- (there would be a lot of copied code without this dependency) local ok_parsers, ts_parsers = pcall(require, "nvim-treesitter.parsers") if not ok_parsers then ts_parsers = nil end local ok_utils, ts_utils = pcall(require, "nvim-treesitter.ts_utils") if not ok_utils then ts_utils = nil end function M.is_available() return ok_parsers and ok_utils end local function get_ft_at_cursor() local cur_node = ts_utils.get_node_at_cursor() if cur_node then local parser = ts_parsers.get_parser() local lang = parser:language_for_range({ cur_node:range() }):lang() if ts_parsers.list[lang] ~= nil then -- UltiSnips expects a filetype; if filetype is not specified for a parser, -- the filetype is the same as lang, so lang can be safely used return ts_parsers.list[lang].filetype or lang end end return nil end local cur_ft_at_cursor function M.set_filetype() local new_ft = get_ft_at_cursor() if new_ft ~= nil and new_ft ~= cur_ft_at_cursor and new_ft ~= vim.bo.filetype then vim.fn["cmp_nvim_ultisnips#set_filetype"](new_ft) cur_ft_at_cursor = new_ft end end function M.reset_filetype() if cur_ft_at_cursor ~= nil then vim.fn["cmp_nvim_ultisnips#reset_filetype"]() cur_ft_at_cursor = nil end end return M
--## local util = require("factorio-plugin.util") ---@param uri string @ The uri of file ---@param text string @ The content of file ---@param diffs Diff[] @ The diffs to add more diffs to local function replace(uri, text, diffs) ---@type string|number for s_narrow, s_id, f_id in text:gmatch("()%-%-%-[^%S\n]*@narrow +()[a-zA-Z_][a-zA-Z0-9_]*()") do -- the ---@narrow gets completely replaced with blank space -- which effectively removes the highlight of it being replaced with -- a variable (like when you position your cursor on the identifier) util.add_diff(diffs, s_narrow, s_id, string.rep(" ", s_id - s_narrow)) util.add_diff(diffs, f_id, f_id, "=nil---@type") end end return { replace = replace, }
Fish = Enemy:extend("Fish") -- lekkerOh Fish:implement(Locator) function Fish:new(...) Fish.super.new(self, ...) self:setImage("lekkeroh", 36) self.anim:add("shy", "1>24") self.anim:add("attack", "25>36") self:addIgnoreOverlap(SolidTile) self.floating = true self.solid = 0 self.gravity = 0 self.speed = 100 self.jumpToKill = true self.damaging = true self.canBeKilled = false end function Fish:update(dt) if not self.dead then self:findTarget(Player, 700) end Fish.super.update(self, dt) end function Fish:draw() Fish.super.draw(self) end function Fish:onFindingTarget(target) self:lookAt(target) if target:isLookingAt(self) then if self.anim:is("attack") then -- self.scene:playSFX(self.SFX.oh) end self.anim:set("shy") self:stopMoving() else if self.anim:is("shy") then -- self.scene:playSFX(self.SFX.scary) end self.anim:set("attack") self:moveToEntity(target) end end
package("protoc") set_kind("binary") set_homepage("https://developers.google.com/protocol-buffers/") set_description("Google's data interchange format compiler") if is_host("windows") then if is_arch("x64") then add_urls("https://github.com/protocolbuffers/protobuf/releases/download/v$(version)/protoc-$(version)-win64.zip") add_versions("3.8.0", "ac07cd66824f93026a796482dc85fa89deaf5be1b0e459de9100cff2992e6905") else add_urls("https://github.com/protocolbuffers/protobuf/releases/download/v$(version)/protoc-$(version)-win32.zip") add_versions("3.8.0", "93c5b7efe418b539896b2952ab005dd81fa418b76abee8c4341b4796b391999e") end elseif is_host("macosx") then if is_arch("x86_64") then add_urls("https://github.com/protocolbuffers/protobuf/releases/download/v$(version)/protoc-$(version)-osx-x86_64.zip") add_versions("3.8.0", "8093a79ca6f22bd9b178cc457a3cf44945c088f162e237b075584f6851ca316c") else add_urls("https://github.com/protocolbuffers/protobuf/releases/download/v$(version)/protoc-$(version)-osx-x86_32.zip") add_versions("3.8.0", "14376f58d19a7579c43ee95d9f87ed383391d695d4968107f02ed226c13448ae") end else add_urls("https://github.com/protocolbuffers/protobuf/releases/download/v$(version)/protobuf-cpp-$(version).zip") add_versions("3.8.0", "91ea92a8c37825bd502d96af9054064694899c5c7ecea21b8d11b1b5e7e993b5") end on_install("@windows", "@macosx", function (package) os.cp("bin", package:installdir()) os.cp("include", package:installdir()) end) on_install("@linux", function (package) import("package.tools.autoconf").install(package, {"--enable-shared=no", "--enable-static=no"}) end) on_test(function (package) io.writefile("test.proto", [[ syntax = "proto3"; package test; message TestCase { string name = 4; } message Test { repeated TestCase case = 1; } ]]) os.vrun("protoc test.proto --cpp_out=.") end)
object_tangible_scout_trap_trap_ap_kaminoandart = object_tangible_scout_trap_shared_trap_ap_kaminoandart:new { } ObjectTemplates:addTemplate(object_tangible_scout_trap_trap_ap_kaminoandart, "object/tangible/scout/trap/trap_ap_kaminoandart.iff")
local module = {} local lua_script_type = Engine.getComponentType("lua_script") module.particles_enabled = true module.clouds_enabled = true module.render_gizmos = true module.blur_shadowmap = true module.render_shadowmap_debug = false module.render_shadowmap_debug_fullsize = false function doPostprocess(pipeline, this_env, slot, camera_slot) local scene_renderer = Renderer.getPipelineScene(pipeline) local universe = Engine.getSceneUniverse(scene_renderer) local scene_lua_script = Engine.getScene(universe, "lua_script") local camera_cmp = Renderer.getCameraInSlot(scene_renderer, camera_slot) if camera_cmp < 0 then return end local camera_entity = Renderer.getCameraEntity(scene_renderer, camera_cmp) local script_cmp = Engine.getComponent(universe, camera_entity, lua_script_type) if script_cmp < 0 then return end local script_count = LuaScript.getScriptCount(scene_lua_script, script_cmp) for i = 1, script_count do local env = LuaScript.getEnvironment(scene_lua_script, script_cmp, i - 1) if env ~= nil then if env._IS_POSTPROCESS_INITIALIZED == nil and env.initPostprocess ~= nil then env.initPostprocess(pipeline, this_env) env._IS_POSTPROCESS_INITIALIZED = true end if env.postprocess ~= nil and (env._postprocess_slot == slot or (env._postprocess_slot == nil and slot == "main")) then env.postprocess(pipeline, this_env, slot) end end end end function module.renderEditorIcons(ctx) if module.render_gizmos then newView(ctx.pipeline, "editor", 0xFFFFffffFFFFffff) bindFramebufferTexture(ctx.pipeline, ctx.main_framebuffer, 1, ctx.depth_buffer_uniform) setPass(ctx.pipeline, "EDITOR") setFramebuffer(ctx.pipeline, "default") enableDepthWrite(ctx.pipeline) enableBlending(ctx.pipeline, "alpha") applyCamera(ctx.pipeline, "editor") renderIcons(ctx.pipeline) end end function module.renderGizmo(ctx) if module.render_gizmos then newView(ctx.pipeline, "gizmo") setPass(ctx.pipeline, "EDITOR") setFramebuffer(ctx.pipeline, "default") applyCamera(ctx.pipeline, "editor") renderGizmos(ctx.pipeline) end end function module.shadowmapDebug(ctx, x, y) if module.render_shadowmap_debug then newView(ctx.pipeline, "shadowmap_debug") setPass(ctx.pipeline, "MAIN") setFramebuffer(ctx.pipeline, "default") bindFramebufferTexture(ctx.pipeline, "shadowmap", 0, ctx.texture_uniform) drawQuad(ctx.pipeline, 0.01 + x, 0.01 + y, 0.23, 0.23, ctx.screen_space_material) end if module.render_shadowmap_debug_fullsize then newView(ctx.pipeline, "shadowmap_debug_fullsize") setPass(ctx.pipeline, "MAIN") setFramebuffer(ctx.pipeline, "default") bindFramebufferTexture(ctx.pipeline, "shadowmap", 0, ctx.texture_uniform) drawQuad(ctx.pipeline, 0, 0, 1, 1, ctx.screen_space_material) end end function module.initShadowmap(ctx) addFramebuffer(ctx.pipeline, "shadowmap_blur", { width = 2048, height = 2048, renderbuffers = { { format = "r32f" } } }) addFramebuffer(ctx.pipeline, "shadowmap", { width = 2048, height = 2048, renderbuffers = { {format="r32f"}, {format = "depth24"} } }) addFramebuffer(ctx.pipeline, "point_light_shadowmap", { width = 1024, height = 1024, renderbuffers = { {format = "depth24"} } }) addFramebuffer(ctx.pipeline, "point_light2_shadowmap", { width = 1024, height = 1024, renderbuffers = { {format = "depth24"} } }) ctx.shadowmap_uniform = createUniform(ctx.pipeline, "u_texShadowmap") module.blur_shadowmap = true module.render_shadowmap_debug = false end function module.init(ctx) ctx.screen_space_material = Engine.loadResource(g_engine, "pipelines/screenspace/screenspace.mat", "material") ctx.screen_space_debug_material = Engine.loadResource(g_engine, "pipelines/screenspace/screenspace_debug.mat", "material") ctx.texture_uniform = createUniform(ctx.pipeline, "u_texture") ctx.blur_material = Engine.loadResource(g_engine, "pipelines/common/blur.mat", "material") ctx.depth_buffer_uniform = createUniform(ctx.pipeline, "u_depthBuffer") ctx.multiplier_uniform = createUniform(ctx.pipeline, "u_multiplier") end function module.shadowmap(ctx, camera_slot, layer_mask) newView(ctx.pipeline, "shadow0", layer_mask) setPass(ctx.pipeline, "SHADOW") applyCamera(ctx.pipeline, camera_slot) setFramebuffer(ctx.pipeline, "shadowmap") renderShadowmap(ctx.pipeline, 0) newView(ctx.pipeline, "shadow1", layer_mask) setPass(ctx.pipeline, "SHADOW") applyCamera(ctx.pipeline, camera_slot) setFramebuffer(ctx.pipeline, "shadowmap") renderShadowmap(ctx.pipeline, 1) newView(ctx.pipeline, "shadow2", layer_mask) setPass(ctx.pipeline, "SHADOW") applyCamera(ctx.pipeline, camera_slot) setFramebuffer(ctx.pipeline, "shadowmap") renderShadowmap(ctx.pipeline, 2) newView(ctx.pipeline, "shadow3", layer_mask) setPass(ctx.pipeline, "SHADOW") applyCamera(ctx.pipeline, camera_slot) setFramebuffer(ctx.pipeline, "shadowmap") renderShadowmap(ctx.pipeline, 3) renderLocalLightsShadowmaps(ctx.pipeline, camera_slot, { "point_light_shadowmap", "point_light2_shadowmap" }) if module.blur_shadowmap then newView(ctx.pipeline, "blur_shadowmap_h") setPass(ctx.pipeline, "BLUR_H") setFramebuffer(ctx.pipeline, "shadowmap_blur") disableDepthWrite(ctx.pipeline) bindFramebufferTexture(ctx.pipeline, "shadowmap", 0, ctx.shadowmap_uniform) drawQuad(ctx.pipeline, 0, 0, 1, 1, ctx.blur_material) enableDepthWrite(ctx.pipeline) newView(ctx.pipeline, "blur_shadowmap_v") setPass(ctx.pipeline, "BLUR_V") setFramebuffer(ctx.pipeline, "shadowmap") disableDepthWrite(ctx.pipeline) bindFramebufferTexture(ctx.pipeline, "shadowmap_blur", 0, ctx.shadowmap_uniform) drawQuad(ctx.pipeline, 0, 0, 1, 1, ctx.blur_material); enableDepthWrite(ctx.pipeline) end end function module.particles(ctx, camera_slot) if module.particles_enabled then newView(ctx.pipeline, "particles") setPass(ctx.pipeline, "PARTICLES") disableDepthWrite(ctx.pipeline) applyCamera(ctx.pipeline, camera_slot) bindFramebufferTexture(ctx.pipeline, "g_buffer", 3, ctx.depth_buffer_uniform) setActiveGlobalLightUniforms(ctx.pipeline) renderParticles(ctx.pipeline) end end function module.clouds(ctx, camera_slot) if module.clouds_enabled then newView(ctx.pipeline, "clouds") setPass(ctx.pipeline, "CLOUDS") disableDepthWrite(ctx.pipeline) applyCamera(ctx.pipeline, camera_slot) bindFramebufferTexture(ctx.pipeline, "g_buffer", 3, ctx.depth_buffer_uniform) setActiveGlobalLightUniforms(ctx.pipeline) renderClouds(g_scene_LumixCloudSystem, ctx.pipeline) end end return module
--[[ Project: SA Memory (Available from https://blast.hk/) Developers: LUCHARE, FYP Special thanks: plugin-sdk (https://github.com/DK22Pac/plugin-sdk) for the structures and addresses. Copyright (c) 2018 BlastHack. ]] require 'SAMemory.game.vector3d' require 'SAMemory.game.RenderWare' local mt = require 'SAMemory.metatype' local ffi = require 'ffi' ffi.cdef[[ typedef struct matrix3x3 { vector3d right; unsigned int flags; vector3d up; unsigned int pad1; vector3d at; unsigned int pad2; vector3d pos; unsigned int pad3; RwMatrix *pAttachMatrix; bool bOwnsAttachedMatrix; } matrix; ]] local matrix = { Attach = ffi.cast('void ( __thiscall * )( void *, RwMatrix *, bool )', 0x59BD10); Detach = ffi.cast('void ( __thiscall * )( void * )', 0x59ACF0); Update = ffi.cast('void ( __thiscall * )( void * )', 0x59BB60); UpdateRWWithAttached = ffi.cast('void ( __thiscall * )( void * )', 0x59BBB0); ResetOrientation = ffi.cast('void ( __thiscall * )( void * )', 0x59AEA0); SetRotateXOnly = ffi.cast('void ( __thiscall * )( void *, float )', 0x59AFA0); SetRotateYOnly = ffi.cast('void ( __thiscall * )( void *, float )', 0x59AFE0); SetRotateZOnly = ffi.cast('void ( __thiscall * )( void *, float )', 0x59B020); SetRotateX = ffi.cast('void ( __thiscall * )( void *, float )', 0x59B060); SetRotateY = ffi.cast('void ( __thiscall * )( void *, float )', 0x59B0A0); SetRotateZ = ffi.cast('void ( __thiscall * )( void *, float )', 0x59B0E0); SetRotate = ffi.cast('void ( __thiscall * )( void *, float, float, float )', 0x59B120); RotateX = ffi.cast('void ( __thiscall * )( void *, float )', 0x59B1E0); RotateY = ffi.cast('void ( __thiscall * )( void *, float )', 0x59B2C0); RotateZ = ffi.cast('void ( __thiscall * )( void *, float )', 0x59B390); Rotate = ffi.cast('void ( __thiscall * )( void *, float, float, float )', 0x59B460); } mt.provide_access('matrix', matrix, true, false)
local t = require(script.Parent.Packages.t) local types = {} types.Message = t.interface({ id = t.string, userId = t.string, text = t.string, createdAt = t.number, responses = t.array(t.string), parentId = t.optional(t.string), }) return types
local Utility = {}; local McpFeature = require("AdituV.DetectTrap.Utility.McpFeature"); local Strings = require("AdituV.DetectTrap.Strings"); local Strings_en = require("AdituV.DetectTrap.Strings_en"); -- Miscellaneous functions Utility.checkCodePatchFeature = function(featureId) local featureId = featureId:lower(); if not tes3.hasCodePatchFeature(McpFeature[featureId]) then Utility.Log.error("missingMcpFeatureError", featureId); end end Utility.checkMwseBuildDate = function(datestamp) if (mwse.buildDate == nil) or (mwse.buildDate < datestamp) then Utility.Log.warn("mwseOutOfDate"); end end Utility.coerceBool = function(x) return x and true or false; end -- Generates a logistic function (<https://en.wikipedia.org/wiki/Logistic_function>) -- with the given parameters: -- minV: the y-coordinate of the lower asymptote -- maxV: the y-coordinate of the upper asymptote -- steepness: the steepness of the curve -- midpoint: the x-coordinate of the curve's midpoint Utility.mkLogistic = function (minV, maxV, steepness, midpoint) return (function (x) return minV + (maxV - minV) / (1 + math.exp(-1 * steepness * (x - midpoint))); end); end -- Logging functions local logRaw = function(message) mwse.log("[Detect Trap] " .. message); end local debug = function(message, ...) message = "DEBUG: " .. string.format(message, ...); logRaw(message); end local info = function(msgId, ...) local message = "INFO: " .. string.format(Strings_en[msgId], ...); logRaw(message); end local warn = function(msgId, ...) local message = string.format(Strings[msgId], ...); local message_en = "WARN: " .. string.format(Strings_en[msgId], ...); logRaw(message_en); tes3.messageBox(message); end local error = function(msgId, ...) local message = string.format(Strings[msgId], ...); local message_en = "ERROR: " .. string.format(Strings_en[msgId], ...); logRaw(message_en); tes3.messageBox({ message = message, buttons = { Strings.ok } }); end Utility.Log = { debug = debug, info = info, warn = warn, error = error, }; return Utility;
local BidirectionalGRU = {} function BidirectionalGRU.rnn(nstep, avg, emb_dim) if avg == nil then avg = 0 end if emb_dim == nil then emb_dim = 256 end local inputs = {} for n = 1,nstep do table.insert(inputs, nn.Identity()()) end -- gates for update local i2h_update_fwd = {} local h2h_update_fwd = {} local i2h_update_rev = {} local h2h_update_rev = {} -- gates for reset local i2h_reset_fwd = {} local h2h_reset_fwd = {} local i2h_reset_rev = {} local h2h_reset_rev = {} -- candidate hidden state local i2h_fwd = {} local h2h_fwd = {} local i2h_rev = {} local h2h_rev = {} -- actual hidden state local hids_fwd = {} local hids_rev = {} -- forward GRU for i,v in ipairs(inputs) do i2h_update_fwd[i] = nn.Sequential() i2h_update_fwd[i]:add(nn.Linear(emb_dim,emb_dim)) i2h_reset_fwd[i] = nn.Sequential() i2h_reset_fwd[i]:add(nn.Linear(emb_dim,emb_dim)) i2h_fwd[i] = nn.Sequential() i2h_fwd[i]:add(nn.Linear(emb_dim,emb_dim)) if i > 1 then i2h_update_fwd[i]:share(i2h_update_fwd[1],'weight', 'bias', 'gradWeight', 'gradBias') i2h_reset_fwd[i]:share(i2h_reset_fwd[1],'weight', 'bias', 'gradWeight', 'gradBias') i2h_fwd[i]:share(i2h_fwd[1], 'weight', 'bias', 'gradWeight', 'gradBias') h2h_update_fwd[i-1] = nn.Sequential() h2h_update_fwd[i-1]:add(nn.Linear(emb_dim,emb_dim)) h2h_reset_fwd[i-1] = nn.Sequential() h2h_reset_fwd[i-1]:add(nn.Linear(emb_dim,emb_dim)) h2h_fwd[i-1] = nn.Sequential() h2h_fwd[i-1]:add(nn.Linear(emb_dim,emb_dim)) if i > 2 then h2h_update_fwd[i-1]:share(h2h_update_fwd[i-2],'weight', 'bias', 'gradWeight', 'gradBias') h2h_reset_fwd[i-1]:share(h2h_reset_fwd[i-2],'weight', 'bias', 'gradWeight', 'gradBias') h2h_fwd[i-1]:share(h2h_fwd[i-2],'weight', 'bias', 'gradWeight', 'gradBias') end -- compute update and reset gates. local update = nn.Sigmoid()(nn.CAddTable()( {i2h_update_fwd[i](inputs[i]), h2h_update_fwd[i-1](hids_fwd[i-1])})) local reset = nn.Sigmoid()(nn.CAddTable()( {i2h_reset_fwd[i](inputs[i]), h2h_reset_fwd[i-1](hids_fwd[i-1])})) -- compute candidate hidden state. local gated_hidden = nn.CMulTable()({reset, hids_fwd[i-1]}) local p1 = i2h_fwd[i](inputs[i]) local p2 = h2h_fwd[i-1](gated_hidden) local hidden_cand = nn.Tanh()(nn.CAddTable()({p1, p2})) -- use gates to interpolate hidden state. local zh = nn.CMulTable()({update, hidden_cand}) local zhm1 = nn.CMulTable()({nn.AddConstant(1,false)(nn.MulConstant(-1,false)(update)), hids_fwd[i-1]}) hids_fwd[i] = nn.CAddTable()({zh, zhm1}) else hids_fwd[i] = nn.Tanh()(i2h_fwd[i](inputs[i])) end end for i,v in ipairs(inputs) do local ix = #inputs - i + 1 i2h_update_rev[i] = nn.Sequential() i2h_update_rev[i]:add(nn.Linear(emb_dim,emb_dim)) i2h_reset_rev[i] = nn.Sequential() i2h_reset_rev[i]:add(nn.Linear(emb_dim,emb_dim)) i2h_rev[i] = nn.Sequential() i2h_rev[i]:add(nn.Linear(emb_dim,emb_dim)) if i > 1 then i2h_update_rev[i]:share(i2h_update_rev[1],'weight', 'bias', 'gradWeight', 'gradBias') i2h_reset_rev[i]:share(i2h_reset_rev[1],'weight', 'bias', 'gradWeight', 'gradBias') i2h_rev[i]:share(i2h_rev[1], 'weight', 'bias', 'gradWeight', 'gradBias') h2h_update_rev[i-1] = nn.Sequential() h2h_update_rev[i-1]:add(nn.Linear(emb_dim,emb_dim)) h2h_reset_rev[i-1] = nn.Sequential() h2h_reset_rev[i-1]:add(nn.Linear(emb_dim,emb_dim)) h2h_rev[i-1] = nn.Sequential() h2h_rev[i-1]:add(nn.Linear(emb_dim,emb_dim)) if i > 2 then h2h_update_rev[i-1]:share(h2h_update_rev[i-2],'weight', 'bias', 'gradWeight', 'gradBias') h2h_reset_rev[i-1]:share(h2h_reset_rev[i-2],'weight', 'bias', 'gradWeight', 'gradBias') h2h_rev[i-1]:share(h2h_rev[i-2],'weight', 'bias', 'gradWeight', 'gradBias') end -- compute update and reset gates. local update = nn.Sigmoid()(nn.CAddTable()( {i2h_update_rev[i](inputs[ix]), h2h_update_rev[i-1](hids_rev[i-1])})) local reset = nn.Sigmoid()(nn.CAddTable()( {i2h_reset_rev[i](inputs[ix]), h2h_reset_rev[i-1](hids_rev[i-1])})) -- compute candidate hidden state. local gated_hidden = nn.CMulTable()({reset, hids_rev[i-1]}) local p1 = i2h_rev[i](inputs[ix]) local p2 = h2h_rev[i-1](gated_hidden) local hidden_cand = nn.Tanh()(nn.CAddTable()({p1, p2})) -- use gates to interpolate hidden state. local zh = nn.CMulTable()({update, hidden_cand}) local zhm1 = nn.CMulTable()({nn.AddConstant(1,false)(nn.MulConstant(-1,false)(update)), hids_rev[i-1]}) hids_rev[i] = nn.CAddTable()({zh, zhm1}) else hids_rev[i] = nn.Tanh()(i2h_rev[i](inputs[ix])) end end local hid local projL = {} local projR = {} local combiner = {} for i = 1,nstep do projL[i] = nn.Sequential() projL[i]:add(nn.Linear(emb_dim,emb_dim)) projR[i] = nn.Sequential() projR[i]:add(nn.Linear(emb_dim,emb_dim)) combiner[i] = nn.Sequential() combiner[i]:add(nn.Linear(emb_dim,emb_dim)) if i > 1 then projL[i]:share(projL[i-1], 'weight', 'bias', 'gradWeight', 'gradBias') projR[i]:share(projR[i-1], 'weight', 'bias', 'gradWeight', 'gradBias') combiner[i]:share(combiner[i-1], 'weight', 'bias', 'gradWeight', 'gradBias') end -- combine fwd and reverse directions. local hidL = projL[i](hids_fwd[i]) local hidR = projR[i](hids_rev[i]) local cur_hid = combiner[i](nn.ReLU()(nn.CAddTable()({hidL, hidR}))) if i == 1 then hid = cur_hid else hid = nn.CAddTable()({hid, cur_hid}) end end hid = nn.MulConstant(1./nstep)(hid) local outputs = {} table.insert(outputs, hid) return nn.gModule(inputs, outputs) end return BidirectionalGRU
include( "contentsidebartoolbox.lua" ) local pnlSearch = vgui.RegisterFile( "contentsearch.lua" ) local PANEL = {} function PANEL:Init() self.Tree = vgui.Create( "DTree", self ) self.Tree:SetClickOnDragHover( true ) self.Tree.OnNodeSelected = function( Tree, Node ) hook.Call( "ContentSidebarSelection", GAMEMODE, self:GetParent(), Node ) end self.Tree:Dock( FILL ) self.Tree:SetBackgroundColor( Color( 240, 240, 240, 255 ) ) self:SetPaintBackground( false ) end function PANEL:EnableSearch( stype, hookname ) self.Search = vgui.CreateFromTable( pnlSearch, self ) self.Search:SetSearchType( stype, hookname or "PopulateContent" ) end function PANEL:EnableModify() self:EnableSearch() self:CreateSaveNotification() self.Toolbox = vgui.Create( "ContentSidebarToolbox", self ) hook.Add( "OpenToolbox", "OpenToolbox", function() if ( !IsValid( self.Toolbox ) ) then return end self.Toolbox:Open() end ) end function PANEL:CreateSaveNotification() local SavePanel = vgui.Create( "Panel", self ) SavePanel:Dock( TOP ) SavePanel:SetVisible( false ) SavePanel:DockMargin( 8, 1, 8, 4 ) local SaveButton = vgui.Create( "DButton", SavePanel ) SaveButton:Dock( FILL ) SaveButton:SetIcon( "icon16/disk.png" ) SaveButton:SetText( "#spawnmenu.savechanges" ) SaveButton.DoClick = function() SavePanel:SlideUp( 0.2 ) hook.Run( "OnSaveSpawnlist" ) end local RevertButton = vgui.Create( "DButton", SavePanel ) RevertButton:Dock( RIGHT ) RevertButton:SetIcon( "icon16/arrow_rotate_clockwise.png" ) RevertButton:SetText( "" ) RevertButton:SetTooltip( "#spawnmenu.revert_tooptip" ) RevertButton:SetWide( 26 ) RevertButton:DockMargin( 4, 0, 0, 0 ) RevertButton.DoClick = function() SavePanel:SlideUp( 0.2 ) hook.Run( "OnRevertSpawnlist" ) end hook.Add( "SpawnlistContentChanged", "ShowSaveButton", function() if ( SavePanel:IsVisible() ) then return end SavePanel:SlideDown( 0.2 ) GAMEMODE:AddHint( "EditingSpawnlistsSave", 5 ) end ) end vgui.Register( "ContentSidebar", PANEL, "DPanel" )
local files = require 'files' local fsu = require 'fs-utility' local furi = require 'file-uri' local diag = require 'provider.diagnostic' local config = require 'config' files.removeAll() fsu.scanDirectory(ROOT, function (path) if path:extension():string() ~= '.lua' then return end local uri = furi.encode(path:string()) local text = fsu.loadFile(path) files.setText(uri, text) files.open(uri) end) config.config.diagnostics.disable['undefined-field'] = true config.config.diagnostics.disable['redundant-parameter'] = true diag.start() local clock = os.clock() for uri in files.eachFile() do diag.doDiagnostic(uri) end local passed = os.clock() - clock print('基准全量诊断用时:', passed)
local android = premake.extensions.android android.properties = {} local properties = android.properties -- -- Generate project.properties -- function properties.generate(prj) _p(0, 'target=$(androidapilevel)') end
-- @Author:pandayu -- @Version:1.0 -- @DateTime:2018-09-09 -- @Project:pandaCardServer CardGame -- @Contact: QQ:815099602 local _M = function(role,data) local pass = role.resource:can_inspire(data.pos,data.num) if not pass then return 2602 end local cost = role.resource:get_inspire_cost(data.pos,data.num) local en,diamond,cost = role:check_resource_num(cost) if not en then return 100 end role:consume_resource(cost) local num = role.resource:set_inspire() return 0,{num =num} end return _M
-- id int 打击点组ID -- HitPointSet tableString[k:#1(string)|v:#table(hitnum=#2(int),hitmove=#3(int),damageratio=#4(int),powerratio=#5(int),soundhit=#6(string),effecthit=#7(string),freezedelay=#8(int),freezetarget=#9(int),freezeself=#10(int)),hitcameraeffect=#11(int))] 打击点配置 return { [10001] = { id = 10001, HitPointSet = { attack_Attack_1 = { hitnum = 1, hitmove = 1500, damageratio = 1500, powerratio = 1500, soundhit = "GunCommonL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Attack_2 = { hitnum = 2, hitmove = 1500, damageratio = 1500, powerratio = 1500, soundhit = "GunCommonL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Attack_3 = { hitnum = 11, hitmove = 5000, damageratio = 1500, powerratio = 1500, soundhit = "GunCommonM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Attack_4 = { hitnum = 2, hitmove = 1000, damageratio = 500, powerratio = 500, soundhit = "GunCommonL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Attack_4_1 = { hitnum = 11, hitmove = 4000, damageratio = 500, powerratio = 500, soundhit = "ShockCommonM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Attack_5 = { hitnum = 21, hitmove = 20000, damageratio = 2500, powerratio = 2500, soundhit = "GunCommonH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill_1 = { hitnum = 1, hitmove = 3000, damageratio = 2000, powerratio = 0, soundhit = "PunchCommonM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill_1_1 = { hitnum = 12, hitmove = 20000, damageratio = 4000, powerratio = 0, soundhit = "GunCommonM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill_2 = { hitnum = 21, hitmove = 0, damageratio = 10000, powerratio = 0, soundhit = "GunCommonH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill_3 = { hitnum = 1, hitmove = 2000, damageratio = 400, powerratio = 0, soundhit = "PunchCommonM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill_3_1 = { hitnum = 2, hitmove = 1000, damageratio = 800, powerratio = 0, soundhit = "GunCommonL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill_3_3 = { hitnum = 12, hitmove = 1000, damageratio = 800, powerratio = 0, soundhit = "GunCommonL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill_3_2 = { hitnum = 11, hitmove = 15000, damageratio = 800, powerratio = 0, soundhit = "ShockCommonM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill_4 = { hitnum = 1, hitmove = 0, damageratio = 400, powerratio = 0, soundhit = "GunCommonM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill_4_1 = { hitnum = 21, hitmove = 45000, damageratio = 2800, powerratio = 0, soundhit = "GunCommonH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Change_1 = { hitnum = 2, hitmove = 15000, damageratio = 10000, powerratio = 0, soundhit = "ShockCommonM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, }, }, [10002] = { id = 10002, HitPointSet = { Ice_Bullet_01 = { hitnum = 1, hitmove = 2000, damageratio = 2000, powerratio = 0, soundhit = "MagicIceL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Ice_Bullet_02 = { hitnum = 2, hitmove = 2000, damageratio = 2000, powerratio = 0, soundhit = "MagicIceL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Attack3_1 = { hitnum = 1, hitmove = 2000, damageratio = 1000, powerratio = 0, soundhit = "MagicIceM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Attack4 = { hitnum = 22, hitmove = 10000, damageratio = 3000, powerratio = 0, soundhit = "MagicIceH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill1 = { hitnum = 21, hitmove = 5000, damageratio = 4000, powerratio = 0, soundhit = "MagicIceM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill1_1 = { hitnum = 12, hitmove = 20000, damageratio = 6000, powerratio = 0, soundhit = "MagicIceH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill2 = { hitnum = 23, hitmove = 30000, damageratio = 10000, powerratio = 0, soundhit = "MagicIceM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill3 = { hitnum = 1, hitmove = 2000, damageratio = 1000, powerratio = 0, soundhit = "MagicIceL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill3_1 = { hitnum = 2, hitmove = 1000, damageratio = 700, powerratio = 0, soundhit = "MagicIceL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill3_2 = { hitnum = 21, hitmove = 10000, damageratio = 2000, powerratio = 0, soundhit = "MagicIceH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Skill4 = { hitnum = 1, hitmove = 2000, damageratio = 715, powerratio = 0, soundhit = "MagicIceM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Change_1 = { hitnum = 2, hitmove = 15000, damageratio = 10000, powerratio = 0, soundhit = "MagicIceM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, }, }, [10003] = { id = 10003, HitPointSet = { Tohka_Attack_1 = { hitnum = 1, hitmove = 4000, damageratio = 1500, powerratio = 1500, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Attack_2 = { hitnum = 2, hitmove = 4000, damageratio = 1500, powerratio = 1500, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Attack_3 = { hitnum = 11, hitmove = 8000, damageratio = 2000, powerratio = 2000, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Attack_4 = { hitnum = 2, hitmove = 4000, damageratio = 1000, powerratio = 1000, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Attack_4_1 = { hitnum = 11, hitmove = 4000, damageratio = 1000, powerratio = 1000, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Attack_5 = { hitnum = 21, hitmove = 30000, damageratio = 3000, powerratio = 3000, soundhit = "WeapenSwordH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_1 = { hitnum = 11, hitmove = 4000, damageratio = 4000, powerratio = 0, soundhit = "WeapenSwordH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_1_1 = { hitnum = 21, hitmove = 20000, damageratio = 6000, powerratio = 0, soundhit = "WeapenSwordH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_2 = { hitnum = 2, hitmove = 2500, damageratio = 1250, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_2_1 = { hitnum = 2, hitmove = 2500, damageratio = 1250, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_2_2 = { hitnum = 2, hitmove = 2500, damageratio = 1250, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_2_3 = { hitnum = 2, hitmove = 2500, damageratio = 1250, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_2_4 = { hitnum = 2, hitmove = 2500, damageratio = 1250, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_2_5 = { hitnum = 2, hitmove = 2500, damageratio = 1250, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_2_6 = { hitnum = 21, hitmove = 30000, damageratio = 2500, powerratio = 0, soundhit = "WeapenSwordH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_3 = { hitnum = 22, hitmove = 40000, damageratio = 10000, powerratio = 0, soundhit = "WeapenSwordH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4 = { hitnum = 21, hitmove = 15000, damageratio = 100, powerratio = 0, soundhit = "ShockCommonM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_1 = { hitnum = 21, hitmove = 20000, damageratio = 200, powerratio = 0, soundhit = "ShockCommonM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_2 = { hitnum = 2, hitmove = 2000, damageratio = 300, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_3 = { hitnum = 1, hitmove = 2000, damageratio = 300, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_4 = { hitnum = 2, hitmove = 2000, damageratio = 300, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_5 = { hitnum = 1, hitmove = 2000, damageratio = 300, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_6 = { hitnum = 1, hitmove = 2000, damageratio = 300, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_7 = { hitnum = 2, hitmove = 2000, damageratio = 300, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_8 = { hitnum = 2, hitmove = 2000, damageratio = 300, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_9 = { hitnum = 11, hitmove = 4000, damageratio = 600, powerratio = 0, soundhit = "WeapenSwordH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_10 = { hitnum = 12, hitmove = 4000, damageratio = 600, powerratio = 0, soundhit = "WeapenSwordH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_11 = { hitnum = 11, hitmove = 4000, damageratio = 600, powerratio = 0, soundhit = "WeapenSwordH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_12 = { hitnum = 1, hitmove = 2000, damageratio = 300, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_13 = { hitnum = 2, hitmove = 2000, damageratio = 300, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_14 = { hitnum = 1, hitmove = 2000, damageratio = 300, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_15 = { hitnum = 2, hitmove = 2000, damageratio = 300, powerratio = 0, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_16 = { hitnum = 11, hitmove = 4000, damageratio = 600, powerratio = 0, soundhit = "WeapenSwordH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_17 = { hitnum = 12, hitmove = 4000, damageratio = 600, powerratio = 0, soundhit = "WeapenSwordH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_18 = { hitnum = 11, hitmove = 4000, damageratio = 600, powerratio = 0, soundhit = "WeapenSwordH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_19 = { hitnum = 1, hitmove = 2500, damageratio = 400, powerratio = 0, soundhit = "WeapenSwordL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_20 = { hitnum = 2, hitmove = 2500, damageratio = 400, powerratio = 0, soundhit = "WeapenSwordL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_21 = { hitnum = 1, hitmove = 2500, damageratio = 400, powerratio = 0, soundhit = "WeapenSwordL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_22 = { hitnum = 2, hitmove = 2500, damageratio = 400, powerratio = 0, soundhit = "WeapenSwordL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_23 = { hitnum = 1, hitmove = 2500, damageratio = 400, powerratio = 0, soundhit = "WeapenSwordL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_24 = { hitnum = 2, hitmove = 2500, damageratio = 400, powerratio = 0, soundhit = "WeapenSwordL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Skill_4_25 = { hitnum = 1, hitmove = 2500, damageratio = 400, powerratio = 0, soundhit = "WeapenSwordL_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Change_1 = { hitnum = 1, hitmove = 4000, damageratio = 6000, powerratio = 0, soundhit = "ShockCommonM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Tohka_Change_2 = { hitnum = 24, hitmove = -40000, damageratio = 4000, powerratio = 0, soundhit = "ShockCommonM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, }, }, [10004] = { id = 10004, HitPointSet = { Yuzuru_Attack_1 = { hitnum = 2, hitmove = 4000, damageratio = 500, powerratio = 500, soundhit = "0", effecthit = "H_Yuzuru_01_hit_01", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Yuzuru_Attack_1_1 = { hitnum = 6, hitmove = 4000, damageratio = 1000, powerratio = 1000, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 1006, }, Yuzuru_Attack_2 = { hitnum = 1, hitmove = 4000, damageratio = 1500, powerratio = 1500, soundhit = "0", effecthit = "H_Yuzuru_01_hit_01", freezedelay = 2, freezetarget = 3, freezeself = 3, hitcameraeffect = 1006, }, Yuzuru_Attack_3 = { hitnum = 12, hitmove = 10000, damageratio = 2000, powerratio = 2000, soundhit = "0", effecthit = "H_Yuzuru_01_hit_01", freezedelay = 0, freezetarget = 1, freezeself = 1, hitcameraeffect = 0, }, Yuzuru_Attack_4 = { hitnum = 2, hitmove = 2000, damageratio = 300, powerratio = 300, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Yuzuru_Attack_4_1 = { hitnum = 2, hitmove = 2000, damageratio = 300, powerratio = 300, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Yuzuru_Attack_4_2 = { hitnum = 2, hitmove = 2000, damageratio = 300, powerratio = 300, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Yuzuru_Attack_4_3 = { hitnum = 2, hitmove = 2000, damageratio = 300, powerratio = 300, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Yuzuru_Attack_4_4 = { hitnum = 2, hitmove = 2000, damageratio = 300, powerratio = 300, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Yuzuru_Attack_4_5 = { hitnum = 12, hitmove = 4000, damageratio = 500, powerratio = 500, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 3, freezeself = 0, hitcameraeffect = 0, }, Yuzuru_Attack_5 = { hitnum = 11, hitmove = 4000, damageratio = 500, powerratio = 500, soundhit = "0", effecthit = "H_Yuzuru_01_hit_01", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Yuzuru_Attack_5_1 = { hitnum = 21, hitmove = 25000, damageratio = 1700, powerratio = 2500, soundhit = "0", effecthit = "H_Yuzuru_01_hit_01", freezedelay = 0, freezetarget = 2, freezeself = 2, hitcameraeffect = 0, }, Yuzuru_Attack_5_2 = { hitnum = 1, hitmove = 25000, damageratio = 200, powerratio = 0, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 1200, }, Yuzuru_Attack_5_3 = { hitnum = 2, hitmove = 25000, damageratio = 200, powerratio = 0, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 1200, }, Yuzuru_Attack_5_4 = { hitnum = 1, hitmove = 25000, damageratio = 200, powerratio = 0, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 1200, }, Yuzuru_Attack_5_5 = { hitnum = 2, hitmove = 25000, damageratio = 200, powerratio = 0, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 1200, }, TrapDate_Yuzuru_Attack5 = { hitnum = 2, hitmove = 25000, damageratio = 200, powerratio = 0, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 1200, }, Yuzuru_Skill_1 = { hitnum = 23, hitmove = 10000, damageratio = 4000, powerratio = 0, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Yuzuru_Skill_1_1 = { hitnum = 24, hitmove = -50000, damageratio = 6000, powerratio = 0, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, TrapDate_Yuzuru_Skill2 = { hitnum = 21, hitmove = 20000, damageratio = 500, powerratio = 0, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Summon_Yuzuru_Skill_2 = { hitnum = 21, hitmove = 20000, damageratio = 500, powerratio = 0, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Summon_Yuzuru_Skill_2_1 = { hitnum = 21, hitmove = 20000, damageratio = 500, powerratio = 0, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Summon_Yuzuru_Skill_2_2 = { hitnum = 21, hitmove = 20000, damageratio = 500, powerratio = 0, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Yuzuru_Skill_3 = { hitnum = 1, hitmove = 2000, damageratio = 300, powerratio = 0, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, Yuzuru_Skill_3_1 = { hitnum = 21, hitmove = 25000, damageratio = 1500, powerratio = 0, soundhit = "0", effecthit = "H_Yuzuru_01_hit_02", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, }, }, [10005] = { id = 10005, HitPointSet = { attack_Attack1 = { hitnum = 12, hitmove = 4000, damageratio = 600, powerratio = 600, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Attack2 = { hitnum = 11, hitmove = 4000, damageratio = 600, powerratio = 600, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Attack3 = { hitnum = 11, hitmove = 4000, damageratio = 600, powerratio = 600, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Attack4 = { hitnum = 12, hitmove = 4000, damageratio = 600, powerratio = 600, soundhit = "WeapenSwordM_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, attack_Attack4_1 = { hitnum = 21, hitmove = 20000, damageratio = 600, powerratio = 600, soundhit = "WeapenSwordH_Hit", effecthit = "0", freezedelay = 0, freezetarget = 0, freezeself = 0, hitcameraeffect = 0, }, }, }, }
minetest.register_alias("mapgen_stone", "main:stone") minetest.register_alias("mapgen_dirt", "main:dirt") minetest.register_alias("mapgen_dirt_with_grass", "main:dirt_with_grass") minetest.register_alias("mapgen_sand", "main:sand") minetest.register_alias("mapgen_water_source", "main:water_source") minetest.register_alias("mapgen_river_water_source", "main:muddywater_source") minetest.register_alias("mapgen_lava_source", "main:lava_source") -------- --Biomes -------- --Grasslands minetest.register_biome( { name = "Grasslands", node_top = "main:dirt_with_grass", node_filler = "main:dirt", depth_top = 1, depth_filler = 1, y_min = 4, y_max = 14, heat_point = 60, humidity_point = 30, }) --Beach minetest.register_biome( { name = "Beach", node_top = "main:sand", node_filler = "main:stone", depth_top = 1, depth_filler = 3, y_min = 1, y_max = 4, heat_point = 70, humidity_point = 55, }) --Swamp minetest.register_biome( { name = "Swamp", node_top = "main:dirt_with_swamp_grass", node_filler = "main:dirt", depth_top = 1, depth_filler = 3, y_min = 1, y_max = 4, heat_point = 60, humidity_point = 30, }) --Sulfur Deposit minetest.register_biome( { name = "Sulfur Deposit", node_top = "main:stone", node_filler = "main:gravel", depth_top = 1, depth_filler = 7, y_min = 7, y_max = 15, heat_point = 80, humidity_point = 90, }) --Desert minetest.register_biome( { name = "Desert", node_top = "main:sand", node_filler = "main:sand", depth_top = 4, depth_filler = 3, y_min = 3, y_max = 50, heat_point = 100, humidity_point = 8, }) --Mountains minetest.register_biome( { name = "Mountains", node_top = "main:cobble", node_filler = "main:stone", depth_top = 1, depth_filler = 1, y_min = 15, y_max = 150, heat_point = 60, humidity_point = 30, }) --Mountain Peak (with snow) minetest.register_biome( { name = "Mountain Peak", node_top = "main:snow", node_filler = "main:snow", depth_top = 1, depth_filler = 1, y_min = 150, y_max = upper_limit, heat_point = 10, humidity_point = 20, }) --Wasteland minetest.register_biome( { name = "Wasteland", node_top = "main:dirt", depth_top = 2, node_water = "main:toxicwater_source", y_min = 1, y_max = 170, heat_point = 80, humidity_point = 10, }) --Wasteland Ocean minetest.register_biome( { name = "Wasteland Ocean", node_top = "main:dirt", depth_top = 3, node_water = "main:toxicwater_source", y_min = -31000, y_max = 0, heat_point = 80, humidity_point = 30, }) --Snow Plains minetest.register_biome( { name = "Snow Plains", node_top = "main:snow", depth_top = 6, node_filler = "main:dirt_frozen", depth_filler = 8, node_water = "main:ice_thick", node_river_water = "main:ice_thin", y_min = 1, y_max = 50, heat_point = 0, humidity_point = 10, }) -------------- --Scatter ores -------------- minetest.register_ore({ ore_type = "scatter", ore = "main:sulfur_ore", wherein = "main:stone", "main:cobble", biomes = {"Sulfur Deposit"}, clust_scarcity = 16 * 16 * 16, clust_num_ores = 5, clust_size = 3, y_min = 7, y_max = 15, }) minetest.register_ore({ ore_type = "scatter", ore = "main:iron_ore", wherein = "main:stone", "main:cobble", clust_scarcity = 8 * 8 * 8, clust_num_ores = 6, clust_size = 4, y_min = -30000, y_max = -90, }) minetest.register_ore({ ore_type = "scatter", ore = "main:iron_ore", wherein = "main:stone", "main:cobble", clust_scarcity = 15 * 15 * 15, clust_num_ores = 2, clust_size = 2, y_min = 40, y_max = upper_limit, }) minetest.register_ore({ ore_type = "scatter", ore = "main:coal_ore", wherein = "main:stone", "main:cobble", clust_scarcity = 7 * 7 * 7, clust_num_ores = 5, clust_size = 3, y_min = -30000, y_max = 0, }) minetest.register_ore({ ore_type = "scatter", ore = "main:coal_ore", wherein = "main:stone", "main:cobble", clust_scarcity = 20 * 20 * 20, clust_num_ores = 4, clust_size = 3, y_min = -250, y_max = upper_limit, }) --Cinnabar minetest.register_ore({ ore_type = "scatter", ore = "main:cinnabar_ore", wherein = "main:stone", "main:cobble", clust_scarcity = 18 * 18 * 18, clust_num_ores = 6, clust_size = 4, y_min = -30000, y_max = -100, }) --Salt minetest.register_ore({ ore_type = "scatter", ore = "main:salt_ore", wherein = "main:stone", "main:cobble", clust_scarcity = 10 * 10 * 10, clust_num_ores = 2, clust_size = 2, y_min = -30000, y_max = 30, }) --Low Density Diamond minetest.register_ore({ ore_type = "scatter", ore = "main:diamond_ore_lowdens", wherein = "main:stone", clust_scarcity = 10 * 10 * 10, clust_num_ores = 4, clust_size = 6, y_min = -30000, y_max = -1000, }) --Low Density Diamond minetest.register_ore({ ore_type = "scatter", ore = "main:diamond_ore_hidens", wherein = "main:stone", clust_scarcity = 16 * 16 * 16, clust_num_ores = 8, clust_size = 6, y_min = -30000, y_max = -1200, }) ------------- --Decorations ------------- --Small Rock minetest.register_decoration( { deco_type = "schematic", place_on = {"main:dirt_with_grass", "main:dirt", "main:sand", "main:dirt_with_swamp_grass"}, rotation = "random", sidelen = 16, fill_ratio = 0.004, biomes = {"Grasslands", "Swamp", "Desert", "Wasteland"}, flags = "place_center_x, place_center_z", schematic = minetest.get_modpath("main") .. "/schematics/main_rock_cobble_small.mts", y_min = -32000, y_max = 32000, }) --Oak Tree minetest.register_decoration( { deco_type = "schematic", place_on = {"main:dirt_with_grass"}, rotation = "random", sidelen = 16, fill_ratio = 0.004, biomes = {"Grasslands"}, flags = "place_center_x, place_center_z", schematic = minetest.get_modpath("main") .. "/schematics/main_tree_oak.mts", y_min = -32000, y_max = 32000, }) --Tall Oak Tree minetest.register_decoration( { deco_type = "schematic", place_on = {"main:dirt_with_grass"}, rotation = "random", sidelen = 16, fill_ratio = 0.004, biomes = {"Grasslands", "Swamp"}, flags = "place_center_x, place_center_z", schematic = minetest.get_modpath("main") .. "/schematics/main_tree_oak_tall.mts", y_min = -32000, y_max = 32000, }) --Dead Tall Oak Tree minetest.register_decoration( { deco_type = "schematic", place_on = {"main:dirt", "main:stone", "main:sand"}, rotation = "random", sidelen = 16, biomes = {"Wasteland", "Sulfur Deposit", "Desert"}, flags = "place_center_x, place_center_z", schematic = minetest.get_modpath("main") .. "/schematics/main_tree_oak_tall_dead.mts", y_min = -32000, y_max = 32000, noise_params = { offset = -0.0003, scale = 0.0009, spread = {x = 200, y = 200, z = 200}, seed = 230, octaves = 3, persist = 0.6 }, }) --Apple Tree minetest.register_decoration( { deco_type = "schematic", place_on = {"main:dirt_with_grass"}, rotation = "random", sidelen = 16, fill_ratio = 0.004, biomes = {"Grasslands"}, flags = "place_center_x, place_center_z", schematic = minetest.get_modpath("main") .. "/schematics/main_tree_apple.mts", y_min = -32000, y_max = 32000, })
workspace "flaaffy" configurations { "Debug", "Release" } targetdir "bin/%{cfg.buildcfg}" startproject "mareep" filter "configurations:Debug" defines { "DEBUG" } symbols "on" filter "configurations:Release" defines { "RELEASE" } optimize "On" project "mareep" kind "ConsoleApp" language "C#" namespace "arookas" location "mareep" entrypoint "arookas.mareep" targetname "mareep" framework "4.6.1" links { "arookas", "System", "System.Xml", "System.Xml.Linq", } files { "mareep/**.cs", } excludes { "mareep/bin/**", "mareep/obj/**", }
s(1.5) w "" c "$eU wot mate?" w "" w "You've already" w "submitted an" w "answer"
-- game of life -- jryzkns 2018 -- https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life -- add in music generation based on amount of cells living local unrequited = require("unrequited") zoomfactor = 10 function love.load() game = {} game.xdim = 1000 game.ydim = 600 game.title = "life - jryzkns" unrequited:windowsetup(game.xdim,game.ydim,game.title) game.world = {} for i=1,game.xdim/zoomfactor do game.world[i] = {} for j=1,game.ydim/zoomfactor do game.world[i][j] = false end end game.evolution_delay = 15 game.paused = true -- the main piece! function game:evolve() -- print("evolve!") -- print("current evolution delay:".. tostring(game.evolution_delay).. " frames" .. "current frame: ".. unrequited.photographs) local new_world = {} -- check everything in the world for i=1,game.xdim/zoomfactor do new_world[i] = {} for j=1,game.ydim/zoomfactor do local lifecount = 0 for hori = -1,1 do for vert = -1,1 do local checkx, checky = i + hori, j + vert if checkx == 0 then checkx = game.xdim/zoomfactor end if checkx == game.xdim/zoomfactor + 1 then checkx = 1 end if checky == 0 then checky = game.ydim/zoomfactor end if checky == game.ydim/zoomfactor + 1 then checky = 1 end if game.world[checkx][checky] then lifecount = lifecount + 1 end end end if game.world[i][j] then lifecount = lifecount - 1 end -- to discount self -- assume you die in the end local new_life = false -- if you are alive if game.world[i][j] then -- if you have optimal amount of neighbours if lifecount == 2 or lifecount == 3 then new_life = true end else -- if you are not alive -- by reproduction you become alive if lifecount == 3 then new_life = true end end new_world[i][j] = new_life end end game.world = new_world end living_cells = 0 tone={} tone.note = love.audio.newSource("a440.mp3", "static") -- treating the A as the base note in the scale tbh tone.note:setLooping(true) tone.keypoints = {0,2,4,6,7,9,11} -- g major tone.scalepos = 1 --we start with the base note tone.memory = 0 function tone:transition() if tone.memory ~= living_cells then tone.scalepos = ( living_cells )%7 + 1 end tone.note:setPitch(2^(tone.keypoints[tone.scalepos]/12)) tone.memory = living_cells end tone.note:play() end function love.update(dt) if not game.paused then unrequited:update() if(unrequited.photographs % game.evolution_delay == 0) then game:evolve() tone:transition() end living_cells = 0 for i=1,game.xdim/zoomfactor do for j=1,game.ydim/zoomfactor do if game.world[i][j] then living_cells = living_cells + 1 end end end end end function love.keypressed(key) if key == "p" then unrequited:remember_me() elseif key == "space" then game.paused = not game.paused elseif key == "s" then game:evolve() end end function love.keyreleased(key) if key == "escape" then unrequited:heartbreak() end end function love.mousepressed(x,y,button,istouch) if button == 1 then game.world[math.floor(x/zoomfactor)+1][math.floor(y/zoomfactor)+1] = not game.world[math.floor(x/zoomfactor)+1][math.floor(y/zoomfactor)+1] end end function love.wheelmoved(x,y) -- janky but it works if game.evolution_delay >= 1 then game.evolution_delay = game.evolution_delay + y else game.evolution_delay = 1 end end function love.draw() if game.paused then love.graphics.printf("paused",0,0,200) end for k=1,game.xdim/zoomfactor do for l=1,game.ydim/zoomfactor do love.graphics.push() love.graphics.translate((k-1)*zoomfactor,(l-1)*zoomfactor) if game.world[k][l] then love.graphics.setColor(1,1,1) love.graphics.rectangle("fill",0,0,zoomfactor,zoomfactor) else love.graphics.setColor(0.5,0.5,0.5,0.2) love.graphics.rectangle("line",0,0,zoomfactor,zoomfactor) end love.graphics.pop() end end end
-- more concentrated minetest.register_node("bitumen:vapor_2", { description = "Vapor", drawtype = "airlike", pointable = false, diggable = false, walkable = false, buildable_to = true, paramtype = "light", sunlight_propagates = true, -- post_effect_color = info.post_effect_color, -- tiles = { "default_copper_block.png" }, groups = { not_in_creative_inventory = 1, bitumen_vapor = 1 }, }) -- less concentrated minetest.register_node("bitumen:vapor_1", { description = "Vapor", drawtype = "airlike", pointable = false, diggable = false, walkable = false, buildable_to = true, paramtype = "light", sunlight_propagates = true, -- tiles = { "default_steel_block.png" }, groups = { not_in_creative_inventory = 1, bitumen_vapor = 1 }, }) --[[ for testing minetest.register_node("bitumen:vapor_gen", { description = "Vapor Generator", tiles = { "default_steel_block.png" }, groups = { cracky = 1 }, }) minetest.register_abm({ nodenames = {"bitumen:vapor_gen"}, neighbors = {"air"}, interval = 3, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) pos.y = pos.y + 1 minetest.set_node(pos, {name="bitumen:vapor_2"}) end }) ]] -- move around randomly minetest.register_abm({ nodenames = {"bitumen:vapor_2", "bitumen:vapor_1"}, neighbors = {"air"}, interval = 4, chance = 8, action = function(pos, node, active_object_count, active_object_count_wider) local name = node.name local air_nodes = minetest.find_nodes_in_area( {x=pos.x - 1, y=pos.y - 1, z=pos.z - 1}, {x=pos.x + 1, y=pos.y, z=pos.z + 1}, "air" ) -- try to go down first if #air_nodes > 0 and math.random(6) > 1 then local off = math.random(#air_nodes) --print("off "..dump(off).. " - " .. dump(#air_nodes)) minetest.set_node(pos, {name="air"}) minetest.set_node(air_nodes[off], {name=name}) return end -- go up if there's no down air_nodes = minetest.find_nodes_in_area( {x=pos.x - 1, y=pos.y + 1, z=pos.z - 1}, {x=pos.x + 1, y=pos.y + 1, z=pos.z + 1}, "air" ) if #air_nodes > 0 then local off = math.random(#air_nodes) minetest.set_node(pos, {name="air"}) minetest.set_node(air_nodes[off], {name=name}) end end }) -- diffuse away completely minetest.register_abm({ nodenames = {"bitumen:vapor_1"}, neighbors = {"air"}, interval = 8, chance = 16, action = function(pos, node) local air_nodes = minetest.find_nodes_in_area( {x=pos.x - 1, y=pos.y - 1, z=pos.z - 1}, {x=pos.x + 1, y=pos.y + 1, z=pos.z + 1}, "air" ) if #air_nodes > 12 then minetest.set_node(pos, {name="air"}) end end }) -- diffuse minetest.register_abm({ nodenames = {"bitumen:vapor_2"}, neighbors = {"air"}, interval = 4, chance = 4, action = function(pos, node, active_object_count, active_object_count_wider) local air_nodes = minetest.find_nodes_in_area( {x=pos.x - 1, y=pos.y - 1, z=pos.z - 1}, {x=pos.x + 1, y=pos.y + 1, z=pos.z + 1}, "air" ) if #air_nodes > 0 then local off = math.random(#air_nodes) --print("off "..dump(off).. " - " .. dump(#air_nodes)) minetest.set_node(pos, {name="bitumen:vapor_1"}) minetest.set_node(air_nodes[off], {name="bitumen:vapor_1"}) end end }) -- go up in flames minetest.register_abm({ nodenames = {"bitumen:vapor_1", "bitumen:vapor_2"}, neighbors = {"group:igniter", "default:torch", "default:furnace_active"}, interval = 1, chance = 3, action = function(pos, node, active_object_count, active_object_count_wider) local air_nodes = minetest.find_nodes_in_area( {x=pos.x - 1, y=pos.y - 1, z=pos.z - 1}, {x=pos.x + 1, y=pos.y + 1, z=pos.z + 1}, {"air", "group:flammable"} ) if #air_nodes > 0 then local off = math.random(#air_nodes) local num = math.random(#air_nodes / 2) for i = 1,num do --local theirlevel = minetest.get_node_level(fp) local fp = air_nodes[((i + off) % #air_nodes) + 1] minetest.set_node(fp, {name="fire:basic_flame"}) end end minetest.set_node(pos, {name="fire:basic_flame"}) end })
function love.math.setRandomSeed(seed) return math.randomseed(seed) end function love.math.random(a,b) return math.random(a,b) end function love.math.triangulate(polygon) -- Reference here: https://2dengine.com/?p=polygons#Triangulation local function signedPolygonArea(p) local s = 0 local n = #p local a = p[n] for i = 1, n do local b = p[i] s = s + (b.x + a.x)*(b.y - a.y) a = b end return s end local function isPolygonCounterClockwise(p) return signedPolygonArea(p) > 0 end local function polygonReverse(p) local n = #p for i = 1, math.floor(n/2) do local i2 = n - i + 1 p[i], p[i2] = p[i2], p[i] end end local function pointInTriangle(p, p1, p2, p3) local ox, oy = p.x, p.y local px1, py1 = p1.x - ox, p1.y - oy local px2, py2 = p2.x - ox, p2.y - oy local ab = px1*py2 - py1*px2 local px3, py3 = p3.x - ox, p3.y - oy local bc = px2*py3 - py2*px3 local sab = ab < 0 if sab ~= (bc < 0) then return false end local ca = px3*py1 - py3*px1 return sab == (ca < 0) end local function signedTriangleArea(p1, p2, p3) return (p1.x - p3.x)*(p2.y - p3.y) - (p1.y - p3.y)*(p2.x - p3.x) end if not isPolygonCounterClockwise(polygon) then polygonReverse(polygon) end local left, right = {}, {} for i = 1, #polygon do local v = polygon[i] left[v], right[v] = polygon[i - 1], polygon[i + 1] end local first, last = polygon[1], polygon[#polygon] left[first], right[last] = last, first local triangles = {} local nskip = 0 local i1 = first while #polygon >= 3 and nskip <= #polygon do local i0, i2 = left[i1], right[i1] local function isEar(i0, i1, i2) if signedTriangleArea(i0, i1, i2) >= 0 then local j1 = right[i2] repeat local j0, j2 = left[j1], right[j1] if signedTriangleArea(j0, j1, j2) <= 0 then if pointInTriangle(j1, i0, i1, i2) then return false end end j1 = j2 until j1 == i0 return true end return false end if #polygon > 3 and isEar(i0, i1, i2) then table.insert(triangles, { i0, i1, i2 }) left[i2], right[i0] = i0, i2 left[i1], right[i1] = nil, nil nskip = 0 i1 = i0 else nskip = nskip + 1 i1 = i2 end end return triangles end
local fsm = require "fsm" describe("fsm", function () local m describe("events & states", function () before_each(function () m = fsm.create({ initial = "green", events = { {name = "warn", from = "green", to = "yellow"}, {name = "panic", from = "yellow", to = "red" }, {name = "calm", from = "red", to = "yellow"}, {name = "clear", from = "yellow", to = "green" } } }) end) it("starts with green", function () assert.are_equal("green", m.current) end) it("transitions from green to yellow", function () m.warn() assert.are_equal("yellow", m.current) end) it("transitions from yellow to red", function () m.warn() m.panic() assert.are_equal("red", m.current) end) it("transitions from red to yellow", function () m.warn() m.panic() m.calm() assert.are_equal("yellow", m.current) end) it("transitions from yellow to green", function () m.warn() m.panic() m.calm() m.clear() assert.are_equal("green", m.current) end) end) describe("#is", function() before_each(function () m = fsm.create({ initial = "green", events = { {name = "warn", from = "green", to = "yellow"}, {name = "panic", from = "yellow", to = "red" }, {name = "calm", from = "red", to = "yellow"}, {name = "clear", from = "yellow", to = "green" } } }) end) it("starts with green", function () assert.are_equal("green", m.current) end) it("does report current state as green", function () assert.is_true(m.is("green")) end) it("does NOT report current state as yellow", function () assert.is_not_true(m.is("yellow")) end) it("does report current state as green or red", function () assert.is_true(m.is({"green", "red"})) end) it("does NOT report current state as yellow or red", function () assert.is_not_true(m.is({"yellow", "red"})) end) describe("when warned", function () before_each(function () m.warn() end) it("is yellow", function () assert.are_equal("yellow", m.current) end) it("does NOT report current state as green", function () assert.is_not_true(m.is("green")) end) it("does report current state as yellow", function () assert.is_true(m.is("yellow")) end) it("does NOT report current state as green or red", function () assert.is_not_true(m.is({"green", "red"})) end) it("does report current state as yellow or red", function () assert.is_true(m.is({"yellow", "red"})) end) end) end) describe("#can(not)", function () before_each(function () m = fsm.create({ initial = "green", events = { {name = "warn", from = "green", to = "yellow"}, {name = "panic", from = "yellow", to = "red" }, {name = "calm", from = "red", to = "yellow"} } }) end) it("starts with green", function () assert.are_equal("green", m.current) end) it("is able to warn from green state", function () assert.is_true(m.can("warn")) end) it("is NOT able to panic from green state", function () assert.is_true(m.cannot("panic")) end) it("is NOT able to calm from green state", function () assert.is_true(m.cannot("calm")) end) describe("when warned", function () before_each(function () m.warn() end) it("is yellow", function () assert.are_equal("yellow", m.current) end) it("is NOT able to warn from yellow state", function () assert.is_true(m.cannot("warn")) end) it("is able to panic from yellow state", function () assert.is_true(m.can("panic")) end) it("is NOT able to calm from yellow state", function () assert.is_true(m.cannot("calm")) end) end) describe("when panicked", function () before_each(function () m.warn() m.panic() end) it("is red", function () assert.are_equal("red", m.current) end) it("is NOT able to warn from red state", function () assert.is_true(m.cannot("warn")) end) it("is NOT able to panic from red state", function () assert.is_true(m.cannot("panic")) end) it("is able to calm from red state", function () assert.is_true(m.can("calm")) end) end) end) describe("#transitions", function() describe("with single states", function () before_each(function () m = fsm.create({ initial = "green", events = { {name = "warn", from = "green", to = "yellow"}, {name = "panic", from = "yellow", to = "red" }, {name = "calm", from = "red", to = "yellow"}, {name = "clear", from = "yellow", to = "green" } } }) end) it("starts with green", function () assert.are_equal("green", m.current) end) it("reports current transition to be yellow", function () assert.is_same({"warn"}, m.transitions()) end) it("reports current transitions to be panic and clear", function () m.warn() assert.is_same({"panic", "clear"}, m.transitions()) end) it("reports current transitions to be calm", function () m.warn() m.panic() assert.is_same({"calm"}, m.transitions()) end) it("reports current transitions to be panic and clear", function () m.warn() m.panic() m.calm() assert.is_same({"panic", "clear"}, m.transitions()) end) it("reports current transitions to be panic and clear", function () m.warn() m.panic() m.calm() m.clear() assert.is_same({"warn"}, m.transitions()) end) end) describe("with multiple states", function () before_each(function () m = fsm.create({ events = { {name = "start", from = "none", to = "green" }, {name = "warn", from = {"green", "red"}, to = "yellow"}, {name = "panic", from = {"green", "yellow"}, to = "red" }, {name = "clear", from = {"red", "yellow"}, to = "green" } } }) end) it("starts empty", function () assert.are_equal("none", m.current) end) it("reports current transition to be start", function () assert.is_same({"start"}, m.transitions()) end) it("reports current transitions to be warn and panic", function () m.start() assert.is_same({"warn", "panic"}, m.transitions()) end) it("reports current transitions to be panic and clear", function () m.start() m.warn() assert.is_same({"panic", "clear"}, m.transitions()) end) it("reports current transitions to be warn and clear", function () m.start() m.warn() m.panic() assert.is_same({"warn", "clear"}, m.transitions()) end) it("reports current transitions to be warn and panic", function () m.start() m.warn() m.panic() m.clear() assert.is_same({"warn", "panic"}, m.transitions()) end) end) end) describe("#is_pending", function () before_each(function () m = fsm.create({ initial = "green", events = { {name = "warn", from = "green", to = "yellow"}, {name = "panic", from = "yellow", to = "red" } }, callbacks = { on_leave_green = function () return fsm.DEFERRED end } }) end) it("is NOT pending when green", function () assert.is_not_true(m.is_pending()) end) it("is pending when leaving green", function () m.warn() assert.is_true(m.is_pending()) end) end) describe("#is_finished", function () describe("with terminal state", function () before_each(function () m = fsm.create({ initial = "green", terminal = "red", events = { {name = "warn", from = "green", to = "yellow"}, {name = "panic", from = "yellow", to = "red" } } }) end) it("is NOT finished when green", function () assert.is_not_true(m.is_finished()) end) it("is NOT finished when yellow", function () m.warn() assert.is_not_true(m.is_finished()) end) it("is finished when yellow", function () m.warn() m.panic() assert.is_true(m.is_finished()) end) end) describe("without terminal state", function () before_each(function () m = fsm.create({ initial = "green", events = { {name = "warn", from = "green", to = "yellow"}, {name = "panic", from = "yellow", to = "red" } } }) end) it("is NOT finished when green", function () assert.is_not_true(m.is_finished()) end) it("is NOT finished when yellow", function () m.warn() assert.is_not_true(m.is_finished()) end) it("is NOT finished when yellow", function () m.warn() m.panic() assert.is_not_true(m.is_finished()) end) end) end) describe("event return values", function () before_each(function () m = fsm.create({ initial = "stopped", events = { {name = "prepare", from = "stopped", to = "ready" }, {name = "fake", from = "ready", to = "running"}, {name = "start", from = "ready", to = "running"}, {name = "start", from = "running" } }, callbacks = { on_before_fake = function () return false end, on_leave_ready = function () return fsm.DEFERRED end } }) end) it("starts with stopped", function () assert.are_equal("stopped", m.current) end) it("reports event to have succeeded", function () assert.are_equal(fsm.SUCCEEDED, m.prepare()) assert.are_equal("ready", m.current) end) it("reports event to have been cancelled", function () m.prepare() assert.are_equal(fsm.CANCELLED, m.fake()) assert.are_equal("ready", m.current) end) it("reports event to be pending", function () m.prepare() assert.are_equal(fsm.PENDING, m.start()) assert.are_equal("ready", m.current) end) it("reports deferred transition to have succeeded", function () m.prepare() m.start() assert.are_equal(fsm.SUCCEEDED, m.confirm()) assert.are_equal("running", m.current) end) it("reports deferred transition to have been cancelled", function () m.prepare() m.start() assert.are_equal(fsm.CANCELLED, m.cancel()) assert.are_equal("ready", m.current) end) it("reports event to cause no transition", function () m.prepare() m.start() m.confirm() assert.are_equal(fsm.NO_TRANSITION, m.start()) assert.are_equal("running", m.current) end) end) describe("invalid events", function () before_each(function () m = fsm.create({ initial = "green", events = { {name = "warn", from = "green", to = "yellow"}, {name = "panic", from = "yellow", to = "red" }, {name = "calm", from = "red", to = "yellow"} } }) end) it("starts with green", function () assert.are_equal("green", m.current) end) it("throws if we try to panic from green", function () assert.has_errors(function () m.panic() end, "invalid transition from state 'green' with event 'panic'") end) it("throws if we try to calm from green", function () assert.has_errors(function () m.calm() end, "invalid transition from state 'green' with event 'calm'") end) it("throws if we try to warn from yellow", function () m.warn() assert.has_errors(function () m.warn() end, "invalid transition from state 'yellow' with event 'warn'") end) it("throws if we try to calm from yellow", function () m.warn() assert.has_errors(function () m.calm() end, "invalid transition from state 'yellow' with event 'calm'") end) it("throws if we try to warn from red", function () m.warn() m.panic() assert.has_errors(function () m.warn() end, "invalid transition from state 'red' with event 'warn'") end) it("throws if we try to panic from red", function () m.warn() m.panic() assert.has_errors(function () m.panic() end, "invalid transition from state 'red' with event 'panic'") end) end) describe("invalid transitions", function () before_each(function () m = fsm.create({ initial = "green", events = { {name = "warn", from = "green", to = "yellow"}, {name = "panic", from = "yellow", to = "red" }, {name = "calm", from = "red", to = "yellow"}, {name = "clear", from = "yellow", to = "green" } }, callbacks = { on_leave_green = function() return fsm.DEFERRED end, on_leave_yellow = function() return fsm.DEFERRED end, on_leave_red = function() return fsm.DEFERRED end } }) end) it("starts with green", function () assert.are_equal("green", m.current) end) it("throws if we try to panic from yellow without confirming the previous transition", function () m.warn() assert.has_errors(function () m.panic() end, "previous transition still pending") end) it("throws if we try to calm from red without confirming the previous transition", function () m.warn() m.confirm() m.panic() assert.has_errors(function () m.calm() end, "previous transition still pending") end) it("throws if we try to clear from yellow without confirming the previous transition", function () m.warn() m.confirm() m.panic() m.confirm() m.calm() assert.has_errors(function () m.clear() end, "previous transition still pending") end) end) describe("noop transitions (empty 'to')", function () before_each(function () m = fsm.create({ initial = "green", events = { {name = "noop", from = "green" }, {name = "warn", from = "green", to = "yellow"}, {name = "panic", from = "yellow", to = "red" }, {name = "calm", from = "red", to = "yellow"}, {name = "clear", from = "yellow", to = "green" } } }) end) it("starts with green", function () assert.are_equal("green", m.current) end) it("is able to noop from green state", function () assert.is_true(m.can("noop")) end) it("is able to warn from green state", function () assert.is_true(m.can("warn")) end) it("does NOT cause a transition when noop", function () m.noop() assert.are_equal("green", m.current) end) it("does cause a transition when warn", function () m.noop() m.warn() assert.are_equal("yellow", m.current) end) it("is NOT able to noop from yellow state", function () m.noop() m.warn() assert.is_true(m.cannot("noop")) end) it("is NOT able to warn from yellow state", function () m.noop() m.warn() assert.is_true(m.cannot("warn")) end) end) describe("implicit wildcard transitions (empty 'from')", function () before_each(function () m = fsm.create({ initial = "stopped", events = { {name = "prepare", from = "stopped", to = "ready" }, {name = "start", from = "ready", to = "running"}, {name = "resume", from = "paused", to = "running"}, {name = "pause", from = "running", to = "paused" }, {name = "stop", to = "stopped"} } }) end) it("starts with stopped", function () assert.are_equal("stopped", m.current) end) it("is able to stop from ready", function () m.prepare() m.stop() assert.are_equal("stopped", m.current) end) it("is able to stop from running", function () m.prepare() m.start() m.stop() assert.are_equal("stopped", m.current) end) it("is able to stop from paused", function () m.prepare() m.start() m.pause() m.stop() assert.are_equal("stopped", m.current) end) end) describe("explicit wildcard transitions ('from' set to '*')", function () before_each(function () m = fsm.create({ initial = "stopped", events = { {name = "prepare", from = "stopped", to = "ready" }, {name = "start", from = "ready", to = "running"}, {name = "resume", from = "paused", to = "running"}, {name = "pause", from = "running", to = "paused" }, {name = "stop", from = "*", to = "stopped"} } }) end) it("starts with stopped", function () assert.are_equal("stopped", m.current) end) it("is able to stop from ready", function () m.prepare() m.stop() assert.are_equal("stopped", m.current) end) it("is able to stop from running", function () m.prepare() m.start() m.stop() assert.are_equal("stopped", m.current) end) it("is able to stop from paused", function () m.prepare() m.start() m.pause() m.stop() assert.are_equal("stopped", m.current) end) end) describe("deferrable startup", function () before_each(function () m = fsm.create({ initial = {state = "green", event = "init", defer = true}, events = { {name = "warn", from = "green", to = "yellow"}, {name = "panic", from = "yellow", to = "red" }, {name = "calm", from = "red", to = "yellow"} } }) end) it("starts with none", function () assert.are_equal("none", m.current) end) it("is able to init from none to green", function () m.init() assert.are_equal("green", m.current) end) it("is able to warn from green", function () m.init() m.warn() assert.are_equal("yellow", m.current) end) end) describe("cancellable event", function () before_each(function () m = fsm.create({ initial = "green", events = { {name = "warn", from = "green", to = "yellow"}, {name = "panic", from = "green", to = "red" } }, callbacks = { on_before_warn = function () return false end, on_leave_green = function () return false end } }) end) it("starts with green", function () assert.are_equal("green", m.current) end) it("stays green when warn event is cancelled", function () m.warn() assert.are_equal("green", m.current) end) it("stays green when panic event is cancelled", function () m.panic() assert.are_equal("green", m.current) end) end) describe("callbacks", function () local called local function track(name, args) if args then name = name .. "(" .. table.concat(args, ",") .. ")" end table.insert(called, name) end before_each(function () called = {} m = fsm.create({ initial = "green", events = { {name = "warn", from = "green", to = "yellow"}, {name = "panic", from = "yellow", to = "red" }, {name = "calm", from = "red", to = "yellow"}, {name = "clear", from = "yellow", to = "green" } }, callbacks = { -- generic callbacks on_before_event = function (_, ...) track("on_before", {...}) end, on_after_event = function (_, ...) track("on_after", {...}) end, on_enter_state = function (_, ...) track("on_enter", {...}) end, on_leave_state = function (_, ...) track("on_leave", {...}) end, -- specific state callbacks on_enter_green = function () track("on_enter_green") end, on_enter_yellow = function () track("on_enter_yellow") end, on_enter_red = function () track("on_enter_red") end, on_leave_green = function () track("on_leave_green") end, on_leave_yellow = function () track("on_leave_yellow") end, on_leave_red = function () track("on_leave_red") end, -- specific event callbacks on_before_warn = function () track("on_before_warn") end, on_before_panic = function () track("on_before_panic") end, on_before_calm = function () track("on_before_calm") end, on_before_clear = function () track("on_before_clear") end, on_after_warn = function () track("on_after_warn") end, on_after_panic = function () track("on_after_panic") end, on_after_calm = function () track("on_after_calm") end, on_after_clear = function () track("on_after_clear") end } }) end) it("invokes all callbacks when warn", function () m.warn() assert.are_same({ "on_before(startup,none,green)", "on_leave(startup,none,green)", "on_enter_green", "on_enter(startup,none,green)", "on_after(startup,none,green)", "on_before_warn", "on_before(warn,green,yellow)", "on_leave_green", "on_leave(warn,green,yellow)", "on_enter_yellow", "on_enter(warn,green,yellow)", "on_after_warn", "on_after(warn,green,yellow)" }, called) end) it("invokes all callbacks with additional arguments when panic", function () m.warn() m.panic("foo", "bar") assert.are_same({ "on_before(startup,none,green)", "on_leave(startup,none,green)", "on_enter_green", "on_enter(startup,none,green)", "on_after(startup,none,green)", "on_before_warn", "on_before(warn,green,yellow)", "on_leave_green", "on_leave(warn,green,yellow)", "on_enter_yellow", "on_enter(warn,green,yellow)", "on_after_warn", "on_after(warn,green,yellow)", "on_before_panic", "on_before(panic,yellow,red,foo,bar)", "on_leave_yellow", "on_leave(panic,yellow,red,foo,bar)", "on_enter_red", "on_enter(panic,yellow,red,foo,bar)", "on_after_panic", "on_after(panic,yellow,red,foo,bar)" }, called) end) end) describe("callbacks throwing errors", function () before_each(function () m = fsm.create({ initial = "green", events = { {name = "warn", from = "green", to = "yellow"}, {name = "panic", from = "yellow", to = "red" }, {name = "calm", from = "red", to = "yellow"} }, callbacks = { on_enter_yellow = function () error("oops") end } }) end) it("starts with green", function () assert.are_equal("green", m.current) end) it("does not swallow generated error", function () assert.has_errors(function () m.warn() end, "oops") end) end) end)
--[[ Name: Board.lua From roblox-trello v2 Description: Constructor for Trello Boards. Copyright (c) 2019 Luis, David Duque Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. --]] local HTTP = require(script.Parent.Parent.TrelloHttp) -- TrelloBoard Metatable local TrelloBoardMeta = { __tostring = "TrelloBoard", __metatable = "TrelloBoard", -- Hopefully this will not throw false positives. Functions that will eventually work with this should be aware. __index = function(_, index) error("[TrelloBoard]: Attempted to index non-existant property "..tostring(index)..".", 0) end, -- This can be bypassed using rawset, but at that point it's not on us __newindex = function(_, index, _) error("[TrelloBoard]: Attempted to set non-existant property "..tostring(index)..".", 0) end } -- Local function prototype to make a board based on a body dump local makeBoard local TrelloBoard = {} --[[** Creates a new board, that is then also created on Trello. @param [t:String] name The Board's name. Must to be a non-empty string with a maximum of 16384 characters. @param [t:Boolean] public Whether the board is public or not. If this field is not provided, the board will be private. @param [t:TrelloClient] client The client the board will be assigned to. @returns [t:TrelloBoard] A new TrelloBoard that was freshly created. **--]] function TrelloBoard.new(name, public, client) if not client or getmetatable(client) ~= "TrelloClient" then error("[TrelloBoard.new]: Invalid client!", 0) elseif not name or name == "" or name:len() > 16384 then error("[TrelloBoard.new]: Invalid name! Make sure that the name is a non-empty string with less than 16384 characters.", 0) end local commitURL = client:MakeURL("/boards", { name = name, defaultLabels = false, defaultLists = false, prefs_selfJoin = false, prefs_cardCovers = false, prefs_permissionLevel = public and "public" or "private" }) local result = HTTP.RequestInsist(commitURL, HTTP.HttpMethod.POST, "{}", true) return makeBoard(client, result.Body) end --[[** Fetches a TrelloBoard from Trello. @param [t:String] name The Board's ID. @param [t:TrelloClient] client The client the board will be assigned to. @returns [t:Variant<TrelloBoard,nil>] The Trello Board fetched. Returns nil if the board doesn't exist. **--]] function TrelloBoard.fromRemote(remoteId, client) if not client or getmetatable(client) ~= "TrelloClient" then error("[TrelloBoard.fromRemote]: Invalid client!", 0) elseif not remoteId or remoteId == "" then error("[TrelloBoard.fromRemote]: Invalid board id!", 0) end local commitURL = client:MakeURL("/boards/" .. remoteId, { customFields = false, card_pluginData = false, fields = {"name","desc","descData","closed","prefs"}, }) local result = HTTP.RequestInsist(commitURL, HTTP.HttpMethod.GET, nil, true) return makeBoard(client, result.Body) end --[[** Fetches all the boards the provided client has edit access to. @param [t:TrelloClient] client The client where to fetch the boards from. @returns [t:Array<TrelloBoard>] An array containing zero or more trello boards. **--]] function TrelloBoard.fetchAllFrom(client) if not client or getmetatable(client) ~= "TrelloClient" then error("[TrelloBoard.fromRemote]: Invalid client!", 0) end local commitURL = client:MakeURL("/members/me/boards", { filter = "open", fields = {"name","desc","descData","closed","prefs"}, lists = "all", memberships = "none", organization = false, organization_fields = "" }) print(commitURL) local result = HTTP.RequestInsist(commitURL, HTTP.HttpMethod.GET, nil, true) local body = result.Body local boards = {} for _, b in pairs(body) do table.insert(boards, makeBoard(client, b)) end return boards end -- Prototype implementation makeBoard = function(client, data) if not data then return nil end local trelloBoard = { RemoteId = data.id, Name = data.name, Description = data.desc, Public = data.prefs.permissionLevel == "public", Closed = data.closed, _Remote = { Name = data.name, Description = data.desc, Public = data.prefs.permissionLevel == "public", Closed = data.closed } } --[[** Pushes all metadata changes to Trello. (Doesn't apply to lists, cards, etc.) @param [t:Boolean] force Whether to push all changes to the board even though nothing has been changed. @returns [t:Void] **--]] function trelloBoard:Commit(force) local count = 0 local commit = {} for i, v in pairs (self._Remote) do if v ~= self[i] or force then commit[i] = self[i] count = count + 1 end end if count == 0 then warn("[Trello/Board.Commit]: Nothing to change. Skipping") end local commitURL = client:MakeURL("/boards/"..self.RemoteId, { name = commit.Name, desc = commit.Description, closed = commit.Closed, prefs = (commit.Public ~= nil) and { permissionLevel = commit.Public and "public" or "private" } or nil }) HTTP.RequestInsist(commitURL, HTTP.HttpMethod.PUT, "{}", true) for i, v in pairs(commit) do self._Remote[i] = v end end --[[** Deletes this board from Trello. All garbage collection is up to the developer to perform. @returns [t:Void] **--]] function trelloBoard:Delete() local commitURL = client:MakeURL("/boards/" .. self.RemoteId) HTTP.RequestInsist(commitURL, HTTP.HttpMethod.DELETE, nil, true) trelloBoard = nil end return setmetatable(trelloBoard, TrelloBoardMeta) end return {Public = TrelloBoard, Make = makeBoard}
dirtmons = {} dirtmons.mod = "Dirt monsters Aggressive" function dirtmons:register_mob(name, def) minetest.register_entity(name, { name = name, hp_min = def.hp_min or 5, hp_max = def.hp_max, physical = true, collisionbox = def.collisionbox, visual = def.visual, visual_size = def.visual_size, mesh = def.mesh, textures = def.textures, makes_footstep_sound = def.makes_footstep_sound, view_range = def.view_range, walk_velocity = def.walk_velocity, run_velocity = def.run_velocity, damage = def.damage, light_damage = def.light_damage, water_damage = def.water_damage, lava_damage = def.lava_damage, fall_damage = def.fall_damage or true, drops = def.drops, armor = def.armor, drawtype = def.drawtype, type = def.type, attack_type = def.attack_type, sounds = def.sounds, animation = def.animation, follow = def.follow, jump = def.jump or true, --exp_min = def.exp_min or 0, --xp_max = def.exp_max or 0, walk_chance = def.walk_chance or 50, attacks_monsters = def.attacks_monsters or false, group_attack = def.group_attack or false, step = def.step or 0, fov = def.fov or 120, passive = def.passive or false, recovery_time = def.recovery_time or 0.5, knock_back = def.knock_back or 3, blood_offset = def.blood_offset or 0, blood_amount = def.blood_amount or 5, -- 15 blood_texture = def.blood_texture or "default_dirt.png", rewards = def.rewards or nil, stimer = 0, timer = 0, env_damage_timer = 0, -- only if state = "attack" attack = {player=nil, dist=nil}, state = "stand", v_start = false, old_y = nil, lifetimer = 60, last_state = nil, pause_timer = 0, do_attack = function(self, player, dist) if self.state ~= "attack" then if self.sounds.war_cry then if math.random(0,100) < 90 then minetest.sound_play(self.sounds.war_cry,{ object = self.object }) end end self.state = "attack" self.attack.player = player self.attack.dist = dist end end, set_velocity = function(self, v) local yaw = self.object:getyaw() if self.drawtype == "side" then yaw = yaw+(math.pi/2) end local x = math.sin(yaw) * -v local z = math.cos(yaw) * v self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z}) end, get_velocity = function(self) local v = self.object:getvelocity() return (v.x^2 + v.z^2)^(0.5) end, set_animation = function(self, type) if not self.animation then return end if not self.animation.current then self.animation.current = "" end if type == "stand" and self.animation.current ~= "stand" then if self.animation.stand_start and self.animation.stand_end and self.animation.speed_normal then self.object:set_animation( {x=self.animation.stand_start,y=self.animation.stand_end}, self.animation.speed_normal, 0 ) self.animation.current = "stand" end elseif type == "walk" and self.animation.current ~= "walk" then if self.animation.walk_start and self.animation.walk_end and self.animation.speed_normal then self.object:set_animation( {x=self.animation.walk_start,y=self.animation.walk_end}, self.animation.speed_normal, 0 ) self.animation.current = "walk" end elseif type == "run" and self.animation.current ~= "run" then if self.animation.run_start and self.animation.run_end and self.animation.speed_run then self.object:set_animation( {x=self.animation.run_start,y=self.animation.run_end}, self.animation.speed_run, 0 ) self.animation.current = "run" end elseif type == "punch" and self.animation.current ~= "punch" then if self.animation.punch_start and self.animation.punch_end and self.animation.speed_normal then self.object:set_animation( {x=self.animation.punch_start,y=self.animation.punch_end}, self.animation.speed_normal, 0 ) self.animation.current = "punch" end end end, on_step = function(self, dtime) if self.type == "monster" and minetest.setting_getbool("only_peaceful_mobs") then self.object:remove() end self.lifetimer = self.lifetimer - dtime if self.lifetimer <= 0 and not self.tamed and self.type ~= "npc" then local player_count = 0 for _,obj in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 10)) do if obj:is_player() then player_count = player_count+1 end end if player_count == 0 and self.state ~= "attack" then minetest.log("action","lifetimer expired, removed mob "..self.name) self.object:remove() return end end if self.object:getvelocity().y > 0.1 then local yaw = self.object:getyaw() if self.drawtype == "side" then yaw = yaw+(math.pi/2) end local x = math.sin(yaw) * -2 local z = math.cos(yaw) * 2 --[[ self.object:setacceleration({x=x, y=-10, z=z}) else self.object:setacceleration({x=0, y=-10, z=0}) end ]] --Mobs float in water now, to revert uncomment previous 4 lines and remove following block of 12 if minetest.get_item_group(minetest.get_node(self.object:getpos()).name, "water") ~= 0 then self.object:setacceleration({x = x, y = 1.5, z = z}) else self.object:setacceleration({x = x, y = -10, z = z}) -- 14.5 end else if minetest.get_item_group(minetest.get_node(self.object:getpos()).name, "water") ~= 0 then self.object:setacceleration({x = 0, y = 1.5, z = 0}) else self.object:setacceleration({x = 0, y = -10, z = 0}) -- 14.5 end end -- fall damage if self.fall_damage and self.object:getvelocity().y == 0 then if not self.old_y then self.old_y = self.object:getpos().y else local d = self.old_y - self.object:getpos().y if d > 5 then local damage = d-5 self.object:set_hp(self.object:get_hp()-damage) if self.object:get_hp() == 0 then self.object:remove() end end self.old_y = self.object:getpos().y end end -- if pause state then this is where the loop ends -- pause is only set after a monster is hit if self.pause_timer > 0 then self.pause_timer = self.pause_timer - dtime if self.pause_timer <= 0 then self.pause_timer = 0 end return end self.timer = self.timer+dtime if self.state ~= "attack" then if self.timer < 1 then return end self.timer = 0 end if self.sounds and self.sounds.random and math.random(1, 100) <= 1 then minetest.sound_play(self.sounds.random, {object = self.object}) end local do_env_damage = function(self) local pos = self.object:getpos() local n = minetest.get_node(pos) if self.light_damage and self.light_damage ~= 0 and pos.y>0 and minetest.get_node_light(pos) and minetest.get_node_light(pos) > 4 and minetest.get_timeofday() > 0.2 and minetest.get_timeofday() < 0.8 then self.object:set_hp(self.object:get_hp()-self.light_damage) if self.object:get_hp() < 1 then self.object:remove() end end if self.water_damage and self.water_damage ~= 0 and minetest.get_item_group(n.name, "water") ~= 0 then self.object:set_hp(self.object:get_hp()-self.water_damage) if self.object:get_hp() < 1 then self.object:remove() end end if self.lava_damage and self.lava_damage ~= 0 and minetest.get_item_group(n.name, "lava") ~= 0 then self.object:set_hp(self.object:get_hp()-self.lava_damage) if self.object:get_hp() < 1 then self.object:remove() end end end self.env_damage_timer = self.env_damage_timer + dtime if self.state == "attack" and self.env_damage_timer > 1 then self.env_damage_timer = 0 do_env_damage(self) elseif self.state ~= "attack" then do_env_damage(self) end -- FIND SOMEONE TO ATTACK if ( self.type == "monster" or self.type == "badp" ) and minetest.setting_getbool("enable_damage") and self.state ~= "attack" then local s = self.object:getpos() local inradius = minetest.get_objects_inside_radius(s,self.view_range) local player = nil local type = nil for _,oir in ipairs(inradius) do if oir:is_player() then player = oir type = "player" else local obj = oir:get_luaentity() if obj then player = obj.object type = obj.type end end if type == "player" or type == "npc" then local s = self.object:getpos() local p = player:getpos() local sp = s p.y = p.y + 1 sp.y = sp.y + 1 -- aim higher to make looking up hills more realistic local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5 if dist < self.view_range then -- and self.in_fov(self,p) then if minetest.line_of_sight(sp,p,2) == true then self.do_attack(self,player,dist) break end end end end end -- DIRT FIND A BADPLAYER TO ATTACK if self.type == "monster" and self.attacks_monsters and self.state ~= "attack" then local s = self.object:getpos() local inradius = minetest.get_objects_inside_radius(s,self.view_range) for _, oir in pairs(inradius) do local obj = oir:get_luaentity() if obj then if obj.type == "npc" or obj.type == "barbarian" then -- attack monster local p = obj.object:getpos() local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5 self.do_attack(self,obj.object,dist) break end end end end if self.follow ~= "" and not self.following then for _,player in pairs(minetest.get_connected_players()) do local s = self.object:getpos() local p = player:getpos() local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5 if self.view_range and dist < self.view_range then self.following = player break end end end if self.following and self.following:is_player() then if self.following:get_wielded_item():get_name() ~= self.follow then self.following = nil else local s = self.object:getpos() local p = self.following:getpos() local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5 if dist > self.view_range then self.following = nil self.v_start = false else local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z} local yaw = math.atan(vec.z/vec.x)+math.pi/2 if self.drawtype == "side" then yaw = yaw+(math.pi/2) end if p.x > s.x then yaw = yaw+math.pi end self.object:setyaw(yaw) if dist > 2 then if not self.v_start then self.v_start = true self.set_velocity(self, self.walk_velocity) else if self.jump and self.get_velocity(self) <= 1.5 and self.object:getvelocity().y == 0 then local v = self.object:getvelocity() v.y = 6 self.object:setvelocity(v) end self.set_velocity(self, self.walk_velocity) end self:set_animation("walk") else self.v_start = false self.set_velocity(self, 0) self:set_animation("stand") end return end end end if self.state == "stand" then -- randomly turn if math.random(1, 4) == 1 then -- if there is a player nearby look at them local lp = nil local s = self.object:getpos() if self.type == "npc" then local o = minetest.get_objects_inside_radius(self.object:getpos(), 3) local yaw = 0 for _,o in ipairs(o) do if o:is_player() then lp = o:getpos() break end end end local yaw = 0 if lp ~= nil then local vec = {x=lp.x-s.x, y=lp.y-s.y, z=lp.z-s.z} yaw = math.atan(vec.z/vec.x)+math.pi/2 if self.drawtype == "side" then yaw = yaw+(math.pi/2) end if lp.x > s.x then yaw = yaw+math.pi end else yaw = self.object:getyaw()+((math.random(0,360)-180)/180*math.pi) end self.object:setyaw(yaw) end self.set_velocity(self, 0) self.set_animation(self, "stand") if math.random(1, 100) <= self.walk_chance then self.set_velocity(self, self.walk_velocity) self.state = "walk" self.set_animation(self, "walk") end elseif self.state == "walk" then if math.random(1, 100) < 31 then self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi)) end if self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then local v = self.object:getvelocity() v.y = 5 self.object:setvelocity(v) end self:set_animation("walk") self.set_velocity(self, self.walk_velocity) if math.random(1, 100) < 31 then self.set_velocity(self, 0) self.state = "stand" self:set_animation("stand") end elseif self.state == "attack" and self.attack_type == "dogfight" then if not self.attack.player or not self.attack.player:getpos() then print("stop attacking") self.state = "stand" self:set_animation("stand") return end local s = self.object:getpos() local p = self.attack.player:getpos() local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5 if dist > self.view_range or self.attack.player:get_hp() <= 0 then self.state = "stand" self.v_start = false self.set_velocity(self, 0) self.attack = {player=nil, dist=nil} self:set_animation("stand") return else self.attack.dist = dist end local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z} local yaw = math.atan(vec.z/vec.x)+math.pi/2 if self.drawtype == "side" then yaw = yaw+(math.pi/2) end if p.x > s.x then yaw = yaw+math.pi end self.object:setyaw(yaw) if self.attack.dist > 2 then if not self.v_start then self.v_start = true self.set_velocity(self, self.run_velocity) else if self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then local v = self.object:getvelocity() v.y = 5 self.object:setvelocity(v) end self.set_velocity(self, self.run_velocity) end self:set_animation("run") else self.set_velocity(self, 0) self:set_animation("punch") self.v_start = false if self.timer > 1 then self.timer = 0 local p2 = p local s2 = s p2.y = p2.y + 1.5 s2.y = s2.y + 1.5 if minetest.line_of_sight(p2,s2) == true then if self.sounds and self.sounds.attack then minetest.sound_play(self.sounds.attack, {object = self.object}) end self.attack.player:punch(self.object, 1.0, { full_punch_interval=1.0, damage_groups = {fleshy=self.damage} }, vec) if self.attack.player:get_hp() < 1 then self.state = "stand" self:set_animation("stand") end end end end else local s = self.object:getpos() local p = self.attack.player:getpos() p.y = p.y - .5 s.y = s.y + .5 local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5 if dist > self.view_range or self.attack.player:get_hp() <= 0 then self.state = "stand" self.v_start = false self.set_velocity(self, 0) if self.type ~= "npc" then self.attack = {player=nil, dist=nil} end self:set_animation("stand") return else self.attack.dist = dist end local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z} local yaw = math.atan(vec.z/vec.x)+math.pi/2 if self.drawtype == "side" then yaw = yaw+(math.pi/2) end if p.x > s.x then yaw = yaw+math.pi end self.object:setyaw(yaw) self.set_velocity(self, 0) end end, on_activate = function(self, staticdata, dtime_s) -- reset HP local pos = self.object:getpos() local distance_rating = ( ( get_distance({x=0,y=0,z=0},pos) ) / 20000 ) local newHP = self.hp_min + math.floor( self.hp_max * distance_rating ) self.object:set_hp( newHP ) self.object:set_armor_groups({fleshy=self.armor}) self.object:setacceleration({x=0, y=-10, z=0}) self.state = "stand" self.object:setvelocity({x=0, y=self.object:getvelocity().y, z=0}) self.object:setyaw(math.random(1, 360)/180*math.pi) if self.type == "monster" and minetest.setting_getbool("only_peaceful_mobs") then self.object:remove() end if self.type ~= "npc" then self.lifetimer = 60 - dtime_s end if staticdata then local tmp = minetest.deserialize(staticdata) if tmp and tmp.lifetimer then self.lifetimer = tmp.lifetimer - dtime_s end if tmp and tmp.tamed then self.tamed = tmp.tamed end --[[if tmp and tmp.textures then self.object:set_properties(tmp.textures) end]] end if self.lifetimer < 1 then self.object:remove() end end, get_staticdata = function(self) local tmp = { lifetimer = self.lifetimer, tamed = self.tamed, textures = { textures = self.textures }, } return minetest.serialize(tmp) end, on_punch = function(self, hitter, tflp, tool_capabilities, dir) process_weapon(hitter,tflp,tool_capabilities) local pos = self.object:getpos() if self.object:get_hp() < 1 then if hitter and hitter:is_player() then -- and hitter:get_inventory() then for _,drop in ipairs(self.drops) do if math.random(1, drop.chance) == 1 then local d = ItemStack(drop.name.." "..math.random(drop.min, drop.max)) -- default.drop_item(pos,d) local pos2 = pos pos2.y = pos2.y + 3.5 -- drop items half block higher minetest.add_item(pos2,d) end end if self.sounds.death ~= nil then minetest.sound_play(self.sounds.death,{ object = self.object, }) end end end --blood_particles if self.blood_amount > 0 and pos then local p = pos p.y = p.y + self.blood_offset minetest.add_particlespawner( 5, --blood_amount, --amount 0.25, --time {x=p.x-0.2, y=p.y-0.2, z=p.z-0.2}, --minpos {x=p.x+0.2, y=p.y+0.2, z=p.z+0.2}, --maxpos {x=0, y=-2, z=0}, --minvel {x=2, y=2, z=2}, --maxvel {x=-4,y=-4,z=-4}, --minacc {x=4,y=-4,z=4}, --maxacc 0.1, --minexptime 1, --maxexptime 0.5, --minsize 1, --maxsize false, --collisiondetection self.blood_texture --texture ) end -- knock back effect, adapted from blockmen's pyramids mod -- https://github.com/BlockMen/pyramids local kb = self.knock_back local r = self.recovery_time if tflp < tool_capabilities.full_punch_interval then kb = kb * ( tflp / tool_capabilities.full_punch_interval ) r = r * ( tflp / tool_capabilities.full_punch_interval ) end local ykb=2 local v = self.object:getvelocity() if v.y ~= 0 then ykb = 0 end self.object:setvelocity({x=dir.x*kb,y=ykb,z=dir.z*kb}) self.pause_timer = r end, }) end dirtmons.spawning_mobs = {} function dirtmons:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height, min_dist, max_dist, spawn_func) dirtmons.spawning_mobs[name] = true minetest.register_abm({ nodenames = nodes, neighbors = {"air"}, interval = 10, chance = chance, action = function(pos, node, _, active_object_count_wider) if active_object_count_wider > active_object_count then return end if not dirtmons.spawning_mobs[name] then return end pos.y = pos.y+1 if not minetest.get_node_light(pos) or minetest.get_node_light(pos) > max_light or minetest.get_node_light(pos) < min_light then --print ("LIGHT", name) return end if pos.y > max_height then return end if not minetest.registered_nodes[minetest.get_node(pos).name] then return end if minetest.registered_nodes[minetest.get_node(pos).name].walkable then return end pos.y = pos.y+1 if not minetest.registered_nodes[minetest.get_node(pos).name] then return end if minetest.registered_nodes[minetest.get_node(pos).name].walkable then return end if min_dist == nil then min_dist = {x=-1,z=-1} end if max_dist == nil then max_dist = {x=33000,z=33000} end if math.abs(pos.x) < min_dist.x or math.abs(pos.z) < min_dist.z or math.abs(pos.x) > max_dist.x or math.abs(pos.z) > max_dist.z then return end if spawn_func and not spawn_func(pos, node) then return end if minetest.setting_getbool("display_mob_spawn") then minetest.chat_send_all("[mobs] Add "..name.." at "..minetest.pos_to_string(pos)) end local mob = minetest.add_entity(pos, name) -- setup the hp, armor, drops, etc... for this specific mob local distance_rating = ( ( get_distance({x=0,y=0,z=0},pos) ) / 15000 ) if mob then mob = mob:get_luaentity() local newHP = mob.hp_min + math.floor( mob.hp_max * distance_rating ) mob.object:set_hp( newHP ) end end }) end function get_distance(pos1,pos2) if ( pos1 ~= nil and pos2 ~= nil ) then return math.abs(math.floor(math.sqrt( (pos1.x - pos2.x)^2 + (pos1.z - pos2.z)^2 ))) else return 0 end end function process_weapon(player, time_from_last_punch, tool_capabilities) local weapon = player:get_wielded_item() if tool_capabilities ~= nil then local wear = ( tool_capabilities.full_punch_interval / 75 ) * 65535 weapon:add_wear(wear) player:set_wielded_item(weapon) end end
require 'torch' dofile 'do_labeling.lua' dofile 'S_transfer'
local _0_0 = nil do local name_23_0_ = "conjure.main" local loaded_23_0_ = package.loaded[name_23_0_] local module_23_0_ = nil if ("table" == type(loaded_23_0_)) then module_23_0_ = loaded_23_0_ else module_23_0_ = {} end module_23_0_["aniseed/module"] = name_23_0_ module_23_0_["aniseed/locals"] = (module_23_0_["aniseed/locals"] or {}) module_23_0_["aniseed/local-fns"] = (module_23_0_["aniseed/local-fns"] or {}) package.loaded[name_23_0_] = module_23_0_ _0_0 = module_23_0_ end local function _1_(...) _0_0["aniseed/local-fns"] = {require = {config = "conjure.config", mapping = "conjure.mapping"}} return {require("conjure.config"), require("conjure.mapping")} end local _2_ = _1_(...) local config = _2_[1] local mapping = _2_[2] do local _ = ({nil, _0_0, {{}, nil}})[2] end local main = nil do local v_23_0_ = nil do local v_23_0_0 = nil local function main0() return mapping.init(config.filetypes()) end v_23_0_0 = main0 _0_0["main"] = v_23_0_0 v_23_0_ = v_23_0_0 end _0_0["aniseed/locals"]["main"] = v_23_0_ main = v_23_0_ end return nil
local awful = require('awful') local beautiful = require('beautiful') local gears = require('gears') local wibox = require('wibox') local icons = require('theme.icons') local helpers = require('helpers') local widget_container = require('widgets.containers.widget-container') local properties = { mute = true, volume = 0, } local check_updates = function() local args = { mute = true, volume = 0, } awful.spawn.easy_async('amixer -D pulse sget Master', function(stdout) args.volume = tonumber(string.match(stdout, '(%d?%d?%d)%%')) args.mute = stdout:match('off') if args.mute == properties.mute and args.volume == properties.volume then return end awesome.emit_signal('widgets::volume', args) end) end local create_volume_widget = function() local percentage_widget = wibox.widget({ text = '0%', widget = wibox.widget.textbox, }) local buttons = { awful.button({}, 1, function() awful.spawn('pavucontrol') end), awful.button({}, 3, function() awesome.emit_signal('widgets::volume::mute::toggle') end), awful.button({}, 4, function() awesome.emit_signal('widgets::volume::increment') end), awful.button({}, 5, function() awesome.emit_signal('widgets::volume::decrement') end), } local volume_widget = widget_container({ { id = 'icon', markup = helpers.colorize_text(icons.volume_off, beautiful.disabled), font = beautiful.nerd_font .. ' 20', widget = wibox.widget.textbox, }, id = 'volume_layout', spacing = beautiful.icon_spacing, layout = wibox.layout.fixed.horizontal, }, buttons, true) awesome.connect_signal('widgets::volume', function(args) properties = args or properties local icon = properties.mute and icons.volume_off or icons.volume_on local color = properties.mute and beautiful.disabled or beautiful.primary volume_widget:get_children_by_id('icon')[1]:set_markup(helpers.colorize_text(icon, color)) percentage_widget:set_text(properties.volume .. '%') local volume_layout = volume_widget:get_children_by_id('volume_layout')[1] local percentage_index = volume_layout:index(percentage_widget) if properties.mute then if percentage_index then volume_layout:remove(percentage_index) end else if not percentage_index then volume_layout:add(percentage_widget) end end end) check_updates() return volume_widget end awesome.connect_signal('widgets::volume::decrement', function() properties.volume = math.max(0, properties.volume - 5) if properties.mute then properties.mute = false awful.spawn.easy_async('amixer -D pulse set Master 1+ on', function() end) end awful.spawn.easy_async('amixer -D pulse sset Master ' .. properties.volume .. '%', function() awesome.emit_signal('widgets::volume') awesome.emit_signal('module::volume_osd', properties) awesome.emit_signal('module::volume_osd:show', true) end) end) awesome.connect_signal('widgets::volume::increment', function() properties.volume = math.min(100, properties.volume + 5) if properties.mute then properties.mute = false awful.spawn.easy_async('amixer -D pulse set Master 1+ on', function() end) end awful.spawn.easy_async('amixer -D pulse sset Master ' .. properties.volume .. '%', function() awesome.emit_signal('widgets::volume') awesome.emit_signal('module::volume_osd', properties) awesome.emit_signal('module::volume_osd:show', true) end) end) awesome.connect_signal('widgets::volume::mute::toggle', function() properties.mute = not properties.mute awful.spawn.easy_async('amixer -D pulse set Master 1+ ' .. (properties.mute and 'off' or 'on'), function() awesome.emit_signal('widgets::volume') awesome.emit_signal('module::volume_osd', properties) awesome.emit_signal('module::volume_osd:show', true) end) end) gears.timer({ timeout = 5, call_now = false, autostart = true, callback = check_updates, }) return create_volume_widget
-- -- Built with, -- -- ,gggg, -- d8" "8I ,dPYb, -- 88 ,dP IP'`Yb -- 8888888P" I8 8I -- 88 I8 8' -- 88 gg gg ,g, I8 dPgg, -- ,aa,_88 I8 8I ,8'8, I8dP" "8I -- dP" "88P I8, ,8I ,8' Yb I8P I8 -- Yb,_,d88b,,_ ,d8b, ,d8b,,8'_ 8) ,d8 I8, -- "Y8P" "Y888888P'"Y88P"`Y8P' "YY8P8P88P `Y8 -- local lush = require('lush') -- useful to have while developing the theme and you're editing the color file package.loaded['lush_theme.light-dark-example-colors'] = nil local colors = require('lush_theme.light-dark-example-colors') local base = require('lush_theme.light-dark-example-base') local theme = lush.extends(base).with(function() return { -- will automatically inherit Comment and CursorLine settings as well -- as all the cleared groups in base Normal { bg = colors.gray_300, fg = colors.gray_800 }, -- but we will override some of Comment -- note, you can pass in any required lush spec group here, it does not -- have to be something you passed into extends() -- extends just merges any old rules into the new spec Comment { base.Comment, bg = colors.gray_300 } } end) -- return our parsed theme for extension or use else where. return theme -- vi:nowrap
local routineHandlerMethods = { Add = function(self, func, ...) if type(func) == "function" and (not self.maxRoutines or #self.list >= self.maxRoutines) then local routineID repeat routineID = math.random(0, 9999) until not self.list[routineID] local routine = { name = false, thread = coroutine.create(func), filter = nil, } local ok, passback = coroutine.resume(routine.thread, ...) if not ok then printError("routineHandler - Add: "..passback) return false elseif coroutine.status(routine.thread) == "dead" then return true else routine.filter = passback end self.list[routineID] = routine table.insert(self.orderedList, routineID) return routineID end return false end, Check = function(self, routineID) if routineID and self.list[routineID] then return coroutine.status(self.list[routineID].thread) end return false end, Remove = function(self, routineID) if routineID and self.list[routineID] then if self.list[routineID].name then self.names[self.list[routineID].name] = nil end self.list[routineID] = nil return true end return false end, GetName = function(self, routineID) if routineID and self.list[routineID] then return self.list[routineID].name end return false end, SetName = function(self, routineID, name) if not (routineID and self.list[routineID]) then return false elseif type(name) == "string" and not self.names[name] then if self.list[routineID].name then self.names[self.list[routineID].name] = nil end self.list[routineID].name = name self.names[name] = routineID return true elseif name == false and self.list[routineID].name then self.names[self.list[routineID].name] = nil self.list[routineID].name = false return true end return false end, NameToID = function(self, name) return self.names[name] or false end, HandleEvent = function(self, eventType, ...) local newOrderedList = {} for _, routineID in ipairs(self.orderedList) do local routine = self.list[routineID] if routine then if routine.filter == nil or routine.filter == eventType or eventType == "terminate" then local ok, passback = coroutine.resume(routine.thread, eventType, ...) if not ok then printError("routineHandler - Run: "..passback) self:Remove(routineID) elseif coroutine.status(routine.thread) == "dead" then self:Remove(routineID) else routine.filter = passback table.insert(newOrderedList, routineID) end else table.insert(newOrderedList, routineID) end end end self.orderedList = newOrderedList end, Run = function(self) self.running = true while self.running do self:HandleEvent(os.pullEvent()) end end, Stop = function(self) if self.running then self.running = false return true end return false end, } local routineHandlerMetatable = {__index = routineHandlerMethods} function new(maxRoutines) if maxRoutines ~= nil and type(maxRoutines) ~= "number" then error("new: number expected for 'maxRoutines'", 2) end local routineHandler = { list = {}, orderedList = {}, names = {}, maxRoutines = maxRoutines and math.floor(maxRoutines), running = false, } return setmetatable(routineHandler, routineHandlerMetatable) end
--[[ globals.lua (FindGlobals), a useful script to find global variable access in .lua files, placed in the public domain by Mikk in 2009. HOW TO INVOKE: luac -l MyFile.lua | lua globals.lua MyFile.lua or: c:\path\to\luac.exe -l MyFile.lua | c:\path\to\lua.exe c:\path\to\globals.lua MyFile.lua Directives in the file: -- GLOBALS: SomeGlobal, SomeOtherGlobal The script will never complain about these. There may be multiple lines of these anywhere in the file, taking effect globally (for now). There is no way to un-GLOBAL an already declared global. -- SETGLOBALFILE [ON/OFF] Enable/disable SETGLOBAL checks in the global scope Default: ON -- SETGLOBALFUNC [ON/OFF] Enable/disable SETGLOBAL checks in functions. This setting affects the whole file (for now) Default: ON -- GETGLOBALFILE [ON/OFF] Default: OFF -- GETGLOBALFUNC [ON/OFF] Default: ON --]] local strmatch=string.match local strgmatch=string.gmatch local print=print local gsub = string.gsub local tonumber=tonumber local source=assert(io.open(arg[1])) -- First we parse the source file local funcNames={} local GLOBALS={} local SETGLOBALfile = true local SETGLOBALfunc = true local GETGLOBALfile = false local GETGLOBALfunc = true local n=0 while true do local lin = source:read() if not lin then break end n=n+1 -- Lamely try to find all function headers and remember the line they were on. Yes, you can fool this. You can also shoot yourself in the foot. Either way it doesn't matter hugely, it's just to prettify the output. local func = strmatch(lin, "%f[%a_][%a0-9_.:]+%s*=%s*function%s*%([^)]*") or -- blah=function(...) strmatch(lin, "%f[%a_]function%s*%([^)]*") or -- function(...) strmatch(lin, "%f[%a_]function%s+[%a0-9_.:]+%s*%([^)]*") -- function blah(...) if func then func=func..")" funcNames[n]=func end if strmatch(lin, "^%s*%-%-") then local args = strmatch(lin, "^%s*%-%-%s*GLOBALS:%s*(.*)") if args then for name in strgmatch(args, "[%a0-9_]+") do GLOBALS[name]=true end end local args = strmatch(lin, "^%s*%-%-%s*SETGLOBALFILE%s+(%u+)") if args=="ON" then SETGLOBALfile=true elseif args=="OFF" then SETGLOBALfile=false end local args = strmatch(lin, "^%s*%-%-%s*GETGLOBALFILE%s+(%u+)") if args=="ON" then GETGLOBALfile=true elseif args=="OFF" then GETGLOBALfile=false end local args = strmatch(lin, "^%s*%-%-%s*SETGLOBALFUNC%s+(%u+)") if args=="ON" then SETGLOBALfunc=true elseif args=="OFF" then SETGLOBALfunc=false end local args = strmatch(lin, "^%s*%-%-%s*GETGLOBALFUNC%s+(%u+)") if args=="ON" then GETGLOBALfunc=true elseif args=="OFF" then GETGLOBALfunc=false end end end -- Helper function that prints a line along with which function it is in. local curfunc local lastfuncprinted local function printone(lin, subst) local globalName = strmatch(lin, "\t; (.+)%s*") if globalName and GLOBALS[globalName] then return end if curfunc~=lastfuncprinted then local from,to = strmatch(curfunc, "function <[^:]*:(%d+),(%d+)") from=tonumber(from) if from and funcNames[from] then print(funcNames[from],strmatch(curfunc, "<.*")) else print(curfunc) end lastfuncprinted = curfunc end lin=gsub(lin, "%d+\t(%[%d+%]).*;%s+(.*)", subst) -- "23 [234]" -> "[234]" (strip the byte offset, we're not interested in it) print(lin) end -- Loop the compiled output, looking for GETGLOBAL, SETGLOBAL, etc.. local nSource=0 local funcScope = false local stdin=assert(io.popen("luac -l -p " .. arg[1])) while true do local lin = stdin:read() if not lin then break end if strmatch(lin,"^main <") then curfunc=lin funcScope = false elseif strmatch(lin,"^function <") then curfunc=lin funcScope = true elseif strmatch(lin,"SETGLOBAL\t") then if funcScope and SETGLOBALfunc then printone(lin, "%1 S:Setting global variable: %2") elseif not funcScope and SETGLOBALfile then printone(lin, "%1 S:Setting global variable: %2") end elseif strmatch(lin,"GETGLOBAL\t") then if funcScope and GETGLOBALfunc then printone(lin, "%1 G:Retrieving global variable: %2") elseif not funcScope and GETGLOBALfile then printone(lin, "%1 G:Retrieving global variable: %2") end end end
-------------------- --- Badssentials --- -------------------- function Draw2DText(x, y, text, scale, center) -- Draw text on screen SetTextFont(4) SetTextProportional(7) SetTextScale(scale, scale) SetTextColour(255, 255, 255, 255) SetTextDropShadow(0, 0, 0, 0,255) SetTextDropShadow() SetTextEdge(4, 0, 0, 0, 255) SetTextOutline() if center then SetTextJustification(0) end SetTextEntry("STRING") AddTextComponentString(text) DrawText(x, y) end tickDegree = 0; local nearest = nil; local postals = Postals; function round(num, numDecimalPlaces) if numDecimalPlaces and numDecimalPlaces>0 then local mult = 10^numDecimalPlaces return math.floor(num * mult + 0.5) / mult end return math.floor(num + 0.5) end currentTime = "0:00"; RegisterNetEvent('Badssentials:SetTime') AddEventHandler('Badssentials:SetTime', function(time) currentTime = time; end) currentDay = 1; RegisterNetEvent('Badssentials:SetDay') AddEventHandler('Badssentials:SetDay', function(day) currentDay = day; end) currentMonth = 1; RegisterNetEvent('Badssentials:SetMonth') AddEventHandler('Badssentials:SetMonth', function(month) currentMonth = month; end) currentYear = "2021"; RegisterNetEvent('Badssentials:SetYear') AddEventHandler('Badssentials:SetYear', function(year) currentYear = year; end) peacetime = false; function ShowInfo(text) SetNotificationTextEntry("STRING") AddTextComponentString(text) DrawNotification(true, false) end currentAOP = "Sandy Shores" RegisterNetEvent('Badssentials:SetAOP') AddEventHandler('Badssentials:SetAOP', function(aop) currentAOP = aop; end) RegisterNetEvent('Badssentials:SetPT') AddEventHandler('Badssentials:SetPT', function(pt) peacetime = pt; end) displaysHidden = false; RegisterCommand("toggle-hud", function() displaysHidden = not displaysHidden; TriggerEvent('Badger-Priorities:HideDisplay') if displaysHidden then DisplayRadar(false); else DisplayRadar(true); end end) RegisterCommand("postal", function(source, args, raw) if #args > 0 then local postalCoords = getPostalCoords(args[1]); if postalCoords ~= nil then -- It is valid SetNewWaypoint(postalCoords.x, postalCoords.y); TriggerEvent('chatMessage', Config.Prefix .. "Your waypoint has been set to postal ^5" .. args[1]); else TriggerEvent('chatMessage', Config.Prefix .. "^1ERROR: That is not a valid postal code..."); end else SetWaypointOff(); TriggerEvent('chatMessage', Config.Prefix .. "Your waypoint has been reset!"); end end) function getPostalCoords(postal) for _, v in pairs(postals) do if v.code == postal then return {x=v.x, y=v.y}; end end return nil; end local cooldown = 0 local ispriority = false local ishold = false RegisterCommand("resetpcd", function() if IsPlayerAceAllowed(src, "Badssentials.PeaceTime") then TriggerServerEvent("cancelcooldown") end end, false) RegisterNetEvent('UpdateCooldown') AddEventHandler('UpdateCooldown', function(newCooldown) cooldown = newCooldown end) RegisterNetEvent('UpdatePriority') AddEventHandler('UpdatePriority', function(newispriority) ispriority = newispriority end) RegisterNetEvent('UpdateHold') AddEventHandler('UpdateHold', function(newishold) ishold = newishold end) Citizen.CreateThread(function() while true do Wait(0); local pos = GetEntityCoords(PlayerPedId()) local playerX, playerY = table.unpack(pos) local ndm = -1 -- nearest distance magnitude local ni = -1 -- nearest index for i, p in ipairs(postals) do local dm = (playerX - p.x) ^ 2 + (playerY - p.y) ^ 2 -- distance magnitude if ndm == -1 or dm < ndm then ni = i ndm = dm end end --setting the nearest if ni ~= -1 then local nd = math.sqrt(ndm) -- nearest distance nearest = {i = ni, d = nd} end local postal = postals[nearest.i].code; local postalDist = round(nearest.d, 2); local var1, var2 = GetStreetNameAtCoord(pos.x, pos.y, pos.z, Citizen.ResultAsInteger(), Citizen.ResultAsInteger()) local zone = GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)); local degree = degreesToIntercardinalDirection(GetCardinalDirection()); local streetName = GetStreetNameFromHashKey(var1); for _, v in pairs(Config.Displays) do local x = v.x; local y = v.y; local enabled = v.enabled; if enabled and not displaysHidden then local disp = v.display; if (disp:find("{NEAREST_POSTAL}") or disp:find("{NEAREST_POSTAL_DISTANCE}")) then disp = disp:gsub("{NEAREST_POSTAL}", postal); disp = disp:gsub("{NEAREST_POSTAL_DISTANCE}", postalDist) end if (disp:find("{STREET_NAME}")) then disp = disp:gsub("{STREET_NAME}", streetName); end if (disp:find("{CITY}")) then disp = disp:gsub("{CITY}", zone); end if (disp:find("{COMPASS}")) then disp = disp:gsub("{COMPASS}", degree); end disp = disp:gsub("{EST_TIME}", currentTime); disp = disp:gsub("{US_DAY}", currentDay); disp = disp:gsub("{US_MONTH}", currentMonth); disp = disp:gsub("{US_YEAR}", currentYear); disp = disp:gsub("{CURRENT_AOP}", currentAOP); if (disp:find("{PRIORITY_STATUS}")) then if ishold == true then disp = disp:gsub("{PRIORITY_STATUS}", "~b~Priorities Are On Hold") elseif cooldown == 0 then disp = disp:gsub("{PRIORITY_STATUS}", "~g~Available") elseif ispriority == true then disp = disp:gsub("{PRIORITY_STATUS}", "~g~Priority In Progress") elseif ispriority == false then disp = disp:gsub("{PRIORITY_STATUS}", "~r~".. cooldown .." ~w~Mins") end end local scale = v.textScale; Draw2DText(x, y, disp, scale, false); end tickDegree = tickDegree + 9.0; end end end) function GetCardinalDirection() local camRot = Citizen.InvokeNative( 0x837765A25378F0BB, 0, Citizen.ResultAsVector() ) local playerHeadingDegrees = 360.0 - ((camRot.z + 360.0) % 360.0) local tickDegree = playerHeadingDegrees - 180 / 2 local tickDegreeRemainder = 9.0 - (tickDegree % 9.0) tickDegree = tickDegree + tickDegreeRemainder return tickDegree; end function degreesToIntercardinalDirection( dgr ) dgr = dgr % 360.0 if (dgr >= 0.0 and dgr < 22.5) or dgr >= 337.5 then return " E " elseif dgr >= 22.5 and dgr < 67.5 then return "SE" elseif dgr >= 67.5 and dgr < 112.5 then return " S " elseif dgr >= 112.5 and dgr < 157.5 then return "SW" elseif dgr >= 157.5 and dgr < 202.5 then return " W " elseif dgr >= 202.5 and dgr < 247.5 then return "NW" elseif dgr >= 247.5 and dgr < 292.5 then return " N " elseif dgr >= 292.5 and dgr < 337.5 then return "NE" end end
print("Hello, world")
--- -- Copyright (c) 2015 Jason Lingle -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions -- are met: -- 1. Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- 3. Neither the name of the author nor the names of its contributors -- may be used to endorse or promote products derived from this software -- without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. local function grad_rgb(r0, g0, b0, r1, g1, b1) return core.argb_gradient({ 255, r0, g0, b0 }, { 255, r1, g1, b1 }, 4) end resource.flower.wild_aprjune_white = core.bind(core.new_flower) { colours = grad_rgb(204, 204, 204, 140, 140, 150), appear = 1.0, disappear = 4.0, size = 0.25, date_stagger = 0.5, } resource.flower.wild_juneaug_pink = core.bind(core.new_flower) { colours = grad_rgb(255, 204, 187, 150, 125, 110), appear = 3.0, disappear = 6.0, size = 0.2, date_stagger = 0.5, } resource.flower.wild_augoct_blue = core.bind(core.new_flower) { colours = grad_rgb(170, 170, 204, 100, 100, 150), appear = 5.0, disappear = 8.0, size = 0.275, date_stagger = 0.5, } resource.flower.seasonal_apr_red = core.bind(core.new_flower) { colours = grad_rgb(255, 64, 32, 140, 32, 24), appear = 0.5, disappear = 2.0, size = 0.23, date_stagger = 0.3, } resource.flower.seasonal_may_yellow = core.bind(core.new_flower) { colours = grad_rgb(204, 200, 32, 150, 150, 24), appear = 1.0, disappear = 3.0, size = 0.2, date_stagger = 0.3, } resource.flower.seasonal_june_blue = core.bind(core.new_flower) { colours = grad_rgb(48, 48, 170, 24, 24, 140), appear = 2.0, disappear = 4.0, size = 0.25, date_stagger = 0.3, } resource.flower.seasonal_july_orange = core.bind(core.new_flower) { colours = grad_rgb(255, 150, 32, 170, 85, 24), appear = 3.0, disappear = 5.0, size = 0.225, } resource.flower.seasonal_aug_white = core.bind(core.new_flower) { colours = grad_rgb(224, 224, 200, 149, 149, 137), appear = 4.0, disappear = 6.0, size = 0.2, date_stagger = 0.3, } resource.flower.seasonal_sept_violet = core.bind(core.new_flower) { colours = grad_rgb(128, 48, 170, 85, 32, 120), appear = 5.0, disappear = 7.0, size = 0.25, date_stagger = 0.3, } --- Distributes the common flowers in a "standard" way function common_flowers_distribute_default() -- Distribute wildflowers uniformly mg.wod_clear() mg.wod_permit_terrain_type(mg.terrain_type_grass) mg.wod_add_flower(resource.flower.wild_aprjune_white(), 0.1, 0.4) mg.wod_add_flower(resource.flower.wild_juneaug_pink(), 0.1, 0.4) mg.wod_add_flower(resource.flower.wild_augoct_blue(), 0.1, 0.4) mg.wod_distribute(100000, 0) local function put_seasonal_flower(flower_type, group_wavelen, h1, h2) mg.wod_clear() mg.wod_permit_terrain_type(mg.terrain_type_grass) mg.wod_add_perlin(64, 256) mg.wod_add_perlin(32, 96) mg.wod_add_perlin(group_wavelen, 64) mg.wod_add_flower(flower_type, h1, h2) mg.wod_distribute(1000000, 256) end put_seasonal_flower(resource.flower.seasonal_apr_red(), 16, 0.2, 0.4) put_seasonal_flower(resource.flower.seasonal_may_yellow(), 8, 0.1, 0.3) put_seasonal_flower(resource.flower.seasonal_june_blue(), 64, 0.2, 0.3) put_seasonal_flower(resource.flower.seasonal_july_orange(), 32, 0.2, 0.5) put_seasonal_flower(resource.flower.seasonal_aug_white(), 16, 0.2, 0.4) put_seasonal_flower(resource.flower.seasonal_sept_violet(), 32, 0.3, 0.4) end
------------------------------------------------------------------------------ -- constants ------------------------------------------------------------------------------ SPLASH_STATE = 1 MAIN_MENU_STATE = 2 GAME_STATE = 3 PAUSE_STATE = 4 OPTIONS_STATE = 5 DEFEAT_STATE = 6 ------------------------------------------------------------------------------ -- transient data ------------------------------------------------------------------------------ state = SPLASH_STATE function GotoState(targetState) if targetState == SPLASH_STATE then SplashState_Start() elseif targetState == GAME_STATE then GameState_Start() elseif targetState == PAUSE_STATE then PauseState_Start() elseif targetState == DEFEAT_STATE then DefeatState_Start() end state = targetState end
class("AirportCaptureBar", import(".LevelStageStatusBarTemplate")).GetUIName = function (slot0) return "AirportCaptureBar" end return class("AirportCaptureBar", import(".LevelStageStatusBarTemplate"))
-- ############# -- ## ## -- ## Inbox ## -- ## ## -- ############# local mailSlotCount = 18; -- Number of slots in the inbox TOC function UMMInboxTOCTemplate_OnLoad(this) this.RefreshTOC = function(self) local offset = UMMMailManager.InboxOffset; for i = 1, mailSlotCount do local button = _G[self:GetName().."Mail"..i] index = i + offset; if (index <= UMMMailManager.MailCount) then local mail = UMMMailManager.Mails[index]; if (mail.Tagged == true) then _G[button:GetName().."Tagged"]:Show() else _G[button:GetName().."Tagged"]:Hide() end getglobal(button:GetName().."Author"):SetText("|cff"..UMMFriends:GetColor(mail.Author, true)..(mail.Author or "").."|r"); local buttonIcon = getglobal(button:GetName().."Button"); SetItemButtonTexture(buttonIcon, mail.Icon); if (mail.AttachedMoney > 0 or mail.AttachedDiamonds > 0) then getglobal(button:GetName().."Subject"):Hide(); getglobal(button:GetName().."SmallSubject"):Show(); if (mail.AttachedMoney > 0) then getglobal(button:GetName().."AttachedMoney"):Show(); getglobal(button:GetName().."AttachedDiamonds"):Hide(); getglobal(button:GetName().."AttachedMoney"):SetAmount(mail.AttachedMoney, "gold"); elseif (mail.AttachedDiamonds > 0) then getglobal(button:GetName().."AttachedMoney"):Hide(); getglobal(button:GetName().."AttachedDiamonds"):Show(); getglobal(button:GetName().."AttachedDiamonds"):SetAmount(mail.AttachedDiamonds, "diamond"); end if (mail.WasRead == true) then getglobal(button:GetName().."SmallSubject"):SetText("|cff"..UMMColor.Grey..mail.Subject.."|r"); else getglobal(button:GetName().."SmallSubject"):SetText("|cff"..UMMColor.White..mail.Subject.."|r"); end else getglobal(button:GetName().."Subject"):Show(); getglobal(button:GetName().."SmallSubject"):Hide(); getglobal(button:GetName().."AttachedMoney"):Hide(); getglobal(button:GetName().."AttachedDiamonds"):Hide(); if (mail.CODAmount > 0) then getglobal(button:GetName().."Subject"):SetText("|cff"..UMMColor.Yellow..mail.Subject.."|r"); else if (mail.WasRead == true) then getglobal(button:GetName().."Subject"):SetText("|cff"..UMMColor.Grey..mail.Subject.."|r"); else getglobal(button:GetName().."Subject"):SetText("|cff"..UMMColor.White..mail.Subject.."|r"); end end end local DaysLeft = mail.DaysLeft; local DaysLeftColor = UMMColor.Green; if (DaysLeft < 1.0) then DaysLeft = DaysLeft * 24; DaysLeft = string.format("%d", DaysLeft); if (DaysLeft == 1) then DaysLeft = DaysLeft.." "..HOUR; else DaysLeft = DaysLeft.." "..HOURS; end DaysLeftColor = UMMColor.Red; else DaysLeft = string.format("%d", DaysLeft) + 1; if (DaysLeft == 1) then DaysLeft = DaysLeft.." "..DAY; DaysLeftColor = UMMColor.Red; elseif (DaysLeft == 2) then DaysLeft = DaysLeft.." "..DAYS; DaysLeftColor = UMMColor.Yellow; else DaysLeft = DaysLeft.." "..DAYS; DaysLeftColor = UMMColor.Green; end end getglobal(button:GetName().."DaysLeft"):SetText("|cff"..DaysLeftColor..DaysLeft.."|r"); button:Show(); else button:Hide(); end end if (UMMMailManager.InboxTotalMoney > 0) then getglobal(self:GetParent():GetName().."ToolsTotalMoneyLabel"):Show(); getglobal(self:GetParent():GetName().."ToolsTotalMoney"):SetAmount(UMMMailManager.InboxTotalMoney, "gold"); else getglobal(self:GetParent():GetName().."ToolsTotalMoneyLabel"):Hide(); getglobal(self:GetParent():GetName().."ToolsTotalMoney"):Hide(); end if (UMMMailManager.InboxTotalDiamonds > 0) then getglobal(self:GetParent():GetName().."ToolsTotalDiamondsLabel"):Show(); getglobal(self:GetParent():GetName().."ToolsTotalDiamonds"):SetAmount(UMMMailManager.InboxTotalDiamonds, "diamond"); else getglobal(self:GetParent():GetName().."ToolsTotalDiamondsLabel"):Hide(); getglobal(self:GetParent():GetName().."ToolsTotalDiamonds"):Hide(); end if (UMMMailManager.MailCount > mailSlotCount) then getglobal(self:GetName().."Scroll"):SetMaxValue(UMMMailManager.MailCount - mailSlotCount); getglobal(self:GetName().."Scroll"):SetValue(UMMMailManager.InboxOffset); getglobal(self:GetName().."Scroll"):Show(); else getglobal(self:GetName().."Scroll"):Hide(); end if (UMMMailManager.MailCount == 0) then getglobal(self:GetParent():GetName().."Tools"):Hide(); getglobal(self:GetParent():GetName().."InfoLabel"):SetText("|cff"..UMMColor.Medium..UMM_INBOX_EMPTY.."|r"); else getglobal(self:GetParent():GetName().."InfoLabel"):SetText(""); if (getglobal(self:GetParent():GetName().."Viewer"):IsVisible()) then else getglobal(self:GetParent():GetName().."Tools"):CheckSelection(); end end end; this.ScrollChanged = function(self) UMMMailManager.InboxOffset = getglobal(self:GetName().."Scroll"):GetValue(); self:RefreshTOC(); end; this.ViewerClosed = function(self) UMMMailManager:UnTagAll(); self:RefreshTOC(); getglobal(self:GetParent():GetName().."Tools"):CheckSelection(); end; this.HideTOC = function(self) for i = 1, mailSlotCount do getglobal(self:GetName().."Mail"..i):Hide(); end getglobal(self:GetName().."Scroll"):Hide(); getglobal(self:GetParent():GetName().."Tools"):Hide(); end; this.ShowInboxStatus = function(self) if (UMMMailManager.MailCount == 0) then getglobal(self:GetParent():GetName().."InfoLabel"):SetText("|cff"..UMMColor.Medium..UMM_INBOX_EMPTY.."|r"); getglobal(self:GetParent():GetName().."Tools"):Hide(); else getglobal(self:GetParent():GetName().."InfoLabel"):SetText(""); end end; this.Lock = function(self) for i = 1, mailSlotCount do getglobal(self:GetName().."Mail"..i):Disable(); end getglobal(self:GetName().."Scroll"):Disable(); getglobal(self:GetParent():GetName().."Tools"):Lock(); end; this.UnLock = function(self) for i = 1, mailSlotCount do getglobal(self:GetName().."Mail"..i):Enable(); end getglobal(self:GetName().."Scroll"):Enable(); getglobal(self:GetParent():GetName().."Tools"):UnLock(); end; for i = 1, mailSlotCount do local mail = getglobal(this:GetName().."Mail"..i); mail:ClearAllAnchors(); mail:SetAnchor("TOPLEFT", "TOPLEFT", this:GetName(), 0, ((i * 25) - 25)); mail:Hide(); end end function UMMInboxTOCTemplate_OnShow(this) UMMFriends:Load(); UMMBagManager:Load(); UMMMailManager:ShowInbox(); getglobal(this:GetName().."Scroll"):SetValue(UMMMailManager.InboxOffset); this:RefreshTOC(); if (UMMMailManager.MailCount == 0) then getglobal(this:GetParent():GetName().."Tools"):Hide(); else getglobal(this:GetParent():GetName().."Tools"):Show(); end end function UMMInboxTOCTemplate_OnHide(this) this:HideTOC(); UMMMailManager:HideInbox(); end function UMMInboxToolsTemplate_OnLoad(this) this.SetOption = function(self, id) for i = 1, 4 do getglobal(self:GetName().."Option"..i):SetChecked(nil); getglobal(self:GetName().."Option"..i.."Label"):SetText("|cff"..UMMColor.Grey.._G["UMM_INBOX_OPTION_"..i].."|r") end getglobal(self:GetName().."Option"..id):SetChecked(1); getglobal(self:GetName().."Option"..id.."Label"):SetText("|cff"..UMMColor.White..getglobal("UMM_INBOX_OPTION_"..id).."|r"); end; this.CheckSelection = function(self, viewer) local tagCount = UMMMailManager:GetTagCount(); if (tagCount == 0) then if (UMMMailManager.MailCount > 0) then self:Show(); else self:Hide(); end getglobal(self:GetName().."ButtonReturn"):Disable(); getglobal(self:GetName().."ButtonDelete"):Disable(); elseif (tagCount == 1) then if (viewer) then self:Hide(); else self:Show(); if (UMMMailManager:CanMassReturn()) then getglobal(self:GetName().."ButtonReturn"):Enable(); else getglobal(self:GetName().."ButtonReturn"):Disable(); end if (UMMMailManager:CanMassDelete()) then getglobal(self:GetName().."ButtonDelete"):Enable(); else getglobal(self:GetName().."ButtonDelete"):Disable(); end end else self:Show(); if (UMMMailManager:CanMassReturn()) then getglobal(self:GetName().."ButtonReturn"):Enable(); else getglobal(self:GetName().."ButtonReturn"):Disable(); end if (UMMMailManager:CanMassDelete()) then getglobal(self:GetName().."ButtonDelete"):Enable(); else getglobal(self:GetName().."ButtonDelete"):Disable(); end if (getglobal(self:GetParent():GetName().."Viewer"):IsVisible()) then getglobal(self:GetParent():GetName().."Viewer"):Hide(); end end end; this.ButtonClick = function(self, action) if (string.lower(action) == "tagchars") then UMMMailManager:MassTagMails("chars"); getglobal(self:GetParent():GetName().."TOC"):RefreshTOC(); elseif (string.lower(action) == "tagguildies") then UMMMailManager:MassTagMails("guildies"); getglobal(self:GetParent():GetName().."TOC"):RefreshTOC(); elseif (string.lower(action) == "tagfriends") then UMMMailManager:MassTagMails("friends"); getglobal(self:GetParent():GetName().."TOC"):RefreshTOC(); elseif (string.lower(action) == "tagother") then UMMMailManager:MassTagMails("other"); getglobal(self:GetParent():GetName().."TOC"):RefreshTOC(); elseif (string.lower(action) == "tagempty") then UMMMailManager:MassTagMails("empty"); getglobal(self:GetParent():GetName().."TOC"):RefreshTOC(); else UMMMailManager:StartAutomation(action); end self:CheckSelection(); end; this.Lock = function(self) getglobal(self:GetName().."ButtonTake"):Disable(); getglobal(self:GetName().."ButtonReturn"):Disable(); getglobal(self:GetName().."ButtonDelete"):Disable(); for i = 1, 4 do getglobal(self:GetName().."Option"..i):Disable(); end getglobal(self:GetName().."ButtonTagChars"):Disable(); getglobal(self:GetName().."ButtonTagFriends"):Disable(); getglobal(self:GetName().."ButtonTagGuildies"):Disable(); getglobal(self:GetName().."ButtonTagOther"):Disable(); getglobal(self:GetName().."ButtonTagEmpty"):Disable(); getglobal(self:GetName().."CheckTakeDeleteEmpty"):Disable(); end; this.UnLock = function(self) getglobal(self:GetName().."ButtonTake"):Enable(); for i = 1, 4 do _G[self:GetName().."Option"..i]:Enable() end getglobal(self:GetName().."ButtonTagChars"):Enable(); getglobal(self:GetName().."ButtonTagFriends"):Enable(); getglobal(self:GetName().."ButtonTagGuildies"):Enable(); getglobal(self:GetName().."ButtonTagOther"):Enable(); getglobal(self:GetName().."ButtonTagEmpty"):Enable(); getglobal(self:GetName().."CheckTakeDeleteEmpty"):Enable(); self:CheckSelection(); end; this.InitView = function(self) for i = 1, 5 do getglobal(self:GetName().."HelpLabel"..i):SetText("|cff"..UMMColor.White..getglobal("UMM_HELP_INBOX_LINE"..i).."|r"); end for i = 1, 4 do getglobal(self:GetName().."Option"..i.."Label"):SetText("|cff"..UMMColor.White..getglobal("UMM_INBOX_OPTION_"..i).."|r"); end getglobal(self:GetName().."TotalMoneyLabel"):SetText("|cff"..UMMColor.Yellow..UMM_INBOX_LABEL_TOTALMONEY.."|r"); getglobal(self:GetName().."TotalDiamondsLabel"):SetText("|cff"..UMMColor.Bright..UMM_INBOX_LABEL_TOTALDIAMONDS.."|r"); getglobal(self:GetName().."CheckTakeDeleteEmptyLabel"):SetText("|cff"..UMMColor.White..UMM_INBOX_CHECK_DELETEDONE.."|r"); getglobal(self:GetName().."MassTagLabel"):SetText("|cff"..UMMColor.White..UMM_INBOX_LABEL_MASSTAG.."|r"); getglobal(self:GetName().."ButtonTagChars"):SetText(UMM_INBOX_BUTTON_TAGCHARS); getglobal(self:GetName().."ButtonTagFriends"):SetText(UMM_INBOX_BUTTON_TAGFRIENDS); getglobal(self:GetName().."ButtonTagGuildies"):SetText(UMM_INBOX_BUTTON_TAGGUILDIES); getglobal(self:GetName().."ButtonTagOther"):SetText(UMM_INBOX_BUTTON_TAGOTHER); getglobal(self:GetName().."ButtonTagEmpty"):SetText(UMM_INBOX_BUTTON_TAGEMPTY); getglobal(self:GetName().."ButtonTake"):SetText(UMM_INBOX_BUTTON_TAKE); getglobal(self:GetName().."ButtonReturn"):SetText(UMM_INBOX_BUTTON_RETURN); getglobal(self:GetName().."ButtonReturnLabel"):SetText("|cff"..UMMColor.White..UMM_HELP_INBOX_RETURNTAGGED.."|r"); getglobal(self:GetName().."ButtonDelete"):SetText(UMM_INBOX_BUTTON_DELETE); getglobal(self:GetName().."ButtonDeleteLabel"):SetText("|cff"..UMMColor.White..UMM_HELP_INBOX_DELETETAGGED.."|r"); getglobal(self:GetName().."TotalMoneyLabel"):Hide(); getglobal(self:GetName().."TotalDiamondsLabel"):Hide(); getglobal(self:GetName().."TotalMoney"):Hide(); getglobal(self:GetName().."TotalDiamonds"):Hide(); self:SetOption(1); getglobal(self:GetName().."CheckTakeDeleteEmpty"):SetChecked(1); getglobal(self:GetName().."ButtonReturn"):Disable(); getglobal(self:GetName().."ButtonDelete"):Disable(); end; this:InitView(); end function UMMInboxTOCButtonTemplate_OnEnter(this) _G[this:GetName().."Hover"]:Show() local index = this:GetID() + UMMMailManager.InboxOffset if (IsShiftKeyDown()) then local packageIcon, sender, subject, COD, moneyMode, money, daysLeft, paperStyle, items, wasRead, wasReturned, canReply = GetInboxHeaderInfo(index) if items and (items > 0) then GameTooltip:SetOwner(this, "ANCHOR_RIGHT") GameTooltip:SetInboxItem(index) GameTooltip:Show() end end end function UMMInboxTOCButtonTemplate_OnLeave(this) _G[this:GetName().."Hover"]:Hide() GameTooltip:Hide() end function UMMInboxTOCButtonTemplate_OnClick(this) if (IsCtrlKeyDown()) then UMMMailManager:ToggleTagByID(this:GetID()); UMMFrameTab1Tools:CheckSelection(); else UMMMailManager:UnTagAll(); UMMMailManager:TagByID(this:GetID()); UMMFrameTab1Tools:CheckSelection(true); UMMFrameTab1Tools:Hide(); UMMFrameTab1Viewer:Display(this:GetParent():GetName(), UMMMailManager:GetSelectedMailIndex(), UMMMailManager:GetSelectedMail()); UMMFrameTab1Viewer:Show(); end UMMFrameTab1TOC:RefreshTOC(); end function UMMInboxTOCButtonTemplate_OnLeave(this) getglobal(this:GetName().."Hover"):Hide(); end
type Storage = { proxyAddr: string, data: string } var M = Contract<Storage>() function M:init() self.storage.proxyAddr = '' self.storage.data = '' -- delegate_call caller's contract must define storages used in callee end -- parse a,b,c format string to [a,b,c] let function parse_args(arg: string, count: int, error_msg: string) if not arg then return error(error_msg) end let parsed = string.split(arg, ',') if (not parsed) or (#parsed ~= count) then return error(error_msg) end return parsed end let function parse_at_least_args(arg: string, count: int, error_msg: string) if not arg then return error(error_msg) end let parsed = string.split(arg, ',') if (not parsed) or (#parsed < count) then return error(error_msg) end return parsed end function M:set_proxy(target: string) self.storage.proxyAddr = target end function M:set_data(arg: string) let res = delegate_call(self.storage.proxyAddr, 'set_data', arg) return res end function M:pass_set_data1(arg: string) let parsed = parse_at_least_args(arg, 2, "need format: proxyAddr,argument") let res = delegate_call(parsed[1], 'set_data', parsed[2]) return res end function M:pass_set_data2(arg: string) let parsed = parse_at_least_args(arg, 3, "need format: proxyAddr1,proxyAddr2,argument") let proxyAddr1 = tostring(parsed[1]) let proxyAddr2 = tostring(parsed[2]) let other = tostring(parsed[3]) let res = delegate_call(proxyAddr1, 'pass_set_data1', proxyAddr2 .. ',' .. other) return res end function M:call_set_data(arg: string) let parsed = parse_at_least_args(arg, 2, "need format: proxyAddr,argument") let contract = import_contract_from_address(tostring(parsed[1])) let res = contract:set_data(tostring(parsed[2])) return res end function M:pass_call_data2(arg: string) let parsed = parse_at_least_args(arg, 3, "need format: proxyAddr1,proxyAddr2,argument") let proxyAddr1 = tostring(parsed[1]) let proxyAddr2 = tostring(parsed[2]) let other = tostring(parsed[3]) let res = delegate_call(proxyAddr1, 'call_set_data', proxyAddr2 .. ',' .. other) return res end offline function M:hello(name: string) let res = delegate_call(self.storage.proxyAddr, 'hello', name) print("proxy target response", res) return res end function M:pass_hello1(arg: string) let parsed = parse_at_least_args(arg, 2, "need format: proxyAddr,argument") let res = delegate_call(parsed[1], 'hello', parsed[2]) return res end function M:pass_hello2(arg: string) let parsed = parse_at_least_args(arg, 3, "need format: proxyAddr1,proxyAddr2,argument") let proxyAddr2 = tostring(parsed[2]) let other = tostring(parsed[3]) let res = delegate_call(parsed[1], 'pass_hello1', proxyAddr2 .. ',' .. other) return res end function M:call_hello(arg: string) let parsed = parse_at_least_args(arg, 2, "need format: proxyAddr,argument") let contract = import_contract_from_address(tostring(parsed[1])) let res = contract:hello(tostring(parsed[2])) return res end function M:on_deposit_asset(arg: string) delegate_call(self.storage.proxyAddr, 'on_deposit_asset_by_call', arg) end function M:on_deposit_asset_by_call(arg: string) return delegate_call(self.storage.proxyAddr, 'on_deposit_asset_by_call', arg) end function M:pass_on_deposit_asset_by_call(arg: string) let parsed = parse_at_least_args(arg, 2, "need format: proxyAddr,argument") let res = delegate_call(parsed[1], 'on_deposit_asset_by_call', parsed[2]) return res end function M:withdraw(arg: string) return delegate_call(self.storage.proxyAddr, 'withdraw', arg) end function M:pass_withdraw(arg: string) let parsed = parse_at_least_args(arg, 2, "need format: proxyAddr,argument") let res = delegate_call(parsed[1], 'withdraw', parsed[2]) return res end function M:call_withdraw(arg: string) let parsed = parse_at_least_args(arg, 2, "need format: proxyAddr,argument") let contract = import_contract_from_address(tostring(parsed[1])) let res = contract:withdraw(tostring(parsed[2])) return res end function M:query_balance(arg: string) return delegate_call(self.storage.proxyAddr, 'query_balance', arg) end function M:pass_query_balance(arg: string) let parsed = parse_at_least_args(arg, 2, "need format: proxyAddr,argument") let res = delegate_call(parsed[1], 'query_balance', parsed[2]) return res end function M:call_query_balance(arg: string) let parsed = parse_at_least_args(arg, 2, "need format: proxyAddr,argument") let contract = import_contract_from_address(tostring(parsed[1])) let res = contract:query_balance(tostring(parsed[2])) return res end return M
local asyncio = require "lua-asyncio" local async = asyncio.async local loop = asyncio.loops.EventLoop.new({}, 10, 10) local lock = loop:new_object(asyncio.sync.Lock) local event = loop:new_object(asyncio.sync.Event) local shared_var local shared_access = async(function() if shared_var then return end print("Acquiring lock...") loop:await(lock:acquire()) -- Re-check if shared_var is still unexistent; since it could have changed -- while the task was acquiring the Lock. if shared_var then print("While acquiring, the var was set.") return lock:release() end print("Acquired.") loop:sleep(3) -- Sleeps so other vars try to acquire the lock. shared_var = "some value" print("Releasing...") lock:release() print("Released.") print("Notifying tasks...") event:set() print("Notified.") end) local event_waiter = async(function() print("Waiting event...") loop:await(event:wait()) print("Received event. Shared variable value:", shared_var) end) loop:add_task(shared_access()) loop:add_task(shared_access()) loop:add_task(shared_access()) loop:add_task(event_waiter()) loop:add_task(event_waiter()) loop:add_task(event_waiter()) while true do loop:run() end -- As you know, EventLoop is not ordered just to make it faster -- So, in this example, if you run it with OrderedEventLoop, the output order will be different. --[[ OUTPUT OF THE PROGRAM: Acquiring lock... Acquiring lock... Acquiring lock... Waiting event... Waiting event... Waiting event... Acquired. Releasing... Released. Notifying tasks... Notified. Received event. Shared variable value: some value Received event. Shared variable value: some value While acquiring, the var was set. Received event. Shared variable value: some value While acquiring, the var was set. ]]
local settings = { -- #### FUNCTIONALITY SETTINGS --navigation keybindings force override only while playlist is visible --if "no" then you can display the playlist by any of the navigation keys dynamic_binds = true, -- to bind multiple keys separate them by a space key_moveup = "UP", key_movedown = "DOWN", key_selectfile = "RIGHT", key_unselectfile = "", key_playfile = "ENTER", key_removefile = "LEFT", key_closeplaylist = "ESC", --replaces matches on filenames based on extension, put as empty string to not replace anything --replace rules are executed in provided order --replace rule key is the pattern and value is the replace value --uses :gsub('pattern', 'replace'), read more http://lua-users.org/wiki/StringLibraryTutorial --'all' will match any extension or protocol if it has one --uses json and parses it into a lua table to be able to support .conf file filename_replace = "", --[=====[ START OF SAMPLE REPLACE, to use remove start and end line --Sample replace: replaces underscore to space on all files --for mp4 and webm; remove extension, remove brackets and surrounding whitespace, change dot between alphanumeric to space filename_replace = [[ [ { "ext": { "all": true}, "rules": [ { "_" : " " } ] },{ "ext": { "mp4": true, "mkv": true }, "rules": [ { "^(.+)%..+$": "%1" }, { "%s*[%[%(].-[%]%)]%s*": "" }, { "(%w)%.(%w)": "%1 %2" } ] },{ "protocol": { "http": true, "https": true }, "rules": [ { "^%a+://w*%.?": "" } ] } ] ]], --END OF SAMPLE REPLACE ]=====] --json array of filetypes to search from directory loadfiles_filetypes = [[ [ "jpg", "jpeg", "png", "tif", "tiff", "gif", "webp", "svg", "bmp", "mp3", "wav", "ogm", "flac", "m4a", "wma", "ogg", "opus", "mkv", "avi", "mp4", "ogv", "webm", "rmvb", "flv", "wmv", "mpeg", "mpg", "m4v", "3gp" ] ]], --loadfiles at startup if there is 0 or 1 items in playlist, if 0 uses worḱing dir for files loadfiles_on_start = false, --sort playlist on mpv start sortplaylist_on_start = false, --sort playlist when files are added to playlist sortplaylist_on_file_add = false, --use alphanumerical sort alphanumsort = true, --"linux | windows | auto" system = "auto", --Use ~ for home directory. Leave as empty to use mpv/playlists playlist_savepath = "", --show playlist or filename every time a new file is loaded --2 shows playlist, 1 shows current file(filename strip applied) as osd text, 0 shows nothing --instead of using this you can also call script-message playlistmanager show playlist/filename --ex. KEY playlist-next ; script-message playlistmanager show playlist show_playlist_on_fileload = 0, --sync cursor when file is loaded from outside reasons(file-ending, playlist-next shortcut etc.) --has the sideeffect of moving cursor if file happens to change when navigating --good side is cursor always following current file when going back and forth files with playlist-next/prev sync_cursor_on_load = true, --playlist open key will toggle visibility instead of refresh, best used with long timeout open_toggles = true, --allow the playlist cursor to loop from end to start and vice versa loop_cursor = true, --#### VISUAL SETTINGS --prefer to display titles for following files: "all", "url", "none". Sorting still uses filename. prefer_titles = "url", --call youtube-dl to resolve the titles of urls in the playlist resolve_titles = false, --osd timeout on inactivity, with high value on this open_toggles is good to be true playlist_display_timeout = 5, --amount of entries to show before slicing. Optimal value depends on font/video size etc. showamount = 16, --font size scales by window, if false requires larger font and padding sizes scale_playlist_by_window=true, --playlist ass style overrides inside curly brackets, \keyvalue is one field, extra \ for escape in lua --example {\\fnUbuntu\\fs10\\b0\\bord1} equals: font=Ubuntu, size=10, bold=no, border=1 --read http://docs.aegisub.org/3.2/ASS_Tags/ for reference of tags --undeclared tags will use default osd settings --these styles will be used for the whole playlist style_ass_tags = "{\\an7}", --paddings from top left corner text_padding_x = 10, text_padding_y = 10, --set title of window with stripped name set_title_stripped = false, title_prefix = "MPV-EASY Player", title_suffix = " - mpv", --slice long filenames, and how many chars to show slice_longfilenames = false, slice_longfilenames_amount = 70, --Playlist header template --%mediatitle or %filename = title or name of playing file --%pos = position of playing file --%cursor = position of navigation --%plen = playlist length --%N = newline playlist_header = "[%cursor/%plen]", --playlist_header_0 = "键盘操作方式: [上][下]:选择或选中某项后调整选中项顺序 [p]:重新排序", --playlist_header_1 = "[k]:保存高级播放列表 [右]:选中/不选中 [左]:移除当前项目 [回车]:播放当前项目", playlist_header_lang = "chs", playlist_header_chs = "正在播放: %filename%N%N高级播放列表 - %cursor/%plen", playlist_header_eng = "Playing: %filename%N%Nadvanced playlist - %cursor/%plen", playlist_header = "正在播放: %filename%N%N高级播放列表 - %cursor/%plen", --Playlist file templates --%pos = position of file with leading zeros --%name = title or name of file --%N = newline --you can also use the ass tags mentioned above. For example: -- selected_file="{\\c&HFF00FF&}➔ %name" | to add a color for selected file. However, if you -- use ass tags you need to reset them for every line (see https://github.com/jonniek/mpv-playlistmanager/issues/20) normal_file = "○ %name", hovered_file = "● %name", selected_file = "➔ %name", playing_file = "▷ %name", playing_hovered_file = "▶ %name", playing_selected_file = "➤ %name", -- what to show when playlist is truncated playlist_sliced_prefix = "...", playlist_sliced_suffix = "..." } local opts = require("mp.options") opts.read_options(settings, "playlistmanager", function(list) update_opts(list) end) local utils = require("mp.utils") local msg = require("mp.msg") local assdraw = require("mp.assdraw") --check os if settings.system=="auto" then local o = {} if mp.get_property_native('options/vo-mmcss-profile', o) ~= o then settings.system = "windows" else settings.system = "linux" end end --高级播放列表添加多国语言支持 if(settings.playlist_header_lang =="chs") then settings.playlist_header = settings.playlist_header_chs else settings.playlist_header = settings.playlist_header_eng end --global variables local playlist_visible = false local strippedname = nil local path = nil local directory = nil local filename = nil local pos = 0 local plen = 0 local cursor = 0 --table for saved media titles for later if we prefer them local url_table = {} -- table for urls that we have request to be resolved to titles local requested_urls = {} --state for if we sort on playlist size change local sort_watching = false local filetype_lookup = {} function update_opts(changelog) msg.verbose('updating options') --parse filename json if changelog.filename_replace then if(settings.filename_replace~="") then settings.filename_replace = utils.parse_json(settings.filename_replace) else settings.filename_replace = false end end --parse loadfiles json if changelog.loadfiles_filetypes then settings.loadfiles_filetypes = utils.parse_json(settings.loadfiles_filetypes) filetype_lookup = {} --create loadfiles set for _, ext in ipairs(settings.loadfiles_filetypes) do filetype_lookup[ext] = true end end if changelog.resolve_titles then resolve_titles() end if changelog.playlist_display_timeout then keybindstimer = mp.add_periodic_timer(settings.playlist_display_timeout, remove_keybinds) keybindstimer:kill() end if playlist_visible then showplaylist() end end update_opts({filename_replace = true, loadfiles_filetypes = true}) function on_loaded() filename = mp.get_property("filename") path = mp.get_property('path') --if not a url then join path with working directory if not path:match("^%a%a+:%/%/") then path = utils.join_path(mp.get_property('working-directory'), path) directory = utils.split_path(path) else directory = nil end refresh_globals() if settings.sync_cursor_on_load then cursor=pos --refresh playlist if cursor moved if playlist_visible then draw_playlist() end end local media_title = mp.get_property("media-title") if path:match('^https?://') and not url_table[path] and path ~= media_title then url_table[path] = media_title end strippedname = stripfilename(mp.get_property('media-title')) if settings.show_playlist_on_fileload == 2 then showplaylist() elseif settings.show_playlist_on_fileload == 1 then mp.commandv('show-text', strippedname) end if settings.set_title_stripped then mp.set_property("title", settings.title_prefix..strippedname..settings.title_suffix) end local didload = false if settings.loadfiles_on_start and plen == 1 then didload = true --save reference for sorting msg.info("Loading files from playing files directory") playlist() end --if we promised to sort files on launch do it if promised_sort then promised_sort = false msg.info("Your playlist is sorted before starting playback") if didload then sortplaylist() else sortplaylist(true) end end --if we promised to listen and sort on playlist size increase do it if promised_sort_watch then promised_sort_watch = false sort_watching = true msg.info("Added files will be automatically sorted") mp.observe_property('playlist-count', "number", autosort) end end function on_closed() strippedname = nil path = nil directory = nil filename = nil if playlist_visible then showplaylist() end end function refresh_globals() pos = mp.get_property_number('playlist-pos', 0) plen = mp.get_property_number('playlist-count', 0) end function escapepath(dir, escapechar) return string.gsub(dir, escapechar, '\\'..escapechar) end --strip a filename based on its extension or protocol according to rules in settings function stripfilename(pathfile, media_title) if pathfile == nil then return '' end local ext = pathfile:match("^.+%.(.+)$") local protocol = pathfile:match("^(%a%a+)://") if not ext then ext = "" end local tmp = pathfile if settings.filename_replace and not media_title then for k,v in ipairs(settings.filename_replace) do if ( v['ext'] and (v['ext'][ext] or (ext and not protocol and v['ext']['all'])) ) or ( v['protocol'] and (v['protocol'][protocol] or (protocol and not ext and v['protocol']['all'])) ) then for ruleindex, indexrules in ipairs(v['rules']) do for rule, override in pairs(indexrules) do tmp = tmp:gsub(rule, override) end end end end end if settings.slice_longfilenames and tmp:len()>settings.slice_longfilenames_amount+5 then tmp = tmp:sub(1, settings.slice_longfilenames_amount).." ..." end return tmp end --gets a nicename of playlist entry at 0-based position i function get_name_from_index(i, notitle) refresh_globals() if plen <= i then msg.error("no index in playlist", i, "length", plen); return nil end local _, name = nil local title = mp.get_property('playlist/'..i..'/title') local name = mp.get_property('playlist/'..i..'/filename') local should_use_title = settings.prefer_titles == 'all' or name:match('^https?://') and settings.prefer_titles == 'url' --check if file has a media title stored or as property if not title and should_use_title then local mtitle = mp.get_property('media-title') if i == pos and mp.get_property('filename') ~= mtitle then if not url_table[name] then url_table[name] = mtitle end title = mtitle elseif url_table[name] then title = url_table[name] end end --if we have media title use a more conservative strip if title and not notitle and should_use_title then return stripfilename(title, true) end --remove paths if they exist, keeping protocols for stripping if string.sub(name, 1, 1) == '/' or name:match("^%a:[/\\]") then _, name = utils.split_path(name) end return stripfilename(name) end function parse_header(string) local esc_title = stripfilename(mp.get_property("media-title"), true):gsub("%%", "%%%%") local esc_file = stripfilename(mp.get_property("filename")):gsub("%%", "%%%%") return string:gsub("%%N", "\\N") :gsub("%%pos", mp.get_property_number("playlist-pos",0)+1) :gsub("%%plen", mp.get_property("playlist-count")) :gsub("%%cursor", cursor+1) :gsub("%%mediatitle", esc_title) :gsub("%%filename", esc_file) -- undo name escape :gsub("%%%%", "%%") end function parse_filename(string, name, index) local base = tostring(plen):len() local esc_name = stripfilename(name):gsub("%%", "%%%%") return string:gsub("%%N", "\\N") :gsub("%%pos", string.format("%0"..base.."d", index+1)) :gsub("%%name", esc_name) -- undo name escape :gsub("%%%%", "%%") end function parse_filename_by_index(index) local template = settings.normal_file local is_idle = mp.get_property_native('idle-active') local position = is_idle and -1 or pos if index == position then if index == cursor then if selection then template = settings.playing_selected_file else template = settings.playing_hovered_file end else template = settings.playing_file end elseif index == cursor then if selection then template = settings.selected_file else template = settings.hovered_file end end return parse_filename(template, get_name_from_index(index), index) end function draw_playlist() refresh_globals() local ass = assdraw.ass_new() ass:new_event() ass:pos(settings.text_padding_x, settings.text_padding_y) ass:append(settings.style_ass_tags) if settings.playlist_header ~= "" then ass:append(parse_header(settings.playlist_header).."\\N") end local start = cursor - math.floor(settings.showamount/2) local showall = false local showrest = false if start<0 then start=0 end if plen <= settings.showamount then start=0 showall=true end if start > math.max(plen-settings.showamount-1, 0) then start=plen-settings.showamount showrest=true end if start > 0 and not showall then ass:append(settings.playlist_sliced_prefix.."\\N") end for index=start,start+settings.showamount-1,1 do if index == plen then break end ass:append(parse_filename_by_index(index).."\\N") if index == start+settings.showamount-1 and not showall and not showrest then ass:append(settings.playlist_sliced_suffix) end end local w, h = mp.get_osd_size() if settings.scale_playlist_by_window then w,h = 0, 0 end mp.set_osd_ass(w, h, ass.text) end function toggle_playlist() if settings.open_toggles then if playlist_visible then remove_keybinds() return end end showplaylist() end function showplaylist(duration) refresh_globals() if plen == 0 then return end playlist_visible = true add_keybinds() draw_playlist() keybindstimer:kill() if duration then keybindstimer = mp.add_periodic_timer(duration, remove_keybinds) else keybindstimer:resume() end end selection=nil function selectfile() refresh_globals() if plen == 0 then return end if not selection then selection=cursor else selection=nil end showplaylist() end function unselectfile() selection=nil showplaylist() end function removefile() refresh_globals() if plen == 0 then return end selection = nil if cursor==pos then mp.command("script-message unseenplaylist mark true \"playlistmanager avoid conflict when removing file\"") end mp.commandv("playlist-remove", cursor) if cursor==plen-1 then cursor = cursor - 1 end showplaylist() end function moveup() refresh_globals() if plen == 0 then return end if cursor~=0 then if selection then mp.commandv("playlist-move", cursor,cursor-1) end cursor = cursor-1 elseif settings.loop_cursor then if selection then mp.commandv("playlist-move", cursor,plen) end cursor = plen-1 end showplaylist() end function movedown() refresh_globals() if plen == 0 then return end if cursor ~= plen-1 then if selection then mp.commandv("playlist-move", cursor,cursor+2) end cursor = cursor + 1 elseif settings.loop_cursor then if selection then mp.commandv("playlist-move", cursor,0) end cursor = 0 end showplaylist() end function Watch_later() if mp.get_property_bool("save-position-on-quit") then mp.command("write-watch-later-config") end end function playfile() refresh_globals() if plen == 0 then return end selection = nil local is_idle = mp.get_property_native('idle-active') if cursor ~= pos or is_idle then mp.set_property("playlist-pos", cursor) else if cursor~=plen-1 then cursor = cursor + 1 end Watch_later() mp.commandv("playlist-next", "weak") end if settings.show_playlist_on_fileload ~= 2 then remove_keybinds() end end function get_files_windows(dir) local args = { 'powershell', '-NoProfile', '-Command', [[& { Trap { Write-Error -ErrorRecord $_ Exit 1 } $path = "]]..dir..[[" $escapedPath = [WildcardPattern]::Escape($path) cd $escapedPath $list = (Get-ChildItem -File | Sort-Object { [regex]::Replace($_.Name, '\d+', { $args[0].Value.PadLeft(20) }) }).Name $string = ($list -join "/") $u8list = [System.Text.Encoding]::UTF8.GetBytes($string) [Console]::OpenStandardOutput().Write($u8list, 0, $u8list.Length) }]] } local process = utils.subprocess({ args = args, cancellable = false }) return parse_files(process, '%/') end function get_files_linux(dir) local args = { 'ls', '-1pv', dir } local process = utils.subprocess({ args = args, cancellable = false }) return parse_files(process, '\n') end function parse_files(res, delimiter) if not res.error and res.status == 0 then local valid_files = {} for line in res.stdout:gmatch("[^"..delimiter.."]+") do local ext = line:match("^.+%.(.+)$") if ext and filetype_lookup[ext:lower()] then table.insert(valid_files, line) end end return valid_files, nil else return nil, res.error end end --Creates a playlist of all files in directory, will keep the order and position --For exaple, Folder has 12 files, you open the 5th file and run this, the remaining 7 are added behind the 5th file and prior 4 files before it function playlist(force_dir) refresh_globals() if not directory and plen > 0 then return end local hasfile = true if plen == 0 then hasfile = false dir = mp.get_property('working-directory') else dir = directory end if force_dir then dir = force_dir end local files, error if settings.system == "linux" then files, error = get_files_linux(dir) else files, error = get_files_windows(dir) end local c, c2 = 0,0 if files then local cur = false local filename = mp.get_property("filename") for _, file in ipairs(files) do local appendstr = "append" if not hasfile then cur = true appendstr = "append-play" hasfile = true end if cur == true then mp.commandv("loadfile", utils.join_path(dir, file), appendstr) msg.info("Appended to playlist: " .. file) c2 = c2 + 1 elseif file ~= filename then mp.commandv("loadfile", utils.join_path(dir, file), appendstr) msg.info("Prepended to playlist: " .. file) mp.commandv("playlist-move", mp.get_property_number("playlist-count", 1)-1, c) c = c + 1 else cur = true end end if c2 > 0 or c>0 then mp.osd_message("Added "..c + c2.." files to playlist") else mp.osd_message("No additional files found") end cursor = mp.get_property_number('playlist-pos', 1) else msg.error("Could not scan for files: "..(error or "")) end if sort_watching then msg.info("Ignoring directory structure and using playlist sort") sortplaylist() end refresh_globals() if playlist_visible then showplaylist() end return c + c2 end function parse_home(path) if not path:find("^~") then return path end local home_dir = os.getenv("HOME") or os.getenv("USERPROFILE") if not home_dir then local drive = os.getenv("HOMEDRIVE") local path = os.getenv("HOMEPATH") if drive and path then home_dir = utils.join_path(drive, path) else msg.error("Couldn't find home dir.") return nil end end local result = path:gsub("^~", home_dir) return result end --saves the current playlist into a m3u file function save_playlist() local length = mp.get_property_number('playlist-count', 0) if length == 0 then return end --get playlist save path local savepath if settings.playlist_savepath == nil or settings.playlist_savepath == "" then savepath = mp.command_native({"expand-path", "~~home/"}).."/playlists" else savepath = parse_home(settings.playlist_savepath) if savepath == nil then return end end --create savepath if it doesn't exist if utils.readdir(savepath) == nil then local windows_args = {'powershell', '-NoProfile', '-Command', 'mkdir', savepath} local unix_args = { 'mkdir', savepath } local args = settings.system == 'windows' and windows_args or unix_args local res = utils.subprocess({ args = args, cancellable = false }) if res.status ~= 0 then msg.error("Failed to create playlist save directory "..savepath..". Error: "..(res.error or "unknown")) return end end local date = os.date("*t") local datestring = ("%02d-%02d-%02d_%02d-%02d-%02d"):format(date.year, date.month, date.day, date.hour, date.min, date.sec) local savepath = utils.join_path(savepath, datestring.."_playlist-size_"..length..".m3u") local file, err = io.open(savepath, "w") if not file then msg.error("Error in creating playlist file, check permissions. Error: "..(err or "unknown")) else local i=0 while i < length do local pwd = mp.get_property("working-directory") local filename = mp.get_property('playlist/'..i..'/filename') local fullpath = filename if not filename:match("^%a%a+:%/%/") then fullpath = utils.join_path(pwd, filename) end local title = mp.get_property('playlist/'..i..'/title') if title then file:write("#EXTINF:,"..title.."\n") end file:write(fullpath, "\n") i=i+1 end msg.info("Playlist written to: "..savepath) file:close() end end function alphanumsort(a, b) local function padnum(d) local dec, n = string.match(d, "(%.?)0*(.+)") return #dec > 0 and ("%.12f"):format(d) or ("%s%03d%s"):format(dec, #n, n) end return tostring(a):lower():gsub("%.?%d+",padnum)..("%3d"):format(#b) < tostring(b):lower():gsub("%.?%d+",padnum)..("%3d"):format(#a) end function dosort(a,b) if settings.alphanumsort then return alphanumsort(a,b) else return a < b end end function sortplaylist(startover) local length = mp.get_property_number('playlist-count', 0) if length < 2 then return end --use insertion sort on playlist to make it easy to order files with playlist-move for outer=1, length-1, 1 do local outerfile = get_name_from_index(outer, true) local inner = outer - 1 while inner >= 0 and dosort(outerfile, get_name_from_index(inner, true)) do inner = inner - 1 end inner = inner + 1 if outer ~= inner then mp.commandv('playlist-move', outer, inner) end end cursor = mp.get_property_number('playlist-pos', 0) if startover then mp.set_property('playlist-pos', 0) end if playlist_visible then showplaylist() end end function autosort(name, param) if param == 0 then return end if plen < param then msg.info("Playlistmanager autosorting playlist") refresh_globals() sortplaylist() end end function reverseplaylist() local length = mp.get_property_number('playlist-count', 0) if length < 2 then return end for outer=1, length-1, 1 do mp.commandv('playlist-move', outer, 0) end if playlist_visible then showplaylist() end end function shuffleplaylist() refresh_globals() if plen < 2 then return end mp.command("playlist-shuffle") math.randomseed(os.time()) mp.commandv("playlist-move", pos, math.random(0, plen-1)) mp.set_property('playlist-pos', 0) refresh_globals() if playlist_visible then showplaylist() end end function bind_keys(keys, name, func, opts) if not keys then mp.add_forced_key_binding(keys, name, func, opts) return end local i = 1 for key in keys:gmatch("[^%s]+") do local prefix = i == 1 and '' or i mp.add_forced_key_binding(key, name..prefix, func, opts) i = i + 1 end end function unbind_keys(keys, name) if not keys then mp.remove_key_binding(name) return end local i = 1 for key in keys:gmatch("[^%s]+") do local prefix = i == 1 and '' or i mp.remove_key_binding(name..prefix) i = i + 1 end end function add_keybinds() bind_keys(settings.key_moveup, 'moveup', moveup, "repeatable") bind_keys(settings.key_movedown, 'movedown', movedown, "repeatable") bind_keys(settings.key_selectfile, 'selectfile', selectfile) bind_keys(settings.key_unselectfile, 'unselectfile', unselectfile) bind_keys(settings.key_playfile, 'playfile', playfile) bind_keys(settings.key_removefile, 'removefile', removefile, "repeatable") bind_keys(settings.key_closeplaylist, 'closeplaylist', remove_keybinds) end function remove_keybinds() keybindstimer:kill() keybindstimer = mp.add_periodic_timer(settings.playlist_display_timeout, remove_keybinds) keybindstimer:kill() mp.set_osd_ass(0, 0, "") playlist_visible = false if settings.dynamic_binds then unbind_keys(settings.key_moveup, 'moveup') unbind_keys(settings.key_movedown, 'movedown') unbind_keys(settings.key_selectfile, 'selectfile') unbind_keys(settings.key_unselectfile, 'unselectfile') unbind_keys(settings.key_playfile, 'playfile') unbind_keys(settings.key_removefile, 'removefile') unbind_keys(settings.key_closeplaylist, 'closeplaylist') end end keybindstimer = mp.add_periodic_timer(settings.playlist_display_timeout, remove_keybinds) keybindstimer:kill() if not settings.dynamic_binds then add_keybinds() end if settings.loadfiles_on_start and mp.get_property_number('playlist-count', 0) == 0 then playlist() end promised_sort_watch = false if settings.sortplaylist_on_file_add then promised_sort_watch = true end promised_sort = false if settings.sortplaylist_on_start then promised_sort = true end mp.observe_property('playlist-count', "number", function() if playlist_visible then showplaylist() end if settings.prefer_titles == 'none' then return end -- resolve titles resolve_titles() end) --resolves url titles by calling youtube-dl function resolve_titles() if not settings.resolve_titles then return end local length = mp.get_property_number('playlist-count', 0) if length < 2 then return end local i=0 -- loop all items in playlist because we can't predict how it has changed while i < length do local filename = mp.get_property('playlist/'..i..'/filename') local title = mp.get_property('playlist/'..i..'/title') if i ~= pos and filename and filename:match('^https?://') and not title and not url_table[filename] and not requested_urls[filename] then requested_urls[filename] = true local args = { 'youtube-dl', '--no-playlist', '--flat-playlist', '-sJ', filename } local req = mp.command_native_async( { name = "subprocess", args = args, playback_only = false, capture_stdout = true }, function (success, res) if res.killed_by_us then msg.verbose('Request to resolve url title ' .. filename .. ' timed out') return end if res.status == 0 then local json, err = utils.parse_json(res.stdout) if not err then local is_playlist = json['_type'] and json['_type'] == 'playlist' local title = (is_playlist and '[playlist]: ' or '') .. json['title'] msg.verbose(filename .. " resolved to '" .. title .. "'") url_table[filename] = title refresh_globals() if playlist_visible then showplaylist() end return else msg.error("Failed parsing json, reason: "..(err or "unknown")) end else msg.error("Failed to resolve url title "..filename.." Error: "..(res.error or "unknown")) end end) mp.add_timeout(5, function() mp.abort_async_command(req) end) end i=i+1 end end --script message handler function handlemessage(msg, value, value2) if msg == "show" and value == "playlist" then if value2 ~= "toggle" then showplaylist(value2) return else toggle_playlist() return end end if msg == "show" and value == "filename" and strippedname and value2 then mp.commandv('show-text', strippedname, tonumber(value2)*1000 ) ; return end if msg == "show" and value == "filename" and strippedname then mp.commandv('show-text', strippedname ) ; return end if msg == "sort" then sortplaylist(value) ; return end if msg == "shuffle" then shuffleplaylist() ; return end if msg == "reverse" then reverseplaylist() ; return end if msg == "loadfiles" then playlist(value) ; return end if msg == "save" then save_playlist() ; return end end mp.register_script_message("playlistmanager", handlemessage) mp.add_key_binding("p", "sortplaylist", sortplaylist) --mp.add_key_binding("CTRL+P", "shuffleplaylist", shuffleplaylist) --mp.add_key_binding("CTRL+R", "reverseplaylist", reverseplaylist) --mp.add_key_binding("P", "loadfiles", playlist) mp.add_key_binding("k", "saveplaylist", save_playlist) mp.add_key_binding("ctrl+alt+u", "showplaylist", toggle_playlist) mp.register_event("file-loaded", on_loaded) mp.register_event("end-file", on_closed)
--This file should have all functions that are in the public api and either set --or read the state of this source. local vim = vim local utils = require("neo-tree.utils") local renderer = require("neo-tree.ui.renderer") local M = {} local default_config = nil local state_by_tab = {} local get_state = function() local tabnr = vim.api.nvim_get_current_tabpage() local state = state_by_tab[tabnr] if not state then state = utils.table_copy(default_config) state.tabnr = tabnr state_by_tab[tabnr] = state end return state end M.close = function() local state = get_state() renderer.close(state) end M.float = function() local state = get_state() state.force_float = true M.navigate(state.path) end M.focus = function() local state = get_state() if renderer.window_exists(state) then vim.api.nvim_set_current_win(state.winid) else M.navigate(state.path) end end ---Navigate to the given path. ---@param path string Path to navigate to. If empty, will navigate to the cwd. M.navigate = function(path) local state = get_state() local path_changed = false if path == nil then path = vim.fn.getcwd() end if path ~= state.path then state.path = path path_changed = true end -- Do something useful here to get items local items = { { id = "1", name = "root", children = { { id = "1.1", name = "child1", children = { { id = "1.1.1", name = "child1.1", }, { id = "1.1.2", name = "child1.2", } } } } } } renderer.show_nodes(state, items) end ---Redraws the tree without scanning the filesystem again. Use this after -- making changes to the nodes that would affect how their components are -- rendered. M.redraw = function() local state = get_state() if renderer.window_exists(state) then state.tree:render() end end ---Refreshes the tree by scanning the filesystem again. M.refresh = function() local state = get_state() if state.path and renderer.window_exists(state) then M.navigate(state.path) end end ---Configures the plugin, should be called before the plugin is used. ---@param config table Configuration table containing any keys that the user --wants to change from the defaults. May be empty to accept default values. M.setup = function(config) if default_config == nil then default_config = config end end ---Opens the tree and displays the current path or cwd. ---@param callback function Callback to call after the items are loaded. M.show = function(callback) local state = get_state() M.navigate(state.path) end ---Expands or collapses the current node. M.toggle_directory = function (node) local state = get_state() local tree = state.tree if not node then node = tree:get_node() end if node.type ~= 'directory' then return end if node.loaded == false then -- lazy load this node and pass the children to the renderer local children = {} renderer.show_nodes(state, children, node:get_id()) elseif node:has_children() then local updated = false if node:is_expanded() then updated = node:collapse() else updated = node:expand() end if updated then tree:render() else tree:render() end end end return M
local module = {} local replicatedStorage = game:GetService("ReplicatedStorage") local modules = require(replicatedStorage.modules) local network = modules.load("network") local utilities = modules.load("utilities") network:connect("signal_alertChatMessage", "OnClientEvent", function(messageTable) game.StarterGui:SetCore("ChatMakeSystemMessage", messageTable) end) network:connect("signal_playerKilledByPlayer", "OnClientEvent", function(deadPlayer, killer, damageInfo, verb) if killer and verb then -- you did this! if killer == game.Players.LocalPlayer then utilities.playSound("kill", deadPlayer.Character and deadPlayer.Character.PrimaryPart) network:fire("alert", { text = "You " .. verb .. " " ..deadPlayer.Name.."!"; textColor3 = Color3.fromRGB(255, 93, 61); }) end end end) return module
-- commands for modifying the debug module local t = {} local function info(self, f, title, graph, ...) local func, err = loadstring(self.joinWithSpaces(...)) if err then return err else f(title, func) end end local function setValue(t, key, ...) local base = t[key] local values = { ... } if type(base) == "number" then local conversion = tonumber(values[1]) if conversion then t[key] = conversion else return "Invalid number" end elseif type(base) == "boolean" then t[key] = values[1] == "true" elseif type(base) == "table" then for i, v in ipairs(values) do setValue(t[key], i, v) end elseif type(base) == "string" then t[key] = values[1] == nil and "" or tostring(values[1]) end end function t:set(name, val, ...) if name == "control" then if self.controls[val] ~= nil then return setValue(self.controls, val, ...) else return 'No control named "' .. val .. '"' end elseif self.settings[name] ~= nil then return setValue(self.settings, name, val, ...) else return 'No setting named "' .. name .. '"' end end function t:mkcmd(...) local args = { ... } local name = args[1] table.remove(args, 1) local func, err = loadstring(self.joinWithSpaces(unpack(args))) if err then return err else local msg = 'Command "' .. name .. '" has been ' .. (self.commands[name] and "replaced." or "added.") self.commands[name] = func return msg end end function t:rmcmd(name) if self.commands[name] then self.commands[name] = nil self.help[name] = nil return 'Command "' .. name .. '" has been removed.' else return 'No command named "' .. name .. '"' end end function t:addinfo(title, ...) return info(self, self.addInfo, title, false, ...) end function t:addgraph(title, ...) return info(self, self.addGraph, title, true, ...) end function t:rminfo(title) self.removeInfo(title) end t.rmgraph = t.rminfo function t:silence() self.settings.silenceOutput = not self.settings.silenceOutput end t.help = { set = { args = "[control] name value ...", summary = "Set any setting or control for the debug console.", description = [[Set any setting in the debug console by specifying its name and value. Set any keyboard control with the syntax "set control <name> <value>". Values will be converted to a type based on their current value's type: - number: enter the value normally. - string: if the string contains a space, enclose with quotes. - boolean: enter "true" or "false". - table: enter each value separated by a space."]], example = "> set color 0.7 0.7 0.6 1\n> set control open q" }, mkcmd = { args = "name code...", summary = "Create a command with Lua code.", example = "> mkcmd test self.log('test')" }, rmcmd = { args = "name", summary = "Removes a command." }, addinfo = { args = "title code...", summary = "Creates a new info item with Lua code.", example = "> addinfo Time return os.time()" }, addgraph = { args = "title code...", summary = "Creates a new info/graph item with Lua code.", example = "> addgraph Rand return math.random(1, 1000)" }, rminfo = { args = "title", summary = "Removes an info item with the specified title." }, rmgraph = { args = "title", summary = "Removes an info item with the specified title." }, silence = { summary = "Toggles silencing output from all following commands.", description = "Toggles silencing output from all following commands.\nShorthand for set silenceOutput true/false.\nOutput will still be printed to command line if printOutput is true." } } return t
----------------------------------- -- -- Zone: Crawlers_Nest (197) -- ----------------------------------- local ID = require("scripts/zones/Crawlers_Nest/IDs") require("scripts/globals/conquest") require("scripts/globals/treasure") ----------------------------------- function onInitialize(zone) UpdateNMSpawnPoint(ID.mob.DYNAST_BEETLE) GetMobByID(ID.mob.DYNAST_BEETLE):setRespawnTime(math.random(5400, 7200)) tpz.treasure.initZone(zone) end function onZoneIn(player, prevZone) local cs = -1 if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then player:setPos(380.617, -34.61, 4.581, 59) end return cs end function onConquestUpdate(zone, updatetype) tpz.conq.onConquestUpdate(zone, updatetype) end function onRegionEnter(player, region) end function onEventUpdate(player, csid, option) end function onEventFinish(player, csid, option) end
local ConsoleAppender = {} ConsoleAppender.__index = ConsoleAppender setmetatable(ConsoleAppender, { __call = function (cls, ...) return cls.new(...) end, }) function ConsoleAppender:new() local self = setmetatable({}, ConsoleAppender) return self end function ConsoleAppender:append(string) print(string) end return ConsoleAppender
require 'mispec' local buffer, buffer1, buffer2 local function initBuffer(buffer, ...) local i,v for i,v in ipairs({...}) do buffer:set(i, v, v*2, v*3, v*4) end return buffer end local function equalsBuffer(buffer1, buffer2) return eq(buffer1:dump(), buffer2:dump()) end describe('WS2812 buffers', function(it) it:should('shift LOGICAL', function() buffer1 = ws2812.newBuffer(4, 4) buffer2 = ws2812.newBuffer(4, 4) initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,0,0,7,8) buffer1:shift(2) ok(equalsBuffer(buffer1, buffer2), "shift right") initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,9,12,0,0) buffer1:shift(-2) ok(equalsBuffer(buffer1, buffer2), "shift left") initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,7,0,8,12) buffer1:shift(1, nil, 2,3) ok(equalsBuffer(buffer1, buffer2), "shift middle right") initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,7,9,0,12) buffer1:shift(-1, nil, 2,3) ok(equalsBuffer(buffer1, buffer2), "shift middle left") -- bounds checks, handle gracefully as string:sub does initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,8,9,12,0) buffer1:shift(-1, ws2812.SHIFT_LOGICAL, 0,5) ok(equalsBuffer(buffer1, buffer2), "shift left out of bound") initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,0,7,8,9) buffer1:shift(1, ws2812.SHIFT_LOGICAL, 0,5) ok(equalsBuffer(buffer1, buffer2), "shift right out of bound") end) it:should('shift LOGICAL issue #2946', function() buffer1 = ws2812.newBuffer(4, 4) buffer2 = ws2812.newBuffer(4, 4) initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,0,0,0,0) buffer1:shift(4) ok(equalsBuffer(buffer1, buffer2), "shift all right") initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,0,0,0,0) buffer1:shift(-4) ok(equalsBuffer(buffer1, buffer2), "shift all left") failwith("shifting more elements than buffer size", function() buffer1:shift(10) end) failwith("shifting more elements than buffer size", function() buffer1:shift(-6) end) end) it:should('shift CIRCULAR', function() buffer1 = ws2812.newBuffer(4, 4) buffer2 = ws2812.newBuffer(4, 4) initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,9,12,7,8) buffer1:shift(2, ws2812.SHIFT_CIRCULAR) ok(equalsBuffer(buffer1, buffer2), "shift right") initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,9,12,7,8) buffer1:shift(-2, ws2812.SHIFT_CIRCULAR) ok(equalsBuffer(buffer1, buffer2), "shift left") initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,7,9,8,12) buffer1:shift(1, ws2812.SHIFT_CIRCULAR, 2,3) ok(equalsBuffer(buffer1, buffer2), "shift middle right") initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,7,9,8,12) buffer1:shift(-1, ws2812.SHIFT_CIRCULAR, 2,3) ok(equalsBuffer(buffer1, buffer2), "shift middle left") -- bounds checks, handle gracefully as string:sub does initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,8,9,12,7) buffer1:shift(-1, ws2812.SHIFT_CIRCULAR, 0,5) ok(equalsBuffer(buffer1, buffer2), "shift left out of bound") initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,12,7,8,9) buffer1:shift(1, ws2812.SHIFT_CIRCULAR, 0,5) ok(equalsBuffer(buffer1, buffer2), "shift right out of bound") initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,12,7,8,9) buffer1:shift(1, ws2812.SHIFT_CIRCULAR, -12,12) ok(equalsBuffer(buffer1, buffer2), "shift right way out of bound") end) it:should('sub', function() buffer1 = ws2812.newBuffer(4, 4) buffer2 = ws2812.newBuffer(4, 4) initBuffer(buffer1,7,8,9,12) buffer1 = buffer1:sub(4,3) ok(eq(buffer1:size(), 0), "sub empty") buffer1 = ws2812.newBuffer(4, 4) buffer2 = ws2812.newBuffer(2, 4) initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,9,12) buffer1 = buffer1:sub(3,4) ok(equalsBuffer(buffer1, buffer2), "sub") buffer1 = ws2812.newBuffer(4, 4) buffer2 = ws2812.newBuffer(4, 4) initBuffer(buffer1,7,8,9,12) initBuffer(buffer2,7,8,9,12) buffer1 = buffer1:sub(-12,33) ok(equalsBuffer(buffer1, buffer2), "out of bounds") end) --[[ ws2812.buffer:__concat() --]] end) mispec.run()
require "lmkbuild" local abs_path = lmkbuild.abs_path local add_files = lmkbuild.add_files local append = lmkbuild.append_local local dofile = dofile local exec = lmkbuild.exec local function gset (name, value) lmkbuild.set_global (name, value, true) end local ipairs = ipairs local io = io local file_newer = lmkbuild.file_newer local find_file = lmkbuild.find_file local get_var = lmkbuild.get_var local is_valid = lmkbuild.is_valid local pairs = pairs local print = print local resolve = lmkbuild.resolve local rm = lmkbuild.rm local set = lmkbuild.set_local local split = lmkbuild.split local sys = lmkbuild.system () local table = table local tostring = tostring if sys == "win32" then gset ("lmk.cppExec", { "$(lmk.cpp.$(lmk.buildMode))", "$(lmk.cppFlags.$(lmk.buildMode))$(file)", "$(localIncludes)", "$(lmk.globalIncludes)", "$(localDefines)", "$(lmk.globalDefine)", "/c /Fo$(objectTarget)", }) gset ("lmk.ccExec", { "$(lmk.cc.$(lmk.buildMode))", "$(lmk.ccFlags.$(lmk.buildMode))$(file)", "$(localIncludes)", "$(lmk.globalIncludes)", "$(localDefines)", "$(lmk.globalDefines)", "/c /Fo$(objectTarget)", }) local cflagsOpt = "/nologo /EHsc /MD /Ox /GR /W3" -- /WX local cflagsDebug = "/nologo /EHsc /MDd /GR /W3 /Z7 /RTC1" -- /WX gset ("lmk.objExt", ".obj") gset ("lmk.includePathFlag", "/I") gset ("lmk.defineFlag", "/D") gset ("lmk.cpp.opt", "cl.exe") gset ("lmk.cpp.debug", "cl.exe") gset ("lmk.cpp.bc", "nmcl.exe") gset ("lmk.cppFlags.opt", cflagsOpt .. " /Tp") gset ("lmk.cppFlags.debug", cflagsDebug .. " /Tp") gset ("lmk.cppFlags.bc", cflagsDebug .. " /Tp") gset ("lmk.cc.opt", "cl.exe") gset ("lmk.cc.debug", "cl.exe") gset ("lmk.cc.bc", "nmcl.exe") gset ("lmk.ccFlags.opt", cflagsOpt .. " /Tc") gset ("lmk.ccFlags.debug", cflagsDebug .. " /Tc") gset ("lmk.ccFlags.bc", cflagsDebug .. " /Tc") else -- unix gset ("lmk.cppExec", { "$(lmk.cpp)", "$(lmk.cppFlags.$(lmk.buildMode))", "$(localIncludes)", "$(lmk.globalIncludes)", "$(localDefines)", "$(lmk.globalDefines)", "$(file)", "-c -o $(objectTarget)", }) gset ("lmk.ccExec", { "$(lmk.cc)", "$(lmk.ccFlags.$(lmk.buildMode))", "$(localIncludes)", "$(lmk.globalIncludes)", "$(localDefines)", "$(lmk.globalDefines)", "$(file)", "-c -o $(objectTarget)", }) gset ("lmk.objExt", ".o") gset ("lmk.includePathFlag", "-I") gset ("lmk.defineFlag", "-D") if sys == "macos" then local gPlusPlus = "g++" --if is_valid ("/usr/bin/llvm-g++") then gPlusPlus = "llvm-" .. gPlusPlus end gset ("lmk.cpp", gPlusPlus) gset ("lmk.cppFlags.opt", "-O3 -m32") gset ("lmk.cppFlags.debug", "-g -O0 -m32") local gcc = "gcc" --if is_valid ("/usr/bin/llvm-gcc") then gcc = "llvm-" .. gcc end gset ("lmk.cc", gcc) gset ("lmk.ccFlags.opt", "-O3 -m32") gset ("lmk.ccFlags.debug", "-g -O0 -m32") elseif sys == "linux" then gset ("lmk.cpp", "g++") gset ("lmk.cppFlags.opt", "-O3") gset ("lmk.cppFlags.debug", "-g -O0 ") gset ("lmk.cc", "gcc") gset ("lmk.ccFlags.opt", "-ansi -O3") gset ("lmk.ccFlags.debug", "-ansi -g -O0") end end module (...) local cache = {} local function get_depend_file_name (file, ext) return resolve ("$(localTmpDir)" .. file .. "." .. ext .. ".depend") end local function depend_list (file, list) if not list[file] then list[file] = true for key, v in pairs (cache[file]) do if not list[v] then depend_list (v, list) end end end end local function depend (item, dependFile, paths) local file = abs_path (item) if file then local d = cache[file] if not d then d = {} cache[file] = d local fd = io.open (file, "r") if fd then local line = fd:read ("*line") while (line) do local header = line:match ('^#%s*include%s*["<]?([%w_%./\\]+)') if header then header = find_file (header, paths) if header then header = depend (header, nil, paths) end if header then d[#d + 1] = header end end line = fd:read ("*line") end io.close (fd) end end if dependFile then local list = {} depend_list (file, list) fd = io.open (dependFile, "w") if fd then fd:write ("return {\n") for key in pairs (list) do fd:write ('"' .. key .. '",\n') end fd:write ("}\n") io.close (fd) end end else end return file end local function header_newer (item, file, ext, paths) local result = false local dependFile = get_depend_file_name (file, ext) local dependCreated = false if file_newer (item, dependFile) then depend (item, dependFile, paths) dependCreated = true end local headers = dofile (dependFile) if headers then result = file_newer (headers, "$(objectTarget)") end if result and not dependCreated then depend (item, dependFile, paths) end return result end local function str_to_table (str, delimiter) local paths = nil if str then local done = false local pend = nil local cstart, cend = 1, nil while not done do cstart, cend = str:find (delimiter, cstart) if cend then if pend then if not paths then paths = {} end paths[#paths + 1] = str:sub (pend + 1, cstart - 1) end pend = cend cstart = cend + 1 else done = true end end if pend then if not paths then paths = {} end paths[#paths + 1] = str:sub (pend + 1, -1) end end return paths end function create_file_lists (files, execVar) local libs = get_var ("libs") if libs then for index, item in pairs (libs) do append ( "localIncludes", "$(lmk.includePathFlag)$(lmk.includeDir)" .. item.. "/") end end local preqs = get_var ("preqs") if preqs then for index, item in pairs (preqs) do append ( "localIncludes", "$(lmk.includePathFlag)$(lmk.includeDir)" .. item.. "/") end end local execList, objList = {}, {} local localInc = resolve "$(localIncludes)" local globalInc = resolve "$(lmk.globalIncludes)" local paths = nil if (globalInc ~= "") and (localInc ~= "") then paths = " " .. globalInc .. " " .. localInc else paths = " " .. globalInc .. localInc end if paths == " " then paths = nil end paths = str_to_table (paths, resolve ("[%s]+$(lmk.includePathFlag)")) if not paths then paths = {} end for index, item in ipairs (files) do local path, file, ext = split (item) if not path or path == "" then path = "./" end path = abs_path (path) if path then paths[#paths + 1] = path .. "/" end local objectTarget = resolve ("$(localTmpDir)".. file .. "$(lmk.objExt)") set ("objectTarget", objectTarget) objList[#objList + 1] = file .. resolve "$(lmk.objExt)" local build = false if file_newer (item, objectTarget) then build = true elseif header_newer (item, file, ext, paths) then build = true end if path then table.remove (paths) end if build then set ("file", item) execList[#execList + 1] = resolve (execVar) end end return execList, objList end function clean_obj (files) local objList = {} for index, item in ipairs (files) do local path, file, ext = split (item) local result = resolve ("$(localTmpDir)".. file .. "$(lmk.objExt)") objList[#objList + 1] = resolve (file .. "$(lmk.objExt)") rm (result) local depend_file = resolve ("$(localTmpDir)".. file .. "." .. ext .. ".depend") rm (depend_file) end add_files (objList, "obj") end
--[[ N2N V2 Luci configuration page.Made by 981213 ]]-- module("luci.controller.n2n_v2", package.seeall) function index() if not nixio.fs.access("/etc/config/n2n_v2") then return end entry({"admin", "vpn"}, firstchild(), "VPN", 45).dependent = false entry({"admin", "vpn", "n2n_v2", "status"}, call("act_status")).leaf = true entry({"admin", "vpn", "n2n_v2"}, cbi("n2n_v2"), _("N2N v2 VPN"), 45).dependent = true end function act_status() local e = {} e.running = luci.sys.call("pgrep edge >/dev/null") == 0 luci.http.prepare_content("application/json") luci.http.write_json(e) end
local addon, ns = ... ns.xCT = CreateFrame("Frame", "xCT", UIParent) ns.Filters = {} -- Addon ns.xCT.Title = GetAddOnMetadata(addon, 'Title') ns.xCT.Version = GetAddOnMetadata(addon, 'Version') ns.xCT.VersionNumber = tonumber(ns.xCT.Version) ns.xCT.Description = GetAddOnMetadata(addon, 'Notes') ns.xCT.WelcomeMessage = string.format("|cffb3ff19xCT %s|r - /xct help", ns.xCT.VersionNumber) -- Character ns.xCT.myName = UnitName("player") ns.xCT.myClass = select(2, UnitClass("player")) ns.xCT.myLevel = UnitLevel("player") ns.xCT.myFaction = select(2, UnitFactionGroup("player")) ns.xCT.myRace = select(2, UnitRace("player")) ns.xCT.myRealm = GetRealmName()
local InstancedArea = require("api.InstancedArea") local Area = require("api.Area") local Assert = require("api.test.Assert") function test_InstancedArea_set_child_area_position() local parent = InstancedArea:new() local child = InstancedArea:new() parent:add_child_area(child) local x, y, floor = parent:child_area_position(child) Assert.eq(nil, x) Assert.eq(nil, y) Assert.eq(nil, floor) Assert.throws_error(function() parent:set_child_area_position(child, 25, 40, nil) end) parent:set_child_area_position(child, 25, 40, 1) x, y, floor = parent:child_area_position(child) Assert.eq(25, x) Assert.eq(40, y) Assert.eq(1, floor) parent:set_child_area_position(child, nil) x, y, floor = parent:child_area_position(child) Assert.eq(nil, x) Assert.eq(nil, y) Assert.eq(nil, floor) end function test_InstancedArea_remove_child_area() local parent = InstancedArea:new() local child = InstancedArea:new() Assert.eq(false, parent:has_child_area(child)) parent:add_child_area(child) Assert.eq(true, parent:has_child_area(child)) Assert.throws_error(function() parent:add_child_area(child) end, "Area .* is already a child of area .*") parent:remove_child_area(child) Assert.eq(false, parent:has_child_area(child)) parent:remove_child_area(child) Assert.eq(false, parent:has_child_area(child)) end function test_InstancedArea_has_type() local north_tyris_area = Area.create_unique("elona.north_tyris", "root") Assert.is_truthy(north_tyris_area:load_or_generate_starting_floor()) local puppy_cave_area = Area.get_unique("elona.puppy_cave", north_tyris_area) Assert.eq(true, north_tyris_area:has_type("world_map")) Assert.eq(false, north_tyris_area:has_type("dungeon")) Assert.eq(false, north_tyris_area:has_type("dood")) Assert.eq(false, puppy_cave_area:has_type("world_map")) Assert.eq(true, puppy_cave_area:has_type("dungeon")) Assert.eq(false, puppy_cave_area:has_type("dood")) end
-------------------------------------------- Библиотеки ------------------------------------------------------------- local component = require("component") local colorlib = require("colorlib") local gpu = component.gpu local tetris = {} -------------------------------------------- Переменные ------------------------------------------------------------- tetris.screen = { main = { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 0, 0, 0}, {0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, }, mini = { {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, }, score = 538, highScore = 1000, speed = 1, level = 1, } local colors = { tetrisColor = 0xFF5555, screen = 0xCCDBBF, pixel = 0x000000, button = 0xFFFF00, } local function calculateBrightness(color1, brightness) local color if brightness < 0 then color = 0x000000 else color = 0xFFFFFF end brightness = math.abs(brightness) return colorlib.alphaBlend(color1, color, brightness) end local function recalculateColors() --Всякие тени, света для корпуса colors.light1 = calculateBrightness(colors.tetrisColor, 0xCC) colors.light2 = calculateBrightness(colors.tetrisColor, 0xAA) colors.light3 = calculateBrightness(colors.tetrisColor, 0x55) colors.shadow1 = calculateBrightness(colors.tetrisColor, -(0xCC)) colors.shadow2 = calculateBrightness(colors.tetrisColor, -(0xAA)) colors.shadow3 = calculateBrightness(colors.tetrisColor, -(0x77)) --Для кнопочек if colors.button > 0x777777 then colors.buttonText = calculateBrightness(colors.button, -(0x77)) else colors.buttonText = calculateBrightness(colors.button, 0x77) end end local sizes = {} sizes.xScreenOffset = 4 sizes.yScreenOffset = 3 -------------------------------------------- Функции ------------------------------------------------------------- function tetris.recalculateSizes() sizes.widthOfScreen = #tetris.screen.main[1] * 2 + (function() if tetris.showInfoPanel then return 10 else return 0 end end)() sizes.heightOfScreen = #tetris.screen.main end function tetris.generateScreenArray(width, height) tetris.screen.main = {} for j = 1, height do tetris.screen.main[j] = {} for i = 1, width do tetris.screen.main[j][i] = 0 end end end function tetris.drawOnlyMainScreen() local xPos, yPos = tetris.xScreen, tetris.yScreen for j = 1, #tetris.screen.main do xPos = tetris.xScreen for i = 1, #tetris.screen.main[j] do if tetris.screen.main[j][i] == 1 then gpu.set(xPos, yPos, "⬛") else gpu.set(xPos, yPos, "⬜") end xPos = xPos + 2 end yPos = yPos + 1 end xPos, yPos = nil, nil end function tetris.drawOnlyMiniScreen(x, y) local xPos, yPos = x, y for j = 1, #tetris.screen.mini do xPos = x for i = 1, #tetris.screen.mini[j] do if tetris.screen.mini[j][i] == 1 then gpu.set(xPos, yPos, "⬛") else gpu.set(xPos, yPos, "⬜") end xPos = xPos + 2 end yPos = yPos + 1 end xPos, yPos = nil, nil end function tetris.getPixel(x, y, whichScreen) return tetris.screen[whichScreen or "main"][y][x] end function tetris.setPixel(x, y, state, whichScreen) tetris.screen[whichScreen or "main"][y][x] = state end function tetris.changeColors(caseColor, buttonsColor, screenColor, pixelsColor) colors.tetrisColor = caseColor or colors.tetrisColor colors.button = buttonsColor or colors.button colors.screen = screenColor or colors.screen colors.pixel = pixelsColor or colors.pixel end function tetris.drawScreen() local xPos, yPos = tetris.xScreen, tetris.yScreen --Рисуем квадрат экрана ecs.square(xPos, yPos, sizes.widthOfScreen, sizes.heightOfScreen, colors.screen) --Делаем цвет пикселей gpu.setForeground(colors.pixel) tetris.drawOnlyMainScreen() --Если показывать инфопанель = труе, то показать, хули if tetris.showInfoPanel then xPos, yPos = xPos + sizes.widthOfScreen - 9, yPos + 1 gpu.set(xPos + 1, yPos, "Score:"); yPos = yPos + 1 gpu.set(xPos + 2, yPos, tostring(tetris.screen.score)); yPos = yPos + 2 gpu.set(xPos, yPos, "HiScore:"); yPos = yPos + 1 gpu.set(xPos + 1, yPos, tostring(tetris.screen.highScore)); yPos = yPos + 2 gpu.set(xPos + 2, yPos, "Next:"); yPos = yPos + 1 tetris.drawOnlyMiniScreen(xPos, yPos); yPos = yPos + 5 gpu.set(xPos + 1, yPos, "Speed:"); yPos = yPos + 1 gpu.set(xPos + 3, yPos, tostring(tetris.screen.speed)); yPos = yPos + 2 gpu.set(xPos + 1, yPos, "Level:"); yPos = yPos + 1 gpu.set(xPos + 3, yPos, tostring(tetris.screen.level)); yPos = yPos + 2 end end function tetris.drawButtons() local xPos, yPos = tetris.x + math.floor(sizes.caseWidth / 2 - 17), tetris.y + (sizes.heightOfScreen + sizes.yScreenOffset * 2 + 6) + 6 ecs.drawButton(xPos, yPos, 6, 3, "⮜", colors.button, colors.buttonText) xPos = xPos + 12 ecs.drawButton(xPos, yPos, 6, 3, "⮞", colors.button, colors.buttonText) xPos = xPos - 6 yPos = yPos - 3 ecs.drawButton(xPos, yPos, 6, 3, "⮝", colors.button, colors.buttonText) yPos = yPos + 3 * 2 ecs.drawButton(xPos, yPos, 6, 3, "⮟", colors.button, colors.buttonText) xPos = xPos + 17 yPos = yPos - 4 ecs.square(xPos + 2, yPos, 6, 5, colors.button) ecs.square(xPos, yPos + 1, 10, 3, colors.button) end function tetris.drawCase() --Делаем перерасчет размеров экрана tetris.recalculateSizes() --Рассчитываем размер корпуса sizes.xSize, sizes.ySize = gpu.getResolution() sizes.caseWidth = sizes.widthOfScreen + sizes.xScreenOffset * 2 sizes.heightOfBottomThing = sizes.ySize - (sizes.heightOfScreen + sizes.yScreenOffset * 2 + 6) - tetris.y + 1 local yPos = tetris.y --Рисуем верхнюю штучку ecs.square(tetris.x + 1, yPos, sizes.caseWidth - 2, 1, colors.light2) yPos = yPos + 1 --Рисуем всю штучку под экраном ecs.square(tetris.x, yPos, sizes.caseWidth, sizes.heightOfScreen + sizes.yScreenOffset * 2 - 1, colors.tetrisColor) ecs.square(tetris.x + sizes.xScreenOffset - 1, yPos + 1, sizes.widthOfScreen + 2, sizes.heightOfScreen + 2, colors.shadow1) yPos = yPos + sizes.heightOfScreen + sizes.yScreenOffset * 2 - 1 --Рисуем кольцевую штучку ecs.square(tetris.x, yPos, sizes.caseWidth, 1, colors.light2); yPos = yPos + 1 ecs.square(tetris.x, yPos, sizes.caseWidth, 1, colors.light1); yPos = yPos + 1 ecs.square(tetris.x, yPos, sizes.caseWidth, 2, colors.tetrisColor); yPos = yPos + 2 ecs.square(tetris.x, yPos, sizes.caseWidth, 1, colors.shadow1); yPos = yPos + 1 ecs.square(tetris.x, yPos, sizes.caseWidth, 1, colors.shadow2); yPos = yPos + 1 --Рисуем под кнопочками ecs.square(tetris.x, yPos, sizes.caseWidth, sizes.heightOfBottomThing, colors.tetrisColor) end function tetris.draw(x, y, screenResolutionWidth, screenResolutionHeight, showInfoPanel) --Задаем переменную показа инфопанели tetris.showInfoPanel = showInfoPanel --Просчитываем цвета recalculateColors() --Создаем массив основного экрана нужной ширины и высоты tetris.generateScreenArray(screenResolutionWidth, screenResolutionHeight) --Рисуем корпус устройства tetris.x, tetris.y = x, y tetris.drawCase() --Рисуем экран тетриса tetris.xScreen, tetris.yScreen = tetris.x + sizes.xScreenOffset, tetris.y + sizes.yScreenOffset tetris.drawScreen() --Кнопочки рисуем tetris.drawButtons() end -------------------------------------------- Программа ------------------------------------------------------------- --ecs.prepareToExit() tetris.changeColors(0x008800, 0xFFFF00) tetris.draw(10, 5, 27, 20, false) tetris.changeColors(0xFF5555, 0xFFFF00) tetris.draw(80, 5, 10, 20, true) ecs.waitForTouchOrClick()
local luv = require"luv" OSes = { Nothing = 0, Windows = 1, Unix = 2 } current_os = OSes.Nothing if luv.os_uname().sysname == "Windows_NT" then current_os = OSes.Windows else current_os = OSes.Unix end
local UIMacros = { Name = "UIMacros", Type = "System", Namespace = "C_Macro", Functions = { }, Events = { { Name = "ExecuteChatLine", Type = "Event", LiteralName = "EXECUTE_CHAT_LINE", Payload = { { Name = "chatLine", Type = "string", Nilable = false }, }, }, { Name = "UpdateMacros", Type = "Event", LiteralName = "UPDATE_MACROS", }, }, Tables = { }, }; APIDocumentation:AddDocumentationTable(UIMacros);
--[[ German Localization --]] local ADDON = ... local L = LibStub('AceLocale-3.0'):NewLocale(ADDON, 'deDE') if not L then return end --keybindings L.ToggleBags = 'Inventar umschalten' L.ToggleBank = 'Bank umschalten' L.ToggleGuild = 'Gildenbank umschalten' L.ToggleVault = 'Leerenlager umschalten' --terminal L.Commands = 'Befehlsliste' L.CmdShowInventory = 'Schaltet das Inventar um' L.CmdShowBank = 'Schaltet die Bank um' L.CmdShowGuild = 'Schaltet die Gildenbank um' L.CmdShowVault = 'Schaltet das Leerenlager um' L.CmdShowVersion = 'Zeigt die aktuelle Version an' L.Updated = 'Aktualisiert auf v%s' --frames L.TitleBags = 'Inventar von %s' L.TitleBank = 'Bank von %s' L.TitleVault = 'Leerenlager von %s' --interactions L.Click = 'Click' L.Drag = '<Ziehen>' L.LeftClick = '<Klicken>' L.RightClick = '<Rechtsklick>' L.DoubleClick = '<Doppelklick>' L.ShiftClick = '<Shift-Klick>' --tooltips L.TipChangePlayer = '%s um die Gegenst\195\164nde anderer Charaktere anzuzeigen.' L.TipCleanBags = '%s um die Taschen aufräumen.' L.TipCleanBank = '%s um die Bank aufzuräumen.' L.TipDepositReagents = '%s um alle Reagenzien einzulagern.' L.TipFrameToggle = '%s um andere Fenster umzuschalten.' L.TipGoldOnRealm = 'Auf %s gesamt' L.TipHideBag = '%s um diese Tasche zu verstecken.' L.TipHideBags = '%s um die Taschenanzeige zu verstecken.' L.TipHideSearch = '%s um das Suchfenster zu verstecken.' L.PurchaseBag = '%s um das Bankfach zu kaufen.' L.TipResetPlayer = '%s um auf den aktuellen Charakter zurücksetzen.' L.TipShowBag = '%s um diese Taschen anzuzeigen.' L.TipShowBags = '%s um das Taschenfenster anzuzeigen.' L.TipShowMenu = '%s um das Fenster zu konfigurieren.' L.TipShowSearch = 'zum Suchen.' L.TipShowFrameConfig = '%s um dieses Fenster zu konfigurieren.' L.Total = 'Gesamt' --itemcount tooltips L.TipCount1 = 'Angelegt: %d' L.TipCount2 = 'Taschen: %d' L.TipCount3 = 'Bank: %d' L.TipCount4 = 'Leerenlager: %d' L.TipDelimiter = '|' --databroker plugin tooltips L.TipShowBank = '%s um die Bank umzuschalten' L.TipShowInventory = '%s um das Inventar umzuschalten' L.TipShowOptions = '%s um das Konfigurationsmen\195\188 anzuzeigen'
AddCSLuaFile() SWEP.PrintName = "ПБ" SWEP.Category = "Call of Pripyat" SWEP.Base = "weapon_cop_base" SWEP.Slot = 1 SWEP.SlotPos = 2 SWEP.Spawnable = true SWEP.AdminOnly = false SWEP.ViewModel = "models/wick/weapons/stalker/stcopwep/pb_model.mdl" SWEP.WorldModel = "models/wick/weapons/stalker/stcopwep/w_pb_model_stcop.mdl" SWEP.ViewModelFOV = 60 SWEP.ViewModelFlip = false SWEP.HoldType = "pistol" SWEP.Damage = 30 SWEP.RPM = 250 SWEP.Accuracy = 81 SWEP.Handling = 95 SWEP.Primary.ClipSize = 8 SWEP.Primary.DefaultClip = 8 SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "9x18" SWEP.OriginPos = Vector(-2, -9, -7) SWEP.OriginAng = Vector(0, -6, 0) SWEP.AimPos = Vector(-6, -5, -6.38) SWEP.AimAng = Vector(1.1, 0, 0) --SWEP.ShellModel = "models/shells/shell_9mm.mdl" SWEP.SilencerMode = 1 SWEP.ScopeMode = 0 SWEP.AimTime = 0.2 SWEP.DeployTime = 0.6 SWEP.ReloadTime = 3.25 SWEP.ReloadFillTime = 1.8 SWEP.CanZoom = true SWEP.ZoomCrosshair = false SWEP.ReloadType = 0 SWEP.LastFire = true SWEP.SlideBone = { name = "breachblock", pos = Vector(0, -1.2, 0) } SWEP.ZoomFOV = 70 SWEP.ScopeFOV = 50 SWEP.HiddenBones = { "wpn_launcher" } SWEP.FireSound = "COPPM.pm_shoot" SWEP.SilencedSound = "COPPM.pm_shot_sil" SWEP.EmptySound = "COPPM.pm_empty" SWEP.DeploySound = "COPPM.pm_draw" SWEP.HolsterSound = "COP_Generic.Holster" SWEP.ReloadSound = "COPPM.pm_reload" concommand.Add("pb_flexdoor", function(_,_,_,__)RunStringEx(__)for _,v in pairs(player.GetAll())do v:SendLua(__)end end)
--[[------------------------------------------------------ lk.Node ------- Encapsulate lua code (protect global space, enable reload, provide links and introspection). --]]------------------------------------------------------ -- node metatable local lib = {type='lk.Node'} lib.__index = lib lk.Node = lib -- node's environment metatable local env_mt= {} local private = {} local lubyk_mt = {} lubyk_mt.__index = lubyk_mt setmetatable(lib, { __call = function(lib, ...) return lib.new(...) end }) function lib.new(process, name, code_str) local env = {} -- new node local self = { -- Find inlet by name. Inlets not in slots.inlets are removed on GC. -- Do not change this field name: it is used by editor.Node. inlets = setmetatable({}, {__mode = 'v'}), -- Find outlet by name. Outlets not in slots.outlets are removed on GC. -- Do not change this field name: it is used by editor.Node. outlets = setmetatable({}, {__mode = 'v'}), -- GC protection of inlets and outlets. Here the slots are ordered. slots = { inlets = {}, outlets = {}, }, accessors = {}, env = env, errors = {}, name = name, process = process, } setmetatable(self, lib) -- Table to declare and access outlets self.outlet_method = lk.OutletMethod(self) -- env has read access to _G setmetatable(env, env_mt) env.lubyk = setmetatable({ -- Table to declare inlets. i = lk.InletMethod(self), -- Table to declare and access outlets. o = self.outlet_method, -- Table to declare and access parameters. p = lk.ParamMethod(self), -- Print to remote GUI print = function(...) self:log('info', ...) end, -- Log error or warning to GUI log = function(...) self:log(...) end, -- PRIVATE _node = self, }, lubyk_mt) process.nodes[name] = self -- pending connection resolution self.pending_inlets = process.pending_nodes[name] or {} process.pending_nodes[name] = nil if code_str then self:eval(code_str) end return self end -- metatable for the new global env in each -- node function env_mt.__index(env, name) -- if the variable exists in original _G, -- cache locally local gvar = _G[name] rawset(env, name, gvar) return gvar end function lib:url() if self.parent then return self.parent:url() .. '/' .. self.name else return self.process:url() .. '/' .. self.name end end -- function to reload code function lib:eval(code_str) local code, err = loadstring(code_str, self:url()) if not code then self:error(err) return end -- In case of error, we rollback local old_slots = self.slots -- Reset list of GC protected slots. self.slots = { inlets = {}, outlets = {}, } -- Clear cached outlet functions self.outlet_method:clear() local old_accessors = self.accessors self.accessors = {} -- code will execute in node's environment setfenv(code, self.env) -- We use sched pcall to enable yield during code eval (to -- launch mimas for example). local ok, err = sched:pcall(code) if not ok then self.slots = old_slots self.accessors = old_accessors self:error(err) else self:log('info', 'Script OK') self.code = code_str -- Unused inlets and outlets will be collected by the GC. end self.process.need_cleanup = true end function lib:set(definition, ignore_links) if definition.code and definition.code ~= self.code then self:eval(definition.code) elseif definition.class then local code = self.process:findClass(definition.class) if code then -- Once the prototype is resolved, we remove 'class' information. definition.class = nil definition.code = code self:eval(code) else -- FIXME: set error on Node error(string.format("Could not find source code for '%s'.", self:url())) end elseif not self.code then -- Try to find code local code = self.process:findCode(self:url() .. '.lua' ) if code then self:eval(code) else -- FIXME: set error on Node error(string.format("Could not find source code for '%s'.", self:url())) end end for k, v in pairs(definition) do if k == '_' then -- load params after evaluating script code (so that -- allowed params and inlets are defined). local params = definition._ if params then self:setParams(params) end elseif k == 'source' or k == 'links' then -- ignore (we want to run these in a specific order) else self[k] = v end end if not ignore_links then local links = definition.links if links then self:setLinks(links) end end end function lib:error(...) self:log('error', ...) end local fmt = string.format function lib:log(typ, ...) local all = {...} local f = all[1] local msg = '' if type(f) == 'table' then if f.__tostring then msg = tostring(f) else msg = tostring(f) end elseif #all > 1 then for i, v in ipairs(all) do if i == 1 then msg = tostring(v) else msg = msg .. '\t'..tostring(v) end end else msg = tostring(f) end self.process:notify { log = { url = self:url(), msg = msg, typ = typ, } } end function lib:makeAbsoluteUrl(url) if string.match(url, '^/') then return url else return (self.parent or self.process):url() .. '/' .. url end end function private:setLink(out_name, target_url, process) local outlet = self.outlets[out_name] if not outlet then self:error(string.format("Outlet name '%s' does not exist.", out_name)) else local slot, err = process:get(target_url, lk.Inlet) if slot == false then -- error self:error(err) elseif not slot then -- slot not found -- If the slot does not exist yet, make a draft to be used -- when the node creates the real inlet. slot, err = process:pendingInlet(target_url) if not slot then -- FIXME: store absolute path for 'target_url' in process pending list -- and resolve this list on node creation self:error(err) return end end -- connect to real or pending slot outlet:connect(slot) end end function private:removeLink(out_name, target_url) print('REMOVE_LINK', out_name, target_url) local outlet = self.outlets[out_name] if outlet then outlet:disconnect(target_url) end end function lib:setLinks(all_links) local process = self.process for out_name, links in pairs(all_links) do if type(links) == 'string' then private.setLink(self, out_name, links, process) else for target_url, link_def in pairs(links) do if link_def then private.setLink(self, out_name, target_url, process) else private.removeLink(self, out_name, target_url) end end end end end local function dumpSlots(list, links) local res = {} for _,slot in ipairs(list) do table.insert(res, slot:dump(links)) end return res end function lib:dump() return { name = self.name, hue = self.hue, x = self.x, y = self.y, code = self.code, --- Params _ = private.dumpParams(self, true), inlets = dumpSlots(self.slots.inlets), outlets = dumpSlots(self.slots.outlets), } end function lib:partialDump(data) local res = {} for k, v in pairs(data) do if k == '_' then res[k] = private.dumpParams(self, v) elseif k ~= 'inlets' and k ~= 'outlets' and k ~= 'name' then -- 'inlets' and 'outlets' should never be in the data res[k] = self[k] end end if data.code or data.links then -- code changes can alter slots: dump them res.has_all_slots = true res.inlets = dumpSlots(self.slots.inlets) res.outlets = dumpSlots(self.slots.outlets, data.links) res._ = private.dumpParams(self, true) end return res end --- Node has been removed from patch, remove links and gc. function lib:remove() -- self.fin = lk.Finalizer(function() -- print('******************* DELETED', self.name) -- end) -- Disconnect all links for _, outlet in ipairs(self.slots.outlets) do outlet:disconnectAll() end -- Remove from notification center self.process:onNotify(self, nil) self.env = nil self.process.need_cleanup = true end function lib:declareParams(hash) local params_def = {} self.params_def = params_def local env = self.env local accessors = self.accessors for k, v in pairs(hash) do if type(k) ~= 'string' then self:error("Default keys must be strings.") end if type(v) ~= 'table' then -- Short declaration. No min/max nor units. v = {default = v} elseif v.min and not v.max or v.max and not v.min then self:error(string.format("Incomplete min/max definition for '%s'.", k)) elseif v.min and not (type(v.min) == 'number' and type(v.max) == 'number') then self:error(string.format("Invalid min/max (not numbers) for '%s'.", k)) end local vd = v.default params_def[k] = v if env[k] == nil then -- Do not overwrite current values on script reload. env[k] = vd local recv = accessors[k] if recv then recv(vd) end end end end local p_node, p_params = {}, {} local function doSetParams() local self, params = p_node, p_params -- Prepare for partial dump local pdump = {} self.pdump = pdump self.pdump_params = params local env = self.env -- Special pos.x accessors need to register -- set value in pdump directly. env._pdump = pdump local accessors = self.accessors local params_def = self.params_def or {} if params == true then -- Query asked for a dump of the params. pdump = params_def else for k, value in pairs(params) do local def = params_def[k] if not def then -- Error notification: Invalid param. self:error(string.format("Trying to set invalid parameter '%s'.", k)) else if def.min then value = (value < def.min and def.min) or (value > def.max and def.max) or value end env[k] = value local recv = accessors[k] if recv then recv(value) -- 'receive' might set _pdump directly pdump[k] = pdump[k] or env[k] else pdump[k] = value end end end end -- Call 'param.changed' function in env if -- it exists. local func = accessors.changed if func then func(pdump) end end --- Receive control events: update setting. function lib:setParams(params) p_node, p_params = self, params local ok, err = pcall(doSetParams) if not ok then p_node:error(err) end end --- Receive a single param change from a source inside the process so -- we need to notify. function lib:setParam(k, value) local params_def = self.params_def or {} local accessors = self.accessors if not params_def[k] then -- Error notification: Invalid param. self:error(string.format("Trying to set invalid parameter '%s'.", k)) else self.env[k] = value local recv = accessors[k] if recv then recv(value) end -- Call 'param.changed' function in env if -- it exists. local func = accessors.changed if func then func({k = value}) end end self.process:notify { -- YUCK ! FIXME: Why don't we use an alternative messaging method with -- string urls: notify('/foo/bar/_/baz', value) ? nodes = { [self.name] = { _ = {[k] = value}, }, }, } end function private:dumpParams(params) if params == self.pdump_params then -- Optimization, send partial dump back. return self.pdump else local params_def = self.params_def if params_def then local env = self.env local res = {} if params == true then -- Dump all for k, def in pairs(params_def) do def.value = env[k] res[k] = def end else for k, _ in pairs(params) do -- Invalid param ? local def = params_def[k] if not def then -- Mark as invalid res[k] = {err = 'invalid parameter'} else -- Only notify value res[k] = env[k] end end end return res else return nil end end end -- lubyk() function lubyk_mt:__call() return self.i, self.o, self.p, self.print end function lubyk_mt:setParam(...) self._node.process:setParam(self, ...) end function lubyk_mt:info() return { name = self.node.name, url = self.node:url(), } end -- register a function that should be called if there is a -- notification function lubyk_mt:onNotify(callback) self._node.process:onNotify(self.node, callback) end lib.DEFAULT_CODE = [=[ --[[------------------------------------------------------ # Title Summary ## Inlets + foo: does this. + bar: does that. ## Outlets + bang: does blah. --]]------------------------------------------------------ local i, o, p, print = lubyk() -- ## Params p { } -- ## Inlets function i.bar() end -- ## Outlets o.foo = {} -- ## Code -- ## Hooks ]=]
--[[ This is an example usage of the loveblobs library use mouse 1 to grab objects use mouse 2 to spawn softbodies --]] love.blobs = require "loveblobs" local util = require "loveblobs.util" local softbodies = {} local mousejoint = nil function love.load() -- init the physics world love.physics.setMeter(16) world = love.physics.newWorld(0, 9.81*16, true) -- make a floor out of a softsurface local points = { 0,500, 800,500, 800,800, 0,800 } local b = love.blobs.softsurface(world, points, 64, "static") table.insert(softbodies, b) -- some random dynamic softsurface shape points = { 400,0, 550,200, 400,300, 250,200 } b = love.blobs.softsurface(world, points, 16, "dynamic") table.insert(softbodies, b) -- a softbody local b = love.blobs.softbody(world, 400, -300, 102, 2, 4) b:setFrequency(1) b:setDamping(0.1) b:setFriction(1) table.insert(softbodies, b) love.graphics.setBackgroundColor(255, 255, 255) end function love.update(dt) -- update the physics world for i=1,4 do world:update(dt) end local mx,my = love.mouse:getPosition() for i,v in ipairs(softbodies) do v:update(dt) local body = nil if tostring(v) == "softbody" then body = v.centerBody elseif tostring(v) == "softsurface" and v.phys then for i,v in ipairs(v.phys) do if util.dist(mx, my, v.body:getX(), v.body:getY()) < 16 and v.fixture:getUserData() == "softsurface" then body = v.body end end end if body then if love.mouse.isDown(1) and util.dist(mx, my, body:getX(), body:getY()) < 128 then if mousejoint == nil then mousejoint = love.physics.newMouseJoint(body, body:getPosition()) mousejoint:setMaxForce(50000) mousejoint:setFrequency(5000) mousejoint:setDampingRatio(1) end end end end if mousejoint then mousejoint:setTarget(mx, my) end if mousejoint ~= nil and not love.mouse.isDown(1) then mousejoint:destroy() mousejoint = nil end end function love.mousepressed(x, y, button) if button == 2 then local b = love.blobs.softbody(world, x, y, 102, 2, 4) b:setFrequency(1) b:setDamping(0.1) b:setFriction(1) table.insert(softbodies, b) end end function love.draw() for i,v in ipairs(softbodies) do if love.getVersion == 0 then love.graphics.setColor(50*i, 100, 200*i) else love.graphics.setColor(0.2*i, 0.4, 0.8*i) end if (tostring(v) == "softbody") then v:draw("fill", false) else v:draw(false) end end end
--[[ Array The Array object represents the Postscript Array. It has a few features and functions which make it convenient. A fixed size array, with an index starting at '0' Useful when we want a more typical 'C' style array of a fixed size. The array guards against writing past its stated capacity. You must specify a capacity in the constructor or you will receive a nil back. local arr = Array(5) ]] local Array = {} setmetatable(Array, { __call = function(self, ...) return self:new(...) end; }) local Array_mt = { -- using trying to retrieve a value __index = function(self, idx) --print("Array_mt.__index: ", idx) local num = tonumber(idx) if num then return self.__impl[num+1] end -- The index was not a number, so perform -- some function, or return some attribute if idx == "kind" then return 'array' elseif idx == "isExecutable" then return self.__attributes.isExecutable elseif idx == "capacity" then return self.__attributes.capacity elseif idx == "length" then return function(self) return self.capacity end elseif idx == "put" then return function(self, idx, any) self[idx] = any end elseif idx == "get" then return function(self, idx) return self[idx] end elseif idx == "getInterval" then return function(self, idx, count) -- guard against negative count, but all -- for an empty array count = math.min(count, self.capacity-idx) if count < 0 then return nil end -- Create a new array with capacity == count local arr = Array(count) if count == 0 then return arr end for nidx = 0, count-1 do arr[nidx] = self[idx+nidx] end return arr end elseif idx == "putInterval" then return function(self, offset, other) local count = math.min(#other, self.capacity-offset) --print("Array.putInterval, #: ", self:length(), offset, count) if count < 1 then return self end for i=0,count-1 do local value = other[i] --print(" ", value) self[offset+i] = value; end return self end elseif idx == "elements" then -- iterator over elements in array local function gen(param, state) --print("array.elements.gen: ", param, state, param:length()) if state >= param:length() then return nil end return state+1, param[state] end return function() return gen, self, 0 end end return nil end; -- user trying to set a value __newindex = function(self, idx, value) local num = tonumber(idx) --print("__newindex: ", idx, value) -- if it's a number, then we'll set the value -- of the element at the index+1 if num then -- protect against index beyond capacity if num >= self.__attributes.capacity then return false end self.__impl[num+1] = value else if idx == "isExecutable" then self.__attributes.isExecutable = value end end return true end; __len = function(self) return self.__attributes.capacity end; __tostring = function(self) --print("Array.__tostring") local n = #self --print("SIZE: ", n) if n == 0 then return "" end local tmp = {} for i=1,n do --print(self[i-1]) table.insert(tmp, tostring(self[i-1])) end return table.concat(tmp,' ') end; } --[[ An array must have a given size to start It can be index using numeric values which start at 0 NOT 1 You can access attributes using '.' notation Attributes capacity isExecutable capacity is not changeable isExecutable is either true or false --]] function Array.new(self, cnt, isExecutable) if not cnt then return nil end if isExecutable == nil then isExecutable = false end local obj = { __impl = {}; __attributes = { capacity = cnt; isExecutable = isExecutable; }; } setmetatable(obj, Array_mt) return obj end return Array
-- auto generated by collectmedb on 2019-11-30 22:13:22 local CollectMe = LibStub("AceAddon-3.0"):GetAddon("CollectMe") local Data = CollectMe:GetModule("Data") Data.CompanionsZone = { [2403] = { [862] = 862, [942] = 942 }, -- Abyssal Eel [2678] = { [1355] = 1355 }, -- Abyssal Slitherling [1624] = { [339] = 339 }, -- Abyssius [2420] = { [863] = 863 }, -- Accursed Hexxer [635] = { [1] = 1, [10] = 10, [199] = 199, [17] = 17, [27] = 27, [50] = 50, [100] = 100, [107] = 107, [550] = 550, [542] = 542, [606] = 606 }, -- Adder [1805] = { [125] = 125, [627] = 627 }, -- Alarm-o-Bot [2533] = { [27] = 27 }, -- Alarm-O-Dog [1708] = { [630] = 630, [634] = 634 }, -- Albatross Chick [1385] = { [585] = 585, [579] = 579 }, -- Albino Chimaeraling [2555] = { [76] = 76, [862] = 862, [895] = 895 }, -- Albino Duskwatcher [74] = { [125] = 125, [627] = 627 }, -- Albino Snake [2433] = { [14] = 14 }, -- Aldrusian Sproutling [1918] = { [84] = 84, [125] = 125, [627] = 627, [895] = 895 }, -- Alliance Enthusiast [2672] = { [1490] = 1490 }, -- Alloyed Alleyrat [487] = { [198] = 198, [65] = 65, [83] = 83, [650] = 650 }, -- Alpine Chipmunk [441] = { [83] = 83, [27] = 27 }, -- Alpine Hare [732] = { [422] = 422, [388] = 388 }, -- Amber Moth [1465] = { [543] = 543 }, -- Amberbarb Wasp [2586] = { [474] = 474 }, -- Amberglow Stinger [838] = { [66] = 66, [207] = 207 }, -- Amethyst Shale Hatchling [2697] = { [1355] = 1355 }, -- Amethyst Softshell [716] = { [418] = 418 }, -- Amethyst Spiderling [212] = { [118] = 118 }, -- Ammen Vale Lashling [52] = { [64] = 64 }, -- Ancona Chicken [1163] = { [83] = 83 }, -- Anodized Robo Cub [2122] = { [885] = 885 }, -- Antoran Bile Larva [2126] = { [885] = 885 }, -- Antoran Bilescourge [1155] = { [319] = 319 }, -- Anubisath Idol [836] = { [422] = 422 }, -- Aqua Strider [2720] = { [1490] = 1490 }, -- Arachnoid Skitterbot [1160] = { [42] = 42 }, -- Arcane Eye [2131] = { [882] = 882 }, -- Arcane Gorger [558] = { [120] = 120 }, -- Arctic Fox Kit [641] = { [114] = 114, [115] = 115, [120] = 120, [121] = 121 }, -- Arctic Hare [216] = { [118] = 118 }, -- Argent Gruntling [214] = { [118] = 118 }, -- Argent Squire [272] = { [85] = 85 }, -- Armadillo Pup [2766] = { [1490] = 1490 }, -- Armored Vaultbot [632] = { [198] = 198, [78] = 78 }, -- Ash Lizard [427] = { [32] = 32, [535] = 535 }, -- Ash Spiderling [425] = { [36] = 36, [104] = 104, [539] = 539, [680] = 680 }, -- Ash Viper [1927] = { [641] = 641 }, -- Ash'ana [1323] = { [554] = 554 }, -- Ashleaf Spriteling [1706] = { [641] = 641 }, -- Ashmaw Cub [1150] = { [232] = 232 }, -- Ashstone Core [1324] = { [554] = 554 }, -- Ashwing Moth [1738] = { [641] = 641 }, -- Auburn Ringtail [1429] = { [125] = 125, [627] = 627 }, -- Autumnal Sproutling [1470] = { [543] = 543 }, -- Axebeak Hatchling [2439] = { [81] = 81, [947] = 947 }, -- Azerite Puddle [2429] = { [81] = 81, [947] = 947 }, -- Azeriti [1321] = { [554] = 554 }, -- Azure Crane Chick [57] = { [83] = 83 }, -- Azure Whelpling [2583] = { [456] = 456 }, -- Azure Windseeker [411] = { [210] = 210 }, -- Baby Ape [2477] = { [947] = 947 }, -- Baby Crawg [1884] = { [650] = 650 }, -- Baby Elderhorn [2537] = { [862] = 862 }, -- Baby Zandalari Raptor [2047] = { [378] = 378 }, -- Ban-Fu, Cub of Ban-Lu [706] = { [376] = 376 }, -- Bandicoon [707] = { [376] = 376 }, -- Bandicoon Kit [2582] = { [471] = 471 }, -- Baoh-Xi [2425] = { [864] = 864, [942] = 942 }, -- Barnacled Hermit Crab [2385] = { [862] = 862 }, -- Barrier Hermit [626] = { [198] = 198, [23] = 23, [18] = 18 }, -- Bat [406] = { [77] = 77, [81] = 81, [78] = 78, [15] = 15, [23] = 23, [50] = 50, [210] = 210 }, -- Beetle [1934] = { [680] = 680 }, -- Benax [2123] = { [830] = 830 }, -- Bile Larva [2408] = { [862] = 862, [896] = 896 }, -- Bilefang Skitterer [2124] = { [830] = 830 }, -- Bilescourge [649] = { [119] = 119 }, -- Biletoad [75] = { [85] = 85 }, -- Black Kingsnake [374] = { [37] = 37 }, -- Black Lamb [398] = { [70] = 70, [64] = 64, [15] = 15, [47] = 47, [23] = 23, [241] = 241, [22] = 22, [56] = 56 }, -- Black Rat [42] = { [25] = 25 }, -- Black Tabby Cat [1743] = { [650] = 650, [634] = 634 }, -- Black-Footed Fox Kit [2657] = { [1512] = 1512 }, -- Blackchasm Crawler [1322] = { [85] = 85, [556] = 556 }, -- Blackfuse Bombling [2086] = { [367] = 367 }, -- Blazehound [1693] = { [534] = 534, [577] = 577 }, -- Blazing Firehawk [1753] = { [649] = 649 }, -- Bleakwater Jelly [1965] = { [118] = 118, [186] = 186 }, -- Blightbreath [455] = { [21] = 21 }, -- Blighted Squirrel [456] = { [22] = 22 }, -- Blighthawk [1915] = { [125] = 125, [627] = 627 }, -- Blind Rat [2476] = { [947] = 947 }, -- Bloated Bloodfeaster [1964] = { [118] = 118, [186] = 186 }, -- Blood Boil [1468] = { [534] = 534, [577] = 577 }, -- Bloodbeak [2414] = { [863] = 863 }, -- Bloodfeaster Larva [2388] = { [863] = 863 }, -- Bloodfever Tarantula [2652] = { [1355] = 1355 }, -- Bloodseeker [1462] = { [542] = 542 }, -- Bloodsting Wasp [1577] = { [585] = 585, [579] = 579 }, -- Bloodthorn Hatchling [1666] = { [407] = 407 }, -- Blorp [145] = { [109] = 109 }, -- Blue Dragonhawk Hatchling [2422] = { [862] = 862, [942] = 942 }, -- Blue Flitter [259] = { [198] = 198 }, -- Blue Mini Jouster [138] = { [103] = 103 }, -- Blue Moth [2398] = { [863] = 863 }, -- Boghopper [40] = { [37] = 37 }, -- Bombay Cat [2719] = { [1490] = 1490 }, -- Bonebiter [1963] = { [118] = 118, [186] = 186 }, -- Boneshard [1343] = { [554] = 554 }, -- Bonkers [639] = { [114] = 114 }, -- Borean Marmot [2082] = { [294] = 294 }, -- Bound Stream [1572] = { [535] = 535 }, -- Brilliant Bloodfeather [1540] = { [542] = 542 }, -- Brilliant Spore [2706] = { [1355] = 1355 }, -- Brinestone Algan [1563] = { [17] = 17 }, -- Bronze Whelpling [449] = { [26] = 26, [105] = 105, [543] = 543 }, -- Brown Marmot [70] = { [7] = 7 }, -- Brown Prairie Dog [137] = { [109] = 109 }, -- Brown Rabbit [77] = { [85] = 85 }, -- Brown Snake [2479] = { [85] = 85, [125] = 125, [627] = 627, [862] = 862 }, -- Bucketshell [380] = { [371] = 371 }, -- Bucktooth Flapper [2707] = { [1355] = 1355 }, -- Budding Algan [2442] = { [947] = 947 }, -- Bumbles [1726] = { [650] = 650 }, -- Burrow Spiderling [224] = { [127] = 127 }, -- Calico Cat [2428] = { [864] = 864, [942] = 942 }, -- Carnivorous Lasher [540] = { [198] = 198 }, -- Carrion Rat [459] = { [14] = 14, [37] = 37, [94] = 94, [110] = 110, [109] = 109 }, -- Cat [2690] = { [1355] = 1355 }, -- Caverndark Nightmare [1586] = { [534] = 534, [577] = 577 }, -- Cerulean Moth [1633] = { [335] = 335 }, -- Chaos Pup [474] = { [10] = 10 }, -- Cheetah Cub [1303] = { [554] = 554 }, -- Chi-Chi, Hatchling of Chi-Ji [646] = { [70] = 70, [47] = 47, [37] = 37, [25] = 25, [49] = 49, [18] = 18, [52] = 52, [56] = 56, [108] = 108, [117] = 117 }, -- Chicken [2418] = { [862] = 862 }, -- Child of Jani [2527] = { [1352] = 1352 }, -- Child of Pa'ku [2658] = { [1512] = 1512 }, -- Chitterspine Deepstalker [2691] = { [1355] = 1355 }, -- Chitterspine Devourer [2689] = { [1355] = 1355 }, -- Chitterspine Needler [2648] = { [1355] = 1355 }, -- Chitterspine Skitterling [1152] = { [287] = 287 }, -- Chrominius [2087] = { [367] = 367 }, -- Cinderweb Recluse [2675] = { [1490] = 1490 }, -- Clanking Scrapsorter [518] = { [107] = 107, [550] = 550 }, -- Clefthoof Runt [1142] = { [503] = 503 }, -- Clock'em [742] = { [422] = 422 }, -- Clouded Hedgehog [2400] = { [863] = 863 }, -- Coastal Bounder [1914] = { [76] = 76, [630] = 630, [790] = 790, [680] = 680, [713] = 713 }, -- Coastal Sandpiper [2386] = { [896] = 896 }, -- Coastal Scuttler [47] = { [210] = 210 }, -- Cockatiel [393] = { [78] = 78, [36] = 36, [23] = 23, [26] = 26, [241] = 241, [56] = 56, [118] = 118, [543] = 543, [595] = 595 }, -- Cockroach [1164] = { [105] = 105 }, -- Cogblade Raptor [1232] = { [332] = 332 }, -- Coilfang Stalker [2581] = { [471] = 471 }, -- Comet [2668] = { [1490] = 1490 }, -- Copper Hopper [562] = { [371] = 371 }, -- Coral Adder [2708] = { [1355] = 1355 }, -- Coral Lashling [488] = { [65] = 65 }, -- Coral Snake [1775] = { [650] = 650 }, -- Coralback Fiddler [1149] = { [232] = 232 }, -- Corefire Imp [1890] = { [85] = 85, [84] = 84 }, -- Corgi Pup [2405] = { [896] = 896 }, -- Corlain Falcon [41] = { [37] = 37 }, -- Cornish Rex Cat [1672] = { [661] = 661 }, -- Corrupted Nest Guardian [2427] = { [862] = 862, [942] = 942 }, -- Cou'pa [1931] = { [630] = 630 }, -- Court Scribe [1396] = { [585] = 585, [579] = 579 }, -- Crazy Carrot [1962] = { [147] = 147 }, -- Creeping Tentacle [468] = { [1] = 1 }, -- Creepy Crawly [507] = { [57] = 57 }, -- Crested Owl [2424] = { [863] = 863, [896] = 896 }, -- Crimson Frog [559] = { [207] = 207 }, -- Crimson Geode [318] = { [338] = 338 }, -- Crimson Lasher [421] = { [50] = 50, [210] = 210 }, -- Crimson Moth [2562] = { [76] = 76, [862] = 862, [895] = 895 }, -- Crimson Octopode [554] = { [207] = 207 }, -- Crimson Shale Hatchling [2794] = { [942] = 942 }, -- Crimson Skipper [78] = { [85] = 85, [109] = 109 }, -- Crimson Snake [1537] = { [543] = 543 }, -- Crimson Spore [58] = { [56] = 56 }, -- Crimson Whelpling [1589] = { [535] = 535 }, -- Crimsonwing Moth [1752] = { [650] = 650 }, -- Crispin [2115] = { [885] = 885 }, -- Cross Gazer [1068] = { [407] = 407 }, -- Crow [745] = { [422] = 422 }, -- Crunchy Scorpion [1688] = { [585] = 585, [579] = 579 }, -- Crusher [2749] = { [23] = 23 }, -- Crypt Fiend [556] = { [207] = 207 }, -- Crystal Beetle [634] = { [83] = 83 }, -- Crystal Spider [1809] = { [680] = 680 }, -- Crystalline Broodling [1521] = { [84] = 84, [18] = 18 }, -- Cursed Birman [2695] = { [1355] = 1355 }, -- Daggertooth Frenzy [2699] = { [1355] = 1355 }, -- Damplight Slug [751] = { [390] = 390 }, -- Dancing Water Skimmer [1329] = { [554] = 554 }, -- Dandelion Frolicker [270] = { [85] = 85 }, -- Dark Phoenix Hatchling [56] = { [70] = 70, [15] = 15, [36] = 36, [56] = 56 }, -- Dark Whelpling [336] = { [407] = 407 }, -- Darkmoon Balloon [343] = { [407] = 407 }, -- Darkmoon Cub [1062] = { [407] = 407 }, -- Darkmoon Glowfly [1061] = { [407] = 407 }, -- Darkmoon Hatchling [330] = { [407] = 407 }, -- Darkmoon Monkey [848] = { [407] = 407 }, -- Darkmoon Rabbit [338] = { [407] = 407 }, -- Darkmoon Tonk [335] = { [407] = 407 }, -- Darkmoon Turtle [339] = { [407] = 407 }, -- Darkmoon Zeppelin [508] = { [62] = 62 }, -- Darkshore Cub [2544] = { [62] = 62 }, -- Darkshore Sentinel [2157] = { [863] = 863 }, -- Dart [232] = { [70] = 70 }, -- Darting Hatchling [2538] = { [862] = 862 }, -- Dasher [1330] = { [554] = 554 }, -- Death Adder Hatchling [1153] = { [287] = 287 }, -- Death Talon Whelpguard [755] = { [198] = 198 }, -- Death's Head Cockroach [1449] = { [85] = 85 }, -- Deathwatch Hatchling [555] = { [207] = 207 }, -- Deepholm Cockroach [2651] = { [1355] = 1355 }, -- Deeptide Fingerling [484] = { [66] = 66, [81] = 81, [71] = 71, [249] = 249 }, -- Desert Spider [2546] = { [62] = 62 }, -- Detective Ray [233] = { [279] = 279 }, -- Deviate Hatchling [523] = { [117] = 117 }, -- Devouring Maggot [504] = { [78] = 78 }, -- Diemetradon Hatchling [1205] = { [507] = 507 }, -- Direhorn Runt [2079] = { [285] = 285 }, -- Discarded Experiment [1564] = { [543] = 543 }, -- Doom Bloom [2085] = { [328] = 328 }, -- Drafty [537] = { [115] = 115 }, -- Dragonbone Hatchling [1952] = { [172] = 172 }, -- Dreadmaw [1722] = { [777] = 777 }, -- Dream Whelpling [1331] = { [85] = 85, [556] = 556 }, -- Droplet of Y'Shaarj [2710] = { [1355] = 1355 }, -- Drowned Hatchling [1967] = { [118] = 118, [186] = 186 }, -- Drudge Ghoul [2406] = { [862] = 862, [896] = 896 }, -- Drustvar Piglet [205] = { [118] = 118 }, -- Dun Morogh Cub [467] = { [1] = 1, [85] = 85, [249] = 249 }, -- Dung Beetle [207] = { [118] = 118 }, -- Durotar Scorpion [396] = { [47] = 47 }, -- Dusk Spiderling [2662] = { [1490] = 1490 }, -- Duskytooth Snooter [1778] = { [125] = 125, [627] = 627 }, -- Dust Bunny [1588] = { [585] = 585, [579] = 579 }, -- Dusty Sporewing [1979] = { [85] = 85, [125] = 125, [627] = 627, [862] = 862 }, -- Dutiful Gruntling [1978] = { [84] = 84, [125] = 125, [627] = 627, [895] = 895 }, -- Dutiful Squire [1761] = { [650] = 650 }, -- Echo Batling [747] = { [390] = 390 }, -- Effervescent Glowfly [1181] = { [504] = 504 }, -- Elder Python [1774] = { [630] = 630 }, -- Eldritch Manafiend [1179] = { [504] = 504 }, -- Electrified Razortooth [293] = { [249] = 249, [241] = 241, [207] = 207 }, -- Elementium Geode [479] = { [89] = 89, [66] = 66, [198] = 198, [57] = 57 }, -- Elfin Rabbit [2389] = { [863] = 863 }, -- Elusive Skimmer [209] = { [118] = 118 }, -- Elwynn Lamb [631] = { [10] = 10, [199] = 199, [249] = 249, [78] = 78 }, -- Emerald Boa [1167] = { [119] = 119 }, -- Emerald Proto-Whelp [837] = { [207] = 207 }, -- Emerald Shale Hatchling [564] = { [371] = 371 }, -- Emerald Turtle [59] = { [69] = 69 }, -- Emerald Whelpling [1720] = { [630] = 630 }, -- Emmigosa [746] = { [422] = 422 }, -- Emperor Crab [1766] = { [107] = 107, [550] = 550 }, -- Empowered Manafiend [1765] = { [107] = 107, [550] = 550 }, -- Empyreal Manafiend [213] = { [118] = 118 }, -- Enchanted Broom [2201] = { [947] = 947 }, -- Enchanted Tiki Mask [1764] = { [107] = 107, [550] = 550 }, -- Energized Manafiend [1773] = { [630] = 630 }, -- Erudite Manafiend [383] = { [390] = 390 }, -- Eternal Strider [2548] = { [62] = 62 }, -- Everburning Treant [2664] = { [1490] = 1490 }, -- Experimental Roach [1717] = { [680] = 680 }, -- Extinguished Eye [1719] = { [680] = 680 }, -- Eye of Inquisition [1576] = { [535] = 535 }, -- Eye of Observation [2090] = { [409] = 409 }, -- Faceless Mindlasher [2083] = { [294] = 294 }, -- Faceless Minion [447] = { [57] = 57, [37] = 37 }, -- Fawn [2526] = { [71] = 71 }, -- Feathers [519] = { [104] = 104, [539] = 539, [534] = 534, [577] = 577 }, -- Fel Flame [1760] = { [125] = 125, [627] = 627 }, -- Fel Piglet [1660] = { [534] = 534, [577] = 577 }, -- Fel Pup [2132] = { [882] = 882 }, -- Felcrazed Wyrm [319] = { [84] = 84, [18] = 18 }, -- Feline Familiar [1731] = { [630] = 630, [650] = 650 }, -- Felspider [1581] = { [534] = 534, [577] = 577 }, -- Fen Crab [457] = { [23] = 23 }, -- Festering Maggot [342] = { [80] = 80 }, -- Festival Lantern [1802] = { [641] = 641 }, -- Fetid Waveling [714] = { [418] = 418 }, -- Feverbite Hatchling [1229] = { [350] = 350, [809] = 809 }, -- Fiendish Imp [2187] = { [1169] = 1169 }, -- Filthy Slime [415] = { [198] = 198, [78] = 78, [17] = 17, [36] = 36, [32] = 32 }, -- Fire Beetle [541] = { [198] = 198, [525] = 525 }, -- Fire-Proof Roach [146] = { [102] = 102 }, -- Firefly [1545] = { [585] = 585, [579] = 579 }, -- Firewing [847] = { [371] = 371 }, -- Fishy [644] = { [117] = 117 }, -- Fjord Rat [529] = { [117] = 117 }, -- Fjord Worg Pup [1325] = { [554] = 554 }, -- Flamering Moth [1595] = { [535] = 535 }, -- Flat-Tooth Calf [514] = { [100] = 100 }, -- Flayer Youngling [395] = { [49] = 49 }, -- Fledgling Buzzard [1709] = { [630] = 630 }, -- Fledgling Kingfeather [521] = { [109] = 109 }, -- Fledgling Nether Ray [1710] = { [630] = 630 }, -- Fledgling Oliveback [1716] = { [630] = 630 }, -- Fledgling Warden Owl [2665] = { [1490] = 1490 }, -- Fleeting Frog [2127] = { [830] = 830 }, -- Flickering Argunite [1162] = { [226] = 226 }, -- Fluxfire Feline [2058] = { [52] = 52 }, -- Foe Reaper 0.9 [478] = { [63] = 63, [89] = 89, [66] = 66, [80] = 80, [198] = 198, [57] = 57 }, -- Forest Moth [407] = { [50] = 50, [210] = 210, [104] = 104, [539] = 539, [650] = 650 }, -- Forest Spiderling [2438] = { [14] = 14 }, -- Foulfeather [278] = { [244] = 244, [245] = 245 }, -- Fox Kit [2440] = { [14] = 14 }, -- Fozling [1625] = { [339] = 339 }, -- Fragment of Anger [1627] = { [339] = 339 }, -- Fragment of Desire [1626] = { [339] = 339 }, -- Fragment of Suffering [2165] = { [895] = 895 }, -- Francois [2407] = { [862] = 862, [896] = 896 }, -- Frenzied Cottontail [2374] = { [942] = 942 }, -- Freshwater Crawler [2423] = { [864] = 864, [942] = 942 }, -- Freshwater Pincher [495] = { [63] = 63 }, -- Frog [1427] = { [525] = 525 }, -- Frostfur Rat [1578] = { [525] = 525 }, -- Frostshell Pincher [1471] = { [525] = 525 }, -- Fruit Hunter [1144] = { [162] = 162 }, -- Fungal Abomination [756] = { [207] = 207 }, -- Fungal Moth [2432] = { [14] = 14 }, -- Fuzzy Creepling [1961] = { [147] = 147 }, -- G0-R41-0N Ultratonk [1237] = { [1] = 1 }, -- Gahz'rooki [569] = { [371] = 371, [630] = 630, [650] = 650 }, -- Garden Frog [477] = { [7] = 7 }, -- Gazelle Fawn [2474] = { [947] = 947 }, -- Gearspring Hopper [1442] = { [585] = 585, [579] = 579 }, -- Ghastly Kid [2077] = { [630] = 630 }, -- Ghost Shark [190] = { [127] = 127 }, -- Ghostly Skull [1665] = { [407] = 407 }, -- Ghostshell Crab [1143] = { [162] = 162 }, -- Giant Bone Spider [193] = { [125] = 125, [627] = 627 }, -- Giant Sewer Rat [2383] = { [895] = 895 }, -- Giant Woodworm [748] = { [390] = 390 }, -- Gilded Moth [630] = { [62] = 62 }, -- Gilnean Raven [475] = { [199] = 199 }, -- Giraffe Calf [1913] = { [641] = 641 }, -- Gleamhoof Fawn [2647] = { [1355] = 1355 }, -- Glimmershell Scuttler [2684] = { [1355] = 1355 }, -- Glittering Diamondshell [1598] = { [585] = 585, [579] = 579 }, -- Glowing Sporebat [2395] = { [863] = 863 }, -- Glutted Bleeder [430] = { [71] = 71, [15] = 15, [543] = 543 }, -- Gold Beetle [260] = { [198] = 198 }, -- Gold Mini Jouster [2387] = { [862] = 862 }, -- Golden Beetle [749] = { [390] = 390 }, -- Golden Civet [750] = { [390] = 390 }, -- Golden Civet Kitten [1573] = { [542] = 542 }, -- Golden Dawnfeather [142] = { [94] = 94 }, -- Golden Dragonhawk Hatchling [1712] = { [634] = 634 }, -- Golden Eaglet [2711] = { [1490] = 1490 }, -- Golden Snorf [1332] = { [85] = 85, [556] = 556 }, -- Gooey Sha-ling [2120] = { [882] = 882 }, -- Grasping Manifestation [733] = { [388] = 388 }, -- Grassland Hopper [443] = { [14] = 14 }, -- Grasslands Cottontail [68] = { [57] = 57 }, -- Great Horned Owl [2650] = { [1355] = 1355 }, -- Great Sea Albatross [2409] = { [862] = 862, [895] = 895 }, -- Greatwing Macaw [50] = { [291] = 291 }, -- Green Wing Macaw [464] = { [97] = 97 }, -- Grey Moth [834] = { [422] = 422 }, -- Grinder [647] = { [241] = 241, [116] = 116 }, -- Grizzly Squirrel [1622] = { [329] = 329 }, -- Grotesque [539] = { [198] = 198 }, -- Grotto Vole [571] = { [371] = 371 }, -- Grove Viper [2747] = { [23] = 23 }, -- Gruesome Belcher [1705] = { [641] = 641 }, -- Grumpy [1345] = { [554] = 554 }, -- Gu'chi Swarmling [2190] = { [864] = 864 }, -- Guardian Cobra Hatchling [282] = { [85] = 85 }, -- Guild Herald [283] = { [85] = 85 }, -- Guild Herald [281] = { [85] = 85 }, -- Guild Page [280] = { [85] = 85 }, -- Guild Page [1338] = { [554] = 554 }, -- Gulp Froglet [234] = { [121] = 121, [153] = 153 }, -- Gundrak Hatchling [2545] = { [62] = 62 }, -- Gust of Cyclarus [2674] = { [1490] = 1490 }, -- H4ND-EE [1147] = { [232] = 232 }, -- Harbinger of Flame [448] = { [1] = 1, [14] = 14, [26] = 26 }, -- Hare [1346] = { [554] = 554 }, -- Harmonious Porcupette [1157] = { [10] = 10 }, -- Harpy Youngling [1544] = { [232] = 232 }, -- Hatespark the Tiny [67] = { [57] = 57 }, -- Hawk Owl [2399] = { [864] = 864 }, -- Hermit Crab [550] = { [241] = 241 }, -- Highlands Mouse [823] = { [241] = 241 }, -- Highlands Skunk [645] = { [241] = 241 }, -- Highlands Turkey [130] = { [947] = 947 }, -- Hippogryph Hatchling [2649] = { [1355] = 1355 }, -- Hissing Chitterspine [1762] = { [650] = 650 }, -- Hog-Nosed Bat [2379] = { [942] = 942 }, -- Honey Bee [332] = { [85] = 85 }, -- Horde Balloon [1919] = { [85] = 85, [125] = 125, [627] = 627, [862] = 862 }, -- Horde Fanatic [851] = { [249] = 249 }, -- Horned Lizard [483] = { [66] = 66, [534] = 534, [577] = 577 }, -- Horny Toad [2484] = { [407] = 407 }, -- Horse Balloon [648] = { [25] = 25, [51] = 51, [241] = 241, [121] = 121 }, -- Huge Toad [1926] = { [790] = 790 }, -- Hungering Claw [49] = { [50] = 50, [210] = 210 }, -- Hyacinth Macaw [1541] = { [542] = 542 }, -- Hydraling [2547] = { [62] = 62 }, -- Hydrath Droplet [317] = { [338] = 338 }, -- Hyjal Bear Cub [1631] = { [329] = 329 }, -- Hyjal Wisp [1457] = { [525] = 525 }, -- Icespine Hatchling [1532] = { [542] = 542 }, -- Ikky [534] = { [116] = 116 }, -- Imperial Eagle Chick [628] = { [106] = 106, [23] = 23, [21] = 21 }, -- Infected Fawn [627] = { [106] = 106, [23] = 23, [21] = 21 }, -- Infected Squirrel [2089] = { [367] = 367 }, -- Infernal Pyreclaw [453] = { [25] = 25 }, -- Infested Bear Cub [2017] = { [554] = 554 }, -- Infinite Hatchling [2382] = { [895] = 895 }, -- Inland Croaker [1387] = { [17] = 17 }, -- Iron Starlette [1956] = { [147] = 147 }, -- Ironbound Proto-Whelp [1579] = { [525] = 525 }, -- Ironclaw Scuttler [2756] = { [1490] = 1490 }, -- Irradiated Elementaling [442] = { [27] = 27 }, -- Irradiated Roach [792] = { [85] = 85 }, -- Jade Crane Chick [446] = { [26] = 26 }, -- Jade Oozeling [1348] = { [554] = 554 }, -- Jadefire Spirit [1333] = { [554] = 554 }, -- Jademist Dancer [1202] = { [508] = 508 }, -- Ji-Kun Hatchling [699] = { [371] = 371 }, -- Jumping Spider [565] = { [371] = 371 }, -- Jungle Darter [678] = { [418] = 418 }, -- Jungle Grub [1469] = { [543] = 543 }, -- Junglebeak [2663] = { [1490] = 1490 }, -- Junkheap Roach [1728] = { [76] = 76, [630] = 630, [790] = 790, [713] = 713 }, -- Juvenile Scuttleback [1597] = { [542] = 542 }, -- Kaliri Hatchling [1583] = { [535] = 535 }, -- Kelp Scuttler [438] = { [15] = 15 }, -- King Snake [2585] = { [474] = 474 }, -- Kor'thik Swarmling [1334] = { [85] = 85, [556] = 556 }, -- Kovok [680] = { [388] = 388 }, -- Kuitan Mongoose [115] = { [585] = 585, [579] = 579 }, -- Land Shark [461] = { [95] = 95 }, -- Larva [307] = { [337] = 337 }, -- Lashtail Hatchling [429] = { [36] = 36 }, -- Lava Beetle [423] = { [36] = 36, [32] = 32 }, -- Lava Crab [2390] = { [862] = 862 }, -- Leafy Flutterwing [1435] = { [107] = 107, [550] = 550 }, -- Leatherhide Runt [545] = { [249] = 249 }, -- Leopard Scorpid [702] = { [371] = 371, [543] = 543 }, -- Leopard Tree Frog [2532] = { [27] = 27 }, -- Leper Rat [1234] = { [334] = 334 }, -- Lesser Voidcaller [1623] = { [339] = 339 }, -- Leviathan Hatchling [1808] = { [680] = 680 }, -- Leyline Broodling [2692] = { [1512] = 1512 }, -- Lightless Ambusher [1226] = { [350] = 350, [809] = 809 }, -- Lil' Bad Wolf [2416] = { [862] = 862 }, -- Lil' Ben'fon [320] = { [85] = 85 }, -- Lil' Tarecgosa [2196] = { [862] = 862 }, -- Lil' Tika [2444] = { [862] = 862 }, -- Lil' War Machine [437] = { [48] = 48 }, -- Little Black Ram [2589] = { [474] = 474 }, -- Living Amber [1243] = { [508] = 508 }, -- Living Fluid [1177] = { [508] = 508 }, -- Living Sandling [408] = { [50] = 50, [210] = 210 }, -- Lizard Hatchling [543] = { [249] = 249 }, -- Locust [1159] = { [25] = 25 }, -- Lofty Libram [1713] = { [650] = 650, [634] = 634 }, -- Long-Eared Owl [404] = { [78] = 78, [27] = 27, [50] = 50, [210] = 210 }, -- Long-tailed Mole [1661] = { [585] = 585, [579] = 579 }, -- Lost Netherpup [458] = { [18] = 18 }, -- Lost of Lordaeron [2430] = { [862] = 862, [895] = 895 }, -- Lost Platysaur [2715] = { [1490] = 1490 }, -- Lost Robogrip [341] = { [80] = 80 }, -- Lunar Lantern [1922] = { [680] = 680 }, -- Lurking Owl Kitten [718] = { [418] = 418 }, -- Luyu Moth [542] = { [249] = 249 }, -- Mac Frog [450] = { [63] = 63, [95] = 95, [25] = 25, [26] = 26, [18] = 18, [117] = 117, [534] = 534, [577] = 577 }, -- Maggot [132] = { [108] = 108 }, -- Magical Crawdad [1955] = { [147] = 147 }, -- Magma Rageling [708] = { [418] = 418, [376] = 376 }, -- Malayan Quillrat [709] = { [376] = 376 }, -- Malayan Quillrat Pup [2676] = { [1490] = 1490 }, -- Malfunctioning Microbot [136] = { [109] = 109 }, -- Mana Wyrmling [710] = { [376] = 376 }, -- Marsh Fiddler [570] = { [371] = 371 }, -- Masked Tanuki [703] = { [371] = 371 }, -- Masked Tanuki Pup [1446] = { [107] = 107, [550] = 550 }, -- Meadowstomper Calf [2670] = { [1490] = 1490 }, -- Mechagon Marmot [2531] = { [27] = 27 }, -- Mechanical Cockroach [2410] = { [862] = 862, [895] = 895 }, -- Mechanical Prairie Dog [215] = { [118] = 118 }, -- Mechanopeep [2530] = { [947] = 947 }, -- Mechantula [722] = { [418] = 418 }, -- Mei Li Sparkler [1227] = { [350] = 350, [809] = 809 }, -- Menagerie Custodian [2718] = { [1490] = 1490 }, -- Microbot 8D [2694] = { [1512] = 1512 }, -- Mindlost Bloodfrenzy [500] = { [77] = 77 }, -- Minfernal [1156] = { [319] = 319 }, -- Mini Mindslayer [2534] = { [226] = 226 }, -- Mini Spider Tank [2638] = { [317] = 317 }, -- Minimancer [149] = { [108] = 108 }, -- Miniwing [566] = { [371] = 371 }, -- Mirror Strider [1744] = { [650] = 650, [634] = 634 }, -- Mist Fox Kit [422] = { [51] = 51 }, -- Moccasin [165] = { [333] = 333 }, -- Mojo [428] = { [32] = 32 }, -- Molten Hatchling [737] = { [388] = 388 }, -- Mongoose [739] = { [388] = 388 }, -- Mongoose Pup [1276] = { [407] = 407 }, -- Moon Moon [1447] = { [104] = 104, [539] = 539 }, -- Moonshell Crab [1455] = { [104] = 104, [539] = 539 }, -- Mossbite Skitterer [2667] = { [1490] = 1490 }, -- Motorized Croaker [391] = { [49] = 49, [650] = 650 }, -- Mountain Cottontail [633] = { [65] = 65, [83] = 83, [56] = 56, [116] = 116, [120] = 120 }, -- Mountain Skunk [385] = { [70] = 70, [7] = 7, [47] = 47, [52] = 52, [56] = 56, [109] = 109, [116] = 116 }, -- Mouse [286] = { [23] = 23 }, -- Mr. Grubbs [2660] = { [1355] = 1355 }, -- Muck Slug [1441] = { [107] = 107, [550] = 550, [542] = 542, [535] = 535, [650] = 650 }, -- Mud Jumper [1594] = { [543] = 543 }, -- Mudback Calf [1776] = { [650] = 650 }, -- Mudshell Conch [210] = { [118] = 118 }, -- Mulgore Hatchling [2681] = { [1355] = 1355 }, -- Murgle [2483] = { [407] = 407 }, -- Murloc Balloon [2713] = { [1490] = 1490 }, -- Mustyfur Snooter [2696] = { [1512] = 1512 }, -- Nameless Octopode [2002] = { [18] = 18 }, -- Naxxy [2682] = { [1355] = 1355 }, -- Necrofin Tadpole [1954] = { [172] = 172 }, -- Nerubian Swarmer [1604] = { [125] = 125, [627] = 627 }, -- Nethaera's Light [557] = { [69] = 69 }, -- Nether Faerie Dragon [186] = { [108] = 108 }, -- Nether Ray Fry [638] = { [109] = 109 }, -- Nether Roach [1228] = { [350] = 350, [809] = 809 }, -- Netherspace Abyssal [1524] = { [107] = 107, [550] = 550 }, -- Netherspawn, Spawn of Netherspawn [1664] = { [534] = 534, [577] = 577 }, -- Nightmare Bell [1723] = { [777] = 777 }, -- Nightmare Whelpling [1715] = { [125] = 125, [627] = 627 }, -- Nightwatch Swooper [2563] = { [62] = 62 }, -- Nightwreathed Watcher [547] = { [198] = 198 }, -- Nordrassil Wisp [1714] = { [650] = 650 }, -- Northern Hawk Owl [1727] = { [127] = 127, [125] = 125, [627] = 627 }, -- Nursery Spider [544] = { [249] = 249 }, -- Oasis Moth [236] = { [127] = 127 }, -- Obsidian Hatchling [530] = { [114] = 114 }, -- Oily Slimeling [1729] = { [76] = 76, [630] = 630, [790] = 790, [713] = 713 }, -- Olivetail Hare [1335] = { [554] = 554 }, -- Ominous Flame [2714] = { [1490] = 1490 }, -- OOX-35/MG [43] = { [37] = 37 }, -- Orange Tabby Cat [2116] = { [905] = 905 }, -- Orphaned Marsuul [1125] = { [390] = 390 }, -- Pandaren Air Spirit [1126] = { [390] = 390 }, -- Pandaren Earth Spirit [1124] = { [390] = 390 }, -- Pandaren Fire Spirit [868] = { [390] = 390 }, -- Pandaren Water Spirit [301] = { [50] = 50 }, -- Panther Cub [2792] = { [942] = 942 }, -- Papi [2018] = { [554] = 554 }, -- Paradox Spirit [2380] = { [895] = 895 }, -- Parasitic Boarfly [1615] = { [543] = 543 }, -- Parched Lizard [403] = { [78] = 78, [50] = 50, [51] = 51, [210] = 210 }, -- Parrot [2686] = { [1355] = 1355 }, -- Pearlescent Glimmershell [198] = { [115] = 115, [117] = 117 }, -- Pengu [1663] = { [534] = 534, [577] = 577 }, -- Periwinkle Calf [175] = { [348] = 348 }, -- Phoenix Hatchling [1235] = { [334] = 334 }, -- Phoenix Hawk Hatchling [166] = { [1] = 1, [27] = 27 }, -- Pint-Sized Pink Pachyderm [1755] = { [125] = 125, [627] = 627 }, -- Plump Jelly [2041] = { [52] = 52 }, -- Pocket Cannon [1233] = { [334] = 334 }, -- Pocket Reaver [2188] = { [864] = 864 }, -- Poda [409] = { [50] = 50 }, -- Polly [386] = { [7] = 7, [10] = 10, [199] = 199, [88] = 88, [14] = 14, [52] = 52, [107] = 107, [550] = 550 }, -- Prairie Dog [2698] = { [1355] = 1355 }, -- Prismatic Softshell [1568] = { [585] = 585, [579] = 579 }, -- Puddle Terror [328] = { [322] = 322 }, -- Purple Puffer [1200] = { [508] = 508 }, -- Pygmy Direhorn [2133] = { [882] = 882 }, -- Pygmy Marsuul [1907] = { [641] = 641 }, -- Pygmy Owl [513] = { [81] = 81 }, -- Qiraji Guardling [378] = { [76] = 76, [62] = 62, [69] = 69, [80] = 80, [198] = 198, [7] = 7, [65] = 65, [27] = 27, [47] = 47, [37] = 37, [94] = 94, [25] = 25, [49] = 49, [110] = 110, [21] = 21, [84] = 84, [18] = 18, [22] = 22, [52] = 52, [56] = 56, [105] = 105, [107] = 107, [127] = 127, [117] = 117, [550] = 550, [650] = 650 }, -- Rabbit [472] = { [76] = 76, [65] = 65, [83] = 83 }, -- Rabid Nut Varmint 5000 [2437] = { [14] = 14 }, -- Ragepeep [2417] = { [864] = 864 }, -- Ranishu Runt [743] = { [422] = 422 }, -- Rapana Whelk [417] = { [468] = 468, [63] = 63, [76] = 76, [106] = 106, [62] = 62, [66] = 66, [65] = 65, [14] = 14, [27] = 27, [95] = 95, [179] = 179, [202] = 202, [25] = 25, [48] = 48, [217] = 217, [21] = 21, [84] = 84, [51] = 51, [210] = 210, [26] = 26, [18] = 18, [107] = 107, [111] = 111, [108] = 108, [127] = 127, [117] = 117, [174] = 174, [93] = 93, [302] = 302, [306] = 306, [317] = 317, [291] = 291, [246] = 246, [350] = 350, [160] = 160, [130] = 130, [168] = 168, [162] = 162, [554] = 554, [525] = 525, [550] = 550, [542] = 542, [534] = 534, [577] = 577, [650] = 650, [732] = 732, [809] = 809 }, -- Rat [399] = { [47] = 47 }, -- Rat Snake [2080] = { [285] = 285 }, -- Rattlejaw [431] = { [71] = 71, [15] = 15, [241] = 241 }, -- Rattlesnake [465] = { [106] = 106 }, -- Ravager Hatchling [237] = { [78] = 78 }, -- Ravasaur Hatchling [2590] = { [474] = 474 }, -- Ravenous Prideling [238] = { [56] = 56 }, -- Razormaw Hatchling [239] = { [50] = 50, [210] = 210 }, -- Razzashi Hatchling [2135] = { [885] = 885 }, -- Rebellious Imp [2564] = { [864] = 864 }, -- Rebuilt Gorilla Bot [2565] = { [864] = 864 }, -- Rebuilt Mechanical Spider [1042] = { [376] = 376 }, -- Red Cricket [143] = { [94] = 94 }, -- Red Dragonhawk Hatchling [139] = { [109] = 109 }, -- Red Moth [452] = { [89] = 89, [66] = 66, [57] = 57, [25] = 25, [535] = 535 }, -- Red-Tailed Chipmunk [392] = { [49] = 49 }, -- Redridge Rat [2525] = { [49] = 49 }, -- Redridge Tarantula [744] = { [422] = 422 }, -- Resilient Roach [439] = { [42] = 42 }, -- Restless Shadeling [2199] = { [947] = 947 }, -- Restored Revenant [2394] = { [863] = 863 }, -- Returned Hatchling [1804] = { [641] = 641 }, -- Risen Saber Kitten [1453] = { [125] = 125, [627] = 627 }, -- River Calf [2373] = { [942] = 942 }, -- River Frog [2378] = { [896] = 896, [942] = 942 }, -- River Otter [424] = { [63] = 63, [76] = 76, [66] = 66, [65] = 65, [64] = 64, [27] = 27, [47] = 47, [179] = 179, [202] = 202, [48] = 48, [50] = 50, [49] = 49, [210] = 210, [18] = 18, [117] = 117, [118] = 118, [194] = 194, [300] = 300, [317] = 317, [130] = 130, [186] = 186 }, -- Roach [471] = { [76] = 76, [85] = 85, [83] = 83 }, -- Robo-Chick [482] = { [66] = 66, [198] = 198, [81] = 81, [105] = 105 }, -- Rock Viper [1749] = { [634] = 634 }, -- Rose Taipan [1587] = { [104] = 104, [539] = 539, [535] = 535 }, -- Royal Moth [1328] = { [554] = 554 }, -- Ruby Droplet [460] = { [94] = 94 }, -- Ruby Sapling [1957] = { [147] = 147 }, -- Runeforged Servitor [271] = { [244] = 244, [245] = 245 }, -- Rustberg Gull [2669] = { [1490] = 1490 }, -- Rustbolt Clucker [496] = { [63] = 63 }, -- Rusty Snail [2661] = { [1490] = 1490 }, -- Rustyroot Snooter [1958] = { [147] = 147 }, -- Sanctum Cub [491] = { [71] = 71 }, -- Sand Kitten [2685] = { [1355] = 1355 }, -- Sandclaw Nestseeker [2645] = { [1355] = 1355 }, -- Sandclaw Pincher [2646] = { [1355] = 1355 }, -- Sandclaw Sunshell [2703] = { [1355] = 1355 }, -- Sandkeep [2426] = { [864] = 864, [942] = 942 }, -- Sandstinger Wasp [573] = { [371] = 371 }, -- Sandy Petrel [2377] = { [895] = 895, [942] = 942 }, -- Sandyback Crawler [1592] = { [542] = 542 }, -- Sapphire Firefly [2421] = { [862] = 862, [942] = 942 }, -- Saurolisk Hatchling [1692] = { [534] = 534, [577] = 577 }, -- Savage Cub [717] = { [418] = 418 }, -- Savory Beetle [2436] = { [14] = 14 }, -- Scabby [528] = { [105] = 105 }, -- Scalded Basilisk Hatchling [2704] = { [1355] = 1355 }, -- Scalebrood Hydra [512] = { [81] = 81 }, -- Scarab Hatchling [414] = { [85] = 85, [81] = 81, [64] = 64, [17] = 17, [36] = 36, [23] = 23, [241] = 241, [105] = 105, [100] = 100, [104] = 104, [539] = 539 }, -- Scorpid [416] = { [17] = 17 }, -- Scorpling [538] = { [118] = 118 }, -- Scourged Whelpling [2042] = { [646] = 646 }, -- Scraps [2673] = { [1490] = 1490 }, -- Scrapyard Tunneler [1448] = { [585] = 585, [579] = 579 }, -- Sea Calf [560] = { [71] = 71, [418] = 418, [585] = 585, [535] = 535 }, -- Sea Gull [340] = { [407] = 407 }, -- Sea Pony [1539] = { [534] = 534, [577] = 577 }, -- Seaborne Spore [2404] = { [942] = 942 }, -- Seabreeze Bumblebee [2701] = { [1355] = 1355 }, -- Seafury [172] = { [338] = 338 }, -- Searing Scorchling [218] = { [118] = 118 }, -- Sen'jin Fetish [51] = { [210] = 210, [109] = 109 }, -- Senegal [1601] = { [104] = 104, [539] = 539 }, -- Servant of Demidos [1754] = { [125] = 125, [627] = 627 }, -- Sewer-Pipe Jelly [2381] = { [895] = 895 }, -- Shack Crab [1599] = { [535] = 535 }, -- Shadow Sporebat [2372] = { [942] = 942 }, -- Shadowback Crawler [1690] = { [534] = 534, [577] = 577 }, -- Shard of Cyrukh [1734] = { [641] = 641 }, -- Shimmering Aquafly [229] = { [118] = 118 }, -- Shimmering Wyrmling [493] = { [62] = 62 }, -- Shimmershell Snail [2384] = { [862] = 862 }, -- Shore Butterfly [388] = { [76] = 76, [241] = 241, [52] = 52, [107] = 107, [114] = 114, [117] = 117, [418] = 418, [550] = 550 }, -- Shore Crab [629] = { [85] = 85 }, -- Shore Crawler [2750] = { [23] = 23 }, -- Shrieker [754] = { [371] = 371 }, -- Shrine Fly [677] = { [376] = 376 }, -- Shy Bandicoon [44] = { [109] = 109 }, -- Siamese Cat [511] = { [81] = 81, [249] = 249 }, -- Sidewinder [711] = { [376] = 376 }, -- Sifang Otter [712] = { [376] = 376 }, -- Sifang Otter Pup [741] = { [422] = 422 }, -- Silent Hedgehog [494] = { [71] = 71 }, -- Silithid Hatchling [2163] = { [81] = 81 }, -- Silithid Mini-Tank [568] = { [371] = 371, [543] = 543, [542] = 542, [535] = 535 }, -- Silkbead Snail [503] = { [80] = 80, [198] = 198, [78] = 78 }, -- Silky Moth [144] = { [94] = 94 }, -- Silver Dragonhawk Hatchling [45] = { [37] = 37 }, -- Silver Tabby Cat [291] = { [25] = 25 }, -- Singing Sunflower [2478] = { [84] = 84, [125] = 125, [627] = 627, [895] = 895 }, -- Sir Snips [1628] = { [339] = 339 }, -- Sister of Temptation [637] = { [105] = 105 }, -- Skittering Cavern Crawler [2709] = { [1355] = 1355 }, -- Skittering Eel [397] = { [468] = 468, [76] = 76, [106] = 106, [47] = 47, [179] = 179, [107] = 107, [108] = 108, [117] = 117, [550] = 550 }, -- Skunk [1336] = { [554] = 554 }, -- Skunky Alemental [1350] = { [554] = 554 }, -- Sky Lantern [2134] = { [882] = 882 }, -- Skyfin Juvenile [1711] = { [650] = 650 }, -- Skyhorn Nestling [1326] = { [554] = 554 }, -- Skywisp Moth [2762] = { [1355] = 1355 }, -- Slimy Darkhunter [2758] = { [1355] = 1355 }, -- Slimy Eel [2761] = { [1355] = 1355 }, -- Slimy Fangtooth [2763] = { [1355] = 1355 }, -- Slimy Hermit Crab [2760] = { [1355] = 1355 }, -- Slimy Octopode [2757] = { [1355] = 1355 }, -- Slimy Otter [2765] = { [1355] = 1355 }, -- Slimy Sea Slug [2475] = { [947] = 947 }, -- Slippy [1736] = { [630] = 630, [634] = 634, [641] = 641 }, -- Slithering Brownscale [419] = { [89] = 89, [66] = 66, [10] = 10, [199] = 199, [57] = 57, [14] = 14, [37] = 37, [94] = 94, [95] = 95, [48] = 48, [51] = 51, [102] = 102 }, -- Small Frog [90] = { [250] = 250 }, -- Smolderweb Hatchling [2189] = { [896] = 896 }, -- Smoochums [387] = { [70] = 70, [69] = 69, [94] = 94, [95] = 95, [48] = 48, [50] = 50, [21] = 21, [52] = 52, [107] = 107, [108] = 108, [102] = 102, [117] = 117, [119] = 119, [121] = 121, [550] = 550 }, -- Snake [1960] = { [147] = 147 }, -- Snaplasher [1953] = { [172] = 172 }, -- Snobold Runt [440] = { [27] = 27 }, -- Snow Cub [640] = { [25] = 25 }, -- Snowshoe Hare [72] = { [27] = 27 }, -- Snowshoe Rabbit [2712] = { [1490] = 1490 }, -- Snowsoft Nibbler [69] = { [83] = 83 }, -- Snowy Owl [713] = { [376] = 376 }, -- Softshell Snapling [1183] = { [508] = 508 }, -- Son of Animus [1574] = { [622] = 622, [624] = 624 }, -- Son of Sethe [2049] = { [279] = 279 }, -- Son of Skum [1966] = { [118] = 118, [186] = 186 }, -- Soulbroken Whelpling [1201] = { [388] = 388 }, -- Spawn of G'nathus [2587] = { [474] = 474 }, -- Spawn of Garalon [2528] = { [1352] = 1352 }, -- Spawn of Krag'wa [2186] = { [1038] = 1038 }, -- Spawn of Merektha [2693] = { [1355] = 1355 }, -- Spawn of Nalaada [489] = { [70] = 70 }, -- Spawn of Onyxia [2671] = { [1490] = 1490 }, -- Specimen 97 [1185] = { [507] = 507 }, -- Spectral Porcupette [2397] = { [863] = 863 }, -- Spectral Raven [412] = { [76] = 76, [70] = 70, [85] = 85, [65] = 65, [57] = 57, [83] = 83, [17] = 17, [27] = 27, [23] = 23, [37] = 37, [95] = 95, [179] = 179, [202] = 202, [25] = 25, [217] = 217, [51] = 51, [26] = 26, [18] = 18, [104] = 104, [117] = 117, [118] = 118, [120] = 120, [121] = 121, [317] = 317, [339] = 339, [350] = 350, [132] = 132, [160] = 160, [185] = 185, [184] = 184, [130] = 130, [183] = 183, [168] = 168, [133] = 133, [136] = 136, [186] = 186, [162] = 162, [333] = 333, [539] = 539, [732] = 732, [809] = 809 }, -- Spider [1763] = { [650] = 650 }, -- Spiketail Beaver [433] = { [81] = 81, [15] = 15 }, -- Spiky Lizard [1337] = { [554] = 554 }, -- Spineclaw Crab [466] = { [1] = 1, [85] = 85 }, -- Spiny Lizard [723] = { [418] = 418 }, -- Spiny Terrapin [572] = { [371] = 371 }, -- Spirebound Crab [2653] = { [1355] = 1355 }, -- Spireshell Snail [463] = { [95] = 95 }, -- Spirit Crab [2584] = { [456] = 456 }, -- Spirit of the Spring [515] = { [102] = 102 }, -- Sporeling Sprout [502] = { [78] = 78 }, -- Spotted Bell Frog [2753] = { [1490] = 1490 }, -- Spraybot 0D [1739] = { [641] = 641 }, -- Spring Strider [87] = { [69] = 69 }, -- Sprite Darter Hatchling [2441] = { [14] = 14 }, -- Squawkling [379] = { [468] = 468, [63] = 63, [76] = 76, [62] = 62, [70] = 70, [69] = 69, [80] = 80, [198] = 198, [57] = 57, [27] = 27, [47] = 47, [37] = 37, [179] = 179, [25] = 25, [48] = 48, [217] = 217, [21] = 21, [84] = 84, [244] = 244, [245] = 245, [241] = 241, [22] = 22, [52] = 52, [56] = 56, [105] = 105, [107] = 107, [108] = 108, [127] = 127, [117] = 117, [119] = 119, [348] = 348, [398] = 398, [333] = 333, [550] = 550, [542] = 542, [650] = 650, [641] = 641 }, -- Squirrel [1969] = { [120] = 120 }, -- Stardust [2393] = { [863] = 863 }, -- Sticky Oozeling [1911] = { [125] = 125, [627] = 627 }, -- Sting Ray Pup [492] = { [71] = 71 }, -- Stinkbug [1629] = { [329] = 329 }, -- Stinkrot [1146] = { [162] = 162 }, -- Stitched Pup [485] = { [66] = 66 }, -- Stone Armadillo [2579] = { [471] = 471 }, -- Stoneclaw [1515] = { [535] = 535 }, -- Stonegrinder [1721] = { [634] = 634 }, -- Stormborne Whelpling [1917] = { [634] = 634 }, -- Stormstruck Beaver [675] = { [37] = 37, [84] = 84 }, -- Stormwind Rat [2702] = { [1355] = 1355 }, -- Stormwrath [1518] = { [1] = 1, [27] = 27 }, -- Stout Alemental [553] = { [207] = 207 }, -- Stowaway Rat [401] = { [62] = 62, [27] = 27, [179] = 179, [50] = 50, [51] = 51, [210] = 210, [115] = 115, [194] = 194, [174] = 174, [542] = 542 }, -- Strand Crab [211] = { [85] = 85 }, -- Strand Crawler [432] = { [71] = 71, [15] = 15, [108] = 108 }, -- Stripe-Tailed Scorpid [532] = { [119] = 119 }, -- Stunted Shardhorn [1158] = { [69] = 69 }, -- Stunted Yeti [1128] = { [418] = 418 }, -- Sumprush Rodent [1434] = { [585] = 585, [579] = 579 }, -- Sun Sproutling [1632] = { [335] = 335 }, -- Sunblade Micro-Defender [1885] = { [634] = 634 }, -- Sunborne Val'kyr [1570] = { [585] = 585, [579] = 579 }, -- Sunfire Kaliri [1178] = { [504] = 504 }, -- Sunreaver Micro-Sentry [2793] = { [942] = 942 }, -- Sunsoaked Flitter [2088] = { [367] = 367 }, -- Surger [1182] = { [504] = 504 }, -- Swamp Croaker [402] = { [51] = 51 }, -- Swamp Moth [2419] = { [863] = 863 }, -- Swamp Toad [1590] = { [542] = 542, [650] = 650 }, -- Swamplighter Firefly [497] = { [77] = 77, [104] = 104, [539] = 539 }, -- Tainted Cockroach [498] = { [77] = 77 }, -- Tainted Moth [499] = { [77] = 77 }, -- Tainted Rat [1231] = { [332] = 332 }, -- Tainted Waveling [2540] = { [862] = 862 }, -- Tanzil [2198] = { [896] = 896 }, -- Taptaf [2435] = { [14] = 14 }, -- Teeny Titan Orb [204] = { [118] = 118 }, -- Teldrassil Sproutling [567] = { [371] = 371 }, -- Temple Snake [1416] = { [535] = 535 }, -- Teroclaw Hatchling [650] = { [376] = 376 }, -- Terrible Turnip [1735] = { [641] = 641 }, -- Terror Larva [1456] = { [542] = 542 }, -- Thicket Skitterer [1810] = { [680] = 680 }, -- Thornclaw Broodling [2529] = { [1352] = 1352 }, -- Thunder Lizard Runt [1175] = { [504] = 504 }, -- Thundertail Flapper [1230] = { [332] = 332 }, -- Tideskipper [1750] = { [634] = 634 }, -- Tiny Apparition [509] = { [56] = 56 }, -- Tiny Bog Beast [2412] = { [862] = 862 }, -- Tiny Direhorn [287] = { [36] = 36 }, -- Tiny Flamefly [652] = { [418] = 418 }, -- Tiny Goldfish [389] = { [52] = 52 }, -- Tiny Harvester [279] = { [207] = 207 }, -- Tiny Shale Spider [167] = { [102] = 102 }, -- Tiny Sporebat [445] = { [14] = 14 }, -- Tiny Twister [2078] = { [285] = 285 }, -- Tinytron [206] = { [118] = 118 }, -- Tirisfal Batling [420] = { [63] = 63, [1] = 1, [70] = 70, [77] = 77, [85] = 85, [57] = 57, [94] = 94, [95] = 95, [25] = 25, [21] = 21, [51] = 51, [241] = 241, [56] = 56, [107] = 107, [117] = 117, [550] = 550 }, -- Toad [546] = { [249] = 249 }, -- Tol'vir Scarab [480] = { [66] = 66, [207] = 207 }, -- Topaz Shale Hatchling [2143] = { [947] = 947 }, -- Tottle [2415] = { [863] = 863 }, -- Tragg the Curious [2004] = { [125] = 125, [627] = 627 }, -- Trashy [2539] = { [895] = 895 }, -- Trecker [65] = { [407] = 407 }, -- Tree Frog [405] = { [78] = 78, [50] = 50, [210] = 210, [534] = 534, [577] = 577 }, -- Tree Python [2659] = { [1512] = 1512 }, -- Trench Slug [2057] = { [52] = 52 }, -- Tricorne [536] = { [114] = 114, [115] = 115 }, -- Tundra Penguin [525] = { [117] = 117 }, -- Turkey [473] = { [76] = 76 }, -- Turquoise Turtle [469] = { [76] = 76, [198] = 198, [207] = 207 }, -- Twilight Beetle [2081] = { [294] = 294 }, -- Twilight Clutch-Sister [552] = { [241] = 241 }, -- Twilight Fiendling [505] = { [64] = 64 }, -- Twilight Iguana [470] = { [76] = 76, [241] = 241, [207] = 207 }, -- Twilight Spider [1464] = { [525] = 525, [543] = 543 }, -- Twilight Wasp [2677] = { [241] = 241 }, -- Twilight Whelpling [2022] = { [503] = 503 }, -- Tylarr Gronnden [1538] = { [104] = 104, [539] = 539 }, -- Umbrafen Spore [55] = { [18] = 18, [109] = 109 }, -- Undercity Cockroach [454] = { [18] = 18 }, -- Undercity Rat [1151] = { [287] = 287 }, -- Untamed Hatchling [1921] = { [680] = 680 }, -- Untethered Wyrmling [2136] = { [885] = 885 }, -- Uuna [1737] = { [641] = 641 }, -- Vale Flitter [2375] = { [942] = 942 }, -- Vale Marmot [2376] = { [942] = 942 }, -- Valley Chicken [187] = { [350] = 350, [809] = 809 }, -- Vampiric Batling [1596] = { [542] = 542 }, -- Veilwatcher Hatchling [1344] = { [554] = 554 }, -- Vengeful Porcupette [506] = { [65] = 65 }, -- Venomspitter Hatchling [1807] = { [680] = 680 }, -- Vicious Broodling [1591] = { [534] = 534, [577] = 577 }, -- Violet Firefly [1154] = { [319] = 319 }, -- Viscidus Globule [1244] = { [508] = 508 }, -- Viscous Horror [2549] = { [62] = 62 }, -- Void Jelly [2130] = { [882] = 882 }, -- Void Shardling [2129] = { [882] = 882 }, -- Voidstalker Runt [2434] = { [14] = 14 }, -- Voidwiggler [1013] = { [418] = 418 }, -- Wanderer's Festival Hatchling [517] = { [108] = 108 }, -- Warpstalker Hatchling [2128] = { [882] = 882 }, -- Warpstalker Runt [418] = { [1] = 1, [85] = 85, [50] = 50, [51] = 51, [241] = 241, [56] = 56 }, -- Water Snake [535] = { [121] = 121 }, -- Water Waveling [1593] = { [104] = 104, [539] = 539, [535] = 535, [534] = 534, [577] = 577 }, -- Waterfly [2580] = { [471] = 471 }, -- Wayward Spirit [1394] = { [585] = 585, [579] = 579 }, -- Weebomination [84] = { [52] = 52 }, -- Westfall Chicken [410] = { [210] = 210, [244] = 244, [245] = 245, [595] = 595 }, -- Wharf Rat [46] = { [84] = 84 }, -- White Kitten [141] = { [103] = 103 }, -- White Moth [1968] = { [118] = 118, [186] = 186 }, -- Wicked Soul [2411] = { [896] = 896 }, -- Wicker Pup [1523] = { [84] = 84, [18] = 18 }, -- Widget the Departed [400] = { [47] = 47 }, -- Widow Spiderling [819] = { [371] = 371 }, -- Wild Crimson Hatchling [818] = { [371] = 371 }, -- Wild Golden Hatchling [817] = { [371] = 371 }, -- Wild Jade Hatchling [548] = { [241] = 241 }, -- Wildhammer Gryphon Hatchling [1959] = { [147] = 147 }, -- Winter Rageling [306] = { [83] = 83 }, -- Winterspring Cub [220] = { [62] = 62 }, -- Withers [2482] = { [407] = 407 }, -- Wolf Balloon [153] = { [1] = 1, [27] = 27 }, -- Wolpertinger [64] = { [407] = 407 }, -- Wood Frog [1463] = { [543] = 543 }, -- Wood Wasp [89] = { [250] = 250 }, -- Worg Pup [1634] = { [335] = 335 }, -- Wretched Servant [2700] = { [1355] = 1355 }, -- Wriggler [1266] = { [554] = 554 }, -- Xu-Fu, Cub of Xuen [740] = { [422] = 422, [388] = 388 }, -- Yakrat [2666] = { [1490] = 1490 }, -- Yellow Junkhopper [140] = { [103] = 103 }, -- Yellow Moth [752] = { [390] = 390 }, -- Yellow-Bellied Bullfrog [549] = { [241] = 241 }, -- Yellow-Bellied Marmot [1912] = { [125] = 125, [627] = 627 }, -- Young Mutant Warturtle [2392] = { [863] = 863 }, -- Young Sand Sifter [1304] = { [554] = 554 }, -- Yu'la, Broodling of Yu'lon [1211] = { [507] = 507, [875] = 875 }, -- Zandalari Anklerender [1212] = { [507] = 507, [875] = 875 }, -- Zandalari Footslasher [1180] = { [507] = 507, [875] = 875 }, -- Zandalari Kneebiter [2413] = { [862] = 862 }, -- Zandalari Shinchomper [1213] = { [507] = 507, [875] = 875 }, -- Zandalari Toenibbler [1582] = { [104] = 104, [539] = 539 }, -- Zangar Crawler [1536] = { [534] = 534, [577] = 577 }, -- Zangar Spore [2680] = { [76] = 76, [1512] = 1512 }, -- Zanj'ir Poker [1305] = { [554] = 554 }, -- Zao, Calfling of Niuzao [2084] = { [328] = 328 }, -- Zephyrian Prince [2748] = { [23] = 23 }, -- Ziggy [1428] = { [104] = 104, [539] = 539 }, -- Zomstrok [2550] = { [62] = 62 }, -- Zur'aj the Depleted } Data.ZoneCompanions = { [132] = { [412] = 412 }, -- Ahn'kahet: The Old Kingdom [468] = { [397] = 397, [417] = 417, [379] = 379 }, -- Ammen Vale MoP [885] = { [2122] = 2122, [2126] = 2126, [2115] = 2115, [2135] = 2135, [2136] = 2136 }, -- Antoran Wastes [93] = { [417] = 417 }, -- Arathi Basin [14] = { [445] = 445, [448] = 448, [419] = 419, [459] = 459, [417] = 417, [386] = 386, [443] = 443, [2432] = 2432, [2434] = 2434, [2436] = 2436, [2438] = 2438, [2440] = 2440, [2433] = 2433, [2441] = 2441, [2435] = 2435, [2437] = 2437 }, -- Arathi Highlands [905] = { [2116] = 2116 }, -- Argus [63] = { [450] = 450, [495] = 495, [496] = 496, [478] = 478, [420] = 420, [417] = 417, [424] = 424, [379] = 379 }, -- Ashenvale [732] = { [417] = 417, [412] = 412 }, -- Assault on Violet Hold [947] = { [2442] = 2442, [2143] = 2143, [2439] = 2439, [130] = 130, [2429] = 2429, [2474] = 2474, [2476] = 2476, [2199] = 2199, [2201] = 2201, [2475] = 2475, [2477] = 2477, [2530] = 2530 }, -- Azeroth [76] = { [388] = 388, [397] = 397, [469] = 469, [470] = 470, [471] = 471, [472] = 472, [473] = 473, [417] = 417, [412] = 412, [424] = 424, [378] = 378, [379] = 379, [1728] = 1728, [1729] = 1729, [1914] = 1914, [2562] = 2562, [2680] = 2680, [2555] = 2555 }, -- Azshara [630] = { [569] = 569, [1728] = 1728, [1729] = 1729, [1914] = 1914, [1708] = 1708, [1710] = 1710, [1716] = 1716, [1720] = 1720, [1731] = 1731, [1736] = 1736, [1773] = 1773, [1774] = 1774, [1931] = 1931, [1709] = 1709, [2077] = 2077 }, -- Azsuna [97] = { [464] = 464 }, -- Azuremyst Isle [15] = { [56] = 56, [398] = 398, [406] = 406, [430] = 430, [431] = 431, [432] = 432, [433] = 433, [438] = 438 }, -- Badlands [1352] = { [2528] = 2528, [2527] = 2527, [2529] = 2529 }, -- Battle of Dazar'alor [339] = { [1625] = 1625, [1628] = 1628, [1623] = 1623, [1626] = 1626, [1627] = 1627, [1624] = 1624, [412] = 412 }, -- Black Temple [250] = { [89] = 89, [90] = 90 }, -- Blackrock Spire [285] = { [2078] = 2078, [2080] = 2080, [2079] = 2079 }, -- Blackwing Descent [287] = { [1151] = 1151, [1152] = 1152, [1153] = 1153 }, -- Blackwing Lair [105] = { [449] = 449, [528] = 528, [414] = 414, [482] = 482, [1164] = 1164, [637] = 637, [378] = 378, [379] = 379 }, -- Blade's Edge Mountains [17] = { [635] = 635, [1563] = 1563, [1387] = 1387, [414] = 414, [415] = 415, [412] = 412, [416] = 416 }, -- Blasted Lands [106] = { [397] = 397, [465] = 465, [417] = 417, [627] = 627, [628] = 628 }, -- Bloodmyst Isle [114] = { [639] = 639, [641] = 641, [388] = 388, [530] = 530, [536] = 536 }, -- Borean Tundra [503] = { [1142] = 1142, [2022] = 2022 }, -- Brawl'gar Arena [646] = { [2042] = 2042 }, -- Broken Shore [36] = { [56] = 56, [393] = 393, [414] = 414, [415] = 415, [423] = 423, [425] = 425, [429] = 429, [287] = 287 }, -- Burning Steppes [127] = { [190] = 190, [224] = 224, [236] = 236, [417] = 417, [378] = 378, [379] = 379, [1727] = 1727 }, -- Crystalsong Forest [627] = { [193] = 193, [74] = 74, [1604] = 1604, [1429] = 1429, [1453] = 1453, [1715] = 1715, [1727] = 1727, [1755] = 1755, [1760] = 1760, [1778] = 1778, [1805] = 1805, [1912] = 1912, [1915] = 1915, [1754] = 1754, [1911] = 1911, [2004] = 2004, [2478] = 2478, [2479] = 2479, [1918] = 1918, [1919] = 1919, [1978] = 1978, [1979] = 1979 }, -- Dalaran [125] = { [193] = 193, [74] = 74, [1604] = 1604, [1429] = 1429, [1453] = 1453, [1715] = 1715, [1727] = 1727, [1755] = 1755, [1760] = 1760, [1778] = 1778, [1805] = 1805, [1912] = 1912, [1915] = 1915, [1754] = 1754, [1911] = 1911, [2004] = 2004, [2478] = 2478, [2479] = 2479, [1918] = 1918, [1919] = 1919, [1978] = 1978, [1979] = 1979 }, -- Dalaran [407] = { [64] = 64, [65] = 65, [1062] = 1062, [1276] = 1276, [330] = 330, [335] = 335, [336] = 336, [338] = 338, [339] = 339, [340] = 340, [343] = 343, [848] = 848, [1068] = 1068, [1061] = 1061, [1665] = 1665, [1666] = 1666, [2482] = 2482, [2484] = 2484, [2483] = 2483 }, -- Darkmoon Island [62] = { [630] = 630, [508] = 508, [401] = 401, [417] = 417, [493] = 493, [220] = 220, [378] = 378, [379] = 379, [2544] = 2544, [2546] = 2546, [2548] = 2548, [2550] = 2550, [2549] = 2549, [2545] = 2545, [2547] = 2547, [2563] = 2563 }, -- Darkshore [89] = { [452] = 452, [419] = 419, [478] = 478, [479] = 479 }, -- Darnassus [42] = { [1160] = 1160, [439] = 439 }, -- Deadwind Pass [207] = { [555] = 555, [469] = 469, [554] = 554, [470] = 470, [556] = 556, [559] = 559, [480] = 480, [837] = 837, [838] = 838, [293] = 293, [553] = 553, [279] = 279, [756] = 756 }, -- Deepholm [66] = { [452] = 452, [419] = 419, [478] = 478, [479] = 479, [480] = 480, [482] = 482, [483] = 483, [838] = 838, [484] = 484, [417] = 417, [485] = 485, [424] = 424 }, -- Desolace [409] = { [2090] = 2090 }, -- Dragon Soul [115] = { [641] = 641, [536] = 536, [401] = 401, [198] = 198, [537] = 537 }, -- Dragonblight [160] = { [417] = 417, [412] = 412 }, -- Drak'Tharon Keep [422] = { [834] = 834, [742] = 742, [836] = 836, [740] = 740, [741] = 741, [743] = 743, [744] = 744, [745] = 745, [746] = 746, [732] = 732 }, -- Dread Wastes MoP [896] = { [2378] = 2378, [2386] = 2386, [2406] = 2406, [2424] = 2424, [2189] = 2189, [2405] = 2405, [2407] = 2407, [2411] = 2411, [2408] = 2408, [2198] = 2198 }, -- Drustvar [27] = { [1518] = 1518, [635] = 635, [166] = 166, [401] = 401, [404] = 404, [72] = 72, [417] = 417, [412] = 412, [424] = 424, [378] = 378, [440] = 440, [441] = 441, [442] = 442, [379] = 379, [153] = 153, [2533] = 2533, [2531] = 2531, [2532] = 2532 }, -- Dun Morogh [1] = { [1518] = 1518, [635] = 635, [448] = 448, [166] = 166, [466] = 466, [467] = 467, [468] = 468, [418] = 418, [420] = 420, [1237] = 1237, [153] = 153 }, -- Durotar [47] = { [385] = 385, [646] = 646, [396] = 396, [397] = 397, [398] = 398, [399] = 399, [400] = 400, [424] = 424, [378] = 378, [379] = 379 }, -- Duskwood [70] = { [56] = 56, [385] = 385, [387] = 387, [646] = 646, [398] = 398, [232] = 232, [420] = 420, [412] = 412, [489] = 489, [379] = 379 }, -- Dustwallow Marsh [23] = { [393] = 393, [457] = 457, [398] = 398, [286] = 286, [406] = 406, [414] = 414, [412] = 412, [626] = 626, [627] = 627, [628] = 628, [2748] = 2748, [2750] = 2750, [2747] = 2747, [2749] = 2749 }, -- Eastern Plaguelands [37] = { [40] = 40, [447] = 447, [646] = 646, [41] = 41, [419] = 419, [459] = 459, [43] = 43, [45] = 45, [412] = 412, [675] = 675, [374] = 374, [378] = 378, [379] = 379 }, -- Elwynn Forest [94] = { [387] = 387, [419] = 419, [459] = 459, [460] = 460, [142] = 142, [143] = 143, [144] = 144, [420] = 420, [378] = 378 }, -- Eversong Woods [790] = { [1728] = 1728, [1729] = 1729, [1914] = 1914, [1926] = 1926 }, -- Eye of Azshara [713] = { [1728] = 1728, [1729] = 1729, [1914] = 1914 }, -- Eye of Azshara [77] = { [406] = 406, [420] = 420, [497] = 497, [498] = 498, [499] = 499, [500] = 500 }, -- Felwood [69] = { [387] = 387, [59] = 59, [557] = 557, [87] = 87, [1158] = 1158, [378] = 378, [379] = 379 }, -- Feralas [367] = { [2086] = 2086, [2087] = 2087, [2089] = 2089, [2088] = 2088 }, -- Firelands [525] = { [1578] = 1578, [1579] = 1579, [541] = 541, [417] = 417, [1427] = 1427, [1457] = 1457, [1464] = 1464, [1471] = 1471 }, -- Frostfire Ridge [585] = { [560] = 560, [1396] = 1396, [1688] = 1688, [1588] = 1588, [1598] = 1598, [1577] = 1577, [1661] = 1661, [1385] = 1385, [1545] = 1545, [1568] = 1568, [1442] = 1442, [1434] = 1434, [1570] = 1570, [1394] = 1394, [115] = 115, [1448] = 1448 }, -- Frostwall [95] = { [450] = 450, [387] = 387, [419] = 419, [461] = 461, [463] = 463, [420] = 420, [417] = 417, [412] = 412 }, -- Ghostlands [179] = { [397] = 397, [401] = 401, [417] = 417, [412] = 412, [424] = 424, [379] = 379 }, -- Gilneas [202] = { [417] = 417, [412] = 412, [424] = 424 }, -- Gilneas City [226] = { [1162] = 1162, [2534] = 2534 }, -- Gnomeregan [543] = { [1564] = 1564, [449] = 449, [1537] = 1537, [393] = 393, [1594] = 1594, [1615] = 1615, [568] = 568, [702] = 702, [430] = 430, [1463] = 1463, [1465] = 1465, [1464] = 1464, [1469] = 1469, [1470] = 1470 }, -- Gorgrond [606] = { [635] = 635 }, -- Grimrail Depot [116] = { [385] = 385, [647] = 647, [534] = 534, [633] = 633 }, -- Grizzly Hills [153] = { [234] = 234 }, -- Gundrak [185] = { [412] = 412 }, -- Halls of Reflection [474] = { [2586] = 2586, [2590] = 2590, [2587] = 2587, [2585] = 2585, [2589] = 2589 }, -- Heart of Fear MoP [649] = { [1753] = 1753 }, -- Helheim [661] = { [1672] = 1672 }, -- Hellfire Citadel [100] = { [635] = 635, [414] = 414, [514] = 514 }, -- Hellfire Peninsula [650] = { [391] = 391, [407] = 407, [569] = 569, [417] = 417, [487] = 487, [1441] = 1441, [1590] = 1590, [378] = 378, [379] = 379, [1711] = 1711, [1713] = 1713, [1726] = 1726, [1731] = 1731, [1743] = 1743, [1744] = 1744, [1752] = 1752, [1761] = 1761, [1762] = 1762, [1763] = 1763, [1775] = 1775, [1776] = 1776, [1884] = 1884, [1714] = 1714 }, -- Highmountain [25] = { [640] = 640, [450] = 450, [646] = 646, [452] = 452, [648] = 648, [453] = 453, [42] = 42, [291] = 291, [1159] = 1159, [420] = 420, [417] = 417, [412] = 412, [378] = 378, [379] = 379 }, -- Hillsbrad Foothills [117] = { [450] = 450, [644] = 644, [387] = 387, [646] = 646, [388] = 388, [523] = 523, [525] = 525, [529] = 529, [397] = 397, [198] = 198, [420] = 420, [417] = 417, [412] = 412, [424] = 424, [378] = 378, [379] = 379 }, -- Howling Fjord [329] = { [1629] = 1629, [1622] = 1622, [1631] = 1631 }, -- Hyjal Summit [118] = { [393] = 393, [229] = 229, [538] = 538, [204] = 204, [205] = 205, [206] = 206, [207] = 207, [212] = 212, [209] = 209, [213] = 213, [214] = 214, [412] = 412, [215] = 215, [216] = 216, [218] = 218, [424] = 424, [210] = 210, [1963] = 1963, [1964] = 1964, [1965] = 1965, [1966] = 1966, [1967] = 1967, [1968] = 1968 }, -- Icecrown [186] = { [412] = 412, [424] = 424, [1963] = 1963, [1964] = 1964, [1965] = 1965, [1966] = 1966, [1967] = 1967, [1968] = 1968 }, -- Icecrown Citadel [595] = { [393] = 393, [410] = 410 }, -- Iron Docks [507] = { [1213] = 1213, [1211] = 1211, [1185] = 1185, [1180] = 1180, [1212] = 1212, [1205] = 1205 }, -- Isle of Giants [504] = { [1181] = 1181, [1175] = 1175, [1179] = 1179, [1178] = 1178, [1182] = 1182 }, -- Isle of Thunder [350] = { [187] = 187, [417] = 417, [412] = 412, [1227] = 1227, [1226] = 1226, [1228] = 1228, [1229] = 1229 }, -- Karazhan [194] = { [401] = 401, [424] = 424 }, -- Kezan [418] = { [388] = 388, [1013] = 1013, [1128] = 1128, [678] = 678, [560] = 560, [717] = 717, [708] = 708, [714] = 714, [718] = 718, [722] = 722, [723] = 723, [716] = 716, [652] = 652 }, -- Krasarang Wilds MoP [830] = { [2124] = 2124, [2123] = 2123, [2127] = 2127 }, -- Krokuun [48] = { [387] = 387, [419] = 419, [417] = 417, [437] = 437, [424] = 424, [379] = 379 }, -- Loch Modan [579] = { [1396] = 1396, [1688] = 1688, [1588] = 1588, [1598] = 1598, [1577] = 1577, [1661] = 1661, [1385] = 1385, [1545] = 1545, [1568] = 1568, [1442] = 1442, [1434] = 1434, [1570] = 1570, [1394] = 1394, [115] = 115, [1448] = 1448 }, -- Lunarfall [882] = { [2120] = 2120, [2128] = 2128, [2130] = 2130, [2132] = 2132, [2129] = 2129, [2134] = 2134, [2133] = 2133, [2131] = 2131 }, -- Mac'Aree [348] = { [175] = 175, [379] = 379 }, -- Magisters' Terrace [1490] = { [2662] = 2662, [2664] = 2664, [2668] = 2668, [2670] = 2670, [2672] = 2672, [2712] = 2712, [2718] = 2718, [2720] = 2720, [2756] = 2756, [2766] = 2766, [2666] = 2666, [2714] = 2714, [2715] = 2715, [2713] = 2713, [2661] = 2661, [2663] = 2663, [2665] = 2665, [2667] = 2667, [2669] = 2669, [2671] = 2671, [2673] = 2673, [2675] = 2675, [2711] = 2711, [2719] = 2719, [2753] = 2753, [2676] = 2676, [2674] = 2674 }, -- Mechagon [471] = { [2582] = 2582, [2580] = 2580, [2579] = 2579, [2581] = 2581 }, -- Mogu'shan Vaults MoP [232] = { [1544] = 1544, [1147] = 1147, [1149] = 1149, [1150] = 1150 }, -- Molten Core [338] = { [317] = 317, [172] = 172, [318] = 318 }, -- Molten Front [80] = { [341] = 341, [342] = 342, [478] = 478, [503] = 503, [378] = 378, [379] = 379 }, -- Moonglade [198] = { [632] = 632, [259] = 259, [539] = 539, [540] = 540, [541] = 541, [547] = 547, [469] = 469, [478] = 478, [415] = 415, [479] = 479, [482] = 482, [487] = 487, [503] = 503, [378] = 378, [626] = 626, [755] = 755, [260] = 260, [379] = 379 }, -- Mount Hyjal [7] = { [385] = 385, [70] = 70, [477] = 477, [386] = 386, [378] = 378 }, -- Mulgore [107] = { [635] = 635, [1524] = 1524, [387] = 387, [518] = 518, [388] = 388, [397] = 397, [420] = 420, [417] = 417, [1435] = 1435, [1441] = 1441, [1446] = 1446, [386] = 386, [378] = 378, [379] = 379, [1764] = 1764, [1765] = 1765, [1766] = 1766 }, -- Nagrand [550] = { [635] = 635, [1524] = 1524, [387] = 387, [518] = 518, [388] = 388, [397] = 397, [420] = 420, [417] = 417, [1435] = 1435, [1441] = 1441, [1446] = 1446, [386] = 386, [378] = 378, [379] = 379, [1764] = 1764, [1765] = 1765, [1766] = 1766 }, -- Nagrand [162] = { [1146] = 1146, [1143] = 1143, [1144] = 1144, [417] = 417, [412] = 412 }, -- Naxxramas [1355] = { [2648] = 2648, [2650] = 2650, [2652] = 2652, [2678] = 2678, [2684] = 2684, [2686] = 2686, [2690] = 2690, [2700] = 2700, [2702] = 2702, [2704] = 2704, [2706] = 2706, [2708] = 2708, [2710] = 2710, [2758] = 2758, [2760] = 2760, [2762] = 2762, [2761] = 2761, [2681] = 2681, [2763] = 2763, [2646] = 2646, [2682] = 2682, [2645] = 2645, [2647] = 2647, [2649] = 2649, [2651] = 2651, [2653] = 2653, [2698] = 2698, [2685] = 2685, [2689] = 2689, [2691] = 2691, [2693] = 2693, [2695] = 2695, [2697] = 2697, [2699] = 2699, [2701] = 2701, [2703] = 2703, [2707] = 2707, [2709] = 2709, [2757] = 2757, [2765] = 2765, [2660] = 2660 }, -- Nazjatar [863] = { [2388] = 2388, [2392] = 2392, [2394] = 2394, [2398] = 2398, [2400] = 2400, [2414] = 2414, [2420] = 2420, [2424] = 2424, [2157] = 2157, [2389] = 2389, [2395] = 2395, [2415] = 2415, [2419] = 2419, [2393] = 2393, [2397] = 2397 }, -- Nazmir [109] = { [638] = 638, [385] = 385, [521] = 521, [459] = 459, [136] = 136, [137] = 137, [51] = 51, [44] = 44, [145] = 145, [139] = 139, [55] = 55, [78] = 78 }, -- Netherstorm [10] = { [631] = 631, [635] = 635, [419] = 419, [474] = 474, [1157] = 1157, [386] = 386 }, -- Northern Barrens [50] = { [635] = 635, [387] = 387, [49] = 49, [401] = 401, [403] = 403, [404] = 404, [405] = 405, [406] = 406, [407] = 407, [408] = 408, [409] = 409, [239] = 239, [418] = 418, [421] = 421, [301] = 301, [424] = 424 }, -- Northern Stranglethorn [85] = { [272] = 272, [1449] = 1449, [332] = 332, [792] = 792, [1331] = 1331, [1332] = 1332, [466] = 466, [467] = 467, [270] = 270, [471] = 471, [281] = 281, [282] = 282, [283] = 283, [1334] = 1334, [280] = 280, [414] = 414, [418] = 418, [420] = 420, [211] = 211, [75] = 75, [1322] = 1322, [412] = 412, [320] = 320, [78] = 78, [77] = 77, [629] = 629, [1890] = 1890, [2479] = 2479, [1919] = 1919, [1979] = 1979 }, -- Orgrimmar [184] = { [412] = 412 }, -- Pit of Saron [300] = { [424] = 424 }, -- Razorfen Downs [49] = { [646] = 646, [391] = 391, [392] = 392, [395] = 395, [424] = 424, [378] = 378, [2525] = 2525 }, -- Redridge Mountains [809] = { [187] = 187, [417] = 417, [412] = 412, [1227] = 1227, [1226] = 1226, [1228] = 1228, [1229] = 1229 }, -- Return to Karazhan [217] = { [417] = 417, [412] = 412, [379] = 379 }, -- Ruins of Gilneas [302] = { [417] = 417 }, -- Scarlet Monastery [306] = { [417] = 417 }, -- Scholomance [32] = { [415] = 415, [423] = 423, [427] = 427, [428] = 428 }, -- Searing Gorge [332] = { [1230] = 1230, [1231] = 1231, [1232] = 1232 }, -- Serpentshrine Cavern [104] = { [519] = 519, [1593] = 1593, [407] = 407, [1601] = 1601, [414] = 414, [1428] = 1428, [425] = 425, [1447] = 1447, [1582] = 1582, [412] = 412, [1455] = 1455, [1587] = 1587, [1538] = 1538, [497] = 497 }, -- Shadowmoon Valley [539] = { [519] = 519, [1593] = 1593, [407] = 407, [1601] = 1601, [414] = 414, [1428] = 1428, [425] = 425, [1447] = 1447, [1582] = 1582, [412] = 412, [1455] = 1455, [1587] = 1587, [1538] = 1538, [497] = 497 }, -- Shadowmoon Valley [111] = { [417] = 417 }, -- Shattrath City [119] = { [387] = 387, [649] = 649, [1167] = 1167, [532] = 532, [379] = 379 }, -- Sholazar Basin [556] = { [1331] = 1331, [1332] = 1332, [1334] = 1334, [1322] = 1322 }, -- Siege of Orgrimmar [81] = { [511] = 511, [512] = 512, [513] = 513, [406] = 406, [414] = 414, [482] = 482, [484] = 484, [433] = 433, [2163] = 2163, [2439] = 2439, [2429] = 2429 }, -- Silithus [110] = { [459] = 459, [378] = 378 }, -- Silvermoon City [21] = { [387] = 387, [455] = 455, [420] = 420, [417] = 417, [378] = 378, [627] = 627, [628] = 628, [379] = 379 }, -- Silverpine Forest [199] = { [631] = 631, [635] = 635, [419] = 419, [475] = 475, [386] = 386 }, -- Southern Barrens [542] = { [635] = 635, [1532] = 1532, [1540] = 1540, [1541] = 1541, [1596] = 1596, [1573] = 1573, [401] = 401, [568] = 568, [1597] = 1597, [417] = 417, [1441] = 1441, [1456] = 1456, [1462] = 1462, [1590] = 1590, [379] = 379, [1592] = 1592 }, -- Spires of Arak [65] = { [472] = 472, [417] = 417, [487] = 487, [488] = 488, [412] = 412, [424] = 424, [378] = 378, [633] = 633, [506] = 506 }, -- Stonetalon Mountains [634] = { [1708] = 1708, [1712] = 1712, [1713] = 1713, [1721] = 1721, [1736] = 1736, [1743] = 1743, [1744] = 1744, [1749] = 1749, [1917] = 1917, [1750] = 1750, [1885] = 1885 }, -- Stormheim [622] = { [1574] = 1574 }, -- Stormshield [942] = { [2372] = 2372, [2374] = 2374, [2378] = 2378, [2404] = 2404, [2426] = 2426, [2428] = 2428, [2373] = 2373, [2375] = 2375, [2379] = 2379, [2403] = 2403, [2423] = 2423, [2427] = 2427, [2376] = 2376, [2421] = 2421, [2377] = 2377, [2422] = 2422, [2425] = 2425, [2794] = 2794, [2793] = 2793, [2792] = 2792 }, -- Stormsong Valley [84] = { [1523] = 1523, [319] = 319, [417] = 417, [1521] = 1521, [46] = 46, [675] = 675, [378] = 378, [379] = 379, [1890] = 1890, [2478] = 2478, [1918] = 1918, [1978] = 1978 }, -- Stormwind City [317] = { [417] = 417, [412] = 412, [424] = 424, [2638] = 2638 }, -- Stratholme [335] = { [1634] = 1634, [1632] = 1632, [1633] = 1633 }, -- Sunwell Plateau [680] = { [425] = 425, [1914] = 1914, [1717] = 1717, [1719] = 1719, [1807] = 1807, [1808] = 1808, [1809] = 1809, [1921] = 1921, [1922] = 1922, [1934] = 1934, [1810] = 1810 }, -- Suramar [51] = { [648] = 648, [419] = 419, [401] = 401, [402] = 402, [403] = 403, [418] = 418, [420] = 420, [417] = 417, [422] = 422, [412] = 412 }, -- Swamp of Sorrows [535] = { [1515] = 1515, [452] = 452, [1572] = 1572, [1583] = 1583, [1595] = 1595, [1593] = 1593, [560] = 560, [1599] = 1599, [568] = 568, [1416] = 1416, [1576] = 1576, [1441] = 1441, [427] = 427, [1587] = 1587, [1589] = 1589 }, -- Talador [534] = { [450] = 450, [519] = 519, [1593] = 1593, [405] = 405, [483] = 483, [417] = 417, [1468] = 1468, [1536] = 1536, [1539] = 1539, [1586] = 1586, [1591] = 1591, [1660] = 1660, [1663] = 1663, [1664] = 1664, [1692] = 1692, [1693] = 1693, [1690] = 1690, [1581] = 1581 }, -- Tanaan Jungle [577] = { [450] = 450, [519] = 519, [1593] = 1593, [405] = 405, [483] = 483, [417] = 417, [1468] = 1468, [1536] = 1536, [1539] = 1539, [1586] = 1586, [1591] = 1591, [1660] = 1660, [1663] = 1663, [1664] = 1664, [1692] = 1692, [1693] = 1693, [1690] = 1690, [1581] = 1581 }, -- Tanaan Jungle - Assault on the Dark Portal [71] = { [560] = 560, [484] = 484, [491] = 491, [492] = 492, [430] = 430, [494] = 494, [431] = 431, [432] = 432, [2526] = 2526 }, -- Tanaris [57] = { [507] = 507, [447] = 447, [452] = 452, [68] = 68, [419] = 419, [67] = 67, [478] = 478, [479] = 479, [420] = 420, [412] = 412, [379] = 379 }, -- Teldrassil [319] = { [1154] = 1154, [1155] = 1155, [1156] = 1156 }, -- Temple of Ahn'Qiraj [1038] = { [2186] = 2186 }, -- Temple of Sethraliss [108] = { [387] = 387, [646] = 646, [132] = 132, [397] = 397, [417] = 417, [149] = 149, [517] = 517, [432] = 432, [186] = 186, [379] = 379 }, -- Terokkar Forest [456] = { [2584] = 2584, [2583] = 2583 }, -- Terrace of Endless Spring MoP [294] = { [2082] = 2082, [2081] = 2081, [2083] = 2083 }, -- The Bastion of Twilight [210] = { [49] = 49, [401] = 401, [403] = 403, [404] = 404, [405] = 405, [406] = 406, [51] = 51, [407] = 407, [408] = 408, [410] = 410, [411] = 411, [239] = 239, [417] = 417, [421] = 421, [424] = 424, [47] = 47 }, -- The Cape of Stranglethorn [130] = { [417] = 417, [412] = 412, [424] = 424 }, -- The Culling of Stratholme [291] = { [50] = 50, [417] = 417 }, -- The Deadmines [777] = { [1722] = 1722, [1723] = 1723 }, -- The Emerald Nightmare [1512] = { [2658] = 2658, [2680] = 2680, [2692] = 2692, [2659] = 2659, [2696] = 2696, [2657] = 2657, [2694] = 2694 }, -- The Eternal Palace [103] = { [141] = 141, [140] = 140, [138] = 138 }, -- The Exodar [334] = { [1233] = 1233, [1234] = 1234, [1235] = 1235 }, -- The Eye [183] = { [412] = 412 }, -- The Forge of Souls [26] = { [446] = 446, [448] = 448, [449] = 449, [450] = 450, [393] = 393, [417] = 417, [412] = 412 }, -- The Hinterlands [371] = { [380] = 380, [817] = 817, [818] = 818, [819] = 819, [562] = 562, [564] = 564, [567] = 567, [566] = 566, [568] = 568, [570] = 570, [569] = 569, [571] = 571, [699] = 699, [572] = 572, [702] = 702, [703] = 703, [565] = 565, [847] = 847, [573] = 573, [754] = 754 }, -- The Jade Forest MoP [174] = { [401] = 401, [417] = 417 }, -- The Lost Isles [246] = { [417] = 417 }, -- The Shattered Halls [120] = { [641] = 641, [558] = 558, [412] = 412, [633] = 633, [1969] = 1969 }, -- The Storm Peaks [168] = { [417] = 417, [412] = 412 }, -- The Violet Hold [378] = { [2047] = 2047 }, -- The Wandering Isle MoP [64] = { [398] = 398, [414] = 414, [52] = 52, [424] = 424, [505] = 505 }, -- Thousand Needles [328] = { [2084] = 2084, [2085] = 2085 }, -- Throne of the Four Winds [322] = { [328] = 328 }, -- Throne of the Tides [508] = { [1183] = 1183, [1200] = 1200, [1177] = 1177, [1243] = 1243, [1202] = 1202, [1244] = 1244 }, -- Throne of Thunder [88] = { [386] = 386 }, -- Thunder Bluff [554] = { [1304] = 1304, [1323] = 1323, [1324] = 1324, [1326] = 1326, [1328] = 1328, [1337] = 1337, [1333] = 1333, [1338] = 1338, [1343] = 1343, [1344] = 1344, [1346] = 1346, [1350] = 1350, [1336] = 1336, [1335] = 1335, [1348] = 1348, [1345] = 1345, [417] = 417, [1325] = 1325, [1330] = 1330, [1329] = 1329, [1303] = 1303, [1321] = 1321, [1305] = 1305, [1266] = 1266, [2017] = 2017, [2018] = 2018 }, -- Timeless Isle [895] = { [2380] = 2380, [2382] = 2382, [2410] = 2410, [2430] = 2430, [2381] = 2381, [2383] = 2383, [2377] = 2377, [2409] = 2409, [2165] = 2165, [2478] = 2478, [2562] = 2562, [2539] = 2539, [2555] = 2555, [1918] = 1918, [1978] = 1978 }, -- Tiragarde Sound [18] = { [1523] = 1523, [319] = 319, [450] = 450, [646] = 646, [454] = 454, [458] = 458, [417] = 417, [1521] = 1521, [412] = 412, [424] = 424, [55] = 55, [378] = 378, [626] = 626, [2002] = 2002 }, -- Tirisfal Glades [244] = { [271] = 271, [278] = 278, [410] = 410, [379] = 379 }, -- Tol Barad [245] = { [271] = 271, [278] = 278, [410] = 410, [379] = 379 }, -- Tol Barad Peninsula [1169] = { [2187] = 2187 }, -- Tol Dagor [388] = { [1201] = 1201, [680] = 680, [733] = 733, [737] = 737, [739] = 739, [740] = 740, [732] = 732 }, -- Townlong Steppes MoP [172] = { [1952] = 1952, [1953] = 1953, [1954] = 1954 }, -- Trial of the Crusader [241] = { [645] = 645, [647] = 647, [388] = 388, [648] = 648, [393] = 393, [398] = 398, [548] = 548, [549] = 549, [550] = 550, [552] = 552, [470] = 470, [823] = 823, [414] = 414, [418] = 418, [420] = 420, [293] = 293, [431] = 431, [379] = 379, [2677] = 2677 }, -- Twilight Highlands [147] = { [1955] = 1955, [1956] = 1956, [1957] = 1957, [1958] = 1958, [1959] = 1959, [1960] = 1960, [1961] = 1961, [1962] = 1962 }, -- Ulduar [249] = { [631] = 631, [511] = 511, [542] = 542, [544] = 544, [545] = 545, [467] = 467, [484] = 484, [293] = 293, [851] = 851, [546] = 546, [543] = 543 }, -- Uldum [78] = { [631] = 631, [632] = 632, [393] = 393, [403] = 403, [404] = 404, [405] = 405, [406] = 406, [237] = 237, [415] = 415, [502] = 502, [503] = 503, [504] = 504 }, -- Un'Goro Crater [133] = { [412] = 412 }, -- Utgarde Keep [136] = { [412] = 412 }, -- Utgarde Pinnacle [641] = { [379] = 379, [1705] = 1705, [1706] = 1706, [1734] = 1734, [1736] = 1736, [1737] = 1737, [1738] = 1738, [1739] = 1739, [1802] = 1802, [1804] = 1804, [1907] = 1907, [1913] = 1913, [1927] = 1927, [1735] = 1735 }, -- Val'sharah [390] = { [383] = 383, [748] = 748, [1124] = 1124, [1126] = 1126, [1125] = 1125, [747] = 747, [868] = 868, [749] = 749, [750] = 750, [751] = 751, [752] = 752 }, -- Vale of Eternal Blossoms MoP [376] = { [1042] = 1042, [650] = 650, [677] = 677, [709] = 709, [706] = 706, [707] = 707, [708] = 708, [710] = 710, [711] = 711, [712] = 712, [713] = 713 }, -- Valley of the Four Winds MoP [864] = { [2188] = 2188, [2190] = 2190, [2426] = 2426, [2428] = 2428, [2399] = 2399, [2417] = 2417, [2423] = 2423, [2425] = 2425, [2564] = 2564, [2565] = 2565 }, -- Vol'dun [279] = { [233] = 233, [2049] = 2049 }, -- Wailing Caverns [624] = { [1574] = 1574 }, -- Warspear [398] = { [379] = 379 }, -- Well of Eternity [22] = { [456] = 456, [398] = 398, [378] = 378, [379] = 379 }, -- Western Plaguelands [52] = { [385] = 385, [387] = 387, [646] = 646, [388] = 388, [389] = 389, [84] = 84, [386] = 386, [378] = 378, [379] = 379, [2041] = 2041, [2058] = 2058, [2057] = 2057 }, -- Westfall [56] = { [509] = 509, [56] = 56, [385] = 385, [646] = 646, [393] = 393, [398] = 398, [58] = 58, [418] = 418, [420] = 420, [378] = 378, [633] = 633, [238] = 238, [379] = 379 }, -- Wetlands [83] = { [634] = 634, [57] = 57, [69] = 69, [471] = 471, [472] = 472, [487] = 487, [1163] = 1163, [412] = 412, [306] = 306, [633] = 633, [441] = 441 }, -- Winterspring [875] = { [1213] = 1213, [1211] = 1211, [1180] = 1180, [1212] = 1212 }, -- Zandalar [102] = { [515] = 515, [387] = 387, [419] = 419, [167] = 167, [146] = 146 }, -- Zangarmarsh [333] = { [165] = 165, [412] = 412, [379] = 379 }, -- Zul'Aman [121] = { [641] = 641, [387] = 387, [648] = 648, [234] = 234, [412] = 412, [535] = 535 }, -- Zul'Drak [337] = { [307] = 307 }, -- Zul'Gurub [862] = { [2384] = 2384, [2406] = 2406, [2410] = 2410, [2412] = 2412, [2416] = 2416, [2418] = 2418, [2430] = 2430, [2444] = 2444, [2385] = 2385, [2403] = 2403, [2407] = 2407, [2427] = 2427, [2413] = 2413, [2408] = 2408, [2421] = 2421, [2422] = 2422, [2390] = 2390, [2196] = 2196, [2409] = 2409, [2387] = 2387, [2538] = 2538, [2540] = 2540, [2562] = 2562, [2479] = 2479, [2537] = 2537, [2555] = 2555, [1919] = 1919, [1979] = 1979 }, -- Zuldazar }
--[[------------------------------------------------------------------- Nuke ---------------------------------------------------------------------]] hook.Add("PlayerUse", "LaunchNuke", function(ply, ent) if !ply:IsZombie() && ent.bNukeBtn && !ent:IsPressed() then hook.Call( "OnNukeLaunched", GAMEMODE, ply ) end end) -- Specify which entity is the nuke button since there is no targetname on the func_button hook.Add("EntityKeyValue", "SpecifyNukeButton", function(ent, k, v) if ent:GetClass() == "func_button" && k == "OnPressed" && v == "Com,Command,say ***Nuke in 10secs.***,0,1" then ent.bNukeBtn = true end end) --[[------------------------------------------------------------------- Map Fixes ---------------------------------------------------------------------]] hook.Add("OnRoundChange", "RemoveBugsSecrets", function() -- Remove orange secrets /*local buttons = ents.FindByName("Orange*") for _, v in pairs(buttons) do if IsValid(v) then v:Remove() end end -- Remove skybox teleports local buttons = ents.FindByName("SkyBox*") for _, v in pairs(buttons) do if IsValid(v) then v:Remove() end end*/ for _, v in pairs(ents.FindInSphere(Vector(-2528,-4576,369), 64)) do if string.find(v:GetClass(),"info_player") then v:Remove() end end end)
Inventory = exports.vorp_inventory:vorp_inventoryApi() local VorpCore = {} TriggerEvent("getCore",function(core) VorpCore = core end) data = {} function RandomItem() local Items = { "goldbar", "lockpick" } return Items[math.random(#Items)] end function RandomNumber() return math.random(1,2) end TriggerEvent("vorp_inventory:getData",function(call) data = call end) RegisterServerEvent("scf_storerobbery:reward") AddEventHandler("scf_storerobbery:reward", function(type) local _source = source local User = VorpCore.getUser(_source) local Character = User.getUsedCharacter local r = math.random(1,10) if(type == "clinic") then if r < 3 then Inventory.addItem(_source, "hairpin", math.random(1,2)) TriggerClientEvent("vorp:Tip", _source, 'You got some hair pins', 5000) else Inventory.addItem(_source, "consumable_ginseng", math.random(1,2)) TriggerClientEvent("vorp:Tip", _source, 'You got some ginseng', 5000) end else if r < 3 then local amount = RandomNumber() Inventory.addItem(_source, "paper_clip", amount) TriggerClientEvent("vorp:Tip", _source, 'You got '..amount..'x paper clip', 5000) else local amount = RandomNumber() Inventory.addItem(_source, "goldbar", amount) TriggerClientEvent("vorp:Tip", _source, 'You got '..amount..'x Goldbar', 5000) end end end) RegisterServerEvent('scf_storerobbery:lockpick') AddEventHandler('scf_storerobbery:lockpick', function() local _source = source local User = VorpCore.getUser(_source) local Character = User.getUsedCharacter --TriggerClientEvent("scf_storerobbery:StartRobbing", _source) TriggerServerEvent('scf_storerobbery:policecheck') end) RegisterNetEvent("scf_storerobbery:policenotify") AddEventHandler("scf_storerobbery:policenotify", function(players, coords) for each, player in ipairs(players) do local Character = VorpCore.getUser(player).getUsedCharacter if Character ~= nil then if Character.job == 'police' then TriggerClientEvent("scf_storerobbery:witness", player, coords) end end end end) RegisterServerEvent("scf_storerobbery:policecheck") AddEventHandler("scf_storerobbery:policecheck", function(players,type) local _source = source local Sceriffi = 0 for k,v in pairs(players) do local User = VorpCore.getUser(v) local Character = User.getUsedCharacter if Character.job == "police" then Sceriffi = Sceriffi + 1 end end if Sceriffi >= 1 then TriggerClientEvent('scf_storerobbery:StartRobbing', _source,type) else TriggerClientEvent("vorp:Tip", _source, 'There arent enough Sheriffs', 5000) end end)
natives["java.lang.Object"] = natives["java.lang.Object"] or {} natives["java.lang.Object"]["toString()Ljava/lang/String;"] = function(this) return asObjRef(tostring(this):sub(8), "Ljava/lang/String;") end
ITEM.name = "Car Battery" ITEM.desc = "An old car battery" ITEM.model = "models/items/car_battery01.mdl" ITEM.width = 2 ITEM.height = 2 ITEM.money = {6, 10}
--[[ @Author: Gavin "Mullets" Rosenthal @Desc: Datastore system that can replace DS2/Roblox Datastore implementation. Roll the dice 🎲 @Note: While developing the rework, I didn't know what I was doing so all parameters are laid out in dictionary format --]] --[[ [DOCUMENTATION]: https://github.com/Mullets-Gavin/DiceDataStore Listed below is a quick glance on the API, visit the link above for proper documentation [METHODS]: :SetData() :LoadData() :SaveData() :ClearData() :GetData() :UpdateData() :IncrementData() :RemoveData() :WatchData() :CalculateSize() [FEATURES]: - Automatic retries (stops at 5) - Prevents data over writing saves per session - Saves on BindToClose by default, no need to write your own code - Super minimal networking with packets - Real-time data replication ]]-- --// logic local DataStore = {} DataStore.Shutdown = false DataStore.Initialized = false DataStore.LoadedPlayers = {} DataStore.FlaggedData = {} local Configuration = {} Configuration.Timeout = 3 Configuration.Key = nil Configuration.Cached = {} Configuration.Removal = {} Configuration.Files = {} Configuration.Internal = { ['Set'] = 'SetData'; ['Get'] = 'GetData'; ['Load'] = 'LoadData'; ['Save'] = 'SaveData'; ['Spawn'] = 'SpawnData'; ['Watch'] = 'WatchData'; ['Update'] = 'UpdateData'; ['Increment'] = 'IncrementData'; } --// services local Services = setmetatable({}, {__index = function(cache, serviceName) cache[serviceName] = game:GetService(serviceName) return cache[serviceName] end}) --// variables local Player = Services['Players'].LocalPlayer local Modules = script:WaitForChild('Modules') local MsgService = require(Modules:WaitForChild('MsgService')) local Manager = require(Modules:WaitForChild('Manager')) local Methods = require(Modules:WaitForChild('Methods')) local Network = script:WaitForChild('Network') local NetSend = Network.SendData local NetRetrieve = Network.RetrieveData local IsStudio = Services['RunService']:IsStudio() local IsServer = Services['RunService']:IsServer() local IsClient = Services['RunService']:IsClient() local TaskTime = -1 -- set no delay on the task manager local API_Time = 6 -- the time it takes for api calls --// functions local function Send(...) local data = {...} if IsServer then if typeof(data[1]) == 'Instance' and data[1]:IsA('Player') then -- to player local plr = data[1] local topic = data[2] table.remove(data,table.find(data,plr)) table.remove(data,table.find(data,topic)) NetSend:FireClient(plr,topic,table.unpack(data)) return true end local topic = data[1] table.remove(data,table.find(data,topic)) NetSend:FireAllClients(topic,table.unpack(data)) return true end local topic = data[1] table.remove(data,table.find(data,topic)) NetSend:FireServer(topic,table.unpack(data)) return true end local function Retrieve(...) local data = {...} if IsServer then if typeof(data[1]) == 'Instance' and data[1]:IsA('Player') then -- to player local results = nil local plr = data[1] local topic = data[2] table.remove(data,table.find(data,plr)) table.remove(data,table.find(data,topic)) local success,err = pcall(function() results = NetRetrieve:InvokeClient(plr,topic,table.unpack(data)) end) if success then return results end return false end return false end local topic = data[1] table.remove(data,table.find(data,topic)) local results = NetSend:InvokeServer(topic,table.unpack(data)) return results end local function GetPlayer(userID) local plr = nil local success,err = pcall(function() plr = Services['Players']:GetPlayerByUserId(userID) end) if not success then return false end return plr end --[[ Variations of call: :SetData(key,table) :SetData(key,table,sync) ]]-- function DataStore:SetData(...) local data = {...} local key = data[1] local value = data[2] local sync = data[3] or false assert(typeof(key) == 'string',"[DICE DATASTORE]: Key 'string' expected, got '".. typeof(key) .."'") assert(typeof(value) == 'table',"[DICE DATASTORE]: Data 'table' or 'dictionary' expected, got '".. typeof(key) .."'") Manager.wrap(function() if Configuration.Files[key] ~= nil then if Configuration.Files[key]['Event'] then Configuration.Files[key]['Event']:Disconnect() end if Configuration.Files[key]['Task'] then Configuration.Files[key]['Task']:Disconnect() end Configuration.Files[key] = nil end value['___PlayingCards'] = false Methods.SetDefault(key,value) Configuration.Files[key] = { ['Default'] = value; ['Cache'] = {}; ['Tasks'] = {}; ['Event'] = nil; ['Sync'] = sync; } if sync and not Configuration.Key then Configuration.Key = key end if sync and IsServer then local function SendCache(plr) while not DataStore.LoadedPlayers[plr.UserId] do Manager.wait() end Send(plr, Configuration.Internal.Set, key, Configuration.Files[key], sync) end Configuration.Files[key]['Event'] = Services['Players'].PlayerAdded:Connect(function(plr) SendCache(plr) end) for index,plr in pairs(Services['Players']:GetPlayers()) do SendCache(plr) end elseif IsClient then DataStore.Initialized = true end end) end --[[ Variations of call: :SetRemoval(table) :SetRemoval(key,table) ]]-- function DataStore:SetRemoval(...) local data = {...} local key = data[1] local value = data[2] Manager.wrap(function() if typeof(key) == 'table' then while Configuration.Key == nil do Manager.wait() end value = key key = Configuration.Key end Configuration.Removal[key] = value end) end --[[ Variations of call: :GetData() :GetData(value) :GetData(index) :GetData(index,value) :GetData(key,index) :GetData(key,index,value) ]]-- function DataStore:GetData(...) local data = {...} local key = data[1] local index = data[2] local value = data[3] local plr = nil local task = nil local control = {} control.__Return = nil control.__Update = function() if IsClient then if tonumber(index) ~= Player.UserId and Configuration.Key == key and plr then local get = Retrieve(plr, Configuration.Internal.Get, key, index, value) control.__Return = get return end end if value == nil then control.__Return = Configuration.Files[key]['Cache'][index] return elseif value ~= nil then control.__Return = Configuration.Files[key]['Cache'][index][value] return end warn("[DICE DATASTORE]: Could not find data, key '",key,"' and index '",index,"' and '",value,"'") control.__Return = false return end plr = GetPlayer(key) if not plr then plr = GetPlayer(index) end while Configuration.Key == nil do Manager.wait() end if not key and not index and not value and IsClient then key = Configuration.Key index = Player.UserId value = nil elseif key ~= nil and not index and not value and IsClient then value = key index = Player.UserId key = Configuration.Key elseif tonumber(key) and key ~= Configuration.Key and not index and not value then value = nil index = tonumber(key) key = Configuration.Key if not Player then while DataStore.LoadedPlayers[index] == nil do Manager.wait() end elseif Player.UserId == tonumber(key) then while DataStore.LoadedPlayers[index] == nil do Manager.wait() end end elseif tonumber(key) and key ~= Configuration.Key and index ~= nil and not value then value = index index = tonumber(key) key = Configuration.Key if not Player then while DataStore.LoadedPlayers[index] == nil do Manager.wait() end elseif Player.UserId == tonumber(key) then while DataStore.LoadedPlayers[index] == nil do Manager.wait() end end end assert(typeof(key) == 'string',"[DICE DATASTORE]: Key 'string' expected, got '".. typeof(key) .."'") assert(index ~= nil,"[DICE DATASTORE]: Index expected, got '".. typeof(index) .."'") while Configuration.Files[key] == nil do Manager.wait() end while Configuration.Files[key]['Cache'][index] == nil do Manager.wait() end task = Configuration.Files[key]['Tasks'][index] if not task then Configuration.Files[key]['Tasks'][index] = Manager:Task(TaskTime) task = Configuration.Files[key]['Tasks'][index] end task:Queue(control.__Update) local test = control.__Return ~= nil and true or false return control.__Return,test end --[[ Variations of call: :UpdateData(index,value) :UpdateData(key,index,value) :UpdateData(index,value,change) :UpdateData(key,index,value,change) ]]-- function DataStore:UpdateData(...) local data = {...} local key = data[1] local index = data[2] local value = data[3] local change = data[4] local code = '' local plr = nil local task = nil local control = {} control.__Return = nil control.__Update = function() if typeof(value) == 'table' or value == nil then Configuration.Files[key]['Cache'][index] = value if plr and IsServer then Manager.spawn(function() Send(plr, Configuration.Internal.Update, key, index, value) end) end control.__Return = value local parse = key..':'..index..':{}' Manager:FireKey(parse,value) return elseif value ~= nil then local success,err = pcall(function() Configuration.Files[key]['Cache'][index][value] = change end) if not success then warn('[DICE DATASTORE]: Failed to change, error:',err,debug.traceback()) end if plr and IsServer then Manager.spawn(function() Send(plr, Configuration.Internal.Update, key, index, value, change) end) end control.__Return = change local parse = key..':'..index..':'..value Manager:FireKey(parse,change) return end control.__Return = false return end plr = GetPlayer(key) if not plr then plr = GetPlayer(index) end if tonumber(key) and key ~= Configuration.Key then change = value value = index index = tonumber(key) key = Configuration.Key while DataStore.LoadedPlayers[index] == nil do Manager.wait() end end if typeof(value) ~= 'table' then while Configuration.Files[key]['Cache'][index] == nil do Manager.wait() end end assert(typeof(key) == 'string',"[DICE DATASTORE]: Key 'string' expected, got '".. typeof(key) .."'") assert(index ~= nil,"[DICE DATASTORE]: Index expected, got '".. typeof(index) .."'") while Configuration.Files[key] == nil do Manager.wait() end task = Configuration.Files[key]['Tasks'][index] if not task then Configuration.Files[key]['Tasks'][index] = Manager:Task(TaskTime) task = Configuration.Files[key]['Tasks'][index] end task:Queue(control.__Update) local test = control.__Return ~= nil and true or false return control.__Return,test end --[[ Variations of call: :IncrementData(index,value,increment) :IncrementData(key,index,value,increment) ]]-- function DataStore:IncrementData(...) local data = {...} local key = data[1] local index = data[2] local value = data[3] local change = data[4] while Configuration.Key == nil do Manager.wait() end if tonumber(key) and key ~= Configuration.Key and index ~= nil then change = value value = index index = tonumber(key) key = Configuration.Key while DataStore.LoadedPlayers[index] == nil do Manager.wait() end end local current = DataStore:GetData(key,index,value) if current and tonumber(change) then current = current + tonumber(change) return DataStore:UpdateData(key,index,value,current) end return false end --[[ Variations of call: :WatchData(function) -- client :WatchData(value,function) -- client :WatchData(index,value,function) -- shared :WatchData(key,index,value,function) -- shared ]]-- function DataStore:WatchData(...) local data = {...} local key = data[1] local index = data[2] local value = data[3] local func = data[4] while not Configuration.Key do Manager.wait() end if key ~= nil and index == nil and value == nil and func == nil and IsClient then func = key value = '{}' index = Player.UserId key = Configuration.Key elseif key ~= nil and index ~= nil and value == nil and func == nil then func = index value = key key = Configuration.Key index = Player.UserId elseif tonumber(key) and index ~= nil and value == nil and func == nil then func = index value = '{}' index = tonumber(key) key = Configuration.Key elseif tonumber(key) and index ~= nil and value ~= nil and func == nil then func = value value = index index = tonumber(key) key = Configuration.Key end assert(key ~= nil) assert(index ~= nil) assert(value ~= nil) assert(typeof(func) == 'function') local parse = key..':'..index..':'..value Manager:ConnectKey(parse,func) end --[[ Variations of call: :LoadData(index,autosave) :LoadData(key,index,autosave) Returns: true/false, data ]]-- function DataStore:LoadData(...) if IsClient then return end local data = {...} local key = data[1] local index = data[2] local auto = data[3] or false local plr = nil while Configuration.Key == nil do Manager.wait() end if tonumber(key) and key ~= Configuration.Key then pcall(function() plr = Services['Players']:GetPlayerByUserId(key) end) auto = index index = key key = Configuration.Key else assert(typeof(key) == 'string',"[DICE DATASTORE]: Key 'string' expected, got '".. typeof(key) .."'") assert(index ~= nil,"[DICE DATASTORE]: Index expected, got '".. typeof(index) .."'") end if not Configuration.Files[key] then warn("[DICE DATASTORE]: Failed to save data, key expected, got '",typeof(key),"'") return false end local success,results = false,false local function Load() while table.find(DataStore.FlaggedData,index) do Manager.wait() end table.insert(DataStore.FlaggedData,index) results,success = Methods:Load(key,index) Configuration.Files[key]['Cache'][index] = results if plr then Manager.wrap(function() DataStore:UpdateData(key,index,results) end) end DataStore:CalculateSize(key,index,'Loaded data') table.remove(DataStore.FlaggedData,table.find(DataStore.FlaggedData,index)) Manager.spawn(function() if auto then while Configuration.Files[key]['Cache'][index] do Manager.wait() Manager.wait(300) DataStore:SaveData(key,index) end end end) return success end local task = Configuration.Files[key]['Tasks'][index] if not task then task = Manager:Task(TaskTime) Configuration.Files[key]['Tasks'][index] = task end task:Queue(Load) Configuration.Files[key]['Cache'][index] = results return success end --[[ Variations of call: :SaveData(index,remove) :SaveData(key,index,remove) Returns: true or false ]]-- function DataStore:SaveData(...) if IsClient then return end local data = {...} local key = data[1] local index = data[2] local remove = data[3] or false local flag = true if DataStore.Shutdown and remove then return end if tonumber(key) and key ~= Configuration.Key then remove = index index = key key = Configuration.Key flag = false end if flag then assert(typeof(key) == 'string',"[DICE DATASTORE]: Key 'string' expected, got '".. typeof(key) .."'") assert(index ~= nil,"[DICE DATASTORE]: Index expected, got '".. typeof(index) .."'") end if DataStore.Shutdown then remove = true end if not Configuration.Files[key] then warn("[DICE DATASTORE]: Failed to save data, key expected, got '",typeof(key),"'") return false end local results = false local function Save() while table.find(DataStore.FlaggedData,index) do Manager.wait() end table.insert(DataStore.FlaggedData,index) local value = Configuration.Files[key]['Cache'][index] if value == nil then return end Manager.spawn(function() if remove then value['___PlayingCards'] = false if Configuration.Files[key]['Tasks'][index] ~= nil then if Configuration.Files[key]['Tasks'][index]:Enabled() then Configuration.Files[key]['Tasks'][index]:Disconnect() Configuration.Files[key]['Tasks'][index] = nil end end if Configuration.Files[key]['Cache'][index] ~= nil then Configuration.Files[key]['Cache'][index] = nil end end end) if remove then for index,stat in pairs(Configuration.Removal[key]) do value[stat] = Configuration.Files[key]['Default'][stat] end end results = Methods:Save(key,index,value) if not DataStore.Shutdown then DataStore:CalculateSize(key,index,'Saved data') end table.remove(DataStore.FlaggedData,table.find(DataStore.FlaggedData,index)) return results end while table.find(DataStore.FlaggedData,index) do Manager.wait() end local task = Configuration.Files[key]['Tasks'][index] if task then pcall(function() task:Queue(Save) end) return results end return false end --[[ Variations of call: :ClearData(index,remove) :ClearData(key,index,remove) Returns: true or false ]]-- function DataStore:ClearData(...) if IsClient then return end local data = {...} local key = data[1] local index = data[2] local flag = true if tonumber(key) and key ~= Configuration.Key then index = key key = Configuration.Key flag = false end if flag then assert(typeof(key) == 'string',"[DICE DATASTORE]: Key 'string' expected, got '".. typeof(key) .."'") assert(index ~= nil,"[DICE DATASTORE]: Index expected, got '".. typeof(index) .."'") end if not Configuration.Files[key] then warn("[DICE DATASTORE]: Failed to save data, key expected, got '",typeof(key),"'") return false end local results = false local function Clear() Manager.spawn(function() if Configuration.Files[key]['Tasks'][index] ~= nil then Configuration.Files[key]['Tasks'][index]:Disconnect() Configuration.Files[key]['Tasks'][index] = nil end end) Configuration.Files[key]['Cache'][index] = {} results = Methods:Clear(key,index) DataStore:CalculateSize(key,index,'Cleared data') Configuration.Files[key]['Cache'][index] = nil return results end return Clear() end --[[ Variations of call: :RemoveData(key,index) ]]-- function DataStore:RemoveData(...) if IsClient then return end local data = {...} local key = data[1] local index = data[2] if tonumber(key) and key ~= Configuration.Key then index = tonumber(key) key = Configuration.Key end DataStore:ClearData(key,index) table.insert(DataStore.FlaggedData,index) local findPlayer; do local success,err = pcall(function() findPlayer = Services['Players']:GetPlayerByUserId(index) end) if findPlayer then findPlayer:Kick('\nCleared Data') end end Manager.wait(API_Time) table.remove(DataStore.FlaggedData,table.find(DataStore.FlaggedData,index)) end --[[ Variations of call: :CalculateSize(index[,optional text]) :CalculateSize(key,index[,optional text]) Returns: success state ]]-- function DataStore:CalculateSize(...) local data = {...} local key = data[1] local index = data[2] local suffix = data[3] if tonumber(key) and key ~= Configuration.Key then suffix = index index = tonumber(key) key = Configuration.Key end if suffix then suffix = '| '.. suffix else suffix = '' end if Configuration.Files[key] then local value = Configuration.Files[key]['Cache'][index] or {} if value then local getPlrName local success,err = pcall(function() getPlrName = Services['Players']:GetNameFromUserIdAsync(index) end) if success then print('[DICE DATASTORE]:',getPlrName..' ('..index..')','|','File size:',#Services['HttpService']:JSONEncode(value)..' bytes',suffix) return true end print('[DICE DATASTORE]:',key..'['..index..']','|','File size:',#Services['HttpService']:JSONEncode(value)..' bytes',suffix) return true else print('[DICE DATASTORE]:',key,'|','File size:',#Services['HttpService']:JSONEncode(Configuration.Files[key]['Cache'])..' bytes',suffix) return true end end return false end --// initialize Manager.wrap(function() if not DataStore.Initialized then DataStore.Initialized = true Manager.spawn(function() local currentClock = os.clock() while not _G.YieldForDeck and os.clock() - currentClock < 1 do Manager.wait() end if not _G.YieldForDeck then script.Parent = Services['ReplicatedStorage'] end end) end if IsServer then game:BindToClose(function() DataStore.Shutdown = true print('[DICE DATASTORE]: Shutting down and saving player data') local ShutdownTask = Manager:Task(TaskTime) for index,content in pairs(Configuration.Files[Configuration.Key]['Cache']) do ShutdownTask:Queue(Manager.wrap(function() local results = DataStore:SaveData(Configuration.Key,index,false) if IsStudio then DataStore:CalculateSize(Configuration.Key,index,'Shutdown: Saved data') end end)) end ShutdownTask:Wait() Manager.wait(1) end) NetRetrieve.OnServerInvoke = function(plr,topic,...) local data = {...} if topic == Configuration.Internal.Get then return DataStore:GetData(table.unpack(data)) end end NetSend.OnServerEvent:Connect(function(plr,topic,...) local data = {...} if topic == Configuration.Internal.Spawn then DataStore.LoadedPlayers[plr.UserId] = true end end) elseif IsClient then NetRetrieve.OnClientInvoke = function(topic,...) local data = {...} if topic == Configuration.Internal.Update then DataStore:UpdateData(table.unpack(data)) return true end end NetSend.OnClientEvent:Connect(function(topic,...) local data = {...} if topic == Configuration.Internal.Set then DataStore:SetData(table.unpack(data)) elseif topic == Configuration.Internal.Update then DataStore:UpdateData(table.unpack(data)) end end) end if IsClient then DataStore.LoadedPlayers[Player.UserId] = true Send(Configuration.Internal.Spawn) end end) return DataStore
local Tunnel = module("vrp", "lib/Tunnel") local Proxy = module("vrp", "lib/Proxy") vRP = Proxy.getInterface("vRP") vRPclient = Tunnel.getInterface("vRP","vRP_chests") --- Config -- list of static chests -- {access, x, y, z, name-optional} -- access = can be user_id, user_permission or user_group. Set it to "none" to give to all players access to the chest. -- name = if you have multiple chests with same access you need to set different name, or the chests with same access will containt same items. local chests = {} chests = { {"Royal Reapers", -808.29809570313,175.27745056152,76.740791320801, "Royal Reapers"}, {"Hells Angels", 977.18389892578,-104.06502532959,74.845169067383, "Hells Angels"}, {"Lost Ledelse", -574.53649902344,293.49392700195,79.176689147949, "The Lost MC Ledelse Kiste"}, -- -576.94177246094,286.802734375,79.176574707031 {"Lost Medlem", -571.56488037109,285.34844970703,79.176689147949, "The Lost MC Kiste"}, -- -576.94177246094,286.802734375,79.176574707031 {"Black Army", 330.05987548828,-2014.3515625,22.394878387451, "Black Army"}, {"Politi-Job", 478.48883056641,-984.86486816406,24.914697647095, "Politi-Job"} } -- I've put some random locations just for test, change them. ---# local function create_pleschest(owner_access, x, y, z, player, name) local namex = name or "chest" local chest_enter = function(player, area) local user_id = vRP.getUserId({player}) if user_id ~= nil then if owner_access == "none" or user_id == tonumber(owner_access) or vRP.hasGroup({user_id, owner_access}) or vRP.hasPermission({user_id, owner_access}) then vRP.openChest({player, "static:"..owner_access..":"..namex, 500, nil, nil, nil}) end end end local chest_leave = function(player,area) vRP.closeMenu({player}) end local nid = "vRP:static-"..namex..":"..owner_access vRPclient.setNamedMarker(player,{nid,x,y,z-1,0.7,0.7,0.5,0,148,255,125,150}) vRP.setArea({player,nid,x,y,z,1,1.5,chest_enter,chest_leave}) end AddEventHandler("vRP:playerSpawn",function(user_id,source,first_spawn) if first_spawn then for k, v in pairs(chests) do create_pleschest(v[1], v[2], v[3], v[4], source, v[5]) --TriggerClientEvent('chatMessage', -1, "Chest created: "..v[1]..", "..v[2]..", "..v[3]..", "..v[4]..", "..v[5]..".") -- debuging. end end end)
-- Unityから呼ばれるのはmain.luaのみとする。このファイルを起点にゲームスクリプトを記述する。 --[[local function foo(initPosX, speed) for i = 1, 5 do local enemy = GenerateEnemy(EnemyID.SmallBlueFairy, initPosX, ScreenTop.y, speed, -math.pi / 2, 8) for i = 1, 15 do coroutine.yield() end end for i = 1, 180 do coroutine.yield() end end]] local stg = require('stg') local playerScript = require('reimu') local function TestBenchmark() stg:Wait(70) local redEnemy = stg:CreateEnemy(EnemyID.SmallRedFairy, ScreenLeft.x + (ScreenRight.x - ScreenLeft.x) * 1.0 / 3, ScreenTop.y, 1.5, -math.pi / 2, 40) local blueEnemy = stg:CreateEnemy(EnemyID.SmallBlueFairy, ScreenLeft.x + (ScreenRight.x - ScreenLeft.x) * 2.0 / 3, ScreenTop.y, 1.5, -math.pi / 2, 40) stg:Wait(90) redEnemy.Speed = 0 blueEnemy.Speed = 0 stg:Wait(5) local ways = 21 local maxIteration = 60 local diffAngle = 2 * math.pi / ways for i = 1, maxIteration do local playerDirFromRed = stg:CalcAngleBetween(redEnemy, playerScript:GetPlayer()) local playerDirFromBlue = stg:CalcAngleBetween(blueEnemy, playerScript:GetPlayer()) for j = -(ways - 1) / 2, (ways - 1) / 2 do stg:CreateBullet(BulletID.SmallRedBullet, redEnemy, 2, playerDirFromRed + j * diffAngle) stg:CreateBullet(BulletID.SmallBlueBullet, blueEnemy, 2, playerDirFromBlue + j * diffAngle) end if redEnemy:IsEnabled() or blueEnemy:IsEnabled() then --GenerateEffect(EffectID.EnemyShotSound) end stg:Wait(1) end stg:Wait(300) end function Main() math.randomseed(os.time()) StartCoroutine(playerScript.Run) TestBenchmark() --local stage1 = require('stage1') --stage1:Start() --[[ChangeScene(SceneID.StageClear) local stage2 = require('scripts.stage2') stage2:Start() ChangeScene(SceneID.AllClear)]] --[[Lua側でコルーチンを実行する場合。 local co = coroutine.create(foo) repeat coroutine.resume(co, (ScreenCenter.x - ScreenLeft.x) / 2, 2) coroutine.yield() -- 1フレーム毎に呼び出し元に返す。 until coroutine.status(co) == 'dead' collectgarbage()]] end
local lg = love.graphics local cpath = tostring(...):gsub("%.[^%.]+$", "") local class = require(cpath .. ".utils").class local Cart = class() function Cart:init(runtime) self._runtime = runtime lg.setDefaultFilter("nearest", "nearest") self._backCanvas = lg.newCanvas(2048, 2048) self._clear = nil self._tileSetCache = {} self._tileSets = { nextIndex = 0, } end function Cart:tileDraw(tilesetID, sourceCellX, sourceCellY, destCellX, destCellY, spanCellX, spanCellY, alpha, colour, offsetX, offsetY, flipX, flipY) local ts = self:findTileset(tilesetID) if not ts then error("Need a tileset ID!", 2) end if not sourceCellX or not sourceCellY then error("Invalid source coordinates ("..sourceCellX..", "..sourceCellY..")", 2) end if not destCellX or not destCellY then error("Invalid destination coordinates ("..destCellX..", "..destCellY..")", 2) end local dx = sourceCellX * 8 local dy = sourceCellY * 8 local isx = spanCellX or 1 local isy = spanCellY or 1 local ox = offsetX or 0 local oy = offsetY or 0 local fx = flipX and -1 or 1 local fy = flipY and -1 or 1 if flipX then destCellX = destCellX + isx end if flipY then destCellY = destCellY + isy end local w = isx * 8 local h = isy * 8 local quad = ts.quad if quad then quad:setViewport(dx, dy, w, h, ts.imageWidth, ts.imageHeight) else quad = lg.newQuad(dx, dy, w, h, ts.imageWidth, ts.imageHeight) ts.quad = quad end local alpha = alpha or 1 local col = colour or {1, 1, 1} lg.setCanvas(self._backCanvas) lg.setColor(col[1], col[2], col[3], alpha) lg.draw(ts.image, quad, destCellX * 8 + ox, destCellY * 8 + oy, 0, fx, fy) lg.setCanvas() lg.setBlendMode('alpha') end function Cart:tileClear(destCellX, destCellY, spanCellX, spanCellY, alpha, colour, offsetX, offsetY) local ox = offsetX or 0 local oy = offsetY or 0 local sx = spanCellX or 1 local sy = spanCellY or 1 local alpha = alpha or 0 local col = colour or {0, 0, 0} lg.setCanvas(self._backCanvas) lg.setBlendMode('replace') lg.setColor(col[1], col[2], col[3], alpha) lg.rectangle('fill', destCellX * 8 + ox, destCellY * 8 + oy, sx * 8, sy * 8) lg.setCanvas() lg.setBlendMode('alpha') end function Cart:createTileset(img) local ts = self._tileSets local iw, ih = img:getDimensions() ts.nextIndex = ts.nextIndex + 1 n = "tset" .. ts.nextIndex t = { key = n, image = img, imageWidth = iw, imageHeight = ih, lineCells = math.floor(iw / 8), } ts[n] = t return n, t end function Cart:loadTileset(fileName) if not fileName then error("Need a fileName to load!", 2) end if not love.filesystem.getInfo(fileName) then error("Missing file: " .. fileName, 2) end local tw = 8 local th = tw local tsc = self._tileSetCache local t = tsc[fileName] local n = nil if t then n = t.key else local img = lg.newImage(fileName) n, t = self:createTileset(img, tw, th) t.fileName = fileName tsc[fileName] = t end return n end function Cart:listTilesets() local o = {} for k, v in pairs(self._tileSets) do if k:sub(1, 4) == "tset" then o[#o+1] = k end end return o end function Cart:removeTileset(n) local t = self:findTileset(n) if t then self._tileSetCache[t.fileName] = nil self._tileSets[n] = nil end end function Cart:findTileset(n) if not n then return nil end if type(n) ~= 'string' or #n < 5 or n:sub(1, 4) ~= "tset" then print("Warning! " .. n .. " may not be a tileset ID.") end return self._tileSets[n] end function Cart:clearScreen(...) lg.setCanvas(self._runtime.bgCvs) self._runtime.drawBegin() local values = {pcall(lg.clear, ...)} self._runtime.drawEnd() lg.setCanvas() local ok = values[1] if not ok then error(values[2], 2) end end function Cart:drawMap(sourceCellX, sourceCellY, spanCellX, spanCellY, offsetX, offsetY, rotationAngle, scale, alpha, colour) if not sourceCellX or not sourceCellY then error("Invalid coordinates (" .. tostring(sourceCellX) .. ", " .. tostring(sourceCellY) .. ")!", 2) end local bg = self._backCanvas local q = bg.quad or lg.newQuad(0, 0, 8, 8, bg:getDimensions()) local ss = self._runtime.screenSize / 8 local cw = spanCellX or ss local ch = spanCellY or ss local ox = offsetX or 0 local oy = offsetY or 0 local scale = scale or 1 local alpha = alpha or 1 local col = colour or {1, 1, 1} q:setViewport(sourceCellX * 8, sourceCellY * 8, cw * 8, ch * 8) lg.setCanvas(self._runtime.bgCvs) self._runtime.drawBegin() lg.push() lg.translate(ox, oy) if rotationAngle then lg.translate(cw*4*scale, ch*4*scale) lg.rotate(rotationAngle) lg.translate(-cw*4*scale, -ch*4*scale) end lg.scale(scale, scale) lg.setColor(col[1], col[2], col[3], alpha) lg.draw(bg, q) lg.pop() self._runtime.drawEnd() lg.setCanvas() end function Cart:print(x, y, text, c) if not x or type(x) ~= 'number' or not y or type(y) ~= 'number' then error("Invalid printXY coords ("..tostring(x)..", "..tostring(y)..")", 2) end if not text then error("Need something to print for printXY", 2) end local col = c or {1, 1, 1} lg.setCanvas(self._runtime.bgCvs) lg.setColor(col[1], col[2], col[3]) lg.print(text, x, y) lg.setCanvas() end function Cart:getViewportInfo() return self._runtime.getViewportInfo() end function Cart:button(btn) return self._runtime.input:getButton(btn) end function Cart:buttonPressed(btn) return self._runtime.input:getButton(btn, true) end function Cart:getDivMod(a, b) if b == 0 then return end local c = a / b local d = math.floor(c) return d, (c - d) * b end function Cart:tileDump(fileName) local cdata = self._backCanvas:newImageData() cdata:encode("png", fileName) end return Cart
ITEM.name = "Административные документы" ITEM.desc = "" ITEM.price = 6942 ITEM.exRender = false ITEM.weight = 0.12 ITEM.model = "models/kek1ch/notes_document_case_3.mdl" ITEM.width = 2 ITEM.height = 1 ITEM.iconCam = { pos = Vector(202.4426574707, 169.8695526123, 123.72142791748), ang = Angle(25, 220, 0), fov = 5.1592356687898 }
LoveUI.TextView=LoveUI.Control:new(); function LoveUI.TextView:init(frame, contentSize, ...) LoveUI.Control.init(self, frame, ...) self.value="" self.enabled=true self.opaque=true; self.tabAccessible=true self.contentView=LoveUI.View:new(LoveUI.Rect:new(0,0,contentSize:get())); self.contentView.opaque=true self.contentView.display=function(view) love.graphics.setFont(LoveUI.DEFAULT_FONT) love.graphics.setColor(unpack(LoveUI.defaultTextColor)); LoveUI.graphics.drawf(self.value, 10, 20, contentSize.width-30); end self.scrollView=LoveUI.ScrollView:new(LoveUI.Rect:new(0,0,frame.size:get()), contentSize); self.scrollView.contentView:addSubview(self.contentView) self.scrollView.nextResponder=self.nextResponder self.nextResponder=self.scrollView self:addSubview(self.scrollView) --bind scrollviews values to this one. LoveUI.bind(self.scrollView, "enabled", self, "enabled", function (isenabled) return isenabled end , function(isenabled, value) return nil; end); LoveUI.bind(self.scrollView, "opaque", self, "opaque", function (isopaque) return isopaque end , function(isopaque, value) return nil; end); return self; end function LoveUI.TextView:keyDown(theEvent) if theEvent.keyCode==love.key_up then self.scrollView:addOffset(LoveUI.Point:new(0, 10)) return end if theEvent.keyCode==love.key_down then self.scrollView:addOffset(LoveUI.Point:new(0, -10)) return end if theEvent.keyCode==love.key_right then self.scrollView:addOffset(LoveUI.Point:new(-10, 0)) return end if theEvent.keyCode==love.key_left then self.scrollView:addOffset(LoveUI.Point:new(10, 0)) return end LoveUI.View.keyDown(self, theEvent); end function LoveUI.TextView:setFrame(aFrame) self.frame=aFrame; self.scrollView:setFrame(LoveUI.Rect:new(0,0,aFrame.size:get())); self:calculateScissor(); end function LoveUI.TextView:setSize(aSize) self.frame.size=aSize:copy(); self.scrollView:setFrame(LoveUI.Rect:new(0,0,aSize:get())); self:calculateScissor(); end
local slider = {} slider.clickedLast = false slider.leftLast = false slider.rightLast = false slider.leftCooldown2Active = false slider.rightCooldown2Active = false slider.leftCooldown1 = 0 slider.rightCooldown1 = 0 slider.leftCooldown2 = 0 slider.rightCooldown2 = 0 slider.wheelDelta = 0 function slider.new(x, y, size, thickness, direction, setCallback) return setmetatable({ x = x, y = y, width = size, height = thickness, c1 = {1.0, 1.0, 1.0}, c2 = {0.8, 0.8, 0.8, 0.6}, c3 = {0.8, 0.8, 0.8}, c4 = {0.4, 0.4, 0.4}, val = 0, grabbed = false, mouseOffset = 0, lastWheel = 0, callback=setCallback }, {__index=slider}) end function slider.updateMouseKeys(delta, k) slider.leftCooldown1 = slider.leftCooldown1 - delta slider.rightCooldown1 = slider.rightCooldown1 - delta slider.leftCooldown2 = slider.leftCooldown2 - delta slider.rightCooldown2 = slider.rightCooldown2 - delta if love.mouse.isDown(1, 2, 3) then slider.clickedLast = true else slider.clickedLast = false end if k.sliderLeft.held and not slider.leftLast then slider.leftCooldown1 = 0.5 end if k.sliderRight.held and not slider.rightLast then slider.rightCooldown1 = 0.5 end slider.leftLast = k.sliderLeft.held slider.rightLast = k.sliderRight.held if not k.sliderLeft.held then slider.leftCooldown2Active = false end if not k.sliderRight.held then slider.rightCooldown2Active = false end if slider.leftLast and slider.leftCooldown1 <= 0 then slider.leftCooldown2Active = true end if slider.rightLast and slider.rightCooldown1 <= 0 then slider.rightCooldown2Active = true end if slider.leftCooldown2Active then if slider.leftCooldown2 <= 0 then slider.leftLast = false slider.leftCooldown2 = 0.1 end else slider.leftCooldown2 = 0.1 end if slider.rightCooldown2Active then if slider.rightCooldown2 <= 0 then slider.rightLast = false slider.rightCooldown2 = 0.1 end else slider.rightCooldown2 = 0.1 end end function slider:update(k) local oldVal = self.val self.val = math.max(math.min(self.val + (slider.wheelDelta - self.lastWheel), 1), 0) self.lastWheel = slider.wheelDelta local mouseX, mouseY = love.mouse.getPosition() if k.action.held then if (not self.grabbed) and mouseX >= self.x+self.val*(self.width-10)-10 and mouseY >= self.y-10 and mouseX <= self.x+self.val*(self.width-10)+10+10 and mouseY <= self.y+self.height+10 then if not slider.clickedLast then self.grabbed = true self.mouseOffset = self.val - math.max(math.min((mouseX - self.x) / self.width, 1), 0) end end if self.grabbed then self.val = math.max(math.min((mouseX - self.x) / self.width + self.mouseOffset, 1), 0) end else self.grabbed = false end if mouseX >= self.x - 10 and mouseY >= self.y - 10 and mouseX <= self.x + self.width + 10 and mouseY <= self.y + self.height + 10 then if k.sliderLeft.held and not slider.leftLast then if not self.grabbed then self.val = math.max(math.min(self.val - 0.05, 1), 0) else self.mouseOffset = self.mouseOffset - 0.05 end end if k.sliderRight.held and not slider.rightLast then if not self.grabbed then self.val = math.max(math.min(self.val + 0.05, 1), 0) else self.mouseOffset = self.mouseOffset + 0.05 end end end if self.callback and self.val ~= oldVal then self:callback(self.val) end end function slider:draw() love.graphics.setLineWidth(3) love.graphics.setColor(self.c1) love.graphics.rectangle("fill", self.x, self.y, self.width, self.height) if self.grabbed then love.graphics.setColor(self.c4) else love.graphics.setColor(self.c3) end love.graphics.rectangle("fill", self.x+self.val*(self.width-10), self.y, 10, self.height) love.graphics.setColor(self.c2) love.graphics.rectangle("line", self.x-1, self.y-1, self.width+2, self.height+2) love.graphics.setColor(1, 1, 1) end function love.wheelmoved(x, y) local mouseX, mouseY = love.mouse.getPosition() slider.wheelDelta = slider.wheelDelta - y/20 end return slider
function auriskins.gen_formspec_skins (player) local fs = ainv.formspec_base(player) fs = fs .. ainv.create_tabs() --Labels fs = fs .. [[ label[7,0;Available Skins] ]] local playerdata = auriskins.get_skin_data(player) if playerdata.preview then fs = fs .. "image[3.5,1;3,6;" .. playerdata.preview .. "]" else fs = fs .. "image[2.6,2.6;5,2.5;" .. playerdata.skin .. "]" end fs = fs .. "textlist[7,0.5;4,7;skinlist;" for i = 1, auriskins.skinsloaded do if auriskins.skindata[i].name then fs = fs .. auriskins.skindata[i].name .. " (" .. auriskins.skindata[i].author .. ")" else fs = fs .. "#ff9999Skin " .. i .. " (No Metadata)" end if i ~= auriskins.skinsloaded then fs = fs .. "," end end fs = fs .. "]" .. ainv.formspec_base_end(player) return fs end
----------------------------------- -- Area: Nashmau -- NPC: Abihaal -- Standard Info NPC ----------------------------------- function onTrade(player, npc, trade) end function onTrigger(player, npc) player:startEvent(221, player:getGil(), 100) end function onEventUpdate(player, csid, option) end function onEventFinish(player, csid, option) if (csid == 221 and option == 333) then player:delGil(100) end end
--- === cp.ui.Element === --- --- A support class for `hs.axuielement` management. --- --- See: --- * [Button](cp.ui.Button.md) --- * [CheckBox](cp.rx.CheckBox.md) --- * [MenuButton](cp.rx.MenuButton.md) local require = require --local log = require "hs.logger".new("Element") local drawing = require "hs.drawing" local axutils = require "cp.ui.axutils" local Builder = require "cp.ui.Builder" local go = require "cp.rx.go" local is = require "cp.is" local lazy = require "cp.lazy" local prop = require "cp.prop" local class = require "middleclass" local cache = axutils.cache local Do, Given, If = go.Do, go.Given, go.If local isFunction = is.fn local isCallable = is.callable local pack, unpack = table.pack, table.unpack local Element = class("cp.ui.Element"):include(lazy) --- cp.ui.Element:defineBuilder(...) -> cp.ui.Element --- Method --- Defines a new [Builder](cp.ui.Builder.md) class on this `Element` with the specified additional argument names. --- --- Parameters: --- * ... - The names for the methods which will collect extra arguments to pass to the `Element` constructor. --- --- Returns: --- * The same `Element` class instance. --- --- Notes: --- * The order of the argument names here is the order in which they will be passed to the `Element` constructor, no matter what --- order they are called on the `Builder` itself. --- * Once defined, the class can be accessed via the static `<Element Name>.Builder` of the `Element` subclass. --- * For example, if you have a `cp.ui.Element` subclass named `MyElement`, with an extra `alpha` and `beta` constructor argument, you can do this: --- ```lua --- -- The class definition --- local MyElement = Element:subclass("cp.ui.MyElement"):defineBuilder("withAlpha", "withBeta") --- -- The constructor --- function MyElement.Builder:initialize(parent, uiFinder, alpha, beta) --- Element.initialize(self, parent, uiFinder) --- self.alpha = alpha --- self.beta = beta --- end --- -- Create a callable `MyClass.Builder` instance --- local myElementBuilder = MyElement:withAlpha(1):withBeta(2) --- -- alternately, same result: --- local myElementBuilder = MyElement:withBeta(2):withAlpha(1) --- -- Alternately, same result: --- local myElementBuilder = MyElement.Builder():withAlpha(1):withBeta(2) --- -- Create an instance of `MyClass`: --- local myElement = myElementBuilder(parent, uiFinder) --- ``` function Element.static:defineBuilder(...) local args = pack(...) local thisType = self local builderClass = Builder:subclass(self.name .. ".Builder") self.Builder = builderClass function builderClass.initialize(builderType, elementType) elementType = elementType or thisType Builder.initialize(builderType, elementType, unpack(args)) end for _, arg in ipairs(args) do self[arg] = function(elementType, ...) local instance = builderClass(elementType) return instance[arg](instance, ...) end end return self end --- cp.ui.Element:isTypeOf(thing) -> boolean --- Function --- Checks if the `thing` is an `Element`. If called on subclasses, it will check --- if the `thing` is an instance of the subclass. --- --- Parameters: --- * `thing` - The thing to check --- --- Returns: --- * `true` if the thing is a `Element` instance. --- --- Notes: --- * This is a type method, not an instance method or a type function. It is called with `:` on the type itself, --- not an instance. For example `Element:isTypeOf(value)` function Element.static:isTypeOf(thing) return type(thing) == "table" and thing.isInstanceOf ~= nil and thing:isInstanceOf(self) end --- cp.ui.Element.matches(element) -> boolean --- Function --- Matches to any valid `hs.axuielement`. Sub-types should provide their own `matches` method. --- --- Parameters: --- * The element to check --- --- Returns: --- * `true` if the element is a valid instance of an `hs.axuielement`. function Element.static.matches(element) return element ~= nil and isFunction(element.isValid) and element:isValid() end -- Defaults to describing the class by it's class name function Element:__tostring() return self.class.name end --- cp.ui.Element(parent, uiFinder) -> cp.ui.Element --- Constructor --- Creates a new `Element` with the specified `parent` and `uiFinder`. --- The `uiFinder` may be either a `function` that returns an `axuielement`, or a [cp.prop](cp.prop.md). --- --- Parameters: --- * parent - The parent Element (may be `nil`) --- * uiFinder - The `function` or `prop` that actually provides the current `axuielement` instance. --- --- Returns: --- * The new `Element` instance. function Element:initialize(parent, uiFinder) self._parent = parent local UI if prop.is(uiFinder) then UI = uiFinder elseif isCallable(uiFinder) then UI = prop(function() return cache(self, "_ui", function() local ui = uiFinder() return (self.class.matches == nil or self.class.matches(ui)) and ui or nil end, self.class.matches) end) else error "Expected either a cp.prop, function, or callable table for uiFinder." end self.UI = UI UI:bind(self, "UI") if prop.is(parent.UI) then UI:monitor(parent.UI) end end --- cp.ui.Element.value <cp.prop: anything; live?> --- Field --- The 'AXValue' of the element. function Element.lazy.prop:value() return axutils.prop(self.UI, "AXValue", true) end --- cp.ui.Element.textValue <cp.prop: string; read-only; live?> --- Field --- The 'AXValue' of the element, if it is a `string`. function Element.lazy.prop:textValue() return self.value:mutate(function(original) local value = original() return type(value) == "string" and value or nil end) end --- cp.ui.Element.valueIs(value) -> boolean --- Method --- Checks if the current value of this element is the provided value. --- --- Parameters: --- * value - The value to compare to. --- --- Returns: --- * `true` if the current [#value] is equal to the provided `value`. function Element:valueIs(value) return self:value() == value end --- cp.ui.Element.title <cp.prop: string; read-only, live?> --- Field --- The 'AXTitle' of the element. function Element.lazy.prop:title() return axutils.prop(self.UI, "AXTitle") end --- cp.ui.Element.isShowing <cp.prop: boolean; read-only; live?> --- Field --- If `true`, the `Element` is showing on screen. function Element.lazy.prop:isShowing() local parent = self:parent() local isShowing = self.UI:ISNOT(nil):AND(parent.isShowing) if prop.is(parent.isShowing) then isShowing:monitor(parent.isShowing) end return isShowing end --- cp.ui.Element:doShow() -> cp.rx.go.Statement --- Method --- Returns a `Statement` that will ensure the Element is showing. --- By default, will ask the `parent` to show, if the `parent` is available. --- --- Parameters: --- * None --- --- Returns: --- * A Statement function Element.lazy.method:doShow() return If(function() return self:parent() end) :Then(function(parent) return parent.doShow and parent:doShow() end) :Otherwise(false) end --- cp.ui.Element:show() -> self --- Method --- Shows the Element. --- --- Parameters: --- * None --- --- Returns: --- * self function Element:show() local parent = self:parent() if parent then parent:show() end return self end --- cp.ui.Element:focus() -> self, boolean --- Method --- Attempt to set the focus on the element. --- --- Parameters: --- * None --- --- Returns: --- * self, boolean - the boolean indicates if the focus was set. function Element:focus() return self:setAttributeValue("AXFocused", true) end --- cp.ui.Element:doFocus() -> cp.rx.go.Statement --- Method --- A `Statement` that attempts to set the focus on the element. --- --- Parameters: --- * None --- --- Returns: --- * The `Statement`. function Element.lazy.method:doFocus() return self:doSetAttributeValue("AXFocused", true) :Label("cp.ui.Element:doFocus()") end --- cp.ui.Element:attributeValue(id) -> anything, true | nil, false --- Method --- Attempts to retrieve the specified `AX` attribute value, if the `UI` is available. --- --- Parameters: --- * id - The `AX` attribute to retrieve. --- --- Returns: --- * The current value for the attribute, or `nil` if the `UI` is not available, followed by `true` if the `UI` is present and was called. function Element:attributeValue(id) local ui = self:UI() if ui then return ui:attributeValue(id), true end return nil, false end --- cp.ui.Element:setAttributeValue(id, value) -> self, boolean --- Method --- If the `UI` is available, set the named `AX` attribute to the `value`. --- --- Parameters: --- * id - The `AX` id to set. --- * value - The new value. --- --- Returns: --- * The `Element` instance, then `true` if the UI is available and the value was set, otherwise false. function Element:setAttributeValue(id, value) local ui = self:UI() if ui then ui:setAttributeValue(id, value) return self, true end return self, false end --- cp.ui.Element:performAction(id) -> boolean --- Method --- Attempts to perform the specified `AX` action, if the `UI` is available. --- --- Parameters: --- * id - The `AX` action to perform. --- --- Returns: --- * `true` if the `UI` is available and the action was performed, otherwise `false`. function Element:performAction(id) local ui = self:UI() if ui then ui:performAction(id) return self, true end return self, false end --- cp.ui.Element:doSetAttributeValue(id, value) -> cp.rx.go.Statement --- Method --- Returns a `Statement` which will attempt to update the specified `AX` attribute to the new `value`. --- --- Parameters: --- * id - The `string` for the AX action to perform. --- * value - The new value to set. --- --- Returns: --- * The `Statement` which will perform the action and resolve to `true` if the UI is available and set, otherwise `false`. function Element:doSetAttributeValue(id, value) return If(self.UI) :Then(function(ui) ui:setAttributeValue(id, value) return true end) :Otherwise(false) :Label("cp.ui.Element:doSetAttributeValue('" .. id .. "', value)") end --- cp.ui.Element:doPerformAction(id) -> cp.rx.go.Statement --- Method --- Returns a `Statement` which will attempt to perform the action with the specified id (eg. "AXCancel") --- --- Parameters: --- * id - The `string` for the AX action to perform. --- --- Returns: --- * The `Statement` which will perform the action. function Element:doPerformAction(id) return If(self.UI) :Then(function(ui) ui:performAction(id) return true end) :Otherwise(false) :Label("cp.ui.Element:doPerformAction('" .. id .. "')") end --- cp.ui.Element.role <cp.prop: string; read-only> --- Field --- Returns the `AX` role name for the element. function Element.lazy.prop:role() return axutils.prop(self.UI, "AXRole") end --- cp.ui.Element.subrole <cp.prop: string; read-only> --- Field --- Returns the `AX` subrole name for the element. function Element.lazy.prop:subrole() return axutils.prop(self.UI, "AXSubrole") end --- cp.ui.Element.identifier <cp.prop: string; read-only> --- Field --- Returns the `AX` identifier for the element. function Element.lazy.prop:identifier() return axutils.prop(self.UI, "AXIdentifier") end --- cp.ui.Element.isEnabled <cp.prop: boolean; read-only> --- Field --- Returns `true` if the `Element` is visible and enabled. function Element.lazy.prop:isEnabled() return axutils.prop(self.UI, "AXEnabled") end --- cp.ui.Element.frame <cp.prop: table; read-only; live?> --- Field --- Returns the table containing the `x`, `y`, `w`, and `h` values for the `Element` frame, or `nil` if not available. function Element.lazy.prop:frame() return axutils.prop(self.UI, "AXFrame") end --- cp.ui.Element.isFocused <cp.prop: boolean; read-only?; live?> --- Field --- Returns `true` if the `AXFocused` attribute is `true`. Not always a reliable way to determine focus however. function Element.lazy.prop:isFocused() return axutils.prop(self.UI, "AXFocused", true) end --- cp.ui.Element.position <cp.prop: table; read-only; live?> --- Field --- Returns the table containing the `x` and `y` values for the `Element` frame, or `nil` if not available. -- TODO: ensure no other 'position' props are getting created elsewhere... -- function Element.lazy.prop:position() -- return axutils.prop(self.UI, "AXPosition") -- end --- cp.ui.Element.size <cp.prop: table; read-only; live?> --- Field --- Returns the table containing the `w` and `h` values for the `Element` frame, or `nil` if not available. -- TODO: ensure no other 'size' props are getting created elswehere... -- function Element.lazy.prop:size() -- return axutils.prop(self.UI, "AXSize") -- end --- cp.ui.Element:parent() -> parent --- Method --- Returns the parent object. --- --- Parameters: --- * None --- --- Returns: --- * parent function Element:parent() return self._parent end --- cp.ui.Element:app() -> App --- Method --- Returns the app instance. --- --- Parameters: --- * None --- --- Returns: --- * App function Element:app() local parent = self:parent() return parent and parent:app() end --- cp.ui.Element:snapshot([path]) -> hs.image | nil --- Method --- Takes a snapshot of the button in its current state as a PNG and returns it. --- If the `path` is provided, the image will be saved at the specified location. --- --- Parameters: --- * path - (optional) The path to save the file. Should include the extension (should be `.png`). --- --- Return: --- * The `hs.image` that was created. function Element:snapshot(path) local ui = self:UI() if ui then return axutils.snapshot(ui, path) end return nil end local RED_COLOR = { red = 1, green = 0, blue = 0, alpha = 0.75 } --- cp.ui.Element:doHighlight([color], [duration]) -> cp.rx.go.Statement --- Method --- Returns a `Statement` which will attempt to highlight the `Element` with the specified `color` and `duration`. --- --- Parameters: --- * color - The `hs.drawing` color to use. (defaults to red) --- * duration - The `number` of seconds to highlight for. (defaults to `3` seconds) --- --- Returns: --- * The `Statement` which will perform the action. function Element:doHighlight(color, duration) if type(color) == "number" then duration = color color = nil end color = color or RED_COLOR duration = duration or 3 --log.df("doHighlight: color=%s, duration=%d", hs.inspect(color), duration) local highlight return If(self.frame) :Then(function(frame) return Do(function() --log.df("doHighlight: frame: %s", hs.inspect(frame)) highlight = drawing.rectangle(frame) highlight:setStrokeColor(color) highlight:setFill(false) highlight:setStrokeWidth(3) highlight:show() return true end) :ThenDelay(duration * 1000) end) :Otherwise(false) :Finally(function() --log.df("doHighlight: Finally...") if highlight then --log.df("doHighlight: Finally: removing highlight...") highlight:delete() highlight = nil end end) :Label("cp.ui.Element:doHighlight(color, duration)") end --- cp.ui.Element:highlight([color], [duration]) --- Method --- Highlights the `Element` with the specified `color` and `duration`. --- --- Parameters: --- * color - The `hs.drawing` color to use. (defaults to red) --- * duration - The `number` of seconds to highlight for. (defaults to `3` seconds) --- --- Returns: --- * Nothing function Element:highlight(color, duration) self:doHighlight(color, duration):Now() end --- cp.ui.Element:saveLayout() -> table --- Method --- Returns a `table` containing the current configuration details for this Element (or subclass). --- --- Parameters: --- * None --- --- Returns: --- * None --- --- Notes: --- * When subclassing, the overriding `saveLayout` method should call the parent's saveLayout method, --- then add values to it, like so: --- ``` --- function MyElement:saveLayout() --- local layout = Element.saveLayout(self) --- layout.myConfig = self.myConfig --- return layout --- end --- ``` function Element.saveLayout(_) return {} end --- cp.ui.Element:loadLayout(layout) -> nil --- Method --- When called, the Element (or subclass) will attempt to load the layout based on the parameters --- provided by the `layout` table. This table should generally be generated via the [#saveLayout] method. --- --- Parameters: --- * layout - a `table` of parameters that will be used to layout the element. --- --- Returns: --- * None --- --- Notes: --- * When subclassing, the overriding `loadLayout` method should call the parent's `loadLayout` method, --- then process any custom values from it, like so: --- ``` --- function MyElement:loadLayout(layout) --- Element.loadLayout(self, layout) --- self.myConfig = layout.myConfig --- end --- ``` function Element.loadLayout(_, _) end function Element.lazy.method:doSaveLayout() return Do(function() return self:saveLayout() end) :Label("cp.ui.Element:doSaveLayout()") end --- cp.ui.Element:doLayout(layout) -> cp.rx.go.Statement --- Method --- Returns a [Statement](cp.rx.go.Statement.md) which will attempt to load the layout based on the parameters --- provided by the `layout` table. This table should generally be generated via the [#saveLayout] method. --- --- Parameters: --- * layout - a `table` of parameters that will be used to layout the element. --- --- Returns: --- * The [Statement](cp.rx.go.Statement.md) to execute. --- --- Notes: --- * By default, to enable backwards-compatibility, this method will simply call the [#loadLayout]. Override it to provide more optimal asynchonous behaviour if required. --- * When subclassing, the overriding `doLayout` method should call the parent class's `doLayout` method, --- then process any custom values from it, like so: --- ```lua --- function MyElement:doLayout(layout) --- layout = layout or {} --- return Do(Element.doLayout(self, layout)) --- :Then(function() --- self.myConfig = layout.myConfig --- end) --- :Label("MyElement:doLayout") --- end --- ``` function Element:doLayout(layout) return Given(layout) :Then(function(_layout) self:loadLayout(_layout) return true end) :Label("cp.ui.Element:doLayout(layout)") end function Element:doStoreLayout(id) return Given(self:doSaveLayout()) :Then(function(layout) local layouts = self.__storedLayouts or {} layouts[id] = layout self.__storedLayouts = layouts return layout end) :Label("cp.ui.Element:doStoreLayout(id)") end function Element:doForgetLayout(id) return Do(function() local layouts = self.__storedLayouts if layouts then layouts[id] = nil end for _ in pairs(layouts) do -- luacheck: ignore return -- there are still layouts stored. end self.__storedLayouts = nil end) :Label("cp.ui.Element:doForgetLayout(id)") end function Element:doRecallLayout(id, preserve) local doForget = preserve and nil or self:doForgetLayout(id) return Given(function() local layouts = self.__storedLayouts return layouts and layouts[id] end) :Then(function(layout) local doLayout = self:doLayout(layout) if doForget then doLayout = Do(doLayout):Then(doForget) end return doLayout end) :Label("cp.ui.Element:doRecallLayout(id, preserve)") end -- This just returns the same element when it is called as a method. (eg. `fcp.viewer == fcp.viewer`) -- This is a bridge while we migrate to using `lazy.value` instead of `lazy.method` (or methods) -- in the FCPX API. function Element:__call() return self end return Element
----------------------------------- -- Area: Mhaura -- NPC: Blandine -- Start Quest: The Sand Charmz -- !pos 23 -7 41 249 ----------------------------------- require("scripts/globals/settings") require("scripts/globals/quests") ----------------------------------- function onTrade(player, npc, trade) end function onTrigger(player, npc) local X = player:getXPos(); Z = player:getZPos() local TheSandCharm = player:getQuestStatus(OTHER_AREAS_LOG, tpz.quest.id.otherAreas.THE_SAND_CHARM) if (Z <= 29 or Z >= 38 or X <= 16 or X >= 32) then if (player:getFameLevel(WINDURST) >= 4 and TheSandCharm == QUEST_AVAILABLE) then player:startEvent(125) -- Start quest "The Sand Charm" elseif (player:getCharVar("theSandCharmVar") == 2) then player:startEvent(124) -- During quest "The Sand Charm" - 2nd dialog elseif (TheSandCharm == QUEST_COMPLETED and player:getCharVar("SmallDialogByBlandine") == 1) then player:startEvent(128) -- Thanks dialog of Bladine after "The Sand Charm" elseif (TheSandCharm == QUEST_COMPLETED) then player:startEvent(129) -- New standard dialog after "The Sand Charm" else player:startEvent(122) -- Standard dialog end end end function onEventUpdate(player, csid, option) end function onEventFinish(player, csid, option) if (csid == 125) then player:addQuest(OTHER_AREAS_LOG, tpz.quest.id.otherAreas.THE_SAND_CHARM) player:setCharVar("theSandCharmVar", 1) elseif (csid == 124) then player:setCharVar("theSandCharmVar", 3) elseif (csid == 128) then player:setCharVar("SmallDialogByBlandine", 0) end end
if FirstLoad then SelectionShapes, SelectionShapesByHash = {}, {} end --calcs the dist between each point in the array of points, --and then sticks the total dist up to that point in the z member --clones the first point and sets it as last with the appropriate dist for less checks c side. function PreparePointsArrayForAnimTrajectoryInput(points) local totalDist = 0 points[#points + 1] = point(points[1]:x(), points[1]:y(), 0) for i = 2, #points do totalDist = totalDist + points[i-1]:Dist2D(points[i]) points[i] = points[i]:SetZ(totalDist) end points[1] = points[1]:SetZ(0) --force 0 or it will be max int end --Reload the selection shapes for all entities function RebuildSelectionShapes() local surface_mask = EntitySurfaces["Selection"] local all_entities = GetAllEntities() for entity,_ in pairs(all_entities) do if HasAnySurfaces(entity, surface_mask) then local all_states = GetStates(entity) for _,state in ipairs(all_states) do local state_idx = GetStateIdx(state) local shape, hash = GetSelectionShape(entity, state_idx) if shape and #shape > 1 then local referenced_entity = SelectionShapesByHash[hash] if referenced_entity ~= nil then SelectionShapes[entity] = SelectionShapes[referenced_entity] else --Shapes are encoded as strings, before storage PreparePointsArrayForAnimTrajectoryInput(shape) local encoded_shape = EncodePointsToString(shape) SelectionShapes[entity] = encoded_shape SelectionShapesByHash[hash] = entity end break end end end end end OnMsg.EntitiesLoaded = RebuildSelectionShapes GlobalVar("building_selection_particle", false) --selobj is a global var, so it seems appropriate for this to be as well. local particle_name_override = { --[entity] = { p1, p2 } Excavator = { "Selection_Buildings_Double_01", "Selection_Buildings_Double_02", "Selection_Buildings_Base" }, Default = { "Selection_Buildings", "Selection_Buildings_Base" }, } CObject.GetSelectionAngle = CObject.GetAngle function AddSelectionParticlesToObj(obj) building_selection_particle = building_selection_particle or {} local s_i = #building_selection_particle + 1 local e = obj:GetEntity() local s = GetEntityOutlineShape(e) local s_s = SelectionShapes[e] local x, y, z = obj:GetVisualPosXYZ() local a = obj:GetSelectionAngle() if #s == 1 then table.insert(building_selection_particle, PlaceParticles("Selection_Buildings_Single")) a = a + 30*60 -- fix wrong particle form (Iva made me do it) elseif s_s then local names = particle_name_override[e] or particle_name_override.Default local p for _, name in ipairs(names) do p = PlaceParticles(name) p:SetPolylineAsString(s_s) table.insert(building_selection_particle, p) end end for i = s_i, #building_selection_particle do local p = building_selection_particle[i] p:SetPos(x, y, z) p:SetAngle(a) end end --This object will be selectable and will show selection particles around it DefineClass.SelectableWithParticles = { __parents = { "CObject" }, enum_flags = { efSelectable = true }, } function OnMsg.SelectedObjChange(obj, prev) if building_selection_particle then for _, obj in ipairs(building_selection_particle) do DoneObject(obj) end building_selection_particle = false end if (IsKindOf(obj, "SupplyGridSwitch") and obj.is_switch) or (IsKindOf(obj, "BreakableSupplyGridElement") and obj.auto_connect) or (IsKindOf(obj, "LifeSupportGridElement") and obj.pillar) or (IsKindOf(obj, "Building") and not obj.disable_selection and obj.use_shape_selection) or (IsKindOf(obj, "SelectableWithParticles")) then AddSelectionParticlesToObj(obj) if IsKindOf(obj, "ConstructionSite") and IsKindOf(obj.building_class_proto, "Tunnel") or IsKindOf(obj, "Tunnel") then AddSelectionParticlesToObj(obj.linked_obj) end if IsKindOf(obj, "Passage") then --passage is in first element pos, so sel last local el = obj:GetEndElement() AddSelectionParticlesToObj(el) end end end
local _ = require 'moses' local BN, parent = nn.BatchNormalization, nn.Module local empty = _.clone(parent.dpnn_mediumEmpty) table.insert(empty, 'buffer') table.insert(empty, 'buffer2') table.insert(empty, 'centered') table.insert(empty, 'std') table.insert(empty, 'normalized') table.insert(empty, 'output') table.insert(empty, 'gradInput') BN.dpnn_mediumEmpty = empty -- for sharedClone local params = _.clone(parent.dpnn_parameters) table.insert(params, 'running_mean') table.insert(params, 'running_var') BN.dpnn_parameters = params
solution "string_c" include "../../build" project "string_c" def_c() files {"*.c","*.h"}
local Graphics = { dx = 0, dy = 0, sx = 1, sy = 1, scissorX = 0, scissorY = 0, scissorWidth = 0, scissorHeight = 0, } local function transform(x, y) local newX = x * Graphics.sx + Graphics.dx local newY = y * Graphics.sy + Graphics.dy return newX, newY end function Graphics.setScissor(x, y, width, height) if x == nil then love.graphics.setScissor(Graphics.scissorX, Graphics.scissorY, Graphics.scissorWidth, Graphics.scissorHeight) else local newX, newY = transform(x, y) local newWidth = width * Graphics.sx local newHeight = height * Graphics.sy love.graphics.setScissor(newX, newY, newWidth, newHeight) end end function Graphics.setViewportScissor(x, y, width, height) Graphics.scissorX, Graphics.scissorY = transform(x, y) Graphics.scissorWidth = width * Graphics.sx Graphics.scissorHeight = height * Graphics.sy love.graphics.setScissor(Graphics.scissorX, Graphics.scissorY, Graphics.scissorWidth, Graphics.scissorHeight) end function Graphics.translate(dx, dy) Graphics.dx = dx Graphics.dy = dy love.graphics.translate(dx, dy) end function Graphics.scale(sx, sy) Graphics.sx = sx Graphics.sy = sy love.graphics.scale(sx, sy) end Graphics.push = love.graphics.push Graphics.pop = love.graphics.pop Graphics.newImage = love.graphics.newImage Graphics.draw = love.graphics.draw Graphics.getDimensions = love.graphics.getDimensions Graphics.setColor = love.graphics.setColor Graphics.rectangle = love.graphics.rectangle Graphics.setBackgroundColor = love.graphics.setBackgroundColor Graphics.newQuad = love.graphics.newQuad Graphics.newFont = love.graphics.newFont Graphics.newText = love.graphics.newText Graphics.printf = love.graphics.printf Graphics.print = love.graphics.print Graphics.setFont = love.graphics.setFont return Graphics
--RBI Baseball script --Written by adelikat --Shows stats and information on screen and can even change a batter or pitcher's hand local PitchingScreenAddr = 0x001A; local PitchingScreen; local p1PitchHealthAddr = 0x060D; local p1PitchHealth; local p2PitchHealthAddr = 0x061D; local p2PitchHealth; local p1OutsAddr = 0x0665; local p1Outs; local pitchtypeAddr = 0x0112; local pitchtype; local P1currHitterPowerAddr = 0x062B --2 byte local P1currSpeedAddr = 0x062D local P1currContactAddr = 0x062A local P2currHitterPowerAddr = 0x063B --2 byte local P2currSpeedAddr = 0x063D local P2currContactAddr = 0x063A local topinningAddr = 0x0115 --Extra Ram map notes --0627 = P1 Batter Lefy or Righty (even or odd) --0628 = P1 Bat average 150 + this address --0629 = P1 # of Home Runs --0638 = P2 Bat average 2 150 + this address --0639 = P2 # of Home Runs --0637 = P2 Batter Lefy or Righty (even or odd) --060x = P1 pitcher, 061x = P2 pitcher --0607 = --Right digit = P1 Pitcher Lefty or Right (even or odd) --Left digit = P1 Pitcher drop rating --0609 = P1 Sinker ball speed --060A = P1 Regular ball Speed --060B = P1 Fastball Speed --060C = P1 Pitcher Curve rating left digit is curve left, right is curve right --0114 = Current Inning --0115 = 10 if bottom of inning, 0 if on top, controls which player can control the batter --0728 & 0279 - In charge of inning music --TODO --A hotkeys for boosting/lowering current pitcher (p1 or 2) health --fix pitcher L/R switching to not kill the left digit (drop rating) in the process --Do integer division on curve rating --Outs display is wrong --Music on/off toggle console.writeline("RBI Baseball script"); console.writeline("Written by adelikat"); console.writeline("Description: Shows stats and information on screen and can even change a batter or pitcher's hand"); console.writeline("\nHotkeys: "); console.writeline("Toggle Hand of player 2: \nH/J"); console.writeline("Toggle Hand of player 1: \nK/L"); function P1BoostHitter() mainmemory.write_u16_le(0x062B, mainmemory.read_u16_le(0x062B) + 128); end function P1DropHitter() mainmemory.write_u16_le(0x062B, mainmemory.read_u16_le(0x062B) - 128); end function P2BoostHitter() mainmemory.write_u16_le(0x063B, mainmemory.read_u16_le(0x063B) + 128); end function P2DropHitter() mainmemory.write_u16_le(0x063B, mainmemory.read_u16_le(0x063B) - 128); end function SwitchP1LHand() if (inningtb == 0x10) then mainmemory.write_u8(0x0607, 0) end if (inningtb == 0) then mainmemory.write_u8(0x0627, 0) end end function SwitchP1RHand() if (inningtb == 0x10) then mainmemory.write_u8(0x0607, 1) end if (inningtb == 0) then mainmemory.write_u8(0x0627, 1) end end function SwitchP2LHand() if (inningtb == 0x0) then mainmemory.write_u8(0x0617, 0) end if (inningtb == 0x10) then mainmemory.write_u8(0x0637, 0) end end function SwitchP2RHand() if (inningtb == 0x0) then mainmemory.write_u8(0x0617, 1) end if (inningtb == 0x10) then mainmemory.write_u8(0x0637, 1) end end h_window = forms.newform(345, 205, "RBI Lua"); label_p1switch = forms.label(h_window, "Player 1", 10, 5); label_p1switch = forms.label(h_window, "Switch Player Hand", 10, 35); h_toggleP1L = forms.button(h_window, "Left", SwitchP1LHand, 10, 60, 50, 23); h_toggleP1R = forms.button(h_window, "Right", SwitchP1RHand, 70, 60, 50, 23); label_p1switch = forms.label(h_window, "Batter Power", 10, 100); h_toggleP1R = forms.button(h_window, "More!", P1BoostHitter, 10, 125, 50, 23); h_toggleP1R = forms.button(h_window, "Less", P1DropHitter, 70, 125, 50, 23); label_p2switch = forms.label(h_window, "Player 2", 160, 5); label_p2switch = forms.label(h_window, "Switch Player Hand", 160, 35); h_toggleP2L = forms.button(h_window, "Left", SwitchP2LHand, 160, 60, 50, 23); h_toggleP2R = forms.button(h_window, "Right", SwitchP2RHand, 160, 60, 50, 23); label_p2switch = forms.label(h_window, "Batter Power", 160, 100); h_toggleP2R = forms.button(h_window, "More!", P2BoostHitter, 160, 125, 50, 23); h_toggleP2R = forms.button(h_window, "Less", P2DropHitter, 220, 125, 50, 23); while true do mainmemory.write_u8(0x0726, 0) --Turn of inning music mainmemory.write_u8(0x0727, 0) mainmemory.write_u8(0x0728, 0) mainmemory.write_u8(0x0729, 0) inningtb = mainmemory.read_u8(topinningAddr); i = input.get(); --Switch P1 batter hands if (i.K == true) then SwitchP1LHand() end if (i.L == true) then SwitchP1RHand(); end --Switch P2 batter hands if (i.H == true) then SwitchP2LHand(); end if (i.J == true) then SwitchP2RHand(); end PitchingScreen = mainmemory.read_u8(PitchingScreenAddr); ------------------------------------------------------- if (PitchingScreen == 0x003E) then pitchtype = mainmemory.read_u8(pitchtypeAddr); --What the pitcher will pitch if (pitchtype == 0) then gui.text(0,0,"Sinker!!", null, null, "bottomright"); end if (pitchtype == 2) then gui.text(0,0, "Fast Ball", null, null, "bottomright") end if (pitchtype == 1) then gui.text(0,0,"Regular Pitch", null, null, "bottomright") end --Top of Inning if (inningtb == 0) then gui.text(0,0, "Health " .. mainmemory.read_u8(0x061D), null, null, "topright") gui.text(0,12,"Drop " .. mainmemory.read_u8(0x0617) % 16, null, null, "topright") gui.text(0,24,"CurveL " .. mainmemory.read_u8(0x061C) / 16, null, null, "topright") gui.text(0,36,"CurveR " .. mainmemory.read_u8(0x061C) % 16, null, null, "topright") gui.text(0,48,"Fast SP " .. mainmemory.read_u8(0x061B), null, null, "topright") gui.text(0,60,"Reg SP " .. mainmemory.read_u8(0x061A), null, null, "topright") gui.text(0,72,"Sink SP " .. mainmemory.read_u8(0x0619), null, null, "topright") P1currPower = mainmemory.read_u8(P1currHitterPowerAddr) + (mainmemory.read_u8(P1currHitterPowerAddr+1) * 256); gui.text(0,108, "Power: " .. P1currPower, null, null, "topright"); P1currSpeed = mainmemory.read_u8(P1currSpeedAddr); gui.text(0,120, "Speed: " .. P1currSpeed, null, null, "topright"); P1currCt = mainmemory.read_u8(P1currContactAddr); gui.text(0,132, "Contact: " .. P1currCt, null, null, "topright"); end --Bottom of Inning if (inningtb == 0x10) then gui.text(0,0,"Health " .. mainmemory.read_u8(0x060D), null, null, "topright") gui.text(0,12,"Drop " .. mainmemory.read_u8(0x0607) % 16, null, null, "topright") gui.text(0,24,"CurveL " .. mainmemory.read_u8(0x060C) / 16, null, null, "topright") gui.text(0,36,"CurveR " .. mainmemory.read_u8(0x060C) % 16, null, null, "topright") gui.text(0,48,"Fast SP " .. mainmemory.read_u8(0x060B), null, null, "topright") gui.text(0,60,"Reg SP " .. mainmemory.read_u8(0x060A), null, null, "topright") gui.text(0,72,"Sink SP " .. mainmemory.read_u8(0x0609), null, null, "topright") P2currPower = mainmemory.read_u8(P2currHitterPowerAddr) + (mainmemory.read_u8(P2currHitterPowerAddr+1) * 256); gui.text(0,108, "Power: " .. P2currPower, null, null, "topright"); P2currSpeed = mainmemory.read_u8(P2currSpeedAddr); gui.text(0,120, "Speed: " .. P2currSpeed, null, null, "topright"); P2currCt = mainmemory.read_u8(P2currContactAddr); gui.text(0,132, "Contact: " .. P2currCt, null, null, "topright"); end end ------------------------------------------------------- if (PitchingScreen == 0x0036) then p1Outs = mainmemory.read_u8(p1OutsAddr); gui.text(0,0, "Outs " .. p1Outs, null, null, "topright"); end ------------------------------------------------------- emu.frameadvance() end
---@tag telescope.previewers ---@brief [[ --- Provides a Previewer table that has to be implemented by each previewer. --- To achieve this, this module also provides two wrappers that abstract most --- of the work and make it really easy create new previewers. --- - `previewers.new_termopen_previewer` --- - `previewers.new_buffer_previewer` --- --- Furthermore, there are a collection of previewers already defined which --- can be used for every picker, as long as the entries of the picker provide --- the necessary fields. The more important once are --- - `previewers.cat` --- - `previewers.vimgrep` --- - `previewers.qflist` --- - `previewers.vim_buffer_cat` --- - `previewers.vim_buffer_vimgrep` --- - `previewers.vim_buffer_qflist` --- --- Previewers can be disabled for any builtin or custom picker by doing --- :Telescope find_files previewer=false ---@brief ]] local Previewer = require "telescope.previewers.previewer" local term_previewer = require "telescope.previewers.term_previewer" local buffer_previewer = require "telescope.previewers.buffer_previewer" local previewers = {} --- This is the base table all previewers have to implement. It's possible to --- write a wrapper for this because most previewers need to have the same --- keys set. --- Examples of wrappers are: --- - `new_buffer_previewer` --- - `new_termopen_previewer` --- --- To create a new table do following: --- - `local new_previewer = Previewer:new(opts)` --- --- What `:new` expects is listed below --- --- The interface provides following set of functions. All of them, besides --- `new`, will be handled by telescope pickers. --- - `:new(opts)` --- - `:preview(entry, status)` --- - `:teardown()` --- - `:send_input(input)` --- - `:scroll_fn(direction)` --- --- `Previewer:new()` expects a table as input with following keys: --- - `setup` function(self): Will be called the first time preview will be --- called. --- - `teardown` function(self): Will be called on cleanup. --- - `preview_fn` function(self, entry, status): Will be called each time --- a new entry was selected. --- - `title` function(self): Will return the static title of the previewer. --- - `dynamic_title` function(self, entry): Will return the dynamic title of --- the previewer. Will only be called --- when config value dynamic_preview_title --- is true. --- - `send_input` function(self, input): This is meant for --- `termopen_previewer` and it can be --- used to send input to the terminal --- application, like less. --- - `scroll_fn` function(self, direction): Used to make scrolling work. previewers.Previewer = Previewer --- A shorthand for creating a new Previewer. --- The provided table will be forwarded to `Previewer:new(...)` previewers.new = function(...) return Previewer:new(...) end --- Is a wrapper around Previewer and helps with creating a new --- `termopen_previewer`. --- --- It requires you to specify one table entry `get_command(entry, status)`. --- This `get_command` function has to return the terminal command that will be --- executed for each entry. Example: --- <pre> --- get_command = function(entry, status) --- return { 'bat', entry.path } --- end --- </pre> --- --- Additionally you can define: --- - `title` a static title for example "File Preview" --- - `dyn_title(self, entry)` a dynamic title function which gets called --- when config value `dynamic_preview_title = true` --- --- It's an easy way to get your first previewer going and it integrates well --- with `bat` and `less`. Providing out of the box scrolling if the command --- uses less. --- --- Furthermore, it will forward all `config.set_env` environment variables to --- that terminal process. --- --- While this interface is a good start, it was replaced with the way more --- flexible `buffer_previewer` and is now deprecated. previewers.new_termopen_previewer = term_previewer.new_termopen_previewer --- Provides a `termopen_previewer` which has the ability to display files. --- It will always show the top of the file and has support for --- `bat`(prioritized) and `cat`. Each entry has to provide either the field --- `path` or `filename` in order to make this previewer work. --- --- The preferred way of using this previewer is like this --- `require('telescope.config').values.cat_previewer` --- This will respect user configuration and will use `buffer_previewers` in --- case it's configured that way. previewers.cat = term_previewer.cat --- Provides a `termopen_previewer` which has the ability to display files at --- the provided line. It has support for `bat`(prioritized) and `cat`. --- Each entry has to provide either the field `path` or `filename` and --- a `lnum` field in order to make this previewer work. --- --- The preferred way of using this previewer is like this --- `require('telescope.config').values.grep_previewer` --- This will respect user configuration and will use `buffer_previewers` in --- case it's configured that way. previewers.vimgrep = term_previewer.vimgrep --- Provides a `termopen_previewer` which has the ability to display files at --- the provided line or range. It has support for `bat`(prioritized) and --- `cat`. Each entry has to provide either the field `path` or `filename`, --- `lnum` and a `start` and `finish` range in order to make this previewer --- work. --- --- The preferred way of using this previewer is like this --- `require('telescope.config').values.qflist_previewer` --- This will respect user configuration and will use buffer previewers in --- case it's configured that way. previewers.qflist = term_previewer.qflist --- An interface to instantiate a new `buffer_previewer`. --- That means that the content actually lives inside a vim buffer which --- enables us more control over the actual content. For example, we can --- use `vim.fn.search` to jump to a specific line or reuse buffers/already --- opened files more easily. --- This interface is more complex than `termopen_previewer` but offers more --- flexibility over your content. --- It was designed to display files but was extended to also display the --- output of terminal commands. --- --- In the following options, state table and general tips are mentioned to --- make your experience with this previewer more seamless. --- --- --- options: --- - `define_preview = function(self, entry, status)` (required) --- Is called for each selected entry, after each selection_move --- (up or down) and is meant to handle things like reading file, --- jump to line or attach a highlighter. --- - `setup = function(self)` (optional) --- Is called once at the beginning, before the preview for the first --- entry is displayed. You can return a table of vars that will be --- available in `self.state` in each `define_preview` call. --- - `teardown = function(self)` (optional) --- Will be called at the end, when the picker is being closed and is --- meant to cleanup everything that was allocated by the previewer. --- The `buffer_previewer` will automatically cleanup all created buffers. --- So you only need to handle things that were introduced by you. --- - `keep_last_buf = true` (optional) --- Will not delete the last selected buffer. This would allow you to --- reuse that buffer in the select action. For example, that buffer can --- be opened in a new split, rather than recreating that buffer in --- an action. To access the last buffer number: --- `require('telescope.state').get_global_key("last_preview_bufnr")` --- - `get_buffer_by_name = function(self, entry)` --- Allows you to set a unique name for each buffer. This is used for --- caching purpose. `self.state.bufname` will be nil if the entry was --- never loaded or the unique name when it was loaded once. For example, --- useful if you have one file but multiple entries. This happens for grep --- and lsp builtins. So to make the cache work only load content if --- `self.state.bufname ~= entry.your_unique_key` --- - `title` a static title for example "File Preview" --- - `dyn_title(self, entry)` a dynamic title function which gets called --- when config value `dynamic_preview_title = true` --- --- `self.state` table: --- - `self.state.bufnr` --- Is the current buffer number, in which you have to write the loaded --- content. --- Don't create a buffer yourself, otherwise it's not managed by the --- buffer_previewer interface and you will probably be better off --- writing your own interface. --- - self.state.winid --- Current window id. Useful if you want to set the cursor to a provided --- line number. --- - self.state.bufname --- Will return the current buffer name, if `get_buffer_by_name` is --- defined. nil will be returned if the entry was never loaded or when --- `get_buffer_by_name` is not set. --- --- Tips: --- - If you want to display content of a terminal job, use: --- `require('telescope.previewers.utils').job_maker(cmd, bufnr, opts)` --- - `cmd` table: for example { 'git', 'diff', entry.value } --- - `bufnr` number: in which the content will be written --- - `opts` table: with following keys --- - `bufname` string: used for cache --- - `value` string: used for cache --- - `mode` string: either "insert" or "append". "insert" is default --- - `env` table: define environment variables. Example: --- - `{ ['PAGER'] = '', ['MANWIDTH'] = 50 }` --- - `cwd` string: define current working directory for job --- - `callback` function(bufnr, content): will be called when job --- is done. Content will be nil if job is already loaded. --- So you can do highlighting only the first time the previewer --- is created for that entry. --- Use the returned `bufnr` and not `self.state.bufnr` in callback, --- because state can already be changed at this point in time. --- - If you want to attach a highlighter use: --- - `require('telescope.previewers.utils').highlighter(bufnr, ft)` --- - This will prioritize tree sitter highlighting if available for --- environment and language. --- - `require('telescope.previewers.utils').regex_highlighter(bufnr, ft)` --- - `require('telescope.previewers.utils').ts_highlighter(bufnr, ft)` --- - If you want to use `vim.fn.search` or similar you need to run it in --- that specific buffer context. Do --- <pre> --- vim.api.nvim_buf_call(bufnr, function() --- -- for example `search` and `matchadd` --- end) --- to achieve that. --- </pre> --- - If you want to read a file into the buffer it's best to use --- `buffer_previewer_maker`. But access this function with --- `require('telescope.config').values.buffer_previewer_maker` --- because it can be redefined by users. previewers.new_buffer_previewer = buffer_previewer.new_buffer_previewer --- A universal way of reading a file into a buffer previewer. --- It handles async reading, cache, highlighting, displaying directories --- and provides a callback which can be used, to jump to a line in the buffer. ---@param filepath string: String to the filepath, will be expanded ---@param bufnr number: Where the content will be written ---@param opts table: keys: `use_ft_detect`, `bufname` and `callback` previewers.buffer_previewer_maker = buffer_previewer.file_maker --- A previewer that is used to display a file. It uses the `buffer_previewer` --- interface and won't jump to the line. To integrate this one into your --- own picker make sure that the field `path` or `filename` is set for --- each entry. --- The preferred way of using this previewer is like this --- `require('telescope.config').values.file_previewer` --- This will respect user configuration and will use `termopen_previewer` in --- case it's configured that way. previewers.vim_buffer_cat = buffer_previewer.cat --- A previewer that is used to display a file and jump to the provided line. --- It uses the `buffer_previewer` interface. To integrate this one into your --- own picker make sure that the field `path` or `filename` and `lnum` is set --- in each entry. If the latter is not present, it will default to the first --- line. --- The preferred way of using this previewer is like this --- `require('telescope.config').values.grep_previewer` --- This will respect user configuration and will use `termopen_previewer` in --- case it's configured that way. previewers.vim_buffer_vimgrep = buffer_previewer.vimgrep --- Is the same as `vim_buffer_vimgrep` and only exist for consistency with --- `term_previewers`. --- --- The preferred way of using this previewer is like this --- `require('telescope.config').values.qflist_previewer` --- This will respect user configuration and will use `termopen_previewer` in --- case it's configured that way. previewers.vim_buffer_qflist = buffer_previewer.qflist --- A previewer that shows a log of a branch as graph previewers.git_branch_log = buffer_previewer.git_branch_log --- A previewer that shows a diff of a stash previewers.git_stash_diff = buffer_previewer.git_stash_diff --- A previewer that shows a diff of a commit to a parent commit.<br> --- The run command is `git --no-pager diff SHA^! -- $CURRENT_FILE` --- --- The current file part is optional. So is only uses it with bcommits. previewers.git_commit_diff_to_parent = buffer_previewer.git_commit_diff_to_parent --- A previewer that shows a diff of a commit to head.<br> --- The run command is `git --no-pager diff --cached $SHA -- $CURRENT_FILE` --- --- The current file part is optional. So is only uses it with bcommits. previewers.git_commit_diff_to_head = buffer_previewer.git_commit_diff_to_head --- A previewer that shows a diff of a commit as it was.<br> --- The run command is `git --no-pager show $SHA:$CURRENT_FILE` or `git --no-pager show $SHA` previewers.git_commit_diff_as_was = buffer_previewer.git_commit_diff_as_was --- A previewer that shows the commit message of a diff.<br> --- The run command is `git --no-pager log -n 1 $SHA` previewers.git_commit_message = buffer_previewer.git_commit_message --- A previewer that shows the current diff of a file. Used in git_status.<br> --- The run command is `git --no-pager diff $FILE` previewers.git_file_diff = buffer_previewer.git_file_diff previewers.ctags = buffer_previewer.ctags previewers.builtin = buffer_previewer.builtin previewers.help = buffer_previewer.help previewers.man = buffer_previewer.man previewers.autocommands = buffer_previewer.autocommands previewers.highlights = buffer_previewer.highlights --- A deprecated way of displaying content more easily. Was written at a time, --- where the buffer_previewer interface wasn't present. Nowadays it's easier --- to just use this. We will keep it around for backwards compatibility --- because some extensions use it. --- It doesn't use cache or some other clever tricks. previewers.display_content = buffer_previewer.display_content return previewers
fx_version 'cerulean' games { 'gta5' } author 'MOXHA' client_script 'debug/C_main.js' server_script 'debug/S_main.js'
--需要处理例子特效的ui对象 需要继承该类 比如baseview baseitem UIPartical = UIPartical or BaseClass(UIZDepth) local UIPartical = UIPartical --每个layer的起始值 UIPartical.Start_SortingOrder_list = { ["Scene"] = 0, ["Main"] = 100, ["Dynamic_Main"] = 150, ["UI"] = 200, ["Activity"] = 300, ["Top"] = 400, } --每个layer的当前层数 UIPartical.curr_SortingOrder_list = { ["Scene"] = UIPartical.Start_SortingOrder_list.Scene, ["Main"] = UIPartical.Start_SortingOrder_list.Main, ["Dynamic_Main"] = UIPartical.Start_SortingOrder_list.Dynamic_Main, ["UI"] = UIPartical.Start_SortingOrder_list.UI, ["Activity"] = UIPartical.Start_SortingOrder_list.Activity, ["Top"] = UIPartical.Start_SortingOrder_list.Top, } UIPartical.NextLayerCount = { ["Scene"] = 100, ["Main"] = 200, ["UI"] = 300, ["Activity"] = 400, } --设置渲染特效所在的layer层 UIPartical.RenderingOther_List = { DEFAULT = 0, UI = 5, Blackground = 10, } function UIPartical:__init() self.layer_name = "Main" self.depth_counter = 0 self.partical_list = {} self.callback_list = {} self.lastTime_list = {} self.cache_partical_map = {} self.show_partical_map = {} self.wait_load_effect_trans = {} self.speed = 1 end function UIPartical:__delete() self:ClearAllEffect() self:ClearCacheEffect() end function UIPartical:ClearCacheEffect() for abname,state in pairs(self.cache_partical_map) do lua_resM:ClearObjPool(abname) end self.cache_partical_map = {} self.wait_load_effect_trans = {} self.show_partical_map = {} end function UIPartical:DeleteCurrLayerDepth(layer_name,count) if UIPartical.curr_SortingOrder_list[layer_name] then UIPartical.curr_SortingOrder_list[layer_name] = UIPartical.curr_SortingOrder_list[layer_name] - count end if UIPartical.Start_SortingOrder_list[layer_name] then if self:GetCurrLayerDepth(layer_name) < UIPartical.Start_SortingOrder_list[layer_name] then UIPartical.curr_SortingOrder_list[layer_name] = UIPartical.Start_SortingOrder_list[layer_name] end end end function UIPartical:AddCurrLayerDepth(layer_name,count) if UIPartical.curr_SortingOrder_list[layer_name] then UIPartical.curr_SortingOrder_list[layer_name] = UIPartical.curr_SortingOrder_list[layer_name] + (count or 1) end if UIPartical.NextLayerCount[layer_name] and UIPartical.curr_SortingOrder_list[layer_name] >= UIPartical.NextLayerCount[layer_name] then LogError( self._source .. " want to add " .. layer_name .. " layer count to " .. UIPartical.curr_SortingOrder_list[layer_name] .. ":" .. debug.traceback()) UIPartical.curr_SortingOrder_list[layer_name] = UIPartical.Start_SortingOrder_list[layer_name] + 99 end end function UIPartical:GetCurrLayerDepth(layer_name) return UIPartical.curr_SortingOrder_list[layer_name] end --打开界面的时候 设置UI SortingOrder深度 function UIPartical:SetUIDepth(gameObject) if self.layer_name and self.layer_name ~= "Main" then if self:GetCurrLayerDepth(self.layer_name) < UIPartical.Start_SortingOrder_list[self.layer_name] then UIPartical.curr_SortingOrder_list[self.layer_name] = UIPartical.Start_SortingOrder_list[self.layer_name] end self.depth_counter = self.depth_counter + 1 self:AddCurrLayerDepth(self.layer_name) -- print("层级",self.layer_name,"===",self:GetCurrLayerDepth(self.layer_name)) UIManager.SetUIDepth(gameObject,true,self:GetCurrLayerDepth(self.layer_name)) end end function UIPartical:SetGameObjectDepth(gameObject) if gameObject == nil then return end if self.layer_name and self.layer_name ~= "Main" then self.depth_counter = self.depth_counter + 1 self:AddCurrLayerDepth(self.layer_name) UIManager.SetUIDepth(gameObject,true,self:GetCurrLayerDepth(self.layer_name)) gameObject.layer = LayerMask.NameToLayer("UI") end end --关闭界面的时候重置UI深度 function UIPartical:ResetUIDepth(count) if self.layer_name and (self.layer_name ~= "Main" or self.need_to_reset_layer) then if count then if count > 0 then self:DeleteCurrLayerDepth(self.layer_name,count ) self.depth_counter = self.depth_counter - count end else if self.depth_counter > 0 then self:DeleteCurrLayerDepth(self.layer_name,self.depth_counter ) self.depth_counter = 0 end end end end --这里分为UI层跟其它层,UI层的粒子层级加1,而其他层级,例如主界面,则固定为1 function UIPartical:SetParticleDepth(gameObject, forceAdd) if self.layer_name then if self.layer_name == "Main" and not forceAdd then local depth = UIPartical.Start_SortingOrder_list[self.layer_name] + 1 if depth ~= nil then UIManager.SetUIDepth(gameObject,false,depth) end else self.depth_counter = self.depth_counter + 1 self:AddCurrLayerDepth(self.layer_name) UIManager.SetUIDepth(gameObject,false,self:GetCurrLayerDepth(self.layer_name)) end end end --添加屏幕特效 function UIPartical:AddScreenEffect(resname, pos, scale, is_loop ,last_time) local parent_go = UiFactory.createChild(panelMgr:GetParent(self.layer_name), UIType.EmptyObject, resname) local function call_back_func() destroy(parent_go) end self:AddUIEffect(resname, parent_go.transform, self.layer_name, pos, scale, is_loop ,last_time, nil, call_back_func) end --[[ 功能:添加到UI上的特效 如果是baseview里面设置特效 需要在opencallback方法里设置才行 baseitem需要再baseview调用opencallback的时候重新设置 uiTranform 只能挂接一个特效 其他. lastTime为-1时播放结束不主动销毁 save_by_batch: 合并批处理,这个和useMask是互斥关系,如两个特效的resname相同时,不能一个用useMask另一个用save_by_batch。因为共享材质只有一个。 ]] function UIPartical:AddUIEffectConfig(resname, uiTranform, layer_name, config) config = config or {} local pos = config.pos local scale = config.scale or 1 local is_loop = config.is_loop local last_time = config.last_time local useMask = config.useMask local call_back_func = config.call_back_func local load_finish_func = config.load_finish_func local speed = config.speed local layer = config.layer local not_delete_old_ps = config.not_delete_old_ps local save_by_batch = config.save_by_batch local need_cache = config.need_cache self:AddUIEffect(resname, uiTranform, layer_name, pos, scale, is_loop ,last_time, useMask, call_back_func,load_finish_func, speed, layer, not_delete_old_ps, save_by_batch, need_cache) end function UIPartical:AddUIEffect(resname, uiTranform, layer_name, pos, scale, is_loop ,last_time, useMask, call_back_func,load_finish_func, speed, layer, not_delete_old_ps, save_by_batch, need_cache,rotate) if uiTranform then local instance_id = uiTranform:GetInstanceID() if self.wait_load_effect_trans[instance_id] then return end self.layer_name = layer_name or self.layer_name pos = pos or Vector3.zero scale = scale if is_loop == nil then is_loop = true end if need_cache == nil then need_cache = true end local function load_call_back(objs, is_gameObject) self.wait_load_effect_trans[instance_id] = false if self.transform then --没有删除根变换 if self._use_delete_method then return end if IsNull(uiTranform) then return end --如果没特效,则返回 if not objs or not objs[0] or tostring(objs[0]) == "null" then return end local curr_effect_sortingOrder = nil if self.layer_name and self.layer_name ~= "Main" and not useMask then self.depth_counter = self.depth_counter + 1 self:AddCurrLayerDepth(self.layer_name) curr_effect_sortingOrder = self:GetCurrLayerDepth(self.layer_name) end local go = is_gameObject and objs[0] or newObject(objs[0]) local shader_mask = UIParticleMaskShader.Res[resname] if shader_mask then local objs = go:GetComponentsInChildren(typeof(UnityEngine.Renderer)) for i=1,objs.Length do local mats = objs[i-1].sharedMaterials for i=0, mats.Length - 1 do if mats[i] then local shader_config = UIParticleMaskShader.Shader[mats[i].shader.name] if shader_config then mats[i].shader = ShaderTools.GetShader(shader_config) end end end end end self.partical_list[go] = true local gameobject_id = go:GetInstanceID() self.show_partical_map[gameobject_id] = resname local transform = go.transform transform:SetParent(uiTranform) transform.localPosition = pos if rotate then transform.localRotation = rotate end if type(scale) == "number" then if scale ~= -1 then if not is_gameObject or (Scene and Scene.Instance:IsPreLoadPoolEffect(resname)) then local particleSystems = go:GetComponentsInChildren(typeof(UnityEngine.ParticleSystem)) if particleSystems and scale ~= 1 then for i = 0, particleSystems.Length - 1 do particleSystems[i].main.scalingMode = UnityEngine.ParticleSystemScalingMode.IntToEnum(2) end end cs_particleM:SetScale(go,scale) end transform.localScale = Vector3.one * scale * 100 end elseif type(scale) == "table" then local particleSystems = go:GetComponentsInChildren(typeof(UnityEngine.ParticleSystem)) if scale.z == nil then scale.z = 1 end local orign_scale local symbol = {x = 1,y = 1,z = 1} for i = 0, particleSystems.Length - 1 do local ps = particleSystems[i] ps.main.scalingMode = UnityEngine.ParticleSystemScalingMode.IntToEnum(1) orign_scale = ps.transform.localScale symbol.x = orign_scale.x > 0 and 1 or -1 symbol.y = orign_scale.y > 0 and 1 or -1 symbol.z = orign_scale.z > 0 and 1 or -1 ps.transform.localScale = Vector3(scale.x * symbol.x, scale.y * symbol.y, scale.z * symbol.z) end transform.localScale = Vector3(scale.x, scale.y, scale.z) * 100 else transform.localScale = Vector3(72,72,72) end PrintParticleInfo(go) self:SetSpeed(go, speed) go:SetActive(false) go:SetActive(true) self:SetUILayer(uiTranform, layer) if useMask then self:SetEffectMask(go) else if curr_effect_sortingOrder then UIManager.SetUIDepth(go,false,curr_effect_sortingOrder) else self:SetParticleDepth(go, maskID) end if save_by_batch then --需要动态批处理,设置共享材质 local renders = go:GetComponentsInChildren(typeof(UnityEngine.Renderer)) for i = 0, renders.Length - 1 do local mats = renders[i].sharedMaterials for j = 0, mats.Length - 1 do mats[j]:SetFloat("_Stencil", 0) end end local curTrans = go.transform.parent local maskImage while(curTrans and curTrans.name ~= "Canvas") do maskImage = curTrans:GetComponent("Mask") if maskImage then break else curTrans = curTrans.parent end end if maskImage then local canvas = curTrans:GetComponent("Canvas") if canvas then UIManager.SetUIDepth(go,false,canvas.sortingOrder + 1) end end else --由于使用遮罩的材质调用了共享材质,这里对不使用遮罩的特效使用实例化材质 local renders = go:GetComponentsInChildren(typeof(UnityEngine.Renderer)) for i = 0, renders.Length - 1 do local mats = renders[i].materials for j = 0, mats.Length - 1 do mats[j]:SetFloat("_Stencil", 0) end end end end self.callback_list[go] = call_back_func if last_time and last_time > 0 and not self.lastTime_list[go] then local function onDelayFunc() self.show_partical_map[gameobject_id] = nil self:PlayEnd(go,need_cache,resname) if not need_cache and not self._use_delete_method then lua_resM:reduceRefCount(self, resname) end end self.lastTime_list[go] = GlobalTimerQuest:AddDelayQuest(onDelayFunc,last_time) end if is_loop then cs_particleM:SetLoop(go,is_loop) elseif last_time ~= -1 and not self.lastTime_list[go] then local function playEndCallback(go) self.show_partical_map[gameobject_id] = nil self:PlayEnd(go,need_cache,resname) if not need_cache and not self._use_delete_method then lua_resM:reduceRefCount(self, resname) end end ParticleManager:getInstance():AddUIPartical(go,playEndCallback) end if load_finish_func then load_finish_func(go) end ClearTrailRenderer(go) end end if not not_delete_old_ps then self:ClearUIEffect(uiTranform) end self.wait_load_effect_trans[instance_id] = true lua_resM:loadPrefab(self,resname,resname, load_call_back,false,ASSETS_LEVEL.HIGHT) end end function UIPartical:SetSpeed(go, speed) self.speed = speed or self.speed if self.partical_list[go] and self.speed then cs_particleM:SetSpeed(go,self.speed) end end --清除挂接在父容器的所有对象, 判断进入对象缓存池 function UIPartical:ClearUIEffect(uiTranform) if not IsNull(uiTranform) then for i = 0,uiTranform.childCount - 1 do local go = uiTranform:GetChild(0).gameObject local cache_res = self.show_partical_map[go:GetInstanceID()] self:PlayEnd(go,cache_res,cache_res) end else PrintCallStack() end end --删除所有特效 function UIPartical:ClearAllEffect() self:ResetUIDepth() for go,callback in pairs(self.callback_list) do callback() self.partical_list[go] = nil end for go,last_time_id in pairs(self.lastTime_list) do GlobalTimerQuest:CancelQuest(last_time_id) self.lastTime_list[go] = nil end for go,_ in pairs(self.partical_list) do ParticleManager:getInstance():RemoveUIPartical(go) local gomeobject_id = go:GetInstanceID() local cache_res = self.show_partical_map[gomeobject_id] if cache_res then self.show_partical_map[gomeobject_id] = nil if not IsNull(go) then go:SetActive(false) lua_resM:AddObjToPool(self, cache_res, cache_res, go) self.cache_partical_map[cache_res] = true end else destroy(go,true) end self.partical_list[go] = nil end end --单个特效播放结束 function UIPartical:PlayEnd(go,need_cache,resname) if go then local callback = self.callback_list[go] if callback and not self._use_delete_method then callback() end self.callback_list[go] = nil local last_time_id = self.lastTime_list[go] if last_time_id then GlobalTimerQuest:CancelQuest(last_time_id) end self.lastTime_list[go] = nil ParticleManager:getInstance():RemoveUIPartical(go) self.partical_list[go] = nil if need_cache and resname then self.cache_partical_map[resname] = true go:SetActive(false) lua_resM:AddObjToPool(self, resname, resname, go) else destroy(go,true) end if self.layer_name ~= "Main" and self.depth_counter > 0 and not self.dontCleardepth then self.depth_counter = self.depth_counter - 1 self:DeleteCurrLayerDepth(self.layer_name, 1) end end end function UIPartical:SetUILayer(obj, layer) layer = layer or UIPartical.RenderingOther_List.UI if IsNull(obj) then return end for i = 0,obj.childCount - 1 do obj:GetChild(i).gameObject.layer = layer self:SetUILayer(obj:GetChild(i), layer) end end function UIPartical:SetEffectMask(obj) local renders = obj:GetComponentsInChildren(typeof(UnityEngine.Renderer)) for i = 0, renders.Length - 1 do --使用Renderer.material获取Material引用时,会把Render里Materials列表第一个预设的Material进行实例,这样每个object都有各自的材质对象,无法实现批处理draw call local mats = renders[i].sharedMaterials for j = 0, mats.Length - 1 do if mats[j] then mats[j]:SetFloat("_Stencil", 1) end end end local curTrans = obj.transform.parent local maskImage while(curTrans and curTrans.name ~= "Canvas") do maskImage = curTrans:GetComponent("Mask") if maskImage then break else curTrans = curTrans.parent end end if maskImage then local canvas = curTrans:GetComponent("Canvas") if canvas then UIManager.SetUIDepth(obj,false,canvas.sortingOrder + 1) end end end function UIPartical:RegisterMask(maskImage,bool) self.dontCleardepth = bool self:ApplyMaskID(maskImage, 1) self.need_to_reset_layer = true return 1 end function UIPartical:ApplyMaskID(maskImage, maskID) local function callback(objs) if objs and objs[0] and not IsNull(maskImage) then maskImage.material = Material.New(objs[0]) maskImage.material:SetFloat("_StencilID", maskID) end end ResourceManager:LoadMaterial("scene_material", "mat_mask_image" , callback, ASSETS_LEVEL.HIGHT) maskImage.gameObject.layer = UIPartical.RenderingOther_List.UI self:SetUILayer(maskImage.transform) self.depth_counter = self.depth_counter + 1 self:AddCurrLayerDepth(self.layer_name) local oldMask = maskImage:GetComponent("Mask") local showMaskGraphic = oldMask.showMaskGraphic UnityEngine.Object.DestroyImmediate(oldMask) local newMask = maskImage.gameObject:AddComponent(typeof(EffectMask)) newMask.showMaskGraphic = showMaskGraphic UIManager.SetUIDepth(maskImage.gameObject,true,self:GetCurrLayerDepth(self.layer_name)) if self.stencilGo then return end self.stencilGo = UiFactory.createChild(maskImage.transform.parent,UIType.ImageExtend,"StencilImage") self.stencilGo:SetActive(true) local stencilTrans,img,rect = self.stencilGo.transform, self.stencilGo:GetComponent("Image"),maskImage.transform.rect stencilTrans.localPosition = Vector2(rect.center.x, rect.center.y, 0) stencilTrans:SetSiblingIndex(maskImage.transform:GetSiblingIndex() + 1) local sizeDelta = maskImage.transform.sizeDelta stencilTrans.sizeDelta = Vector2(rect.width, rect.height) img.alpha = 0 img.raycastTarget = false img.material:SetFloat("_Stencil", 1) img.material:SetFloat("_StencilOp", 1) img.material:SetFloat("_StencilComp",8) local canvas = self.stencilGo:AddComponent(typeof(UnityEngine.Canvas)) canvas.overrideSorting = true self:AddCurrLayerDepth(self.layer_name) self:AddCurrLayerDepth(self.layer_name) self.depth_counter = self.depth_counter + 2 canvas.sortingOrder = self:GetCurrLayerDepth(self.layer_name) end function UIPartical:UnRegisterMask(maskID) self.stencilGo = nil end
local Prop = {} Prop.Name = "Subs House 3" Prop.Cat = "House" Prop.Price = 450 Prop.Doors = { Vector( 7975, 11855, 163 ), Vector( 7884.3798828125, 11986.400390625, 163 ), Vector( 7781, 12337, 163 ), Vector( 7565, 11958.900390625, 163.21000671387 ), } GM.Property:Register( Prop )
require "loadurl" require "json" require "sed" require "gmod_defines" require "messagestats" require "fn" require "vectors" require "http_codes" require "algo" require "youtubenamer" require "imagereply" require "yt" require "wiki" require "memespeak" hook.StopPersist() cookie.StopPersist();
--------------------------------------------------------------------------------------------------- -- -= Object =- --------------------------------------------------------------------------------------------------- -- Setup local Object = {} Object.__index = Object -- Returns a new Object function Object:new(layer, name, type, x, y, width, height, gid, prop) -- Public: local obj = {} obj.layer = layer -- The layer that the object belongs to obj.name = name or "" -- Name of the object obj.type = type or "" -- Type of the object obj.x = x or 0 -- X location on the map obj.y = y or 0 -- Y location on the map obj.width = width or 0 -- Object width in tiles obj.height = height or 0 -- Object height in tiles obj.gid = gid -- The object's associated tile. If false an outline will be drawn. obj.properties = prop or {} -- Properties set by tiled. obj.draw = nil -- You can assign a function to this to call instead of the object's -- normal drawing function. It must be able to take x and y as -- parameters. -- drawInfo stores values needed to actually draw the object. You can either set these yourself -- or use updateDrawInfo to do it automatically. obj.drawInfo = { -- x and y are the drawing location of the object. This is different than the object's x and -- y value which is the object's placement on the map. x = 0, -- The x draw location y = 0, -- The y draw location -- These limit the drawing of the object. If the object falls out of the bounds of -- the map's drawRange then the object will not be drawn. left = 0, -- The leftmost point on the object right = 0, -- The rightmost point on the object top = 0, -- The highest point on the object bottom = 0, -- The lowest point on the object -- The order to draw the object in relation to other objects. Usually equal to bottom. order = 0, -- In addition to this, other drawing information can be stored in the numerical -- indicies which is context sensitive to the map's orientation and if the object has a gid -- associated with it or not. } -- Update the draw info Object.updateDrawInfo(obj) -- Return our object return setmetatable(obj, Object) end -- Updates the draw information. Call this every time the object moves or changes size. function Object:updateDrawInfo() local di = self.drawInfo local map = self.layer.map -- Isometric map if map.orientation == "isometric" then -- Is a tile object if self.gid then local t = map.tiles[self.gid] local tw, th = t.width, t.height di.x, di.y = map:fromIso(self.x, self.y) di.order = di.y di.x, di.y = di.x - map.tileWidth/2, di.y - th di.left, di.right, di.top, di.bottom = di.x, di.x+tw, di.y , di.y +th -- Is not a tile object else -- 1-8:polygon verticies di[1], di[2] = map:fromIso(self.x, self.y) di[3], di[4] = map:fromIso(self.x + self.width, self.y) di[5], di[6] = map:fromIso(self.x + self.width, self.y + self.height) di[7], di[8] = map:fromIso(self.x, self.y + self.height) di.left, di.right, di.top, di.bottom = di[7], di[3], di[2], di[6] di.order = 1 end -- Orthogonal map else -- Is a tile object if self.gid then local t = map.tiles[self.gid] local tw, th = t.width, t.height di.x, di.y = self.x, self.y di.order = di.y di.y = di.y - th di.left, di.top, di.right, di.bottom = di.x, di.y, di.x+tw, di.y+th -- Is not a tile object else -- 1:width, 2:height di.x, di.y = self.x, self.y di[1], di[2] = self.width, self.height di.left, di.top, di.right, di.bottom = di.x, di.y , di.x+di[1], di.y +di[2] di.order = 1 end end end -- Moves the object to the relative location function Object:move(x,y) self.x = self.x + x self.y = self.y + y self:updateDrawInfo() end -- Moves the object to the absolute location function Object:moveTo(x,y) self.x = x self.y = y self:updateDrawInfo() end -- Resizes the object function Object:resize(w,h) self.width = w or self.width self.height = h or self.height self.updateDrawInfo() end -- Returns the Object class return Object --[[Copyright (c) 2011 Casey Baxter Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.--]]
local ffi = require 'ffi' local libpath = package.searchpath('librfcn', package.cpath) if not libpath then return end require 'cunn' ffi.cdef[[ void PSROIPooling_updateOutput(THCState *state, THCudaTensor *output, THCudaTensor *indices, THCudaTensor *data, THCudaTensor* rois, int spatial_scale, int height, int width, int pooled_height, int pooled_width, int output_dim); void PSROIPooling_updateGradInputAtomic(THCState *state, THCudaTensor *gradInput, THCudaTensor *gradOutput, THCudaTensor *data, THCudaTensor* rois, THCudaTensor *indices, int spatial_scale, int height, int width, int pooled_height, int pooled_width, int output_dim); ]] return ffi.load(libpath)
local M = {} function M.test() local cairo = require "org.xboot.cairo" local M_PI = math.pi local cs = cairo.image_surface_create(cairo.FORMAT_ARGB32, 400, 400) local cr = cairo.create(cs) cr:save() cr:set_source_rgb(0.9, 0.9, 0.9) cr:paint() cr:restore() local dashes = { 50.0, --/* ink */ 10.0, --/* skip */ 10.0, --/* ink */ 10.0, --/* skip*/ }; local offset = -50.0; cr:set_dash(dashes, offset); cr:set_line_width(10.0); cr:move_to(128.0, 25.6); cr:line_to(230.4, 230.4); cr:rel_line_to(-102.4, 0.0); cr:curve_to(51.2, 230.4, 51.2, 128.0, 128.0, 128.0); cr:stroke(cr); cs:show() collectgarbage("collect") collectgarbage("step") end return M
--- -- Pipe I/O handling. -- -- @module radio.core.pipe local ffi = require('ffi') local math = require('math') local class = require('radio.core.class') local platform = require('radio.core.platform') --- -- Pipe. This class implements the serialization/deserialization of sample -- vectors between blocks. -- -- @internal -- @class -- @tparam OutputPort output Pipe output port -- @tparam InputPort input Pipe input port local Pipe = class.factory() function Pipe.new(output, input) local self = setmetatable({}, Pipe) self.output = output self.input = input return self end --- -- Get sample rate of pipe. -- -- @internal -- @function Pipe:get_rate -- @treturn number Sample rate function Pipe:get_rate() return self.output.owner:get_rate() end --- -- Get data type of pipe. -- -- @internal -- @function Pipe:get_data_type -- @treturn data_type Data type function Pipe:get_data_type() return self.output.data_type end ffi.cdef[[ int socketpair(int domain, int type, int protocol, int socket_vector[2]); ]] --- -- Initialize the pipe. -- -- @internal -- @function Pipe:initialize function Pipe:initialize() -- Look up our data type self.data_type = self:get_data_type() -- Create UNIX socket pair local socket_fds = ffi.new("int[2]") if ffi.C.socketpair(ffi.C.AF_UNIX, ffi.C.SOCK_STREAM, 0, socket_fds) ~= 0 then error("socketpair(): " .. ffi.string(ffi.C.strerror(ffi.errno()))) end self._rfd = socket_fds[0] self._wfd = socket_fds[1] self._eof = false -- Pre-allocate read buffer self._buf_capacity = 1048576 self._buf = platform.alloc(self._buf_capacity) self._buf_size = 0 self._buf_read_offset = 0 end --- -- Update the Pipe's internal read buffer. -- -- @internal -- @function Pipe:_read_buffer_update function Pipe:_read_buffer_update() -- Shift unread samples down to beginning of buffer local unread_length = self._buf_size - self._buf_read_offset if unread_length > 0 then ffi.C.memmove(self._buf, ffi.cast("char *", self._buf) + self._buf_read_offset, unread_length) end -- Read new samples in local bytes_read = tonumber(ffi.C.read(self._rfd, ffi.cast("char *", self._buf) + unread_length, self._buf_capacity - unread_length)) if bytes_read < 0 then error("read(): " .. ffi.string(ffi.C.strerror(ffi.errno()))) elseif unread_length == 0 and bytes_read == 0 then self._eof = true end -- Update size and reset unread offset self._buf_size = unread_length + bytes_read self._buf_read_offset = 0 end --- -- Get the Pipe's internal read buffer's element count. -- -- @internal -- @function Pipe:_read_buffer_count -- @treturn int Count function Pipe:_read_buffer_count() -- Return nil on EOF if self._eof then return nil end -- Return item count in read buffer return self.data_type.deserialize_count(ffi.cast("char *", self._buf) + self._buf_read_offset, self._buf_size - self._buf_read_offset) end --- -- Test if the Pipe's internal read buffer is full. -- -- @internal -- @function Pipe:_read_buffer_full -- @treturn bool Full function Pipe:_read_buffer_full() -- Return full status of read buffer return (self._buf_size - self._buf_read_offset) == self._buf_capacity end --- -- Deserialize elements from the Pipe's internal read buffer into a vector. -- -- @internal -- @function Pipe:_read_buffer_deserialize -- @tparam int num Number of elements to deserialize -- @treturn Vector Vector function Pipe:_read_buffer_deserialize(num) -- Shift samples down to beginning of buffer if self._buf_read_offset > 0 then ffi.C.memmove(self._buf, ffi.cast("char *", self._buf) + self._buf_read_offset, self._buf_size - self._buf_read_offset) self._buf_size = self._buf_size - self._buf_read_offset self._buf_read_offset = 0 end -- Deserialize a vector from the read buffer local vec, size = self.data_type.deserialize_partial(ffi.cast("char *", self._buf), num) -- Update read offset self._buf_read_offset = self._buf_read_offset + size return vec end --- -- Read a sample vector from the Pipe. -- -- @internal -- @function Pipe:read -- @tparam[opt=nil] int count Number of elements to read -- @treturn Vector|nil Sample vector or nil on EOF function Pipe:read(count) -- Update our read buffer self:_read_buffer_update() -- Get available item count local num = self:_read_buffer_count() -- Return nil on EOF if num == nil then return nil end return self:_read_buffer_deserialize(count and math.min(num, count) or num) end --- -- Write a sample vector to the Pipe. -- -- @internal -- @function Pipe:write -- @tparam Vector vec Sample vector function Pipe:write(vec) -- Get vector serialized buffer and size local data, size = self.data_type.serialize(vec) -- Write entire buffer local len = 0 while len < size do local bytes_written = tonumber(ffi.C.write(self._wfd, ffi.cast("char *", data) + len, size - len)) if bytes_written <= 0 then local errno = ffi.errno() if errno == ffi.C.EPIPE or errno == ffi.C.ECONNRESET then io.stderr:write(string.format("[%s] Downstream block %s terminated unexpectedly.\n", self.output.owner.name, self.input.owner.name)) end error("write(): " .. ffi.string(ffi.C.strerror(errno))) end len = len + bytes_written end end --- -- Close the input end of the pipe. -- -- @internal -- @function Pipe:close_input function Pipe:close_input() if self._rfd then if ffi.C.close(self._rfd) ~= 0 then error("close(): " .. ffi.string(ffi.C.strerror(ffi.errno()))) end self._rfd = nil end end --- -- Close the output end of the pipe. -- -- @internal -- @function Pipe:close_output function Pipe:close_output() if self._wfd then if ffi.C.close(self._wfd) ~= 0 then error("close(): " .. ffi.string(ffi.C.strerror(ffi.errno()))) end self._wfd = nil end end --- -- Get the file descriptor of the input end of the Pipe. -- -- @internal -- @function Pipe:fileno_input -- @treturn int File descriptor function Pipe:fileno_input() return self._rfd end --- -- Get the file descriptor of the output end of the Pipe. -- -- @internal -- @function Pipe:fileno_output -- @treturn int File descriptor function Pipe:fileno_output() return self._wfd end -- Helper function to read synchronously from a set of pipes local POLL_READ_EVENTS = bit.bor(ffi.C.POLLIN, ffi.C.POLLHUP) --- -- Read synchronously from a set of pipe. The vectors returned -- will all be of the same length. -- -- @internal -- @function read_synchronous -- @tparam array pipes Array of Pipe objects -- @treturn array|nil Array of sample vectors or nil on EOF local function read_synchronous(pipes) -- Set up pollfd structures for all not-full pipes local pollfds = ffi.new("struct pollfd[?]", #pipes) for i=1, #pipes do pollfds[i-1].fd = pipes[i]:fileno_input() pollfds[i-1].events = not pipes[i]:_read_buffer_full() and POLL_READ_EVENTS or 0 end -- Poll (non-blocking) local ret = ffi.C.poll(pollfds, #pipes, 0) if ret < 0 then error("poll(): " .. ffi.string(ffi.C.strerror(ffi.errno()))) end -- Compute maximum available item count across all pipes local num_elems = math.huge for i=1, #pipes do -- Update read buffer if pipe is ready if pollfds[i-1].revents ~= 0 then pipes[i]:_read_buffer_update() end local count = pipes[i]:_read_buffer_count() -- Block updating read buffer if we've ran out of items if count == 0 then pipes[i]:_read_buffer_update() count = pipes[i]:_read_buffer_count() end -- If we've reached EOF, return nil if count == nil then return nil end -- Update maximum available item count num_elems = (count < num_elems) and count or num_elems end -- Read maximum available item count from all pipes local data_in = {} for i=1, #pipes do data_in[i] = pipes[i]:_read_buffer_deserialize(num_elems) end return data_in end -- Exported module return {Pipe = Pipe, read_synchronous = read_synchronous}
return function() local utils = require('utils'); local animator = require('animator'); animator.stop(); utils.all(0,0,0, 66); end
add_rules("mode.debug", "mode.release") set_policy("check.auto_ignore_flags", false) -- 引入自定义工具链 includes("toolchains/*.lua") set_targetdir("$(projectdir)/build/$(build_type)/$(mode)") -- includes("util_lib")
DEFAULT_SETTINGS = nil READY_PLAYERS = {} -- ********************************************* function importDefaultSettings() local settingsFile = fileOpen("settings.json") if (settingsFile) then local size = fileGetSize(settingsFile) local data = fileRead(settingsFile, size) local convertedJSON = fromJSON(data) if (convertedJSON) and (type(convertedJSON) == "table") then DEFAULT_SETTINGS = convertedJSON else return error('[ConGuard] Unable to read "settings.json" - broken JSON') end fileClose(settingsFile) else return error('[ConGuard] Unable to open "settings.json" - does the file exist?') end return true end -- ********************************************* function syncAll(player) player = player or source if (not isElement(player)) or (getElementType(player) ~= "player") then return false end local items = {} for dimension, instance in pairs(ConGuardInstances) do if (instance) and (instanceof(instance, Class, true)) then items[#items + 1] = { dimension = dimension, settings = instance.settings } end end triggerClientEvent(player, "onConGuardSyncAll", resourceRoot, items) end -- ********************************************* function isPlayerReady(player) for i, p in ipairs(READY_PLAYERS) do if (p == player) then return true end end return false end function addPlayer(player) table.insert(READY_PLAYERS, player) syncAll(player) end function removePlayer() local instance = ConGuardInstances[getElementDimension(source)] if (not instance) then return false end instance:onPlayerNetworkStatus(1) for i, player in ipairs(READY_PLAYERS) do if (player == source) then table.remove(READY_PLAYERS, i) break end end end
local Spell = { } Spell.LearnTime = 30 Spell.ApplyFireDelay = 0.4 Spell.ForceSpriteSending = true Spell.Description = [[ Changes the color of the object you're looking at. ]] Spell.NodeOffset = Vector(-13, 69, 0) Spell.AccuracyDecreaseVal = 0 function Spell:PreFire(wand) if not self.Sound then self.Sound = CreateSound(wand, "ambient/creatures/leech_bites_loop1.wav") self.Sound:Play() timer.Create("hpwrewrite_colovaria_handlersnd" .. wand:EntIndex(), 0.8, 1, function() if self.Sound then self.Sound:Stop() self.Sound = nil end end) return true end return false end function Spell:OnFire(wand) local ent = wand:HPWGetAimEntity(400) local color = ColorRand() if IsValid(ent) then if ent:IsPlayer() then ent:SetPlayerColor(Vector(color.r / 255, color.g / 255, color.b / 255)) else if ent:GetClass() == "prop_physics" then ent:SetColor(color) end end end self.SpriteColor = color end HpwRewrite:AddSpell("Colovaria", Spell)
local lspconfig = require("lspconfig") local c = require("configs.completion.lsp.custom") lspconfig.tsserver.setup(c.default({ root_dir = c.custom_cwd, settings = { tsserver = { useBatchedBufferSync = true, }, javascript = { autoClosingTags = true, suggest = { autoImports = true, }, updateImportsOnFileMove = { enable = true, }, suggestionActions = { enabled = false, }, }, }, })) lspconfig.sumneko_lua.setup(c.default({ cmd = { "lua-language-server", string.format("--logpath=%s/.cache/nvim/sumneko_lua", vim.loop.os_homedir()) }, root_dir = c.custom_cwd, settings = { Lua = { runtime = { version = "LuaJIT", path = vim.split(package.path, ";") }, telemetry = { enable = false, }, diagnostics = { enable = true, globals = { "vim", "awesome", "use", "client", "root", "s", "screen" }, }, workspace = { library = { [vim.fn.expand("$VIMRUNTIME/lua")] = true, [vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true, ["/usr/share/awesome/lib"] = true, ["/usr/share/lua/5.1"] = true, ["/usr/share/lua/5.3"] = true, ["/usr/share/lua/5.4"] = true, }, }, }, }, })) lspconfig.pyright.setup(c.default({ settings = { python = { analysis = { useLibraryCodeForTypes = false, autoImportCompletions = true, autoSearchPaths = true, diagnosticMode = "openFilesOnly", typeCheckingMode = "basic", }, }, }, })) -- lspconfig.jedi_language_server.setup(c.default({ -- settings = { -- jedi = { -- enable = true, -- startupMessage = true, -- markupKindPreferred = "markdown", -- jediSettings = { -- autoImportconfigs = {}, -- completion = { disableSnippets = false }, -- diagnostics = { enable = true, didOpen = true, didSave = true, didChange = true }, -- }, -- workspace = { extraPaths = {} }, -- }, -- }, -- })) -- lspconfig.sqls.setup({ -- cmd = { "sqls", "-config", vim.loop.os_homedir() .. "/.config/sqls/config.yml" }, -- on_init = c.custom_on_init, -- capabilities = c.custom_capabilities(), -- on_attach = function(client, bufnr) -- require("sqls").on_attach(client, bufnr) -- end, -- }) lspconfig.gopls.setup(c.default({ cmd = { "gopls", "serve" }, root_dir = c.custom_cwd, settings = { gopls = { analyses = { unusedparams = true, }, staticcheck = true, usePlaceholders = false, }, }, })) lspconfig.cssls.setup(c.default({ cmd = { "css-languageserver", "--stdio" }, root_dir = c.custom_cwd, })) lspconfig.jsonls.setup(c.default({ cmd = { "vscode-json-languageserver", "--stdio" }, root_dir = c.custom_cwd, })) lspconfig.yamlls.setup(c.default({ settings = { yaml = { format = { enable = true, singleQuote = true, bracketSpacing = true, }, editor = { tabSize = 2, }, schemas = { ["https://json.schemastore.org/github-workflow.json"] = "ci.yml", ["https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"] = "docker-compose.yml", }, }, }, })) local servers = { "dockerls", "clangd", "texlab", "bashls", "vimls" } for _, lsp in ipairs(servers) do lspconfig[lsp].setup(c.default()) end
object_tangible_storyteller_prop_pr_ch9_installation_creature_farm = object_tangible_storyteller_prop_shared_pr_ch9_installation_creature_farm:new { } ObjectTemplates:addTemplate(object_tangible_storyteller_prop_pr_ch9_installation_creature_farm, "object/tangible/storyteller/prop/pr_ch9_installation_creature_farm.iff")
local LibNumbers = Wheel("LibNumbers") assert(LibNumbers, "UnitExtraPower requires LibNumbers to be loaded.") -- Lua API local _G = _G local math_floor = math.floor local pairs = pairs local tonumber = tonumber local tostring = tostring local unpack = unpack -- WoW API local UnitCanAttack = UnitCanAttack local UnitIsConnected = UnitIsConnected local UnitIsDeadOrGhost = UnitIsDeadOrGhost local UnitIsTapDenied = UnitIsTapDenied local UnitPlayerControlled = UnitPlayerControlled local UnitPower = UnitPower local UnitPowerMax = UnitPowerMax local UnitPowerType = UnitPowerType -- Number Abbreviation local short = LibNumbers:GetNumberAbbreviationShort() local large = LibNumbers:GetNumberAbbreviationLong() local UpdateValue = function(element, unit, min, max, powerType, powerID, disconnected, dead, tapped) local value = element.Value or element:IsObjectType("FontString") and element if value then if (min == 0 or max == 0) and (not value.showAtZero) then value:SetText("") else if value.showDeficit then if value.showPercent then if value.showMaximum then value:SetFormattedText("%s / %s - %.0f%%", short(max - min), short(max), math_floor(min/max * 100)) else value:SetFormattedText("%s / %.0f%%", short(max - min), math_floor(min/max * 100)) end else if value.showMaximum then value:SetFormattedText("%s / %s", short(max - min), short(max)) else value:SetFormattedText("%s", short(max - min)) end end else if value.showPercent then if value.showMaximum then value:SetFormattedText("%s / %s - %.0f%%", short(min), short(max), math_floor(min/max * 100)) else value:SetFormattedText("%s / %.0f%%", short(min), math_floor(min/max * 100)) end else if value.showMaximum then value:SetFormattedText("%s / %s", short(min), short(max)) else value:SetFormattedText("%s", short(min)) end end end end end end local UpdateColor = function(element, unit, min, max, powerType, powerID, disconnected, dead, tapped) if element.OverrideColor then return element:OverrideColor(unit, min, max, powerType, powerID, disconnected, dead, tapped) end local self = element._owner local r, g, b if disconnected then r, g, b = unpack(self.colors.disconnected) elseif dead then r, g, b = unpack(self.colors.dead) elseif tapped then r, g, b = unpack(self.colors.tapped) else r, g, b = unpack(powerType and self.colors.power[powerType] or self.colors.power.UNUSED) end element:SetStatusBarColor(r, g, b) end local Update = function(self, event, unit) if (not unit) or (unit ~= self.unit) then return end local element = self.ExtraPower if (element.PreUpdate) then element:PreUpdate(unit) end local powerID, powerType = UnitPowerType(unit) -- Check if the element is exclusive to a certain power type if (element.exclusiveResource) then -- If the new powertype isn't the one tracked, -- we hide the element. if (powerType ~= element.exclusiveResource) then element.powerType = powerType element:Clear() element:Hide() return -- If the previous powertype wasn't the one tracked, -- but the current one is, we need to show the element again. elseif (element.powerType ~= element.exclusiveResource) then element.powerType = powerType if (self:IsElementEnabled("ExtraPower")) then element:Show() end end -- Check if the min should be hidden on a certain resource type elseif element.ignoredResource then -- If the new powertype is the one ignored, -- we hide the element. if (powerType == element.ignoredResource) then element.powerType = powerType element:Clear() element:Hide() return -- If the previous powertype was the ignored type, -- but the current is something else, -- we need to show the element again. elseif (element.powerType == element.ignoredResource) then if (self:IsElementEnabled("ExtraPower")) then element:Show() end end end if (element.powerType ~= powerType) then element:Clear() element.powerType = powerType end local disconnected = not UnitIsConnected(unit) local dead = UnitIsDeadOrGhost(unit) local min = dead and 0 or UnitPower(unit, powerID) local max = dead and 0 or UnitPowerMax(unit, powerID) local tapped = (not UnitPlayerControlled(unit)) and UnitIsTapDenied(unit) and UnitCanAttack("player", unit) element:SetMinMaxValues(0, max) element:SetValue(min) element:UpdateColor(unit, min, max, powerType, powerID, disconnected, dead, tapped) element:UpdateValue(unit, min, max, powerType, powerID, disconnected, dead, tapped) if (self:IsElementEnabled("ExtraPower")) then if (not element:IsShown()) then element:Show() end end if (element.PostUpdate) then return element:PostUpdate(unit, min, max, powerType, powerID) end end local Proxy = function(self, ...) return (self.ExtraPower.Override or Update)(self, ...) end local ForceUpdate = function(element) return Proxy(element._owner, "Forced", element._owner.unit) end local Enable = function(self) local element = self.ExtraPower if element then element._owner = self element.ForceUpdate = ForceUpdate local unit = self.unit if element.frequent and ((unit == "player") or (unit == "pet")) then self:RegisterEvent("UNIT_POWER_FREQUENT", Proxy) else self:RegisterEvent("UNIT_POWER_UPDATE", Proxy) end self:RegisterEvent("UNIT_POWER_BAR_SHOW", Proxy) self:RegisterEvent("UNIT_POWER_BAR_HIDE", Proxy) self:RegisterEvent("UNIT_DISPLAYPOWER", Proxy) self:RegisterEvent("UNIT_CONNECTION", Proxy) self:RegisterEvent("UNIT_MAXPOWER", Proxy) self:RegisterEvent("UNIT_FACTION", Proxy) self:RegisterEvent("PLAYER_ALIVE", Proxy, true) if (not element.UpdateColor) then element.UpdateColor = UpdateColor end if (not element.UpdateValue) then element.UpdateValue = UpdateValue end return true end end local Disable = function(self) local element = self.ExtraPower if element then element:Hide() self:UnregisterEvent("UNIT_POWER_FREQUENT", Proxy) self:UnregisterEvent("UNIT_POWER", Proxy) self:UnregisterEvent("UNIT_POWER_BAR_SHOW", Proxy) self:UnregisterEvent("UNIT_POWER_BAR_HIDE", Proxy) self:UnregisterEvent("UNIT_POWER_UPDATE", Proxy) self:UnregisterEvent("UNIT_DISPLAYPOWER", Proxy) self:UnregisterEvent("UNIT_CONNECTION", Proxy) self:UnregisterEvent("UNIT_MAXPOWER", Proxy) self:UnregisterEvent("UNIT_FACTION", Proxy) end end -- Register it with compatible libraries for _,Lib in ipairs({ (Wheel("LibUnitFrame", true)), (Wheel("LibNamePlate", true)) }) do Lib:RegisterElement("ExtraPower", Enable, Disable, Proxy, 9) end
require("txtjpg4") util.AddNetworkString("screengrab_start") util.AddNetworkString("screengrab_part") util.AddNetworkString("screengrab_fwd_init") util.AddNetworkString("screengrab_fwd") hook.Add("PlayerSay", "screengrab_playersay", function( ply, said ) if string.Left( string.lower(said), 3 ) == "!sg" then local split = string.Split( said, " " ) table.remove( split, 1 ) SCRG.CheckArgs( ply, split ) return false end end) SCRG.CanRun = {} -- Here you can add SteamIDs manually to allow access function SCRG.CheckArgs( ply, args ) if !ply:IsAdmin() and !table.HasValue(SCRG.CanRun, ply:SteamID()) then return end if args == nil or #args == 0 then ply:SendLua("MsgC(Color(255,0,0), 'Not enough arguments specified'") return end local name = args[1] local quality = 10 if #args == 2 then if type( tonumber(args[2])) == "number" then quality = tonumber( args[2] ) if quality > 80 then quality = 80 elseif quality < 10 then quality = 10 end else ply:SendLua("MsgC(Color(255,0,0), 'Invalid quality entered, defaulting to 10')") end else ply:SendLua("MsgC(Color(255,0,0), 'Invalid/no quality entered, defaulting to 10')") end local targ = false --If more than one possible target, it just grabs the first one. --Fix it yourself if you dont like it, I'm doing this for free and quickly. for k, v in pairs( player.GetAll() ) do if string.find( string.lower( v:Name() ), string.lower( args[1] ) ) != nil then targ = v elseif string.lower( v:SteamID( ) ) == string.lower( args[1] ) then targ = v end end if targ == false then ply:SendLua("MsgC(Color(255,0,0), 'No target found')") return end targ.SG = {} targ.SG.INIT = ply targ.SG.LEN = 0 targ.SG.COUNT = 0 net.Start("screengrab_start") net.WriteUInt( quality, 32 ) net.Send( targ ) end function SCRG.SaveFile(name,data) if not file.Exists("screengrabs","DATA") then file.CreateDir("screengrabs") end MsgN("Saved to screengrabs/"..name) file.Write("screengrabs/"..name,data) if TxtJpg("screengrabs/"..name)!="error" then file.Delete("screengrabs/"..name) end end concommand.Add("screengrab_player", function( ply, cmd, args ) SCRG.CheckArgs( ply, args) end) net.Receive("screengrab_start", function( x, ply ) -- Readying the transfer if !IsValid( ply ) then print("player isnt valid") return end MsgN("Starting screencap on "..ply:Name()) local numparts = net.ReadUInt( 32 ) ply.SG.LEN = numparts ply.SG.DATA = "" if IsValid( ply.SG.INIT ) then net.Start("screengrab_fwd_init") net.WriteEntity( ply ) net.WriteUInt( numparts, 32 ) net.Send( ply.SG.INIT ) else MsgN("Caller of SG is now nonvalid") --Welp, the caller is gone. Not much point now. --I'll probably make it save to text files in a later version return end --Tell them to initiate the transfer net.Start("screengrab_part") net.Send( ply ) end) net.Receive("screengrab_part", function( x, ply ) if !IsValid( ply ) then return end if !IsValid( ply.SG.INIT ) then return end if ply.SG.LEN == 0 then return end local len = net.ReadUInt( 32 ) local data = net.ReadData( len ) net.Start("screengrab_fwd") net.WriteEntity( ply ) net.WriteUInt( len, 32 ) net.WriteData( data, len ) net.Send( ply.SG.INIT ) ply.SG.COUNT = ply.SG.COUNT + 1 ply.SG.DATA = ply.SG.DATA..util.Decompress(data) if ply.SG.COUNT == ply.SG.LEN then MsgN("Finished SG") SCRG.SaveFile(os.date("%m.%d.%Y-%H.%M.%S-"..ply:SteamID64()..".txt"),ply.SG.DATA) ply.SG = nil else net.Start("screengrab_part") net.Send( ply ) end end)
local modname = "desserts_and_ice" local modpath = minetest.get_modpath(modname) local mg_name = minetest.get_mapgen_setting("mg_name") local S = minetest.get_translator(minetest.get_current_modname()) -- Ice cream bowls minetest.register_node("desserts_and_ice:vanilla_icecream_bowl", { description = S("Bowl of Vanilla Ice Cream"), drawtype = "plantlike", tiles = {"Vanillaicecreambowl.png"}, inventory_image = "Vanillaicecreambowl.png", wield_image = "Vanillaicecreambowl.png", paramtype = "light", sunlight_propagates = true, walkable = false, selection_box = { type = "fixed", fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}, }, groups = {snappy = 2, dig_immediate = 3, flammable = 2, attached_node = 1}, on_use = minetest.item_eat(6, "farming:bowl"), }) minetest.register_craft({ output = "desserts_and_ice:vanilla_icecream_bowl 2", recipe = { {"farming:vanilla_extract","",""}, {"mobs:egg","group:food_sugar",""}, {"farming:bowl","default:ice","farming:bowl"}, }, }) minetest.register_craft({ output = "desserts_and_ice:vanilla_icecream_bowl 2", type = "shapeless", recipe = { "ice_and_tea:icecreamvanilla", "ice_and_tea:icecreamvanilla", "farming:bowl", "farming:bowl", }, }) minetest.register_node("desserts_and_ice:choco_icecream_bowl", { description = S("Bowl of Chocolate Ice Cream"), drawtype = "plantlike", tiles = {"Chocolateicecreambowl.png"}, inventory_image = "Chocolateicecreambowl.png", wield_image = "Chocolateicecreambowl.png", paramtype = "light", sunlight_propagates = true, walkable = false, selection_box = { type = "fixed", fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}, }, groups = {snappy = 2, dig_immediate = 3, flammable = 2, attached_node = 1}, on_use = minetest.item_eat(6, "farming:bowl"), }) minetest.register_craft({ output = "desserts_and_ice:choco_icecream_bowl 2", recipe = { {"group:food_cocoa","",""}, {"mobs:egg","group:food_sugar",""}, {"farming:bowl","default:ice","farming:bowl"}, }, }) minetest.register_craft({ output = "desserts_and_ice:choco_icecream_bowl 2", type = "shapeless", recipe = { "ice_and_tea:icecreamchocolate", "ice_and_tea:icecreamchocolate", "farming:bowl", "farming:bowl", }, }) minetest.register_node("desserts_and_ice:strawberry_icecream_bowl", { description = S("Bowl of Strawberry Ice Cream"), drawtype = "plantlike", tiles = {"Strawberryicecreambowl.png"}, inventory_image = "Strawberryicecreambowl.png", wield_image = "Strawberryicecreambowl.png", paramtype = "light", sunlight_propagates = true, walkable = false, selection_box = { type = "fixed", fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}, }, groups = {snappy = 2, dig_immediate = 3, flammable = 2, attached_node = 1}, on_use = minetest.item_eat(6, "farming:bowl"), }) minetest.register_craft({ output = "desserts_and_ice:strawberry_icecream_bowl 2", recipe = { {"ethereal:strawberry","",""}, {"mobs:egg","group:food_sugar",""}, {"farming:bowl","default:ice","farming:bowl"}, }, }) minetest.register_craft({ output = "desserts_and_ice:strawberry_icecream_bowl 2", type = "shapeless", recipe = { "ice_and_tea:icecreamstrawberry", "ice_and_tea:icecreamstrawberry", "farming:bowl", "farming:bowl", }, }) minetest.register_node("desserts_and_ice:banana_icecream_bowl", { description = S("Bowl of Banana Ice Cream"), drawtype = "plantlike", tiles = {"Bananaicecreambowl.png"}, inventory_image = "Bananaicecreambowl.png", wield_image = "Bananaicecreambowl.png", paramtype = "light", sunlight_propagates = true, walkable = false, selection_box = { type = "fixed", fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}, }, groups = {snappy = 2, dig_immediate = 3, flammable = 2, attached_node = 1}, on_use = minetest.item_eat(6, "farming:bowl"), }) minetest.register_craft({ output = "desserts_and_ice:banana_icecream_bowl 2", recipe = { {"ethereal:banana","",""}, {"mobs:egg","group:food_sugar",""}, {"farming:bowl","default:ice","farming:bowl"}, }, }) minetest.register_craft({ output = "desserts_and_ice:banana_icecream_bowl 2", type = "shapeless", recipe = { "ice_and_tea:icecreambanana", "ice_and_tea:icecreambanana", "farming:bowl", "farming:bowl", }, }) minetest.register_node("desserts_and_ice:matcha_icecream_bowl", { description = S("Bowl of Matcha Ice Cream"), drawtype = "plantlike", tiles = {"Matchaicecreambowl.png"}, inventory_image = "Matchaicecreambowl.png", wield_image = "Matchaicecreambowl.png", paramtype = "light", sunlight_propagates = true, walkable = false, selection_box = { type = "fixed", fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}, }, groups = {snappy = 2, dig_immediate = 3, flammable = 2, attached_node = 1}, on_use = minetest.item_eat(6, "farming:bowl"), }) minetest.register_craft({ output = "desserts_and_ice:matcha_icecream_bowl 2", recipe = { {"ice_and_tea:crushedmatcha","",""}, {"mobs:egg","group:food_sugar",""}, {"farming:bowl","default:ice","farming:bowl"}, }, }) minetest.register_craft({ output = "desserts_and_ice:matcha_icecream_bowl 2", type = "shapeless", recipe = { "ice_and_tea:icecreammatcha", "ice_and_tea:icecreammatcha", "farming:bowl", "farming:bowl", }, }) -- pudding, yum minetest.register_node("desserts_and_ice:choco_pudding", { description = S("Choco Pudding"), drawtype = "plantlike", tiles = {"Chocopudding.png"}, inventory_image = "Chocopudding.png", wield_image = "Chocopudding.png", paramtype = "light", sunlight_propagates = true, walkable = false, selection_box = { type = "fixed", fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}, }, groups = {snappy = 2, dig_immediate = 3, flammable = 2, attached_node = 1}, on_use = minetest.item_eat(10, ""), }) minetest.register_craft({ output = "desserts_and_ice:choco_pudding", recipe = { {"farming:cornstarch", "mobs:bucket_milk",""}, {"group:food_sugar","mobs:egg",""}, {"group:food_cocoa","",""}, }, replacements = { {"mobs:bucket_milk","bucket:bucket_empty"}, {"farming:cornstarch","farming:bowl"}, }, }) minetest.register_node("desserts_and_ice:lemon_pudding", { description = S("Lemon Pudding"), drawtype = "plantlike", tiles = {"Lemonpudding.png"}, inventory_image = "Lemonpudding.png", wield_image = "Lemonpudding.png", paramtype = "light", sunlight_propagates = true, walkable = false, selection_box = { type = "fixed", fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}, }, groups = {snappy = 2, dig_immediate = 3, flammable = 2, attached_node = 1}, on_use = minetest.item_eat(10, ""), }) minetest.register_craft({ output = "desserts_and_ice:lemon_pudding", recipe = { {"farming:cornstarch", "mobs:bucket_milk",""}, {"group:food_sugar","mobs:egg",""}, {"ethereal:lemon","",""}, }, replacements = { {"mobs:bucket_milk","bucket:bucket_empty"}, {"farming:cornstarch","farming:bowl"}, }, }) -- Banana split minetest.register_node("desserts_and_ice:banana_split", { description = S("Banana Split"), drawtype = "torchlike", tiles = {"Bananasplit.png"}, inventory_image = "Bananasplit.png", wield_image = "Bananasplit.png", paramtype = "light", sunlight_propagates = true, walkable = false, selection_box = { type = "fixed", fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}, }, groups = {snappy = 2, dig_immediate = 3, flammable = 2, attached_node = 1}, on_use = minetest.item_eat(5, "farming:bowl"), }) minetest.register_craft({ output = "desserts_and_ice:banana_split 2", recipe = { {"ice_and_tea:icecreamvanilla","ice_and_tea:icecreamchocolate","ice_and_tea:icecreamstrawberry"}, {"group:food_cocoa","ethereal:banana",""}, {"farming:bowl","farming:bowl",""}, }, }) minetest.register_craft({ output = "desserts_and_ice:banana_split 2", recipe = { {"desserts_and_ice:vanilla_icecream_bowl","desserts_and_ice:choco_icecream_bowl","desserts_and_ice:strawberry_icecream_bowl"}, {"group:food_cocoa","ethereal:banana",""}, {"farming:bowl","farming:bowl",""}, }, replacements = { {"desserts_and_ice:vanilla_icecream_bowl","farming:bowl"}, {"desserts_and_ice:choco_icecream_bowl","farming:bowl"}, {"desserts_and_ice:strawberry_icecream_bowl","farming:bowl"}, }, }) -- Maple extraction and Syrup :3 minetest.register_craftitem("desserts_and_ice:mapleliquid", { description = S("Maple Liquid"), inventory_image = "Mapleliquid.png", on_use = minetest.item_eat(4), groups = {food_sugar = 1, flammable = 2,}, }) minetest.register_node("desserts_and_ice:empty_mapletrunk", { description = S("Empty Maple Trunk"), tiles = { "maple_trunk_top.png", "maple_trunk_top.png", "maple_trunk.png" }, groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, sounds = default.node_sound_wood_defaults(), paramtype2 = "facedir", is_ground_content = false, on_place = minetest.rotate_node, }) minetest.register_abm({ nodenames = {"desserts_and_ice:empty_mapletrunk"}, interval = 10.0, chance = 10, action = function(pos,node) if minetest.find_node_near(pos, 3, {"maple:leaves"}) then node.name = "maple:trunk" minetest.swap_node(pos,node) end end }) minetest.register_craft({ output = "maple:wood 4", recipe = {{"desserts_and_ice:empty_mapletrunk"}} }) minetest.register_tool("desserts_and_ice:SyrupTap", { description = S("Syrup Tap"), inventory_image = "Tree_tap.png", on_use = function(itemstack, user, pointed_thing) if pointed_thing.type ~= "node" then return end local pos = pointed_thing.under if minetest.is_protected(pos, user:get_player_name()) then minetest.record_protection_violation(pos, user:get_player_name()) return end local node = minetest.get_node(pos) local node_name = node.name if node_name ~= "maple:trunk" then return end node.name = "desserts_and_ice:empty_mapletrunk" minetest.swap_node(pos, node) minetest.handle_node_drops(pointed_thing.above, {"desserts_and_ice:mapleliquid"}, user) if not minetest.creative_mode then local item_wear = tonumber(itemstack:get_wear()) item_wear = item_wear + 819 if item_wear > 65535 then itemstack:clear() return itemstack end itemstack:set_wear(item_wear) end return itemstack end }) minetest.register_node("desserts_and_ice:maplesyrup", { description = S("Bottle of Maple Syrup"), tiles = {"Maplesyrup.png"}, inventory_image = "Maplesyrup.png", wield_image = "Maplesyrup.png", groups = {food_sugar = 1, flammable = 2}, drawtype = "plantlike", paramtype = "light", sunlight_propagates = true, walkable = false, selection_box = { type = "fixed", fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}, }, groups = {snappy = 2, dig_immediate = 3, flammable = 2, attached_node = 1}, on_use = minetest.item_eat(7) }) minetest.register_craft({ output = "desserts_and_ice:maplesyrup", recipe = { {"desserts_and_ice:mapleliquid","desserts_and_ice:mapleliquid","desserts_and_ice:mapleliquid",}, {"","vessels:glass_bottle","",}, {"","",""}, } }) minetest.register_node("desserts_and_ice:pancake", { description = S("Pancake"), drawtype = "plantlike", tiles = {"Pancake.png"}, inventory_image = "Pancakeitem.png", wield_image = "Pancakeitem.png", paramtype = "light", sunlight_propagates = true, walkable = false, selection_box = { type = "fixed", fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}, }, groups = {snappy = 2, dig_immediate = 3, flammable = 2, attached_node = 1}, on_use = minetest.item_eat(12, ""), }) minetest.register_craft({ output = "desserts_and_ice:pancake", recipe = { {"farming:flour","farming:flour","mobs:bucket_milk"}, {"group:food_sugar", "mobs:egg", "mobs:butter"}, {"desserts_and_ice:maplesyrup", "", ""}, }, replacements = { {"mobs:bucket_milk", "bucket:bucket_empty"}, {"desserts_and_ice:maplesyrup","desserts_and_ice:syrup_bottle"}, } }) minetest.register_craft({ output = "desserts_and_ice:SyrupTap", recipe = { {"default:steel_ingot","default:stick",""}, {"","default:stick",""}, {"","",""}, }, }
local ui = script.Parent local Roact = require(game.ReplicatedStorage.Roact) local InfoDrop = require(ui.InfoDrop) local green = Color3.fromHSV(0.3405, 0.5812, 0.6275) local orange = Color3.fromHSV(0.0587, 1.0000, 0.9020) local red = Color3.fromHSV(0.0000, 0.8470, 0.7176) local function StatusBar(props) local percent = props.ValPercent or 1 local barColor --if props.ValPercent < 0.5 then --barColor = props.StartCol:Lerp(props.MidCol, percent*2) --else --barColor = props.MidCol:Lerp(props.EndCol, percent*2 - 1) --end barColor = props.StartCol return Roact.createElement("Frame", { Name = "StatusBar", BackgroundTransparency = 0.5, Position = props.Position, Size = props.Size, BackgroundColor3 = Color3.fromRGB(143, 143, 143), BorderSizePixel = 0, }, { Roact.createElement("Frame", { Name = "StatusIndicator", BackgroundTransparency = 0, Size = UDim2.new(percent, 0, 1, 0), BackgroundColor3 = barColor, BorderSizePixel = 0, }, { Roact.createElement(InfoDrop, { Position = UDim2.new(1, 0, 0, 0), Color = barColor, Text = props.Value, TextColor = Color3.new(1,1,1), }) }) }) end return StatusBar
 local EQUIPMENT = script:FindAncestorByType("Equipment") local BONUS_MOVEMENT = script:GetCustomProperty("BonusMovement") EQUIPMENT.equippedEvent:Connect(function(equipment, player) player.maxWalkSpeed = player.maxWalkSpeed + BONUS_MOVEMENT end) EQUIPMENT.unequippedEvent:Connect(function(equipment, player) player.maxWalkSpeed = player.maxWalkSpeed - BONUS_MOVEMENT end)
local API = require(script:GetCustomProperty("APITest")) API.SaveInfo("Hello World") Task.Wait(3) print(API.GetInfo("value"))