content stringlengths 5 1.05M |
|---|
local has_technic = minetest.get_modpath("technic")
local drain_inv = minetest.settings:get_bool("headlamp_drain_inventory", false)
local battery_life = tonumber(minetest.settings:get("headlamp_battery_life")) or 180
local battery_drain = math.floor(65535 / (battery_life * 60)) * 5
-- Helper function to make code neater
local function merge(t1, t2)
local t = table.copy(t1)
for k, v in pairs(t2) do
t[k] = v
end
return t
end
-- Battery draining logic
--------------------------------------------------
local function use_battery(stack)
if stack:get_wear() >= (65535 - battery_drain) then
stack:set_name("headlamp:headlamp_off")
return false
end
stack:add_wear(battery_drain)
return true
end
local function update_wielded(player)
local stack = player:get_wielded_item()
if stack:get_name() == "headlamp:headlamp_on" then
use_battery(stack)
player:set_wielded_item(stack)
end
end
local function update_inventory(player)
local inv = player:get_inventory()
if not inv:contains_item("main", "headlamp:headlamp_on") then
return -- Skip checking every stack
end
for i=1, inv:get_size("main") do
local stack = inv:get_stack("main", i)
if stack:get_name() == "headlamp:headlamp_on" then
use_battery(stack)
inv:set_stack("main", i, stack)
end
end
end
local function update_armor(player)
local name, inv = armor:get_valid_player(player)
if not name then
return -- Armor not initialized yet
end
if not inv:contains_item("armor", "headlamp:headlamp_on") then
return -- Skip checking every stack
end
for i=1, inv:get_size("armor") do
local stack = inv:get_stack("armor", i)
if stack:get_name() == "headlamp:headlamp_on" then
local success = use_battery(stack)
inv:set_stack("armor", i, stack)
armor:save_armor_inventory(player)
if not success then
armor:set_player_armor(player)
end
return -- There can only be one
end
end
end
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer < 5 then return end -- Doesn't need a fast update, every 5 seconds is enough
timer = 0
for _, player in pairs(minetest.get_connected_players()) do
if not minetest.is_creative_enabled(player:get_player_name()) then
update_armor(player)
if drain_inv then
update_inventory(player)
else
update_wielded(player)
end
end
end
end)
-- Item registration
--------------------------------------------------
local base_def = {
groups = {armor_head = 1, armor_heal = 0, armor_use = 0},
armor_groups = {fleshy = 2}, -- Headlamp is terrible armor, but it's better than nothing
on_secondary_use = function(stack, player)
return armor:equip(player, stack)
end,
on_place = function(stack, player, pointed)
if pointed.type == "node" and player and not player:get_player_control().sneak then
local node = minetest.get_node(pointed.under)
local ndef = minetest.registered_nodes[node.name]
if ndef and ndef.on_rightclick then
return ndef.on_rightclick(pointed.under, node, player, stack, pointed)
end
end
return armor:equip(player, stack)
end,
}
if has_technic then
-- Battery values are now charge values instead of wear
battery_life = battery_life * 600
battery_drain = 50
-- Different code for different APIs
if technic.plus then
use_battery = function(stack)
if technic.use_RE_charge(stack, battery_drain) then
return true
end
stack:set_name("headlamp:headlamp_off")
return false
end
base_def.max_charge = battery_life
else
use_battery = function(stack)
local meta = stack:get_meta()
local metadata = minetest.deserialize(meta:get_string("")) or {}
if not metadata.charge or metadata.charge <= battery_drain then
stack:set_name("headlamp:headlamp_off")
return false
end
metadata.charge = metadata.charge - battery_drain
meta:set_string("", minetest.serialize(metadata))
technic.set_RE_wear(stack, metadata.charge, battery_life)
return true
end
base_def.wear_represents = "technic_RE_charge"
base_def.on_refill = technic.refill_RE_charge
end
end
local off_def = merge(base_def, {
description = "Headlamp (Off)",
inventory_image = "headlamp_inv_headlamp_off.png",
on_use = function(stack, player)
-- Turn headlamp on if there is enough battery left
if minetest.is_creative_enabled(player:get_player_name()) or use_battery(stack) then
stack:set_name("headlamp:headlamp_on")
end
return stack
end,
})
local on_def = merge(base_def, {
description = "Headlamp (On)",
inventory_image = "headlamp_inv_headlamp_on.png",
groups = {armor_head = 1, armor_heal = 0, armor_use = 0, not_in_creative_inventory = 1},
light_source = 14,
on_use = function(stack)
-- Turn headlamp off
stack:set_name("headlamp:headlamp_off")
return stack
end,
})
if has_technic and technic.plus then
technic.register_power_tool("headlamp:headlamp_off", off_def)
technic.register_power_tool("headlamp:headlamp_on", on_def)
else
minetest.register_tool("headlamp:headlamp_off", off_def)
minetest.register_tool("headlamp:headlamp_on", on_def)
if has_technic then
technic.register_power_tool("headlamp:headlamp_off", battery_life)
technic.register_power_tool("headlamp:headlamp_on", battery_life)
end
end
-- Crafting recipe
--------------------------------------------------
if minetest.get_modpath("farming") then
if has_technic then
-- Somewhat realistic recipe
minetest.register_craft({
output = "headlamp:headlamp_off",
recipe = {
{"farming:string", "technic:battery", "farming:string"},
{"technic:rubber", "technic:lv_led", "technic:rubber"},
{"farming:string", "technic:stainless_steel_ingot", "farming:string"},
}
})
elseif minetest.get_modpath("default") then
-- Magic mese powered headlamp
minetest.register_craft({
output = "headlamp:headlamp_off",
recipe = {
{"farming:string", "farming:string", "farming:string"},
{"farming:string", "default:mese_crystal", "farming:string"},
{"farming:string", "default:steel_ingot", "farming:string"},
}
})
end
end
|
return {
tllobliterator1 = {
activatewhenbuilt = true,
buildangle = 4096,
buildcostenergy = 267109,
buildcostmetal = 21755,
builder = false,
buildinggrounddecaldecayspeed = 30,
buildinggrounddecalsizex = 10,
buildinggrounddecalsizey = 10,
buildinggrounddecaltype = "tllobliterator_aoplane.dds",
buildpic = "tllobliterator.dds",
buildtime = 248000,
canattack = true,
canguard = true,
canstop = 1,
category = "ALL SURFACE",
collisionvolumeoffsets = "0 -3 0",
collisionvolumescales = "133 127 133",
collisionvolumetype = "CylY",
corpse = "dead",
damagemodifier = 0.10,
defaultmissiontype = "GUARD_NOMOVE",
description = "High Energy weapon",
energystorage = 1500,
energyuse = 0,
explodeas = "CRAWL_BLAST",
firestandorders = 1,
footprintx = 9,
footprintz = 7,
icontype = "building",
idleautoheal = 5,
idletime = 1800,
losemitheight = 74,
mass = 21755,
maxdamage = 52685,
maxslope = 10,
maxwaterdepth = 0,
name = "Advanced Obliterator",
noautofire = false,
objectname = "tllobliterator1",
onoffable = true,
radardistance = 1200,
radaremitheight = 74,
selfdestructas = "BANTHA_BLAST",
sightdistance = 850,
standingfireorder = 2,
unitname = "tllobliterator1",
usebuildinggrounddecal = true,
yardmap = "ooooooooo ooooooooo ooooooooo ooooooooo ooooooooo ooooooooo ooooooooo",
customparams = {
buildpic = "tllobliterator.dds",
faction = "TLL",
},
featuredefs = {
dead = {
blocking = true,
damage = 29875,
description = "Advanced Obliterator Wreckage",
featuredead = "heap",
footprintx = 5,
footprintz = 4,
metal = 13237,
object = "tllobliterator1_dead",
reclaimable = true,
customparams = {
fromunit = 1,
},
},
heap = {
blocking = false,
damage = 27344,
description = "Advanced Obliterator Debris",
featuredead = "heap2",
footprintx = 5,
footprintz = 4,
metal = 6260,
object = "4x4C",
reclaimable = true,
customparams = {
fromunit = 1,
},
},
heap2 = {
blocking = false,
damage = 16172,
description = "Advanced Obliterator Metal Shards",
footprintx = 4,
footprintz = 4,
metal = 7412,
object = "3x3C",
reclaimable = true,
customparams = {
fromunit = 1,
},
},
},
sfxtypes = {
pieceexplosiongenerators = {
[1] = "piecetrail0",
[2] = "piecetrail1",
[3] = "piecetrail2",
[4] = "piecetrail3",
[5] = "piecetrail4",
[6] = "piecetrail6",
},
},
sounds = {
canceldestruct = "cancel2",
underattack = "warning1",
cant = {
[1] = "cantdo4",
},
count = {
[1] = "count6",
[2] = "count5",
[3] = "count4",
[4] = "count3",
[5] = "count2",
[6] = "count1",
},
ok = {
[1] = "anni",
},
select = {
[1] = "anni",
},
},
weapondefs = {
gauss_tll = {
alphaDecay = 0.5,
areaofeffect = 32,
avoidfeature = false,
cegtag = "GAUSS_HIT_M",
craterareaofeffect = 0,
craterboost = 0,
cratermult = 0,
impulseboost = 0,
impulsefactor = 0,
name = "Gauss",
nogap = 1,
noselfdamage = true,
range = 1800,
reloadtime = 4,
rgbcolor = "0.2 0.2 1.0",
--separation = 0.15,
size = 1.0,
sizedecay = -0.1,
soundhitdry = "soft_crunch",
soundhitwet = "splsmed",
soundhitwetvolume = 0.6,
soundstart = "tllgauss",
stages = 32,
turret = true,
weapontype = "Cannon",
weaponvelocity = 850,
damage = {
commanders = 3200,
default = 6400,
subs = 5,
},
},
},
weapons = {
[1] = {
badtargetcategory = "SMALL TINY",
def = "GAUSS_TLL",
onlytargetcategory = "SURFACE",
},
},
},
}
|
require("ui/node");
local match_hall_record_item_rank_layout = require(ViewPath .. "hall/matchHall/widget/match_hall_record_item_rank_layout");
require("uilibs/userMoneyItem");
local ranklist_pin_map = require("qnFiles/qnPlist/hall/ranklist_pin");
-- 好友排行
local GameMatchHallRecordRankItem = class(Node);
GameMatchHallRecordRankItem.s_defaultWidth = 300;
GameMatchHallRecordRankItem.s_defaultHeight = 300;
GameMatchHallRecordRankItem.setDefaultSize = function(width, height)
GameMatchHallRecordRankItem.s_defaultWidth = width or 300;
GameMatchHallRecordRankItem.s_defaultHeight = height or 300;
end
GameMatchHallRecordRankItem.setOnItemClick = function(obj, func)
GameMatchHallRecordRankItem.s_callbackObj = obj;
GameMatchHallRecordRankItem.s_callbackFunc = func;
end
GameMatchHallRecordRankItem.ctor = function(self, data)
local view = SceneLoader.load(match_hall_record_item_rank_layout);
view:setAlign(kAlignCenter);
view:setFillParent(false, true);
self:addChild(view);
self:setSize(GameMatchHallRecordRankItem.s_defaultWidth, GameMatchHallRecordRankItem.s_defaultHeight);
self:setEventTouch(self, self.onItemClick);
self.m_view = view;
self.m_data = data;
self:initView();
end
GameMatchHallRecordRankItem.dtor = function(self)
self.m_view = nil;
self.m_data = nil;
end
GameMatchHallRecordRankItem.updateListItem = function (self, data)
self.m_data = data;
self:initView();
end
GameMatchHallRecordRankItem.removeData = function(self)
self:setVisible(false);
end
GameMatchHallRecordRankItem.onItemClick = function(self, finger_action, x, y)
if finger_action == kFingerDown then
self.m_moving = false;
self.m_startY = y;
elseif finger_action == kFingerMove then
if math.abs(y - self.m_startY) > 100 then
self.m_moving = true;
end
elseif finger_action == kFingerUp then
if not self.m_moving and GameMatchHallRecordRankItem.s_callbackObj and GameMatchHallRecordRankItem.s_callbackFunc then
GameMatchHallRecordRankItem.s_callbackFunc(GameMatchHallRecordRankItem.s_callbackObj, self.m_data, self);
end
end
end
---------------------------------------------------------------------------------------
GameMatchHallRecordRankItem.initView = function(self)
local data = self.m_data;
local number = self.m_view:getChildByName("number");
local numberImg = self.m_view:getChildByName("numberImg");
local name = self.m_view:getChildByName("name");
local score = self.m_view:getChildByName("score");
local levelBg = self.m_view:getChildByName("levelBg");
local contentView = levelBg:getChildByName("contentView");
local img = contentView:getChildByName("img");
local levelView = contentView:getChildByName("levelView");
if not self.m_levelItem then
self.m_levelItem = new(UserMoneyItem);
self.m_levelItem:setAlign(kAlignLeft);
levelView:addChild(self.m_levelItem);
end
UserMoneyItem.setFilePath(UserMoneyItem.s_matchDetailNumFilePath);
self.m_levelItem:setNormalMoneyNum(tostring(data.level) or "0", 0.4);
UserMoneyItem.setFilePath();
local widthNumber = numberImg:getSize();
number:setVisible(false);
numberImg:setVisible(false);
if data.rank >= 1 and data.rank <= 3 then
local file = ranklist_pin_map[string.format("rank_%s.png", data.rank)];
if file then
numberImg:setFile(file);
end
numberImg:setVisible(true);
else
number:setText(string.format("%s、", data.rank), widthNumber);
widthNumber = number:getSize();
number:setVisible(true);
end
name:setText(data.nick, 1);
score:setText(string.format("%s大师分", data.masterpoints));
local widthName = name:getSize();
name:setPos(widthNumber);
local posLevelBg = widthNumber + widthName;
posLevelBg = math.max(posLevelBg, 200);
levelBg:setPos(posLevelBg);
local widthImg = img:getSize();
local widthLevel = self.m_levelItem:getSize();
contentView:setSize(widthImg + widthLevel);
end
return GameMatchHallRecordRankItem; |
modifier_puck_dream_coil_lua_thinker = class({})
--------------------------------------------------------------------------------
-- Classifications
function modifier_puck_dream_coil_lua_thinker:IsHidden()
return false
end
function modifier_puck_dream_coil_lua_thinker:IsPurgable()
return false
end
--------------------------------------------------------------------------------
-- Initializations
function modifier_puck_dream_coil_lua_thinker:OnCreated( kv )
if IsServer() then
self:PlayEffects()
end
end
function modifier_puck_dream_coil_lua_thinker:OnRefresh( kv )
end
function modifier_puck_dream_coil_lua_thinker:OnDestroy( kv )
if IsServer() then
ParticleManager:DestroyParticle( self.effect_cast, false )
ParticleManager:ReleaseParticleIndex( self.effect_cast )
UTIL_Remove( self:GetParent() )
end
end
--------------------------------------------------------------------------------
-- Graphics & Animations
function modifier_puck_dream_coil_lua_thinker:PlayEffects()
-- Get Resources
local particle_cast = "particles/units/heroes/hero_puck/puck_dreamcoil.vpcf"
-- Create Particle
-- self.effect_cast = ParticleManager:CreateParticle( particle_cast, PATTACH_WORLDORIGIN, self:GetParent() )
self.effect_cast = assert(loadfile("lua_abilities/rubick_spell_steal_lua/rubick_spell_steal_lua_arcana"))(self, particle_cast, PATTACH_WORLDORIGIN, self:GetParent() )
ParticleManager:SetParticleControl( self.effect_cast, 0, self:GetParent():GetOrigin() )
end |
-- Generated using ntangle.nvim
local client1, client2
local nodejs = false
local num_connected = 0
events = {}
local test_passed = 0
local test_failed = 0
local node_finish = false
local log
local assertEq
function log(str)
print(str)
end
function assertEq(val1, val2)
if val1 == val2 then
test_passed = test_passed + 1
log("assertEq(" .. vim.inspect(val1) .. ", " .. vim.inspect(val2) .. ") OK")
else
test_failed = test_failed + 1
log("assertEq(" .. vim.inspect(val1) .. ", " .. vim.inspect(val2) .. ") FAIL")
end
end
local client1 = vim.fn.jobstart({vim.v.progpath, '--embed', '--headless'}, {rpc = true})
local client2 = vim.fn.jobstart({vim.v.progpath, '--embed', '--headless'}, {rpc = true})
vim.fn.rpcrequest(client1, 'nvim_exec', [[let g:instant_username = "test"]], false)
vim.fn.rpcrequest(client2, 'nvim_exec', [[let g:instant_username = "test"]], false)
local stdin, stdout, stderr
if nodejs then
stdin = vim.loop.new_pipe(false)
stdout = vim.loop.new_pipe(false)
stderr = vim.loop.new_pipe(false)
handle, pid = vim.loop.spawn("node",
{
stdio = {stdin, stdout, stderr},
args = { "ws_server.js" },
cwd = "../../server"
}, function(code, signal)
vim.schedule(function()
node_finish = true
log("exit code" .. code)
log("exit signal" .. signal)
end)
end)
if not handle then
print(pid)
else
print("started nodejs server " .. vim.inspect(pid))
end
stdout:read_start(function(err, data)
assert(not err, err)
if data then
vim.schedule(function()
print("nodejs out " .. vim.inspect(data))
end)
table.insert(events, data)
if vim.startswith(data, "Server is listening") then
vim.schedule(function()
vim.fn.rpcrequest(client1, 'nvim_exec', "new", false)
vim.fn.rpcrequest(client2, 'nvim_exec', "new", false)
vim.fn.rpcrequest(client1, 'nvim_exec', "InstantStartSingle 127.0.0.1 8080", false)
vim.wait(1000)
vim.fn.rpcrequest(client2, 'nvim_exec', "InstantJoinSingle 127.0.0.1 8080", false)
end)
end
if vim.startswith(data, "Peer connected") then
vim.schedule(function()
num_connected = num_connected + 1
if num_connected == 2 then
table.insert(events, "Both clients connected and it's all fine")
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "test"} )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "test")
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "hello"} )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "hello")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { ""} )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "test again" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "test again")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "test again", "hey hey" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 2)
assertEq(content2[1], "test again")
assertEq(content2[2], "hey hey")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "a" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "a")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "aaaaaaaa" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "aaaaaaaa")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "hello" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "hello")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "hallo" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "hallo")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "halllo" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "halllo")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "halll" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "halll")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "alll" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "alll")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 1, 1, false, { "test" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 2)
assertEq(content2[1], "alll")
assertEq(content2[2], "test")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 1, 2, false, { "testo" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 2)
assertEq(content2[1], "alll")
assertEq(content2[2], "testo")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 2, 2, false, { "another" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 3)
assertEq(content2[1], "alll")
assertEq(content2[2], "testo")
assertEq(content2[3], "another")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client2, 'nvim_buf_set_lines', 0, 2, 3, false, { "hehe" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 3)
assertEq(content2[1], "alll")
assertEq(content2[2], "testo")
assertEq(content2[3], "hehe")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client2, 'nvim_buf_set_lines', 0, 2, 3, false, { "hat the" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 3)
assertEq(content2[1], "alll")
assertEq(content2[2], "testo")
assertEq(content2[3], "hat the")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client2, 'nvim_buf_set_lines', 0, 0, 1, false, { "lll" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 3)
assertEq(content2[1], "lll")
assertEq(content2[2], "testo")
assertEq(content2[3], "hat the")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { ""} )
vim.wait(100)
local content1 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content1, 1)
assertEq(content1[1], "")
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "")
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "hello"} )
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_command', "normal u")
vim.wait(100)
local content1 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content1, 1)
assertEq(content1[1], "")
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "")
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "hello"} )
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "hllo"} )
vim.wait(500)
vim.fn.rpcrequest(client1, 'nvim_feedkeys', "u", "n", true)
vim.wait(100)
local content1 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content1, 1)
assertEq(content1[1], "hello")
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "hello")
local redo_key = vim.api.nvim_replace_termcodes("<C-r>", true, false, true)
vim.fn.rpcrequest(client1, 'nvim_feedkeys', redo_key, "n", true)
vim.wait(500)
local content1 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content1, 1)
assertEq(content1[1], "hllo")
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "hllo")
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { ""} )
vim.wait(100)
local content1 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content1, 1)
assertEq(content1[1], "")
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "")
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "client1"} )
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client2, 'nvim_buf_set_lines', 0, -1, -1, true, { "client2"} )
vim.wait(100)
local content1 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content1, 2)
assertEq(content1[1], "client1")
assertEq(content1[2], "client2")
vim.wait(1000)
vim.fn.rpcrequest(client1, 'nvim_command', "normal u")
vim.wait(1000)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 2)
assertEq(content2[1], "")
assertEq(content2[2], "client2")
vim.wait(1000)
vim.fn.rpcrequest(client2, 'nvim_command', "normal u")
vim.wait(1000)
local content1 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content1, 1)
assertEq(content1[1], "")
vim.wait(1000)
vim.fn.rpcrequest(client1, 'nvim_exec', "InstantStop", false)
vim.fn.rpcrequest(client2, 'nvim_exec', "InstantStop", false)
end
end)
end
if vim.startswith(data, "Peer disconnected") then
vim.schedule(function()
num_connected = num_connected - 1
log("Peer disconnected " .. num_connected)
if num_connected == 0 then
handle:kill()
end
end)
end
end
end)
stderr:read_start(function(err, data)
assert(not err, err)
if data then
vim.schedule(function()
print("nodejs err " .. vim.inspect(data))
end)
table.insert(events, data)
end
end)
while not node_finish do
vim.wait(1000)
end
vim.fn.jobstop(client1)
vim.fn.jobstop(client2)
else
vim.schedule(function()
vim.fn.rpcrequest(client1, 'nvim_exec', "InstantStartServer", false)
vim.wait(1000)
vim.fn.rpcrequest(client1, 'nvim_exec', "new", false)
vim.fn.rpcrequest(client2, 'nvim_exec', "new", false)
vim.fn.rpcrequest(client1, 'nvim_exec', "InstantStartSingle 127.0.0.1 8080", false)
vim.wait(1000)
vim.fn.rpcrequest(client2, 'nvim_exec', "InstantJoinSingle 127.0.0.1 8080", false)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "test"} )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "test")
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "hello"} )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "hello")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { ""} )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "test again" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "test again")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "test again", "hey hey" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 2)
assertEq(content2[1], "test again")
assertEq(content2[2], "hey hey")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "a" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "a")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "aaaaaaaa" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "aaaaaaaa")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "hello" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "hello")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "hallo" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "hallo")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "halllo" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "halllo")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "halll" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "halll")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "alll" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "alll")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 1, 1, false, { "test" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 2)
assertEq(content2[1], "alll")
assertEq(content2[2], "test")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 1, 2, false, { "testo" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 2)
assertEq(content2[1], "alll")
assertEq(content2[2], "testo")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 2, 2, false, { "another" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 3)
assertEq(content2[1], "alll")
assertEq(content2[2], "testo")
assertEq(content2[3], "another")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client2, 'nvim_buf_set_lines', 0, 2, 3, false, { "hehe" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 3)
assertEq(content2[1], "alll")
assertEq(content2[2], "testo")
assertEq(content2[3], "hehe")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client2, 'nvim_buf_set_lines', 0, 2, 3, false, { "hat the" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 3)
assertEq(content2[1], "alll")
assertEq(content2[2], "testo")
assertEq(content2[3], "hat the")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client2, 'nvim_buf_set_lines', 0, 0, 1, false, { "lll" } )
vim.wait(100)
local content2 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 3)
assertEq(content2[1], "lll")
assertEq(content2[2], "testo")
assertEq(content2[3], "hat the")
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { ""} )
vim.wait(100)
local content1 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content1, 1)
assertEq(content1[1], "")
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "")
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "hello"} )
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_command', "normal u")
vim.wait(100)
local content1 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content1, 1)
assertEq(content1[1], "")
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "")
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "hello"} )
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "hllo"} )
vim.wait(500)
vim.fn.rpcrequest(client1, 'nvim_feedkeys', "u", "n", true)
vim.wait(100)
local content1 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content1, 1)
assertEq(content1[1], "hello")
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "hello")
local redo_key = vim.api.nvim_replace_termcodes("<C-r>", true, false, true)
vim.fn.rpcrequest(client1, 'nvim_feedkeys', redo_key, "n", true)
vim.wait(500)
local content1 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content1, 1)
assertEq(content1[1], "hllo")
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "hllo")
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { ""} )
vim.wait(100)
local content1 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content1, 1)
assertEq(content1[1], "")
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 1)
assertEq(content2[1], "")
vim.wait(100)
vim.fn.rpcrequest(client1, 'nvim_buf_set_lines', 0, 0, -1, true, { "client1"} )
vim.wait(100)
vim.wait(100)
vim.fn.rpcrequest(client2, 'nvim_buf_set_lines', 0, -1, -1, true, { "client2"} )
vim.wait(100)
local content1 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content1, 2)
assertEq(content1[1], "client1")
assertEq(content1[2], "client2")
vim.wait(1000)
vim.fn.rpcrequest(client1, 'nvim_command', "normal u")
vim.wait(1000)
local content2 = vim.fn.rpcrequest(client2, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content2, 2)
assertEq(content2[1], "")
assertEq(content2[2], "client2")
vim.wait(1000)
vim.fn.rpcrequest(client2, 'nvim_command', "normal u")
vim.wait(1000)
local content1 = vim.fn.rpcrequest(client1, 'nvim_buf_get_lines', 0, 0, -1, true)
assertEq(#content1, 1)
assertEq(content1[1], "")
vim.wait(1000)
vim.fn.rpcrequest(client1, 'nvim_exec', "InstantStop", false)
vim.fn.rpcrequest(client2, 'nvim_exec', "InstantStop", false)
vim.wait(1000)
vim.fn.rpcrequest(client1, 'nvim_exec', "InstantStopServer", false)
vim.wait(1000)
log("")
log("PASSED " .. test_passed)
log("")
log("FAILED " .. test_failed)
log("")
vim.fn.jobstop(client1)
vim.fn.jobstop(client2)
if test_failed == 0 then
local f = io.open("result.txt", "w")
f:write("OK")
f:close()
print("OK!")
end
end)
end
|
local dyes = {
{"white", "White", "basecolor_white"},
{"grey", "Grey", "basecolor_grey"},
{"black", "Black", "basecolor_black"},
{"red", "Red", "basecolor_red"},
{"yellow", "Yellow", "basecolor_yellow"},
{"green", "Green", "basecolor_green"},
{"cyan", "Cyan", "basecolor_cyan"},
{"blue", "Blue", "basecolor_blue"},
{"magenta", "Magenta", "basecolor_magenta"},
{"orange", "Orange", "excolor_orange"},
{"violet", "Violet", "excolor_violet"},
{"brown", "Brown", "unicolor_dark_orange"},
{"pink", "Pink", "unicolor_light_red"},
{"light_brown", "Light Brown", "unicolor_light_brown"},
{"dark_grey", "Dark Grey", "unicolor_darkgrey"},
{"dark_green", "Dark Green", "unicolor_dark_green"},
{"royal_blue", "Royal Blue", "unicolor_royal_blue"},
{"lime_green", "Lime Green", "unicolor_lime_green"},
{"gradient_rb", "Gradient (Red/Blue)", "unicolor_gradient_rb"},
}
for i = 1, #dyes do
local name, desc, craft_color_group = unpack(dyes[i])
minetest.register_node("pixel_color:" .. name, {
description = desc .. " Pixel",
tiles = {"pixel_" .. name .. ".png"},
is_ground_content = false,
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3,
flammable = 3, wool = 1},
sounds = default.node_sound_defaults(),
})
end
|
workspace "LZW"
architecture "x86_64"
configurations {
"Release",
"Debug"
}
targetdir "bin/%{cfg.buildcfg}/%{prj.name}"
objdir "obj/%{cfg.buildcfg}/%{prj.name}"
startproject "LZW_CLI"
filter "system:Windows"
systemversion "latest"
filter "Release"
defines { "NDEBUG", "RELEASE" }
optimize "On"
filter "Debug"
defines { "DEBUG" }
symbols "On"
-- <filesystem> support for all projects
filter "toolset:gcc" -- GCC v8.x
links "stdc++fs"
filter "toolset:clang" -- clang
if _OPTIONS["cc"] == "clang" then
premake.warn("Clang is not supporterd yet. Problems with <filesystem> may occur.")
end
--links "c++fs"
--buildoptions {"-stdlib=libc++"}
filter {}
-- LZW_Core project cotains logic and algorithms for LZW coding.
-- It also manages filesystem for input and output data.
project "LZW_Core"
location "LZW_Core"
kind "StaticLib"
language "C++"
cppdialect "C++17"
targetname "lzw_core"
files {
"%{prj.name}/src/**.hpp",
"%{prj.name}/src/**.cpp"
}
filter "Release"
optimize "Speed"
-- Simple Command-Line Interface for LZW_Core.
-- There should be no critical logic here.
project "LZW_CLI"
location "LZW_CLI"
kind "ConsoleApp"
language "C++"
cppdialect "C++17"
targetname "lzw"
files {
"%{prj.name}/src/**.hpp",
"%{prj.name}/src/**.cpp",
"%{prj.name}/vendor/CLI/CLI11.hpp"
}
includedirs {
"LZW_Core/src",
"%{prj.name}/vendor"
}
links {
"LZW_Core"
}
group "Tests"
-- Tests project for LZW_Core. It produces executable with
-- embeded CLI from Catch2. Run this program with no arguments
-- to simply run all the tests.
project "LZW_Core_Tests"
location "LZW_Core_Tests"
kind "ConsoleApp"
language "C++"
cppdialect "C++17"
targetname "lzw_core_tests"
files {
"%{prj.name}/src/**.hpp",
"%{prj.name}/src/**.cpp",
"%{prj.name}/vendor/catch2/catch.hpp"
}
includedirs {
"LZW_Core/src",
"%{prj.name}/vendor"
}
links {
"LZW_Core"
}
group ""
-- Additional actions for maintaining project files.
newaction {
trigger = "clean",
description = "Clean project from binaries and obj files",
execute = function ()
print("Removing bin/...")
os.rmdir("./bin")
print("Removing obj/...")
os.rmdir("./obj")
print("Done")
end
}
newaction {
trigger = "reset",
description = "Removes all files ignored by git",
execute = function()
print("Removing generated files...")
os.execute("git clean -Xdf")
print("Done")
end
}
|
local oldInitialize = GUIMinimap.Initialize
function GUIMinimap:Initialize()
gMaskMapName = false
oldInitialize(self)
gMaskMapName = true
end
|
local KUI, E, L, V, P, G = unpack(select(2, ...))
local ElvUF = ElvUI.oUF
assert(ElvUF, "ElvUI was unable to locate oUF.")
--All credits belongs to Merathilis, Blazeflack and Rehok for this mod
-- Cache global variables
local abs = math.abs
local format, match, sub, gsub, len = string.format, string.match, string.sub, string.gsub, string.len
local assert, tonumber, type = assert, tonumber, type
-- WoW API / Variables
local UnitIsDead = UnitIsDead
local UnitClass = UnitClass
local UnitIsGhost = UnitIsGhost
local UnitIsConnected = UnitIsConnected
local UnitHealth, UnitHealthMax = UnitHealth, UnitHealthMax
local UnitName = UnitName
local UnitFactionGroup = UnitFactionGroup
local UnitPower = UnitPower
local IsResting = IsResting
-- GLOBALS: Hex, _COLORS
local textFormatStyles = {
["CURRENT"] = "%.1f",
["CURRENT_MAX"] = "%.1f - %.1f",
["CURRENT_PERCENT"] = "%.1f - %.1f%%",
["CURRENT_MAX_PERCENT"] = "%.1f - %.1f | %.1f%%",
["PERCENT"] = "%.1f%%",
["DEFICIT"] = "-%.1f"
}
local textFormatStylesNoDecimal = {
["CURRENT"] = "%s",
["CURRENT_MAX"] = "%s - %s",
["CURRENT_PERCENT"] = "%s - %.0f%%",
["CURRENT_MAX_PERCENT"] = "%s - %s | %.0f%%",
["PERCENT"] = "%.0f%%",
["DEFICIT"] = "-%s"
}
local shortenNumber = function(number)
if type(number) ~= "number" then
number = tonumber(number)
end
if not number then
return
end
local affixes = {
"",
"k",
"m",
"b",
}
local affix = 1
local dec = 0
local num1 = math.abs(number)
while num1 >= 1000 and affix < #affixes do
num1 = num1 / 1000
affix = affix + 1
end
if affix > 1 then
dec = 2
local num2 = num1
while num2 >= 10 do
num2 = num2 / 10
dec = dec - 1
end
end
if number < 0 then
num1 = -num1
end
return string.format("%."..dec.."f"..affixes[affix], num1)
end
-- Displays CurrentHP | Percent --(2.04b | 100)--
_G["ElvUF"].Tags.Events['health:current-percent-kui'] = 'UNIT_HEALTH_FREQUENT UNIT_MAXHEALTH UNIT_CONNECTION PLAYER_FLAGS_CHANGED'
_G["ElvUF"].Tags.Methods['health:current-percent-kui'] = function(unit)
local status = UnitIsDead(unit) and L["RIP"] or UnitIsGhost(unit) and L["Ghost"] or not UnitIsConnected(unit) and L["Offline"]
if (status) then
return status
else
local CurrentHealth = UnitHealth(unit)
local CurrentPercent = (UnitHealth(unit)/UnitHealthMax(unit))*100
if CurrentPercent > 99.9 then
return shortenNumber(CurrentHealth) .. " | " .. format("%.0f%%", CurrentPercent)
else
return shortenNumber(CurrentHealth) .. " | " .. format("%.1f%%", CurrentPercent)
end
end
end
-- Displays CurrentHP | Percent --(2.04b | 100)--
_G["ElvUF"].Tags.Events['health:current-percent1-kui'] = 'UNIT_HEALTH_FREQUENT UNIT_MAXHEALTH UNIT_CONNECTION PLAYER_FLAGS_CHANGED'
_G["ElvUF"].Tags.Methods['health:current-percent1-kui'] = function(unit)
local status = UnitIsDead(unit) and L["RIP"] or UnitIsGhost(unit) and L["Ghost"] or not UnitIsConnected(unit) and L["Offline"]
if (status) then
return status
else
local CurrentHealth = UnitHealth(unit)
local CurrentPercent = (UnitHealth(unit)/UnitHealthMax(unit))*100
if CurrentPercent > 99.9 then
return format("%.0f%%", CurrentPercent) .. " | " .. shortenNumber(CurrentHealth)
else
return format("%.1f%%", CurrentPercent) .. " | " .. shortenNumber(CurrentHealth)
end
end
end
-- Displays current HP --(2.04B, 2.04M, 204k, 204)--
_G["ElvUF"].Tags.Events['health:deficit-kui'] = 'UNIT_HEALTH_FREQUENT UNIT_MAXHEALTH UNIT_CONNECTION PLAYER_FLAGS_CHANGED'
_G["ElvUF"].Tags.Methods['health:deficit-kui'] = function(unit)
local status = UnitIsDead(unit) and L["RIP"] or UnitIsGhost(unit) and L["Ghost"] or not UnitIsConnected(unit) and L["Offline"]
if (status) then
return status
else
return E:GetFormattedText('DEFICIT', UnitHealth(unit), UnitHealthMax(unit))
end
end
-- Displays current power and 0 when no power instead of hiding when at 0, Also formats it like HP tag
_G["ElvUF"].Tags.Events['power:current-kui'] = 'UNIT_DISPLAYPOWER UNIT_POWER_UPDATE UNIT_POWER_FREQUENT'
_G["ElvUF"].Tags.Methods['power:current-kui'] = function(unit)
local CurrentPower = UnitPower(unit)
return shortenNumber(CurrentPower)
end
-- Displays Power Percent without any decimals
_G["ElvUF"].Tags.Events['power:percent-kui'] = 'UNIT_DISPLAYPOWER UNIT_POWER_UPDATE UNIT_POWER_FREQUENT'
_G["ElvUF"].Tags.Methods['power:percent-kui'] = function(unit)
local CurrentPercent = (UnitPower(unit)/UnitPowerMax(unit))*100
local min = UnitPower(unit, SPELL_POWER_MANA)
if min == 0 then
return nil
else
if CurrentPercent > 99.9 then
return format("%.0f%%", CurrentPercent)
else
return format("%.0f%%", CurrentPercent)
end
end
end
-- Displays long names better --(First Name Second Name Last Name = F.S Last Name)--
_G["ElvUF"].Tags.Methods['name:condensed-kui'] = function(unit)
local name = UnitName(unit)
name = name:gsub('(%S+) ',function(t) return t:sub(1,1)..'.' end)
return name
end |
-- This lua script file represents a lua implementation translation of sample00-mesh with a box instead of a duck.
function initialize()
-- Display splash screen for at least 1 second.
ScreenDisplayer.start("drawSplash", 1000)
_touched = false
_touchX = 0
-- Load font
_font = Font.create("res/ui/arial.gpb")
-- Load mesh/scene from file
_scene = Scene.load("res/lua.scene")
-- Get the box node
_modelNode = _scene:findNode("box")
-- Find the light node
local lightNode = _scene:findNode("directionalLight1")
-- Bind the light node's direction into the box material.
_modelNode:getModel():getMaterial():getParameter("u_directionalLightColor[0]"):setValue(lightNode:getLight():getColor())
_modelNode:getModel():getMaterial():getParameter("u_directionalLightDirection[0]"):bindValue(lightNode, "&Node::getForwardVectorWorld")
-- Update the aspect ratio for our scene's camera to match the current device resolution
local game = Game.getInstance()
_scene:getActiveCamera():setAspectRatio(game:getWidth() / game:getHeight())
-- Create the grid and add it to the scene.
local model = createGridModel()
_scene:addNode("grid"):setModel(model)
-- Load the AI script
game:getScriptController():loadScript("res/ai.lua")
ScreenDisplayer.finish()
end
function update(elapsedTime)
end
-- Avoid allocating new objects every frame.
textColor = Vector4.new(0, 0.5, 1, 1)
function render(elapsedTime)
-- Clear the color and depth buffers.
Game.getInstance():clear(Game.CLEAR_COLOR_DEPTH, Vector4.zero(), 1.0, 0)
-- Visit all the nodes in the scene, drawing the models/mesh.
_scene:visit("drawScene")
-- Draw the fps.
local buffer = string.format("%u\n%s", Game.getInstance():getFrameRate(), _stateMachine:getActiveState():getId())
_font:start()
_font:drawText(buffer, 5, 1, textColor, _font:getSize())
_font:finish()
end
function finalize()
_font = nil
_scene = nil
end
function drawScene(node)
local model = node:getModel()
if model then
model:draw()
end
return true
end
function drawSplash()
local game = Game.getInstance()
game:clear(Game.CLEAR_COLOR_DEPTH, 0, 0, 0, 1, 1.0, 0)
local batch = SpriteBatch.create("res/logo_powered_white.png")
batch:start()
batch:draw(game:getWidth() * 0.5, game:getHeight() * 0.5, 0.0, 512.0, 512.0, 0.0, 1.0, 1.0, 0.0, Vector4.one(), true)
batch:finish()
end
function keyEvent(evt, key)
if evt == Keyboard.KEY_PRESS then
if key == Keyboard.KEY_ESCAPE then
Game.getInstance():exit()
end
end
end
function touchEvent(evt, x, y, contactIndex)
if evt == Touch.TOUCH_PRESS then
_touchTime = Game.getAbsoluteTime()
_touched = true
_touchX = x
elseif evt == Touch.TOUCH_RELEASE then
_touched = false
_touchX = 0
-- Basic emulation of tap to change state
if (Game.getAbsoluteTime() - _touchTime) < 200 then
toggleState()
end
elseif evt == Touch.TOUCH_MOVE then
local deltaX = x - _touchX
_touchX = x
_modelNode:rotateY(math.rad(deltaX * 0.5))
end
end
function createGridModel()
local lineCount = 41
local pointCount = lineCount * 4
local verticesSize = pointCount * (3 + 3)
local vertices = {}
local gridLength = math.floor(lineCount / 2)
local value = -gridLength
while #vertices + 1 < verticesSize do
-- Default line color is dark grey
local red, green, blue = 0.3, 0.3, 0.3
-- Every 10th line is brighter grey
if math.floor(value + 0.5) % 10 == 0 then
red, green, blue = 0.45, 0.45, 0.45
end
-- The Z axis is blue
if value == 0 then
red, green, blue = 0.15, 0.15, 0.7
end
-- Build the lines
vertices[#vertices+1] = value
vertices[#vertices+1] = 0.0
vertices[#vertices+1] = -gridLength
vertices[#vertices+1] = red
vertices[#vertices+1] = green
vertices[#vertices+1] = blue
vertices[#vertices+1] = value
vertices[#vertices+1] = 0.0
vertices[#vertices+1] = gridLength
vertices[#vertices+1] = red
vertices[#vertices+1] = green
vertices[#vertices+1] = blue
-- The X axis is red
if value == 0.0 then
red, green, blue = 0.7, 0.15, 0.15
end
vertices[#vertices+1] = -gridLength
vertices[#vertices+1] = 0.0
vertices[#vertices+1] = value
vertices[#vertices+1] = red
vertices[#vertices+1] = green
vertices[#vertices+1] = blue
vertices[#vertices+1] = gridLength
vertices[#vertices+1] = 0.0
vertices[#vertices+1] = value
vertices[#vertices+1] = red
vertices[#vertices+1] = green
vertices[#vertices+1] = blue
value = value + 1.0
end
local elements = {
VertexFormat.Element.new(VertexFormat.POSITION, 3),
VertexFormat.Element.new(VertexFormat.COLOR, 3)
}
local mesh = Mesh.createMesh(VertexFormat.new(elements, 2), pointCount, false)
if mesh == nil then
return nil, "Error creating grid mesh."
end
mesh:setPrimitiveType(Mesh.LINES)
mesh:setVertexData(vertices, 0, pointCount)
local model = Model.create(mesh)
model:setMaterial("res/lua.material#grid")
return model
end
|
return {
zh = {
-- 系统状态码
[0x000000] = 'ok',
[0x000001] = '验证错误',
[0x000002] = '数据不存在',
[0x000003] = '密码错误',
[0x000004] = '未授权访问',
[0x000005] = '系统错误,数据库错误',
[0x000006] = '请求太频繁,请稍后访问',
[0x000007] = '系统错误,系统数据异常',
[0x000008] = '系统错误,共享内存错误',
[0x000009] = '系统错误,发起 Http 请求错误',
[0x00000A] = '系统错误, Cookie 错误',
[0x00000B] = '系统错误,定时器错误',
[0x00000C] = '系统异常,用户未登录',
-- user module
[0x010001] = '注册失败,手机号已存在',
[0x010002] = '登录失败,手机号或密码错误',
[0x010003] = '登录失败,用户不存在',
[0x010004] = '短信验证失败,短信验证码错误',
[0x010005] = '重置密码失败,旧密码错误',
[0x010006] = '重置密码失败,系统异常',
[0x010007] = '重置密码失败,新密码不能和旧密码相同',
[0x010008] = '获取用户信息失败,系统错误',
[0x010009] = '重置密码失败,用户不存在',
[0x01000A] = '登录失败,短信验证码错误',
-- notify module
[0x020001] = '发送短信验证码失败,请在60秒之后重试',
-- post module
[0x030001] = '获取文章信息失败,文章不存在',
[0x030002] = '更新文章失败,你不是文章作者',
[0x030003] = '获取文章标签失败,标签不存在',
[0x030004] = '删除文章失败,文章不存在或无权限操作',
-- comment module
[0x040002] = '发布评论失败,关联文章不存在',
-- oauth module
[0x050001] = 'github 授权失败,请返回 https://lua-china.com/login 重新操作',
[0x050002] = 'github 授权失败,系统错误,请返回 https://lua-china.com/login 重新操作',
[0x050003] = 'github 获取用户邮箱失败,请返回 https://lua-china.com/login 重新操作',
[0x050004] = 'github 获取用户基础信息失败,请返回 https://lua-china.com/login 重新操作',
},
en = {
-- system code
[0x000000] = 'ok',
[0x000001] = 'validate error',
[0x000002] = 'data not found',
[0x000003] = 'password error',
[0x000004] = 'no authorization',
[0x000005] = 'database error',
[0x000006] = 'request frequency please be gentle',
[0x000007] = 'system error,data cache error',
[0x000008] = 'shared memory error',
[0x000009] = 'http request err',
[0x00000A] = 'system error, cookie error',
[0x00000B] = 'system error, timer error',
[0x00000C] = 'system error,user not authenticat',
-- user module
[0x010001] = 'phone number already exits',
[0x010002] = 'phone no or password error',
[0x010003] = 'user not exits',
[0x010004] = 'SMS verification failed, SMS code error',
[0x010005] = 'fail to reset password, old password error',
[0x010006] = 'fail to reset password, unknow error',
[0x010007] = 'fail to reset password, new password cannot equal to old password',
[0x010008] = 'fail to get user info, system error',
}
}
|
--[[
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
]]--
function gru_core(x, prev_h)
local function new_input_sum(xv, hv)
local i2h = nn.Linear(params.rnn_size, params.rnn_size)(xv)
local h2h = nn.Linear(params.rnn_size, params.rnn_size)(hv)
return nn.CAddTable()({i2h, h2h})
end
local update_gate = nn.Sigmoid()(new_input_sum(x, prev_h))
local reset_gate = nn.Sigmoid()(new_input_sum(x, prev_h))
-- compute candidate hidden state
local gated_hidden = nn.CMulTable()({reset_gate, prev_h})
local p2 = nn.Linear(params.rnn_size, params.rnn_size)(gated_hidden)
local p1 = nn.Linear(params.rnn_size, params.rnn_size)(x)
local hidden_candidate = nn.Tanh()(nn.CAddTable()({p1,p2}))
-- compute new interpolated hidden state, based on the update gate
local zh = nn.CMulTable()({update_gate, hidden_candidate})
local zhm1 = nn.CMulTable()({nn.AddConstant(1,false)(nn.MulConstant(-1,false)(update_gate)), prev_h})
local next_h = nn.CAddTable()({zh, zhm1})
return next_h
end
function gru(single_input, prev_s)
local i = {[0] = single_input}
local next_s = {}
local split = split(prev_s, params.layers)
for layer_idx = 1, params.layers do
local prev_h = split[layer_idx]
local next_h = gru_core(i[layer_idx - 1], prev_h)
table.insert(next_s, next_h)
i[layer_idx] = next_h
end
return i[params.layers], nn.Identity()(next_s)
end
function feedforward(h, prev_s)
return h, prev_s
end
function lstm_core(x, prev_c, prev_h)
local i2h = nn.Linear(params.rnn_size, 4 * params.rnn_size)(x)
local h2h = nn.Linear(params.rnn_size, 4 * params.rnn_size)(prev_h)
local gates = nn.CAddTable()({i2h, h2h})
local reshaped_gates = nn.Reshape(4, params.rnn_size)(gates)
local sliced_gates = nn.SplitTable(2)(reshaped_gates)
local in_gate = nn.Sigmoid()(nn.SelectTable(1)(sliced_gates))
local in_transform = nn.Tanh()(nn.SelectTable(2)(sliced_gates))
local forget_gate = nn.Sigmoid()(nn.SelectTable(3)(sliced_gates))
local out_gate = nn.Sigmoid()(nn.SelectTable(4)(sliced_gates))
local next_c = nn.CAddTable()({
nn.CMulTable()({forget_gate, prev_c}),
nn.CMulTable()({in_gate, in_transform})
})
local next_h = nn.CMulTable()({out_gate, nn.Tanh()(next_c)})
return next_c, next_h
end
function lstm(single_input, prev_s)
local i = {[0] = single_input}
local next_s = {}
local split = {prev_s:split(2 * params.layers)}
for layer_idx = 1, params.layers do
local prev_c = split[2 * layer_idx - 1]
local prev_h = split[2 * layer_idx]
local next_c, next_h
next_c, next_h = lstm_core(i[layer_idx - 1], prev_c, prev_h)
table.insert(next_s, next_c)
table.insert(next_s, next_h)
i[layer_idx] = next_h
end
return i[params.layers], nn.Identity()(next_s)
end
|
return {
_fold = false,
_id = "APITest",
_type = "APITest",
height = "$fill",
ignoreAnchor = 0,
popOnBack = 1,
width = "$fill"} |
local NoobTacoUI, E, L, V, P, G = unpack(select(2, ...))
function NoobTacoUI:SetupActionBars()
-- Main Actionbar
E.db["actionbar"]["bar1"]["enabled"] = true
E.db["actionbar"]["bar1"]["buttons"] = 12
E.db["actionbar"]["bar1"]["buttonsPerRow"] = 12
E.db["actionbar"]["bar1"]["buttonSize"] = 32
E.db["actionbar"]["bar1"]["backdrop"] = true
E.db["actionbar"]["bar1"]["hotkeyFont"] = "Montserrat-Bold"
E.db["actionbar"]["bar1"]["countFont"] = "Montserrat-Bold"
E.db["actionbar"]["bar1"]["hotkeyFontSize"] = 9
E.db["actionbar"]["bar1"]["hotkeyTextXOffset"] = -2
E.db["actionbar"]["bar1"]["hotkeyFontOutline"] = "NONE"
E.db["actionbar"]["bar1"]["buttonSpacing"] = 2
-- Top Actionbar - BottomLeft
E.db["actionbar"]["bar6"]["enabled"] = true
E.db["actionbar"]["bar6"]["buttons"] = 12
E.db["actionbar"]["bar6"]["buttonsPerRow"] = 12
E.db["actionbar"]["bar6"]["buttonSize"] = 32
E.db["actionbar"]["bar6"]["backdrop"] = true
E.db["actionbar"]["bar6"]["hotkeyFont"] = "Montserrat-Bold"
E.db["actionbar"]["bar6"]["countFont"] = "Montserrat-Bold"
E.db["actionbar"]["bar6"]["hotkeyFontOutline"] = "NONE"
E.db["actionbar"]["bar6"]["hotkeyFontSize"] = 9
E.db["actionbar"]["bar6"]["hotkeyTextXOffset"] = -2
E.db["actionbar"]["bar6"]["buttonSpacing"] = 2
-- Left Actionbar Cluster
E.db["actionbar"]["bar3"]["enabled"] = true
E.db["actionbar"]["bar3"]["buttons"] = 12
E.db["actionbar"]["bar3"]["buttonsPerRow"] = 6
E.db["actionbar"]["bar3"]["buttonSize"] = 25
E.db["actionbar"]["bar3"]["inheritGlobalFade"] = true
E.db["actionbar"]["bar3"]["backdrop"] = true
E.db["actionbar"]["bar3"]["visibility"] = "[vehicleui] hide; [overridebar] hide; [petbattle] hide; show"
E.db["actionbar"]["bar3"]["hotkeyFont"] = "Montserrat-Bold"
E.db["actionbar"]["bar3"]["countFont"] = "Montserrat-Bold"
E.db["actionbar"]["bar3"]["hotkeyFontOutline"] = "NONE"
E.db["actionbar"]["bar3"]["hotkeyFontSize"] = 9
E.db["actionbar"]["bar3"]["hotkeyTextXOffset"] = -2
if WOW_PROJECT_ID == WOW_PROJECT_CLASSIC then -- Classic
E.db["actionbar"]["bar3"]["buttonSpacing"] = 1
end
if WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC then -- TBCc
E.db["actionbar"]["bar3"]["buttonSpacing"] = 2
end
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then -- Retail
E.db["actionbar"]["bar3"]["buttonSpacing"] = 2
end
-- Right Actionbar Cluster - BottomRight
E.db["actionbar"]["bar5"]["enabled"] = true
E.db["actionbar"]["bar5"]["buttons"] = 12
E.db["actionbar"]["bar2"]["mouseover"] = false
E.db["actionbar"]["bar5"]["buttonsPerRow"] = 6
E.db["actionbar"]["bar5"]["buttonSize"] = 25
E.db["actionbar"]["bar5"]["inheritGlobalFade"] = true
E.db["actionbar"]["bar5"]["backdrop"] = true
E.db["actionbar"]["bar5"]["visibility"] = "[vehicleui] hide; [overridebar] hide; [petbattle] hide; show"
E.db["actionbar"]["bar5"]["hotkeyFont"] = "Montserrat-Bold"
E.db["actionbar"]["bar5"]["countFont"] = "Montserrat-Bold"
E.db["actionbar"]["bar5"]["hotkeyFontOutline"] = "NONE"
E.db["actionbar"]["bar5"]["hotkeyFontSize"] = 9
E.db["actionbar"]["bar5"]["hotkeyTextXOffset"] = -2
if WOW_PROJECT_ID == WOW_PROJECT_CLASSIC then -- Classic
E.db["actionbar"]["bar5"]["buttonSpacing"] = 1
end
if WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC then -- TBCc
E.db["actionbar"]["bar5"]["buttonSpacing"] = 2
end
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then -- Retail
E.db["actionbar"]["bar5"]["buttonSpacing"] = 2
end
E.db["actionbar"]["bar2"]["enabled"] = true
E.db["actionbar"]["bar2"]["buttons"] = 12
E.db["actionbar"]["bar2"]["mouseover"] = true
E.db["actionbar"]["bar2"]["inheritGlobalFade"] = true
E.db["actionbar"]["bar2"]["backdrop"] = true
E.db["actionbar"]["bar2"]["buttonsPerRow"] = 2
E.db["actionbar"]["bar2"]["buttonSize"] = 25
E.db["actionbar"]["bar2"]["hotkeyFont"] = "Montserrat-Bold"
E.db["actionbar"]["bar2"]["countFont"] = "Montserrat-Bold"
E.db["actionbar"]["bar2"]["hotkeyFontOutline"] = "NONE"
E.db["actionbar"]["bar2"]["hotkeyFontSize"] = 9
E.db["actionbar"]["bar2"]["hotkeyTextXOffset"] = -2
-- Disabled Actionbars
E.db["actionbar"]["bar4"]["enabled"] = false
E.db["actionbar"]["bar6"]["visibility"] = "[overridebar] hide; [petbattle] hide; show"
-- Actionbar Options from import
E.db["actionbar"]["fontColor"]["r"] = 0.68235294117647
E.db["actionbar"]["fontColor"]["g"] = 0.68235294117647
E.db["actionbar"]["fontColor"]["b"] = 0.68235294117647
E.db["actionbar"]["flashAnimation"] = true
E.db["actionbar"]["fontOutline"] = "NONE"
E.db["actionbar"]["noRangeColor"]["r"] = 0.74901960784314
E.db["actionbar"]["noRangeColor"]["g"] = 0.38039215686275
E.db["actionbar"]["noRangeColor"]["b"] = 0.4156862745098
E.db["actionbar"]["notUsableColor"]["r"] = 0.26274509803922
E.db["actionbar"]["notUsableColor"]["g"] = 0.29803921568627
E.db["actionbar"]["notUsableColor"]["b"] = 0.36862745098039
E.db["actionbar"]["microbar"]["enabled"] = true
E.db["actionbar"]["microbar"]["mouseover"] = true
E.db["actionbar"]["font"] = "Montserrat-Bold"
E.db["actionbar"]["noPowerColor"]["r"] = 0.36862745098039
E.db["actionbar"]["noPowerColor"]["g"] = 0.56862745098039
E.db["actionbar"]["noPowerColor"]["b"] = 0.67450980392157
E.db["actionbar"]["usableColor"]["r"] = 0.92549019607843
E.db["actionbar"]["usableColor"]["g"] = 0.93725490196078
E.db["actionbar"]["usableColor"]["b"] = 0.95686274509804
E.db["actionbar"]["transparent"] = true
E.db["actionbar"]["addNewSpells"] = true
E.db["actionbar"]["stanceBar"]["buttonSize"] = 25
E.db["actionbar"]["stanceBar"]["buttonsPerRow"] = 1
E.db["actionbar"]["stanceBar"]["hotkeyFont"] = "Montserrat-Bold"
E.db["actionbar"]["stanceBar"]["hotkeyFontOutline"] = "NONE"
E.db["actionbar"]["stanceBar"]["hotkeyFontSize"] = 9
E.db["actionbar"]["stanceBar"]["hotkeyTextXOffset"] = -2
E.db["actionbar"]["barPet"]["buttonsPerRow"] = 10
E.db["actionbar"]["barPet"]["buttonSize"] = 25
E.db["actionbar"]["barPet"]["point"] = "TOPLEFT"
E.db["actionbar"]["barPet"]["hotkeyFont"] = "Montserrat-Bold"
E.db["actionbar"]["barPet"]["hotkeyFontOutline"] = "NONE"
E.db["actionbar"]["barPet"]["hotkeyFontSize"] = 9
E.db["actionbar"]["barPet"]["hotkeyTextXOffset"] = -2
end |
local config_dbg_core = slc.config("SL_CPC_DEBUG_SYSTEM_VIEW_LOG_CORE_EVENT")
local config_dbg_endpoint = slc.config("SL_CPC_DEBUG_SYSTEM_VIEW_LOG_ENDPOINT_EVENT")
if config_dbg_core.value == "1" and not slc.is_provided("segger_systemview") then
validation.error(
"Segger System View is required when SL_CPC_DEBUG_SYSTEM_VIEW_LOG_CORE_EVENT is enabled",
validation.target_for_defines({"SL_CPC_DEBUG_SYSTEM_VIEW_LOG_CORE_EVENT"}),
nil,
nil)
elseif config_dbg_endpoint.value == "1" and not slc.is_provided("segger_systemview") then
validation.error(
"Segger System View is required when SL_CPC_DEBUG_SYSTEM_VIEW_LOG_ENDPOINT_EVENT is enabled",
validation.target_for_defines({"SL_CPC_DEBUG_SYSTEM_VIEW_LOG_ENDPOINT_EVENT"}),
nil,
nil)
end
local config_security = slc.config("SL_CPC_ENDPOINT_SECURITY_ENABLED")
if config_security.value == "1" then
local config_binding_key = slc.config("SL_CPC_SECURITY_BINDING_KEY_METHOD")
if config_binding_key.value == "SL_CPC_SECURITY_BINDING_KEY_NONE" then
validation.error(
"CPC encryption is enabled but binding method is selected as none",
validation.target_for_defines({"SL_CPC_SECURITY_BINDING_KEY_METHOD"}),
nil,
nil)
end
end |
require("lspconfig").prismals.setup({
root_dir = function()
return vim.loop.cwd()
end,
})
|
local _, NeP = ...
local _G = _G
NeP.Core = {}
local last_print = ""
function NeP.Core.Print(_, ...)
if last_print ~= ... then
last_print = ...
print('[|cff'..NeP.Color..'NeP|r]', ...)
end
end
local d_color = {
hex = 'FFFFFF',
rgb = {1,1,1}
}
function NeP.Core.ClassColor(_, unit, type)
type = type and type:lower() or 'hex'
if _G.UnitExists(unit) then
local classid = select(3, _G.UnitClass(unit))
if classid then
return NeP.ClassTable:GetClassColor(classid, type)
end
end
return d_color[type]
end
function NeP.Core.Round(_, num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
function NeP.Core.GetSpellID(_, spell)
local _type = type(spell)
if not spell then
return
elseif _type == 'string' and spell:find('^%d') then
return tonumber(spell)
end
local index, stype = NeP.Core:GetSpellBookIndex(spell)
local spellID = select(7, _G.GetSpellInfo(index, stype))
return spellID
end
function NeP.Core.GetSpellName(_, spell)
if not spell or type(spell) == 'string' then return spell end
local spellID = tonumber(spell)
if spellID then
return _G.GetSpellInfo(spellID)
end
return spell
end
function NeP.Core.GetItemID(_, item)
if not item or type(item) == 'number' then return item end
local itemID = string.match(select(2, _G.GetItemInfo(item)) or '', 'Hitem:(%d+):')
return tonumber(itemID) or item
end
function NeP.Core.UnitID(_, unit)
if unit and _G.UnitExists(unit) then
local guid = _G.UnitGUID(unit)
if guid then
local type, _, server_id,_,_, npc_id = _G.strsplit("-", guid)
if type == "Player" then
return tonumber(server_id)
elseif npc_id then
return tonumber(npc_id)
end
end
end
end
function NeP.Core.GetSpellBookIndex(_, spell)
local spellName = NeP.Core:GetSpellName(spell)
if not spellName then return end
spellName = spellName:lower()
for t = 1, 2 do
local _, _, offset, numSpells = _G.GetSpellTabInfo(t)
for i = 1, (offset + numSpells) do
if _G.GetSpellBookItemName(i, _G.BOOKTYPE_SPELL):lower() == spellName then
return i, _G.BOOKTYPE_SPELL
end
end
end
local numFlyouts = _G.GetNumFlyouts()
for f = 1, numFlyouts do
local flyoutID = _G.GetFlyoutID(f)
local _, _, numSlots, isKnown = _G.GetFlyoutInfo(flyoutID)
if isKnown and numSlots > 0 then
for g = 1, numSlots do
local spellID, _, isKnownSpell = _G.GetFlyoutSlotInfo(flyoutID, g)
local name = NeP.Core:GetSpellName(spellID)
if name and isKnownSpell and name:lower() == spellName then
return spellID, nil
end
end
end
end
local numPetSpells = _G.HasPetSpells()
if numPetSpells then
for i = 1, numPetSpells do
if _G.GetSpellBookItemName(i, _G.BOOKTYPE_PET):lower() == spellName then
return i, _G.BOOKTYPE_PET
end
end
end
end
local Run_Cache = {}
function NeP.Core.WhenInGame(_, func, prio)
if Run_Cache then
table.insert(Run_Cache, {func = func, prio = prio or -(#Run_Cache)})
else
func()
end
end
function NeP.Core.HexToRGB(_, hex)
return tonumber("0x"..hex:sub(1,2)), tonumber("0x"..hex:sub(3,4)), tonumber("0x"..hex:sub(5,6))
end
function NeP.Core.string_split(_, string, delimiter)
local result, from = {}, 1
local delim_from, delim_to = string.find(string, delimiter, from)
while delim_from do
table.insert( result, string.sub(string, from , delim_from-1))
from = delim_to + 1
delim_from, delim_to = string.find(string, delimiter, from)
end
table.insert(result, string.sub(string, from))
return result
end
NeP.Listener:Add("NeP_Core_load", "PLAYER_LOGIN", function()
_G.C_Timer.After(5, function()
table.sort(Run_Cache, function(a,b) return a.prio > b.prio end)
NeP.Color = NeP.Core:ClassColor('player', 'hex')
for i=1, #Run_Cache do
Run_Cache[i].func()
end
Run_Cache = nil
end)
end)
|
---
--- this demo shows how to use memory data: new/foreach/convert/isValid
--- memory support types: f, d, w, b, i, s, c, F
--- float, uint32, uint16, uint8, int, short, signed char, double
---
local mem = require("memory")
local me;
print("------------ start test value range of 'fdwbiscF' --------------")
me = mem.new("fdwbiscF", {1.1,2,3,4,5,6,7,8.88}, {11,12,13,14,15,16,17,18})
print("me = ", me)
me = mem.new("fdwbiscF", {1.1,4294967295,65535,255, 2147483647,32767,127,8.88});
print("max range: me = ", me)
me = mem.new("fdwbiscF", {1.1,4294967295+1,65535+1,255+1, 2147483647+1,32767+1,127+1,8.88});
print("over max range: me = ", me)
me = mem.new("fdwbiscF", {0,0,0,0, -2147483648,-32768,-128,8.88});
print("min range: me = ", me)
me = mem.new("fdwbiscF", {0,-1, -1, -1, -2147483648-1,-32768-1,-128-1,8.88});
print("less min range: me = ", me)
print("-------------- start test foreach ---------------")
me = mem.new('d', {1,2,3,4,5,6})
me.foreach(function (index, value)
print("foreach: d", index, value);
end);
me = mem.new("fdwbiscF", {1.1,2,3,4,5,6,7,8.88});
me.foreach(function (index, value)
print("foreach: fdwbiscF", index, value);
end);
print("---------------- start test convert -------------- ")
me = mem.new('d', {1,2,3,4,5,6})
me = me.convert('fff')
print("convert: fff", me);
me = mem.new("fdwbiscF", {1.1,2,3,4,5,6,7,8.88});
me = me.convert('iiii');
print("convert: iiii", me);
print("isValid", me.isValid())
|
data:extend({
{ --nuclear furnace
type = "recipe",
name = "nuclear-furnace",
enabled = false,
ingredients = {
{"steel-plate", 25}, {"refined-concrete", 20}, {"processing-unit", 5}
},
result = "nuclear-furnace",
},
{ --nuclear inserter
type = "recipe",
name = "nuclear-inserter",
enabled = false,
ingredients = {
{"stack-inserter", 1}, {"processing-unit", 1}, {"steel-plate", 15}, {"advanced-circuit", 15}
},
result = "nuclear-inserter",
},
{ --liquid mercury
type = "recipe",
name = "liquid-mercury",
category = "chemistry",
enabled = false,
energy_required = 3,
ingredients = {
{type = "item", name = "cinnabar", amount = 10},
},
results = {
{type = "fluid", name ="liquid-mercury", amount = 60},
},
subgroup = "fluid-recipes",
crafting_machine_tint = {
primary = {r = 67, g = 71, b = 74},
secondary = {r = 61, g = 12, b = 12},
tertiary = {r = 74, g = 70, b = 70},
quaternary = {r = 74, g = 61, b = 61},
},
},
{ --salt using mercury (calomel-electrodes)
type = "recipe",
name = "salt-calomel",
category = "chemistry",
enabled = false,
energy_required = 5,
ingredients = {
{type = "fluid", name = "water", amount = 100},
{type = "fluid", name = "liquid-mercury", amount = 5},
},
results = {
{type = "item", name = "salt", amount = 5},
},
subgroup = "fluid-recipes",
icon = "__GnosticTest__/graphics/recipe/salt-calomel.png",
icon_size = 64, icon_mipmaps = 4,
crafting_machine_tint = {
primary = {r = 205, g = 210, b = 202},
secondary = {r = 0, g = 105, b = 148},
tertiary = {r = 112, g = 128, b = 144},
quaternary = {r = 141, g = 166, b = 191},
},
},
{ --salt using evaporation (salt-refining)
type = "recipe",
name = "salt-evaporate",
category = "chemistry",
enabled = false,
energy_required = 10,
ingredients = {
{type = "fluid", name = "water", amount = 150},
},
results = {
{type = "item", name = "salt", amount = 5},
},
subgroup = "fluid-recipes",
crafting_machine_tint = {
primary = {r = 214, g = 235, b = 255},
secondary = {r = 159, g = 207, b = 251},
tertiary = {r = 244, g = 229, b = 229},
quaternary = {r = 208, g = 224, b = 227},
},
},
{ --molten salt
type = "recipe",
name = "molten-salt",
category = "chemistry",
enabled = false,
energy_required = 12,
ingredients = {
{type = "item", name = "salt", amount = 10},
},
results = {
{type = "fluid", name = "molten-salt", amount = 15},
},
subgroup = "fluid-recipes",
crafting_machine_tint = {
primary = {r = 255, g = 122, b = 50},
secondary = {r = 176, g = 32, b = 16},
tertiary = {r = 255, g = 90, b = 0},
quaternary = {r = 199, g = 36, b = 18},
},
},
{ --molten salt fuel cell
type = "recipe",
name = "molten-salt-fuel-cell",
category = "crafting-with-fluid",
enabled = false,
energy_required = 20,
ingredients = {
{type = "fluid", name = "molten-salt", amount = 100},
{type = "item", name = "uranium-235", amount = 2},
{type = "item", name = "uranium-238", amount = 13},
{type = "item", name = "iron-plate", amount = 10},
},
result = "molten-salt-fuel-cell",
},
{ --depleted molten salt fuel cell reprocessing
type = "recipe",
name = "molten-salt-reprocessing",
energy_required = 75,
enabled = false,
category = "centrifuging",
ingredients = {
{"depleted-molten-salt-fuel-cell", 5},
},
main_product = "",
results = {
{"salt", 10}, {"uranium-238", 3},
},
icon = "__GnosticTest__/graphics/recipe/molten-salt-reprocessing.png",
icon_size = 64, icon_mipmaps = 4,
subgroup = "intermediate-product",
order = "s[molten-salt-fuel-cell]-b[molten-salt-reprocessing]",
allow_decomposition = false,
},
{ --Downs cell sodium production from molten salt/ molten salt electrolysis
type = "recipe",
name = "downs-cell",
category = "chemistry",
enabled = false,
energy_required = 3.6,
ingredients = {
{type = "fluid", name = "molten-salt", amount = 20},
{type = "item", name = "iron-plate", amount = 1},
},
results = {
{type = "item", name = "sodium", amount = 10},
{type = "fluid", name = "chlorine", amount = 5},
},
subgroup = "fluid-recipes",
icon = "__GnosticTest__/graphics/recipe/downs-cell.png",
icon_size = 64, icon_mipmaps = 4,
crafting_machine_tint = {
primary = {r = 255, g = 147, b = 51},
secondary = {r = 155, g = 76, b = 16},
tertiary = {r = 255, g = 196, b = 0},
quaternary = {r = 255, g = 239, b = 0},
},
},
{ --biolab
type = "recipe",
name = "biolab",
enabled = false,
ingredients = {
{"iron-plate", 10}, {"copper-cable", 5}, {"electronic-circuit", 10},
},
result = "biolab",
},
{ --offal / fish bones (fish liquefaction)
type = "recipe",
name = "fish-liquefaction",
category = "biology",
enabled = false,
energy_required = 1,
ingredients = {
{type = "item", name = "raw-fish", amount = 1},
},
results ={
{type = "item", name = "offal", amount = 5},
{type = "item", name = "fish-bones", amount = 1},
},
icon = "__GnosticTest__/graphics/recipe/fish-liquefaction.png",
icon_size = 64, icon_mipmaps = 4,
subgroup = "raw-material",
order = "h[fish-liquefaction]",
},
{ --biological waste / fish extract
type = "recipe",
name = "offal-separation",
category = "chemistry",
enabled = false,
energy_required = 20,
main_product = "fish-extract",
ingredients = {
{type = "item", name = "offal", amount = 50},
},
results = {
{type = "fluid", name = "fish-extract", amount = 500},
{type = "item", name = "biological-waste", amount = 50},
},
subgroup = "fluid-recipes",
order = "c[fish-extract]",
crafting_machine_tint = {
primary = {r = 250, g = 128, b = 114},
secondary = {r = 249, g = 106, b = 89},
tertiary = {r = 240, g = 128, b = 128},
quaternary = {r = 246, g = 178, b = 178},
},
},
{ --water electrolysis (hydrogen and oxygen)
type = "recipe",
name = "water-electrolysis",
category = "chemistry",
enabled = true,
energy_required = 8,
ingredients = {
{type = "fluid", name = "water", amount = 20},
},
results = {
{type = "fluid", name = "hydrogen", amount = 10},
{type = "fluid", name = "oxygen", amount = 10}
},
icon = "__GnosticTest__/graphics/recipe/water-electrolysis.png",
icon_size = 64, icon_mipmaps = 4,
subgroup = "fluid-recipes",
crafting_machine_tint = {
primary = {r = 82, g = 180, b = 217},
secondary = {r = 98, g = 171, b = 199},
tertiary = {r = 201, g = 208, b = 209},
quaternary = {r = 210, g = 219, b = 220},
},
},
{ --geothermal derrick
type = "recipe",
name = "geothermal-derrick",
enabled = false,
ingredients = {
{"steel-plate", 5}, {"iron-gear-wheel", 10}, {"electronic-circuit", 5}, {"pipe", 10},
},
result = "geothermal-derrick",
},
}
)
|
local assets =
{
-- Asset("ANIM", "anim/blacklotus.zip"),
-- Asset("ANIM", "anim/swap_darklotus.zip"),
-- Asset("ANIM", "anim/swap_lightlotus.zip"),
}
local function fx_enable(inst)
local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner or nil
if owner ~= nil then
if inst._fx == nil then
inst._fx = SpawnPrefab("nightsword_curve_fx")
inst._fx.entity:AddFollower()
end
inst._fx.entity:SetParent(owner.entity)
inst._fx.Follower:FollowSymbol(owner.GUID, "swap_object", 0, -100, 0)
end
end
local function fx_disable(inst)
if inst._fx ~= nil then
inst._fx:Remove()
inst._fx = nil
end
end
local function onremove(inst)
fx_disable(inst)
end
local function onfinished(inst)
local owner = inst.components.inventoryitem.owner or nil
if owner ~= nil and owner.prefab == "civi" and owner.components.inventory then
local inv = owner.components.inventory
if inst.prefab == "darklotus" and inv:Has("darkgem",1) then
inv:ConsumeByName("darkgem",1)
inst.components.finiteuses:SetPercent(1)
SpawnPrefab("pandorachest_reset").entity:SetParent(owner.entity)
elseif inst.prefab == "lightlotus" and inv:Has("lightgem",1) then
inv:ConsumeByName("lightgem",1)
inst.components.finiteuses:SetPercent(1)
SpawnPrefab("pandorachest_reset").entity:SetParent(owner.entity)
else
inst:Remove()
end
else
inst:Remove()
end
end
local function onequip_dark(inst, owner)
owner.AnimState:OverrideSymbol("swap_object", "swap_darklotus", "swap_machete")
owner.AnimState:Show("ARM_carry")
owner.AnimState:Hide("ARM_normal")
fx_enable(inst)
end
local function onequip_light(inst, owner)
owner.AnimState:OverrideSymbol("swap_object", "swap_lightlotus", "swap_machete")
owner.AnimState:Show("ARM_carry")
owner.AnimState:Hide("ARM_normal")
end
local function onunequip(inst, owner)
owner.AnimState:Hide("ARM_carry")
owner.AnimState:Show("ARM_normal")
fx_disable(inst)
end
local function darkfn()
local inst = CreateEntity()
inst.entity:AddTransform()
inst.entity:AddAnimState()
inst.entity:AddNetwork()
inst.entity:AddSoundEmitter()
MakeInventoryPhysics(inst)
inst.AnimState:SetBank("blacklotus")
inst.AnimState:SetBuild("blacklotus")
inst.AnimState:PlayAnimation("idle_dark")
inst:AddTag("shadow")
inst:AddTag("sharp")
inst:AddTag("weapon")
local swap_data = {sym_build = "swap_darklotus", sym_name = "swap_machete", bank = "blacklotus", anim="idle_dark"}
MakeInventoryFloatable(inst, "med", -0.05, {1.0, 0.4, 1.0}, true, -18, swap_data)
inst.entity:SetPristine()
if not TheWorld.ismastersim then
return inst
end
inst:AddComponent("halloweenmoonmutable")
inst:AddComponent("weapon")
inst.components.weapon:SetDamage(76.5)
inst:AddComponent("finiteuses")
inst.components.finiteuses:SetMaxUses(100)
inst.components.finiteuses:SetUses(100)
inst.components.finiteuses:SetOnFinished(onfinished)
inst:AddComponent("inspectable")
inst:AddComponent("inventoryitem")
inst:AddComponent("equippable")
inst.components.equippable:SetOnEquip(onequip_dark)
inst.components.equippable:SetOnUnequip(onunequip)
inst.components.equippable.dapperness = (TUNING.CRAZINESS_MED * 1.5)
MakeHauntableLaunch(inst)
inst.OnRemoveEntity = onremove
inst:DoTaskInTime(0, function(inst)
inst.components.halloweenmoonmutable:Mutate("nightsword")
end)
return inst
end
local function lightfn()
local inst = CreateEntity()
inst.entity:AddTransform()
inst.entity:AddAnimState()
inst.entity:AddNetwork()
inst.entity:AddSoundEmitter()
MakeInventoryPhysics(inst)
inst.AnimState:SetBank("blacklotus")
inst.AnimState:SetBuild("blacklotus")
inst.AnimState:PlayAnimation("idle_light")
inst:AddTag("shadow")
inst:AddTag("sharp")
inst:AddTag("weapon")
local swap_data = {sym_build = "swap_lightlotus", sym_name = "swap_machete", bank = "blacklotus", anim="idle_light"}
MakeInventoryFloatable(inst, "med", -0.05, {1.0, 0.4, 1.0}, true, -18, swap_data)
inst.entity:SetPristine()
if not TheWorld.ismastersim then
return inst
end
inst:AddComponent("halloweenmoonmutable")
inst:AddComponent("weapon")
inst.components.weapon:SetDamage(68)
inst:AddComponent("finiteuses")
inst.components.finiteuses:SetMaxUses(120)
inst.components.finiteuses:SetUses(120)
inst.components.finiteuses:SetOnFinished(onfinished)
inst:AddComponent("inspectable")
inst:AddComponent("inventoryitem")
inst:AddComponent("equippable")
inst.components.equippable:SetOnEquip(onequip_light)
inst.components.equippable:SetOnUnequip(onunequip)
MakeHauntableLaunch(inst)
inst:DoTaskInTime(0, function(inst)
inst.components.halloweenmoonmutable:Mutate("nightsword")
end)
return inst
end
return Prefab("darklotus", darkfn, assets),
Prefab("lightlotus",lightfn, assets)
|
return {
id = "ingotCopper",
name = "Copper Ingot",
tier = 2,
spriteSheet = "materials",
spriteCoords = Vector2.new(4,2),
recipe = {
oreCopper = 15,
},
craftQuantity = 5,
tags = {
"material",
}
} |
-- This code is licensed under the MIT Open Source License.
-- Copyright (c) 2015 Ruairidh Carmichael - ruairidhcarmichael@live.co.uk
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
local server = {}
local net = require 'engine.libs.LUBE'
function server.start(port)
if not CLIENT then
print('[network] Starting server ...')
server.internal = net.lubeServer()
server.internal.handshake = "80085"
server.internal:listen(port or "18025")
server.internal.callbacks.connect = server.onConnect or function()
print('[network] Player connected, but a handler does not exist (make one) [network.server.onConnect(id)].')
end
server.internal.callbacks.recv = server.onReceive or function()
print('[network] Packet received, but a handler does not exist (make one) [network.server.onReceive(packet, id)].')
end
server.internal.callbacks.disconnect = server.onDisconnect or function()
print('[network] Player disconnected, but a handler does not exist (make one) [network.server.onDisconnect(id)].')
end
SERVER = true
else
error('[network] Can\'nt start Server when Client is running')
end
end
function server.update(dt)
server.internal:update(dt)
end
function server.send(name, data, id)
if SERVER then
local packet = {
name = name,
data = data
}
local packagedtbl = json.encode(packet)
if id then
server.internal:send(packagedtbl, id)
else
server.internal:send(packagedtbl)
end
end
end
return server |
local cv = require 'cv'
require 'cv.features2d'
require 'cv.imgcodecs'
require 'cv.highgui'
if not arg[1] then
print('Usage: `th demo/descriptors.lua path-to-image`')
print('Now using demo/lena.jpg')
end
local image = cv.imread{arg[1] or 'demo/lena.jpg'}
if not image then
print("Problem loading image\n")
os.exit(0)
end
cv.namedWindow{"win1"}
cv.setWindowTitle{"win1", "Original image"}
cv.imshow{"win1", image}
cv.waitKey{0}
local AGAST = cv.AgastFeatureDetector{threshold=34}
local keyPts = AGAST:detect{image}
-- show keypoints to the user
local imgWithAllKeypoints = cv.drawKeypoints{image, keyPts}
cv.setWindowTitle{"win1", keyPts.size .. " keypoints by AGAST"}
cv.imshow{"win1", imgWithAllKeypoints}
cv.waitKey{0}
-- remove keypoints within 60 pixels from image border
local imageSize = {image:size()[2], image:size()[1]}
keyPts = cv.KeyPointsFilter.runByImageBorder{keyPts, imageSize, 60}
-- show again, with reduced number of keypoints
local imgWithSomeKeypoints = cv.drawKeypoints{image, keyPts}
cv.setWindowTitle{"win1", keyPts.size .. " remaining keypoints"}
cv.imshow{"win1", imgWithSomeKeypoints}
cv.waitKey{0}
|
-- fall (1.0.2)
--
-- generative melodies
--
-- E2: Add/remove leaves
-- E3: Cycle attack/release times
-- K2: Rand notes
-- K3: Rand notes and scales
--
-- written by ambalek for
-- the norns community
-- luacheck: globals engine clock util screen softcut enc key audio init redraw midi params include
local settings = include("lib/settings")
local SoundConfigPage = include("lib/page.sound")
local ScaleConfigPage = include("lib/page.scales")
local DelayConfigPage = include("lib/page.delays")
local LFOPage = include("lib/page.lfo")
local LFO = include("lib/lfo")
local MusicUtil = require "musicutil"
local UI = require "ui"
local ground_level = 58
local screen_width = 120
local midi_device = nil
local midi_start_note = settings.midi_start_note
local midi_end_note = settings.midi_end_note
local max_light_leaves = 20
local max_heavy_leaves = 10
local crow_gate_voltages = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
local visual_timers = {
default_time = 1500,
attack = 0,
release = 0
}
engine.name = 'Autumn'
local pages = UI.Pages.new(1, 5)
local function use_midi()
return params:get("use_midi") == 1
end
local function use_crow()
return params:get("use_crow") == 1
end
local function panic()
if use_midi() then
for note = 1, 127 do
for channel = 1, 16 do
midi_device:note_off(note, 0, channel)
end
end
end
end
local function make_scale_options()
local scale_index = params:get("scale")
local random_scale = settings.scales[scale_index]
local start_note = params:get("root_note")
return {
high = MusicUtil.generate_scale(start_note, random_scale, 2),
bass = MusicUtil.generate_scale(start_note - 12, random_scale, 1),
}
end
local function make_new_scale_options()
params:set("scale", math.random(1, #settings.scales))
params:set("root_note", math.random(midi_start_note, midi_end_note))
return make_scale_options()
end
local scale = nil
-- 4*4 sprites
local sprites = {
leaves = {
{
{ 0, 0, 1, 0 },
{ 0, 1, 1, 0 },
{ 0, 1, 1, 0 },
{ 1, 1, 0, 0 },
},
{
{ 0, 1, 1, 0 },
{ 0, 1, 1, 1 },
{ 0, 0, 1, 1 },
{ 0, 0, 0, 0 },
},
{
{ 0, 0, 0, 0 },
{ 0, 1, 1, 1 },
{ 0, 1, 1, 0 },
{ 1, 1, 0, 0 },
},
{
{ 0, 1, 0, 0 },
{ 0, 1, 1, 0 },
{ 0, 1, 1, 0 },
{ 0, 0, 1, 0 },
},
{
{ 0, 0, 0, 0 },
{ 0, 1, 1, 1 },
{ 1, 1, 1, 0 },
{ 0, 0, 0, 0 },
},
{
{ 1, 0, 0, 0 },
{ 1, 1, 1, 0 },
{ 0, 1, 1, 1 },
{ 0, 0, 0, 0 },
},
{
{ 0, 1, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 1, 0 },
},
}
}
local leaves = {}
local function get_midi_note(bass)
if bass then
return scale.bass[math.random(1, #scale.bass)]
else
return scale.high[math.random(1, #scale.high)]
end
end
local function get_attack(_)
return params:get("attack")
end
local function get_release(_)
return params:get("release")
end
local function make_leaf(bass)
local velocity = math.random(params:get("velocity_min"), params:get("velocity_max"))
if bass then
velocity = math.random(params:get("bass_velocity_min"), params:get("bass_velocity_max"))
end
return {
bass = bass,
sway = math.random(),
speed = math.random() * (params:get("gravity") / 5),
sprite_change = math.random(3, 10),
sprite = math.random(1, #sprites.leaves),
x = math.random(20, 100),
y = math.random(1, 40),
level = math.random(2, 12),
fade = math.random(
params:get("fade_median") - params:get("fade_range"),
params:get("fade_median") + params:get("fade_range")
),
resting = false,
midi_note_number = get_midi_note(bass),
release = get_release(bass),
attack = get_attack(bass),
amp = (velocity / 127),
velocity = velocity,
collision_counter = nil
}
end
local function add_random_leaf()
local bass = math.random() > 0.85
if bass then
params:set("heavy_leaves", util.clamp(params:get("heavy_leaves") + 1, 0, max_heavy_leaves))
else
params:set("light_leaves", util.clamp(params:get("light_leaves") + 1, 1, max_light_leaves))
end
if #leaves < (max_heavy_leaves + max_light_leaves) then
table.insert(leaves, make_leaf(bass))
end
end
local function remove_random_leaf()
if #leaves > 1 then
local id = math.random(1, #leaves)
if leaves[id].bass and params:get("heavy_leaves") > 0 then
params:set("heavy_leaves", params:get("heavy_leaves") - 1)
elseif params:get("light_leaves") > 1 then
params:set("light_leaves", params:get("light_leaves") - 1)
end
table.remove(leaves, id)
end
end
local function get_pan(leaf)
return ((leaf.x / screen_width) - 0.5) * 2
end
local function schedule_note_off(leaf)
local ticks = math.floor(leaf.attack * leaf.release * 16)
clock.run(
function()
while ticks > 0 do
ticks = ticks - 1
clock.sync(1 / 16)
if ticks == 0 then
midi_device:note_off(leaf.midi_note_number, leaf.velocity, params:get("midi_out_channel"))
end
end
end
)
end
local function make_sound()
return params:get("make_sound") == 1
end
local function make_rustle()
return params:get("make_rustle") == 1
end
local function play(leaf)
if make_sound() then
engine.release(leaf.release + LFO.last_release_value)
engine.attack(leaf.attack + LFO.last_attack_value)
engine.pan(get_pan(leaf))
engine.amp(leaf.amp)
engine.hz(MusicUtil.note_num_to_freq(leaf.midi_note_number))
end
if use_midi() and midi_device then
midi_device:note_on(leaf.midi_note_number, leaf.velocity, params:get("midi_out_channel"))
if params:get("use_midi_pan") == 1 then
midi_device:cc(10, math.floor(get_pan(leaf) * 127))
end
schedule_note_off(leaf)
end
if use_crow() then
crow.output[1].volts = (((leaf.midi_note_number)-60)/12)
local gate_voltage = params:get("crow_volt")
if params:get("crow_dyn") == 1 then
gate_voltage = gate_voltage * (leaf.velocity/127)
end
crow.output[2].action = "{to(".. gate_voltage ..",0),to(0,".. 0.05 .. ")}"
crow.output[2]()
end
end
local function play_rustle(leaf)
if make_rustle() then
local amp = (util.wrap(leaf.sway, 1, params:get("rustle_limit")) / 100) + 0.1
local freq = math.floor(1200 + (leaf.speed * 5000))
engine.rustlepan(get_pan(leaf))
engine.rustleamp(amp)
engine.rustle(freq)
end
end
local function winds()
local wind = params:get("wind") / 100
for i = 1, #leaves do
local leaf = leaves[i]
if leaf.resting == true then
leaf.fade = leaf.fade - 0.1
leaf.level = math.floor(leaf.fade)
if leaf.level < 0 then
leaves[i] = make_leaf(leaf.bass)
leaves[i].y = 0
end
else
leaf.y = leaf.y + leaf.speed
leaf.sway = leaf.sway + wind
leaf.x = util.wrap(leaf.x + math.sin(leaf.sway), 0, 120)
leaf.sprite_change = leaf.sprite_change - 1
if leaf.sprite_change == 0 then
leaf.sprite_change = math.random(3, 10)
leaf.sprite = math.random(1, #sprites.leaves)
end
if leaf.y > ground_level then
leaf.resting = true
play(leaf)
end
end
end
end
local function collisions()
local collision_map = {}
for i = 1, #leaves do
local leaf = leaves[i]
if leaf.resting == false then
local x = math.floor(leaf.x / 4)
local y = math.floor(leaf.y / 4)
if collision_map[y] == nil then
collision_map[y] = {}
end
if collision_map[y][x] == 1 then
if leaf.collision_counter ~= nil then
leaf.collision_counter = leaf.collision_counter - 1
if leaf.collision_counter == 0 then
leaf.collision_counter = nil
end
else
leaf.collision_counter = 10
play_rustle(leaf)
end
else
collision_map[y][x] = 1
end
end
end
end
local function level_for_timer(value)
return util.round((value / visual_timers.default_time) * 15)
end
function redraw()
screen.clear()
if pages.index == 1 then
for i = 1, #leaves do
local leaf = leaves[i]
local leaf_sprite = sprites.leaves[leaf.sprite]
screen.level(leaf.level)
for ly = 1, #leaf_sprite do
for lx = 1, #leaf_sprite[ly] do
if leaf_sprite[ly][lx] == 1 then
screen.pixel(leaf.x + lx, leaf.y + ly)
screen.stroke()
end
end
end
if visual_timers.attack > 0 then
visual_timers.attack = visual_timers.attack - 1
screen.level(level_for_timer(visual_timers.attack))
screen.move(10, 5)
screen.text("atk: " .. util.round(params:get("attack"), 0.00001))
end
if visual_timers.release > 0 then
visual_timers.release = visual_timers.release - 1
screen.level(level_for_timer(visual_timers.release))
screen.move(10, 15)
screen.text("rel: " .. util.round(params:get("release"), 0.00001))
end
end
elseif pages.index == 2 then
pages:redraw()
ScaleConfigPage.menu:redraw(ScaleConfigPage)
elseif pages.index == 3 then
pages:redraw()
SoundConfigPage.menu:redraw(SoundConfigPage)
elseif pages.index == 4 then
pages:redraw()
DelayConfigPage.menu:redraw(DelayConfigPage)
elseif pages.index == 5 then
pages:redraw()
local page = LFOPage
page.LFO = LFO
page.render(page)
end
screen.update()
end
local function softcut_delay(ch, time, feedback, rate, level)
softcut.level(ch, level)
softcut.level_slew_time(ch, 0)
softcut.level_input_cut(ch, 1, 1.0)
softcut.level_input_cut(ch, 2, 1.0)
softcut.pan(ch, 0.0)
softcut.play(ch, 1)
softcut.rate(ch, rate)
softcut.rate_slew_time(ch, 0)
softcut.loop_start(ch, 0)
softcut.loop_end(ch, time)
softcut.loop(ch, 1)
softcut.fade_time(ch, 0.1)
softcut.rec(ch, 1)
softcut.rec_level(ch, 1)
softcut.pre_level(ch, feedback)
softcut.position(ch, 0)
softcut.enable(ch, 1)
softcut.pre_filter_dry(ch, 0)
softcut.pre_filter_hp(ch, 1.0)
softcut.pre_filter_fc(ch, 300)
softcut.pre_filter_rq(ch, 4.0)
end
local function apply_delays()
softcut_delay(1,
params:get("long_delay_time"), params:get("long_delay_feedback"), 1.0, params:get("long_delay_level")
)
softcut_delay(2,
params:get("short_delay_time"), params:get("short_delay_feedback"), 1.0, params:get("short_delay_level")
)
end
local function softcut_setup()
softcut.reset()
for i = 1, 2 do
softcut.position(i, 0)
softcut.rate(0, 1)
end
softcut.buffer_clear()
audio.level_cut(1.0)
audio.level_adc_cut(1)
audio.level_eng_cut(1)
apply_delays()
end
local function make_leaves()
leaves = {}
for _ = 1, params:get("light_leaves") do
table.insert(leaves, make_leaf(false))
end
for _ = 1, params:get("heavy_leaves") do
table.insert(leaves, make_leaf(true))
end
end
local function setup_params()
params:add_separator("midi")
local vports = {}
params:add_option("use_midi", "use midi", { "Yes", "No" }, 2)
params:set_action("use_midi", function(value)
local device = params:get("midi_out_device")
if device == nil and #vports > 0 then
device = vports[0]
end
if value == 1 and device ~= nil then
midi_device = midi.connect(device)
end
end)
local function refresh_params_vports()
for i = 1, #midi.vports do
vports[i] = midi.vports[i].name ~= "none" and
util.trim_string_to_width(midi.vports[i].name, 70) or
tostring(i)..": [device]"
end
end
refresh_params_vports()
params:add_option("midi_out_device", "MIDI out", vports, 1)
params:set_action("midi_out_device", function(value)
midi_device = midi.connect(value)
end)
params:add_number("midi_out_channel", "midi out channel", 1, 16, 1)
params:add_option("use_midi_pan", "midi panning", { "Yes", "No" }, 2)
params:add_separator("crow")
params:add_option("use_crow", "use crow (1+2)", { "Yes", "No" }, 2)
params:add_option("crow_volt", "gate voltage", crow_gate_voltages, 8)
params:add_option("crow_dyn", "dynamic gates", {"Yes", "No"}, 2)
params:add_separator("sound")
params:add_option("make_sound", "make sound", { "Yes", "No" }, 1)
params:add_option("make_rustle", "make rustles", { "Yes", "No" }, 1)
params:add_number("velocity_min", "velocity min", 1, 127, 20)
params:add_number("velocity_max", "velocity max", 1, 127, 90)
params:add_number("bass_velocity_min", "bass velocity min", 1, 127, 10)
params:add_number("bass_velocity_max", "bass velocity max", 1, 127, 70)
params:add_number("rustle_limit", "rustle gain limit", 1, 50, 20)
params:add_separator("time and delays")
params:add_taper("short_delay_time", "short delay", 1, 5, 1, 0.01, "sec")
params:set_action("short_delay_time", function(value) softcut.loop_end(2, value) end)
params:add_taper("short_delay_level", "short delay gain", 0, 1, 0.4, 0.01, "")
params:set_action("short_delay_level", function(value) softcut.level(2, value) end)
params:add_taper("short_delay_feedback", "short delay feedback", 0, 1, 0.5, 0.01)
params:set_action("short_delay_feedback", function()
apply_delays()
end)
params:add_taper("long_delay_time", "long delay", 1, settings.max_loop_length, 10, 0.1, "sec")
params:set_action("long_delay_time", function(value) softcut.loop_end(1, value) end)
params:add_taper("long_delay_level", "long delay gain", 0, 1, 0.6, 0.01, "")
params:set_action("long_delay_level", function(value) softcut.level(1, value) end)
params:add_taper("long_delay_feedback", "long delay feedback", 0, 1, 0.5, 0.01)
params:set_action("long_delay_feedback", function()
apply_delays()
end)
params:add_separator("melodies")
params:add_option("scale", "scale", settings.scales, math.random(1, #settings.scales))
params:set_action("scale", function()
make_leaves()
end)
params:add_number(
"root_note", "root note", midi_start_note, midi_end_note, math.random(midi_start_note, midi_end_note),
function(root_note)
return MusicUtil.note_num_to_name(root_note.value, true)
end
)
params:set_action("root_note", function()
scale = make_scale_options()
make_leaves()
end)
params:add_taper("wind", "wind", 1, 10, 3, 0.01, "")
params:add_taper("gravity", "gravity", 0.01, 10, 2, 0.01, "")
params:add_number("fade_median", "leaf fade median", 1, 50, 14)
params:add_number("fade_range", "leaf fade range", 1, 50, 8)
params:add_number("light_leaves", "total light leaves", 1, max_light_leaves, 8)
params:add_number("heavy_leaves", "total heavy leaves", 1, max_heavy_leaves, 2)
params:add_separator("autumn engine")
params:add_taper("attack", "attack", 0, 10, 1.0, 0.001, "seconds")
params:add_taper("release", "release", 0, 10, 3.0, 0.001, "seconds")
params:add_taper("pw", "pulse width", 0, 1, 0.6, 0.01)
params:set_action("pw", function(value)
engine.pw(value)
end)
params:add_number("bits", "bits", 6, 32, 13)
params:set_action("bits", function(value)
engine.bits(value)
end)
engine.bits(params:get("bits"))
LFO.init()
end
function enc(n, d)
if n == 1 then
pages:set_index_delta(util.clamp(d, -1, 1), false)
end
if pages.index == 1 then
if n == 2 then
if math.random() > 0.8 then
if d > 0 then
add_random_leaf()
else
remove_random_leaf()
end
end
elseif n == 3 then
if d > 0 then
local attack = params:get("attack")
visual_timers.attack = visual_timers.default_time
params:set("attack", util.wrap(attack - (d / 100), 0, 10))
else
local release = params:get("release")
visual_timers.release = visual_timers.default_time
params:set("release", util.wrap(release + (d / 100), 0, 10))
end
end
elseif pages.index == 2 then
ScaleConfigPage.enc_handler(ScaleConfigPage, n, d)
elseif pages.index == 3 then
SoundConfigPage.enc_handler(SoundConfigPage, n, d)
elseif pages.index == 4 then
DelayConfigPage.enc_handler(DelayConfigPage, n, d)
elseif pages.index == 5 then
LFOPage.enc_handler(LFOPage, n, d)
end
end
local function call_key_page_action(page, key)
if key == 2 and page.key_2_action then
page.key_2_action.action(page)
elseif key == 3 and page.key_3_action then
page.key_3_action.action(page)
end
end
function key(n, z)
if pages.index == 1 then
if n == 3 and z == 1 then
softcut_setup()
scale = make_new_scale_options()
make_leaves()
elseif n == 2 and z == 1 then
scale = make_scale_options()
make_leaves()
end
elseif pages.index == 5 and z == 1 then
call_key_page_action(LFOPage, n)
end
end
function init()
setup_params()
scale = make_scale_options()
softcut_setup()
panic()
make_leaves()
engine.hiss(0)
engine.attack(0.1)
engine.release(4)
engine.amp(0.2)
engine.pan(0.5)
engine.pw(params:get("pw"))
clock.run(
function()
while true do
clock.sleep(1 / 30)
redraw()
end
end
)
clock.run(
function()
while true do
clock.sync(1 / 16)
winds()
end
end
)
clock.run(
function()
while true do
clock.sync(1 / 10)
collisions()
end
end
)
end
|
--- 近战武器类
-- @module MeleeWeapon
-- @copyright Lilith Games, Avatar Team
-- @author Dead Ratman
local MeleeWeapon = class('MeleeWeapon', WeaponBase)
function MeleeWeapon:initialize(_data, _config)
WeaponBase.initialize(self, _data, _config)
print('MeleeWeapon:initialize()')
end
--攻击
function MeleeWeapon:Attack()
WeaponBase.Attack(self)
invoke(
function()
self.equipObj.Col:SetActive(true)
wait(1)
self.equipObj.Col:SetActive(false)
end
)
end
function MeleeWeapon:Equip()
WeaponBase.Equip(self)
invoke(
function()
self.equipObj.Col:SetActive(false)
self.equipObj.Col.OnCollisionBegin:Connect(
function(_hitObj, _hitPoint)
if _hitObj ~= localPlayer and _hitObj.ClassName == 'PlayerInstance' and _hitObj.Avatar then
if _hitObj.Avatar.ClassName == 'PlayerAvatarInstance' then
self:AddForceToHitPlayer(_hitObj)
self:HitBuff(_hitObj)
self:PlayHitSoundEffect(_hitPoint)
end
end
end
)
end,
self.baseData.TakeOutTime + 0.1
)
end
--对命中玩家施加力
function MeleeWeapon:AddForceToHitPlayer(_player)
_player.LinearVelocity = (_player.Position - localPlayer.Position).Normalized * self.derivedData.HitForce
end
--命中增加/移除buff
function MeleeWeapon:HitBuff(_player)
CloudLogUtil.UploadLog(
'battle_actions',
'hit_event',
{hit_target_id = 'Player', target_detail = _player.Name, attack_target = localPlayer.Name, attack_type = 'Melee'}
)
NetUtil.Fire_S(
'SPlayerHitEvent',
localPlayer,
_player,
{
addBuffID = self.derivedData.HitAddBuffID,
addDur = self.derivedData.HitAddBuffDur,
removeBuffID = self.derivedData.HitRemoveBuffID
}
)
end
--播放命中音效和特效
function MeleeWeapon:PlayHitSoundEffect(_pos)
SoundUtil.Play3DSE(_pos, self.derivedData.HitSoundID)
local effect =
world:CreateInstance(self.derivedData.HitEffectName, self.derivedData.HitEffectName .. 'Instance', world, _pos)
invoke(
function()
effect:Destroy()
end,
1
)
end
return MeleeWeapon
|
-- Copyright (c) 2021 Ashish Panigrahi
-- MIT license, see LICENSE for more details.
-- stylua: ignore
local colors = {
black = '#202020',
neon = '#DFFF00',
white = '#FFFFFF',
green = '#00D700',
purple = '#5F005F',
blue = '#00DFFF',
darkblue = '#00005F',
navyblue = '#000080',
brightgreen = '#9CFFD3',
gray = '#444444',
darkgray = '#3c3836',
lightgray = '#504945',
inactivegray = '#7c6f64',
orange = '#FFAF00',
red = '#5F0000',
brightorange = '#C08A20',
brightred = '#AF0000',
cyan = '#00DFFF',
}
return {
normal = {
a = { bg = colors.neon, fg = colors.black, gui = 'bold' },
b = { bg = colors.gray, fg = colors.white },
c = { bg = colors.black, fg = colors.brightgreen },
},
insert = {
a = { bg = colors.blue, fg = colors.darkblue, gui = 'bold' },
b = { bg = colors.navyblue, fg = colors.white },
c = { bg = colors.purple, fg = colors.white },
},
visual = {
a = { bg = colors.orange, fg = colors.black, gui = 'bold' },
b = { bg = colors.darkgray, fg = colors.white },
c = { bg = colors.red, fg = colors.white },
},
replace = {
a = { bg = colors.brightred, fg = colors.white, gui = 'bold' },
b = { bg = colors.cyan, fg = colors.darkblue },
c = { bg = colors.navyblue, fg = colors.white },
},
command = {
a = { bg = colors.green, fg = colors.black, gui = 'bold' },
b = { bg = colors.darkgray, fg = colors.white },
c = { bg = colors.black, fg = colors.brightgreen },
},
inactive = {
a = { bg = colors.darkgray, fg = colors.gray, gui = 'bold' },
b = { bg = colors.darkgray, fg = colors.gray },
c = { bg = colors.darkgray, fg = colors.gray },
},
}
|
local robot = require("robot")
local component = require("component")
for i = 1, 32, 1 do
robot.forward()
end |
--[[
=== hegetopt
]]
local he = require "he"
local function parseoptstr(optstr)
if not optstr:match("^[:%a]*$") then return nil end
local optdic = {}
local i = 1
while i <= #optstr do
local c = optstr:sub(i, i)
local c1 = optstr:sub(i+1, i+1)
if c ~= ':' then
optdic[c] = (c1 == ":") and 'arg' or 'flag'
end
i = i + 1
end
--~ ppt(optdic)
return optdic
end
local function isopt(s)
return s:match("^%-")
end
local function isvalidgroup(s)
return s:match("^%-%a+$")
end
local function optvalue(optdic, opttbl, arglist, i)
-- return stat, j the next position in arglist
-- stat:
-- 1=still more opts,
-- 2=switch to positional args,
-- 3=switch to positional args after '--' (args may start with '-')
-- nil=error
-- if optflag, value = true
-- if end of options, return opt=1
-- if opt error, return opt=nil
local err = "invalid option: "
local o, v
local a = arglist[i]
if not a then return 2, i end
if a == '--' then return 3, i+1 end
if not isopt(a) then return 2, i end -- not an option, -> positional
if not isvalidgroup(a) then return nil, err .. a end
a = a:sub(2)
while true do -- process all options in the group
o = a:sub(1,1)
if not optdic[o] then return nil, err .. '-' .. o end
if optdic[o] == 'flag' then
opttbl[o] = true
else -- assume it is an option with argument
if #a > 1 then -- opt is not the last
return nil, err .. '-' .. o .. " not last in group"
end
i = i + 1
v = arglist[i]
if (not v) or isopt(v) then -- argument is ""
opttbl[o] = ""
return 1, i
else
opttbl[o] = v
return 1, i + 1
end
end
if #a < 2 then --no more option in the group
return 1, i + 1
else -- continue parsing the group
a = a:sub(2)
end
end --while
end
local function getopt(optstr, arglist)
-- very simple getopt.
-- arglist is optional. default is to use gobal 'arg'
-- restrictions, rules:
-- - only short opts (one letter, no digit)
-- - values must be separated from optnames ('-f abc', no '-fabc')
-- - optflags can be grouped ('-am' or '-a -m')
-- - last option of a group may have a value ('-am blah')
-- - all opts come before positional arguments
-- - option processing stops at '--'
-- return a table with positional arguments, and option values
-- eg. with optstr "a:bhv" and arg line 'pgm -v -a hello file1 file2'
-- the following table is returned:
-- {"file1", "file2", v=true, a="hello"}
-- if optstr is not valid (starts with ':', repeated options,
-- non-letter character), nil, error_msg is returned
local ot = {}
local msg_invalid = "invalid option string: " .. optstr
local msg_noarg = "missing option value: "
local optdic = parseoptstr(optstr)
if not optdic then return nil, msg_invalid end
local i = 1
local pos = 1
-- stat: parsing state
-- 1 = parsing options,
-- 2 = parsing positional arguments (no more options)
-- 3 = parsing positional arguments after '--' (arg may start with '-')
-- nil = parsing error
local stat = 1
local a, o, v, j
while true do
stat, j = optvalue(optdic, ot, arglist, i)
if not stat then return nil, j end -- optvalue error
i = j
if stat >= 2 then break end -- move to positional parameters
end--while
while true do -- collect positional arguments
a = arglist[i]
if not a then break end
if isopt(a) and stat == 2 then
return nil, "option after positional argument"
end
ot[pos] = a
pos = pos + 1 -- next positional argument
i = i + 1 -- next element in arglist
end --while
return ot
end
return { -- module
getopt = getopt,
}
|
vim.g.doge_mapping = "<Leader>*"
|
ESX = nil
if Config.UseESX then
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
RegisterServerEvent('fuel:pay')
AddEventHandler('fuel:pay', function(price)
local xPlayer = ESX.GetPlayerFromId(source)
local amount = ESX.Math.Round(price)
TriggerEvent('esx_statejob:getTaxed', 'FUEL', amount, function(total)
end)
if price > 0 then
if (price > xPlayer.getMoney()) then
xPlayer.removeMoney(xPlayer.getMoney())
else
xPlayer.removeMoney(amount)
end
end
end)
end
AddEventHandler('esx_legacyfuel:GetFuel', function(vehicle, cb)
TriggerClientEvent("esx_legacyfuel:GetFuel", vehicle, function(fuel)
cb(fuel)
end)
end)
AddEventHandler('esx_legacyfuel:SetFuel', function(vehicle, fuel)
TriggerClientEvent("esx_legacyfuel:SetFuel", vehicle, fuel)
end)
|
-- Natural Selection 2 Competitive Mod
-- Source located at - https://github.com/xToken/CompMod
-- lua\CompMod\Weapons\Weapon\shared.lua
-- - Dragon
-- Just Override these, we change too much here anyways
function Weapon:GetUpgradeTier()
return kTechId.None, 0
end |
--[[
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.
]]
local shared = require 'SAMemory.shared'
shared.require 'CPed'
shared.ffi.cdef[[
typedef enum eCopType
{
COP_TYPE_CITYCOP,
COP_TYPE_LAPDM1,
COP_TYPE_SWAT1,
COP_TYPE_SWAT2,
COP_TYPE_FBI,
COP_TYPE_ARMY,
COP_TYPE_CSHER = 7
} eCopType;
typedef struct CCopPed CCopPed;
struct CCopPed : CPed
{
int field_79C;
unsigned int copType;
int field_7A4;
CCopPed *pCopPartner;
CPed *apCriminalsToKill[5];
char field_7C0;
};
]]
shared.validate_size('CCopPed', 0x7C4)
|
-- serve test results, in case operating in an environemnt with no console
local S = require "syscall"
-- exit will cause issues, override
os.exit = function() end
-- open output file
local outname = "output"
local fd = S.creat(outname, "rwxu")
-- set stdio to file, keep handle so not garbage collected
local stdin = S.dup2(fd, 0)
local stdout = S.dup2(fd, 1)
local stderr = S.dup2(fd, 2)
-- run tests
require "test.test"
local st = fd:stat()
-- close file
fd:close()
local results = S.util.readfile(outname, nil, st.size)
-- serve file - this code is borrowed from examples/epoll.lua
local t, c = S.t, S.c
local function assert(cond, s, ...)
if cond == nil then error(tostring(s)) end -- annoyingly, assert does not call tostring!
return cond, s, ...
end
local maxevents = 1024
local poll
-- this is somewhat working toward a common API but needs a lot more work, but has resulted in some improvements
if S.epoll_create then
poll = {
init = function(this)
return setmetatable({fd = assert(S.epoll_create())}, {__index = this})
end,
event = t.epoll_event(),
add = function(this, s)
local event = this.event
event.events = c.EPOLL.IN
event.data.fd = s:getfd()
assert(this.fd:epoll_ctl("add", s, event))
end,
events = t.epoll_events(maxevents),
get = function(this)
return this.fd:epoll_wait(this.events)
end,
eof = function(ev) return ev.HUP or ev.ERR or ev.RDHUP end,
}
elseif S.kqueue then
poll = {
init = function(this)
return setmetatable({fd = assert(S.kqueue())}, {__index = this})
end,
event = t.kevents(1),
add = function(this, s)
local event = this.event[1]
event.fd = s
event.setfilter = "read"
event.setflags = "add"
assert(this.fd:kevent(this.event, nil, 0))
end,
events = t.kevents(maxevents),
get = function(this)
return this.fd:kevent(nil, this.events)
end,
eof = function(ev) return ev.EOF or ev.ERROR end,
}
else
error("no epoll or kqueue support")
end
local s = assert(S.socket("inet", "stream, nonblock"))
s:setsockopt("socket", "reuseaddr", true)
local sa = assert(t.sockaddr_in(80, "0.0.0.0"))
assert(s:bind(sa))
assert(s:listen(128))
ep = poll:init()
ep:add(s)
local w = {}
local msg = [[
<html>
<head>
<title>performance test</title>
</head>
<body>
]] .. results .. [[
</body>
</html>
]]
local reply = table.concat({
"HTTP/1.0 200 OK",
"Content-type: text/html",
"Connection: close",
"Content-Length: " .. #msg,
"",
"",
}, "\r\n") .. msg
local bufsize = 4096
local buffer = t.buffer(bufsize)
local ss = t.sockaddr_storage()
local addrlen = t.socklen1(#ss)
local function loop()
for i, ev in ep:get() do
if ep.eof(ev) then
fd:close()
w[ev.fileno] = nil
end
if ev.fd == s.filenum then -- server socket, accept
repeat
local a, err = s:accept("nonblock", ss, addrlen)
if a then
ep:add(a.fd)
w[a.fd:getfd()] = a.fd
end
until not a
else
local fd = w[ev.fd]
fd:read(buffer, bufsize)
local n = fd:write(reply)
assert(n == #reply)
assert(fd:close())
w[ev.fd] = nil
end
end
return loop()
end
loop()
|
local config = {
positions = {
Position({x = 33258, y = 31080, z = 8}),
Position({x = 33266, y = 31084, z = 8}),
Position({x = 33259, y = 31089, z = 8}),
Position({x = 33263, y = 31093, z = 8})
},
stairPosition = Position(33265, 31116, 8),
areaCenter = Position(33268, 31119, 7),
zalamonPosition = Position(33353, 31410, 8),
summonArea = {
from = Position(33252, 31105, 7),
to = Position(33288, 31134, 7)
},
waves = {
{monster = 'eternal guardian', size = 20},
{monster = 'eternal guardian', size = 20},
{monster = 'eternal guardian', size = 20},
{monster = 'lizard chosen', size = 20}
}
}
function doClearMissionArea()
Game.setStorageValue(Storage.ChildrenoftheRevolution.Mission05, -1)
local spectators, spectator = Game.getSpectators(config.areaCenter, false, true, 26, 26, 20, 20)
for i = 1, #spectators do
spectator = spectators[i]
if spectator:isPlayer() then
spectator:teleportTo(config.zalamonPosition)
spectator:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
if spectator:getStorageValue(Storage.ChildrenoftheRevolution.Questline) == 19 then
spectator:setStorageValue(Storage.ChildrenoftheRevolution.Questline, 20)
end
else
spectator:remove()
end
end
return true
end
local function removeStairs()
local stair = Tile(config.stairPosition):getItemById(3687)
if stair then
stair:transform(3653)
end
end
local function summonWave(i)
local wave = config.waves[i]
local summonPosition
for i = 1, wave.size do
summonPosition = Position(math.random(config.summonArea.from.x, config.summonArea.to.x), math.random(config.summonArea.from.y, config.summonArea.to.y), 7)
Game.createMonster(wave.monster, summonPosition)
summonPosition:sendMagicEffect(CONST_ME_TELEPORT)
end
end
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return true
end
if player:getStorageValue(Storage.ChildrenoftheRevolution.Questline) ~= 19
or Game.getStorageValue(Storage.ChildrenoftheRevolution.Mission05) == 1 then
return true
end
local players = {}
for i = 1, #config.positions do
local creature = Tile(config.positions[i]):getTopCreature()
if creature and creature:isPlayer() then
players[#players + 1] = creature
end
end
if #players ~= #config.positions then
return true
end
for i = 1, #players do
players[i]:say('A clicking sound tatters the silence.', TALKTYPE_MONSTER_SAY)
end
local stair = Tile(config.stairPosition):getItemById(3653)
if stair then
stair:transform(3687)
end
Game.setStorageValue(Storage.ChildrenoftheRevolution.Mission05, 1)
for wave = 1, #config.waves do
addEvent(summonWave, wave * 30 * 1000, wave)
end
addEvent(removeStairs, 30 * 1000)
addEvent(doClearMissionArea, 5 * 30 * 1000)
return true
end
|
--[[
TheNexusAvenger
Manages the quests for players.
Class is static (should not be created).
--]]
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ReplicatedStorageProject = require(ReplicatedStorage:WaitForChild("Project"):WaitForChild("ReplicatedStorage"))
local ServerScriptServiceProject = require(ReplicatedStorage:WaitForChild("Project"):WaitForChild("ServerScriptService")):GetContext(script)
local QuestsData = ReplicatedStorageProject:GetResource("GameData.Quest.Quests")
local ItemData = ReplicatedStorageProject:GetResource("GameData.Item.Items")
local NPCLocations = ReplicatedStorageProject:GetResource("GameData.Generation.NPCLocations")
local Quests = ReplicatedStorageProject:GetResource("State.Quests")
local GameReplication = ReplicatedStorageProject:GetResource("GameReplication")
local QuestService = ReplicatedStorageProject:GetResource("ExternalUtil.NexusInstance.NexusInstance"):Extend()
QuestService:SetClassName("QuestService")
QuestService.PlayerQuests = {}
ServerScriptServiceProject:SetContextResource(QuestService)
local InventoryService = ServerScriptServiceProject:GetResource("Service.InventoryService")
local PlayerDataService = ServerScriptServiceProject:GetResource("Service.PlayerDataService")
--Set up the replication.
local QuestReplication = Instance.new("Folder")
QuestReplication.Name = "QuestReplication"
QuestReplication.Parent = GameReplication
local TurnInQuest = Instance.new("RemoteEvent")
TurnInQuest.Name = "TurnInQuest"
TurnInQuest.Parent = QuestReplication
TurnInQuest.OnServerEvent:Connect(function(Player,NPCName,QuestName)
QuestService:CompleteQuest(Player,NPCName,QuestName)
end)
local StartQuest = Instance.new("RemoteEvent")
StartQuest.Name = "StartQuest"
StartQuest.Parent = QuestReplication
StartQuest.OnServerEvent:Connect(function(Player,NPCName,QuestName)
QuestService:StartQuest(Player,NPCName,QuestName)
end)
local SelectQuest = Instance.new("RemoteEvent")
SelectQuest.Name = "SelectQuest"
SelectQuest.Parent = QuestReplication
SelectQuest.OnServerEvent:Connect(function(Player,QuestName)
QuestService:SelectQuest(Player,QuestName)
end)
local DisplayItemAwards = Instance.new("RemoteEvent")
DisplayItemAwards.Name = "DisplayItemAwards"
DisplayItemAwards.Parent = QuestReplication
--[[
Initializes the data for a player.
--]]
function QuestService:LoadPlayer(Player)
self.PlayerQuests[Player] = Quests.GetQuests(Player)
end
--[[
Returns if the given quest is valid
for a given condition.
--]]
function QuestService:QuestConditonValid(Player,QuestName,Condition)
return self.PlayerQuests[Player]:QuestConditonValid(QuestName,Condition)
end
--[[
Starts a quest for a player. Performs security
checks to make sure the player can only accept a
quest in the current dialog. The quest name
is required because dialogs can award multiple
quests.
--]]
function QuestService:StartQuest(Player,NPCName,QuestName)
--Return if the quest is not unlocked.
local PlayerQuests = self.PlayerQuests[Player]
if not PlayerQuests:QuestConditonValid(QuestName,"NotUnlocked") then
return
end
--Get the NPC dialog and return if it doesn't exist.
local Dialog = PlayerQuests:GetDialogForNPC(NPCName)
if not Dialog then
return
end
--[[
Returns if the quest is valid for a given table.
--]]
local function QuestValid(DialogTable)
--Return true if the quest matches.
if QuestName == DialogTable.Quest then
return true
end
--Return if a sub-table is true.
for _,SubTable in pairs(DialogTable) do
if type(SubTable) == "table" and QuestValid(SubTable) then
return true
end
end
--Return false (not valid).
return false
end
--Add the quest if it is valid.
if QuestValid(Dialog) then
PlayerQuests:AddQuest(QuestName)
end
end
--[[
Completes a quest for a player. The quest
name is not given since each NPC
--]]
function QuestService:CompleteQuest(Player,NPCName,QuestName)
--Return if the quest is not able to be turned in.
local PlayerQuests = self.PlayerQuests[Player]
if not PlayerQuests:QuestConditonValid(QuestName,"AllItems") then
return
end
--Get the NPC dialog and return if it doesn't exist.
local Dialog = PlayerQuests:GetDialogForNPC(NPCName)
if not Dialog then
return
end
--[[
Returns if the quest is valid for a given table.
--]]
local function QuestValid(DialogTable)
--Return true if the turn in quest matches.
if QuestName == DialogTable.TurnIn then
return true
end
--Return if a sub-table is true.
for _,SubTable in pairs(DialogTable) do
if type(SubTable) == "table" and QuestValid(SubTable) then
return true
end
end
--Return false (not valid).
return false
end
--Complete the quest if it is valid.
if QuestValid(Dialog) then
PlayerQuests:CompleteQuest(QuestName)
--Remove the quest items.
local QuestData = QuestsData[QuestName]
if QuestData.QuestType == "Items" then
local RequiredItems = QuestData.RequiredItems[1]
InventoryService:RemoveItemsByName(Player,RequiredItems.Name)
end
--Reward the player.
local RewardsToDisplay = {}
for RewardType,Reward in pairs(QuestData.Rewards or {}) do
local PlayerData = PlayerDataService:GetPlayerData(Player)
if RewardType == "Badge" then
--Award a bloxkin.
local Bloxkins = PlayerData:GetValue("CollectedBloxkins")
Bloxkins[Reward] = true
PlayerData:SetValue("CollectedBloxkins",Bloxkins)
table.insert(RewardsToDisplay,{Type="Bloxkin",Name=Reward})
elseif RewardType == "XP" then
--Award XP.
local XP = PlayerData:GetValue("XP") + Reward
PlayerData:SetValue("XP",XP)
elseif RewardType == "Items" then
--Award items.
for _,Item in pairs(Reward) do
for i = 1,Item.Amount do
local NewItem = {Name=Item.Name}
if ItemData[Item.Name].IncludeZoneData then
NewItem.Zone = NPCLocations[NPCName].Zone
end
InventoryService:AddItem(Player,NewItem)
table.insert(RewardsToDisplay,{Type="Item",Name=Reward})
end
end
end
end
DisplayItemAwards:FireClient(Player,RewardsToDisplay)
end
end
--[[
Selects the primary quest for the player.
--]]
function QuestService:SelectQuest(Player,QuestName)
self.PlayerQuests[Player]:SelectQuest(QuestName)
end
--[[
Registers a monster kill.
--]]
function QuestService:RegisterMonsterKill(Player,MonsterName)
self.PlayerQuests[Player]:RegisterMonsterKill(MonsterName)
end
--[[
Clears a player.
--]]
function QuestService:ClearPlayer(Player)
self.PlayerQuests[Player] = nil
end
return QuestService |
-- https://github.com/sotakoira/pandora-luas
ui.add_label("Aiming at player color")
local atplayer = ui.add_colorpicker("Aiming at player")
ui.add_label("Regular color")
local noplayer = ui.add_colorpicker("Regular")
function on_paint()
local_player = entity_list.get_client_entity(engine.get_local_player())
if not engine.in_game() then
return
end
if local_player == nil then
return
end
if local_player:get_prop("DT_BasePlayer", "m_iHealth"):get_int() <= 0 then
return
end
penetration_damage = penetration.damage()
aiming_at_player = penetration.aiming_at_player()
if penetration_damage > 0 and aiming_at_player then render.add_indicator(tostring(penetration_damage), atplayer:get())
elseif penetration_damage > 0 and not aiming_at_player then render.add_indicator(tostring(penetration_damage), noplayer:get())
else return
end
end
callbacks.register("paint", on_paint) |
-- Includes
local json = require "dkjson"
local date = require "pl.Date"
local path = require "pl.path"
local file = require "pl.file"
local post = {}
local blogs_path = path.join("..", "pub", "blogs.json")
local function load_existing_data()
if path.exists(blogs_path) then
return json.decode(file.read(blogs_path))
end
return {}
end
function post.get_all()
return load_existing_data()
end
function post.create(title, textbody)
-- Load any existing blog data
local data = load_existing_data()
-- Append the new blog post
-- Get the date in ISO 8601 format
local timestamp = tostring(date())
table.insert(data, 1, {
timestamp = timestamp,
textbody = textbody,
folder_id = #data + 1,
title = title
})
-- Write the new data
file.write(blogs_path, json.encode(data))
return true
end
function post.update(title, textbody, id)
-- Load any existing blog data
local data = load_existing_data()
-- Update the blog post, preserve the date
data[id].textbody = textbody
data[id].title = title
-- Write the new data
file.write(blogs_path, json.encode(data))
return true
end
function post.remove(id)
-- Load any existing blog data
local data = load_existing_data()
-- Remove the blog post, but without shifting other elements
data[id] = nil
-- Write the new data
file.write(blogs_path, json.encode(data))
return true
end
return post
|
---@class Config
local config
-- shim vim for kitty and other generators
vim = vim or { g = {}, o = {} }
local function opt(key, default)
key = "tokyonight_" .. key
if vim.g[key] == nil then
return default
end
if vim.g[key] == 0 then
return false
end
return vim.g[key]
end
config = {
style = opt("style", "storm"),
dayBrightness = opt("day_brightness", 0.3),
transparent = opt("transparent", false),
commentStyle = opt("italic_comments", true) and "italic" or "NONE",
keywordStyle = opt("italic_keywords", true) and "italic" or "NONE",
functionStyle = opt("italic_functions", false) and "italic" or "NONE",
variableStyle = opt("italic_variables", false) and "italic" or "NONE",
hideInactiveStatusline = opt("hide_inactive_statusline", false),
terminalColors = opt("terminal_colors", true),
sidebars = opt("sidebars", {}),
colors = opt("colors", {}),
dev = opt("dev", false),
darkFloat = opt("dark_float", true),
darkSidebar = opt("dark_sidebar", true),
transparentSidebar = opt("transparent_sidebar", false),
transform_colors = false,
lualineBold = opt("lualine_bold", false),
lineNr = opt("line_number_color", "#bb9af7"),
}
if config.style == "day" then
vim.o.background = "light"
end
return config
|
require("util")
local random = math.random
-- stuff should have first_seven, metal, vs_mode, metal_col, prev_metal_col
function make_panels(ncolors, prev_panels, stuff)
local ret = prev_panels
local rows_to_make = 20
if ncolors < 2 then return end
local cut_panels = false
if prev_panels == "000000" then
if stuff.first_seven then
ret = stuff.first_seven
rows_to_make = rows_to_make - 7
else
cut_panels = true
end
end
for x=0,rows_to_make-1 do
if stuff.metal then
local nogood = true
while nogood do
stuff.metal_col = random(0,5)
nogood = stuff.metal_col == stuff.prev_metal_col
end
end
for y=0,5 do
local prevtwo = y>1 and string.sub(ret,-1,-1) == string.sub(ret,-2,-2)
local nogood,color = true
while nogood do
color = (y==stuff.metal_col) and 8 or tostring(math.random(1,ncolors))
nogood = (prevtwo and color == string.sub(ret,-1,-1)) or
color == string.sub(ret,-6,-6)
end
ret = ret..color
end
stuff.prev_metal_col = stuff.metal_col
stuff.metal_col = nil
stuff.rows_left = stuff.rows_left - 1
if stuff.rows_left == 0 then
if stuff.vs_mode then
stuff.metal = not stuff.metal
end
if stuff.metal then
stuff.rows_left = random(3,4)
else
stuff.rows_left = random(7,10)
end
end
end
if cut_panels then
ret = procat(ret)
local height = {7,7,7,7,7,7}
local to_remove = 12
while to_remove > 0 do
idx = random(1,6)
if height[idx] > 0 then
ret[idx+6*(-height[idx]+8)] = "0"
height[idx] = height[idx] - 1
to_remove = to_remove - 1
end
end
ret = table.concat(ret)
stuff.first_seven = string.sub(ret,1,48)
end
return string.sub(ret,7,-1)
end
function make_gpanels(ncolors, prev_panels)
local ret = prev_panels
for x=0,19 do
for y=0,5 do
local nogood,color = true
while nogood do
color = tostring(math.random(1,ncolors))
nogood = (y>0 and color == string.sub(ret,-1,-1)) or
color == string.sub(ret,-6,-6)
end
ret = ret..color
end
end
return string.sub(ret,7,-1)
end
|
--[[
dbg: Lua 5.1 module for debugging with vardump
Lua Programming Gems Chapter 3
Vardump: The Power of Seeing What's Behind
Copyright (C) 2008 by Tobias Sülzenbrück and Christoph Beckmann
]]--
local getfenv, getmetatable, print, pairs, type, tostring = getfenv, getmetatable, print, pairs, type, tostring
module(...)
local modenv = getfenv() -- module environment
function vardump(value, depth, key)
local linePrefix = ""
local spaces = ""
if key ~= nil then
linePrefix = "["..key.."] = "
end
if depth == nil then
depth = 0
else
depth = depth + 1
for i = 1,depth do spaces = spaces.." " end
end
if type(value) == 'table' then
-- mTable = getmetatable(value)
-- if mTable == nil then
print(spaces..linePrefix.."(table) ")
-- else
-- print(spaces.."(metatable) ")
-- value = mTable
-- end
for tableKey, tableValue in pairs(value) do
vardump(tableValue, depth, tableKey)
end
elseif type(value) == 'function'
or type(value) == 'thread'
or type(value) == 'userdata'
or value == nil
then
print(spaces..tostring(value))
else
print(spaces..linePrefix.."("..type(value)..") "..tostring(value))
end
end
|
modernUI.showNPCShop = function(self, items)
local id = self.id
local player = self.player
local width = self.width
local height = self.height
local x = (400 - width/2) + 20
local y = (200 - height/2) + 65
local currentPage = 1
local maxPages = math.ceil(#items/15)
local boughtSomething = false -- for prevent players from duplicating rare items
players[player]._modernUIImages[id][#players[player]._modernUIImages[id]+1] = addImage('172763e41e1.jpg', ":27", x+337, y-14, player)
local function showItems()
local minn = 15 * (currentPage-1) + 1
local maxx = currentPage * 15
local i = 0
for _ = minn, maxx do
local data = items[_]
if not data then break end
local selectedQuanty = 1
local v = mainAssets.__furnitures[data[1]] or bagItems[data[2]]
players[player]._modernUISelectedItemImages[3][#players[player]._modernUISelectedItemImages[3]+1] = addImage('1722d2d8234.jpg', ":26", x + (i%5)*63, y + math.floor(i/5)*65, player)
players[player]._modernUISelectedItemImages[3][#players[player]._modernUISelectedItemImages[3]+1] = addImage(v.png, ":26", x + 5 + (i%5)*63, y + 5 + math.floor(i/5)*65, player)
if v.stockLimit and checkIfPlayerHasFurniture(player, data[1]) then
ui.addTextArea(id..(900+i), '<p align="center"><font size="9"><r>'..translate('error_maxStorage', player), player, x + (i%5)*63, y + 3 + math.floor(i/5)*65, 58, 55, 0xff0000, 0xff0000, 0, true)
players[player]._modernUISelectedItemImages[3][#players[player]._modernUISelectedItemImages[3]+1] = addImage('1725d179b2f.png', ":26", x + (i%5)*63, y + math.floor(i/5)*65, player)
elseif v.requireQuest and players[player].questStep[1] <= v.requireQuest then
ui.addTextArea(id..(900+i), '<p align="center"><font size="9"><r>'..translate('locked_quest', player):format(v.requireQuest), player, x + (i%5)*63, y + 3 + math.floor(i/5)*65, 58, 55, 0xff0000, 0xff0000, 0, true)
players[player]._modernUISelectedItemImages[3][#players[player]._modernUISelectedItemImages[3]+1] = addImage('1725d179b2f.png', ":26", x + (i%5)*63, y + math.floor(i/5)*65, player)
else
ui.addTextArea(id..(900+i), '\n\n\n\n', player, x + 3 + (i%5)*63, y + 3 + math.floor(i/5)*65, 55, 55, 0xff0000, 0xff0000, 0, true,
function(player, i)
local name = mainAssets.__furnitures[data[1]] and translate('furniture_'..v.name, player) or translate('item_'..data[2], player)
player_removeImages(players[player]._modernUISelectedItemImages[1])
ui.addTextArea(id..'890', '<p align="center"><font size="13"><fc>'..name, player, x+340, y-15, 135, 215, 0x24474D, 0x314e57, 0, true)
local description = item_getDescription(mainAssets.__furnitures[data[1]] and data[1] or data[2], player, mainAssets.__furnitures[data[1]])
ui.addTextArea(id..'891', '<font size="9"><bl>'..description, player, x+340, y+50, 135, nil, 0x24474D, 0x314e5, 0, true)
ui.addTextArea(id..'894', '', player, x + 3 + (i%5)*63, y + 3 + math.floor(i/5)*65, 55, 55, 0xff0000, 0xff0000, 0, true)
players[player]._modernUISelectedItemImages[1][#players[player]._modernUISelectedItemImages[1]+1] = addImage(v.png, "&26", 542, 125, player)
players[player]._modernUISelectedItemImages[1][#players[player]._modernUISelectedItemImages[1]+1] = addImage('1722d33f76a.png', ":26", x + (i%5)*63-3, y + math.floor(i/5)*65-3, player)
local function button(i, text, callback, x, y, width, height, blockClick)
local colorPallete = {
button_confirmBg = 0x95d44d,
button_confirmFront = 0x44662c
}
if blockClick then
colorPallete.button_confirmBg = 0xbdbdbd
colorPallete.button_confirmFront = 0x5b5b5b
end
ui.addTextArea(id..(930+i*5), '', player, x-1, y-1, width, height, colorPallete.button_confirmBg, colorPallete.button_confirmBg, 1, true)
ui.addTextArea(id..(931+i*5), '', player, x+1, y+1, width, height, 0x1, 0x1, 1, true)
ui.addTextArea(id..(932+i*5), '', player, x, y, width, height, colorPallete.button_confirmFront, colorPallete.button_confirmFront, 1, true)
ui.addTextArea(id..(933+i*5), '<p align="center"><font color="#cef1c3" size="13">'..text..'\n', player, x-4, y-4, width+8, height+8, 0xff0000, 0xff0000, 0, true, not blockClick and callback or nil)
end
local currency = v.qpPrice and {players[player].sideQuests[4], v.qpPrice*selectedQuanty} or {players[player].coins, v.price*selectedQuanty}
local buttonTxt = nil
local blockClick = false
if currency[1] >= currency[2] then
buttonTxt = '<font size="11">'..translate('confirmButton_Buy', player):format('<b><fc>'..(v.qpPrice and 'QP$'..(v.qpPrice*selectedQuanty) or '$'..(v.price*selectedQuanty)))
else
blockClick = true
buttonTxt = '<r>'..(v.qpPrice and 'QP$'..v.qpPrice or '$'..v.price)
end
local function buyItem()
if boughtSomething then return end
if currency[1] < currency[2] then return alert_Error(player, 'error', 'error') end
if mainAssets.__furnitures[data[1]] then
local total_of_storedFurnitures = 0
for _, v in next, players[player].houseData.furnitures.stored do
total_of_storedFurnitures = total_of_storedFurnitures + v.quanty
end
if (total_of_storedFurnitures + selectedQuanty) > maxFurnitureDepot then return alert_Error(player, 'error', 'maxFurnitureDepot', maxFurnitureDepot) end
if not players[player].houseData.furnitures.stored[data[1]] then
players[player].houseData.furnitures.stored[data[1]] = {quanty = selectedQuanty, type = data[1]}
else
players[player].houseData.furnitures.stored[data[1]].quanty = players[player].houseData.furnitures.stored[data[1]].quanty + selectedQuanty
end
else
if (players[player].totalOfStoredItems.bag + selectedQuanty) > players[player].bagLimit then return alert_Error(player, 'error', 'bagError') end
local item = data[2]
addItem(item, selectedQuanty, player)
for id, properties in next, players[player].questLocalData.other do
if id:find('BUY_') then
if id:lower():find(item:lower()) then
if type(properties) == 'boolean' then
quest_updateStep(player)
else
players[player].questLocalData.other[id] = properties - selectedQuanty
if players[player].questLocalData.other[id] <= 0 then
quest_updateStep(player)
end
end
break
end
end
end
end
if v.qpPrice then
players[player].sideQuests[4] = players[player].sideQuests[4] - currency[2]
else
giveCoin(-currency[2], player)
end
boughtSomething = true
savedata(player)
eventTextAreaCallback(0, player, 'modernUI_Close_'..id, true)
end
local function addBuyButton(buttonTxt)
button(0, buttonTxt,
function()
buyItem()
end, 507, 295, 120, 13, blockClick)
end
if not blockClick and not v.stockLimit then
ui.addTextArea(id..'892', '<font color="#cef1c3">'..translate('confirmButton_Select', player), player, x+337, y+151, nil, nil, 0x24474D, 0x314e5, 0, true)
ui.addTextArea(id..'893', '<font color="#cef1c3">01', player, x+425, y+151, nil, nil, 0x24474D, 0x314e5, 0, true)
for i = 1, 2 do
button(i, i == 1 and '-' or '+',
function(player)
local calc = i == 1 and -1 or 1
if (selectedQuanty + calc) > 50 or (selectedQuanty + calc) < 1 then return end
selectedQuanty = selectedQuanty + calc
currency = v.qpPrice and {players[player].sideQuests[4], v.qpPrice*selectedQuanty} or {players[player].coins, v.price*selectedQuanty}
ui.updateTextArea(id..'893', '<font color="#cef1c3">'..string.format("%.2d", selectedQuanty), player)
buttonTxt = '<font size="11">'..translate('confirmButton_Buy', player):format('<b><fc>'..(v.qpPrice and 'QP$'..(v.qpPrice*selectedQuanty) or '$'..(v.price*selectedQuanty))..'</fc></b>')
addBuyButton(buttonTxt)
end, 565 + (i-1)*50, 270, 10, 10)
end
end
addBuyButton(buttonTxt)
end, i)
end
i = i + 1
end
end
local function updateScrollbar()
local function updatePage(count)
if currentPage + count > maxPages or currentPage + count < 1 then return end
currentPage = currentPage + count
player_removeImages(players[player]._modernUISelectedItemImages[1])
player_removeImages(players[player]._modernUISelectedItemImages[3])
for i = 897, 929 do
ui.removeTextArea(id..i, player)
end
updateScrollbar()
showItems()
end
ui.addTextArea(id..'888', string.rep('\n', 10), player, x+2, y+200, 155, 10, 0x24474D, 0xff0000, 0, true,
function()
updatePage(-1)
end)
ui.addTextArea(id..'889', string.rep('\n', 10), player, x+157, y+200, 155, 10, 0x24474D, 0xff0000, 0, true,
function()
updatePage(1)
end)
player_removeImages(players[player]._modernUISelectedItemImages[2])
players[player]._modernUISelectedItemImages[2][#players[player]._modernUISelectedItemImages[2]+1] = addImage('1729eacaeb5.jpg', ":26", x+2, y+205, player)
for i = 1, (10 - math.min(8, maxPages)+1) do
players[player]._modernUISelectedItemImages[2][#players[player]._modernUISelectedItemImages[2]+1] = addImage('1729ebf25cc.jpg', ":27", x+2 + (i-1)*31 + (currentPage-1)*31, y+205, player)
end
end
if maxPages > 1 then
updateScrollbar()
end
showItems()
return setmetatable(self, modernUI)
end
|
-- TODO: use argValidationUtils?
local function argChecker(position, value, validTypesList, level)
-- check our own args first, sadly we can't use ourself for this
if type(position) ~= "number" then
error("argChecker: arg[1] expected number got "..type(position),2)
end
-- value could be anything, it's what the caller wants us to check for them
if type(validTypesList) ~= "table" then
error("argChecker: arg[3] expected table got "..type(validTypesList),2)
end
if not validTypesList[1] then
error("argChecker: arg[3] table must contain at least one element",2)
end
for k, v in ipairs(validTypesList) do
if type(v) ~= "string" then
error("argChecker: arg[3]["..tostring(k).."] expected string got "..type(v),2)
end
end
if type(level) ~= "nil" and type(level) ~= "number" then
error("argChecker: arg[4] expected number or nil got "..type(level),2)
end
level = level and level + 1 or 3
-- check the client's stuff
for k, v in ipairs(validTypesList) do
if type(value) == v then
return
end
end
local expectedTypes
if #validTypesList == 1 then
expectedTypes = validTypesList[1]
else
expectedTypes = table.concat(validTypesList, ", ", 1, #validTypesList - 1) .. " or " .. validTypesList[#validTypesList]
end
error("arg["..tostring(position).."] expected "..expectedTypes
.." got "..type(value), level)
end
local function toEventName(protocol)
argChecker(1, protocol, {"string"})
return "rednet_protocol_message_"..protocol -- TODO: I don't like this prefix rednet one is "rednet_message"
end
local function wrap(protocol)
argChecker(1, protocol, {"string"})
local wrappedRednetProtocol = {
protocol = protocol
}
wrappedRednetProtocol.send = function(id, message)
argChecker(1, id, {"number"})
return rednet.send(id, message, wrappedRednetProtocol.protocol)
end
wrappedRednetProtocol.broadcast = function(message)
return rednet.broadcast(message, wrappedRednetProtocol.protocol)
end
wrappedRednetProtocol.receive = function(timeout)
argChecker(1, id, {"number","nil"})
return rednet.receive(wrappedRednetProtocol.protocol, timeout) -- TODO: test wth nil timeout and protocol #homeOnly
end
wrappedRednetProtocol.host = function (hostname)
argChecker(1, hostname, {"string"})
return rednet.host(wrappedRednetProtocol.protocol, hostname)
end
wrappedRednetProtocol.unhost = function (hostname)
argChecker(1, hostname, {"string"})
return rednet.unhost(wrappedRednetProtocol.protocol, hostname)
end
wrappedRednetProtocol.lookup = function (hostname)
argChecker(1, hostname, {"string", nil})
return rednet.lookup(wrappedRednetProtocol.protocol, hostname)
end
wrappedRednetProtocol.getEventName = function()
return toEventName(wrappedRednetProtocol.protocol)
end
end
local runEventTranslator
local function startEventTranslator() -- only required for events, the wrapped methods still work stand alone
runEventTranslator = true
while runEventTranslator do
local event = table.pack(os.pullevent("rednet_message"))
os.queueEvent(toEventName(event[4]), event[2], event[3])
end
end
local function stopEventTranslator()
runEventTranslator = false
end
local isEventTranslatorRunning()
return runEventTranslator
end
local rednetProtocolWrapper = {
toEventName = toEventName,
wrap = wrap,
startEventTranslator = startEventTranslator,
stopEventTranslator = stopEventTranslator,
isEventTranslatorRunning = isEventTranslatorRunning,
open = rednet.open,
close = rednet.close,
isOpen = rednet.isOpen,
}
|
#!/usr/bin/lua
--[[
Test unit for tracing API
]]
local config = require 'test_config'
local fb = require 'fbclient.class'
local asserts = (require 'fbclient.util').asserts
function test_everything(env)
local at = env:create_test_db()
--
at:close()
return 1,0
end
--local comb = {{lib='fbembed',ver='2.1.3'}}
config.run(test_everything,comb,nil,...)
|
FakeRequire = {
originalRequire = require,
fakedModules = {},
whitelisted = {}
}
function FakeRequire:fakeModule( name, table )
self.fakedModules[name] = table
end
function FakeRequire:whitelist( prefix )
table.insert(self.whitelisted, '^'..prefix)
end
function FakeRequire:isWhitelisted( name )
for _, pattern in ipairs(self.whitelisted) do
if string.find(name, pattern) then
return true
end
end
return false
end
function FakeRequire._require( moduleName )
local module = FakeRequire.fakedModules[moduleName]
if module then return module end
if FakeRequire:isWhitelisted(moduleName) then
return FakeRequire.originalRequire(moduleName)
else
error('Requiring non whitelisted module: '..moduleName, 2)
end
end
function FakeRequire:install()
require = self._require
end
function FakeRequire:uninstall()
require = self.originalRequire
end
return FakeRequire
|
-- @Author:pandayu
-- @Version:1.0
-- @DateTime:2018-09-09
-- @Project:pandaCardServer CardGame
-- @Contact: QQ:815099602
local config = require "game.template.commander"
local _M = function(role,data)
if not data.cid or type(data.cid) ~= "number" then return 2 end
local id = data.id or 101
local commander = role.commanders:get(id)
if not commander then return 400 end
local canup,add_exp = config:can_car_strengthen(commander,data.cid)
if not canup then return 101 end
local cost = config:get_car_strengthen_cost(commander,data.cid)
if not cost then return 4 end
local enough,diamond,cost = role:check_resource_num(cost)
if not enough then
if data.usediamond ~= 1 or role.base:get_diamond() < diamond then return 100 end
end
role:consume_resource(cost)
commander:car_strengthen(data.cid,cost)
return 0
end
return _M
|
local msgserver = require "snax.msgserver"
local crypt = require "skynet.crypt"
local skynet = require "skynet"
local loginservice = tonumber(...)
local server = {}
local users = {}
local username_map = {}
local internal_id = 0
-- login server disallow multi login, so login_handler never be reentry
-- call by login server
function server.login_handler(uid, secret)
if users[uid] then
error(string.format("%s is already login", uid))
end
internal_id = internal_id + 1
local id = internal_id -- don't use internal_id directly
local username = msgserver.username(uid, id, servername)
-- you can use a pool to alloc new agent
local agent = skynet.newservice "msgagent"
local u = {
username = username,
agent = agent,
uid = uid,
subid = id,
}
-- trash subid (no used)
skynet.call(agent, "lua", "login", uid, id, secret)
users[uid] = u
username_map[username] = u
msgserver.login(username, secret)
-- you should return unique subid
return id
end
-- call by agent
function server.logout_handler(uid, subid)
local u = users[uid]
if u then
local username = msgserver.username(uid, subid, servername)
assert(u.username == username)
msgserver.logout(u.username)
users[uid] = nil
username_map[u.username] = nil
skynet.call(loginservice, "lua", "logout",uid, subid)
end
end
-- call by login server
function server.kick_handler(uid, subid)
local u = users[uid]
if u then
local username = msgserver.username(uid, subid, servername)
assert(u.username == username)
-- NOTICE: logout may call skynet.exit, so you should use pcall.
pcall(skynet.call, u.agent, "lua", "logout")
end
end
-- call by self (when socket disconnect)
function server.disconnect_handler(username)
local u = username_map[username]
if u then
skynet.call(u.agent, "lua", "afk")
end
end
-- call by self (when recv a request from client)
function server.request_handler(username, msg)
local u = username_map[username]
return skynet.tostring(skynet.rawcall(u.agent, "client", msg))
end
-- call by self (when gate open)
function server.register_handler(name)
servername = name
skynet.error("register_handler name="..name)
skynet.call(loginservice, "lua", "register_gate", servername, skynet.self())
end
msgserver.start(server)
|
global.real_time = 0
global.real_time_update = 0
global.real_ups = 60
require("script.commands")
require("script.clock")
|
local cpath = select(1, ...) or "" -- callee path
local function nTimes(n, f, x) for i = 0, n - 1 do x = f(x) end return x end -- calls n times f(x)
local function rmlast(str) return str:sub(1, -2):match(".+[%./]") or "" end -- removes last dir / file from the callee path
local cpppdpath = nTimes(4, rmlast, cpath) -- callee parent parent of parent dir path
local _ss = require (cpppdpath .. "Settings/Static_Settings")
return function()
local H_SUBWAY = 1
if getServer() ~= "None" then
local ss = _ss()
H_SUBWAY = ss.H_SUBWAY
end
local HoennMap = {}
HoennMap["Abandoned Ship 1F Room 1"] = {["Abandoned Ship 1F_B"] = {1}}
HoennMap["Abandoned Ship 1F Room 2_A"] = {["Abandoned Ship 1F_A"] = {1}}
HoennMap["Abandoned Ship 1F Room 2_B"] = {["Abandoned Ship 1F_A"] = {1}}
HoennMap["Abandoned Ship 1F_A"] = {["Abandoned Ship B1F"] = {1}, ["Abandoned Ship 1F Room 2_A"] = {}, ["Abandoned Ship 1F Room 2_B"] = {}, ["Abandoned Ship Exterior_A"] = {1}}
HoennMap["Abandoned Ship 1F_B"] = {["Abandoned Ship Exterior_B"] = {1}, ["Abandoned Ship 1F Room 1"] = {1}, ["Abandoned Ship B1F"] = {1}}
HoennMap["Abandoned Ship B1F Room 1"] = {["Abandoned Ship B1F"] = {1}}
HoennMap["Abandoned Ship B1F Room 2"] = {["Abandoned Ship B1F"] = {1}}
HoennMap["Abandoned Ship B1F Room 3"] = {["Abandoned Ship B1F"] = {1}}
HoennMap["Abandoned Ship B1F Room 4"] = {["Abandoned Ship B1F"] = {1}}
HoennMap["Abandoned Ship B1F"] = {["Storage Unit"] = {1}, ["Abandoned Ship B1F Room 4"] = {1}, ["Abandoned Ship B1F Room 3"] = {1}, ["Abandoned Ship B1F Room 2"] = {1}, ["Abandoned Ship B1F Room 1"] = {1}, ["Abandoned Ship 1F_B"] = {1}, ["Abandoned Ship 1F_A"] = {1}}
HoennMap["Abandoned Ship Exterior_A"] = {["Abandoned Ship 1F_A"] = {1}, ["Route 108"] = {1}}
HoennMap["Abandoned Ship Exterior_B"] = {["Captains Office"] = {1}, ["Abandoned Ship 1F_B"] = {1}}
HoennMap["Ancient Tomb_A"] = {["Ancient Tomb_B"] = {1}, ["Route 120_A"] = {1}}
HoennMap["Ancient Tomb_B"] = {["Ancient Tomb_A"] = {1}}
HoennMap["Backdoor House 1"] = {["Backdoor House 2"] = {1}, ["Mossdeep City"] = {1}}
HoennMap["Backdoor House 2"] = {["Backdoor House 1"] = {1}}
HoennMap["Berry Masters House"] = {["Route 123_C"] = {1}}
HoennMap["Cable Car Station 1"] = {["Cable Car Station 2"] = {0.2}, ["Route 112_B"] = {0.2}}
HoennMap["Cable Car Station 2"] = {["Cable Car Station 1"] = {0.2}, ["Mt. Chimney"] = {0.2}}
HoennMap["Captains Office"] = {["Abandoned Ship Exterior_B"] = {1}}
HoennMap["Cave Of Steel 1F_A"] = {["Valley Of Steel_B"] = {1}, ["Cave Of Steel 2F"] = {1}}
HoennMap["Cave Of Steel 1F_B"] = {["Valley Of Steel_B"] = {1}}
HoennMap["Cave Of Steel 1F_C"] = {["Valley Of Steel Eastern Peak"] = {1}, ["Valley Of Steel_B"] = {1}}
HoennMap["Cave Of Steel 2F"] = {["Cave Of Steel 1F_A"] = {1}, ["Valley Of Steel_A"] = {1}}
HoennMap["Cave of Origin 1F"] = {["Cave of Origin B1F"] = {1}, ["Cave of Origin Entrance"] = {1}}
HoennMap["Cave of Origin B1F"] = {["Cave of Origin B2F"] = {1}, ["Cave of Origin 1F"] = {1}}
HoennMap["Cave of Origin B2F"] = {["Cave of Origin B3F"] = {1}, ["Cave of Origin B1F"] = {1}}
HoennMap["Cave of Origin B3F"] = {["Marine Cave Entrance"] = {1}, ["Terra Cave Entrance"] = {1}, ["Cave of Origin B2F"] = {1}}
HoennMap["Cave of Origin Entrance"] = {["Cave of Origin 1F"] = {1}, ["Sootopolis City"] = {1}}
HoennMap["Cutter House"] = {["Rustboro City_A"] = {1}}
HoennMap["Cycle Road Stop House 1"] = {["Route 110_B"] = {0.2}, ["Route 110_D"] = {0.2, {["items"] = {"Bicycle"}}, {["items"] = {"Green Bicycle"}}, {["items"] = {"Yellow Bicycle"}}, {["items"] = {"Blue Bicycle"}}}}
HoennMap["Cycle Road Stop House 2"] = {["Route 110_A"] = {0.2}, ["Route 110_D"] = {0.2, {["items"] = {"Bicycle"}}, {["items"] = {"Green Bicycle"}}, {["items"] = {"Yellow Bicycle"}}, {["items"] = {"Blue Bicycle"}}}}
HoennMap["Desert Ruins_A"] = {["Route 111 Desert"] = {1}, ["Desert Ruins_B"] = {1}}
HoennMap["Desert Ruins_B"] = {["Desert Ruins_A"] = {1}}
HoennMap["Desert Underpass Entrance"] = {["Fossil Maniac House"] = {1}}
HoennMap["Devon Corporation 1F"] = {["Devon Corporation 2F"] = {1}, ["Rustboro City_A"] = {1}}
HoennMap["Devon Corporation 2F"] = {["Devon Corporation 3F"] = {1}, ["Devon Corporation 1F"] = {1}}
HoennMap["Devon Corporation 3F"] = {["Devon Corporation 2F"] = {1}}
HoennMap["Dewford Town Gym"] = {["Dewford Town"] = {1}}
HoennMap["Dewford Town House 1"] = {["Dewford Town"] = {1}}
HoennMap["Dewford Town House 2"] = {["Dewford Town"] = {1}}
HoennMap["Dewford Town House 3"] = {["Dewford Town"] = {1}}
HoennMap["Dewford Town"] = {["Dewford Town Gym"] = {1}, ["Dewford Town House 3"] = {1}, ["Dewford Town House 2"] = {1}, ["Dewford Town House 1"] = {1}, ["Pokecenter Dewford Town"] = {1}, ["Route 106"] = {1}, ["Route 107"] = {1, {["abilities"] = {"surf"}}}}
HoennMap["Eastern House 1"] = {["Valley Of Steel Eastern Peak"] = {1}}
HoennMap["Eastern House 2"] = {["Valley Of Steel Eastern Peak"] = {1}}
HoennMap["Eastern House 3"] = {["Valley Of Steel Eastern Peak"] = {1}}
HoennMap["Ever Grande City_A"] = {["Pokecenter Ever Grande City"] = {1}, ["Ever Grande City_B"] = {1, {["abilities"] = {"dig"}}}, ["Route 128"] = {1, {["abilities"] = {"surf"}}}, ["Victory Road Hoenn 1F_A"] = {1}}
HoennMap["Ever Grande City_B"] = {["Ever Grande City_A"] = {1, {["abilities"] = {"dig"}}}, ["Pokemon League Hoenn"] = {1}, ["Victory Road Hoenn 1F_B"] = {1}}
HoennMap["Fallarbor House"] = {["Fallarbor Town"] = {1}}
HoennMap["Fallarbor Town"] = {["Fallarbor House"] = {1}, ["Professor Cozmo House"] = {1}, ["Mart Fallarbor Town"] = {1}, ["Pokecenter Fallarbor Town"] = {1}, ["Route 113"] = {1}, ["Route 114"] = {1}}
HoennMap["Feral Site_A"] = {["Feral Site_B"] = {1}, ["Fiery Path"] = {1}}
HoennMap["Feral Site_B"] = {["Feral Site_A"] = {1}}
HoennMap["Fiery Path"] = {["Feral Site_A"] = {1}, ["Route 112_A"] = {1.5}, ["Route 112_B"] = {1.5}}
HoennMap["Fortree City"] = {["Fortree Gym"] = {1}, ["Fortree House 1"] = {1}, ["Fortree House 2"] = {1}, ["Fortree House 3"] = {1}, ["Fortree House 4"] = {1}, ["Fortree House 5"] = {1}, ["Fortree House 6"] = {1}, ["Fortree Mart"] = {1}, ["Pokecenter Fortree City"] = {1}, ["Route 119A"] = {1}, ["Route 120_A"] = {1}}
HoennMap["Fortree Gym"] = {["Fortree City"] = {1}}
HoennMap["Fortree House 1"] = {["Fortree City"] = {1}}
HoennMap["Fortree House 2"] = {["Fortree City"] = {1}}
HoennMap["Fortree House 3"] = {["Fortree City"] = {1}}
HoennMap["Fortree House 4"] = {["Fortree City"] = {1}}
HoennMap["Fortree House 5"] = {["Fortree City"] = {1}}
HoennMap["Fortree House 6"] = {["Fortree City"] = {1}}
HoennMap["Fortree Mart"] = {["Fortree City"] = {1}}
HoennMap["Fossil Maniac House"] = {["Desert Underpass Entrance"] = {1}, ["Route 114"] = {1}}
HoennMap["Glacial Site"] = {["Route 103_C"] = {1}}
HoennMap["Granite Cave 1F2"] = {["Granite Cave 1F_B"] = {1}}
HoennMap["Granite Cave 1F_A"] = {["Granite Cave B1F_A"] = {1}, ["Route 106"] = {1}}
HoennMap["Granite Cave 1F_B"] = {["Granite Cave B1F_B"] = {1}, ["Granite Cave 1F2"] = {1}}
HoennMap["Granite Cave B1F_A"] = {["Granite Cave B2F_C"] = {1}, ["Granite Cave B2F_B"] = {1}, ["Granite Cave B2F_D"] = {1}, ["Granite Cave B2F_A"] = {1}, ["Granite Cave 1F_A"] = {1}}
HoennMap["Granite Cave B1F_B"] = {["Granite Cave B2F_D"] = {1}, ["Granite Cave 1F_B"] = {1}}
HoennMap["Granite Cave B2F_A"] = {["Granite Cave B1F_A"] = {1}}
HoennMap["Granite Cave B2F_B"] = {["Granite Cave B1F_A"] = {1}}
HoennMap["Granite Cave B2F_C"] = {["Granite Cave B1F_A"] = {1}}
HoennMap["Granite Cave B2F_D"] = {["Granite Cave B1F_A"] = {1}, ["Granite Cave B1F_B"] = {1}}
HoennMap["Haunted Site"] = {["Rusturf Tunnel_C"] = {1}}
HoennMap["Historical Site_A"] = {["Historical Site_B"] = {1}, ["Historical Site_C"] = {1}, ["Route 111 Desert"] = {1}}
HoennMap["Historical Site_B"] = {["Historical Site_A"] = {1}}
HoennMap["Historical Site_C"] = {["Historical Site_A"] = {1}}
HoennMap["Hoenn Safari Zone Area 1"] = {["Hoenn Safari Zone Lobby"] = {1}, ["Hoenn Safari Zone Area 2_A"] = {1}, ["Hoenn Safari Zone Area 2_B"] = {1}, ["Hoenn Safari Zone Area 4"] = {1}, ["Hoenn Safari Zone Area 5"] = {1}}
HoennMap["Hoenn Safari Zone Area 2_A"] = {["Hoenn Safari Zone Area 1"] = {1}}
HoennMap["Hoenn Safari Zone Area 2_B"] = {["Hoenn Safari Zone Area 1"] = {1}, ["Hoenn Safari Zone Area 2_A"] = {0.5}}
HoennMap["Hoenn Safari Zone Area 2_C"] = {["Hoenn Safari Zone Area 2_B"] = {0}, ["Hoenn Safari Zone Area 3"] = {0.2}}
HoennMap["Hoenn Safari Zone Area 2_D"] = {["Hoenn Safari Zone Area 2_A"] = {0}, ["Hoenn Safari Zone Area 3"] = {0.2}}
HoennMap["Hoenn Safari Zone Area 3"] = {["Hoenn Safari Zone Area 4"] = {1}, ["Hoenn Safari Zone Area 2_C"] = {1}, ["Hoenn Safari Zone Area 2_D"] = {1}}
HoennMap["Hoenn Safari Zone Area 4"] = {["Hoenn Safari Zone Area 1"] = {1}, ["Hoenn Safari Zone Area 3"] = {1}}
HoennMap["Hoenn Safari Zone Area 5"] = {["Hoenn Safari Zone Area 1"] = {1}, ["Hoenn Safari Zone Area 6"] = {1}}
HoennMap["Hoenn Safari Zone Area 6"] = {["Hoenn Safari Zone Area 5"] = {1}}
HoennMap["Hoenn Safari Zone Lobby"] = {["Hoenn Safari Zone Area 1"] = {1}, ["Route 121"] = {1}}
HoennMap["Island Cave_A"] = {["Island Cave_B"] = {1}, ["Route 105"] = {1}}
HoennMap["Island Cave_B"] = {["Island Cave_A"] = {1}}
HoennMap["Jagged Pass_A"] = {["Mt. Chimney"] = {1}, ["Jagged Pass_B"] = {0.5}}
HoennMap["Jagged Pass_B"] = {["Jagged Pass_C"] = {0.5}}
HoennMap["Jagged Pass_C"] = {["Route 112_C"] = {0.5}}
HoennMap["Jura Cave"] = {["Jura Pass"] = {1}}
HoennMap["Jura Pass"] = {["Leev Town"] = {1}, ["Jura Cave"] = {1}}
HoennMap["Lab Littleroot Town"] = {["Littleroot Town"] = {1}}
HoennMap["Lavaridge Mart"] = {["Lavaridge Town"] = {1}}
HoennMap["Lavaridge Town Gym 1F_A"] = {["Lavaridge Town Gym B1F_I"] = {1}, ["Lavaridge Town Gym B1F_D"] = {1}, ["Lavaridge Town"] = {1}}
HoennMap["Lavaridge Town Gym 1F_B"] = {["Lavaridge Town Gym B1F_H"] = {1}, ["Lavaridge Town Gym 1F_A"] = {1}}
HoennMap["Lavaridge Town Gym 1F_C"] = {["Lavaridge Town Gym B1F_D"] = {1}, ["Lavaridge Town Gym B1F_B"] = {1}}
HoennMap["Lavaridge Town Gym 1F_D"] = {["Lavaridge Town Gym B1F_C"] = {1}, ["Lavaridge Town Gym 1F_C"] = {1}, ["Lavaridge Town Gym 1F_B"] = {1}}
HoennMap["Lavaridge Town Gym 1F_E"] = {["Lavaridge Town Gym B1F_A"] = {1}, ["Lavaridge Town Gym B1F_B"] = {1}}
HoennMap["Lavaridge Town Gym 1F_F"] = {["Lavaridge Town Gym B1F_E"] = {1}, ["Lavaridge Town Gym B1F_A"] = {1}, ["Lavaridge Town Gym B1F_F"] = {1}}
HoennMap["Lavaridge Town Gym 1F_G"] = {["Lavaridge Town Gym B1F_G"] = {1}, ["Lavaridge Town Gym B1F_A"] = {1}}
HoennMap["Lavaridge Town Gym B1F_A"] = {["Lavaridge Town Gym 1F_G"] = {1}, ["Lavaridge Town Gym 1F_F"] = {1}, ["Lavaridge Town Gym 1F_E"] = {1}}
HoennMap["Lavaridge Town Gym B1F_B"] = {["Lavaridge Town Gym B1F_J"] = {1}, ["Lavaridge Town Gym 1F_C"] = {1}, ["Lavaridge Town Gym B1F_D"] = {1}, ["Lavaridge Town Gym 1F_E"] = {1}}
HoennMap["Lavaridge Town Gym B1F_C"] = {["Lavaridge Town Gym B1F_D"] = {1}}
HoennMap["Lavaridge Town Gym B1F_D"] = {["Lavaridge Town Gym 1F_A"] = {1}, ["Lavaridge Town Gym 1F_D"] = {1}, ["Lavaridge Town Gym 1F_C"] = {1}}
HoennMap["Lavaridge Town Gym B1F_E"] = {["Lavaridge Town Gym 1F_A"] = {1}}
HoennMap["Lavaridge Town Gym B1F_F"] = {["Lavaridge Town Gym B1F_H"] = {1}}
HoennMap["Lavaridge Town Gym B1F_G"] = {}
HoennMap["Lavaridge Town Gym B1F_H"] = {["Lavaridge Town Gym 1F_B"] = {1}}
HoennMap["Lavaridge Town Gym B1F_I"] = {["Lavaridge Town Gym 1F_A"] = {1}, ["Lavaridge Town Gym B1F_H"] = {1}}
HoennMap["Lavaridge Town Gym B1F_J"] = {["Lavaridge Town Gym B1F_B"] = {1}}
HoennMap["Lavaridge Town Herb Shop"] = {["Lavaridge Town"] = {1}}
HoennMap["Lavaridge Town House"] = {["Lavaridge Town"] = {1}}
HoennMap["Lavaridge Town"] = {["Valley Of Steel Entrance"] = {1}, ["Lavaridge Town Gym 1F_A"] = {1}, ["Lavaridge Town House"] = {1}, ["Lavaridge Town Herb Shop"] = {1}, ["Lavaridge Mart"] = {1}, ["Pokecenter Lavaridge Town"] = {1}, ["Route 112_C"] = {1}} -- links
HoennMap["Leev Town Entrance"] = {["Leev Town"] = {1}, ["Leev Town Port"] = {1}}
HoennMap["Leev Town Port"] = {["Leev Town Entrance"] = {1}, ["Lilycove City Harbor"] = {1}}
HoennMap["Leev Town"] = {["Leev Town Entrance"] = {1}, ["Jura Pass"] = {1}, ["Pokecenter Leev Town"] = {1}}
HoennMap["Lilycove CIty House 3"]--[[Capital I in CIty]] = {["Lilycove City"] = {1}}
HoennMap["Lilycove City Harbor"] = {["Leev Town Port"] = {1}, ["Lilycove City"] = {0.2}}
HoennMap["Lilycove City House 1"] = {["Lilycove City"] = {1}}
HoennMap["Lilycove City House 2"] = {["Lilycove City"] = {1}}
HoennMap["Lilycove City House 4"] = {["Lilycove City"] = {1}}
HoennMap["Lilycove City House 5"] = {["Lilycove City"] = {1}}
HoennMap["Lilycove City"] = {["Team Aqua Hideout Entrance"] = {1}, ["Lilycove Motel 1F"] = {1}, ["Lilycove Museum 1F"] = {1}, ["Lilycove City House 1"] = {1}, ["Lilycove City House 2"] = {1}, ["Lilycove CIty House 3"] = {1}, ["Lilycove City House 4"] = {1}, ["Lilycove City House 5"] = {1}, ["Lilycove City Harbor"] = {1}, ["Pokecenter Lilycove City"] = {1}, ["Route 121"] = {1}, ["Route 124_A"] = {1, {["abilities"] = {"surf"}}}, ["Lilycove Department Store 1F"] = {1}}
HoennMap["Lilycove Department Store 1F"] = {["Lilycove City"] = {1}, ["Lilycove Department Store 2F"] = {1}, ["Lilycove Department Store Elevator"] = {1}}
HoennMap["Lilycove Department Store 2F"] = {["Lilycove Department Store 1F"] = {1}, ["Lilycove Department Store 3F"] = {1}, ["Lilycove Department Store Elevator"] = {1}}
HoennMap["Lilycove Department Store 3F"] = {["Lilycove Department Store 2F"] = {1}, ["Lilycove Department Store 4F"] = {1}, ["Lilycove Department Store Elevator"] = {1}}
HoennMap["Lilycove Department Store 4F"] = {["Lilycove Department Store 3F"] = {1}, ["Lilycove Department Store 5F"] = {1}, ["Lilycove Department Store Elevator"] = {1}}
HoennMap["Lilycove Department Store 5F"] = {["Lilycove Department Store 4F"] = {1}, ["Lilycove Department Store Roof"] = {1}, ["Lilycove Department Store Elevator"] = {1}}
HoennMap["Lilycove Department Store Elevator"] = {["Lilycove Department Store 1F"] = {0.2}, ["Lilycove Department Store 2F"] = {0.2}, ["Lilycove Department Store 3F"] = {0.2}, ["Lilycove Department Store 4F"] = {0.2}, ["Lilycove Department Store 5F"] = {0.2}}
HoennMap["Lilycove Department Store Roof"] = {["Lilycove Department Store 5F"] = {1}}
HoennMap["Lilycove Motel 1F"] = {["Lilycove Motel 2F"] = {1}, ["Lilycove City"] = {1}}
HoennMap["Lilycove Motel 2F"] = {["Lilycove Motel 1F"] = {1}}
HoennMap["Lilycove Museum 1F"] = {["Lilycove Museum 2F"] = {1}, ["Lilycove City"] = {1}}
HoennMap["Lilycove Museum 2F"] = {["Lilycove Museum 1F"] = {1}}
HoennMap["Littleroot Town Truck"] = {["Littleroot Town"] = {1}}
HoennMap["Littleroot Town"] = {["Player House Littleroot Town"] = {1}, ["Prof. Birch House"] = {1}, ["Lab Littleroot Town"] = {1}, ["Littleroot Town Truck"] = {1}, ["Route 101"] = {1}}
HoennMap["Low Tide Entrance Room_A"] = {["Route 125"] = {1}}
HoennMap["Marine Cave End"] = {["Marine Cave Entrance"] = {1}} --aqua leader archie (10,28)
HoennMap["Marine Cave Entrance"] = {["Marine Cave End"] = {1}--[[need to speak to npc first (16,3)]], ["Cave of Origin B3F"] = {1}}
HoennMap["Mart Fallarbor Town"] = {["Fallarbor Town"] = {1}}
HoennMap["Mart Mauville City"] = {["Mauville City"] = {1}}
HoennMap["Mart Oldale Town"] = {["Oldale Town"] = {1}}
HoennMap["Mart Petalburg City"] = {["Petalburg City"] = {1}}
HoennMap["Mart Rustboro City"] = {["Rustboro City_A"] = {1}}
HoennMap["Mart Slateport"] = {["Slateport City"] = {1}}
HoennMap["Mauville City Game Corner"] = {["Mauville City"] = {1}}
HoennMap["Mauville City Gym"] = {["Mauville City"] = {1}}
HoennMap["Mauville City House 1"] = {["Mauville City"] = {1}}
HoennMap["Mauville City House 2"] = {["Mauville City"] = {1}}
HoennMap["Mauville City Stop House 1"] = {["Mauville City"] = {0.2}, ["Route 110_A"] = {0.2}}
HoennMap["Mauville City Stop House 2"] = {["Mauville City"] = {0.2}, ["Route 117"] = {0.2}}
HoennMap["Mauville City Stop House 3"] = {["Mauville City"] = {0.2}, ["Route 111 South"] = {0.2}}
HoennMap["Mauville City Stop House 4"] = {["Mauville City"] = {0.2}, ["Route 118_A"] = {0.2}}
HoennMap["Mauville City"] = {["Mauville City Gym"] = {1}, ["Rydels Cycles"] = {1}, ["Mauville City Game Corner"] = {1}, ["Mauville City House 1"] = {1}, ["Mauville City House 2"] = {1}, ["Mart Mauville City"] = {1}, ["Mauville City Stop House 1"] = {1}, ["Mauville City Stop House 2"] = {1}, ["Mauville City Stop House 3"] = {1}, ["Mauville City Stop House 4"] = {1}, ["Pokecenter Mauville City"] = {1}}
HoennMap["Meteor Falls 1F 2R_A"] = {["Meteor Falls 1F 2R_B"] = {1}, ["Meteor falls B1F 1R_A"] = {1}}
HoennMap["Meteor Falls 1F 2R_B"] = {["Meteor falls 1F 1R_B"] = {1.5}, ["Meteor falls B1F 1R_A"] = {1}, ["Meteor falls B1F 1R_B"] = {1}}
HoennMap["Meteor Falls B1F 2R"] = {["Meteor falls B1F 1R_B"] = {1}}
HoennMap["Meteor falls 1F 1R_A"] = {["Route 114"] = {1.5}, ["Meteor falls 1F 1R_X"] = {0.7}}
HoennMap["Meteor falls 1F 1R_B"] = {["Meteor Falls 1F 2R_B"] = {0.5}, ["Meteor falls 1F 1R_A"] = {1}}
HoennMap["Meteor falls 1F 1R_C"] = {["Meteor falls B1F 1R_A"] = {0.5}}
HoennMap["Meteor falls 1F 1R_D"] = {["Meteor falls B1F 1R_B"] = {0.5}}
HoennMap["Meteor falls 1F 1R_X"] = {["Meteor falls 1F 1R_A"] = {0.7}, ["Route 115_A"] = {1.5}}
HoennMap["Meteor falls B1F 1R_A"] = {["Meteor falls 1F 1R_C"] = {1}, ["Meteor Falls 1F 2R_B"] = {1}, ["Meteor Falls 1F 2R_A"] = {1}}
HoennMap["Meteor falls B1F 1R_B"] = {["Meteor Falls 1F 2R_B"] = {1.5}, ["Meteor Falls B1F 2R"] = {1.5}, ["Meteor falls 1F 1R_D"] = {1.5}}
HoennMap["Mineral Site_A"] = {["Mineral Site_B"] = {1}, ["Route 115_A"] = {1}}
HoennMap["Mineral Site_B"] = {["Mineral Site_A"] = {1}}
HoennMap["Moon 1F_A"] = {["Moon_A"] = {1}, ["Moon_B"] = {1}, ["Moon B1F_C"] = {1}}
HoennMap["Moon 1F_B"] = {["Moon_B"] = {1}, ["Moon_C"] = {1}, ["Moon B1F_A"] = {1}}
HoennMap["Moon 1F_C"] = {["Moon_C"] = {1}, ["Moon B1F_B"] = {1}}
HoennMap["Moon 1F_D"] = {["Moon_D"] = {1}, ["Moon B1F_D"] = {1}}
HoennMap["Moon 1F_E"] = {} -- not in story yet
HoennMap["Moon 2F_A"] = {["Moon B1F_D"] = {1}, ["Moon 2F_B"] = {1}}
HoennMap["Moon 2F_B"] = {["Moon 2F_A"] = {1}, ["Moon_E"] = {1}}
HoennMap["Moon B1F_A"] = {["Moon 1F_B"] = {1}}
HoennMap["Moon B1F_B"] = {["Sootopolis City"] = {1}, ["Moon 1F_C"] = {1}}
HoennMap["Moon B1F_C"] = {["Moon 1F_A"] = {1}}
HoennMap["Moon B1F_D"] = {["Moon B1F_C"] = {1}, ["Moon 1F_D"] = {1}, ["Moon 2F_A"] = {1}}
HoennMap["Moon_A"] = {["Moon 1F_A"] = {1}}
HoennMap["Moon_B"] = {["Moon_A"] = {1}, ["Moon 1F_A"] = {1}, ["Moon 1F_B"] = {1}}
HoennMap["Moon_C"] = {["Moon_D"] = {1}, ["Moon 1F_B"] = {1}, ["Moon 1F_C"] = {1}}
HoennMap["Moon_D"] = {["Moon_A"] = {1}, ["Moon 1F_D"] = {1}}
HoennMap["Moon_E"] = {["Moon 2F_A"] = {1}}
HoennMap["Mossdeep City House"] = {["Mossdeep City"] = {1}}
HoennMap["Mossdeep City Space Center 1F"] = {["Mossdeep City Space Center 2F"] = {1}, ["Mossdeep City"] = {1}}
HoennMap["Mossdeep City Space Center 2F"] = {["Moon_A"] = {1}, ["Mossdeep City Space Center 1F"] = {1}}
HoennMap["Mossdeep City"] = {["Mossdeep Gym_A"] = {1}, ["Mossdeep City Space Center 1F"] = {1}, ["Stevens House"] = {1}, ["Mossdeep City House"] = {1}, ["Secret Base Boy House"] = {1}, ["Backdoor House 1"] = {1}, ["Pokeblock Enthusiasts House"] = {1}, ["Mossdeep Pokemart"] = {1}, ["Pokecenter Mossdeep City"] = {1}, ["Route 124_A"] = {1.5, {["abilities"] = {"surf"}}}, ["Route 125"] = {1.5, {["abilities"] = {"surf"}}}, ["Route 127_A"] = {1.5, {["abilities"] = {"surf"}}}}
HoennMap["Mossdeep Gym_A"] = {["Mossdeep City"] = {1}, ["Mossdeep Gym_D"] = {1}, ["Mossdeep Gym_C"] = {1}, ["Mossdeep Gym_B"] = {1}}
HoennMap["Mossdeep Gym_B"] = {["Mossdeep Gym_A"] = {1}, ["Mossdeep Gym_D"] = {1}, ["Mossdeep Gym_F"] = {1}}
HoennMap["Mossdeep Gym_C"] = {["Mossdeep Gym_E"] = {1}, ["Mossdeep Gym_A"] = {1}}
HoennMap["Mossdeep Gym_D"] = {["Mossdeep Gym_F"] = {1}, ["Mossdeep Gym_B"] = {1}, ["Mossdeep Gym_E"] = {1}}
HoennMap["Mossdeep Gym_E"] = {["Mossdeep Gym_D"] = {1}, ["Mossdeep Gym_C"] = {1}}
HoennMap["Mossdeep Gym_F"] = {["Mossdeep Gym_B"] = {1}, ["Mossdeep Gym_D"] = {1}}
HoennMap["Mossdeep Pokemart"] = {["Mossdeep City"] = {1}}
HoennMap["Mt. Chimney"] = {["Cable Car Station 2"] = {1}, ["Jagged Pass_A"] = {1}}
HoennMap["Mt. Pyre 1F"] = {["Route 122"] = {1.5}, ["Mt. Pyre 2F"] = {1.5}}
HoennMap["Mt. Pyre 2F"] = {["Mt. Pyre 1F"] = {1.5}, ["Mt. Pyre 3F"] = {1.5}}
HoennMap["Mt. Pyre 3F"] = {["Mt. Pyre 2F"] = {1.5}, ["Mt. Pyre 4F"] = {1.5}, ["Mt. Pyre Exterior"] = {1.5}}
HoennMap["Mt. Pyre 4F"] = {["Mt. Pyre 3F"] = {1.5}}
HoennMap["Mt. Pyre Exterior"] = {["Mt. Pyre 3F"] = {3}, ["Mt. Pyre Summit"] = {3}}
HoennMap["Mt. Pyre Summit"] = {["Mt. Pyre Exterior"] = {1.5}}
HoennMap["Natural Site"] = {["Route 119A"] = {1}}
HoennMap["New Mauville Entrance"] = {["Route 110_C"] = {1}, ["New Mauville"] = {1}--[[talk to shelly maybe 12, 7]]}
HoennMap["New Mauville"] = {["New Mauville Entrance"] = {1}} -- not fully supported with npc restrictions
HoennMap["Old Lady House"] = {["Route 111 North"] = {1}}
HoennMap["Oldale Town House 1"] = {["Oldale Town"] = {1}}
HoennMap["Oldale Town House 2"] = {["Oldale Town"] = {1}}
HoennMap["Oldale Town"] = {["Oldale Town House 2"] = {1}, ["Oldale Town House 1"] = {1}, ["Mart Oldale Town"] = {1}, ["Pokecenter Oldale Town"] = {1}, ["Route 101"] = {1}, ["Route 102"] = {1}, ["Route 103_A"] = {1}}
HoennMap["Pacifidlog Town House 1"] = {["Pacifidlog Town"] = {1}}
HoennMap["Pacifidlog Town House 2"] = {["Pacifidlog Town"] = {1}}
HoennMap["Pacifidlog Town House 3"] = {["Pacifidlog Town"] = {1}}
HoennMap["Pacifidlog Town House 4"] = {["Pacifidlog Town"] = {1}}
HoennMap["Pacifidlog Town House 5"] = {["Pacifidlog Town"] = {1}}
HoennMap["Pacifidlog Town"] = {["Pacifidlog Town House 1"] = {1}, ["Pacifidlog Town House 2"] = {1}, ["Pacifidlog Town House 3"] = {1}, ["Pacifidlog Town House 4"] = {1}, ["Pacifidlog Town House 5"] = {1}, ["Pokecenter Pacifidlog Town"] = {1}, ["Route 131"] = {1}, ["Route 132"] = {1}}
HoennMap["Petalburg City Gym_A"] = {["Petalburg City Gym_C"] = {1}, ["Petalburg City Gym_B"] = {1}, ["Petalburg City"] = {1}}
HoennMap["Petalburg City Gym_B"] = {["Petalburg City Gym_A"] = {1}, ["Petalburg City Gym_D"] = {1}, ["Petalburg City Gym_E"] = {1}}
HoennMap["Petalburg City Gym_C"] = {["Petalburg City Gym_A"] = {1}, ["Petalburg City Gym_E"] = {1}, ["Petalburg City Gym_F"] = {1}}
HoennMap["Petalburg City Gym_D"] = {["Petalburg City Gym_B"] = {1}, ["Petalburg City Gym_G"] = {1}}
HoennMap["Petalburg City Gym_E"] = {["Petalburg City Gym_G"] = {1}, ["Petalburg City Gym_B"] = {1}, ["Petalburg City Gym_C"] = {1}}
HoennMap["Petalburg City Gym_F"] = {["Petalburg City Gym_C"] = {1}}
HoennMap["Petalburg City Gym_G"] = {["Petalburg City Gym_I"] = {1}, ["Petalburg City Gym_D"] = {1}, ["Petalburg City Gym_E"] = {1}}
HoennMap["Petalburg City Gym_H"] = {["Petalburg City Gym_I"] = {1}}
HoennMap["Petalburg City Gym_I"] = {["Petalburg City Gym_H"] = {1}, ["Petalburg City Gym_G"] = {1}}
HoennMap["Petalburg City House 1"] = {["Petalburg City"] = {1}}
HoennMap["Petalburg City House 2"] = {["Petalburg City"] = {1}}
HoennMap["Petalburg City Wallys House"] = {["Petalburg City"] = {1}}
HoennMap["Petalburg City"] = {["Petalburg City Wallys House"] = {1}, ["Petalburg City Gym_A"] = {1}, ["Petalburg City House 2"] = {1}, ["Petalburg City House 1"] = {1}, ["Mart Petalburg City"] = {1}, ["Pokecenter Petalburg City"] = {1}, ["Route 102"] = {1}, ["Route 104_B"] = {1}}
HoennMap["Petalburg Maze"] = {["Petalburg Woods_B"] = {1}}
HoennMap["Petalburg Woods_A"] = {["Route 104_A"] = {1}, ["Route 104_B"] = {1}, ["Route 104_C"] = {1}, ["Petalburg Woods_B"] = {1, {["abilities"] = {"cut"}}}}
HoennMap["Petalburg Woods_B"] = {["Petalburg Maze"] = {1}, ["Petalburg Woods_A"] = {1}} -- link inside wood
HoennMap["Player Bedroom Littleroot Town"] = {["Player House Littleroot Town"] = {1}}
HoennMap["Player House Littleroot Town"] = {["Player Bedroom Littleroot Town"] = {1}, ["Littleroot Town"] = {1}}
HoennMap["Pokeblock Enthusiasts House"] = {["Mossdeep City"] = {1}}
HoennMap["Pokecenter Dewford Town"] = {["Dewford Town"] = {1}, ["Transmat Station"] = {0.2}}
HoennMap["Pokecenter Eastern Peak"] = {["Valley Of Steel Eastern Peak"] = {1}}
HoennMap["Pokecenter Ever Grande City"] = {["Ever Grande City_A"] = {1}, ["Transmat Station"] = {0.2}}
HoennMap["Pokecenter Fallarbor Town"] = {["Fallarbor Town"] = {1}, ["Transmat Station"] = {0.2}}
HoennMap["Pokecenter Fortree City"] = {["Fortree City"] = {1}, ["Transmat Station"] = {0.2}}
HoennMap["Pokecenter Lavaridge Town"] = {["Lavaridge Town"] = {1}, ["Transmat Station"] = {0.2}}
HoennMap["Pokecenter Leev Town"] = {["Leev Town"] = {1}}
HoennMap["Pokecenter Lilycove City"] = {["Lilycove City"] = {1}, ["Transmat Station"] = {0.2}}
HoennMap["Pokecenter Mauville City"] = {["Mauville City"] = {1}, ["Transmat Station"] = {0.2}}
HoennMap["Pokecenter Mossdeep City"] = {["Mossdeep City"] = {1}, ["Transmat Station"] = {0.2}}
HoennMap["Pokecenter Oldale Town"] = {["Oldale Town"] = {1}, ["Transmat Station"] = {0.2}}
HoennMap["Pokecenter Pacifidlog Town"] = {["Pacifidlog Town"] = {1}, ["Transmat Station"] = {0.2}}
HoennMap["Pokecenter Petalburg City"] = {["Petalburg City"] = {1}, ["Transmat Station"] = {0.2}}
HoennMap["Pokecenter Rustboro City"] = {["Rustboro City_A"] = {1}, ["Transmat Station"] = {0.2}}
HoennMap["Pokecenter Slateport"] = {["Slateport City"] = {1}, ["Transmat Station"] = {0.2}}
HoennMap["Pokecenter Sootopolis City"] = {["Sootopolis City"] = {1}, ["Transmat Station"] = {0.2}}
HoennMap["Pokecenter Verdanturf"] = {["Verdanturf Town"] = {1}, ["Transmat Station"] = {0.2}}
HoennMap["Pokecenter Western Peak"] = {["Valley Of Steel Western Peak"] = {1}}
HoennMap["Pokemon League Hoenn"] = {["Ever Grande City_B"] = {1}}
HoennMap["Pokemon Trainers School"] = {["Rustboro City_A"] = {1}}
HoennMap["Prof. Birch Bedroom"] = {["Prof. Birch House"] = {1}}
HoennMap["Prof. Birch House"] = {["Prof. Birch Bedroom"] = {1}, ["Littleroot Town"] = {1}}
HoennMap["Professor Cozmo House"] = {["Fallarbor Town"] = {1}}
HoennMap["Route 101"] = {["Littleroot Town"] = {1}, ["Oldale Town"] = {1}}
HoennMap["Route 102"] = {["Oldale Town"] = {1}, ["Petalburg City"] = {1}}
HoennMap["Route 103_A"] = {["Oldale Town"] = {0.5}, ["Route 103_B"] = {0.5, {["abilities"] = {"surf"}}}}
HoennMap["Route 103_B"] = {["Route 103_C"] = {0, {["abilities"] = {"cut"}}}, ["Route 103_A"] = {0.5, {["abilities"] = {"surf"}}}, ["Route 103_D"] = {0.5, {["abilities"] = {"surf"}}}, ["Route 110_B"] = {1}}
HoennMap["Route 103_C"] = {["Glacial Site"] = {1}, ["Route 103_B"] = {0, {["abilities"] = {"surf"}}}}
HoennMap["Route 103_D"] = {["Route 103_B"] = {0, {["abilities"] = {"cut"}}}}
HoennMap["Route 104 House"] = {["Route 104_A"] = {1}}
HoennMap["Route 104 Sailor House"] = {["Route 104_B"] = {1}}
HoennMap["Route 104_A"] = {["Route 104 House"] = {1}, ["Petalburg Woods_A"] = {1}, ["Rustboro City_A"] = {1}, ["Rustboro City_B"] = {1.1}}
HoennMap["Route 104_B"] = {["Route 104 Sailor House"] = {1}, ["Petalburg Woods_A"] = {1}, ["Route 105"] = {1.5, {["abilities"] = {"surf"}}}, ["Petalburg City"] = {1}}
HoennMap["Route 104_C"] = {["Route 104_B"] = {0.5}}
HoennMap["Route 105"] = {["Island Cave_A"] = {1}, ["Route 104_B"] = {3}, ["Route 106"] = {3}}
HoennMap["Route 106"] = {["Granite Cave 1F_A"] = {1}, ["Dewford Town"] = {1.5}, ["Route 105"] = {1.5, {["abilities"] = {"surf"}}}} -- link cave
HoennMap["Route 107"] = {["Dewford Town"] = {2}, ["Route 108"] = {2}}
HoennMap["Route 108"] = {["Abandoned Ship Exterior_A"] = {1}, ["Route 107"] = {2}, ["Route 109"] = {2}} -- link abandoned ship
HoennMap["Route 109 House"] = {["Route 109"] = {1}}
HoennMap["Route 109"] = {["Route 109 House"] = {1}, ["Route 108"] = {2, {["abilities"] = {"surf"}}}, ["Slateport City"] = {2}}
HoennMap["Route 110_A"] = {["Mauville City Stop House 1"] = {1}, ["Cycle Road Stop House 2"] = {1}, ["Route 110_B"] = {2}, ["Route 110_C"] = {1.5, {["abilities"] = {"surf"}}}}
HoennMap["Route 110_B"] = {["Trick House"] = {1}, ["Route 103_B"] = {1}, ["Slateport City"] = {1}, ["Cycle Road Stop House 1"] = {1}, ["Route 110_A"] = {2}}
HoennMap["Route 110_C"] = {["Route 110_A"] = {1.5, {["abilities"] = {"surf"}}}, ["New Mauville Entrance"] = {1}}
HoennMap["Route 110_D"] = {["Cycle Road Stop House 1"] = {0.5}, ["Cycle Road Stop House 2"] = {0.5}}
HoennMap["Route 111 Desert"] = {["Historical Site_A"] = {1}, ["Desert Ruins_A"] = {1}, ["Route 111 North"] = {1}, ["Route 111 South"] = {1}}
HoennMap["Route 111 House 1"] = {["Route 111 South"] = {1}}
HoennMap["Route 111 North"] = {["Old Lady House"] = {1}, ["Route 111 Desert"] = {1, {["items"] = {"Go-Goggles"}}}, ["Route 112_A"] = {1}, ["Route 113"] = {1}}
HoennMap["Route 111 South"] = {["Route 111 House 1"] = {1}, ["Mauville City Stop House 3"] = {1.5}, ["Route 111 Desert"] = {1.5, {["items"] = {"Go-Goggles"}}}, ["Route 112_B"] = {1.5}}
HoennMap["Route 112_A"] = {["Fiery Path"] = {1}, ["Route 111 North"] = {1}}
HoennMap["Route 112_B"] = {["Cable Car Station 1"] = {1}, ["Fiery Path"] = {1}, ["Route 111 South"] = {1}}
HoennMap["Route 112_C"] = {["Lavaridge Town"] = {0.5}, ["Jagged Pass_C"] = {0.5}, ["Route 112_B"] = {0.5}}
HoennMap["Route 113"] = {["Fallarbor Town"] = {1.5}, ["Route 111 North"] = {1.5}}
HoennMap["Route 114 House"] = {["Route 114"] = {1}}
HoennMap["Route 114"] = {["Route 114 House"] = {1}, ["Fossil Maniac House"] = {1}, ["Fallarbor Town"] = {1.5}, ["Meteor falls 1F 1R_A"] = {1.5}}
HoennMap["Route 115_A"] = {["Mineral Site_A"] = {1}, ["Meteor falls 1F 1R_X"] = {1}, ["Route 115_B"] = {0.5}, ["Route 115_C"] = {1, {["abilities"] = {"surf"}}}}
HoennMap["Route 115_B"] = {["Route 115_A"] = {0.5, {["abilities"] = {"surf"}}}, ["Rustboro City_A"] = {1}}
HoennMap["Route 115_C"] = {["Route 115_A"] = {1.5, {["abilities"] = {"surf"}}}, ["Route 115_B"] = {1.5, {["abilities"] = {"surf"}}}, ["Route 115_E"] = {1.5, {["abilities"] = {"rock climb"}}}, ["Route 115_D"] = {1.5, {["abilities"] = {"rock smash"}}}}
HoennMap["Route 115_D"] = {["Route 115_C"] = {0.5}, ["Meteor falls 1F 1R_C"] = {0.5}}
HoennMap["Route 115_E"] = {["Route 115_C"] = {1}}
HoennMap["Route 116 House"] = {["Route 116_A"] = {0.5}}
HoennMap["Route 116_A"] = {["Route 116 House"] = {1}, ["Rustboro City_A"] = {1}, ["Rusturf Tunnel_A"] = {1}, ["Route 116_C"] = {0.5, {["abilities"] = {"cut"}}}, ["Route 116_B"] = {1, {["abilities"] = {"dig"}}}, ["Verdanturf Town"] = {1, {["abilities"] = {"dig"}}}}
HoennMap["Route 116_B"] = {["Rusturf Tunnel_B"] = {1}, ["Route 116_A"] = {1, {["abilities"] = {"dig"}}}, ["Verdanturf Town"] = {1, {["abilities"] = {"dig"}}}}
HoennMap["Route 116_C"] = {["Route 116_A"] = {0.5}}
HoennMap["Route 117"] = {["Mauville City Stop House 2"] = {1.5}, ["Verdanturf Town"] = {1.5}}
HoennMap["Route 118_A"] = {["Mauville City Stop House 4"] = {0.5}, ["Route 118_B"] = {0.5, {["abilities"] = {"surf"}}}}
HoennMap["Route 118_B"] = {["Route 118_A"] = {0.5, {["abilities"] = {"surf"}}}, ["Route 119B"] = {0.5}, ["Route 123_C"] = {0.5}}
HoennMap["Route 119A"] = {["Natural Site"] = {1}, ["Weather Institute 1F"] = {1}, ["Fortree City"] = {2}, ["Route 119B"] = {2}}
HoennMap["Route 119B House"] = {["Route 119B"] = {1}}
HoennMap["Route 119B"] = {["Route 119B House"] = {1}, ["Route 118_B"] = {2}, ["Route 119A"] = {2}}
HoennMap["Route 120_A"] = {["Ancient Tomb_A"] = {1}, ["Fortree City"] = {2}, ["Route 121"] = {2}, ["Route 120_B"] = {2, {["abilities"] = {"surf"}}}}
HoennMap["Route 120_B"] = {["Route 120_A"] = {0.5, {["abilities"] = {"surf"}}}}
HoennMap["Route 121"] = {["Lilycove City"] = {1.5}, ["Route 120_A"] = {1.5}, ["Route 122"] = {1.5, {["abilities"] = {"surf"}}}, ["Hoenn Safari Zone Lobby"] = {1.5}}
HoennMap["Route 122"] = {["Route 121"] = {2, {["abilities"] = {"surf"}}}, ["Route 123_A"] = {2, {["abilities"] = {"surf"}}}, ["Mt. Pyre 1F"] = {2, {["abilities"] = {"surf"}}}}
HoennMap["Route 123_A"] = {["Route 122"] = {1}, ["Route 123_B"] = {1, {["abilities"] = {"cut"}}}, ["Route 123_C"] = {1}}
HoennMap["Route 123_B"] = {["Route 123_C"] = {1}}
HoennMap["Route 123_C"] = {["Berry Masters House"] = {1}, ["Route 118_B"] = {1}}
HoennMap["Route 124 Underwater_A"] = {["Route 124_A"] = {1.5}, ["Route 124_C"] = {1.5}, ["Route 124_D"] = {1.5}}
HoennMap["Route 124 Underwater_B"] = {["Route 124_A"] = {1.5}}
HoennMap["Route 124 Underwater_C"] = {["Route 124_B"] = {1.5}}
HoennMap["Route 124 Underwater_D"] = {["Route 124_B"] = {1.5}, ["Route 124_A"] = {1.5}}
HoennMap["Route 124 Underwater_E"] = {["Route 124_A"] = {1.5}}
HoennMap["Route 124_A"] = {["Treasure Hunter House"] = {1}, ["Lilycove City"] = {2.5}, ["Mossdeep City"] = {2.5}, ["Route 126_A"] = {2.5}, ["Route 124 Underwater_A"] = {2.5, {["abilities"] = {"dive"}}}, ["Route 124 Underwater_B"] = {2.5, {["abilities"] = {"dive"}}}, ["Route 124 Underwater_D"] = {2.5, {["abilities"] = {"dive"}}}, ["Route 124 Underwater_E"] = {2.5, {["abilities"] = {"dive"}}}}
HoennMap["Route 124_B"] = {["Route 124 Underwater_C"] = {2.5, {["abilities"] = {"dive"}}}, ["Route 124 Underwater_D"] = {2.5, {["abilities"] = {"dive"}}}}
HoennMap["Route 124_C"] = {["Route 124 Underwater_A"] = {1.5}}
HoennMap["Route 124_D"] = {["Route 124 Underwater_A"] = {1.5}}
HoennMap["Route 125"] = {["Low Tide Entrance Room_A"] = {1}, ["Mossdeep City"] = {2}}
HoennMap["Route 126 Underwater_A"] = {["Route 126_A"] = {2}, ["Route 126_C"] = {2}, ["Sootopolis City Underwater"] = {2}}
HoennMap["Route 126 Underwater_B"] = {["Route 126_B"] = {1}, ["Route 126_A"] = {1}}
HoennMap["Route 126 Underwater_C"] = {["Route 126_C"] = {1}, ["Route 126_D"] = {1}}
HoennMap["Route 126_A"] = {["Route 124_A"] = {2}, ["Route 126 Underwater_A"] = {2}, ["Route 127_A"] = {2}}
HoennMap["Route 126_B"] = {["Route 126 Underwater_B"] = {1, {["abilities"] = {"dive"}}}}
HoennMap["Route 126_C"] = {["Route 126 Underwater_A"] = {1, {["abilities"] = {"dive"}}}, ["Route 126 Underwater_C"] = {1, {["abilities"] = {"dive"}}}}
HoennMap["Route 126_D"] = {["Route 126 Underwater_C"] = {1, {["abilities"] = {"dive"}}}}
HoennMap["Route 127 Underwater_A"] = {["Route 127_A"] = {2}, ["Route 128 Underwater_A"] = {2}}
HoennMap["Route 127 Underwater_B"] = {["Route 127_A"] = {1}, ["Route 127_B"] = {1}}
HoennMap["Route 127_A"] = {["Mossdeep City"] = {2}, ["Route 126_A"] = {2}, ["Route 128"] = {2}, ["Route 127 Underwater_A"] = {2.5, {["abilities"] = {"dive"}}}, ["Route 127 Underwater_B"] = {2.5, {["abilities"] = {"dive"}}}}
HoennMap["Route 127_B"] = {["Route 127 Underwater_B"] = {2.5, {["abilities"] = {"dive"}}}}
HoennMap["Route 128 Underwater_A"] = {["Secret Underwater Cavern"] = {2.5}, ["Route 127 Underwater_A"] = {2.5, {["abilities"] = {"dive"}}}}
HoennMap["Route 128 Underwater_B"] = {["Route 128"] = {1}}
HoennMap["Route 128 Underwater_C"] = {["Route 128"] = {1}}
HoennMap["Route 128"] = {["Ever Grande City_A"] = {2}, ["Route 127_A"] = {2}, ["Route 129_A"] = {2}, ["Route 128 Underwater_B"] = {2, {["abilities"] = {"dive"}}}, ["Route 128 Underwater_C"] = {2, {["abilities"] = {"dive"}}}}
HoennMap["Route 129 Underwater"] = {["Route 129_A"] = {1.5}, ["Route 129_B"] = {1.5}, ["Route 130 Underwater_A"] = {1.5}}
HoennMap["Route 129_A"] = {["Route 128"] = {2}, ["Route 130_A"] = {2}, ["Route 129 Underwater"] = {2, {["abilities"] = {"dive"}}}}
HoennMap["Route 129_B"] = {["Route 129 Underwater"] = {2, {["abilities"] = {"dive"}}}}
HoennMap["Route 130 Underwater_A"] = {["Route 130_B"] = {2}, ["Route 129 Underwater"] = {2}}
HoennMap["Route 130 Underwater_B"] = {["Route 130_A"] = {1}}
HoennMap["Route 130_A"] = {["Route 129_A"] = {2}, ["Route 131"] = {2}, ["Route 130 Underwater_B"] = {2, {["abilities"] = {"dive"}}}}
HoennMap["Route 130_B"] = {["Route 130 Underwater_A"] = {1, {["abilities"] = {"dive"}}}}
HoennMap["Route 131"] = {["Pacifidlog Town"] = {2}, ["Route 130_A"] = {2}, ["Sky Pillar Entrance_A"] = {2}}
HoennMap["Route 132"] = {["Pacifidlog Town"] = {2}, ["Route 133"] = {2}}
HoennMap["Route 133"] = {["Route 132"] = {2}, ["Route 134"] = {2}}
HoennMap["Route 134"] = {["Route 133"] = {2}, ["Slateport City"] = {2}}
HoennMap["Rustboro City Building 1 1F"] = {["Rustboro City Building 1 2F"] = {1}, ["Rustboro City_A"] = {1}}
HoennMap["Rustboro City Building 1 2F"] = {["Rustboro City Building 1 3F"] = {1}, ["Rustboro City Building 1 1F"] = {1}}
HoennMap["Rustboro City Building 1 3F"] = {["Rustboro City Building 1 2F"] = {1}}
HoennMap["Rustboro City Building 2 1F"] = {["Rustboro City Building 2 2F"] = {1}, ["Rustboro City_A"] = {1}}
HoennMap["Rustboro City Building 2 2F"] = {["Rustboro City Building 2 1F"] = {1}}
HoennMap["Rustboro City Gym"] = {["Rustboro City_A"] = {1}}
HoennMap["Rustboro City House 1"] = {["Rustboro City_A"] = {1}}
HoennMap["Rustboro City House 2"] = {["Rustboro City_A"] = {1}}
HoennMap["Rustboro City House 3"] = {["Rustboro City_A"] = {1}}
HoennMap["Rustboro City_A"] = {["Devon Corporation 1F"] = {1}, ["Rustboro City Gym"] = {1}, ["Rustboro City Building 2 1F"] = {1}, ["Pokemon Trainers School"] = {1}, ["Cutter House"] = {1}, ["Rustboro City House 1"] = {1}, ["Rustboro City House 2"] = {1}, ["Rustboro City House 3"] = {1}, ["Rustboro City Building 1 1F"] = {1}, ["Mart Rustboro City"] = {1}, ["Pokecenter Rustboro City"] = {1}, ["Route 104_A"] = {1}, ["Route 115_B"] = {1}, ["Route 116_A"] = {1}}
HoennMap["Rustboro City_B"] = {["Route 104_A"] = {1}}
HoennMap["Rusturf Tunnel_A"] = {["Route 116_A"] = {1}, ["Rusturf Tunnel_B"] = {0.5, {["abilities"] = {"rock smash"}--[[npc maybe]]}}, ["Rusturf Tunnel_C"] = {0.5, {["abilities"] = {"rock smash"}}}}
HoennMap["Rusturf Tunnel_B"] = {["Route 116_B"] = {1}, ["Verdanturf Town"] = {1}, ["Rusturf Tunnel_A"] = {0.5, {["abilities"] = {"rock smash"}}}}
HoennMap["Rusturf Tunnel_C"] = {["Haunted Site"] = {1}, ["Rusturf Tunnel_A"] = {0.5, {["abilities"] = {"rock smash"}}}}
HoennMap["Rydels Cycles"] = {["Mauville City"] = {1}}
HoennMap["Secret Base Boy House"] = {["Mossdeep City"] = {1}}
HoennMap["Secret Underwater Cavern"] = {["Route 128 Underwater_A"] = {1}} -- links cavern
HoennMap["Sky Pillar 1F"] = {["Sky Pillar Entrance_B"] = {1}, ["Sky Pillar 2F"] = {1}}
HoennMap["Sky Pillar 2F"] = {["Sky Pillar 1F"] = {1}, ["Sky Pillar 3F"] = {1}}
HoennMap["Sky Pillar 3F"] = {["Sky Pillar 2F"] = {1}, ["Sky Pillar 4F_A"] = {1}, ["Sky Pillar 4F_B"] = {1}}
HoennMap["Sky Pillar 4F_A"] = {["Sky Pillar 3F"] = {1}, ["Sky Pillar 5F"] = {1}}
HoennMap["Sky Pillar 4F_B"] = {["Sky Pillar 3F"] = {1}}
HoennMap["Sky Pillar 5F"] = {["Sky Pillar 4F_A"] = {1}, ["Sky Pillar 6F"] = {1}}
HoennMap["Sky Pillar 6F"] = {["Sky Pillar 5F"] = {1}}
HoennMap["Sky Pillar Entrance Cave 1F"] = {["Sky Pillar Entrance_A"] = {1}, ["Sky Pillar Entrance_B"] = {1}}
HoennMap["Sky Pillar Entrance_A"] = {["Route 131"] = {1}, ["Sky Pillar Entrance Cave 1F"] = {1}}
HoennMap["Sky Pillar Entrance_B"] = {["Sky Pillar Entrance Cave 1F"] = {1}, ["Sky Pillar 1F"] = {1}}
HoennMap["Slateport City House 1"] = {["Slateport City"] = {1}}
HoennMap["Slateport City House 2"] = {["Slateport City"] = {1}}
HoennMap["Slateport City"] = {["Slateport Harbor"] = {1}, ["Slateport Museum 1F"] = {1}, ["Slateport Shipyard 1F"] = {1}, ["Slateport City House 2"] = {1}, ["Slateport City House 1"] = {1}, ["Mart Slateport"] = {1}, ["Pokecenter Slateport"] = {1}, ["Route 109"] = {1}, ["Route 110_B"] = {1}, ["Route 134"] = {1, {["abilities"] = {"dive"}}}}
HoennMap["Slateport Harbor"] = {["Slateport City"] = {1}}
HoennMap["Slateport Museum 1F"] = {["Slateport Museum 2F"] = {1}, ["Slateport City"] = {1}}
HoennMap["Slateport Museum 2F"] = {["Slateport Museum 1F"] = {1}}
HoennMap["Slateport Shipyard 1F"] = {["Slateport Shipyard 2F"] = {1}, ["Slateport City"] = {1}}
HoennMap["Slateport Shipyard 2F"] = {["Slateport Shipyard 1F"] = {1}}
HoennMap["Sootopolis City Gym 1F"] = {["Sootopolis City"] = {1}}
HoennMap["Sootopolis City House 1"] = {["Sootopolis City"] = {1}}
HoennMap["Sootopolis City House 2"] = {["Sootopolis City"] = {1}}
HoennMap["Sootopolis City House 3"] = {["Sootopolis City"] = {1}}
HoennMap["Sootopolis City House 4"] = {["Sootopolis City"] = {1}}
HoennMap["Sootopolis City House 5"] = {["Sootopolis City"] = {1}}
HoennMap["Sootopolis City House 6"] = {["Sootopolis City"] = {1}}
HoennMap["Sootopolis City House 7"] = {["Sootopolis City"] = {1}}
HoennMap["Sootopolis City House 8"] = {["Sootopolis City"] = {1}}
HoennMap["Sootopolis City Underwater"] = {["Route 126 Underwater_A"] = {1}, ["Sootopolis City"] = {1}}
HoennMap["Sootopolis City"] = {["Sootopolis City Gym 1F"] = {1}, ["Cave of Origin Entrance"] = {1}, ["Pokecenter Sootopolis City"] = {1}, ["Sootopolis City Underwater"] = {1, {["abilities"] = {"dive"}}}, ["Sootopolis Mart"] = {1}, ["Sootopolis City House 1"] = {1}, ["Sootopolis City House 2"] = {1}, ["Sootopolis City House 3"] = {1}, ["Sootopolis City House 4"] = {1}, ["Sootopolis City House 5"] = {1}, ["Sootopolis City House 6"] = {1}, ["Sootopolis City House 7"] = {1}, ["Sootopolis City House 8"] = {1}, }
HoennMap["Sootopolis Mart"] = {["Sootopolis City"] = {1}}
HoennMap["Stevens House"] = {["Mossdeep City"] = {1}}
HoennMap["Storage Unit"] = {["Abandoned Ship B1F"] = {1}}
HoennMap["Team Aqua Hideout Entrance"] = {["Team Aqua Hideout 1F_A"] = {1}, ["Lilycove City"] = {1}}
HoennMap["Team Aqua Hideout 1F_A"] = {["Team Aqua Hideout 1F_C"] = {1}, ["Team Aqua Hideout 1F_E"] = {1}, ["Team Aqua Hideout Entrance"] = {1}}
HoennMap["Team Aqua Hideout 1F_B"] = {["Team Aqua Hideout B2F_E"] = {1}}
HoennMap["Team Aqua Hideout 1F_C"] = {["Team Aqua Hideout B1F_A"] = {1}, ["Team Aqua Hideout 1F_D"] = {1}, ["Team Aqua Hideout 1F_A"] = {1}}
HoennMap["Team Aqua Hideout 1F_D"] = {["Team Aqua Hideout 1F_C"] = {1}}
HoennMap["Team Aqua Hideout 1F_E"] = {["Team Aqua Hideout 1F_A"] = {1}}
HoennMap["Team Aqua Hideout 1F_F"] = {["Team Aqua Hideout B1F_B"] = {1}, ["Team Aqua Hideout B1F_C"] = {1}}
HoennMap["Team Aqua Hideout 1F_G"] = {["Team Aqua Hideout Warp Hallway_A"] = {1}, ["Team Aqua Hideout B1F_A"] = {1}}
HoennMap["Team Aqua Hideout B1F_A"] = {["Team Aqua Hideout B1F_F"] = {1}, ["Team Aqua Hideout 1F_G"] = {1}, ["Team Aqua Hideout B2F_A"] = {1}, ["Team Aqua Hideout 1F_C"] = {1}}
HoennMap["Team Aqua Hideout B1F_B"] = {["Team Aqua Hideout B1F_E"] = {1}, ["Team Aqua Hideout 1F_F"] = {1}}
HoennMap["Team Aqua Hideout B1F_C"] = {["Team Aqua Hideout Warp Hallway_C"] = {1}, ["Team Aqua Hideout 1F_F"] = {1}}
HoennMap["Team Aqua Hideout B1F_D"] = {["Team Aqua Hideout B2F_B"] = {1}}
HoennMap["Team Aqua Hideout B1F_E"] = {["Team Aqua Hideout B2F_E"] = {1}, ["Team Aqua Hideout B1F_B"] = {1}}
HoennMap["Team Aqua Hideout B1F_F"] = {["Team Aqua Hideout Warp Hallway_E"] = {1}, ["Team Aqua Hideout B1F_A"] = {1}}
HoennMap["Team Aqua Hideout B2F_A"] = {["Team Aqua Hideout B1F_A"] = {1}}
HoennMap["Team Aqua Hideout B2F_B"] = {["Team Aqua Hideout B1F_D"] = {1}, ["Team Aqua Hideout Warp Hallway_B"] = {1}, }
HoennMap["Team Aqua Hideout B2F_C"] = {["Team Aqua Hideout Warp Hallway_B"] = {1}, ["Team Aqua Hideout B1F_B"] = {1}, ["Team Aqua Hideout B2F_E"] = {1}}
HoennMap["Team Aqua Hideout B2F_D"] = {}
HoennMap["Team Aqua Hideout B2F_E"] = {["Team Aqua Hideout 1F_B"] = {1}, ["Team Aqua Hideout B1F_E"] = {1}, ["Team Aqua Hideout B2F_C"] = {1}}
HoennMap["Team Aqua Hideout Warp Hallway_A"] = {["Team Aqua Hideout 1F_G"] = {1}}
HoennMap["Team Aqua Hideout Warp Hallway_B"] = {["Team Aqua Hideout B2F_B"] = {1}, ["Team Aqua Hideout Warp Hallway_F"] = {1}}
HoennMap["Team Aqua Hideout Warp Hallway_C"] = {["Team Aqua Hideout B1F_C"] = {1}, ["Team Aqua Hideout Warp Hallway_I"] = {1}}
HoennMap["Team Aqua Hideout Warp Hallway_D"] = {["Team Aqua Hideout Warp Hallway_E"] = {1}, ["Team Aqua Hideout Warp Hallway_C"] = {1}}
HoennMap["Team Aqua Hideout Warp Hallway_E"] = {["Team Aqua Hideout Warp Hallway_I"] = {1}, ["Team Aqua Hideout B1F_F"] = {1}}
HoennMap["Team Aqua Hideout Warp Hallway_F"] = {["Team Aqua Hideout Warp Hallway_B"] = {1}, ["Team Aqua Hideout Warp Hallway_J"] = {1}}
HoennMap["Team Aqua Hideout Warp Hallway_G"] = {["Team Aqua Hideout Warp Hallway_F"] = {1}, ["Team Aqua Hideout Warp Hallway_H"] = {1}}
HoennMap["Team Aqua Hideout Warp Hallway_H"] = {["Team Aqua Hideout Warp Hallway_J"] = {1}, ["Team Aqua Hideout Warp Hallway_L"] = {1}}
HoennMap["Team Aqua Hideout Warp Hallway_I"] = {["Team Aqua Hideout Warp Hallway_D"] = {1}, ["Team Aqua Hideout Warp Hallway_G"] = {1}}
HoennMap["Team Aqua Hideout Warp Hallway_J"] = {["Team Aqua Hideout Warp Hallway_I"] = {1}, ["Team Aqua Hideout Warp Hallway_K"] = {1}}
HoennMap["Team Aqua Hideout Warp Hallway_K"] = {["Team Aqua Hideout Warp Hallway_G"] = {1}, ["Team Aqua Hideout Warp Hallway_L"] = {1}}
HoennMap["Team Aqua Hideout Warp Hallway_L"] = {["Team Aqua Hideout B2F_C"] = {1}, ["Team Aqua Hideout Warp Hallway_H"] = {1}, ["Team Aqua Hideout Warp Hallway_K"] = {1}}
HoennMap["Terra Cave End"] = {["Terra Cave Entrance"] = {1}} --magma leader maxie (17, 28)
HoennMap["Terra Cave Entrance"] = {["Terra Cave End"] = {1}--[[need to speak to npc first (16,3)]], ["Cave of Origin B3F"] = {1}}
HoennMap["Transmat Station"] = {["Pokecenter Verdanturf"] = {H_SUBWAY}, ["Pokecenter Sootopolis City"] = {H_SUBWAY}, ["Pokecenter Slateport"] = {H_SUBWAY}, ["Pokecenter Rustboro City"] = {H_SUBWAY}, ["Pokecenter Petalburg City"] = {H_SUBWAY}, ["Pokecenter Pacifidlog Town"] = {H_SUBWAY}, ["Pokecenter Oldale Town"] = {H_SUBWAY}, ["Pokecenter Mossdeep City"] = {H_SUBWAY}, ["Pokecenter Mauville City"] = {H_SUBWAY}, ["Pokecenter Lilycove City"] = {H_SUBWAY}, ["Pokecenter Lavaridge Town"] = {H_SUBWAY}, ["Pokecenter Fortree City"] = {H_SUBWAY}, ["Pokecenter Fallarbor Town"] = {H_SUBWAY}, ["Pokecenter Ever Grande City"] = {H_SUBWAY}, ["Pokecenter Dewford Town"] = {H_SUBWAY}}
HoennMap["Treasure Hunter House"] = {["Route 124_A"] = {1}}
HoennMap["Trick House"] = {["Route 110_B"] = {1}}
HoennMap["Valley Of Steel Eastern Peak"] = {["Pokecenter Eastern Peak"] = {1}, ["Eastern House 1"] = {1}, ["Eastern House 2"] = {1}, ["Eastern House 3"] = {1}, ["Cave Of Steel 1F_C"] = {1}}
HoennMap["Valley Of Steel Entrance"] = {["Valley Of Steel_A"] = {1}, ["Lavaridge Town"] = {1}}
HoennMap["Valley Of Steel Western Peak"] = {["Pokecenter Western Peak"] = {1}, ["Western House 1"] = {1}, ["Western House 2"] = {1}, ["Western House 3"] = {1}, ["Western House 4"] = {1}}
HoennMap["Valley Of Steel_A"] = {["Cave Of Steel 2F"] = {1}, ["Valley Of Steel Entrance"] = {1}}
HoennMap["Valley Of Steel_B"] = {["Cave Of Steel 1F_A"] = {1}, ["Cave Of Steel 1F_C"] = {1}}
HoennMap["Verdanturf Battle Tent"] = {["Verdanturf Town"] = {1}}
HoennMap["Verdanturf House 1"] = {["Verdanturf Town"] = {1}}
HoennMap["Verdanturf House 2"] = {["Verdanturf Town"] = {1}}
HoennMap["Verdanturf House 3"] = {["Verdanturf Town"] = {1}}
HoennMap["Verdanturf Mart"] = {["Verdanturf Town"] = {1}}
HoennMap["Verdanturf Town"] = {["Verdanturf House 1"] = {1}, ["Verdanturf House 2"] = {1}, ["Verdanturf House 3"] = {1}, ["Verdanturf Battle Tent"] = {1}, ["Pokecenter Verdanturf"] = {1}, ["Route 117"] = {1}, ["Rusturf Tunnel_B"] = {1}, ["Verdanturf Mart"] = {1}, ["Route 116_A"] = {1, {["abilities"] = {"dig"}}}, ["Route 116_B"] = {1, {["abilities"] = {"dig"}}}}
HoennMap["Victory Road Hoenn 1F_A"] = {["Ever Grande City_A"] = {2}, ["Victory Road Hoenn B1F_B"] = {2}, ["Victory Road Hoenn B1F_A"] = {2}}
HoennMap["Victory Road Hoenn 1F_B"] = {["Ever Grande City_B"] = {0.5}, ["Victory Road Hoenn 1F_A"] = {0.5}, ["Victory Road Hoenn B1F_A"] = {0.5}}
HoennMap["Victory Road Hoenn 1F_C"] = {["Victory Road Hoenn B1F_A"] = {1}}
HoennMap["Victory Road Hoenn B1F_A"] = {["Victory Road Hoenn 1F_A"] = {1.5}, ["Victory Road Hoenn 1F_B"] = {1.5}, ["Victory Road Hoenn 1F_C"] = {1.5}, ["Victory Road Hoenn B2F_A"]= {1.5}}
HoennMap["Victory Road Hoenn B1F_B"] = {["Victory Road Hoenn B1F_C"] = {0.5}, ["Victory Road Hoenn 1F_A"] = {0.5}, ["Victory Road Hoenn B2F_E"] = {0.5}}
HoennMap["Victory Road Hoenn B1F_C"] = {["Victory Road Hoenn B2F_B"] = {0.5}}
HoennMap["Victory Road Hoenn B1F_D"] = {["Victory Road Hoenn B2F_A"] = {1}}
HoennMap["Victory Road Hoenn B2F_A"] = {["Victory Road Hoenn B1F_D"] = {2}, ["Victory Road Hoenn B1F_A"] = {2}}
HoennMap["Victory Road Hoenn B2F_B"] = {["Victory Road Hoenn B2F_C"] = {0.5}}
HoennMap["Victory Road Hoenn B2F_C"] = {["Victory Road Hoenn B2F_F"] = {0.5, {["abilities"] = {"surf"}}}}
HoennMap["Victory Road Hoenn B2F_D"] = {["Victory Road Hoenn B2F_C"] = {1}, ["Victory Road Hoenn B2F_A"] = {1}, ["Victory Road Hoenn B2F_F"] = {1}}
HoennMap["Victory Road Hoenn B2F_E"] = {["Victory Road Hoenn B2F_F"] = {0.1, {["abilities"] = {"surf"}}}, ["Victory Road Hoenn B1F_B"] = {0.1}}
HoennMap["Victory Road Hoenn B2F_F"] = {["Victory Road Hoenn B2F_E"] = {0}}
HoennMap["Weather Institute 1F"] = {["Weather Institute 2F"] = {1}, ["Route 119A"] = {1}}
HoennMap["Weather Institute 2F"] = {["Weather Institute 1F"] = {1}}
HoennMap["Western House 1"] = {["Valley Of Steel Western Peak"] = {1}}
HoennMap["Western House 2"] = {["Valley Of Steel Western Peak"] = {1}}
HoennMap["Western House 3"] = {["Valley Of Steel Western Peak"] = {1}}
HoennMap["Western House 4"] = {["Valley Of Steel Western Peak"] = {1}}
-- HoennMap["node"] = {["link"] = {distance, {["restrictionType"] = {"restriction"}}}}
return HoennMap
end
|
--- === Caffeine ===
---
--- Prevent the screen from going to sleep
--- Download: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/Caffeine.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/Caffeine.spoon.zip)
local obj = { __gc = true }
--obj.__index = obj
setmetatable(obj, obj)
obj.__gc = function(t)
t:stop()
end
-- Metadata
obj.name = "Caffeine"
obj.version = "1.0"
obj.author = "Chris Jones <cmsj@tenshu.net>"
obj.homepage = "https://github.com/Hammerspoon/Spoons"
obj.license = "MIT - https://opensource.org/licenses/MIT"
obj.menuBarItem = nil
obj.hotkeyToggle = nil
-- combine two path
local function getPathAbsolute(path1, path2)
return hs.fs.pathToAbsolute(string.format("%s/%s",path1,path2))
end
--get user home dir file
local function getUserFilePathhAbsolute(path)
return hs.fs.pathToAbsolute(string.format("%s/%s",os.getenv('HOME'),path))
end
-- Internal function used to find our location, so we know where to load files from
local function script_path()
local str = debug.getinfo(2, "S").source:sub(2)
return str:match("(.*/)")
end
obj.spoonPath = script_path()
function obj:init()
self.menubar = hs.menubar.new()
obj:start()
end
obj.paths = {}
obj.paths.base = os.getenv('HOME')
obj.paths.hs = getPathAbsolute(obj.paths.base, '.hammerspoon')
--read user customer config
customer =dofile(getPathAbsolute(obj.paths.hs ,'private/caffeine.lua'))
--if user config does not esist
if not customer then
customer = dofile(obj.spoonPath.."/caffeine.lua")
end
--if user config does not esist
if not activeIcon then
activeIcon = "active.png"
end
if not inActiveIcon then
inActiveIcon = "inative.png"
end
--scheduled time
if time_scheduled then
obj.time_scheduled = time_scheduled
end
--- Caffeine:bindHotkeys(mapping)
--- Method
--- Binds hotkeys for Caffeine
---
--- Parameters:
--- * mapping - A table containing hotkey modifier/key details for the following items:
--- * toggle - This will toggle the state of display sleep prevention, and update the menubar graphic
---
--- Returns:
--- * The Caffeine object
function obj:bindHotkeys(mapping)
if (self.hotkeyToggle) then
self.hotkeyToggle:delete()
end
local toggleMods = mapping["toggle"][1]
local toggleKey = mapping["toggle"][2]
self.hotkeyToggle = hs.hotkey.new(toggleMods, toggleKey, function() self.clicked() end)
return self
end
--- Caffeine:start()
--- Method
--- Starts Caffeine
---
--- Parameters:
--- * None
---
--- Returns:
--- * The Caffeine object
function obj:start()
if self.menuBarItem then self:stop() end
self.menuBarItem = hs.menubar.new()
self.menuBarItem:setClickCallback(self.clicked)
if (self.hotkeyToggle) then
self.hotkeyToggle:enable()
end
self.setDisplay(hs.caffeinate.get("displayIdle"))
return self
end
--- Caffeine:stop()
--- Method
--- Stops Caffeine
---
--- Parameters:
--- * None
---
--- Returns:
--- * The Caffeine object
function obj:stop()
if self.menuBarItem then self.menuBarItem:delete() end
if (self.hotkeyToggle) then
self.hotkeyToggle:disable()
end
self.menuBarItem = nil
return self
end
function obj.setDisplay(state)
local result
if state then
result = obj.menuBarItem:setIcon(string.format("%s%s",obj.spoonPath,activeIcon ))
else
result = obj.menuBarItem:setIcon(string.format("%s%s",obj.spoonPath,inActiveIcon))
end
end
function obj.clicked()
obj.setDisplay(hs.caffeinate.toggle("displayIdle"))
end
return obj
|
-- Copyright (C) 2012-2013 Diego Martínez <kaeza@users.sf.net>
-- License is WTFPL (see README.txt).
-- This file defines some items in order to not have to depend on other mods.
-- Boilerplate to support localized strings if intllib mod is installed.
local S;
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua");
S = intllib.Getter(minetest.get_current_modname());
else
S = function ( s ) return s; end
end
if (not minetest.get_modpath("homedecor")) then
minetest.register_craftitem(":homedecor:plastic_sheeting", {
description = S("Plastic sheet"),
inventory_image = "homedecor_plastic_sheeting.png",
})
minetest.register_craftitem(":homedecor:plastic_base", {
description = S("Unprocessed Plastic base"),
wield_image = "homedecor_plastic_base.png",
inventory_image = "homedecor_plastic_base_inv.png",
})
minetest.register_craft({
type = "shapeless",
output = 'homedecor:plastic_base 6',
recipe = { "default:junglegrass",
"default:junglegrass",
"default:junglegrass"
}
})
minetest.register_craft({
type = "shapeless",
output = 'homedecor:plastic_base 3',
recipe = { "default:dry_shrub",
"default:dry_shrub",
"default:dry_shrub"
},
})
minetest.register_craft({
type = "shapeless",
output = 'homedecor:plastic_base 4',
recipe = { "default:leaves",
"default:leaves",
"default:leaves",
"default:leaves",
"default:leaves",
"default:leaves"
}
})
minetest.register_craft({
type = "cooking",
output = "homedecor:plastic_sheeting",
recipe = "homedecor:plastic_base",
})
minetest.register_craft({
type = 'fuel',
recipe = 'homedecor:plastic_base',
burntime = 30,
})
minetest.register_craft({
type = 'fuel',
recipe = 'homedecor:plastic_sheeting',
burntime = 30,
})
end -- not homedecor
|
data:extend({
{
type = "item-subgroup",
name = "colonists-fluids",
group = "colonists",
order = "f"
},
-- waste
{
type = "fluid",
name = "waste",
subgroup = "colonists-fluids",
default_temperature = 25,
heat_capacity = "0.0KJ",
base_color = {r=0.5, g=0.04, b=0},
flow_color = {r=0.85, g=0.6, b=0.3},
max_temperature = 100,
icon = "__Colonists__/graphics/icons/fluid/oxygen.png",
icon_size = 32,
pressure_to_speed_ratio = 0.4,
flow_to_energy_ratio = 0.59,
order = "a[fluid]-x[waste]"
},
}) |
--DEPENDENCIES
--whatever is used here idk lol
local awful = require('awful')
local wibox = require('wibox')
local gears = require('gears')
local clickable_container = require('widget.clickable-container')
local dpi = require('beautiful').xresources.apply_dpi
local icons = require('themes.icons')
local colors = require('themes.dracula.colors')
local watch = require('awful.widget.watch')
local awful = require('awful')
local beautiful = require('beautiful')
local naughty = require('naughty')
local widget_icon = wibox.widget {
layout = wibox.layout.align.vertical,
expand = 'none',
nil,
{
id = 'icon',
image = icons.search,
resize = true,
widget = wibox.widget.imagebox
},
nil
}
local widget = wibox.widget {
{
{
{
widget_icon,
layout = wibox.layout.fixed.horizontal,
},
margins = dpi(15),
widget = wibox.container.margin
},
forced_height = dpi(50),
widget = clickable_container
},
shape = gears.shape.circle,
bg = colors.background,
widget = wibox.container.background
}
widget:connect_signal(
"mouse::enter",
function()
widget.bg = colors.red
end
)
widget:connect_signal(
"mouse::leave",
function()
widget.bg = colors.background
end
)
widget:buttons(
gears.table.join(
awful.button(
{},
1,
nil,
awesome.restart
)
)
)
return widget
|
--- Sets up the spawn location when the game starts
-- @classmod SetupSpawnListener
-- region imports
local class = require('classes/class')
local prototype = require('prototypes/prototype')
require('prototypes/listener')
local Location = require('classes/location')
local locations = require('functional/game_context/locations')
-- endregion
local SetupSpawnListener = {}
function SetupSpawnListener:get_events() return { NewGameEvent = true } end
function SetupSpawnListener:is_prelistener() return false end
function SetupSpawnListener:is_postlistener() return true end
function SetupSpawnListener:compare(other, pre) return 0 end
function SetupSpawnListener:process(game_ctx, local_ctx, networking, event)
locations.add_location(game_ctx, Location:new({
name = 'pregame',
description = 'A place to hang out while we wait for more people',
consecrated = false,
lighting = 'outside'
}))
end
prototype.support(SetupSpawnListener, 'listener')
return class.create('SetupSpawnListener', SetupSpawnListener)
|
function love.conf(t)
t.window.title = "DESTROY ASTEROIDS"
t.window.icon = "images/ship.png"
end |
--
-- floating_terminal.lua
-- floating terminal component
--
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
-- ========================================
-- Config
-- ========================================
-- terminal client name argument
local terminal_name_arg = "--class "
-- terminal client instance name
local client_name = "FloatingTerminal"
-- terminal client placement
local client_placement = awful.placement.right
+ awful.placement.maximize_vertically
-- terminal client width
local client_width = dpi(600)
-- terminal client height
local client_height = dpi(500)
-- ========================================
-- Logic
-- ========================================
-- Define a new class
local FloatingTerminal = {}
FloatingTerminal.__index = FloatingTerminal
-- Class constructor
function FloatingTerminal:new ()
-- create new class instance
local floating_terminal = {}
setmetatable(floating_terminal, FloatingTerminal)
-- set configs
floating_terminal.app = Apps.terminal
floating_terminal.arg = terminal_name_arg .. client_name
floating_terminal.name = client_name
floating_terminal.visible = false
floating_terminal:init_signals()
return floating_terminal
end
-- get floating terminal instance
function FloatingTerminal:get_instance ()
local matcher = function (c)
return awful.rules.match(c, { instance = self.name })
end
-- First, we locate the terminal
for c in awful.client.iterate(matcher) do
return c
end
-- If not found return nil
return nil
end
-- spawn the floating terminal
function FloatingTerminal:spawn ()
awful.spawn(self.app .. " " .. self.arg)
end
-- show the floating terminal
function FloatingTerminal:show ()
local c = self:get_instance()
if c == nil then return self:spawn() end
-- This is not a normal window, don't apply any specific keyboard stuff
c:buttons({})
c:keys({})
-- Set client attrs
c.honor_padding = false
c.honor_workarea = false
c.size_hints_honor = false
c.hidden = false
c.floating = true
c.sticky = true
c.ontop = true
c.above = true
-- Focus client
c:raise()
client.focus = c
-- Resize
c:geometry({ width = client_width, height = client_height })
client_placement(c)
self.visible = true
end
-- hide the floating terminal
function FloatingTerminal:hide ()
local c = self:get_instance()
if c ~= nil then c.hidden = true end
self.visible = false
end
-- Toggle the floating terminal
function FloatingTerminal:toggle()
if self.visible then self:hide() else self:show() end
end
-- Init signals
function FloatingTerminal:init_signals ()
-- detect when floating terminal is spawned
client.connect_signal("manage", function(c)
if c.instance == self.name then self:show() end
end)
-- detect when floating terminal is killed
client.connect_signal("unmanage", function(c)
if c.instance == self.name then self.visible = false end
end)
-- show the floating terminal when signal is broadcasted
awesome.connect_signal("floating_terminal::show", function()
self:show()
end)
-- hide the floating terminal when signal is broadcasted
awesome.connect_signal("floating_terminal::hide", function()
self:hide()
end)
-- toggle the floating terminal when signal is broadcasted
awesome.connect_signal("floating_terminal::toggle", function()
self:toggle()
end)
end
-- ========================================
-- Initialization
-- ========================================
FloatingTerminal:new()
|
local _M={}
_M.goods_search="搜索成功"
return _M |
local Config = require('opus.config')
local UI = require('opus.ui')
local Util = require('opus.util')
local tab = UI.Tab {
title = 'Requires',
description = 'Require path',
tabClose = true,
entry = UI.TextEntry {
x = 2, y = 2, ex = -2,
shadowText = 'Enter new require path',
accelerators = {
enter = 'update_path',
},
help = 'add a new path (reboot required)',
},
grid = UI.Grid {
y = 4, ey = -3,
disableHeader = true,
columns = { { key = 'value' } },
autospace = true,
sortColumn = 'index',
help = 'double-click to remove, shift-arrow to move',
accelerators = {
delete = 'remove',
},
},
statusBar = UI.StatusBar { },
accelerators = {
[ 'shift-up' ] = 'move_up',
[ 'shift-down' ] = 'move_down',
},
}
function tab:updateList(lua_path)
self.grid.values = { }
for k,v in ipairs(Util.split(lua_path, '(.-);')) do
table.insert(self.grid.values, { index = k, value = v })
end
self.grid:update()
end
function tab:enable()
local env = Config.load('shell')
self:updateList(env.lua_path)
UI.Tab.enable(self)
end
function tab:save()
local t = { }
for _, v in ipairs(self.grid.values) do
table.insert(t, v.value)
end
local env = Config.load('shell')
env.lua_path = table.concat(t, ';')
self:updateList(env.lua_path)
Config.update('shell', env)
end
function tab:eventHandler(event)
if event.type == 'update_path' then
table.insert(self.grid.values, {
value = self.entry.value,
})
self:save()
self.entry:reset()
self.entry:draw()
self.grid:draw()
return true
elseif event.type == 'grid_select' or event.type == 'remove' then
local selected = self.grid:getSelected()
if selected then
table.remove(self.grid.values, selected.index)
self:save()
self.grid:draw()
end
elseif event.type == 'focus_change' then
self.statusBar:setStatus(event.focused.help)
elseif event.type == 'move_up' then
local entry = self.grid:getSelected()
if entry.index > 1 then
table.insert(self.grid.values, entry.index - 1, table.remove(self.grid.values, entry.index))
self.grid:setIndex(entry.index - 1)
self:save()
self.grid:draw()
end
elseif event.type == 'move_down' then
local entry = self.grid:getSelected()
if entry.index < #self.grid.values then
table.insert(self.grid.values, entry.index + 1, table.remove(self.grid.values, entry.index))
self.grid:setIndex(entry.index + 1)
self:save()
self.grid:draw()
end
end
end
--this needs rework - see 4.user.lua
--return tab
|
-- misc utils
-- aim is to move a lot of stuff that is not strictly syscalls out of main code to modularise better
-- most code here is man(1) or man(3) or misc helpers for common tasks.
-- TODO rework so that items can be methods on fd again, for eventfd, timerfd, signalfd and tty
local require, error, assert, tonumber, tostring,
setmetatable, pairs, ipairs, unpack, rawget, rawset,
pcall, type, table, string =
require, error, assert, tonumber, tostring,
setmetatable, pairs, ipairs, unpack, rawget, rawset,
pcall, type, table, string
local function init(S)
local abi, types, c = S.abi, S.types, S.c
local t, pt, s = types.t, types.pt, types.s
local h = require "syscall.helpers"
local ffi = require "ffi"
local bit = require "syscall.bit"
local octal = h.octal
-- TODO move to helpers? see notes in syscall.lua about reworking though
local function istype(tp, x)
if ffi.istype(tp, x) then return x end
return false
end
local util = {}
local mt = {}
local function if_nametoindex(name, s)
local ifr = t.ifreq{name = name}
local ret, err = S.ioctl(s, "SIOCGIFINDEX", ifr)
if not ret then return nil, err end
return ifr.ivalue
end
function util.if_nametoindex(name) -- standard function in some libc versions
local s, err = S.socket(c.AF.LOCAL, c.SOCK.STREAM, 0)
if not s then return nil, err end
local i, err = if_nametoindex(name, s)
if not i then return nil, err end
local ok, err = S.close(s)
if not ok then return nil, err end
return i
end
-- bridge functions.
local function bridge_ioctl(io, name)
local s, err = S.socket(c.AF.LOCAL, c.SOCK.STREAM, 0)
if not s then return nil, err end
local ret, err = S.ioctl(s, io, name)
if not ret then
s:close()
return nil, err
end
local ok, err = s:close()
if not ok then return nil, err end
return ret
end
function util.bridge_add(name) return bridge_ioctl("SIOCBRADDBR", name) end
function util.bridge_del(name) return bridge_ioctl("SIOCBRDELBR", name) end
local function bridge_if_ioctl(io, name, dev)
local err, s, ifr, len, ret, ok
s, err = S.socket(c.AF.LOCAL, c.SOCK.STREAM, 0)
if not s then return nil, err end
if type(dev) == "string" then
dev, err = if_nametoindex(dev, s)
if not dev then return nil, err end
end
ifr = t.ifreq{name = name, ivalue = dev}
ret, err = S.ioctl(s, io, ifr);
if not ret then
s:close()
return nil, err
end
ok, err = s:close()
if not ok then return nil, err end
return ret
end
function util.bridge_add_interface(bridge, dev) return bridge_if_ioctl(c.SIOC.BRADDIF, bridge, dev) end
function util.bridge_add_interface(bridge, dev) return bridge_if_ioctl(c.SIOC.BRDELIF, bridge, dev) end
local function brinfo(d) -- can be used as subpart of general interface info
local bd = "/sys/class/net/" .. d .. "/" .. c.SYSFS_BRIDGE_ATTR
if not S.stat(bd) then return nil end
local bridge = {}
for fn, f in util.ls(bd) do
local s = util.readfile(bd .. "/" .. fn)
if s then
s = s:sub(1, #s - 1) -- remove newline at end
if fn == "group_addr" or fn == "root_id" or fn == "bridge_id" then -- string values
bridge[fn] = s
elseif f == "stp_state" then -- bool
bridge[fn] = s == 1
elseif fn ~= "." and fn ~=".." then
bridge[fn] = tonumber(s) -- not quite correct, most are timevals TODO
end
end
end
local brif, err = util.dirtable("/sys/class/net/" .. d .. "/" .. c.SYSFS_BRIDGE_PORT_SUBDIR, true)
if not brif then return nil end
local fdb = "/sys/class/net/" .. d .. "/" .. c.SYSFS_BRIDGE_FDB
if not S.stat(fdb) then return nil end
local sl = 2048
local buffer = t.buffer(sl)
local fd = S.open(fdb, "rdonly")
if not fd then return nil end
local brforward = {}
repeat
local n = S.read(fd, buffer, sl)
if not n then return nil end
local fdbs = pt.fdb_entry(buffer)
for i = 1, bit.rshift(n, 4) do -- fdb_entry is 16 bytes
local fdb = fdbs[i - 1]
local mac = t.macaddr()
ffi.copy(mac, fdb.mac_addr, s.macaddr)
-- TODO ageing_timer_value is not an int, time, float
brforward[#brforward + 1] = {
mac_addr = mac, port_no = tonumber(fdb.port_no),
is_local = fdb.is_local ~= 0,
ageing_timer_value = tonumber(fdb.ageing_timer_value)
}
end
until n == 0
if not fd:close() then return nil end
return {bridge = bridge, brif = brif, brforward = brforward}
end
function util.bridge_list()
local b = {}
for d in util.ls("/sys/class/net") do
if d ~= "." and d ~= ".." then b[d] = brinfo(d) end
end
return b
end
-- eventfd read and write helpers, as in glibc but Lua friendly. Note returns 0 for EAGAIN, as 0 never returned directly
-- returns Lua number - if you need all 64 bits, pass your own value in and use that for the exact result
function util.eventfd_read(fd, value)
if not value then value = t.uint64_1() end
local ret, err = S.read(fd, value, 8)
if err and err.AGAIN then
value[0] = 0
return 0
end
if not ret then return nil, err end
return tonumber(value[0])
end
function util.eventfd_write(fd, value)
if not value then value = 1 end
if type(value) == "number" then value = t.uint64_1(value) end
local ret, err = S.write(fd, value, 8)
if not ret then return nil, err end
return true
end
function util.signalfd_read(fd, ss)
ss = istype(t.siginfos, ss) or t.siginfos(ss or 8)
local ret, err = S.read(fd, ss.sfd, ss.bytes)
if ret == 0 or (err and err.AGAIN) then return {} end
if not ret then return nil, err end
ss.count = ret / s.signalfd_siginfo -- may not be full length
return ss
end
function util.timerfd_read(fd, buffer)
if not buffer then buffer = t.uint64_1() end
local ret, err = S.read(fd, buffer, 8)
if not ret and err.AGAIN then return 0 end -- will never actually return 0
if not ret then return nil, err end
return tonumber(buffer[0])
end
local auditarch_le = {
x86 = "I386",
x64 = "X86_64",
arm = "ARM",
arm64 = "AARCH64",
mipsel = "MIPSEL",
ppc64le = "PPC64LE",
}
local auditarch_be = {
ppc = "PPC",
arm = "ARMEB",
arm64 = "AARCH64",
mips = "MIPS",
}
function util.auditarch()
if abi.le then return c.AUDIT_ARCH[auditarch_le[abi.arch]] else return c.AUDIT_ARCH[auditarch_be[abi.arch]] end
end
-- file system capabilities
local seccap = "security.capability"
function util.capget(f)
local attr, err
if type(f) == "string" then attr, err = S.getxattr(f, seccap) else attr, err = f:getxattr(seccap) end
if not attr then return nil, err end
local vfs = pt.vfs_cap_data(attr)
local magic_etc = h.convle32(vfs.magic_etc)
local version = bit.band(c.VFS_CAP.REVISION_MASK, magic_etc)
-- TODO if you need support for version 1 filesystem caps add here, fairly simple
assert(version == c.VFS_CAP.REVISION_2, "FIXME: Currently only support version 2 filesystem capabilities")
local cap = t.capabilities()
cap.permitted.cap[0], cap.permitted.cap[1] = h.convle32(vfs.data[0].permitted), h.convle32(vfs.data[1].permitted)
cap.inheritable.cap[0], cap.inheritable.cap[1] = h.convle32(vfs.data[0].inheritable), h.convle32(vfs.data[1].inheritable)
if bit.band(magic_etc, c.VFS_CAP_FLAGS.EFFECTIVE) ~= 0 then
cap.effective.cap[0] = bit.bor(cap.permitted.cap[0], cap.inheritable.cap[0])
cap.effective.cap[1] = bit.bor(cap.permitted.cap[1], cap.inheritable.cap[1])
end
return cap
end
function util.capset(f, cap, flags)
cap = istype(t.capabilities, cap) or t.capabilities(cap)
local vfsflags = 0
-- is this the correct way to do this? TODO check
for k, _ in pairs(c.CAP) do if cap.effective[k] then vfsflags = c.VFS_CAP_FLAGS.EFFECTIVE end end
local vfs = t.vfs_cap_data()
vfs.magic_etc = h.convle32(c.VFS_CAP.REVISION_2 + vfsflags)
vfs.data[0].permitted, vfs.data[1].permitted = h.convle32(cap.permitted.cap[0]), h.convle32(cap.permitted.cap[1])
vfs.data[0].inheritable, vfs.data[1].inheritable = h.convle32(cap.inheritable.cap[0]), h.convle32(cap.inheritable.cap[1])
if type(f) == "string" then return S.setxattr(f, seccap, vfs, flags) else return f:getxattr(seccap, vfs, flags) end
end
-- TODO could add umount method.
mt.mount = {
__tostring = function(m) return m.source .. " on " .. m.target .. " type " .. m.type .. " (" .. m.flags .. ")" end,
}
mt.mounts = {
__tostring = function(ms)
local rs = ""
for i = 1, #ms do
rs = rs .. tostring(ms[i]) .. '\n'
end
return rs
end
}
-- will work on netbsd with Linux compat, but should use getvfsstat()
function util.mounts(file)
local mf, err = util.readfile(file or "/proc/mounts")
if not mf then return nil, err end
local mounts = {}
for line in mf:gmatch("[^\r\n]+") do
local l = {}
local parts = {"source", "target", "type", "flags", "freq", "passno"}
local p = 1
for word in line:gmatch("%S+") do
l[parts[p]] = word
p = p + 1
end
mounts[#mounts + 1] = setmetatable(l, mt.mount)
end
-- TODO some of the options you get in /proc/mounts are file system specific and should be moved to l.data
-- idea is you can round-trip this data
-- a lot of the fs specific options are key=value so easier to recognise
return setmetatable(mounts, mt.mounts)
end
-- table based mount, more cross OS compatible
function util.mount(tab)
local source = tab.source or "none" -- standard default
local target = tab.target or tab.dir -- netbsd compatible
local filesystemtype = tab.type
local mountflags = tab.flags
local data = tab.data
return S.mount(source, target, filesystemtype, mountflags, data)
end
function util.sendcred(fd, pid, uid, gid)
if not pid then pid = S.getpid() end
if not uid then uid = S.getuid() end
if not gid then gid = S.getgid() end
local ucred = t.ucred{pid = pid, uid = uid, gid = gid}
local buf1 = t.buffer(1) -- need to send one byte
local io = t.iovecs{{buf1, 1}}
local cmsg = t.cmsghdr("socket", "credentials", ucred)
local msg = t.msghdr{iov = io, control = cmsg}
return S.sendmsg(fd, msg, 0)
end
return util
end
return {init = init}
|
return
{
[1] = {id=1,x1={1,2,},x2={3,4,},x3={5,6,},x4={[1]=2,[3]=4,},},
}
|
InstancesEditor = InstancesEditor or class(EditorPart)
local Instance = InstancesEditor
function Instance:init(parent, menu)
self:init_basic(parent, name)
self._units = {}
self._triggers = {}
self._static = self:Manager("static")
MenuUtils:new(self, self._static:GetMenu())
end
function Instance:build_editor_menu()
Instance.super.build_default_menu(self)
self._editors = {}
local other = self:Group("Main")
self._static:build_positions_items(true)
self._static:SetTitle("Instance Selection")
self:TextBox("Name", callback(self, self, "set_data"), nil, {group = other, help = "the name of the instance(make sure it's unique!)"})
self:ComboBox("Continent", callback(self, self, "set_data"), self._parent._continents, 1, {group = other})
self:ComboBox("Script", callback(self, self, "set_data"), table.map_keys(managers.mission._scripts), 1, {group = other})
self:Toggle("MissionPlaced", callback(self, self, "set_data"), false, {group = other})
end
function Instance:set_instance(reset)
self._static._built_multi = false
if reset then
self._static:reset_selected_units()
end
local unit = self:selected_unit()
if alive(unit) and unit:fake() then
if not reset then
self:set_menu_unit(unit)
return
end
end
self._static:build_default_menu()
end
function Instance:delete_instance(instance)
instance = instance or self:selected_unit():object()
local instances = managers.worlddefinition._continent_definitions[instance.continent].instances
for _, mission in pairs(managers.mission._missions) do
for _, script in pairs(mission) do
if script.instances then
table.delete(script.instances, instance.name)
end
end
end
local script = managers.mission._scripts[instance.script]
local temp = clone(script._elements)
for i, element in pairs(temp) do
if element.instance == instance.name then
script._elements[i] = nil
table.delete(script._element_groups[element.class], element)
end
end
for i, ins in pairs(instances) do
if ins.name == instance.name then
for _, unit in pairs(World:find_units_quick("all")) do
if unit:unit_data() and unit:unit_data().instance == instance.name then
managers.worlddefinition:delete_unit(unit)
World:delete_unit(unit)
end
end
for k, ins in pairs(managers.world_instance._instance_data) do
if instance.name == ins.name then
table.remove(managers.world_instance._instance_data, k)
break
end
end
table.remove(instances, i)
break
end
end
end
function Instance:set_menu_unit(unit)
self:build_editor_menu()
local instance = unit:object()
self:GetItem("Name"):SetValue(instance.name, false, true)
self:GetItem("MissionPlaced"):SetValue(instance.mission_placed)
self:GetItem("Continent"):SetSelectedItem(instance.continent)
self:GetItem("Script"):SetSelectedItem(instance.script)
self._static:update_positions()
end
function Instance:update_positions()
for _, unit in pairs(self:selected_units()) do
if unit:fake() then
local instance = unit:object()
local instance_name = instance.name
for _, unit in pairs(World:find_units_quick("all")) do
if unit:unit_data() and unit:unit_data().instance == instance_name then
BeardLibEditor.Utils:SetPosition(unit, instance.position + unit:unit_data().local_pos:rotate_with(instance.rotation), instance.rotation * unit:unit_data().local_rot)
end
end
end
end
end
function Instance:update(menu, item)
local unit = self:selected_unit()
if unit and alive(unit) and unit:fake() then
Application:draw_sphere(unit:position(), 30, 0, 0, 0.7)
end
end
function Instance:set_data(menu, item)
local main = self:GetItem("Main")
main:RemoveItem(self:GetItem("NameWarning"))
local instance = self:selected_unit():object()
local instance_in_continent
local instance_in_continent_index
local instance_in_script_mission
local instance_in_script_index
local new_name = self:GetItem("Name"):Value()
local no_saving_name
local continents = managers.worlddefinition._continent_definitions
for name, continent in pairs(continents) do
continent.instances = continent.instances or {}
for i, ins in pairs(continent.instances) do
if instance.name ~= new_name and ins.name == new_name then
no_saving_name = true
self:Divider("NameWarning", {group = main, index = "After|Name", text = "*Warning: name is taken by a different instance", color = false})
end
if name == instance.continent and ins.name == instance.name and not instance_in_continent then
instance_in_continent = ins
instance_in_continent_index = i
break
end
end
end
for _, mission in pairs(managers.mission._missions) do
for _, script in pairs(mission) do
if script.instances then
local index = table.get_key(script.instances, instance.name)
if index then
instance_in_script_mission = script
instance_in_script_index = index
break
end
end
end
end
if instance_in_continent then
local old_continent = instance.continent
local old_script = instance.script
local old_name = instance.name
if not no_saving_name then
instance.name = new_name
end
instance.continent = self:GetItem("Continent"):SelectedItem()
instance.script = self:GetItem("Script"):SelectedItem()
instance.mission_placed = self:GetItem("MissionPlaced"):Value()
instance_in_continent.name = instance.name
instance_in_continent.mission_placed = instance.mission_placed
instance_in_continent.continent = instance.continent
instance_in_continent.script = instance.script
if old_continent ~= instance.continent then
table.remove(continents[old_continent].instances, instance_in_continent_index)
table.insert(continents[instance.continent].instances, instance_in_continent)
end
if instance_in_script_mission then
instance_in_script_mission.instances[instance_in_script_index] = instance.name
if old_script ~= instance.script then
table.remove(instance_in_script_mission.instances, instance_in_script_index)
local script = managers.mission._scripts[old_script]
local temp = clone(script._element)
for i, element in pairs(temp) do
if element.instance == instance.name then
script._element[i] = nil
table.delete(script._element_groups[element.class], element)
end
end
for _, mission in pairs(managers.mission._missions) do
if mission[instance.script] then
table.insert(mission[instance.script].instances, instance.name)
local script = managers.mission._scripts[instance.script]
local prepare_mission_data = managers.world_instance:prepare_mission_data_by_name(instance_name)
if not instance.mission_placed then
script:create_instance_elements(prepare_mission_data)
else
script:_preload_instance_class_elements(prepare_mission_data)
end
break
end
end
end
end
for _, unit in pairs(World:find_units_quick("all")) do
if unit:unit_data() and unit:unit_data().instance == old_name then
unit:unit_data().instance = instance.name
unit:unit_data().continent = instance.continent
end
end
else
BeardLibEditor:log("[Error] This is not a valid instance")
end
end |
local path = ...
local folder = string.match(path, ".*/") or ""
local jump_splash = require(folder .. "jump")
local love_splash = require(folder .. "love")
local splash = {}
splash.prevBG = {}
splash.splashes = {"love", "jump", false}
splash.index = 1
splash.load = 1
local prev
function splash.update(dt)
if splash.isPlaying() then
local current = splash.splashes[splash.index]
local running = true
if not splash.prevBG[1] then
local r, g, b, a = love.graphics.getBackgroundColor()
splash.prevBG = {r, g, b, a}
end
--Load splashes in update to avoid load freeze
if splash.load == 1 then
love_splash.load()
splash.load = splash.load + 1
elseif splash.load == 2 then
jump_splash.load()
splash.load = splash.load + 1
elseif splash.load <= #splash.splashes then
love.graphics.setBackgroundColor(0,0,0,1)
if not (prev == current) then
j.log("Playing " .. current .. " splash!")
end
if current == "love" then running = love_splash.update(dt, width, height)
elseif current == "jump" then running = jump_splash.update(dt, width, height)
end
if not running and splash.index < #splash.splashes then
love.audio.stop()
splash.index = constrain(1, #splash.splashes, splash.index + 1)
if splash.index == #splash.splashes then
j.log("Resetting background color!")
love.graphics.setBackgroundColor(splash.prevBG)
sm.change("loading")
end
end
prev = current
else
return false
end
end
end
function splash.draw()
local current = splash.splashes[splash.index]
if current == "love" then love_splash.draw(dt)
elseif current == "jump" then jump_splash.draw(dt)
else return false
end
end
function splash.keypressed(key, scancode, isrepeat)
if splash.load < #splash.splashes then return end
if key and splash.index < #splash.splashes then
love.audio.stop()
splash.index = constrain(1, #splash.splashes, splash.index + 1)
j.log("Skipping splash...")
if splash.index == #splash.splashes then
j.log("Resetting background color!")
love.graphics.setBackgroundColor(splash.prevBG)
sm.change("loading")
end
end
end
function splash.mousepressed(x, y, button, istouch, presses)
if splash.load < #splash.splashes then return end
if button and splash.index < #splash.splashes then
love.audio.stop()
splash.index = constrain(1, #splash.splashes, splash.index + 1)
j.log("Skipping splash...")
if splash.index == #splash.splashes then
j.log("Resetting background color!")
love.graphics.setBackgroundColor(splash.prevBG)
sm.change("loading")
end
end
end
function splash.resize(w, h)
width = w
height = h
end
function splash.isPlaying()
if splash.splashes[splash.index] == false then return false else return true end
end
function constrain(min, max, input)
return math.max(math.min(input, max), min)
end
return splash |
-- Functions to use neovim as a pager.
-- This code is a rewrite of two sources: vimcat and vimpager (which also
-- conatins a version of vimcat).
-- Vimcat back to Matthew J. Wozniski and can be found at
-- https://github.com/godlygeek/vim-files/blob/master/macros/vimcat.sh
-- Vimpager was written by Rafael Kitover and can be found at
-- https://github.com/rkitover/vimpager
-- Information about terminal escape codes:
-- https://en.wikipedia.org/wiki/ANSI_escape_code
-- Neovim defines this object but luacheck doesn't know it. So we define a
-- shortcut and tell luacheck to ignore it.
local nvim = vim.api -- luacheck: ignore
-- These variables will be initialized by the first call to init_cat_mode():
-- We cache the calculated escape sequences for the syntax groups.
local cache = {}
-- A local copy of the termguicolors option, used for color output in cat
-- mode.
local colors_24_bit
local color2escape
-- This variable holds the name of the detected parent process for pager mode.
local doc = nil
local function split_rgb_number(color_number)
-- The lua implementation of these bit shift operations is taken from
-- http://nova-fusion.com/2011/03/21/simulate-bitwise-shift-operators-in-lua
local r = math.floor(color_number / 2 ^ 16)
local g = math.floor(math.floor(color_number / 2 ^ 8) % 2 ^ 8)
local b = math.floor(color_number % 2 ^ 8)
return r, g, b
end
local function color2escape_24bit(color_number, foreground)
local red, green, blue = split_rgb_number(color_number)
local escape
if foreground then
escape = '38;2;'
else
escape = '48;2;'
end
return escape .. red .. ';' .. green .. ';' .. blue
end
local function color2escape_8bit(color_number, foreground)
local prefix
if color_number < 8 then
if foreground then
prefix = '3'
else
prefix = '4'
end
elseif color_number < 16 then
color_number = color_number - 8
if foreground then
prefix = '9'
else
prefix = '10'
end
elseif foreground then
prefix = '38;5;'
else
prefix = '48;5;'
end
return prefix .. color_number
end
local function group2ansi(groupid)
if cache[groupid] then
return cache[groupid]
end
local info = nvim.nvim_get_hl_by_id(groupid, colors_24_bit)
if info.reverse then
info.foreground, info.background = info.background, info.foreground
end
-- Reset all attributes before setting new ones. The vimscript version did
-- use sevel explicit reset codes: 22, 24, 25, 27 and 28. If no foreground
-- or background color was defined for a syntax item they were reset with
-- 39 or 49.
local escape = '\27[0'
if info.bold then escape = escape .. ';1' end
if info.italic then escape = escape .. ';3' end
if info.underline then escape = escape .. ';4' end
if info.foreground then
escape = escape .. ';' .. color2escape(info.foreground, true)
end
if info.background then
escape = escape .. ';' .. color2escape(info.background, false)
end
escape = escape .. 'm'
cache[groupid] = escape
return escape
end
local function init_cat_mode()
-- Initialize the ansi group to color cache with the "Normal" hl group.
cache[0] = group2ansi(nvim.nvim_call_function('hlID', {'Normal'}))
-- Get the value of &termguicolors from neovim.
colors_24_bit = nvim.nvim_get_option('termguicolors')
-- Select the correct coloe escaping function.
if colors_24_bit then
color2escape = color2escape_24bit
else
color2escape = color2escape_8bit
end
end
-- Check if the begining of the current buffer contains ansi escape sequences.
local function check_escape_sequences()
local filetype = nvim.nvim_buf_get_option(0, 'filetype')
if filetype == '' or filetype == 'text' then
for _, line in ipairs(nvim.nvim_buf_get_lines(0, 0, 100, false)) do
if line:find('\27%[[;?]*[0-9.;]*[A-Za-z]') ~= nil then return true end
end
end
return false
end
-- Iterate through the current buffer and print it to stdout with terminal
-- color codes for highlighting.
local function highlight()
-- Detect an empty buffer, see :help line2byte(). We can not use
-- nvim_buf_get_lines as the table will contain one empty string for both an
-- empty file and a file with just one empty line.
if nvim.nvim_buf_line_count(0) == 1 and
nvim.nvim_call_function("line2byte", {2}) == -1 then
return
elseif check_escape_sequences() then
for _, line in ipairs(nvim.nvim_buf_get_lines(0, 0, -1, false)) do
io.write(line, '\n')
end
return
end
local conceallevel = nvim.nvim_win_get_option(0, 'conceallevel')
local last_syntax_id = -1
local last_conceal_id = -1
local linecount = nvim.nvim_buf_line_count(0)
for lnum, line in ipairs(nvim.nvim_buf_get_lines(0, 0, -1, false)) do
local outline = ''
for cnum = 1, line:len() do
local conceal_info = nvim.nvim_call_function('synconcealed',
{lnum, cnum})
local conceal = conceal_info[1] == 1
local replace = conceal_info[2]
local conceal_id = conceal_info[3]
if conceal and last_conceal_id == conceal_id then
-- skip this char
else
local syntax_id, append
if conceal then
syntax_id = nvim.nvim_call_function('hlID', {'Conceal'})
if replace == '' and conceallevel == 1 then replace = ' ' end
append = replace
last_conceal_id = conceal_id
else
syntax_id = nvim.nvim_call_function('synID', {lnum, cnum, true})
append = line:sub(cnum, cnum)
end
if syntax_id ~= last_syntax_id then
outline = outline .. group2ansi(syntax_id)
last_syntax_id = syntax_id
end
outline = outline .. append
end
end
-- Write the whole line and a newline char. If this was the last line
-- also reset the terminal attributes.
io.write(outline, lnum == linecount and cache[0] or '', '\n')
end
end
-- Call the highlight function to write the highlighted version of all buffers
-- to stdout and quit nvim.
local function cat_mode()
init_cat_mode()
highlight()
-- We can not use nvim_list_bufs() as a file might appear on the command
-- line twice. In this case we want to behave like cat(1) and display the
-- file twice.
for _ = 2, nvim.nvim_call_function('argc', {}) do
nvim.nvim_command('next')
highlight()
end
nvim.nvim_command('quitall!')
end
-- Join a table with a string
local function join(table, seperator)
if #table == 0 then return '' end
local index = 1
local ret = table[index]
index = index + 1
while index <= #table do
ret = ret .. seperator .. table[index]
index = index + 1
end
return ret
end
-- Replace a string prefix in all items in a list
local function replace_prefix(table, old_prefix, new_prefix)
-- Escape all punctuation chars to protect from lua pattern chars.
old_prefix = old_prefix:gsub('[^%w]', '%%%0')
for index, value in ipairs(table) do
table[index] = value:gsub('^' .. old_prefix, new_prefix, 1)
end
return table
end
-- Fix the runtimepath. All user nvim folders are replaced by corresponding
-- nvimpager folders.
local function fix_runtime_path()
local runtimepath = nvim.nvim_list_runtime_paths()
-- Remove the custom nvimpager entry that was added on the command line.
runtimepath[#runtimepath] = nil
local new
for _, name in ipairs({"config", "data"}) do
local original = nvim.nvim_call_function("stdpath", {name})
new = original .."pager"
runtimepath = replace_prefix(runtimepath, original, new)
end
runtimepath = os.getenv("RUNTIME") .. "," .. join(runtimepath, ",")
nvim.nvim_set_option("runtimepath", runtimepath)
new = new .. '/rplugin.vim'
nvim.nvim_command("let $NVIM_RPLUGIN_MANIFEST = '" .. new .. "'")
end
-- Parse the command of the calling process to detect some common
-- documentation programs (man, pydoc, perldoc, git, ...). $PPID was exported
-- by the calling bash script and points to the calling program.
local function detect_parent_process()
local ppid = os.getenv('PPID')
if not ppid then return nil end
local proc = nvim.nvim_get_proc(tonumber(ppid))
if proc == nil then return 'none' end
local command = proc.name
if command == 'man' then
return 'man'
elseif command:find('^[Pp]ython[0-9.]*') ~= nil or
command:find('^[Pp]ydoc[0-9.]*') ~= nil then
return 'pydoc'
elseif command == 'ruby' or command == 'irb' or command == 'ri' then
return 'ri'
elseif command == 'perl' or command == 'perldoc' then
return 'perldoc'
elseif command == 'git' then
return 'git'
end
return nil
end
-- Search the begining of the current buffer to detect if it contains a man
-- page.
local function detect_man_page_in_current_buffer()
-- Only check the first twelve lines (for speed).
for _, line in ipairs(nvim.nvim_buf_get_lines(0, 0, 12, false)) do
-- Check if the line contains the string "NAME" or "NAME" with every
-- character overwritten by itself.
-- An earlier version of this code did also check if there are whitespace
-- characters at the end of the line. I could not find a man pager where
-- this was the case.
-- FIXME This only works for man pages in languages where "NAME" is used
-- as the headline. Some (not all!) German man pages use "BBEZEICHNUNG"
-- instead.
if line == 'NAME' or line == 'N\bNA\bAM\bME\bE' then
return true
end
end
return false
end
-- Remove ansi escape sequences from the current buffer.
local function strip_ansi_escape_sequences_from_current_buffer()
local modifiable = nvim.nvim_buf_get_option(0, "modifiable")
nvim.nvim_buf_set_option(0, "modifiable", true)
nvim.nvim_command(
[=[keepjumps silent %substitute/\v\e\[[;?]*[0-9.;]*[a-z]//egi]=])
nvim.nvim_win_set_cursor(0, {1, 0})
nvim.nvim_buf_set_option(0, "modifiable", modifiable)
end
-- Detect possible filetypes for the current buffer by looking at the pstree
-- or ansi escape sequences or manpage sequences in the current buffer.
local function detect_filetype()
if not doc then
if detect_man_page_in_current_buffer() then
-- FIXME: Why does this need to be the command? Why doesn't this work:
--nvim.nvim_buf_set_option(0, 'filetype', 'man')
nvim.nvim_command('setfiletype man')
end
else
if doc == 'git' then
-- Use nvim's syntax highlighting for git buffers instead of git's
-- internal highlighting.
strip_ansi_escape_sequences_from_current_buffer()
elseif doc == 'pydoc' or doc == 'perldoc' or doc == 'ri' then
doc = 'man'
end
-- FIXME: Why does this need to be the command? Why doesn't this work:
--nvim.nvim_buf_set_option(0, 'filetype', doc)
nvim.nvim_command('setfiletype '..doc)
end
end
-- Set up mappings to make nvim behave a little more like a pager.
local function set_maps()
nvim.nvim_command('nnoremap q :quitall!<CR>')
nvim.nvim_command('vnoremap q :quitall!<CR>')
nvim.nvim_command('nnoremap <Space> <PageDown>')
nvim.nvim_command('nnoremap <S-Space> <PageUp>')
nvim.nvim_command('nnoremap g gg')
nvim.nvim_command('nnoremap <Up> <C-Y>')
nvim.nvim_command('nnoremap <Down> <C-E>')
nvim.nvim_command('nnoremap k <C-Y>')
nvim.nvim_command('nnoremap j <C-E>')
end
-- Unset all mappings set in set_maps().
-- FIXME This is currently unused but keept for reference.
local function unset_maps()
nvim.nvim_command("nunmap q")
nvim.nvim_command("nunmap <Space>")
nvim.nvim_command("nunmap <S-Space>")
nvim.nvim_command("nunmap g")
nvim.nvim_command("nunmap <Up>")
nvim.nvim_command("nunmap <Down>")
end
-- Setup function for the VimEnter autocmd.
local function pager_mode()
if check_escape_sequences() then
-- Try to highlight ansi escape sequences with the AnsiEsc plugin.
nvim.nvim_command('AnsiEsc')
end
nvim.nvim_buf_set_option(0, 'modifiable', false)
nvim.nvim_buf_set_option(0, 'modified', false)
end
-- Setup function to be called from --cmd.
local function stage1()
fix_runtime_path()
-- Don't remember file names and positions
nvim.nvim_set_option('shada', '')
-- prevent messages when opening files (especially for the cat version)
nvim.nvim_set_option('shortmess', nvim.nvim_get_option('shortmess')..'F')
-- Define autocmd group for nvimpager.
nvim.nvim_command('augroup NvimPager')
nvim.nvim_command(' autocmd!')
nvim.nvim_command('augroup END')
doc = detect_parent_process()
if doc == 'git' then
-- We disable modelines for this buffer as they could disturb the git
-- highlighting in diffs.
nvim.nvim_buf_set_option(0, 'modeline', false)
nvim.nvim_set_option('modelines', 0)
end
-- Theoretically these options only affect the pager mode so they could also
-- be set in stage2() but that would overwrite user settings from the init
-- file.
nvim.nvim_set_option('mouse', 'a')
nvim.nvim_set_option('laststatus', 0)
end
-- Set up autocomands to start the correct mode after startup or for each
-- file. This function assumes that in "cat mode" we are called with
-- --headless and hence do not have a user interface. This also means that
-- this function can only be called with -c or later as the user interface
-- would not be available in --cmd.
local function stage2()
detect_filetype()
local mode, events
if #nvim.nvim_list_uis() == 0 then
mode, events = 'cat', 'VimEnter'
else
set_maps()
mode, events = 'pager', 'VimEnter,BufWinEnter'
end
-- The "nested" in these autocomands enables nested executions of
-- autocomands inside the *_mode() functions. See :h autocmd-nested, for
-- compatibility with nvim < 0.4 we use "nested" and not "++nested".
nvim.nvim_command(
'autocmd NvimPager '..events..' * nested lua nvimpager.'..mode..'_mode()')
end
return {
cat_mode = cat_mode,
pager_mode = pager_mode,
stage1 = stage1,
stage2 = stage2,
_testable = {
color2escape_24bit = color2escape_24bit,
color2escape_8bit = color2escape_8bit,
detect_parent_process = detect_parent_process,
group2ansi = group2ansi,
init_cat_mode = init_cat_mode,
join = join,
replace_prefix = replace_prefix,
split_rgb_number = split_rgb_number,
}
}
|
require("player")
require("ball")
require("ai")
file = ("C:\\Users\\Valer\\Desktop\\undone\\EveryEveryEveryEveryEveryEveryEveryEveryEveryEveryEvery.txt")
function love.load()
Player:load()
Ball:load()
AI:load()
function filewrite(filename, filetext)
local file = io.open("C:\\Users\\Valer\\Desktop\\undone\\EveryEveryEveryEveryEveryEveryEveryEveryEveryEveryEvery.txt", "w" )
file:write(filetext)
print("For monikas")
file:close()
end
end
function love.update(dt)
Player:update(dt)
Ball:update(dt)
AI:update(dt)
end
function love.draw()
Player:draw()
Ball:draw()
AI:draw()
end
function checkCollision(a, b)
if a.x + a.width > b.x and a.x < b.x + b.width and a.y + a.height > b.y and a.y < b.y + b.height then
return true
else
return false
end
end |
local require = require
-- local log = require "hs.logger" .new "Scenario"
local Definition = require "cp.spec.Definition"
local Handled = require "cp.spec.Handled"
local Run = require "cp.spec.Run"
local Where = require "cp.spec.Where"
local format = string.format
--- === cp.spec.Scenario ===
---
--- A [Definition](cp.spec.Definition.md) which describes a specific scenario.
---
--- A `Scenario` is most typically created via the [it](cp.spec.md#it) function, like so:
---
--- ```lua
--- local spec = require "cp.spec"
--- local describe, it = spec.describe, spec.it
---
--- local Rainbow = require "my.rainbow"
---
--- return describe "a rainbow" {
--- it "has seven colors"
--- :doing(function()
--- local rainbow = Rainbow()
--- assert(#rainbow:colors() == 7, "the rainbow has seven colors")
--- end)
--- }
--- ```
---
--- Scenarios can be run asynchronously via the [Run.This](cp.spec.Run.This.md) instance passed to the `doing` function.
--- To indicate a scenario is asynchronous, call [`this:wait()`](cp.spec.Run.This.md#wait), then call
--- [`this:done()`](cp.spec.Run.This.md#done), to indicate it has completed. Any `assert` call which fails will
--- result in the run failing, and stop at that point.
---
--- For example:
---
--- ```lua
--- return describe "a rainbow" {
--- it "has a pot of gold at the end"
--- :doing(function(this)
--- this:wait()
--- local rainbow = Rainbow()
--- rainbow:goToEnd(function(whatIsThere)
--- assert(whatIsThere:isInstanceOf(PotOfGold))
--- this:done()
--- end)
--- end)
--- }
--- ```
---
--- Definitions can also be data-driven, via the [where](#where) method:
---
--- ```lua
--- return describe "a rainbow" {
--- it "has ${color} at index ${index}"
--- :doing(function(this)
--- local rainbow = Rainbow()
--- assert(rainbow[this.index] == this.color)
--- end)
--- :where {
--- { "index", "color" },
--- { 1, "red" },
--- { 2, "orange" },
--- { 3, "yellow" },
--- { 4, "blue" },
--- { 5, "green" },
--- { 6, "indigo" },
--- { 7, "violet" },
--- },
--- }
--- ```
---
--- This will do a run for each variation and interpolate the value into the run name for each.
---
--- **Note:** "where" parameters will not override built-in functions and fields in the [this](cp.spec.Run.This.md)
--- instance (such as "async" or "done") so ensure that you pick names that don't clash.
local Scenario = Definition:subclass("cp.spec.Scenario")
-- default `doing` function for Definitions.
local function doingNothing()
error("It must be doing something.")
end
--- cp.spec.Specification.is(instance) -> boolean
--- Function
--- Checks if the `instance` is an instance of `Specification`.
---
--- Presentation:
--- * instance - The instance to check
---
--- Returns:
--- * `true` if it's a `Specification` instance.
function Scenario.static.is(instance)
return type(instance) == "table" and instance.isInstanceOf and instance:isInstanceOf(Scenario)
end
--- cp.spec.Scenario(name[, testFn]) -> cp.spec.Scenario
--- Constructor
--- Creates a new `Scenario` with the specified name.
---
--- Parameters:
--- * name - The name of the scenario.
--- * testFn - (optional) The `function` which performs the test for in the scenario.
---
--- Returns:
--- * The new `Scenario`.
---
--- Notes:
--- * If the `testFn` is not provided here, it must be done via the [doing](#doing) method prior to running,
--- an `error` will occur.
function Scenario:initialize(name, testFn)
Definition.initialize(self, name)
self.testFn = testFn or doingNothing
end
--- cp.spec.Scenario:doing(actionFn) -> self
--- Method
--- Specifies the `function` for the definition.
---
--- Parameters:
--- * testFn - The function that will do the test.
---
--- Returns:
--- * The same `Definition`.
function Scenario:doing(testFn)
if type(testFn) ~= "function" then
error("Provide a function to execute.")
end
if self.testFn and self.testFn ~= doingNothing then
error("It already has a test function.")
end
self.testFn = testFn
return self
end
local ASSERT = {}
local ERROR = {}
-- hijacks the global `assert` and `error` functions and captures the results as part of the spec.
local function hijackAssert(this)
-- log.df(">>> hijackAssert: called")
this:run()[ASSERT] = _G.assert
this:run()[ERROR] = _G.error
_G.assert = function(ok, message, level)
level = (level or 1) + 1
-- log.df("hijacked assert: called with %s, %q", ok, string.format(message, ...))
if ok then
-- log.df("hijacked assert: passed")
return ok, message
else
local msg = tostring(message)
if this:fail(format("[%s:%d] %s", debug.getinfo(level, 'S').short_src, debug.getinfo(level, 'l').currentline, msg)) then
this:run()[ASSERT](ok, Handled(msg, level))
end
end
end
_G.error = function(msg, level)
level = (level or 1) + 1
-- log.df("hijacked error: %s", msg)
if this:abort(format("[%s:%d] %s", debug.getinfo(level, 'S').short_src, debug.getinfo(level, 'l').currentline, msg)) then
this:run()[ERROR](msg, level)
end
end
end
-- restores the global `assert` and `error` functions to their previous values.
local function restoreAssert(this)
-- log.df(">>> restoreAssert: called")
if this:run()[ASSERT] then
-- log.df("restoreAssert: resetting assert")
_G.assert = this:run()[ASSERT]
this:run()[ASSERT] = nil
end
if this:run()[ERROR] then
_G.error = this:run()[ERROR]
this:run()[ERROR] = nil
end
end
--- cp.spec.Scenario:run(...) -> cp.spec.Run
--- Method
--- Runs the scenario.
---
--- Parameters:
--- * ... - The list of filters. The first one will be compared to this scenario to determine it should be run.
function Scenario:run()
-- TODO: support filtering
return Run(self.name, self)
:onBefore(hijackAssert)
:onRunning(self.testFn)
:onAfter(restoreAssert)
:onComplete(function(this)
if this:run().result == Run.result.running then
this:run().report:passed()
end
end)
end
--- cp.spec.Scenario:where(data) -> cp.spec.Where
--- Method
--- Specifies a `table` of data that will be iterated through as multiple [Runs](cp.spec.Run.md), one row at a time.
--- The first row should be all strings, which will be the name of the parameter. Subsequent rows are the values for
--- those rows.
---
--- Parameters:
--- * data - The data table.
---
--- Returns:
--- * The [Where](cp.spec.Where.md).
function Scenario:where(data)
return Where(self, data)
end
return Scenario |
project("RED4ext.NativeGlobalsRedscript")
targetdir(red4ext.paths.build("examples"))
kind("SharedLib")
language("C++")
defines(
{
"RED4EXT_STATIC_LIB"
})
includedirs(
{
".",
red4ext.paths.include()
})
files(
{
"**.cpp",
"**.hpp"
})
links(
{
"RED4ext.SDK"
})
|
return function (title)
local scene = {}
scene.draw = function ()
love.graphics.printf(
title .. '\n\n[press z]', 0, 200, 1024, 'center')
end
scene.update = function ()
end
scene.keypressed = function (self, key, game)
if key == 'z' then game.scenes:pop() end
end
return scene
end
|
-- Copyright (c) 2021 Trevor Redfern
--
-- This software is released under the MIT License.
-- https://opensource.org/licenses/MIT
describe("moonpie.tables.min", function()
local min = require "moonpie.tables.min"
it("finds the lowest value in an array", function()
local a = { 1, 4, 8, -2, 3, 4, 12 }
assert.equals(-2, min(a))
end)
it("accepts a function to retrieve value", function()
local a = {
{ x = 1 }, { x = 4 }, { x = -9 }, { x = 3 }
}
assert.equals(-9, min(a, function(item) return item.x end))
end)
end) |
--------------------------------
-- @module MenuItemFont
-- @extend MenuItemLabel
-- @parent_module cc
--------------------------------
-- get font size .<br>
-- js getFontSize
-- @function [parent=#MenuItemFont] getFontSizeObj
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- Returns the name of the Font.<br>
-- js getFontNameObj
-- @function [parent=#MenuItemFont] getFontNameObj
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- Set font size.<br>
-- c++ can not overload static and non-static member functions with the same parameter types.<br>
-- so change the name to setFontSizeObj.<br>
-- js setFontSize
-- @function [parent=#MenuItemFont] setFontSizeObj
-- @param self
-- @param #int size
-- @return MenuItemFont#MenuItemFont self (return value: cc.MenuItemFont)
--------------------------------
-- Set the font name .<br>
-- c++ can not overload static and non-static member functions with the same parameter types.<br>
-- so change the name to setFontNameObj.<br>
-- js setFontName
-- @function [parent=#MenuItemFont] setFontNameObj
-- @param self
-- @param #string name
-- @return MenuItemFont#MenuItemFont self (return value: cc.MenuItemFont)
--------------------------------
-- Set the default font name.
-- @function [parent=#MenuItemFont] setFontName
-- @param self
-- @param #string name
-- @return MenuItemFont#MenuItemFont self (return value: cc.MenuItemFont)
--------------------------------
-- Get default font size.
-- @function [parent=#MenuItemFont] getFontSize
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- Get the default font name.
-- @function [parent=#MenuItemFont] getFontName
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- Set default font size.
-- @function [parent=#MenuItemFont] setFontSize
-- @param self
-- @param #int size
-- @return MenuItemFont#MenuItemFont self (return value: cc.MenuItemFont)
return nil
|
local M = {}
M.bounds_min = vmath.vector3(-0.301300019026, -0.4117000103, -0.125)
M.bounds_max = vmath.vector3(0.301300019026, 0.4117000103, 0.125)
M.size = vmath.vector3(0.602600038052, 0.823400020599, 0.25)
return M
|
helpers = require "lua_funcs"
usbDeviceCallback = function(data)
local usb = {
helpers.titleCase(data.eventType),
data.productName,
data.vendorName
}
local message = table.concat(usb, " ")
-- print("usbDeviceCallback: " .. hs.inspect(data))
hs.alert.show("🖴 " .. message)
hs.notify.new({
title = "USB Event",
informativeText = message
}):send()
end
usbWatcher = hs.usb.watcher.new(usbDeviceCallback)
usbWatcher:start()
-- Modified version of:
-- https://github.com/NavePnow/Hammerspoon/blob/master/usb/usb.lua
|
local Shared = ...
local Msg = Shared.Msg
local ffi = require "ffi"
local C = ffi.C
local F = far.Flags
local PPIF_SELECTED = F.PPIF_SELECTED
local FILE_ATTRIBUTE_DIRECTORY = 0x00000010
local MCODE_F_SETCUSTOMSORTMODE = 0x80C67
local band, bor = bit.band, bit.bor -- 32 bits, be careful
local tonumber = tonumber
local CustomSortModes = {} -- key=integer, value=table
local CanChangeSortMode = true
-- shellsort [ http://lua-users.org/wiki/LuaSorting ]
-- Written by Rici Lake. The author disclaims all copyright and offers no warranty.
-- For convenience, shellsort returns its first argument.
local incs = { 1391376,
463792, 198768, 86961, 33936,
13776, 4592, 1968, 861, 336,
112, 48, 21, 7, 3, 1 }
local function shellsort(t, n, before)
for _, h in ipairs(incs) do
for i = h, n - 1 do
local v = t[i]
for j = i - h, 0, -h do
local testval = t[j]
if not before(v, testval) then break end
t[i] = testval
i = j
end
t[i] = v
end
end
return t
end
-- qsort [ extracted from Lua 5.1 distribution (file /test/sort.lua) ]
local function qsort(x,l,u,f)
local function recurse(l,u)
if l<u then
local m=math.random(u-(l-1))+l-1 -- choose a random pivot in range l..u
x[l],x[m] = x[m],x[l] -- swap pivot to first position
local t = x[l] -- pivot value
m = l
for i=l+1, u do
-- invariant: x[l+1..m] < t <= x[m+1..i-1]
if f(x[i], t) then
m = m+1
x[m],x[i] = x[i],x[m] -- swap x[i] and x[m]
end
end
x[l],x[m] = x[m],x[l] -- swap pivot to a valid place
-- x[l+1..m-1] < x[m] <= x[m+1..u]
recurse(l, m-1)
recurse(m+1, u)
end
end
recurse(l,u)
end
local BooleanProperties = {
"InvertByDefault", "NoSortEqualsByName"
}
local TernaryProperties = {
"DirectoriesFirst", "SelectedFirst", "RevertSorting", "SortGroups"
}
local function LoadCustomSortMode (nMode, Settings)
assert(type(nMode)=="number" and nMode==math.floor(nMode) and nMode>=100 and nMode<=0x7FFFFFFF)
if type(Settings) == "table" then
local t = {}
if type(Settings.Compare) == "function" then t.Compare=Settings.Compare end
local cond = Settings.Condition or Settings.condition -- allow lower case for 'Condition'
if type(cond) == "function" then t.Condition=cond end
if not (t.Compare or t.Condition) then
CustomSortModes[nMode] = nil
return
end
if type(Settings.InitSort) == "function" then t.InitSort=Settings.InitSort end
if type(Settings.EndSort) == "function" then t.EndSort=Settings.EndSort end
if type(Settings.SortFunction) == "string" then t.SortFunction=Settings.SortFunction end
if type(Settings.Description) == "string" then t.Description=Settings.Description end
if type(Settings.Indicator) == "string" then t.Indicator=(Settings.Indicator.." "):sub(1,2)
else t.Indicator = " "
end
for _,v in ipairs(BooleanProperties) do t[v] = not not Settings[v] end
for _,v in ipairs(TernaryProperties) do t[v] = Settings[v]==0 and 0 or Settings[v]==1 and 1 or 2 end
CustomSortModes[nMode] = t
else
CustomSortModes[nMode] = nil
end
end
local function CanDoPanelSort (SortMode)
local tSettings = CustomSortModes[SortMode]
if tSettings then
if tSettings.Condition then
CanChangeSortMode = false
local ok, ret = pcall(tSettings.Condition, SortMode)
CanChangeSortMode = true
if not ok then Shared.ErrMsg(ret); return; end
if not ret then return; end
tSettings = CustomSortModes[SortMode] -- retrieve again as it may be reloaded by Condition()
return tSettings and tSettings.Compare and true
else
return true
end
end
end
local function SetCustomSortMode (nMode, whatpanel, order)
if CanChangeSortMode then
if CanDoPanelSort(nMode) then
if order=="auto" then order=0
elseif order=="current" then order=1
elseif order=="direct" then order=2
elseif order=="reverse" then order=3
else order = 0
end
local Settings = CustomSortModes[nMode]
whatpanel = whatpanel==1 and 1 or 0
Shared.MacroCallFar(MCODE_F_SETCUSTOMSORTMODE, whatpanel, nMode, Settings.InvertByDefault, order)
end
end
end
local function CustomSortMenu()
local Id = win.Uuid("C323FBCF-6803-4F2C-B8B4-E576E7F125DC")
local items, bkeys = {}, {
{ BreakKey="C+RETURN", order="auto" },
{ BreakKey="CS+RETURN", order="auto" },
{ BreakKey="ADD", order="direct" },
{ BreakKey="C+ADD", order="direct" },
{ BreakKey="CS+ADD", order="direct" },
{ BreakKey="SUBTRACT", order="reverse" },
{ BreakKey="C+SUBTRACT", order="reverse" },
{ BreakKey="CS+SUBTRACT", order="reverse" },
}
local pinfo = panel.GetPanelInfo(nil,1)
for k,v in pairs(CustomSortModes) do
local item = { text=v.Description and tostring(v.Description) or Msg.PSDefaultMenuItemText..k; Mode=k; }
if pinfo.SortMode == k then
item.selected = true
item.checked = band(pinfo.Flags,F.PFLAGS_REVERSESORTORDER)==0 and "+" or "-"
end
items[#items+1] = item
end
table.sort(items, function(a,b) return a.Mode < b.Mode end)
local r, pos = far.Menu({Title=Msg.PSMenuTitle, Id=Id}, items, bkeys)
if r and (pos > 0) then
local apanel = not r.BreakKey or r.BreakKey:find("^CS%+") or not r.BreakKey:find("%+")
local ppanel = r.BreakKey and r.BreakKey:find("^CS?%+")
if ppanel then SetCustomSortMode(items[pos].Mode, 1, r.order) end
if apanel then SetCustomSortMode(items[pos].Mode, 0, r.order) end
end
end
local function GetSortModes()
local t = {}
for mode in pairs(CustomSortModes) do
t[#t+1]=mode; t[#t+1]=mode; t[#t+1]=mode;
end
table.sort(t)
for k=1,#t,3 do
local mode = t[k]
t[k+1] = CustomSortModes[mode].InvertByDefault
t[k+2] = CustomSortModes[mode].Description or "Sort mode "..mode
end
t.n = #t
return t
end
ffi.cdef[[
typedef struct
{
unsigned int *Positions;
void *Items;
size_t ItemsCount;
void (*FileListToPluginItem)(const void*, int, struct SortingPanelItem*);
int SortGroups;
int SelectedFirst;
int DirectoriesFirst;
int SortMode;
int RevertSorting;
int NumericSort;
int CaseSensitiveSort;
HANDLE hSortPlugin;
} CustomSort;
]]
-- local function Utf16Buf (str)
-- str = win.Utf8ToUtf16(str)
-- local buf = ffi.new("wchar_t[?]", #str/2+1)
-- ffi.copy(buf, str, #str)
-- return buf
-- end
-- local function wcscmp(p1,p2)
-- local pos = 0
-- while p1[pos] == p2[pos] do
-- if p1[pos] == 0 then return 0 end
-- pos = pos + 1
-- end
-- return p1[pos] - p2[pos]
-- end
local function IsTwoDots(p) return p[0]==46 and p[1]==46 and p[2]==0 end
local function Empty(p) return p[0]==0 end
-- called from Far
local function SortPanelItems (params)
jit.flush()
params = ffi.cast("CustomSort*", params)
local tSettings = CustomSortModes[tonumber(params.SortMode)]
if not (tSettings and tSettings.Compare) then return end
local Compare = tSettings.Compare
local SortEqualsByName = not tSettings.NoSortEqualsByName
local pi1 = ffi.new("struct SortingPanelItem")
local pi2 = ffi.new("struct SortingPanelItem")
local SortGroups, SelectedFirst, DirectoriesFirst, RevertSorting
if tSettings.SortGroups==0 then SortGroups=false
elseif tSettings.SortGroups==1 then SortGroups=true
else SortGroups = params.SortGroups ~= 0
end
if tSettings.SelectedFirst==0 then SelectedFirst=false
elseif tSettings.SelectedFirst==1 then SelectedFirst=true
else SelectedFirst = params.SelectedFirst ~= 0
end
if tSettings.DirectoriesFirst==0 then DirectoriesFirst=false
elseif tSettings.DirectoriesFirst==1 then DirectoriesFirst=true
else DirectoriesFirst = params.DirectoriesFirst ~= 0
end
if tSettings.RevertSorting==0 then RevertSorting=false
elseif tSettings.RevertSorting==1 then RevertSorting=true
else RevertSorting = params.RevertSorting ~= 0
end
local outParams = {
SortGroups = params.SortGroups ~= 0;
SelectedFirst = params.SelectedFirst ~= 0;
DirectoriesFirst = params.DirectoriesFirst ~= 0;
RevertSorting = params.RevertSorting ~= 0;
NumericSort = params.NumericSort ~= 0;
CaseSensitiveSort = params.CaseSensitiveSort ~= 0;
}
local function Before(n1, n2)
params.FileListToPluginItem(params.Items, n1, pi1)
params.FileListToPluginItem(params.Items, n2, pi2)
----------------------------------------------------------------------------
-- TODO: fix in Far
if IsTwoDots(pi1.FileName) then
if not IsTwoDots(pi2.FileName) then return true end
if Empty(pi1.AlternateFileName) or IsTwoDots(pi1.AlternateFileName) then
if not (Empty(pi2.AlternateFileName) or IsTwoDots(pi2.AlternateFileName)) then return true end
else
if Empty(pi2.AlternateFileName) or IsTwoDots(pi2.AlternateFileName) then return false end
end
elseif IsTwoDots(pi2.FileName) then
return false
end
----------------------------------------------------------------------------
if DirectoriesFirst then
local a1,a2 = band(tonumber(pi1.FileAttributes), FILE_ATTRIBUTE_DIRECTORY),
band(tonumber(pi2.FileAttributes), FILE_ATTRIBUTE_DIRECTORY)
if a1 ~= a2 then return a1 > a2 end
end
----------------------------------------------------------------------------
if SelectedFirst then
local s1,s2 = band(tonumber(pi1.Flags),PPIF_SELECTED), band(tonumber(pi2.Flags),PPIF_SELECTED)
if s1 ~= s2 then return s1 > s2 end
end
----------------------------------------------------------------------------
if SortGroups then
if pi1.SortGroup ~= pi2.SortGroup then return pi1.SortGroup < pi2.SortGroup end
end
----------------------------------------------------------------------------
local r = Compare(pi1, pi2, outParams)
if r ~= 0 then
if RevertSorting then r = -r end
return r < 0
else
if SortEqualsByName then
return 1 == C.CompareStringW(C.LOCALE_USER_DEFAULT, bor(C.NORM_IGNORECASE,C.SORT_STRINGSORT),
pi1.FileName, -1, pi2.FileName, -1)
end
end
return false
end
if tSettings.InitSort then tSettings.InitSort(outParams) end
if tSettings.SortFunction == "qsort" then
qsort(params.Positions, 0, tonumber(params.ItemsCount)-1, Before)
else -- default
shellsort(params.Positions, tonumber(params.ItemsCount), Before)
end
if tSettings.EndSort then tSettings.EndSort() end
return tSettings.Indicator
end
return {
SortPanelItems=SortPanelItems,
LoadCustomSortMode=LoadCustomSortMode,
SetCustomSortMode=SetCustomSortMode,
CustomSortMenu=CustomSortMenu,
GetSortModes=GetSortModes,
DeleteSortModes=function() CustomSortModes={} end,
CanDoPanelSort=CanDoPanelSort,
}
|
-----------------------------------
-- Area: Castle Zvahl Baileys
-- Mob: Demon's Avatar
-----------------------------------
mixins = {require("scripts/mixins/families/avatar")}
function onMobDeath(mob, player, isKiller)
end
|
local mod = DBM:NewMod("d499", "DBM-Scenario-MoP")
local L = mod:GetLocalizedStrings()
mod:SetRevision(("$Revision: 2 $"):sub(12, -3))
mod:SetZone()
mod:RegisterCombat("scenario", 1048)
mod:RegisterEventsInCombat(
"SPELL_AURA_APPLIED",
-- "UNIT_DIED",
"UNIT_SPELLCAST_SUCCEEDED target focus",
"SCENARIO_UPDATE"
)
mod.onlyNormal = true
--Captain Ook
local warnOrange = mod:NewTargetAnnounce(121895, 3)
--Captain Ook
local specWarnOrange = mod:NewSpecialWarningSpell(121895)
--Captain Ook
--local timerOrangeCD = mod:NewCDTimer(45, 121895)--Not good sample size, could be inaccurate
local timerKegRunner = mod:NewAchievementTimer(240, 7232)
mod:RemoveOption("HealthFrame")
--[["<398.3 22:41:57> [CHAT_MSG_MONSTER_SAY] CHAT_MSG_MONSTER_SAY#DELICIOUS!#Brewmaster Bo###Omegal##0#0##0#1219#nil#0#false#false", -- [2789]
"<398.3 22:41:58> [UPDATE_WORLD_STATES] |0#0#false#######0#0#0", -- [2790]
"<398.3 22:41:58> [CLEU] SPELL_AURA_APPLIED#false#0x04000000035FAB24#Omegal#1297#0#0x04000000035FAB24#Omegal#1297#0#121934#Unga Jungle Brew#1#BUFF", -- [2791]
"<398.3 22:41:58> [CLEU] SPELL_AURA_APPLIED#false#0x0400000005F7D31A#Zabijak#1298#0#0x0400000005F7D31A#Zabijak#1298#0#121934#Unga Jungle Brew#1#BUFF", -- [2792]
"<403.0 22:42:02> [CHAT_MSG_MONSTER_YELL] CHAT_MSG_MONSTER_YELL#YOU BETTER BE READY TO GET SOME OOK IN YER DOOKER!#Captain Ook#####0#0##0#1222#nil#0#false#false", -- [2806]--]]
function mod:SPELL_AURA_APPLIED(args)
if args.spellId == 121934 and self:AntiSpam() then
self:SendSync("Phase3")
end
end
function mod:UNIT_DIED(args)
local cid = self:GetCIDFromGUID(args.destGUID)
if cid == 62465 then--Captain Ook
end
end
function mod:UNIT_SPELLCAST_SUCCEEDED(uId, _, _, _, spellId)
if spellId == 121895 and self:AntiSpam() then
self:SendSync("Orange")
end
end
function mod:OnSync(msg)
if msg == "Phase3" then
timerKegRunner:Cancel()
-- timerOrangeCD:Start()
elseif msg == "Orange" then
warnOrange:Show()
specWarnOrange:Show()
end
end
function mod:SCENARIO_UPDATE(newStep)
local _, currentStage = C_Scenario.GetInfo()
if currentStage == 2 then
timerKegRunner:Start()
end
end
|
local ffi = require('ffi')
local C = ffi.C
local levee = require("levee")
return {
test_core = function()
local h = levee.Hub()
local r1 = h:signal(C.SIGALRM, C.SIGTERM)
local r2 = h:signal(C.SIGALRM)
local pid = C.getpid()
C.kill(pid, C.SIGALRM)
assert.same({r1:recv()}, {nil, C.SIGALRM})
assert.same({r2:recv()}, {nil, C.SIGALRM})
C.kill(pid, C.SIGTERM)
assert.same({r1:recv()}, {nil, C.SIGTERM})
assert.same({r2:recv(10)}, {levee.errors.TIMEOUT})
r1:close()
C.kill(pid, C.SIGALRM)
assert.same({r1:recv()}, {levee.errors.CLOSED})
assert.same({r2:recv()}, {nil, C.SIGALRM})
r2:close()
assert(not h:in_use())
assert.same(h.signal.reverse, {})
-- C.kill(pid, C.SIGALRM)
end,
}
|
function main()
tmr.alarm(0, 10000, 1, function()
dofile("ds18b20-example.lua")
end)
end
|
-- shared
--[[
duck typing:
]]--
local _={}
return _ |
-- ========== THIS IS AN AUTOMATICALLY GENERATED FILE! ==========
PlaceObj('StoryBit', {
ActivationEffects = {},
Category = "Tick_BeforeFounders",
Effects = {},
EnableChance = 40,
Enabled = true,
Enables = {
"Boost15_ColonyInvestmentFollowup",
},
Image = "UI/Messages/Events/01_video_call.tga",
Prerequisites = {
PlaceObj('CheckResource', {
'Condition', "<=",
'Resource', "Funding",
'Amount', 500000000,
}),
},
ScriptDone = true,
Text = T(109851937466, --[[StoryBit Boost15_ColonyInvestment Text]] "No matter how much you bang your head against the wall, the budget charts don’t start to make sense. We are severely overstretched. What are they thinking! Do they think colonizing Mars is a walk in the… then the call comes in.\n\nThe mission’s board has decided to bail us out after catching wind of your financial woes, and not a moment too soon.\n\nYou give out a sigh of relief."),
TextReadyForValidation = true,
TextsDone = true,
Title = T(201837685410, --[[StoryBit Boost15_ColonyInvestment Title]] "Colony Investment"),
VoicedText = T(488586618641, --[[voice:narrator]] "Slash it... Spread it... Prioritize... Then start all over again."),
group = "Pre-Founder Stage",
id = "Boost15_ColonyInvestment",
max_reply_id = 3,
qa_info = PlaceObj('PresetQAInfo', {
data = {
{
action = "Modified",
time = 1549623566,
user = "Boyan",
},
{
action = "Modified",
time = 1549984138,
user = "Kmilushev",
},
{
action = "Modified",
time = 1550491862,
user = "Boyan",
},
{
action = "Modified",
time = 1550492835,
user = "Blizzard",
},
{
action = "Modified",
time = 1550752016,
user = "Boyan",
},
{
action = "Modified",
time = 1551964089,
user = "Radomir",
},
},
}),
PlaceObj('StoryBitParamFunding', {
'Name', "basereward",
'Value', 500000000,
}),
PlaceObj('StoryBitParamFunding', {
'Name', "bluesunreward",
'Value', 2000000000,
}),
PlaceObj('StoryBitParamResearchPoints', {
'Name', "sponsorreserachreward",
'Value', 100,
}),
PlaceObj('StoryBitReply', {
'Text', T(636146241083, --[[StoryBit Boost15_ColonyInvestment Text]] "Sure, take your time."),
'OutcomeText', "auto",
'unique_id', 1,
}),
PlaceObj('StoryBitOutcome', {
'Prerequisites', {},
'Effects', {
PlaceObj('RewardFunding', {
'Amount', "<basereward>",
}),
},
}),
PlaceObj('StoryBitReply', {
'Text', T(320565583039, --[[StoryBit Boost15_ColonyInvestment Text]] "It is the lack of knowledge that burdens us more."),
'OutcomeText', "auto",
'unique_id', 2,
}),
PlaceObj('StoryBitOutcome', {
'Prerequisites', {},
'Effects', {
PlaceObj('RewardSponsorResearch', {
'Amount', 100,
'ModifyId', "Colony_Investment",
}),
},
}),
PlaceObj('StoryBitReply', {
'Text', T(455932341890, --[[StoryBit Boost15_ColonyInvestment Text]] "Threaten to submit report of gross failure unless further funding is secured."),
'OutcomeText', "auto",
'Prerequisite', PlaceObj('IsSponsor', {
'SponsorName', "BlueSun",
}),
'unique_id', 3,
}),
PlaceObj('StoryBitOutcome', {
'Prerequisites', {},
'Effects', {
PlaceObj('RewardFunding', {
'Amount', "<bluesunreward>",
}),
},
}),
})
|
local cmd = {}
cmd.title = "Kick"
cmd.description = "Kick a player from the server."
cmd.author = "Nub"
cmd.timeCreated = "Apr. 1, 2020 @ 7:36 PM CST"
cmd.category = "Player Management"
cmd.usage = "<player> {reason}"
cmd.call = "kick"
cmd.server = function(caller, args)
if #args > 0 then
local targ = nadmin:FindPlayer(table.remove(args, 1), caller, nadmin.MODE_BELOW)
if table.HasValue(targ, caller) then
for i, t in ipairs(targ) do
if t == caller then table.remove(targ, i) break end
end
end
if #targ > 0 then
local myCol = nadmin:GetNameColor(caller) or nadmin.colors.blue
local msg = {myCol, caller:Nick(), nadmin.colors.white, " has kicked "}
table.Add(msg, nadmin:FormatPlayerList(targ, "and"))
table.Add(msg, {nadmin.colors.white, "."})
nadmin:Notify(unpack(msg))
local list = nadmin:FormatPlayerListNoColor(targ, "and", "nick (steamid)<ipaddress>")
nadmin:Log("administration", caller:PlayerToString("nick (steamid)<ipaddress>") .. " has kicked " .. list)
local reason = nil
if #args > 0 then
reason = table.concat(args, " ")
end
for i, ply in ipairs(targ) do
ply:RemoveProps()
ply:Kick(reason)
end
else
nadmin:Notify(caller, nadmin.colors.red, nadmin.errors.noTargLess)
end
else
nadmin:Notify(caller, nadmin.colors.red, "First argument must be a player.")
end
end
local dis = Material("icon16/disconnect.png")
cmd.advUsage = {
{
type = "player",
text = "Player",
targetMode = nadmin.MODE_BELOW,
canTargetSelf = false
},
{
text = "Reason",
type = "string"
}
}
cmd.scoreboard = {}
cmd.scoreboard.targetMode = nadmin.MODE_BELOW
cmd.scoreboard.canTargetSelf = false
cmd.scoreboard.iconRender = function(panel, w, h, ply)
surface.SetDrawColor(255, 255, 255)
surface.SetMaterial(dis)
surface.DrawTexturedRect(w/2 - 10, 4, 20, 20)
end
cmd.scoreboard.OnClick = function(ply, rmb)
nadmin.scoreboard.cmd = cmd.advUsage
nadmin.scoreboard.call = cmd.call
nadmin.scoreboard:Hide()
nadmin.scoreboard:Show()
end
nadmin:RegisterCommand(cmd)
|
---------------------------------------------------------------------------------------------------
-- Common module
---------------------------------------------------------------------------------------------------
--[[ General configuration parameters ]]
config.defaultProtocolVersion = 2
--[[ Required Shared libraries ]]
local actions = require("user_modules/sequences/actions")
--[[ Variables ]]
local m = actions
m.type = "FILE"
--[[ Functions]]
function m.pTUpdateFunc(pTbl)
pTbl.policy_table.functional_groupings["Base-4"].rpcs.ShowAppMenu = nil
end
function m.addSubMenu(pMenuID)
local cid = m.getMobileSession():SendRPC("AddSubMenu",
{
menuID = pMenuID,
position = 500,
menuName ="SubMenupositive"
})
m.getHMIConnection():ExpectRequest("UI.AddSubMenu",
{
menuID = pMenuID,
menuParams = {
position = 500,
menuName ="SubMenupositive"
}
})
:Do(function(_,data)
m.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {})
end)
m.getMobileSession():ExpectResponse(cid, { success = true, resultCode = "SUCCESS" })
m.getMobileSession():ExpectNotification("OnHashChange",{})
end
function m.showAppMenuSuccess(pMenuID)
local cid = m.getMobileSession():SendRPC("ShowAppMenu", { menuID = pMenuID })
m.getHMIConnection():ExpectRequest("UI.ShowAppMenu", { appID = m.getHMIAppId(), menuID = pMenuID })
:Do(function(_, data)
m.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {})
end)
m.getMobileSession():ExpectResponse(cid, { success = true, resultCode = "SUCCESS" })
end
function m.showAppMenuUnsuccess(pMenuID, pResultCode)
local cid = m.getMobileSession():SendRPC("ShowAppMenu", { menuID = pMenuID })
m.getHMIConnection():ExpectRequest("UI.ShowAppMenu")
:Times(0)
m.getMobileSession():ExpectResponse(cid, { success = false, resultCode = pResultCode })
m.getMobileSession():ExpectNotification("OnHashChange")
:Times(0)
end
function m.showAppMenuHMIwithoutResponse(pMenuID)
local cid = m.getMobileSession():SendRPC("ShowAppMenu", { menuID = pMenuID })
m.getHMIConnection():ExpectRequest("UI.ShowAppMenu", { appID = m.getHMIAppId(), menuID = pMenuID })
:Do(function()
-- HMI did not response
end)
m.getMobileSession():ExpectResponse(cid, { success = false, resultCode = "GENERIC_ERROR" })
m.getMobileSession():ExpectNotification("OnHashChange")
:Times(0)
end
function m.changeHMISystemContext(pSystemContext)
m.getHMIConnection():SendNotification("UI.OnSystemContext", { systemContext = pSystemContext })
m.getMobileSession():ExpectNotification("OnHMIStatus", { systemContext = pSystemContext, hmiLevel = "FULL" })
end
function m.deactivateAppToBackground(pSystemContext)
if not pSystemContext then pSystemContext = "MAIN" end
m.getHMIConnection():SendNotification("BasicCommunication.OnEventChanged",
{ eventName = "AUDIO_SOURCE", isActive = true })
m.getMobileSession():ExpectNotification("OnHMIStatus",
{ hmiLevel = "BACKGROUND", audioStreamingState = "NOT_AUDIBLE", systemContext = pSystemContext })
end
function m.hmiLeveltoLimited(pAppId, pSystemContext)
if not pAppId then pAppId = 1 end
m.getHMIConnection(pAppId):SendNotification("BasicCommunication.OnAppDeactivated",
{ appID = m.getHMIAppId(pAppId) })
m.getMobileSession(pAppId):ExpectNotification("OnHMIStatus",
{ hmiLevel = "LIMITED", audioStreamingState = "AUDIBLE", systemContext = pSystemContext })
end
return m
|
-- This output package is deprecated and should only be used as an
-- example of how to create alternative output backends, in comparison
-- with the libtexpdf and debug backends.
local lgi = require("lgi")
local cairo = lgi.cairo
-- local pango = lgi.Pango
-- local fm = lgi.PangoCairo.FontMap.get_default()
-- local pango_context = lgi.Pango.FontMap.create_context(fm)
local imagesize = SILE.require("imagesize")
if (not SILE.outputters) then SILE.outputters = {} end
local cursorX = 0
local cursorY = 0
local cr
local move -- See https://github.com/pavouk/lgi/issues/48
local sgs
local _deprecationCheck = function (caller)
if type(caller) ~= "table" or type(caller.debugHbox) ~= "function" then
SU.deprecated("SILE.outputter.*", "SILE.outputter:*", "0.10.9", "0.10.10")
end
end
SILE.outputters.cairo = {
init = function (self)
_deprecationCheck(self)
local surface = cairo.PdfSurface.create(SILE.outputFilename, SILE.documentState.paperSize[1], SILE.documentState.paperSize[2])
cr = cairo.Context.create(surface)
move = cr.move_to
sgs = cr.show_glyph_string
end,
newPage = function (self)
_deprecationCheck(self)
cr:show_page()
end,
finish = function (self)
_deprecationCheck(self)
end,
cursor = function (self)
_deprecationCheck(self)
SU.deprecated("SILE.outputter:cursor", "SILE.outputter:getCursor", "0.10.10", "0.11.0")
return self:getCursor()
end,
getCursor = function (self)
_deprecationCheck(self)
return cursorX, cursorY
end,
moveTo = function (self, x, y)
_deprecationCheck(self)
SU.deprecated("SILE.outputter:moveTo", "SILE.outputter:setCursor", "0.10.10", "0.11.0")
return self:setCursor(x, y)
end,
setCursor = function (self, x, y, relative)
_deprecationCheck(self)
local offset = relative and { x = cursorX, y = cursorY } or { x = 0, y = 0 }
cursorX = offset.x + x
cursorY = offset.y - y
move(cr, cursorX, cursorY)
end,
setColor = function (self, color)
_deprecationCheck(self)
cr:set_source_rgb(color.r, color.g, color.b)
end,
pushColor = function (self)
_deprecationCheck(self)
end,
popColor = function (self)
_deprecationCheck(self)
end,
outputHbox = function (self, value, width)
_deprecationCheck(self)
SU.deprecated("SILE.outputter:outputHbox", "SILE.outputter:drawHbox", "0.10.10", "0.11.0")
return self:drawHbox(value, width)
end,
drawHbox = function (self, value, _)
_deprecationCheck(self)
if not value then return end
if value.pgs then
sgs(cr, value.font, value.pgs)
elseif value.text then
cr:show_text(value.text)
end
end,
setFont = function (self, options)
_deprecationCheck(self)
cr:select_font_face(options.font, options.style:lower() == "italic" and 1 or 0, options.weight > 100 and 0 or 1)
cr:set_font_size(options.size)
end,
drawImage = function (self, src, x, y, width, height)
_deprecationCheck(self)
local image = cairo.ImageSurface.create_from_png(src)
if not image then SU.error("Could not load image "..src) end
local src_width = image:get_width()
local src_height = image:get_height()
if not (src_width > 0) then SU.error("Something went wrong loading image "..src) end
cr:save()
cr:set_source_surface(image, 0, 0)
local p = cr:get_source()
local matrix, sx, sy
if width or height then
if width > 0 then sx = src_width / width end
if height > 0 then sy = src_height / height end
matrix = cairo.Matrix.create_scale(sx or sy, sy or sx)
else
matrix = cairo.Matrix.create_identity()
end
matrix:translate(-x, -y)
p:set_matrix(matrix)
cr:paint()
cr:restore()
end,
imageSize = function (self, src)
_deprecationCheck(self)
SU.deprecated("SILE.outputter:imageSize", "SILE.outputter:getImageSize", "0.10.10", "0.11.0")
return self:getImageSize(src)
end,
getImageSize = function (self, src)
_deprecationCheck(self)
local box_width, box_height, err = imagesize.imgsize(src)imagesize.imgsize(src)
if not box_width then
SU.error(err.." loading image")
end
return box_width, box_height
end,
drawSVG = function (self)
_deprecationCheck(self)
end,
rule = function (self, x, y, width, depth)
_deprecationCheck(self)
SU.deprecated("SILE.outputter:rule", "SILE.outputter:drawRule", "0.10.10", "0.11.0")
return self:drawRule(x, y, width, depth)
end,
drawRule = function (self, x, y, width, depth)
_deprecationCheck(self)
cr:rectangle(x, y, width, depth)
cr:fill()
end,
debugFrame = function (self, frame)
_deprecationCheck(self)
cr:set_source_rgb(0.8, 0, 0)
cr:set_line_width(0.5)
cr:rectangle(frame:left(), frame:top(), frame:width(), frame:height())
cr:stroke()
cr:move_to(frame:left() - 10, frame:top() -2)
cr:show_text(frame.id)
cr:set_source_rgb(0, 0, 0)
end,
debugHbox = function (self, typesetter, hbox, scaledWidth)
_deprecationCheck(self)
cr:set_source_rgb(0.9, 0.9, 0.9)
cr:set_line_width(0.5)
cr:rectangle(typesetter.frame.state.cursorX, typesetter.frame.state.cursorY-(hbox.height), scaledWidth, hbox.height+hbox.depth)
if (hbox.depth) then cr:rectangle(typesetter.frame.state.cursorX, typesetter.frame.state.cursorY-(hbox.height), scaledWidth, hbox.height); end
cr:stroke()
cr:set_source_rgb(0, 0, 0)
cr:move_to(typesetter.frame.state.cursorX, typesetter.frame.state.cursorY)
end
}
SILE.outputter = SILE.outputters.cairo
if not SILE.outputFilename and SILE.masterFilename then
SILE.outputFilename = SILE.masterFilename..".pdf"
end
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BitBuffer = require(ReplicatedStorage.Packages.BitBuffer)
local buffer = BitBuffer.new()
for i = 1, 1024 do
buffer:WriteUInt(32, i)
end
local b91 = buffer:ToBase91()
return function(b)
b.start()
BitBuffer.FromBase91(b91)
b.done()
end |
-- Gem color table and potential logic data (for future releases)
-- based on an idea derived by the GemHelper addon
-- GemHelper is an addon by Xinhuan @ US Blackrock Alliance (http://wowui.incgamers.com/?p=mod&m=4149)
-- all rights recognised
BonusScanner_Gems = {
-- Crafted Uncommon Quality Gems
{ itemID = "23095", red = 1, yellow = 0, blue = 0, meta = 0 }, --Bold Blood Garnet
{ itemID = "28595", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Bright Blood Garnet
{ itemID = "23113", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Brilliant Golden Draenite
{ itemID = "23106", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Dazzling Deep Peridot
{ itemID = "23097", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Delicate Blood Garnet
{ itemID = "23105", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Enduring Deep Peridot
{ itemID = "23114", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Gleaming Golden Draenite
{ itemID = "23100", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Glinting Flame Spessarite
{ itemID = "23108", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Glowing Shadow Draenite
{ itemID = "23098", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Inscribed Flame Spessarite
{ itemID = "23104", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Jagged Deep Peridot
{ itemID = "23099", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Luminous Flame Spessarite
{ itemID = "23121", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Lustrous Azure Moonstone
{ itemID = "23101", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Potent Flame Spessarite
{ itemID = "23103", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Radiant Deep Peridot
{ itemID = "23116", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Rigid Golden Draenite
{ itemID = "23109", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Royal Shadow Draenite
{ itemID = "23096", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Runed Blood Garnet
{ itemID = "23110", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Shifting Shadow Draenite
{ itemID = "28290", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Smooth Golden Draenite
{ itemID = "23118", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Solid Azure Moonstone
{ itemID = "23111", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Sovereign Shadow Draenite
{ itemID = "23119", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Sparkling Azure Moonstone
{ itemID = "23120", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Stormy Azure Moonstone
{ itemID = "23094", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Teardrop Blood Garnet
{ itemID = "23115", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Thick Golden Draenite
-- Crafted Rare Quality Gems
{ itemID = "24027", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Bold Living Ruby
{ itemID = "24031", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Bright Living Ruby
{ itemID = "24047", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Brilliant Dawnstone
{ itemID = "24065", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Dazzling Talasite
{ itemID = "24028", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Delicate Living Ruby
{ itemID = "24062", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Enduring Talasite
{ itemID = "24036", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Flashing Living Ruby
{ itemID = "24050", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Gleaming Dawnstone
{ itemID = "24061", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Glinting Noble Topaz
{ itemID = "24056", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Glowing Nightseye
{ itemID = "24058", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Inscribed Noble Topaz
{ itemID = "24067", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Jagged Talasite
{ itemID = "24060", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Luminous Noble Topaz
{ itemID = "24037", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Lustrous Star of Elune
{ itemID = "24059", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Potent Noble Topaz
{ itemID = "24066", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Radiant Talasite
{ itemID = "24051", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Rigid Dawnstone
{ itemID = "24057", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Royal Nightseye
{ itemID = "24030", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Runed Living Ruby
{ itemID = "24055", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Shifting Nightseye
{ itemID = "24048", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Smooth Dawnstone
{ itemID = "24033", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Solid Star of Elune
{ itemID = "24054", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Sovereign Nightseye
{ itemID = "24035", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Sparkling Star of Elune
{ itemID = "24039", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Stormy Star of Elune
{ itemID = "24032", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Subtle Living Ruby
{ itemID = "24029", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Teardrop Living Ruby
{ itemID = "24052", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Thick Dawnstone
-- Crafted Rare Meta Gems
{ itemID = "25897", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Bracing Earthstorm Diamond
{ itemID = "25899", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Brutal Earthstorm Diamond
{ itemID = "25890", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Destructive Skyfire Diamond
{ itemID = "25895", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Enigmatic Skyfire Diamond
{ itemID = "25901", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Insightful Earthstorm Diamond
{ itemID = "25893", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Mystical Skyfire Diamond
{ itemID = "25896", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Powerful Earthstorm Diamond
{ itemID = "25894", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Swift Skyfire Diamond
{ itemID = "25898", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Tenacious Earthstorm Diamond
-- Enchanter Created
{ itemID = "22460", red = 1, yellow = 1, blue = 1, meta = 0 }, -- Prismatic Sphere
{ itemID = "22459", red = 1, yellow = 1, blue = 1, meta = 0 }, -- Void Sphere
-- PvP Purchased Rare Meta Gems (Terrokar Spirit Towers)
{ itemID = "28557", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Swift Starfire Diamond
{ itemID = "28556", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Swift Windfire Diamond
-- PvP Purchased Gems (Nagrand, Halaa)
{ itemID = "27679", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Sublime Mystic Dawnstone
{ itemID = "30598", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Don Amancio's Heart
-- PvP Purchased Epic Gems (Honor Points)
{ itemID = "28362", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Bold Ornate Ruby
{ itemID = "28120", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Gleaming Ornate Dawnstone
{ itemID = "28363", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Inscribed Ornate Topaz
{ itemID = "28123", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Potent Ornate Topaz
{ itemID = "28118", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Runed Ornate Ruby
{ itemID = "28119", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Smooth Ornate Dawnstone
-- PvP Puchased Rare Gems (Honor Hold/Thrallmar)
{ itemID = "27809", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Barbed Deep Peridot
{ itemID = "27786", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Barbed Deep Peridot
{ itemID = "28361", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Mighty Blood Garnet
{ itemID = "28360", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Mighty Blood Garnet
{ itemID = "27820", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Notched Deep Peridot
{ itemID = "27785", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Notched Deep Peridot
{ itemID = "27812", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Stark Blood Garnet
{ itemID = "27777", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Stark Blood Garnet
-- Vendor Purchased (Common Gems)
{ itemID = "28458", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Bold Tourmaline
{ itemID = "28462", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Bright Tourmaline
{ itemID = "28466", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Brilliant Amber
{ itemID = "28459", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Delicate Tourmaline
{ itemID = "28469", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Gleaming Amber
{ itemID = "28465", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Lustrous Zircon
{ itemID = "28468", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Rigid Amber
{ itemID = "28461", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Runed Tourmaline
{ itemID = "28467", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Smooth Amber
{ itemID = "28463", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Solid Zircon
{ itemID = "28464", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Sparkling Zircon
{ itemID = "28460", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Teardrop Tourmaline
{ itemID = "28470", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Thick Amber
-- Instance Epic Gem Drops
{ itemID = "30565", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Assassin's Fire Opal
{ itemID = "30601", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Beaming Fire Opal
{ itemID = "30574", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Brutal Tanzanite
{ itemID = "30587", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Champion's Fire Opal
{ itemID = "30566", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Defender's Tanzanite
{ itemID = "30594", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Effulgent Chrysoprase
{ itemID = "30584", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Enscribed Fire Opal
{ itemID = "30559", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Etched Fire Opal
{ itemID = "30600", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Fluorescent Tanzanite
{ itemID = "30558", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Glimmering Fire Opal
{ itemID = "30556", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Glinting Fire Opal
{ itemID = "30585", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Glistening Fire Opal
{ itemID = "30555", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Glowing Tanzanite
{ itemID = "31116", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Infused Amethyst
{ itemID = "30551", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Infused Fire Opal
{ itemID = "30593", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Iridescent Fire Opal
{ itemID = "30602", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Jagged Chrysoprase
{ itemID = "30606", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Lambent Chrysophrase
{ itemID = "30547", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Luminous Fire Opal
{ itemID = "30548", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Polished Chrysoprase
{ itemID = "30553", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Pristine Fire Opal
{ itemID = "31118", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Pulsing Amethyst
{ itemID = "30608", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Radiant Chrysoprase
{ itemID = "30563", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Regal Tanzanite
{ itemID = "30604", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Resplendent Fire Opal
{ itemID = "30603", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Royal Tanzanite
{ itemID = "30586", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Seer's Chrysoprase
{ itemID = "30549", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Shifting Tanzanite
{ itemID = "30564", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Shining Fire Opal
{ itemID = "31117", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Soothing Amethyst
{ itemID = "30546", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Sovereign Tanzanite
{ itemID = "30607", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Splendid Fire Opal
{ itemID = "30554", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Stalwart Fire Opal
{ itemID = "30592", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Steady Chrysoprase
{ itemID = "30550", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Sundered Chrysoprase
{ itemID = "30583", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Timeless Chrysoprase
{ itemID = "30605", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Vivid Chrysoprase
{ itemID = "30552", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Blessed Tanzanite
{ itemID = "30589", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Dazzling Chrysoprase
{ itemID = "30582", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Deadly Fire Opal
{ itemID = "30581", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Durable Fire Opal
{ itemID = "30591", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Empowered Fire Opal
{ itemID = "30590", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Enduring Chrysoprase
{ itemID = "30572", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Imperial Tanzanite
{ itemID = "30573", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Mysterious Fire Opal
{ itemID = "30575", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Nimble Fire Opal
{ itemID = "30588", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Potent Fire Opal
{ itemID = "30560", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Rune Covered Chrysoprase
-- (patch 2.1.1)
{ itemID = "31863", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Balanced Nightseye
{ itemID = "31861", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Great Dawnstone
{ itemID = "31865", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Infused Nightseye
{ itemID = "31867", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Veiled Noble Topaz
{ itemID = "31868", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Wicked Noble Topaz
{ itemID = "32836", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Purified Shadow Pearl
{ itemID = "32833", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Purified Jaggal Pearl
{ itemID = "32409", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Relentless Earthstorm Diamond
{ itemID = "32410", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Thundering Skyfire Diamond
-- (patch 2.1.3)
{ itemID = "24053", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Mystic Dawnstone
{ itemID = "32634", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Unstable Amethyst
{ itemID = "32635", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Unstable Peridot
{ itemID = "32636", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Unstable Sapphire
{ itemID = "32637", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Unstable Citrine
{ itemID = "32638", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Unstable Topaz
{ itemID = "32639", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Unstable Talasite
{ itemID = "32640", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Potent Unstable Diamond
{ itemID = "32641", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Imbued Unstable Diamond
-- Epic gem drops in Black Temple/Hyjal
{ itemID = "32193", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Bold Crimson Spinel
{ itemID = "32194", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Delicate Crimson Spinel
{ itemID = "32195", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Teardrop Crimson Spinel
{ itemID = "35489", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Teardrop Crimson Spinel
{ itemID = "32196", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Runed Crimson Spinel
{ itemID = "35488", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Runed Crimson Spinel
{ itemID = "32197", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Bright Crimson Spinel
{ itemID = "35487", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Bright Crimson Spinel
{ itemID = "32198", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Subtle Crimson Spinel
{ itemID = "32199", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Flashing Crimson Spinel
{ itemID = "32200", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Solid Empyrean Sapphire
{ itemID = "32201", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Sparkling Empyrean Sapphire
{ itemID = "32202", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Lustrous Empyrean Sapphire
{ itemID = "32203", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Stormy Empyrean Sapphire
{ itemID = "32204", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Brilliant Lionseye
{ itemID = "32205", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Smooth Lionseye
{ itemID = "32206", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Rigid Lionseye
{ itemID = "32207", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Gleaming Lionseye
{ itemID = "32208", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Thick Lionseye
{ itemID = "32209", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Mystic Lionseye
{ itemID = "32210", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Great Lionseye
{ itemID = "32211", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Sovereign Shadowsong Amethyst
{ itemID = "32212", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Shifting Shadowsong Amethyst
{ itemID = "32213", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Balanced Shadowsong Amethyst
{ itemID = "32214", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Infused Shadowsong Amethyst
{ itemID = "32215", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Glowing Shadowsong Amethyst
{ itemID = "32216", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Royal Shadowsong Amethyst
{ itemID = "32217", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Inscribed Pyrestone
{ itemID = "32218", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Potent Pyrestone
{ itemID = "32219", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Luminous Pyrestone
{ itemID = "32220", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Glinting Pyrestone
{ itemID = "32221", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Veiled Pyrestone
{ itemID = "32222", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Wicked Pyrestone
{ itemID = "32223", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Enduring Seaspray Emerald
{ itemID = "32224", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Radiant Seaspray Emerald
{ itemID = "32225", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Dazzling Seaspray Emerald
{ itemID = "32226", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Jagged Seaspray Emerald
-- (patch 2.2.0)
{ itemID = "33131", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Crimson Sun
{ itemID = "33133", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Don Julio's Heart
{ itemID = "33134", red = 1, yellow = 0, blue = 0, meta = 0 }, -- Kailee's Rose
{ itemID = "33135", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Falling Star
{ itemID = "33140", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Blood of Ember
{ itemID = "33143", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Stone of Blades
{ itemID = "33144", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Facet of Eternity
{ itemID = "33782", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Steady Talasite
-- (patch 2.2.2)
{ itemID = "31862", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Balanced Shadow Draenite
{ itemID = "31860", red = 0, yellow = 1, blue = 0, meta = 0 }, -- Great Golden Draenite
{ itemID = "31864", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Infused Shadow Draenite
{ itemID = "31866", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Veiled Flame Spessarite
{ itemID = "31869", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Wicked Flame Spessarite
-- (patch 2.3.0)
{ itemID = "34220", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Chaotic Skyfire Diamond
{ itemID = "34256", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Charmed Amani Jewel
-- (patch 2.4.0)
{ itemID = "35503", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Ember Skyfire Diamond
{ itemID = "35501", red = 0, yellow = 0, blue = 0, meta = 1 }, -- Eternal Earthstorm Diamond
{ itemID = "35707", red = 1, yellow = 0, blue = 1, meta = 0 }, -- Regal Nightseye
{ itemID = "34831", red = 0, yellow = 0, blue = 1, meta = 0 }, -- Eye of the Sea
{ itemID = "35758", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Steady Seaspray Emerald
{ itemID = "35759", red = 0, yellow = 1, blue = 1, meta = 0 }, -- Forceful Seaspray Emerald
{ itemID = "35760", red = 1, yellow = 1, blue = 0, meta = 0 }, -- Reckless Pyrestone
{ itemID = "35761", red = 0, yellow = 1, blue = 0, meta = 0 } -- Quick Lionseye
};
--(xarthasskrillexx): table for metagems, their requirements, and their effects (only stat effects are counted, not things like procs (see: Brutal Earthstorm Diamond)).
--Using the gem itemID as the key for table of stats (as opposed to having "itemID" as key and gemID as value for that key, as above) is probably faster. Maybe. Who knows.
BonusScanner_MetaGems = {
-- Crafted Rare Meta Gems
["25897"] = { -- Bracing Earthstorm Diamond
minRed = 0,
minYellow = 0,
minBlue = 0,
specReq = 1, --more Red gems than Blue gems
effs = { HEAL = 26, DMG = 9, THREATREDUCTION = 2 }
},
["25899"] = { -- Brutal Earthstorm Diamond
minRed = 2,
minYellow = 2,
minBlue = 2,
specReq = 0,
effs = { DMGWPN = 3 }
},
["25890"] = { -- Destructive Skyfire Diamond
minRed = 2,
minYellow = 2,
minBlue = 2,
specReq = 0,
effs = { SPELLCRIT = 14, SPELLREFLECT = 1 }
},
["25895"] = { -- Enigmatic Skyfire Diamond
minRed = 0,
minYellow = 0,
minBlue = 0,
specReq = 2, --more Red gems than Yellow gems
effs = { CRIT = 12, SNARERESIST = 5 }
},
["25901"] = { -- Insightful Earthstorm Diamond
minRed = 2,
minYellow = 2,
minBlue = 2,
specReq = 0,
effs = { INT = 12 }
},
["25893"] = { -- Mystical Skyfire Diamond
minRed = 0,
minYellow = 0,
minBlue = 0,
specReq = 3, --more Blue gems than Yellow gems
effs = {}
},
["25896"] = { -- Powerful Earthstorm Diamond
minRed = 0,
minYellow = 0,
minBlue = 3,
specReq = 0,
effs = { STA = 18, STUNRESIST = 5 }
},
["25894"] = { -- Swift Skyfire Diamond
minRed = 1,
minYellow = 2,
minBlue = 0,
specReq = 0,
effs = { ATTACKPOWER = 24 }
},
["25898"] = { -- Tenacious Earthstorm Diamond
minRed = 0,
minYellow = 0,
minBlue = 5,
specReq = 0,
effs = { DEFENSE = 12 }
},
-- PvP Purchased Rare Meta Gems (Terrokar Spirit Towers)
["28557"] = { -- Swift Starfire Diamond
minRed = 1,
minYellow = 2,
minBlue = 0,
specReq = 0,
effs = { DMG = 12 }
},
["28556"] = { -- Swift Windfire Diamond
minRed = 1,
minYellow = 2,
minBlue = 0,
specReq = 0,
effs = { ATTACKPOWER = 20 }
},
-- Patch 2.1.1
["32409"] = { -- Relentless Earthstorm Diamond
minRed = 2,
minYellow = 2,
minBlue = 2,
specReq = 0,
effs = { AGI = 12, INCRCRITDMG = 3 }
},
["32410"] = { -- Thundering Skyfire Diamond
minRed = 2,
minYellow = 2,
minBlue = 2,
specReq = 0,
effs = {}
},
-- Patch 2.1.3
["32640"] = { -- Potent Unstable Diamond
minRed = 0,
minYellow = 0,
minBlue = 0,
specReq = 3, --more Blue gems than Yellow gems
effs = { ATTACKPOWER = 24, STUNRESIST = 5 }
},
["32641"] = { -- Imbued Unstable Diamond
minRed = 0,
minYellow = 3,
minBlue = 0,
specReq = 0,
effs = { DMG = 14, STURNRESIST = 5 }
},
-- Patch 2.3.0
["34220"] = { -- Chaotic Skyfire Diamond
minRed = 0,
minYellow = 0,
minBlue = 2,
specReq = 0,
effs = { SPELLCRIT = 12, INCRCRITDMG = 3 }
},
-- Patch 2.4.0
["35503"] = { -- Ember Skyfire Diamond
minRed = 3,
minYellow = 0,
minBlue = 0,
specReq = 0,
effs = { DMG = 14, PERCINT = 2 }
},
["35501"] = { -- Eternal Earthstorm Diamond
minRed = 0,
minYellow = 1,
minBlue = 2,
specReq = 0,
effs = { DEFENSE = 12, PERCBLOCKVALUE = 10 }
},
} |
-- RedFlat util submodule
local awful = require("awful")
local client = { floatset = {} }
-- Functions
-----------------------------------------------------------------------------------------------------------------------
local function size_correction(c, geometry, is_restore)
local sign = is_restore and - 1 or 1
local bg = sign * 2 * c.border_width
if geometry.width then geometry.width = geometry.width - bg end
if geometry.height then geometry.height = geometry.height - bg end
end
-- Client geometry correction by border width
--------------------------------------------------------------------------------
function client.fullgeometry(c, g)
local ng
if g then
if g.width and g.width <= 1 then return end
if g.height and g.height <= 1 then return end
size_correction(c, g, false)
ng = c:geometry(g)
else
ng = c:geometry()
end
size_correction(c, ng, true)
return ng
end
-- Smart swap include floating layout
--------------------------------------------------------------------------------
function client.swap(c1, c2)
local lay = awful.layout.get(c1.screen)
if awful.util.table.hasitem(client.floatset, lay) then
local g1, g2 = client.fullgeometry(c1), client.fullgeometry(c2)
client.fullgeometry(c1, g2)
client.fullgeometry(c2, g1)
end
c1:swap(c2)
end
-- End
-----------------------------------------------------------------------------------------------------------------------
return client
|
if not Translations then Translations = {} end
if not Translations.LibVersionCheck then Translations.LibVersionCheck = {} end
local translationTable = {
["German"] = {
["LibVersionCheck"] = "LibVersionCheck",
["Addon "] = "Addon ",
[" has version "] = " hat Version ",
[" but "] = ", aber ",
[" uses version "] = " verwendet Version ",
["Addons are outdated"] = "Addons sind veraltet",
["Addon"] = "Addon",
["my Version"] = "Meine Version",
["newest Version"] = "Neueste Version",
["show again : "] = "wieder zeigen : ",
["next login"] = "nächster Login",
["tomorrow"] = "morgen",
["in a week"] = "in 1 Woche",
["in a month"] = "in 1 Monat",
["never"] = "niemals",
},
["French"] = {
},
["Russian"] = {
},
}
function Translations.LibVersionCheck.L(x)
local lang=Inspect.System.Language()
if translationTable[lang]
and translationTable[lang][x] then
return translationTable[lang][x]
elseif lang == "English" then
return x
else
if not translationTable[lang] then translationTable[lang]={} end
translationTable[lang][x]=x
print ("No translation yet for '" .. lang .. "'/'" .. x .. "'")
return x
end
end
|
local SafeZone_Pos = {
--{ world = "MORDANMAP1.ZEN", x = 905.78521728516, z = 7113.150390625, dist = 6700 },
{ world = "KYRMIR.ZEN", x = 0.0, z = 0.0, dist = 5000 },
--{ world = "MORDANKHORINIS.ZEN", x = 5493.8037109375, z = 508.14431762695, dist = 8500 },
}
function GetSZParametrs( playerid )
for i, tab in ipairs( SafeZone_Pos ) do
if tab.world == GetPlayerWorld(playerid) then
return tab.x, tab.z, tab.dist;
end
end
return 0, 0, 0;
end
|
// Include needed files
include("shared.lua")
|
MusicModule = MusicModule or class(ItemModuleBase)
MusicModule.type_id = "Music"
function MusicModule:RegisterHook()
self._config.id = self._config.id or "Err"
local dir = self._config.directory
dir = (dir and dir .. "/") or ""
if self._config.source then
self._config.source = dir .. self._config.source
end
if self._config.start_source then
self._config.start_source = dir .. self._config.start_source
end
local music = {menu = self._config.menu, heist = self._config.heist, source = self._config.source, start_source = self._config.start_source, events = {}}
for k,v in ipairs(self._config) do
if type(v) == "table" and v._meta == "event" then
if v.start_source then
v.start_source = dir .. v.start_source
end
if v.alt_source then
v.alt_source = Path:Combine(dir, v.alt_source)
v.alt_start_source = v.alt_start_source and Path:Combine(dir, v.alt_start_source)
v.alt_chance = v.alt_chance and tonumber(v.alt_chance) or 0.1
v.allow_switch = NotNil(v.allow_switch, true)
end
if v.source then
v.source = dir .. v.source
else
self:log("[ERROR] Music with the id '%s' has an event that has no source!", self._config.id)
return
end
music.events[v.name] = {source = v.source, start_source = v.start_source, alt_source = v.alt_source, alt_start_source = v.alt_start_source, alt_chance = v.alt_chance, allow_switch = v.allow_switch}
end
end
if not self._mod._config.AddFiles then
local add = {directory = self._config.assets_directory or "Assets"}
table.insert(add, {_meta = "movie", path = music.source})
if music.start_source then
table.insert(add, {_meta = "movie", path = music.start_source})
end
if music.alt_source then
table.insert(add, {_meta = "movie", path = music.alt_source})
if music.alt_start_source then
table.insert(add, {_meta = "movie", path = music.alt_start_source})
end
end
for _, event in pairs(music.events) do
table.insert(add, {_meta = "movie", path = event.source})
if event.start_source then
table.insert(add, {_meta = "movie", path = event.start_source})
end
if event.alt_source then
table.insert(add, {_meta = "movie", path = event.alt_source})
if event.alt_start_source then
table.insert(add, {_meta = "movie", path = event.alt_start_source})
end
end
end
self._mod._config.AddFiles = AddFilesModule:new(self._mod, add)
end
BeardLib.MusicMods[self._config.id] = music
end
BeardLib:RegisterModule(MusicModule.type_id, MusicModule)
|
--[[ PreloadUtils.lua v1.0.0 https://www.hiveworkshop.com/threads/lua-preloadutils.325644/
uses:
- Global Initialization: https://www.hiveworkshop.com/threads/lua-global-initialization.317099/
API:
function PreloadUnit(arg)
function PreloadItem(arg)
function PreloadAbility(arg)
- Args: rawcode(s) enclosed in FourCC()
function PreloadEffect(arg)
function PreloadSound(arg)
- Args: string path(s)
Sample Usage:
PreloadUnit(FourCC('hfoo'))
PreloadAbility{ FourCC('A000'), FourCC('A001'), FourCC('A002') }
PreloadEffect{ path_1, {path_2, path_3}, path_4 }
]]--
do
local t = {}
local dummy
local function OnPreload(callback, arg)
if type(arg) == 'table' then
for k, v in pairs(arg) do
OnPreload(callback, v)
end
elseif t[arg] == nil then
t[arg] = 1 -- prevents redundant preloading
callback(arg)
end
end
local function UnitPreloader(id)
RemoveUnit(CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), id, 0, 0, 0))
end
local function ItemPreloader(id)
RemoveItem(UnitAddItemById(dummy, id))
end
local function AbilityPreloader(id)
if UnitAddAbility(dummy, id) then UnitRemoveAbility(dummy, id) end
end
local function EffectPreloader(path)
DestroyEffect(AddSpecialEffectTarget(path, dummy, "origin"))
end
-- Credits to Silvenon for sound preloading method
local function SoundPreloader(path)
local s = CreateSound(path, false, false, false, 10, 10, "")
SetSoundVolume(s, 0)
StartSound(s)
KillSoundWhenDone(s)
end
function PreloadUnit(arg)
OnPreload(UnitPreloader, arg)
end
function PreloadItem(arg)
OnPreload(ItemPreloader, arg)
end
function PreloadAbility(arg)
OnPreload(AbilityPreloader, arg)
end
function PreloadEffect(arg)
OnPreload(EffectPreloader, arg)
end
function PreloadSound(arg)
OnPreload(SoundPreloader, arg)
end
-- init
onGlobalInit(function ()
local world = GetWorldBounds()
dummy = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), FourCC('hpea'), 0, 0, 0)
SetUnitY(dummy, GetRectMaxY(world) + 1000)
UnitAddAbility(dummy, FourCC('AInv'))
UnitAddAbility(dummy, FourCC('Avul'))
UnitRemoveAbility(dummy, FourCC('Amov'))
RemoveRect(world)
end)
end |
local map = require "utils".map
local termcode = require "utils".termcode
local command = require "utils".command
local cmd = vim.cmd
local fn = vim.fn
local opts = {noremap = true, silent = true}
local actions = require("telescope.actions")
local trouble = require("trouble.providers.telescope")
-- map("n", "<C-D>", ":Siblings<CR>", opts)
--
local noremap = { noremap = true };
map(
"n",
"<C-P>",
"<cmd>lua require('telescope.builtin').find_files(require('telescope.themes').get_dropdown({}))<cr>",
noremap
)
map(
"n",
"<C-N>",
"<cmd>lua require('telescope').extensions.notify.notify(require('telescope.themes').get_dropdown({}))<cr>",
noremap
)
map(
"n",
"<C-M>",
"<cmd>lua require('telescope.builtin').oldfiles(require('telescope.themes').get_dropdown({}))<cr>",
noremap
)
map(
"n",
"<C-T>",
"<cmd>lua require('telescope.builtin').tags(require('telescope.themes').get_dropdown({}))<cr>",
noremap
)
map(
"n",
"<C-A>",
"<cmd>lua require('telescope.builtin').live_grep(require('telescope.themes').get_dropdown({}))<cr>",
noremap
)
map(
"n",
"<C-B>",
"<cmd>lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown({}))<cr>",
noremap
)
map(
"n",
"<leader>fh",
"<cmd>lua require('telescope.builtin').help_tags(require('telescope.themes').get_dropdown({}))<cr>",
noremap
)
require("telescope").setup(
{
defaults = {
vimgrep_arguments = {
"rg",
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
"--smart-case"
},
mappings = {
i = {["<c-t>"] = trouble.open_with_trouble},
n = {["<c-t>"] = trouble.open_with_trouble}
},
prompt_prefix = " ",
selection_caret = "● ",
entry_prefix = " ",
initial_mode = "insert",
selection_strategy = "reset",
sorting_strategy = "ascending",
layout_strategy = "horizontal",
layout_config = {
horizontal = {
prompt_position = "top",
preview_width = 0.55,
results_width = 0.8
},
vertical = {
mirror = false
},
width = 0.67,
height = 0.60,
preview_cutoff = 80
},
file_sorter = require("telescope.sorters").get_fuzzy_file,
file_ignore_patterns = {"node_modules", ".git"},
generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter,
path_display = {"relative"},
winblend = 0,
border = {},
borderchars = {"─", "│", "─", "│", "╭", "╮", "╯", "╰"},
color_devicons = true,
use_less = true,
set_env = {["COLORTERM"] = "truecolor"}, -- default = nil,
file_previewer = require("telescope.previewers").vim_buffer_cat.new,
grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new,
qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new
}
}
)
|
-- This is a NTest output handler that formats its output in a way that
-- resembles the Test Anything Protocol (though prefixed with "TAP: " so we can
-- more readily find it in comingled output streams).
local nrun
return function(e, test, msg, err)
msg = msg or ""
err = err or ""
if e == "pass" then
print(("\nTAP: ok %d %s # %s"):format(nrun, test, msg))
nrun = nrun + 1
elseif e == "fail" then
print(("\nTAP: not ok %d %s # %s: %s"):format(nrun, test, msg, err))
nrun = nrun + 1
elseif e == "except" then
print(("\nTAP: not ok %d %s # exn; %s: %s"):format(nrun, test, msg, err))
nrun = nrun + 1
elseif e == "abort" then
print(("\nTAP: Bail out! %d %s # exn; %s: %s"):format(nrun, test, msg, err))
elseif e == "start" then
-- We don't know how many tests we plan to run, so emit a comment instead
print(("\nTAP: # STARTUP %s"):format(test))
nrun = 1
elseif e == "finish" then
-- Ah, now, here we go; we know how many tests we ran, so signal completion
print(("\nTAP: POST 1..%d"):format(nrun))
elseif #msg ~= 0 or #err ~= 0 then
print(("\nTAP: # %s: %s: %s"):format(test, msg, err))
end
end
|
local status_ok, util = pcall(require, 'lspconfig.util')
if not status_ok then
return
end
local bin_name = 'docker-langserver'
local cmd = { bin_name, '--stdio' }
return {
default_config = {
cmd = cmd,
filetypes = { 'dockerfile' },
root_dir = util.root_pattern 'Dockerfile',
single_file_support = true,
},
docs = {
description = [[
https://github.com/rcjsuen/dockerfile-language-server-nodejs
`docker-langserver` can be installed via `npm`:
```sh
npm install -g dockerfile-language-server-nodejs
```
]],
default_config = {
root_dir = [[root_pattern("Dockerfile")]],
},
},
}
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
require("lualib_bundle");
local ____exports = {}
____exports.Ellipse = __TS__Class()
local Ellipse = ____exports.Ellipse
Ellipse.name = "Ellipse"
function Ellipse.prototype.____constructor(self, mode, width, height, x, y)
if x == nil then
x = 0
end
if y == nil then
y = 0
end
self.color = {1, 1, 1}
self.border_thickness = 0
self.border_color = {1, 1, 1}
self.x = x
self.y = y
self.mode = mode
self.width = width
self.height = height
end
function Ellipse.prototype.update(self)
end
function Ellipse.prototype.draw(self)
love.graphics.push("all")
if self.mode == "fill" then
love.graphics.setColor(self.color)
love.graphics.ellipse(
"fill",
self.x,
self.y,
self.width,
self.height
)
end
love.graphics.setLineWidth(self.border_thickness)
love.graphics.setColor(self.border_color)
love.graphics.ellipse(
"line",
self.x,
self.y,
self.width,
self.height
)
love.graphics.pop()
end
return ____exports
|
require("stringutil")
require("compiler-core/src")
require("compiler-core/src/NodeTypes")
require("compiler-core/src/runtimeHelpers")
require("compiler-core/__tests__/testUtils")
require("@vue/shared/PatchFlags")
function createRoot(options)
if options == nil then
options={}
end
return {type=NodeTypes.ROOT, children={}, helpers={}, components={}, directives={}, imports={}, hoists={}, cached=0, temps=0, codegenNode=createSimpleExpression(false), loc=locStub, ...}
end
describe('compiler: codegen', function()
test('module mode preamble', function()
local root = createRoot({helpers={CREATE_VNODE, RESOLVE_DIRECTIVE}})
local = generate(root, {mode='module'})
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('module mode preamble w/ optimizeBindings: true', function()
local root = createRoot({helpers={CREATE_VNODE, RESOLVE_DIRECTIVE}})
local = generate(root, {mode='module', optimizeBindings=true})
expect(code):toMatch()
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('function mode preamble', function()
local root = createRoot({helpers={CREATE_VNODE, RESOLVE_DIRECTIVE}})
local = generate(root, {mode='function'})
expect(code):toMatch()
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('function mode preamble w/ prefixIdentifiers: true', function()
local root = createRoot({helpers={CREATE_VNODE, RESOLVE_DIRECTIVE}})
local = generate(root, {mode='function', prefixIdentifiers=true})
expect(code).tsvar_not:toMatch()
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('assets + temps', function()
local root = createRoot({components={}, directives={}, temps=3})
local = generate(root, {mode='function'})
expect(code):toMatch()
expect(code):toMatch()
expect(code):toMatch()
expect(code):toMatch()
expect(code):toMatch()
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('hoists', function()
local root = createRoot({hoists={createSimpleExpression(false, locStub), createObjectExpression({createObjectProperty(createSimpleExpression(true, locStub), createSimpleExpression(true, locStub))}, locStub)}})
local = generate(root)
expect(code):toMatch()
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('temps', function()
local root = createRoot({temps=3})
local = generate(root)
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('static text', function()
local = generate(createRoot({codegenNode={type=NodeTypes.TEXT, content='hello', loc=locStub}}))
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('interpolation', function()
local = generate(createRoot({codegenNode=createInterpolation(locStub)}))
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('comment', function()
local = generate(createRoot({codegenNode={type=NodeTypes.COMMENT, content='foo', loc=locStub}}))
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('compound expression', function()
local = generate(createRoot({codegenNode=createCompoundExpression({createSimpleExpression(false, locStub), , {type=NodeTypes.INTERPOLATION, loc=locStub, content=createSimpleExpression(false, locStub)}, createCompoundExpression({})})}))
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('ifNode', function()
local = generate(createRoot({codegenNode={type=NodeTypes.IF, loc=locStub, branches={}, codegenNode=createConditionalExpression(createSimpleExpression('foo', false), createSimpleExpression('bar', false), createSimpleExpression('baz', false))}}))
-- [ts2lua]tslua无法自动转换正则表达式,请手动处理。
expect(code):toMatch(/return foo\s+\? bar\s+: baz/)
expect(code):toMatchSnapshot()
end
)
test('forNode', function()
local = generate(createRoot({codegenNode={type=NodeTypes.FOR, loc=locStub, source=createSimpleExpression('foo', false), valueAlias=undefined, keyAlias=undefined, objectIndexAlias=undefined, children={}, parseResult={}, codegenNode={type=NodeTypes.VNODE_CALL, tag=FRAGMENT, isBlock=true, disableTracking=true, props=undefined, children=createCallExpression(RENDER_LIST), patchFlag='1', dynamicProps=undefined, directives=undefined, loc=locStub}}}))
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('forNode with constant expression', function()
local = generate(createRoot({codegenNode={type=NodeTypes.FOR, loc=locStub, source=createSimpleExpression('1 + 2', false, locStub, true), valueAlias=undefined, keyAlias=undefined, objectIndexAlias=undefined, children={}, parseResult={}, codegenNode={type=NodeTypes.VNODE_CALL, tag=FRAGMENT, isBlock=true, disableTracking=false, props=undefined, children=createCallExpression(RENDER_LIST), patchFlag=genFlagText(PatchFlags.STABLE_FRAGMENT), dynamicProps=undefined, directives=undefined, loc=locStub}}}))
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('Element (callExpression + objectExpression + TemplateChildNode[])', function()
local = generate(createRoot({codegenNode=createElementWithCodegen(createObjectExpression({createObjectProperty(createSimpleExpression(true, locStub), createSimpleExpression(true, locStub)), createObjectProperty(createSimpleExpression(false, locStub), createSimpleExpression(false, locStub)), createObjectProperty({type=NodeTypes.COMPOUND_EXPRESSION, loc=locStub, children={createSimpleExpression(false, locStub)}}, createSimpleExpression(false, locStub))}, locStub), {createElementWithCodegen(createObjectExpression({createObjectProperty(createSimpleExpression(true, locStub), createSimpleExpression(true, locStub))}, locStub))}, PatchFlags.FULL_PROPS .. '')}))
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('ArrayExpression', function()
local = generate(createRoot({codegenNode=createArrayExpression({createSimpleExpression(false), createCallExpression({})})}))
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('ConditionalExpression', function()
local = generate(createRoot({codegenNode=createConditionalExpression(createSimpleExpression(false), createCallExpression(), createConditionalExpression(createSimpleExpression(false), createCallExpression(), createCallExpression()))}))
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('CacheExpression', function()
local = generate(createRoot({cached=1, codegenNode=createCacheExpression(1, createSimpleExpression(false))}), {mode='module', prefixIdentifiers=true})
expect(code):toMatch()
expect(code):toMatchSnapshot()
end
)
test('CacheExpression w/ isVNode: true', function()
local = generate(createRoot({cached=1, codegenNode=createCacheExpression(1, createSimpleExpression(false), true)}), {mode='module', prefixIdentifiers=true})
expect(code):toMatch(():trim())
expect(code):toMatchSnapshot()
end
)
test('TemplateLiteral', function()
local = generate(createRoot({codegenNode=createCallExpression({createTemplateLiteral({createCallExpression({'id', 'foo'}), })})}), {ssr=true, mode='module'})
expect(code):toMatchInlineSnapshot()
end
)
describe('IfStatement', function()
test('if', function()
local = generate(createRoot({codegenNode=createBlockStatement({createIfStatement(createSimpleExpression('foo', false), createBlockStatement({createCallExpression()}))})}), {ssr=true, mode='module'})
expect(code):toMatchInlineSnapshot()
end
)
test('if/else', function()
local = generate(createRoot({codegenNode=createBlockStatement({createIfStatement(createSimpleExpression('foo', false), createBlockStatement({createCallExpression()}), createBlockStatement({createCallExpression('bar')}))})}), {ssr=true, mode='module'})
expect(code):toMatchInlineSnapshot()
end
)
test('if/else-if', function()
local = generate(createRoot({codegenNode=createBlockStatement({createIfStatement(createSimpleExpression('foo', false), createBlockStatement({createCallExpression()}), createIfStatement(createSimpleExpression('bar', false), createBlockStatement({createCallExpression()})))})}), {ssr=true, mode='module'})
expect(code):toMatchInlineSnapshot()
end
)
test('if/else-if/else', function()
local = generate(createRoot({codegenNode=createBlockStatement({createIfStatement(createSimpleExpression('foo', false), createBlockStatement({createCallExpression()}), createIfStatement(createSimpleExpression('bar', false), createBlockStatement({createCallExpression()}), createBlockStatement({createCallExpression('baz')})))})}), {ssr=true, mode='module'})
expect(code):toMatchInlineSnapshot()
end
)
end
)
test('AssignmentExpression', function()
local = generate(createRoot({codegenNode=createAssignmentExpression(createSimpleExpression(false), createSimpleExpression(false))}))
expect(code):toMatchInlineSnapshot()
end
)
describe('VNodeCall', function()
function genCode(node)
return ()[1+1]
end
local mockProps = createObjectExpression({createObjectProperty(createSimpleExpression(true))})
local mockChildren = createCompoundExpression({'children'})
local mockDirs = createArrayExpression({createArrayExpression({createSimpleExpression(false)})})
test('tag only', function()
expect(genCode(createVNodeCall(nil, ))):toMatchInlineSnapshot()
expect(genCode(createVNodeCall(nil, FRAGMENT))):toMatchInlineSnapshot()
end
)
test('with props', function()
expect(genCode(createVNodeCall(nil, , mockProps))):toMatchInlineSnapshot()
end
)
test('with children, no props', function()
expect(genCode(createVNodeCall(nil, , undefined, mockChildren))):toMatchInlineSnapshot()
end
)
test('with children + props', function()
expect(genCode(createVNodeCall(nil, , mockProps, mockChildren))):toMatchInlineSnapshot()
end
)
test('with patchFlag and no children/props', function()
expect(genCode(createVNodeCall(nil, , undefined, undefined, '1'))):toMatchInlineSnapshot()
end
)
test('as block', function()
expect(genCode(createVNodeCall(nil, , mockProps, mockChildren, undefined, undefined, undefined, true))):toMatchInlineSnapshot()
end
)
test('as for block', function()
expect(genCode(createVNodeCall(nil, , mockProps, mockChildren, undefined, undefined, undefined, true, true))):toMatchInlineSnapshot()
end
)
test('with directives', function()
expect(genCode(createVNodeCall(nil, , mockProps, mockChildren, undefined, undefined, mockDirs))):toMatchInlineSnapshot()
end
)
test('block + directives', function()
expect(genCode(createVNodeCall(nil, , mockProps, mockChildren, undefined, undefined, mockDirs, true))):toMatchInlineSnapshot()
end
)
end
)
end
) |
-- scaffolding entry point for khutils
return dofile("khutils.lua")
|
--[[
The following sequence of bits...
... come only in 2 types.
You are free to do with them whatever you want.
]]
--[[
A small collection of functions with various usefulness.
utils.hextobin(string_hex)
utils.logbase(number, number_base)
utils.sign(number)
utils.clamp(number, number_lower_limit, number_upper_limit)
utils.round(number)
utils.xy_to_x(number_x, number_y, number_width, number_offset)
utils.tobase(number, number_base)
utils.todecimal(string_number, number_base)
utils.strint(string_int, bool_signed, bool_big_endian, bool_ones_complement)
utils.intstr(number, number_num_bytes, bool_signed, bool_big_endian, bool_ones_complement)
utils.strfloat(string_float, bool_big_endian)
utils.floatstr(number, bool_big_endian)
utils.strdouble(string_double, bool_big_endian)
utils.byte_scale(number, bool_show_unit, bool_binary)
utils.bswap32(number)
utils.linear_bounce(number, number_range)
]]
local strsub = string.sub
local strchar = string.char
local strbyte = string.byte
local floor = math.floor
local ceil = math.ceil
local log = math.log
local abs = math.abs
local POWN126 = 2^-126
local POWN1022 = 2^-1022
local INFINITY = math.huge
local utils = {}
utils.strchar_lookup = {}
utils.strbyte_lookup = {}
for i = 0, 255 do
local char = strchar(i)
utils.strchar_lookup[i] = char
utils.strbyte_lookup[char] = i
end
-- Hex to binary.
utils.hextobin = function(hex)
return (hex:gsub("(..)", function(byte) return utils.strchar_lookup[tonumber(byte, 16)] end))
end
-- Lua 5.2's math.log for older versions.
utils.logbase = function(x, base)
return log(x)/log(base)
end
-- Sign checker.
utils.sign = function(x)
return (x>0 and 1) or (x<0 and -1) or 0
end
-- Value clamper.
utils.clamp = function(v, l, h)
return (v<l and l) or (v>h and h) or v
end
-- Round to nearest.
utils.round = function(x)
return (x<0 and ceil(x-0.5)) or floor(x+0.5)
end
-- Two dimensions to one.
utils.xy_to_x = function(x, y, width, offset)
if offset then -- 'if ... then' is actually faster than '+(... or 0)'.
return y*width + x + offset
end
return y*width + x
end
-- Lookup tables for the next functions.
local base_digits = { [0]=
"0","1", "2", "3", "4", "5", "6", "7", "8", "9",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
}
local base_digits_as_numbers = { [0]=
48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90
}
local base_digits_lookup = {
["0"]= 0, ["1"]= 1, ["2"]= 2, ["3"]= 3, ["4"]= 4, ["5"]= 5, ["6"]= 6, ["7"]= 7, ["8"]= 8, ["9"]= 9,
["A"]=10, ["B"]=11, ["C"]=12, ["D"]=13, ["E"]=14, ["F"]=15, ["G"]=16, ["H"]=17,
["I"]=18, ["J"]=19, ["K"]=20, ["L"]=21, ["M"]=22, ["N"]=23, ["O"]=24, ["P"]=25,
["Q"]=26, ["R"]=27, ["S"]=28, ["T"]=29, ["U"]=30, ["V"]=31, ["W"]=32, ["X"]=33,
["Y"]=34, ["Z"]=35,
["a"]=10, ["b"]=11, ["c"]=12, ["d"]=13, ["e"]=14, ["f"]=15, ["g"]=16, ["h"]=17,
["i"]=18, ["j"]=19, ["k"]=20, ["l"]=21, ["m"]=22, ["n"]=23, ["o"]=24, ["p"]=25,
["q"]=26, ["r"]=27, ["s"]=28, ["t"]=29, ["u"]=30, ["v"]=31, ["w"]=32, ["x"]=33,
["y"]=34, ["z"]=35
}
local function tobase_calc(num, base, ...)
if num > 0 then
local rem = num%base
return tobase_calc((num-rem)/base, base, base_digits_as_numbers[rem], ...)
end
return ...
end
-- Converts decimal integers into a new base.
-- 53216 in base 21 -> "5FE2"
utils.tobase = function(num, base)
if num == 0 then
return "0"
end
return strchar(tobase_calc(num, base))
end
-- Higher precision for tonumber with bases other than decimal.
utils.todecimal = function(num_str, base)
local num, str_len = 0, #num_str
for i = 0, str_len-1 do
num = num + base_digits_lookup[strsub(num_str, str_len-i, str_len-i)]*(base^i)
end
return num
end
local function strint_split_be(num, byte, byte2, ...)
if not byte2 and byte then
return num*256 + byte
end
return strint_split_be(num*256 + byte, byte2, ...)
end
local function strint_split_le(num, byte, byte2, ...)
if not byte2 and byte then
return num*0.00390625 + byte
end
return strint_split_le(num*0.00390625 + byte, byte2, ...)
end
-- Converts binary integer in a string to number.
utils.strint = function(int_str, signed, big_endian, ones_complement)
local num_bytes = #int_str
local num
if big_endian then
num = strint_split_be(0, strbyte(int_str, 1, -1))
else
num = strint_split_le(0, strbyte(int_str, 1, -1))*2^((num_bytes-1)*8)
end
if signed then
local signed_bit = 2^(num_bytes*8-1)
if num >= signed_bit then
if ones_complement then
return num - signed_bit*2 + 1
end
return num - signed_bit*2
end
end
return num
end
local function intstr_split_be(i, num, ...)
local byte = num%256
if i > 1 then
return intstr_split_be(i-1,(num-byte)*0.00390625, byte, ...)
end
return byte, ...
end
local function intstr_split_le(i, num, ...)
local frac = num%1
local byte = num - frac
if i > 1 then
return intstr_split_le(i-1, frac*256, byte, ...)
end
return byte, ...
end
-- Converts number to binary integer in a string.
utils.intstr = function(num, int_bytes, signed, big_endian, ones_complement)
if not int_bytes then
int_bytes = 4
end
if num < 0 then
if signed then
num = 2^(int_bytes*8) + num
if ones_complement then
num = num - 1
end
else
num = num % 2^(int_bytes*8)
end
end
if big_endian then
return strchar(intstr_split_be(int_bytes, num))
end
return strchar(intstr_split_le(int_bytes, num/256^(int_bytes-1)))
end
-- Converts 32-bit float to number.
utils.strfloat = function(float, big_endian)
local f4, f3, f2, f1 = strbyte(float, 1, 4)
if big_endian then
f1, f2, f3, f4 = f4, f3, f2, f1
end
local sgn = 1
local exp = f1*2
if f1 >= 128 then
sgn = -1
exp = exp - 256
end
local man = f2*65536 + f3*256 + f4
if f2 >= 128 then
man = man - 8388608
exp = exp + 1
end
if exp == 0 then
return sgn * (man*(1/8388608)) * POWN126
elseif exp == 255 then
if man == 0 then
return sgn * INFINITY
else
return 0/0
end
else
return sgn * (1 + man*(1/8388608)) * 2^(exp-127)
end
end
-- Lazy and untested number to 32-bit float conversion.
utils.floatstr = function(num, big_endian)
local exp, sgn = 127, 0
if num ~= 0 then
if num < 0 then
sgn = 1
num = -num
end
if num >= 2 then
while num >= 2 do
num = num * 0.5
exp = exp + 1
end
elseif num < 1 then
while num < 1 do
num = num * 2
exp = exp - 1
end
end
num = (num-1)*8388608
if big_endian then
return strchar(128*sgn + floor(exp/2), 128*(exp%2) + floor(num/65536), floor(num/256)%256, floor(num)%256)
end
return strchar(floor(num)%256, floor(num/256)%256, 128*(exp%2) + floor(num/65536), 128*sgn + floor(exp/2))
end
return "\0\0\0\0"
end
-- Converts 64-bit float to number.
utils.strdouble = function(double, big_endian)
local f8, f7, f6, f5, f4, f3, f2, f1 = strbyte(double, 1, 8)
if big_endian then
f1, f2, f3, f4, f5, f6, f7, f8 = f8, f7, f6, f5, f4, f3, f2, f1
end
local sgn = 1
local exp = f1*16
if f1 >= 128 then
sgn = -1
exp = exp - 2048
end
local msm = f2%16
exp = exp + (f2 - msm)*0.0625
local man = msm*281474976710656 + f3*1099511627776 + f4*4294967296 + f5*16777216 + f6*65536 + f7*256 + f8
if exp == 0 then
return sgn * (man*(1/4503599627370496)) * POWN1022
elseif exp == 2047 then
if man == 0 then
return sgn * INFINITY
else
return 0/0
end
else
return sgn * (1 + man*(1/4503599627370496)) * 2^(exp-1023)
end
end
-- Auto scaler for byte size in decimal and binary notation.
local byte_prefixes = {
{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"},
{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}
}
utils.byte_scale = function(num, show_unit, binary)
local base, step = 1, 1000
if binary then
base, step = 2, 1024
end
-- log is slower: local unit = floor(logbase(max(1, size), step)+1)
local mag
for i = 1, 9 do
if num >= step then
num = num / step
else
mag = i
break
end
end
if show_unit then
return (ceil(num*1000)/1000).." "..byte_prefixes[base][mag], mag
end
return ceil(num*1000)/1000, mag
end
-- 32-bit byte swapping.
utils.bswap32 = function(n)
local b1, b2, b3, b4
b1 = n%256
n = (n-b1)/256
b2 = n%256
n = (n-b2)/256
b3 = n%256
b4 = (n-b3)/256
return b1*16777216 + b2*65536 + b3*256 + b4
end
-- Clamps x to [0, range) by bouncing up and down.
utils.linear_bounce = function(x, range)
range = range - 1
return abs(x%(range*2) - range)
end
return utils |
local misc = { }
misc.IsUnderTurretEnemy = function(pos)
if not pos then return false; end
for i = 0, objManager.turrets.size[TEAM_ENEMY] - 1 do
local tower = objManager.turrets[TEAM_ENEMY][i]
if tower and not tower.isDead and tower.health > 0 then
local turretPos = vec3(tower.x, tower.y, tower.z)
if turretPos:dist(pos) < 900 then
return true;
end
else
tower = nil;
end
end
return false;
end
return misc |
--MoveCurve
--H_Tohka/curve_Rush curve_Rush
return
{
filePath = "H_Tohka/curve_Rush",
startTime = Fixed64(12582912) --[[12]],
startRealTime = Fixed64(75498) --[[0.072]],
endTime = Fixed64(104857600) --[[100]],
endRealTime = Fixed64(629146) --[[0.6]],
isZoom = false,
isCompensate = false,
curve = {
[1] = {
time = 0 --[[0]],
value = 0 --[[0]],
inTangent = 11447336 --[[10.91703]],
outTangent = 11447336 --[[10.91703]],
},
[2] = {
time = 480248 --[[0.458]],
value = 5242880 --[[5]],
inTangent = 0 --[[0]],
outTangent = 0 --[[0]],
},
[3] = {
time = 1048576 --[[1]],
value = 5242880 --[[5]],
inTangent = 0 --[[0]],
outTangent = 0 --[[0]],
},
},
} |
local SkillValidator = {} --# assume SkillValidator: SKILL_VALIDATOR
SkillValidator.__index = SkillValidator;
SkillValidator.viewModel = nil --: SKILL_QUEUE_VIEW_MODEL
--v function(self: SKILL_VALIDATOR, skill: string) --> boolean
function SkillValidator.canUnlockSkill(self, skill)
local questSkill = string.match(skill, "_quest");
if questSkill then
return false;
end
return true;
end
--v function(viewModel: SKILL_QUEUE_VIEW_MODEL) --> SKILL_VALIDATOR
function SkillValidator.new(viewModel)
local sv = {};
setmetatable(sv, SkillValidator);
--# assume sv: SKILL_VALIDATOR
sv.viewModel = viewModel;
return sv;
end
return {
new = SkillValidator.new
} |
local ft = require "fort"
local function print_table_with_styles(style, name)
-- Just create a table with some content
local ftable = ft.new()
ftable:set_cell_prop(ft.ANY_ROW, 1, ft.CPROP_TEXT_ALIGN, ft.ALIGNED_CENTER)
ftable:set_cell_prop(ft.ANY_ROW, 2, ft.CPROP_TEXT_ALIGN, ft.ALIGNED_LEFT)
ftable:set_cell_prop(1, ft.ANY_COLUMN, ft.CPROP_ROW_TYPE, ft.ROW_HEADER)
ftable:write_ln("Rank", "Title", "Year", "Rating")
ftable:write_ln("1", "The Shawshank Redemption", "1994", "9.5")
ftable:write_ln("2", "12 Angry Men", "1957", "8.8")
ftable:write_ln("3", "It's a Wonderful Life", "1946", "8.6")
ftable:add_separator()
ftable:write_ln("4", "2001: A Space Odyssey", "1968", "8.5")
ftable:write_ln("5", "Blade Runner", "1982", "8.1")
-- Setup border style
ftable:set_border_style(style)
-- Print ftable
print(string.format("%s style:\n\n%s\n\n", name, tostring(ftable)))
end
local function print_table_with_different_styles()
local function print_style(name) print_table_with_styles(ft[name], name) end
print_style("BASIC_STYLE")
print_style("BASIC2_STYLE")
print_style("SIMPLE_STYLE")
print_style("PLAIN_STYLE")
print_style("DOT_STYLE")
print_style("EMPTY_STYLE")
print_style("EMPTY2_STYLE")
print_style("SOLID_STYLE")
print_style("SOLID_ROUND_STYLE")
print_style("NICE_STYLE")
print_style("DOUBLE_STYLE")
print_style("DOUBLE2_STYLE")
print_style("BOLD_STYLE")
print_style("BOLD2_STYLE")
print_style("FRAME_STYLE")
end
print_table_with_different_styles()
|
--- 练习10.1 请编写一个函数split,该函数接受两个参数,第一个参数是字符串,第二个参数是分隔符模式,函数的返回值是分隔符分割后的原始字符串中每一部分的序列。
---你编写的函数是如何处理空字符串的呢?
---use find and sub
function string.split(str, sep)
local result = {}
if not str or str == "" then
return result
end
if sep == "" then
result[#result + 1] = str
return result
end
sep = sep or " "
local start, length = 1, #str
while start <= length do
local i, j = string.find(str, sep, start)
if not i or not j then
if start <= length then
result[#result + 1] = string.sub(str, start, length)
end
break
end
result[#result + 1] = string.sub(str, start, i - 1)
start = j + 1
end
return result
end
--use pattern (deal with empty string)
function string.split2(str, sep)
local result = {}
sep = sep or " "
string.gsub(str, string.format("([^%s]+)", sep), function(c)
result[#result + 1] = c
end)
return result
end
local function test10_1()
local test1 = "a whole new World"
local a = string.split(test1, " ")
local b = string.split2(test1, " ")
for i = 1, #a do
print(a[i])
end
print("----------------")
for i = 1, #b do
print(b[i])
end
print("==================")
local test2 = "a|whole|new|||||World"
a = string.split(test2, "|")
b = string.split2(test2, "|")
for i = 1, #a do
print(a[i])
end
print("----------------")
for i = 1, #b do
print(b[i])
end
end
test10_1()
--- 练习10.2 模式'%D'和'^%d'是等价的,那么模式'[^%d%u]'和'[%D%U]'呢?
-- 后者不等价
local str = "A"
print(string.match(str, "[^%d%u]")) --非数字并且非大写字母
print(string.match(str, "[%D%U]")) --非数字或者非大写字母 其实还是匹配所有字符
--- 练习10.3 请编写一个函数transliterate,该函数接受两个参数,第1个参数是字符串,第二个参数是一个表。
---函数 transliterate 根据第二个参数 表 使用一个字符替换字符串中的字符。如果表中将a映射为b ,那么该函数将所有 a 替换为 b 。
---如果表中将 a 映射为 false,那么该函数则把结果中的所有a移除
local function transliterate(str, t)
if not str or not t then
error("Invalid argument")
end
str = string.gsub(str,".", function(c)
local v = t[c]
if v then
return v
elseif v == false then
return ""
else
return c
end
end)
return str
end
local t = { ["-"] = " ",["?"] = false}
print(transliterate("Lua-is-a-good-language-for-me?????????",t))
--- 练习10.4 在10.3节的最后,我们定义了一个trim函数。由于该函数使用了回溯,所以对于某些字符串来说该函数的时间复杂度是O(n^2)。
--- ●构造一个可能会导致函数trim耗费O(n^2)时间复杂度的字符串。
--- ●重写这个函数使得其时间复杂度为O(n)。
local function trim(s) -- 每个字符间都有空格的情况下 复杂度为 O(n^2)
s = string.gsub(s,"^%s*(.-)%s*$","%1")
return s
end
local function trim2(s) --O(n)
local n = string.find(s,"%S")
if n then
return string.match(s,".*%S", n)
end
return ""
end
-- 更多方式可参考 lua-users.org/wiki/StringTrim
local function test10_4()
local a = {}
for i = 1,500000 do --O(n^2) string
a[i] = " a b c d e f g h i j k l m n o p q r s t u v w x y z "
end
local test = table.concat(a)
local startTime = os.clock()
for i = 1,10 do
trim(test)
end
local time1 = os.clock() - startTime
startTime = os.clock()
for i = 1,10 do
trim2(test)
end
local time2 = os.clock() - startTime
print("trim cost Time : " .. time1 .. "s")
print("trim2 cost Time : " .. time2 .. "s")
print(trim(test) == trim2(test))
end
test10_4()
--- 练习10.5 请使用转义序列\x编写一个函数,将一个二进制字符串格式转化为Lua语言中的字符串常量
--- 作为优化,请同时使用转义序列\z打破较长的行
local function escape(str)
str = string.gsub(str,'.',function (c)
return string.format("\\x%02x", string.byte(c))
end)
return str
end
print(escape("\0\1hello\200"))
print(escape(" I am a long string, \z
a very long string, \z
a very very very long string, \z
but I am still a single string only!"))
--- 练习10.6 请为UTF-8字符重写函数transliterate。
--注: 可以复习下章节4.5的知识
local function transliterate_utf8(str,t)
if not str or not t then
error("Invalid argument")
end
str = string.gsub(str,".[\128-\191]*", function(c)
local v = t[c]
if v then
return v
elseif v == false then
return ""
else
return c
end
end)
return str
end
local t2 = { ["三"] = "四",["书"] = false}
print(transliterate_utf8("Lua程序设计第三版书书书书书书书书书书书书书",t2))
--- 练习10.7 请编写一个函数,该函数用于逆转一个UTF-8字符串
--参见练习4.9
function string.utf8reverse(str)
if not str then
error("the argument#1 is nil!")
end
if str == "" then
return str
end
local array = { utf8.codepoint(str, utf8.offset(str, 1), utf8.offset(str, -1)) }
local rArray = {}
local len = #array
for i = len, 1, -1 do
rArray[len - i + 1] = array[i]
end
return utf8.char(table.unpack(rArray))
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.