repo_name stringlengths 6 69 | path stringlengths 6 178 | copies stringclasses 278
values | size stringlengths 4 7 | content stringlengths 671 917k | license stringclasses 15
values |
|---|---|---|---|---|---|
extreme01/extreme | plugins/plugins.lua | 62 | 5964 | do
-- Returns the key (index) in the config.enabled_plugins table
local function plugin_enabled( name )
for k,v in pairs(_config.enabled_plugins) do
if name == v then
return k
end
end
-- If not found
return false
end
-- Returns true if file exists in plugins folder
local function plugin_exists( name )
for k,v in pairs(plugins_names()) do
if name..'.lua' == v then
return true
end
end
return false
end
local function list_all_plugins(only_enabled)
local text = ''
local nsum = 0
for k, v in pairs( plugins_names( )) do
-- ✔ enabled, ❌ disabled
local status = '❌'
nsum = nsum+1
nact = 0
-- Check if is enabled
for k2, v2 in pairs(_config.enabled_plugins) do
if v == v2..'.lua' then
status = '✔'
end
nact = nact+1
end
if not only_enabled or status == '✔' then
-- get the name
v = string.match (v, "(.*)%.lua")
text = text..nsum..'> '..status..' '..v..'\n'
end
end
local text = text..'\n______________________________\nNumber of all tools: '..nsum..'\nEnable tools= '..nact..' and Disables= '..nsum-nact
return text
end
local function list_plugins(only_enabled)
local text = ''
local nsum = 0
for k, v in pairs( plugins_names( )) do
-- ✔ enabled, ❌ disabled
local status = '❌'
nsum = nsum+1
nact = 0
-- Check if is enabled
for k2, v2 in pairs(_config.enabled_plugins) do
if v == v2..'.lua' then
status = '✔'
end
nact = nact+1
end
if not only_enabled or status == '✔' then
-- get the name
v = string.match (v, "(.*)%.lua")
text = text..status..' '..v..'\n'
end
end
local text = text..'\n___________________________\nAll tools= '..nsum..' ,Enable items= '..nact
return text
end
local function reload_plugins( )
plugins = {}
load_plugins()
return list_plugins(true)
end
local function enable_plugin( plugin_name )
print('checking if '..plugin_name..' exists')
-- Check if plugin is enabled
if plugin_enabled(plugin_name) then
return plugin_name..' is enabled'
end
-- Checks if plugin exists
if plugin_exists(plugin_name) then
-- Add to the config table
table.insert(_config.enabled_plugins, plugin_name)
print(plugin_name..' added to _config table')
save_config()
-- Reload the plugins
return reload_plugins( )
else
return plugin_name..' does not exists'
end
end
local function disable_plugin( name, chat )
-- Check if plugins exists
if not plugin_exists(name) then
return name..' does not exists'
end
local k = plugin_enabled(name)
-- Check if plugin is enabled
if not k then
return name..' not enabled'
end
-- Disable and reload
table.remove(_config.enabled_plugins, k)
save_config( )
return reload_plugins(true)
end
local function disable_plugin_on_chat(receiver, plugin)
if not plugin_exists(plugin) then
return "Plugin doesn't exists"
end
if not _config.disabled_plugin_on_chat then
_config.disabled_plugin_on_chat = {}
end
if not _config.disabled_plugin_on_chat[receiver] then
_config.disabled_plugin_on_chat[receiver] = {}
end
_config.disabled_plugin_on_chat[receiver][plugin] = true
save_config()
return plugin..' disabled in group'
end
local function reenable_plugin_on_chat(receiver, plugin)
if not _config.disabled_plugin_on_chat then
return 'There aren\'t any disabled plugins'
end
if not _config.disabled_plugin_on_chat[receiver] then
return 'There aren\'t any disabled plugins for this chat'
end
if not _config.disabled_plugin_on_chat[receiver][plugin] then
return 'This plugin is not disabled'
end
_config.disabled_plugin_on_chat[receiver][plugin] = false
save_config()
return plugin..' enabled again'
end
local function run(msg, matches)
-- Show the available plugins
if matches[1] == '[!/]plugins' and is_sudo(msg) then --after changed to moderator mode, set only sudo
return list_all_plugins()
end
-- Re-enable a plugin for this chat
if matches[1] == '+' and matches[3] == 'gp' then
local receiver = get_receiver(msg)
local plugin = matches[2]
print(""..plugin..' enabled in group')
return reenable_plugin_on_chat(receiver, plugin)
end
-- Enable a plugin
if matches[1] == '+' and is_sudo(msg) then --after changed to moderator mode, set only sudo
local plugin_name = matches[2]
print("enable: "..matches[2])
return enable_plugin(plugin_name)
end
-- Disable a plugin on a chat
if matches[1] == '-' and matches[3] == 'gp' then
local plugin = matches[2]
local receiver = get_receiver(msg)
print(""..plugin..' disabled in group')
return disable_plugin_on_chat(receiver, plugin)
end
-- Disable a plugin
if matches[1] == '-' and is_sudo(msg) then --after changed to moderator mode, set only sudo
if matches[2] == 'plugins' then
return 'This plugin can\'t be disabled'
end
print("disable: "..matches[2])
return disable_plugin(matches[2])
end
-- Reload all the plugins!
if matches[1] == '@' and is_sudo(msg) then --after changed to moderator mode, set only sudo
return reload_plugins(true)
end
end
return {
description = "Plugin Manager",
usage = {
moderator = {
"/plugins - (name) gp : disable item in group",
"/plugins + (name) gp : enable item in group",
},
sudo = {
"/plugins : plugins list",
"/plugins + (name) : enable bot item",
"/plugins - (name) : disable bot item",
"/plugins @ : reloads plugins" },
},
patterns = {
"^[!/]plugins$",
"^[!/]plugins? (+) ([%w_%.%-]+)$",
"^[!/]plugins? (-) ([%w_%.%-]+)$",
"^[!/]plugins? (+) ([%w_%.%-]+) (gp)",
"^[!/]plugins? (-) ([%w_%.%-]+) (gp)",
"^[!/]plugins? (@)$" },
run = run,
moderated = true, -- set to moderator mode
--privileged = true
}
end
| gpl-2.0 |
fgielow/devenserver | data/actions/scripts/quests/arenareward.lua | 2 | 3691 | function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.actionid >= 42361 and item.actionid <= 42365 then
if player:getStorageValue(42361) ~= 1 then
if item.actionid == 42361 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You found a present.')
local reward = player:addItem(1990, 1)
reward:addItem(7372, 1)
reward:addItem(6569, 10)
reward:addItem(6574, 1)
reward:addItem(2114, 1)
elseif item.actionid == 42362 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You found a blacksteel sword.')
player:addItem(7406, 1)
elseif item.actionid == 42363 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You found a headchopper.')
player:addItem(7380, 1)
elseif item.actionid == 42364 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You found an orcish maul.')
player:addItem(7392, 1)
elseif item.actionid == 42365 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You found a fur backpack.')
local reward = player:addItem(7342, 1)
reward:addItem(7365, 100)
reward:addItem(7364, 100)
end
player:setStorageValue(42361, 1)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
end
elseif item.actionid >= 42371 and item.actionid <= 42375 then
if player:getStorageValue(42371) ~= 1 then
if item.actionid == 42371 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You found a present.')
local reward = player:addItem(1990,1)
reward:addItem(7372, 1)
reward:addItem(6569, 10)
reward:addItem(6574, 1)
reward:addItem(7183, 1)
elseif item.actionid == 42372 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You found a mystic blade.')
player:addItem(7384,1)
elseif item.actionid == 42373 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You found a heroic axe.')
player:addItem(7389,1)
elseif item.actionid == 42374 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You found a cranial basher.')
player:addItem(7415,1)
elseif item.actionid == 42375 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You found a fur backpack.')
local reward = player:addItem(7342,1)
reward:addItem(7365, 100)
reward:addItem(2547, 100)
reward:addItem(2547, 100)
reward:addItem(2311, 50)
reward:addItem(2304, 50)
end
player:setStorageValue(42371, 1)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
end
elseif item.actionid >= 42381 and item.actionid <= 42385 then
if player:getStorageValue(42381) ~= 1 then
if item.actionid == 42381 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You found a present.')
local reward = player:addItem(1990, 1)
reward:addItem(7372, 1)
reward:addItem(6569, 10)
reward:addItem(6574, 1)
reward:addItem(6568, 1)
elseif item.actionid == 42382 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You found a blessed sceptre.')
player:addItem(7429, 1)
elseif item.actionid == 42383 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You found a royal axe.')
player:addItem(7434, 1)
elseif item.actionid == 42384 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You found the justice seeker.')
player:addItem(7390, 1)
elseif item.actionid == 42385 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You found a fur backpack.')
local reward = player:addItem(7342, 1)
reward:addItem(2273, 50)
reward:addItem(2268, 50)
reward:addItem(7443, 1)
reward:addItem(7440, 1)
reward:addItem(6529, 100)
end
player:setStorageValue(42381, 1)
player:setStorageValue(42356, 1)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
end
end
return true
end
| gpl-2.0 |
Squ34k3rZ/SamsBday | cocos2d/external/lua/luajit/src/dynasm/dasm_mips.lua | 74 | 28080 | ------------------------------------------------------------------------------
-- DynASM MIPS module.
--
-- Copyright (C) 2005-2013 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------
-- Module information:
local _info = {
arch = "mips",
description = "DynASM MIPS module",
version = "1.3.0",
vernum = 10300,
release = "2012-01-23",
author = "Mike Pall",
license = "MIT",
}
-- Exported glue functions for the arch-specific module.
local _M = { _info = _info }
-- Cache library functions.
local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs
local assert, setmetatable = assert, setmetatable
local _s = string
local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char
local match, gmatch = _s.match, _s.gmatch
local concat, sort = table.concat, table.sort
local bit = bit or require("bit")
local band, shl, sar, tohex = bit.band, bit.lshift, bit.arshift, bit.tohex
-- Inherited tables and callbacks.
local g_opt, g_arch
local wline, werror, wfatal, wwarn
-- Action name list.
-- CHECK: Keep this in sync with the C code!
local action_names = {
"STOP", "SECTION", "ESC", "REL_EXT",
"ALIGN", "REL_LG", "LABEL_LG",
"REL_PC", "LABEL_PC", "IMM",
}
-- Maximum number of section buffer positions for dasm_put().
-- CHECK: Keep this in sync with the C code!
local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines.
-- Action name -> action number.
local map_action = {}
for n,name in ipairs(action_names) do
map_action[name] = n-1
end
-- Action list buffer.
local actlist = {}
-- Argument list for next dasm_put(). Start with offset 0 into action list.
local actargs = { 0 }
-- Current number of section buffer positions for dasm_put().
local secpos = 1
------------------------------------------------------------------------------
-- Dump action names and numbers.
local function dumpactions(out)
out:write("DynASM encoding engine action codes:\n")
for n,name in ipairs(action_names) do
local num = map_action[name]
out:write(format(" %-10s %02X %d\n", name, num, num))
end
out:write("\n")
end
-- Write action list buffer as a huge static C array.
local function writeactions(out, name)
local nn = #actlist
if nn == 0 then nn = 1; actlist[0] = map_action.STOP end
out:write("static const unsigned int ", name, "[", nn, "] = {\n")
for i = 1,nn-1 do
assert(out:write("0x", tohex(actlist[i]), ",\n"))
end
assert(out:write("0x", tohex(actlist[nn]), "\n};\n\n"))
end
------------------------------------------------------------------------------
-- Add word to action list.
local function wputxw(n)
assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range")
actlist[#actlist+1] = n
end
-- Add action to list with optional arg. Advance buffer pos, too.
local function waction(action, val, a, num)
local w = assert(map_action[action], "bad action name `"..action.."'")
wputxw(0xff000000 + w * 0x10000 + (val or 0))
if a then actargs[#actargs+1] = a end
if a or num then secpos = secpos + (num or 1) end
end
-- Flush action list (intervening C code or buffer pos overflow).
local function wflush(term)
if #actlist == actargs[1] then return end -- Nothing to flush.
if not term then waction("STOP") end -- Terminate action list.
wline(format("dasm_put(Dst, %s);", concat(actargs, ", ")), true)
actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put().
secpos = 1 -- The actionlist offset occupies a buffer position, too.
end
-- Put escaped word.
local function wputw(n)
if n >= 0xff000000 then waction("ESC") end
wputxw(n)
end
-- Reserve position for word.
local function wpos()
local pos = #actlist+1
actlist[pos] = ""
return pos
end
-- Store word to reserved position.
local function wputpos(pos, n)
assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range")
actlist[pos] = n
end
------------------------------------------------------------------------------
-- Global label name -> global label number. With auto assignment on 1st use.
local next_global = 20
local map_global = setmetatable({}, { __index = function(t, name)
if not match(name, "^[%a_][%w_]*$") then werror("bad global label") end
local n = next_global
if n > 2047 then werror("too many global labels") end
next_global = n + 1
t[name] = n
return n
end})
-- Dump global labels.
local function dumpglobals(out, lvl)
local t = {}
for name, n in pairs(map_global) do t[n] = name end
out:write("Global labels:\n")
for i=20,next_global-1 do
out:write(format(" %s\n", t[i]))
end
out:write("\n")
end
-- Write global label enum.
local function writeglobals(out, prefix)
local t = {}
for name, n in pairs(map_global) do t[n] = name end
out:write("enum {\n")
for i=20,next_global-1 do
out:write(" ", prefix, t[i], ",\n")
end
out:write(" ", prefix, "_MAX\n};\n")
end
-- Write global label names.
local function writeglobalnames(out, name)
local t = {}
for name, n in pairs(map_global) do t[n] = name end
out:write("static const char *const ", name, "[] = {\n")
for i=20,next_global-1 do
out:write(" \"", t[i], "\",\n")
end
out:write(" (const char *)0\n};\n")
end
------------------------------------------------------------------------------
-- Extern label name -> extern label number. With auto assignment on 1st use.
local next_extern = 0
local map_extern_ = {}
local map_extern = setmetatable({}, { __index = function(t, name)
-- No restrictions on the name for now.
local n = next_extern
if n > 2047 then werror("too many extern labels") end
next_extern = n + 1
t[name] = n
map_extern_[n] = name
return n
end})
-- Dump extern labels.
local function dumpexterns(out, lvl)
out:write("Extern labels:\n")
for i=0,next_extern-1 do
out:write(format(" %s\n", map_extern_[i]))
end
out:write("\n")
end
-- Write extern label names.
local function writeexternnames(out, name)
out:write("static const char *const ", name, "[] = {\n")
for i=0,next_extern-1 do
out:write(" \"", map_extern_[i], "\",\n")
end
out:write(" (const char *)0\n};\n")
end
------------------------------------------------------------------------------
-- Arch-specific maps.
local map_archdef = { sp="r29", ra="r31" } -- Ext. register name -> int. name.
local map_type = {} -- Type name -> { ctype, reg }
local ctypenum = 0 -- Type number (for Dt... macros).
-- Reverse defines for registers.
function _M.revdef(s)
if s == "r29" then return "sp"
elseif s == "r31" then return "ra" end
return s
end
------------------------------------------------------------------------------
-- Template strings for MIPS instructions.
local map_op = {
-- First-level opcodes.
j_1 = "08000000J",
jal_1 = "0c000000J",
b_1 = "10000000B",
beqz_2 = "10000000SB",
beq_3 = "10000000STB",
bnez_2 = "14000000SB",
bne_3 = "14000000STB",
blez_2 = "18000000SB",
bgtz_2 = "1c000000SB",
addi_3 = "20000000TSI",
li_2 = "24000000TI",
addiu_3 = "24000000TSI",
slti_3 = "28000000TSI",
sltiu_3 = "2c000000TSI",
andi_3 = "30000000TSU",
lu_2 = "34000000TU",
ori_3 = "34000000TSU",
xori_3 = "38000000TSU",
lui_2 = "3c000000TU",
beqzl_2 = "50000000SB",
beql_3 = "50000000STB",
bnezl_2 = "54000000SB",
bnel_3 = "54000000STB",
blezl_2 = "58000000SB",
bgtzl_2 = "5c000000SB",
lb_2 = "80000000TO",
lh_2 = "84000000TO",
lwl_2 = "88000000TO",
lw_2 = "8c000000TO",
lbu_2 = "90000000TO",
lhu_2 = "94000000TO",
lwr_2 = "98000000TO",
sb_2 = "a0000000TO",
sh_2 = "a4000000TO",
swl_2 = "a8000000TO",
sw_2 = "ac000000TO",
swr_2 = "b8000000TO",
cache_2 = "bc000000NO",
ll_2 = "c0000000TO",
lwc1_2 = "c4000000HO",
pref_2 = "cc000000NO",
ldc1_2 = "d4000000HO",
sc_2 = "e0000000TO",
swc1_2 = "e4000000HO",
sdc1_2 = "f4000000HO",
-- Opcode SPECIAL.
nop_0 = "00000000",
sll_3 = "00000000DTA",
movf_2 = "00000001DS",
movf_3 = "00000001DSC",
movt_2 = "00010001DS",
movt_3 = "00010001DSC",
srl_3 = "00000002DTA",
rotr_3 = "00200002DTA",
sra_3 = "00000003DTA",
sllv_3 = "00000004DTS",
srlv_3 = "00000006DTS",
rotrv_3 = "00000046DTS",
srav_3 = "00000007DTS",
jr_1 = "00000008S",
jalr_1 = "0000f809S",
jalr_2 = "00000009DS",
movz_3 = "0000000aDST",
movn_3 = "0000000bDST",
syscall_0 = "0000000c",
syscall_1 = "0000000cY",
break_0 = "0000000d",
break_1 = "0000000dY",
sync_0 = "0000000f",
mfhi_1 = "00000010D",
mthi_1 = "00000011S",
mflo_1 = "00000012D",
mtlo_1 = "00000013S",
mult_2 = "00000018ST",
multu_2 = "00000019ST",
div_2 = "0000001aST",
divu_2 = "0000001bST",
add_3 = "00000020DST",
move_2 = "00000021DS",
addu_3 = "00000021DST",
sub_3 = "00000022DST",
negu_2 = "00000023DT",
subu_3 = "00000023DST",
and_3 = "00000024DST",
or_3 = "00000025DST",
xor_3 = "00000026DST",
not_2 = "00000027DS",
nor_3 = "00000027DST",
slt_3 = "0000002aDST",
sltu_3 = "0000002bDST",
tge_2 = "00000030ST",
tge_3 = "00000030STZ",
tgeu_2 = "00000031ST",
tgeu_3 = "00000031STZ",
tlt_2 = "00000032ST",
tlt_3 = "00000032STZ",
tltu_2 = "00000033ST",
tltu_3 = "00000033STZ",
teq_2 = "00000034ST",
teq_3 = "00000034STZ",
tne_2 = "00000036ST",
tne_3 = "00000036STZ",
-- Opcode REGIMM.
bltz_2 = "04000000SB",
bgez_2 = "04010000SB",
bltzl_2 = "04020000SB",
bgezl_2 = "04030000SB",
tgei_2 = "04080000SI",
tgeiu_2 = "04090000SI",
tlti_2 = "040a0000SI",
tltiu_2 = "040b0000SI",
teqi_2 = "040c0000SI",
tnei_2 = "040e0000SI",
bltzal_2 = "04100000SB",
bal_1 = "04110000B",
bgezal_2 = "04110000SB",
bltzall_2 = "04120000SB",
bgezall_2 = "04130000SB",
synci_1 = "041f0000O",
-- Opcode SPECIAL2.
madd_2 = "70000000ST",
maddu_2 = "70000001ST",
mul_3 = "70000002DST",
msub_2 = "70000004ST",
msubu_2 = "70000005ST",
clz_2 = "70000020DS=",
clo_2 = "70000021DS=",
sdbbp_0 = "7000003f",
sdbbp_1 = "7000003fY",
-- Opcode SPECIAL3.
ext_4 = "7c000000TSAM", -- Note: last arg is msbd = size-1
ins_4 = "7c000004TSAM", -- Note: last arg is msb = pos+size-1
wsbh_2 = "7c0000a0DT",
seb_2 = "7c000420DT",
seh_2 = "7c000620DT",
rdhwr_2 = "7c00003bTD",
-- Opcode COP0.
mfc0_2 = "40000000TD",
mfc0_3 = "40000000TDW",
mtc0_2 = "40800000TD",
mtc0_3 = "40800000TDW",
rdpgpr_2 = "41400000DT",
di_0 = "41606000",
di_1 = "41606000T",
ei_0 = "41606020",
ei_1 = "41606020T",
wrpgpr_2 = "41c00000DT",
tlbr_0 = "42000001",
tlbwi_0 = "42000002",
tlbwr_0 = "42000006",
tlbp_0 = "42000008",
eret_0 = "42000018",
deret_0 = "4200001f",
wait_0 = "42000020",
-- Opcode COP1.
mfc1_2 = "44000000TG",
cfc1_2 = "44400000TG",
mfhc1_2 = "44600000TG",
mtc1_2 = "44800000TG",
ctc1_2 = "44c00000TG",
mthc1_2 = "44e00000TG",
bc1f_1 = "45000000B",
bc1f_2 = "45000000CB",
bc1t_1 = "45010000B",
bc1t_2 = "45010000CB",
bc1fl_1 = "45020000B",
bc1fl_2 = "45020000CB",
bc1tl_1 = "45030000B",
bc1tl_2 = "45030000CB",
["add.s_3"] = "46000000FGH",
["sub.s_3"] = "46000001FGH",
["mul.s_3"] = "46000002FGH",
["div.s_3"] = "46000003FGH",
["sqrt.s_2"] = "46000004FG",
["abs.s_2"] = "46000005FG",
["mov.s_2"] = "46000006FG",
["neg.s_2"] = "46000007FG",
["round.l.s_2"] = "46000008FG",
["trunc.l.s_2"] = "46000009FG",
["ceil.l.s_2"] = "4600000aFG",
["floor.l.s_2"] = "4600000bFG",
["round.w.s_2"] = "4600000cFG",
["trunc.w.s_2"] = "4600000dFG",
["ceil.w.s_2"] = "4600000eFG",
["floor.w.s_2"] = "4600000fFG",
["movf.s_2"] = "46000011FG",
["movf.s_3"] = "46000011FGC",
["movt.s_2"] = "46010011FG",
["movt.s_3"] = "46010011FGC",
["movz.s_3"] = "46000012FGT",
["movn.s_3"] = "46000013FGT",
["recip.s_2"] = "46000015FG",
["rsqrt.s_2"] = "46000016FG",
["cvt.d.s_2"] = "46000021FG",
["cvt.w.s_2"] = "46000024FG",
["cvt.l.s_2"] = "46000025FG",
["cvt.ps.s_3"] = "46000026FGH",
["c.f.s_2"] = "46000030GH",
["c.f.s_3"] = "46000030VGH",
["c.un.s_2"] = "46000031GH",
["c.un.s_3"] = "46000031VGH",
["c.eq.s_2"] = "46000032GH",
["c.eq.s_3"] = "46000032VGH",
["c.ueq.s_2"] = "46000033GH",
["c.ueq.s_3"] = "46000033VGH",
["c.olt.s_2"] = "46000034GH",
["c.olt.s_3"] = "46000034VGH",
["c.ult.s_2"] = "46000035GH",
["c.ult.s_3"] = "46000035VGH",
["c.ole.s_2"] = "46000036GH",
["c.ole.s_3"] = "46000036VGH",
["c.ule.s_2"] = "46000037GH",
["c.ule.s_3"] = "46000037VGH",
["c.sf.s_2"] = "46000038GH",
["c.sf.s_3"] = "46000038VGH",
["c.ngle.s_2"] = "46000039GH",
["c.ngle.s_3"] = "46000039VGH",
["c.seq.s_2"] = "4600003aGH",
["c.seq.s_3"] = "4600003aVGH",
["c.ngl.s_2"] = "4600003bGH",
["c.ngl.s_3"] = "4600003bVGH",
["c.lt.s_2"] = "4600003cGH",
["c.lt.s_3"] = "4600003cVGH",
["c.nge.s_2"] = "4600003dGH",
["c.nge.s_3"] = "4600003dVGH",
["c.le.s_2"] = "4600003eGH",
["c.le.s_3"] = "4600003eVGH",
["c.ngt.s_2"] = "4600003fGH",
["c.ngt.s_3"] = "4600003fVGH",
["add.d_3"] = "46200000FGH",
["sub.d_3"] = "46200001FGH",
["mul.d_3"] = "46200002FGH",
["div.d_3"] = "46200003FGH",
["sqrt.d_2"] = "46200004FG",
["abs.d_2"] = "46200005FG",
["mov.d_2"] = "46200006FG",
["neg.d_2"] = "46200007FG",
["round.l.d_2"] = "46200008FG",
["trunc.l.d_2"] = "46200009FG",
["ceil.l.d_2"] = "4620000aFG",
["floor.l.d_2"] = "4620000bFG",
["round.w.d_2"] = "4620000cFG",
["trunc.w.d_2"] = "4620000dFG",
["ceil.w.d_2"] = "4620000eFG",
["floor.w.d_2"] = "4620000fFG",
["movf.d_2"] = "46200011FG",
["movf.d_3"] = "46200011FGC",
["movt.d_2"] = "46210011FG",
["movt.d_3"] = "46210011FGC",
["movz.d_3"] = "46200012FGT",
["movn.d_3"] = "46200013FGT",
["recip.d_2"] = "46200015FG",
["rsqrt.d_2"] = "46200016FG",
["cvt.s.d_2"] = "46200020FG",
["cvt.w.d_2"] = "46200024FG",
["cvt.l.d_2"] = "46200025FG",
["c.f.d_2"] = "46200030GH",
["c.f.d_3"] = "46200030VGH",
["c.un.d_2"] = "46200031GH",
["c.un.d_3"] = "46200031VGH",
["c.eq.d_2"] = "46200032GH",
["c.eq.d_3"] = "46200032VGH",
["c.ueq.d_2"] = "46200033GH",
["c.ueq.d_3"] = "46200033VGH",
["c.olt.d_2"] = "46200034GH",
["c.olt.d_3"] = "46200034VGH",
["c.ult.d_2"] = "46200035GH",
["c.ult.d_3"] = "46200035VGH",
["c.ole.d_2"] = "46200036GH",
["c.ole.d_3"] = "46200036VGH",
["c.ule.d_2"] = "46200037GH",
["c.ule.d_3"] = "46200037VGH",
["c.sf.d_2"] = "46200038GH",
["c.sf.d_3"] = "46200038VGH",
["c.ngle.d_2"] = "46200039GH",
["c.ngle.d_3"] = "46200039VGH",
["c.seq.d_2"] = "4620003aGH",
["c.seq.d_3"] = "4620003aVGH",
["c.ngl.d_2"] = "4620003bGH",
["c.ngl.d_3"] = "4620003bVGH",
["c.lt.d_2"] = "4620003cGH",
["c.lt.d_3"] = "4620003cVGH",
["c.nge.d_2"] = "4620003dGH",
["c.nge.d_3"] = "4620003dVGH",
["c.le.d_2"] = "4620003eGH",
["c.le.d_3"] = "4620003eVGH",
["c.ngt.d_2"] = "4620003fGH",
["c.ngt.d_3"] = "4620003fVGH",
["add.ps_3"] = "46c00000FGH",
["sub.ps_3"] = "46c00001FGH",
["mul.ps_3"] = "46c00002FGH",
["abs.ps_2"] = "46c00005FG",
["mov.ps_2"] = "46c00006FG",
["neg.ps_2"] = "46c00007FG",
["movf.ps_2"] = "46c00011FG",
["movf.ps_3"] = "46c00011FGC",
["movt.ps_2"] = "46c10011FG",
["movt.ps_3"] = "46c10011FGC",
["movz.ps_3"] = "46c00012FGT",
["movn.ps_3"] = "46c00013FGT",
["cvt.s.pu_2"] = "46c00020FG",
["cvt.s.pl_2"] = "46c00028FG",
["pll.ps_3"] = "46c0002cFGH",
["plu.ps_3"] = "46c0002dFGH",
["pul.ps_3"] = "46c0002eFGH",
["puu.ps_3"] = "46c0002fFGH",
["c.f.ps_2"] = "46c00030GH",
["c.f.ps_3"] = "46c00030VGH",
["c.un.ps_2"] = "46c00031GH",
["c.un.ps_3"] = "46c00031VGH",
["c.eq.ps_2"] = "46c00032GH",
["c.eq.ps_3"] = "46c00032VGH",
["c.ueq.ps_2"] = "46c00033GH",
["c.ueq.ps_3"] = "46c00033VGH",
["c.olt.ps_2"] = "46c00034GH",
["c.olt.ps_3"] = "46c00034VGH",
["c.ult.ps_2"] = "46c00035GH",
["c.ult.ps_3"] = "46c00035VGH",
["c.ole.ps_2"] = "46c00036GH",
["c.ole.ps_3"] = "46c00036VGH",
["c.ule.ps_2"] = "46c00037GH",
["c.ule.ps_3"] = "46c00037VGH",
["c.sf.ps_2"] = "46c00038GH",
["c.sf.ps_3"] = "46c00038VGH",
["c.ngle.ps_2"] = "46c00039GH",
["c.ngle.ps_3"] = "46c00039VGH",
["c.seq.ps_2"] = "46c0003aGH",
["c.seq.ps_3"] = "46c0003aVGH",
["c.ngl.ps_2"] = "46c0003bGH",
["c.ngl.ps_3"] = "46c0003bVGH",
["c.lt.ps_2"] = "46c0003cGH",
["c.lt.ps_3"] = "46c0003cVGH",
["c.nge.ps_2"] = "46c0003dGH",
["c.nge.ps_3"] = "46c0003dVGH",
["c.le.ps_2"] = "46c0003eGH",
["c.le.ps_3"] = "46c0003eVGH",
["c.ngt.ps_2"] = "46c0003fGH",
["c.ngt.ps_3"] = "46c0003fVGH",
["cvt.s.w_2"] = "46800020FG",
["cvt.d.w_2"] = "46800021FG",
["cvt.s.l_2"] = "46a00020FG",
["cvt.d.l_2"] = "46a00021FG",
-- Opcode COP1X.
lwxc1_2 = "4c000000FX",
ldxc1_2 = "4c000001FX",
luxc1_2 = "4c000005FX",
swxc1_2 = "4c000008FX",
sdxc1_2 = "4c000009FX",
suxc1_2 = "4c00000dFX",
prefx_2 = "4c00000fMX",
["alnv.ps_4"] = "4c00001eFGHS",
["madd.s_4"] = "4c000020FRGH",
["madd.d_4"] = "4c000021FRGH",
["madd.ps_4"] = "4c000026FRGH",
["msub.s_4"] = "4c000028FRGH",
["msub.d_4"] = "4c000029FRGH",
["msub.ps_4"] = "4c00002eFRGH",
["nmadd.s_4"] = "4c000030FRGH",
["nmadd.d_4"] = "4c000031FRGH",
["nmadd.ps_4"] = "4c000036FRGH",
["nmsub.s_4"] = "4c000038FRGH",
["nmsub.d_4"] = "4c000039FRGH",
["nmsub.ps_4"] = "4c00003eFRGH",
}
------------------------------------------------------------------------------
local function parse_gpr(expr)
local tname, ovreg = match(expr, "^([%w_]+):(r[1-3]?[0-9])$")
local tp = map_type[tname or expr]
if tp then
local reg = ovreg or tp.reg
if not reg then
werror("type `"..(tname or expr).."' needs a register override")
end
expr = reg
end
local r = match(expr, "^r([1-3]?[0-9])$")
if r then
r = tonumber(r)
if r <= 31 then return r, tp end
end
werror("bad register name `"..expr.."'")
end
local function parse_fpr(expr)
local r = match(expr, "^f([1-3]?[0-9])$")
if r then
r = tonumber(r)
if r <= 31 then return r end
end
werror("bad register name `"..expr.."'")
end
local function parse_imm(imm, bits, shift, scale, signed)
local n = tonumber(imm)
if n then
local m = sar(n, scale)
if shl(m, scale) == n then
if signed then
local s = sar(m, bits-1)
if s == 0 then return shl(m, shift)
elseif s == -1 then return shl(m + shl(1, bits), shift) end
else
if sar(m, bits) == 0 then return shl(m, shift) end
end
end
werror("out of range immediate `"..imm.."'")
elseif match(imm, "^[rf]([1-3]?[0-9])$") or
match(imm, "^([%w_]+):([rf][1-3]?[0-9])$") then
werror("expected immediate operand, got register")
else
waction("IMM", (signed and 32768 or 0)+scale*1024+bits*32+shift, imm)
return 0
end
end
local function parse_disp(disp)
local imm, reg = match(disp, "^(.*)%(([%w_:]+)%)$")
if imm then
local r = shl(parse_gpr(reg), 21)
local extname = match(imm, "^extern%s+(%S+)$")
if extname then
waction("REL_EXT", map_extern[extname], nil, 1)
return r
else
return r + parse_imm(imm, 16, 0, 0, true)
end
end
local reg, tailr = match(disp, "^([%w_:]+)%s*(.*)$")
if reg and tailr ~= "" then
local r, tp = parse_gpr(reg)
if tp then
waction("IMM", 32768+16*32, format(tp.ctypefmt, tailr))
return shl(r, 21)
end
end
werror("bad displacement `"..disp.."'")
end
local function parse_index(idx)
local rt, rs = match(idx, "^(.*)%(([%w_:]+)%)$")
if rt then
rt = parse_gpr(rt)
rs = parse_gpr(rs)
return shl(rt, 16) + shl(rs, 21)
end
werror("bad index `"..idx.."'")
end
local function parse_label(label, def)
local prefix = sub(label, 1, 2)
-- =>label (pc label reference)
if prefix == "=>" then
return "PC", 0, sub(label, 3)
end
-- ->name (global label reference)
if prefix == "->" then
return "LG", map_global[sub(label, 3)]
end
if def then
-- [1-9] (local label definition)
if match(label, "^[1-9]$") then
return "LG", 10+tonumber(label)
end
else
-- [<>][1-9] (local label reference)
local dir, lnum = match(label, "^([<>])([1-9])$")
if dir then -- Fwd: 1-9, Bkwd: 11-19.
return "LG", lnum + (dir == ">" and 0 or 10)
end
-- extern label (extern label reference)
local extname = match(label, "^extern%s+(%S+)$")
if extname then
return "EXT", map_extern[extname]
end
end
werror("bad label `"..label.."'")
end
------------------------------------------------------------------------------
-- Handle opcodes defined with template strings.
map_op[".template__"] = function(params, template, nparams)
if not params then return sub(template, 9) end
local op = tonumber(sub(template, 1, 8), 16)
local n = 1
-- Limit number of section buffer positions used by a single dasm_put().
-- A single opcode needs a maximum of 2 positions (ins/ext).
if secpos+2 > maxsecpos then wflush() end
local pos = wpos()
-- Process each character.
for p in gmatch(sub(template, 9), ".") do
if p == "D" then
op = op + shl(parse_gpr(params[n]), 11); n = n + 1
elseif p == "T" then
op = op + shl(parse_gpr(params[n]), 16); n = n + 1
elseif p == "S" then
op = op + shl(parse_gpr(params[n]), 21); n = n + 1
elseif p == "F" then
op = op + shl(parse_fpr(params[n]), 6); n = n + 1
elseif p == "G" then
op = op + shl(parse_fpr(params[n]), 11); n = n + 1
elseif p == "H" then
op = op + shl(parse_fpr(params[n]), 16); n = n + 1
elseif p == "R" then
op = op + shl(parse_fpr(params[n]), 21); n = n + 1
elseif p == "I" then
op = op + parse_imm(params[n], 16, 0, 0, true); n = n + 1
elseif p == "U" then
op = op + parse_imm(params[n], 16, 0, 0, false); n = n + 1
elseif p == "O" then
op = op + parse_disp(params[n]); n = n + 1
elseif p == "X" then
op = op + parse_index(params[n]); n = n + 1
elseif p == "B" or p == "J" then
local mode, n, s = parse_label(params[n], false)
if p == "B" then n = n + 2048 end
waction("REL_"..mode, n, s, 1)
n = n + 1
elseif p == "A" then
op = op + parse_imm(params[n], 5, 6, 0, false); n = n + 1
elseif p == "M" then
op = op + parse_imm(params[n], 5, 11, 0, false); n = n + 1
elseif p == "N" then
op = op + parse_imm(params[n], 5, 16, 0, false); n = n + 1
elseif p == "C" then
op = op + parse_imm(params[n], 3, 18, 0, false); n = n + 1
elseif p == "V" then
op = op + parse_imm(params[n], 3, 8, 0, false); n = n + 1
elseif p == "W" then
op = op + parse_imm(params[n], 3, 0, 0, false); n = n + 1
elseif p == "Y" then
op = op + parse_imm(params[n], 20, 6, 0, false); n = n + 1
elseif p == "Z" then
op = op + parse_imm(params[n], 10, 6, 0, false); n = n + 1
elseif p == "=" then
op = op + shl(band(op, 0xf800), 5) -- Copy D to T for clz, clo.
else
assert(false)
end
end
wputpos(pos, op)
end
------------------------------------------------------------------------------
-- Pseudo-opcode to mark the position where the action list is to be emitted.
map_op[".actionlist_1"] = function(params)
if not params then return "cvar" end
local name = params[1] -- No syntax check. You get to keep the pieces.
wline(function(out) writeactions(out, name) end)
end
-- Pseudo-opcode to mark the position where the global enum is to be emitted.
map_op[".globals_1"] = function(params)
if not params then return "prefix" end
local prefix = params[1] -- No syntax check. You get to keep the pieces.
wline(function(out) writeglobals(out, prefix) end)
end
-- Pseudo-opcode to mark the position where the global names are to be emitted.
map_op[".globalnames_1"] = function(params)
if not params then return "cvar" end
local name = params[1] -- No syntax check. You get to keep the pieces.
wline(function(out) writeglobalnames(out, name) end)
end
-- Pseudo-opcode to mark the position where the extern names are to be emitted.
map_op[".externnames_1"] = function(params)
if not params then return "cvar" end
local name = params[1] -- No syntax check. You get to keep the pieces.
wline(function(out) writeexternnames(out, name) end)
end
------------------------------------------------------------------------------
-- Label pseudo-opcode (converted from trailing colon form).
map_op[".label_1"] = function(params)
if not params then return "[1-9] | ->global | =>pcexpr" end
if secpos+1 > maxsecpos then wflush() end
local mode, n, s = parse_label(params[1], true)
if mode == "EXT" then werror("bad label definition") end
waction("LABEL_"..mode, n, s, 1)
end
------------------------------------------------------------------------------
-- Pseudo-opcodes for data storage.
map_op[".long_*"] = function(params)
if not params then return "imm..." end
for _,p in ipairs(params) do
local n = tonumber(p)
if not n then werror("bad immediate `"..p.."'") end
if n < 0 then n = n + 2^32 end
wputw(n)
if secpos+2 > maxsecpos then wflush() end
end
end
-- Alignment pseudo-opcode.
map_op[".align_1"] = function(params)
if not params then return "numpow2" end
if secpos+1 > maxsecpos then wflush() end
local align = tonumber(params[1])
if align then
local x = align
-- Must be a power of 2 in the range (2 ... 256).
for i=1,8 do
x = x / 2
if x == 1 then
waction("ALIGN", align-1, nil, 1) -- Action byte is 2**n-1.
return
end
end
end
werror("bad alignment")
end
------------------------------------------------------------------------------
-- Pseudo-opcode for (primitive) type definitions (map to C types).
map_op[".type_3"] = function(params, nparams)
if not params then
return nparams == 2 and "name, ctype" or "name, ctype, reg"
end
local name, ctype, reg = params[1], params[2], params[3]
if not match(name, "^[%a_][%w_]*$") then
werror("bad type name `"..name.."'")
end
local tp = map_type[name]
if tp then
werror("duplicate type `"..name.."'")
end
-- Add #type to defines. A bit unclean to put it in map_archdef.
map_archdef["#"..name] = "sizeof("..ctype..")"
-- Add new type and emit shortcut define.
local num = ctypenum + 1
map_type[name] = {
ctype = ctype,
ctypefmt = format("Dt%X(%%s)", num),
reg = reg,
}
wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype))
ctypenum = num
end
map_op[".type_2"] = map_op[".type_3"]
-- Dump type definitions.
local function dumptypes(out, lvl)
local t = {}
for name in pairs(map_type) do t[#t+1] = name end
sort(t)
out:write("Type definitions:\n")
for _,name in ipairs(t) do
local tp = map_type[name]
local reg = tp.reg or ""
out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg))
end
out:write("\n")
end
------------------------------------------------------------------------------
-- Set the current section.
function _M.section(num)
waction("SECTION", num)
wflush(true) -- SECTION is a terminal action.
end
------------------------------------------------------------------------------
-- Dump architecture description.
function _M.dumparch(out)
out:write(format("DynASM %s version %s, released %s\n\n",
_info.arch, _info.version, _info.release))
dumpactions(out)
end
-- Dump all user defined elements.
function _M.dumpdef(out, lvl)
dumptypes(out, lvl)
dumpglobals(out, lvl)
dumpexterns(out, lvl)
end
------------------------------------------------------------------------------
-- Pass callbacks from/to the DynASM core.
function _M.passcb(wl, we, wf, ww)
wline, werror, wfatal, wwarn = wl, we, wf, ww
return wflush
end
-- Setup the arch-specific module.
function _M.setup(arch, opt)
g_arch, g_opt = arch, opt
end
-- Merge the core maps and the arch-specific maps.
function _M.mergemaps(map_coreop, map_def)
setmetatable(map_op, { __index = map_coreop })
setmetatable(map_def, { __index = map_archdef })
return map_op, map_def
end
return _M
------------------------------------------------------------------------------
| mit |
dacrybabysuck/darkstar | scripts/zones/Valkurm_Dunes/npcs/qm3.lua | 9 | 1421 | -----------------------------------
-- Area: Valkurm Dunes
-- NPC: qm3 (???)
-- Involved In Quest: Yomi Okuri
-- !pos -767 -4 192 103
-----------------------------------
local ID = require("scripts/zones/Valkurm_Dunes/IDs");
require("scripts/globals/keyitems");
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
local cstime = VanadielHour();
if (player:hasKeyItem(dsp.ki.YOMOTSU_HIRASAKA) and (cstime > 18 or cstime < 5) and not GetMobByID(ID.mob.DOMAN):isSpawned() and not GetMobByID(ID.mob.ONRYO):isSpawned()) then
if (player:getCharVar("OkuriNMKilled") >= 1 and player:needToZone()) then
player:delKeyItem(dsp.ki.YOMOTSU_HIRASAKA);
player:addKeyItem(dsp.ki.FADED_YOMOTSU_HIRASAKA);
player:messageSpecial(ID.text.KEYITEM_OBTAINED,dsp.ki.FADED_YOMOTSU_HIRASAKA);
player:setCharVar("OkuriNMKilled",0);
else
player:startEvent(10);
end
else
player:messageSpecial(ID.text.NOTHING_OUT_OF_ORDINARY);
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 10 and option == 1) then
player:needToZone(true); -- If you zone, you will need to repeat the fight.
player:setCharVar("OkuriNMKilled",0);
SpawnMob(ID.mob.DOMAN):updateClaim(player);
SpawnMob(ID.mob.ONRYO):updateClaim(player);
end
end;
| gpl-3.0 |
Suprcheese/Red-Alerts | config.lua | 1 | 1680 | -- Choose which announcer voice you would like. Your options are:
--
-- "CommandAndConquer" - the original C&C from 1995.
-- "RedAlert" - C&C: Red Alert from 1996
-- "TiberianSunEVA" - C&C: Tiberian Sun EVA
-- "TiberianSunCABAL" - C&C: Tiberian Sun CABAL
-- "SFX_daydev" - non-verbal sound notifications (probably, not very good)
voiceStyle = "CommandAndConquer"
-- This controls the minimum time between consecutive voiced alerts.
-- The value is measured in gameticks; there are 60 ticks per second, so the default 300 ticks would be 5 seconds.
minTicksBetweenAlerts = 300
-- Here you can enable/disable each category of alerts
-- Note that "Structure destroyed" plays when a building-type entity is destroyed, while "Unit lost" plays when a non-structure entity such as a combat robot is destroyed.
lowPowerWarning = true
playerJoinedGameAlert = true
unitLostAlert = true
structureDestroyedAlert = true
-- Choose whether or not to show the "Dismiss Low Power Warning?" dialog.
showSnoozePopup = true
-- This is how many seconds the Low Power warning will be suppressed when you choose to dismiss it.
snoozeSeconds = 60
-- This table enumerates all entity-types that are considered "units" and trigger the "Unit Lost" voice clip when destroyed, rather than "Structure Destroyed".
unitEntityTypes = {}
unitEntityTypes["unit"] = true
unitEntityTypes["car"] = true
unitEntityTypes["cargo-wagon"] = true
unitEntityTypes["combat-robot"] = true
unitEntityTypes["construction-robot"] = true
unitEntityTypes["logistic-robot"] = true
unitEntityTypes["locomotive"] = true
unitEntityTypes["player"] = true
| mit |
arsjac/DotaClassic | game/dota_addons/dotaclassic/scripts/vscripts/meteor.lua | 1 | 6616 | --adapted by arsjac from original code by:
--[[ ============================================================================================================
Author: Rook
Date: April 06, 2015
Called when Chaos Meteor is cast.
Additional parameters: keys.LandTime, keys.TravelSpeed, keys.VisionDistance, keys.EndVisionDuration, and
keys.BurnDuration
================================================================================================================= ]]
function meteor_datadriven_on_spell_start(keys)
local ability = keys.ability
local ability_level = ability:GetLevel() - 1
local caster_point = keys.caster:GetAbsOrigin()
local target_point = keys.target_points[1]
local caster_point_temp = Vector(caster_point.x, caster_point.y, 0)
local target_point_temp = Vector(target_point.x, target_point.y, 0)
local point_difference_normalized = (target_point_temp - caster_point_temp):Normalized()
local velocity_per_second = point_difference_normalized * keys.TravelSpeed
local travel_distance = 100
keys.caster:EmitSound("Hero_Invoker.ChaosMeteor.Cast")
keys.caster:EmitSound("Hero_Invoker.ChaosMeteor.Loop")
--Create a particle effect consisting of the meteor falling from the sky and landing at the target point.
local meteor_fly_original_point = (target_point - (velocity_per_second * keys.LandTime)) + Vector (0, 0, 1000) --Start the meteor in the air in a place where it'll be moving the same speed when flying and when rolling.
local chaos_meteor_fly_particle_effect = ParticleManager:CreateParticle("particles/units/heroes/hero_invoker/invoker_chaos_meteor_fly.vpcf", PATTACH_ABSORIGIN, keys.caster)
ParticleManager:SetParticleControl(chaos_meteor_fly_particle_effect, 0, meteor_fly_original_point)
ParticleManager:SetParticleControl(chaos_meteor_fly_particle_effect, 1, target_point)
ParticleManager:SetParticleControl(chaos_meteor_fly_particle_effect, 2, Vector(1.3, 0, 0))
--Spawn the rolling meteor after the delay.
Timers:CreateTimer({
endTime = keys.LandTime,
callback = function()
--Create a dummy unit will follow the path of the meteor, providing flying vision, sound, damage, etc.
local chaos_meteor_dummy_unit = CreateUnitByName("npc_dummy_unit", target_point, false, nil, nil, keys.caster:GetTeam())
chaos_meteor_dummy_unit:AddAbility("meteor_datadriven")
local chaos_meteor_unit_ability = chaos_meteor_dummy_unit:FindAbilityByName("meteor_datadriven")
if chaos_meteor_unit_ability ~= nil then
chaos_meteor_unit_ability:SetLevel(1)
chaos_meteor_unit_ability:ApplyDataDrivenModifier(chaos_meteor_dummy_unit, chaos_meteor_dummy_unit, "meteor_datadriven_unit_ability", {duration = -1})
end
keys.caster:StopSound("Hero_Invoker.ChaosMeteor.Loop")
chaos_meteor_dummy_unit:EmitSound("Hero_Invoker.ChaosMeteor.Impact")
chaos_meteor_dummy_unit:EmitSound("Hero_Invoker.ChaosMeteor.Loop") --Emit a sound that will follow the meteor.
--IMPACT
local area_of_effect = ability:GetLevelSpecialValueFor("area_of_effect", ability_level)
local meteor_damage = ability:GetLevelSpecialValueFor("meteor_damage", ability_level)
local target_teams = ability:GetAbilityTargetTeam()
local target_types = ability:GetAbilityTargetType()
local target_flags = ability:GetAbilityTargetFlags()
local found_targets = FindUnitsInRadius(keys.caster:GetTeamNumber(), target_point, nil, area_of_effect, target_teams, target_types, target_flags, FIND_CLOSEST, false)
local damage_table = {}
damage_table.attacker = keys.caster
damage_table.ability = ability
damage_table.damage_type = ability:GetAbilityDamageType()
damage_table.damage = meteor_damage
for _, unit in pairs(found_targets) do
damage_table.victim = unit
ApplyDamage(damage_table)
end
--
chaos_meteor_dummy_unit:SetDayTimeVisionRange(keys.VisionDistance)
chaos_meteor_dummy_unit:SetNightTimeVisionRange(keys.VisionDistance)
chaos_meteor_dummy_unit.invoker_chaos_meteor_parent_caster = keys.caster
local chaos_meteor_duration = travel_distance / keys.TravelSpeed
local chaos_meteor_velocity_per_frame = velocity_per_second * .03
--It would seem that the Chaos Meteor projectile needs to be attached to a particle in order to move and roll and such.
local projectile_information =
{
EffectName = "particles/units/heroes/hero_invoker/invoker_chaos_meteor.vpcf",
Ability = chaos_meteor_unit_ability,
vSpawnOrigin = target_point,
fDistance = travel_distance,
fStartRadius = 0,
fEndRadius = 0,
Source = chaos_meteor_dummy_unit,
bHasFrontalCone = false,
iMoveSpeed = keys.TravelSpeed,
bReplaceExisting = false,
bProvidesVision = true,
iVisionTeamNumber = keys.caster:GetTeam(),
iVisionRadius = keys.VisionDistance,
bDrawsOnMinimap = false,
bVisibleToEnemies = true,
iUnitTargetTeam = DOTA_UNIT_TARGET_TEAM_NONE,
iUnitTargetFlags = DOTA_UNIT_TARGET_FLAG_NONE,
iUnitTargetType = DOTA_UNIT_TARGET_NONE ,
fExpireTime = GameRules:GetGameTime() + chaos_meteor_duration + keys.EndVisionDuration,
}
projectile_information.vVelocity = velocity_per_second
local chaos_meteor_projectile = ProjectileManager:CreateLinearProjectile(projectile_information)
-- chaos_meteor_unit_ability:ApplyDataDrivenModifier(chaos_meteor_dummy_unit, chaos_meteor_dummy_unit, "modifier_invoker_chaos_meteor_datadriven_main_damage", nil)
--Adjust the dummy unit's position every frame.
local endTime = GameRules:GetGameTime() + chaos_meteor_duration
Timers:CreateTimer({
callback = function()
chaos_meteor_dummy_unit:SetAbsOrigin(chaos_meteor_dummy_unit:GetAbsOrigin() + chaos_meteor_velocity_per_frame)
if GameRules:GetGameTime() > endTime then
--Stop the sound, particle, and damage when the meteor disappears.
chaos_meteor_dummy_unit:StopSound("Hero_Invoker.ChaosMeteor.Loop")
chaos_meteor_dummy_unit:StopSound("Hero_Invoker.ChaosMeteor.Destroy")
-- chaos_meteor_dummy_unit:RemoveModifierByName("modifier_invoker_chaos_meteor_datadriven_main_damage")
--Have the dummy unit linger in the position the meteor ended up in, in order to provide vision.
Timers:CreateTimer({
endTime = keys.EndVisionDuration,
callback = function()
chaos_meteor_dummy_unit:SetDayTimeVisionRange(0)
chaos_meteor_dummy_unit:SetNightTimeVisionRange(0)
chaos_meteor_dummy_unit:RemoveSelf()
end
})
return
else
return .03
end
end
})
end
})
end | gpl-3.0 |
cmusatyalab/openface | training/util.lua | 8 | 2973 | -- Source: https://github.com/soumith/imagenet-multiGPU.torch/blob/master/util.lua
local ffi=require 'ffi'
------ Some FFI stuff used to pass storages between threads ------------------
ffi.cdef[[
void THFloatStorage_free(THFloatStorage *self);
void THLongStorage_free(THLongStorage *self);
]]
local function setFloatStorage(tensor, storage_p)
assert(storage_p and storage_p ~= 0, "FloatStorage is NULL pointer");
local cstorage = ffi.cast('THFloatStorage*', torch.pointer(tensor:storage()))
if cstorage ~= nil then
ffi.C['THFloatStorage_free'](cstorage)
end
local storage = ffi.cast('THFloatStorage*', storage_p)
tensor:cdata().storage = storage
end
local function setLongStorage(tensor, storage_p)
assert(storage_p and storage_p ~= 0, "LongStorage is NULL pointer");
local cstorage = ffi.cast('THLongStorage*', torch.pointer(tensor:storage()))
if cstorage ~= nil then
ffi.C['THLongStorage_free'](cstorage)
end
local storage = ffi.cast('THLongStorage*', storage_p)
tensor:cdata().storage = storage
end
function sendTensor(inputs)
local size = inputs:size()
local ttype = inputs:type()
local i_stg = tonumber(ffi.cast('intptr_t', torch.pointer(inputs:storage())))
inputs:cdata().storage = nil
return {i_stg, size, ttype}
end
function receiveTensor(obj, buffer)
local pointer = obj[1]
local size = obj[2]
local ttype = obj[3]
if buffer then
buffer:resize(size)
assert(buffer:type() == ttype, 'Buffer is wrong type')
else
buffer = torch[ttype].new():resize(size)
end
if ttype == 'torch.FloatTensor' then
setFloatStorage(buffer, pointer)
elseif ttype == 'torch.LongTensor' then
setLongStorage(buffer, pointer)
else
error('Unknown type')
end
return buffer
end
--Reduce the memory consumption by model by sharing the buffers
function optimizeNet( model, inputSize )
local optnet_loaded, optnet = pcall(require,'optnet')
if optnet_loaded then
local opts = {inplace=true, mode='training', removeGradParams=false}
local input = torch.rand(2,3,inputSize,inputSize)
if opt.cuda then
input = input:cuda()
end
optnet.optimizeMemory(model, input, opts)
else
print("'optnet' package not found, install it to reduce the memory consumption.")
print("Repo: https://github.com/fmassa/optimize-net")
end
end
function makeDataParallel(model, nGPU)
-- Wrap the model with DataParallelTable, if using more than one GPU
if nGPU > 1 then
local gpus = torch.range(1, nGPU):totable()
local fastest, benchmark = cudnn.fastest, cudnn.benchmark
local dpt = nn.DataParallelTable(1, true, true)
:add(model, gpus)
:threads(function()
require ("dpnn")
local cudnn = require 'cudnn'
cudnn.fastest, cudnn.benchmark = fastest, benchmark
end)
dpt.gradInput = nil
model = dpt:cuda()
end
return model
end
| apache-2.0 |
ralucah/splay-daemon-lua5.2 | settings.lua | 1 | 2722 | --[[
Splay ### v1.2 ###
Copyright 2006-2011
http://www.splay-project.org
]]
--[[
This file is part of Splay.
Splay is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
Splay is distributed in the hope that it will be useful,but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Splayd. If not, see <http://www.gnu.org/licenses/>.
]]
-- Splayd settings, can't be changed by Controller
-- Controller will ask for them.
-- Default values are in splayd.lua
--[[ DO YOUR SETTINGS CHANGE HERE ]]--
splayd.settings.key = "local" -- received at the registration
splayd.settings.name = "my name"
splayd.settings.controller.ip = "localhost"
splayd.settings.controller.port = 11000
-- Set wether you want to be able to support native libs
splayd.settings.protocol = "grid"
-- all sizes are in bytes
splayd.settings.job.max_number = 16
splayd.settings.job.max_mem = 12 * 1024 * 1024 -- 12 Mo
splayd.settings.job.disk.max_size = 1024 * 1024 * 1024 -- 1 Go
splayd.settings.job.disk.max_files = 1024
splayd.settings.job.disk.max_file_descriptors = 64
splayd.settings.job.network.max_send = 1024 * 1024 * 1024
splayd.settings.job.network.max_receive = 1024 * 1024 * 1024
splayd.settings.job.network.max_sockets = 64
splayd.settings.job.network.max_ports = 2
splayd.settings.job.network.start_port = 22000
splayd.settings.job.network.end_port = 32000
-- Information about your connection (or your limitations)
-- Enforce them with trickle or other tools
splayd.settings.network.send_speed = 1024 * 1024
splayd.settings.network.receive_speed = 1024 * 1024
--[[ NOTES ABOUT LIMITATIONS
The network.max_send and network.max_receive settings don't directly limit your
bandwith. They only avoid a job to do something weird. But when a job finish,
it can be quickly replaced by a new one. And each one will have again the same
limitations. So, jobs can use a lot of bandwith if their lifetime is short.
The true way to protect you is using an external bandwith management (QoS) like
'trickle' on unixes that permit you to set limits. Then, put the speed
limitations you have choosed in network.send_speed and network.receive_speed.
CPU limitations are not enforced by splayd, but you can give a low priority to
the process using the 'nice' command.
--]]
print("Edit settings.lua and comment out or remove these 2 lines...")
os.exit()
| gpl-3.0 |
mehrpouya81/gamermir | plugins/invite.lua | 10 | 2350 | --[[
Invite other user to the chat group.
Use !invite 1234567890 (where 1234567890 is id_number) to invite a user by id_number.
This is the most reliable method.
Use !invite @username to invite a user by @username.
Less reliable. Some users don't have @username.
Use !invite Type print_name Here to invite a user by print_name.
Unreliable. Avoid if possible.
]]--
do
-- Think it's kind of useless. Just to suppress '*** lua: attempt to call a nil value'
local function callback(extra, success, result)
if success == 1 and extra ~= false then
return extra.text
else
return send_large_msg(chat, "Can't invite user to this group.")
end
end
local function resolve_username(extra, success, result)
if success == 1 then
chat_add_user(extra.chat, 'user#id'..result.id, callback, false)
return extra.text
else
return send_large_msg(extra.chat, "Can't invite user to this group.")
end
end
local function action_by_reply(extra, success, result)
if success == 1 then
chat_add_user('chat#id'..result.to.id, 'user#id'..result.from.id, callback, false)
else
return send_large_msg('chat#id'..result.to.id, "Can't invite user to this group.")
end
end
local function run(msg, matches)
local receiver = get_receiver(msg)
local text = "Add: "..matches[1].." to "..receiver
if is_chat_msg(msg) then
if msg.reply_id and msg.text == "!invite" then
msgr = get_message(msg.reply_id, action_by_reply, {msg=msg})
end
if string.match(matches[1], '^%d+$') then
chat_add_user(receiver, 'user#id'..matches[1], callback, {chat=receiver, text=text})
elseif string.match(matches[1], '^@.+$') then
msgr = res_user(string.gsub(matches[1], '@', ''), resolve_username, {chat=receiver, text=text})
else
chat_add_user(receiver, string.gsub(matches[1], ' ', '_'), callback, {chat=receiver, text=text})
end
else
return 'This isnt a chat group!'
end
end
return {
description = 'Invite other user to the chat group.',
usage = {
-- Need space in front of this, so bot won't consider it as a command
' !invite [id|user_name|name]'
},
patterns = {
"^!invite$",
"^!invite (.*)$",
"^!invite (%d+)$"
},
run = run,
moderated = true
}
end
| gpl-2.0 |
dcourtois/premake-core | src/base/string.lua | 16 | 1838 | --
-- string.lua
-- Additions to Lua's built-in string functions.
-- Copyright (c) 2002-2013 Jason Perkins and the Premake project
--
--
-- Capitalize the first letter of the string.
--
function string.capitalized(self)
return self:gsub("^%l", string.upper)
end
--
-- Returns true if the string has a match for the plain specified pattern
--
function string.contains(s, match)
return string.find(s, match, 1, true) ~= nil
end
--
-- Returns an array of strings, each of which is a substring of s
-- formed by splitting on boundaries formed by `pattern`.
--
function string.explode(s, pattern, plain, maxTokens)
if (pattern == '') then return false end
local pos = 0
local arr = { }
for st,sp in function() return s:find(pattern, pos, plain) end do
table.insert(arr, s:sub(pos, st-1))
pos = sp + 1
if maxTokens ~= nil and maxTokens > 0 then
maxTokens = maxTokens - 1
if maxTokens == 0 then
break
end
end
end
table.insert(arr, s:sub(pos))
return arr
end
--
-- Find the last instance of a pattern in a string.
--
function string.findlast(s, pattern, plain)
local curr = 0
repeat
local next = s:find(pattern, curr + 1, plain)
if (next) then curr = next end
until (not next)
if (curr > 0) then
return curr
end
end
--
-- Returns the number of lines of text contained by the string.
--
function string.lines(s)
local trailing, n = s:gsub('.-\n', '')
if #trailing > 0 then
n = n + 1
end
return n
end
---
-- Return a plural version of a string.
---
function string:plural()
if self:endswith("y") then
return self:sub(1, #self - 1) .. "ies"
else
return self .. "s"
end
end
---
-- Returns the string escaped for Lua patterns.
---
function string.escapepattern(s)
return s:gsub("[%(%)%.%%%+%-%*%?%[%]%^%$]", "%%%0")
end
| bsd-3-clause |
dacrybabysuck/darkstar | scripts/globals/spells/silencega.lua | 12 | 1342 | -----------------------------------------
-- Spell: Silence
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/magic")
require("scripts/globals/msg")
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0
end
function onSpellCast(caster,target,spell)
local effectType = dsp.effect.SILENCE
if (target:hasStatusEffect(effectType)) then
spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT) -- no effect
return effectType
end
--Pull base stats.
local dMND = (caster:getStat(dsp.mod.MND) - target:getStat(dsp.mod.MND))
--Duration, including resistance. May need more research.
local duration = 120
--Resist
local params = {}
params.diff = nil
params.attribute = dsp.mod.MND
params.skillType = 35
params.bonus = 0
params.effect = dsp.effect.SILENCE
local resist = applyResistanceEffect(caster, target, spell, params)
if (resist >= 0.5) then --Do it!
if (target:addStatusEffect(effectType,1,0,duration * resist)) then
spell:setMsg(dsp.msg.basic.MAGIC_ENFEEB_IS)
else
spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT) -- no effect
end
else
spell:setMsg(dsp.msg.basic.MAGIC_RESIST)
end
return effectType
end
| gpl-3.0 |
AbolDalton/Abolbot | plugins/setbye.lua | 7 | 2274 | do
local function run(msg, matches, callback, extra)
local data = load_data(_config.moderation.data)
local rules = data[tostring(msg.to.id)]['rules']
local about = data[tostring(msg.to.id)]['description']
local hash = 'group:'..msg.to.id
local group_bye = redis:hget(hash,'bye')
if matches[1] == 'delbye' and not matches[2] and is_owner(msg) then
redis:hdel(hash,'welcome')
return 'Bye Text Cleaned'
end
local url , res = http.request('http://api.gpmod.ir/time/')
if res ~= 200 then return "No connection" end
local jdat = json:decode(url)
if matches[1] == 'setbye' and is_owner(msg) then
redis:hset(hash,'bye',matches[2])
return 'Bye Text Changed To : ✋\n'..matches[2]
end
if matches[1] == 'chat_del_user' and msg.service then
group_bye = string.gsub(group_bye, '{gpname}', msg.to.title)
group_bye = string.gsub(group_bye, '{firstname}', ""..(msg.action.user.first_name or '').."")
group_bye = string.gsub(group_bye, '{lastname}', ""..(msg.action.user.last_name or '').."")
group_bye = string.gsub(group_bye, '{username}', "@"..(msg.action.user.username or '').."")
group_bye = string.gsub(group_bye, '{fatime}', ""..(jdat.FAtime).."")
group_bye = string.gsub(group_bye, '{entime}', ""..(jdat.ENtime).."")
group_bye = string.gsub(group_bye, '{fadate}', ""..(jdat.FAdate).."")
group_bye = string.gsub(group_bye, '{endate}', ""..(jdat.ENdate).."")
group_bye = string.gsub(group_bye, '{نام گروه}', msg.to.title)
group_bye = string.gsub(group_bye, '{نام اول}', ""..(msg.action.user.first_name or '').."")
group_bye = string.gsub(group_bye, '{نام آخر}', ""..(msg.action.user.last_name or '').."")
group_bye = string.gsub(group_bye, '{نام کاربری}', "@"..(msg.action.user.username or '').."")
group_bye = string.gsub(group_bye, '{ساعت فارسی}', ""..(jdat.FAtime).."")
group_bye = string.gsub(group_bye, '{ساعت انگلیسی}', ""..(jdat.ENtime).."")
group_bye = string.gsub(group_bye, '{تاریخ فارسی}', ""..(jdat.FAdate).."")
group_bye = string.gsub(group_bye, '{تاریخ انگلیسی}', ""..(jdat.ENdate).."")
end
return group_bye
end
return {
patterns = {
"^[!#/](setbye) +(.*)$",
"^[!#/](delbye)$",
"^!!tgservice (chat_del_user)$",
},
run = run
}
end
| gpl-2.0 |
dacrybabysuck/darkstar | scripts/zones/Crawlers_Nest/mobs/Aqrabuamelu.lua | 11 | 1468 | -----------------------------------
-- Area: Crawlers' Nest
-- NM: Aqrabuamelu
-----------------------------------
require("scripts/globals/status")
require("scripts/globals/magic")
require("scripts/globals/msg")
-----------------------------------
function onMobInitialize(mob)
mob:setMobMod(dsp.mobMod.AUTO_SPIKES, 1)
mob:addStatusEffect(dsp.effect.ICE_SPIKES, 45, 0, 0)
mob:getStatusEffect(dsp.effect.ICE_SPIKES):setFlag(dsp.effectFlag.DEATH)
end
function onSpikesDamage(mob, target, damage)
local INT_diff = mob:getStat(dsp.mod.INT) - target:getStat(dsp.mod.INT)
if INT_diff > 20 then
INT_diff = 20 + (INT_diff - 20) * 0.5 -- INT above 20 is half as effective.
end
local dmg = (damage + INT_diff) * 0.5 -- INT adjustment and base damage averaged together.
local params = {}
params.bonusmab = 0
params.includemab = false
dmg = addBonusesAbility(mob, dsp.magic.ele.ICE, target, dmg, params)
dmg = dmg * applyResistanceAddEffect(mob, target, dsp.magic.ele.ICE, 0)
dmg = adjustForTarget(target, dmg, dsp.magic.ele.ICE)
dmg = finalMagicNonSpellAdjustments(mob, target, dsp.magic.ele.ICE, dmg)
if dmg < 0 then
dmg = 0
end
return dsp.subEffect.ICE_SPIKES, dsp.msg.basic.SPIKES_EFFECT_DMG, dmg
end
function onMobDeath(mob, player, isKiller)
end
function onMobDespawn(mob)
UpdateNMSpawnPoint(mob:getID())
mob:setRespawnTime(math.random(7200, 7800)) -- 120 to 130 min
end | gpl-3.0 |
NielsH/FindYourHealers | Libs/GeminiGUI/examples/Demo/GeminiGUI.lua | 6 | 46270 | -----------------------------------------------------------------------------------------------------------------------
-- GeminiGUI
-- Formerly DaiGUI
-- @author daihenka
-- GUI Widget Creation Library for WildStar.
-----------------------------------------------------------------------------------------------------------------------
local MAJOR, MINOR = "Gemini:GUI-1.0", 3
local Lib = Apollo.GetPackage("Gemini:GUI-1.0") and Apollo.GetPackage("Gemini:GUI-1.0").tPackage or {}
if Lib and (Lib._VERSION or 0) >= MINOR then
return -- no upgrade is needed
end
local assert, tostring, error, pcall = assert, tostring, error, pcall
local getmetatable, setmetatable, rawset, rawget, pairs = getmetatable, setmetatable, rawset, rawget, pairs
local type, next = type, next
Lib._VERSION = MINOR
Lib.WidgetRegistry = Lib.WidgetRegistry or {}
Lib.WidgetVersions = Lib.WidgetVersions or {}
-- local upvalues
local WidgetRegistry = Lib.WidgetRegistry
local WidgetVersions = Lib.WidgetVersions
-- Create a widget prototype object
-- @param strType (Optional) Widget type. If not provided it will look at tOptions for
-- a WidgetType value. If no widget type is found, defaults to "Window".
-- @param tOptions Options table for the widget (see below usages)
-- @returns (table) Widget Prototype Object
--
-- @usage
-- local btnProto = GeminiGUI:Create("PushButton", {
-- AnchorCenter = { 100, 30 },
-- Text = "Push Me",
-- Events = { ButtonSignal = function() Print("You pushed me!") end },
-- })
-- local wndBtn = btnProto:GetInstance()
--
-- @usage #2
-- local myEventHandler = { OnClick = function() Print("You pushed me!") end }
--
-- local btnProto = GeminiGUI:Create({
-- WidgetType = "PushButton",
-- AnchorCenter = { 100, 30 },
-- Text = "Push Me",
-- Events = { ButtonSignal = "OnClick" },
-- })
-- local wndBtn = btnProto:GetInstance(myEventHandler)
function Lib:Create(strType, tOptions)
-- check if passed a function to generate the tOptions
if type(strType) == "function" then
tOptions = strType()
strType = tOptions.WidgetType or "Window"
elseif type(strType) == "string" and type(tOptions) == "function" then
tOptions = tOptions()
strType = strType or tOptions.WidgetType or "Window"
-- check if passed a table without a strType
elseif type(strType) == "table" then
tOptions = strType
strType = tOptions.WidgetType or "Window"
end
if type(strType) ~= "string" then
error(("Usage: Create([strType,] tOptions): 'strType' - string expected got '%s'."):format(type(strType)), 2)
end
if type(tOptions) ~= "table" then
error(("Usage: Create([strType,] tOptions): 'tOptions' - table expected got '%s'."):format(type(tOptions)), 2)
end
-- check if tOptions is already a widget prototype
if tOptions.__IsGeminiGuiPrototype == true then
return tOptions
end
strType = strType or "Window"
-- if not, check if the widget type is valid
if WidgetRegistry[strType] then
-- create the widget
local widget = WidgetRegistry[strType]()
widget.WidgetVersion = WidgetVersions[strType]
if tOptions ~= nil and type(tOptions) == "table" then
widget:SetOptions(tOptions)
end
widget.__IsGeminiGuiPrototype = true
return widget
end
end
-- Register a widget constructor that will return a new prototype of the widget
-- @param strType Name of the widget
-- @param fnConstructor Widget constructor function
-- @param nVersion Version of the widget
function Lib:RegisterWidgetType(strType, fnConstructor, nVersion)
assert(type(fnConstructor) == "function")
assert(type(nVersion) == "number")
local oldVersion = WidgetVersions[strType]
if oldVersion and oldVersion >= nVersion then return end
WidgetVersions[strType] = nVersion
WidgetRegistry[strType] = fnConstructor
end
-- Return the version of the currently registered widget type
-- @param strType Name of the widget
-- @returns (number) Version of the widget
function Lib:GetWidgetVersion(strType)
return WidgetVersions[strType]
end
function Lib:OnLoad()
end
function Lib:OnDependencyError(strDep, strError)
return false
end
Apollo.RegisterPackage(Lib, MAJOR, MINOR, {})
--[[ Widgets ]]--
local GeminiGUI = Lib
--[[ File: widgets/ControlBase.lua ]]--
do
GeminiGUI.ControlBase = {}
local Control = GeminiGUI.ControlBase
local kstrDefaultName = "GeminiGUIControl"
local pairs, ipairs, type, unpack, error = pairs, ipairs, type, unpack, error
local setmetatable, tostring = setmetatable, tostring
local ktAnchorPoints = {
TOPLEFT = { 0, 0, 0, 0 },
TOPRIGHT = { 1, 0, 1, 0 },
BOTTOMLEFT = { 0, 1, 0, 1 },
BOTTOMRIGHT = { 1, 1, 1, 1 },
CENTER = { 0.5, 0.5, 0.5, 0.5 },
VCENTER = { 0, 0.5, 0, 0.5 },
HCENTER = { 0.5, 0, 0.5, 0 },
VCENTERRIGHT = { 1, 0.5, 1, 0.5 },
HCENTERBOTTOM = { 0.5, 1, 0.5, 1 },
FILL = { 0, 0, 1, 1 },
HFILL = { 0, 0, 1, 0 },
VFILL = { 0, 0, 0, 1 },
VFILLRIGHT = { 1, 0, 1, 1 },
HFILLBOTTOM = { 0, 1, 1, 1 },
}
local function TranslateAnchorPoint(s, tOptions, v)
if type(v) == "string" then
tOptions.LAnchorPoint, tOptions.TAnchorPoint, tOptions.RAnchorPoint, tOptions.BAnchorPoint = unpack(ktAnchorPoints[v])
elseif type(v) == "table" then
tOptions.LAnchorPoint, tOptions.TAnchorPoint, tOptions.RAnchorPoint, tOptions.BAnchorPoint = unpack(v)
end
end
local function SetupWhiteFillMe(self, tOptions, v)
if v ~= true then return end
tOptions.Picture = true
tOptions.Sprite = "ClientSprites:WhiteFill"
tOptions.BGColor = "white"
end
local kSpecialFields = {
AnchorOffsets = function(s, tOptions, v)
tOptions.LAnchorOffset, tOptions.TAnchorOffset, tOptions.RAnchorOffset, tOptions.BAnchorOffset = unpack(v)
end,
AnchorPoints = TranslateAnchorPoint,
Anchor = TranslateAnchorPoint,
IncludeEdgeAnchors = function(s, tOptions, v)
if type(v) ~= "string" and (s.options.Name == nil or string.len(s.options.Name) == 0) then
error("IncludeEdgeAnchors requires a string or the control name to be set", 2)
end
local strPrefix = ((type(v) == "string") and v or s.options.Name)
tOptions.LeftEdgeControlsAnchor, tOptions.TopEdgeControlsAnchor, tOptions.RightEdgeControlsAnchor, tOptions.BottomEdgeControlsAnchor = strPrefix .. "_Left", strPrefix .. "_Top", strPrefix .. "_Right", strPrefix .. "_Bottom"
end,
AnchorCenter = function(s, tOptions, v)
if type(v) ~= "table" or #v ~= 2 then return end
local nWidth, nHeight = unpack(v)
tOptions.LAnchorPoint, tOptions.TAnchorPoint, tOptions.RAnchorPoint, tOptions.BAnchorPoint = unpack(ktAnchorPoints["CENTER"])
tOptions.LAnchorOffset, tOptions.TAnchorOffset, tOptions.RAnchorOffset, tOptions.BAnchorOffset = nWidth / 2 * -1, nHeight / 2 * -1, nWidth / 2, nHeight / 2
end,
AnchorFill = function(s, tOptions, v)
local nPadding = (type(v) == "number") and v or 0
tOptions.LAnchorPoint, tOptions.TAnchorPoint, tOptions.RAnchorPoint, tOptions.BAnchorPoint = unpack(ktAnchorPoints["FILL"])
tOptions.LAnchorOffset, tOptions.TAnchorOffset, tOptions.RAnchorOffset, tOptions.BAnchorOffset = nPadding, nPadding, -nPadding, -nPadding
end,
PosSize = function(s, tOptions, v)
if type(v) ~= "table" or #v ~= 4 then return end
local nLeft, nTop, nWidth, nHeight = unpack(v)
tOptions.LAnchorPoint, tOptions.TAnchorPoint, tOptions.RAnchorPoint, tOptions.BAnchorPoint = unpack(ktAnchorPoints["TOPLEFT"])
tOptions.LAnchorOffset, tOptions.TAnchorOffset, tOptions.RAnchorOffset, tOptions.BAnchorOffset = nLeft, nTop, nLeft + nWidth, nTop + nHeight
end,
UserData = function(s, tOptions, v)
s:SetData(v)
end,
LuaData = function(s, tOptions, v)
s:SetData(v)
end,
Events = function(s, tOptions, v)
if type(v) == "table" then
for strEventName, oHandler in pairs(v) do
if type(strEventName) == "number" and type(oHandler) == "table" then -- handle the old style
s:AddEvent(unpack(oHandler))
elseif type(strEventName) == "string" and (type(oHandler) == "string" or type(oHandler) == "function") then
s:AddEvent(strEventName, oHandler)
end
end
end
end,
Pixies = function(s, tOptions, v)
if type(v) == "table" then
for _, tPixie in ipairs(v) do
s:AddPixie(tPixie)
end
end
end,
Children = function(s, tOptions, v)
if type(v) == "table" then
for _, tChild in ipairs(v) do
local strWidgetType = "Window"
if type(tChild.WidgetType) == "string" then
strWidgetType = tChild.WidgetType
end
s:AddChild(GeminiGUI:Create(strWidgetType, tChild))
end
end
end,
}
function Control:new(o)
o = o or {}
o.events = {}
o.children = {}
o.pixies = {}
o.options = {}
setmetatable(o, self)
self.__index = self
return o
end
-- Set an option on the widget prototype
-- @param strOptionName the option name
-- @param value the value to set
function Control:SetOption(key, value)
self.options[key] = value
end
-- Set multiple options on the widget prototype
-- @param tOptions the options table
function Control:SetOptions(tOptions)
for k,v in pairs(tOptions) do
self.options[k] = v
end
end
-- pixie mapping table
local ktPixieMapping = {
strText = "Text",
strFont = "Font",
bLine = "Line",
fWidth = "Width",
strSprite = "Sprite",
cr = "BGColor",
crText = "TextColor",
fRotation = "Rotation",
strTextId = "TextId",
nTextId = "TextId",
loc = { fPoints = "AnchorPoints", nOffsets = "AnchorOffsets" },
flagsText = { DT_CENTER = "DT_CENTER", DT_VCENTER = "DT_VCENTER", DT_RIGHT = "DT_RIGHT", DT_BOTTOM = "DT_BOTTOM",
DT_WORDBREAK = "DT_WORDBREAK", DT_SINGLELINE = "DT_SINGLELINE" },
}
-- Add a pixie to the widget prototype
-- @param tPixie a table with pixie options
function Control:AddPixie(tPixie)
if tPixie == nil then return end
-- in case someone uses the C++ Window:AddPixie() format. Preference to the XML format over the C++ Window:AddPixie() format.
for oldKey, newKey in pairs(ktPixieMapping) do
if tPixie[oldKey] ~= nil then
if type(tPixie[oldKey]) == "table" then
for oldKey2, newKey2 in pairs(tPixie[oldKey]) do
if tPixie[oldKey][oldKey2] ~= nil then
tPixie[newKey2] = tPixie[newKey2] or tPixie[oldKey][oldKey2]
end
end
else
tPixie[newKey] = tPixie[newKey] or tPixie[oldKey]
end
end
end
if type(tPixie.AnchorOffsets) == "table" then
tPixie.LAnchorOffset, tPixie.TAnchorOffset, tPixie.RAnchorOffset, tPixie.BAnchorOffset = unpack(tPixie.AnchorOffsets)
tPixie.AnchorOffsets = nil
end
if tPixie.AnchorPoints ~= nil or tPixie.Anchor ~= nil then
local tAnchorPoints = tPixie.AnchorPoints or tPixie.Anchor
if type(tAnchorPoints) == "string" then
tPixie.LAnchorPoint, tPixie.TAnchorPoint, tPixie.RAnchorPoint, tPixie.BAnchorPoint = unpack(ktAnchorPoints[tAnchorPoints])
else
tPixie.LAnchorPoint, tPixie.TAnchorPoint, tPixie.RAnchorPoint, tPixie.BAnchorPoint = unpack(tAnchorPoints)
end
tPixie.AnchorPoints = nil
tPixie.Anchor = nil
end
if tPixie.AnchorFill ~= nil then
tPixie.LAnchorPoint, tPixie.TAnchorPoint, tPixie.RAnchorPoint, tPixie.BAnchorPoint = unpack(ktAnchorPoints["FILL"])
if type(self.options.AnchorFill) == "number" then
local nPadding = tPixie.AnchorFill
tPixie.LAnchorOffset, tPixie.TAnchorOffset, tPixie.RAnchorOffset, tPixie.BAnchorOffset = nPadding, nPadding, -nPadding, -nPadding
elseif type(self.options.AnchorFill) == "boolean" then
tPixie.LAnchorOffset, tPixie.TAnchorOffset, tPixie.RAnchorOffset, tPixie.BAnchorOffset = 0,0,0,0
end
tPixie.AnchorFill = nil
end
if type(tPixie.AnchorCenter) == "table" then
local nWidth, nHeight = unpack(tPixie.AnchorCenter)
tPixie.LAnchorPoint, tPixie.TAnchorPoint, tPixie.RAnchorPoint, tPixie.BAnchorPoint = unpack(ktAnchorPoints["CENTER"])
tPixie.LAnchorOffset, tPixie.TAnchorOffset, tPixie.RAnchorOffset, tPixie.BAnchorOffset = nWidth / 2 * -1, nHeight / 2 * -1, nWidth / 2, nHeight / 2
tPixie.AnchorCenter = nil
end
if type(tPixie.PosSize) == "table" then
local nLeft, nTop, nWidth, nHeight = unpack(tPixie.PosSize)
tPixie.LAnchorPoint, tPixie.TAnchorPoint, tPixie.RAnchorPoint, tPixie.BAnchorPoint = unpack(ktAnchorPoints["TOPLEFT"])
tPixie.LAnchorOffset, tPixie.TAnchorOffset, tPixie.RAnchorOffset, tPixie.BAnchorOffset = nLeft, nTop, nLeft + nWidth, nTop + nHeight
tPixie.PosSize = nil
end
tPixie.LAnchorOffset = tPixie.LAnchorOffset or 0
tPixie.RAnchorOffset = tPixie.RAnchorOffset or 0
tPixie.TAnchorOffset = tPixie.TAnchorOffset or 0
tPixie.BAnchorOffset = tPixie.BAnchorOffset or 0
tPixie.LAnchorPoint = tPixie.LAnchorPoint or 0
tPixie.RAnchorPoint = tPixie.RAnchorPoint or 0
tPixie.TAnchorPoint = tPixie.TAnchorPoint or 0
tPixie.BAnchorPoint = tPixie.BAnchorPoint or 0
-- ensure that pixie booleans are properly converted to 1/0
for k,v in pairs(tPixie) do
if type(v) == "boolean" then
tPixie[k] = v and "1" or "0"
end
end
table.insert(self.pixies, tPixie)
end
-- Add a child widget prototype to the widget prototype
-- @param tChild The child widget to add -- NOTE: Must be a GeminiGUI:Create() blessed prototype
function Control:AddChild(tChild)
if tChild == nil then return end
table.insert(self.children, tChild)
end
-- Add an event handler to the widget prototype
-- @param strName The event name to be handled
-- @param strFunction (Optional) The function name on the event handler table
-- @param fnInline (Optional) The anonymous function to handle the event
--
-- @usage myPrototype:AddEvent("ButtonSignal", "OnButtonClick") -- when the event is fired, it will call OnButtonClick on the event handler table
-- @usage myPrototype:AddEvent("ButtonSignal", function() Print("Clicked!") end) -- when the event is fired, the anonymous function will be called
function Control:AddEvent(strName, strFunction, fnInline)
if type(strFunction) == "function" then
fnInline = strFunction
strFunction = "On" .. strName .. tostring(fnInline):gsub("function: ", "_")
end
table.insert(self.events, {strName = strName, strFunction = strFunction, fnInline = fnInline })
end
-- Set the data the widget is to store
-- @param oData the lua data object
function Control:SetData(oData)
self.oData = oData
end
-- Parses the options table for the widget
-- Internal use only
function Control:ParseOptions()
local tOptions = {}
for k, fn in pairs(kSpecialFields) do
if self.options[k] ~= nil then
fn(self, tOptions, self.options[k])
end
end
for k,v in pairs(self.options) do
if not kSpecialFields[k] or k == "WhiteFillMe" then
tOptions[k] = v
end
end
SetupWhiteFillMe(self, tOptions, self.options.WhiteFillMe) -- for debug purposes ;)
-- if picture hasn't been set but a sprite has been, enable picture
if tOptions.Sprite ~= nil and tOptions.Picture == nil then
tOptions.Picture = true
end
for k,v in pairs(tOptions) do
if type(v) == "boolean" then
tOptions[k] = v and "1" or "0"
end
end
return tOptions
end
-- Creates an XmlDoc Table of the widget prototype
function Control:ToXmlDocTable(bIsForm)
local tInlineFunctions = {}
local tForm = self:ParseOptions()
-- setup defaults and necessary values
tForm.__XmlNode = bIsForm and "Form" or "Control"
tForm.Font = tForm.Font or "Default"
tForm.Template = tForm.Template or "Default"
tForm.TooltipType = tForm.TooltipType or "OnCursor"
if not tForm.PosX or not tForm.PosY or not tForm.Height or not tForm.Width then
tForm.TAnchorOffset = tForm.TAnchorOffset or 0
tForm.LAnchorOffset = tForm.LAnchorOffset or 0
tForm.BAnchorOffset = tForm.BAnchorOffset or 0
tForm.RAnchorOffset = tForm.RAnchorOffset or 0
tForm.BAnchorPoint = tForm.BAnchorPoint or 0
tForm.RAnchorPoint = tForm.RAnchorPoint or 0
tForm.TAnchorPoint = tForm.TAnchorPoint or 0
tForm.LAnchorPoint = tForm.LAnchorPoint or 0
end
if self.AddSubclassFields ~= nil and type(self.AddSubclassFields) == "function" then
self:AddSubclassFields(tForm)
end
tForm.Name = tForm.Name or kstrDefaultName
tForm.Class = tForm.Class or "Window"
local tAliasEvents = {}
local tInlineLookup = {}
for _, tEvent in ipairs(self.events) do
if tEvent.strName and tEvent.strFunction and tEvent.strName ~= "" then
if tEvent.strFunction:match("^Event::") then
table.insert(tAliasEvents, tEvent)
elseif tEvent.strFunction ~= "" then
table.insert(tForm, { __XmlNode = "Event", Function = tEvent.strFunction, Name = tEvent.strName })
if tEvent.fnInline ~= nil then
tInlineLookup[tEvent.strName] = tEvent.strFunction
tInlineFunctions[tEvent.strFunction] = tEvent.fnInline
end
end
end
end
-- check if an event would like to reference an another event handler's inline function
for _, tEvent in ipairs(tAliasEvents) do
local strFunctionName = tInlineLookup[tEvent.strFunction:gsub("^Event::", "")]
if strFunctionName then
table.insert(tForm, { __XmlNode = "Event", Function = strFunctionName, Name = tEvent.strName })
end
end
for _, tPixie in ipairs(self.pixies) do
local tPixieNode = { __XmlNode = "Pixie", }
for k,v in pairs(tPixie) do
tPixieNode[k] = v
end
table.insert(tForm, tPixieNode)
end
for _, tChild in ipairs(self.children) do
if tChild.ToXmlDocTable and type(tChild.ToXmlDocTable) == "function" then
local tXd, tIf = tChild:ToXmlDocTable()
table.insert(tForm, tXd)
for k,v in pairs(tIf) do
tInlineFunctions[k] = tInlineFunctions[k] or v
end
end
end
if self.oData ~= nil then
tForm.__GEMINIGUI_LUADATA = self.oData
end
if bIsForm then
tForm = { __XmlNode = "Forms", tForm }
end
return tForm, tInlineFunctions
end
-- Collect window name, data and text from the XmlDoc table (recursively)
-- and give each window a unique name for it's layer
local kstrTempName = "GeminiGUIWindow."
local function CollectNameData(tXml, tData, strNamespace)
if type(tXml) ~= "table" then return end
local nCount = 0
tData = tData or {}
strNamespace = strNamespace or ""
for i, t in ipairs(tXml) do
if t.__XmlNode == "Control" then -- only process controls (aka children)
local strName = t.Name
local strNS = string.format("%s%s%s", strNamespace, strNamespace:len() > 0 and ":" or "", strName)
while (strName or "") == "" or tData[strNS] ~= nil do
-- window name already exists at this child depth, rename it temporarily
nCount = nCount + 1
strName = "GeminiGUIWindow." .. nCount
strNS = string.format("%s%s%s", strNamespace, strNamespace:len() > 0 and ":" or "", strName)
end
local strFinalName = t.Name or strName
-- collect the info for the window/control
tData[strNS] = { strNS = strNS, strName = strName, strFinalName = strFinalName, luaData = t.__GEMINIGUI_LUADATA, strText = t.Text, bIsMLWindow = t.Class == "MLWindow" }
-- rename the window to the unique layered name
t.Name = strName
-- clean up XmlDoc table by removing unnecessary elements
t.__GEMINIGUI_LUADATA = nil
CollectNameData(t, tData, strNS)
elseif t.__XmlNode == "Form" or t.__XmlNode == "Forms" then
CollectNameData(t, tData, "")
end
end
return tData
end
-- Process each window and it's children and assign data, AML
-- and rename the window back to what the consumer wants.
local function FinalizeWindow(wnd, tData)
-- collect a list of keys and sort them in order
-- of how deep they are overall (# of :) (>^o^)>
local tChildOrder = {}
for strNS, _ in pairs(tData) do
local _, nCount = strNS:gsub(":", "")
table.insert(tChildOrder, { strNS, nCount })
end
table.sort(tChildOrder, function(a,b) return a[2] > b[2] end)
-- process child windows in depth order, setting their data, AML and
-- renaming them back to what they are intended to be
for i = 1, #tChildOrder do
local tWndData = tData[tChildOrder[i][1]]
local wndChild = wnd:FindChild(tWndData.strNS)
if wndChild then
if tWndData.luaData then
wndChild:SetData(tWndData.luaData)
end
if tWndData.bIsMLWindow and tWndData.strText then
wndChild:SetAML(tWndData.strText)
end
if tWndData.strFinalName ~= tWndData.strName then
wndChild:SetName(tWndData.strFinalName)
end
end
end
end
-- Gets an instance of the widget
-- @param eventHandler The eventHandler of the widget
-- @param wndParent The parent of the widget
-- @returns (userdata) The userdata version of the widget
function Control:GetInstance(eventHandler, wndParent)
eventHandler = eventHandler or {}
if type(eventHandler) ~= "table" then
error("Usage: EventHandler is not valid. Must be a table.")
end
local xdt, tInlines = self:ToXmlDocTable(true)
for k,v in pairs(tInlines) do
eventHandler[k] = eventHandler[k] or v
end
-- collect names and reassign them to something generic
-- collect any lua data and if AML needs to be set
local tChildData = CollectNameData(xdt)
-- create the XmlDoc and C++ window
local xd = XmlDoc.CreateFromTable(xdt)
local strFormName = self.options.Name or kstrDefaultName
local wnd = Apollo.LoadForm(xd, strFormName, wndParent, eventHandler)
if wnd then
-- set the lua data and aml followed by name for all child widgets
FinalizeWindow(wnd, tChildData)
if self.oData then
wnd:SetData(self.oData)
end
else
-- Print("GeminiGUI failed to create window")
end
return wnd
end
end
--[[ File: widgets/Window.lua ]]--
do
local WidgetType, Version = "Window", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
Font = "Default",
Template = "Default",
TooltipType = "OnCursor",
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/Button.lua ]]--
do
local WidgetType, Version = "Button", 1
local Button = GeminiGUI.ControlBase:new()
local function GetTextTheme(strTheme)
return {
NormalTextColor = strTheme .. "Normal",
PressedTextColor = strTheme .. "Pressed",
PressedFlybyTextColor = strTheme .. "PressedFlyby",
FlybyTextColor = strTheme .. "Flyby",
DisabledTextColor = strTheme .. "Disabled"
}
end
local function GetTextColorTheme(strColor)
return {
NormalTextColor = strColor,
PressedTextColor = strColor,
PressedFlybyTextColor = strColor,
FlybyTextColor = strColor,
DisabledTextColor = strColor
}
end
function Button:SetTextThemeToColor(strColor)
self:SetOptions(GetTextColorTheme(strColor))
end
function Button:SetTextTheme(strTheme)
self:SetOptions(GetTextTheme(strTheme))
end
function Button:AddSubclassFields(tForm)
if self.options.TextThemeColor ~= nil then
local tTheme = GetTextColorTheme(self.options.TextThemeColor)
for k,v in pairs(tTheme) do
tForm[k] = v
end
if tForm.TextThemeColor ~= nil then
tForm.TextThemeColor = nil
end
end
if self.options.TextTheme ~= nil then
local tTheme = GetTextTheme(self.options.TextTheme)
for k,v in pairs(tTheme) do
tForm[k] = v
end
if tForm.TextTheme ~= nil then
tForm.TextTheme = nil
end
end
end
local function Constructor()
local ctrl = Button:new()
ctrl:SetOptions{
Name = "GeminiGUI" .. WidgetType,
Class = WidgetType,
ButtonType = "PushButton",
RadioGroup = "",
Font = "Thick",
DT_VCENTER = true,
DT_CENTER = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/PushButton.lua ]]--
do
local WidgetType, Version = "PushButton", 1
local function Constructor()
local btn = GeminiGUI:Create('Button', {
Name = "GeminiGUI" .. WidgetType,
ButtonType = "PushButton",
DT_VCENTER = true,
DT_CENTER = true,
Base = "CRB_Basekit:kitBtn_Holo",
Font = "CRB_InterfaceMedium",
})
btn:SetTextTheme("UI_BtnTextHolo")
return btn
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/Buzzer.lua ]]--
do
local WidgetType, Version = "Buzzer", 1
local function Constructor()
local btn = GeminiGUI:Create('Button', {
Name = "GeminiGUI" .. WidgetType,
ButtonType = "Buzzer",
DT_VCENTER = true,
DT_CENTER = true,
Base = "CRB_Basekit:kitBtn_Holo",
Font = "CRB_InterfaceMedium",
BuzzerFrequency = 15,
})
btn:SetTextTheme("UI_BtnTextHolo")
return btn
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/CheckBox.lua ]]--
do
local WidgetType, Version = "CheckBox", 1
local function Constructor()
local checkbox = GeminiGUI:Create('Button', {
Name = "GeminiGUI" .. WidgetType,
DrawAsCheckbox = true,
DT_CENTER = false,
DT_VCENTER = true,
ButtonType = "Check",
Font = "CRB_InterfaceMedium",
Base = "CRB_Basekit:kitBtn_Holo_RadioRound",
TextColor = "White",
})
return checkbox
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/ActionBarButton.lua ]]--
do
local WidgetType, Version = "ActionBarButton", 1
local function Constructor()
local btn = GeminiGUI.ControlBase:new()
btn:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Base = "ClientSprites:Button_ActionBarBlank",
RelativeToClient = true,
IfHoldNoSignal = true,
DT_VCENTER = true,
DT_CENTER = true,
NeverBringToFront = true,
WindowSoundTemplate = "ActionBarButton",
ProcessRightClick = true,
Font = "CRB_InterfaceLarge_O",
IgnoreTooltipDelay = true,
RechargeBarLAnchorPoint = 1,
RechargeBarLAnchorOffset = -8,
RechargeBarTAnchorPoint = 0,
RechargeBarTAnchorOffset = 4,
RechargeBarRAnchorPoint = 1,
RechargeBarRAnchorOffset = 4,
RechargeBarBAnchorPoint = 1,
RechargeBarBAnchorOffset = -14,
RechargeBarEmptyColorAttribute = "Black",
RechargeBarFullColorAttribute = "ffffffff",
RechargeBarEmptyAttribute = "WhiteFill",
RechargeBarFullAttribute = "sprStalker_VerticalGooPulse",
TooltipType = "DynamicFloater",
ShortHotkeyFontAttribute = "CRB_InterfaceLarge_BO",
LongHotkeyFontAttribute = "CRB_InterfaceSmall_O",
CountFontAttribute = "CRB_InterfaceSmall_O",
CooldownFontAttribute = "CRB_HeaderLarge",
}
return btn
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/TreeControl.lua ]]--
do
local WidgetType, Version = "TreeControl", 1
local function Constructor()
local wnd = GeminiGUI.ControlBase:new()
wnd:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Font = "CRB_Pixel",
Template = "CRB_Hologram",
UseTemplateBG = true,
Picture = true,
Border = true,
RelativeToClient = true,
}
return wnd
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/ComboBox.lua ]]--
do
local WidgetType, Version = "ComboBox", 1
local ComboBox = GeminiGUI.ControlBase:new()
function ComboBox:AddSubclassFields(tForm)
if self.options.UseTheme == true then
-- if windowload is set, it will respect that
-- apply the theme then call the windowload set
-- by the consumer. Otherwise it will setup
-- its own windowload event
-- todo: probably needs a refactor
local windowLoadEvent
for k,v in pairs(self.events) do
if v.strName == "WindowLoad" then
windowLoadEvent = v
break
end
end
if windowLoadEvent ~= nil then
local strFont = self.options.Font or "CRB_InterfaceMedium"
local strBtnBase = self.options.DropdownBtnBase or "Collections_TEMP:sprCollections_TEMP_RightAlignDropdown"
local nBtnWidth = self.options.DropdownBtnWidth
local fOldWindowLoad = windowLoadEvent.fnInline
local strOldWindowLoad = windowLoadEvent.strFunction
if windowLoadEvent.fnInline == nil then
fOldWindowLoad = windowLoadEvent.strFunction
end
local fNewWindowLoad = function(self, wndHandler, wndControl)
if wndHandler == wndControl then
local cbBtnSkin = GeminiGUI:Create({ Class="Button", Base=strBtnBase }):GetInstance()
if nBtnWidth then
wndControl:GetButton():SetAnchorOffsets(-nBtnWidth,0,0,0)
end
wndControl:GetButton():ChangeArt(cbBtnSkin)
wndControl:GetGrid():SetStyle("AutoHideScroll", true)
wndControl:GetGrid():SetStyle("TransitionShowHide", true)
wndControl:GetGrid():SetFont(strFont)
end
if type(fOldWindowLoad) == "function" then
fOldWindowLoad(self, wndHandler, wndControl)
elseif type(fOldWindowLoad) == "string" and type(self[fOldWindowLoad]) == "function" then
self[fOldWindowLoad](self, wndHandler, wndControl)
end
end
windowLoadEvent.fnInline = fNewWindowLoad
windowLoadEvent.strFunction = "OnWindowLoad_" .. tostring(windowLoadEvent.fnInline):gsub("function: ", "_")
end
if tForm.UseTheme ~= nil then
tForm.UseTheme = nil
end
end
end
local function Constructor()
local cbo = ComboBox:new()
cbo:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Font = "CRB_InterfaceMedium",
DT_VCENTER = true,
RelativeToClient = true,
Overlapped = true,
AutoSize = true,
Template = "HologramControl2",
UseTemplateBG = true,
Picture = true,
Border = true,
UseTheme = true,
-- DropdownBtnBase = "CRB_Basekit:kitBtn_ScrollHolo_DownLarge",
-- DropdownBtnWidth = 20,
}
return cbo
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/Slider.lua ]]--
do
local WidgetType, Version = "SliderBar", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Template = "CRB_Scroll_HoloLarge",
Middle = "CRB_Basekit:kitScrollbase_Horiz_Holo",
UseButtons = true,
Min = 1,
Max = 100,
TickAmount = 1,
RelativeToClient = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/ProgressBar.lua ]]--
do
local WidgetType, Version = "ProgressBar", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
ProgressEmpty = "BlackFill",
ProgressFull = "CRB_Raid:sprRaid_ShieldProgBar",
UseTemplateBG = true,
Template = "CRB_Hologram",
Border = true,
Picture = true,
BarColor = "white",
Font = "CRB_InterfaceMedium_BO",
UseValues = true,
RelativeToClient = true,
SetTextToProgress = true,
DT_CENTER = true,
DT_VCENTER = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/EditBox.lua ]]--
do
local WidgetType, Version = "EditBox", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
TabStop = true,
Font = "CRB_InterfaceMedium",
RelativeToClient = true,
DT_VCENTER = true,
Template = "HologramControl2",
UseTemplateBG = true,
Border = true,
Picture = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/Grid.lua ]]--
do
local WidgetType, Version = "Grid", 1
local Grid = GeminiGUI.ControlBase:new()
function Grid:AddColumn(tColumn)
self.columns = self.columns or {}
tColumn.TextColor = tColumn.TextColor or "White"
if tColumn.SimpleSort == nil then
tColumn.SimpleSort = true
end
table.insert(self.columns, tColumn)
end
function Grid:AddSubclassFields(tForm)
if self.options.Columns ~= nil then
for i = 1, #self.options.Columns do
self:AddColumn(self.options.Columns[i])
end
if tForm.Columns ~= nil then
tForm.Columns = nil
end
end
if self.columns ~= nil then
for i = #self.columns, 1, -1 do
local tColumn = self.columns[i]
local tNode = { __XmlNode = "Column", }
for k,v in pairs(tColumn) do
tNode[k] = v
end
table.insert(tForm, tNode)
end
end
end
local function Constructor()
local ctrl = Grid:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
IgnoreMouse = true,
Template = "CRB_Hologram",
UseTemplateBG = true,
Picture = true,
Border = true,
HeaderFont = "CRB_Pixel",
HeaderBG = "CRB_Basekit:kitBtn_List_HoloDisabled",
HeaderHeight = 26,
Font = "CRB_Pixel",
CellBGBase = "CRB_Basekit:kitBtn_List_HoloNormal",
RowHeight = 26,
MultiColumn = true,
FocusOnMouseOver = true,
SelectWholeRow = true,
RelativeToClient = true,
VariableHeight = true,
HeaderRow = true,
TextNormalColor = "white",
TextSelectedColor = "ff31fcf6",
TextNormalFocusColor = "white",
TextSelectedFocusColor = "ff31fcf6",
TextDisabledColor = "9d666666",
DT_VCENTER = true,
VScroll = true,
AutoHideScroll = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/MLWindow.lua ]]--
do
local WidgetType, Version = "MLWindow", 1
local function Constructor()
local ctrl = GeminiGUI:Create("Window", {
Class = "MLWindow",
Name = "GeminiGUI" .. WidgetType,
Font = "CRB_InterfaceSmall",
})
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/TabWindow.lua ]]--
do
local WidgetType, Version = "TabWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Template = "CRB_ChatWindow",
Font = "CRB_InterfaceMedium",
Moveable = true,
Border = true,
AutoFadeNC = true,
AudoFadeBG = true,
Picture = true,
Sizable = true,
Overlapped = true,
DT_CENTER = true,
DT_VCENTER = true,
UseTemplateBG = true,
RelativeToClient = true,
TabTextMarginLeft = 10,
TabTextMarginRight = 10,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/AbilityItemWindow.lua ]]--
do
local WidgetType, Version = "AbilityItemWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
IgnoreTooltipDelay = true,
RelativeToClient = true,
DT_CENTER = true,
DT_VCENTER = true,
ListItem = true,
IgnoreMouse = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/ActionConfirmButton.lua ]]--
do
local WidgetType, Version = "ActionConfirmButton", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Font = "Default",
RelativeToClient = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/BagWindow.lua ]]--
do
local WidgetType, Version = "BagWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
SwallowMouseClicks = true,
IgnoreTooltipDelay = true,
Sprite = "CRB_UIKitSprites:spr_baseframe",
Template = "CRB_Normal",
NoClip = true,
UseTemplateBG = true,
NewQuestOverlaySprite = "ClientSprites:sprItem_NewQuest",
SquareSize = 50,
BoxesPerRow = 5,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/BuffWindow.lua ]]--
do
local WidgetType, Version = "BuffWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
NoClip = true,
HarmfulBuffs = true,
BuffIndex = 1,
IgnoreTooltipDelay = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/BuffContainerWindow.lua ]]--
do
local WidgetType, Version = "BuffContainerWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
Font = "Default",
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/CashWindow.lua ]]--
do
local WidgetType, Version = "CashWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Font = "CRB_InterfaceSmall",
DT_RIGHT = true,
RelativeToClient = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/CharacterFrame.lua ]]--
do
local WidgetType, Version = "CharacterFrame", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
Overlapped = true,
TestAlpha = true,
TransitionShowHide = true,
SwallowMouseClicks = true,
Font = "Default",
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/CostumeWindow.lua ]]--
do
local WidgetType, Version = "CostumeWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
Font = "Default",
Camera = "Paperdoll",
Animated = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/IconButton.lua ]]--
do
local WidgetType, Version = "IconButton", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
NoClip = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/ItemSlotWindow.lua ]]--
do
local WidgetType, Version = "ItemSlotWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
WhenEmpty = "btn_Armor_HeadNormal",
EquipmentSlot = 2,
IgnoreTooltipDelay = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/LootWindow.lua ]]--
do
local WidgetType, Version = "LootWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Font = "CRB_InterfaceMedium",
SwallowMouseClicks = true,
IgnoreTooltipDelay = true,
Sprite = "CRB_UIKitSprites:spr_baseframe",
Template = "CRB_Normal",
NoClip = true,
UseTemplateBG = true,
NewQuestOverlaySprite = "ClientSprites:sprItem_NewQuest",
SquareSize = 50,
BoxesPerRow = 3,
NewControlDepth = 1,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/MannequinSlotWindow.lua ]]--
do
local WidgetType, Version = "MannequinSlotWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
WhenEmpty = "btn_Armor_HeadNormal",
EquipmentSlot = 2,
IgnoreTooltipDelay = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/MiniMapWindow.lua ]]--
do
local WidgetType, Version = "MiniMapWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
Font = "Default",
Template = "Default",
NewControlDepth = 2,
Mask = [[ui\textures\UI_CRB_HUD_MiniMap_Mask.tex]],
CircularItems = true,
ItemRadius = 0.7,
IgnoreMouse = true,
MapOrientation = 0,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/ProtostarMapWindow.lua ]]--
do
local WidgetType, Version = "ProtostarMapWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
Template = "CRB_Normal",
NewControlDepth = 1,
SwallowMouseClicks = true,
IgnoreTooltipDelay = true,
NoClip = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/SendEmailButton.lua ]]--
do
local WidgetType, Version = "SendEmailButton", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/TradeCommitButton.lua ]]--
do
local WidgetType, Version = "TradeCommitButton", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/WorldFixedWindow.lua ]]--
do
local WidgetType, Version = "WorldFixedWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
Font = "Default",
Template = "Default",
SwallowMouseClicks = true,
Overlapped = true,
IgnoreMouse = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
--[[ File: widgets/ZoneMapWindow.lua ]]--
do
local WidgetType, Version = "ZoneMapWindow", 1
local function Constructor()
local ctrl = GeminiGUI.ControlBase:new()
ctrl:SetOptions{
Class = WidgetType,
Name = "GeminiGUI" .. WidgetType,
RelativeToClient = true,
Template = "CRB_HologramFramedThick",
UseTemplateBG = true,
IgnoreTooltipDelay = true,
DrawObjectsOnContinent = true,
}
return ctrl
end
GeminiGUI:RegisterWidgetType(WidgetType, Constructor, Version)
end
| gpl-3.0 |
StewEsho/LudumDare38 | levels/descent.lua | 1 | 22015 | return {
version = "1.1",
luaversion = "5.1",
tiledversion = "0.18.2",
orientation = "orthogonal",
renderorder = "right-down",
width = 80,
height = 75,
tilewidth = 64,
tileheight = 64,
nextobjectid = 1,
properties = {},
tilesets = {
{
name = "Platforms",
firstgid = 1,
tilewidth = 64,
tileheight = 64,
spacing = 0,
margin = 0,
image = "../art/descent/platforms.png",
imagewidth = 192,
imageheight = 256,
tileoffset = {
x = 0,
y = 0
},
properties = {},
terrains = {},
tilecount = 12,
tiles = {
{
id = 0,
properties = {
["category"] = 4,
["isSolid"] = true,
["userData"] = "ground"
}
},
{
id = 1,
properties = {
["category"] = 4,
["isSolid"] = true,
["userData"] = "ground"
}
},
{
id = 2,
properties = {
["category"] = 4,
["isSolid"] = true,
["userData"] = "ground"
}
},
{
id = 3,
properties = {
["category"] = 4,
["isSolid"] = true,
["userData"] = "wall"
}
},
{
id = 4,
properties = {
["category"] = 4,
["isSolid"] = false,
["userData"] = "background"
}
},
{
id = 5,
properties = {
["category"] = 4,
["isSolid"] = true,
["userData"] = "wall"
}
},
{
id = 6,
properties = {
["category"] = 4,
["isSolid"] = true,
["userData"] = "ground"
}
},
{
id = 7,
properties = {
["category"] = 4,
["isSolid"] = true,
["userData"] = "ground"
}
},
{
id = 8,
properties = {
["category"] = 4,
["isSolid"] = true,
["userData"] = "ground"
}
},
{
id = 9,
properties = {
["category"] = 4,
["isSolid"] = true,
["userData"] = "wall"
}
},
{
id = 10,
properties = {
["category"] = 5,
["isSolid"] = true,
["userData"] = "goal"
}
},
{
id = 11,
properties = {
["category"] = 4,
["isSolid"] = false,
["userData"] = "background"
}
}
}
}
},
layers = {
{
type = "tilelayer",
name = "Tile Layer 1",
x = 0,
y = 0,
width = 80,
height = 75,
visible = true,
opacity = 1,
offsetx = 0,
offsety = 0,
properties = {
["bgm"] = "music/tense.wav"
},
encoding = "lua",
data = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 0, 12, 0, 12, 0, 12, 12, 12, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 12, 0, 12, 0, 12, 0, 12, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 0, 12, 0, 12, 0, 12, 0, 12, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 12, 0, 12, 0, 12, 0, 12, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 0, 12, 12, 12, 0, 12, 0, 12, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 11, 11, 11, 11, 10,
10, 0, 0, 0, 0, 0, 0, 0, 12, 0, 12, 0, 12, 0, 12, 0, 12, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 8, 8, 8, 9, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8, 10, 11, 11, 11, 11, 11, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 12, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 8, 8, 8, 9, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 8, 8, 8, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 0, 0, 12, 12, 12, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 12, 0, 12, 0, 12, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 8, 8, 9, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 0, 0, 12, 0, 12, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 10, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 12, 0, 12, 0, 12, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 10, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 8, 8, 9, 0, 12, 12, 12, 0, 0, 12, 12, 12, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 10, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 0, 0, 0, 0, 10, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 8, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 12, 12, 12, 12, 0, 12, 0, 0, 12, 0, 12, 0, 10, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 8, 8, 9, 0, 12, 0, 0, 0, 12, 0, 0, 12, 0, 12, 0, 0, 12, 0, 12, 0, 10, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 8, 8, 9, 0, 0, 0, 0, 0, 0, 10, 0, 12, 0, 0, 0, 12, 0, 0, 12, 0, 12, 0, 0, 12, 0, 12, 0, 10, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 12, 12, 12, 0, 12, 12, 12, 12, 0, 12, 12, 12, 12, 12, 12, 0, 10, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 8, 8, 8, 8, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 10, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 10, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 10, 11, 11, 11, 11, 10, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 8, 8, 8, 8, 8, 9, 10, 11, 11, 11, 11, 10, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
10, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9
}
}
}
}
| mit |
mosy210/shadow-bot | libs/mimetype.lua | 3662 | 2922 | -- Thanks to https://github.com/catwell/lua-toolbox/blob/master/mime.types
do
local mimetype = {}
-- TODO: Add more?
local types = {
["text/html"] = "html",
["text/css"] = "css",
["text/xml"] = "xml",
["image/gif"] = "gif",
["image/jpeg"] = "jpg",
["application/x-javascript"] = "js",
["application/atom+xml"] = "atom",
["application/rss+xml"] = "rss",
["text/mathml"] = "mml",
["text/plain"] = "txt",
["text/vnd.sun.j2me.app-descriptor"] = "jad",
["text/vnd.wap.wml"] = "wml",
["text/x-component"] = "htc",
["image/png"] = "png",
["image/tiff"] = "tiff",
["image/vnd.wap.wbmp"] = "wbmp",
["image/x-icon"] = "ico",
["image/x-jng"] = "jng",
["image/x-ms-bmp"] = "bmp",
["image/svg+xml"] = "svg",
["image/webp"] = "webp",
["application/java-archive"] = "jar",
["application/mac-binhex40"] = "hqx",
["application/msword"] = "doc",
["application/pdf"] = "pdf",
["application/postscript"] = "ps",
["application/rtf"] = "rtf",
["application/vnd.ms-excel"] = "xls",
["application/vnd.ms-powerpoint"] = "ppt",
["application/vnd.wap.wmlc"] = "wmlc",
["application/vnd.google-earth.kml+xml"] = "kml",
["application/vnd.google-earth.kmz"] = "kmz",
["application/x-7z-compressed"] = "7z",
["application/x-cocoa"] = "cco",
["application/x-java-archive-diff"] = "jardiff",
["application/x-java-jnlp-file"] = "jnlp",
["application/x-makeself"] = "run",
["application/x-perl"] = "pl",
["application/x-pilot"] = "prc",
["application/x-rar-compressed"] = "rar",
["application/x-redhat-package-manager"] = "rpm",
["application/x-sea"] = "sea",
["application/x-shockwave-flash"] = "swf",
["application/x-stuffit"] = "sit",
["application/x-tcl"] = "tcl",
["application/x-x509-ca-cert"] = "crt",
["application/x-xpinstall"] = "xpi",
["application/xhtml+xml"] = "xhtml",
["application/zip"] = "zip",
["application/octet-stream"] = "bin",
["audio/midi"] = "mid",
["audio/mpeg"] = "mp3",
["audio/ogg"] = "ogg",
["audio/x-m4a"] = "m4a",
["audio/x-realaudio"] = "ra",
["video/3gpp"] = "3gpp",
["video/mp4"] = "mp4",
["video/mpeg"] = "mpeg",
["video/quicktime"] = "mov",
["video/webm"] = "webm",
["video/x-flv"] = "flv",
["video/x-m4v"] = "m4v",
["video/x-mng"] = "mng",
["video/x-ms-asf"] = "asf",
["video/x-ms-wmv"] = "wmv",
["video/x-msvideo"] = "avi"
}
-- Returns the common file extension from a content-type
function mimetype.get_mime_extension(content_type)
return types[content_type]
end
-- Returns the mimetype and subtype
function mimetype.get_content_type(extension)
for k,v in pairs(types) do
if v == extension then
return k
end
end
end
-- Returns the mimetype without the subtype
function mimetype.get_content_type_no_sub(extension)
for k,v in pairs(types) do
if v == extension then
-- Before /
return k:match('([%w-]+)/')
end
end
end
return mimetype
end | gpl-2.0 |
AbolDalton/Abolbot | libs/mimetype.lua | 3662 | 2922 | -- Thanks to https://github.com/catwell/lua-toolbox/blob/master/mime.types
do
local mimetype = {}
-- TODO: Add more?
local types = {
["text/html"] = "html",
["text/css"] = "css",
["text/xml"] = "xml",
["image/gif"] = "gif",
["image/jpeg"] = "jpg",
["application/x-javascript"] = "js",
["application/atom+xml"] = "atom",
["application/rss+xml"] = "rss",
["text/mathml"] = "mml",
["text/plain"] = "txt",
["text/vnd.sun.j2me.app-descriptor"] = "jad",
["text/vnd.wap.wml"] = "wml",
["text/x-component"] = "htc",
["image/png"] = "png",
["image/tiff"] = "tiff",
["image/vnd.wap.wbmp"] = "wbmp",
["image/x-icon"] = "ico",
["image/x-jng"] = "jng",
["image/x-ms-bmp"] = "bmp",
["image/svg+xml"] = "svg",
["image/webp"] = "webp",
["application/java-archive"] = "jar",
["application/mac-binhex40"] = "hqx",
["application/msword"] = "doc",
["application/pdf"] = "pdf",
["application/postscript"] = "ps",
["application/rtf"] = "rtf",
["application/vnd.ms-excel"] = "xls",
["application/vnd.ms-powerpoint"] = "ppt",
["application/vnd.wap.wmlc"] = "wmlc",
["application/vnd.google-earth.kml+xml"] = "kml",
["application/vnd.google-earth.kmz"] = "kmz",
["application/x-7z-compressed"] = "7z",
["application/x-cocoa"] = "cco",
["application/x-java-archive-diff"] = "jardiff",
["application/x-java-jnlp-file"] = "jnlp",
["application/x-makeself"] = "run",
["application/x-perl"] = "pl",
["application/x-pilot"] = "prc",
["application/x-rar-compressed"] = "rar",
["application/x-redhat-package-manager"] = "rpm",
["application/x-sea"] = "sea",
["application/x-shockwave-flash"] = "swf",
["application/x-stuffit"] = "sit",
["application/x-tcl"] = "tcl",
["application/x-x509-ca-cert"] = "crt",
["application/x-xpinstall"] = "xpi",
["application/xhtml+xml"] = "xhtml",
["application/zip"] = "zip",
["application/octet-stream"] = "bin",
["audio/midi"] = "mid",
["audio/mpeg"] = "mp3",
["audio/ogg"] = "ogg",
["audio/x-m4a"] = "m4a",
["audio/x-realaudio"] = "ra",
["video/3gpp"] = "3gpp",
["video/mp4"] = "mp4",
["video/mpeg"] = "mpeg",
["video/quicktime"] = "mov",
["video/webm"] = "webm",
["video/x-flv"] = "flv",
["video/x-m4v"] = "m4v",
["video/x-mng"] = "mng",
["video/x-ms-asf"] = "asf",
["video/x-ms-wmv"] = "wmv",
["video/x-msvideo"] = "avi"
}
-- Returns the common file extension from a content-type
function mimetype.get_mime_extension(content_type)
return types[content_type]
end
-- Returns the mimetype and subtype
function mimetype.get_content_type(extension)
for k,v in pairs(types) do
if v == extension then
return k
end
end
end
-- Returns the mimetype without the subtype
function mimetype.get_content_type_no_sub(extension)
for k,v in pairs(types) do
if v == extension then
-- Before /
return k:match('([%w-]+)/')
end
end
end
return mimetype
end | gpl-2.0 |
shahabsaf12/x | libs/mimetype.lua | 3662 | 2922 | -- Thanks to https://github.com/catwell/lua-toolbox/blob/master/mime.types
do
local mimetype = {}
-- TODO: Add more?
local types = {
["text/html"] = "html",
["text/css"] = "css",
["text/xml"] = "xml",
["image/gif"] = "gif",
["image/jpeg"] = "jpg",
["application/x-javascript"] = "js",
["application/atom+xml"] = "atom",
["application/rss+xml"] = "rss",
["text/mathml"] = "mml",
["text/plain"] = "txt",
["text/vnd.sun.j2me.app-descriptor"] = "jad",
["text/vnd.wap.wml"] = "wml",
["text/x-component"] = "htc",
["image/png"] = "png",
["image/tiff"] = "tiff",
["image/vnd.wap.wbmp"] = "wbmp",
["image/x-icon"] = "ico",
["image/x-jng"] = "jng",
["image/x-ms-bmp"] = "bmp",
["image/svg+xml"] = "svg",
["image/webp"] = "webp",
["application/java-archive"] = "jar",
["application/mac-binhex40"] = "hqx",
["application/msword"] = "doc",
["application/pdf"] = "pdf",
["application/postscript"] = "ps",
["application/rtf"] = "rtf",
["application/vnd.ms-excel"] = "xls",
["application/vnd.ms-powerpoint"] = "ppt",
["application/vnd.wap.wmlc"] = "wmlc",
["application/vnd.google-earth.kml+xml"] = "kml",
["application/vnd.google-earth.kmz"] = "kmz",
["application/x-7z-compressed"] = "7z",
["application/x-cocoa"] = "cco",
["application/x-java-archive-diff"] = "jardiff",
["application/x-java-jnlp-file"] = "jnlp",
["application/x-makeself"] = "run",
["application/x-perl"] = "pl",
["application/x-pilot"] = "prc",
["application/x-rar-compressed"] = "rar",
["application/x-redhat-package-manager"] = "rpm",
["application/x-sea"] = "sea",
["application/x-shockwave-flash"] = "swf",
["application/x-stuffit"] = "sit",
["application/x-tcl"] = "tcl",
["application/x-x509-ca-cert"] = "crt",
["application/x-xpinstall"] = "xpi",
["application/xhtml+xml"] = "xhtml",
["application/zip"] = "zip",
["application/octet-stream"] = "bin",
["audio/midi"] = "mid",
["audio/mpeg"] = "mp3",
["audio/ogg"] = "ogg",
["audio/x-m4a"] = "m4a",
["audio/x-realaudio"] = "ra",
["video/3gpp"] = "3gpp",
["video/mp4"] = "mp4",
["video/mpeg"] = "mpeg",
["video/quicktime"] = "mov",
["video/webm"] = "webm",
["video/x-flv"] = "flv",
["video/x-m4v"] = "m4v",
["video/x-mng"] = "mng",
["video/x-ms-asf"] = "asf",
["video/x-ms-wmv"] = "wmv",
["video/x-msvideo"] = "avi"
}
-- Returns the common file extension from a content-type
function mimetype.get_mime_extension(content_type)
return types[content_type]
end
-- Returns the mimetype and subtype
function mimetype.get_content_type(extension)
for k,v in pairs(types) do
if v == extension then
return k
end
end
end
-- Returns the mimetype without the subtype
function mimetype.get_content_type_no_sub(extension)
for k,v in pairs(types) do
if v == extension then
-- Before /
return k:match('([%w-]+)/')
end
end
end
return mimetype
end | gpl-2.0 |
ArIaNDeVeLoPeR/IDsearcher | libs/mimetype.lua | 3662 | 2922 | -- Thanks to https://github.com/catwell/lua-toolbox/blob/master/mime.types
do
local mimetype = {}
-- TODO: Add more?
local types = {
["text/html"] = "html",
["text/css"] = "css",
["text/xml"] = "xml",
["image/gif"] = "gif",
["image/jpeg"] = "jpg",
["application/x-javascript"] = "js",
["application/atom+xml"] = "atom",
["application/rss+xml"] = "rss",
["text/mathml"] = "mml",
["text/plain"] = "txt",
["text/vnd.sun.j2me.app-descriptor"] = "jad",
["text/vnd.wap.wml"] = "wml",
["text/x-component"] = "htc",
["image/png"] = "png",
["image/tiff"] = "tiff",
["image/vnd.wap.wbmp"] = "wbmp",
["image/x-icon"] = "ico",
["image/x-jng"] = "jng",
["image/x-ms-bmp"] = "bmp",
["image/svg+xml"] = "svg",
["image/webp"] = "webp",
["application/java-archive"] = "jar",
["application/mac-binhex40"] = "hqx",
["application/msword"] = "doc",
["application/pdf"] = "pdf",
["application/postscript"] = "ps",
["application/rtf"] = "rtf",
["application/vnd.ms-excel"] = "xls",
["application/vnd.ms-powerpoint"] = "ppt",
["application/vnd.wap.wmlc"] = "wmlc",
["application/vnd.google-earth.kml+xml"] = "kml",
["application/vnd.google-earth.kmz"] = "kmz",
["application/x-7z-compressed"] = "7z",
["application/x-cocoa"] = "cco",
["application/x-java-archive-diff"] = "jardiff",
["application/x-java-jnlp-file"] = "jnlp",
["application/x-makeself"] = "run",
["application/x-perl"] = "pl",
["application/x-pilot"] = "prc",
["application/x-rar-compressed"] = "rar",
["application/x-redhat-package-manager"] = "rpm",
["application/x-sea"] = "sea",
["application/x-shockwave-flash"] = "swf",
["application/x-stuffit"] = "sit",
["application/x-tcl"] = "tcl",
["application/x-x509-ca-cert"] = "crt",
["application/x-xpinstall"] = "xpi",
["application/xhtml+xml"] = "xhtml",
["application/zip"] = "zip",
["application/octet-stream"] = "bin",
["audio/midi"] = "mid",
["audio/mpeg"] = "mp3",
["audio/ogg"] = "ogg",
["audio/x-m4a"] = "m4a",
["audio/x-realaudio"] = "ra",
["video/3gpp"] = "3gpp",
["video/mp4"] = "mp4",
["video/mpeg"] = "mpeg",
["video/quicktime"] = "mov",
["video/webm"] = "webm",
["video/x-flv"] = "flv",
["video/x-m4v"] = "m4v",
["video/x-mng"] = "mng",
["video/x-ms-asf"] = "asf",
["video/x-ms-wmv"] = "wmv",
["video/x-msvideo"] = "avi"
}
-- Returns the common file extension from a content-type
function mimetype.get_mime_extension(content_type)
return types[content_type]
end
-- Returns the mimetype and subtype
function mimetype.get_content_type(extension)
for k,v in pairs(types) do
if v == extension then
return k
end
end
end
-- Returns the mimetype without the subtype
function mimetype.get_content_type_no_sub(extension)
for k,v in pairs(types) do
if v == extension then
-- Before /
return k:match('([%w-]+)/')
end
end
end
return mimetype
end | gpl-2.0 |
juanchanco/lua-xcb | swig/ft/hello_pango.lua | 1 | 2072 | local pango = require("pango")
local cairo = require("cairo")
local RADIUS = 200
local N_WORDS = 8
local FONT_WITH_MANUAL_SIZE = "Times new roman,Sans"
local FONT_SIZE = 36
local DEVICE_DPI = 72
--local TWEAKABLE_SCALE = 0.1
local PANGO_SCALE = 1024
local draw_text = function(cr)
--cr:translate (RADIUS, RADIUS)
local layout = pango.PangoCairo.createPangoLayout(cr)
local text8 = "Ленивый рыжий кот شَدَّة latin العَرَبِية";
layout:setText(text8, -1)
local desc = pango.Font.fontDescriptionFromString(FONT_WITH_MANUAL_SIZE)
desc:setAbsoluteSize( FONT_SIZE * DEVICE_DPI * PANGO_SCALE / (72.0))
local w,_ = layout:getSize()
layout:setFontDescription(desc)
cr:setSourceRgb(0.0, 0.0, 0.0)
pango.PangoCairo.updatePangoLayout(cr, layout)
cr:moveTo (10,10)
pango.PangoCairo.showPangoLayout(cr, layout)
end
local xcb = require("xcb")
local conn = xcb.connect()
local screen = conn:getSetup():setupRootsIterator().data
local window = conn:createWindow({
parent=screen.root,
visual=screen.root_visual,
x=20, y=20, w=650, h=150, border=10,
class = xcb.WindowClass.InputOutput,
mask=xcb.CW.BackPixel | xcb.CW.EventMask,
value0=screen.white_pixel,
value1=xcb.EventMask.Exposure | xcb.EventMask.KeyPress
})
conn:mapWindow(window)
conn:flush()
local visual = cairo.findVisual(conn, screen.root_visual)
local surface = cairo.xcbSurfaceCreate(conn, window.id, visual, 650, 150)
local cr = surface:cairoCreate()
--cr:scale(1 * TWEAKABLE_SCALE, 1 * TWEAKABLE_SCALE)
conn:flush()
local e = conn:waitForEvent()
while (e) do
local response_type = e.response_type
if (response_type == xcb.EventType.Expose) then
cr:setSourceRgb(.9, .9, .9)
cr:paint()
draw_text (cr)
surface:flush()
conn:flush()
elseif (response_type == xcb.EventType.KeyPress) then
break
elseif (response_type == 0) then
if (e.error_code) then
print(string.format("Event error code:%i", e.error_code))
else
print("Event error code:null")
end
end
e = conn:waitForEvent()
end
conn:disconnect()
| mit |
dacrybabysuck/darkstar | scripts/zones/Northern_San_dOria/npcs/Olbergieut.lua | 11 | 1887 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Olbergieut
-- Type: Quest NPC
-- !pos 91 0 121 231
--
-- Starts and Finishes Quest: Gates of Paradise
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
local ID = require("scripts/zones/Northern_San_dOria/IDs");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
gates = player:getQuestStatus(SANDORIA,dsp.quest.id.sandoria.GATES_TO_PARADISE);
if (player:hasKeyItem(dsp.ki.SCRIPTURE_OF_WATER) == true) then
player:startEvent(620);
elseif (gates == QUEST_ACCEPTED) then
player:showText(npc, ID.text.OLBERGIEUT_DIALOG, dsp.ki.SCRIPTURE_OF_WIND);
elseif (player:getFameLevel(SANDORIA) >= 2 and gates == QUEST_AVAILABLE) then
player:startEvent(619);
else
player:startEvent(612);
end;
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 619 and option == 0) then
player:addQuest(SANDORIA, dsp.quest.id.sandoria.GATES_TO_PARADISE);
player:addKeyItem(dsp.ki.SCRIPTURE_OF_WIND);
player:messageSpecial(ID.text.KEYITEM_OBTAINED, dsp.ki.SCRIPTURE_OF_WIND);
elseif (csid == 620) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED, 13584);
else
player:completeQuest(SANDORIA,dsp.quest.id.sandoria.GATES_TO_PARADISE);
player:addFame(SANDORIA,30);
player:addTitle(dsp.title.THE_PIOUS_ONE);
player:delKeyItem(dsp.ki.SCRIPTURE_OF_WATER);
player:addItem(13584,1);
player:messageSpecial(ID.text.ITEM_OBTAINED,13584);
end;
end;
end;
| gpl-3.0 |
dacrybabysuck/darkstar | scripts/globals/items/pear_crepe.lua | 11 | 1177 | -----------------------------------------
-- ID: 5777
-- Item: Pear Crepe
-- Food Effect: 30 Min, All Races
-----------------------------------------
-- Intelligence +2
-- MP Healing +2
-- Magic Accuracy +20% (cap 45)
-- Magic Defense +1
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,1800,5777)
end
function onEffectGain(target,effect)
target:addMod(dsp.mod.INT, 2)
target:addMod(dsp.mod.FOOD_MACCP, 20)
target:addMod(dsp.mod.FOOD_MACC_CAP, 45)
target:addMod(dsp.mod.MDEF, 1)
target:addMod(dsp.mod.MPHEAL, 2)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.INT, 2)
target:delMod(dsp.mod.FOOD_MACCP, 20)
target:delMod(dsp.mod.FOOD_MACC_CAP, 45)
target:delMod(dsp.mod.MDEF, 1)
target:delMod(dsp.mod.MPHEAL, 2)
end
| gpl-3.0 |
dacrybabysuck/darkstar | scripts/zones/Windurst_Waters_[S]/npcs/Ezura-Romazura.lua | 12 | 1063 | -----------------------------------
-- Area: Windurst Waters [S]
-- NPC: Ezura-Romazura
-- Standard Merchant NPC
-----------------------------------
local ID = require("scripts/zones/Windurst_Waters_[S]/IDs")
require("scripts/globals/shop")
-----------------------------------
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
local stock =
{
4771,123750, -- Scroll of Stone V
4781,133110, -- Scroll of Water V
4766,144875, -- Scroll of Aero V
4756,162500, -- Scroll of Fire V
4761,186375, -- Scroll of Blizzard V
4893,168150, -- Scroll of Stoneja
4895,176700, -- Scroll of Waterja
4890,193800, -- Scroll of Firaja
4892,185240, -- Scroll of Aeroja
4863,126000, -- Scroll of Break
}
player:showText(npc,ID.text.EZURAROMAZURA_SHOP_DIALOG)
dsp.shop.general(player, stock)
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
end
| gpl-3.0 |
wizardbottttt/powerplus | plugins/spammer.lua | 86 | 65983 | local function run(msg)
if msg.text == "[!/]killwili" then
return "".. [[
kose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nkose nanat hack shod left bede\nv
]]
end
end
return {
description = "Spamms the group fastly",
usage = "!fuck or Fuckgp or Fuck : send 10000 Spams to the group",
patterns = {
"^[!/]fuck$",
"^fuckgp$",
"^Fuck$",
"^spam$",
"^Fuckgp$",
},
run = run,
privileged = true,
pre_process = pre_process
}
| gpl-2.0 |
turingbot/B1 | plugins/ping.lua | 1 | 1043 | local datebase = {
"اگه با منی که من آنلاینم 😐❤️ ",
"آنلاین بودم وقتی آنلاین بودن مد نبود 😐❤️ ",
"گفتم که آنلاینم 😐❤️ ",
"کار و زندگی نداری تو گیر میدی به من 😐❤️ ",
"عجب گیری کردیم از دست این 😐❤️ ",
"چقد بدم بیخیال من شی 😐❤️ ",
"عجب داستانی دارم من با تو 😐❤️ ",
"خوشت میاد منو اذیت کنی 😐❤️ ",
"یه بار دیگه بگی ربات خودت میدونی 😐❤️ ",
"من از دست این آدم بیکار لفت بدم بهتره 😐❤️ ",
"منو بیخیال بچسب به کار و زندگیت 😐❤️ ",
"درد و بلات بخوره تو سر ربات گروه بغلی چیه آخه 😐❤️ ",
}
local function run(msg, matches)
if is_mod(msg) then
return datebase[math.random(#datebase)]
end
end
return {
patterns = {
"^ربات$",
"^رباط$",
},
run = run
} | gpl-3.0 |
dacrybabysuck/darkstar | scripts/globals/items/pork_cutlet_rice_bowl.lua | 11 | 1782 | -----------------------------------------
-- ID: 6406
-- Item: pork_cutlet_rice_bowl
-- Food Effect: 180Min, All Races
-----------------------------------------
-- HP +60
-- MP +60
-- STR +7
-- VIT +3
-- AGI +5
-- INT -7
-- Fire resistance +20
-- Attack +23% (cap 125)
-- Ranged Attack +23% (cap 125)
-- Store TP +4
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,10800,6406)
end
function onEffectGain(target,effect)
target:addMod(dsp.mod.HP, 60)
target:addMod(dsp.mod.MP, 60)
target:addMod(dsp.mod.STR, 7)
target:addMod(dsp.mod.VIT, 3)
target:addMod(dsp.mod.AGI, 5)
target:addMod(dsp.mod.INT, -7)
target:addMod(dsp.mod.FIRERES, 20)
target:addMod(dsp.mod.FOOD_ATTP, 23)
target:addMod(dsp.mod.FOOD_ATT_CAP, 125)
target:addMod(dsp.mod.FOOD_RATTP, 23)
target:addMod(dsp.mod.FOOD_RATT_CAP, 125)
target:addMod(dsp.mod.STORETP, 4)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.HP, 60)
target:delMod(dsp.mod.MP, 60)
target:delMod(dsp.mod.STR, 7)
target:delMod(dsp.mod.VIT, 3)
target:delMod(dsp.mod.AGI, 5)
target:delMod(dsp.mod.INT, -7)
target:delMod(dsp.mod.FIRERES, 20)
target:delMod(dsp.mod.FOOD_ATTP, 23)
target:delMod(dsp.mod.FOOD_ATT_CAP, 125)
target:delMod(dsp.mod.FOOD_RATTP, 23)
target:delMod(dsp.mod.FOOD_RATT_CAP, 125)
target:delMod(dsp.mod.STORETP, 4)
end
| gpl-3.0 |
andeandr100/Crumbled-World | Lua/MapEditor/Tools/ModelPlaceTool.lua | 1 | 7885 | require("MapEditor/Tools/Tool.lua")
require("MapEditor/Tools/ModelPlaceToolMenu.lua")
--this = SceneNode()
local firstUpdateOfSelectedModel = false
setttings = {}
function setModel(panel)
toolManager = this:getRootNode():findNodeByTypeTowardsLeafe(NodeId.toolManager)
if toolManager then
toolManager:setToolScript("MapEditor/Tools/ModelPlaceTool.lua")
print("Model: "..panel:getTag():toString().."\n")
nextModel = panel:getTag():toString()
firstUpdateOfSelectedModel = true
end
end
function updateSettings()
selectedConfig = modelPlaceToolMenu.getSelectedConfig()
setttings.enableObjectCollision = selectedConfig:get("objectCollision", true):getBool()
setttings.enableSpaceCollision = selectedConfig:get("spaceCollision", true):getBool()
setttings.enableUseObjectNormal = selectedConfig:get("useNormal", true):getBool()
setttings.minRed = selectedConfig:get("minColorRed", 255):getInt()
setttings.maxRed = selectedConfig:get("maxColorRed", 255):getInt()
setttings.minGreen = selectedConfig:get("minColorGreen", 255):getInt()
setttings.maxGreen = selectedConfig:get("maxColorGreen", 255):getInt()
setttings.minBlue = selectedConfig:get("minColorBlue", 255):getInt()
setttings.maxBlue = selectedConfig:get("maxColorBlue", 255):getInt()
setttings.minRotationX = selectedConfig:get("minRotationAroundX", 0):getInt()
setttings.maxRotationX = selectedConfig:get("maxRotationAroundX", 0):getInt()
setttings.minRotationY = selectedConfig:get("minRotationAroundY", 0):getInt()
setttings.maxRotationY = selectedConfig:get("maxRotationAroundY", 0):getInt()
setttings.minRotationZ = selectedConfig:get("minRotationAroundZ", 0):getInt()
setttings.maxRotationZ = selectedConfig:get("maxRotationAroundZ", 0):getInt()
setttings.minScale = selectedConfig:get("minScale", 1.0):getDouble()
setttings.maxScale = selectedConfig:get("maxScale", 1.0):getDouble()
local numDefaultScript = selectedConfig:get("numDefaultScript", 0):getInt()
setttings.defaultScripts = {}
for i=1, numDefaultScript do
setttings.defaultScripts[i] = selectedConfig:get("defaultScript"..tostring(i), ""):getString()
end
updateModelState()
end
function updateModelState()
if currentModel then
currentModel:setColor( Vec3( math.randomFloat(setttings.minRed, setttings.maxRed)/255, math.randomFloat(setttings.minGreen, setttings.maxGreen)/255, math.randomFloat(setttings.minBlue, setttings.maxBlue)/255 ) )
--currentModelMatrix = currentModel:getLocalMatrix()
if setttings.minRotationX ~= 0 or setttings.maxRotationX ~= 0 or setttings.minRotationY ~= 0 or setttings.maxRotationY ~= 0 or setttings.minRotationZ ~= 0 or setttings.maxRotationZ ~= 0 then
local rotX = math.degToRad( math.randomFloat(setttings.minRotationX, setttings.maxRotationX) )
local rotY = math.degToRad( math.randomFloat(setttings.minRotationY, setttings.maxRotationY) )
local rotZ = math.degToRad( math.randomFloat(setttings.minRotationZ, setttings.maxRotationZ) )
local cVec = currentModelMatrix:getRotation()
--change only rotations that is set between 2 values
if setttings.minRotationX ~= 0 or setttings.maxRotationX ~= 0 then
cVec.x = rotX
end
if setttings.minRotationY ~= 0 or setttings.maxRotationY ~= 0 then
cVec.y = rotY
end
if setttings.minRotationZ ~= 0 or setttings.maxRotationZ ~= 0 then
cVec.z = rotZ
end
currentModelMatrix:setRotation(cVec)
end
--scale will be randomized every time
currentModelMatrix:setScale(Vec3(math.randomFloat(setttings.minScale, setttings.maxScale)))
currentModel:setLocalMatrix(currentModelMatrix)
end
end
function create()
Tool.create()
Tool.enableChangeOfSelectedScene = false
nextModel = nil
currentModel = nil
currentModelMatrix = Matrix()
useObjectCollision = true
--Get billboard for the map editor
local mapEditor = Core.getBillboard("MapEditor")
--Get the Tool panel
local toolPanel = mapEditor:getPanel("ToolPanel")
--Get the setting panel
local settingPanel = mapEditor:getPanel("SettingPanel")
--Load config
rootConfig = Config("ToolsSettings")
--Get the ligt tool config settings
modelInfoConfig = rootConfig:get("ModelInfo")
modelPlaceToolMenu = ModelPlaceToolMenu.new(toolPanel, setModel, settingPanel, updateSettings)
return true
end
function changeModel()
if nextModel then
currentModel = Core.getModel(nextModel)
--currentModel = Model()
if currentModel then
if this:getRootNode() then
this:getRootNode():addChild(currentModel)
else
currentModel = nil
end
end
--Update settings panel, update model rotation and scale
modelPlaceToolMenu.setToolSettingsForModel(nextModel)
nextModel = nil
end
end
--Called when the tool has been activated
function activated()
changeModel()
currentModelMatrix = Matrix()
toolModelSettingsPanel:setVisible(true)
Tool.clearSelectedNodes()
print("activated\n")
--currentFrae = Core.get
end
--Called when tool is being deactivated
function deActivated()
if currentModel then
if currentModel:getParent() then
currentModel:getParent():removeChild(currentModel)
end
currentModel = nil
end
toolModelSettingsPanel:setVisible(false)
print("Deactivated\n")
end
--As long as the tool is active update is caled
function update()
--Check if new model has been requested
if nextModel then
changeModel()
end
--Check if there is a selected model
if not currentModel then
return true
end
--Do collision check
local node, collisionPos, collisionNormal = Tool.getCollision(setttings.enableObjectCollision, setttings.enableSpaceCollision)
if node then
if firstUpdateOfSelectedModel then
firstUpdateOfSelectedModel = false
updateModelState()
end
local ticks = Core.getInput():getMouseWheelTicks()
--linux only ticks=={-50,0,50}
local rotation = 0
if ticks~=0 then
rotation = (ticks>0) and -math.pi/36 or math.pi/36
end
--Rotate around local parent y axist
local rotMat = Matrix()
rotMat:setRotation(Vec3(0,rotation,0))
currentModelMatrix = rotMat * currentModelMatrix
if setttings.enableUseObjectNormal then
local normalMat = Matrix()
local normal = collisionNormal
if normal:length() < 0.01 then
normal = Vec3(0,1,0)
end
if math.abs(normal:normalizeV():dot(currentModelMatrix:getRightVec())) > 0.9 then
normalMat:createMatrixUp(normal, currentModelMatrix:getAtVec())
else
normalMat:createMatrixUp(normal, currentModelMatrix:getRightVec())
end
local localMatrix = normalMat * currentModelMatrix
localMatrix:setPosition(collisionPos)
currentModel:setLocalMatrix(localMatrix )
else
local localMatrix = currentModelMatrix
localMatrix:setPosition(collisionPos)
currentModel:setLocalMatrix(localMatrix )
end
--Collision was found show the model
currentModel:setVisible(true)
--Set the local position to the global position
--currentModel:setLocalPosition(collisionPos)
if collisionPos:length() < 0.1 then
print("No position")
end
if Core.getInput():getMouseDown(MouseKey.left) then
--Create a copy of the model
local model = Model(currentModel)
--Set script
for i=1, #setttings.defaultScripts do
model:loadLuaScript(setttings.defaultScripts[i])
end
--Convert from global space to local space
model:setLocalMatrix( node:getGlobalMatrix():inverseM() * currentModel:getGlobalMatrix() )
--Add model to collision sceneNode
node:addChild( model )
--update model, color, rotation and scale
updateModelState()
end
--print("Colision\n")
else
--No collision was found, hidde the model
currentModel:setVisible(false)
end
--Update basic tool
Tool.update()
return true
end | mit |
dacrybabysuck/darkstar | scripts/globals/items/sausage_roll.lua | 11 | 1482 | -----------------------------------------
-- ID: 4396
-- Item: sausage_roll
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Health % 6 (cap 160)
-- Vitality 3
-- Intelligence -1
-- Attack % 27
-- Attack Cap 30
-- Ranged ATT % 27
-- Ranged ATT Cap 30
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,1800,4396)
end
function onEffectGain(target, effect)
target:addMod(dsp.mod.FOOD_HPP, 6)
target:addMod(dsp.mod.FOOD_HP_CAP, 160)
target:addMod(dsp.mod.VIT, 3)
target:addMod(dsp.mod.INT, -1)
target:addMod(dsp.mod.FOOD_ATTP, 27)
target:addMod(dsp.mod.FOOD_ATT_CAP, 30)
target:addMod(dsp.mod.FOOD_RATTP, 27)
target:addMod(dsp.mod.FOOD_RATT_CAP, 30)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.FOOD_HPP, 6)
target:delMod(dsp.mod.FOOD_HP_CAP, 160)
target:delMod(dsp.mod.VIT, 3)
target:delMod(dsp.mod.INT, -1)
target:delMod(dsp.mod.FOOD_ATTP, 27)
target:delMod(dsp.mod.FOOD_ATT_CAP, 30)
target:delMod(dsp.mod.FOOD_RATTP, 27)
target:delMod(dsp.mod.FOOD_RATT_CAP, 30)
end
| gpl-3.0 |
sk89q/saitohud | src/SaitoHUD/lua/saitohud/geom.lua | 3 | 6250 | -- SaitoHUD
-- Copyright (c) 2009-2010 sk89q <http://www.sk89q.com>
-- Copyright (c) 2010 BoJaN
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- $Id$
local subclassVector = CreateClientConVar("geom_subclass_vector", "0", true, false)
local GEOM = {}
SaitoHUD.GEOM = GEOM
GEOM.Points = {}
GEOM.Lines = {}
GEOM.Planes = {}
GEOM.Angles = {}
--- Makes a dynamic vector class that will update its value every tick
-- (if needed). This is used for vectors local to an entity, so that they can
-- stay up to date.
-- @param constructorFunc Function to construct the object with
-- @param updateFunc Function that should return a new Vector or nil
-- @return Class table (with a __call)
function GEOM.MakeDynamicVectorType()
local v = {}
local mt = {
__call = function(t, ...)
local arg = {...}
local instance = {}
instance._CachedVector = Vector(0, 0, 0)
instance._LastUpdate = 0
instance._Update = function(self)
if CurTime() - self._LastUpdate ~= 0 then
local vec = v.Update(self)
if vec then self._CachedVector = vec end
end
end
local mt = {}
mt.__index = function(t, key)
t:_Update()
local r = t._CachedVector[key]
if type(r) == 'function' then
return function(self, ...)
local arg = {...}
return self._CachedVector[key](self._CachedVector, unpack(arg))
end
end
return r
end
mt.__add = function(a, b) return a._CachedVector.__add(a, b) end
mt.__sub = function(a, b) return a._CachedVector.__sub(a, b) end
mt.__mul = function(a, b) return a._CachedVector.__mul(a, b) end
mt.__div = function(a, b) return a._CachedVector.__div(a, b) end
mt.__mod = function(a, b) return a._CachedVector.__mod(a, b) end
mt.__pow = function(a, b) return a._CachedVector.__pow(a, b) end
setmetatable(instance, mt)
v.Initialize(instance, unpack(arg))
return instance
end
}
setmetatable(v, mt)
return v
end
--- Overrides the Vector object so that dynamic vectors can work seamlessly.
local function OverrideVectorForDynamic()
if not g_GEOMOrigVector then g_GEOMOrigVector = {} end
local keys = {
'Cross', 'Distance', 'Dot', 'DotProduct', '__add', '__sub', '__mul',
'__div', '__mod', '__pow'
}
local vecMt = FindMetaTable("Vector")
for _, key in pairs(keys) do
if not g_GEOMOrigVector[key] then
g_GEOMOrigVector[key] = vecMt[key]
end
vecMt[key] = function(self, ...)
local arg = {...}
if type(self) == 'table' and self._CachedVector then
self = self._CachedVector
end
if type(arg[1]) == 'table' and arg[1]._CachedVector then
arg[1] = arg[1]._CachedVector
end
return g_GEOMOrigVector[key](self, unpack(arg))
end
end
MsgN("Vector subclassed for seamless GOEM functionality")
end
GEOM.EntityRelVector = GEOM.MakeDynamicVectorType()
--- Construct a vector that is relative to an entity.
-- @param x
-- @param y
-- @param z
-- @param ent Entity
function GEOM.EntityRelVector:Initialize(x, y, z, ent)
self.LocalVector = ent:WorldToLocal(Vector(x, y, z))
self.Entity = ent
end
--- Updates the vector.
-- @return Vector
function GEOM.EntityRelVector:Update()
if ValidEntity(self.Entity) then
return self.Entity:LocalToWorld(self.LocalVector)
end
end
GEOM.Ray = SaitoHUD.MakeClass()
--- Creates a ray (point and direction).
-- @param
function GEOM.Ray:Initialize(pt1, pt2)
self.pt1 = pt1
self.pt2 = pt2
end
GEOM.Line = SaitoHUD.MakeClass()
--- Creates a line.
-- @param
function GEOM.Line:Initialize(pt1, pt2)
self.pt1 = pt1
self.pt2 = pt2
end
function GEOM.Line:__tostring()
return tostring(self.pt1) .. " -> " .. tostring(self.pt2)
end
--- Used to get a built-in point.
-- @param key Key
-- @return Vector or nil
function GEOM.GetBuiltInPoint(key)
key = key:lower()
if key == "me" then
return SaitoHUD.GetRefPos()
elseif key == "trace" then
local tr = SaitoHUD.GetRefTrace()
return tr.HitPos
end
end
--- Used to get a built-in line.
-- @param key Key
-- @return Line or nil
function GEOM.GetBuiltInLine(key)
end
function GEOM.SetPoint(key, v)
GEOM.Points[key] = v
end
function GEOM.SetLine(key, v)
GEOM.Lines[key] = v
end
function GEOM.SetPlane(key, v)
GEOM.Planes[key] = v
end
function GEOM.SetAngle(key, v)
if type(v) == "Angle" then v = v:Forward() end
GEOM.Angles[key] = v
end
--- Returns the projection of a point onto a line segment in 3D space.
-- @param line
-- @param point
-- @return Distance
function GEOM.PointLineSegmentProjection(pt, line)
local a = line.pt1:Distance(line.pt1)^2
if a == 0 then return line.pt1 end
local b = (pt - line.pt1):Dot(line.pt2 - line.pt1) / a
if b < 0 then return line.pt1 end
if b > 1 then return line.pt2 end
return line.pt1 + b * (line.pt2 - line.pt1)
end
if subclassVector:GetBool() then
OverrideVectorForDynamic()
end | gpl-2.0 |
kikito/Algorithm-Implementations | Bresenham_Line/Lua/Yonaba/bresenham_test.lua | 27 | 1097 | -- Tests for bresenham.lua
local bresenham = require 'bresenham'
local total, pass = 0, 0
local function dec(str, len)
return #str < len
and str .. (('.'):rep(len-#str))
or str:sub(1,len)
end
local function run(message, f)
total = total + 1
local ok, err = pcall(f)
if ok then pass = pass + 1 end
local status = ok and 'PASSED' or 'FAILED'
print(('%02d. %68s: %s'):format(total, dec(message,68), status))
end
-- Checks if t1 and t2 arrays are the same
local function same(t1, t2)
for k,v in ipairs(t1) do
if t2[k].x ~= v.x or t2[k].y ~= v.y then
return false
end
end
return true
end
run('Testing Bresenham line marching', function()
local expected = {{x = 1, y = 1}, {x = 2, y = 2}, {x = 3, y = 3}, {x = 4, y = 4}, {x = 5, y = 5}}
assert(same(bresenham(1, 1, 5, 5), expected))
local expected = {{x = 1, y = 1}, {x = 2, y = 2}, {x = 2, y = 3}, {x = 3, y = 4}}
assert(same(bresenham(1, 1, 3, 4), expected))
end)
print(('-'):rep(80))
print(('Total : %02d: Pass: %02d - Failed : %02d - Success: %.2f %%')
:format(total, pass, total-pass, (pass*100/total)))
| mit |
dcourtois/premake-core | modules/vstudio/vs2008.lua | 14 | 1387 | --
-- vs2008.lua
-- Add support for the Visual Studio 2008 project formats.
-- Copyright (c) Jason Perkins and the Premake project
--
local p = premake
p.vstudio.vs2008 = {}
local vs2008 = p.vstudio.vs2008
local vstudio = p.vstudio
---
-- Define the Visual Studio 2008 export action.
---
newaction {
-- Metadata for the command line and help system
trigger = "vs2008",
shortname = "Visual Studio 2008",
description = "Generate Visual Studio 2008 project files",
-- Visual Studio always uses Windows path and naming conventions
targetos = "windows",
toolset = "msc-v90",
-- The capabilities of this action
valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Makefile", "None" },
valid_languages = { "C", "C++", "C#", "F#" },
valid_tools = {
cc = { "msc" },
dotnet = { "msnet" },
},
-- Workspace and project generation logic
onWorkspace = vstudio.vs2005.generateSolution,
onProject = vstudio.vs2005.generateProject,
onCleanWorkspace = vstudio.cleanSolution,
onCleanProject = vstudio.cleanProject,
onCleanTarget = vstudio.cleanTarget,
-- This stuff is specific to the Visual Studio exporters
vstudio = {
csprojSchemaVersion = "2.0",
productVersion = "9.0.30729",
solutionVersion = "10",
versionName = "2008",
toolsVersion = "3.5",
}
}
| bsd-3-clause |
dcourtois/premake-core | modules/vstudio/tests/cs2005/test_files.lua | 14 | 9178 | --
-- tests/actions/vstudio/cs2005/test_files.lua
-- Validate generation of <Files/> block in Visual Studio 2005 .csproj
-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("vstudio_cs2005_files")
local dn2005 = p.vstudio.dotnetbase
--
-- Setup
--
local wks, prj
function suite.setup()
p.action.set("vs2005")
wks = test.createWorkspace()
end
local function prepare()
prj = test.getproject(wks, 1)
dn2005.files(prj)
end
--
-- Test grouping and nesting
--
function suite.SimpleSourceFile()
files { "Hello.cs" }
prepare()
test.capture [[
<Compile Include="Hello.cs" />
]]
end
function suite.NestedSourceFile()
files { "Src/Hello.cs" }
prepare()
test.capture [[
<Compile Include="Src\Hello.cs" />
]]
end
function suite.PerConfigFile()
files { "Hello.cs" }
configuration { 'debug' }
files { "HelloTwo.cs" }
prepare()
test.capture [[
<Compile Include="Hello.cs" />
<Compile Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' " Include="HelloTwo.cs" />
]]
end
--
-- Test file dependencies
--
function suite.resourceDesignerDependency()
files { "Resources.resx", "Resources.Designer.cs" }
prepare()
test.capture [[
<Compile Include="Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
]]
end
function suite.publicResourceDesignerDependency()
files { "Resources.resx", "Resources.Designer.cs" }
resourcegenerator 'public'
prepare()
test.capture [[
<Compile Include="Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
]]
end
function suite.settingsDesignerDependency()
files { "Properties/Settings.settings", "Properties/Settings.Designer.cs" }
prepare()
test.capture [[
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
]]
end
function suite.datasetDesignerDependency()
files { "DataSet.xsd", "DataSet.Designer.cs" }
prepare()
test.capture [[
<Compile Include="DataSet.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>DataSet.xsd</DependentUpon>
</Compile>
<None Include="DataSet.xsd">
<Generator>MSDataSetGenerator</Generator>
<LastGenOutput>DataSet.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</None>
]]
end
function suite.datasetDependencies()
files { "DataSet.xsd", "DataSet.xsc", "DataSet.xss" }
prepare()
test.capture [[
<None Include="DataSet.xsc">
<DependentUpon>DataSet.xsd</DependentUpon>
</None>
<None Include="DataSet.xsd" />
<None Include="DataSet.xss">
<DependentUpon>DataSet.xsd</DependentUpon>
</None>
]]
end
function suite.textTemplatingDependency()
files { "foobar.tt", "foobar.cs" }
prepare()
test.capture [[
<Compile Include="foobar.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>foobar.tt</DependentUpon>
</Compile>
<Content Include="foobar.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>foobar.cs</LastGenOutput>
</Content>
]]
end
--
-- File associations should always be made relative to the file
-- which is doing the associating.
--
function suite.resourceDependency_inSubfolder()
files { "Forms/TreeListView.resx", "Forms/TreeListView.cs" }
prepare()
test.capture [[
<Compile Include="Forms\TreeListView.cs" />
<EmbeddedResource Include="Forms\TreeListView.resx">
<DependentUpon>TreeListView.cs</DependentUpon>
</EmbeddedResource>
]]
end
function suite.datasetDependency_inSubfolder()
files { "DataSets/DataSet.xsd", "DataSets/DataSet.Designer.cs" }
prepare()
test.capture [[
<Compile Include="DataSets\DataSet.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>DataSet.xsd</DependentUpon>
</Compile>
<None Include="DataSets\DataSet.xsd">
<Generator>MSDataSetGenerator</Generator>
<LastGenOutput>DataSet.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</None>
]]
end
--
-- Test build actions.
--
function suite.copyAction()
files { "Hello.txt" }
filter "files:**.txt"
buildaction "Copy"
prepare()
test.capture [[
<Content Include="Hello.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
]]
end
function suite.componentAction()
files { "Hello.cs" }
filter "files:Hello.cs"
buildaction "Component"
prepare()
test.capture [[
<Compile Include="Hello.cs">
<SubType>Component</SubType>
</Compile>
]]
end
function suite.embeddedResourceAction()
files { "Hello.ico" }
filter "files:*.ico"
buildaction "Embed"
prepare()
test.capture [[
<EmbeddedResource Include="Hello.ico" />
]]
end
function suite.formAction()
files { "HelloForm.cs" }
filter "files:HelloForm.cs"
buildaction "Form"
prepare()
test.capture [[
<Compile Include="HelloForm.cs">
<SubType>Form</SubType>
</Compile>
]]
end
function suite.userControlAction()
files { "Hello.cs" }
filter "files:Hello.cs"
buildaction "UserControl"
prepare()
test.capture [[
<Compile Include="Hello.cs">
<SubType>UserControl</SubType>
</Compile>
]]
end
function suite.resourceAction()
files { "Hello.ico" }
filter "files:*.ico"
buildaction "Resource"
prepare()
test.capture [[
<Resource Include="Hello.ico" />
]]
end
--
-- Files that exist outside the project folder should be added as
-- links, with a relative path. Weird but true.
--
function suite.usesLink_onExternalSourceCode()
files { "../Hello.cs" }
prepare()
test.capture [[
<Compile Include="..\Hello.cs">
<Link>Hello.cs</Link>
</Compile>
]]
end
function suite.usesLinkInFolder_onExternalSourceCode()
files { "../Src/Hello.cs" }
prepare()
test.capture [[
<Compile Include="..\Src\Hello.cs">
<Link>Src\Hello.cs</Link>
</Compile>
]]
end
function suite.usesLinkInFolder_onExternalContent()
files { "../Resources/Hello.txt" }
filter "files:**.txt"
buildaction "Copy"
prepare()
test.capture [[
<Content Include="..\Resources\Hello.txt">
<Link>Resources\Hello.txt</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
]]
end
function suite.usesLinkInFolder_onExternalReference()
files { "../Resources/Hello.txt" }
prepare()
test.capture [[
<None Include="..\Resources\Hello.txt">
<Link>Resources\Hello.txt</Link>
</None>
]]
end
--
-- Files that exist outside the project's folder are allowed to be
-- placed into a folder using a virtual path, which is better than
-- dropping them at the root. Files within the project folder cannot
-- use virtual paths, because Visual Studio won't allow it.
--
function suite.usesLinks_onVpath_onLocalSourceFile()
files { "Hello.cs" }
vpaths { ["Sources"] = "**.cs" }
prepare()
test.capture [[
<Compile Include="Hello.cs" />
]]
end
function suite.usesLinks_onVpath_onExternalSourceFile()
files { "../Src/Hello.cs" }
vpaths { ["Sources"] = "../**.cs" }
prepare()
test.capture [[
<Compile Include="..\Src\Hello.cs">
<Link>Sources\Hello.cs</Link>
</Compile>
]]
end
--
-- Check WPF XAML handling.
--
function suite.associatesFiles_onXamlForm()
files { "MainWindow.xaml", "MainWindow.xaml.cs" }
prepare()
test.capture [[
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
]]
end
function suite.xamlApp_onAppXaml()
files { "App.xaml", "App.xaml.cs" }
prepare()
test.capture [[
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
]]
end
function suite.xamlApp_onBuildAction()
files { "MyApp.xaml", "MyApp.xaml.cs" }
filter "files:MyApp.xaml"
buildaction "Application"
prepare()
test.capture [[
<ApplicationDefinition Include="MyApp.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="MyApp.xaml.cs">
<DependentUpon>MyApp.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
]]
end
| bsd-3-clause |
andeandr100/Crumbled-World | Lua/Tower/supportManager.lua | 1 | 6858 | require("Tower/upgrade.lua")
SupportManager = {}
function SupportManager.new()
local self = {}
local upgrade --upgrade = Upgrade.new()
local comUnitTable
local comUnit = Core.getComUnit()
local onChangeCallback
--
local PERUNITDAMGINCPERLEVEL = 10
local PERDAMGINCPERLEVEL = 0.10
--
local restartListenerSupport
--
local supportLevel = {}
-- function: fixLevel
-- purpose: To set the correct upgrade level for a specefic upgrade
-- upg: The name of the upgrade
-- level: What level is should have
local function fixLevel(upg,level)
print("fixLevel("..upg..","..level..")")
local dCount = 0
while upgrade.getLevel(upg)~=level do
dCount = dCount + 1
print("upgrade.getLevel("..upg..") = "..upgrade.getLevel(upg))
print("level = "..level)
if upgrade.getLevel(upg)>level then
upgrade.degrade(upg)
else
upgrade.upgrade(upg)
end
if dCount==5 then
abort()
end
end
end
-- function: updateSupportUpgrades
-- purpose: fix all level for all upgrades
-- upg: The name of the upgrade
local function updateSupportUpgrades(upg)
--support
if supportLevel[upg] then
local maxLevel = 0
for k,v in pairs(supportLevel[upg]) do
maxLevel = math.max(maxLevel, v)
end
fixLevel(upg,maxLevel)
end
end
-- function: handleSupportDamage
-- purpose: a help function for calculating who the damge should be attributed to
-- upg: The name of the upgrade
-- damage: The amount of damage dealt
-- return: The amount of damage the tower actual did by it self
function self.handleSupportDamage(damage)
local tab = {}
if supportLevel["supportDamage"] then
local maxLevel = 0
for k,v in pairs(supportLevel["supportDamage"]) do
if v>maxLevel then
tab = {[1]=k}
maxLevel = v
elseif v==maxLevel then
tab[#tab+1] = k
end
end
--
local tDamage = damage*( 1.0/(1.0+(maxLevel*PERDAMGINCPERLEVEL)) )
local sDamage = damage*( (maxLevel*PERDAMGINCPERLEVEL)/(1.0+(maxLevel*PERDAMGINCPERLEVEL)) )
local size = #tab
for i=1, size do
comUnit:sendTo(tab[i],"dmgDealtMarkOfDeath",tostring(sDamage/size) )--dmgDealtMarkOfDeath only because it already does it, just wrong name
end
fixLevel("supportDamage",maxLevel)
return tDamage
end
return damage
end
-- function: handle
-- purpose: a help function for handleSupportRange, handleSupportDamage
-- upg: The name of the upgrade
-- param: the level of the tower
-- index: what tower it is from
local function handle(upg, param, index)
local level = tonumber(param)
supportLevel[upg] = supportLevel[upg] or {}
supportLevel[upg][index] = level
--fix level on all upgrades
updateSupportUpgrades(upg)
end
-- function: handleSupportRange
-- purpose: a support tower has been upgraded or sold
-- param: the level of the tower
-- index: what tower it is from
local function handleSupportRange(param,index)
handle("supportRange",param,index)
if onChangeCallback then
onChangeCallback()
end
end
-- function: handleSupportDamage
-- purpose: a support tower has been upgraded or sold
-- param: the level of the tower
-- index: what tower it is from
local function handleSupportDamage(param,index)
handle("supportDamage",param,index)
if onChangeCallback then
onChangeCallback()
end
end
-- function: handleSupportBoost
-- purpose: a support tower has been upgraded or sold
-- param: the level of the tower
-- index: what tower it is from
local function handleSupportBoost(param,index)
if upgrade.getLevel("supportBoost")==0 then
upgrade.upgrade("supportBoost")
end
end
-- function: setUpgrade
-- purpose: Sets the upgrade class, that will be used
-- upg: The class that will be used
function self.setUpgrade(upg)
upgrade = upg
end
-- function: addHiddenUpgrades
-- purpose: Add the hidden upgrades for the support tower to the upgrade list
function self.addHiddenUpgrades()
-- restartListenerSupport = Listener("RestartWave")
-- restartListenerSupport:registerEvent("restartWave", self.waveRestart)
--
if not upgrade then
error("The setUpgrade must have been used")
else
--local function spportBoostDamage() return upgrade.getStats("damage")*(1.0+math.clamp(0.25+(waveCount/100),0.25,0.5)) end
upgrade.addUpgrade( { cost = 0,
name = "supportBoost",
info = "support boost",
order = 9,
duration = 10,
cooldown = 0,
icon = 68,
hidden = true,
stats = { damage = { upgrade.mul, 1.80, ""},
range = { upgrade.mul, 1.15 } }
} )
upgrade.addUpgrade( { cost = 0,
name = "supportRange",
info = "support manager range",
icon = 65,
order = 7,
hidden = true,
value1 = 10,
stats = { range = { upgrade.mul, 1+(PERDAMGINCPERLEVEL*1) }}
} )
upgrade.addUpgrade( { cost = 0,
name = "supportRange",
info = "support manager range",
icon = 65,
order = 7,
hidden = true,
value1 = 20,
stats = { range = { upgrade.mul, 1+(PERDAMGINCPERLEVEL*2) }}
} )
upgrade.addUpgrade( { cost = 0,
name = "supportRange",
info = "support manager range",
icon = 65,
order = 7,
hidden = true,
value1 = 30,
stats = { range = { upgrade.mul, 1+(PERDAMGINCPERLEVEL*3) }}
} )
upgrade.addUpgrade( { cost = 0,
name = "supportDamage",
info = "support manager damage",
icon = 64,
order = 8,
hidden = true,
value1 = 10,
stats = { damage = { upgrade.mul, 1+(PERDAMGINCPERLEVEL*1) }}
} )
upgrade.addUpgrade( { cost = 0,
name = "supportDamage",
info = "support manager damage",
icon = 64,
order = 8,
hidden = true,
value1 = 20,
stats = { damage = { upgrade.mul, 1+(PERDAMGINCPERLEVEL*2) }}
} )
upgrade.addUpgrade( { cost = 0,
name = "supportDamage",
info = "support manager damage",
icon = 64,
order = 8,
hidden = true,
value1 = 30,
stats = { damage = { upgrade.mul, 1+(PERDAMGINCPERLEVEL*3) }}
} )
end
end
-- function: setComUnitTable
-- purpose: Sets what comUnitTable will be used
function self.setComUnitTable(pcomUnitTable)
comUnitTable = pcomUnitTable
end
-- function: addCallbacks
-- purpose: Adds all callbacks that will be used for the support tower
function self.addCallbacks()
comUnitTable["supportRange"] = handleSupportRange
comUnitTable["supportDamage"] = handleSupportDamage
comUnitTable["supportBoost"] = handleSupportBoost
end
function self.addSetCallbackOnChange(func)
onChangeCallback = func
end
function self.restartWave()
supportLevel = {}
end
return self
end | mit |
gpedro/otclient | modules/gamelib/protocol.lua | 4 | 8464 | GameServerOpcodes = {
GameServerInitGame = 10,
GameServerGMActions = 11,
GameServerEnterGame = 15,
GameServerLoginError = 20,
GameServerLoginAdvice = 21,
GameServerLoginWait = 22,
GameServerAddCreature = 23,
GameServerPingBack = 29,
GameServerPing = 30,
GameServerChallenge = 31,
GameServerDeath = 40,
-- all in game opcodes must be greater than 50
GameServerFirstGameOpcode = 50,
-- otclient ONLY
GameServerExtendedOpcode = 50,
-- NOTE: add any custom opcodes in this range
-- 51 - 99
-- original tibia ONLY
GameServerFullMap = 100,
GameServerMapTopRow = 101,
GameServerMapRightRow = 102,
GameServerMapBottomRow = 103,
GameServerMapLeftRow = 104,
GameServerUpdateTile = 105,
GameServerCreateOnMap = 106,
GameServerChangeOnMap = 107,
GameServerDeleteOnMap = 108,
GameServerMoveCreature = 109,
GameServerOpenContainer = 110,
GameServerCloseContainer = 111,
GameServerCreateContainer = 112,
GameServerChangeInContainer = 113,
GameServerDeleteInContainer = 114,
GameServerSetInventory = 120,
GameServerDeleteInventory = 121,
GameServerOpenNpcTrade = 122,
GameServerPlayerGoods = 123,
GameServerCloseNpcTrade = 124,
GameServerOwnTrade = 125,
GameServerCounterTrade = 126,
GameServerCloseTrade = 127,
GameServerAmbient = 130,
GameServerGraphicalEffect = 131,
GameServerTextEffect = 132,
GameServerMissleEffect = 133,
GameServerMarkCreature = 134,
GameServerTrappers = 135,
GameServerCreatureHealth = 140,
GameServerCreatureLight = 141,
GameServerCreatureOutfit = 142,
GameServerCreatureSpeed = 143,
GameServerCreatureSkull = 144,
GameServerCreatureParty = 145,
GameServerCreatureUnpass = 146,
GameServerEditText = 150,
GameServerEditList = 151,
GameServerPlayerDataBasic = 159, -- 910
GameServerPlayerData = 160,
GameServerPlayerSkills = 161,
GameServerPlayerState = 162,
GameServerClearTarget = 163,
GameServerSpellDelay = 164, --870
GameServerSpellGroupDelay = 165, -- 870
GameServerMultiUseDelay = 166, -- 870
GameServerTalk = 170,
GameServerChannels = 171,
GameServerOpenChannel = 172,
GameServerOpenPrivateChannel = 173,
GameServerRuleViolationChannel = 174,
GameServerRuleViolationRemove = 175,
GameServerRuleViolationCancel = 176,
GameServerRuleViolationLock = 177,
GameServerOpenOwnChannel = 178,
GameServerCloseChannel = 179,
GameServerTextMessage = 180,
GameServerCancelWalk = 181,
GameServerWalkWait = 182,
GameServerFloorChangeUp = 190,
GameServerFloorChangeDown = 191,
GameServerChooseOutfit = 200,
GameServerVipAdd = 210,
GameServerVipLogin = 211,
GameServerVipLogout = 212,
GameServerTutorialHint = 220,
GameServerAutomapFlag = 221,
GameServerQuestLog = 240,
GameServerQuestLine = 241,
GameServerChannelEvent = 243, -- 910
GameServerItemInfo = 244, -- 910
GameServerPlayerInventory = 245, -- 910
GameServerMarketEnter = 246, -- 944
GameServerMarketLeave = 247, -- 944
GameServerMarketDetail = 248, -- 944
GameServerMarketBrowse = 249, -- 944
GameServerShowModalDialog = 250 -- 960
}
ClientOpcodes = {
ClientEnterAccount = 1,
ClientEnterGame = 10,
ClientLeaveGame = 20,
ClientPing = 29,
ClientPingBack = 30,
-- all in game opcodes must be equal or greater than 50
ClientFirstGameOpcode = 50,
-- otclient ONLY
ClientExtendedOpcode = 50,
-- NOTE: add any custom opcodes in this range
-- 51 - 99
-- original tibia ONLY
ClientAutoWalk = 100,
ClientWalkNorth = 101,
ClientWalkEast = 102,
ClientWalkSouth = 103,
ClientWalkWest = 104,
ClientStop = 105,
ClientWalkNorthEast = 106,
ClientWalkSouthEast = 107,
ClientWalkSouthWest = 108,
ClientWalkNorthWest = 109,
ClientTurnNorth = 111,
ClientTurnEast = 112,
ClientTurnSouth = 113,
ClientTurnWest = 114,
ClientEquipItem = 119, -- 910
ClientMove = 120,
ClientInspectNpcTrade = 121,
ClientBuyItem = 122,
ClientSellItem = 123,
ClientCloseNpcTrade = 124,
ClientRequestTrade = 125,
ClientInspectTrade = 126,
ClientAcceptTrade = 127,
ClientRejectTrade = 128,
ClientUseItem = 130,
ClientUseItemWith = 131,
ClientUseOnCreature = 132,
ClientRotateItem = 133,
ClientCloseContainer = 135,
ClientUpContainer = 136,
ClientEditText = 137,
ClientEditList = 138,
ClientLook = 140,
ClientTalk = 150,
ClientRequestChannels = 151,
ClientJoinChannel = 152,
ClientLeaveChannel = 153,
ClientOpenPrivateChannel = 154,
ClientCloseNpcChannel = 158,
ClientChangeFightModes = 160,
ClientAttack = 161,
ClientFollow = 162,
ClientInviteToParty = 163,
ClientJoinParty = 164,
ClientRevokeInvitation = 165,
ClientPassLeadership = 166,
ClientLeaveParty = 167,
ClientShareExperience = 168,
ClientDisbandParty = 169,
ClientOpenOwnChannel = 170,
ClientInviteToOwnChannel = 171,
ClientExcludeFromOwnChannel = 172,
ClientCancelAttackAndFollow = 190,
ClientRefreshContainer = 202,
ClientRequestOutfit = 210,
ClientChangeOutfit = 211,
ClientMount = 212, -- 870
ClientAddVip = 220,
ClientRemoveVip = 221,
ClientBugReport = 230,
ClientRuleViolation = 231,
ClientDebugReport = 232,
ClientRequestQuestLog = 240,
ClientRequestQuestLine = 241,
ClientNewRuleViolation = 242, -- 910
ClientRequestItemInfo = 243, -- 910
ClientMarketLeave = 244, -- 944
ClientMarketBrowse = 245, -- 944
ClientMarketCreate = 246, -- 944
ClientMarketCancel = 247, -- 944
ClientMarketAccept = 248, -- 944
ClientAnswerModalDialog = 249 -- 960
}
| mit |
branden/dcos | packages/adminrouter/extra/src/lib/cache.lua | 1 | 23176 | local cjson_safe = require "cjson.safe"
local shmlock = require "resty.lock"
local http = require "resty.http"
local resolver = require "resty.resolver"
local util = require "util"
-- In order to make caching code testable, these constants need to be
-- configurable/exposed through env vars.
--
-- Values assigned to these variable need to fufil following condition:
--
-- CACHE_FIRST_POLL_DELAY << CACHE_EXPIRATION < CACHE_POLL_PERIOD < CACHE_MAX_AGE_SOFT_LIMIT < CACHE_MAX_AGE_HARD_LIMIT
--
-- CACHE_BACKEND_REQUEST_TIMEOUT << CACHE_REFRESH_LOCK_TIMEOUT
--
-- Before changing CACHE_POLL_INTERVAL, please check the comment for resolver
-- statement configuration in includes/http/master.conf
--
-- All are in units of seconds. Below are the defaults:
local _CONFIG = {}
local env_vars = {CACHE_FIRST_POLL_DELAY = 2,
CACHE_POLL_PERIOD = 25,
CACHE_EXPIRATION = 20,
CACHE_MAX_AGE_SOFT_LIMIT = 75,
CACHE_MAX_AGE_HARD_LIMIT = 259200,
CACHE_BACKEND_REQUEST_TIMEOUT = 10,
CACHE_REFRESH_LOCK_TIMEOUT = 20,
}
for key, value in pairs(env_vars) do
-- yep, we are OK with key==nil, tonumber will just return nil
local env_var_val = tonumber(os.getenv(key))
if env_var_val == nil or env_var_val == value then
ngx.log(ngx.DEBUG, "Using default ".. key .. " value: `" .. value .. "` seconds")
_CONFIG[key] = value
else
ngx.log(ngx.NOTICE,
key .. " overridden by ENV to `" .. env_var_val .. "` seconds")
_CONFIG[key] = env_var_val
end
end
local function cache_data(key, value)
-- Store key/value pair to SHM cache (shared across workers).
-- Return true upon success, false otherwise.
-- Expected to run within lock context.
local cache = ngx.shared.cache
local success, err, forcible = cache:set(key, value)
if success then
return true
end
ngx.log(
ngx.ERR,
"Could not store " .. key .. " to state cache: " .. err
)
return false
end
local function request(url, accept_404_reply, auth_token)
local headers = {["User-Agent"] = "Master Admin Router"}
if auth_token ~= nil then
headers["Authorization"] = "token=" .. auth_token
end
-- Use cosocket-based HTTP library, as ngx subrequests are not available
-- from within this code path (decoupled from nginx' request processing).
-- The timeout parameter is given in milliseconds. The `request_uri`
-- method takes care of parsing scheme, host, and port from the URL.
local httpc = http.new()
httpc:set_timeout(_CONFIG.CACHE_BACKEND_REQUEST_TIMEOUT * 1000)
local res, err = httpc:request_uri(url, {
method="GET",
headers=headers,
ssl_verify=true
})
if not res then
return nil, err
end
if res.status ~= 200 then
if accept_404_reply and res.status ~= 404 or not accept_404_reply then
return nil, "invalid response status: " .. res.status
end
end
ngx.log(
ngx.NOTICE,
"Request url: " .. url .. " " ..
"Response Body length: " .. string.len(res.body) .. " bytes."
)
return res, nil
end
local function is_ip_per_task(app)
return app["ipAddress"] ~= nil and app["ipAddress"] ~= cjson_safe.null
end
local function is_user_network(app)
local container = app["container"]
return container and container["type"] == "DOCKER" and container["docker"]["network"] == "USER"
end
local function fetch_and_store_marathon_apps(auth_token)
-- Access Marathon through localhost.
ngx.log(ngx.NOTICE, "Cache Marathon app state")
local appsRes, err = request(UPSTREAM_MARATHON .. "/v2/apps?embed=apps.tasks&label=DCOS_SERVICE_NAME",
false,
auth_token)
if err then
ngx.log(ngx.NOTICE, "Marathon app request failed: " .. err)
return
end
local apps, err = cjson_safe.decode(appsRes.body)
if not apps then
ngx.log(ngx.WARN, "Cannot decode Marathon apps JSON: " .. err)
return
end
local svcApps = {}
for _, app in ipairs(apps["apps"]) do
local appId = app["id"]
local labels = app["labels"]
if not labels then
ngx.log(ngx.NOTICE, "Labels not found in app '" .. appId .. "'")
goto continue
end
-- Service name should exist as we asked Marathon for it
local svcId = util.normalize_service_name(labels["DCOS_SERVICE_NAME"])
local scheme = labels["DCOS_SERVICE_SCHEME"]
if not scheme then
ngx.log(ngx.NOTICE, "Cannot find DCOS_SERVICE_SCHEME for app '" .. appId .. "'")
goto continue
end
local portIdx = labels["DCOS_SERVICE_PORT_INDEX"]
if not portIdx then
ngx.log(ngx.NOTICE, "Cannot find DCOS_SERVICE_PORT_INDEX for app '" .. appId .. "'")
goto continue
end
local portIdx = tonumber(portIdx)
if not portIdx then
ngx.log(ngx.NOTICE, "Cannot convert port to number for app '" .. appId .. "'")
goto continue
end
-- Lua arrays default starting index is 1 not the 0 of marathon
portIdx = portIdx + 1
local tasks = app["tasks"]
-- Process only tasks in TASK_RUNNING state.
-- From http://lua-users.org/wiki/TablesTutorial: "inside a pairs loop,
-- it's safe to reassign existing keys or remove them"
for i, t in ipairs(tasks) do
if t["state"] ~= "TASK_RUNNING" then
table.remove(tasks, i)
end
end
-- next() returns nil if table is empty.
local i, task = next(tasks)
if i == nil then
ngx.log(ngx.NOTICE, "No task in state TASK_RUNNING for app '" .. appId .. "'")
goto continue
end
ngx.log(
ngx.NOTICE,
"Reading state for appId '" .. appId .. "' from task with id '" .. task["id"] .. "'"
)
local host_or_ip = task["host"] --take host by default
if is_ip_per_task(app) then
ngx.log(ngx.NOTICE, "app '" .. appId .. "' is using ip-per-task")
-- override with the ip of the task
local task_ip_addresses = task["ipAddresses"]
if task_ip_addresses then
host_or_ip = task_ip_addresses[1]["ipAddress"]
else
ngx.log(ngx.NOTICE, "no ip address allocated yet for app '" .. appId .. "'")
goto continue
end
end
if not host_or_ip then
ngx.log(ngx.NOTICE, "Cannot find host or ip for app '" .. appId .. "'")
goto continue
end
local ports = task["ports"] --task host port mapping by default
if is_ip_per_task(app) then
ports = {}
if is_user_network(app) then
-- override with ports from the container's portMappings
local port_mappings = app["container"]["docker"]["portMappings"] or app["portDefinitions"] or {}
local port_attr = app["container"]["docker"]["portMappings"] and "containerPort" or "port"
for _, port_mapping in ipairs(port_mappings) do
table.insert(ports, port_mapping[port_attr])
end
else
--override with the discovery ports
local discovery_ports = app["ipAddress"]["discovery"]["ports"]
for _, discovery_port in ipairs(discovery_ports) do
table.insert(ports, discovery_port["number"])
end
end
end
if not ports then
ngx.log(ngx.NOTICE, "Cannot find ports for app '" .. appId .. "'")
goto continue
end
local port = ports[portIdx]
if not port then
ngx.log(ngx.NOTICE, "Cannot find port at Marathon port index '" .. (portIdx - 1) .. "' for app '" .. appId .. "'")
goto continue
end
local url = scheme .. "://" .. host_or_ip .. ":" .. port
svcApps[svcId] = {scheme=scheme, url=url}
::continue::
end
svcApps_json = cjson_safe.encode(svcApps)
ngx.log(ngx.DEBUG, "Storing Marathon apps data to SHM.")
if not cache_data("svcapps", svcApps_json) then
ngx.log(ngx.ERR, "Storing marathon apps cache failed")
return
end
ngx.update_time()
local time_now = ngx.now()
if cache_data("svcapps_last_refresh", time_now) then
ngx.log(ngx.INFO, "Marathon apps cache has been successfully updated")
end
return
end
function store_leader_data(leader_name, leader_ip)
if HOST_IP == 'unknown' or leader_ip == 'unknown' then
ngx.log(ngx.ERR,
"Private IP address of the host is unknown, aborting cache-entry creation for ".. leader_name .. " leader")
mleader = '{"is_local": "unknown", "leader_ip": null}'
elseif leader_ip == HOST_IP then
mleader = '{"is_local": "yes", "leader_ip": "'.. HOST_IP ..'"}'
ngx.log(ngx.INFO, leader_name .. " leader is local")
else
mleader = '{"is_local": "no", "leader_ip": "'.. leader_ip ..'"}'
ngx.log(ngx.INFO, leader_name .. " leader is non-local: `" .. leader_ip .. "`")
end
ngx.log(ngx.DEBUG, "Storing " .. leader_name .. " leader to SHM")
if not cache_data(leader_name .. "_leader", mleader) then
ngx.log(ngx.ERR, "Storing " .. leader_name .. " leader cache failed")
return
end
ngx.update_time()
local time_now = ngx.now()
if cache_data(leader_name .. "_leader_last_refresh", time_now) then
ngx.log(ngx.INFO, leader_name .. " leader cache has been successfully updated")
end
return
end
local function fetch_generic_leader(leaderAPI_url, leader_name, auth_token)
local mleaderRes, err = request(leaderAPI_url, true, auth_token)
if err then
ngx.log(ngx.WARN, leader_name .. " leader request failed: " .. err)
return nil
end
-- We need to translate 404 reply into a JSON that is easy to process for
-- endpoints. I.E.:
-- https://mesosphere.github.io/marathon/docs/rest-api.html#get-v2-leader
local res_body
if mleaderRes.status == 404 then
-- Just a hack in order to avoid using gotos - create a substitute JSON
-- that can be parsed and processed by normal execution path and at the
-- same time passes the information of a missing Marathon leader.
ngx.log(ngx.NOTICE, "Using empty " .. leader_name .. " leader JSON")
res_body = '{"leader": "unknown:0"}'
else
res_body = mleaderRes.body
end
local mleader, err = cjson_safe.decode(res_body)
if not mleader then
ngx.log(ngx.WARN, "Cannot decode " .. leader_name .. " leader JSON: " .. err)
return nil
end
return mleader['leader']:split(":")[1]
end
local function fetch_and_store_marathon_leader(auth_token)
leader_ip = fetch_generic_leader(
UPSTREAM_MARATHON .. "/v2/leader", "marathon", auth_token)
if leader_ip ~= nil then
store_leader_data("marathon", leader_ip)
end
end
local function fetch_and_store_state_mesos(auth_token)
-- Fetch state JSON summary from Mesos. If successful, store to SHM cache.
-- Expected to run within lock context.
local response, err = request(UPSTREAM_MESOS .. "/master/state-summary",
false,
auth_token)
if err then
ngx.log(ngx.NOTICE, "Mesos state request failed: " .. err)
return
end
local raw_state_summary, err = cjson_safe.decode(response.body)
if not raw_state_summary then
ngx.log(ngx.WARN, "Cannot decode Mesos state-summary JSON: " .. err)
return
end
local parsed_state_summary = {}
parsed_state_summary['f_by_id'] = {}
parsed_state_summary['f_by_name'] = {}
parsed_state_summary['agent_pids'] = {}
for _, framework in ipairs(raw_state_summary["frameworks"]) do
local f_id = framework["id"]
local f_name = util.normalize_service_name(framework["name"])
parsed_state_summary['f_by_id'][f_id] = {}
parsed_state_summary['f_by_id'][f_id]['webui_url'] = framework["webui_url"]
parsed_state_summary['f_by_id'][f_id]['name'] = f_name
parsed_state_summary['f_by_name'][f_name] = {}
parsed_state_summary['f_by_name'][f_name]['webui_url'] = framework["webui_url"]
end
for _, agent in ipairs(raw_state_summary["slaves"]) do
a_id = agent["id"]
parsed_state_summary['agent_pids'][a_id] = agent["pid"]
end
local parsed_state_summary_json = cjson_safe.encode(parsed_state_summary)
ngx.log(ngx.DEBUG, "Storing parsed Mesos state to SHM.")
if not cache_data("mesosstate", parsed_state_summary_json) then
ngx.log(ngx.WARN, "Storing parsed Mesos state to cache failed")
return
end
ngx.update_time()
local time_now = ngx.now()
if cache_data("mesosstate_last_refresh", time_now) then
ngx.log(ngx.INFO, "Mesos state cache has been successfully updated")
end
return
end
local function fetch_mesos_leader_state()
-- Lua forbids jumping over local variables definition, hence we define all
-- of them here.
local r, err, answers
-- We want to use Navstar's dual-dispatch approach and get the response
-- as fast as possible from any operational MesosDNS. If we set it to local
-- instance, its failure will break this part of the cache as well.
--
-- As for the DNS TTL - we're on purpose ignoring it and going with own
-- refresh cycle period. Assuming that Navstar and MesosDNS do not do
-- caching on their own, we just treat DNS as an interface to obtain
-- current mesos leader data. How long we cache it is just an internal
-- implementation detail of AR.
--
-- Also, see https://github.com/openresty/lua-resty-dns#limitations
r, err = resolver:new{
nameservers = {{"198.51.100.1", 53},
{"198.51.100.2", 53},
{"198.51.100.3", 53}},
retrans = 3, -- retransmissions on receive timeout
timeout = 2000, -- msec
}
if not r then
ngx.log(ngx.ERR, "Failed to instantiate the resolver: " .. err)
return nil
end
answers, err = r:query("leader.mesos")
if not answers then
ngx.log(ngx.ERR, "Failed to query the DNS server: " .. err)
return nil
end
if answers.errcode then
ngx.log(ngx.ERR,
"DNS server returned error code: " .. answers.errcode .. ": " .. answers.errstr)
return nil
end
if util.table_len(answers) == 0 then
ngx.log(ngx.ERR,
"DNS server did not return anything for leader.mesos")
return nil
end
-- Yes, we are assuming that leader.mesos will always be just one A entry.
-- AAAA support is a different thing...
return answers[1].address
end
local function fetch_and_store_mesos_leader()
leader_ip = fetch_mesos_leader_state()
if leader_ip ~= nil then
store_leader_data("mesos", leader_ip)
end
end
local function refresh_needed(ts_name)
-- ts_name (str): name of the '*_last_refresh' timestamp to check
local cache = ngx.shared.cache
local last_fetch_time = cache:get(ts_name)
-- Handle the special case of first invocation.
if not last_fetch_time then
ngx.log(ngx.INFO, "Cache `".. ts_name .. "` empty. Fetching.")
return true
end
ngx.update_time()
local cache_age = ngx.now() - last_fetch_time
if cache_age > _CONFIG.CACHE_EXPIRATION then
ngx.log(ngx.INFO, "Cache `".. ts_name .. "` expired. Refresh.")
return true
end
ngx.log(ngx.DEBUG, "Cache `".. ts_name .. "` populated and fresh. NOOP.")
return false
end
local function refresh_cache(from_timer, auth_token)
-- Refresh cache in case when it expired or has not been created yet.
-- Use SHM-based lock for synchronizing coroutines across worker processes.
--
-- This function can be invoked via two mechanisms:
--
-- * Via ngx.timer (in a coroutine), which is triggered
-- periodically in all worker processes for performing an
-- out-of-band cache refresh (this is the usual mode of operation).
-- In that case, perform cache invalidation only if no other timer
-- instance currently does so (abort if lock cannot immediately be
-- acquired).
--
-- * During HTTP request processing, when cache content is
-- required for answering the request but the cache was not
-- populated yet (i.e. usually early after nginx startup).
-- In that case, return from this function only after the cache
-- has been populated (block on lock acquisition).
--
-- Args:
-- from_timer: set to true if invoked from a timer
-- Acquire lock.
local lock
-- In order to avoid deadlocks, we are relying on `exptime` param of
-- resty.lock (https://github.com/openresty/lua-resty-lock#new)
--
-- It's value is maximum time it may take to fetch data from all the
-- backends (ATM 2xMarathon + Mesos) plus an arbitrary two seconds period
-- just to be on the safe side.
local lock_ttl = 3 * (_CONFIG.CACHE_BACKEND_REQUEST_TIMEOUT + 2)
if from_timer then
ngx.log(ngx.INFO, "Executing cache refresh triggered by timer")
-- Fail immediately if another worker currently holds
-- the lock, because a single timer-based update at any
-- given time suffices.
lock = shmlock:new("shmlocks", {timeout=0, exptime=lock_ttl})
local elapsed, err = lock:lock("cache")
if elapsed == nil then
ngx.log(ngx.INFO, "Timer-based update is in progress. NOOP.")
return
end
else
ngx.log(ngx.INFO, "Executing cache refresh triggered by request")
-- Cache content is required for current request
-- processing. Wait for lock acquisition, for at
-- most 20 seconds.
lock = shmlock:new("shmlocks", {timeout=_CONFIG.CACHE_REFRESH_LOCK_TIMEOUT,
exptime=lock_ttl })
local elapsed, err = lock:lock("cache")
if elapsed == nil then
ngx.log(ngx.ERR, "Could not acquire lock: " .. err)
-- Leave early (did not make sure that cache is populated).
return
end
end
if refresh_needed("mesosstate_last_refresh") then
fetch_and_store_state_mesos(auth_token)
end
if refresh_needed("svcapps_last_refresh") then
fetch_and_store_marathon_apps(auth_token)
end
if refresh_needed("marathon_leader_last_refresh") then
fetch_and_store_marathon_leader(auth_token)
end
if refresh_needed("mesos_leader_last_refresh") then
fetch_and_store_mesos_leader()
end
local ok, err = lock:unlock()
if not ok then
-- If this fails, an unlock happens automatically via `exptime` lock
-- param described earlier.
ngx.log(ngx.ERR, "Failed to unlock cache shmlock: " .. err)
end
end
local function periodically_refresh_cache(auth_token)
-- This function is invoked from within init_worker_by_lua code.
-- ngx.timer.at() can be called here, whereas most of the other ngx.*
-- API is not available.
timerhandler = function(premature)
-- Handler for recursive timer invocation.
-- Within a timer callback, plenty of the ngx.* API is available,
-- with the exception of e.g. subrequests. As ngx.sleep is also not
-- available in the current context, the recommended approach of
-- implementing periodic tasks is via recursively defined timers.
-- Premature timer execution: worker process tries to shut down.
if premature then
return
end
-- Invoke timer business logic.
refresh_cache(true, auth_token)
-- Register new timer.
local ok, err = ngx.timer.at(_CONFIG.CACHE_POLL_PERIOD, timerhandler)
if not ok then
ngx.log(ngx.ERR, "Failed to create timer: " .. err)
else
ngx.log(ngx.INFO, "Created recursive timer for cache updating.")
end
end
-- Trigger initial timer, about CACHE_FIRST_POLL_DELAY seconds after
-- Nginx startup.
local ok, err = ngx.timer.at(_CONFIG.CACHE_FIRST_POLL_DELAY, timerhandler)
if not ok then
ngx.log(ngx.ERR, "Failed to create timer: " .. err)
return
else
ngx.log(ngx.INFO, "Created initial recursive timer for cache updating.")
end
end
local function get_cache_entry(name, auth_token)
local cache = ngx.shared.cache
local name_last_refresh = name .. "_last_refresh"
-- Handle the special case of very early request - before the first
-- timer-based cache refresh
local entry_last_refresh = cache:get(name_last_refresh)
if entry_last_refresh == nil then
refresh_cache(false, auth_token)
entry_last_refresh = cache:get(name .. "_last_refresh")
if entry_last_refresh == nil then
-- Something is really broken, abort!
ngx.log(ngx.ERR, "Could not retrieve last refresh time for `" .. name .. "` cache entry")
return nil
end
end
-- Check the clock
ngx.update_time()
local cache_age = ngx.now() - entry_last_refresh
-- Cache is too old, we can't use it:
if cache_age > _CONFIG.CACHE_MAX_AGE_HARD_LIMIT then
ngx.log(ngx.ERR, "Cache entry `" .. name .. "` is too old, aborting request")
return nil
end
-- Cache is stale, but still usable:
if cache_age > _CONFIG.CACHE_MAX_AGE_SOFT_LIMIT then
ngx.log(ngx.NOTICE, "Cache entry `" .. name .. "` is stale")
end
local entry_json = cache:get(name)
if entry_json == nil then
ngx.log(ngx.ERR, "Could not retrieve `" .. name .. "` cache entry from SHM")
return nil
end
local entry, err = cjson_safe.decode(entry_json)
if entry == nil then
ngx.log(ngx.ERR, "Cannot decode JSON for entry `" .. entry_json .. "`: " .. err)
return nil
end
return entry
end
-- Expose Admin Router cache interface
local _M = {}
function _M.init(auth_token)
-- At some point auth_token passing will be refactored out in
-- favour of service accounts support.
local res = {}
if auth_token ~= nil then
-- auth_token variable is needed by a few functions which are
-- nested inside top-level ones. We can either define all the functions
-- inside the same lexical block, or we pass it around. Passing it
-- around seems cleaner.
res.get_cache_entry = function (name)
return get_cache_entry(name, auth_token)
end
res.periodically_refresh_cache = function()
return periodically_refresh_cache(auth_token)
end
else
res.get_cache_entry = get_cache_entry
res.periodically_refresh_cache = periodically_refresh_cache
end
return res
end
return _M
| apache-2.0 |
ovh/overthebox-feeds | luci-mod-admin-full/luasrc/model/cbi/admin_system/fstab.lua | 39 | 5639 | -- Copyright 2008 Steven Barth <steven@midlink.org>
-- Licensed to the public under the Apache License 2.0.
require("luci.tools.webadmin")
local fs = require "nixio.fs"
local util = require "nixio.util"
local tp = require "luci.template.parser"
local block = io.popen("block info", "r")
local ln, dev, devices = nil, nil, {}
repeat
ln = block:read("*l")
dev = ln and ln:match("^/dev/(.-):")
if dev then
local e, s, key, val = { }
for key, val in ln:gmatch([[(%w+)="(.-)"]]) do
e[key:lower()] = val
devices[val] = e
end
s = tonumber((fs.readfile("/sys/class/block/%s/size" % dev)))
e.dev = "/dev/%s" % dev
e.size = s and math.floor(s / 2048)
devices[e.dev] = e
end
until not ln
block:close()
m = Map("fstab", translate("Mount Points"))
local mounts = luci.sys.mounts()
v = m:section(Table, mounts, translate("Mounted file systems"))
fs = v:option(DummyValue, "fs", translate("Filesystem"))
mp = v:option(DummyValue, "mountpoint", translate("Mount Point"))
avail = v:option(DummyValue, "avail", translate("Available"))
function avail.cfgvalue(self, section)
return luci.tools.webadmin.byte_format(
( tonumber(mounts[section].available) or 0 ) * 1024
) .. " / " .. luci.tools.webadmin.byte_format(
( tonumber(mounts[section].blocks) or 0 ) * 1024
)
end
used = v:option(DummyValue, "used", translate("Used"))
function used.cfgvalue(self, section)
return ( mounts[section].percent or "0%" ) .. " (" ..
luci.tools.webadmin.byte_format(
( tonumber(mounts[section].used) or 0 ) * 1024
) .. ")"
end
mount = m:section(TypedSection, "mount", translate("Mount Points"), translate("Mount Points define at which point a memory device will be attached to the filesystem"))
mount.anonymous = true
mount.addremove = true
mount.template = "cbi/tblsection"
mount.extedit = luci.dispatcher.build_url("admin/system/fstab/mount/%s")
mount.create = function(...)
local sid = TypedSection.create(...)
if sid then
luci.http.redirect(mount.extedit % sid)
return
end
end
mount:option(Flag, "enabled", translate("Enabled")).rmempty = false
dev = mount:option(DummyValue, "device", translate("Device"))
dev.rawhtml = true
dev.cfgvalue = function(self, section)
local v, e
v = m.uci:get("fstab", section, "uuid")
e = v and devices[v:lower()]
if v and e and e.size then
return "UUID: %s (%s, %d MB)" %{ tp.pcdata(v), e.dev, e.size }
elseif v and e then
return "UUID: %s (%s)" %{ tp.pcdata(v), e.dev }
elseif v then
return "UUID: %s (<em>%s</em>)" %{ tp.pcdata(v), translate("not present") }
end
v = m.uci:get("fstab", section, "label")
e = v and devices[v]
if v and e and e.size then
return "Label: %s (%s, %d MB)" %{ tp.pcdata(v), e.dev, e.size }
elseif v and e then
return "Label: %s (%s)" %{ tp.pcdata(v), e.dev }
elseif v then
return "Label: %s (<em>%s</em>)" %{ tp.pcdata(v), translate("not present") }
end
v = Value.cfgvalue(self, section) or "?"
e = v and devices[v]
if v and e and e.size then
return "%s (%d MB)" %{ tp.pcdata(v), e.size }
elseif v and e then
return tp.pcdata(v)
elseif v then
return "%s (<em>%s</em>)" %{ tp.pcdata(v), translate("not present") }
end
end
mp = mount:option(DummyValue, "target", translate("Mount Point"))
mp.cfgvalue = function(self, section)
if m.uci:get("fstab", section, "is_rootfs") == "1" then
return "/overlay"
else
return Value.cfgvalue(self, section) or "?"
end
end
fs = mount:option(DummyValue, "fstype", translate("Filesystem"))
fs.cfgvalue = function(self, section)
local v, e
v = m.uci:get("fstab", section, "uuid")
v = v and v:lower() or m.uci:get("fstab", section, "label")
v = v or m.uci:get("fstab", section, "device")
e = v and devices[v]
return e and e.type or m.uci:get("fstab", section, "fstype") or "?"
end
op = mount:option(DummyValue, "options", translate("Options"))
op.cfgvalue = function(self, section)
return Value.cfgvalue(self, section) or "defaults"
end
rf = mount:option(DummyValue, "is_rootfs", translate("Root"))
rf.cfgvalue = function(self, section)
local target = m.uci:get("fstab", section, "target")
if target == "/" then
return translate("yes")
elseif target == "/overlay" then
return translate("overlay")
else
return translate("no")
end
end
ck = mount:option(DummyValue, "enabled_fsck", translate("Check"))
ck.cfgvalue = function(self, section)
return Value.cfgvalue(self, section) == "1"
and translate("yes") or translate("no")
end
swap = m:section(TypedSection, "swap", "SWAP", translate("If your physical memory is insufficient unused data can be temporarily swapped to a swap-device resulting in a higher amount of usable <abbr title=\"Random Access Memory\">RAM</abbr>. Be aware that swapping data is a very slow process as the swap-device cannot be accessed with the high datarates of the <abbr title=\"Random Access Memory\">RAM</abbr>."))
swap.anonymous = true
swap.addremove = true
swap.template = "cbi/tblsection"
swap.extedit = luci.dispatcher.build_url("admin/system/fstab/swap/%s")
swap.create = function(...)
local sid = TypedSection.create(...)
if sid then
luci.http.redirect(swap.extedit % sid)
return
end
end
swap:option(Flag, "enabled", translate("Enabled")).rmempty = false
dev = swap:option(DummyValue, "device", translate("Device"))
dev.cfgvalue = function(self, section)
local v
v = m.uci:get("fstab", section, "uuid")
if v then return "UUID: %s" % v end
v = m.uci:get("fstab", section, "label")
if v then return "Label: %s" % v end
v = Value.cfgvalue(self, section) or "?"
e = v and devices[v]
if v and e and e.size then
return "%s (%s MB)" % {v, e.size}
else
return v
end
end
return m
| gpl-3.0 |
andeandr100/Crumbled-World | Lua/Game/spirits.lua | 1 | 5571 | SpiritsParticleEffect = {
endCrystalSpirit1 = {
WallboardParticle = true,
airResistance = 0,
color = {
color1 = {r = 0.65,g = 0.33,b = 0.05,a = 0.25,per = 0,size = 0.025},
color2 = {r = 1.20,g = 1.20,b = 0.15,a = 0.65,per = 0.25,size = 0.05},
color3 = {r = 0.80,g = 0.80,b = 0.80,a = 0.25,per = 1,size = 0.015},
renderPhase = {GL_Blend.SRC_ALPHA, GL_Blend.ONE_MINUS_SRC_ALPHA, GL_Blend.SRC_ALPHA, GL_Blend.ONE}
},
emitterSpeedMultiplyer = 1,
gravity = 0,
lifeTime = {
max = 2,
min = 1
},
spawn = {
OffsetFromGroundPer = 0.0,
maxParticles = 12,
minParticles = 0,
pattern = "sphere",
patternData = {
max = 1,
min = -1
},
spawnDuration = math.huge,
spawnRadius = 0.015,
spawnRate = 6,
spawnSpeed = 0
},
texture = {
countX = 1,
countY = 2,
lengthEqlWidthMul = 1,
startX = 0,
startY = 0.75,
widthX = 0.125,
widthY = 0.125
}
},
endCrystalSpiritTale1 = {
WallboardParticle = true,
airResistance = 0,
color = {
color1 = {r = 1.20,g = 1.20,b = 0.15,a = 0.026,per = 0,size = 0.05},
color2 = {r = 0.80,g = 0.80,b = 0.80,a = 0.013,per = 1,size = 0.015},
renderPhase = {GL_Blend.SRC_ALPHA, GL_Blend.ONE_MINUS_SRC_ALPHA, GL_Blend.SRC_ALPHA, GL_Blend.ONE}
},
emitterSpeedMultiplyer = 1,
gravity = 0,
lifeTime = {
max = 0.5,--0.25,
min = 0.25--0.125
},
spawn = {
OffsetFromGroundPer = 0.0,
maxParticles = 50,--50,
minParticles = 0,
pattern = "sphere",
patternData = {
max = 1,
min = -1
},
spawnDuration = math.huge,
spawnRadius = 0.0,
spawnRate = 100,
spawnSpeed = 0
},
texture = {
countX = 1,
countY = 1,
lengthEqlWidthMul = 1,
startX = 0,
startY = 0.875,
widthX = 0.125,
widthY = 0.125
}
},
endCrystalSpirit2 = {
WallboardParticle = true,
airResistance = 0,
color = {
color1 = {r = 0.05,g = 0.33,b = 0.65,a = 0.25,per = 0,size = 0.025},
color2 = {r = 0.15,g = 1.20,b = 1.20,a = 0.65,per = 0.25,size = 0.05},
color3 = {r = 0.80,g = 0.80,b = 0.80,a = 0.25,per = 1,size = 0.015},
renderPhase = {GL_Blend.SRC_ALPHA, GL_Blend.ONE_MINUS_SRC_ALPHA, GL_Blend.SRC_ALPHA, GL_Blend.ONE}
},
emitterSpeedMultiplyer = 1,
gravity = 0,
lifeTime = {
max = 2,
min = 1
},
spawn = {
OffsetFromGroundPer = 0.0,
maxParticles = 12,
minParticles = 0,
pattern = "sphere",
patternData = {
max = 1,
min = -1
},
spawnDuration = math.huge,
spawnRadius = 0.015,
spawnRate = 6,
spawnSpeed = 0
},
texture = {
countX = 1,
countY = 2,
lengthEqlWidthMul = 1,
startX = 0,
startY = 0.75,
widthX = 0.125,
widthY = 0.125
}
},
endCrystalSpiritTale2 = {
WallboardParticle = true,
airResistance = 0,
color = {
color1 = {r = 0.15,g = 1.20,b = 1.20,a = 0.026,per = 0,size = 0.05},
color2 = {r = 0.80,g = 0.80,b = 0.80,a = 0.013,per = 1,size = 0.015},
renderPhase = {GL_Blend.SRC_ALPHA, GL_Blend.ONE_MINUS_SRC_ALPHA, GL_Blend.SRC_ALPHA, GL_Blend.ONE}
},
emitterSpeedMultiplyer = 1,
gravity = 0,
lifeTime = {
max = 0.5,--0.25,
min = 0.25--0.125
},
spawn = {
OffsetFromGroundPer = 0.0,
maxParticles = 50,--50,
minParticles = 0,
pattern = "sphere",
patternData = {
max = 1,
min = -1
},
spawnDuration = math.huge,
spawnRadius = 0.0,
spawnRate = 100,
spawnSpeed = 0
},
texture = {
countX = 1,
countY = 1,
lengthEqlWidthMul = 1,
startX = 0,
startY = 0.875,
widthX = 0.125,
widthY = 0.125
}
},
endCrystalSpirit3 = {
WallboardParticle = true,
airResistance = 0,
color = {
color1 = {r = 0.65,g = 0.65,b = 0.65,a = 0.25,per = 0,size = 0.025},
color2 = {r = 1.20,g = 1.20,b = 1.20,a = 0.65,per = 0.25,size = 0.05},
color3 = {r = 0.80,g = 0.80,b = 0.80,a = 0.25,per = 1,size = 0.015},
renderPhase = {GL_Blend.SRC_ALPHA, GL_Blend.ONE_MINUS_SRC_ALPHA, GL_Blend.SRC_ALPHA, GL_Blend.ONE}
},
emitterSpeedMultiplyer = 1,
gravity = 0,
lifeTime = {
max = 2,
min = 1
},
spawn = {
OffsetFromGroundPer = 0.0,
maxParticles = 12,
minParticles = 0,
pattern = "sphere",
patternData = {
max = 1,
min = -1
},
spawnDuration = math.huge,
spawnRadius = 0.015,
spawnRate = 6,
spawnSpeed = 0
},
texture = {
countX = 1,
countY = 2,
lengthEqlWidthMul = 1,
startX = 0,
startY = 0.75,
widthX = 0.125,
widthY = 0.125
}
},
endCrystalSpiritTale3 = {
WallboardParticle = true,
airResistance = 0,
color = {
color1 = {r = 1.20,g = 1.20,b = 1.20,a = 0.026,per = 0,size = 0.05},
color2 = {r = 0.80,g = 0.80,b = 0.80,a = 0.013,per = 1,size = 0.015},
renderPhase = {GL_Blend.SRC_ALPHA, GL_Blend.ONE_MINUS_SRC_ALPHA, GL_Blend.SRC_ALPHA, GL_Blend.ONE}
},
emitterSpeedMultiplyer = 1,
gravity = 0,
lifeTime = {
max = 0.5,--0.25,
min = 0.25--0.125
},
spawn = {
OffsetFromGroundPer = 0.0,
maxParticles = 50,--50,
minParticles = 0,
pattern = "sphere",
patternData = {
max = 1,
min = -1
},
spawnDuration = math.huge,
spawnRadius = 0.0,
spawnRate = 100,
spawnSpeed = 0
},
texture = {
countX = 1,
countY = 1,
lengthEqlWidthMul = 1,
startX = 0,
startY = 0.875,
widthX = 0.125,
widthY = 0.125
}
}
} | mit |
MrTheSoulz/NerdPack | Libs/DiesalGUI-1.0/Objects/CheckBox.lua | 3 | 5705 | -- $Id: CheckBox.lua 60 2016-11-04 01:34:23Z diesal2010 $
local DiesalGUI = LibStub("DiesalGUI-1.0")
-- ~~| Libraries |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local DiesalTools = LibStub("DiesalTools-1.0")
local DiesalStyle = LibStub("DiesalStyle-1.0")
-- ~~| Diesal Upvalues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local Colors = DiesalStyle.Colors
local HSL, ShadeColor, TintColor = DiesalTools.HSL, DiesalTools.ShadeColor, DiesalTools.TintColor
-- ~~| Lua Upvalues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local type, tonumber, select = type, tonumber, select
local pairs, ipairs, next = pairs, ipairs, next
local min, max = math.min, math.max
-- ~~| WoW Upvalues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local CreateFrame, UIParent, GetCursorPosition = CreateFrame, UIParent, GetCursorPosition
local GetScreenWidth, GetScreenHeight = GetScreenWidth, GetScreenHeight
local GetSpellInfo, GetBonusBarOffset, GetDodgeChance = GetSpellInfo, GetBonusBarOffset, GetDodgeChance
local GetPrimaryTalentTree, GetCombatRatingBonus = GetPrimaryTalentTree, GetCombatRatingBonus
-- ~~| Button |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local TYPE = "CheckBox"
local VERSION = 1
-- ~~| Button Stylesheets |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local Stylesheet = {
['frame-background'] = {
type = 'texture',
layer = 'BACKGROUND',
color = '000000',
alpha = .60,
position = -2
},
['frame-inline'] = {
type = 'outline',
layer = 'BORDER',
color = '000000',
alpha = .6,
position = -2
},
['frame-outline'] = {
type = 'outline',
layer = 'BORDER',
color = 'FFFFFF',
alpha = .02,
position = -1,
},
}
local checkBoxStyle = {
base = {
type = 'texture',
layer = 'ARTWORK',
color = Colors.UI_A400,
position = -3,
},
disabled = {
type = 'texture',
color = HSL(Colors.UI_Hue,Colors.UI_Saturation,.35),
},
enabled = {
type = 'texture',
color = Colors.UI_A400,
},
}
local wireFrame = {
['frame-white'] = {
type = 'outline',
layer = 'OVERLAY',
color = 'ffffff',
},
}
-- ~~| Button Methods |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local methods = {
['OnAcquire'] = function(self)
self:ApplySettings()
self:SetStylesheet(Stylesheet)
self:Enable()
-- self:SetStylesheet(wireFrameSheet)
self:Show()
end,
['OnRelease'] = function(self) end,
['ApplySettings'] = function(self)
local settings = self.settings
local frame = self.frame
self:SetWidth(settings.width)
self:SetHeight(settings.height)
end,
["SetChecked"] = function(self,value)
self.settings.checked = value
self.frame:SetChecked(value)
self[self.settings.disabled and "Disable" or "Enable"](self)
end,
["GetChecked"] = function(self)
return self.settings.checked
end,
["Disable"] = function(self)
self.settings.disabled = true
DiesalStyle:StyleTexture(self.check,checkBoxStyle.disabled)
self.frame:Disable()
end,
["Enable"] = function(self)
self.settings.disabled = false
DiesalStyle:StyleTexture(self.check,checkBoxStyle.enabled)
self.frame:Enable()
end,
["RegisterForClicks"] = function(self,...)
self.frame:RegisterForClicks(...)
end,
}
-- ~~| Button Constructor |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local function Constructor()
local self = DiesalGUI:CreateObjectBase(TYPE)
local frame = CreateFrame('CheckButton', nil, UIParent)
self.frame = frame
-- ~~ Default Settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
self.defaults = {
height = 11,
width = 11,
}
-- ~~ Events ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- OnAcquire, OnRelease, OnHeightSet, OnWidthSet
-- OnValueChanged, OnEnter, OnLeave, OnDisable, OnEnable
-- ~~ Construct ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local check = self:CreateRegion("Texture", 'check', frame)
DiesalStyle:StyleTexture(check,checkBoxStyle.base)
frame:SetCheckedTexture(check)
frame:SetScript('OnClick', function(this,button,...)
DiesalGUI:OnMouse(this,button)
if not self.settings.disabled then
self:SetChecked(not self.settings.checked)
if self.settings.checked then
PlaySound(856)
else
PlaySound(857)
end
self:FireEvent("OnValueChanged", self.settings.checked)
end
end)
frame:SetScript('OnEnter', function(this)
self:FireEvent("OnEnter")
end)
frame:SetScript('OnLeave', function(this)
self:FireEvent("OnLeave")
end)
frame:SetScript("OnDisable", function(this)
self:FireEvent("OnDisable")
end)
frame:SetScript("OnEnable", function(this)
self:FireEvent("OnEnable")
end)
-- ~~ Methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for method, func in pairs(methods) do self[method] = func end
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
return self
end
DiesalGUI:RegisterObjectConstructor(TYPE,Constructor,VERSION)
| mit |
Flatlander57/TheImaginedOTClient | modules/corelib/ui/uicombobox.lua | 3 | 3606 | -- @docclass
UIComboBox = extends(UIWidget)
function UIComboBox.create()
local combobox = UIComboBox.internalCreate()
combobox:setFocusable(false)
combobox.options = {}
combobox.currentIndex = -1
combobox.mouseScroll = true
return combobox
end
function UIComboBox:clearOptions()
self.options = {}
self.currentIndex = -1
self:clearText()
end
function UIComboBox:getOption(text)
if not self.options then return nil end
for i,v in ipairs(self.options) do
if v.text == text then
return nil
end
end
end
function UIComboBox:setCurrentOption(text)
if not self.options then return end
for i,v in ipairs(self.options) do
if v.text == text and self.currentIndex ~= i then
self.currentIndex = i
self:setText(text)
signalcall(self.onOptionChange, self, text, v.data)
return
end
end
end
function UIComboBox:setCurrentOptionByData(data)
if not self.options then return end
for i,v in ipairs(self.options) do
if v.data == data and self.currentIndex ~= i then
self.currentIndex = i
self:setText(v.text)
signalcall(self.onOptionChange, self, v.text, v.data)
return
end
end
end
function UIComboBox:setCurrentIndex(index)
if index >= 1 and index <= #self.options then
local v = self.options[index]
self.currentIndex = index
self:setText(v.text)
signalcall(self.onOptionChange, self, v.text, v.data)
end
end
function UIComboBox:getCurrentOption()
if table.haskey(self.options, self.currentIndex) then
return self.options[self.currentIndex]
end
end
function UIComboBox:addOption(text, data)
table.insert(self.options, { text = text, data = data })
local index = #self.options
if index == 1 then self:setCurrentOption(text) end
return index
end
function UIComboBox:removeOption(text)
for i,v in ipairs(self.options) do
if v.text == text then
table.remove(self.options, i)
if self.currentIndex == i then
self:setCurrentIndex(1)
elseif self.currentIndex > i then
self.currentIndex = self.currentIndex - 1
end
return
end
end
end
function UIComboBox:onMousePress(mousePos, mouseButton)
local menu = g_ui.createWidget(self:getStyleName() .. 'PopupMenu')
menu:setId(self:getId() .. 'PopupMenu')
for i,v in ipairs(self.options) do
menu:addOption(v.text, function() self:setCurrentOption(v.text) end)
end
menu:setWidth(self:getWidth())
menu:display({ x = self:getX(), y = self:getY() + self:getHeight() })
connect(menu, { onDestroy = function() self:setOn(false) end })
self:setOn(true)
return true
end
function UIComboBox:onMouseWheel(mousePos, direction)
if not self.mouseScroll then
return false
end
if direction == MouseWheelUp and self.currentIndex > 1 then
self:setCurrentIndex(self.currentIndex - 1)
elseif direction == MouseWheelDown and self.currentIndex < #self.options then
self:setCurrentIndex(self.currentIndex + 1)
end
return true
end
function UIComboBox:onStyleApply(styleName, styleNode)
if styleNode.options then
for k,option in pairs(styleNode.options) do
self:addOption(option)
end
end
if styleNode.data then
for k,data in pairs(styleNode.data) do
local option = self.options[k]
if option then
option.data = data
end
end
end
for name,value in pairs(styleNode) do
if name == 'mouse-scroll' then
self.mouseScroll = value
end
end
end
function UIComboBox:setMouseScroll(scroll)
self.mouseScroll = scroll
end
function UIComboBox:canMouseScroll()
return self.mouseScroll
end
| mit |
opensourcechipspark/platform_external_skia | tools/lua/bbh_filter.lua | 207 | 4407 | -- bbh_filter.lua
--
-- This script outputs info about 'interesting' skp files,
-- where the definition of 'interesting' changes but is roughly:
-- "Interesting for bounding box hierarchy benchmarks."
--
-- Currently, the approach is to output, in equal ammounts, the names of the files that
-- have most commands, and the names of the files that use the least popular commands.
function count_entries(table)
local count = 0
for _,_ in pairs(table) do
count = count + 1
end
return count
end
verbCounts = {}
function reset_current()
-- Data about the skp in transit
currentInfo = {
fileName = '',
verbs = {},
numOps = 0
}
end
reset_current()
numOutputFiles = 10 -- This is per measure.
globalInfo = {} -- Saves currentInfo for each file to be used at the end.
output = {} -- Stores {fileName, {verb, count}} tables.
function tostr(t)
local str = ""
for k, v in next, t do
if #str > 0 then
str = str .. ", "
end
if type(k) == "number" then
str = str .. "[" .. k .. "] = "
else
str = str .. tostring(k) .. " = "
end
if type(v) == "table" then
str = str .. "{ " .. tostr(v) .. " }"
else
str = str .. tostring(v)
end
end
return str
end
function sk_scrape_startcanvas(c, fileName) end
function sk_scrape_endcanvas(c, fileName)
globalInfo[fileName] = currentInfo
globalInfo[fileName].fileName = fileName
reset_current()
end
function sk_scrape_accumulate(t)
-- dump the params in t, specifically showing the verb first, which we
-- then nil out so it doesn't appear in tostr()
--
verbCounts[t.verb] = (verbCounts[t.verb] or 0) + 1
currentInfo.verbs[t.verb] = (currentInfo.verbs[t.verb] or 0) + 1
currentInfo.numOps = currentInfo.numOps + 1
t.verb = nil
end
function sk_scrape_summarize()
verbWeights = {} -- {verb, weight}, where 0 < weight <= 1
meta = {}
for k,v in pairs(verbCounts) do
table.insert(meta, {key=k, value=v})
end
table.sort(meta, function (a,b) return a.value > b.value; end)
maxValue = meta[1].value
io.write("-- ==================\n")
io.write("------------------------------------------------------------------ \n")
io.write("-- Command\t\t\tNumber of calls\t\tPopularity\n")
io.write("------------------------------------------------------------------ \n")
for k, v in pairs(meta) do
verbWeights[v.key] = v.value / maxValue
-- Poor man's formatting:
local padding = "\t\t\t"
if (#v.key + 3) < 8 then
padding = "\t\t\t\t"
end
if (#v.key + 3) >= 16 then
padding = "\t\t"
end
io.write ("-- ",v.key, padding, v.value, '\t\t\t', verbWeights[v.key], "\n")
end
meta = {}
function calculate_weight(verbs)
local weight = 0
for name, count in pairs(verbs) do
weight = weight + (1 / verbWeights[name]) * count
end
return weight
end
for n, info in pairs(globalInfo) do
table.insert(meta, info)
end
local visitedFiles = {}
-- Prints out information in lua readable format
function output_with_metric(metric_func, description, numOutputFiles)
table.sort(meta, metric_func)
print(description)
local iter = 0
for i, t in pairs(meta) do
if not visitedFiles[t.fileName] then
visitedFiles[t.fileName] = true
io.write ("{\nname = \"", t.fileName, "\", \nverbs = {\n")
for verb,count in pairs(globalInfo[t.fileName].verbs) do
io.write(' ', verb, " = ", count, ",\n")
end
io.write("}\n},\n")
iter = iter + 1
if iter >= numOutputFiles then
break
end
end
end
end
output_with_metric(
function(a, b) return calculate_weight(a.verbs) > calculate_weight(b.verbs); end,
"\n-- ================== skps with calling unpopular commands.", 10)
output_with_metric(
function(a, b) return a.numOps > b.numOps; end,
"\n-- ================== skps with the most calls.", 50)
local count = count_entries(visitedFiles)
print ("-- Spat", count, "files")
end
| bsd-3-clause |
MrTheSoulz/NerdPack | onload/apis.lua | 1 | 1698 | local NeP = NeP
local g = NeP.Globals
g.Actions = NeP.Actions
g.RegisterCommand = NeP.Commands.Register
g.Core = NeP.Core
g._G = NeP._G
g.FakeUnits = NeP.FakeUnits
g.Listener = NeP.Listener
g.Queue = NeP.Queuer.Add
g.Tooltip = NeP.Tooltip
g.Protected = NeP.Protected
g.Artifact = NeP.Artifact
g.DBM = NeP.DBM
g.ClassTable = NeP.ClassTable
g.Spells = NeP.Spells
g.Version = NeP.Version
g.Timer = {
Add = NeP.Timer.Add,
updatePeriod = NeP.Timer.updatePeriod
}
g.CR = {
Add = NeP.CR.Add,
GetList = NeP.CR.GetList
}
g.Debug = {
Add = NeP.Debug.Add
}
g.DSL = {
Get = NeP.DSL.Get,
Register = NeP.DSL.Register,
Parse = NeP.DSL.Parse
}
g.Library = {
Add = NeP.Library.Add,
Fetch = NeP.Library.Fetch,
Parse = NeP.Library.Parse
}
g.OM = {
Add = NeP.OM.Add,
Get = NeP.OM.Get,
FindObjectByGuid = NeP.OM.FindObjectByGuid,
RemoveObjectByGuid = NeP.OM.RemoveObjectByGuid,
}
g.Interface = {
BuildGUI = NeP.Interface.BuildGUI,
Fetch = NeP.Interface.Fetch,
GetElement = NeP.Interface.GetElement,
Add = NeP.Interface.Add,
toggleToggle = NeP.Interface.toggleToggle,
AddToggle = NeP.Interface.AddToggle,
Alert = NeP.Interface.Alert,
Splash = NeP.Interface.Splash
}
g.ActionLog = {
Add = NeP.ActionLog.Add,
}
g.AddsID = {
Add = NeP.AddsID.Add,
Eval = NeP.AddsID.Eval,
Get = NeP.AddsID.Get
}
g.Debuffs = {
Add = NeP.Debuffs.Add,
Eval = NeP.Debuffs.Eval,
Get = NeP.Debuffs.Get
}
g.BossID = {
Add = NeP.BossID.Add,
Eval = NeP.BossID.Eval,
Get = NeP.BossID.Get
}
g.ByPassMounts = {
Add = NeP.ByPassMounts.Add,
Eval = NeP.ByPassMounts.Eval,
Get = NeP.ByPassMounts.Get
}
g.Taunts = {
Add = NeP.Taunts.Add,
ShouldTaunt = NeP.Taunts.ShouldTaunt,
Get = NeP.Taunts.Get
}
| mit |
wangxing1517/kubernetes | test/images/echoserver/template.lua | 195 | 17200 | -- vendored from https://raw.githubusercontent.com/bungle/lua-resty-template/1f9a5c24fc7572dbf5be0b9f8168cc3984b03d24/lib/resty/template.lua
-- only modification: remove / from HTML_ENTITIES to not escape it, and fix the appropriate regex.
--[[
Copyright (c) 2014 - 2017 Aapo Talvensaari
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of the {organization} nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--]]
local setmetatable = setmetatable
local loadstring = loadstring
local loadchunk
local tostring = tostring
local setfenv = setfenv
local require = require
local capture
local concat = table.concat
local assert = assert
local prefix
local write = io.write
local pcall = pcall
local phase
local open = io.open
local load = load
local type = type
local dump = string.dump
local find = string.find
local gsub = string.gsub
local byte = string.byte
local null
local sub = string.sub
local ngx = ngx
local jit = jit
local var
local _VERSION = _VERSION
local _ENV = _ENV
local _G = _G
local HTML_ENTITIES = {
["&"] = "&",
["<"] = "<",
[">"] = ">",
['"'] = """,
["'"] = "'",
}
local CODE_ENTITIES = {
["{"] = "{",
["}"] = "}",
["&"] = "&",
["<"] = "<",
[">"] = ">",
['"'] = """,
["'"] = "'",
["/"] = "/"
}
local VAR_PHASES
local ok, newtab = pcall(require, "table.new")
if not ok then newtab = function() return {} end end
local caching = true
local template = newtab(0, 12)
template._VERSION = "1.9"
template.cache = {}
local function enabled(val)
if val == nil then return true end
return val == true or (val == "1" or val == "true" or val == "on")
end
local function trim(s)
return gsub(gsub(s, "^%s+", ""), "%s+$", "")
end
local function rpos(view, s)
while s > 0 do
local c = sub(view, s, s)
if c == " " or c == "\t" or c == "\0" or c == "\x0B" then
s = s - 1
else
break
end
end
return s
end
local function escaped(view, s)
if s > 1 and sub(view, s - 1, s - 1) == "\\" then
if s > 2 and sub(view, s - 2, s - 2) == "\\" then
return false, 1
else
return true, 1
end
end
return false, 0
end
local function readfile(path)
local file = open(path, "rb")
if not file then return nil end
local content = file:read "*a"
file:close()
return content
end
local function loadlua(path)
return readfile(path) or path
end
local function loadngx(path)
local vars = VAR_PHASES[phase()]
local file, location = path, vars and var.template_location
if sub(file, 1) == "/" then file = sub(file, 2) end
if location and location ~= "" then
if sub(location, -1) == "/" then location = sub(location, 1, -2) end
local res = capture(concat{ location, '/', file})
if res.status == 200 then return res.body end
end
local root = vars and (var.template_root or var.document_root) or prefix
if sub(root, -1) == "/" then root = sub(root, 1, -2) end
return readfile(concat{ root, "/", file }) or path
end
do
if ngx then
VAR_PHASES = {
set = true,
rewrite = true,
access = true,
content = true,
header_filter = true,
body_filter = true,
log = true
}
template.print = ngx.print or write
template.load = loadngx
prefix, var, capture, null, phase = ngx.config.prefix(), ngx.var, ngx.location.capture, ngx.null, ngx.get_phase
if VAR_PHASES[phase()] then
caching = enabled(var.template_cache)
end
else
template.print = write
template.load = loadlua
end
if _VERSION == "Lua 5.1" then
local context = { __index = function(t, k)
return t.context[k] or t.template[k] or _G[k]
end }
if jit then
loadchunk = function(view)
return assert(load(view, nil, nil, setmetatable({ template = template }, context)))
end
else
loadchunk = function(view)
local func = assert(loadstring(view))
setfenv(func, setmetatable({ template = template }, context))
return func
end
end
else
local context = { __index = function(t, k)
return t.context[k] or t.template[k] or _ENV[k]
end }
loadchunk = function(view)
return assert(load(view, nil, nil, setmetatable({ template = template }, context)))
end
end
end
function template.caching(enable)
if enable ~= nil then caching = enable == true end
return caching
end
function template.output(s)
if s == nil or s == null then return "" end
if type(s) == "function" then return template.output(s()) end
return tostring(s)
end
function template.escape(s, c)
if type(s) == "string" then
if c then return gsub(s, "[}{\">/<'&]", CODE_ENTITIES) end
return gsub(s, "[\"><'&]", HTML_ENTITIES)
end
return template.output(s)
end
function template.new(view, layout)
assert(view, "view was not provided for template.new(view, layout).")
local render, compile = template.render, template.compile
if layout then
if type(layout) == "table" then
return setmetatable({ render = function(self, context)
local context = context or self
context.blocks = context.blocks or {}
context.view = compile(view)(context)
layout.blocks = context.blocks or {}
layout.view = context.view or ""
return layout:render()
end }, { __tostring = function(self)
local context = self
context.blocks = context.blocks or {}
context.view = compile(view)(context)
layout.blocks = context.blocks or {}
layout.view = context.view
return tostring(layout)
end })
else
return setmetatable({ render = function(self, context)
local context = context or self
context.blocks = context.blocks or {}
context.view = compile(view)(context)
return render(layout, context)
end }, { __tostring = function(self)
local context = self
context.blocks = context.blocks or {}
context.view = compile(view)(context)
return compile(layout)(context)
end })
end
end
return setmetatable({ render = function(self, context)
return render(view, context or self)
end }, { __tostring = function(self)
return compile(view)(self)
end })
end
function template.precompile(view, path, strip)
local chunk = dump(template.compile(view), strip ~= false)
if path then
local file = open(path, "wb")
file:write(chunk)
file:close()
end
return chunk
end
function template.compile(view, key, plain)
assert(view, "view was not provided for template.compile(view, key, plain).")
if key == "no-cache" then
return loadchunk(template.parse(view, plain)), false
end
key = key or view
local cache = template.cache
if cache[key] then return cache[key], true end
local func = loadchunk(template.parse(view, plain))
if caching then cache[key] = func end
return func, false
end
function template.parse(view, plain)
assert(view, "view was not provided for template.parse(view, plain).")
if not plain then
view = template.load(view)
if byte(view, 1, 1) == 27 then return view end
end
local j = 2
local c = {[[
context=... or {}
local function include(v, c) return template.compile(v)(c or context) end
local ___,blocks,layout={},blocks or {}
]] }
local i, s = 1, find(view, "{", 1, true)
while s do
local t, p = sub(view, s + 1, s + 1), s + 2
if t == "{" then
local e = find(view, "}}", p, true)
if e then
local z, w = escaped(view, s)
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = sub(view, i, s - 1 - w)
c[j+2] = "]=]\n"
j=j+3
end
if z then
i = s
else
c[j] = "___[#___+1]=template.escape("
c[j+1] = trim(sub(view, p, e - 1))
c[j+2] = ")\n"
j=j+3
s, i = e + 1, e + 2
end
end
elseif t == "*" then
local e = find(view, "*}", p, true)
if e then
local z, w = escaped(view, s)
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = sub(view, i, s - 1 - w)
c[j+2] = "]=]\n"
j=j+3
end
if z then
i = s
else
c[j] = "___[#___+1]=template.output("
c[j+1] = trim(sub(view, p, e - 1))
c[j+2] = ")\n"
j=j+3
s, i = e + 1, e + 2
end
end
elseif t == "%" then
local e = find(view, "%}", p, true)
if e then
local z, w = escaped(view, s)
if z then
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = sub(view, i, s - 1 - w)
c[j+2] = "]=]\n"
j=j+3
end
i = s
else
local n = e + 2
if sub(view, n, n) == "\n" then
n = n + 1
end
local r = rpos(view, s - 1)
if i <= r then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = sub(view, i, r)
c[j+2] = "]=]\n"
j=j+3
end
c[j] = trim(sub(view, p, e - 1))
c[j+1] = "\n"
j=j+2
s, i = n - 1, n
end
end
elseif t == "(" then
local e = find(view, ")}", p, true)
if e then
local z, w = escaped(view, s)
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = sub(view, i, s - 1 - w)
c[j+2] = "]=]\n"
j=j+3
end
if z then
i = s
else
local f = sub(view, p, e - 1)
local x = find(f, ",", 2, true)
if x then
c[j] = "___[#___+1]=include([=["
c[j+1] = trim(sub(f, 1, x - 1))
c[j+2] = "]=],"
c[j+3] = trim(sub(f, x + 1))
c[j+4] = ")\n"
j=j+5
else
c[j] = "___[#___+1]=include([=["
c[j+1] = trim(f)
c[j+2] = "]=])\n"
j=j+3
end
s, i = e + 1, e + 2
end
end
elseif t == "[" then
local e = find(view, "]}", p, true)
if e then
local z, w = escaped(view, s)
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = sub(view, i, s - 1 - w)
c[j+2] = "]=]\n"
j=j+3
end
if z then
i = s
else
c[j] = "___[#___+1]=include("
c[j+1] = trim(sub(view, p, e - 1))
c[j+2] = ")\n"
j=j+3
s, i = e + 1, e + 2
end
end
elseif t == "-" then
local e = find(view, "-}", p, true)
if e then
local x, y = find(view, sub(view, s, e + 1), e + 2, true)
if x then
local z, w = escaped(view, s)
if z then
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = sub(view, i, s - 1 - w)
c[j+2] = "]=]\n"
j=j+3
end
i = s
else
y = y + 1
x = x - 1
if sub(view, y, y) == "\n" then
y = y + 1
end
local b = trim(sub(view, p, e - 1))
if b == "verbatim" or b == "raw" then
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = sub(view, i, s - 1 - w)
c[j+2] = "]=]\n"
j=j+3
end
c[j] = "___[#___+1]=[=["
c[j+1] = sub(view, e + 2, x)
c[j+2] = "]=]\n"
j=j+3
else
if sub(view, x, x) == "\n" then
x = x - 1
end
local r = rpos(view, s - 1)
if i <= r then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = sub(view, i, r)
c[j+2] = "]=]\n"
j=j+3
end
c[j] = 'blocks["'
c[j+1] = b
c[j+2] = '"]=include[=['
c[j+3] = sub(view, e + 2, x)
c[j+4] = "]=]\n"
j=j+5
end
s, i = y - 1, y
end
end
end
elseif t == "#" then
local e = find(view, "#}", p, true)
if e then
local z, w = escaped(view, s)
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = sub(view, i, s - 1 - w)
c[j+2] = "]=]\n"
j=j+3
end
if z then
i = s
else
e = e + 2
if sub(view, e, e) == "\n" then
e = e + 1
end
s, i = e - 1, e
end
end
end
s = find(view, "{", s + 1, true)
end
s = sub(view, i)
if s and s ~= "" then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = s
c[j+2] = "]=]\n"
j=j+3
end
c[j] = "return layout and include(layout,setmetatable({view=table.concat(___),blocks=blocks},{__index=context})) or table.concat(___)"
return concat(c)
end
function template.render(view, context, key, plain)
assert(view, "view was not provided for template.render(view, context, key, plain).")
return template.print(template.compile(view, key, plain)(context))
end
return template | apache-2.0 |
dacrybabysuck/darkstar | scripts/zones/Sealions_Den/Zone.lua | 9 | 1216 | -----------------------------------
--
-- Zone: Sealions_Den (32)
--
-----------------------------------
local ID = require("scripts/zones/Sealions_Den/IDs")
require("scripts/globals/conquest")
require("scripts/globals/missions")
-----------------------------------
function onInitialize(zone)
end;
function onConquestUpdate(zone, updatetype)
dsp.conq.onConquestUpdate(zone, updatetype)
end;
function onZoneIn(player,prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(600.101,130.355,797.612,50);
end
if (player:getCurrentMission(COP) == dsp.mission.id.cop.ONE_TO_BE_FEARED and player:getCharVar("PromathiaStatus")==1) then
cs=15;
elseif (player:getCurrentMission(COP) == dsp.mission.id.cop.CHAINS_AND_BONDS and player:getCharVar("PromathiaStatus")==2) then
cs=14;
end
return cs;
end;
function onRegionEnter(player,region)
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 15) then
player:setCharVar("PromathiaStatus",2);
elseif (csid == 14) then
player:setCharVar("PromathiaStatus",3);
end
end;
| gpl-3.0 |
soveran/stal | stal.lua | 2 | 1594 | -- Copyright (c) 2016 Michel Martens
local expr = cjson.decode(ARGV[1])
local tr = {
SDIFF = "SDIFFSTORE",
SINTER = "SINTERSTORE",
SUNION = "SUNIONSTORE",
ZINTER = "ZINTERSTORE",
ZUNION = "ZUNIONSTORE",
}
local function append(t1, t2)
for _, item in ipairs(t2) do
table.insert(t1, item)
end
end
local function map(t, f)
local nt = {}
for k, v in pairs(t) do
nt[k] = f(v)
end
return nt
end
local compile, convert
function compile(expr, ids, ops)
return map(expr, function(v)
if (type(v) == "table") then
return convert(v, ids, ops)
else
return v
end
end)
end
function convert(expr, ids, ops)
local tail = {unpack(expr)}
local head = table.remove(tail, 1)
-- Key where partial results will be stored
local id = "stal:" .. #ids
-- Keep a reference to clean it up later
table.insert(ids, id)
-- Translate into command and destination key
local op = {tr[head] or head, id}
-- Compile the rest recursively
append(op, compile(tail, ids, ops))
-- Append the outermost operation
table.insert(ops, op)
return id
end
local function solve(expr)
local ids = {}
local ops = {}
local res = nil
table.insert(ops, compile(expr, ids, ops))
if (#ops == 1) then
return redis.call(unpack(ops[1]))
else
for _, op in ipairs(ops) do
if (#op > 1) then
res = redis.call(unpack(op))
end
end
redis.call("DEL", unpack(ids))
return res
end
end
if redis.replicate_commands then
redis.replicate_commands()
redis.set_repl(redis.REPL_NONE)
end
return solve(expr)
| mit |
dacrybabysuck/darkstar | scripts/globals/weaponskills/scourge.lua | 10 | 2112 | -----------------------------------
-- Scourge
-- Great Sword weapon skill
-- Skill level: N/A
-- Additional effect: temporarily improves params.critical hit rate.
-- params.critical hit rate boost duration is based on TP when the weapon skill is used. 100% TP will give 20 seconds of params.critical hit rate boost this scales linearly to 60 seconds of params.critical hit rate boost at 300% TP. 5 TP = 1 Second of Aftermath.
-- Parses show the params.critical hit rate increase from the Scourge Aftermath is between 10% and 15%.
-- This weapon skill is only available with the stage 5 relic Great Sword Ragnarok or within Dynamis with the stage 4 Valhalla.
-- Aligned with the Light Gorget & Flame Gorget.
-- Aligned with the Light Belt & Flame Belt.
-- Element: None
-- Modifiers: STR:40% VIT:40%
-- 100%TP 200%TP 300%TP
-- 3.00 3.00 3.00
-----------------------------------
require("scripts/globals/aftermath")
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/weaponskills")
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar)
local params = {}
params.numHits = 1
params.ftp100 = 3 params.ftp200 = 3 params.ftp300 = 3
params.str_wsc = 0.0 params.dex_wsc = 0.0 params.vit_wsc = 0.0 params.agi_wsc = 0.0 params.int_wsc = 0.0 params.mnd_wsc = 0.4 params.chr_wsc = 0.4
params.crit100 = 0.0 params.crit200 = 0.0 params.crit300 = 0.0
params.canCrit = false
params.acc100 = 0.0 params.acc200 = 0.0 params.acc300 = 0.0
params.atk100 = 1; params.atk200 = 1; params.atk300 = 1;
if USE_ADOULIN_WEAPON_SKILL_CHANGES then
params.str_wsc = 0.4 params.vit_wsc = 0.4 params.mnd_wsc = 0.0 params.chr_wsc = 0.0
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, action, primary, taChar)
-- Apply aftermath
if damage > 0 then
dsp.aftermath.addStatusEffect(player, tp, dsp.slot.MAIN, dsp.aftermath.type.RELIC)
end
return tpHits, extraHits, criticalHit, damage
end
| gpl-3.0 |
pSyChOoOo/TeleSeed | .luarocks/share/lua/5.2/luarocks/make.lua | 18 | 3687 |
--- Module implementing the LuaRocks "make" command.
-- Builds sources in the current directory, but unlike "build",
-- it does not fetch sources, etc., assuming everything is
-- available in the current directory.
--module("luarocks.make", package.seeall)
local make = {}
package.loaded["luarocks.make"] = make
local build = require("luarocks.build")
local fs = require("luarocks.fs")
local util = require("luarocks.util")
local cfg = require("luarocks.cfg")
local fetch = require("luarocks.fetch")
local pack = require("luarocks.pack")
local remove = require("luarocks.remove")
local deps = require("luarocks.deps")
make.help_summary = "Compile package in current directory using a rockspec."
make.help_arguments = "[--pack-binary-rock] [<rockspec>]"
make.help = [[
Builds sources in the current directory, but unlike "build",
it does not fetch sources, etc., assuming everything is
available in the current directory. If no argument is given,
look for a rockspec in the current directory. If more than one
is found, you must specify which to use, through the command-line.
This command is useful as a tool for debugging rockspecs.
To install rocks, you'll normally want to use the "install" and
"build" commands. See the help on those for details.
--pack-binary-rock Do not install rock. Instead, produce a .rock file
with the contents of compilation in the current
directory.
--keep Do not remove previously installed versions of the
rock after installing a new one. This behavior can
be made permanent by setting keep_other_versions=true
in the configuration file.
--branch=<name> Override the `source.branch` field in the loaded
rockspec. Allows to specify a different branch to
fetch. Particularly for SCM rocks.
]]
--- Driver function for "make" command.
-- @param name string: A local rockspec.
-- @return boolean or (nil, string, exitcode): True if build was successful; nil and an
-- error message otherwise. exitcode is optionally returned.
function make.run(...)
local flags, rockspec = util.parse_flags(...)
assert(type(rockspec) == "string" or not rockspec)
if not rockspec then
for file in fs.dir() do
if file:match("rockspec$") then
if rockspec then
return nil, "Please specify which rockspec file to use."
else
rockspec = file
end
end
end
if not rockspec then
return nil, "Argument missing: please specify a rockspec to use on current directory."
end
end
if not rockspec:match("rockspec$") then
return nil, "Invalid argument: 'make' takes a rockspec as a parameter. "..util.see_help("make")
end
if flags["pack-binary-rock"] then
local rspec, err, errcode = fetch.load_rockspec(rockspec)
if not rspec then
return nil, err
end
return pack.pack_binary_rock(rspec.name, rspec.version, build.build_rockspec, rockspec, false, true, deps.get_deps_mode(flags))
else
local ok, err = fs.check_command_permissions(flags)
if not ok then return nil, err, cfg.errorcodes.PERMISSIONDENIED end
ok, err = build.build_rockspec(rockspec, false, true, deps.get_deps_mode(flags))
if not ok then return nil, err end
local name, version = ok, err
if (not flags["keep"]) and not cfg.keep_other_versions then
local ok, err = remove.remove_other_versions(name, version, flags["force"])
if not ok then util.printerr(err) end
end
return name, version
end
end
return make
| gpl-2.0 |
skogler/GearHelper | libs/LibDataBroker-1.1/LibDataBroker-1.1.lua | 12 | 3229 |
assert(LibStub, "LibDataBroker-1.1 requires LibStub")
assert(LibStub:GetLibrary("CallbackHandler-1.0", true), "LibDataBroker-1.1 requires CallbackHandler-1.0")
local lib, oldminor = LibStub:NewLibrary("LibDataBroker-1.1", 4)
if not lib then return end
oldminor = oldminor or 0
lib.callbacks = lib.callbacks or LibStub:GetLibrary("CallbackHandler-1.0"):New(lib)
lib.attributestorage, lib.namestorage, lib.proxystorage = lib.attributestorage or {}, lib.namestorage or {}, lib.proxystorage or {}
local attributestorage, namestorage, callbacks = lib.attributestorage, lib.namestorage, lib.callbacks
if oldminor < 2 then
lib.domt = {
__metatable = "access denied",
__index = function(self, key) return attributestorage[self] and attributestorage[self][key] end,
}
end
if oldminor < 3 then
lib.domt.__newindex = function(self, key, value)
if not attributestorage[self] then attributestorage[self] = {} end
if attributestorage[self][key] == value then return end
attributestorage[self][key] = value
local name = namestorage[self]
if not name then return end
callbacks:Fire("LibDataBroker_AttributeChanged", name, key, value, self)
callbacks:Fire("LibDataBroker_AttributeChanged_"..name, name, key, value, self)
callbacks:Fire("LibDataBroker_AttributeChanged_"..name.."_"..key, name, key, value, self)
callbacks:Fire("LibDataBroker_AttributeChanged__"..key, name, key, value, self)
end
end
if oldminor < 2 then
function lib:NewDataObject(name, dataobj)
if self.proxystorage[name] then return end
if dataobj then
assert(type(dataobj) == "table", "Invalid dataobj, must be nil or a table")
self.attributestorage[dataobj] = {}
for i,v in pairs(dataobj) do
self.attributestorage[dataobj][i] = v
dataobj[i] = nil
end
end
dataobj = setmetatable(dataobj or {}, self.domt)
self.proxystorage[name], self.namestorage[dataobj] = dataobj, name
self.callbacks:Fire("LibDataBroker_DataObjectCreated", name, dataobj)
return dataobj
end
end
if oldminor < 1 then
function lib:DataObjectIterator()
return pairs(self.proxystorage)
end
function lib:GetDataObjectByName(dataobjectname)
return self.proxystorage[dataobjectname]
end
function lib:GetNameByDataObject(dataobject)
return self.namestorage[dataobject]
end
end
if oldminor < 4 then
local next = pairs(attributestorage)
function lib:pairs(dataobject_or_name)
local t = type(dataobject_or_name)
assert(t == "string" or t == "table", "Usage: ldb:pairs('dataobjectname') or ldb:pairs(dataobject)")
local dataobj = self.proxystorage[dataobject_or_name] or dataobject_or_name
assert(attributestorage[dataobj], "Data object not found")
return next, attributestorage[dataobj], nil
end
local ipairs_iter = ipairs(attributestorage)
function lib:ipairs(dataobject_or_name)
local t = type(dataobject_or_name)
assert(t == "string" or t == "table", "Usage: ldb:ipairs('dataobjectname') or ldb:ipairs(dataobject)")
local dataobj = self.proxystorage[dataobject_or_name] or dataobject_or_name
assert(attributestorage[dataobj], "Data object not found")
return ipairs_iter, attributestorage[dataobj], 0
end
end
| mit |
p00ria/Blacklife-Pouria | plugins/Abjad.lua | 2 | 3981 | local numbers = {}
numbers['ا'] = 1
numbers['ب'] = 2
numbers['ج'] = 3
numbers['د'] = 4
numbers['ه'] = 5
numbers['و'] = 6
numbers['ز'] = 7
numbers['ح'] = 8
numbers['ط'] = 9
numbers['ی'] = 10
numbers['ک'] = 20
numbers['ل'] = 30
numbers['م'] = 40
numbers['ن'] = 50
numbers['س'] = 60
numbers['ع'] = 70
numbers['ف'] = 80
numbers['ص'] = 90
numbers['ق'] = 100
numbers['ر'] = 200
numbers['ش'] = 300
numbers['ت'] = 400
numbers['ث'] = 500
numbers['خ'] = 600
numbers['ذ'] = 700
numbers['ض'] = 800
numbers['ظ'] = 900
numbers['غ'] = 900
local function convert(text)
local text = text:gsub('ژ','ز')
local text = text:gsub('گ','ک')
local text = text:gsub('چ','ج')
local text = text:gsub('پ','ب')
local text = text:gsub('ئ','ی')
local text = text:gsub('آ','ا')
local text = text:gsub('ۀ','ه')
local text = text:gsub('ي','ی')
local text = text:gsub('ة','ه')
local text = text:gsub('ؤ','و')
return text
end
local function abjad(text,num,str)
local num = num
local text = text
if text:match(str) then
for word in string.gmatch(text, str) do num = num + numbers[str]
end
text = text:gsub(str,'')
end
return text , num
end
local function run(msg, matches)
if not matches[2] or matches[2] == '' then
return [[حروف جمل یا به عبارت دیگر حروف ابجد،نام مجموع صور هشتگانه حروف عرب است. این صور ازین قرار است: ابجد – هوز- حطي - کلمن - سعفص - قرشت - ثخذ - ضظغ.
ترتيب حروف (مراد،حروف صامت است) درين نسق همان ترتيب عبري آرامي است و اين امر با دلايل ديگر مؤید آنست که عرب الفباي خود را از آنان بوساطت نبطيان اقتباس کرده و شش حرف مخصوص عرب در آخر ترتيب ابجدي قرار داده شده است؛ علاوه برين ترتيب هشت کلمه تذکاريه که مفهومي ندارند با عبري و آرامي در اينکه حروف معرف اعدادند نيز شباهت دارد،از «همزه» تا «ی» نماينده ی 1تا10 ،«ک» تا «ق» نماینده ی 20تا100 و نه حرف آخر معرف 200تا1000 باشد. ابجد تجريد نوشتن (تصوف) ترک خواهش و آرزو کردن و از خودي و مزاحمت خواهش آمدن و از ماسوي الله مجرد گرديدن...
ا=1 ک=20 ش=300
ب=2 ل=30 ت=400
ج=3 م=40 ث=500
د=4 ن=50 خ=600
ه=5 س=60 ذ=700
و=6 ع=70 ض=800
ز=7 ف=80 ظ=900
ح=8 ص=90 غ=1000
ط=9 ق=100
ی=10 ر=200
]]
end
local text = convert(matches[2])
local num = 0
text , num = abjad(text,num,'ا')
text , num = abjad(text,num,'ب')
text , num = abjad(text,num,'ج')
text , num = abjad(text,num,'د')
text , num = abjad(text,num,'ه')
text , num = abjad(text,num,'و')
text , num = abjad(text,num,'ز')
text , num = abjad(text,num,'ح')
text , num = abjad(text,num,'ط')
text , num = abjad(text,num,'ی')
text , num = abjad(text,num,'ک')
text , num = abjad(text,num,'ل')
text , num = abjad(text,num,'م')
text , num = abjad(text,num,'ن')
text , num = abjad(text,num,'س')
text , num = abjad(text,num,'ع')
text , num = abjad(text,num,'ف')
text , num = abjad(text,num,'ص')
text , num = abjad(text,num,'ق')
text , num = abjad(text,num,'ر')
text , num = abjad(text,num,'ش')
text , num = abjad(text,num,'ت')
text , num = abjad(text,num,'ث')
text , num = abjad(text,num,'خ')
text , num = abjad(text,num,'ذ')
text , num = abjad(text,num,'ض')
text , num = abjad(text,num,'ظ')
text , num = abjad(text,num,'غ')
if text ~= '' then
return 'فقط زبان فارسی پشتیبانی میشود'
end
return 'عدد ابجد کبیر : '..num
end
return {
patterns = {
"^[!/#]([Aa]bjad) (.*)$",
"^[!/#]([Aa]bjad)$"
},
run = run
}
| gpl-2.0 |
dacrybabysuck/darkstar | scripts/globals/items/moorish_idol.lua | 11 | 1051 | -----------------------------------------
-- ID: 5121
-- Item: Moorish Idol
-- Food Effect: 5Min, Mithra only
-----------------------------------------
-- Dexterity 2
-- Mind -4
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if (target:getRace() ~= dsp.race.MITHRA) then
result = dsp.msg.basic.CANNOT_EAT
end
if (target:getMod(dsp.mod.EAT_RAW_FISH) == 1) then
result = 0
end
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,300,5121)
end
function onEffectGain(target, effect)
target:addMod(dsp.mod.DEX, 2)
target:addMod(dsp.mod.MND, -4)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.DEX, 2)
target:delMod(dsp.mod.MND, -4)
end
| gpl-3.0 |
dacrybabysuck/darkstar | scripts/globals/mobskills/ion_shower.lua | 11 | 1056 | ---------------------------------------------
-- Ion Shower
--
-- Description: Calls forth an ion storm, dealing Lightning damage to all nearby targets. Additional effect: Stun
-- Type: Magical
-- Utsusemi/Blink absorb: Wipes shadows
-- Range: Unknown radial
-- Notes:
---------------------------------------------
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/monstertpmoves")
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
return 0
end
function onMobWeaponSkill(target, mob, skill)
local typeEffect = dsp.effect.STUN
MobStatusEffectMove(mob, target, typeEffect, 1, 0, 5)
local dmgmod = 1
local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*3.5,dsp.magic.ele.THUNDER,dmgmod,TP_NO_EFFECT)
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,dsp.attackType.MAGICAL,dsp.damageType.LIGHTNING,MOBPARAM_WIPE_SHADOWS)
target:takeDamage(dmg, mob, dsp.attackType.MAGICAL, dsp.damageType.LIGHTNING)
return dmg
end
| gpl-3.0 |
keviner2004/shoot-em-up | scenes/start.lua | 1 | 9269 | local composer = require("composer")
local MenuScene = require("scenes.templates.MenuScene")
local Sprite = require("Sprite")
local logger = require("logger")
local gameConfig = require("gameConfig")
local sfx = require("sfx")
local TAG = "START MENU"
local navigator = require("navigator")
local dbHelper = require("dbHelper")
local facebook = require("facebook")
local ScaleText = require("ui.ScaleText")
local Title = require("ui.Title")
local scene = MenuScene.new()
local INDEX_START_1P = 1
local INDEX_START_2P = 2
local INDEX_LEADERBOARD = 3
local INDEX_WHO_ARE_YOU = 4
local INDEX_LOGIN = 5
local TEXT_LOGIN = "Sign in"
local TEXT_LOGOUT = "Logout"
function scene:init()
logger:debug(TAG, "~~~~~~~~~~Init start scene~~~~~~~~~~")
navigator:clear()
self.menuWidth = math.round(gameConfig.contentWidth*0.8)
self.menuHeight = math.round(gameConfig.contentHeight*0.5)
if gameConfig.singlePlayerOnly then
INDEX_START_1P = 1
INDEX_START_2P = 999
INDEX_LEADERBOARD = 2
INDEX_WHO_ARE_YOU = 3
INDEX_LOGIN = 4
else
INDEX_START_1P = 1
INDEX_START_2P = 2
INDEX_LEADERBOARD = 3
INDEX_WHO_ARE_YOU = 4
INDEX_LOGIN = 5
end
end
function scene:construct()
local logo = Sprite["expansion-9"].new("Logo")
local versionTxt = ScaleText.new({
text = "Ver."..gameConfig.version,
x = 0, y = 0, font = gameConfig.defaultFont, fontSize = 17
})
self.superGroup:insert(logo)
self.superGroup:insert(versionTxt)
self.logo = logo
self.versionTxt = versionTxt
self.glassPanel.alpha = 0
end
function scene:insertButtons()
logger:debug(TAG, "insertButtons")
local function blink(btn, show)
if not show then
alpha = 0.65
else
alpha = 1
end
transition.to(btn, {time = 300, alpha = alpha, onComplete =
function()
return blink(btn, not show)
end
})
end
local startButtonText = "~Start~"
if not gameConfig.singlePlayerOnly then
startButtonText = "~1P~"
end
local startButton = self:newButton(startButtonText)
startButton.buttonView.alpha = 0
startButton.buttonText.size = 30 * gameConfig.scaleFactor
startButton.pressSound = "start"
startButton.buttonView.isHitTestable = true
blink(startButton)
self:insertButton(startButton)
if not gameConfig.singlePlayerOnly then
local secondButton = self:newButton("~2P~")
secondButton.buttonView.alpha = 0
secondButton.buttonText.size = 30 * gameConfig.scaleFactor
secondButton.pressSound = "start"
secondButton.buttonView.isHitTestable = true
blink(secondButton)
self:insertButton(secondButton)
end
local userButton = self:createUserButton()
local leaderBoardButton = self:createLeaderBoardButton()
local loginButton = self:createLoginButton()
self:insertButton(leaderBoardButton)
self:insertButton(userButton)
self:insertButton(loginButton)
self.userButton = userButton
self.leaderBoardButton = leaderBoardButton
self.loginButton = loginButton
--[[
function startButton:onTouch(event)
--print("!!!!!!!!!!!!")
--print("custom: "..event.phase.."/"..event.phase)
if event.phase == "ended" then
gameConfig.numOfPlayers = 1
--scene:startGame()
scene:selectLevel()
end
end
function secondButton:onTouch(event)
--print("!!!!!!!!!!!!")
--print("custom: "..event.phase.."/"..event.phase)
if event.phase == "ended" then
gameConfig.numOfPlayers = 2
--scene:startGame()
scene:selectLevel()
end
end
--]]
end
function scene:createUserButton()
local button = display.newGroup()
--add user icon
local userIcon = Sprite["expansion-9"].new("UI/Icons/oneUser")
--add user name
local userText = ScaleText.new({
text = "",
x = 0,
y = 0,
font = gameConfig.defaultFont,
fontSize = 17
})
local gap = 15
userIcon.xScale = 0.5
userIcon.yScale = 0.5
button:insert(userText)
button:insert(userIcon)
function button:resize()
local width = userText.width + userIcon.contentWidth
userIcon.x = (userIcon.contentWidth - width)/2
userText.x = userIcon.x + gap + (userIcon.contentWidth + userText.width)/2
end
function button:setUserName(text)
userText.text = text
self:resize()
end
button:setUserName("Who are you?")
return button
end
function scene:createLoginButton()
local button = display.newGroup()
local title = Title.new({
text = {
font = native.systemFont,
fontSize = 20,
value = TEXT_LOGIN
}
})
button:insert(title)
--button:insert(text)
self.loginTitle = title
return button
end
function scene:createLeaderBoardButton()
local button = display.newGroup()
--add user icon
local icon = Sprite["expansion-9"].new("UI/Icons/leaderBoard")
--add user name
local text = ScaleText.new({text = "", x = 0, y = 0, font = gameConfig.defaultFont, fontSize = 20})
local gap = 15
button:insert(text)
button:insert(icon)
function button:resize()
local width = text.width + icon.width
icon.x = (icon.width - width)/2
text.x = icon.x + gap + (icon.width + text.width)/2
end
function button:setText(value)
text.text = value
self:resize()
end
button:setText("")
return button
end
function scene:startGame()
logger:debug(TAG, "Start the game")
--composer.gotoScene("scenes.game")
end
function scene:selectLevel()
navigator:push("scenes.start")
composer.showOverlay( "scenes.chapterSelection", {
isModal = true,
effect = "fromRight",
time = 400
})
end
function scene:onWillShow( event )
local userName = dbHelper:getInfo("userName")
if not userName or userName == "" then
userName = "Who are you?"
end
self.userButton:setUserName(userName)
self.logo.x = gameConfig.contentWidth/2
self.logo.y = self.buttons.y - (self.buttons.height + self.logo.height) * 0.5 - gameConfig.contentHeight * 0.05
self.versionTxt.x = self.logo.x
self.versionTxt.y = self.logo.y + self.logo.height/2 + self.versionTxt.height/2
self.leaderBoardButton.y = self.leaderBoardButton.y + gameConfig.contentHeight * 0.05
self.userButton.y = self.leaderBoardButton.y + (self.leaderBoardButton.height + self.userButton.height)/2 + gameConfig.contentHeight * 0.05
self.loginButton.y = self.userButton.y + (self.userButton.height + self.loginButton.height)/2 + gameConfig.contentHeight * 0.05
end
function scene:updateLoginStatus()
if facebook.getCurrentAccessToken() then
self.loginTitle:setText(TEXT_LOGOUT)
else
self.loginTitle:setText(TEXT_LOGIN)
end
end
function scene:onDidShow( event )
--self:alert("Welcome")
--auto login
local autoLogin = dbHelper:getAutoSignIn()
logger:debug(TAG, "check need login to facebook, autoLogin: %s, disable: %s", tostring(autoLogin), tostring((event.params and event.params.action == "disableLogin") or 0))
if autoLogin and not (event.params and event.params.action == "disableLogin") then
logger:debug(TAG, "login with facebook")
facebook.login(function(status)
logger:debug(TAG, "login with status %s", status)
if status == facebook.STATUS_LOGIN then
self:updateLoginStatus()
facebook.getUserInfo(function(info)
dbHelper:setLoginType("FB")
dbHelper:setUser(info.id or "")
end)
end
end)
else
self:updateLoginStatus()
end
end
function scene:onWillHide( event )
end
function scene:onConfirm(buttonSelectedIndex)
logger:debug(TAG, "Select mode %d", buttonSelectedIndex)
sfx:play("start")
--if name is empty, fore user add it
local userName = dbHelper:getUserName()
if not userName or userName == "" then
logger:warn(TAG, "No user name, force user to create it")
self:go("scenes.start", "scenes.whoAreYou")
return
end
if buttonSelectedIndex == INDEX_LOGIN then
--sfx:play("start")
--LOGIN OR LOGOUT
if facebook.getCurrentAccessToken() then
--logout
facebook.logout(function(status)
dbHelper:enableAutoSignIn(false)
self:updateLoginStatus()
end)
else
self:go("scenes.start", "scenes.login", {
text = userName
})
end
return
end
if buttonSelectedIndex == INDEX_WHO_ARE_YOU then
--sfx:play("start")
self:go("scenes.start", "scenes.whoAreYou", {
text = userName
})
return
end
if buttonSelectedIndex == INDEX_LEADERBOARD then
--sfx:play("start")
self:go("scenes.start", "scenes.leaderBoardSelection")
return
end
if buttonSelectedIndex == INDEX_START_2P then
gameConfig.numOfPlayers = 2
elseif buttonSelectedIndex == INDEX_START_1P then
gameConfig.numOfPlayers = 1
end
self:selectLevel()
--self:startGame()
end
return scene
| mit |
dacrybabysuck/darkstar | scripts/zones/Lower_Jeuno/npcs/Bki_Tbujhja.lua | 9 | 4220 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: Bki Tbujhja
-- Involved in Quest: The Old Monument
-- Starts and Finishes Quests: Path of the Bard (just start), The Requiem (BARD AF2)
-- !pos -22 0 -60 245
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/globals/shop");
local ID = require("scripts/zones/Lower_Jeuno/IDs");
-----------------------------------
function onTrade(player,npc,trade)
local theRequiem = player:getQuestStatus(JEUNO,dsp.quest.id.jeuno.THE_REQUIEM);
-- THE REQUIEM (holy water)
if (theRequiem == QUEST_ACCEPTED and player:getCharVar("TheRequiemCS") == 2 and trade:hasItemQty(4154,1) and trade:getItemCount() == 1) then
player:startEvent(151);
end;
end;
function onTrigger(player,npc)
local aMinstrelInDespair = player:getQuestStatus(JEUNO,dsp.quest.id.jeuno.A_MINSTREL_IN_DESPAIR);
local painfulMemory = player:getQuestStatus(JEUNO,dsp.quest.id.jeuno.PAINFUL_MEMORY);
local theRequiem = player:getQuestStatus(JEUNO,dsp.quest.id.jeuno.THE_REQUIEM);
-- THE OLD MONUMENT
if (player:getCharVar("TheOldMonument_Event") == 1) then
player:startEvent(181); -- mentions song runes in Buburimu
-- PATH OF THE BARD (Bard Flag)
elseif (aMinstrelInDespair == QUEST_COMPLETED and player:getCharVar("PathOfTheBard_Event") == 0) then
player:startEvent(182); -- mentions song runes in Valkurm
-- THE REQUIEM (Bard AF2)
elseif (painfulMemory == QUEST_COMPLETED and theRequiem == QUEST_AVAILABLE and player:getMainJob() == dsp.job.BRD and player:getMainLvl() >= AF2_QUEST_LEVEL) then
if (player:getCharVar("TheRequiemCS") == 0) then
player:startEvent(145); -- Long dialog & Start Quest "The Requiem"
else
player:startEvent(148); -- Shot dialog & Start Quest "The Requiem"
end;
elseif (theRequiem == QUEST_ACCEPTED and player:getCharVar("TheRequiemCS") == 2) then
player:startEvent(146); -- During Quest "The Requiem" (before trading Holy Water)
elseif (theRequiem == QUEST_ACCEPTED and player:getCharVar("TheRequiemCS") == 3 and player:hasKeyItem(dsp.ki.STAR_RING1) == false) then
if (math.random(1,2) == 1) then
player:startEvent(147); -- oh, did you take the holy water and play the requiem? you must do both!
else
player:startEvent(149); -- his stone sarcophagus is deep inside the eldieme necropolis.
end;
elseif (theRequiem == QUEST_ACCEPTED and player:hasKeyItem(dsp.ki.STAR_RING1) == true) then
player:startEvent(150); -- Finish Quest "The Requiem"
elseif (theRequiem == QUEST_COMPLETED) then
player:startEvent(134); -- Standard dialog after "The Requiem"
-- DEFAULT DIALOG
else
player:startEvent(180);
end;
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
-- THE OLD MONUMENT
if (csid == 181) then
player:setCharVar("TheOldMonument_Event",2);
-- PATH OF THE BARD
elseif (csid == 182) then
player:setCharVar("PathOfTheBard_Event",1);
-- THE REQUIEM
elseif (csid == 145 and option == 0) then
player:setCharVar("TheRequiemCS",1); -- player declines quest
elseif ((csid == 145 or csid == 148) and option == 1) then
player:addQuest(JEUNO,dsp.quest.id.jeuno.THE_REQUIEM);
player:setCharVar("TheRequiemCS",2);
elseif (csid == 151) then
player:setCharVar("TheRequiemCS",3);
player:messageSpecial(ID.text.ITEM_OBTAINED,4154); -- Holy Water (just message)
player:setCharVar("TheRequiemRandom",math.random(1,5)); -- pick a random sarcophagus
elseif (csid == 150) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,14098);
else
player:addItem(14098);
player:messageSpecial(ID.text.ITEM_OBTAINED,14098); -- Choral Slippers
player:addFame(JEUNO, 30);
player:completeQuest(JEUNO,dsp.quest.id.jeuno.THE_REQUIEM);
end;
end;
end;
| gpl-3.0 |
dacrybabysuck/darkstar | scripts/globals/items/butter_crepe.lua | 11 | 1187 | -----------------------------------------
-- ID: 5766
-- Item: Butter Crepe
-- Food Effect: 30 Min, All Races
-----------------------------------------
-- HP +10% (cap 10)
-- Magic Accuracy +20% (cap 25)
-- Magic Defense +1
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,1800,5766)
end
function onEffectGain(target,effect)
target:addMod(dsp.mod.FOOD_HPP, 10)
target:addMod(dsp.mod.FOOD_HP_CAP, 10)
target:addMod(dsp.mod.MDEF, 1)
target:addMod(dsp.mod.FOOD_MACCP, 20)
target:addMod(dsp.mod.FOOD_MACC_CAP, 25)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.FOOD_HPP, 10)
target:delMod(dsp.mod.FOOD_HP_CAP, 10)
target:delMod(dsp.mod.MDEF, 1)
target:delMod(dsp.mod.FOOD_MACCP, 20)
target:delMod(dsp.mod.FOOD_MACC_CAP, 25)
end
| gpl-3.0 |
dacrybabysuck/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Kemha_Flasehp.lua | 12 | 1754 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Kemha Flasehp
-- Type: Fishing Normal/Adv. Image Support
-- !pos -28.4 -6 -98 50
-----------------------------------
require("scripts/globals/status")
require("scripts/globals/crafting")
require("scripts/globals/npc_util")
local ID = require("scripts/zones/Aht_Urhgan_Whitegate/IDs")
-----------------------------------
function onTrade(player,npc,trade)
local guildMember = isGuildMember(player,5)
if guildMember == 1 then
if npcUtil.tradeHas(trade,2184) then
if player:hasStatusEffect(dsp.effect.FISHING_IMAGERY) == false then
player:confirmTrade()
player:startEvent(643,8,0,0,0,188,0,6,0)
else
npc:showText(npc, ID.text.IMAGE_SUPPORT_ACTIVE)
end
end
end
end
function onTrigger(player,npc)
local guildMember = isGuildMember(player,5)
local SkillLevel = player:getSkillLevel(dsp.skill.FISHING)
if guildMember == 1 then
if player:hasStatusEffect(dsp.effect.FISHING_IMAGERY) == false then
player:startEvent(642,8,0,0,511,1,0,0,2184)
else
player:startEvent(642,8,0,0,511,1,19267,0,2184)
end
else
player:startEvent(642,0,0,0,0,0,0,0,0) -- Standard Dialogue
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 642 and option == 1 then
player:messageSpecial(ID.text.IMAGE_SUPPORT,0,0,1)
player:addStatusEffect(dsp.effect.FISHING_IMAGERY,1,0,3600)
elseif csid == 643 then
player:messageSpecial(ID.text.IMAGE_SUPPORT,0,0,0)
player:addStatusEffect(dsp.effect.FISHING_IMAGERY,2,0,7200)
end
end | gpl-3.0 |
myself1185/self | plugins/member.lua | 1 | 23879 | local function is_spromoted(chat_id, user_id)
local hash = 'sprom:'..chat_id..':'..user_id
local spromoted = redis:get(hash)
return spromoted or false
end
local function kick_user(user_id, chat_id)
local chat = 'chat#id'..chat_id
local user = 'user#id'..user_id
chat_del_user(chat, user, ok_cb, true)
end
local function kick_user_chan(user_id, chat_id)
local channel = 'channel#id'..chat_id
local user = 'user#id'..user_id
channel_kick_user(channel, user, ok_cb, true)
end
local function ban_user(user_id, chat_id)
local hash = 'banned:'..chat_id..':'..user_id
redis:set(hash, true)
kick_user(user_id, chat_id)
end
local function superban_user(user_id, chat_id)
local hash = 'superbanned:'..user_id
redis:set(hash, true)
kick_user(user_id, chat_id)
end
local function superban_user_chan(user_id, chat_id)
local hash = 'superbanned:'..user_id
redis:set(hash, true)
kick_user_chan(user_id, chat_id)
end
local function silent_user(user_id, chat_id)
local hash = 'silent:'..chat_id..':'..user_id
redis:set(hash, true)
end
local function is_banned(user_id, chat_id)
local hash = 'banned:'..chat_id..':'..user_id
local banned = redis:get(hash)
return banned or false
end
local function is_super_banned(user_id)
local hash = 'superbanned:'..user_id
local superbanned = redis:get(hash)
return superbanned or false
end
local function is_user_silent(user_id, chat_id)
local hash = 'silent:'..chat_id..':'..user_id
local silent = redis:get(hash)
return silent or false
end
local function pre_process(msg)
if msg.action and msg.action.type then
local action = msg.action.type
if action == 'chat_add_user' or action == 'chat_add_user_link' then
local user_id
if msg.action.link_issuer then
user_id = msg.from.id
else
user_id = msg.action.user.id
end
print('Checking invited user '..user_id)
local superbanned = is_super_banned(user_id)
local banned = is_banned(user_id, msg.to.id)
if superbanned or banned then
print('User is banned!')
if msg.to.type == 'chat' then
kick_user(user_id, msg.to.id)
end
if msg.to.type == 'channel' then
kick_user_chan(user_id, msg.to.id)
end
end
end
return msg
end
-- BANNED USER TALKING
if msg.to.type == 'chat' then -- For chat
local user_id = msg.from.id
local chat_id = msg.to.id
local superbanned = is_super_banned(user_id)
local banned = is_banned(user_id, chat_id)
if superbanned then
print('SuperBanned user talking!')
superban_user(user_id, chat_id)
msg.text = ''
end
if banned then
print('Banned user talking!')
ban_user(user_id, chat_id)
msg.text = ''
end
end
if msg.to.type == 'channel' then -- For supergroup
local user_id = msg.from.id
local chat_id = msg.to.id
if is_user_silent(user_id, chat_id) then -- is user allowed to talk?
delete_msg(msg.id, ok_cb, false)
return nil
end
local superbanned = is_super_banned(user_id)
local banned = is_banned(user_id, chat_id)
if superbanned then
print('SuperBanned user talking!')
superban_user_chan(user_id, chat_id)
msg.text = ''
end
if banned then
print('Banned user talking!')
ban_user(user_id, chat_id)
msg.text = ''
end
end
return msg
end
local function username_id(cb_extra, success, result)
local get_cmd = cb_extra.get_cmd
local receiver = cb_extra.receiver
local member = cb_extra.member
local chat_id = string.gsub(receiver,'.+#id', '')
local text = 'No user @'..member..' in this group.'
for k,v in pairs(result.members) do
vusername = v.username
if vusername == member then
member_username = member
member_id = v.peer_id
if get_cmd == 'kick' then
if member_id == our_id then
send_large_msg(receiver, 'Are you kidding?')
return nil
end
local data = load_data(_config.moderation.data)
if data[tostring('admins')] then
if data[tostring('admins')][tostring(member_id)] then
send_large_msg(receiver, 'You can\'t kick admin!')
return nil
end
end
if is_spromoted(chat_id, member_id) then
return send_large_msg(receiver,'You can\'t kick leader')
end
return kick_user(member_id, chat_id)
end
if get_cmd == 'ban' then
if member_id == our_id then
send_large_msg(receiver, 'Are you kidding?')
return nil
end
local data = load_data(_config.moderation.data) -- FLUX MOD
if data[tostring('admins')] then
if data[tostring('admins')][tostring(member_id)] then
send_large_msg(receiver, 'You can\'t ban admin!')
return nil
end
end
if is_spromoted(chat_id, member_id) then
return send_large_msg(receiver, 'You can\'t ban leader')
end
send_large_msg(receiver, 'User @'..member..' ['..member_id..'] banned')
return ban_user(member_id, chat_id)
end
if get_cmd == 'sban' then
if member_id == our_id then
return nil
end
send_large_msg(receiver, 'User @'..member..' ['..member_id..'] globally banned!')
return superban_user(member_id, chat_id)
end
end
end
return send_large_msg(receiver, text)
end
local function channel_username_id(cb_extra, success, result)
local get_cmd = cb_extra.get_cmd
local receiver = cb_extra.receiver
local chat_id = string.gsub(receiver,'.+#id', '')
local member = cb_extra.member
local text = 'No user @'..member..' in this group.'
for k,v in pairs(result) do
vusername = v.username
if vusername == member then
member_username = member
member_id = v.peer_id
if get_cmd == 'kick' then
if member_id == our_id then
send_large_msg(receiver, 'Are you kidding?')
return nil
end
local data = load_data(_config.moderation.data) -- FLUX MOD
if data[tostring('admins')] then
if data[tostring('admins')][tostring(member_id)] then
send_large_msg(receiver, 'You can\'t kick admin!')
return nil
end
end
if is_spromoted(chat_id, member_id) then
return send_large_msg(receiver,'You can\'t kick leader')
end
return kick_user_chan(member_id, chat_id)
end
if get_cmd == 'ban' then
if member_id == our_id then
send_large_msg(receiver, 'Are you kidding?')
return nil
end
local data = load_data(_config.moderation.data)
if data[tostring('admins')] then
if data[tostring('admins')][tostring(member_id)] then
send_large_msg(receiver, 'You can\'t ban admin!')
return nil
end
end
if is_spromoted(chat_id, member_id) then
return send_large_msg(receiver, 'You can\'t ban leader')
end
send_large_msg(receiver, 'User @'..member..' ['..member_id..'] banned')
return ban_user(member_id, chat_id)
end
if get_cmd == 'sban' then
if member_id == our_id then
return nil
end
send_large_msg(receiver, 'User @'..member..' ['..member_id..'] globally banned!')
return superban_user_chan(member_id, chat_id)
end
if get_cmd == 'silent' then
if member_id == our_id then
return nil
end
local data = load_data(_config.moderation.data)
if data[tostring('admins')] then
if data[tostring('admins')][tostring(member_id)] then
send_large_msg(receiver, 'You can\'t do this to admin!')
return nil
end
end
if is_spromoted(chat_id, member_id) then
return send_large_msg(receiver, 'You can\'t do this to leader')
end
send_large_msg(receiver, 'User '..member_id..' not allowed to talk!')
return silent_user(member_id, chat_id)
end
if get_cmd == 'unsilent' then
if member_id == our_id then
return nil
end
local data = load_data(_config.moderation.data)
if data[tostring('admins')] then
if data[tostring('admins')][tostring(member_id)] then
send_large_msg(receiver, 'Admin always allowed to talk!')
return nil
end
end
local hash = 'silent:'..chat_id..':'..member_id
redis:del(hash)
return send_large_msg(receiver, 'User '..member_id..' allowed to talk')
end
end
end
return send_large_msg(receiver, text)
end
local function get_msg_callback(extra, success, result)
if success ~= 1 then return end
local get_cmd = extra.get_cmd
local receiver = extra.receiver
local user_id = result.from.peer_id
local chat_id = string.gsub(receiver,'.+#id', '')
if result.from.username then
username = '@'..result.from.username
else
username = string.gsub(result.from.print_name, '_', ' ')
end
if string.find(receiver,'chat#id.+') then
group_type = 'chat'
else
group_type = 'channel'
end
if get_cmd == 'kick' then
if user_id == our_id then
return nil
end
local data = load_data(_config.moderation.data)
if data[tostring('admins')] then
if data[tostring('admins')][tostring(user_id)] then
return send_large_msg(receiver, 'You can\'t kick admin!')
end
end
if is_spromoted(chat_id, user_id) then
print('kick leader')
return send_large_msg(receiver,'You can\'t kick leader')
end
if group_type == 'chat' then
return kick_user(user_id, chat_id)
else
return kick_user_chan(user_id, chat_id)
end
end
if get_cmd == 'ban' then
if user_id == our_id then
return nil
end
local data = load_data(_config.moderation.data) -- FLUX MOD
if data[tostring('admins')] then
if data[tostring('admins')][tostring(user_id)] then
return send_large_msg(receiver, 'You can\'t ban admin!')
end
end
if is_spromoted(chat_id, user_id) then
return send_large_msg(receiver,'You can\'t ban leader')
end
send_large_msg(receiver, 'User '..username..' ['..user_id..'] banned')
if group_type == 'chat' then
return ban_user(user_id, chat_id)
else
return kick_user_chan(user_id, chat_id)
end
end
if get_cmd == 'unban' then
if user_id == our_id then
return nil
end
local hash = 'banned:'..chat_id..':'..user_id
redis:del(hash)
return send_large_msg(receiver, 'User '..user_id..' unbanned')
end
if get_cmd == 'sban' then
if user_id == our_id then
return nil
end
send_large_msg(receiver, 'User '..username..' ['..user_id..'] globally banned!')
return superban_user(member_id, chat_id)
end
if get_cmd == 'silent' then
if user_id == our_id then
return nil
end
local data = load_data(_config.moderation.data)
if data[tostring('admins')] then
if data[tostring('admins')][tostring(user_id)] then
send_large_msg(receiver, 'You can\'t do this to admin!')
return nil
end
end
if is_spromoted(chat_id, user_id) then
return send_large_msg(receiver, 'You can\'t do this to leader')
end
send_large_msg(receiver, 'User '..user_id..' not allowed to talk!')
return silent_user(user_id, chat_id)
end
if get_cmd == 'unsilent' then
if member_id == our_id then
return nil
end
local data = load_data(_config.moderation.data)
if data[tostring('admins')] then
if data[tostring('admins')][tostring(user_id)] then
send_large_msg(receiver, 'Admin always allowed to talk!')
return nil
end
end
local hash = 'silent:'..chat_id..':'..user_id
redis:del(hash)
return send_large_msg(receiver, 'User '..user_id..' allowed to talk')
end
end
local function run(msg, matches)
if matches[1] == 'kickme' then
if is_chat_msg(msg) then
kick_user(msg.from.id, msg.to.id)
elseif is_channel_msg(msg) then
kick_user_chan(msg.from.id, msg.to.id)
else
return
end
end
if not is_momod(msg) then
return nil
end
local receiver = get_receiver(msg)
local get_cmd = matches[1]
if is_channel_msg(msg) then -- SUPERGROUUUPPPPPPPPPPPP
if matches[1] == 'ban' then
if not matches[2] and msg.reply_id then
get_message(msg.reply_id, get_msg_callback, {get_cmd=get_cmd, receiver=receiver})
end
if not matches[2] then
return
end
local user_id = matches[2]
local chat_id = msg.to.id
if string.match(matches[2], '^%d+$') then
if matches[2] == our_id then
return
end
local data = load_data(_config.moderation.data) -- FLUX MOD
if data[tostring('admins')] then
if data[tostring('admins')][tostring(user_id)] then
return 'You can\'t ban admin!'
end
end
if is_spromoted(msg.to.id, matches[2]) and not is_admin(msg) then
return 'You can\'t ban leader'
end
ban_user(user_id, chat_id)
send_large_msg(receiver, 'User '..user_id..' banned!')
else
local member = string.gsub(matches[2], '@', '')
channel_get_users(receiver, chanel_username_id, {get_cmd=get_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'unban' then
if not matches[2] and msg.reply_id then
get_message(msg.reply_id, get_msg_callback, {get_cmd=get_cmd, receiver=receiver})
end
if not matches[2] then
return
end
local user_id = matches[2]
local chat_id = msg.to.id
if string.match(matches[2], '^%d+$') then
local hash = 'banned:'..chat_id..':'..user_id
redis:del(hash)
return 'User '..user_id..' unbanned'
else
return 'Use user id only'
end
end
if matches[1] == 'sban' and is_admin(msg) then
if not matches[2] and msg.reply_id then
get_message(msg.reply_id, get_msg_callback, {get_cmd=get_cmd, receiver=receiver})
end
if not matches[2] then
return
end
local user_id = matches[2]
local chat_id = msg.to.id
if string.match(matches[2], '^%d+$') then
if matches[2] == our_id then
return
end
local data = load_data(_config.moderation.data) -- FLUX MOD
if data[tostring('admins')] then
if data[tostring('admins')][tostring(user_id)] then
return 'You can\'t ban admin!'
end
end
if is_spromoted(msg.to.id, matches[2]) and not is_admin(msg) then
return 'You can\'t ban leader'
end
ban_user(user_id, chat_id)
send_large_msg(receiver, 'User '..user_id..' globally banned!')
else
local member = string.gsub(matches[2], '@', '')
channel_get_users(receiver, chanel_username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=chat_id, member=member})
end
end
if matches[1] == 'unsban' then
local user_id = matches[2]
local chat_id = msg.to.id
local hash = 'superbanned:'..user_id
redis:del(hash)
return 'User '..user_id..' unbanned'
end
if matches[1] == 'kick' then
if not matches[2] and msg.reply_id then
get_message(msg.reply_id, get_msg_callback, {get_cmd=get_cmd, receiver=receiver})
return
end
if not matches[2] then
return
end
if string.match(matches[2], '^%d+$') then
if matches[2] == our_id and not is_admin(msg) then
return
end
local data = load_data(_config.moderation.data)
if data[tostring('admins')] then
if data[tostring('admins')][tostring(matches[2])] then
return 'You can\'t kick admin!'
end
end
if is_spromoted(msg.to.id, matches[2]) and not is_admin(msg) then
return 'You can\'t kick leader'
end
kick_user_chan(matches[2], msg.to.id)
else
local member = string.gsub(matches[2], '@', '')
channel_get_users(receiver, channel_username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member})
end
end
if matches[1] == 'silent' then
if not matches[2] and msg.reply_id then
get_message(msg.reply_id, get_msg_callback, {get_cmd=get_cmd, receiver=receiver})
return
end
if not matches[2] then
return
end
if string.match(matches[2], '^%d+$') then
if matches[2] == our_id then
return
end
local data = load_data(_config.moderation.data)
if data[tostring('admins')] then
if data[tostring('admins')][tostring(matches[2])] then
return 'You can\'t do this to admin!'
end
end
if is_spromoted(msg.to.id, matches[2]) and not is_admin(msg) then
return 'You can\'t do this to leader'
end
silent_user(matches[2], msg.to.id)
send_large_msg(receiver, 'User '..matches[2]..' not allowed to talk!')
else
local member = string.gsub(matches[2], '@', '')
channel_get_users(receiver, channel_username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member})
end
end
if matches[1] == 'unsilent' then
if not matches[2] and msg.reply_id then
get_message(msg.reply_id, get_msg_callback, {get_cmd=get_cmd, receiver=receiver})
return
end
if not matches[2] then
return
end
if string.match(matches[2], '^%d+$') then
if matches[2] == our_id then
return
end
local data = load_data(_config.moderation.data)
if data[tostring('admins')] then
if data[tostring('admins')][tostring(matches[2])] then
return 'Admin always allowed to talk!'
end
end
local hash = 'silent:'..msg.to.id..':'..matches[2]
redis:del(hash)
return 'User '..user_id..' allowed to talk'
else
local member = string.gsub(matches[2], '@', '')
channel_get_users(receiver, channel_username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member})
end
end
end
if is_chat_msg(msg) then -- CHAAAAAAAAATTTTTTTTTTTTTTTTTTTTTT
if matches[1] == 'ban' then
if not matches[2] and msg.reply_id then
get_message(msg.reply_id, get_msg_callback, {get_cmd=get_cmd, receiver=receiver})
end
if not matches[2] then
return
end
local user_id = matches[2]
local chat_id = msg.to.id
if string.match(matches[2], '^%d+$') then
if matches[2] == our_id then
return
end
local data = load_data(_config.moderation.data) -- FLUX MOD
if data[tostring('admins')] then
if data[tostring('admins')][tostring(user_id)] then
return 'You can\'t ban admin!'
end
end
if is_spromoted(msg.to.id, matches[2]) and not is_admin(msg) then
return 'You can\'t ban leader'
end
ban_user(user_id, chat_id)
send_large_msg(receiver, 'User '..user_id..' banned!')
else
local member = string.gsub(matches[2], '@', '')
chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'unban' then
local user_id = matches[2]
local chat_id = msg.to.id
if string.match(matches[2], '^%d+$') then
local hash = 'banned:'..chat_id..':'..user_id
redis:del(hash)
return 'User '..user_id..' unbanned'
else
return 'Use user id only'
end
end
if matches[1] == 'sban' and is_admin(msg) then
if not matches[2] and msg.reply_id then
get_message(msg.reply_id, get_msg_callback, {get_cmd=get_cmd, receiver=receiver})
end
if not matches[2] then
return
end
local user_id = matches[2]
local chat_id = msg.to.id
if string.match(matches[2], '^%d+$') then
if matches[2] == our_id then
return
end
local data = load_data(_config.moderation.data) -- FLUX MOD
if data[tostring('admins')] then
if data[tostring('admins')][tostring(user_id)] then
return 'You can\'t ban admin!'
end
end
if is_spromoted(msg.to.id, matches[2]) and not is_admin(msg) then
return 'You can\'t ban leader'
end
ban_user(user_id, chat_id)
send_large_msg(receiver, 'User '..user_id..' globally banned!')
else
local member = string.gsub(matches[2], '@', '')
chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'unsban' then
local hash = 'superbanned:'..user_id
redis:del(hash)
return 'User '..user_id..' unbanned'
end
if matches[1] == 'kick' then
if not matches[2] and msg.reply_id then
get_message(msg.reply_id, get_msg_callback, {get_cmd=get_cmd, receiver=receiver})
return
end
if not matches[2] then
return
end
if string.match(matches[2], '^%d+$') then
if matches[2] == our_id and not is_admin(msg) then
return
end
local data = load_data(_config.moderation.data)
if data[tostring('admins')] then
if data[tostring('admins')][tostring(matches[2])] then
return 'You can\'t kick admin!'
end
end
if is_spromoted(msg.to.id, matches[2]) then
if not is_admin(msg) then
return 'You can\'t kick leader'
end
end
kick_user(matches[2], msg.to.id)
else
local member = string.gsub(matches[2], '@', '')
chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=chat_id, member=member})
end
end
end
end
return {
description = "Plugin to manage bans, kicks and white/black lists.",
usage = {
user = "!kickme : Exit from group",
moderator = {
"!ban user <user_id> : Kick user from chat and kicks it if joins chat again",
"!ban user <username> : Kick user from chat and kicks it if joins chat again",
"!unban (on reply)",
"!kick (on reply) : Kick user from chat group by reply",
"!ban delete <user_id> : Unban user",
"!kick <user_id> : Kick user from chat group by id",
"!kick <username> : Kick user from chat group by username",
"!kick (on reply) : Kick user from chat group by reply",
"!silent (username|id|reply) : make a user silent",
},
admin = {
"!banallgp user <user_id> : Ban user from all chat by id",
"!banallgp user <username> : Ban user from all chat by username",
"!banallgp (on reply) : Ban user from all chat by reply",
"!banallgp delete <user_id> : Unban user",
},
},
patterns = {
"^(ban) (.*)$",
"^(unban) (.*)$",
"^(unban)$",
"^(ban)$",
"^(sban) (.*)$",
"^(unsban) (.*)$",
"^(sban)$",
"^(kick) (.*)$",
"^(kick)$",
"^(kickme)$",
"^(silent) (.*)$", --only for supergroup
"^(silent)$",
"^(unsilent) (.*)$",
"^(unsilent)$", --till here
"^!!tgservice (.+)$",
},
run = run,
pre_process = pre_process
}
| gpl-3.0 |
simoncozens/lunamark | lunamark/writer/man.lua | 4 | 3084 | -- (c) 2009-2011 John MacFarlane. Released under MIT license.
-- See the file LICENSE in the source for details.
--- Groff man writer for lunamark.
-- Extends [lunamark.writer.groff].
--
-- Note: continuation paragraphs in lists are not
-- handled properly.
local M = {}
local groff = require("lunamark.writer.groff")
local util = require("lunamark.util")
local format = string.format
--- Returns a new groff writer.
-- For a list of fields, see [lunamark.writer.generic].
function M.new(options)
options = options or {}
local Man = groff.new(options)
local endnotes = {}
function Man.link(lab,src,tit)
return {lab," (",src,")"}
end
function Man.image(lab,src,tit)
return {"[IMAGE (",lab,")]"}
end
-- TODO handle continuations properly.
-- pandoc does this:
-- .IP \[bu] 2
-- one
-- .RS 2
-- .PP
-- cont
-- .RE
function Man.paragraph(contents)
return {".PP\n",contents}
end
function Man.bulletlist(items,tight)
local buffer = {}
for _,item in ipairs(items) do
local revitem = item
-- we don't want to have .IP then .PP
if revitem[1][1] == ".PP\n" then revitem[1][1] = "" end
buffer[#buffer + 1] = {".IP \\[bu] 2\n",item}
end
return util.intersperse(buffer, Man.containersep)
end
function Man.orderedlist(items,tight,startnum)
local buffer = {}
local num = startnum or 1
for _,item in ipairs(items) do
local revitem = item
-- we don't want to have .IP then .PP
if revitem[1][1] == ".PP\n" then revitem[1][1] = "" end
buffer[#buffer + 1] = {format(".IP \"%d.\" 4\n",num),item}
num = num + 1
end
return util.intersperse(buffer, Man.containersep)
end
function Man.blockquote(s)
return {".RS\n",s,"\n.RE"}
end
function Man.verbatim(s)
return {".IP\n.nf\n\\f[C]\n",s,".fi"}
end
Man.fenced_code = Man.verbatim
function Man.header(s,level)
local hcode = ".SS"
if level == 1 then hcode = ".SH" end
return {hcode," ",s}
end
Man.hrule = ".PP\n * * * * *"
function Man.note(contents)
local num = #endnotes + 1
endnotes[num] = {format(".SS [%d]\n",num),contents}
return format('[%d]', num)
end
function Man.definitionlist(items,tight)
local buffer = {}
local ds
for _,item in ipairs(items) do
if tight then
ds = util.intersperse(item.definitions,"\n.RS\n.RE\n")
buffer[#buffer + 1] = {".TP\n.B ",item.term,"\n",ds,"\n.RS\n.RE"}
else
ds = util.intersperse(item.definitions,"\n.RS\n.RE\n")
buffer[#buffer + 1] = {".TP\n.B ",item.term,"\n.RS\n",ds,"\n.RE"}
end
end
local contents = util.intersperse(buffer,"\n")
return contents
end
function Man.start_document()
endnotes = {}
return ""
end
function Man.stop_document()
if #endnotes == 0 then
return ""
else
return {"\n.SH NOTES\n", util.intersperse(endnotes, "\n")}
end
end
Man.template = [===[
.TH "$title" "$section" "$date" "$left_footer" "$center_header"
$body
]===]
return Man
end
return M
| mit |
xnyhps/luasec | src/https.lua | 4 | 3983 | ----------------------------------------------------------------------------
-- LuaSec 0.6a
-- Copyright (C) 2009-2015 PUC-Rio
--
-- Author: Pablo Musa
-- Author: Tomas Guisasola
---------------------------------------------------------------------------
local socket = require("socket")
local ssl = require("ssl")
local ltn12 = require("ltn12")
local http = require("socket.http")
local url = require("socket.url")
local try = socket.try
--
-- Module
--
local _M = {
_VERSION = "0.6a",
_COPYRIGHT = "LuaSec 0.6a - Copyright (C) 2009-2015 PUC-Rio",
PORT = 443,
}
-- TLS configuration
local cfg = {
protocol = "tlsv1",
options = "all",
verify = "none",
}
--------------------------------------------------------------------
-- Auxiliar Functions
--------------------------------------------------------------------
-- Insert default HTTPS port.
local function default_https_port(u)
return url.build(url.parse(u, {port = _M.PORT}))
end
-- Convert an URL to a table according to Luasocket needs.
local function urlstring_totable(url, body, result_table)
url = {
url = default_https_port(url),
method = body and "POST" or "GET",
sink = ltn12.sink.table(result_table)
}
if body then
url.source = ltn12.source.string(body)
url.headers = {
["content-length"] = #body,
["content-type"] = "application/x-www-form-urlencoded",
}
end
return url
end
-- Forward calls to the real connection object.
local function reg(conn)
local mt = getmetatable(conn.sock).__index
for name, method in pairs(mt) do
if type(method) == "function" then
conn[name] = function (self, ...)
return method(self.sock, ...)
end
end
end
end
-- Return a function which performs the SSL/TLS connection.
local function tcp(params)
params = params or {}
-- Default settings
for k, v in pairs(cfg) do
params[k] = params[k] or v
end
-- Force client mode
params.mode = "client"
-- 'create' function for LuaSocket
return function ()
local conn = {}
conn.sock = try(socket.tcp())
local st = getmetatable(conn.sock).__index.settimeout
function conn:settimeout(...)
return st(self.sock, ...)
end
-- Replace TCP's connection function
function conn:connect(host, port)
try(self.sock:connect(host, port))
self.sock = try(ssl.wrap(self.sock, params))
try(self.sock:dohandshake())
reg(self, getmetatable(self.sock))
return 1
end
return conn
end
end
--------------------------------------------------------------------
-- Main Function
--------------------------------------------------------------------
-- Make a HTTP request over secure connection. This function receives
-- the same parameters of LuaSocket's HTTP module (except 'proxy' and
-- 'redirect') plus LuaSec parameters.
--
-- @param url mandatory (string or table)
-- @param body optional (string)
-- @return (string if url == string or 1), code, headers, status
--
local function request(url, body)
local result_table = {}
local stringrequest = type(url) == "string"
if stringrequest then
url = urlstring_totable(url, body, result_table)
else
url.url = default_https_port(url.url)
end
if http.PROXY or url.proxy then
return nil, "proxy not supported"
elseif url.redirect then
return nil, "redirect not supported"
elseif url.create then
return nil, "create function not permitted"
end
-- New 'create' function to establish a secure connection
url.create = tcp(url)
local res, code, headers, status = http.request(url)
if res and stringrequest then
return table.concat(result_table), code, headers, status
end
return res, code, headers, status
end
--------------------------------------------------------------------------------
-- Export module
--
_M.request = request
return _M
| mit |
fgielow/devenserver | data/npc/scripts/soft.lua | 2 | 1514 | local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'reparar') or msgcontains(msg, 'soft boots')) then
selfSay('You want to repair your soft boots worn by 10000 gold coins?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(getPlayerItemCount(cid, 10021) >= 1) then
if(doPlayerRemoveMoney(cid, 10000) == TRUE) then
doPlayerRemoveItem(cid, 10021, 1)
doPlayerAddItem(cid, 2640)
selfSay('Here you are.', cid)
else
selfSay('Sorry, come back when you have money.', cid)
end
else
selfSay('Sorry, you do not have this item.', cid)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
| gpl-2.0 |
22333322/i4bot | plugins/isup.lua | 741 | 3095 | do
local socket = require("socket")
local cronned = load_from_file('data/isup.lua')
local function save_cron(msg, url, delete)
local origin = get_receiver(msg)
if not cronned[origin] then
cronned[origin] = {}
end
if not delete then
table.insert(cronned[origin], url)
else
for k,v in pairs(cronned[origin]) do
if v == url then
table.remove(cronned[origin], k)
end
end
end
serialize_to_file(cronned, 'data/isup.lua')
return 'Saved!'
end
local function is_up_socket(ip, port)
print('Connect to', ip, port)
local c = socket.try(socket.tcp())
c:settimeout(3)
local conn = c:connect(ip, port)
if not conn then
return false
else
c:close()
return true
end
end
local function is_up_http(url)
-- Parse URL from input, default to http
local parsed_url = URL.parse(url, { scheme = 'http', authority = '' })
-- Fix URLs without subdomain not parsed properly
if not parsed_url.host and parsed_url.path then
parsed_url.host = parsed_url.path
parsed_url.path = ""
end
-- Re-build URL
local url = URL.build(parsed_url)
local protocols = {
["https"] = https,
["http"] = http
}
local options = {
url = url,
redirect = false,
method = "GET"
}
local response = { protocols[parsed_url.scheme].request(options) }
local code = tonumber(response[2])
if code == nil or code >= 400 then
return false
end
return true
end
local function isup(url)
local pattern = '^(%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?):?(%d?%d?%d?%d?%d?)$'
local ip,port = string.match(url, pattern)
local result = nil
-- !isup 8.8.8.8:53
if ip then
port = port or '80'
result = is_up_socket(ip, port)
else
result = is_up_http(url)
end
return result
end
local function cron()
for chan, urls in pairs(cronned) do
for k,url in pairs(urls) do
print('Checking', url)
if not isup(url) then
local text = url..' looks DOWN from here. 😱'
send_msg(chan, text, ok_cb, false)
end
end
end
end
local function run(msg, matches)
if matches[1] == 'cron delete' then
if not is_sudo(msg) then
return 'This command requires privileged user'
end
return save_cron(msg, matches[2], true)
elseif matches[1] == 'cron' then
if not is_sudo(msg) then
return 'This command requires privileged user'
end
return save_cron(msg, matches[2])
elseif isup(matches[1]) then
return matches[1]..' looks UP from here. 😃'
else
return matches[1]..' looks DOWN from here. 😱'
end
end
return {
description = "Check if a website or server is up.",
usage = {
"!isup [host]: Performs a HTTP request or Socket (ip:port) connection",
"!isup cron [host]: Every 5mins check if host is up. (Requires privileged user)",
"!isup cron delete [host]: Disable checking that host."
},
patterns = {
"^!isup (cron delete) (.*)$",
"^!isup (cron) (.*)$",
"^!isup (.*)$",
"^!ping (.*)$",
"^!ping (cron delete) (.*)$",
"^!ping (cron) (.*)$"
},
run = run,
cron = cron
}
end
| gpl-2.0 |
dacrybabysuck/darkstar | scripts/commands/setmobflags.lua | 22 | 1334 | ---------------------------------------------------------------------------------------------------
-- func: setmobflags <flags> <optional MobID>
-- desc: Used to manipulate a mob's nameflags for testing.
-- MUST either target a mob first or else specify a Mob ID.
---------------------------------------------------------------------------------------------------
cmdprops =
{
permission = 1,
parameters = "si"
};
function error(player, msg)
player:PrintToPlayer(msg);
player:PrintToPlayer("!setmobflags <flags> {mob ID}");
end;
function onTrigger(player, flags, target)
-- validate flags
if (flags == nil) then
error(player, "You must supply a flags value.");
return;
end
-- validate target
local targ;
if (target == nil) then
targ = player:getCursorTarget();
if (targ == nil or not targ:isMob()) then
error(player, "You must either supply a mob ID or target a mob.");
return;
end
else
targ = GetMobByID(target);
if (targ == nil) then
error(player, "Invalid mob ID.");
return;
end
end
-- set flags
player:setMobFlags(flags, targ:getID());
player:PrintToPlayer( string.format("Set %s %i flags to %i.", targ:getName(), targ:getID(), flags) );
end; | gpl-3.0 |
fakechris/Atlas | tests/suite/base/t/bug_46141-test.lua | 4 | 1799 | --[[ $%BEGINLICENSE%$
Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; version 2 of the
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
$%ENDLICENSE%$ --]]
local proto = require("mysql.proto")
---
-- Bug #46141
--
-- .prepend() does handle the 3rd optional parameter
--
-- which leads to a not-working read_query_result() for queries that
-- got prepended to the query-queue
--
function read_query(packet)
-- pass on everything that is not on the initial connection
if packet:byte() ~= proxy.COM_QUERY then
proxy.response = {
type = proxy.MYSQLD_PACKET_OK
}
return proxy.PROXY_SEND_RESULT
end
if packet:sub(2) == "SELECT 1" then
proxy.queries:prepend(1, packet, { resultset_is_needed = true })
return proxy.PROXY_SEND_QUERY
else
proxy.response = {
type = proxy.MYSQLD_PACKET_ERR,
errmsg = "(bug_41991-test) >" .. packet:sub(2) .. "<"
}
return proxy.PROXY_SEND_RESULT
end
end
function read_query_result(inj)
if inj.id == 1 then
proxy.response = {
type = proxy.MYSQLD_PACKET_OK,
resultset = {
fields = {
{ name = "1", type = proxy.MYSQL_TYPE_STRING },
},
rows = {
{ "2" }
}
}
}
return proxy.PROXY_SEND_RESULT
end
end
| gpl-2.0 |
fetchbot/nodemcu-firmware | lua_modules/email/imap.lua | 81 | 6275 | ---
-- Working Example: https://www.youtube.com/watch?v=PDxTR_KJLhc
-- IMPORTANT: run node.compile("imap.lua") after uploading this script
-- to create a compiled module. Then run file.remove("imap.lua")
-- @name imap
-- @description An IMAP 4rev1 module that can be used to read email.
-- Tested on NodeMCU 0.9.5 build 20150213.
-- @date March 12, 2015
-- @author Miguel
-- GitHub: https://github.com/AllAboutEE
-- YouTube: https://www.youtube.com/user/AllAboutEE
-- Website: http://AllAboutEE.com
--
-- Visit the following URLs to learn more about IMAP:
-- "How to test an IMAP server by using telnet" http://www.anta.net/misc/telnet-troubleshooting/imap.shtml
-- "RFC 2060 - Internet Message Access Protocol - Version 4rev1" http://www.faqs.org/rfcs/rfc2060.html
-------------------------------------------------------------------------------------------------------------
local moduleName = ...
local M = {}
_G[moduleName] = M
local USERNAME = ""
local PASSWORD = ""
local SERVER = ""
local PORT = ""
local TAG = ""
local DEBUG = false
local body = "" -- used to store an email's body / main text
local header = "" -- used to store an email's last requested header field e.g. SUBJECT, FROM, DATA etc.
local most_recent_num = 1 -- used to store the latest/newest email number/id
local response_processed = false -- used to know if the last IMAP response has been processed
---
-- @name response_processed
-- @returns The response process status of the last IMAP command sent
function M.response_processed()
return response_processed
end
---
-- @name display
-- @description A generic IMAP response processing function.
-- Can disply the IMAP response if DEBUG is set to true.
-- Sets the reponse processed variable to true when the string "complete"
-- is found in the IMAP reply/response
local function display(socket, response)
-- If debuggins is enabled print the IMAP response
if(DEBUG) then
print(response)
end
-- Some IMAP responses are long enough that they will cause the display
-- function to be called several times. One thing is certain, IMAP will replay with
-- "<tag> OK <command> complete" when it's done sending data back.
if(string.match(response,'complete') ~= nil) then
response_processed = true
end
end
---
-- @name config
-- @description Initiates the IMAP settings
function M.config(username,password,tag,debug)
USERNAME = username
PASSWORD = password
TAG = tag
DEBUG = debug
end
---
-- @name login
-- @descrpiton Logs into a new email session
function M.login(socket)
response_processed = false -- we are sending a new command
-- which means that the response for it has not been processed
socket:send(TAG .. " LOGIN " .. USERNAME .. " " .. PASSWORD .. "\r\n")
socket:on("receive",display)
end
---
-- @name get_most_recent_num
-- @returns The most recent email number. Should only be called after examine()
function M.get_most_recent_num()
return most_recent_num
end
---
-- @name set_most_recent_num
-- @description Gets the most recent email number from the EXAMINE command.
-- i.e. if EXAMINE returns "* 4 EXISTS" this means that there are 4 emails,
-- so the latest/newest will be identified by the number 4
local function set_most_recent_num(socket,response)
if(DEBUG) then
print(response)
end
local _, _, num = string.find(response,"([0-9]+) EXISTS(\.)") -- the _ and _ keep the index of the string found
-- but we don't care about that.
if(num~=nil) then
most_recent_num = num
end
if(string.match(response,'complete') ~= nil) then
response_processed = true
end
end
---
-- @name examine
-- @description IMAP examines the given mailbox/folder. Sends the IMAP EXAMINE command
function M.examine(socket,mailbox)
response_processed = false
socket:send(TAG .. " EXAMINE " .. mailbox .. "\r\n")
socket:on("receive",set_most_recent_num)
end
---
-- @name get_header
-- @returns The last fetched header field
function M.get_header()
return header
end
---
-- @name set_header
-- @description Records the IMAP header field response in a variable
-- so that it may be read later
local function set_header(socket,response)
if(DEBUG) then
print(response)
end
header = header .. response
if(string.match(response,'complete') ~= nil) then
response_processed = true
end
end
---
-- @name fetch_header
-- @description Fetches an emails header field e.g. SUBJECT, FROM, DATE
-- @param socket The IMAP socket to use
-- @param msg_number The email number to read e.g. 1 will read fetch the latest/newest email
-- @param field A header field such as SUBJECT, FROM, or DATE
function M.fetch_header(socket,msg_number,field)
header = "" -- we are getting a new header so clear this variable
response_processed = false
socket:send(TAG .. " FETCH " .. msg_number .. " BODY[HEADER.FIELDS (" .. field .. ")]\r\n")
socket:on("receive",set_header)
end
---
-- @name get_body
-- @return The last email read's body
function M.get_body()
return body
end
---
-- @name set_body
-- @description Records the IMAP body response in a variable
-- so that it may be read later
local function set_body(socket,response)
if(DEBUG) then
print(response)
end
body = body .. response
if(string.match(response,'complete') ~= nil) then
response_processed = true
end
end
---
-- @name fetch_body_plain_text
-- @description Sends the IMAP command to fetch a plain text version of the email's body
-- @param socket The IMAP socket to use
-- @param msg_number The email number to obtain e.g. 1 will obtain the latest email
function M.fetch_body_plain_text(socket,msg_number)
response_processed = false
body = "" -- clear the body variable since we'll be fetching a new email
socket:send(TAG .. " FETCH " .. msg_number .. " BODY[1]\r\n")
socket:on("receive",set_body)
end
---
-- @name logout
-- @description Sends the IMAP command to logout of the email session
function M.logout(socket)
response_processed = false
socket:send(TAG .. " LOGOUT\r\n")
socket:on("receive",display)
end
| mit |
dacrybabysuck/darkstar | scripts/globals/spells/bluemagic/zephyr_mantle.lua | 12 | 1175 | -----------------------------------------
-- Spell: Zephyr Mantle
-- Creates shadow images that each absorb a single attack directed at you
-- Spell cost: 31 MP
-- Monster Type: Dragons
-- Spell Type: Magical (Wind)
-- Blue Magic Points: 2
-- Stat Bonus: AGI+2
-- Level: 65
-- Casting Time: 7 seconds
-- Recast Time: 60 seconds
-- Duration: 5 minutes
--
-- Combos: Conserve MP
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0
end
function onSpellCast(caster,target,spell)
local typeEffect = dsp.effect.BLINK
local power = 4
local duration = 300
if (caster:hasStatusEffect(dsp.effect.DIFFUSION)) then
local diffMerit = caster:getMerit(dsp.merit.DIFFUSION)
if (diffMerit > 0) then
duration = duration + (duration/100)* diffMerit
end
caster:delStatusEffect(dsp.effect.DIFFUSION)
end
if (target:addStatusEffect(typeEffect,power,0,duration) == false) then
spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT)
end
return typeEffect
end
| gpl-3.0 |
cmingjian/skynet | service/service_mgr.lua | 8 | 3860 | local skynet = require "skynet"
require "skynet.manager" -- import skynet.register
local snax = require "skynet.snax"
local cmd = {}
local service = {}
local function request(name, func, ...)
local ok, handle = pcall(func, ...)
local s = service[name]
assert(type(s) == "table")
if ok then
service[name] = handle
else
service[name] = tostring(handle)
end
for _,v in ipairs(s) do
skynet.wakeup(v)
end
if ok then
return handle
else
error(tostring(handle))
end
end
local function waitfor(name , func, ...)
local s = service[name]
if type(s) == "number" then
return s
end
local co = coroutine.running()
if s == nil then
s = {}
service[name] = s
elseif type(s) == "string" then
error(s)
end
assert(type(s) == "table")
if not s.launch and func then
s.launch = true
return request(name, func, ...)
end
table.insert(s, co)
skynet.wait()
s = service[name]
if type(s) == "string" then
error(s)
end
assert(type(s) == "number")
return s
end
local function read_name(service_name)
if string.byte(service_name) == 64 then -- '@'
return string.sub(service_name , 2)
else
return service_name
end
end
function cmd.LAUNCH(service_name, subname, ...)
local realname = read_name(service_name)
if realname == "snaxd" then
return waitfor(service_name.."."..subname, snax.rawnewservice, subname, ...)
else
return waitfor(service_name, skynet.newservice, realname, subname, ...)
end
end
function cmd.QUERY(service_name, subname)
local realname = read_name(service_name)
if realname == "snaxd" then
return waitfor(service_name.."."..subname)
else
return waitfor(service_name)
end
end
local function list_service()
local result = {}
for k,v in pairs(service) do
if type(v) == "string" then
v = "Error: " .. v
elseif type(v) == "table" then
v = "Querying"
else
v = skynet.address(v)
end
result[k] = v
end
return result
end
local function register_global()
function cmd.GLAUNCH(name, ...)
local global_name = "@" .. name
return cmd.LAUNCH(global_name, ...)
end
function cmd.GQUERY(name, ...)
local global_name = "@" .. name
return cmd.QUERY(global_name, ...)
end
local mgr = {}
function cmd.REPORT(m)
mgr[m] = true
end
local function add_list(all, m)
local harbor = "@" .. skynet.harbor(m)
local result = skynet.call(m, "lua", "LIST")
for k,v in pairs(result) do
all[k .. harbor] = v
end
end
function cmd.LIST()
local result = {}
for k in pairs(mgr) do
pcall(add_list, result, k)
end
local l = list_service()
for k, v in pairs(l) do
result[k] = v
end
return result
end
end
local function register_local()
local function waitfor_remote(cmd, name, ...)
local global_name = "@" .. name
local local_name
if name == "snaxd" then
local_name = global_name .. "." .. (...)
else
local_name = global_name
end
return waitfor(local_name, skynet.call, "SERVICE", "lua", cmd, global_name, ...)
end
function cmd.GLAUNCH(...)
return waitfor_remote("LAUNCH", ...)
end
function cmd.GQUERY(...)
return waitfor_remote("QUERY", ...)
end
function cmd.LIST()
return list_service()
end
skynet.call("SERVICE", "lua", "REPORT", skynet.self())
end
skynet.start(function()
skynet.dispatch("lua", function(session, address, command, ...)
local f = cmd[command]
if f == nil then
skynet.ret(skynet.pack(nil, "Invalid command " .. command))
return
end
local ok, r = pcall(f, ...)
if ok then
skynet.ret(skynet.pack(r))
else
skynet.ret(skynet.pack(nil, r))
end
end)
local handle = skynet.localname ".service"
if handle then
skynet.error(".service is already register by ", skynet.address(handle))
skynet.exit()
else
skynet.register(".service")
end
if skynet.getenv "standalone" then
skynet.register("SERVICE")
register_global()
else
register_local()
end
end)
| mit |
disslove2-bot/MAX-BOT | plugins/groupmanager.lua | 5 | 15183 | -- data saved to data/moderation.json
do
local function gpadd(msg)
-- because sudo are always has privilege
if not is_sudo(msg) then
return nil
end
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
return 'Group is already added.'
end
-- create data array in moderation.json
data[tostring(msg.to.id)] = {
moderators ={},
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_bots = 'no',
lock_name = 'no',
lock_photo = 'no',
lock_member = 'no',
anti_flood = 'no',
welcome = 'no'
}
}
save_data(_config.moderation.data, data)
return 'Group has been added.'
end
local function gprem(msg)
-- because sudo are always has privilege
if not is_sudo(msg) then
return nil
end
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if not data[tostring(msg.to.id)] then
return 'Group is not added.'
end
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
return 'Group has been removed'
end
local function export_chat_link_callback(extra, success, result)
local receiver = extra.receiver
local data = extra.data
local chat_id = extra.chat_id
local group_name = extra.group_name
if success == 0 then
return send_large_msg(receiver, "Can't generate invite link for this group.\nMake sure you're the admin or sudoer.")
end
data[tostring(chat_id)]['link'] = result
save_data(_config.moderation.data, data)
return send_large_msg(receiver,'Newest generated invite link for '..group_name..' is:\n'..result)
end
local function set_description(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local data_cat = 'description'
data[tostring(msg.to.id)][data_cat] = deskripsi
save_data(_config.moderation.data, data)
return 'Set group description to:\n'..deskripsi
end
local function get_description(msg, data)
local data_cat = 'description'
if not data[tostring(msg.to.id)][data_cat] then
return 'No description available.'
end
local about = data[tostring(msg.to.id)][data_cat]
return string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about
end
local function set_rules(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local data_cat = 'rules'
data[tostring(msg.to.id)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..rules
end
local function get_rules(msg, data)
local data_cat = 'rules'
if not data[tostring(msg.to.id)][data_cat] then
return 'No rules available.'
end
local rules = data[tostring(msg.to.id)][data_cat]
local rules = string.gsub(msg.to.print_name, '_', ' ')..' rules:\n\n'..rules
return rules
end
-- dis/allow APIs bots to enter group. Spam prevention.
local function allow_api_bots(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_bot_lock = data[tostring(msg.to.id)]['settings']['lock_bots']
if group_bot_lock == 'no' then
return 'Bots allowed to enter group.'
else
data[tostring(msg.to.id)]['settings']['lock_bots'] = 'no'
save_data(_config.moderation.data, data)
return 'Group is open for bots.'
end
end
local function disallow_api_bots(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_bot_lock = data[tostring(msg.to.id)]['settings']['lock_bots']
if group_bot_lock == 'yes' then
return 'Group already locked from bots.'
else
data[tostring(msg.to.id)]['settings']['lock_bots'] = 'yes'
save_data(_config.moderation.data, data)
return 'Group is locked from bots.'
end
end
-- lock/unlock group name. bot automatically change group name when locked
local function lock_group_name(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(msg.to.id)]['settings']['set_name']
local group_name_lock = data[tostring(msg.to.id)]['settings']['lock_name']
if group_name_lock == 'yes' then
return 'Group name is already locked'
else
data[tostring(msg.to.id)]['settings']['lock_name'] = 'yes'
save_data(_config.moderation.data, data)
data[tostring(msg.to.id)]['settings']['set_name'] = string.gsub(msg.to.print_name, '_', ' ')
save_data(_config.moderation.data, data)
return 'Group name has been locked'
end
end
local function unlock_group_name(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(msg.to.id)]['settings']['set_name']
local group_name_lock = data[tostring(msg.to.id)]['settings']['lock_name']
if group_name_lock == 'no' then
return 'Group name is already unlocked'
else
data[tostring(msg.to.id)]['settings']['lock_name'] = 'no'
save_data(_config.moderation.data, data)
return 'Group name has been unlocked'
end
end
--lock/unlock group member. bot automatically kick new added user when locked
local function lock_group_member(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(msg.to.id)]['settings']['lock_member']
if group_member_lock == 'yes' then
return 'Group members are already locked'
else
data[tostring(msg.to.id)]['settings']['lock_member'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group members has been locked'
end
local function unlock_group_member(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(msg.to.id)]['settings']['lock_member']
if group_member_lock == 'no' then
return 'Group members are not locked'
else
data[tostring(msg.to.id)]['settings']['lock_member'] = 'no'
save_data(_config.moderation.data, data)
return 'Group members has been unlocked'
end
end
--lock/unlock group photo. bot automatically keep group photo when locked
local function lock_group_photo(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_photo_lock = data[tostring(msg.to.id)]['settings']['lock_photo']
if group_photo_lock == 'yes' then
return 'Group photo is already locked'
else
data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
end
return 'Please send me the group photo now'
end
local function unlock_group_photo(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_photo_lock = data[tostring(msg.to.id)]['settings']['lock_photo']
if group_photo_lock == 'no' then
return 'Group photo is not locked'
else
data[tostring(msg.to.id)]['settings']['lock_photo'] = 'no'
save_data(_config.moderation.data, data)
return 'Group photo has been unlocked'
end
end
local function set_group_photo(msg, success, result)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if success then
local file = 'data/photos/chat_photo_'..msg.to.id..'.jpg'
print('File downloaded to:', result)
os.rename(result, file)
print('File moved to:', file)
chat_set_photo (receiver, file, ok_cb, false)
data[tostring(msg.to.id)]['settings']['set_photo'] = file
save_data(_config.moderation.data, data)
data[tostring(msg.to.id)]['settings']['lock_photo'] = 'yes'
save_data(_config.moderation.data, data)
send_large_msg(receiver, 'Photo saved!', ok_cb, false)
else
print('Error downloading: '..msg.id)
send_large_msg(receiver, 'Failed, please try again!', ok_cb, false)
end
end
-- show group settings
local function show_group_settings(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local settings = data[tostring(msg.to.id)]['settings']
local text = "Group settings:\n\nLock group from bot : "..settings.lock_bots
.."\nLock group name : "..settings.lock_name
.."\nLock group photo : "..settings.lock_photo
.."\nLock group member : "..settings.lock_member
.."\nFlood protection : "..settings.anti_flood
.."\nWelcome service : "..settings.welcome
return text
end
-- media handler. needed by group_photo_lock
local function pre_process(msg)
if not msg.text and msg.media then
msg.text = '['..msg.media.type..']'
end
return msg
end
function run(msg, matches)
--vardump(msg)
if not is_chat_msg(msg) then
return "This is not a group chat."
end
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
-- add a group to be moderated
if matches[1] == 'gpadd' then
return gpadd(msg)
end
-- remove group from moderation
if matches[1] == 'gprem' then
return gprem(msg)
end
if msg.media and is_chat_msg(msg) and is_sudo(msg) then
if msg.media.type == 'photo' and data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' then
load_photo(msg.id, set_group_photo, msg)
end
end
end
if data[tostring(msg.to.id)] then
local settings = data[tostring(msg.to.id)]['settings']
if matches[1] == 'setabout' and matches[2] then
deskripsi = matches[2]
return set_description(msg, data)
end
if matches[1] == 'about' then
return get_description(msg, data)
end
if matches[1] == 'setrules' then
rules = matches[2]
return set_rules(msg, data)
end
if matches[1] == 'rules' then
return get_rules(msg, data)
end
-- group link {get|set}
if matches[1] == 'link' then
local chat = 'chat#id'..msg.to.id
if matches[2] == 'get' then
if data[tostring(msg.to.id)]['link'] then
local about = get_description(msg, data)
local link = data[tostring(msg.to.id)]['link']
return about.."\n\n"..link
else
return "Invite link is not exist.\nTry !link set to generate it."
end
end
if matches[2] == 'set' and is_sudo(msg) then
msgr = export_chat_link('chat#id'..msg.to.id, export_chat_link_callback, {receiver=receiver, data=data, chat_id=msg.to.id, group_name=msg.to.print_name})
end
end
-- lock {bot|name|member|photo}
if matches[1] == 'group' and matches[2] == 'lock' then
if matches[3] == 'bot' then
return disallow_api_bots(msg, data)
end
if matches[3] == 'name' then
return lock_group_name(msg, data)
end
if matches[3] == 'member' then
return lock_group_member(msg, data)
end
if matches[3] == 'photo' then
return lock_group_photo(msg, data)
end
end
-- unlock {bot|name|member|photo}
if matches[1] == 'group' and matches[2] == 'unlock' then
if matches[3] == 'bot' then
return allow_api_bots(msg, data)
end
if matches[3] == 'name' then
return unlock_group_name(msg, data)
end
if matches[3] == 'member' then
return unlock_group_member(msg, data)
end
if matches[3] == 'photo' then
return unlock_group_photo(msg, data)
end
end
-- view group settings
if matches[1] == 'group' and matches[2] == 'settings' then
return show_group_settings(msg, data)
end
-- if group name is renamed
if matches[1] == 'chat_rename' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_name_set = settings.set_name
local group_name_lock = settings.lock_name
local to_rename = 'chat#id'..msg.to.id
if group_name_lock == 'yes' then
if group_name_set ~= tostring(msg.to.print_name) then
rename_chat(to_rename, group_name_set, ok_cb, false)
end
elseif group_name_lock == 'no' then
return nil
end
end
-- set group name
if matches[1] == 'setname' and is_sudo(msg) then
local new_name = string.gsub(matches[2], '_', ' ')
data[tostring(msg.to.id)]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(msg.to.id)]['settings']['set_name']
local to_rename = 'chat#id'..msg.to.id
rename_chat(to_rename, group_name_set, ok_cb, false)
end
-- set group photo
if matches[1] == 'setphoto' and is_sudo(msg) then
data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
return 'Please send me new group photo now'
end
-- if a user is added to group
if matches[1] == 'chat_add_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_member_lock = settings.lock_member
local group_bot_lock = settings.lock_bots
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if group_member_lock == 'yes' then
chat_del_user(chat, user, ok_cb, true)
-- no APIs bot are allowed to enter chat group.
elseif group_bot_lock == 'yes' and msg.action.user.flags == 4352 then
chat_del_user(chat, user, ok_cb, true)
elseif group_bot_lock == 'no' or group_member_lock == 'no' then
return nil
end
end
-- if group photo is deleted
if matches[1] == 'chat_delete_photo' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_photo_lock = settings.lock_photo
if group_photo_lock == 'yes' then
chat_set_photo (receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
-- if group photo is changed
if matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then
if not msg.service then
return "Are you trying to troll me?"
end
local group_photo_lock = settings.lock_photo
if group_photo_lock == 'yes' then
chat_set_photo (receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
end
end
return {
description = "Plugin to manage group chat.",
usage = {
"!about : Read group description",
"!group <lock|unlock> bot : {Dis}allow APIs bots",
"!group <lock|unlock> member : Lock/unlock group member",
"!group <lock|unlock> name : Lock/unlock group name",
"!group <lock|unlock> photo : Lock/unlock group photo",
"!group settings : Show group settings",
"!link <get|set> : Get or revoke invite link",
"!rules : Read group rules",
"!setabout <description> : Set group description",
"!setname <new_name> : Set group name",
"!setphoto : Set group photo",
"!setrules <rules> : Set group rules"
},
patterns = {
"^!(about)$",
"%[(audio)%]",
"%[(document)%]",
"^!(gpadd)$",
"^!(gprem)$",
"^!(group) (lock) (.*)$",
"^!(group) (settings)$",
"^!(group) (unlock) (.*)$",
"^!(link) (.*)$",
"%[(photo)%]",
"%[(photo)%]",
"^!(rules)$",
"^!(setabout) (.*)$",
"^!(setname) (.*)$",
"^!(setphoto)$",
"^!(setrules) (.*)$",
"^!!tgservice (.+)$",
"%[(video)%]"
},
run = run,
privileged = true,
hide = true,
pre_process = pre_process
}
end
| gpl-2.0 |
dacrybabysuck/darkstar | scripts/zones/Bastok_Mines/npcs/Virnage.lua | 11 | 1920 | -----------------------------------
-- Area: Bastok Mines
-- NPC: Virnage
-- Starts Quest: Altana's Sorrow
-- !pos 0 0 51 234
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/shop");
require("scripts/globals/quests");
local ID = require("scripts/zones/Bastok_Mines/IDs");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
AltanaSorrow = player:getQuestStatus(BASTOK,dsp.quest.id.bastok.ALTANA_S_SORROW);
if (AltanaSorrow == QUEST_AVAILABLE and player:getFameLevel(BASTOK) >= 4 and player:getMainLvl() >= 10) then
player:startEvent(141); -- Start quest "Altana's Sorrow"
elseif (AltanaSorrow == QUEST_ACCEPTED) then
if (player:hasKeyItem(dsp.ki.BUCKET_OF_DIVINE_PAINT) == true) then
player:startEvent(143); -- CS with Bucket of Divine Paint KI
elseif (player:hasKeyItem(dsp.ki.LETTER_FROM_VIRNAGE) == true) then
--player:showText(npc,ID.text.VIRNAGE_DIALOG_2);
player:startEvent(144); -- During quest (after KI)
else
-- player:showText(npc,ID.text.VIRNAGE_DIALOG_1);
player:startEvent(142); -- During quest "Altana's Sorrow" (before KI)
end
elseif (AltanaSorrow == QUEST_COMPLETED) then
player:startEvent(145); -- New standard dialog
else
player:startEvent(140); -- Standard dialog
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 141 and option == 0) then
player:addQuest(BASTOK,dsp.quest.id.bastok.ALTANA_S_SORROW);
elseif (csid == 143) then
player:delKeyItem(dsp.ki.BUCKET_OF_DIVINE_PAINT);
player:addKeyItem(dsp.ki.LETTER_FROM_VIRNAGE);
player:messageSpecial(ID.text.KEYITEM_OBTAINED,dsp.ki.LETTER_FROM_VIRNAGE);
end
end; | gpl-3.0 |
dacrybabysuck/darkstar | scripts/zones/Southern_San_dOria/npcs/Miogique.lua | 11 | 1523 | -----------------------------------
-- Area: Southern San d'Oria
-- NPC: Miogique
-- Standard Merchant NPC
-----------------------------------
local ID = require("scripts/zones/Southern_San_dOria/IDs")
require("scripts/globals/npc_util")
require("scripts/globals/quests")
require("scripts/globals/shop")
function onTrade(player,npc,trade)
if player:getQuestStatus(SANDORIA, dsp.quest.id.sandoria.FLYERS_FOR_REGINE) == QUEST_ACCEPTED and npcUtil.tradeHas(trade, 532) then
player:messageSpecial(ID.text.FLYER_REFUSED)
end
end
function onTrigger(player,npc)
local stock =
{
12552, 14256, 1, -- Chainmail
12680, 7783, 1, -- Chain Mittens
12672, 23846, 1, -- Gauntlets
12424, 9439, 1, -- Iron Mask
12442, 13179, 2, -- Studded Bandana
12698, 11012, 2, -- Studded Gloves
12570, 20976, 2, -- Studded Vest
12449, 1504, 3, -- Brass Cap
12577, 2286, 3, -- Brass Harness
12705, 1255, 3, -- Brass Mittens
12448, 154, 3, -- Bronze Cap
12576, 576, 3, -- Bronze Harness
12704, 128, 3, -- Bronze Mittens
12440, 396, 3, -- Leather Bandana
12696, 331, 3, -- Leather Gloves
12568, 618, 3, -- Leather Vest
}
player:showText(npc, ID.text.MIOGIQUE_SHOP_DIALOG)
dsp.shop.nation(player, stock, dsp.nation.SANDORIA)
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
end
| gpl-3.0 |
Flatlander57/TheImaginedOTClient | modules/game_spelllist/spelllist.lua | 1 | 13272 | local SpelllistProfile = 'Default'
spelllistWindow = nil
spelllistButton = nil
spellList = nil
nameValueLabel = nil
formulaValueLabel = nil
vocationValueLabel = nil
groupValueLabel = nil
typeValueLabel = nil
cooldownValueLabel = nil
levelValueLabel = nil
manaValueLabel = nil
premiumValueLabel = nil
descriptionValueLabel = nil
vocationBoxAny = nil
vocationBoxSorcerer = nil
vocationBoxDruid = nil
vocationBoxPaladin = nil
vocationBoxKnight = nil
groupBoxAny = nil
groupBoxAttack = nil
groupBoxHealing = nil
groupBoxSupport = nil
premiumBoxAny = nil
premiumBoxNo = nil
premiumBoxYes = nil
vocationRadioGroup = nil
groupRadioGroup = nil
premiumRadioGroup = nil
-- consts
FILTER_PREMIUM_ANY = 0
FILTER_PREMIUM_NO = 1
FILTER_PREMIUM_YES = 2
FILTER_VOCATION_ANY = 0
FILTER_VOCATION_SORCERER = 1
FILTER_VOCATION_DRUID = 2
FILTER_VOCATION_PALADIN = 3
FILTER_VOCATION_KNIGHT = 4
FILTER_GROUP_ANY = 0
FILTER_GROUP_ATTACK = 1
FILTER_GROUP_HEALING = 2
FILTER_GROUP_SUPPORT = 3
-- Filter Settings
local filters = {
level = false,
vocation = false,
vocationId = FILTER_VOCATION_ANY,
premium = FILTER_PREMIUM_ANY,
groupId = FILTER_GROUP_ANY
}
function getSpelllistProfile()
return SpelllistProfile
end
function setSpelllistProfile(name)
if SpelllistProfile == name then return end
if SpelllistSettings[name] and SpellInfo[name] then
local oldProfile = SpelllistProfile
SpelllistProfile = name
changeSpelllistProfile(oldProfile)
else
perror('Spelllist profile \'' .. name .. '\' could not be set.')
end
end
function online()
if g_game.getFeature(GameSpellList) then
spelllistButton:show()
else
spelllistButton:hide()
end
if g_game.getProtocolVersion() >= 950 then -- Vocation is only send in newer clients
spelllistWindow:getChildById('buttonFilterVocation'):setVisible(true)
else
spelllistWindow:getChildById('buttonFilterVocation'):setVisible(false)
end
end
function offline()
resetWindow()
end
function init()
connect(g_game, { onGameStart = online,
onGameEnd = offline })
spelllistWindow = g_ui.displayUI('spelllist', modules.game_interface.getRightPanel())
spelllistWindow:hide()
spelllistButton = modules.client_topmenu.addRightGameToggleButton('spelllistButton', tr('Spell List'), '/images/topbuttons/spelllist', toggle)
spelllistButton:setOn(false)
nameValueLabel = spelllistWindow:getChildById('labelNameValue')
formulaValueLabel = spelllistWindow:getChildById('labelFormulaValue')
vocationValueLabel = spelllistWindow:getChildById('labelVocationValue')
groupValueLabel = spelllistWindow:getChildById('labelGroupValue')
typeValueLabel = spelllistWindow:getChildById('labelTypeValue')
cooldownValueLabel = spelllistWindow:getChildById('labelCooldownValue')
levelValueLabel = spelllistWindow:getChildById('labelLevelValue')
manaValueLabel = spelllistWindow:getChildById('labelManaValue')
premiumValueLabel = spelllistWindow:getChildById('labelPremiumValue')
descriptionValueLabel = spelllistWindow:getChildById('labelDescriptionValue')
vocationBoxAny = spelllistWindow:getChildById('vocationBoxAny')
vocationBoxSorcerer = spelllistWindow:getChildById('vocationBoxSorcerer')
vocationBoxDruid = spelllistWindow:getChildById('vocationBoxDruid')
vocationBoxPaladin = spelllistWindow:getChildById('vocationBoxPaladin')
vocationBoxKnight = spelllistWindow:getChildById('vocationBoxKnight')
groupBoxAny = spelllistWindow:getChildById('groupBoxAny')
groupBoxAttack = spelllistWindow:getChildById('groupBoxAttack')
groupBoxHealing = spelllistWindow:getChildById('groupBoxHealing')
groupBoxSupport = spelllistWindow:getChildById('groupBoxSupport')
premiumBoxAny = spelllistWindow:getChildById('premiumBoxAny')
premiumBoxYes = spelllistWindow:getChildById('premiumBoxYes')
premiumBoxNo = spelllistWindow:getChildById('premiumBoxNo')
vocationRadioGroup = UIRadioGroup.create()
vocationRadioGroup:addWidget(vocationBoxAny)
vocationRadioGroup:addWidget(vocationBoxSorcerer)
vocationRadioGroup:addWidget(vocationBoxDruid)
vocationRadioGroup:addWidget(vocationBoxPaladin)
vocationRadioGroup:addWidget(vocationBoxKnight)
groupRadioGroup = UIRadioGroup.create()
groupRadioGroup:addWidget(groupBoxAny)
groupRadioGroup:addWidget(groupBoxAttack)
groupRadioGroup:addWidget(groupBoxHealing)
groupRadioGroup:addWidget(groupBoxSupport)
premiumRadioGroup = UIRadioGroup.create()
premiumRadioGroup:addWidget(premiumBoxAny)
premiumRadioGroup:addWidget(premiumBoxYes)
premiumRadioGroup:addWidget(premiumBoxNo)
premiumRadioGroup:selectWidget(premiumBoxAny)
vocationRadioGroup:selectWidget(vocationBoxAny)
groupRadioGroup:selectWidget(groupBoxAny)
vocationRadioGroup.onSelectionChange = toggleFilter
groupRadioGroup.onSelectionChange = toggleFilter
premiumRadioGroup.onSelectionChange = toggleFilter
spellList = spelllistWindow:getChildById('spellList')
g_keyboard.bindKeyPress('Down', function() spellList:focusNextChild(KeyboardFocusReason) end, spelllistWindow)
g_keyboard.bindKeyPress('Up', function() spellList:focusPreviousChild(KeyboardFocusReason) end, spelllistWindow)
initialiseSpelllist()
resizeWindow()
if g_game.isOnline() then
online()
end
end
function terminate()
disconnect(g_game, { onGameStart = online,
onGameEnd = offline })
disconnect(spellList, { onChildFocusChange = function(self, focusedChild)
if focusedChild == nil then return end
updateSpellInformation(focusedChild)
end })
spelllistWindow:destroy()
spelllistButton:destroy()
vocationRadioGroup:destroy()
groupRadioGroup:destroy()
premiumRadioGroup:destroy()
end
function initialiseSpelllist()
for i = 1, #SpelllistSettings[SpelllistProfile].spellOrder do
local spell = SpelllistSettings[SpelllistProfile].spellOrder[i]
local info = SpellInfo[SpelllistProfile][spell]
local tmpLabel = g_ui.createWidget('SpellListLabel', spellList)
tmpLabel:setId(spell)
tmpLabel:setText(spell .. '\n\'' .. info.words .. '\'')
tmpLabel:setPhantom(false)
local iconId = tonumber(info.icon)
if not iconId and SpellIcons[info.icon] then
iconId = SpellIcons[info.icon][1]
end
if not(iconId) then
perror('Spell icon \'' .. info.icon .. '\' not found.')
end
tmpLabel:setHeight(SpelllistSettings[SpelllistProfile].iconSize.height + 4)
tmpLabel:setTextOffset(topoint((SpelllistSettings[SpelllistProfile].iconSize.width + 10) .. ' ' .. (SpelllistSettings[SpelllistProfile].iconSize.height - 32)/2 + 3))
tmpLabel:setImageSource(SpelllistSettings[SpelllistProfile].iconFile)
tmpLabel:setImageClip(Spells.getImageClip(iconId, SpelllistProfile))
tmpLabel:setImageSize(tosize(SpelllistSettings[SpelllistProfile].iconSize.width .. ' ' .. SpelllistSettings[SpelllistProfile].iconSize.height))
tmpLabel.onClick = updateSpellInformation
end
connect(spellList, { onChildFocusChange = function(self, focusedChild)
if focusedChild == nil then return end
updateSpellInformation(focusedChild)
end })
end
function changeSpelllistProfile(oldProfile)
-- Delete old labels
for i = 1, #SpelllistSettings[oldProfile].spellOrder do
local spell = SpelllistSettings[oldProfile].spellOrder[i]
local tmpLabel = spellList:getChildById(spell)
tmpLabel:destroy()
end
-- Create new spelllist and ajust window
initialiseSpelllist()
setOptions()
resizeWindow()
resetWindow()
end
function updateSpelllist()
for i = 1, #SpelllistSettings[SpelllistProfile].spellOrder do
local spell = SpelllistSettings[SpelllistProfile].spellOrder[i]
local info = SpellInfo[SpelllistProfile][spell]
local tmpLabel = spellList:getChildById(spell)
local localPlayer = g_game.getLocalPlayer()
if (not(filters.level) or info.level <= localPlayer:getLevel()) and (not(filters.vocation) or table.find(info.vocations, localPlayer:getVocation())) and (filters.vocationId == FILTER_VOCATION_ANY or table.find(info.vocations, filters.vocationId) or table.find(info.vocations, filters.vocationId+4)) and (filters.groupId == FILTER_GROUP_ANY or info.group[filters.groupId]) and (filters.premium == FILTER_PREMIUM_ANY or (info.premium and filters.premium == FILTER_PREMIUM_YES) or (not(info.premium) and filters.premium == FILTER_PREMIUM_NO)) then
tmpLabel:setVisible(true)
else
tmpLabel:setVisible(false)
end
end
end
function updateSpellInformation(widget)
local spell = widget:getId()
local name = ''
local formula = ''
local vocation = ''
local group = ''
local type = ''
local cooldown = ''
local level = ''
local mana = ''
local premium = ''
local description = ''
if SpellInfo[SpelllistProfile][spell] then
local info = SpellInfo[SpelllistProfile][spell]
name = spell
formula = info.words
for i = 1, #info.vocations do
local vocationId = info.vocations[i]
if vocationId <= 4 or not(table.find(info.vocations, (vocationId-4))) then
vocation = vocation .. (vocation:len() == 0 and '' or ', ') .. VocationNames[vocationId]
end
end
cooldown = (info.exhaustion / 1000) .. 's'
for groupId, groupName in ipairs(SpellGroups) do
if info.group[groupId] then
group = group .. (group:len() == 0 and '' or ' / ') .. groupName
cooldown = cooldown .. ' / ' .. (info.group[groupId] / 1000) .. 's'
end
end
type = info.type
level = info.level
mana = info.mana .. ' / ' .. info.soul
premium = (info.premium and 'yes' or 'no')
description = info.description or '-'
end
nameValueLabel:setText(name)
formulaValueLabel:setText(formula)
vocationValueLabel:setText(vocation)
groupValueLabel:setText(group)
typeValueLabel:setText(type)
cooldownValueLabel:setText(cooldown)
levelValueLabel:setText(level)
manaValueLabel:setText(mana)
premiumValueLabel:setText(premium)
descriptionValueLabel:setText(description)
end
function toggle()
if spelllistButton:isOn() then
spelllistWindow:hide()
spelllistButton:setOn(false)
else
spelllistWindow:show()
spelllistButton:setOn(true)
end
end
function toggleFilter(widget, selectedWidget)
if widget == vocationRadioGroup then
local boxId = selectedWidget:getId()
if boxId == 'vocationBoxAny' then
filters.vocationId = FILTER_VOCATION_ANY
elseif boxId == 'vocationBoxSorcerer' then
filters.vocationId = FILTER_VOCATION_SORCERER
elseif boxId == 'vocationBoxDruid' then
filters.vocationId = FILTER_VOCATION_DRUID
elseif boxId == 'vocationBoxPaladin' then
filters.vocationId = FILTER_VOCATION_PALADIN
elseif boxId == 'vocationBoxKnight' then
filters.vocationId = FILTER_VOCATION_KNIGHT
end
elseif widget == groupRadioGroup then
local boxId = selectedWidget:getId()
if boxId == 'groupBoxAny' then
filters.groupId = FILTER_GROUP_ANY
elseif boxId == 'groupBoxAttack' then
filters.groupId = FILTER_GROUP_ATTACK
elseif boxId == 'groupBoxHealing' then
filters.groupId = FILTER_GROUP_HEALING
elseif boxId == 'groupBoxSupport' then
filters.groupId = FILTER_GROUP_SUPPORT
end
elseif widget == premiumRadioGroup then
local boxId = selectedWidget:getId()
if boxId == 'premiumBoxAny' then
filters.premium = FILTER_PREMIUM_ANY
elseif boxId == 'premiumBoxNo' then
filters.premium = FILTER_PREMIUM_NO
elseif boxId == 'premiumBoxYes' then
filters.premium = FILTER_PREMIUM_YES
end
else
local id = widget:getId()
if id == 'buttonFilterLevel' then
filters.level = not(filters.level)
widget:setOn(filters.level)
elseif id == 'buttonFilterVocation' then
filters.vocation = not(filters.vocation)
widget:setOn(filters.vocation)
end
end
updateSpelllist()
end
function resizeWindow()
spelllistWindow:setWidth(SpelllistSettings['Default'].spellWindowWidth + SpelllistSettings[SpelllistProfile].iconSize.width - 32)
spellList:setWidth(SpelllistSettings['Default'].spellListWidth + SpelllistSettings[SpelllistProfile].iconSize.width - 32)
end
function resetWindow()
spelllistWindow:hide()
spelllistButton:setOn(false)
-- Resetting filters
filters.level = false
filters.vocation = false
local buttonFilterLevel = spelllistWindow:getChildById('buttonFilterLevel')
buttonFilterLevel:setOn(filters.level)
local buttonFilterVocation = spelllistWindow:getChildById('buttonFilterVocation')
buttonFilterVocation:setOn(filters.vocation)
vocationRadioGroup:selectWidget(vocationBoxAny)
groupRadioGroup:selectWidget(groupBoxAny)
premiumRadioGroup:selectWidget(premiumBoxAny)
updateSpelllist()
end
| mit |
francoiscote/dotfiles | hammerspoon/.hammerspoon/window-management/grid.lua | 1 | 2843 | helpers = require("window-management/helpers")
-- SETTINGS
-------------------------------------------------------------------------------
local gapSize = 10
local menuGapSize = 0
-- GRID
-------------------------------------------------------------------------------
local mainScreen = hs.screen.mainScreen()
local frame = nil
if menuGapSize > 0 then
local max = mainScreen:frame()
frame = hs.geometry(0, menuGapSize, max.w, max.h - menuGapSize)
end
local defaultMargins = gapSize .. 'x' .. gapSize
local largeMargins = helpers.getDynamicMargins(0.02, 0.04)
local extraLargeMargins = helpers.getDynamicMargins(0.03, 0.07)
local hsGrid = hs.grid.setGrid('12x12', mainScreen, frame).setMargins(defaultMargins)
local areas = {
smallSplit = {
secondaryFull = '0,0 4x12',
secondaryTop = '0,0 4x5',
secondaryBottom = '0,5 4x7',
main = '4,0 8x12',
},
mediumSplit = {
secondaryFull = '0,0 5x12',
secondaryTop = '0,0 5x6',
secondaryBottom = '0,6 5x6',
main = '5,0 7x12',
},
evenSplit = {
leftFull = '0,0 6x12',
leftTop = '0,0 6x5',
leftBottom = '0,6 6x5',
rightFull = '6,0 6x12',
rightTop = '6,0 6x5',
rightBottom = '6,6 6x5',
},
tripleSplit = {
leftFull = '0,0 4x12',
leftTop = '0,0 4x6',
leftBottom = '0,6 4x6',
mainFull = '4,0 4x12',
mainTop = '4,0 4x5',
mainBottom = '4,5 4x7',
rightFull = '8,0 4x12',
rightTop = '8,0 4x6',
rightBottom = '8,6 4x6',
},
custom = {
smallLeft = '0,0 4x12',
largeLeft = '0,0 8x12',
finder = '3,2 4x6',
center = '2,1 8x10',
browser = '2,0 8x12',
largeRight = '4,0 8x12',
smallRight = '8,0 4x12'
},
customTwitch = {
finder = '2,1.5 3x4',
spotify = '0.5,0.5 6x7',
browser = '1,0 5x8'
}
}
-- FUNCTIONS
-----------------------------------------------------------------------------
function setDefaultMargins()
hsGrid.setMargins(defaultMargins)
end
function setLargeMargins()
hsGrid.setMargins(largeMargins)
end
function setExtraLargeMargins()
hsGrid.setMargins(extraLargeMargins)
end
function setWindowsToCell(windows, cell)
for i,w in pairs(windows) do
hsGrid.set(w, cell)
end
end
function setFilteredWindowsToCell(wf, cell)
local windows = wf:getWindows()
setWindowsToCell(windows, cell)
end
function setFocusedWindowToCell(cell)
local win = hs.window.focusedWindow()
hsGrid.set(win, cell)
end
-- EXPORT
-----------------------------------------------------------------------------
local export = {
hsGrid = hsGrid,
areas = areas,
setDefaultMargins = setDefaultMargins,
setLargeMargins = setLargeMargins,
setExtraLargeMargins = setExtraLargeMargins,
setWindowsToCell = setWindowsToCell,
setFilteredWindowsToCell = setFilteredWindowsToCell,
setFocusedWindowToCell = setFocusedWindowToCell
}
return export
| mit |
dacrybabysuck/darkstar | scripts/zones/Fort_Ghelsba/npcs/_3x1.lua | 14 | 1183 | -----------------------------------
-- Area: Fort Ghelsba
-- NPC: Elevator Lever (lower)
-- !pos -0.652 -28.996 100.445 141
-----------------------------------
require("scripts/globals/status")
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
-- local vars to reduce repeat calls..
local lever = npc:getID()
local gear = GetNPCByID(lever +2)
local bigWinch = GetNPCByID(lever -1)
-- Animate lever
npc:openDoor(1)
-- Animate lever's Gear - do not use openDoor() / closeDoor() here!
if gear:getAnimation() == dsp.animation.OPEN_DOOR then
gear:setAnimation(dsp.animation.CLOSE_DOOR)
else
gear:setAnimation(dsp.animation.OPEN_DOOR)
end
-- Animate bigWinch - do not use openDoor() / closeDoor() here!
if bigWinch:getAnimation() == dsp.animation.OPEN_DOOR then
bigWinch:setAnimation(dsp.animation.CLOSE_DOOR)
else
bigWinch:setAnimation(dsp.animation.OPEN_DOOR)
end
-- Move platform
RunElevator(dsp.elevator.FORT_GHELSBA_LIFT)
end;
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
end
| gpl-3.0 |
CCAAHH/pm | plugins/bot_on_off.lua | 292 | 1641 | -- Checks if bot was disabled on specific chat
local function is_channel_disabled( receiver )
if not _config.disabled_channels then
return false
end
if _config.disabled_channels[receiver] == nil then
return false
end
return _config.disabled_channels[receiver]
end
local function enable_channel(receiver)
if not _config.disabled_channels then
_config.disabled_channels = {}
end
if _config.disabled_channels[receiver] == nil then
return 'Robot is Online'
end
_config.disabled_channels[receiver] = false
save_config()
return "Robot is Online"
end
local function disable_channel( receiver )
if not _config.disabled_channels then
_config.disabled_channels = {}
end
_config.disabled_channels[receiver] = true
save_config()
return "Robot is Offline"
end
local function pre_process(msg)
local receiver = get_receiver(msg)
-- If sender is moderator then re-enable the channel
--if is_sudo(msg) then
if is_momod(msg) then
if msg.text == "[!/]bot on" then
enable_channel(receiver)
end
end
if is_channel_disabled(receiver) then
msg.text = ""
end
return msg
end
local function run(msg, matches)
local receiver = get_receiver(msg)
-- Enable a channel
if matches[1] == 'on' then
return enable_channel(receiver)
end
-- Disable a channel
if matches[1] == 'off' then
return disable_channel(receiver)
end
end
return {
description = "Robot Switch",
usage = {
"/bot on : enable robot in group",
"/bot off : disable robot in group" },
patterns = {
"^[!/]bot? (on)",
"^[!/]bot? (off)" },
run = run,
privileged = true,
--moderated = true,
pre_process = pre_process
}
| gpl-2.0 |
keviner2004/shoot-em-up | sprites/tiles.lua | 1 | 1346 | --
-- created with TexturePacker (http://www.codeandweb.com/texturepacker)
--
-- $TexturePacker:SmartUpdate:53496ed08f6b65acc16dda6fa974ed8c:c8b1774d0c0e7018596b0041ca2be5c5:f4492607ea55a754477543692c89a688$
--
-- local sheetInfo = require("mysheet")
-- local myImageSheet = graphics.newImageSheet( "mysheet.png", sheetInfo:getSheet() )
-- local sprite = display.newSprite( myImageSheet , {frames={sheetInfo:getFrameIndex("sprite")}} )
--
local SheetInfo = {}
SheetInfo.sheet =
{
frames = {
{
-- black
x=1,
y=1,
width=256,
height=256,
},
{
-- blue
x=259,
y=1,
width=256,
height=256,
},
{
-- darkPurple
x=517,
y=1,
width=256,
height=256,
},
{
-- purple
x=775,
y=1,
width=256,
height=256,
},
},
sheetContentWidth = 1032,
sheetContentHeight = 258
}
SheetInfo.frameIndex =
{
["black"] = 1,
["blue"] = 2,
["darkPurple"] = 3,
["purple"] = 4,
}
function SheetInfo:getSheet()
return self.sheet;
end
function SheetInfo:getFrameIndex(name)
return self.frameIndex[name];
end
return SheetInfo
| mit |
dacrybabysuck/darkstar | scripts/zones/LaLoff_Amphitheater/bcnms/divine_might.lua | 9 | 2685 | -----------------------------------
-- Area: LaLoff Amphitheater
-- Name: Divine Might
--[[ caps:
7d01, 0, 529, 1, 950, 180, 6, 0, 0 --Neo AA HM
7d01, 0, 1400, 5, 1400, 180, 11, 0, 0 --Neo DM
7d01, 1, 405, 1, 1599, 180, 7, 0, 0 -- Neo AA TT
7d01, 1, 378, 3, 903, 180, 8, 0, 0 -- Neo AA MR
7d02, 0, 80, 1, 512, 4, 4, 180 -- Neo DM (lose)
]]
-----------------------------------
local ID = require("scripts/zones/LaLoff_Amphitheater/IDs")
require("scripts/globals/battlefield")
require("scripts/globals/keyitems")
require("scripts/globals/missions")
require("scripts/globals/quests")
-----------------------------------
function onBattlefieldTick(battlefield, tick)
dsp.battlefield.onBattlefieldTick(battlefield, tick)
end
function onBattlefieldRegister(player, battlefield)
end
function onBattlefieldEnter(player, battlefield)
player:startEvent(32001, battlefield:getArea(), clearTime, partySize, battlefield:getTimeInside(), 1, battlefield:getLocalVar("[cs]bit"), 1)
end
function onBattlefieldLeave(player, battlefield, leavecode)
if leavecode == dsp.battlefield.leaveCode.WON then
local name, clearTime, partySize = battlefield:getRecord()
local arg8 = (player:hasCompletedMission(ZILART, dsp.mission.id.zilart.ARK_ANGELS)) and 1 or 0
player:startEvent(32001, battlefield:getArea(), clearTime, partySize, battlefield:getTimeInside(), 180, battlefield:getLocalVar("[cs]bit"), arg8)
elseif leavecode == dsp.battlefield.leaveCode.LOST then
player:startEvent(32002, 0, 0, 0, 0, 0, battlefield:getArea(), 180)
end
end
function onEventUpdate(player, csid, option)
end
function onEventFinish(player, csid, option)
if csid == 32001 then
if player:getQuestStatus(OUTLANDS, dsp.quest.id.outlands.DIVINE_MIGHT) == QUEST_ACCEPTED then
player:setCharVar("DivineMight", 2) -- Used to use 2 to track completion, so that's preserved to maintain compatibility
for i = dsp.ki.SHARD_OF_APATHY, dsp.ki.SHARD_OF_RAGE do
player:addKeyItem(i)
player:messageSpecial(ID.text.KEYITEM_OBTAINED, i)
end
if player:getCurrentMission(ZILART) == dsp.mission.id.zilart.ARK_ANGELS then
player:completeMission(ZILART, dsp.mission.id.zilart.ARK_ANGELS)
player:addMission(ZILART, dsp.mission.id.zilart.THE_SEALED_SHRINE)
player:setCharVar("ZilartStatus", 0)
end
elseif player:getQuestStatus(OUTLANDS, dsp.quest.id.outlands.DIVINE_MIGHT_REPEAT) == QUEST_ACCEPTED and player:hasKeyItem(dsp.ki.MOONLIGHT_ORE) then
player:setCharVar("DivineMight", 2)
end
end
end
| gpl-3.0 |
dacrybabysuck/darkstar | scripts/globals/abilities/pets/magic_mortar.lua | 11 | 1395 | ---------------------------------------------------
-- Magic Mortar
---------------------------------------------------
require("scripts/globals/status")
require("scripts/globals/settings")
require("scripts/globals/automatonweaponskills")
---------------------------------------------------
function onMobSkillCheck(target, automaton, skill)
local master = automaton:getMaster()
return master:countEffect(dsp.effect.LIGHT_MANEUVER)
end
function onPetAbility(target, automaton, skill, master, action)
local ftp
local tp = skill:getTP()
if not USE_ADOULIN_WEAPON_SKILL_CHANGES then
ftp = 0.5 + ((0.5/3000) * tp)
else
-- Might be wrong, it may only use max hp in its new form, also it may be able to miss and take defense into account as well
if tp >= 3000 then
ftp = 2.5
elseif tp >= 2000 then
ftp = 1.75 + ((0.75/3000) * tp)
else
ftp = 1.5 + ((0.25/3000) * tp)
end
end
local hpdamage = (automaton:getMaxHP() - automaton:getHP()) * ftp
local skilldamage = automaton:getSkillLevel(dsp.skill.AUTOMATON_MELEE) * ftp
local damage = (hpdamage > skilldamage) and hpdamage or skilldamage
if damage > 0 then
target:addTP(20)
automaton:addTP(80)
end
target:takeDamage(damage, pet, dsp.attackType.MAGICAL, dsp.damageType.LIGHT)
return damage
end
| gpl-3.0 |
kikito/Algorithm-Implementations | A_Star_Search/Lua/Yonaba/bheap.lua | 2 | 2404 | -- Binary Heap data structure implementation
-- See: http://www.policyalmanac.org/games/binaryHeaps.htm
-- Adapted from: https://github.com/Yonaba/Binary-Heaps
local class = require 'class'
-- Looks for item in an array
local function findIndex(array, item)
for k,v in ipairs(array) do
if v == item then return k end
end
end
-- Percolates up to restore heap property
local function sift_up(bheap, index)
if index == 1 then return end
local pIndex
if index <= 1 then return end
if index%2 == 0 then
pIndex = index/2
else pIndex = (index-1)/2
end
if not bheap._sort(bheap._heap[pIndex], bheap._heap[index]) then
bheap._heap[pIndex], bheap._heap[index] =
bheap._heap[index], bheap._heap[pIndex]
sift_up(bheap, pIndex)
end
end
-- Percolates down to restore heap property
local function sift_down(bheap,index)
local lfIndex,rtIndex,minIndex
lfIndex = 2*index
rtIndex = lfIndex + 1
if rtIndex > bheap.size then
if lfIndex > bheap.size then return
else minIndex = lfIndex end
else
if bheap._sort(bheap._heap[lfIndex],bheap._heap[rtIndex]) then
minIndex = lfIndex
else
minIndex = rtIndex
end
end
if not bheap._sort(bheap._heap[index],bheap._heap[minIndex]) then
bheap._heap[index],bheap._heap[minIndex] = bheap._heap[minIndex],bheap._heap[index]
sift_down(bheap,minIndex)
end
end
-- Binary heap class
-- Instantiates minHeaps by default
local bheap = class()
function bheap:initialize()
self.size = 0
self._sort = function(a,b) return a < b end
self._heap = {}
end
-- Clears the heap
function bheap:clear()
self._heap = {}
self.size = 0
end
-- Checks if the heap is empty
function bheap:isEmpty()
return (self.size==0)
end
-- Pushes a new item into the heap
function bheap:push(item)
self.size = self.size + 1
self._heap[self.size] = item
sift_up(self, self.size)
end
-- Pops the lowest (or highest) best item out of the heap
function bheap:pop()
local root
if self.size > 0 then
root = self._heap[1]
self._heap[1] = self._heap[self.size]
self._heap[self.size] = nil
self.size = self.size-1
if self.size > 1 then
sift_down(self, 1)
end
end
return root
end
-- Sorts a specific item in the heap
function bheap:sort(item)
if self.size <= 1 then return end
local i = findIndex(self._heap, item)
if i then sift_up(self, i) end
end
return bheap
| mit |
dacrybabysuck/darkstar | scripts/globals/mobskills/digest.lua | 11 | 1112 | ---------------------------------------------
-- Digest
-- Deals dark damage to a single target. Additional effect: Drain
-- Type: Magical
-- Utsusemi/Blink absorb: 1 shadow
-- Range: Melee
-- Notes: If used against undead, it will simply do damage and not drain HP.
---------------------------------------------
require("scripts/globals/monstertpmoves")
require("scripts/globals/settings")
require("scripts/globals/status")
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
if (mob:getFamily() == 290) then -- Claret
if (mob:checkDistance(target) < 3) then -- Don't use it if he is on his target.
return 1
end
end
return 0
end
function onMobWeaponSkill(target, mob, skill)
local dmgmod = 1
local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*2.6,dsp.magic.ele.DARK,dmgmod,TP_MAB_BONUS,1)
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,dsp.attackType.MAGICAL,dsp.damageType.DARK,MOBPARAM_1_SHADOW)
skill:setMsg(MobPhysicalDrainMove(mob, target, skill, MOBDRAIN_HP, dmg))
return dmg
end
| gpl-3.0 |
dcourtois/premake-core | modules/d/tools/gdc.lua | 4 | 7302 | --
-- d/tools/gdc.lua
-- Provides GDC-specific configuration strings.
-- Copyright (c) 2013-2015 Andrew Gough, Manu Evans, and the Premake project
--
local p = premake
p.tools.gdc = { }
local gdc = p.tools.gdc
local project = p.project
local config = p.config
local d = p.modules.d
--
-- Set default tools
--
gdc.dc = "gdc"
--
-- Returns list of D compiler flags for a configuration.
--
gdc.dflags = {
architecture = {
x86 = "-m32",
x86_64 = "-m64",
},
flags = {
Documentation = "-fdoc",
FatalWarnings = "-Werror",
GenerateHeader = "-fintfc",
GenerateJSON = "-fX",
-- Release = "-frelease",
RetainPaths = "-op",
SymbolsLikeC = "-fdebug-c",
UnitTest = "-funittest",
Verbose = "-fd-verbose",
-- THESE ARE THE DMD ARGS...
-- ProfileGC = "-profile=gc",
-- StackFrame = "-gs",
-- StackStomp = "-gx",
-- AllInstantiate = "-allinst",
-- BetterC = "-betterC",
-- Main = "-main",
-- PerformSyntaxCheckOnly = "-o-",
ShowTLS = "-fd-vtls",
-- ShowGC = "-vgc",
-- IgnorePragma = "-ignore",
ShowDependencies = "-fdeps",
},
boundscheck = {
Off = "-fno-bounds-check",
-- On = "-boundscheck=on",
-- SafeOnly = "-boundscheck=safeonly",
},
deprecatedfeatures = {
Allow = "-fdeprecated",
-- Warn = "-dw",
-- Error = "-de",
},
floatingpoint = {
Fast = "-ffast-math",
Strict = "-ffloat-store",
},
optimize = {
Off = "-O0",
On = "-O2 -finline-functions",
Debug = "-Og",
Full = "-O3 -finline-functions",
Size = "-Os -finline-functions",
Speed = "-O3 -finline-functions",
},
pic = {
On = "-fPIC",
},
vectorextensions = {
AVX = "-mavx",
SSE = "-msse",
SSE2 = "-msse2",
},
warnings = {
-- Default = "-w", -- TODO: check this...
High = "-Wall",
Extra = "-Wall -Wextra",
Everything = "-Weverything",
},
symbols = {
On = "-g",
FastLink = "-g",
Full = "-g -gf",
}
}
function gdc.getdflags(cfg)
local flags = config.mapFlags(cfg, gdc.dflags)
if config.isDebugBuild(cfg) then
table.insert(flags, "-fdebug")
else
table.insert(flags, "-frelease")
end
if cfg.flags.Documentation then
if cfg.docname then
table.insert(flags, "-fdoc-file=" .. p.quoted(cfg.docname))
end
if cfg.docdir then
table.insert(flags, "-fdoc-dir=" .. p.quoted(cfg.docdir))
end
end
if cfg.flags.GenerateHeader then
if cfg.headername then
table.insert(flags, "-fintfc-file=" .. p.quoted(cfg.headername))
end
if cfg.headerdir then
table.insert(flags, "-fintfc-dir=" .. p.quoted(cfg.headerdir))
end
end
return flags
end
--
-- Decorate versions for the DMD command line.
--
function gdc.getversions(versions, level)
local result = {}
for _, version in ipairs(versions) do
table.insert(result, '-fversion=' .. version)
end
if level then
table.insert(result, '-fversion=' .. level)
end
return result
end
--
-- Decorate debug constants for the DMD command line.
--
function gdc.getdebug(constants, level)
local result = {}
for _, constant in ipairs(constants) do
table.insert(result, '-fdebug=' .. constant)
end
if level then
table.insert(result, '-fdebug=' .. level)
end
return result
end
--
-- Decorate import file search paths for the DMD command line.
--
function gdc.getimportdirs(cfg, dirs)
local result = {}
for _, dir in ipairs(dirs) do
dir = project.getrelative(cfg.project, dir)
table.insert(result, '-I' .. p.quoted(dir))
end
return result
end
--
-- Decorate import file search paths for the DMD command line.
--
function gdc.getstringimportdirs(cfg, dirs)
local result = {}
for _, dir in ipairs(dirs) do
dir = project.getrelative(cfg.project, dir)
table.insert(result, '-J' .. p.quoted(dir))
end
return result
end
--
-- Returns the target name specific to compiler
--
function gdc.gettarget(name)
return "-o " .. name
end
--
-- Return a list of LDFLAGS for a specific configuration.
--
gdc.ldflags = {
architecture = {
x86 = { "-m32" },
x86_64 = { "-m64" },
},
kind = {
SharedLib = function(cfg)
local r = { iif(cfg.system == p.MACOSX, "-dynamiclib", "-shared") }
if cfg.system == "windows" and not cfg.flags.NoImportLib then
table.insert(r, '-Wl,--out-implib="' .. cfg.linktarget.relpath .. '"')
end
return r
end,
WindowedApp = function(cfg)
if cfg.system == p.WINDOWS then return "-mwindows" end
end,
},
}
function gdc.getldflags(cfg)
local flags = config.mapFlags(cfg, gdc.ldflags)
return flags
end
--
-- Return a list of decorated additional libraries directories.
--
gdc.libraryDirectories = {
architecture = {
x86 = "-L/usr/lib",
x86_64 = "-L/usr/lib64",
}
}
function gdc.getLibraryDirectories(cfg)
local flags = config.mapFlags(cfg, gdc.libraryDirectories)
-- Scan the list of linked libraries. If any are referenced with
-- paths, add those to the list of library search paths
for _, dir in ipairs(config.getlinks(cfg, "system", "directory")) do
table.insert(flags, '-Wl,-L' .. project.getrelative(cfg.project, dir))
end
return flags
end
--
-- Return the list of libraries to link, decorated with flags as needed.
--
function gdc.getlinks(cfg, systemonly)
local result = {}
local links
if not systemonly then
links = config.getlinks(cfg, "siblings", "object")
for _, link in ipairs(links) do
-- skip external project references, since I have no way
-- to know the actual output target path
if not link.project.external then
if link.kind == p.STATICLIB then
-- Don't use "-l" flag when linking static libraries; instead use
-- path/libname.a to avoid linking a shared library of the same
-- name if one is present
table.insert(result, "-Wl," .. project.getrelative(cfg.project, link.linktarget.abspath))
else
table.insert(result, "-Wl,-l" .. link.linktarget.basename)
end
end
end
end
-- The "-l" flag is fine for system libraries
links = config.getlinks(cfg, "system", "fullpath")
for _, link in ipairs(links) do
if path.isframework(link) then
table.insert(result, "-framework " .. path.getbasename(link))
elseif path.isobjectfile(link) then
table.insert(result, "-Wl," .. link)
else
table.insert(result, "-Wl,-l" .. path.getbasename(link))
end
end
return result
end
--
-- Returns makefile-specific configuration rules.
--
gdc.makesettings = {
}
function gdc.getmakesettings(cfg)
local settings = config.mapFlags(cfg, gdc.makesettings)
return table.concat(settings)
end
--
-- Retrieves the executable command name for a tool, based on the
-- provided configuration and the operating environment.
--
-- @param cfg
-- The configuration to query.
-- @param tool
-- The tool to fetch, one of "dc" for the D compiler, or "ar" for the static linker.
-- @return
-- The executable command name for a tool, or nil if the system's
-- default value should be used.
--
gdc.tools = {
ps3 = {
dc = "ppu-lv2-gdc",
ar = "ppu-lv2-ar",
},
}
function gdc.gettoolname(cfg, tool)
local names = gdc.tools[cfg.architecture] or gdc.tools[cfg.system] or {}
local name = names[tool]
return name or gdc[tool]
end
| bsd-3-clause |
tung/doomrl | bin/core/level.lua | 2 | 10040 | function level:get_being_table( dlevel, weights, reqs, dmod )
local dmod = dmod or math.clamp( (DIFFICULTY-2)*3, 0, 6 )
local danger = dlevel or self.danger_level
local list = weight_table.new()
for _,b in ipairs(beings) do
if b.weight > 0 and danger+dmod >= b.min_lev and danger <= b.max_lev then
if core.proto_reqs_met( b, reqs ) then
local weight = core.proto_weight( b, weights )
list:add( b, weight )
end
end
end
for _,bg in ipairs(being_groups) do
if bg.weight > 0 and danger+dmod >= bg.min_lev and danger <= bg.max_lev then
if core.proto_reqs_met( bg, reqs ) then
local weight = core.proto_weight( bg, weights )
list:add( bg )
end
end
end
return list
end
function level:get_item_table( dlevel, weights, reqs )
local danger = dlevel or self.danger_level
local allow_exotic = self.danger_level > DIFFICULTY
local allow_unique = self.danger_level > DIFFICULTY+3
local list = weight_table.new()
for _,i in ipairs(items) do
if i.weight > 0 and danger >= i.level then
if (not i.is_exotic or allow_exotic) and (not i.is_unique or allow_unique) then
if core.proto_reqs_met( i, reqs ) then
local weight = core.proto_weight( i, weights )
if weight > 0 and (not i.is_unique or not player.__props.items_found[i.id]) then
list:add( i, weight )
end
end
end
end
end
return list
end
function level:flood_monsters( params )
if not params.danger and not params.amount then
error("level:flood_monsters expects at least danger or count!")
end
local flags = params.flags or { EF_NOBEINGS, EF_NOBLOCK, EF_NOHARM, EF_NOSPAWN }
local dtotal = params.danger or 100000000
local count = params.amount or 100000000
local reqs = params.reqs
if params.no_groups then
reqs = reqs or {}
reqs.is_group = false
end
local list
if params.list then
list = weight_table.new()
for k,v in pairs( params.list ) do
if type(k) == "string" then
list:add( beings[k], v )
else
list:add( beings[v] )
end
end
else
list = self:get_being_table( params.level, params.weights, reqs, params.diffmod )
end
while (dtotal > 0) and (count > 0) do
local bp = list:roll()
local where = generator.random_empty_coord( flags, params.area )
if not where then break end
if bp.is_group then
for _,group in ipairs(bp.beings) do
local count = resolverange(group.amount or 1)
for i=1,count do
self:drop_being( group.being, where )
dtotal = dtotal - beings[group.being].danger
count = count - 1
end
end
else
self:drop_being( bp.id, where )
dtotal = dtotal - beings[bp.id].danger
count = count - 1
end
end
end
function level:flood_monster( params )
if not params.id or (not params.danger and not params.amount) then
error("level:flood_monster expects at least id and danger or count!")
end
local id = params.id
local flags = params.flags or { EF_NOBEINGS, EF_NOBLOCK, EF_NOHARM, EF_NOSPAWN }
local dtotal = params.danger or 100000000
local count = params.amount or 100000000
while (dtotal > 0) and (count > 0) do
local being = self:drop_being( id, generator.random_empty_coord( flags, params.area ) )
if not being then return end
dtotal = dtotal - beings[id].danger
count = count - 1
end
end
function level:flood_items( params )
params = params or {}
local amount = params.amount or params
local list = self:get_item_table( params.level or level.danger_level, params.weights, params.reqs )
while amount > 0 do
local ip = list:roll()
if not ( ip.is_unique and self.flags[ LF_UNIQUEITEM ] ) then
if ip.is_unique then
self.flags[ LF_UNIQUEITEM ] = true
end
local where = generator.random_empty_coord{ EF_NOITEMS, EF_NOBLOCK, EF_NOHARM, EF_NOSPAWN }
self:drop_item( ip.id, where, true )
amount = amount - 1
end
end
end
function level:roll_being( params )
local flags = params.flags or { EF_NOBEINGS, EF_NOBLOCK, EF_NOHARM, EF_NOSPAWN }
local reqs = params.reqs or {}
reqs.is_group = false
local list
if params.list then
list = weight_table.new()
for k,v in pairs( params.list ) do
if type(k) == "string" then
list:add( beings[k], v )
else
list:add( beings[v] )
end
end
else
list = self:get_being_table( params.level, params.weights, reqs, params.diffmod )
end
return list:roll().id
end
function level:roll_item( params )
params = params or {}
local reqs = params.reqs
local weights = params.weights
if self.flags[ LF_UNIQUEITEM ] then
reqs = reqs or {}
reqs.is_unique = false
end
if params.type then
reqs = reqs or {}
reqs.type = params.type
end
if params.unique_mod or params.special_mod or params.exotic_mod then
weights = weights or {}
weights[ IF_UNIQUE ] = params.unique_mod
weights[ IF_EXOTIC ] = params.exotic_mod
weights.is_special = params.special_mod
end
local list = self:get_item_table( params.level, weights, reqs )
if list:size() == 0 then return nil end
local ip = list:roll()
if ip.is_unique then
self.flags[ LF_UNIQUEITEM ] = true
end
return ip.id
end
function level:summon(t,opt)
local count = 1
local where = nil
local cid = nil
local bid = nil
local empty = { EF_NOBEINGS, EF_NOBLOCK, EF_NOHARM, EF_NOSPAWN }
if type(t) == "string" then
bid = t
count = opt or 1
elseif type(t) == "table" then
bid = t.id or t[1]
count = t.count or t[2] or 1
cid = t.cell
if cid then empty = { EF_NOBEINGS, EF_NOBLOCK } end
where = t.area
empty = t.empty or empty
else
error( "Bad argument #1 passed to summon!" )
end
if not bid then
error( "Being id not defined for summon!" )
end
if count <= 0 then return nil end
local last_being = nil
local c
for i=1,count or 1 do
if cid then
c = generator.random_empty_coord(empty, cid, where)
else
c = generator.random_empty_coord(empty, where)
end
last_being = self:drop_being( bid, c )
end
return last_being
end
-- Overrides LuaMapNode API!
function level:drop(iid,count)
if type(iid) == "string" then iid = items[iid].nid end
local last_item = nil
for i=1,count or 1 do
last_item = self:drop_item(iid,generator.random_empty_coord{ EF_NOITEMS, EF_NOBLOCK, EF_NOHARM, EF_NOSPAWN })
end
return last_item
end
function level:area_drop(where,iid,count,onfloor)
if type(iid) == "string" then iid = items[iid].nid end
onfloor = onfloor or false
local last_item = nil
for i=1,count or 1 do
local pos = generator.random_empty_coord( { EF_NOITEMS, EF_NOBLOCK, EF_NOHARM, EF_NOSPAWN }, where )
if not pos then break end
last_item = self:drop_item(iid,pos,onfloor)
end
return last_item
end
function level:drop_item_ext( item, c )
local id = item
if type(id) == "table" then id = id[1] end
if type(id) == "string" then id = items[id].nid end
local new_item = self:drop_item(id,c)
if type(item) == "table" then
for k,v in pairs(item) do
if type(k) == "string" then
new_item[k] = v
end
end
end
end
function level:drop_being_ext( being, c )
local id = being
if type(id) == "table" then id = id[1] end
if type(id) == "string" then id = beings[id].nid end
local new_being = self:drop_being(id,c)
if type(being) == "table" then
for k,v in pairs(being) do
if type(k) == "string" then
new_being[k] = v
end
end
end
end
function level:try_destroy_item( coord )
local item = self:get_item( coord )
if item and not item.flags[ IF_UNIQUE ] and not item.flags[ IF_NODESTROY ] then item:destroy() end
end
function level:flood( tile, flood_area )
local hazard = cells[tile].flags[ CF_HAZARD ]
local nid = cells[tile].nid
for c in flood_area() do
local cell_proto = cells[generator.get_cell(c)]
if cell_proto.set == CELLSET_FLOORS or cell_proto.flags[ CF_LIQUID ] then
generator.set_cell(c,nid)
end
if hazard then
self:try_destroy_item(c)
end
end
self:recalc_fluids()
end
function level:is_corpse( c )
local cell = cells[ self.map[ c ] ]
return cell.id == "corpse" or cell.flags[ CF_CORPSE ]
end
function level:push_cell(c, target, quiet)
local cell_id = self.map[c]
local name = cells[ cell_id ].name
if not area.FULL:contains(target) then
if not quiet then ui.msg( "It doesn't seem to move there." ) end
self:play_sound( cell_id .. ".movefail", c )
return false
end
local cell = cells[cell_id]
local target_cell_id = self.map[target]
local target_cell = cells[target_cell_id]
if target_cell.flags[CF_HAZARD] then
if not quiet then ui.msg( "Oh my, how stupid!" ) end
self:play_sound( cell_id .. ".move", c )
--self.map[c] = cell.destroyto
cell.OnDestroy( c )
return true
end
if target_cell.set ~= CELLSET_FLOORS then
if not quiet then ui.msg( "It doesn't seem to move there." ) end
self:play_sound( cell_id .. ".movefail", c )
return false
end
if not generator.is_empty( target, { EF_NOITEMS, EF_NOBEINGS } ) then
if not quiet then ui.msg( "Something's blocking the "..name.."." ) end
self:play_sound( cell_id .. ".movefail", c )
return false
end
self:play_sound( cell_id .. ".move", c )
--TODO: trigger smooth move animation in G-version?
local hp_c = self.hp[c]
local hp_target = self.hp[target]
self.map[c] = target_cell_id
self.map[target] = cell_id
self.hp[target] = hp_c
self.hp[c] = hp_target
if not quiet then ui.msg( "You push the "..name.."." ) end
return true
end
function level:beings()
return self:children("being")
end
function level:items()
return self:children("item")
end
function level:beings_in_range( position, range )
return self:children_in_range( position, range, ENTITY_BEING )
end
function level:items_in_range( position, range )
return self:children_in_range( position, range, ENTITY_ITEM )
end
level.data = setmetatable({}, {
__newindex = function (_, k,v)
local l = levels[level.id]
if not l.data then
l.data = {}
end
l.data[k] = v
end,
__index = function (_, k,v)
local l = levels[level.id]
if not l.data then
l.data = {}
end
return l.data[k]
end,
})
table.merge( level, game_object )
setmetatable( level, getmetatable(game_object) )
| gpl-2.0 |
Dingf/Icewrack | game/dota_addons/icewrack/scripts/vscripts/link_ext_ability.lua | 1 | 31419 | --[[
Icewrack Extended Ability Linker
]]
--TODO: Investigate whether we can stop the game from generating a dozen CastFilterResult calls
--There was a similar problem a while back with modifiers, see http://dev.dota2.com/showthread.php?t=172252&p=1247001&viewfull=1#post1247001
--However we don't have any identifying information this time, as all the calls are the same...
--TODO: Implement weather abilities (i.e. make it so that only one weather ability can be active at a time)
if not CExtAbilityLinker then CExtAbilityLinker = {}
if _VERSION < "Lua 5.2" then
bit = require("lib/numberlua")
bit32 = bit.bit32
end
if IsServer() then
require("timer")
require("mechanics/modifier_triggers")
require("mechanics/skills")
require("instance")
require("entity_base")
end
stExtAbilityFlagEnum =
{
IW_ABILITY_FLAG_ONLY_CAST_OUTSIDE = 1,
IW_ABILITY_FLAG_ONLY_CAST_INSIDE = 2,
IW_ABILITY_FLAG_ONLY_CAST_AT_DAY = 4,
IW_ABILITY_FLAG_ONLY_CAST_AT_NIGHT = 8,
IW_ABILITY_FLAG_CAN_TARGET_CORPSES = 16,
IW_ABILITY_FLAG_ONLY_TARGET_CORPSES = 32,
IW_ABILITY_FLAG_CAN_TARGET_OBJECTS = 64, --TODO: Implement me
IW_ABILITY_FLAG_ONLY_TARGET_OBJECTS = 128, --TODO: Implement me
IW_ABILITY_FLAG_ONLY_CAST_IN_COMBAT = 256,
IW_ABILITY_FLAG_ONLY_CAST_NO_COMBAT = 512,
IW_ABILITY_FLAG_DOES_NOT_REQ_VISION = 1024,
IW_ABILITY_FLAG_IGNORE_LOS_BLOCKERS = 2048,
IW_ABILITY_FLAG_CAN_CAST_IN_TOWN = 4096, --TODO: Implement me
IW_ABILITY_FLAG_USES_ATTACK_RANGE = 8192,
IW_ABILITY_FLAG_AUTOCAST_ATTACK = 16384,
IW_ABILITY_FLAG_TOGGLE_OFF_ON_DEATH = 32768,
IW_ABILITY_FLAG_KEYWORD_SPELL = 65536,
IW_ABILITY_FLAG_KEYWORD_ATTACK = 131072,
IW_ABILITY_FLAG_KEYWORD_SINGLE = 262144,
IW_ABILITY_FLAG_KEYWORD_AOE = 524288,
IW_ABILITY_FLAG_KEYWORD_WEATHER = 1048576,
IW_ABILITY_FLAG_KEYWORD_AURA = 2097152,
}
for k,v in pairs(stExtAbilityFlagEnum) do _G[k] = v end
local stUnitFilterCastErrors =
{
[UF_FAIL_ANCIENT] = "#dota_hud_error_cant_cast_on_ancient",
[UF_FAIL_ATTACK_IMMUNE] = "#dota_hud_error_target_attack_immune",
[UF_FAIL_BUILDING] = "#dota_hud_error_cant_cast_on_building",
[UF_FAIL_CONSIDERED_HERO] = "#dota_hud_error_cant_cast_on_considered_hero",
[UF_FAIL_COURIER] = "#dota_hud_error_cant_cast_on_courier",
[UF_FAIL_CREEP] = "#dota_hud_error_cant_cast_on_creep",
[UF_FAIL_CUSTOM] = "#dota_hud_error_cant_cast_on_other",
[UF_FAIL_DEAD] = "#dota_hud_error_unit_dead",
[UF_FAIL_DISABLE_HELP] = "#dota_hud_error_target_has_disable_help",
[UF_FAIL_DOMINATED] = "#dota_hud_error_cant_cast_on_dominated",
[UF_FAIL_ENEMY] = "#dota_hud_error_cant_cast_on_enemy" ,
[UF_FAIL_FRIENDLY] = "#dota_hud_error_cant_cast_on_ally",
[UF_FAIL_HERO] = "#dota_hud_error_cant_cast_on_hero",
[UF_FAIL_ILLUSION] = "#dota_hud_error_cant_cast_on_illusion",
[UF_FAIL_INVALID_LOCATION] = "#dota_hud_error_invalid_location",
[UF_FAIL_INVISIBLE] = "#dota_hud_error_target_invisible",
[UF_FAIL_INVULNERABLE] = "#dota_hud_error_target_invulnerable",
[UF_FAIL_IN_FOW] = "#dota_hud_error_cant_target_unexplored",
[UF_FAIL_MAGIC_IMMUNE_ALLY] = "#dota_hud_error_target_magic_immune",
[UF_FAIL_MAGIC_IMMUNE_ENEMY] = "#dota_hud_error_target_magic_immune",
[UF_FAIL_MELEE] = "#dota_hud_error_target_melee",
[UF_FAIL_NIGHTMARED] = "#dota_hud_error_target_nightmared",
[UF_FAIL_NOT_PLAYER_CONTROLLED] = "#dota_hud_error_cant_cast_not_player_controlled",
[UF_FAIL_OTHER] = "#dota_hud_error_cant_cast_on_other",
[UF_FAIL_OUT_OF_WORLD] = "#dota_hud_error_target_out_of_world",
[UF_FAIL_RANGED] = "#dota_hud_error_target_ranged",
[UF_FAIL_SUMMONED] = "#dota_hud_error_cant_cast_on_summoned",
}
local floor = math.floor
function CExtAbilityLinker:GetAbilityFlags()
return self._nAbilityFlags or 0
end
function CExtAbilityLinker:GetSkillRequirements()
return self._nAbilitySkill or 0
end
function CExtAbilityLinker:GetBehavior()
return self._nAbilityBehavior or self.BaseClass.GetBehavior(self)
end
function CExtAbilityLinker:GetAbilityTargetTeam()
return self._nAbilityTargetTeam or DOTA_UNIT_TARGET_TEAM_NONE
end
function CExtAbilityLinker:GetAbilityTargetType()
return self._nAbilityTargetType or DOTA_UNIT_TARGET_NONE
end
function CExtAbilityLinker:GetAbilityTargetFlags()
return self._nAbilityTargetFlags or DOTA_UNIT_TARGET_FLAG_NONE
end
function CExtAbilityLinker:GetCastAnimation()
if self._tAbilityCastAnimations then
local tAnimationTable = self._tAbilityCastAnimations[self:GetCaster():GetUnitName()]
if tAnimationTable then
self._nLastAnimationIndex = RandomInt(1, #tAnimationTable)
return GameActivity_t[tAnimationTable[self._nLastAnimationIndex]] or 0
end
end
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.GetCastAnimation
if hBaseFunction then
return hBaseFunction(self)
end
end
return 0
end
function CExtAbilityLinker:GetPlaybackRateOverride()
if self._tAbilityPlaybackRates then
local tPlaybackTable = self._tAbilityPlaybackRates[self:GetCaster():GetUnitName()]
if tPlaybackTable and self._nLastAnimationIndex then
return tPlaybackTable[self._nLastAnimationIndex]
end
end
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.GetPlaybackRateOverride
if hBaseFunction then
return hBaseFunction(self)
end
end
return 1.0
end
function CExtAbilityLinker:GetAOERadius()
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.GetAOERadius
if hBaseFunction then
return hBaseFunction(self)
end
end
return self._nAbilityAOERadius
end
function CExtAbilityLinker:GetCastRange(vLocation, hTarget)
local hEntity = self:GetCaster()
if not vLocation then vLocation = hEntity:GetAbsOrigin() end
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.GetCastRange
if hBaseFunction then
return hBaseFunction(self, vLocation, hTarget)
end
end
local nAbilityFlags = self:GetAbilityFlags()
if bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_USES_ATTACK_RANGE) then
return hEntity:GetAttackRange()
end
return self.BaseClass.GetCastRange(self, vLocation, hTarget)
end
function CExtAbilityLinker:GetChannelTime()
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.GetChannelTime
if hBaseFunction then
return hBaseFunction(self)
end
end
return self.BaseClass.GetChannelTime(self)
end
function CExtAbilityLinker:GetCooldown(nLevel)
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.GetCooldown
if hBaseFunction then
return hBaseFunction(self, nLevel)
end
end
return self.BaseClass.GetCooldown(self, nLevel)
end
function CExtAbilityLinker:GetBaseHealthCost(nLevel)
local hEntity = self:GetCaster()
local fHealthCost = 0
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions and tBaseFunctions.GetHealthCost then
fHealthCost = tBaseFunctions.GetHealthCost(self, nLevel)
elseif self._tAbilityCosts then
local tHealthCosts = self._tAbilityCosts.HealthCost
if not nLevel or nLevel == -1 then nLevel = self:GetLevel() end
fHealthCost = tHealthCosts[nLevel] or 0
end
local nAbilityFlags = self:GetAbilityFlags()
if bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_KEYWORD_ATTACK) then
local hAttackSource = hEntity:GetCurrentAttackSource()
if not hAttackSource then
hAttackSource = hEntity
end
fHealthCost = fHealthCost + hAttackSource:GetBasePropertyValue(IW_PROPERTY_ATTACK_HP_FLAT)
end
return fHealthCost
end
function CExtAbilityLinker:GetHealthCost(nLevel)
local hEntity = self:GetCaster()
return floor(self:GetBaseHealthCost(nLevel) * (1.0 + hEntity:GetPropertyValue(IW_PROPERTY_HP_COST_PCT)/100.0))
end
function CExtAbilityLinker:GetBaseManaCost(nLevel)
local hEntity = self:GetCaster()
local fManaCost = 0
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions and tBaseFunctions.GetManaCost then
fManaCost = tBaseFunctions.GetManaCost(self, nLevel)
elseif self._tAbilityCosts then
local tManaCosts = self._tAbilityCosts.ManaCost
if not nLevel or nLevel == -1 then nLevel = self:GetLevel() end
fManaCost = tManaCosts[nLevel] or 0
end
local nAbilityFlags = self:GetAbilityFlags()
if bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_KEYWORD_ATTACK) then
local hAttackSource = hEntity:GetCurrentAttackSource()
if not hAttackSource then
hAttackSource = hEntity
end
fManaCost = fManaCost + hAttackSource:GetBasePropertyValue(IW_PROPERTY_ATTACK_MP_FLAT)
end
return fManaCost
end
function CExtAbilityLinker:GetManaCost(nLevel)
local hEntity = self:GetCaster()
return floor(self:GetBaseManaCost(nLevel) * (1.0 + hEntity:GetPropertyValue(IW_PROPERTY_MP_COST_PCT)/100.0))
end
function CExtAbilityLinker:GetManaUpkeep()
local hEntity = self:GetCaster()
local fManaUpkeep = self._fManaUpkeep or 0
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions and tBaseFunctions.GetManaUpkeep then
fManaUpkeep = tBaseFunctions.GetManaUpkeep(self)
end
fManaUpkeep = fManaUpkeep * (1.0 + hEntity:GetPropertyValue(IW_PROPERTY_MP_COST_PCT)/100.0)
return fManaUpkeep
end
function CExtAbilityLinker:GetBaseStaminaCost(nLevel)
local hEntity = self:GetCaster()
local fStaminaCost = 0
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions and tBaseFunctions.GetStaminaCost then
fStaminaCost = tBaseFunctions.GetStaminaCost(self, nLevel)
elseif self._tAbilityCosts then
local tStaminaCosts = self._tAbilityCosts.StaminaCost
if not nLevel or nLevel == -1 then nLevel = self:GetLevel() end
fStaminaCost = tStaminaCosts[nLevel] or 0
end
local nAbilityFlags = self:GetAbilityFlags()
if bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_KEYWORD_ATTACK) then
local hAttackSource = hEntity:GetCurrentAttackSource()
if not hAttackSource then
hAttackSource = hEntity
end
fStaminaCost = fStaminaCost + hAttackSource:GetBasePropertyValue(IW_PROPERTY_ATTACK_SP_FLAT)
end
return fStaminaCost
end
function CExtAbilityLinker:GetStaminaCost(nLevel)
local hEntity = self:GetCaster()
return floor(self:GetBaseStaminaCost(nLevel) * (1.0 + hEntity:GetPropertyValue(IW_PROPERTY_SP_COST_PCT)/100.0))
end
function CExtAbilityLinker:GetStaminaUpkeep()
local hEntity = self:GetCaster()
local fStaminaUpkeep = self._fStaminaUpkeep or 0
local tBaseFunctions = self._tBaseFunctions
local nAbilityFlags = self:GetAbilityFlags()
if tBaseFunctions and tBaseFunctions.GetStaminaUpkeep then
fStaminaUpkeep = tBaseFunctions.GetStaminaUpkeep(self)
end
fStaminaUpkeep = fStaminaUpkeep * (1.0 + hEntity:GetPropertyValue(IW_PROPERTY_SP_COST_PCT)/100.0)
return fStaminaUpkeep
end
function CExtAbilityLinker:GetGoldCost(nLevel)
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions and tBaseFunctions.GetGoldCost then
return tBaseFunctions.GetGoldCost(self, nLevel)
elseif self._tAbilityCosts then
local tGoldCosts = self._tAbilityCosts.GoldCost
if not nLevel or nLevel == -1 then nLevel = self:GetLevel() end
local fBaseCost = tGoldCosts[nLevel] or 0
return fBaseCost
end
return 0
end
--[[function CExtAbilityLinker:GetIntrinsicModifierName()
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.GetIntrinsicModifierName
if hBaseFunction then
return hBaseFunction(self)
end
end
return self._szIntrinsicModifierName
end]]
function CExtAbilityLinker:CheckSkillRequirements(hEntity)
if IsServer() then
local nAbilitySkill = self:GetSkillRequirements()
for i=1,4 do
local nLevel = bit32.extract(nAbilitySkill, (i-1)*8, 3)
local nSkill = bit32.extract(nAbilitySkill, ((i-1)*8)+3, 5)
--TODO: Make this not hardcoded
if nSkill ~= 0 and nSkill <= 26 then
if hEntity:GetPropertyValue(IW_PROPERTY_SKILL_FIRE + nSkill - 1) < nLevel then
return false
end
end
end
end
return true
end
function CExtAbilityLinker:IsSkillRequired(nSkill)
if IsServer() and stIcewrackSkillValues[nSkill] then
local nAbilitySkill = self:GetSkillRequirements()
for i=1,4 do
if bit32.extract(nAbilitySkill, ((i-1)*8)+3, 5) == nSkill then
return true
end
end
end
return false
end
function CExtAbilityLinker:IsWeatherAbility()
return bit32.btest(self._nAbilityFlags, IW_ABILITY_FLAG_KEYWORD_WEATHER)
end
function CExtAbilityLinker:IsFullyCastable()
if IsServer() then
local hEntity = self:GetCaster()
local nAbilityFlags = self:GetAbilityFlags()
if not self:IsActivated() then
return false, "hidden"
elseif self:GetCooldownTimeRemaining() > 0 then
return false, "cd"
elseif self:GetHealthCost() > hEntity:GetHealth() then
return false, "hp"
elseif self:GetManaCost() > hEntity:GetMana() then
return false, "mp"
elseif hEntity.GetStamina and self:GetStaminaCost() > hEntity:GetStamina() then
return false, "sp"
elseif bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_ONLY_CAST_OUTSIDE) and not GameRules:GetMapInfo():IsOutside() then
return false, "outside"
elseif bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_ONLY_CAST_INSIDE) and not GameRules:GetMapInfo():IsInside() then
return false, "inside"
elseif bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_ONLY_CAST_AT_DAY) and not GameRules:IsDaytime() then
return false, "day"
elseif bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_ONLY_CAST_AT_NIGHT) and GameRules:IsDaytime() then
return false, "night"
elseif bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_ONLY_CAST_IN_COMBAT) and not GameRules:IsInCombat() then
return false, "combat"
elseif bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_ONLY_CAST_NO_COMBAT) and GameRules:IsInCombat() then
return false, "nocombat"
--TODO: Re-enable me after you've finished testing
--elseif not bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_CAN_CAST_IN_TOWN) and GameRules:GetMapInfo():IsTown() then
-- return false, "town"
end
return CDOTABaseAbility.IsFullyCastable(self), "other"
end
return true
end
function CExtAbilityLinker:EvaluateFlags(vLocation, hTarget)
if IsServer() then
local nAbilityFlags = self:GetAbilityFlags()
if hTarget then
if bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_CAN_TARGET_CORPSES) and not bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_ONLY_TARGET_CORPSES) then
if not hTarget:IsAlive() then
return false
end
elseif bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_ONLY_TARGET_CORPSES) and hTarget:IsAlive() then
return false
end
end
end
return true
end
function CExtAbilityLinker:GetCustomCastErrorFlags(vLocation, hTarget)
if IsServer() then
local nAbilityFlags = self:GetAbilityFlags()
if hTarget then
if not bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_CAN_TARGET_CORPSES) and not bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_ONLY_TARGET_CORPSES) then
if not hTarget:IsAlive() then
return "#iw_error_flag_no_corpse"
end
elseif bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_ONLY_TARGET_CORPSES) and hTarget:IsAlive() then
return "#iw_error_flag_only_corpse"
end
end
end
return
end
function CExtAbilityLinker:EvaluatePrereqs(vLocation, hTarget)
if IsServer() and IsInstanceOf(self, CDOTA_Ability_Lua) then
local hEntity = self:GetCaster()
for k,v in pairs(self._tPrereqCasterModifiers) do
if not hEntity:HasModifier(v) then return false end
end
local nAbilityBehavior = self:GetBehavior()
if bit32.btest(nAbilityBehavior, DOTA_ABILITY_BEHAVIOR_UNIT_TARGET) then
if hTarget then
for k,v in pairs(self._tPrereqTargetModifiers) do
if not hTarget:HasModifier(v) then return false end
end
end
end
for k,v in pairs(self._tPrereqScripts) do
if not v(self, vLocation, hTarget) then return false end
end
end
return true
end
function CExtAbilityLinker:CastFilterResult(vLocation, hTarget)
if not IsServer() then
local nAbilityIndex = self:entindex()
local nEntityIndex = self:GetCaster():entindex()
local tSpellbookNetTable = CustomNetTables:GetTableValue("spellbook", tostring(nEntityIndex))
local tEntityNetTable = CustomNetTables:GetTableValue("entities", tostring(nEntityIndex))
local fStaminaCost = 0
for k,v in pairs(tSpellbookNetTable.Spells) do
if v.entindex == nAbilityIndex then
fStaminaCost = v.stamina
break
end
end
self._bStaminaFailed = false
if tEntityNetTable.stamina < fStaminaCost then
self._bStaminaFailed = true
return UF_FAIL_CUSTOM
end
elseif IsServer() and not self._bCastFilterLock then
local hEntity = self:GetCaster()
if not self:IsFullyCastable() then
return UF_FAIL_CUSTOM
end
self._bCastFilterLock = true
CTimer(0.03, function() self._bCastFilterLock = nil end)
self._bSkillsFailed = false
if not self:CheckSkillRequirements(hEntity) then
self._bSkillsFailed = true
return UF_FAIL_CUSTOM
end
self._bFlagsFailed = false
if not self:EvaluateFlags(vLocation, hTarget) then
self._bFlagsFailed = true
return UF_FAIL_CUSTOM
end
self._bPrereqFailed = false
if not self:EvaluatePrereqs(vLocation, hTarget) then
self._bPrereqFailed = true
return UF_FAIL_CUSTOM
end
self._bEventFailed = false
if hEntity:TriggerExtendedEvent(IW_MODIFIER_EVENT_ON_CAST_FILTER) == UF_FAIL_CUSTOM then
self._bEventFailed = true
return UF_FAIL_CUSTOM
end
end
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local args = nil
local hBaseFunction = nil
if vLocation then
hBaseFunction = tBaseFunctions.CastFilterResultLocation
args = vLocation
elseif hTarget then
hBaseFunction = tBaseFunctions.CastFilterResultTarget
args = hTarget
else
hBaseFunction = tBaseFunctions.CastFilterResult
end
if hBaseFunction and type(hBaseFunction) == "function" then
return hBaseFunction(self, args) or UF_SUCCESS
end
end
return UF_SUCCESS
end
function CExtAbilityLinker:GetCustomCastError(vLocation, hTarget)
bResult, szMessage = self:IsFullyCastable()
if not bResult then
return "#iw_error_cast_" .. szMessage
end
if IsServer() then
if self._bSkillsFailed then return "#iw_error_insufficient_skill" end
if self._bFlagsFailed then return self:GetCustomCastErrorFlags(vLocation, hTarget) end
if self._bPrereqFailed then return "#iw_error_prereq_not_met" end
if self._bEventFailed then return self:GetCaster():TriggerExtendedEvent(IW_MODIFIER_EVENT_ON_CAST_ERROR) end
else
if self._bStaminaFailed then return "#iw_error_cast_sp" end
end
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local args = nil
local hBaseFunction = nil
if vLocation then
hBaseFunction = tBaseFunctions.GetCustomCastErrorLocation
args = vLocation
elseif hTarget then
hBaseFunction = tBaseFunctions.GetCustomCastErrorTarget
args = hTarget
else
hBaseFunction = tBaseFunctions.GetCustomCastError
end
if hBaseFunction and type(hBaseFunction) == "function" then
local szErrorString = hBaseFunction(self, args)
if szErrorString then
return szErrorString
end
end
end
return ""
end
function CExtAbilityLinker:CastFilterResultLocation(vLocation)
return self:CastFilterResult(vLocation, nil)
end
function CExtAbilityLinker:GetCustomCastErrorLocation(vLocation)
return self:GetCustomCastError(vLocation, nil)
end
function CExtAbilityLinker:CastFilterResultTarget(hTarget)
local hCaster = self:GetCaster()
local nResult = ExtUnitFilter(hCaster, hTarget, self:GetAbilityTargetTeam(), self:GetAbilityTargetType(), self:GetAbilityTargetFlags())
if nResult ~= UF_SUCCESS then
return nResult
end
return self:CastFilterResult(nil, hTarget)
end
function CExtAbilityLinker:GetCustomCastErrorTarget(hTarget)
local hCaster = self:GetCaster()
local nResult = ExtUnitFilter(hCaster, hTarget, self:GetAbilityTargetTeam(), self:GetAbilityTargetType(), self:GetAbilityTargetFlags())
if nResult ~= UF_SUCCESS then
return stUnitFilterCastErrors[nResult]
end
return self:GetCustomCastError(nil, hTarget)
end
function CExtAbilityLinker:OnAbilityLearned(hEntity)
self:RemoveModifiers(IW_MODIFIER_ON_LEARN)
self:ApplyModifiers(IW_MODIFIER_ON_LEARN, hEntity)
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.OnAbilityLearned
if hBaseFunction then
return hBaseFunction(self, hEntity)
end
end
end
function CExtAbilityLinker:OnAbilityPhaseStart()
local hEntity = self:GetCaster()
hEntity:TriggerExtendedEvent(IW_MODIFIER_EVENT_ON_PRE_ABILITY_CAST, self)
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.OnAbilityPhaseStart
if hBaseFunction then
return hBaseFunction(self)
end
end
return true
end
function CExtAbilityLinker:OnSpellStart()
local hEntity = self:GetCaster()
local fHealthCost = self:GetHealthCost()
if fHealthCost > 0 then
local fCurrentHealth = hEntity:GetHealth()
if fCurrentHealth > fHealthCost then
hEntity:ModifyHealth(fCurrentHealth - fHealthCost, hEntity, true, 0)
end
end
local fStaminaCost = self:GetStaminaCost()
if fStaminaCost > 0 and IsValidExtendedEntity(hEntity) then
local fCurrentStamina = hEntity:GetStamina()
if fCurrentStamina > fStaminaCost then
hEntity:SpendStamina(fStaminaCost)
end
end
self:ApplyModifiers(IW_MODIFIER_ON_USE)
local hCursorTarget = self:GetCursorTarget()
if hCursorTarget and hEntity:IsTargetEnemy(hCursorTarget) then
hEntity:SetAttacking(hCursorTarget)
end
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.OnSpellStart
if hBaseFunction then
hBaseFunction(self)
end
end
hEntity:TriggerExtendedEvent(IW_MODIFIER_EVENT_ON_POST_ABILITY_CAST, self)
end
function CExtAbilityLinker:OnChannelThink(fInterval)
local hEntity = self:GetCaster()
local fManaUpkeep = self:GetManaUpkeep() * fInterval
if fManaUpkeep > 0 then
local fEntityMana = hEntity:GetMana()
if fManaUpkeep >= fEntityMana then
hEntity:SetMana(0)
hEntity:Interrupt()
else
hEntity:SetMana(fEntityMana - fManaUpkeep)
end
end
local fStaminaUpkeep = self:GetStaminaUpkeep() * fInterval
if fStaminaUpkeep > 0 then
local fEntityStamina = hEntity:GetStamina()
if fStaminaUpkeep >= fEntityStamina then
hEntity:Interrupt()
else
hEntity:SpendStamina(fStaminaUpkeep)
end
end
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.OnChannelThink
if hBaseFunction then
hBaseFunction(self, fInterval)
end
end
end
function CExtAbilityLinker:OnChannelFinish(bInterrupted)
self:ApplyModifiers(IW_MODIFIER_ON_CHANNEL_END)
if not bInterrupted then self:ApplyModifiers(IW_MODIFIER_ON_CHANNEL_SUCCESS) end
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.OnChannelFinish
if hBaseFunction then
hBaseFunction(self)
end
end
end
local function OnExtAbilityUpkeepThink(self)
local hEntity = self:GetCaster()
if self:GetToggleState() then
local fManaUpkeep = self:GetManaUpkeep()/10.0
if fManaUpkeep > 0 then
local fEntityMana = hEntity:GetMana()
if fManaUpkeep >= fEntityMana then
hEntity:SetMana(0)
self:ToggleAbility()
return
else
hEntity:SetMana(fEntityMana - fManaUpkeep)
end
end
local fStaminaUpkeep = self:GetStaminaUpkeep()/10.0
if fStaminaUpkeep > 0 then
local fEntityStamina = hEntity:GetStamina()
hEntity:SpendStamina(fStaminaUpkeep)
if fStaminaUpkeep >= fEntityStamina then
self:ToggleAbility()
return
end
end
return 0.1
end
end
function CExtAbilityLinker:OnToggle()
if self:GetToggleState() then
self:ApplyModifiers(IW_MODIFIER_ON_TOGGLE)
if self:GetManaUpkeep() > 0 or self:GetStaminaUpkeep() > 0 then
CTimer(0.03, OnExtAbilityUpkeepThink, self)
end
self:EndCooldown()
else
self:RemoveModifiers(IW_MODIFIER_ON_TOGGLE)
local fCooldownTime = self:GetCooldown(self:GetLevel())
if fCooldownTime > 0 then
self:StartCooldown(fCooldownTime)
end
end
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.OnToggle
if hBaseFunction then
hBaseFunction(self)
end
end
end
function CExtAbilityLinker:OnToggleAutoCast()
--Unlike OnToggle(), OnToggleAutoCast() is called when the command is issued, not when the ability changes toggle states
if not self:GetAutoCastState() then
self:ApplyModifiers(IW_MODIFIER_ON_TOGGLE)
if self:GetManaUpkeep() > 0 or self:GetStaminaUpkeep() > 0 then
CTimer(0.03, OnExtAbilityUpkeepThink, self)
end
else
self:RemoveModifiers(IW_MODIFIER_ON_TOGGLE)
end
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.OnToggleAutoCast
if hBaseFunction then
hBaseFunction(self)
end
end
end
local function OnOwnerDiedToggleThink(self)
if self:GetToggleState() then
self:ToggleAbility()
return 0.03
elseif self:GetAutoCastState() then
self:ToggleAutoCast()
return 0.03
end
end
function CExtAbilityLinker:OnOwnerDied()
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.OnOwnerDied
if hBaseFunction then
hBaseFunction(self)
end
end
local nAbilityFlags = self:GetAbilityFlags()
if bit32.btest(nAbilityFlags, IW_ABILITY_FLAG_TOGGLE_OFF_ON_DEATH) then
CTimer(0.03, OnOwnerDiedToggleThink, self)
end
end
function CExtAbilityLinker:OnRefreshEntity()
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.OnRefreshEntity
if hBaseFunction then
hBaseFunction(self)
end
end
end
function CExtAbilityLinker:OnAbilityBind(hEntity)
if self:CheckSkillRequirements(hEntity) then
self:ApplyModifiers(IW_MODIFIER_ON_ACQUIRE, hEntity)
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.OnAbilityBind
if hBaseFunction then
hBaseFunction(self, hEntity)
end
end
end
end
function CExtAbilityLinker:OnAbilityUnbind(hEntity)
if self:GetToggleState() then
self:ToggleAbility()
elseif self:GetAutoCastState() then
self:ToggleAutoCast()
end
self:RemoveModifiers(IW_MODIFIER_ON_ACQUIRE, hEntity)
local tBaseFunctions = self._tBaseFunctions
if tBaseFunctions then
local hBaseFunction = tBaseFunctions.OnAbilityUnbind
if hBaseFunction then
hBaseFunction(self, hEntity)
end
end
end
function CExtAbilityLinker:ApplyModifiers(hEntity, nTrigger)
--This function should be overriden by the implementing classes (ext_ability, ext_item)
LogMessage("Tried to access virtual function CExtAbilityLinker:ApplyModifiers()", LOG_SEVERITY_WARNING)
end
function CExtAbilityLinker:RemoveModifiers(nTrigger)
--This function should be overriden by the implementing classes (ext_ability, ext_item)
LogMessage("Tried to access virtual function CExtAbilityLinker:RemoveModifiers()", LOG_SEVERITY_WARNING)
end
function CExtAbilityLinker:LinkExtAbility(szAbilityName, tBaseTemplate, tExtTemplate)
local tContext = getfenv()
local szScriptFilename = tExtTemplate.ScriptFile
if szScriptFilename then
szScriptFilename = string.gsub(szScriptFilename, "\\", "/")
szScriptFilename = string.gsub(szScriptFilename, "scripts/vscripts/", "")
szScriptFilename = string.gsub(szScriptFilename, ".lua", "")
local tSandbox = setmetatable({}, { __index = tContext })
setfenv(1, tSandbox)
dofile(szScriptFilename)
tContext[szAbilityName] = tSandbox[szAbilityName]
setfenv(1, tContext)
end
if not tContext[szAbilityName] then tContext[szAbilityName] = class({}) end
local hExtAbility = tContext[szAbilityName]
for k,v in pairs(tBaseTemplate.Modifiers or {}) do
LinkLuaModifier(k, "link_ext_modifier", LUA_MODIFIER_MOTION_NONE)
end
hExtAbility._tBaseFunctions = {}
for k,v in pairs(hExtAbility) do
if type(hExtAbility[k]) == "function" then
hExtAbility._tBaseFunctions[k] = hExtAbility[k]
end
end
ExtendIndexTable(hExtAbility, CExtAbilityLinker)
hExtAbility._tPropertyList = {}
for k,v in pairs(tExtTemplate.Properties or {}) do
if stIcewrackPropertyEnum[k] then
if type(v) == "number" then
hExtAbility._tPropertyList[k] = v
else
LogMessage("Unsupported type \"" .. type(v) .. "\" for property \"" .. k .. "\" in ability \"" .. szAbilityName .. "\"", LOG_SEVERITY_WARNING)
end
else
LogMessage("Unknown property \"" .. k .. "\" in ability \"" .. szAbilityName .. "\"", LOG_SEVERITY_WARNING)
end
end
--hExtAbility._szIntrinsicModifierName = tExtTemplate.IntrinsicModifier
hExtAbility._nAbilitySkill = tExtTemplate.AbilitySkill or 0
--hExtAbility._nAbilityBehavior = GetFlagValue(tBaseTemplate.AbilityBehavior, DOTA_ABILITY_BEHAVIOR)
hExtAbility._nAbilityTargetTeam = DOTA_UNIT_TARGET_TEAM[tBaseTemplate.AbilityUnitTargetTeam]
hExtAbility._nAbilityTargetType = GetFlagValue(tBaseTemplate.AbilityUnitTargetType, DOTA_UNIT_TARGET_TYPE)
hExtAbility._nAbilityTargetFlags = GetFlagValue(tBaseTemplate.AbilityUnitTargetFlags, DOTA_UNIT_TARGET_FLAGS)
hExtAbility._nAbilityFlags = GetFlagValue(tExtTemplate.AbilityFlags, stExtAbilityFlagEnum)
hExtAbility._nAbilityAOERadius = tonumber(tBaseTemplate.AbilityAOERadius) or 0
hExtAbility._fManaUpkeep = tExtTemplate.ManaUpkeep or 0
hExtAbility._fStaminaUpkeep = tExtTemplate.StaminaUpkeep or 0
hExtAbility._tAbilityCosts =
{
HealthCost = {},
ManaCost = {},
StaminaCost = {},
GoldCost = {}
}
for k,v in pairs(hExtAbility._tAbilityCosts) do
local szCostValue = tExtTemplate[k]
if szCostValue then
for k2 in string.gmatch(tostring(szCostValue), "[-+]*[%d]+[.]*[%d]*") do
local fValue = tonumber(k2)
if fValue then
table.insert(v, fValue)
end
end
end
end
hExtAbility._tAbilityCastAnimations = {}
hExtAbility._tAbilityPlaybackRates = {}
if type(tExtTemplate.AbilityCastAnimation) == "table" then
for k,v in pairs(tExtTemplate.AbilityCastAnimation) do
hExtAbility._tAbilityCastAnimations[k] = {}
hExtAbility._tAbilityPlaybackRates[k] = {}
for k2,v2 in pairs(v) do
table.insert(hExtAbility._tAbilityCastAnimations[k], k2)
table.insert(hExtAbility._tAbilityPlaybackRates[k], v2)
end
end
end
if IsServer() then
local tExtAbilityPrereqs = tExtTemplate.Prequisites or {}
hExtAbility._tPrereqCasterModifiers = tExtAbilityPrereqs.CasterModifiers or {}
hExtAbility._tPrereqTargetModifiers = tExtAbilityPrereqs.TargetModifiers or {}
--TODO: Test this implementation
hExtAbility._tPrereqScripts = {}
local tPrereqScripts = tExtAbilityPrereqs.Scripts or {}
for k,v in pairs(tPrereqScripts) do
if v and type(v) == "table" then
local szScriptFilename = v.Filename
local szScriptFunction = v.Function
if szScriptFilename and szScriptFunction then
if not pcall(require(szScriptFilename)) then
error("[CExtAbility]: Failed to load script file " .. szScriptFilename)
end
local hScriptFunction = _G[szScriptFunction]
if hScriptFunction and type(hScriptFunction) == "function" then
table.insert(hAbility._tPrereqScripts, hScriptFunction)
end
end
end
end
end
return hExtAbility
end
end | mit |
aqasaeed/hesamsharr | plugins/banhammer.lua | 10 | 12148 |
local function pre_process(msg)
-- SERVICE MESSAGE
if msg.action and msg.action.type then
local action = msg.action.type
-- Check if banned user joins chat by link
if action == 'chat_add_user_link' then
local user_id = msg.from.id
print('Checking invited user '..user_id)
local banned = is_banned(user_id, msg.to.id)
if banned or is_gbanned(user_id) then -- Check it with redis
print('User is banned!')
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] is banned and kicked ! ")-- Save to logs
kick_user(user_id, msg.to.id)
end
end
-- Check if banned user joins chat
if action == 'chat_add_user' then
local user_id = msg.action.user.id
print('Checking invited user '..user_id)
local banned = is_banned(user_id, msg.to.id)
if banned or is_gbanned(user_id) then -- Check it with redis
print('User is banned!')
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] added a banned user >"..msg.action.user.id)-- Save to logs
kick_user(user_id, msg.to.id)
local banhash = 'addedbanuser:'..msg.to.id..':'..msg.from.id
redis:incr(banhash)
local banhash = 'addedbanuser:'..msg.to.id..':'..msg.from.id
local banaddredis = redis:get(banhash)
if banaddredis then
if tonumber(banaddredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)-- Kick user who adds ban ppl more than 3 times
end
if tonumber(banaddredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)-- Kick user who adds ban ppl more than 7 times
local banhash = 'addedbanuser:'..msg.to.id..':'..msg.from.id
redis:set(banhash, 0)-- Reset the Counter
end
end
end
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['settings'] then
if data[tostring(msg.to.id)]['settings']['lock_bots'] then
bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots']
end
end
end
if msg.action.user.username ~= nil then
if string.sub(msg.action.user.username:lower(), -3) == 'bot' and not is_momod(msg) and bots_protection == "yes" then --- Will kick bots added by normal users
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] added a bot > @".. msg.action.user.username)-- Save to logs
kick_user(msg.action.user.id, msg.to.id)
end
end
end
-- No further checks
return msg
end
-- banned user is talking !
if msg.to.type == 'chat' then
local data = load_data(_config.moderation.data)
local group = msg.to.id
local texttext = 'groups'
--if not data[tostring(texttext)][tostring(msg.to.id)] and not is_realm(msg) then -- Check if this group is one of my groups or not
--chat_del_user('chat#id'..msg.to.id,'user#id'..our_id,ok_cb,false)
--return
--end
local user_id = msg.from.id
local chat_id = msg.to.id
local banned = is_banned(user_id, chat_id)
if banned or is_gbanned(user_id) then -- Check it with redis
print('Banned user talking!')
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] banned user is talking !")-- Save to logs
kick_user(user_id, chat_id)
msg.text = ''
end
end
return msg
end
local function username_id(cb_extra, success, result)
local get_cmd = cb_extra.get_cmd
local receiver = cb_extra.receiver
local chat_id = cb_extra.chat_id
local member = cb_extra.member
local sender = sender
local text = ''
for k,v in pairs(result.members) do
vusername = v.username
if vusername == member then
member_username = member
member_id = v.id
if member_id == our_id then return false end
if get_cmd == 'kick' then
if sender==member then
return send_large_msg(receiver, "You can't kick yourself")
end
if is_momod2(member_id, chat_id) then
return send_large_msg(receiver, "You can't kick mods/owner/admins")
end
return kick_user(member_id, chat_id)
elseif get_cmd == 'ban' then
if is_momod2(member_id, chat_id) then
return send_large_msg(receiver, "You can't ban mods/owner/admins")
end
send_large_msg(receiver, 'User @'..member..' ['..member_id..'] banned')
return ban_user(member_id, chat_id)
elseif get_cmd == 'unban' then
send_large_msg(receiver, 'User @'..member..' ['..member_id..'] unbanned')
local hash = 'banned:'..chat_id
redis:srem(hash, member_id)
return 'User '..user_id..' unbanned'
elseif get_cmd == 'banall' then
send_large_msg(receiver, 'User @'..member..' ['..member_id..'] globally banned')
return banall_user(member_id, chat_id)
elseif get_cmd == 'unbanall' then
send_large_msg(receiver, 'User @'..member..' ['..member_id..'] unbanned')
return unbanall_user(member_id, chat_id)
end
end
end
return send_large_msg(receiver, text)
end
local function run(msg, matches)
if matches[1]:lower() == 'id' then
if msg.to.type == "user" then
return "Bot ID: "..msg.to.id.. "\n\nYour ID: "..msg.from.id
end
if type(msg.reply_id) ~= "nil" then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] used /id ")
id = get_message(msg.reply_id,get_message_callback_id, false)
elseif matches[1]:lower() == 'id' then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] used /id ")
return "Group ID for " ..string.gsub(msg.to.print_name, "_", " ").. ":\n\n"..msg.to.id
end
end
local receiver = get_receiver(msg)
if matches[1]:lower() == 'kickme' then-- /kickme
if msg.to.type == 'chat' then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] left using kickme ")-- Save to logs
chat_del_user("chat#id"..msg.to.id, "user#id"..msg.from.id, ok_cb, false)
end
end
if not is_momod(msg) then -- Ignore normal users
return nil
end
if matches[1]:lower() == "banlist" then -- Ban list !
local chat_id = msg.to.id
if matches[2] and is_admin(msg) then
chat_id = matches[2]
end
return ban_list(chat_id)
end
if matches[1]:lower() == 'ban' then-- /ban
if type(msg.reply_id)~="nil" and is_momod(msg) then
if is_admin(msg) then
local msgr = get_message(msg.reply_id,ban_by_reply_admins, false)
else
msgr = get_message(msg.reply_id,ban_by_reply, false)
end
end
if msg.to.type == 'chat' then
local user_id = matches[2]
local chat_id = msg.to.id
if string.match(matches[2], '^%d+$') then
if tonumber(matches[2]) == tonumber(our_id) then
return
end
if not is_admin(msg) and is_momod2(tonumber(matches[2]), msg.to.id) then
return "you can't ban mods/owner/admins"
end
if tonumber(matches[2]) == tonumber(msg.from.id) then
return "You can't ban your self !"
end
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] baned user ".. matches[2])
ban_user(user_id, chat_id)
else
local member = string.gsub(matches[2], '@', '')
local get_cmd = 'ban'
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] baned user ".. matches[2])
chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member})
end
return
end
end
if matches[1]:lower() == 'unban' then -- /unban
if type(msg.reply_id)~="nil" and is_momod(msg) then
local msgr = get_message(msg.reply_id,unban_by_reply, false)
end
if msg.to.type == 'chat' then
local user_id = matches[2]
local chat_id = msg.to.id
local targetuser = matches[2]
if string.match(targetuser, '^%d+$') then
local user_id = targetuser
local hash = 'banned:'..chat_id
redis:srem(hash, user_id)
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] unbaned user ".. matches[2])
return 'User '..user_id..' unbanned'
else
local member = string.gsub(matches[2], '@', '')
local get_cmd = 'unban'
chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member})
end
end
end
if matches[1]:lower() == 'kick' then
if type(msg.reply_id)~="nil" and is_momod(msg) then
if is_admin(msg) then
local msgr = get_message(msg.reply_id,Kick_by_reply_admins, false)
else
msgr = get_message(msg.reply_id,Kick_by_reply, false)
end
end
if msg.to.type == 'chat' then
local user_id = matches[2]
local chat_id = msg.to.id
if string.match(matches[2], '^%d+$') then
if tonumber(matches[2]) == tonumber(our_id) then
return
end
if not is_admin(msg) and is_momod2(matches[2], msg.to.id) then
return "you can't kick mods/owner/admins"
end
if tonumber(matches[2]) == tonumber(msg.from.id) then
return "You can't kick your self !"
end
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] kicked user ".. matches[2])
kick_user(user_id, chat_id)
else
local member = string.gsub(matches[2], '@', '')
local get_cmd = 'kick'
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] kicked user ".. matches[2])
chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member, sender=msg.from.id})
end
else
return 'This isn\'t a chat group'
end
end
if not is_admin(msg) then
return
end
if matches[1]:lower() == 'banall' then -- Global ban
if type(msg.reply_id) ~="nil" and is_admin(msg) then
return get_message(msg.reply_id,banall_by_reply, false)
end
local user_id = matches[2]
local chat_id = msg.to.id
if msg.to.type == 'chat' then
local targetuser = matches[2]
if string.match(targetuser, '^%d+$') then
if tonumber(matches[2]) == tonumber(our_id) then
return false
end
banall_user(targetuser)
return 'User ['..user_id..' ] globally banned'
else
local member = string.gsub(matches[2], '@', '')
local get_cmd = 'banall'
chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member})
end
end
end
if matches[1]:lower() == 'unbanall' then -- Global unban
local user_id = matches[2]
local chat_id = msg.to.id
if msg.to.type == 'chat' then
if string.match(matches[2], '^%d+$') then
if tonumber(matches[2]) == tonumber(our_id) then
return false
end
unbanall_user(user_id)
return 'User ['..user_id..' ] removed from global ban list'
else
local member = string.gsub(matches[2], '@', '')
local get_cmd = 'unbanall'
chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member})
end
end
end
if matches[1]:lower() == "gbanlist" then -- Global ban list
return banall_list()
end
end
return {
patterns = {
"^[!/]([Bb]anall) (.*)$",
"^[!/]([Bb]anall)$",
"^[!/]([Bb]anlist) (.*)$",
"^[!/]([Bb]anlist)$",
"^[!/]([Gg]banlist)$",
"^[!/]([Bb]an) (.*)$",
"^[!/]([Kk]ick)$",
"^[!/]([Uu]nban) (.*)$",
"^[!/]([Uu]nbanall) (.*)$",
"^[!/]([Uu]nbanall)$",
"^[!/]([Kk]ick) (.*)$",
"^[!/]([Kk]ickme)$",
"^[!/]([Bb]an)$",
"^[!/]([Uu]nban)$",
"^[!/]([Ii]d)$",
"^!!tgservice (.+)$",
},
run = run,
pre_process = pre_process
}
| gpl-2.0 |
aircross/OpenWrt-Firefly-LuCI | applications/luci-statistics/luasrc/model/cbi/luci_statistics/dns.lua | 78 | 1344 | --[[
Luci configuration model for statistics - collectd dns plugin configuration
(c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
]]--
require("luci.sys")
m = Map("luci_statistics",
translate("DNS Plugin Configuration"),
translate(
"The dns plugin collects detailled statistics about dns " ..
"related traffic on selected interfaces."
))
-- collectd_dns config section
s = m:section( NamedSection, "collectd_dns", "luci_statistics" )
-- collectd_dns.enable
enable = s:option( Flag, "enable", translate("Enable this plugin") )
enable.default = 0
-- collectd_dns.interfaces (Interface)
interfaces = s:option( MultiValue, "Interfaces", translate("Monitor interfaces") )
interfaces.widget = "select"
interfaces.size = 5
interfaces:depends( "enable", 1 )
interfaces:value("any")
for k, v in pairs(luci.sys.net.devices()) do
interfaces:value(v)
end
-- collectd_dns.ignoresources (IgnoreSource)
ignoresources = s:option( Value, "IgnoreSources", translate("Ignore source addresses") )
ignoresources.default = "127.0.0.1"
ignoresources:depends( "enable", 1 )
return m
| apache-2.0 |
Tatwi/legend-of-hondo | MMOCoreORB/bin/scripts/mobile/endor/gnarled_donkuwah_spiritmaster.lua | 1 | 1095 | gnarled_donkuwah_spiritmaster = Creature:new {
objectName = "@mob/creature_names:gnarled_donkuwah_spiritmaster",
randomNameType = NAME_GENERIC,
randomNameTag = true,
socialGroup = "donkuwah_tribe",
faction = "donkuwah_tribe",
level = 35,
chanceHit = 0.41,
damageMin = 320,
damageMax = 350,
baseXp = 3551,
baseHAM = 9000,
baseHAMmax = 11000,
armor = 0,
resists = {0,40,0,0,0,-1,0,-1,-1},
meatType = "",
meatAmount = 0,
hideType = "",
hideAmount = 0,
boneType = "",
boneAmount = 0,
milk = 0,
tamingChance = 0,
ferocity = 0,
pvpBitmask = AGGRESSIVE + ATTACKABLE + ENEMY,
creatureBitmask = PACK + KILLER,
optionsBitmask = AIENABLED,
diet = HERBIVORE,
templates = {
"object/mobile/dulok_male.iff",
"object/mobile/dulok_female.iff"},
lootGroups = {
{
groups = {
{group = "donkuwah_common", chance = 10000000}
},
lootChance = 1700000
}
},
weapons = {"donkuwah_weapons"},
conversationTemplate = "",
attacks = merge(fencermaster,brawlermaster)
}
CreatureTemplates:addCreatureTemplate(gnarled_donkuwah_spiritmaster, "gnarled_donkuwah_spiritmaster")
| agpl-3.0 |
Tatwi/legend-of-hondo | MMOCoreORB/bin/scripts/object/tangible/medicine/crafted/medpack_enhance_action_a.lua | 2 | 3072 | --Copyright (C) 2010 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
object_tangible_medicine_crafted_medpack_enhance_action_a = object_tangible_medicine_crafted_shared_medpack_enhance_action_a:new {
gameObjectType = 8238,
templateType = ENHANCEPACK,
useCount = 10,
medicineUse = 5,
effectiveness = 100,
duration = 1800,
attribute = 3,
numberExperimentalProperties = {1, 1, 2, 2, 2, 2, 1},
experimentalProperties = {"XX", "XX", "OQ", "PE", "OQ", "UT", "DR", "OQ", "OQ", "PE", "XX"},
experimentalWeights = {1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1},
experimentalGroupTitles = {"null", "null", "exp_effectiveness", "exp_charges", "exp_effectiveness", "expEaseOfUse", "null"},
experimentalSubGroupTitles = {"null", "null", "power", "charges", "duration", "skillmodmin", "hitpoints"},
experimentalMin = {0, 0, 10, 5, 1200, 60, 1000},
experimentalMax = {0, 0, 100, 10, 3600, 50, 1000},
experimentalPrecision = {0, 0, 0, 0, 0, 0, 0},
experimentalCombineType = {0, 0, 1, 1, 1, 1, 4},
}
ObjectTemplates:addTemplate(object_tangible_medicine_crafted_medpack_enhance_action_a, "object/tangible/medicine/crafted/medpack_enhance_action_a.iff")
| agpl-3.0 |
motoschifo/mame | plugins/inputmacro/init.lua | 12 | 3651 | -- license:BSD-3-Clause
-- copyright-holders:Vas Crabb
local exports = {
name = 'inputmacro',
version = '0.0.1',
description = 'Input macro plugin',
license = 'BSD-3-Clause',
author = { name = 'Vas Crabb' } }
local inputmacro = exports
function inputmacro.startplugin()
--[[
Configuration data:
* name: display name (string)
* binding: activation sequence (input sequence)
* bindingcfg: activation sequence configuration (string)
* earlycancel: cancel or complete on release (Boolean)
* loop: -1 = release, 0 = prolong, >0 = loop to step on hold (integer)
* steps:
* inputs:
* port: port tag (string)
* mask: port field mask (integer)
* type: port field type (integer)
* field: field (I/O port field)
* delay: delay before activating inputs in frames (integer)
* duration: duration to activate inputs for (integer)
Live state:
* step: current step (integer or nil)
* frame: frame of current step, starting at 1 (integer)
]]
local macros = { }
local active_inputs = { }
local menu
local input
local function activate_inputs(inputs)
for index, input in ipairs(inputs) do
if input.field then
active_inputs[string.format('%s.%d.%d', input.port, input.mask, input.type)] = input.field
end
end
end
local function process_frame()
local previous_inputs = active_inputs
active_inputs = { }
for index, macro in ipairs(macros) do
if macro.step then
if macro.earlycancel and (not input:seq_pressed(macro.binding)) then
-- stop immediately on release if early cancel set
macro.step = nil
else
-- advance frame
macro.frame = macro.frame + 1
local step = macro.steps[macro.step]
if macro.frame > (step.delay + step.duration) then
if macro.step < #macro.steps then
-- not the last step, advance step
macro.step = macro.step + 1
macro.frame = 1
step = macro.steps[macro.step]
elseif not input:seq_pressed(macro.binding) then
-- input released and macro completed
macro.step = nil
step = nil
elseif macro.loop > 0 then
-- loop to step
macro.step = macro.loop
macro.frame = 1
elseif macro.loop < 0 then
-- release if held
step = nil
end
end
if step and (macro.frame > step.delay) then
activate_inputs(step.inputs)
end
end
elseif input:seq_pressed(macro.binding) then
-- initial activation
macro.step = 1
macro.frame = 1
local step = macro.steps[1]
if step.delay == 0 then
-- no delay on first step, activate inputs
activate_inputs(step.inputs)
end
end
end
for key, field in pairs(active_inputs) do
field:set_value(1)
end
for key, field in pairs(previous_inputs) do
if not active_inputs[key] then
field:set_value(0)
end
end
end
local function start()
input = manager.machine.input
local persister = require('inputmacro/inputmacro_persist')
macros = persister.load_settings()
end
local function stop()
local persister = require('inputmacro/inputmacro_persist')
persister:save_settings(macros)
macros = { }
active_inputs = { }
menu = nil
end
local function menu_callback(index, event)
return menu:handle_event(index, event)
end
local function menu_populate()
if not menu then
menu = require('inputmacro/inputmacro_menu')
menu:init(macros)
end
return menu:populate()
end
emu.register_frame(process_frame)
emu.register_prestart(start)
emu.register_stop(stop)
emu.register_menu(menu_callback, menu_populate, _p('plugin-inputmacro', 'Input Macros'))
end
return exports
| gpl-2.0 |
Tatwi/legend-of-hondo | MMOCoreORB/bin/scripts/object/static/particle/particle_test_20.lua | 3 | 2216 | --Copyright (C) 2010 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
object_static_particle_particle_test_20 = object_static_particle_shared_particle_test_20:new {
}
ObjectTemplates:addTemplate(object_static_particle_particle_test_20, "object/static/particle/particle_test_20.iff")
| agpl-3.0 |
Tatwi/legend-of-hondo | MMOCoreORB/bin/scripts/mobile/rori/garyns_thief.lua | 1 | 1251 | garyns_thief = Creature:new {
objectName = "@mob/creature_names:garyn_thief",
randomNameType = NAME_GENERIC,
randomNameTag = true,
socialGroup = "garyn",
faction = "garyn",
level = 15,
chanceHit = 0.31,
damageMin = 160,
damageMax = 170,
baseXp = 831,
baseHAM = 2400,
baseHAMmax = 3000,
armor = 0,
resists = {0,0,0,0,0,0,0,0,-1},
meatType = "",
meatAmount = 0,
hideType = "",
hideAmount = 0,
boneType = "",
boneAmount = 0,
milk = 0,
tamingChance = 0,
ferocity = 0,
pvpBitmask = AGGRESSIVE + ATTACKABLE + ENEMY,
creatureBitmask = PACK + STALKER,
optionsBitmask = AIENABLED,
diet = HERBIVORE,
templates = {
"object/mobile/dressed_garyn_theif_zabrak_male_01.iff",
"object/mobile/dressed_garyn_theif_zabrak_female_01.iff"},
lootGroups = {
{
groups = {
{group = "junk", chance = 2000000},
{group = "wearables_common", chance = 2000000},
{group = "pistols", chance = 2000000},
{group = "tailor_components", chance = 2000000},
{group = "loot_kit_parts", chance = 2000000}
}
}
},
weapons = {"pirate_weapons_light"},
conversationTemplate = "",
reactionStf = "@npc_reaction/slang",
attacks = merge(brawlermid,marksmanmid)
}
CreatureTemplates:addCreatureTemplate(garyns_thief, "garyns_thief")
| agpl-3.0 |
Tatwi/legend-of-hondo | MMOCoreORB/bin/scripts/object/intangible/ship/tieadvanced_pcd.lua | 3 | 2212 | --Copyright (C) 2010 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
object_intangible_ship_tieadvanced_pcd = object_intangible_ship_shared_tieadvanced_pcd:new {
}
ObjectTemplates:addTemplate(object_intangible_ship_tieadvanced_pcd, "object/intangible/ship/tieadvanced_pcd.iff")
| agpl-3.0 |
Tatwi/legend-of-hondo | MMOCoreORB/bin/scripts/object/intangible/pet/nuna_hue.lua | 3 | 2180 | --Copyright (C) 2010 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
object_intangible_pet_nuna_hue = object_intangible_pet_shared_nuna_hue:new {
}
ObjectTemplates:addTemplate(object_intangible_pet_nuna_hue, "object/intangible/pet/nuna_hue.iff")
| agpl-3.0 |
lo7err/khodemuni | plugins/setrank.lua | 40 | 8897 | do
local Dev = 122774063 --put your id here(BOT OWNER ID)
local function setrank(msg, name, value) -- setrank function
local hash = nil
if msg.to.type == 'chat' then
hash = 'rank:'..msg.to.id..':variables'
end
if hash then
redis:hset(hash, name, value)
return send_msg('chat#id'..msg.to.id, 'مقام کاربر ('..name..') به '..value..' تغییر داده شد ', ok_cb, true)
end
end
local function res_user_callback(extra, success, result) -- /info <username> function
if success == 1 then
if result.username then
Username = '@'..result.username
else
Username = 'ندارد'
end
local text = 'نام کامل : '..(result.first_name or '')..' '..(result.last_name or '')..'\n'
..'یوزر: '..Username..'\n'
..'ایدی کاربری : '..result.id..'\n\n'
local hash = 'rank:'..extra.chat2..':variables'
local value = redis:hget(hash, result.id)
if not value then
if result.id == tonumber(Dev) then
text = text..'مقام : مدیر کل ربات (Executive Admin) \n\n'
elseif is_admin2(result.id) then
text = text..'مقام : ادمین ربات (Admin) \n\n'
elseif is_owner2(result.id, extra.chat2) then
text = text..'مقام : مدیر کل گروه (Owner) \n\n'
elseif is_momod2(result.id, extra.chat2) then
text = text..'مقام : مدیر گروه (Moderator) \n\n'
else
text = text..'مقام : کاربر (Member) \n\n'
end
else
text = text..'مقام : '..value..'\n\n'
end
local uhash = 'user:'..result.id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..result.id..':'..extra.chat2
user_info_msgs = tonumber(redis:get(um_hash) or 0)
text = text..'تعداد پیام های فرستاده شده : '..user_info_msgs..'\n\n'
text = text..'SBSS Team'
send_msg(extra.receiver, text, ok_cb, true)
else
send_msg(extra.receiver, extra.user..' نام کاربری مورد نظر یافت نشد.', ok_cb, false)
end
end
local function action_by_id(extra, success, result) -- /info <ID> function
if success == 1 then
if result.username then
Username = '@'..result.username
else
Username = 'ندارد'
end
local text = 'نام کامل : '..(result.first_name or '')..' '..(result.last_name or '')..'\n'
..'یوزر: '..Username..'\n'
..'ایدی کاربری : '..result.id..'\n\n'
local hash = 'rank:'..extra.chat2..':variables'
local value = redis:hget(hash, result.id)
if not value then
if result.id == tonumber(Dev) then
text = text..'مقام : مدیر کل ربات (Executive Admin) \n\n'
elseif is_admin2(result.id) then
text = text..'مقام : ادمین ربات (Admin) \n\n'
elseif is_owner2(result.id, extra.chat2) then
text = text..'مقام : مدیر کل گروه (Owner) \n\n'
elseif is_momod2(result.id, extra.chat2) then
text = text..'مقام : مدیر گروه (Moderator) \n\n'
else
text = text..'مقام : کاربر (Member) \n\n'
end
else
text = text..'مقام : '..value..'\n\n'
end
local uhash = 'user:'..result.id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..result.id..':'..extra.chat2
user_info_msgs = tonumber(redis:get(um_hash) or 0)
text = text..'تعداد پیام های فرستاده شده : '..user_info_msgs..'\n\n'
text = text..'SBSS Team'
send_msg(extra.receiver, text, ok_cb, true)
else
send_msg(extra.receiver, 'ایدی شخص مورد نظر در سیستم ثبت نشده است.\nاز دستور زیر استفاده کنید\n/info @username', ok_cb, false)
end
end
local function action_by_reply(extra, success, result)-- (reply) /info function
if result.from.username then
Username = '@'..result.from.username
else
Username = 'ندارد'
end
local text = 'نام کامل : '..(result.from.first_name or '')..' '..(result.from.last_name or '')..'\n'
..'یوزر: '..Username..'\n'
..'ایدی کاربری : '..result.from.id..'\n\n'
local hash = 'rank:'..result.to.id..':variables'
local value = redis:hget(hash, result.from.id)
if not value then
if result.from.id == tonumber(Dev) then
text = text..'مقام : مدیر کل ربات (Executive Admin) \n\n'
elseif is_admin2(result.from.id) then
text = text..'مقام : ادمین ربات (Admin) \n\n'
elseif is_owner2(result.from.id, result.to.id) then
text = text..'مقام : مدیر کل گروه (Owner) \n\n'
elseif is_momod2(result.from.id, result.to.id) then
text = text..'مقام : مدیر گروه (Moderator) \n\n'
else
text = text..'مقام : کاربر (Member) \n\n'
end
else
text = text..'مقام : '..value..'\n\n'
end
local user_info = {}
local uhash = 'user:'..result.from.id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..result.from.id..':'..result.to.id
user_info_msgs = tonumber(redis:get(um_hash) or 0)
text = text..'تعداد پیام های فرستاده شده : '..user_info_msgs..'\n\n'
text = text..'SBSS Team'
send_msg(extra.receiver, text, ok_cb, true)
end
local function action_by_reply2(extra, success, result)
local value = extra.value
setrank(result, result.from.id, value)
end
local function run(msg, matches)
if matches[1]:lower() == 'setrank' then
local hash = 'usecommands:'..msg.from.id..':'..msg.to.id
redis:incr(hash)
if not is_sudo(msg) then
return "Only for Sudo"
end
local receiver = get_receiver(msg)
local Reply = msg.reply_id
if msg.reply_id then
local value = string.sub(matches[2], 1, 1000)
msgr = get_message(msg.reply_id, action_by_reply2, {receiver=receiver, Reply=Reply, value=value})
else
local name = string.sub(matches[2], 1, 50)
local value = string.sub(matches[3], 1, 1000)
local text = setrank(msg, name, value)
return text
end
end
if matches[1]:lower() == 'آیدی' and not matches[2] then
local receiver = get_receiver(msg)
local Reply = msg.reply_id
if msg.reply_id then
msgr = get_message(msg.reply_id, action_by_reply, {receiver=receiver, Reply=Reply})
else
if msg.from.username then
Username = '@'..msg.from.username
else
Username = 'ندارد'
end
local text = 'نام : '..(msg.from.first_name or 'ندارد')..'\n'
local text = text..'فامیل : '..(msg.from.last_name or 'ندارد')..'\n'
local text = text..'یوزر : '..Username..'\n'
local text = text..'ایدی کاربری : '..msg.from.id..'\n\n'
local hash = 'rank:'..msg.to.id..':variables'
if hash then
local value = redis:hget(hash, msg.from.id)
if not value then
if msg.from.id == tonumber(Dev) then
text = text..'مقام : مدیر کل ربات (Executive Admin) \n\n'
elseif is_sudo(msg) then
text = text..'مقام : ادمین ربات (Admin) \n\n'
elseif is_owner(msg) then
text = text..'مقام : مدیر کل گروه (Owner) \n\n'
elseif is_momod(msg) then
text = text..'مقام : مدیر گروه (Moderator) \n\n'
else
text = text..'مقام : کاربر (Member) \n\n'
end
else
text = text..'مقام : '..value..'\n'
end
end
local uhash = 'user:'..msg.from.id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..msg.from.id..':'..msg.to.id
user_info_msgs = tonumber(redis:get(um_hash) or 0)
text = text..'تعداد پیام های فرستاده شده : '..user_info_msgs..'\n\n'
if msg.to.type == 'chat' then
text = text..'نام گروه : '..msg.to.title..'\n'
text = text..'ایدی گروه : '..msg.to.id
end
text = text..'\n\nSBSS Team'
return send_msg(receiver, text, ok_cb, true)
end
end
if matches[1]:lower() == 'info' and matches[2] then
local user = matches[2]
local chat2 = msg.to.id
local receiver = get_receiver(msg)
if string.match(user, '^%d+$') then
user_info('user#id'..user, action_by_id, {receiver=receiver, user=user, text=text, chat2=chat2})
elseif string.match(user, '^@.+$') then
username = string.gsub(user, '@', '')
msgr = res_user(username, res_user_callback, {receiver=receiver, user=user, text=text, chat2=chat2})
end
end
end
return {
description = 'Know your information or the info of a chat members.',
usage = {
'!info: Return your info and the chat info if you are in one.',
'(Reply)!info: Return info of replied user if used by reply.',
'!info <id>: Return the info\'s of the <id>.',
'!info @<user_name>: Return the member @<user_name> information from the current chat.',
'!setrank <userid> <rank>: change members rank.',
'(Reply)!setrank <rank>: change members rank.',
},
patterns = {
"^(آیدی)$",
"^(آیدی) (.*)$",
"^[/!]([Ss][Ee][Tt][Rr][Aa][Nn][Kk]) (%d+) (.*)$",
"^[/!]([Ss][Ee][Tt][Rr][Aa][Nn][Kk]) (.*)$",
},
run = run
}
end
| gpl-2.0 |
Tatwi/legend-of-hondo | MMOCoreORB/bin/scripts/object/building/general/cave_02_ice.lua | 3 | 2200 | --Copyright (C) 2010 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
object_building_general_cave_02_ice = object_building_general_shared_cave_02_ice:new {
}
ObjectTemplates:addTemplate(object_building_general_cave_02_ice, "object/building/general/cave_02_ice.iff")
| agpl-3.0 |
Tatwi/legend-of-hondo | MMOCoreORB/bin/scripts/object/tangible/event_perk/dant_imprv_flagpole_s01.lua | 1 | 2418 | --Copyright (C) 2010 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
object_tangible_event_perk_dant_imprv_flagpole_s01 = object_tangible_event_perk_shared_dant_imprv_flagpole_s01:new {
objectMenuComponent = "EventPerkMenuComponent",
dataObjectComponent = "EventPerkDataComponent",
attributeListComponent = "EventPerkAttributeListComponent",
}
ObjectTemplates:addTemplate(object_tangible_event_perk_dant_imprv_flagpole_s01, "object/tangible/event_perk/dant_imprv_flagpole_s01.iff")
| agpl-3.0 |
jbeley/packages | net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_policy.lua | 9 | 2668 | -- ------ extra functions ------ --
function policy_check() -- check to see if any policy names exceed the maximum of 15 characters
uci.cursor():foreach("mwan3", "policy",
function (section)
if string.len(section[".name"]) > 15 then
toolong = 1
err_name_list = err_name_list .. section[".name"] .. " "
end
end
)
end
function policy_warn() -- display status and warning messages at the top of the page
if toolong == 1 then
return "<font color=\"ff0000\"><strong>WARNING: Some policies have names exceeding the maximum of 15 characters!</strong></font>"
else
return ""
end
end
-- ------ policy configuration ------ --
ds = require "luci.dispatcher"
sys = require "luci.sys"
toolong = 0
err_name_list = " "
policy_check()
m5 = Map("mwan3", translate("MWAN3 Multi-WAN Policy Configuration"),
translate(policy_warn()))
m5:append(Template("mwan3/mwan3_config_css"))
mwan_policy = m5:section(TypedSection, "policy", translate("Policies"),
translate("Policies are profiles grouping one or more members controlling how MWAN3 distributes traffic<br />" ..
"Member interfaces with lower metrics are used first. Interfaces with the same metric load-balance<br />" ..
"Load-balanced member interfaces distribute more traffic out those with higher weights<br />" ..
"Names may contain characters A-Z, a-z, 0-9, _ and no spaces. Names must be 15 characters or less<br />" ..
"Policies may not share the same name as configured interfaces, members or rules"))
mwan_policy.addremove = true
mwan_policy.dynamic = false
mwan_policy.sectionhead = "Policy"
mwan_policy.sortable = true
mwan_policy.template = "cbi/tblsection"
mwan_policy.extedit = ds.build_url("admin", "network", "mwan3", "configuration", "policy", "%s")
function mwan_policy.create(self, section)
TypedSection.create(self, section)
m5.uci:save("mwan3")
luci.http.redirect(ds.build_url("admin", "network", "mwan3", "configuration", "policy", section))
end
use_member = mwan_policy:option(DummyValue, "use_member", translate("Members assigned"))
use_member.rawhtml = true
function use_member.cfgvalue(self, s)
local tab, str = self.map:get(s, "use_member"), ""
if tab then
for k,v in pairs(tab) do
str = str .. v .. "<br />"
end
return str
else
return "—"
end
end
errors = mwan_policy:option(DummyValue, "errors", translate("Errors"))
errors.rawhtml = true
function errors.cfgvalue(self, s)
if not string.find(err_name_list, " " .. s .. " ") then
return ""
else
return "<span title=\"Name exceeds 15 characters\"><img src=\"/luci-static/resources/cbi/reset.gif\" alt=\"error\"></img></span>"
end
end
return m5
| gpl-2.0 |
Tatwi/legend-of-hondo | MMOCoreORB/bin/scripts/object/draft_schematic/space/booster/fast_charge_fuel_cell_mk1.lua | 1 | 3328 | --Copyright (C) 2010 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
object_draft_schematic_space_booster_fast_charge_fuel_cell_mk1 = object_draft_schematic_space_booster_shared_fast_charge_fuel_cell_mk1:new {
templateType = DRAFTSCHEMATIC,
customObjectName = "Fast Charge Fuel Cell - Mark I",
craftingToolTab = 131072, -- (See DraftSchematicObjectTemplate.h)
complexity = 19,
size = 1,
xpType = "shipwright",
xp = 25,
assemblySkill = "booster_assembly",
experimentingSkill = "booster_experimentation",
customizationSkill = "medicine_customization",
customizationOptions = {},
customizationStringNames = {},
customizationDefaults = {},
ingredientTemplateNames = {"craft_item_ingredients_n", "craft_item_ingredients_n"},
ingredientTitleNames = {"fuel_cell_core", "adv_fuel_cell_enhancer"},
ingredientSlotType = {0, 0},
resourceTypes = {"steel", "gas_reactive_organometallic"},
resourceQuantities = {75, 25},
contribution = {100, 100},
targetTemplate = "object/tangible/ship/crafted/booster/fast_charge_fuel_cell_mk1.iff",
additionalTemplates = {
"object/tangible/ship/crafted/booster/shared_fast_charge_fuel_cell_mk1.iff",
}
}
ObjectTemplates:addTemplate(object_draft_schematic_space_booster_fast_charge_fuel_cell_mk1, "object/draft_schematic/space/booster/fast_charge_fuel_cell_mk1.iff")
| agpl-3.0 |
Tatwi/legend-of-hondo | MMOCoreORB/bin/scripts/object/mobile/dressed_draya_korbinari.lua | 3 | 2208 | --Copyright (C) 2010 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
object_mobile_dressed_draya_korbinari = object_mobile_shared_dressed_draya_korbinari:new {
}
ObjectTemplates:addTemplate(object_mobile_dressed_draya_korbinari, "object/mobile/dressed_draya_korbinari.iff")
| agpl-3.0 |
Tatwi/legend-of-hondo | MMOCoreORB/bin/scripts/object/tangible/ship/attachment/weapon/bwing_weapon1_s05.lua | 3 | 2284 | --Copyright (C) 2010 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
object_tangible_ship_attachment_weapon_bwing_weapon1_s05 = object_tangible_ship_attachment_weapon_shared_bwing_weapon1_s05:new {
}
ObjectTemplates:addTemplate(object_tangible_ship_attachment_weapon_bwing_weapon1_s05, "object/tangible/ship/attachment/weapon/bwing_weapon1_s05.iff")
| agpl-3.0 |
istayping/istyping | plugins/quotes.lua | 651 | 1630 | local quotes_file = './data/quotes.lua'
local quotes_table
function read_quotes_file()
local f = io.open(quotes_file, "r+")
if f == nil then
print ('Created a new quotes file on '..quotes_file)
serialize_to_file({}, quotes_file)
else
print ('Quotes loaded: '..quotes_file)
f:close()
end
return loadfile (quotes_file)()
end
function save_quote(msg)
local to_id = tostring(msg.to.id)
if msg.text:sub(11):isempty() then
return "Usage: !addquote quote"
end
if quotes_table == nil then
quotes_table = {}
end
if quotes_table[to_id] == nil then
print ('New quote key to_id: '..to_id)
quotes_table[to_id] = {}
end
local quotes = quotes_table[to_id]
quotes[#quotes+1] = msg.text:sub(11)
serialize_to_file(quotes_table, quotes_file)
return "done!"
end
function get_quote(msg)
local to_id = tostring(msg.to.id)
local quotes_phrases
quotes_table = read_quotes_file()
quotes_phrases = quotes_table[to_id]
return quotes_phrases[math.random(1,#quotes_phrases)]
end
function run(msg, matches)
if string.match(msg.text, "!quote$") then
return get_quote(msg)
elseif string.match(msg.text, "!addquote (.+)$") then
quotes_table = read_quotes_file()
return save_quote(msg)
end
end
return {
description = "Save quote",
description = "Quote plugin, you can create and retrieve random quotes",
usage = {
"!addquote [msg]",
"!quote",
},
patterns = {
"^!addquote (.+)$",
"^!quote$",
},
run = run
}
| gpl-2.0 |
Tatwi/legend-of-hondo | MMOCoreORB/bin/scripts/loot/items/armor/bone_armor_bicep_l.lua | 4 | 1129 | bone_armor_bicep_l = {
minimumLevel = 0,
maximumLevel = -1,
customObjectName = "Bone Armor Left Bicep",
directObjectTemplate = "object/tangible/wearables/armor/bone/armor_bone_s01_bicep_l.iff",
craftingValues = {
{"armor_rating",1,1,0},
{"energyeffectiveness",10,35,10},
{"armor_effectiveness",4,19,10},
{"armor_integrity",7500, 12500,0},
{"armor_health_encumbrance",6,4,0},
{"armor_action_encumbrance",8,4,0},
{"armor_mind_encumbrance",4,2,0},
},
skillMods = {
},
customizationStringNames = {"/private/index_color_0", "/private/index_color_1"},
customizationValues = {
{0, 1},
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 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, 91, 92, 93, 94, 95}
},
junkDealerTypeNeeded = JUNKARMOUR,
junkMinValue = 25,
junkMaxValue = 50
}
addLootItemTemplate("bone_armor_bicep_l", bone_armor_bicep_l)
| agpl-3.0 |
Tatwi/legend-of-hondo | MMOCoreORB/bin/scripts/object/static/structure/general/prp_junk_s5.lua | 3 | 2232 | --Copyright (C) 2010 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
object_static_structure_general_prp_junk_s5 = object_static_structure_general_shared_prp_junk_s5:new {
}
ObjectTemplates:addTemplate(object_static_structure_general_prp_junk_s5, "object/static/structure/general/prp_junk_s5.iff")
| agpl-3.0 |
TerraME/terrame | test/packages/depend/tests/Tube.lua | 30 | 1562 | -------------------------------------------------------------------------------------------
-- TerraME - a software platform for multiple scale spatially-explicit dynamic modeling.
-- Copyright (C) 2001-2014 INPE and TerraLAB/UFOP.
--
-- This code is part of the TerraME framework.
-- This framework is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library.
--
-- The authors reassure the license terms regarding the warranties.
-- They specifically disclaim any warranties, including, but not limited to,
-- the implied warranties of merchantability and fitness for a particular purpose.
-- The framework provided hereunder is on an "as is" basis, and the authors have no
-- obligation to provide maintenance, support, updates, enhancements, or modifications.
-- In no event shall INPE and TerraLAB / UFOP be held liable to any party for direct,
-- indirect, special, incidental, or consequential damages arising out of the use
-- of this library and its documentation.
--
-- Authors: Tiago Garcia de Senna Carneiro (tiago@dpi.inpe.br)
-- Pedro R. Andrade (pedro.andrade@inpe.br)
-------------------------------------------------------------------------------------------
return{
Tube = function(unitTest)
local t = Tube{}
unitTest:assert(true)
end
}
| lgpl-3.0 |
Tatwi/legend-of-hondo | MMOCoreORB/bin/scripts/object/draft_schematic/clothing/clothing_ith_shirt_formal_10.lua | 1 | 3307 | --Copyright (C) 2010 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
object_draft_schematic_clothing_clothing_ith_shirt_formal_10 = object_draft_schematic_clothing_shared_clothing_ith_shirt_formal_10:new {
templateType = DRAFTSCHEMATIC,
customObjectName = "Ithorian Mystic Shirt",
craftingToolTab = 8, -- (See DraftSchematicObjectTemplate.h)
complexity = 16,
size = 4,
xpType = "crafting_clothing_general",
xp = 100,
assemblySkill = "clothing_assembly",
experimentingSkill = "clothing_experimentation",
customizationSkill = "clothing_customization",
customizationOptions = {},
customizationStringNames = {},
customizationDefaults = {},
ingredientTemplateNames = {"craft_clothing_ingredients_n", "craft_clothing_ingredients_n", "craft_clothing_ingredients_n"},
ingredientTitleNames = {"body", "trim", "binding_and_hardware"},
ingredientSlotType = {0, 1, 0},
resourceTypes = {"fiberplast", "object/tangible/component/clothing/shared_trim.iff", "fiberplast"},
resourceQuantities = {80, 3, 5},
contribution = {100, 100, 100},
targetTemplate = "object/tangible/wearables/ithorian/ith_shirt_s10.iff",
additionalTemplates = {
}
}
ObjectTemplates:addTemplate(object_draft_schematic_clothing_clothing_ith_shirt_formal_10, "object/draft_schematic/clothing/clothing_ith_shirt_formal_10.iff")
| agpl-3.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.