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 |
|---|---|---|---|---|---|
nitheeshkl/kln_awesome | awesome_3.5/vicious/widgets/uptime.lua | 15 | 1191 | ---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
---------------------------------------------------
-- {{{ Grab environment
local setmetatable = setmetatable
local math = { floor = math.floor }
local string = { match = string.match }
local helpers = require("vicious.helpers")
-- }}}
-- Uptime: provides system uptime and load information
-- vicious.widgets.uptime
local uptime = {}
-- {{{ Uptime widget type
local function worker(format)
local proc = helpers.pathtotable("/proc")
-- Get system uptime
local up_t = math.floor(string.match(proc.uptime, "[%d]+"))
local up_d = math.floor(up_t / (3600 * 24))
local up_h = math.floor((up_t % (3600 * 24)) / 3600)
local up_m = math.floor(((up_t % (3600 * 24)) % 3600) / 60)
local l1, l5, l15 = -- Get load averages for past 1, 5 and 15 minutes
string.match(proc.loadavg, "([%d%.]+)[%s]([%d%.]+)[%s]([%d%.]+)")
return {up_d, up_h, up_m, l1, l5, l15}
end
-- }}}
return setmetatable(uptime, { __call = function(_, ...) return worker(...) end })
| gpl-2.0 |
cho4036/package | net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/rule.lua | 80 | 4829 | -- ------ extra functions ------ --
function ruleCheck() -- determine if rules needs a proper protocol configured
uci.cursor():foreach("mwan3", "rule",
function (section)
local sourcePort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. section[".name"] .. ".src_port"))
local destPort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. section[".name"] .. ".dest_port"))
if sourcePort ~= "" or destPort ~= "" then -- ports configured
local protocol = ut.trim(sys.exec("uci -p /var/state get mwan3." .. section[".name"] .. ".proto"))
if protocol == "" or protocol == "all" then -- no or improper protocol
error_protocol_list = error_protocol_list .. section[".name"] .. " "
end
end
end
)
end
function ruleWarn() -- display warning messages at the top of the page
if error_protocol_list ~= " " then
return "<font color=\"ff0000\"><strong>WARNING: some rules have a port configured with no or improper protocol specified! Please configure a specific protocol!</strong></font>"
else
return ""
end
end
-- ------ rule configuration ------ --
dsp = require "luci.dispatcher"
sys = require "luci.sys"
ut = require "luci.util"
error_protocol_list = " "
ruleCheck()
m5 = Map("mwan3", translate("MWAN Rule Configuration"),
translate(ruleWarn()))
m5:append(Template("mwan/config_css"))
mwan_rule = m5:section(TypedSection, "rule", translate("Traffic Rules"),
translate("Rules specify which traffic will use a particular MWAN policy based on IP address, port or protocol<br />" ..
"Rules are matched from top to bottom. Rules below a matching rule are ignored. Traffic not matching any rule is routed using the main routing table<br />" ..
"Traffic destined for known (other than default) networks is handled by the main routing table. Traffic matching a rule, but all WAN interfaces for that policy are down will be blackholed<br />" ..
"Names may contain characters A-Z, a-z, 0-9, _ and no spaces<br />" ..
"Rules may not share the same name as configured interfaces, members or policies"))
mwan_rule.addremove = true
mwan_rule.anonymous = false
mwan_rule.dynamic = false
mwan_rule.sectionhead = "Rule"
mwan_rule.sortable = true
mwan_rule.template = "cbi/tblsection"
mwan_rule.extedit = dsp.build_url("admin", "network", "mwan", "configuration", "rule", "%s")
function mwan_rule.create(self, section)
TypedSection.create(self, section)
m5.uci:save("mwan3")
luci.http.redirect(dsp.build_url("admin", "network", "mwan", "configuration", "rule", section))
end
src_ip = mwan_rule:option(DummyValue, "src_ip", translate("Source address"))
src_ip.rawhtml = true
function src_ip.cfgvalue(self, s)
return self.map:get(s, "src_ip") or "—"
end
src_port = mwan_rule:option(DummyValue, "src_port", translate("Source port"))
src_port.rawhtml = true
function src_port.cfgvalue(self, s)
return self.map:get(s, "src_port") or "—"
end
dest_ip = mwan_rule:option(DummyValue, "dest_ip", translate("Destination address"))
dest_ip.rawhtml = true
function dest_ip.cfgvalue(self, s)
return self.map:get(s, "dest_ip") or "—"
end
dest_port = mwan_rule:option(DummyValue, "dest_port", translate("Destination port"))
dest_port.rawhtml = true
function dest_port.cfgvalue(self, s)
return self.map:get(s, "dest_port") or "—"
end
proto = mwan_rule:option(DummyValue, "proto", translate("Protocol"))
proto.rawhtml = true
function proto.cfgvalue(self, s)
return self.map:get(s, "proto") or "all"
end
sticky = mwan_rule:option(DummyValue, "sticky", translate("Sticky"))
sticky.rawhtml = true
function sticky.cfgvalue(self, s)
if self.map:get(s, "sticky") == "1" then
stickied = 1
return "Yes"
else
stickied = nil
return "No"
end
end
timeout = mwan_rule:option(DummyValue, "timeout", translate("Sticky timeout"))
timeout.rawhtml = true
function timeout.cfgvalue(self, s)
if stickied then
local timeoutValue = self.map:get(s, "timeout")
if timeoutValue then
return timeoutValue .. "s"
else
return "600s"
end
else
return "—"
end
end
ipset = mwan_rule:option(DummyValue, "ipset", translate("IPset"))
ipset.rawhtml = true
function ipset.cfgvalue(self, s)
return self.map:get(s, "ipset") or "—"
end
use_policy = mwan_rule:option(DummyValue, "use_policy", translate("Policy assigned"))
use_policy.rawhtml = true
function use_policy.cfgvalue(self, s)
return self.map:get(s, "use_policy") or "—"
end
errors = mwan_rule:option(DummyValue, "errors", translate("Errors"))
errors.rawhtml = true
function errors.cfgvalue(self, s)
if not string.find(error_protocol_list, " " .. s .. " ") then
return ""
else
return "<span title=\"No protocol specified\"><img src=\"/luci-static/resources/cbi/reset.gif\" alt=\"error\"></img></span>"
end
end
return m5
| gpl-2.0 |
mattyx14/otxserver | data/monster/fey/wisp.lua | 2 | 3040 | local mType = Game.createMonsterType("Wisp")
local monster = {}
monster.description = "a wisp"
monster.experience = 0
monster.outfit = {
lookType = 294,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.raceId = 462
monster.Bestiary = {
class = "Fey",
race = BESTY_RACE_FEY,
toKill = 250,
FirstUnlock = 10,
SecondUnlock = 100,
CharmsPoints = 5,
Stars = 1,
Occurrence = 0,
Locations = "All around Tiquanda and Feyrist. Several groups of Wisps can be found in and around \z
the forests north of Edron. West of Hardek. Inside the Cyclops Camp. North of the triple \z
Wyvern spawn outside Kazordoon. West of Ab'Dendriel. West of Venore Amazon Camp. \z
A few spawns around Venore, 2 spawn on the Formorgar Glacier, and on Krimhorn."
}
monster.health = 115
monster.maxHealth = 115
monster.race = "undead"
monster.corpse = 6323
monster.speed = 162
monster.manaCost = 0
monster.changeTarget = {
interval = 60000,
chance = 0
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = true,
canPushItems = false,
canPushCreatures = false,
staticAttackChance = 15,
targetDistance = 7,
runHealth = 115,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "Crackle!", yell = false},
{text = "Tsshh", yell = false}
}
monster.loot = {
{name = "moon backpack", chance = 220}
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -10},
{name ="combat", interval = 2000, chance = 15, type = COMBAT_LIFEDRAIN, minDamage = -3, maxDamage = -7, range = 1, effect = CONST_ME_MAGIC_RED, target = true}
}
monster.defenses = {
defense = 10,
armor = 10,
{name ="speed", interval = 2000, chance = 15, speedChange = 200, effect = CONST_ME_MAGIC_RED, target = false, duration = 5000},
{name ="combat", interval = 2000, chance = 5, type = COMBAT_HEALING, minDamage = 15, maxDamage = 25, effect = CONST_ME_MAGIC_GREEN, target = false},
{name ="invisible", interval = 2000, chance = 10, effect = CONST_ME_MAGIC_BLUE, target = false, duration = 3000}
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 60},
{type = COMBAT_ENERGYDAMAGE, percent = 40},
{type = COMBAT_EARTHDAMAGE, percent = 90},
{type = COMBAT_FIREDAMAGE, percent = 0},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 100}
}
monster.immunities = {
{type = "paralyze", condition = true},
{type = "outfit", condition = false},
{type = "invisible", condition = false},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
raminea/capitan-Deadpool | plugins/ingroup.lua | 371 | 44212 | do
-- Check Member
local function check_member_autorealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Realm',
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes'
}
}
save_data(_config.moderation.data, data)
local realms = 'realms'
if not data[tostring(realms)] then
data[tostring(realms)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(realms)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Welcome to your new realm !')
end
end
end
local function check_member_realm_add(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Realm',
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes'
}
}
save_data(_config.moderation.data, data)
local realms = 'realms'
if not data[tostring(realms)] then
data[tostring(realms)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(realms)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Realm has been added!')
end
end
end
function check_member_group(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Group',
moderators = {},
set_owner = member_id ,
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes',
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'You have been promoted as the owner.')
end
end
end
local function check_member_modadd(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Group',
moderators = {},
set_owner = member_id ,
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes',
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Group is added and you have been promoted as the owner ')
end
end
end
local function automodadd(msg)
local data = load_data(_config.moderation.data)
if msg.action.type == 'chat_created' then
receiver = get_receiver(msg)
chat_info(receiver, check_member_group,{receiver=receiver, data=data, msg = msg})
end
end
local function autorealmadd(msg)
local data = load_data(_config.moderation.data)
if msg.action.type == 'chat_created' then
receiver = get_receiver(msg)
chat_info(receiver, check_member_autorealm,{receiver=receiver, data=data, msg = msg})
end
end
local function check_member_realmrem(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Realm configuration removal
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local realms = 'realms'
if not data[tostring(realms)] then
data[tostring(realms)] = nil
save_data(_config.moderation.data, data)
end
data[tostring(realms)][tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Realm has been removed!')
end
end
end
local function check_member_modrem(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration removal
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = nil
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Group has been removed')
end
end
end
--End Check Member
local function show_group_settingsmod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['settings']['flood_msg_max'] then
NUM_MSG_MAX = tonumber(data[tostring(msg.to.id)]['settings']['flood_msg_max'])
print('custom'..NUM_MSG_MAX)
else
NUM_MSG_MAX = 5
end
end
local bots_protection = "Yes"
if data[tostring(msg.to.id)]['settings']['lock_bots'] then
bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots']
end
local leave_ban = "no"
if data[tostring(msg.to.id)]['settings']['leave_ban'] then
leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban']
end
local settings = data[tostring(target)]['settings']
local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nLock group leave : "..leave_ban.."\nflood sensitivity : "..NUM_MSG_MAX.."\nBot protection : "..bots_protection--"\nPublic: "..public
return text
end
local function set_descriptionmod(msg, data, target, about)
if not is_momod(msg) then
return "For moderators only!"
end
local data_cat = 'description'
data[tostring(target)][data_cat] = about
save_data(_config.moderation.data, data)
return 'Set group description to:\n'..about
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]
local about = string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about
return 'About '..about
end
local function lock_group_arabic(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'yes' then
return 'Arabic is already locked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'yes'
save_data(_config.moderation.data, data)
return 'Arabic has been locked'
end
end
local function unlock_group_arabic(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'no' then
return 'Arabic is already unlocked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'no'
save_data(_config.moderation.data, data)
return 'Arabic has been unlocked'
end
end
local function lock_group_bots(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'yes' then
return 'Bots protection is already enabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'yes'
save_data(_config.moderation.data, data)
return 'Bots protection has been enabled'
end
end
local function unlock_group_bots(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'no' then
return 'Bots protection is already disabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'no'
save_data(_config.moderation.data, data)
return 'Bots protection has been disabled'
end
end
local function lock_group_namemod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'yes' then
return 'Group name is already locked'
else
data[tostring(target)]['settings']['lock_name'] = 'yes'
save_data(_config.moderation.data, data)
rename_chat('chat#id'..target, group_name_set, ok_cb, false)
return 'Group name has been locked'
end
end
local function unlock_group_namemod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'no' then
return 'Group name is already unlocked'
else
data[tostring(target)]['settings']['lock_name'] = 'no'
save_data(_config.moderation.data, data)
return 'Group name has been unlocked'
end
end
local function lock_group_floodmod(msg, data, target)
if not is_owner(msg) then
return "Only admins can do it for now"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'yes' then
return 'Group flood is locked'
else
data[tostring(target)]['settings']['flood'] = 'yes'
save_data(_config.moderation.data, data)
return 'Group flood has been locked'
end
end
local function unlock_group_floodmod(msg, data, target)
if not is_owner(msg) then
return "Only admins can do it for now"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'no' then
return 'Group flood is not locked'
else
data[tostring(target)]['settings']['flood'] = 'no'
save_data(_config.moderation.data, data)
return 'Group flood has been unlocked'
end
end
local function lock_group_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'yes' then
return 'Group members are already locked'
else
data[tostring(target)]['settings']['lock_member'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group members has been locked'
end
local function unlock_group_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'no' then
return 'Group members are not locked'
else
data[tostring(target)]['settings']['lock_member'] = 'no'
save_data(_config.moderation.data, data)
return 'Group members has been unlocked'
end
end
local function set_public_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['public']
if group_member_lock == 'yes' then
return 'Group is already public'
else
data[tostring(target)]['settings']['public'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group is now: public'
end
local function unset_public_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['public']
if group_member_lock == 'no' then
return 'Group is not public'
else
data[tostring(target)]['settings']['public'] = 'no'
save_data(_config.moderation.data, data)
return 'Group is now: not public'
end
end
local function lock_group_leave(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban']
if leave_ban == 'yes' then
return 'Leaving users will be banned'
else
data[tostring(msg.to.id)]['settings']['leave_ban'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Leaving users will be banned'
end
local function unlock_group_leave(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban']
if leave_ban == 'no' then
return 'Leaving users will not be banned'
else
data[tostring(msg.to.id)]['settings']['leave_ban'] = 'no'
save_data(_config.moderation.data, data)
return 'Leaving users will not be banned'
end
end
local function unlock_group_photomod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'no' then
return 'Group photo is not locked'
else
data[tostring(target)]['settings']['lock_photo'] = 'no'
save_data(_config.moderation.data, data)
return 'Group photo has been unlocked'
end
end
local function set_rulesmod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local data_cat = 'rules'
data[tostring(target)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..rules
end
local function modadd(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if is_group(msg) then
return 'Group is already added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_modadd,{receiver=receiver, data=data, msg = msg})
end
local function realmadd(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if is_realm(msg) then
return 'Realm is already added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_realm_add,{receiver=receiver, data=data, msg = msg})
end
-- Global functions
function modrem(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if not is_group(msg) then
return 'Group is not added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_modrem,{receiver=receiver, data=data, msg = msg})
end
function realmrem(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if not is_realm(msg) then
return 'Realm is not added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_realmrem,{receiver=receiver, data=data, msg = msg})
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 = 'Chat rules:\n'..rules
return rules
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
local function promote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'chat#id', '')
if not data[group] then
return send_large_msg(receiver, 'Group is not added.')
end
if data[group]['moderators'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is already a moderator.')
end
data[group]['moderators'][tostring(member_id)] = member_username
save_data(_config.moderation.data, data)
return send_large_msg(receiver, member_username..' has been promoted.')
end
local function promote_by_reply(extra, success, result)
local msg = result
local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '')
if msg.from.username then
member_username = '@'.. msg.from.username
else
member_username = full_name
end
local member_id = msg.from.id
if msg.to.type == 'chat' then
return promote(get_receiver(msg), member_username, member_id)
end
end
local function demote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'chat#id', '')
if not data[group] then
return send_large_msg(receiver, 'Group is not added.')
end
if not data[group]['moderators'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is not a moderator.')
end
data[group]['moderators'][tostring(member_id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, member_username..' has been demoted.')
end
local function demote_by_reply(extra, success, result)
local msg = result
local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '')
if msg.from.username then
member_username = '@'..msg.from.username
else
member_username = full_name
end
local member_id = msg.from.id
if msg.to.type == 'chat' then
return demote(get_receiver(msg), member_username, member_id)
end
end
local function setowner_by_reply(extra, success, result)
local msg = result
local receiver = get_receiver(msg)
local data = load_data(_config.moderation.data)
local name_log = msg.from.print_name:gsub("_", " ")
data[tostring(msg.to.id)]['set_owner'] = tostring(msg.from.id)
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] setted ["..msg.from.id.."] as owner")
local text = msg.from.print_name:gsub("_", " ").." is the owner now"
return send_large_msg(receiver, text)
end
local function promote_demote_res(extra, success, result)
--vardump(result)
--vardump(extra)
local member_id = result.id
local member_username = "@"..result.username
local chat_id = extra.chat_id
local mod_cmd = extra.mod_cmd
local receiver = "chat#id"..chat_id
if mod_cmd == 'promote' then
return promote(receiver, member_username, member_id)
elseif mod_cmd == 'demote' then
return demote(receiver, member_username, member_id)
end
end
local function modlist(msg)
local data = load_data(_config.moderation.data)
local groups = "groups"
if not data[tostring(groups)][tostring(msg.to.id)] then
return 'Group is not added.'
end
-- determine if table is empty
if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way
return 'No moderator in this group.'
end
local i = 1
local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
message = message ..i..' - '..v..' [' ..k.. '] \n'
i = i + 1
end
return message
end
local function callbackres(extra, success, result)
--vardump(result)
local user = result.id
local name = string.gsub(result.print_name, "_", " ")
local chat = 'chat#id'..extra.chatid
send_large_msg(chat, user..'\n'..name)
return user
end
local function help()
local help_text = tostring(_config.help_text)
return help_text
end
local function cleanmember(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user(v.id, result.id)
end
end
local function killchat(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function killrealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function user_msgs(user_id, chat_id)
local user_info
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..user_id..':'..chat_id
user_info = tonumber(redis:get(um_hash) or 0)
return user_info
end
local function kick_zero(cb_extra, success, result)
local chat_id = cb_extra.chat_id
local chat = "chat#id"..chat_id
local ci_user
local re_user
for k,v in pairs(result.members) do
local si = false
ci_user = v.id
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
for i = 1, #users do
re_user = users[i]
if tonumber(ci_user) == tonumber(re_user) then
si = true
end
end
if not si then
if ci_user ~= our_id then
if not is_momod2(ci_user, chat_id) then
chat_del_user(chat, 'user#id'..ci_user, ok_cb, true)
end
end
end
end
end
local function kick_inactive(chat_id, num, receiver)
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = user_msgs(user_id, chat_id)
local nmsg = user_info
if tonumber(nmsg) < tonumber(num) then
if not is_momod2(user_id, chat_id) then
chat_del_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, true)
end
end
end
return chat_info(receiver, kick_zero, {chat_id = chat_id})
end
local function run(msg, matches)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
local name_log = user_print_name(msg.from)
local group = msg.to.id
if msg.media then
if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_chat_msg(msg) and is_momod(msg) then
load_photo(msg.id, set_group_photo, msg)
end
end
if matches[1] == 'add' and not matches[2] then
if is_realm(msg) then
return 'Error: Already a realm.'
end
print("group "..msg.to.print_name.."("..msg.to.id..") added")
return modadd(msg)
end
if matches[1] == 'add' and matches[2] == 'realm' then
if is_group(msg) then
return 'Error: Already a group.'
end
print("group "..msg.to.print_name.."("..msg.to.id..") added as a realm")
return realmadd(msg)
end
if matches[1] == 'rem' and not matches[2] then
print("group "..msg.to.print_name.."("..msg.to.id..") removed")
return modrem(msg)
end
if matches[1] == 'rem' and matches[2] == 'realm' then
print("group "..msg.to.print_name.."("..msg.to.id..") removed as a realm")
return realmrem(msg)
end
if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "group" then
return automodadd(msg)
end
if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "realm" then
return autorealmadd(msg)
end
if msg.to.id and data[tostring(msg.to.id)] then
local settings = data[tostring(msg.to.id)]['settings']
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 user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if group_member_lock == 'yes' and not is_owner2(msg.action.user.id, msg.to.id) then
chat_del_user(chat, user, ok_cb, true)
elseif group_member_lock == 'yes' and tonumber(msg.from.id) == tonumber(our_id) then
return nil
elseif group_member_lock == 'no' then
return nil
end
end
if matches[1] == 'chat_del_user' then
if not msg.service then
-- return "Are you trying to troll me?"
end
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..user)
end
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
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:incr(picturehash)
---
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
local picprotectionredis = redis:get(picturehash)
if picprotectionredis then
if tonumber(picprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(picprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:set(picturehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to deleted picture but failed ")
chat_set_photo(receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
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
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:incr(picturehash)
---
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
local picprotectionredis = redis:get(picturehash)
if picprotectionredis then
if tonumber(picprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(picprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:set(picturehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change picture but failed ")
chat_set_photo(receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
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
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
redis:incr(namehash)
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
local nameprotectionredis = redis:get(namehash)
if nameprotectionredis then
if tonumber(nameprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(nameprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
redis:set(namehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change name but failed ")
rename_chat(to_rename, group_name_set, ok_cb, false)
end
elseif group_name_lock == 'no' then
return nil
end
end
if matches[1] == 'setname' and is_momod(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)
savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
if matches[1] == 'setphoto' and is_momod(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 matches[1] == 'promote' and not matches[2] then
if not is_owner(msg) then
return "Only the owner can prmote new moderators"
end
if type(msg.reply_id)~="nil" then
msgr = get_message(msg.reply_id, promote_by_reply, false)
end
end
if matches[1] == 'promote' and matches[2] then
if not is_momod(msg) then
return
end
if not is_owner(msg) then
return "Only owner can promote"
end
local member = matches[2]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @".. member)
local cbres_extra = {
chat_id = msg.to.id,
mod_cmd = 'promote',
from_id = msg.from.id
}
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
return res_user(username, promote_demote_res, cbres_extra)
end
if matches[1] == 'demote' and not matches[2] then
if not is_owner(msg) then
return "Only the owner can demote moderators"
end
if type(msg.reply_id)~="nil" then
msgr = get_message(msg.reply_id, demote_by_reply, false)
end
end
if matches[1] == 'demote' and matches[2] then
if not is_momod(msg) then
return
end
if not is_owner(msg) then
return "Only owner can demote"
end
if string.gsub(matches[2], "@", "") == msg.from.username and not is_owner(msg) then
return "You can't demote yourself"
end
local member = matches[2]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @".. member)
local cbres_extra = {
chat_id = msg.to.id,
mod_cmd = 'demote',
from_id = msg.from.id
}
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
return res_user(username, promote_demote_res, cbres_extra)
end
if matches[1] == 'modlist' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist")
return modlist(msg)
end
if matches[1] == 'about' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group description")
return get_description(msg, data)
end
if matches[1] == 'rules' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group rules")
return get_rules(msg, data)
end
if matches[1] == 'set' then
if matches[2] == 'rules' then
rules = matches[3]
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[3].."]")
return set_rulesmod(msg, data, target)
end
if matches[2] == 'about' then
local data = load_data(_config.moderation.data)
local target = msg.to.id
local about = matches[3]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group description to ["..matches[3].."]")
return set_descriptionmod(msg, data, target, about)
end
end
if matches[1] == 'lock' then
local target = msg.to.id
if matches[2] == 'name' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked name ")
return lock_group_namemod(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ")
return lock_group_membermod(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ")
return lock_group_floodmod(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ")
return lock_group_arabic(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots ")
return lock_group_bots(msg, data, target)
end
if matches[2] == 'leave' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked leaving ")
return lock_group_leave(msg, data, target)
end
end
if matches[1] == 'unlock' then
local target = msg.to.id
if matches[2] == 'name' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked name ")
return unlock_group_namemod(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ")
return unlock_group_membermod(msg, data, target)
end
if matches[2] == 'photo' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked photo ")
return unlock_group_photomod(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood ")
return unlock_group_floodmod(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked arabic ")
return unlock_group_arabic(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked bots ")
return unlock_group_bots(msg, data, target)
end
if matches[2] == 'leave' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked leaving ")
return unlock_group_leave(msg, data, target)
end
end
if matches[1] == 'settings' then
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group settings ")
return show_group_settingsmod(msg, data, target)
end
--[[if matches[1] == 'public' then
local target = msg.to.id
if matches[2] == 'yes' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: public")
return set_public_membermod(msg, data, target)
end
if matches[2] == 'no' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: not public")
return unset_public_membermod(msg, data, target)
end
end]]
if matches[1] == 'newlink' and not is_realm(msg) then
if not is_momod(msg) then
return "For moderators only!"
end
local function callback (extra , success, result)
local receiver = 'chat#'..msg.to.id
if success == 0 then
return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.')
end
send_large_msg(receiver, "Created a new link")
data[tostring(msg.to.id)]['settings']['set_link'] = result
save_data(_config.moderation.data, data)
end
local receiver = 'chat#'..msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] revoked group link ")
return export_chat_link(receiver, callback, true)
end
if matches[1] == 'link' then
if not is_momod(msg) then
return "For moderators only!"
end
local group_link = data[tostring(msg.to.id)]['settings']['set_link']
if not group_link then
return "Create a link using /newlink first !"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]")
return "Group link:\n"..group_link
end
if matches[1] == 'setowner' and matches[2] then
if not is_owner(msg) then
return "For owner only!"
end
data[tostring(msg.to.id)]['set_owner'] = matches[2]
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] as owner")
local text = matches[2].." added as owner"
return text
end
if matches[1] == 'setowner' and not matches[2] then
if not is_owner(msg) then
return "only for the owner!"
end
if type(msg.reply_id)~="nil" then
msgr = get_message(msg.reply_id, setowner_by_reply, false)
end
end
if matches[1] == 'owner' then
local group_owner = data[tostring(msg.to.id)]['set_owner']
local user_info = redis:hgetall('user:'..group_owner)
if not group_owner then
return "no owner,ask admins in support groups to set owner for your group"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner")
if user_info.username then
return "Group onwer is @"..user_info.username.." ["..group_owner.."]"
else
return "Group owner is ["..group_owner..']'
end
end
if matches[1] == 'setgpowner' then
local receiver = "chat#id"..matches[2]
if not is_admin(msg) then
return "For admins only!"
end
data[tostring(matches[2])]['set_owner'] = matches[3]
save_data(_config.moderation.data, data)
local text = matches[3].." added as owner"
send_large_msg(receiver, text)
return
end
if matches[1] == 'setflood' then
if not is_momod(msg) then
return "For moderators only!"
end
if tonumber(matches[2]) < 5 or tonumber(matches[2]) > 20 then
return "Wrong number,range is [5-20]"
end
local flood_max = matches[2]
data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]")
return 'Group flood has been set to '..matches[2]
end
if matches[1] == 'clean' then
if not is_owner(msg) then
return "Only owner can clean"
end
if matches[2] == 'member' then
if not is_owner(msg) then
return "Only admins can clean members"
end
local receiver = get_receiver(msg)
chat_info(receiver, cleanmember, {receiver=receiver})
end
if matches[2] == 'modlist' then
if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way
return 'No moderator in this group.'
end
local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil
save_data(_config.moderation.data, data)
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist")
end
if matches[2] == 'rules' then
local data_cat = 'rules'
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules")
end
if matches[2] == 'about' then
local data_cat = 'description'
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about")
end
end
if matches[1] == 'kill' and matches[2] == 'chat' then
if not is_admin(msg) then
return nil
end
if not is_realm(msg) then
local receiver = get_receiver(msg)
return modrem(msg),
print("Closing Group..."),
chat_info(receiver, killchat, {receiver=receiver})
else
return 'This is a realm'
end
end
if matches[1] == 'kill' and matches[2] == 'realm' then
if not is_admin(msg) then
return nil
end
if not is_group(msg) then
local receiver = get_receiver(msg)
return realmrem(msg),
print("Closing Realm..."),
chat_info(receiver, killrealm, {receiver=receiver})
else
return 'This is a group'
end
end
if matches[1] == 'help' then
if not is_momod(msg) or is_realm(msg) then
return
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help")
return help()
end
if matches[1] == 'res' and is_momod(msg) then
local cbres_extra = {
chatid = msg.to.id
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username)
return res_user(username, callbackres, cbres_extra)
end
if matches[1] == 'kickinactive' then
--send_large_msg('chat#id'..msg.to.id, 'I\'m in matches[1]')
if not is_momod(msg) then
return 'Only a moderator can kick inactive users'
end
local num = 1
if matches[2] then
num = matches[2]
end
local chat_id = msg.to.id
local receiver = get_receiver(msg)
return kick_inactive(chat_id, num, receiver)
end
end
end
return {
patterns = {
"^[!/](add)$",
"^[!/](add) (realm)$",
"^[!/](rem)$",
"^[!/](rem) (realm)$",
"^[!/](rules)$",
"^[!/](about)$",
"^[!/](setname) (.*)$",
"^[!/](setphoto)$",
"^[!/](promote) (.*)$",
"^[!/](promote)",
"^[!/](help)$",
"^[!/](clean) (.*)$",
"^[!/](kill) (chat)$",
"^[!/](kill) (realm)$",
"^[!/](demote) (.*)$",
"^[!/](demote)",
"^[!/](set) ([^%s]+) (.*)$",
"^[!/](lock) (.*)$",
"^[!/](setowner) (%d+)$",
"^[!/](setowner)",
"^[!/](owner)$",
"^[!/](res) (.*)$",
"^[!/](setgpowner) (%d+) (%d+)$",-- (group id) (owner id)
"^[!/](unlock) (.*)$",
"^[!/](setflood) (%d+)$",
"^[!/](settings)$",
-- "^[!/](public) (.*)$",
"^[!/](modlist)$",
"^[!/](newlink)$",
"^[!/](link)$",
"^[!/](kickinactive)$",
"^[!/](kickinactive) (%d+)$",
"%[(photo)%]",
"^!!tgservice (.+)$",
},
run = run
}
end
| gpl-2.0 |
zakariaRobot/TeleSeed | plugins/ingroup.lua | 371 | 44212 | do
-- Check Member
local function check_member_autorealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Realm',
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes'
}
}
save_data(_config.moderation.data, data)
local realms = 'realms'
if not data[tostring(realms)] then
data[tostring(realms)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(realms)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Welcome to your new realm !')
end
end
end
local function check_member_realm_add(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Realm',
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes'
}
}
save_data(_config.moderation.data, data)
local realms = 'realms'
if not data[tostring(realms)] then
data[tostring(realms)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(realms)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Realm has been added!')
end
end
end
function check_member_group(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Group',
moderators = {},
set_owner = member_id ,
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes',
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'You have been promoted as the owner.')
end
end
end
local function check_member_modadd(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Group',
moderators = {},
set_owner = member_id ,
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes',
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Group is added and you have been promoted as the owner ')
end
end
end
local function automodadd(msg)
local data = load_data(_config.moderation.data)
if msg.action.type == 'chat_created' then
receiver = get_receiver(msg)
chat_info(receiver, check_member_group,{receiver=receiver, data=data, msg = msg})
end
end
local function autorealmadd(msg)
local data = load_data(_config.moderation.data)
if msg.action.type == 'chat_created' then
receiver = get_receiver(msg)
chat_info(receiver, check_member_autorealm,{receiver=receiver, data=data, msg = msg})
end
end
local function check_member_realmrem(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Realm configuration removal
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local realms = 'realms'
if not data[tostring(realms)] then
data[tostring(realms)] = nil
save_data(_config.moderation.data, data)
end
data[tostring(realms)][tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Realm has been removed!')
end
end
end
local function check_member_modrem(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration removal
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = nil
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Group has been removed')
end
end
end
--End Check Member
local function show_group_settingsmod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['settings']['flood_msg_max'] then
NUM_MSG_MAX = tonumber(data[tostring(msg.to.id)]['settings']['flood_msg_max'])
print('custom'..NUM_MSG_MAX)
else
NUM_MSG_MAX = 5
end
end
local bots_protection = "Yes"
if data[tostring(msg.to.id)]['settings']['lock_bots'] then
bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots']
end
local leave_ban = "no"
if data[tostring(msg.to.id)]['settings']['leave_ban'] then
leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban']
end
local settings = data[tostring(target)]['settings']
local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nLock group leave : "..leave_ban.."\nflood sensitivity : "..NUM_MSG_MAX.."\nBot protection : "..bots_protection--"\nPublic: "..public
return text
end
local function set_descriptionmod(msg, data, target, about)
if not is_momod(msg) then
return "For moderators only!"
end
local data_cat = 'description'
data[tostring(target)][data_cat] = about
save_data(_config.moderation.data, data)
return 'Set group description to:\n'..about
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]
local about = string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about
return 'About '..about
end
local function lock_group_arabic(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'yes' then
return 'Arabic is already locked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'yes'
save_data(_config.moderation.data, data)
return 'Arabic has been locked'
end
end
local function unlock_group_arabic(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'no' then
return 'Arabic is already unlocked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'no'
save_data(_config.moderation.data, data)
return 'Arabic has been unlocked'
end
end
local function lock_group_bots(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'yes' then
return 'Bots protection is already enabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'yes'
save_data(_config.moderation.data, data)
return 'Bots protection has been enabled'
end
end
local function unlock_group_bots(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'no' then
return 'Bots protection is already disabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'no'
save_data(_config.moderation.data, data)
return 'Bots protection has been disabled'
end
end
local function lock_group_namemod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'yes' then
return 'Group name is already locked'
else
data[tostring(target)]['settings']['lock_name'] = 'yes'
save_data(_config.moderation.data, data)
rename_chat('chat#id'..target, group_name_set, ok_cb, false)
return 'Group name has been locked'
end
end
local function unlock_group_namemod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'no' then
return 'Group name is already unlocked'
else
data[tostring(target)]['settings']['lock_name'] = 'no'
save_data(_config.moderation.data, data)
return 'Group name has been unlocked'
end
end
local function lock_group_floodmod(msg, data, target)
if not is_owner(msg) then
return "Only admins can do it for now"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'yes' then
return 'Group flood is locked'
else
data[tostring(target)]['settings']['flood'] = 'yes'
save_data(_config.moderation.data, data)
return 'Group flood has been locked'
end
end
local function unlock_group_floodmod(msg, data, target)
if not is_owner(msg) then
return "Only admins can do it for now"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'no' then
return 'Group flood is not locked'
else
data[tostring(target)]['settings']['flood'] = 'no'
save_data(_config.moderation.data, data)
return 'Group flood has been unlocked'
end
end
local function lock_group_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'yes' then
return 'Group members are already locked'
else
data[tostring(target)]['settings']['lock_member'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group members has been locked'
end
local function unlock_group_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'no' then
return 'Group members are not locked'
else
data[tostring(target)]['settings']['lock_member'] = 'no'
save_data(_config.moderation.data, data)
return 'Group members has been unlocked'
end
end
local function set_public_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['public']
if group_member_lock == 'yes' then
return 'Group is already public'
else
data[tostring(target)]['settings']['public'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group is now: public'
end
local function unset_public_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['public']
if group_member_lock == 'no' then
return 'Group is not public'
else
data[tostring(target)]['settings']['public'] = 'no'
save_data(_config.moderation.data, data)
return 'Group is now: not public'
end
end
local function lock_group_leave(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban']
if leave_ban == 'yes' then
return 'Leaving users will be banned'
else
data[tostring(msg.to.id)]['settings']['leave_ban'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Leaving users will be banned'
end
local function unlock_group_leave(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban']
if leave_ban == 'no' then
return 'Leaving users will not be banned'
else
data[tostring(msg.to.id)]['settings']['leave_ban'] = 'no'
save_data(_config.moderation.data, data)
return 'Leaving users will not be banned'
end
end
local function unlock_group_photomod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'no' then
return 'Group photo is not locked'
else
data[tostring(target)]['settings']['lock_photo'] = 'no'
save_data(_config.moderation.data, data)
return 'Group photo has been unlocked'
end
end
local function set_rulesmod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local data_cat = 'rules'
data[tostring(target)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..rules
end
local function modadd(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if is_group(msg) then
return 'Group is already added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_modadd,{receiver=receiver, data=data, msg = msg})
end
local function realmadd(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if is_realm(msg) then
return 'Realm is already added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_realm_add,{receiver=receiver, data=data, msg = msg})
end
-- Global functions
function modrem(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if not is_group(msg) then
return 'Group is not added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_modrem,{receiver=receiver, data=data, msg = msg})
end
function realmrem(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if not is_realm(msg) then
return 'Realm is not added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_realmrem,{receiver=receiver, data=data, msg = msg})
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 = 'Chat rules:\n'..rules
return rules
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
local function promote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'chat#id', '')
if not data[group] then
return send_large_msg(receiver, 'Group is not added.')
end
if data[group]['moderators'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is already a moderator.')
end
data[group]['moderators'][tostring(member_id)] = member_username
save_data(_config.moderation.data, data)
return send_large_msg(receiver, member_username..' has been promoted.')
end
local function promote_by_reply(extra, success, result)
local msg = result
local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '')
if msg.from.username then
member_username = '@'.. msg.from.username
else
member_username = full_name
end
local member_id = msg.from.id
if msg.to.type == 'chat' then
return promote(get_receiver(msg), member_username, member_id)
end
end
local function demote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'chat#id', '')
if not data[group] then
return send_large_msg(receiver, 'Group is not added.')
end
if not data[group]['moderators'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is not a moderator.')
end
data[group]['moderators'][tostring(member_id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, member_username..' has been demoted.')
end
local function demote_by_reply(extra, success, result)
local msg = result
local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '')
if msg.from.username then
member_username = '@'..msg.from.username
else
member_username = full_name
end
local member_id = msg.from.id
if msg.to.type == 'chat' then
return demote(get_receiver(msg), member_username, member_id)
end
end
local function setowner_by_reply(extra, success, result)
local msg = result
local receiver = get_receiver(msg)
local data = load_data(_config.moderation.data)
local name_log = msg.from.print_name:gsub("_", " ")
data[tostring(msg.to.id)]['set_owner'] = tostring(msg.from.id)
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] setted ["..msg.from.id.."] as owner")
local text = msg.from.print_name:gsub("_", " ").." is the owner now"
return send_large_msg(receiver, text)
end
local function promote_demote_res(extra, success, result)
--vardump(result)
--vardump(extra)
local member_id = result.id
local member_username = "@"..result.username
local chat_id = extra.chat_id
local mod_cmd = extra.mod_cmd
local receiver = "chat#id"..chat_id
if mod_cmd == 'promote' then
return promote(receiver, member_username, member_id)
elseif mod_cmd == 'demote' then
return demote(receiver, member_username, member_id)
end
end
local function modlist(msg)
local data = load_data(_config.moderation.data)
local groups = "groups"
if not data[tostring(groups)][tostring(msg.to.id)] then
return 'Group is not added.'
end
-- determine if table is empty
if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way
return 'No moderator in this group.'
end
local i = 1
local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
message = message ..i..' - '..v..' [' ..k.. '] \n'
i = i + 1
end
return message
end
local function callbackres(extra, success, result)
--vardump(result)
local user = result.id
local name = string.gsub(result.print_name, "_", " ")
local chat = 'chat#id'..extra.chatid
send_large_msg(chat, user..'\n'..name)
return user
end
local function help()
local help_text = tostring(_config.help_text)
return help_text
end
local function cleanmember(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user(v.id, result.id)
end
end
local function killchat(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function killrealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function user_msgs(user_id, chat_id)
local user_info
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..user_id..':'..chat_id
user_info = tonumber(redis:get(um_hash) or 0)
return user_info
end
local function kick_zero(cb_extra, success, result)
local chat_id = cb_extra.chat_id
local chat = "chat#id"..chat_id
local ci_user
local re_user
for k,v in pairs(result.members) do
local si = false
ci_user = v.id
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
for i = 1, #users do
re_user = users[i]
if tonumber(ci_user) == tonumber(re_user) then
si = true
end
end
if not si then
if ci_user ~= our_id then
if not is_momod2(ci_user, chat_id) then
chat_del_user(chat, 'user#id'..ci_user, ok_cb, true)
end
end
end
end
end
local function kick_inactive(chat_id, num, receiver)
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = user_msgs(user_id, chat_id)
local nmsg = user_info
if tonumber(nmsg) < tonumber(num) then
if not is_momod2(user_id, chat_id) then
chat_del_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, true)
end
end
end
return chat_info(receiver, kick_zero, {chat_id = chat_id})
end
local function run(msg, matches)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
local name_log = user_print_name(msg.from)
local group = msg.to.id
if msg.media then
if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_chat_msg(msg) and is_momod(msg) then
load_photo(msg.id, set_group_photo, msg)
end
end
if matches[1] == 'add' and not matches[2] then
if is_realm(msg) then
return 'Error: Already a realm.'
end
print("group "..msg.to.print_name.."("..msg.to.id..") added")
return modadd(msg)
end
if matches[1] == 'add' and matches[2] == 'realm' then
if is_group(msg) then
return 'Error: Already a group.'
end
print("group "..msg.to.print_name.."("..msg.to.id..") added as a realm")
return realmadd(msg)
end
if matches[1] == 'rem' and not matches[2] then
print("group "..msg.to.print_name.."("..msg.to.id..") removed")
return modrem(msg)
end
if matches[1] == 'rem' and matches[2] == 'realm' then
print("group "..msg.to.print_name.."("..msg.to.id..") removed as a realm")
return realmrem(msg)
end
if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "group" then
return automodadd(msg)
end
if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "realm" then
return autorealmadd(msg)
end
if msg.to.id and data[tostring(msg.to.id)] then
local settings = data[tostring(msg.to.id)]['settings']
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 user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if group_member_lock == 'yes' and not is_owner2(msg.action.user.id, msg.to.id) then
chat_del_user(chat, user, ok_cb, true)
elseif group_member_lock == 'yes' and tonumber(msg.from.id) == tonumber(our_id) then
return nil
elseif group_member_lock == 'no' then
return nil
end
end
if matches[1] == 'chat_del_user' then
if not msg.service then
-- return "Are you trying to troll me?"
end
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..user)
end
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
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:incr(picturehash)
---
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
local picprotectionredis = redis:get(picturehash)
if picprotectionredis then
if tonumber(picprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(picprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:set(picturehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to deleted picture but failed ")
chat_set_photo(receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
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
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:incr(picturehash)
---
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
local picprotectionredis = redis:get(picturehash)
if picprotectionredis then
if tonumber(picprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(picprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:set(picturehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change picture but failed ")
chat_set_photo(receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
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
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
redis:incr(namehash)
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
local nameprotectionredis = redis:get(namehash)
if nameprotectionredis then
if tonumber(nameprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(nameprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
redis:set(namehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change name but failed ")
rename_chat(to_rename, group_name_set, ok_cb, false)
end
elseif group_name_lock == 'no' then
return nil
end
end
if matches[1] == 'setname' and is_momod(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)
savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
if matches[1] == 'setphoto' and is_momod(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 matches[1] == 'promote' and not matches[2] then
if not is_owner(msg) then
return "Only the owner can prmote new moderators"
end
if type(msg.reply_id)~="nil" then
msgr = get_message(msg.reply_id, promote_by_reply, false)
end
end
if matches[1] == 'promote' and matches[2] then
if not is_momod(msg) then
return
end
if not is_owner(msg) then
return "Only owner can promote"
end
local member = matches[2]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @".. member)
local cbres_extra = {
chat_id = msg.to.id,
mod_cmd = 'promote',
from_id = msg.from.id
}
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
return res_user(username, promote_demote_res, cbres_extra)
end
if matches[1] == 'demote' and not matches[2] then
if not is_owner(msg) then
return "Only the owner can demote moderators"
end
if type(msg.reply_id)~="nil" then
msgr = get_message(msg.reply_id, demote_by_reply, false)
end
end
if matches[1] == 'demote' and matches[2] then
if not is_momod(msg) then
return
end
if not is_owner(msg) then
return "Only owner can demote"
end
if string.gsub(matches[2], "@", "") == msg.from.username and not is_owner(msg) then
return "You can't demote yourself"
end
local member = matches[2]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @".. member)
local cbres_extra = {
chat_id = msg.to.id,
mod_cmd = 'demote',
from_id = msg.from.id
}
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
return res_user(username, promote_demote_res, cbres_extra)
end
if matches[1] == 'modlist' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist")
return modlist(msg)
end
if matches[1] == 'about' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group description")
return get_description(msg, data)
end
if matches[1] == 'rules' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group rules")
return get_rules(msg, data)
end
if matches[1] == 'set' then
if matches[2] == 'rules' then
rules = matches[3]
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[3].."]")
return set_rulesmod(msg, data, target)
end
if matches[2] == 'about' then
local data = load_data(_config.moderation.data)
local target = msg.to.id
local about = matches[3]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group description to ["..matches[3].."]")
return set_descriptionmod(msg, data, target, about)
end
end
if matches[1] == 'lock' then
local target = msg.to.id
if matches[2] == 'name' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked name ")
return lock_group_namemod(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ")
return lock_group_membermod(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ")
return lock_group_floodmod(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ")
return lock_group_arabic(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots ")
return lock_group_bots(msg, data, target)
end
if matches[2] == 'leave' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked leaving ")
return lock_group_leave(msg, data, target)
end
end
if matches[1] == 'unlock' then
local target = msg.to.id
if matches[2] == 'name' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked name ")
return unlock_group_namemod(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ")
return unlock_group_membermod(msg, data, target)
end
if matches[2] == 'photo' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked photo ")
return unlock_group_photomod(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood ")
return unlock_group_floodmod(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked arabic ")
return unlock_group_arabic(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked bots ")
return unlock_group_bots(msg, data, target)
end
if matches[2] == 'leave' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked leaving ")
return unlock_group_leave(msg, data, target)
end
end
if matches[1] == 'settings' then
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group settings ")
return show_group_settingsmod(msg, data, target)
end
--[[if matches[1] == 'public' then
local target = msg.to.id
if matches[2] == 'yes' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: public")
return set_public_membermod(msg, data, target)
end
if matches[2] == 'no' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: not public")
return unset_public_membermod(msg, data, target)
end
end]]
if matches[1] == 'newlink' and not is_realm(msg) then
if not is_momod(msg) then
return "For moderators only!"
end
local function callback (extra , success, result)
local receiver = 'chat#'..msg.to.id
if success == 0 then
return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.')
end
send_large_msg(receiver, "Created a new link")
data[tostring(msg.to.id)]['settings']['set_link'] = result
save_data(_config.moderation.data, data)
end
local receiver = 'chat#'..msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] revoked group link ")
return export_chat_link(receiver, callback, true)
end
if matches[1] == 'link' then
if not is_momod(msg) then
return "For moderators only!"
end
local group_link = data[tostring(msg.to.id)]['settings']['set_link']
if not group_link then
return "Create a link using /newlink first !"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]")
return "Group link:\n"..group_link
end
if matches[1] == 'setowner' and matches[2] then
if not is_owner(msg) then
return "For owner only!"
end
data[tostring(msg.to.id)]['set_owner'] = matches[2]
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] as owner")
local text = matches[2].." added as owner"
return text
end
if matches[1] == 'setowner' and not matches[2] then
if not is_owner(msg) then
return "only for the owner!"
end
if type(msg.reply_id)~="nil" then
msgr = get_message(msg.reply_id, setowner_by_reply, false)
end
end
if matches[1] == 'owner' then
local group_owner = data[tostring(msg.to.id)]['set_owner']
local user_info = redis:hgetall('user:'..group_owner)
if not group_owner then
return "no owner,ask admins in support groups to set owner for your group"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner")
if user_info.username then
return "Group onwer is @"..user_info.username.." ["..group_owner.."]"
else
return "Group owner is ["..group_owner..']'
end
end
if matches[1] == 'setgpowner' then
local receiver = "chat#id"..matches[2]
if not is_admin(msg) then
return "For admins only!"
end
data[tostring(matches[2])]['set_owner'] = matches[3]
save_data(_config.moderation.data, data)
local text = matches[3].." added as owner"
send_large_msg(receiver, text)
return
end
if matches[1] == 'setflood' then
if not is_momod(msg) then
return "For moderators only!"
end
if tonumber(matches[2]) < 5 or tonumber(matches[2]) > 20 then
return "Wrong number,range is [5-20]"
end
local flood_max = matches[2]
data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]")
return 'Group flood has been set to '..matches[2]
end
if matches[1] == 'clean' then
if not is_owner(msg) then
return "Only owner can clean"
end
if matches[2] == 'member' then
if not is_owner(msg) then
return "Only admins can clean members"
end
local receiver = get_receiver(msg)
chat_info(receiver, cleanmember, {receiver=receiver})
end
if matches[2] == 'modlist' then
if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way
return 'No moderator in this group.'
end
local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil
save_data(_config.moderation.data, data)
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist")
end
if matches[2] == 'rules' then
local data_cat = 'rules'
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules")
end
if matches[2] == 'about' then
local data_cat = 'description'
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about")
end
end
if matches[1] == 'kill' and matches[2] == 'chat' then
if not is_admin(msg) then
return nil
end
if not is_realm(msg) then
local receiver = get_receiver(msg)
return modrem(msg),
print("Closing Group..."),
chat_info(receiver, killchat, {receiver=receiver})
else
return 'This is a realm'
end
end
if matches[1] == 'kill' and matches[2] == 'realm' then
if not is_admin(msg) then
return nil
end
if not is_group(msg) then
local receiver = get_receiver(msg)
return realmrem(msg),
print("Closing Realm..."),
chat_info(receiver, killrealm, {receiver=receiver})
else
return 'This is a group'
end
end
if matches[1] == 'help' then
if not is_momod(msg) or is_realm(msg) then
return
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help")
return help()
end
if matches[1] == 'res' and is_momod(msg) then
local cbres_extra = {
chatid = msg.to.id
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username)
return res_user(username, callbackres, cbres_extra)
end
if matches[1] == 'kickinactive' then
--send_large_msg('chat#id'..msg.to.id, 'I\'m in matches[1]')
if not is_momod(msg) then
return 'Only a moderator can kick inactive users'
end
local num = 1
if matches[2] then
num = matches[2]
end
local chat_id = msg.to.id
local receiver = get_receiver(msg)
return kick_inactive(chat_id, num, receiver)
end
end
end
return {
patterns = {
"^[!/](add)$",
"^[!/](add) (realm)$",
"^[!/](rem)$",
"^[!/](rem) (realm)$",
"^[!/](rules)$",
"^[!/](about)$",
"^[!/](setname) (.*)$",
"^[!/](setphoto)$",
"^[!/](promote) (.*)$",
"^[!/](promote)",
"^[!/](help)$",
"^[!/](clean) (.*)$",
"^[!/](kill) (chat)$",
"^[!/](kill) (realm)$",
"^[!/](demote) (.*)$",
"^[!/](demote)",
"^[!/](set) ([^%s]+) (.*)$",
"^[!/](lock) (.*)$",
"^[!/](setowner) (%d+)$",
"^[!/](setowner)",
"^[!/](owner)$",
"^[!/](res) (.*)$",
"^[!/](setgpowner) (%d+) (%d+)$",-- (group id) (owner id)
"^[!/](unlock) (.*)$",
"^[!/](setflood) (%d+)$",
"^[!/](settings)$",
-- "^[!/](public) (.*)$",
"^[!/](modlist)$",
"^[!/](newlink)$",
"^[!/](link)$",
"^[!/](kickinactive)$",
"^[!/](kickinactive) (%d+)$",
"%[(photo)%]",
"^!!tgservice (.+)$",
},
run = run
}
end
| gpl-2.0 |
manoelcampos/LuaXML | xmlhandler/dom.lua | 1 | 4020 | ---- @module Handler to generate a DOM-like node tree structure with
-- a single ROOT node parent - each node is a table comprising
-- the fields below.
--
-- node = { _name = <Element Name>,
-- _type = ROOT|ELEMENT|TEXT|COMMENT|PI|DECL|DTD,
-- _attr = { Node attributes - see callback API },
-- _parent = <Parent Node>
-- _children = { List of child nodes - ROOT/NODE only }
-- }
-- where:
-- - PI = XML Processing Instruction tag.
-- - DECL = XML declaration tag
--
-- The dom structure is capable of representing any valid XML document
--
-- Options
-- =======
-- options.(comment|pi|dtd|decl)Node = bool
-- - Include/exclude given node types
--
-- License:
-- ========
--
-- This code is freely distributable under the terms of the [MIT license](LICENSE).
--
--@author Paul Chakravarti (paulc@passtheaardvark.com)
--@author Manoel Campos da Silva Filho
local dom = {
options = {commentNode=1, piNode=1, dtdNode=1, declNode=1},
current = { _children = {n=0}, _type = "ROOT" },
_stack = {}
}
---Parses a start tag.
-- @param tag a {name, attrs} table
-- where name is the name of the tag and attrs
-- is a table containing the atributtes of the tag
function dom:starttag(tag)
local node = { _type = 'ELEMENT',
_name = tag.name,
_attr = tag.attrs,
_children = {n=0}
}
if self.root == nil then
self.root = node
end
table.insert(self._stack, node)
table.insert(self.current._children, node)
self.current = node
end
---Parses an end tag.
-- @param tag a {name, attrs} table
-- where name is the name of the tag and attrs
-- is a table containing the atributtes of the tag
function dom:endtag(tag, s)
--Table representing the containing tag of the current tag
local prev = self._stack[#self._stack]
if tag.name ~= prev._name then
error("XML Error - Unmatched Tag ["..s..":"..tag.name.."]\n")
end
table.remove(self._stack)
end
---Parses a tag content.
-- @param text text to process
function dom:text(text)
local node = { _type = "TEXT",
_text = text
}
table.insert(self.current._children, node)
end
---Parses a comment tag.
-- @param text comment text
function dom:comment(text)
if self.options.commentNode then
local node = { _type = "COMMENT",
_text = text
}
table.insert(self.current._children, node)
end
end
--- Parses a XML processing instruction (PI) tag
-- @param tag a {name, attrs} table
-- where name is the name of the tag and attrs
-- is a table containing the atributtes of the tag
function dom:pi(tag)
if self.options.piNode then
local node = { _type = "PI",
_name = tag.name,
_attr = tag.attrs,
}
table.insert(self.current._children, node)
end
end
---Parse the XML declaration line (the line that indicates the XML version).
-- @param tag a {name, attrs} table
-- where name is the name of the tag and attrs
-- is a table containing the atributtes of the tag
function dom:decl(tag)
if self.options.declNode then
local node = { _type = "DECL",
_name = tag.name,
_attr = tag.attrs,
}
table.insert(self.current._children, node)
end
end
---Parses a DTD tag.
-- @param tag a {name, attrs} table
-- where name is the name of the tag and attrs
-- is a table containing the atributtes of the tag
function dom:dtd(tag)
if self.options.dtdNode then
local node = { _type = "DTD",
_name = tag.name,
_attr = tag.attrs,
}
table.insert(self.current._children, node)
end
end
---Parses CDATA tag content.
dom.cdata = dom.text
return dom
| mit |
mattyx14/otxserver | data/monster/humanoids/troll_guard.lua | 2 | 2379 | local mType = Game.createMonsterType("Troll Guard")
local monster = {}
monster.description = "a troll guard"
monster.experience = 25
monster.outfit = {
lookType = 281,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.raceId = 745
monster.Bestiary = {
class = "Humanoid",
race = BESTY_RACE_HUMANOID,
toKill = 5,
FirstUnlock = 2,
SecondUnlock = 3,
CharmsPoints = 30,
Stars = 2,
Occurrence = 3,
Locations = "Rookgaard's central cave in the new western Troll tunnel, \z
north-west of Carlin during raids and Thais Knights' Guild arena during raids on Kingsday."
}
monster.health = 60
monster.maxHealth = 60
monster.race = "blood"
monster.corpse = 861
monster.speed = 126
monster.manaCost = 0
monster.changeTarget = {
interval = 5000,
chance = 20
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = true,
rewardBoss = false,
illusionable = false,
canPushItems = false,
canPushCreatures = false,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 17,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
{id = 3003, chance = 10000}, -- rope
{name = "gold coin", chance = 58000, maxCount = 12},
{name = "studded club", chance = 3000},
{name = "meat", chance = 14000, maxCount = 2}
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -15}
}
monster.defenses = {
defense = 2,
armor = 1
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 20},
{type = COMBAT_EARTHDAMAGE, percent = -10},
{type = COMBAT_FIREDAMAGE, percent = 0},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 10},
{type = COMBAT_DEATHDAMAGE , percent = -10}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = false},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
mattyx14/otxserver | data/scripts/spells/support/levitate.lua | 2 | 1734 | local function levitate(creature, parameter)
local fromPosition = creature:getPosition()
if parameter == "up" and fromPosition.z ~= 8 or parameter == "down" and fromPosition.z ~= 7 then
local toPosition = creature:getPosition()
toPosition:getNextPosition(creature:getDirection())
local tile = Tile(parameter == "up" and Position(fromPosition.x, fromPosition.y, fromPosition.z - 1) or toPosition)
if not tile or not tile:getGround() and not tile:hasFlag(parameter == "up" and TILESTATE_IMMOVABLEBLOCKSOLID or TILESTATE_BLOCKSOLID) then
tile = Tile(toPosition.x, toPosition.y, toPosition.z + (parameter == "up" and -1 or 1))
if tile and tile:getGround() and not tile:hasFlag(bit.bor(TILESTATE_IMMOVABLEBLOCKSOLID, TILESTATE_FLOORCHANGE)) then
return creature:move(tile, bit.bor(FLAG_IGNOREBLOCKITEM, FLAG_IGNOREBLOCKCREATURE))
end
end
end
return RETURNVALUE_NOTPOSSIBLE
end
local spell = Spell("instant")
function spell.onCastSpell(creature, variant)
local returnValue = levitate(creature, variant:getString():lower())
if returnValue ~= RETURNVALUE_NOERROR then
creature:sendCancelMessage(returnValue)
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return true
end
spell:name("Levitate")
spell:words("exani hur")
spell:group("support")
spell:vocation("druid;true", "elder druid;true", "knight;true", "elite knight;true", "paladin;true", "royal paladin;true", "sorcerer;true", "master sorcerer;true")
spell:id(81)
spell:cooldown(2 * 1000)
spell:groupCooldown(2 * 1000)
spell:level(12)
spell:mana(50)
spell:hasParams(true)
spell:isAggressive(false)
spell:isPremium(true)
spell:needLearn(false)
spell:register()
| gpl-2.0 |
mattyx14/otxserver | data/monster/aquatics/deepsea_blood_crab.lua | 2 | 2463 | local mType = Game.createMonsterType("Deepsea Blood Crab")
local monster = {}
monster.description = "a deepsea blood crab"
monster.experience = 180
monster.outfit = {
lookType = 200,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.raceId = 437
monster.Bestiary = {
class = "Aquatic",
race = BESTY_RACE_AQUATIC,
toKill = 500,
FirstUnlock = 25,
SecondUnlock = 250,
CharmsPoints = 15,
Stars = 2,
Occurrence = 0,
Locations = "Svargrond (Sea Serpent Area), Drefia. \z
There is also one under Rookgaard Academy, however it is unreachable."
}
monster.health = 320
monster.maxHealth = 320
monster.race = "blood"
monster.corpse = 6075
monster.speed = 380
monster.manaCost = 0
monster.changeTarget = {
interval = 4000,
chance = 10
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = true,
canPushItems = true,
canPushCreatures = false,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = true,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
{name = "gold coin", chance = 87000, maxCount = 20},
{id = 3578, chance = 10450}, -- fish
{name = "bloody pincers", chance = 6980},
{name = "chain armor", chance = 5020},
{name = "brass legs", chance = 2720},
{name = "white pearl", chance = 620}
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -111, effect = CONST_ME_DRAWBLOOD}
}
monster.defenses = {
defense = 28,
armor = 28
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 5},
{type = COMBAT_ENERGYDAMAGE, percent = -5},
{type = COMBAT_EARTHDAMAGE, percent = 100},
{type = COMBAT_FIREDAMAGE, percent = -10},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 100},
{type = COMBAT_ICEDAMAGE, percent = 100},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = false},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
mattyx14/otxserver | data/lib/core/revscriptsys.lua | 2 | 7669 | -- Create functions revscriptsys
function createFunctions(class)
local exclude = {[2] = {"is"}, [3] = {"get", "set", "add", "can"}, [4] = {"need"}}
local temp = {}
for name, func in pairs(class) do
local add = true
for strLen, strTable in pairs(exclude) do
if table.contains(strTable, name:sub(1, strLen)) then
add = false
end
end
if add then
local str = name:sub(1, 1):upper() .. name:sub(2)
local getFunc = function(self) return func(self) end
local setFunc = function(self, ...) return func(self, ...) end
local get = "get" .. str
local set = "set" .. str
if not (rawget(class, get) and rawget(class, set)) then
table.insert(temp, {set, setFunc, get, getFunc})
end
end
end
for _, func in ipairs(temp) do
rawset(class, func[1], func[2])
rawset(class, func[3], func[4])
end
end
-- Creature index
do
local function CreatureIndex(self, key)
local methods = getmetatable(self)
if key == "uid" then
return methods.getId(self)
elseif key == "type" then
local creatureType = 0
if methods.isPlayer(self) then
creatureType = THING_TYPE_PLAYER
elseif methods.isMonster(self) then
creatureType = THING_TYPE_MONSTER
elseif methods.isNpc(self) then
creatureType = THING_TYPE_NPC
end
return creatureType
elseif key == "itemid" then
return 1
elseif key == "actionid" then
return 0
end
return methods[key]
end
rawgetmetatable("Player").__index = CreatureIndex
rawgetmetatable("Monster").__index = CreatureIndex
rawgetmetatable("Npc").__index = CreatureIndex
end
-- Item index
do
local function ItemIndex(self, key)
local methods = getmetatable(self)
if key == "itemid" then
return methods.getId(self)
elseif key == "actionid" then
return methods.getActionId(self)
elseif key == "uid" then
return methods.getUniqueId(self)
elseif key == "type" then
return methods.getSubType(self)
end
return methods[key]
end
rawgetmetatable("Item").__index = ItemIndex
rawgetmetatable("Container").__index = ItemIndex
rawgetmetatable("Teleport").__index = ItemIndex
end
-- Action revscriptsys
do
local function ActionNewIndex(self, key, value)
if key == "onUse" then
self:onUse(value)
return
end
rawset(self, key, value)
end
rawgetmetatable("Action").__newindex = ActionNewIndex
end
-- TalkAction revscriptsys
do
local function TalkActionNewIndex(self, key, value)
if key == "onSay" then
self:onSay(value)
return
end
rawset(self, key, value)
end
rawgetmetatable("TalkAction").__newindex = TalkActionNewIndex
end
-- CreatureEvent revscriptsys
do
local function CreatureEventNewIndex(self, key, value)
if key == "onLogin" then
self:type("login")
self:onLogin(value)
return
elseif key == "onLogout" then
self:type("logout")
self:onLogout(value)
return
elseif key == "onThink" then
self:type("think")
self:onThink(value)
return
elseif key == "onPrepareDeath" then
self:type("preparedeath")
self:onPrepareDeath(value)
return
elseif key == "onDeath" then
self:type("death")
self:onDeath(value)
return
elseif key == "onKill" then
self:type("kill")
self:onKill(value)
return
elseif key == "onAdvance" then
self:type("advance")
self:onAdvance(value)
return
elseif key == "onModalWindow" then
self:type("modalwindow")
self:onModalWindow(value)
return
elseif key == "onTextEdit" then
self:type("textedit")
self:onTextEdit(value)
return
elseif key == "onHealthChange" then
self:type("healthchange")
self:onHealthChange(value)
return
elseif key == "onManaChange" then
self:type("manachange")
self:onManaChange(value)
return
elseif key == "onExtendedOpcode" then
self:type("extendedopcode")
self:onExtendedOpcode(value)
return
end
rawset(self, key, value)
end
rawgetmetatable("CreatureEvent").__newindex = CreatureEventNewIndex
end
-- MoveEvent revscriptsys
do
local function MoveEventNewIndex(self, key, value)
if key == "onEquip" then
self:type("equip")
self:onEquip(value)
return
elseif key == "onDeEquip" then
self:type("deequip")
self:onDeEquip(value)
return
elseif key == "onAddItem" then
self:type("additem")
self:onAddItem(value)
return
elseif key == "onRemoveItem" then
self:type("removeitem")
self:onRemoveItem(value)
return
elseif key == "onStepIn" then
self:type("stepin")
self:onStepIn(value)
return
elseif key == "onStepOut" then
self:type("stepout")
self:onStepOut(value)
return
end
rawset(self, key, value)
end
rawgetmetatable("MoveEvent").__newindex = MoveEventNewIndex
end
-- GlobalEvent revscriptsys
do
local function GlobalEventNewIndex(self, key, value)
if key == "onThink" then
self:onThink(value)
return
elseif key == "onTime" then
self:onTime(value)
return
elseif key == "onStartup" then
self:type("startup")
self:onStartup(value)
return
elseif key == "onShutdown" then
self:type("shutdown")
self:onShutdown(value)
return
elseif key == "onRecord" then
self:type("record")
self:onRecord(value)
return
elseif key == "onPeriodChange" then
self:type("periodchange")
self:onPeriodChange(value)
return
end
rawset(self, key, value)
end
rawgetmetatable("GlobalEvent").__newindex = GlobalEventNewIndex
end
-- Weapons revscriptsys
do
local function WeaponNewIndex(self, key, value)
if key == "onUseWeapon" then
self:onUseWeapon(value)
return
end
rawset(self, key, value)
end
rawgetmetatable("Weapon").__newindex = WeaponNewIndex
end
-- Spells revscriptsys
do
local function SpellNewIndex(self, key, value)
if key == "onCastSpell" then
self:onCastSpell(value)
return
end
rawset(self, key, value)
end
rawgetmetatable("Spell").__newindex = SpellNewIndex
end
-- Monsters revscriptsys
do
local function MonsterTypeNewIndex(self, key, value)
if key == "onThink" then
self:eventType(MONSTERS_EVENT_THINK)
self:onThink(value)
return
elseif key == "onAppear" then
self:eventType(MONSTERS_EVENT_APPEAR)
self:onAppear(value)
return
elseif key == "onDisappear" then
self:eventType(MONSTERS_EVENT_DISAPPEAR)
self:onDisappear(value)
return
elseif key == "onMove" then
self:eventType(MONSTERS_EVENT_MOVE)
self:onMove(value)
return
elseif key == "onSay" then
self:eventType(MONSTERS_EVENT_SAY)
self:onSay(value)
return
end
rawset(self, key, value)
end
rawgetmetatable("MonsterType").__newindex = MonsterTypeNewIndex
end
-- Npcs revscriptsys
do
local function NpcTypeNewIndex(self, key, value)
if key == "onThink" then
self:eventType(NPCS_EVENT_THINK)
self:onThink(value)
return
elseif key == "onAppear" then
self:eventType(NPCS_EVENT_APPEAR)
self:onAppear(value)
return
elseif key == "onDisappear" then
self:eventType(NPCS_EVENT_DISAPPEAR)
self:onDisappear(value)
return
elseif key == "onMove" then
self:eventType(NPCS_EVENT_MOVE)
self:onMove(value)
return
elseif key == "onSay" then
self:eventType(NPCS_EVENT_SAY)
self:onSay(value)
return
elseif key == "onBuyItem" then
self:eventType(NPCS_EVENT_PLAYER_BUY)
self:onBuyItem(value)
return
elseif key == "onSellItem" then
self:eventType(NPCS_EVENT_PLAYER_SELL)
self:onSellItem(value)
return
elseif key == "onCheckItem" then
self:eventType(NPCS_EVENT_PLAYER_CHECK_ITEM)
self:onCheckItem(value)
return
elseif key == "onCloseChannel" then
self:eventType(NPCS_EVENT_PLAYER_CLOSE_CHANNEL)
self:onBuyItem(value)
return
end
rawset(self, key, value)
end
rawgetmetatable("NpcType").__newindex = NpcTypeNewIndex
end
| gpl-2.0 |
mumuqz/luci | applications/luci-app-pbx/luasrc/model/cbi/pbx.lua | 146 | 4360 | --[[
Copyright 2011 Iordan Iordanov <iiordanov (AT) gmail.com>
This file is part of luci-pbx.
luci-pbx 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.
luci-pbx 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 luci-pbx. If not, see <http://www.gnu.org/licenses/>.
]]--
modulename = "pbx"
if nixio.fs.access("/etc/init.d/asterisk") then
server = "asterisk"
elseif nixio.fs.access("/etc/init.d/freeswitch") then
server = "freeswitch"
else
server = ""
end
-- Returns formatted output of string containing only the words at the indices
-- specified in the table "indices".
function format_indices(string, indices)
if indices == nil then
return "Error: No indices to format specified.\n"
end
-- Split input into separate lines.
lines = luci.util.split(luci.util.trim(string), "\n")
-- Split lines into separate words.
splitlines = {}
for lpos,line in ipairs(lines) do
splitlines[lpos] = luci.util.split(luci.util.trim(line), "%s+", nil, true)
end
-- For each split line, if the word at all indices specified
-- to be formatted are not null, add the formatted line to the
-- gathered output.
output = ""
for lpos,splitline in ipairs(splitlines) do
loutput = ""
for ipos,index in ipairs(indices) do
if splitline[index] ~= nil then
loutput = loutput .. string.format("%-40s", splitline[index])
else
loutput = nil
break
end
end
if loutput ~= nil then
output = output .. loutput .. "\n"
end
end
return output
end
m = Map (modulename, translate("PBX Main Page"),
translate("This configuration page allows you to configure a phone system (PBX) service which \
permits making phone calls through multiple Google and SIP (like Sipgate, \
SipSorcery, and Betamax) accounts and sharing them among many SIP devices. \
Note that Google accounts, SIP accounts, and local user accounts are configured in the \
\"Google Accounts\", \"SIP Accounts\", and \"User Accounts\" sub-sections. \
You must add at least one User Account to this PBX, and then configure a SIP device or \
softphone to use the account, in order to make and receive calls with your Google/SIP \
accounts. Configuring multiple users will allow you to make free calls between all users, \
and share the configured Google and SIP accounts. If you have more than one Google and SIP \
accounts set up, you should probably configure how calls to and from them are routed in \
the \"Call Routing\" page. If you're interested in using your own PBX from anywhere in the \
world, then visit the \"Remote Usage\" section in the \"Advanced Settings\" page."))
-----------------------------------------------------------------------------------------
s = m:section(NamedSection, "connection_status", "main",
translate("PBX Service Status"))
s.anonymous = true
s:option (DummyValue, "status", translate("Service Status"))
sts = s:option(DummyValue, "_sts")
sts.template = "cbi/tvalue"
sts.rows = 20
function sts.cfgvalue(self, section)
if server == "asterisk" then
regs = luci.sys.exec("asterisk -rx 'sip show registry' | sed 's/peer-//'")
jabs = luci.sys.exec("asterisk -rx 'jabber show connections' | grep onnected")
usrs = luci.sys.exec("asterisk -rx 'sip show users'")
chan = luci.sys.exec("asterisk -rx 'core show channels'")
return format_indices(regs, {1, 5}) ..
format_indices(jabs, {2, 4}) .. "\n" ..
format_indices(usrs, {1} ) .. "\n" .. chan
elseif server == "freeswitch" then
return "Freeswitch is not supported yet.\n"
else
return "Neither Asterisk nor FreeSwitch discovered, please install Asterisk, as Freeswitch is not supported yet.\n"
end
end
return m
| apache-2.0 |
CarabusX/Zero-K | LuaUI/Widgets/gui_showeco_action.lua | 4 | 11263 | local version = "v1.003"
function widget:GetInfo()
return {
name = "Showeco and Grid Drawer",
desc = "Register an action called Showeco & draw overdrive overlay.", --"acts like F4",
author = "xponen, ashdnazg",
date = "July 19 2013",
license = "GNU GPL, v2 or later",
layer = 0, --only layer > -4 works because it seems to be blocked by something.
enabled = true, -- loaded by default?
handler = true,
}
end
local pylon ={}
local spGetMapDrawMode = Spring.GetMapDrawMode
local spSendCommands = Spring.SendCommands
local function ToggleShoweco()
WG.showeco = not WG.showeco
if (not WG.metalSpots and (spGetMapDrawMode() == "metal") ~= WG.showeco) then
spSendCommands("showmetalmap")
end
end
WG.ToggleShoweco = ToggleShoweco
--------------------------------------------------------------------------------------
--Grid drawing. Copied and trimmed from unit_mex_overdrive.lua gadget (by licho & googlefrog)
VFS.Include("LuaRules/Configs/constants.lua", nil, VFS.ZIP_FIRST)
VFS.Include("LuaRules/Utilities/glVolumes.lua") --have to import this incase it fail to load before this widget
local spGetSelectedUnits = Spring.GetSelectedUnits
local spGetUnitDefID = Spring.GetUnitDefID
local spGetUnitPosition = Spring.GetUnitPosition
local spGetActiveCommand = Spring.GetActiveCommand
local spTraceScreenRay = Spring.TraceScreenRay
local spGetMouseState = Spring.GetMouseState
local spAreTeamsAllied = Spring.AreTeamsAllied
local spGetMyTeamID = Spring.GetMyTeamID
local spGetUnitPosition = Spring.GetUnitPosition
local spValidUnitID = Spring.ValidUnitID
local spGetUnitRulesParam = Spring.GetUnitRulesParam
local spGetSpectatingState = Spring.GetSpectatingState
local spGetBuildFacing = Spring.GetBuildFacing
local spPos2BuildPos = Spring.Pos2BuildPos
local glVertex = gl.Vertex
local glCallList = gl.CallList
local glColor = gl.Color
local glCreateList = gl.CreateList
--// gl const
local pylons = {count = 0, data = {}}
local pylonByID = {}
local pylonDefs = {}
local isBuilder = {}
local floatOnWater = {}
for i=1,#UnitDefs do
local udef = UnitDefs[i]
local range = tonumber(udef.customParams.pylonrange)
if (range and range > 0) then
pylonDefs[i] = range
end
if udef.isBuilder then
isBuilder[i] = true
end
if udef.floatOnWater then
floatOnWater[i] = true
end
end
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
-- Utilities
local drawList = 0
local disabledDrawList = 0
local lastDrawnFrame = 0
local lastFrame = 2
local highlightQueue = false
local prevCmdID
local lastCommandsCount
local function ForceRedraw()
lastDrawnFrame = 0
end
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
-- Menu Options
local drawAlpha = 0.2
WG.showeco_always_mexes = true -- No OnChange when not changed from the default.
options_path = 'Settings/Interface/Economy Overlay'
options_order = {'start_with_showeco', 'always_show_mexes', 'mergeCircles', 'drawQueued'}
options = {
start_with_showeco = {
name = "Start with economy overlay",
desc = "Game starts with Economy Overlay enabled",
type = 'bool',
value = false,
noHotkey = true,
OnChange = function(self)
if (self.value) then
WG.showeco = self.value
end
end,
},
always_show_mexes = {
name = "Always show Mexes",
desc = "Show metal extractors even when the full economy overlay is not enabled.",
type = 'bool',
value = true,
OnChange = function(self)
WG.showeco_always_mexes = self.value
end,
},
mergeCircles = {
name = "Draw merged grid circles",
desc = "Merge overlapping grid circle visualisation. Does not work on older hardware and should automatically disable.",
type = 'bool',
value = true,
OnChange = ForceRedraw,
},
drawQueued = {
name = "Draw grid in queue",
desc = "Shows the grid of not-yet constructed buildings in the queue of a selected constructor. Activates only when placing grid structures.",
type = 'bool',
value = true,
OnChange = ForceRedraw,
},
}
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
-- local functions
local disabledColor = { 0.6,0.7,0.5, drawAlpha}
local placementColor = { 0.6, 0.7, 0.5, drawAlpha} -- drawAlpha on purpose!
local GetGridColor = VFS.Include("LuaUI/Headers/overdrive.lua")
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
-- Unit Handling
local function addUnit(unitID, unitDefID, unitTeam)
if pylonDefs[unitDefID] and not pylonByID[unitID] then
local spec, fullview = spGetSpectatingState()
spec = spec or fullview
if spec or spAreTeamsAllied(unitTeam, spGetMyTeamID()) then
local x,y,z = spGetUnitPosition(unitID)
pylons.count = pylons.count + 1
pylons.data[pylons.count] = {unitID = unitID, x = x, y = y, z = z, range = pylonDefs[unitDefID]}
pylonByID[unitID] = pylons.count
end
end
end
local function removeUnit(unitID, unitDefID, unitTeam)
pylons.data[pylonByID[unitID]] = pylons.data[pylons.count]
pylonByID[pylons.data[pylons.count].unitID] = pylonByID[unitID]
pylons.data[pylons.count] = nil
pylons.count = pylons.count - 1
pylonByID[unitID] = nil
end
function widget:UnitCreated(unitID, unitDefID, unitTeam)
addUnit(unitID, unitDefID, unitTeam)
end
function widget:UnitDestroyed(unitID, unitDefID, unitTeam)
if pylonByID[unitID] then
removeUnit(unitID, unitDefID, unitTeam)
end
end
function widget:UnitGiven(unitID, unitDefID, unitTeam, oldTeam)
addUnit(unitID, unitDefID, unitTeam)
end
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
local function InitializeUnits()
pylons = {count = 0, data = {}}
pylonByID = {}
local allUnits = Spring.GetAllUnits()
for i=1, #allUnits do
local unitID = allUnits[i]
local unitDefID = spGetUnitDefID(unitID)
local unitTeam = Spring.GetUnitTeam(unitID)
widget:UnitCreated(unitID, unitDefID, unitTeam)
end
end
local prevFullView = false
local prevTeamID = -1
function widget:Update(dt)
local teamID = Spring.GetMyTeamID()
local _, fullView = Spring.GetSpectatingState()
if (fullView ~= prevFullView) or (teamID ~= prevTeamID) then
InitializeUnits()
end
prevFullView = fullView
prevTeamID = teamID
end
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
-- Drawing
function widget:Initialize()
InitializeUnits()
end
function widget:Shutdown()
gl.DeleteList(drawList or 0)
gl.DeleteList(disabledDrawList or 0)
end
function widget:GameFrame(f)
if f%32 == 2 then
lastFrame = f
end
end
local function makePylonListVolume(onlyActive, onlyDisabled)
local drawGroundCircle = options.mergeCircles.value and gl.Utilities.DrawMergedGroundCircle or gl.Utilities.DrawGroundCircle
local i = 1
while i <= pylons.count do
local data = pylons.data[i]
local unitID = data.unitID
if spValidUnitID(unitID) then
local efficiency = spGetUnitRulesParam(unitID, "gridefficiency") or -1
if efficiency == -1 and not onlyActive then
glColor(disabledColor)
drawGroundCircle(data.x, data.z, data.range)
elseif efficiency ~= -1 and not onlyDisabled then
local color = GetGridColor(efficiency, drawAlpha)
glColor(color)
drawGroundCircle(data.x, data.z, data.range)
end
i = i + 1
else
pylons.data[i] = pylons.data[pylons.count]
pylonByID[pylons.data[i].unitID] = i
pylons.data[pylons.count] = nil
pylons.count = pylons.count - 1
end
end
if highlightQueue and not onlyActive then
local selUnits = spGetSelectedUnits()
for i=1,#selUnits do
local unitID = selUnits[i]
local unitDefID = spGetUnitDefID(unitID)
if unitDefID and isBuilder[unitDefID] then
local cmdQueue = Spring.GetCommandQueue(unitID, -1)
if cmdQueue then
for i = 1, #cmdQueue do
local cmd = cmdQueue[i]
local radius = pylonDefs[-cmd.id]
if radius then
glColor(disabledColor)
drawGroundCircle(cmd.params[1], cmd.params[3], radius)
end
end
end
break
end
end
end
-- Keep clean for everyone after us
gl.Clear(GL.STENCIL_BUFFER_BIT, 0)
end
local function HighlightPylons()
if lastDrawnFrame < lastFrame then
lastDrawnFrame = lastFrame
if options.mergeCircles.value then
gl.DeleteList(disabledDrawList or 0)
disabledDrawList = gl.CreateList(makePylonListVolume, false, true)
gl.DeleteList(drawList or 0)
drawList = gl.CreateList(makePylonListVolume, true, false)
else
gl.DeleteList(drawList or 0)
drawList = gl.CreateList(makePylonListVolume)
end
end
gl.CallList(drawList)
if options.mergeCircles.value then
gl.CallList(disabledDrawList)
end
end
local function HighlightPlacement(unitDefID)
if not unitDefID then
return
end
local mx, my = spGetMouseState()
local _, coords = spTraceScreenRay(mx, my, true, true, false, not floatOnWater[unitDefID])
if coords then
local radius = pylonDefs[unitDefID]
if (radius ~= 0) then
local x, _, z = spPos2BuildPos( unitDefID, coords[1], 0, coords[3], spGetBuildFacing())
glColor(placementColor)
gl.Utilities.DrawGroundCircle(x,z, radius)
end
end
end
function widget:SelectionChanged(selectedUnits)
-- force regenerating the lists if we've selected a different unit
lastDrawnFrame = 0
end
function widget:DrawWorldPreUnit()
if Spring.IsGUIHidden() then return end
local _, cmdID = spGetActiveCommand() -- show pylons if pylon is about to be placed
if cmdID ~= prevCmdID then
-- force regenerating the lists if just picked a building to place
lastDrawnFrame = 0
prevCmdID = cmdID
end
if (cmdID) then
if pylonDefs[-cmdID] then
if lastDrawnFrame ~= 0 then
local selUnits = spGetSelectedUnits()
local commandsCount = 0
for i=1,#selUnits do
local unitID = selUnits[i]
local unitDefID = spGetUnitDefID(unitID)
if unitDefID and isBuilder[unitDefID] then
commandsCount = Spring.GetCommandQueue(unitID, 0)
break
end
end
if commandsCount ~= lastCommandsCount then
-- force regenerating the lists if a building was placed/removed
lastCommandsCount = commandsCount
lastDrawnFrame = 0
end
end
highlightQueue = options.drawQueued.value
HighlightPylons()
highlightQueue = false
HighlightPlacement(-cmdID)
glColor(1,1,1,1)
return
end
end
local selUnits = spGetSelectedUnits() -- or show it if its selected
if selUnits then
for i=1,#selUnits do
local ud = spGetUnitDefID(selUnits[i])
if (pylonDefs[ud]) then
HighlightPylons()
glColor(1,1,1,1)
return
end
end
end
local showecoMode = WG.showeco
if showecoMode then
HighlightPylons()
glColor(1,1,1,1)
return
end
end
| gpl-2.0 |
guitaryang/lualib | lmap_test.lua | 1 | 2196 |
local lmap = require"lmap"
local tinsert = table.insert
local function test()
local mm = lmap.new()
mm:insert("gutiar1", 100)
mm:insert("gutiar2", 200)
mm:insert("gutiar3", 300)
mm:insert("gutiar4", 400)
mm:insert("gutiar5", 500)
mm:insert("gutiar6", 600)
mm["guitar7"] = 700
print(mm.guitar7)
mm["guitar7"] = 800
print(mm.guitar7)
mm.guitar7 = 900
print(mm.guitar7)
print(mm.guitar8)
mm.guitar8 = nil
mm:insert(50, 50000)
mm:insert(50, 40000)
print(mm[50])
print("count = ", #mm)
print("count = ", mm:count())
for k, v in mm:pairs() do
print("pairs---k,v=", k,v)
end
local iter = mm:first()
while iter do
print("iter--first---k,v=", iter.k, iter.v)
iter = mm:next(iter)
end
local iter = mm:last()
while iter do
print("iter--last---k,v=", iter.k, iter.v)
iter = mm:prev(iter)
end
--[[
math.randomseed(os.time())
local start = os.clock()
local keyprefix = "robot"
local count = 10000
local record = {}
for i = 1, count do
-- local posfix = math.random(1, count)
local posfix = i
local key = keyprefix .. posfix
local score = math.random(1, 1000 * 10000)
mm[key] = score
tinsert(record, key)
end
collectgarbage()
local k, b = collectgarbage("count")
k = k * 1024 + (b or 0)
print("insert************cost--time=", os.clock() - start, k, mm:count())
local start = os.clock()
for i = 1, 4 do
local key = keyprefix .. i
print(key, mm[key])
end
print("get val------------cost--time=", os.clock() - start, collectgarbage("count"), mm:count())
local lr = #record
if lr > 0 then
local start = os.clock()
for i = 1, count / 2 do
-- local idx = math.random(1, #record)
-- local val = record[math.random(1, #record)]
local posfix = math.random(1, count)
local key = keyprefix .. posfix
if mm:erase(key) then
-- trb:check_valid()
end
end
print("erase************cost--time=", os.clock() - start, collectgarbage("count"), mm:count())
collectgarbage()
end
local start = os.clock()
for i = 1, 400 do
local key = keyprefix .. i
print(key, mm[key])
end
print("get val------------cost--time=", os.clock() - start, collectgarbage("count"), mm:count())
--]]
end
test()
| mit |
CarabusX/Zero-K | scripts/planeheavyfighter.lua | 5 | 3785 | include "constants.lua"
--pieces
local base = piece "base"
local wingR, wingL, wingtipR, wingtipL = piece("wingr", "wingl", "wingtip1", "wingtip2")
local engineR, engineL, thrust1, thrust2, thrust3 = piece("jetr", "jetl", "thrust1", "thrust2", "thrust3")
local missR, missL = piece("m1", "m2")
local smokePiece = {base, engineL, engineR}
--constants
--variables
local gun = false
local RESTORE_DELAY = 150
local FIRE_SLOWDOWN = tonumber(UnitDef.customParams.combat_slowdown)
--signals
local SIG_RESTORE = 2
----------------------------------------------------------
local function getState()
local state = Spring.GetUnitStates(unitID)
return state and state.active
end
function script.Create()
Turn(thrust1, x_axis, -math.rad(90), 1)
Turn(thrust2, x_axis, -math.rad(90), 1)
StartThread(GG.Script.SmokeUnit, unitID, smokePiece)
end
function script.StartMoving()
Turn(engineL, z_axis, -1.57, 1)
Turn(engineR, z_axis, 1.57, 1)
Turn(engineL, y_axis, -1.57, 1)
Turn(engineR, y_axis, 1.57, 1)
Turn(engineL, x_axis, 0, 1)
Turn(engineR, x_axis, 0, 1)
end
function script.StopMoving()
Turn(engineL, z_axis, 0, 1)
Turn(engineR, z_axis, 0, 1)
Turn(engineL, y_axis, 0, 1)
Turn(engineR, y_axis, 0, 1)
Turn(engineL, x_axis, 0, 1)
Turn(engineR, x_axis, 0, 1)
end
function script.QueryWeapon(num)
if gun then
return missR
else
return missL
end
end
function script.AimFromWeapon(num)
return base
end
function script.AimWeapon(num, heading, pitch)
return not (GetUnitValue(COB.CRASHING) == 1)
end
function script.EndBurst(num)
gun = not gun
end
local function RestoreAfterDelay()
Signal(SIG_RESTORE)
SetSignalMask(SIG_RESTORE)
if getState() then
Turn(engineL, z_axis, -1.2, 1)
Turn(engineR, z_axis, 1.2, 1)
Turn(engineL, y_axis, -1.2, 1)
Turn(engineR, y_axis, 1.2, 1)
Turn(engineL, x_axis, 0.6, 1)
Turn(engineR, x_axis, 0.6, 1)
end
Sleep(RESTORE_DELAY)
Spring.SetUnitRulesParam(unitID, "selfMoveSpeedChange", 1)
Spring.SetUnitRulesParam(unitID, "selfTurnSpeedChange", 1)
-- Don't ask me why this must be called twice for planes, Spring is crazy
GG.UpdateUnitAttributes(unitID)
GG.UpdateUnitAttributes(unitID)
if getState() then
script.StartMoving()
else
script.StopMoving()
end
end
function script.BlockShot(num)
if GetUnitValue(GG.Script.CRASHING) == 1 then
return true
else
if Spring.GetUnitRulesParam(unitID, "selfMoveSpeedChange") ~= FIRE_SLOWDOWN then
Spring.SetUnitRulesParam(unitID, "selfMoveSpeedChange", FIRE_SLOWDOWN)
Spring.SetUnitRulesParam(unitID, "selfTurnSpeedChange", 1/FIRE_SLOWDOWN)
GG.UpdateUnitAttributes(unitID)
end
StartThread(RestoreAfterDelay)
return false
end
end
function OnLoadGame()
Spring.SetUnitRulesParam(unitID, "selfMoveSpeedChange", 1)
Spring.SetUnitRulesParam(unitID, "selfTurnSpeedChange", 1)
GG.UpdateUnitAttributes(unitID)
end
function script.Killed(recentDamage, maxHealth)
local severity = recentDamage/maxHealth
if severity < 0.25 then
Explode(base, SFX.NONE)
Explode(wingL, SFX.NONE)
Explode(wingR, SFX.NONE)
return 1
elseif severity < 0.5 or (Spring.GetUnitMoveTypeData(unitID).aircraftState == "crashing") then
Explode(base, SFX.NONE)
Explode(engineL, SFX.SMOKE)
Explode(engineR, SFX.SMOKE)
Explode(wingL, SFX.NONE)
Explode(wingR, SFX.NONE)
return 1
elseif severity < 0.75 then
Explode(engineL, SFX.SMOKE + SFX.FIRE + SFX.EXPLODE)
Explode(engineR, SFX.SMOKE + SFX.FIRE + SFX.EXPLODE)
Explode(wingL, SFX.FALL + SFX.SMOKE)
Explode(wingR, SFX.FALL + SFX.SMOKE)
return 2
else
Explode(base, SFX.SHATTER)
Explode(engineL, SFX.SMOKE + SFX.FIRE + SFX.EXPLODE)
Explode(engineR, SFX.SMOKE + SFX.FIRE + SFX.EXPLODE)
Explode(wingL, SFX.SMOKE + SFX.EXPLODE)
Explode(wingR, SFX.SMOKE + SFX.EXPLODE)
return 2
end
end
| gpl-2.0 |
dbltnk/macro-prototype | loveframes/objects/internal/columnlist/columnlistrow.lua | 1 | 5046 | --[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- columnlistrow class
local newobject = loveframes.NewObject("columnlistrow", "loveframes_object_columnlistrow", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: intializes the element
--]]---------------------------------------------------------
function newobject:initialize(parent, data)
self.type = "columnlistrow"
self.parent = parent
self.colorindex = self.parent.rowcolorindex
self.font = loveframes.basicfontsmall
self.width = 80
self.height = 25
self.textx = 5
self.texty = 5
self.internal = true
self.columndata = data
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover()
-- move to parent if there is a parent
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if visible == false then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawColumnListRow or skins[defaultskin].DrawColumnListRow
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
if not self.visible then
return
end
if self.hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
if not self.visible then
return
end
if self.hover and button == "l" then
local parent1 = self:GetParent()
local parent2 = parent1:GetParent()
local onrowclicked = parent2.OnRowClicked
if onrowclicked then
onrowclicked(parent2, self, self.columndata)
end
end
end
--[[---------------------------------------------------------
- func: SetTextPos(x, y)
- desc: sets the positions of the object's text
--]]---------------------------------------------------------
function newobject:SetTextPos(x, y)
self.textx = x
self.texty = y
end
--[[---------------------------------------------------------
- func: GetTextX()
- desc: gets the object's text x position
--]]---------------------------------------------------------
function newobject:GetTextX()
return self.textx
end
--[[---------------------------------------------------------
- func: GetTextY()
- desc: gets the object's text y position
--]]---------------------------------------------------------
function newobject:GetTextY()
return self.texty
end
--[[---------------------------------------------------------
- func: SetFont(font)
- desc: sets the object's font
--]]---------------------------------------------------------
function newobject:SetFont(font)
self.font = font
end
--[[---------------------------------------------------------
- func: GetFont()
- desc: gets the object's font
--]]---------------------------------------------------------
function newobject:GetFont()
return self.font
end
--[[---------------------------------------------------------
- func: GetColorIndex()
- desc: gets the object's color index
--]]---------------------------------------------------------
function newobject:GetColorIndex()
return self.colorindex
end
--[[---------------------------------------------------------
- func: GetColumnData()
- desc: gets the object's column data
--]]---------------------------------------------------------
function newobject:GetColumnData()
return self.columndata
end | mit |
aledbf/ingress-nginx | rootfs/etc/nginx/lua/configuration.lua | 4 | 6889 | local cjson = require("cjson.safe")
local io = io
local ngx = ngx
local tostring = tostring
local string = string
local table = table
local pairs = pairs
-- this is the Lua representation of Configuration struct in internal/ingress/types.go
local configuration_data = ngx.shared.configuration_data
local certificate_data = ngx.shared.certificate_data
local certificate_servers = ngx.shared.certificate_servers
local ocsp_response_cache = ngx.shared.ocsp_response_cache
local EMPTY_UID = "-1"
local _M = {}
function _M.get_backends_data()
return configuration_data:get("backends")
end
function _M.get_general_data()
return configuration_data:get("general")
end
function _M.get_raw_backends_last_synced_at()
local raw_backends_last_synced_at = configuration_data:get("raw_backends_last_synced_at")
if raw_backends_last_synced_at == nil then
raw_backends_last_synced_at = 1
end
return raw_backends_last_synced_at
end
local function fetch_request_body()
ngx.req.read_body()
local body = ngx.req.get_body_data()
if not body then
-- request body might've been written to tmp file if body > client_body_buffer_size
local file_name = ngx.req.get_body_file()
local file = io.open(file_name, "rb")
if not file then
return nil
end
body = file:read("*all")
file:close()
end
return body
end
local function get_pem_cert(hostname)
local uid = certificate_servers:get(hostname)
if not uid then
return nil
end
return certificate_data:get(uid)
end
local function handle_servers()
if ngx.var.request_method ~= "POST" then
ngx.status = ngx.HTTP_BAD_REQUEST
ngx.print("Only POST requests are allowed!")
return
end
local raw_configuration = fetch_request_body()
local configuration, err = cjson.decode(raw_configuration)
if not configuration then
ngx.log(ngx.ERR, "could not parse configuration: ", err)
ngx.status = ngx.HTTP_BAD_REQUEST
return
end
local err_buf = {}
for server, uid in pairs(configuration.servers) do
if uid == EMPTY_UID then
-- notice that we do not delete certificate corresponding to this server
-- this is because a certificate can be used by multiple servers/hostnames
certificate_servers:delete(server)
else
local success, set_err, forcible = certificate_servers:set(server, uid)
if not success then
local err_msg = string.format("error setting certificate for %s: %s\n",
server, tostring(set_err))
table.insert(err_buf, err_msg)
end
if forcible then
local msg = string.format("certificate_servers dictionary is full, "
.. "LRU entry has been removed to store %s", server)
ngx.log(ngx.WARN, msg)
end
end
end
for uid, cert in pairs(configuration.certificates) do
-- don't delete the cache here, certificate_data[uid] is not replaced yet.
-- there is small chance that nginx worker still get the old certificate,
-- then fetch and cache the old OCSP Response
local old_cert = certificate_data:get(uid)
local is_renew = (old_cert ~= nil and old_cert ~= cert)
local success, set_err, forcible = certificate_data:set(uid, cert)
if success then
-- delete ocsp cache after certificate_data:set succeed
if is_renew then
ocsp_response_cache:delete(uid)
end
else
local err_msg = string.format("error setting certificate for %s: %s\n",
uid, tostring(set_err))
table.insert(err_buf, err_msg)
end
if forcible then
local msg = string.format("certificate_data dictionary is full, "
.. "LRU entry has been removed to store %s", uid)
ngx.log(ngx.WARN, msg)
end
end
if #err_buf > 0 then
ngx.log(ngx.ERR, table.concat(err_buf))
ngx.status = ngx.HTTP_INTERNAL_SERVER_ERROR
return
end
ngx.status = ngx.HTTP_CREATED
end
local function handle_general()
if ngx.var.request_method == "GET" then
ngx.status = ngx.HTTP_OK
ngx.print(_M.get_general_data())
return
end
if ngx.var.request_method ~= "POST" then
ngx.status = ngx.HTTP_BAD_REQUEST
ngx.print("Only POST and GET requests are allowed!")
return
end
local config = fetch_request_body()
local success, err = configuration_data:safe_set("general", config)
if not success then
ngx.status = ngx.HTTP_INTERNAL_SERVER_ERROR
ngx.log(ngx.ERR, "error setting general config: " .. tostring(err))
return
end
ngx.status = ngx.HTTP_CREATED
end
local function handle_certs()
if ngx.var.request_method ~= "GET" then
ngx.status = ngx.HTTP_BAD_REQUEST
ngx.print("Only GET requests are allowed!")
return
end
local query = ngx.req.get_uri_args()
if not query["hostname"] then
ngx.status = ngx.HTTP_BAD_REQUEST
ngx.print("Hostname must be specified.")
return
end
local key = get_pem_cert(query["hostname"])
if key then
ngx.status = ngx.HTTP_OK
ngx.print(key)
return
else
ngx.status = ngx.HTTP_NOT_FOUND
ngx.print("No key associated with this hostname.")
return
end
end
local function handle_backends()
if ngx.var.request_method == "GET" then
ngx.status = ngx.HTTP_OK
ngx.print(_M.get_backends_data())
return
end
local backends = fetch_request_body()
if not backends then
ngx.log(ngx.ERR, "dynamic-configuration: unable to read valid request body")
ngx.status = ngx.HTTP_BAD_REQUEST
return
end
local success, err = configuration_data:set("backends", backends)
if not success then
ngx.log(ngx.ERR, "dynamic-configuration: error updating configuration: " .. tostring(err))
ngx.status = ngx.HTTP_BAD_REQUEST
return
end
ngx.update_time()
local raw_backends_last_synced_at = ngx.time()
success, err = configuration_data:set("raw_backends_last_synced_at", raw_backends_last_synced_at)
if not success then
ngx.log(ngx.ERR, "dynamic-configuration: error updating when backends sync, " ..
"new upstream peers waiting for force syncing: " .. tostring(err))
ngx.status = ngx.HTTP_BAD_REQUEST
return
end
ngx.status = ngx.HTTP_CREATED
end
function _M.call()
if ngx.var.request_method ~= "POST" and ngx.var.request_method ~= "GET" then
ngx.status = ngx.HTTP_BAD_REQUEST
ngx.print("Only POST and GET requests are allowed!")
return
end
if ngx.var.request_uri == "/configuration/servers" then
handle_servers()
return
end
if ngx.var.request_uri == "/configuration/general" then
handle_general()
return
end
if ngx.var.uri == "/configuration/certs" then
handle_certs()
return
end
if ngx.var.request_uri == "/configuration/backends" then
handle_backends()
return
end
ngx.status = ngx.HTTP_NOT_FOUND
ngx.print("Not found!")
end
setmetatable(_M, {__index = { handle_servers = handle_servers }})
return _M
| apache-2.0 |
williamhogman/dsv-gamejam16 | hump/vector.lua | 20 | 5319 | --[[
Copyright (c) 2010-2013 Matthias Richter
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
Except as contained in this notice, the name(s) of the above copyright holders
shall not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
]]--
local assert = assert
local sqrt, cos, sin, atan2 = math.sqrt, math.cos, math.sin, math.atan2
local vector = {}
vector.__index = vector
local function new(x,y)
return setmetatable({x = x or 0, y = y or 0}, vector)
end
local zero = new(0,0)
local function isvector(v)
return type(v) == 'table' and type(v.x) == 'number' and type(v.y) == 'number'
end
function vector:clone()
return new(self.x, self.y)
end
function vector:unpack()
return self.x, self.y
end
function vector:__tostring()
return "("..tonumber(self.x)..","..tonumber(self.y)..")"
end
function vector.__unm(a)
return new(-a.x, -a.y)
end
function vector.__add(a,b)
assert(isvector(a) and isvector(b), "Add: wrong argument types (<vector> expected)")
return new(a.x+b.x, a.y+b.y)
end
function vector.__sub(a,b)
assert(isvector(a) and isvector(b), "Sub: wrong argument types (<vector> expected)")
return new(a.x-b.x, a.y-b.y)
end
function vector.__mul(a,b)
if type(a) == "number" then
return new(a*b.x, a*b.y)
elseif type(b) == "number" then
return new(b*a.x, b*a.y)
else
assert(isvector(a) and isvector(b), "Mul: wrong argument types (<vector> or <number> expected)")
return a.x*b.x + a.y*b.y
end
end
function vector.__div(a,b)
assert(isvector(a) and type(b) == "number", "wrong argument types (expected <vector> / <number>)")
return new(a.x / b, a.y / b)
end
function vector.__eq(a,b)
return a.x == b.x and a.y == b.y
end
function vector.__lt(a,b)
return a.x < b.x or (a.x == b.x and a.y < b.y)
end
function vector.__le(a,b)
return a.x <= b.x and a.y <= b.y
end
function vector.permul(a,b)
assert(isvector(a) and isvector(b), "permul: wrong argument types (<vector> expected)")
return new(a.x*b.x, a.y*b.y)
end
function vector:len2()
return self.x * self.x + self.y * self.y
end
function vector:len()
return sqrt(self.x * self.x + self.y * self.y)
end
function vector.dist(a, b)
assert(isvector(a) and isvector(b), "dist: wrong argument types (<vector> expected)")
local dx = a.x - b.x
local dy = a.y - b.y
return sqrt(dx * dx + dy * dy)
end
function vector.dist2(a, b)
assert(isvector(a) and isvector(b), "dist: wrong argument types (<vector> expected)")
local dx = a.x - b.x
local dy = a.y - b.y
return (dx * dx + dy * dy)
end
function vector:normalizeInplace()
local l = self:len()
if l > 0 then
self.x, self.y = self.x / l, self.y / l
end
return self
end
function vector:normalized()
return self:clone():normalizeInplace()
end
function vector:rotateInplace(phi)
local c, s = cos(phi), sin(phi)
self.x, self.y = c * self.x - s * self.y, s * self.x + c * self.y
return self
end
function vector:rotated(phi)
local c, s = cos(phi), sin(phi)
return new(c * self.x - s * self.y, s * self.x + c * self.y)
end
function vector:perpendicular()
return new(-self.y, self.x)
end
function vector:projectOn(v)
assert(isvector(v), "invalid argument: cannot project vector on " .. type(v))
-- (self * v) * v / v:len2()
local s = (self.x * v.x + self.y * v.y) / (v.x * v.x + v.y * v.y)
return new(s * v.x, s * v.y)
end
function vector:mirrorOn(v)
assert(isvector(v), "invalid argument: cannot mirror vector on " .. type(v))
-- 2 * self:projectOn(v) - self
local s = 2 * (self.x * v.x + self.y * v.y) / (v.x * v.x + v.y * v.y)
return new(s * v.x - self.x, s * v.y - self.y)
end
function vector:cross(v)
assert(isvector(v), "cross: wrong argument types (<vector> expected)")
return self.x * v.y - self.y * v.x
end
-- ref.: http://blog.signalsondisplay.com/?p=336
function vector:trimInplace(maxLen)
local s = maxLen * maxLen / self:len2()
s = (s > 1 and 1) or math.sqrt(s)
self.x, self.y = self.x * s, self.y * s
return self
end
function vector:angleTo(other)
if other then
return atan2(self.y, self.x) - atan2(other.y, other.x)
end
return atan2(self.y, self.x)
end
function vector:trimmed(maxLen)
return self:clone():trimInplace(maxLen)
end
-- the module
return setmetatable({new = new, isvector = isvector, zero = zero},
{__call = function(_, ...) return new(...) end})
| mit |
tgp1994/LiquidRP-tgp1994 | gamemode/liquiddrp/cl_qmenu.lua | 1 | 15039 | if LDRP_SH.DisableQMenu then return end
local LDRP = {}
function LDRP.QMenuHUD()
if LDRP.QMenuStr then
local Font = (string.len(LDRP.QMenuStr) > 28 and "Trebuchet24") or "HUDNumber5"
draw.SimpleTextOutlined(LDRP.QMenuStr, Font, ScrW()*.5, ScrH()*.03, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, Color(0,0,0) )
end
end
hook.Add("HUDPaint","Shows that they added to favs",LDRP.QMenuHUD)
function LDRP.SetQMenuStr(text,time)
LDRP.QMenuStr = text
timer.Create("ResetStr0",time,1,function()
LDRP.QMenuStr = nil
end)
end
local function MC(a) return math.Clamp(a,0,255) end
local function LDRPColorMod(r,g,b,a)
local Clrs = LDRP_Theme[LDRP_Theme.CurrentSkin].BGColor
return Color(MC(Clrs.r+r),MC(Clrs.g+g),MC(Clrs.b+b),MC(Clrs.a+a))
end
local OldVGUICreate = vgui.Create
function vgui.Create(classnamE, parent, name, ...)
local classname = classnamE
if classname == "SpawnIconMenu" then
classname = "SpawnIcon"
local SpawnIcon = OldVGUICreate(classname, parent, name, ...)
timer.Simple(0, function() -- The .OpenMenu function will be there the next frame
if not SpawnIcon.OpenMenu or not SpawnIcon.Mdl then return end
local model = string.match(SpawnIcon.Mdl, "(.*.mdl)")
if not model then return end
function SpawnIcon:OpenMenu()
local menu = DermaMenu()
menu:AddOption(((SpawnIcon.Section == "Favorites" and "Remove from favorites") or "Add to favorites"), function()
if SpawnIcon.Section == "Favorites" then
table.remove(LDRP.Props["Favorites"], table.KeyFromValue(LDRP.Props["Favorites"],model))
SpawnIcon:Remove()
SpawnIcon.RefreshList()
LDRP.SetQMenuStr("Removed prop from favorites.",3)
else
if table.HasValue(LDRP.Props["Favorites"], model) then LDRP.SetQMenuStr("Prop already in favorites!",3) return end
table.insert(LDRP.Props["Favorites"], model)
LDRP.SetQMenuStr("Added prop to favorites.",3)
end
LocalPlayer():EmitSound("UI/buttonrollover.wav",60,120)
LDRP_SH.SaveFavs()
end)
menu:AddOption("Copy to Clipboard", function() SetClipboardText(model) end)
if LocalPlayer():IsAdmin() then menu:AddOption("Add/remove to prop blacklist", function() RunConsoleCommand("_protector","model",model) end) end
menu:Open()
end
end)
return SpawnIcon
end
return OldVGUICreate(classname, parent, name, ...)
end
LDRP.Tools = LDRP_SH.Tools --Moved down
--[[-----------------------------------------------
AssociateToolData - Find all of the client's
tools, and then filter them out based on the
allowed tools present in LDRP.Tools. This has
the advantage of only showing tools that are
actually installed in the server, even if
invalid tools are specified in LDRP.Tools.
raw_tools = A table with the tool names as
strings.
--------------------------------------------------]]
local function AssociateToolData(raw_tools)
local newtable = {}
for k, v in pairs(spawnmenu.GetTools()[1].Items) do --In the "Main" tools tab
for a, b in ipairs(v) do --Navigate through the categories (Constraints, Construction, etc.)
for c, d in ipairs(raw_tools) do --Run through the allowed tools table, and associate any found info
if string.lower(d) == b.ItemName then
table.Add(newtable, {b})
break
end
end
end
end
return newtable
end
LDRP.Props = LDRP_SH.Props
LDRP.ContextType = "-"
hook.Add("InitPostEntity", "GiveAdminControls", function()
if LocalPlayer():IsAdmin() then
LDRP.AdminControls = LDRP_SH.AdminControls
end
end)
--[[-------------------------------------------------------
LDRP Spawn menu VGUI code
Moved from the OnSpawnMenuOpen section
]]---------------------------------------------------------
local PANEL = {}
function PANEL:Init()
self.m_bHangOpen = false
self.Opened = {} --Replaces LDRP.Opened = {}
self.CurSpawnList = {}
LDRP.Tools = AssociateToolData(LDRP.Tools)
LDRP.VIPTools = AssociateToolData( LDRP_SH.VIPTools )
table.sort(LDRP.Tools, function(a,b) return b.ItemName > a.ItemName end)
table.sort(LDRP.VIPTools, function(a,b) return b.ItemName > a.ItemName end)
if !LDRP.DontKnow then LDRP.DontKnow = true LDRP.SetQMenuStr("Right click on a prop for adding it to favorites.",6) end
self:CreateBG("Props",ScrW()*.05,ScrH()*.05,ScrW()*.625,ScrH()*.9)
self:CreateBG("Tools",ScrW()*.68,ScrH()*.05,ScrW()*.25,ScrH()*.9)
self.PropList = vgui.Create("DPanelList", self.Opened["Props"])
self.PropList:SetPos(12,ScrH()*.08)
self.PropList:SetSize(ScrW()*.625-24,ScrH()*.82-12)
self.PropList:SetSpacing(4)
self.PropList:SetPadding(4)
self.PropList:EnableHorizontal(true)
self.PropList:EnableVerticalScrollbar(true)
function self.PropList:RefreshList()
timer.Simple(.01,function()
if !self:IsValid() then return end
self:PerformLayout()
self.VBar:SetScroll( 1 )
end)
end
self:SetPropList(LDRP.LastTab or "Construction")
local Sections = 0
LDRP.Props["Context Menu"] = {}
if LocalPlayer():IsAdmin() or LocalPlayer():IsUserGroup("Moderator") then
LDRP.Props["Mod Controls"] = {}
end
for k,v in pairs(LDRP.Props) do
local SectionButton = vgui.Create("DButton", self.Opened["Props"])
SectionButton:SetPos(12+Sections, ScrH()*.05)
SectionButton:SetText(k)
local width = string.len(k)*10
SectionButton:SetSize(width, 22)
Sections = Sections + width + 4
SectionButton.DoClick = function(btn)
if k == "Context Menu" then
LDRP.ContextType = (LDRP.ContextType == "-" and "+") or "-"
if LDRP.ContextType == "+" then LDRP.SetQMenuStr("Press this again to close it.",3) end
RunConsoleCommand(LDRP.ContextType .. "menu_context")
return
elseif k == "Mod Controls" then
for k,v in pairs(self.CurSpawnList) do
if v:IsValid() then v:Remove() end
end
self.CurSpawnList = {}
for k,v in pairs(LDRP.AdminControls) do
local button = vgui.Create("DButton", self.PropList)
button:SetText(k)
button:SetSize(ScrW()*.625-32,ScrH()*.05)
button:SetToolTip(v.descrpt)
if v.sv then
button.DoClick = function() RunConsoleCommand(v.sv) end
else
button.DoClick = v.func
end
self.PropList:AddItem(button)
table.insert(self.CurSpawnList, button)
end
self.PropList:RefreshList()
LDRP.LastTab = "Mod Controls"
return
end
self:SetPropList(k)
LocalPlayer():EmitSound("UI/buttonclick.wav",60,150)
end
end
--Prep the tool menu
self.ToolList = vgui.Create("DPropertySheet", self.Opened["Tools"])
self.ToolList.ToolPanels = {}
self.ToolList:SetPos(12,ScrH()*.06)
self.ToolList:SetSize(ScrW()*.25-24, (ScrH()*.84-12) / 2)
function self.ToolList:GetToolPanel( id )
return self.ToolPanels[ id ]
end
local toolMenu = self.Opened["Tools"]
local tools = vgui.Create( "DScrollPanel" )
tools.List = tools
local function GenerateToolButton( toolMode )
local ToolButton = vgui.Create( "DButton" )
ToolButton:SetText(toolMode.Text)
ToolButton.DoClick = function(btn)
if ( btn.Command ) then
LocalPlayer():ConCommand( btn.Command )
end
local cp = controlpanel.Get( btn.Name )
if ( !cp:GetInitialized() ) then
cp:FillViaTable( btn )
end
spawnmenu.ActivateToolPanel( 1, cp)
LocalPlayer():EmitSound("buttons/lightswitch2.wav")
end
ToolButton.Name = toolMode.ItemName
ToolButton.ControlPanelBuildFunction = toolMode.CPanelFunction
ToolButton.Command = toolMode.Command
ToolButton.Controls = toolMode.Controls
ToolButton.Text = toolMode.Text
ToolButton:Dock( TOP )
return ToolButton
end
for k, v in pairs( LDRP.VIPTools ) do
local ToolButton = tools:Add( GenerateToolButton ( v ) )
ToolButton:SetImage( "icon16/star.png" )
end
for k, v in pairs( LDRP.Tools ) do
local ToolButton = tools:Add( GenerateToolButton( v ) )
end
self.ToolList.ToolPanels[ 1 ] = tools
self.ToolList:AddSheet("Tools", tools, "icon16/wrench.png")
tools.SetActive = function( self2, cp )
self.ControlPanel:SetActive( cp )
end
self:LoadTools()
self.ControlPanel = vgui.Create("DCategoryList", self.Opened["Tools"])
self.ControlPanel:SetPos(12, ((ScrH()*.84) / 2) + 48)
self.ControlPanel:SetSize(ScrW()*.25-24, (ScrH()*.84-12) / 2)
self.ControlPanel.ClearControls = function( panel )
panel:Clear()
end
function self.ControlPanel:SetActive( cp )
local kids = self:GetCanvas():GetChildren()
for k, v in pairs( kids ) do
v:SetVisible( false )
end
self:AddItem( cp )
cp:SetVisible( true )
cp:Dock( TOP )
end
end
--[[ LoadTools
Load all tool _menus_ given from spawnmenu.GetTools()
]]
function PANEL:LoadTools()
local tools = spawnmenu.GetTools()
for strName, pTable in pairs( tools ) do
if pTable.Name ~= "AAAAAAA_Main" then
local toolPanel = vgui.Create("ToolPanel")
toolPanel.Content:Remove()
toolPanel.Content = nil
toolPanel.List:StretchToParent(nil, nil, 0, nil)
toolPanel:SetTabID(strName)
toolPanel:LoadToolsFromTable(pTable.Items)
toolPanel.SetActive = function( self2, cp )
self.ControlPanel:SetActive( cp )
end
self.ToolList:AddSheet(pTable.Label, toolPanel, pTable.Icon)
self.ToolList.ToolPanels[ strName ] = toolPanel
end
end
end
function PANEL:GetToolMenu()
return self.ToolList
end
function PANEL:CreateBG(name, x, y, w, h)
local BackGroundWindow
BackGroundWindow = vgui.Create("DFrame")
self.Opened[name] = BackGroundWindow
BackGroundWindow:SetPos(x,y)
BackGroundWindow:SetSize(w,h)
BackGroundWindow:MakePopup()
BackGroundWindow:SetDraggable(false)
BackGroundWindow:ShowCloseButton(false)
BackGroundWindow:SetTitle("")
BackGroundWindow:SetParent(self)
BackGroundWindow.Paint = function()
draw.RoundedBox( 8, 0, 0, w, h, LDRPColorMod(0,0,0,-40) )
draw.RoundedBox( 8, 6, 6, w-12, h-12, LDRPColorMod(40,40,40,-40) )
draw.SimpleTextOutlined(name, "HUDNumber5", w*.5, h*.03, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, Color(0,0,0) )
end
end
function PANEL:SetPropList(section)
if self.QOpened == section then return end
LDRP.LastTab = section
self.QOpened = section
for k,v in pairs(self.CurSpawnList) do
if v:IsValid() then v:Remove() end
end
self.CurSpawnList = {}
for k,v in pairs(LDRP.Props[section]) do
local PropIcon = vgui.Create("SpawnIconMenu", self.PropList)
PropIcon:SetModel(v)
PropIcon:SetSize(81, 81)
PropIcon.Mdl = v
PropIcon.Section = section
PropIcon:SetToolTip()
PropIcon.RefreshList = function()
self.PropList:RefreshList()
end
PropIcon.DoClick = function()
RunConsoleCommand("gm_spawn",v)
LocalPlayer():EmitSound("UI/buttonclickrelease.wav",60,150)
end
self.PropList:AddItem(PropIcon)
table.insert(self.CurSpawnList, PropIcon)
end
self.PropList:RefreshList()
end
--We'll have this simply switch to the appropriate menu on the spawn menu.
function PANEL:OpenCreationMenuTab( name )
local createTabs = spawnmenu.GetCreationTabs()
for k,v in pairs(self.CurSpawnList) do
if v:IsValid() then v:Remove() end
end
self.CurSpawnList = {}
local pan = createTabs[ name ].Function()
pan:SetParent( self.PropList )
pan:Dock( FILL )
table.insert( self.CurSpawnList, pan )
self.PropList:RefreshList()
LDRP.LastTab = name
self.QOpened = name
end
function PANEL:HangOpen( bHang )
self.m_bHangOpen = bHang
end
function PANEL:HangingOpen()
return self.m_bHangOpen
end
function PANEL:Open()
RestoreCursorPosition()
self.m_bHangOpen = false
-- If the context menu is open, try to close it..
if ( g_ContextMenu:IsVisible() ) then
g_ContextMenu:Close( true )
end
if ( self:IsVisible() ) then return end
CloseDermaMenus()
self:MakePopup()
self:SetVisible( true )
self:SetKeyboardInputEnabled( false )
self:SetMouseInputEnabled( true )
self:SetAlpha( 255 )
achievements.SpawnMenuOpen()
end
function PANEL:Close( bSkipAnim )
if ( self.m_bHangOpen ) then
self.m_bHangOpen = false
return
end
RememberCursorPosition()
CloseDermaMenus()
self:SetKeyboardInputEnabled( false )
self:SetMouseInputEnabled( false )
self:SetVisible( false )
end
--[[---------------------------------------------------------
Name: StartKeyFocus
-----------------------------------------------------------]]
function PANEL:StartKeyFocus( pPanel )
self.m_pKeyFocus = pPanel
self:SetKeyboardInputEnabled( true )
self:HangOpen( true )
g_ContextMenu:StartKeyFocus( pPanel )
end
--[[---------------------------------------------------------
Name: EndKeyFocus
-----------------------------------------------------------]]
function PANEL:EndKeyFocus( pPanel )
if ( self.m_pKeyFocus != pPanel ) then return end
self:SetKeyboardInputEnabled( false )
g_ContextMenu:EndKeyFocus( pPanel )
end
vgui.Register( "LDRPSpawnMenu", PANEL, "EditablePanel" )
--[[Creates the LDRP spawn menu GUI.
This function wasn't in the original LDRP code,
but I figure making this act more like the default
spawnmenu will fix some compatibility issues
*cough*Tool panels*cough*
]]
local function CreateSpawnMenu()
-- If we have an old spawn menu remove it.
if ( g_SpawnMenu ) then
g_SpawnMenu:Remove()
g_SpawnMenu = nil
end
-- Start Fresh
spawnmenu.ClearToolMenus()
-- Add defaults for the gamemode. In sandbox these defaults
-- are the Main/Postprocessing/Options tabs.
-- They're added first in sandbox so they're always first
hook.Run( "AddGamemodeToolMenuTabs" )
-- Use this hook to add your custom tools
-- This ensures that the default tabs are always
-- first.
hook.Run( "AddToolMenuTabs" )
-- Use this hook to add your custom tools
-- We add the gamemode tool menu categories first
-- to ensure they're always at the top.
hook.Run( "AddGamemodeToolMenuCategories" )
hook.Run( "AddToolMenuCategories" )
-- Add the tabs to the tool menu before trying
-- to populate them with tools.
hook.Run( "PopulateToolMenu" )
g_SpawnMenu = vgui.Create( "LDRPSpawnMenu" )
g_SpawnMenu:SetVisible( false )
CreateContextMenu()
hook.Run( "PostReloadToolsMenu" )
end
function GM:OnSpawnMenuOpen()
-- Let the gamemode decide whether we should open or not..
if ( !hook.Call( "SpawnMenuOpen", GAMEMODE ) ) then return end
if ( g_SpawnMenu ) then
g_SpawnMenu:Open()
end
end
function GM:OnSpawnMenuClose()
if ( g_SpawnMenu ) then g_SpawnMenu:Close() end
-- We're dragging from the spawnmenu but the spawnmenu is closed
-- so keep the dragging going using the screen clicker
if ( dragndrop.IsDragging() ) then
gui.EnableScreenClicker( true )
end
end
-- Hook to create the spawnmenu at the appropriate time (when all sents and sweps are loaded)
-- This is different from the default spawnmenu hook because LocalPlayer is called.
hook.Add( "InitPostEntity", "CreateSpawnMenu", CreateSpawnMenu ) | gpl-3.0 |
rafael/kong | spec/plugins/key-auth/daos_spec.lua | 7 | 2379 | local spec_helper = require "spec.spec_helpers"
local uuid = require "uuid"
local env = spec_helper.get_env()
local dao_factory = env.dao_factory
local faker = env.faker
describe("DAO key-auth Credentials", function()
setup(function()
spec_helper.prepare_db()
end)
it("should not insert in DB if consumer does not exist", function()
-- Without a consumer_id, it's a schema error
local app_t = {name = "key-auth", config = {key_names = {"apikey"}}}
local app, err = dao_factory.keyauth_credentials:insert(app_t)
assert.falsy(app)
assert.truthy(err)
assert.True(err.schema)
assert.are.same("consumer_id is required", err.message.consumer_id)
-- With an invalid consumer_id, it's a FOREIGN error
local app_t = {key = "apikey123", consumer_id = uuid()}
local app, err = dao_factory.keyauth_credentials:insert(app_t)
assert.falsy(app)
assert.truthy(err)
assert.True(err.foreign)
assert.equal("consumer_id "..app_t.consumer_id.." does not exist", err.message.consumer_id)
end)
it("should insert in DB and add generated values", function()
local consumer_t = faker:fake_entity("consumer")
local consumer, err = dao_factory.consumers:insert(consumer_t)
assert.falsy(err)
local cred_t = {key = "apikey123", consumer_id = consumer.id}
local app, err = dao_factory.keyauth_credentials:insert(cred_t)
assert.falsy(err)
assert.truthy(app.key)
assert.are.same("apikey123", app.key)
assert.truthy(app.id)
assert.truthy(app.created_at)
end)
it("should insert an autogenerated key", function()
local consumer_t = faker:fake_entity("consumer")
local consumer, err = dao_factory.consumers:insert(consumer_t)
assert.falsy(err)
local cred_t = {consumer_id = consumer.id}
local app, err = dao_factory.keyauth_credentials:insert(cred_t)
assert.falsy(err)
assert.truthy(app.key)
assert.truthy(app.id)
assert.truthy(app.created_at)
end)
it("should find a Credential by public_key", function()
local app, err = dao_factory.keyauth_credentials:find_by_keys {
key = "user122"
}
assert.falsy(err)
assert.truthy(app)
end)
it("should handle empty strings", function()
local apps, err = dao_factory.keyauth_credentials:find_by_keys {
key = ""
}
assert.falsy(err)
assert.same({}, apps)
end)
end)
| apache-2.0 |
amirmrbad/superbot | plugins/inrealm.lua | 13 | 25404 | -- data saved to moderation.json
-- check moderation plugin
do
local function create_group(msg)
-- superuser and admins only (because sudo are always has privilege)
if is_sudo(msg) or is_realm(msg) and is_admin(msg) then
local group_creator = msg.from.print_name
create_group_chat (group_creator, group_name, ok_cb, false)
return 'گروهی بانام [ '..string.gsub(group_name, '_', ' ')..' ] ساخته شد.'
end
end
local function create_realm(msg)
-- superuser and admins only (because sudo are always has privilege)
if is_sudo(msg) or is_realm(msg) and is_admin(msg) then
local group_creator = msg.from.print_name
create_group_chat (group_creator, group_name, ok_cb, false)
return 'گپ مادر بانام [ '..string.gsub(group_name, '_', ' ')..' ] ساخته شد.'
end
end
local function killchat(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function killrealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function get_group_type(msg)
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
if not data[tostring(msg.to.id)]['group_type'] then
return 'No group type available.'
end
local group_type = data[tostring(msg.to.id)]['group_type']
return group_type
else
return 'Chat type not found.'
end
end
local function callbackres(extra, success, result)
--vardump(result)
local user = result.id
local name = string.gsub(result.print_name, "_", " ")
local chat = 'chat#id'..extra.chatid
send_large_msg(chat, user..'\n'..name)
return user
end
local function set_description(msg, data, target, about)
if not is_admin(msg) then
return "فقط ادمین رباتا"
end
local data_cat = 'description'
data[tostring(target)][data_cat] = about
save_data(_config.moderation.data, data)
return 'قوانین گروه:\n'..about
end
local function set_rules(msg, data, target)
if not is_admin(msg) then
return "فقط ادمین"
end
local data_cat = 'rules'
data[tostring(target)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'قوانین گروه:\n'..rules
end
-- lock/unlock group name. bot automatically change group name when locked
local function lock_group_name(msg, data, target)
if not is_admin(msg) then
return "فقط ادمین!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'غیرفعال' then
return 'اسم گروه قفل است.'
else
data[tostring(target)]['settings']['lock_name'] = 'فعال'
save_data(_config.moderation.data, data)
rename_chat('chat#id'..target, group_name_set, ok_cb, false)
return 'اسم گروه قفل است.'
end
end
local function unlock_group_name(msg, data, target)
if not is_admin(msg) then
return "فقط ادمین"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'غیرفعال' then
return 'اسم گروه آزاد شد.'
else
data[tostring(target)]['settings']['lock_name'] = 'غیر فعال'
save_data(_config.moderation.data, data)
return 'اسم گروه آزاد شد.'
end
end
--lock/unlock group member. bot automatically kick new added user when locked
local function lock_group_member(msg, data, target)
if not is_admin(msg) then
return "فقط ادمین"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'فعال' then
return 'قفل ادد ممبر فعال'
else
data[tostring(target)]['settings']['lock_member'] = 'فعال'
save_data(_config.moderation.data, data)
end
return 'قفل اددممبر فعال'
end
local function unlock_group_member(msg, data, target)
if not is_admin(msg) then
return "فقط ادمین"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'غیرفعال' then
return 'اددممبر قفل نیست'
else
data[tostring(target)]['settings']['lock_member'] = 'غیر فعال'
save_data(_config.moderation.data, data)
return 'قفل ادد ممبر فعال نیست'
end
end
--lock/unlock group photo. bot automatically keep group photo when locked
local function lock_group_photo(msg, data, target)
if not is_admin(msg) then
return "فقط ادمین"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'فعال' then
return 'قفل عکس فعال'
else
data[tostring(target)]['settings']['set_photo'] = 'صبرکنید'
save_data(_config.moderation.data, data)
end
return 'هرعکسی که بفرستی میزارم روی پروفایل گروه'
end
local function unlock_group_photo(msg, data, target)
if not is_admin(msg) then
return "فقط ادمین"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'غیرفعال' then
return 'عکس گروه قفل نیست'
else
data[tostring(target)]['settings']['lock_photo'] = 'غیرفعال'
save_data(_config.moderation.data, data)
return 'قفل عکس گروه غیرفعال شد'
end
end
local function lock_group_flood(msg, data, target)
if not is_admin(msg) then
return "فقط ادمین"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'فعال' then
return 'اسپم قفل شد'
else
data[tostring(target)]['settings']['flood'] = 'فعال'
save_data(_config.moderation.data, data)
return 'اسپم فعال'
end
end
local function unlock_group_flood(msg, data, target)
if not is_admin(msg) then
return "فقط ادمین"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'فعال' then
return 'قفل اسپم غیرفعال'
else
data[tostring(target)]['settings']['flood'] = 'غیرفعال'
save_data(_config.moderation.data, data)
return 'قفل اسپم غیرفعال'
end
end
-- show group settings
local function show_group_settings(msg, data, target)
local data = load_data(_config.moderation.data, data)
if not is_admin(msg) then
return "فقط ادمین"
end
local settings = data[tostring(target)]['settings']
local text = "تنظیمات گروه:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member
return text
end
local function returnids(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
if v.print_name then
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
end
send_large_msg(receiver, text)
local file = io.open("./groups/lists/"..result.id.."لیست افراداینگروه.txt", "w")
file:write(text)
file:flush()
file:close()
end
local function returnidsfile(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
if v.print_name then
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
end
local file = io.open("./groups/lists/"..result.id.."لیست افزاد این گروه.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("chat#id"..result.id,"./groups/lists/"..result.id.."memberlist.txt", ok_cb, false)
end
local function admin_promote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if data[tostring(admins)][tostring(admin_id)] then
return admin_name..' is already an admin.'
end
data[tostring(admins)][tostring(admin_id)] = admin_id
save_data(_config.moderation.data, data)
return admin_id..' has been promoted as admin.'
end
local function admin_demote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if not data[tostring(admins)][tostring(admin_id)] then
return admin_id..' is not an admin.'
end
data[tostring(admins)][tostring(admin_id)] = nil
save_data(_config.moderation.data, data)
return admin_id..' has been demoted from admin.'
end
local function admin_list(msg)
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
local message = 'List for Realm admins:\n'
for k,v in pairs(data[tostring(admins)]) do
message = message .. '- (at)' .. v .. ' [' .. k .. '] ' ..'\n'
end
return message
end
local function groups_list(msg)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] then
return 'No groups at the moment'
end
local message = 'List of groups:\n'
for k,v in pairs(data[tostring(groups)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairs(settings) do
if m == 'set_name' then
name = n
end
end
local group_owner = "No owner"
if data[tostring(v)]['set_owner'] then
group_owner = tostring(data[tostring(v)]['set_owner'])
end
local group_link = "No link"
if data[tostring(v)]['settings']['set_link'] then
group_link = data[tostring(v)]['settings']['set_link']
end
message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n"
end
local file = io.open("./groups/lists/groups.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function realms_list(msg)
local data = load_data(_config.moderation.data)
local realms = 'realms'
if not data[tostring(realms)] then
return 'No Realms at the moment'
end
local message = 'List of Realms:\n'
for k,v in pairs(data[tostring(realms)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairs(settings) do
if m == 'set_name' then
name = n
end
end
local group_owner = "No owner"
if data[tostring(v)]['admins_in'] then
group_owner = tostring(data[tostring(v)]['admins_in'])
end
local group_link = "No link"
if data[tostring(v)]['settings']['set_link'] then
group_link = data[tostring(v)]['settings']['set_link']
end
message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n"
end
local file = io.open("./groups/lists/realms.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function admin_user_promote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
if not data['admins'] then
data['admins'] = {}
save_data(_config.moderation.data, data)
end
if data['admins'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is already as admin.')
end
data['admins'][tostring(member_id)] = member_username
save_data(_config.moderation.data, data)
return send_large_msg(receiver, '@'..member_username..' has been promoted as admin.')
end
local function admin_user_demote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
if not data['admins'] then
data['admins'] = {}
save_data(_config.moderation.data, data)
end
if not data['admins'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is not an admin.')
end
data['admins'][tostring(member_id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Admin '..member_username..' has been demoted.')
end
local function username_id(cb_extra, success, result)
local mod_cmd = cb_extra.mod_cmd
local receiver = cb_extra.receiver
local member = cb_extra.member
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.id
if mod_cmd == 'addadmin' then
return admin_user_promote(receiver, member_username, member_id)
elseif mod_cmd == 'removeadmin' then
return admin_user_demote(receiver, member_username, member_id)
end
end
end
send_large_msg(receiver, text)
end
local function set_log_group(msg)
if not is_admin(msg) then
return
end
local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group']
if log_group == 'yes' then
return 'Log group is already set'
else
data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'yes'
save_data(_config.moderation.data, data)
return 'Log group has been set'
end
end
local function unset_log_group(msg)
if not is_admin(msg) then
return
end
local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group']
if log_group == 'no' then
return 'Log group is already disabled'
else
data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'no'
save_data(_config.moderation.data, data)
return 'log group has been disabled'
end
end
local function help()
local help_text = tostring(_config.help_text_realm)
return help_text
end
function run(msg, matches)
--vardump(msg)
local name_log = user_print_name(msg.from)
if matches[1] == 'log' and is_owner(msg) then
savelog(msg.to.id, "log file created by owner")
send_document("chat#id"..msg.to.id,"./groups/"..msg.to.id.."log.txt", ok_cb, false)
end
if matches[1] == 'who' and is_momod(msg) then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list ")
local receiver = get_receiver(msg)
chat_info(receiver, returnidsfile, {receiver=receiver})
end
if matches[1] == 'wholist' and is_momod(msg) then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list in a file")
local receiver = get_receiver(msg)
chat_info(receiver, returnids, {receiver=receiver})
end
if matches[1] == 'creategroup' and matches[2] then
group_name = matches[2]
group_type = 'group'
return create_group(msg)
end
if not is_sudo(msg) or not is_admin(msg) and not is_realm(msg) then
return --Do nothing
end
if matches[1] == 'createrealm' and matches[2] then
group_name = matches[2]
group_type = 'realm'
return create_realm(msg)
end
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if matches[2] then if data[tostring(matches[2])] then
local settings = data[tostring(matches[2])]['settings']
if matches[1] == 'setabout' and matches[2] then
local target = matches[2]
local about = matches[3]
return set_description(msg, data, target, about)
end
if matches[1] == 'setrules' then
rules = matches[3]
local target = matches[2]
return set_rules(msg, data, target)
end
if matches[1] == 'lock' then --group lock *
local target = matches[2]
if matches[3] == 'name' then
return lock_group_name(msg, data, target)
end
if matches[3] == 'member' then
return lock_group_member(msg, data, target)
end
if matches[3] == 'photo' then
return lock_group_photo(msg, data, target)
end
if matches[3] == 'flood' then
return lock_group_flood(msg, data, target)
end
end
if matches[1] == 'unlock' then --group unlock *
local target = matches[2]
if matches[3] == 'name' then
return unlock_group_name(msg, data, target)
end
if matches[3] == 'member' then
return unlock_group_member(msg, data, target)
end
if matches[3] == 'photo' then
return unlock_group_photo(msg, data, target)
end
if matches[3] == 'flood' then
return unlock_group_flood(msg, data, target)
end
end
if matches[1] == 'settings' and data[tostring(matches[2])]['settings'] then
local target = matches[2]
return show_group_settings(msg, data, target)
end
if matches[1] == 'setname' and is_realm(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)
savelog(msg.to.id, "Realm { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
if matches[1] == 'setgpname' and is_admin(msg) then
local new_name = string.gsub(matches[3], '_', ' ')
data[tostring(matches[2])]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(matches[2])]['settings']['set_name']
local to_rename = 'chat#id'..matches[2]
rename_chat(to_rename, group_name_set, ok_cb, false)
savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
end
end
if matches[1] == 'help' and is_realm(msg) then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help")
return help()
end
if matches[1] == 'set' then
if matches[2] == 'loggroup' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set as log group")
return set_log_group(msg)
end
end
if matches[1] == 'kill' and matches[2] == 'chat' then
if not is_admin(msg) then
return nil
end
if is_realm(msg) then
local receiver = 'chat#id'..matches[3]
return modrem(msg),
print("Closing Group: "..receiver),
chat_info(receiver, killchat, {receiver=receiver})
else
return 'Error: Group '..matches[3]..' not found'
end
end
if matches[1] == 'kill' and matches[2] == 'realm' then
if not is_admin(msg) then
return nil
end
if is_realm(msg) then
local receiver = 'chat#id'..matches[3]
return realmrem(msg),
print("Closing realm: "..receiver),
chat_info(receiver, killrealm, {receiver=receiver})
else
return 'Error: Realm '..matches[3]..' not found'
end
end
if matches[1] == 'chat_add_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if not is_admin(msg) then
chat_del_user(chat, user, ok_cb, true)
end
end
if matches[1] == 'addadmin' then
if string.match(matches[2], '^%d+$') then
local admin_id = matches[2]
print("user "..admin_id.." has been promoted as admin")
return admin_promote(msg, admin_id)
else
local member = string.gsub(matches[2], "@", "")
local mod_cmd = "addadmin"
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'removeadmin' then
if string.match(matches[2], '^%d+$') then
local admin_id = matches[2]
print("user "..admin_id.." has been demoted")
return admin_demote(msg, admin_id)
else
local member = string.gsub(matches[2], "@", "")
local mod_cmd = "removeadmin"
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'type'then
local group_type = get_group_type(msg)
return group_type
end
if matches[1] == 'list' and matches[2] == 'admins' then
return admin_list(msg)
end
if matches[1] == 'list' and matches[2] == 'groups' then
if msg.to.type == 'chat' then
groups_list(msg)
send_document("chat#id"..msg.to.id, "./groups/lists/groups.txt", ok_cb, false)
return "Group list created" --group_list(msg)
elseif msg.to.type == 'user' then
groups_list(msg)
send_document("user#id"..msg.from.id, "./groups/lists/groups.txt", ok_cb, false)
return "Group list created" --group_list(msg)
end
end
if matches[1] == 'list' and matches[2] == 'realms' then
if msg.to.type == 'chat' then
realms_list(msg)
send_document("chat#id"..msg.to.id, "./groups/lists/realms.txt", ok_cb, false)
return "Realms list created" --realms_list(msg)
elseif msg.to.type == 'user' then
realms_list(msg)
send_document("user#id"..msg.from.id, "./groups/lists/realms.txt", ok_cb, false)
return "Realms list created" --realms_list(msg)
end
end
if matches[1] == 'res' and is_momod(msg) then
local cbres_extra = {
chatid = msg.to.id
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username)
return res_user(username, callbackres, cbres_extra)
end
end
return {
patterns = {
"^[!/](creategroup) (.*)$",
"^[!/](createrealm) (.*)$",
"^[!/](setabout) (%d+) (.*)$",
"^[!/](setrules) (%d+) (.*)$",
"^[!/](setname) (.*)$",
"^[!/](setgpname) (%d+) (.*)$",
"^[!/](setname) (%d+) (.*)$",
"^[!/](lock) (%d+) (.*)$",
"^[!/](unlock) (%d+) (.*)$",
"^[!/](setting) (%d+)$",
"^[!/](wholist)$",
"^[!/](who)$",
"^[!/](type)$",
"^[!/](kill) (chat) (%d+)$",
"^[!/](kill) (realm) (%d+)$",
"^[!/](addadmin) (.*)$", -- sudoers only
"^[!/](removeadmin) (.*)$", -- sudoers only
"^[!/](list) (.*)$",
"^[!/](log)$",
"^[!/](help)$",
"^!!tgservice (.+)$",
},
run = run
}
end
| gpl-2.0 |
GetDotaStats/stat-achievements | statachievement/scripts/vscripts/addon_game_mode.lua | 1 | 2702 | -- Load Stat collection (statcollection should be available from any script scope)
require('lib.statcollection_achievement')
statcollection_achievement.setModID(
'achievement_test' --GET THIS FROM http://getdotastats.com/#d2mods__my_mods
)
print( "Example stat collection game mode loaded." )
if YourGamemode == nil then
YourGamemode = class({})
end
--------------------------------------------------------------------------------
-- ACTIVATE
--------------------------------------------------------------------------------
function Activate()
GameRules.YourGamemode = YourGamemode()
GameRules.YourGamemode:InitGameMode()
end
--------------------------------------------------------------------------------
-- INIT
--------------------------------------------------------------------------------
function YourGamemode:InitGameMode()
local GameMode = GameRules:GetGameModeEntity()
-- Register Think
GameMode:SetContextThink( "YourGamemode:Think_LoadAchievements", function() return self:Think_LoadAchievements() end, 0.25 )
GameMode:SetContextThink( "YourGamemode:Think_SendAchievements", function() return self:Think_SendAchievements() end, 0.25 )
-- Register Game Events
ListenToGameEvent( "npc_spawned", function ( event )
-- Apply tracking modifier for achievements to hero
local unit = EntIndexToHScript( event.entindex )
if not unit:IsRealHero() then return end
if unit:GetPlayerID() < 0 then return end
local achievementItem = CreateItem( "item_achievements", nil, nil )
achievementItem:ApplyDataDrivenModifier( unit, unit, "modifier_achievement_tracker", {} )
end, nil )
-- Register Commands
Convars:RegisterCommand( "stat_ach_send", function ( _ )
statcollection_achievement.sendAchievements()
end, "", 0 )
end
--------------------------------------------------------------------------------
function YourGamemode:Think_LoadAchievements()
-- Check to see if all players have joined
if PlayerResource:HaveAllPlayersJoined() then
-- Load stats
statcollection_achievement.loadAchievements()
-- Delete the thinker
return
else
-- Check again in 1 second
return 1
end
end
--------------------------------------------------------------------------------
function YourGamemode:Think_SendAchievements()
-- Check to see if the game has finished
if GameRules:State_Get() >= DOTA_GAMERULES_STATE_POST_GAME then
-- Send stats
statcollection_achievement.sendAchievements()
-- Delete the thinker
return
else
-- Check again in 1 second
return 1
end
end | gpl-2.0 |
Links7094/nwf | resources/lua/app_initialized.lua | 2 | 1535 | ------------------------------------------------------------------
-- desc: 服务器、框架完全加载之后的处理脚本
-- author: zenghui
-- date: 2017-3-27
-- attention: 网站启动时将自动执行此文件一次。
-- 注意此文件执行之时服务器、框架、模块已经完全加载完毕。
-- 可以在这个文件里加入一些业务脚本
------------------------------------------------------------------
local nwf = commonlib.gettable("nwf");
------------------------------------------------------------------
-- 这里加载web应用需要的公共模块
-- e.g. NPL.load("(gl)www/utils/stlutil.lua");
------------------------------------------------------------------
------------------------------------------------------------------
-- 这里注册web应用的各种过滤器
------------------------------------------------------------------
--[[
nwf.registerFilter(function(ctx, doNext)
local req = ctx.request;
local res = ctx.response;
doSomething();
doNext();
doSomething();
end);
]]
------------------------------------------------------------------
-- 这里加载业务组件
-- e.g. NPL.load("(gl)www/service/xxx.lua");
------------------------------------------------------------------
------------------------------------------------------------------
-- 网站启动成功的提示信息
------------------------------------------------------------------
print("nwf application starting completed.");
| mit |
rainfiel/skynet | service/cslave.lua | 19 | 6492 | local skynet = require "skynet"
local socket = require "socket"
require "skynet.manager" -- import skynet.launch, ...
local table = table
local slaves = {}
local connect_queue = {}
local globalname = {}
local queryname = {}
local harbor = {}
local harbor_service
local monitor = {}
local monitor_master_set = {}
local function read_package(fd)
local sz = socket.read(fd, 1)
assert(sz, "closed")
sz = string.byte(sz)
local content = assert(socket.read(fd, sz), "closed")
return skynet.unpack(content)
end
local function pack_package(...)
local message = skynet.packstring(...)
local size = #message
assert(size <= 255 , "too long")
return string.char(size) .. message
end
local function monitor_clear(id)
local v = monitor[id]
if v then
monitor[id] = nil
for _, v in ipairs(v) do
v(true)
end
end
end
local function connect_slave(slave_id, address)
local ok, err = pcall(function()
if slaves[slave_id] == nil then
local fd = assert(socket.open(address), "Can't connect to "..address)
skynet.error(string.format("Connect to harbor %d (fd=%d), %s", slave_id, fd, address))
slaves[slave_id] = fd
monitor_clear(slave_id)
socket.abandon(fd)
skynet.send(harbor_service, "harbor", string.format("S %d %d",fd,slave_id))
end
end)
if not ok then
skynet.error(err)
end
end
local function ready()
local queue = connect_queue
connect_queue = nil
for k,v in pairs(queue) do
connect_slave(k,v)
end
for name,address in pairs(globalname) do
skynet.redirect(harbor_service, address, "harbor", 0, "N " .. name)
end
end
local function response_name(name)
local address = globalname[name]
if queryname[name] then
local tmp = queryname[name]
queryname[name] = nil
for _,resp in ipairs(tmp) do
resp(true, address)
end
end
end
local function monitor_master(master_fd)
while true do
local ok, t, id_name, address = pcall(read_package,master_fd)
if ok then
if t == 'C' then
if connect_queue then
connect_queue[id_name] = address
else
connect_slave(id_name, address)
end
elseif t == 'N' then
globalname[id_name] = address
response_name(id_name)
if connect_queue == nil then
skynet.redirect(harbor_service, address, "harbor", 0, "N " .. id_name)
end
elseif t == 'D' then
local fd = slaves[id_name]
slaves[id_name] = false
if fd then
monitor_clear(id_name)
socket.close(fd)
end
end
else
skynet.error("Master disconnect")
for _, v in ipairs(monitor_master_set) do
v(true)
end
socket.close(master_fd)
break
end
end
end
local function accept_slave(fd)
socket.start(fd)
local id = socket.read(fd, 1)
if not id then
skynet.error(string.format("Connection (fd =%d) closed", fd))
socket.close(fd)
return
end
id = string.byte(id)
if slaves[id] ~= nil then
skynet.error(string.format("Slave %d exist (fd =%d)", id, fd))
socket.close(fd)
return
end
slaves[id] = fd
monitor_clear(id)
socket.abandon(fd)
skynet.error(string.format("Harbor %d connected (fd = %d)", id, fd))
skynet.send(harbor_service, "harbor", string.format("A %d %d", fd, id))
end
skynet.register_protocol {
name = "harbor",
id = skynet.PTYPE_HARBOR,
pack = function(...) return ... end,
unpack = skynet.tostring,
}
skynet.register_protocol {
name = "text",
id = skynet.PTYPE_TEXT,
pack = function(...) return ... end,
unpack = skynet.tostring,
}
local function monitor_harbor(master_fd)
return function(session, source, command)
local t = string.sub(command, 1, 1)
local arg = string.sub(command, 3)
if t == 'Q' then
-- query name
if globalname[arg] then
skynet.redirect(harbor_service, globalname[arg], "harbor", 0, "N " .. arg)
else
socket.write(master_fd, pack_package("Q", arg))
end
elseif t == 'D' then
-- harbor down
local id = tonumber(arg)
if slaves[id] then
monitor_clear(id)
end
slaves[id] = false
else
skynet.error("Unknown command ", command)
end
end
end
function harbor.REGISTER(fd, name, handle)
assert(globalname[name] == nil)
globalname[name] = handle
response_name(name)
socket.write(fd, pack_package("R", name, handle))
skynet.redirect(harbor_service, handle, "harbor", 0, "N " .. name)
end
function harbor.LINK(fd, id)
if slaves[id] then
if monitor[id] == nil then
monitor[id] = {}
end
table.insert(monitor[id], skynet.response())
else
skynet.ret()
end
end
function harbor.LINKMASTER()
table.insert(monitor_master_set, skynet.response())
end
function harbor.CONNECT(fd, id)
if not slaves[id] then
if monitor[id] == nil then
monitor[id] = {}
end
table.insert(monitor[id], skynet.response())
else
skynet.ret()
end
end
function harbor.QUERYNAME(fd, name)
if name:byte() == 46 then -- "." , local name
skynet.ret(skynet.pack(skynet.localname(name)))
return
end
local result = globalname[name]
if result then
skynet.ret(skynet.pack(result))
return
end
local queue = queryname[name]
if queue == nil then
socket.write(fd, pack_package("Q", name))
queue = { skynet.response() }
queryname[name] = queue
else
table.insert(queue, skynet.response())
end
end
skynet.start(function()
local master_addr = skynet.getenv "master"
local harbor_id = tonumber(skynet.getenv "harbor")
local slave_address = assert(skynet.getenv "address")
local slave_fd = socket.listen(slave_address)
skynet.error("slave connect to master " .. tostring(master_addr))
local master_fd = assert(socket.open(master_addr), "Can't connect to master")
skynet.dispatch("lua", function (_,_,command,...)
local f = assert(harbor[command])
f(master_fd, ...)
end)
skynet.dispatch("text", monitor_harbor(master_fd))
harbor_service = assert(skynet.launch("harbor", harbor_id, skynet.self()))
local hs_message = pack_package("H", harbor_id, slave_address)
socket.write(master_fd, hs_message)
local t, n = read_package(master_fd)
assert(t == "W" and type(n) == "number", "slave shakehand failed")
skynet.error(string.format("Waiting for %d harbors", n))
skynet.fork(monitor_master, master_fd)
if n > 0 then
local co = coroutine.running()
socket.start(slave_fd, function(fd, addr)
skynet.error(string.format("New connection (fd = %d, %s)",fd, addr))
if pcall(accept_slave,fd) then
local s = 0
for k,v in pairs(slaves) do
s = s + 1
end
if s >= n then
skynet.wakeup(co)
end
end
end)
skynet.wait()
end
socket.close(slave_fd)
skynet.error("Shakehand ready")
skynet.fork(ready)
end)
| mit |
junkblocker/hammerspoon | extensions/battery/init.lua | 20 | 1813 | --- === hs.battery ===
---
--- Battery/power information
--- All functions here may return nil, if the information requested is not available.
---
--- This module is based primarily on code from the previous incarnation of Mjolnir by [Steven Degutis](https://github.com/sdegutis/).
local module = require("hs.battery.internal")
local fnutils = require("hs.fnutils")
-- private variables and methods -----------------------------------------
local check_list = {}
for i,v in pairs(module) do check_list[#check_list + 1] = i end
local __tostring_for_tables = function(self)
local result = ""
local width = 0
for i,v in fnutils.sortByKeys(self) do
if type(i) == "string" and width < i:len() then width = i:len() end
end
for i,v in fnutils.sortByKeys(self) do
if type(i) == "string" then
result = result..string.format("%-"..tostring(width).."s %s\n", i, tostring(v))
end
end
return result
end
-- Public interface ------------------------------------------------------
module.watcher = require("hs.battery.watcher")
--- hs.battery.getAll() -> table
--- Function
--- Get all available battery information
---
--- Parameters:
--- * None
---
--- Returns:
--- * A table containing all the information provided by the separate functions in hs.battery
---
--- Notes:
--- * If you require multiple pieces of information about a battery, this function may be more efficient than calling several other functions separately
module.getAll = function()
local t = {}
for i, v in ipairs(check_list) do
t[v] = module[v]()
if t[v] == nil then t[v] = "n/a" end
end
return setmetatable(t, {__tostring = __tostring_for_tables })
end
-- Return Module Object --------------------------------------------------
return module
| mit |
Frownigami1/cuberite | Server/Plugins/APIDump/Hooks/OnBlockToPickups.lua | 36 | 2438 | return
{
HOOK_BLOCK_TO_PICKUPS =
{
CalledWhen = "A block is about to be dug ({{cPlayer|player}}, {{cEntity|entity}} or natural reason), plugins may override what pickups that will produce.",
DefaultFnName = "OnBlockToPickups", -- also used as pagename
Desc = [[
This callback gets called whenever a block is about to be dug. This includes {{cPlayer|players}}
digging blocks, entities causing blocks to disappear ({{cTNTEntity|TNT}}, Endermen) and natural
causes (water washing away a block). Plugins may override the amount and kinds of pickups this
action produces.
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the block resides" },
{ Name = "Digger", Type = "{{cEntity}} descendant", Notes = "The entity causing the digging. May be a {{cPlayer}}, {{cTNTEntity}} or even nil (natural causes)" },
{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
{ Name = "BlockType", Type = "BLOCKTYPE", Notes = "Block type of the block" },
{ Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "Block meta of the block" },
{ Name = "Pickups", Type = "{{cItems}}", Notes = "Items that will be spawned as pickups" },
},
Returns = [[
If the function returns false or no value, the next callback in the hook chain will be called. If
the function returns true, no other callbacks in the chain will be called.</p>
<p>
Either way, the server will then spawn pickups specified in the Pickups parameter, so to disable
pickups, you need to Clear the object first, then return true.
]],
CodeExamples =
{
{
Title = "Modify pickups",
Desc = "This example callback function makes tall grass drop diamonds when digged by natural causes (washed away by water).",
Code = [[
function OnBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_Pickups)
if (a_Digger ~= nil) then
-- Not a natural cause
return false;
end
if (a_BlockType ~= E_BLOCK_TALL_GRASS) then
-- Not a tall grass being washed away
return false;
end
-- Remove all pickups suggested by Cuberite:
a_Pickups:Clear();
-- Drop a diamond:
a_Pickups:Add(cItem(E_ITEM_DIAMOND));
return true;
end;
]],
},
} , -- CodeExamples
}, -- HOOK_BLOCK_TO_PICKUPS
}
| apache-2.0 |
mattyx14/otxserver | data/monster/mammals/sibang.lua | 2 | 2865 | local mType = Game.createMonsterType("Sibang")
local monster = {}
monster.description = "a sibang"
monster.experience = 105
monster.outfit = {
lookType = 118,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.raceId = 118
monster.Bestiary = {
class = "Mammal",
race = BESTY_RACE_MAMMAL,
toKill = 500,
FirstUnlock = 25,
SecondUnlock = 250,
CharmsPoints = 15,
Stars = 2,
Occurrence = 0,
Locations = "In Banuta, north-east of Port Hope."
}
monster.health = 225
monster.maxHealth = 225
monster.race = "blood"
monster.corpse = 6045
monster.speed = 214
monster.manaCost = 0
monster.changeTarget = {
interval = 4000,
chance = 10
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = true,
canPushItems = true,
canPushCreatures = false,
staticAttackChance = 70,
targetDistance = 4,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = true
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "Eeeeek! Eeeeek!", yell = false},
{text = "Huh! Huh! Huh!", yell = false},
{text = "Ahhuuaaa!", yell = false}
}
monster.loot = {
{name = "small stone", chance = 30060, maxCount = 3},
{name = "gold coin", chance = 56000, maxCount = 35},
{name = "orange", chance = 19840, maxCount = 5},
{name = "banana", chance = 30000, maxCount = 12},
{name = "coconut", chance = 1960, maxCount = 3},
{name = "melon", chance = 1000},
{name = "ape fur", chance = 1000},
{name = "banana sash", chance = 5000}
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -40},
{name ="combat", interval = 2000, chance = 35, type = COMBAT_PHYSICALDAMAGE, minDamage = 0, maxDamage = -55, range = 7, shootEffect = CONST_ANI_SMALLSTONE, target = false}
}
monster.defenses = {
defense = 15,
armor = 15,
{name ="speed", interval = 2000, chance = 15, speedChange = 380, effect = CONST_ME_MAGIC_RED, target = false, duration = 5000}
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 25},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = -15},
{type = COMBAT_HOLYDAMAGE , percent = 10},
{type = COMBAT_DEATHDAMAGE , percent = -5}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = true},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
mattyx14/otxserver | data/monster/bosses/yaga_the_crone.lua | 2 | 3581 | local mType = Game.createMonsterType("Yaga The Crone")
local monster = {}
monster.description = "Yaga The Crone"
monster.experience = 375
monster.outfit = {
lookType = 54,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.health = 620
monster.maxHealth = 620
monster.race = "blood"
monster.corpse = 18306
monster.speed = 240
monster.manaCost = 0
monster.changeTarget = {
interval = 5000,
chance = 8
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = true,
illusionable = false,
canPushItems = true,
canPushCreatures = false,
staticAttackChance = 90,
targetDistance = 4,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "Where did I park my hut?", yell = false},
{text = "You will taste so sweet!", yell = false},
{text = "Hexipooh, bewitched are you!", yell = false}
}
monster.loot = {
{name = "cape", chance = 66000},
{name = "broom", chance = 62500},
{name = "cookie", chance = 62500, maxCount = 8},
{name = "gold coin", chance = 29170, maxCount = 55},
{name = "star herb", chance = 20833},
{id = 3012, chance = 20833}, -- wolf tooth chain
{name = "garlic necklace", chance = 8333},
{name = "spellbook of mind control", chance = 8333},
{name = "coat", chance = 4170},
{name = "necrotic rod", chance = 4170},
{name = "silver dagger", chance = 4170}
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -50},
{name ="combat", interval = 2500, chance = 50, type = COMBAT_FIREDAMAGE, minDamage = -30, maxDamage = -50, range = 5, shootEffect = CONST_ANI_FIRE, effect = CONST_ME_HITBYFIRE, target = false},
-- poison
{name ="condition", type = CONDITION_POISON, interval = 3000, chance = 13, minDamage = -10, maxDamage = -10, range = 5, shootEffect = CONST_ANI_POISON, target = false},
{name ="firefield", interval = 2000, chance = 13, range = 5, shootEffect = CONST_ANI_FIRE, target = false}
}
monster.defenses = {
defense = 20,
armor = 15,
{name ="invisible", interval = 2000, chance = 18, effect = CONST_ME_MAGIC_RED},
{name ="outfit", interval = 4000, chance = 9, effect = CONST_ME_MAGIC_RED, target = false, duration = 4000, outfitMonster = "green frog"}
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = -1},
{type = COMBAT_ENERGYDAMAGE, percent = 100},
{type = COMBAT_EARTHDAMAGE, percent = 1},
{type = COMBAT_FIREDAMAGE, percent = 0},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = -5}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType.onThink = function(monster, interval)
end
mType.onAppear = function(monster, creature)
if monster:getType():isRewardBoss() then
monster:setReward(true)
end
end
mType.onDisappear = function(monster, creature)
end
mType.onMove = function(monster, creature, fromPosition, toPosition)
end
mType.onSay = function(monster, creature, type, message)
end
mType:register(monster)
| gpl-2.0 |
Erfanh/Fighter_Bot | plugins/all.lua | 264 | 4202 | do
data = load_data(_config.moderation.data)
local function get_msgs_user_chat(user_id, chat_id)
local user_info = {}
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..user_id..':'..chat_id
user_info.msgs = tonumber(redis:get(um_hash) or 0)
user_info.name = user_print_name(user)..' ['..user_id..']'
return user_info
end
local function chat_stats(chat_id)
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'chat stats! \n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
return text
end
local function show_group_settings(target)
local data = load_data(_config.moderation.data)
if data[tostring(target)] then
if data[tostring(target)]['settings']['flood_msg_max'] then
NUM_MSG_MAX = tonumber(data[tostring(target)]['settings']['flood_msg_max'])
print('custom'..NUM_MSG_MAX)
else
NUM_MSG_MAX = 5
end
end
local settings = data[tostring(target)]['settings']
local text = "Lock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nflood sensitivity : "..NUM_MSG_MAX
return text
end
local function get_description(target)
local data = load_data(_config.moderation.data)
local data_cat = 'description'
if not data[tostring(target)][data_cat] then
return 'No description available.'
end
local about = data[tostring(target)][data_cat]
return about
end
local function get_rules(target)
local data = load_data(_config.moderation.data)
local data_cat = 'rules'
if not data[tostring(target)][data_cat] then
return 'No rules available.'
end
local rules = data[tostring(target)][data_cat]
return rules
end
local function modlist(target)
local data = load_data(_config.moderation.data)
if not data[tostring(target)] then
return 'Group is not added.'
end
if next(data[tostring(target)]['moderators']) == nil then
return 'No moderator in this group.'
end
local i = 1
local message = '\nList of moderators :\n'
for k,v in pairs(data[tostring(target)]['moderators']) do
message = message ..i..' - @'..v..' [' ..k.. '] \n'
i = i + 1
end
return message
end
local function get_link(target)
local data = load_data(_config.moderation.data)
local group_link = data[tostring(target)]['settings']['set_link']
if not group_link then
return "No link"
end
return "Group link:\n"..group_link
end
local function all(target, receiver)
local text = "All the things I know about this group \n \n"
local settings = show_group_settings(target)
text = text.."Group settings \n"..settings
local rules = get_rules(target)
text = text.."\n\nRules: \n"..rules
local description = get_description(target)
text = text.."\n\nAbout: \n"..description
local modlist = modlist(target)
text = text.."\n\n"..modlist
local link = get_link(target)
text = text.."\n\n"..link
local stats = chat_stats(target)
text = text.."\n\n"..stats
local ban_list = ban_list(target)
text = text.."\n\n"..ban_list
local file = io.open("./groups/"..target.."all.txt", "w")
file:write(text)
file:flush()
file:close()
send_document(receiver,"./groups/"..target.."all.txt", ok_cb, false)
return
end
function run(msg, matches)
if matches[1] == "all" and matches[2] and is_owner2(msg.from.id, matches[2]) then
local receiver = get_receiver(msg)
local target = matches[2]
return all(target, receiver)
end
if not is_owner(msg) then
return
end
if matches[1] == "all" and not matches[2] and msg.to.id ~= our_id then
local receiver = get_receiver(msg)
if not is_owner(msg) then
return
end
return all(msg.to.id, receiver)
end
return
end
return {
patterns = {
"^[!/](all)$",
"^[!/](all) (%d+)$"
},
run = run
}
end | gpl-2.0 |
CarabusX/Zero-K | LuaRules/Gadgets/Include/PriorityQueue.lua | 6 | 1525 | --
-- Slight adaptation from:
-- https://gist.github.com/leegao/1074642
--
local insert = table.insert
local remove = table.remove
local PriorityQueue = {}
function PriorityQueue.new(cmp, initial)
local pq = setmetatable({}, {
__index = {
cmp = cmp or function(a,b) return a < b end,
push = function(self, v)
insert(self, v)
local next = #self
local prev = (next-next%2)/2
while next > 1 and cmp(self[next], self[prev]) do
self[next], self[prev] = self[prev], self[next]
next = prev
prev = (next-next%2)/2
end
end,
pop = function(self)
if #self < 2 then
return remove(self)
end
local root = 1
local r = self[root]
self[root] = remove(self)
local size = #self
if size > 1 then
local child = 2*root
while child <= size do
local aBool = cmp(self[root],self[child]);
local bBool = true;
local cBool = true;
if child+1 <= size then
bBool = cmp( self[root],self[child+1]);
cBool = cmp(self[child], self[child+1]);
end
if aBool and bBool then
break;
elseif cBool then
self[root], self[child] = self[child], self[root]
root = child
else
self[root], self[child+1] = self[child+1], self[root]
root = child+1
end
child = 2*root
end
end
return r
end,
peek = function(self)
return self[1]
end,
}
})
for _,el in ipairs(initial or {}) do
pq:push(el)
end
return pq
end
return PriorityQueue
| gpl-2.0 |
ld-test/feedparser | tests/XMLElement.lua | 3 | 2322 | local XMLElement = require "feedparser.XMLElement"
local lom = require "lxp.lom"
local function req(a, b)
local t = type(a)
if t~=type(b) then return false end
if t == 'table' then
for i,v in pairs(a) do
local eq = req(v, b[i])
if not eq then return nil end
end
return true
elseif t == 'function' or t == 'userdata' then
return true
else
return a == b
end
end
local function dump(tbl)
local function tcopy(t) local nt={}; for i,v in pairs(t) do nt[i]=v end; return nt end
local function printy(thing, prefix, tablestack)
local t = type(thing)
if t == "nil" then return "nil"
elseif t == "string" then return string.format('%q', thing)
elseif t == "number" then return tostring(thing)
elseif t == "table" then
if tablestack[thing] then return string.format("%s (recursion)", tostring(thing)) end
local kids, pre, substack = {}, "\t" .. prefix, (tablestack and tcopy(tablestack) or {})
substack[thing]=true
for k, v in pairs(thing) do
table.insert(kids, string.format('%s%s=%s,',pre,printy(k, ''),printy(v, pre, substack)))
end
return string.format("%s{\n%s\n%s}", tostring(thing), table.concat(kids, "\n"), prefix)
else
return tostring(thing)
end
end
local ret = printy(tbl, "", {})
print(ret)
return ret
end
local function filecontents(path)
local f = io.open(path, 'r')
if not f then return nil, path .. " is not a file or doesn't exist." end
local res = f:read('*a')
f:close()
return res
end
print "consistency"
local xml = assert(filecontents("tests/xml/simple.xml"))
local l= assert(lom.parse(xml))
local root = assert(XMLElement.new(l))
assert(req(root, XMLElement.new(lom.parse(root:getXML()))))
local feedxml = assert(filecontents("tests/xml/simple.xml"))
local feedroot = XMLElement.new(assert(lom.parse(xml)))
assert(req(feedroot, XMLElement.new(lom.parse(feedroot:getXML()))))
print "children"
local kids = root:getChildren('foo')
assert(#kids==3)
assert(#root:getChildren({'selfclosing', 'bacon:strip'}==4))
for i, el in ipairs(kids) do
assert(getmetatable(root)==getmetatable(el))
assert(el:getTag()=='foo')
end
assert(#root:getChild('foo'):getChildren()==2)
assert(root:getText())
print('blank element')
local blanky = XMLElement.new()
assert(blanky:getText()=='')
print("descendants")
assert(#root:getDescendants()==8)
| bsd-3-clause |
imeteora/cocos2d-x-3.x-Qt | cocos/scripting/lua-bindings/auto/api/MenuItem.lua | 6 | 1112 |
--------------------------------
-- @module MenuItem
-- @extend Node
--------------------------------
-- @function [parent=#MenuItem] setEnabled
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#MenuItem] activate
-- @param self
--------------------------------
-- @function [parent=#MenuItem] isEnabled
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#MenuItem] selected
-- @param self
--------------------------------
-- @function [parent=#MenuItem] isSelected
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#MenuItem] unselected
-- @param self
--------------------------------
-- @function [parent=#MenuItem] rect
-- @param self
-- @return rect_table#rect_table ret (return value: rect_table)
--------------------------------
-- @function [parent=#MenuItem] getDescription
-- @param self
-- @return string#string ret (return value: string)
return nil
| gpl-2.0 |
ReclaimYourPrivacy/cloak-luci | applications/luci-app-ocserv/luasrc/model/cbi/ocserv/users.lua | 28 | 2106 | -- Copyright 2014 Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
-- Licensed to the public under the Apache License 2.0.
local dsp = require "luci.dispatcher"
local nixio = require "nixio"
m = Map("ocserv", translate("OpenConnect VPN"))
if m.uci:get("ocserv", "config", "auth") == "plain" then
--[[Users]]--
function m.on_commit(map)
luci.sys.call("/etc/init.d/ocserv restart >/dev/null 2>&1")
end
s = m:section(TypedSection, "ocservusers", translate("Available users"))
s.anonymous = true
s.addremove = true
s.template = "cbi/tblsection"
s:option(Value, "name", translate("Name")).rmempty = true
s:option(DummyValue, "group", translate("Group")).rmempty = true
pwd = s:option(Value, "password", translate("Password"))
pwd.password = false
function pwd.write(self, section, value)
local pass
if string.match(value, "^\$%d\$.*") then
pass = value
else
local t = tonumber(nixio.getpid()*os.time())
local salt = "$1$" .. t .. "$"
pass = nixio.crypt(value, salt)
end
Value.write(self, section, pass)
end
--[[if plain]]--
end
local lusers = { }
local fd = io.popen("/usr/bin/occtl show users", "r")
if fd then local ln
repeat
ln = fd:read("*l")
if not ln then break end
local id, user, group, vpn_ip, ip, device, time, cipher, status =
ln:match("^%s*(%d+)%s+([-_%w]+)%s+([%.%*-_%w]+)%s+([%:%.-_%w]+)%s+([%:%.-_%w]+)%s+([%:%.-_%w]+)%s+([%:%.-_%w]+)%s+([%(%)%:%.-_%w]+)%s+([%:%.-_%w]+).*")
if id then
table.insert(lusers, {id, user, group, vpn_ip, ip, device, time, cipher, status})
end
until not ln
fd:close()
end
--[[Active Users]]--
local s = m:section(Table, lusers, translate("Active users"))
s.anonymous = true
s.template = "cbi/tblsection"
s:option(DummyValue, 1, translate("ID"))
s:option(DummyValue, 2, translate("Username"))
s:option(DummyValue, 3, translate("Group"))
s:option(DummyValue, 4, translate("IP"))
s:option(DummyValue, 5, translate("VPN IP"))
s:option(DummyValue, 6, translate("Device"))
s:option(DummyValue, 7, translate("Time"))
s:option(DummyValue, 8, translate("Cipher"))
s:option(DummyValue, 9, translate("Status"))
return m
| apache-2.0 |
mattyx14/otxserver | data/monster/humanoids/pirat_artillerist.lua | 2 | 3283 | local mType = Game.createMonsterType("Pirat Artillerist")
local monster = {}
monster.description = "a pirat artillerist"
monster.experience = 2800
monster.outfit = {
lookType = 1346,
lookHead = 126,
lookBody = 94,
lookLegs = 86,
lookFeet = 94,
lookAddons = 2,
lookMount = 0
}
monster.raceId = 918
monster.Bestiary = {
class = "Humanoid",
race = BESTY_RACE_HUMANOID,
toKill = 1000,
FirstUnlock = 50,
SecondUnlock = 500,
CharmsPoints = 35,
Stars = 3,
Occurrence = 0,
Locations = "The Wreckoning"
}
monster.health = 2700
monster.maxHealth = 2700
monster.race = "blood"
monster.corpse = 35372
monster.speed = 200
monster.manaCost = 0
monster.changeTarget = {
interval = 4000,
chance = 10
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 70,
targetDistance = 1,
runHealth = 50,
healthHidden = false,
isBlockable = true,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "Gimme! Gimme!", yell = false}
}
monster.loot = {
{id = 3031, chance = 100000, maxCount = 120}, -- gold coin
{id = 7642, chance = 100000, maxCount = 2}, -- great spirit potion
{id = 35572, chance = 10000}, -- pirate coin
{id = 813, chance = 4761}, -- terra boots
{id = 813, chance = 4761}, -- terra boots
{id = 17812, chance = 5000}, -- ratana
{id = 17813, chance = 5000}, -- life preserver
{id = 17817, chance = 16666}, -- cheese cutter
{id = 17818, chance = 3846}, -- cheesy figurine
{id = 35596, chance = 11111}, -- mouldy powder
{id = 17820, chance = 14285}, -- soft cheese
{id = 17821, chance = 14285}, -- rat cheese
{id = 820, chance = 1612}, -- lightning boots
{id = 818, chance = 3225} -- magma boots
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 450, maxDamage = -140},
{name ="corym vanguard wave", interval = 2000, chance = 10, minDamage = -50, maxDamage = -100, target = false},
{name ="combat", interval = 2000, chance = 15, type = COMBAT_DEATHDAMAGE, minDamage = -40, maxDamage = -70, radius = 4, effect = CONST_ME_MORTAREA, target = true}
}
monster.defenses = {
defense = 65,
armor = 65,
{name ="combat", interval = 2000, chance = 10, type = COMBAT_HEALING, minDamage = 30, maxDamage = 60, effect = CONST_ME_MAGIC_BLUE, target = false}
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = -110},
{type = COMBAT_ENERGYDAMAGE, percent = 30},
{type = COMBAT_EARTHDAMAGE, percent = -130},
{type = COMBAT_FIREDAMAGE, percent = 30},
{type = COMBAT_LIFEDRAIN, percent = 30},
{type = COMBAT_MANADRAIN, percent = 30},
{type = COMBAT_DROWNDAMAGE, percent = 30},
{type = COMBAT_ICEDAMAGE, percent = 20},
{type = COMBAT_HOLYDAMAGE , percent = 30},
{type = COMBAT_DEATHDAMAGE , percent = 30}
}
monster.immunities = {
{type = "paralyze", condition = true},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
Quit/jelly | lib/resources.lua | 1 | 2048 | --[=============================================================================[
The MIT License (MIT)
Copyright (c) 2014 RepeatPan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
]=============================================================================]
local radiant = radiant
local type, error = type, error
--! realm jelly
local resources = {}
--! desc If `name` is a table, `name` is returned. If `name` is a string, it is tried to `radiant.resources.load_json`.
--! param string/table name The value that should be loaded (if necessary).
--! returns table The table that represents this value.
--! remarks This function is especially useful if you wish to load data from JSON, but wish that they might be `file()`'d or aliased instead of "written in"
function resources.load_table(name)
if type(name) == 'table' then
return name
elseif type(name) == 'string' then
return radiant.resources.load_json(name)
else
error('bad argument #1 to jelly.resources.load_table: expected string or table, got ' .. type(name))
end
end
return resources | mit |
PAC3-Server/ServerContent | lua/notagain/jrpg/autorun/client/impact_effects.lua | 2 | 6638 | local jfx = requirex("jfx")
local draw_line = requirex("draw_line")
do
local glyph_disc = jfx.CreateMaterial({
Shader = "UnlitGeneric",
BaseTexture = "https://raw.githubusercontent.com/PAC3-Server/ServerAssets/master/materials/pac_server/jrpg/disc.png",
VertexColor = 1,
VertexAlpha = 1,
})
local ring = jfx.CreateMaterial({
Shader = "UnlitGeneric",
BaseTexture = "https://raw.githubusercontent.com/PAC3-Server/ServerAssets/master/materials/pac_server/jrpg/ring2.png",
Additive = 0,
VertexColor = 1,
VertexAlpha = 1,
})
local hand = jfx.CreateMaterial({
Shader = "UnlitGeneric",
BaseTexture = "https://raw.githubusercontent.com/PAC3-Server/ServerAssets/master/materials/pac_server/jrpg/clock_hand.png",
Additive = 0,
VertexColor = 1,
VertexAlpha = 1,
BaseTextureTransform = "center .5 .5 scale 1 5 rotate 0 translate 0 1.25",
})
local glow = jfx.CreateMaterial({
Shader = "UnlitGeneric",
BaseTexture = "https://raw.githubusercontent.com/PAC3-Server/ServerAssets/master/materials/pac_server/jrpg/glow.png",
Additive = 1,
VertexColor = 1,
VertexAlpha = 1,
})
local glow2 = jfx.CreateMaterial({
Shader = "UnlitGeneric",
BaseTexture = "sprites/light_glow02",
Additive = 1,
VertexColor = 1,
VertexAlpha = 1,
Translucent = 1,
})
local META = {}
META.Name = "impact_effect"
function META:Initialize()
self.pixvis = util.GetPixelVisibleHandle()
self.color = self.color or Color(255, 217, 104, 255)
self.size = self.size or 0.6
self.something = self.something or 1
self.dlight = DynamicLight( 0 )
self.dlight.DieTime = 99999
end
function META:DrawSprites(time, f, f2)
local s = self.size*1.5
local c = Color(self.color.r^1.15, self.color.g^1.15, self.color.b^1.15)
c.a = 255
local dark = Color(0,0,0,c.a)
cam.Start3D(EyePos(), EyeAngles())
local pos = self.position
render.SetMaterial(glow2)
render.DrawQuadEasy(pos, Vector(0,0,1), 420*s, 420*s, c, 45)
render.SetMaterial(glow)
render.DrawQuadEasy(self.position, -EyeVector(), 10*s, 10*s, c, -45)
render.SetMaterial(glow2)
render.DrawQuadEasy(self.position, -EyeVector(), 220*s, 220*s, c, 45)
cam.End3D()
end
function META:DrawGlow(time, f, f2)
local s = self.size
local c = Color(self.color.r, self.color.g, self.color.b)
c.a = 20*f2*self.visible
cam.Start3D(EyePos(), EyeAngles())
cam.IgnoreZ(true)
render.SetMaterial(glow)
local size = 500*s
render.DrawSprite(self.position, size, size, c)
cam.IgnoreZ(false)
cam.End3D()
end
function META:DrawRefraction(time, f, f2)
local s = self.size
local c = Color(self.color.r, self.color.g, self.color.b)
c.a = 100*f2*self.something
cam.Start3D(EyePos(), EyeAngles())
render.SetMaterial(jfx.materials.refract)
render.DrawQuadEasy(self.position, -EyeVector(), 128*s, 128*s, c, f*45)
cam.End3D()
end
function META:DrawRefraction2(time, f, f2)
local s = self.size
local c = Color(self.color.r, self.color.g, self.color.b)
c.a = (self.something*100)*f2
cam.Start3D(EyePos(), EyeAngles())
render.SetMaterial(jfx.materials.refract2)
render.DrawQuadEasy(self.position, -EyeVector(), 130*s, 130*s, c, f*45)
cam.End3D()
end
function META:DrawSunbeams(time, f, f2)
local s = self.size
local pos = self.position
local screen_pos = pos:ToScreen()
DrawSunbeams(0, (f2*self.visible*0.05)*self.something, 30 * (1/pos:Distance(EyePos()))*s, screen_pos.x / ScrW(), screen_pos.y / ScrH())
end
function META:DrawTranslucent(time, f, f2)
self.position = self.pos
self.visible = util.PixelVisible(self.position, 50, self.pixvis)
self:DrawSprites(time, f, f2)
self:DrawGlow(time, f, f2)
self:DrawSunbeams(time, f, f2)
end
function META:DrawOpaque(time, f, f2)
self.position = self.pos
self:DrawRefraction2(time, f, f2)
local dlight = self.dlight
if dlight then
dlight.pos = self.position
dlight.r = self.color.r
dlight.g = self.color.g
dlight.b = self.color.b
dlight.Brightness = 2
dlight.Decay = 1
dlight.Size = self.size*300
end
end
function META:OnRemove()
self.dlight.Decay = 0
self.dlight.DieTime = 0
end
jfx.RegisterEffect(META)
end
local function think(p)
local f = math.Clamp(-(p:GetLifeTime() / p:GetDieTime())+1, 0, 1)
local vel = p:GetVelocity() + (Vector(jfx.GetRandomOffset(p:GetPos(), p:GetRoll(), 0.04)) * 10)
p:SetVelocity(vel)
local l = (vel:Length()/10) + 1
p:SetStartLength(l)
p:SetEndLength(-l)
p:SetNextThink(CurTime())
end
local materials = {
"particle/particle_glow_05",
"particle/fire",
"particle/Particle_Glow_04_Additive",
}
function jrpg.ImpactEffect(pos, normal, dir, f, color)
if jfx.emitter:GetNumActiveParticles() > 500 then return end
local h = color and (ColorToHSV(color) / 360) or 20/360
jfx.CreateEffect("impact_effect", {
color = Color(jfx.HSV2RGB(h+math.Rand(-0.03,0.03), math.Rand(0.25, 0.75)^2, 1)),
size = 0.1*f,
something = 0,
length = 0.1*f,
pos = pos,
})
local t = CurTime()
local gravity = physenv.GetGravity()
for i = 1, math.random(100*f,200*f) do
local p = jfx.emitter:Add(materials[math.random(1, #materials)], pos)
local r,g,b = jfx.HSV2RGB(h+math.Rand(-0.05,0.05), math.Rand(0.25, 0.75)^2, 1)
p:SetColor(r, g, b)
p:SetNextThink(t)
p:SetThinkFunction(think)
p:SetDieTime((math.Rand(0.5, 1)^10)*3*f)
p:SetLifeTime(0)
local size = math.max((math.Rand(5,7)^0.25)*f, 1)
p:SetStartSize(size)
p:SetEndSize(size)
p:SetStartAlpha(255)
p:SetEndAlpha(0)
p:SetCollide(true)
p:SetBounce(1)
p:SetRoll(i)
p:SetAirResistance(math.Rand(100,500))
p:SetVelocity((VectorRand()*(math.Rand(0.5, 1)^5)*100 + normal*100 * math.Rand(1,4)) * f)
p:SetGravity(gravity*math.Rand(0.2,0.3))
end
end | mit |
tenplus1/ethereal | onion.lua | 1 | 2742 |
local S = ethereal.intllib
-- wild onion
minetest.register_craftitem("ethereal:wild_onion_plant", {
description = S("Wild Onion"),
inventory_image = "wild_onion.png",
wield_image = "wild_onion.png",
groups = {food_onion = 1, flammable = 2},
on_place = function(itemstack, placer, pointed_thing)
return farming.place_seed(itemstack, placer, pointed_thing, "ethereal:wild_onion_1")
end,
on_use = minetest.item_eat(2),
})
-- Define Onion growth stages
local crop_def = {
drawtype = "plantlike",
tiles = {"ethereal_wild_onion_1.png"},
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = "",
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
},
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
growing = 1, not_in_creative_inventory = 1
},
sounds = default.node_sound_leaves_defaults(),
}
--stage 1
minetest.register_node("ethereal:onion_1", table.copy(crop_def))
--stage 2
crop_def.tiles = {"ethereal_wild_onion_2.png"}
minetest.register_node("ethereal:onion_2", table.copy(crop_def))
--stage 3
crop_def.tiles = {"ethereal_wild_onion_3.png"}
minetest.register_node("ethereal:onion_3", table.copy(crop_def))
--stage 4
crop_def.tiles = {"ethereal_wild_onion_4.png"}
crop_def.drop = {
items = {
{items = {"ethereal:wild_onion_plant"}, rarity = 1},
{items = {"ethereal:wild_onion_plant 2"}, rarity = 3},
}
}
minetest.register_node("ethereal:onion_4", table.copy(crop_def))
--stage 5
crop_def.tiles = {"ethereal_wild_onion_5.png"}
crop_def.groups.growing = 0
crop_def.drop = {
items = {
{items = {"ethereal:wild_onion_plant 2"}, rarity = 1},
{items = {"ethereal:wild_onion_plant 3"}, rarity = 2},
}
}
minetest.register_node("ethereal:onion_5", table.copy(crop_def))
-- growing routine if farming redo isn't present
if not farming or not farming.mod or farming.mod ~= "redo" then
minetest.register_abm({
label = "Ethereal grow onion",
nodenames = {"ethereal:onion_1", "ethereal:onion_2", "ethereal:onion_3", "ethereal:onion_4"},
neighbors = {"farming:soil_wet"},
interval = 9,
chance = 20,
catch_up = false,
action = function(pos, node)
-- are we on wet soil?
pos.y = pos.y - 1
if minetest.get_item_group(minetest.get_node(pos).name, "soil") < 3 then
return
end
pos.y = pos.y + 1
-- do we have enough light?
local light = minetest.get_node_light(pos)
if not light
or light < 13 then
return
end
-- grow to next stage
local num = node.name:split("_")[2]
node.name = "ethereal:onion_" .. tonumber(num + 1)
minetest.swap_node(pos, node)
end
})
end -- END IF
| mit |
CarabusX/Zero-K | scripts/turretaaflak.lua | 8 | 2814 | local flare = {piece 'flare1', piece 'flare2'}
local barrel = {piece 'barrel1', piece 'barrel2'}
local base = piece 'base'
local turret = piece 'turret'
local guns = piece 'guns'
local a1, a2, a3, a4 = piece('a1', 'a2', 'a3', 'neck')
local floatbase = piece 'floatbase'
local trueaim = piece 'trueaim'
local gun_to_use = 1
local SIG_AIM = 1
include "constants.lua"
include "pieceControl.lua"
local stuns = {false, false, false}
local disarmed = false
local StopTurn = GG.PieceControl.StopTurn
function script.Create()
if not GG.Script.onWater(unitID) then
Hide(floatbase)
end
StartThread(GG.Script.SmokeUnit, unitID, {guns})
end
local function RestoreAfterDelay()
SetSignalMask(SIG_AIM)
Sleep(6000)
Turn (a1, x_axis, 0, math.rad(20))
Turn (a2, x_axis, 0, math.rad(60))
Turn (a3, x_axis, 0, math.rad(50))
Turn (a4, x_axis, 0, math.rad(10))
end
local function StunThread ()
Signal (SIG_AIM)
SetSignalMask(SIG_AIM)
disarmed = true
StopTurn (turret, y_axis)
StopTurn (guns, x_axis)
StopTurn (a1, x_axis)
StopTurn (a2, x_axis)
StopTurn (a3, x_axis)
StopTurn (a4, x_axis)
end
local function UnstunThread ()
disarmed = false
RestoreAfterDelay()
end
function Stunned (stun_type)
stuns[stun_type] = true
StartThread (StunThread)
end
function Unstunned (stun_type)
stuns[stun_type] = false
if not stuns[1] and not stuns[2] and not stuns[3] then
StartThread (UnstunThread)
end
end
function script.AimWeapon(num, heading, pitch)
Signal (SIG_AIM)
SetSignalMask (SIG_AIM)
while disarmed do
Sleep(34)
end
local slowMult = (Spring.GetUnitRulesParam(unitID,"baseSpeedMult") or 1)
Turn (a1, x_axis, math.rad(-45), math.rad(200)*slowMult)
Turn (a2, x_axis, math.rad(135), math.rad(600)*slowMult)
Turn (a3, x_axis, math.rad(-112.5), math.rad(500)*slowMult)
Turn (a4, x_axis, math.rad(22.5), math.rad(100)*slowMult)
Turn (turret, y_axis, heading, 3*slowMult)
Turn (guns, x_axis, -pitch, 3*slowMult)
WaitForTurn (turret, y_axis)
WaitForTurn (guns, x_axis)
StartThread(RestoreAfterDelay)
return true
end
function script.AimFromWeapon()
return trueaim
end
function script.QueryWeapon()
return flare[gun_to_use]
end
function script.FireWeapon()
Move(barrel[gun_to_use], z_axis, -15)
EmitSfx(flare[gun_to_use], 1024)
Move(barrel[gun_to_use], z_axis, 0, 40)
gun_to_use = 3 - gun_to_use
end
local explodables = {barrel[1], barrel[2], a2, a4, turret}
function script.Killed (recentDamage, maxHealth)
local severity = recentDamage / maxHealth
local brutal = (severity > 0.5)
local sfx = SFX
local effect = sfx.FALL + (brutal and (sfx.SMOKE + sfx.FIRE) or 0)
for i = 1, #explodables do
if math.random() < severity then
Explode (explodables[i], effect)
end
end
if not brutal then
return 1
else
Explode (base, sfx.SHATTER)
return 2
end
end
| gpl-2.0 |
raminea/capitan-Deadpool | plugins/inpm.lua | 1114 | 3008 | do
local function pairsByKeys (t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0 -- iterator variable
local iter = function () -- iterator function
i = i + 1
if a[i] == nil then return nil
else return a[i], t[a[i]]
end
end
return iter
end
local function chat_list(msg)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] then
return 'No groups at the moment'
end
local message = 'List of Groups:\n*Use /join (ID) to join*\n\n '
for k,v in pairs(data[tostring(groups)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairsByKeys(settings) do
if m == 'set_name' then
name = n
end
end
message = message .. '👥 '.. name .. ' (ID: ' .. v .. ')\n\n '
end
local file = io.open("./groups/lists/listed_groups.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function run(msg, matches)
if msg.to.type ~= 'chat' or is_sudo(msg) or is_admin(msg) and is_realm(msg) then
local data = load_data(_config.moderation.data)
if matches[1] == 'join' and data[tostring(matches[2])] then
if is_banned(msg.from.id, matches[2]) then
return 'You are banned.'
end
if is_gbanned(msg.from.id) then
return 'You are globally banned.'
end
if data[tostring(matches[2])]['settings']['lock_member'] == 'yes' and not is_owner2(msg.from.id, matches[2]) then
return 'Group is private.'
end
local chat_id = "chat#id"..matches[2]
local user_id = "user#id"..msg.from.id
chat_add_user(chat_id, user_id, ok_cb, false)
local group_name = data[tostring(matches[2])]['settings']['set_name']
return "Added you to chat:\n\n👥"..group_name.." (ID:"..matches[2]..")"
elseif matches[1] == 'join' and not data[tostring(matches[2])] then
return "Chat not found."
end
if matches[1] == 'chats'then
if is_admin(msg) and msg.to.type == 'chat' then
return chat_list(msg)
elseif msg.to.type ~= 'chat' then
return chat_list(msg)
end
end
if matches[1] == 'chatlist'then
if is_admin(msg) and msg.to.type == 'chat' then
send_document("chat#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false)
elseif msg.to.type ~= 'chat' then
send_document("user#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false)
end
end
end
end
return {
patterns = {
"^[/!](chats)$",
"^[/!](chatlist)$",
"^[/!](join) (.*)$",
"^[/!](kickme) (.*)$",
"^!!tgservice (chat_add_user)$"
},
run = run,
}
end
| gpl-2.0 |
MRAHS/Backup | plugins/inpm.lua | 1114 | 3008 | do
local function pairsByKeys (t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0 -- iterator variable
local iter = function () -- iterator function
i = i + 1
if a[i] == nil then return nil
else return a[i], t[a[i]]
end
end
return iter
end
local function chat_list(msg)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] then
return 'No groups at the moment'
end
local message = 'List of Groups:\n*Use /join (ID) to join*\n\n '
for k,v in pairs(data[tostring(groups)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairsByKeys(settings) do
if m == 'set_name' then
name = n
end
end
message = message .. '👥 '.. name .. ' (ID: ' .. v .. ')\n\n '
end
local file = io.open("./groups/lists/listed_groups.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function run(msg, matches)
if msg.to.type ~= 'chat' or is_sudo(msg) or is_admin(msg) and is_realm(msg) then
local data = load_data(_config.moderation.data)
if matches[1] == 'join' and data[tostring(matches[2])] then
if is_banned(msg.from.id, matches[2]) then
return 'You are banned.'
end
if is_gbanned(msg.from.id) then
return 'You are globally banned.'
end
if data[tostring(matches[2])]['settings']['lock_member'] == 'yes' and not is_owner2(msg.from.id, matches[2]) then
return 'Group is private.'
end
local chat_id = "chat#id"..matches[2]
local user_id = "user#id"..msg.from.id
chat_add_user(chat_id, user_id, ok_cb, false)
local group_name = data[tostring(matches[2])]['settings']['set_name']
return "Added you to chat:\n\n👥"..group_name.." (ID:"..matches[2]..")"
elseif matches[1] == 'join' and not data[tostring(matches[2])] then
return "Chat not found."
end
if matches[1] == 'chats'then
if is_admin(msg) and msg.to.type == 'chat' then
return chat_list(msg)
elseif msg.to.type ~= 'chat' then
return chat_list(msg)
end
end
if matches[1] == 'chatlist'then
if is_admin(msg) and msg.to.type == 'chat' then
send_document("chat#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false)
elseif msg.to.type ~= 'chat' then
send_document("user#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false)
end
end
end
end
return {
patterns = {
"^[/!](chats)$",
"^[/!](chatlist)$",
"^[/!](join) (.*)$",
"^[/!](kickme) (.*)$",
"^!!tgservice (chat_add_user)$"
},
run = run,
}
end
| gpl-2.0 |
ali0098/zombi-bot | plugins/inpm.lua | 1114 | 3008 | do
local function pairsByKeys (t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0 -- iterator variable
local iter = function () -- iterator function
i = i + 1
if a[i] == nil then return nil
else return a[i], t[a[i]]
end
end
return iter
end
local function chat_list(msg)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] then
return 'No groups at the moment'
end
local message = 'List of Groups:\n*Use /join (ID) to join*\n\n '
for k,v in pairs(data[tostring(groups)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairsByKeys(settings) do
if m == 'set_name' then
name = n
end
end
message = message .. '👥 '.. name .. ' (ID: ' .. v .. ')\n\n '
end
local file = io.open("./groups/lists/listed_groups.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function run(msg, matches)
if msg.to.type ~= 'chat' or is_sudo(msg) or is_admin(msg) and is_realm(msg) then
local data = load_data(_config.moderation.data)
if matches[1] == 'join' and data[tostring(matches[2])] then
if is_banned(msg.from.id, matches[2]) then
return 'You are banned.'
end
if is_gbanned(msg.from.id) then
return 'You are globally banned.'
end
if data[tostring(matches[2])]['settings']['lock_member'] == 'yes' and not is_owner2(msg.from.id, matches[2]) then
return 'Group is private.'
end
local chat_id = "chat#id"..matches[2]
local user_id = "user#id"..msg.from.id
chat_add_user(chat_id, user_id, ok_cb, false)
local group_name = data[tostring(matches[2])]['settings']['set_name']
return "Added you to chat:\n\n👥"..group_name.." (ID:"..matches[2]..")"
elseif matches[1] == 'join' and not data[tostring(matches[2])] then
return "Chat not found."
end
if matches[1] == 'chats'then
if is_admin(msg) and msg.to.type == 'chat' then
return chat_list(msg)
elseif msg.to.type ~= 'chat' then
return chat_list(msg)
end
end
if matches[1] == 'chatlist'then
if is_admin(msg) and msg.to.type == 'chat' then
send_document("chat#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false)
elseif msg.to.type ~= 'chat' then
send_document("user#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false)
end
end
end
end
return {
patterns = {
"^[/!](chats)$",
"^[/!](chatlist)$",
"^[/!](join) (.*)$",
"^[/!](kickme) (.*)$",
"^!!tgservice (chat_add_user)$"
},
run = run,
}
end
| gpl-2.0 |
mattyx14/otxserver | data/monster/vermins/lesser_swarmer.lua | 2 | 2075 | local mType = Game.createMonsterType("Lesser Swarmer")
local monster = {}
monster.description = "a lesser swarmer"
monster.experience = 0
monster.outfit = {
lookType = 460,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.health = 230
monster.maxHealth = 230
monster.race = "venom"
monster.corpse = 13973
monster.speed = 180
monster.manaCost = 0
monster.changeTarget = {
interval = 5000,
chance = 0
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = true,
canPushItems = false,
canPushCreatures = false,
staticAttackChance = 95,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -77, condition = {type = CONDITION_POISON, totalDamage = 60, interval = 4000}},
{name ="combat", interval = 2000, chance = 15, type = COMBAT_LIFEDRAIN, minDamage = -15, maxDamage = -70, range = 5, effect = CONST_ME_MAGIC_RED, target = true}
}
monster.defenses = {
defense = 5,
armor = 5
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 100},
{type = COMBAT_FIREDAMAGE, percent = 0},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = false},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
nitheeshkl/kln_awesome | awesome_3.4/vicious/pacman.lua | 1 | 1147 | ---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2009, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- {{{ Grab environment
local tonumber = tonumber
local io = { popen = io.popen }
local setmetatable = setmetatable
--local string = { match = string.match }
-- }}}
-- Pacman: provides number of pending updates on Arch Linux
module("vicious.pacman")
-- {{{ Pacman widget type
local function worker(format)
-- Initialise counters
local updates = 0
-- Check if updates are available
local f = io.popen("pacman -Qu")
for line in f:lines() do
-- Pacman 3.2 provides the number of available updates
--updates = string.match(line, "^Targets[%s]%(([%d]+)%)") or 0
---- If the count changed then break out of the loop
--if tonumber(updates) > 0 then
-- break
--end
-- Pacman 3.3 returns one line per package
updates = updates + 1
end
f:close()
return {updates}
end
-- }}}
setmetatable(_M, { __call = function(_, ...) return worker(...) end })
| gpl-2.0 |
tgp1994/LiquidRP-tgp1994 | gamemode/fadmin/fadmin/playeractions/giveweapons/sv_init.lua | 3 | 1795 | local function GiveWeapon(ply, cmd, args)
if not FAdmin.Access.PlayerHasPrivilege(ply, "giveweapon") then FAdmin.Messages.SendMessage(ply, 5, "No access!") return end
if not args[2] then return end
local targets = FAdmin.FindPlayer(args[1])
if not targets or #targets == 1 and not IsValid(targets[1]) then
FAdmin.Messages.SendMessage(ply, 1, "Player not found")
return
end
local weapon = weapons.GetStored(args[2])
if table.HasValue(FAdmin.HL2Guns, args[2]) then weapon = args[2]
elseif weapon and weapon.ClassName then weapon = weapon.ClassName end
if not weapon then return end
for _, target in pairs(targets) do
if IsValid(target) then
target:Give(weapon)
end
end
FAdmin.Messages.ActionMessage(ply, targets, "You gave %s a "..weapon, "%s gave you a "..weapon, "Gave %s a "..weapon)
end
local function GiveAmmo(ply, cmd, args)
if not FAdmin.Access.PlayerHasPrivilege(ply, "giveweapon") then FAdmin.Messages.SendMessage(ply, 5, "No access!") return end
if not args[2] or not FAdmin.AmmoTypes[args[2]] then return end
local targets = FAdmin.FindPlayer(args[1])
if not targets or #targets == 1 and not IsValid(targets[1]) then
FAdmin.Messages.SendMessage(ply, 1, "Player not found")
return
end
local ammo = args[2]
local amount = tonumber(args[3]) or FAdmin.AmmoTypes[args[2]]
for _, target in pairs(targets) do
if IsValid(target) then
target:GiveAmmo(amount, ammo)
end
end
FAdmin.Messages.ActionMessage(ply, targets, "You gave %s "..amount.." "..ammo.. " ammo", "%s gave you ".. amount.." "..ammo.. " ammo", "Gave %s "..amount.." "..ammo)
end
FAdmin.StartHooks["GiveWeapons"] = function()
FAdmin.Commands.AddCommand("giveweapon", GiveWeapon)
FAdmin.Commands.AddCommand("giveammo", GiveAmmo)
FAdmin.Access.AddPrivilege("giveweapon", 2)
end | gpl-3.0 |
rainfiel/skynet | service/launcher.lua | 24 | 3372 | local skynet = require "skynet"
local core = require "skynet.core"
require "skynet.manager" -- import manager apis
local string = string
local services = {}
local command = {}
local instance = {} -- for confirm (function command.LAUNCH / command.ERROR / command.LAUNCHOK)
local function handle_to_address(handle)
return tonumber("0x" .. string.sub(handle , 2))
end
local NORET = {}
function command.LIST()
local list = {}
for k,v in pairs(services) do
list[skynet.address(k)] = v
end
return list
end
function command.STAT()
local list = {}
for k,v in pairs(services) do
local ok, stat = pcall(skynet.call,k,"debug","STAT")
if not ok then
stat = string.format("ERROR (%s)",v)
end
list[skynet.address(k)] = stat
end
return list
end
function command.KILL(_, handle)
handle = handle_to_address(handle)
skynet.kill(handle)
local ret = { [skynet.address(handle)] = tostring(services[handle]) }
services[handle] = nil
return ret
end
function command.MEM()
local list = {}
for k,v in pairs(services) do
local ok, kb, bytes = pcall(skynet.call,k,"debug","MEM")
if not ok then
list[skynet.address(k)] = string.format("ERROR (%s)",v)
else
list[skynet.address(k)] = string.format("%.2f Kb (%s)",kb,v)
end
end
return list
end
function command.GC()
for k,v in pairs(services) do
skynet.send(k,"debug","GC")
end
return command.MEM()
end
function command.REMOVE(_, handle, kill)
services[handle] = nil
local response = instance[handle]
if response then
-- instance is dead
response(not kill) -- return nil to caller of newservice, when kill == false
instance[handle] = nil
end
-- don't return (skynet.ret) because the handle may exit
return NORET
end
local function launch_service(service, ...)
local param = table.concat({...}, " ")
local inst = skynet.launch(service, param)
local response = skynet.response()
if inst then
services[inst] = service .. " " .. param
instance[inst] = response
else
response(false)
return
end
return inst
end
function command.LAUNCH(_, service, ...)
launch_service(service, ...)
return NORET
end
function command.LOGLAUNCH(_, service, ...)
local inst = launch_service(service, ...)
if inst then
core.command("LOGON", skynet.address(inst))
end
return NORET
end
function command.ERROR(address)
-- see serivce-src/service_lua.c
-- init failed
local response = instance[address]
if response then
response(false)
instance[address] = nil
end
services[address] = nil
return NORET
end
function command.LAUNCHOK(address)
-- init notice
local response = instance[address]
if response then
response(true, address)
instance[address] = nil
end
return NORET
end
-- for historical reasons, launcher support text command (for C service)
skynet.register_protocol {
name = "text",
id = skynet.PTYPE_TEXT,
unpack = skynet.tostring,
dispatch = function(session, address , cmd)
if cmd == "" then
command.LAUNCHOK(address)
elseif cmd == "ERROR" then
command.ERROR(address)
else
error ("Invalid text command " .. cmd)
end
end,
}
skynet.dispatch("lua", function(session, address, cmd , ...)
cmd = string.upper(cmd)
local f = command[cmd]
if f then
local ret = f(address, ...)
if ret ~= NORET then
skynet.ret(skynet.pack(ret))
end
else
skynet.ret(skynet.pack {"Unknown command"} )
end
end)
skynet.start(function() end)
| mit |
luciouskami/YDWE | Development/Component/compiler/script/computed/order_id.lua | 3 | 8231 | local order2id = {
smart = 0xD0003,
stop = 0xD0004,
setrally = 0xD000C,
getitem = 0xD000D,
attack = 0xD000F,
attackground = 0xD0010,
attackonce = 0xD0011,
move = 0xD0012,
AImove = 0xD0014,
patrol = 0xD0016,
holdposition = 0xD0019,
build = 0xD001A,
humanbuild = 0xD001B,
orcbuild = 0xD001C,
nightelfbuild = 0xD001D,
undeadbuild = 0xD001E,
resumebuild = 0xD001F,
dropitem = 0xD0021,
detectaoe = 0xD002F,
resumeharvesting = 0xD0031,
harvest = 0xD0032,
returnresources = 0xD0034,
autoharvestgold = 0xD0035,
autoharvestlumber = 0xD0036,
neutraldetectaoe = 0xD0037,
repair = 0xD0038,
repairon = 0xD0039,
repairoff = 0xD003A,
revive = 0xD0047,
selfdestruct = 0xD0048,
selfdestructon = 0xD0049,
selfdestructoff = 0xD004A,
board = 0xD004B,
forceboard = 0xD004C,
load = 0xD004E,
unload = 0xD004F,
unloadall = 0xD0050,
unloadallinstant = 0xD0051,
loadcorpse = 0xD0052,
loadcorpseinstant = 0xD0055,
unloadallcorpses = 0xD0056,
defend = 0xD0057,
undefend = 0xD0058,
dispel = 0xD0059,
flare = 0xD005C,
heal = 0xD005F,
healon = 0xD0060,
healoff = 0xD0061,
innerfire = 0xD0062,
innerfireon = 0xD0063,
innerfireoff = 0xD0064,
invisibility = 0xD0065,
militiaconvert = 0xD0067,
militia = 0xD0068,
militiaoff = 0xD0069,
polymorph = 0xD006A,
slow = 0xD006B,
slowon = 0xD006C,
slowoff = 0xD006D,
tankdroppilot = 0xD006F,
tankloadpilot = 0xD0070,
tankpilot = 0xD0071,
townbellon = 0xD0072,
townbelloff = 0xD0073,
avatar = 0xD0076,
unavatar = 0xD0077,
blizzard = 0xD0079,
divineshield = 0xD007A,
undivineshield = 0xD007B,
holybolt = 0xD007C,
massteleport = 0xD007D,
resurrection = 0xD007E,
thunderbolt = 0xD007F,
thunderclap = 0xD0080,
waterelemental = 0xD0081,
battlestations = 0xD0083,
berserk = 0xD0084,
bloodlust = 0xD0085,
bloodluston = 0xD0086,
bloodlustoff = 0xD0087,
devour = 0xD0088,
evileye = 0xD0089,
ensnare = 0xD008A,
ensnareon = 0xD008B,
ensnareoff = 0xD008C,
healingward = 0xD008D,
lightningshield = 0xD008E,
purge = 0xD008F,
standdown = 0xD0091,
stasistrap = 0xD0092,
chainlightning = 0xD0097,
earthquake = 0xD0099,
farsight = 0xD009A,
mirrorimage = 0xD009B,
shockwave = 0xD009D,
spiritwolf = 0xD009E,
stomp = 0xD009F,
whirlwind = 0xD00A0,
windwalk = 0xD00A1,
unwindwalk = 0xD00A2,
ambush = 0xD00A3,
autodispel = 0xD00A4,
autodispelon = 0xD00A5,
autodispeloff = 0xD00A6,
barkskin = 0xD00A7,
barkskinon = 0xD00A8,
barkskinoff = 0xD00A9,
bearform = 0xD00AA,
unbearform = 0xD00AB,
corrosivebreath = 0xD00AC,
loadarcher = 0xD00AE,
mounthippogryph = 0xD00AF,
cyclone = 0xD00B0,
detonate = 0xD00B1,
eattree = 0xD00B2,
entangle = 0xD00B3,
entangleinstant = 0xD00B4,
faeriefire = 0xD00B5,
faeriefireon = 0xD00B6,
faeriefireoff = 0xD00B7,
ravenform = 0xD00BB,
unravenform = 0xD00BC,
recharge = 0xD00BD,
rechargeon = 0xD00BE,
rechargeoff = 0xD00BF,
rejuvination = 0xD00C0,
renew = 0xD00C1,
renewon = 0xD00C2,
renewoff = 0xD00C3,
roar = 0xD00C4,
root = 0xD00C5,
unroot = 0xD00C6,
entanglingroots = 0xD00CB,
flamingarrowstarg = 0xD00CD,
flamingarrows = 0xD00CE,
unflamingarrows = 0xD00CF,
forceofnature = 0xD00D0,
immolation = 0xD00D1,
unimmolation = 0xD00D2,
manaburn = 0xD00D3,
metamorphosis = 0xD00D4,
scout = 0xD00D5,
sentinel = 0xD00D6,
starfall = 0xD00D7,
tranquility = 0xD00D8,
acolyteharvest = 0xD00D9,
antimagicshell = 0xD00DA,
blight = 0xD00DB,
cannibalize = 0xD00DC,
cripple = 0xD00DD,
curse = 0xD00DE,
curseon = 0xD00DF,
curseoff = 0xD00E0,
freezingbreath = 0xD00E3,
possession = 0xD00E4,
raisedead = 0xD00E5,
raisedeadon = 0xD00E6,
raisedeadoff = 0xD00E7,
instant = 0xD00E8,
requestsacrifice = 0xD00E9,
restoration = 0xD00EA,
restorationon = 0xD00EB,
restorationoff = 0xD00EC,
sacrifice = 0xD00ED,
stoneform = 0xD00EE,
unstoneform = 0xD00EF,
unholyfrenzy = 0xD00F1,
unsummon = 0xD00F2,
web = 0xD00F3,
webon = 0xD00F4,
weboff = 0xD00F5,
wispharvest = 0xD00F6,
auraunholy = 0xD00F7,
auravampiric = 0xD00F8,
animatedead = 0xD00F9,
carrionswarm = 0xD00FA,
darkritual = 0xD00FB,
darksummoning = 0xD00FC,
deathanddecay = 0xD00FD,
deathcoil = 0xD00FE,
deathpact = 0xD00FF,
dreadlordinferno = 0xD0100,
frostarmor = 0xD0101,
frostnova = 0xD0102,
sleep = 0xD0103,
darkconversion = 0xD0104,
darkportal = 0xD0105,
fingerofdeath = 0xD0106,
firebolt = 0xD0107,
inferno = 0xD0108,
gold2lumber = 0xD0109,
lumber2gold = 0xD010A,
spies = 0xD010B,
rainofchaos = 0xD010D,
rainoffire = 0xD010E,
request_hero = 0xD010F,
disassociate = 0xD0110,
revenge = 0xD0111,
soulpreservation = 0xD0112,
coldarrowstarg = 0xD0113,
coldarrows = 0xD0114,
uncoldarrows = 0xD0115,
creepanimatedead = 0xD0116,
creepdevour = 0xD0117,
creepheal = 0xD0118,
creephealon = 0xD0119,
creephealoff = 0xD011A,
creepthunderbolt = 0xD011C,
creepthunderclap = 0xD011D,
poisonarrowstarg = 0xD011E,
poisonarrows = 0xD011F,
unpoisonarrows = 0xD0120,
frostarmoron = 0xD01EA,
frostarmoroff = 0xD01EB,
awaken = 0xD01F2,
nagabuild = 0xD01F3,
mount = 0xD01F5,
dismount = 0xD01F6,
cloudoffog = 0xD01F9,
controlmagic = 0xD01FA,
magicdefense = 0xD01FE,
magicundefense = 0xD01FF,
magicleash = 0xD0200,
phoenixfire = 0xD0201,
phoenixmorph = 0xD0202,
spellsteal = 0xD0203,
spellstealon = 0xD0204,
spellstealoff = 0xD0205,
banish = 0xD0206,
drain = 0xD0207,
flamestrike = 0xD0208,
summonphoenix = 0xD0209,
ancestralspirit = 0xD020A,
ancestralspirittarget = 0xD020B,
corporealform = 0xD020D,
uncorporealform = 0xD020E,
disenchant = 0xD020F,
etherealform = 0xD0210,
unetherealform = 0xD0211,
spiritlink = 0xD0213,
unstableconcoction = 0xD0214,
healingwave = 0xD0215,
hex = 0xD0216,
voodoo = 0xD0217,
ward = 0xD0218,
autoentangle = 0xD0219,
autoentangleinstant = 0xD021A,
coupletarget = 0xD021B,
coupleinstant = 0xD021C,
decouple = 0xD021D,
grabtree = 0xD021F,
manaflareon = 0xD0220,
manaflareoff = 0xD0221,
phaseshift = 0xD0222,
phaseshifton = 0xD0223,
phaseshiftoff = 0xD0224,
phaseshiftinstant = 0xD0225,
taunt = 0xD0228,
vengeance = 0xD0229,
vengeanceon = 0xD022A,
vengeanceoff = 0xD022B,
vengeanceinstant = 0xD022C,
blink = 0xD022D,
fanofknives = 0xD022E,
shadowstrike = 0xD022F,
spiritofvengeance = 0xD0230,
absorb = 0xD0231,
avengerform = 0xD0233,
unavengerform = 0xD0234,
burrow = 0xD0235,
unburrow = 0xD0236,
devourmagic = 0xD0238,
flamingattacktarg = 0xD023B,
flamingattack = 0xD023C,
unflamingattack = 0xD023D,
replenish = 0xD023E,
replenishon = 0xD023F,
replenishoff = 0xD0240,
replenishlife = 0xD0241,
replenishlifeon = 0xD0242,
replenishlifeoff = 0xD0243,
replenishmana = 0xD0244,
replenishmanaon = 0xD0245,
replenishmanaoff = 0xD0246,
carrionscarabs = 0xD0247,
carrionscarabson = 0xD0248,
carrionscarabsoff = 0xD0249,
carrionscarabsinstant = 0xD024A,
impale = 0xD024B,
locustswarm = 0xD024C,
breathoffrost = 0xD0250,
frenzy = 0xD0251,
frenzyon = 0xD0252,
frenzyoff = 0xD0253,
mechanicalcritter = 0xD0254,
mindrot = 0xD0255,
neutralinteract = 0xD0256,
preservation = 0xD0258,
sanctuary = 0xD0259,
shadowsight = 0xD025A,
spellshield = 0xD025B,
spellshieldaoe = 0xD025C,
spirittroll = 0xD025D,
steal = 0xD025E,
attributemodskill = 0xD0260,
blackarrow = 0xD0261,
blackarrowon = 0xD0262,
blackarrowoff = 0xD0263,
breathoffire = 0xD0264,
charm = 0xD0265,
doom = 0xD0267,
drunkenhaze = 0xD0269,
elementalfury = 0xD026A,
forkedlightning = 0xD026B,
howlofterror = 0xD026C,
manashieldon = 0xD026D,
manashieldoff = 0xD026E,
monsoon = 0xD026F,
silence = 0xD0270,
stampede = 0xD0271,
summongrizzly = 0xD0272,
summonquillbeast = 0xD0273,
summonwareagle = 0xD0274,
tornado = 0xD0275,
wateryminion = 0xD0276,
battleroar = 0xD0277,
channel = 0xD0278,
parasite = 0xD0279,
parasiteon = 0xD027A,
parasiteoff = 0xD027B,
submerge = 0xD027C,
unsubmerge = 0xD027D,
neutralspell = 0xD0296,
militiaunconvert = 0xD02AB,
clusterrockets = 0xD02AC,
robogoblin = 0xD02B0,
unrobogoblin = 0xD02B1,
summonfactory = 0xD02B2,
acidbomb = 0xD02B6,
chemicalrage = 0xD02B7,
healingspray = 0xD02B8,
transmute = 0xD02B9,
lavamonster = 0xD02BB,
soulburn = 0xD02BC,
volcano = 0xD02BD,
incineratearrow = 0xD02BE,
incineratearrowon = 0xD02BF,
incineratearrowoff = 0xD02C0,
}
return order2id
| gpl-3.0 |
mattyx14/otxserver | data/monster/reptiles/lizard_legionnaire.lua | 2 | 3112 | local mType = Game.createMonsterType("Lizard Legionnaire")
local monster = {}
monster.description = "a lizard legionnaire"
monster.experience = 1100
monster.outfit = {
lookType = 338,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.raceId = 624
monster.Bestiary = {
class = "Reptile",
race = BESTY_RACE_REPTILE,
toKill = 1000,
FirstUnlock = 50,
SecondUnlock = 500,
CharmsPoints = 25,
Stars = 3,
Occurrence = 0,
Locations = "Zzaion, Zao Palace and its antechambers, Muggy Plains, Zao Orc Land (in fort), \z
Corruption Hole, Razachai, Temple of Equilibrium, Northern Zao Plantations."
}
monster.health = 1400
monster.maxHealth = 1400
monster.race = "blood"
monster.corpse = 10359
monster.speed = 266
monster.manaCost = 0
monster.changeTarget = {
interval = 4000,
chance = 10
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = false,
staticAttackChance = 90,
targetDistance = 4,
runHealth = 10,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = true,
canWalkOnPoison = true
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "Tssss!", yell = false}
}
monster.loot = {
{name = "small diamond", chance = 1001, maxCount = 2},
{name = "gold coin", chance = 44000, maxCount = 100},
{name = "gold coin", chance = 54000, maxCount = 65},
{name = "lizard leather", chance = 970},
{name = "lizard scale", chance = 980, maxCount = 3},
{name = "strong health potion", chance = 3880},
{name = "red lantern", chance = 530},
{name = "bunch of ripe rice", chance = 1950},
{name = "zaoan armor", chance = 70},
{name = "zaoan shoes", chance = 460},
{name = "drakinata", chance = 710},
{name = "zaoan halberd", chance = 960},
{name = "legionnaire flags", chance = 1940},
{name = "broken halberd", chance = 14940},
{name = "lizard trophy", chance = 20}
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -180},
{name ="combat", interval = 2000, chance = 40, type = COMBAT_PHYSICALDAMAGE, minDamage = 0, maxDamage = -200, range = 7, shootEffect = CONST_ANI_SPEAR, target = true}
}
monster.defenses = {
defense = 25,
armor = 25
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 100},
{type = COMBAT_FIREDAMAGE, percent = 45},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = -10},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
HeavenIsLost/cast | data/npc/lib/npcsystem/npchandler.lua | 13 | 21971 | -- Advanced NPC System by Jiddo
if NpcHandler == nil then
-- Constant talkdelay behaviors.
TALKDELAY_NONE = 0 -- No talkdelay. Npc will reply immedeatly.
TALKDELAY_ONTHINK = 1 -- Talkdelay handled through the onThink callback function. (Default)
TALKDELAY_EVENT = 2 -- Not yet implemented
-- Currently applied talkdelay behavior. TALKDELAY_ONTHINK is default.
NPCHANDLER_TALKDELAY = TALKDELAY_ONTHINK
-- Constant indexes for defining default messages.
MESSAGE_GREET = 1 -- When the player greets the npc.
MESSAGE_FAREWELL = 2 -- When the player unGreets the npc.
MESSAGE_BUY = 3 -- When the npc asks the player if he wants to buy something.
MESSAGE_ONBUY = 4 -- When the player successfully buys something via talk.
MESSAGE_BOUGHT = 5 -- When the player bought something through the shop window.
MESSAGE_SELL = 6 -- When the npc asks the player if he wants to sell something.
MESSAGE_ONSELL = 7 -- When the player successfully sells something via talk.
MESSAGE_SOLD = 8 -- When the player sold something through the shop window.
MESSAGE_MISSINGMONEY = 9 -- When the player does not have enough money.
MESSAGE_NEEDMONEY = 10 -- Same as above, used for shop window.
MESSAGE_MISSINGITEM = 11 -- When the player is trying to sell an item he does not have.
MESSAGE_NEEDITEM = 12 -- Same as above, used for shop window.
MESSAGE_NEEDSPACE = 13 -- When the player don't have any space to buy an item
MESSAGE_NEEDMORESPACE = 14 -- When the player has some space to buy an item, but not enough space
MESSAGE_IDLETIMEOUT = 15 -- When the player has been idle for longer then idleTime allows.
MESSAGE_WALKAWAY = 16 -- When the player walks out of the talkRadius of the npc.
MESSAGE_DECLINE = 17 -- When the player says no to something.
MESSAGE_SENDTRADE = 18 -- When the npc sends the trade window to the player
MESSAGE_NOSHOP = 19 -- When the npc's shop is requested but he doesn't have any
MESSAGE_ONCLOSESHOP = 20 -- When the player closes the npc's shop window
MESSAGE_ALREADYFOCUSED = 21 -- When the player already has the focus of this npc.
MESSAGE_WALKAWAY_MALE = 22 -- When a male player walks out of the talkRadius of the npc.
MESSAGE_WALKAWAY_FEMALE = 23 -- When a female player walks out of the talkRadius of the npc.
-- Constant indexes for callback functions. These are also used for module callback ids.
CALLBACK_CREATURE_APPEAR = 1
CALLBACK_CREATURE_DISAPPEAR = 2
CALLBACK_CREATURE_SAY = 3
CALLBACK_ONTHINK = 4
CALLBACK_GREET = 5
CALLBACK_FAREWELL = 6
CALLBACK_MESSAGE_DEFAULT = 7
CALLBACK_PLAYER_ENDTRADE = 8
CALLBACK_PLAYER_CLOSECHANNEL = 9
CALLBACK_ONBUY = 10
CALLBACK_ONSELL = 11
CALLBACK_ONADDFOCUS = 18
CALLBACK_ONRELEASEFOCUS = 19
CALLBACK_ONTRADEREQUEST = 20
-- Addidional module callback ids
CALLBACK_MODULE_INIT = 12
CALLBACK_MODULE_RESET = 13
-- Constant strings defining the keywords to replace in the default messages.
TAG_PLAYERNAME = "|PLAYERNAME|"
TAG_ITEMCOUNT = "|ITEMCOUNT|"
TAG_TOTALCOST = "|TOTALCOST|"
TAG_ITEMNAME = "|ITEMNAME|"
NpcHandler = {
keywordHandler = nil,
focuses = nil,
talkStart = nil,
idleTime = 120,
talkRadius = 3,
talkDelayTime = 1, -- Seconds to delay outgoing messages.
talkDelay = nil,
callbackFunctions = nil,
modules = nil,
shopItems = nil, -- They must be here since ShopModule uses 'static' functions
eventSay = nil,
eventDelayedSay = nil,
topic = nil,
messages = {
-- These are the default replies of all npcs. They can/should be changed individually for each npc.
[MESSAGE_GREET] = "Greetings, |PLAYERNAME|.",
[MESSAGE_FAREWELL] = "Good bye, |PLAYERNAME|.",
[MESSAGE_BUY] = "Do you want to buy |ITEMCOUNT| |ITEMNAME| for |TOTALCOST| gold coins?",
[MESSAGE_ONBUY] = "Here you are.",
[MESSAGE_BOUGHT] = "Bought |ITEMCOUNT|x |ITEMNAME| for |TOTALCOST| gold.",
[MESSAGE_SELL] = "Do you want to sell |ITEMCOUNT| |ITEMNAME| for |TOTALCOST| gold coins?",
[MESSAGE_ONSELL] = "Here you are, |TOTALCOST| gold.",
[MESSAGE_SOLD] = "Sold |ITEMCOUNT|x |ITEMNAME| for |TOTALCOST| gold.",
[MESSAGE_MISSINGMONEY] = "You don't have enough money.",
[MESSAGE_NEEDMONEY] = "You don't have enough money.",
[MESSAGE_MISSINGITEM] = "You don't have so many.",
[MESSAGE_NEEDITEM] = "You do not have this object.",
[MESSAGE_NEEDSPACE] = "You do not have enough capacity.",
[MESSAGE_NEEDMORESPACE] = "You do not have enough capacity for all items.",
[MESSAGE_IDLETIMEOUT] = "Good bye.",
[MESSAGE_WALKAWAY] = "Good bye.",
[MESSAGE_DECLINE] = "Then not.",
[MESSAGE_SENDTRADE] = "Of course, just browse through my wares.",
[MESSAGE_NOSHOP] = "Sorry, I'm not offering anything.",
[MESSAGE_ONCLOSESHOP] = "Thank you, come back whenever you're in need of something else.",
[MESSAGE_ALREADYFOCUSED]= "|PLAYERNAME|, I am already talking to you.",
[MESSAGE_WALKAWAY_MALE] = "Good bye.",
[MESSAGE_WALKAWAY_FEMALE] = "Good bye."
}
}
-- Creates a new NpcHandler with an empty callbackFunction stack.
function NpcHandler:new(keywordHandler)
local obj = {}
obj.callbackFunctions = {}
obj.modules = {}
obj.eventSay = {}
obj.eventDelayedSay = {}
obj.topic = {}
obj.focuses = {}
obj.talkStart = {}
obj.talkDelay = {}
obj.keywordHandler = keywordHandler
obj.messages = {}
obj.shopItems = {}
setmetatable(obj.messages, self.messages)
self.messages.__index = self.messages
setmetatable(obj, self)
self.__index = self
return obj
end
-- Re-defines the maximum idle time allowed for a player when talking to this npc.
function NpcHandler:setMaxIdleTime(newTime)
self.idleTime = newTime
end
-- Attaches a new keyword handler to this npchandler
function NpcHandler:setKeywordHandler(newHandler)
self.keywordHandler = newHandler
end
-- Function used to change the focus of this npc.
function NpcHandler:addFocus(newFocus)
if self:isFocused(newFocus) then
return
end
self.focuses[#self.focuses + 1] = newFocus
self.topic[newFocus] = 0
local callback = self:getCallback(CALLBACK_ONADDFOCUS)
if callback == nil or callback(newFocus) then
self:processModuleCallback(CALLBACK_ONADDFOCUS, newFocus)
end
self:updateFocus()
end
-- Function used to verify if npc is focused to certain player
function NpcHandler:isFocused(focus)
for k,v in pairs(self.focuses) do
if v == focus then
return true
end
end
return false
end
-- This function should be called on each onThink and makes sure the npc faces the player it is talking to.
-- Should also be called whenever a new player is focused.
function NpcHandler:updateFocus()
for pos, focus in pairs(self.focuses) do
if focus ~= nil then
doNpcSetCreatureFocus(focus)
return
end
end
doNpcSetCreatureFocus(0)
end
-- Used when the npc should un-focus the player.
function NpcHandler:releaseFocus(focus)
if shop_cost[focus] ~= nil then
table.remove(shop_amount, focus)
table.remove(shop_cost, focus)
table.remove(shop_rlname, focus)
table.remove(shop_itemid, focus)
table.remove(shop_container, focus)
table.remove(shop_npcuid, focus)
table.remove(shop_eventtype, focus)
table.remove(shop_subtype, focus)
table.remove(shop_destination, focus)
table.remove(shop_premium, focus)
end
if self.eventDelayedSay[focus] then
self:cancelNPCTalk(self.eventDelayedSay[focus])
end
if not self:isFocused(focus) then
return
end
local pos = nil
for k,v in pairs(self.focuses) do
if v == focus then
pos = k
end
end
table.remove(self.focuses, pos)
self.eventSay[focus] = nil
self.eventDelayedSay[focus] = nil
self.talkStart[focus] = nil
self.topic[focus] = nil
local callback = self:getCallback(CALLBACK_ONRELEASEFOCUS)
if callback == nil or callback(focus) then
self:processModuleCallback(CALLBACK_ONRELEASEFOCUS, focus)
end
if Player(focus) ~= nil then
closeShopWindow(focus) --Even if it can not exist, we need to prevent it.
self:updateFocus()
end
end
-- Returns the callback function with the specified id or nil if no such callback function exists.
function NpcHandler:getCallback(id)
local ret = nil
if self.callbackFunctions ~= nil then
ret = self.callbackFunctions[id]
end
return ret
end
-- Changes the callback function for the given id to callback.
function NpcHandler:setCallback(id, callback)
if self.callbackFunctions ~= nil then
self.callbackFunctions[id] = callback
end
end
-- Adds a module to this npchandler and inits it.
function NpcHandler:addModule(module)
if self.modules ~= nil then
self.modules[#self.modules +1] = module
module:init(self)
end
end
-- Calls the callback function represented by id for all modules added to this npchandler with the given arguments.
function NpcHandler:processModuleCallback(id, ...)
local ret = true
for i, module in pairs(self.modules) do
local tmpRet = true
if id == CALLBACK_CREATURE_APPEAR and module.callbackOnCreatureAppear ~= nil then
tmpRet = module:callbackOnCreatureAppear(...)
elseif id == CALLBACK_CREATURE_DISAPPEAR and module.callbackOnCreatureDisappear ~= nil then
tmpRet = module:callbackOnCreatureDisappear(...)
elseif id == CALLBACK_CREATURE_SAY and module.callbackOnCreatureSay ~= nil then
tmpRet = module:callbackOnCreatureSay(...)
elseif id == CALLBACK_PLAYER_ENDTRADE and module.callbackOnPlayerEndTrade ~= nil then
tmpRet = module:callbackOnPlayerEndTrade(...)
elseif id == CALLBACK_PLAYER_CLOSECHANNEL and module.callbackOnPlayerCloseChannel ~= nil then
tmpRet = module:callbackOnPlayerCloseChannel(...)
elseif id == CALLBACK_ONBUY and module.callbackOnBuy ~= nil then
tmpRet = module:callbackOnBuy(...)
elseif id == CALLBACK_ONSELL and module.callbackOnSell ~= nil then
tmpRet = module:callbackOnSell(...)
elseif id == CALLBACK_ONTRADEREQUEST and module.callbackOnTradeRequest ~= nil then
tmpRet = module:callbackOnTradeRequest(...)
elseif id == CALLBACK_ONADDFOCUS and module.callbackOnAddFocus ~= nil then
tmpRet = module:callbackOnAddFocus(...)
elseif id == CALLBACK_ONRELEASEFOCUS and module.callbackOnReleaseFocus ~= nil then
tmpRet = module:callbackOnReleaseFocus(...)
elseif id == CALLBACK_ONTHINK and module.callbackOnThink ~= nil then
tmpRet = module:callbackOnThink(...)
elseif id == CALLBACK_GREET and module.callbackOnGreet ~= nil then
tmpRet = module:callbackOnGreet(...)
elseif id == CALLBACK_FAREWELL and module.callbackOnFarewell ~= nil then
tmpRet = module:callbackOnFarewell(...)
elseif id == CALLBACK_MESSAGE_DEFAULT and module.callbackOnMessageDefault ~= nil then
tmpRet = module:callbackOnMessageDefault(...)
elseif id == CALLBACK_MODULE_RESET and module.callbackOnModuleReset ~= nil then
tmpRet = module:callbackOnModuleReset(...)
end
if not tmpRet then
ret = false
break
end
end
return ret
end
-- Returns the message represented by id.
function NpcHandler:getMessage(id)
local ret = nil
if self.messages ~= nil then
ret = self.messages[id]
end
return ret
end
-- Changes the default response message with the specified id to newMessage.
function NpcHandler:setMessage(id, newMessage)
if self.messages ~= nil then
self.messages[id] = newMessage
end
end
-- Translates all message tags found in msg using parseInfo
function NpcHandler:parseMessage(msg, parseInfo)
local ret = msg
for search, replace in pairs(parseInfo) do
ret = string.gsub(ret, search, replace)
end
return ret
end
-- Makes sure the npc un-focuses the currently focused player
function NpcHandler:unGreet(cid)
if not self:isFocused(cid) then
return
end
local callback = self:getCallback(CALLBACK_FAREWELL)
if callback == nil or callback() then
if self:processModuleCallback(CALLBACK_FAREWELL) then
local msg = self:getMessage(MESSAGE_FAREWELL)
local parseInfo = { [TAG_PLAYERNAME] = Player(cid):getName() }
self:resetNpc(cid)
msg = self:parseMessage(msg, parseInfo)
self:say(msg, cid, true)
self:releaseFocus(cid)
end
end
end
-- Greets a new player.
function NpcHandler:greet(cid)
if cid ~= 0 then
local callback = self:getCallback(CALLBACK_GREET)
if callback == nil or callback(cid) then
if self:processModuleCallback(CALLBACK_GREET, cid) then
local msg = self:getMessage(MESSAGE_GREET)
local parseInfo = { [TAG_PLAYERNAME] = Player(cid):getName() }
msg = self:parseMessage(msg, parseInfo)
self:say(msg, cid, true)
else
return
end
else
return
end
end
self:addFocus(cid)
end
-- Handles onCreatureAppear events. If you with to handle this yourself, please use the CALLBACK_CREATURE_APPEAR callback.
function NpcHandler:onCreatureAppear(creature)
local cid = creature:getId()
if cid == getNpcCid() and next(self.shopItems) ~= nil then
local npc = Npc()
local speechBubble = npc:getSpeechBubble()
if speechBubble == 3 then
npc:setSpeechBubble(4)
else
npc:setSpeechBubble(2)
end
end
local callback = self:getCallback(CALLBACK_CREATURE_APPEAR)
if callback == nil or callback(cid) then
if self:processModuleCallback(CALLBACK_CREATURE_APPEAR, cid) then
--
end
end
end
-- Handles onCreatureDisappear events. If you with to handle this yourself, please use the CALLBACK_CREATURE_DISAPPEAR callback.
function NpcHandler:onCreatureDisappear(creature)
local cid = creature:getId()
if getNpcCid() == cid then
return
end
local callback = self:getCallback(CALLBACK_CREATURE_DISAPPEAR)
if callback == nil or callback(cid) then
if self:processModuleCallback(CALLBACK_CREATURE_DISAPPEAR, cid) then
if self:isFocused(cid) then
self:unGreet(cid)
end
end
end
end
-- Handles onCreatureSay events. If you with to handle this yourself, please use the CALLBACK_CREATURE_SAY callback.
function NpcHandler:onCreatureSay(creature, msgtype, msg)
local cid = creature:getId()
local callback = self:getCallback(CALLBACK_CREATURE_SAY)
if callback == nil or callback(cid, msgtype, msg) then
if self:processModuleCallback(CALLBACK_CREATURE_SAY, cid, msgtype, msg) then
if not self:isInRange(cid) then
return
end
if self.keywordHandler ~= nil then
if self:isFocused(cid) and msgtype == TALKTYPE_PRIVATE_PN or not self:isFocused(cid) then
local ret = self.keywordHandler:processMessage(cid, msg)
if(not ret) then
local callback = self:getCallback(CALLBACK_MESSAGE_DEFAULT)
if callback ~= nil and callback(cid, msgtype, msg) then
self.talkStart[cid] = os.time()
end
else
self.talkStart[cid] = os.time()
end
end
end
end
end
end
-- Handles onPlayerEndTrade events. If you wish to handle this yourself, use the CALLBACK_PLAYER_ENDTRADE callback.
function NpcHandler:onPlayerEndTrade(creature)
local cid = creature:getId()
local callback = self:getCallback(CALLBACK_PLAYER_ENDTRADE)
if callback == nil or callback(cid) then
if self:processModuleCallback(CALLBACK_PLAYER_ENDTRADE, cid, msgtype, msg) then
if self:isFocused(cid) then
local parseInfo = { [TAG_PLAYERNAME] = Player(cid):getName() }
local msg = self:parseMessage(self:getMessage(MESSAGE_ONCLOSESHOP), parseInfo)
self:say(msg, cid)
end
end
end
end
-- Handles onPlayerCloseChannel events. If you wish to handle this yourself, use the CALLBACK_PLAYER_CLOSECHANNEL callback.
function NpcHandler:onPlayerCloseChannel(creature)
local cid = creature:getId()
local callback = self:getCallback(CALLBACK_PLAYER_CLOSECHANNEL)
if callback == nil or callback(cid) then
if self:processModuleCallback(CALLBACK_PLAYER_CLOSECHANNEL, cid, msgtype, msg) then
if self:isFocused(cid) then
self:unGreet(cid)
end
end
end
end
-- Handles onBuy events. If you wish to handle this yourself, use the CALLBACK_ONBUY callback.
function NpcHandler:onBuy(creature, itemid, subType, amount, ignoreCap, inBackpacks)
local cid = creature:getId()
local callback = self:getCallback(CALLBACK_ONBUY)
if callback == nil or callback(cid, itemid, subType, amount, ignoreCap, inBackpacks) then
if self:processModuleCallback(CALLBACK_ONBUY, cid, itemid, subType, amount, ignoreCap, inBackpacks) then
--
end
end
end
-- Handles onSell events. If you wish to handle this yourself, use the CALLBACK_ONSELL callback.
function NpcHandler:onSell(creature, itemid, subType, amount, ignoreCap, inBackpacks)
local cid = creature:getId()
local callback = self:getCallback(CALLBACK_ONSELL)
if callback == nil or callback(cid, itemid, subType, amount, ignoreCap, inBackpacks) then
if self:processModuleCallback(CALLBACK_ONSELL, cid, itemid, subType, amount, ignoreCap, inBackpacks) then
--
end
end
end
-- Handles onTradeRequest events. If you wish to handle this yourself, use the CALLBACK_ONTRADEREQUEST callback.
function NpcHandler:onTradeRequest(cid)
local callback = self:getCallback(CALLBACK_ONTRADEREQUEST)
if callback == nil or callback(cid) then
if self:processModuleCallback(CALLBACK_ONTRADEREQUEST, cid) then
return true
end
end
return false
end
-- Handles onThink events. If you wish to handle this yourself, please use the CALLBACK_ONTHINK callback.
function NpcHandler:onThink()
local callback = self:getCallback(CALLBACK_ONTHINK)
if callback == nil or callback() then
if NPCHANDLER_TALKDELAY == TALKDELAY_ONTHINK then
for cid, talkDelay in pairs(self.talkDelay) do
if talkDelay.time ~= nil and talkDelay.message ~= nil and os.time() >= talkDelay.time then
selfSay(talkDelay.message, cid, talkDelay.publicize and true or false)
self.talkDelay[cid] = nil
end
end
end
if self:processModuleCallback(CALLBACK_ONTHINK) then
for pos, focus in pairs(self.focuses) do
if focus ~= nil then
if not self:isInRange(focus) then
self:onWalkAway(focus)
elseif self.talkStart[focus] ~= nil and (os.time() - self.talkStart[focus]) > self.idleTime then
self:unGreet(focus)
else
self:updateFocus()
end
end
end
end
end
end
-- Tries to greet the player with the given cid.
function NpcHandler:onGreet(cid)
if self:isInRange(cid) then
if not self:isFocused(cid) then
self:greet(cid)
return
end
end
end
-- Simply calls the underlying unGreet function.
function NpcHandler:onFarewell(cid)
self:unGreet(cid)
end
-- Should be called on this npc's focus if the distance to focus is greater then talkRadius.
function NpcHandler:onWalkAway(cid)
if self:isFocused(cid) then
local callback = self:getCallback(CALLBACK_CREATURE_DISAPPEAR)
if callback == nil or callback() then
if self:processModuleCallback(CALLBACK_CREATURE_DISAPPEAR, cid) then
local msg = self:getMessage(MESSAGE_WALKAWAY)
local playerName = Player(cid):getName()
if not playerName then
playerName = -1
end
local parseInfo = { [TAG_PLAYERNAME] = playerName }
local message = self:parseMessage(msg, parseInfo)
local msg_male = self:getMessage(MESSAGE_WALKAWAY_MALE)
local message_male = self:parseMessage(msg_male, parseInfo)
local msg_female = self:getMessage(MESSAGE_WALKAWAY_FEMALE)
local message_female = self:parseMessage(msg_female, parseInfo)
if message_female ~= message_male then
if Player(cid):getSex() == 0 then
selfSay(message_female)
else
selfSay(message_male)
end
elseif message ~= "" then
selfSay(message)
end
self:resetNpc(cid)
self:releaseFocus(cid)
end
end
end
end
-- Returns true if cid is within the talkRadius of this npc.
function NpcHandler:isInRange(cid)
local distance = Player(cid) ~= nil and getDistanceTo(cid) or -1
if distance == -1 then
return false
end
return distance <= self.talkRadius
end
-- Resets the npc into its initial state (in regard of the keywordhandler).
-- All modules are also receiving a reset call through their callbackOnModuleReset function.
function NpcHandler:resetNpc(cid)
if self:processModuleCallback(CALLBACK_MODULE_RESET) then
self.keywordHandler:reset(cid)
end
end
function NpcHandler:cancelNPCTalk(events)
for aux = 1, #events do
stopEvent(events[aux].event)
end
events = nil
end
function NpcHandler:doNPCTalkALot(msgs, interval, pcid)
if self.eventDelayedSay[pcid] then
self:cancelNPCTalk(self.eventDelayedSay[pcid])
end
self.eventDelayedSay[pcid] = {}
local ret = {}
for aux = 1, #msgs do
self.eventDelayedSay[pcid][aux] = {}
doCreatureSayWithDelay(getNpcCid(), msgs[aux], TALKTYPE_PRIVATE_NP, ((aux-1) * (interval or 4000)) + 700, self.eventDelayedSay[pcid][aux], pcid)
ret[#ret +1] = self.eventDelayedSay[pcid][aux]
end
return(ret)
end
-- Makes the npc represented by this instance of NpcHandler say something.
-- This implements the currently set type of talkdelay.
-- shallDelay is a boolean value. If it is false, the message is not delayed. Default value is true.
function NpcHandler:say(message, focus, publicize, shallDelay, delay)
if type(message) == "table" then
return self:doNPCTalkALot(message, delay or 6000, focus)
end
if self.eventDelayedSay[focus] then
self:cancelNPCTalk(self.eventDelayedSay[focus])
end
local shallDelay = not shallDelay and true or shallDelay
if NPCHANDLER_TALKDELAY == TALKDELAY_NONE or shallDelay == false then
selfSay(message, focus, publicize and true or false)
return
end
stopEvent(self.eventSay[focus])
self.eventSay[focus] = addEvent(function(npcId, message, focusId)
local npc = Npc(npcId)
if npc == nil then
return
end
local player = Player(focusId)
if player then
npc:say(message, TALKTYPE_PRIVATE_NP, false, player, npc:getPosition())
end
end, self.talkDelayTime * 1000, Npc():getId(), message, focus)
end
end
| gpl-2.0 |
christopherjwang/rackspace-monitoring-agent | tests/test-net.lua | 4 | 3647 | --[[
Copyright 2015 Rackspace
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--]]
require('tap')(function(test)
local server = require('./server')
local Endpoint = require('virgo/client/endpoint').Endpoint
local ConnectionStream = require('virgo/client/connection_stream').ConnectionStream
local async = require('async')
local constants = require('../constants')
local los = require('los')
local misc = require('virgo/util/misc')
local timer = require('timer')
-----------------------------------------------------------------------------
local TimeoutServer = server.Server:extend()
function TimeoutServer:initialize(options)
server.Server.initialize(self, options)
end
function TimeoutServer:_onLineProtocol(client, line)
-- Timeout All Requests
end
-----------------------------------------------------------------------------
server.opts.destroy_connection_base = 200
server.opts.destroy_connection_jitter = 200
constants:setGlobal('DATACENTER_FIRST_RECONNECT_DELAY', 3000)
constants:setGlobal('DATACENTER_FIRST_RECONNECT_DELAY_JITTER', 0)
constants:setGlobal('DATACENTER_RECONNECT_DELAY', 3000)
constants:setGlobal('DATACENTER_RECONNECT_DELAY_JITTER', 0)
constants:setGlobal('DEFAULT_HANDSHAKE_TIMEOUT', 10000)
-----------------------------------------------------------------------------
test('test handshake timeout', function()
local options = {
datacenter = 'test',
tls = { rejectUnauthorized = false }
}
local client = ConnectionStream:new('id', 'token', 'guid', false, options)
local endpoints = { Endpoint:new('127.0.0.1:4444') }
local AEP = TimeoutServer:new({ includeTimeouts = false })
AEP:listen(4444, '127.0.0.1')
async.series({
function(callback)
client:createConnections(endpoints, callback)
end,
function(callback)
client:once('reconnect', callback)
end
}, function()
AEP:close()
client:shutdown()
end)
end)
test('test reconnects', function()
local options = {
datacenter = 'test',
tls = { rejectUnauthorized = false }
}
local client = ConnectionStream:new('id', 'token', 'guid', false, options)
local clientEnd = 0
local reconnect = 0
client:on('client_end', function(err)
clientEnd = clientEnd + 1
end)
client:on('reconnect', function(err)
reconnect = reconnect + 1
end)
local endpoints = { Endpoint:new('127.0.0.1:4444')}
local AEP = server.Server:new({ includeTimeouts = false })
AEP:listen(4444, '127.0.0.1')
async.series({
function(callback)
client:once('handshake_success', callback)
client:createConnections(endpoints, function() end)
end,
function(callback)
AEP:close()
timer.setImmediate(function()
AEP = server.Server:new({ includeTimeouts = false })
AEP:listen(4444, '127.0.0.1')
end)
client:once('reconnect', callback)
end,
function(callback)
client:once('handshake_success', callback)
end,
}, function()
client:shutdown()
AEP:close()
end)
end)
end)
| apache-2.0 |
mattyx14/otxserver | data/monster/traps/hive_pore.lua | 2 | 1900 | local mType = Game.createMonsterType("Hive Pore")
local monster = {}
monster.description = "a hive pore"
monster.experience = 0
monster.outfit = {
lookTypeEx = 14064
}
monster.health = 1
monster.maxHealth = 1
monster.race = "venom"
monster.corpse = 0
monster.speed = 0
monster.manaCost = 355
monster.changeTarget = {
interval = 4000,
chance = 10
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = false,
canPushCreatures = false,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.summon = {
maxSummons = 3,
summons = {
{name = "Lesser Swarmer", chance = 100, interval = 30000, count = 3}
}
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
}
monster.attacks = {
}
monster.defenses = {
defense = 0,
armor = 0,
{name ="effect", interval = 30000, chance = 100, radius = 3, effect = CONST_ME_HITBYPOISON, target = false}
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 100},
{type = COMBAT_ENERGYDAMAGE, percent = 100},
{type = COMBAT_EARTHDAMAGE, percent = 100},
{type = COMBAT_FIREDAMAGE, percent = 100},
{type = COMBAT_LIFEDRAIN, percent = 100},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 100},
{type = COMBAT_HOLYDAMAGE , percent = 100},
{type = COMBAT_DEATHDAMAGE , percent = 100}
}
monster.immunities = {
{type = "paralyze", condition = true},
{type = "outfit", condition = true},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
CarabusX/Zero-K | LuaUI/Widgets/gui_chili_commander_upgrade.lua | 6 | 30608 | --------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function widget:GetInfo()
return {
name = "Chili Commander Upgrade",
desc = "Interface for commander upgrade selection.",
author = "GoogleFrog",
date = "29 December 2015",
license = "GNU GPL, v2 or later",
handler = true,
layer = -10,
enabled = true
}
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
include("colors.lua")
VFS.Include("LuaRules/Configs/constants.lua")
local Chili
local Button
local Label
local Window
local Panel
local StackPanel
local LayoutPanel
local Image
local screen0
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Most things are local to their own code block. These blocks are (in order)
-- * Replacement Button Handler. This creates and keeps track of buttons
-- which appear in the replacement window.
-- * Replacement Window Handler. This creates and updates the window which holds
-- the replacement buttons.
-- * Current Module Tracker. This does not directly control Chili. This block of
-- code keeps track of the data behind the modules system. This includes a
-- list of current modules and functions for getting the replacementSet and
-- whether a module choice is still valid.
-- * Main Button Handler. This updates the module selection buttons and keeps
-- click functions and restrictions.
-- * Main Window Handler. This handles the main chili window. Will handle
-- acceptance and rejection of the current module setup.
-- * Command Handling. Handles command displaying and issuing to the upgradable
-- units.
-- * Callins. This block handles widget callins. Does barely anything.
-- Module config
local moduleDefs, chassisDefs, upgradeUtilities, LEVEL_BOUND, _, moduleDefNames = VFS.Include("LuaRules/Configs/dynamic_comm_defs.lua")
VFS.Include("LuaRules/Configs/customcmds.h.lua")
-- Configurable things, possible to add to Epic Menu later.
local BUTTON_SIZE = 55
local ROW_COUNT = 6
-- Index of module which is selected for the purposes of replacement.
local activeSlotIndex
-- Whether already owned modules are shown
local alreadyOwnedShown = false
-- StackPanel containing the buttons for the current list of modules
local currentModuleList
-- Button for viewing owned modules
local viewAlreadyOwnedButton
local moduleTextColor = {.8,.8,.8,.9}
local commanderUnitDefID = {}
for i = 1, #UnitDefs do
if UnitDefs[i].customParams.dynamic_comm then
commanderUnitDefID[i] = true
end
end
local UPGRADE_CMD_DESC = {
id = CMD_UPGRADE_UNIT,
type = CMDTYPE.ICON,
tooltip = 'Upgrade Commander',
cursor = 'Repair',
action = 'upgradecomm',
params = {},
texture = 'LuaUI/Images/commands/Bold/upgrade.png',
}
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- New Module Selection Button Handling
local newButtons = {}
local function AddNewSelectonButton(buttonIndex, moduleDefID)
local moduleData = moduleDefs[moduleDefID]
local newButton = Button:New{
caption = "",
width = BUTTON_SIZE,
minHeight = BUTTON_SIZE,
padding = {0, 0, 0, 0},
OnClick = {
function(self)
SelectNewModule(self.moduleDefID)
end
},
backgroundColor = {0.5,0.5,0.5,0.1},
color = {1,1,1,0.1},
tooltip = moduleData.description
}
Image:New{
x = 0,
right = 0,
y = 0,
bottom = 0,
keepAspect = true,
file = moduleData.image,
parent = newButton,
}
newButton.moduleDefID = moduleDefID
newButtons[buttonIndex] = newButton
end
local function UpdateNewSelectionButton(buttonIndex, moduleDefID)
local moduleData = moduleDefs[moduleDefID]
local button = newButtons[buttonIndex]
button.tooltip = moduleData.description
button.moduleDefID = moduleDefID
button.children[1].file = moduleData.image
button.children[1]:Invalidate()
return button
end
local function GetNewSelectionButton(buttonIndex, moduleDefID)
if newButtons[buttonIndex] then
UpdateNewSelectionButton(buttonIndex, moduleDefID)
else
AddNewSelectonButton(buttonIndex, moduleDefID)
end
return newButtons[buttonIndex]
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Selection Window Handling
local selectionWindow
local function CreateModuleSelectionWindow()
local selectionButtonPanel = LayoutPanel:New{
x = 0,
y = 0,
right = 0,
orientation = "vertical",
columns = 7,
--width = "100%",
height = "100%",
backgroundColor = {1,1,1,1},
color = {1,1,1,1},
--children = buttons,
itemPadding = {0,0,0,0},
itemMargin = {0,0,0,0},
resizeItems = false,
centerItems = false,
autosize = true,
}
local fakeSelectionWindow = Panel:New{
x = 0,
width = 20,
y = 0,
height = 20,
padding = {0, 0, 0, 0},
backgroundColor = {1, 1, 1, 0.8},
children = {selectionButtonPanel}
}
local screenWidth,screenHeight = Spring.GetViewGeometry()
local minimapHeight = screenWidth/6 + 45
local selectionWindowMain = Window:New{
name = "ModuleSelectionWindow",
fontsize = 20,
x = 200,
y = minimapHeight,
clientWidth = 500,
clientHeight = 500,
minWidth = 0,
minHeight = 0,
padding = {0, 0, 0, 0},
resizable = false,
draggable = false,
dockable = true,
dockableSavePositionOnly = true,
dockableNoResize = true,
tweakDraggable = true,
tweakResizable = true,
color = {0,0,0,0},
children = {fakeSelectionWindow}
}
return {
window = selectionWindowMain,
fakeWindow = fakeSelectionWindow,
panel = selectionButtonPanel,
windowShown = false,
}
end
local function HideModuleSelection()
if selectionWindow and selectionWindow.windowShown then
selectionWindow.windowShown = false
screen0:RemoveChild(selectionWindow.window)
end
end
local function ShowModuleSelection(moduleSet, supressButton)
if not selectionWindow then
selectionWindow = CreateModuleSelectionWindow()
end
local panel = selectionWindow.panel
local fakeWindow = selectionWindow.fakeWindow
local window = selectionWindow.window
-- The number of modules which need to be displayed.
local moduleCount = #moduleSet
if moduleCount == 0 then
HideModuleSelection()
return
end
-- Update buttons
if moduleCount < #panel.children then
-- Remove buttons if there are too many
for i = #panel.children, moduleCount + 1, -1 do
panel:RemoveChild(panel.children[i])
end
else
-- Add buttons if there are too few
for i = #panel.children + 1, moduleCount do
local button = GetNewSelectionButton(i, moduleSet[i])
panel:AddChild(button)
button.supressButtonReaction = supressButton
end
end
-- Update buttons which were not added or removed.
local forLimit = math.min(moduleCount, #panel.children)
for i = 1, forLimit do
local button = UpdateNewSelectionButton(i, moduleSet[i])
button.supressButtonReaction = supressButton
end
-- Resize window to fit module count
local rows, columns
if moduleCount < 3*ROW_COUNT then
columns = math.min(moduleCount, 3)
rows = math.ceil(moduleCount/3)
else
columns = math.ceil(moduleCount/ROW_COUNT)
rows = math.ceil(moduleCount/columns)
end
-- Column updating works without Invalidate
panel.columns = columns
window:Resize(columns*BUTTON_SIZE + 10, rows*BUTTON_SIZE + 10)
fakeWindow:Resize(columns*BUTTON_SIZE + 10, rows*BUTTON_SIZE + 10)
-- Display window if not already shown
if not selectionWindow.windowShown then
selectionWindow.windowShown = true
screen0:AddChild(window)
end
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Keep track of the current modules and generate restrictions
local alreadyOwnedModules = {}
local alreadyOwnedModulesByDefID = {}
local currentModulesBySlot = {}
local currentModulesByDefID = {}
local function ResetCurrentModules(newAlreadyOwned)
currentModulesBySlot = {}
currentModulesByDefID = {}
alreadyOwnedModules = newAlreadyOwned
alreadyOwnedModulesByDefID = upgradeUtilities.ModuleListToByDefID(newAlreadyOwned)
end
local function GetCurrentModules()
return currentModulesBySlot
end
local function GetAlreadyOwned()
return alreadyOwnedModules
end
local function GetSlotModule(slot, emptyModule)
return currentModulesBySlot[slot] or emptyModule
end
local function UpdateSlotModule(slot, moduleDefID)
if currentModulesBySlot[slot] then
local oldID = currentModulesBySlot[slot]
local count = currentModulesByDefID[oldID]
if count and count > 1 then
currentModulesByDefID[oldID] = count - 1
else
currentModulesByDefID[oldID] = nil
end
end
currentModulesBySlot[slot] = moduleDefID
currentModulesByDefID[moduleDefID] = (currentModulesByDefID[moduleDefID] or 0) + 1
end
local function ModuleIsValid(level, chassis, slotAllows, slotIndex)
local moduleDefID = currentModulesBySlot[slotIndex]
return upgradeUtilities.ModuleIsValid(level, chassis, slotAllows, moduleDefID, alreadyOwnedModulesByDefID, currentModulesByDefID)
end
local function GetNewReplacementSet(level, chassis, slotAllows, ignoreSlot)
local replacementSet = {}
local haveEmpty = false
for i = 1, #moduleDefs do
local data = moduleDefs[i]
if slotAllows[data.slotType] and (data.requireLevel or 0) <= level and
((not data.requireChassis) or data.requireChassis[chassis]) and not data.unequipable then
local accepted = true
-- Check whether required modules are present, not counting ignored slot
if data.requireOneOf then
local foundRequirement = false
for j = 1, #data.requireOneOf do
local req = data.requireOneOf[j]
if (alreadyOwnedModulesByDefID[req] or
(currentModulesByDefID[req] and
(currentModulesBySlot[ignoreSlot] ~= req or
currentModulesByDefID[req] > 1))) then
foundRequirement = true
break
end
end
if not foundRequirement then
accepted = false
end
end
-- Check whether prohibited modules are present, not counting ignored slot
if accepted and data.prohibitingModules then
for j = 1, #data.prohibitingModules do
local prohibit = data.prohibitingModules[j]
if (alreadyOwnedModulesByDefID[prohibit] or
(currentModulesByDefID[prohibit] and
(currentModulesBySlot[ignoreSlot] ~= prohibit or
currentModulesByDefID[prohibit] > 1))) then
accepted = false
break
end
end
end
-- cheapass hack to prevent cremcom dual wielding same weapon (not supported atm)
-- proper solution: make the second instance of a weapon apply projectiles x2 or reloadtime x0.5 and get cremcoms unit script to work with that
local limit = data.limit
if chassis == 5 and data.slotType == "basic_weapon" and limit == 2 then
limit = 1
end
-- Check against module limit, not counting ignored slot
if accepted and limit and (currentModulesByDefID[i] or alreadyOwnedModulesByDefID[i]) then
local count = (currentModulesByDefID[i] or 0) + (alreadyOwnedModulesByDefID[i] or 0)
if currentModulesBySlot[ignoreSlot] == i then
count = count - 1
end
if count >= limit then
accepted = false
end
end
-- Only put one empty module in the accepted set (for the case of slots which allow two or more types)
if accepted and data.emptyModule then
if haveEmpty then
accepted = false
else
haveEmpty = true
end
end
-- Add the module once accepted
if accepted then
replacementSet[#replacementSet + 1] = i
end
end
end
return replacementSet
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Current Module Button Handling
-- Two seperate lists because buttons are stored, module data is not and
-- may change size between invocations of the window.
local currentModuleData = {}
local currentModuleButton = {}
local function ResetCurrentModuleData()
currentModuleData = {}
end
local function ClearActiveButton()
if alreadyOwnedShown then
viewAlreadyOwnedButton.backgroundColor = {0.5,0.5,0.5,0.5}
viewAlreadyOwnedButton:Invalidate()
alreadyOwnedShown = false
end
if activeSlotIndex then
currentModuleButton[activeSlotIndex].backgroundColor = {0.5,0.5,0.5,0.5}
currentModuleButton[activeSlotIndex]:Invalidate()
end
alreadyOwnedShown = false
activeSlotIndex = false
end
local function CurrentModuleClick(self, slotIndex)
if (not activeSlotIndex) or activeSlotIndex ~= slotIndex then
ClearActiveButton()
self.backgroundColor = {0,1,0,1}
activeSlotIndex = slotIndex
ShowModuleSelection(currentModuleData[slotIndex].replacementSet)
else
self.backgroundColor = {0.5,0.5,0.5,0.5}
activeSlotIndex = false
HideModuleSelection()
end
end
local function AlreadyOwnedModuleClick(self)
if not alreadyOwnedShown then
ClearActiveButton()
self.backgroundColor = {0,1,0,1}
alreadyOwnedShown = true
ShowModuleSelection(GetAlreadyOwned(), true)
else
self.backgroundColor = {0.5,0.5,0.5,0.5}
alreadyOwnedShown = false
HideModuleSelection()
end
end
local function AddCurrentModuleButton(slotIndex, moduleDefID)
local moduleData = moduleDefs[moduleDefID]
local newButton = Button:New{
caption = "",
x = 0,
y = 0,
right = 0,
minHeight = BUTTON_SIZE,
height = BUTTON_SIZE,
padding = {0, 0, 0, 0},
backgroundColor = {0.5,0.5,0.5,0.5},
OnClick = {
function(self)
CurrentModuleClick(self, slotIndex)
end
},
tooltip = moduleData.description
}
Image:New{
x = 0,
y = 0,
bottom = 0,
keepAspect = true,
file = moduleData.image,
parent = newButton,
}
local textBox = Chili.TextBox:New{
x = 64,
y = 10,
right = 8,
bottom = 8,
valign = "left",
text = moduleData.humanName,
font = {size = 16, outline = true, color = moduleTextColor, outlineWidth = 2, outlineWeight = 2},
parent = newButton,
}
currentModuleButton[slotIndex] = newButton
end
-- This type of module replacement updates the button as well.
-- UpdateSlotModule only updates module tracking. This function
-- does not update replacementSet.
local function ModuleReplacmentWithButton(slotIndex, moduleDefID)
local moduleData = moduleDefs[moduleDefID]
local button = currentModuleButton[slotIndex]
button.tooltip = moduleData.description
button.children[1].file = moduleData.image
button.children[1]:Invalidate()
button.children[2]:SetText(moduleData.humanName)
UpdateSlotModule(slotIndex, moduleDefID)
end
local function GetCurrentModuleButton(moduleDefID, slotIndex, level, chassis, slotAllows, empty)
if not currentModuleButton[slotIndex] then
AddCurrentModuleButton(slotIndex, moduleDefID)
end
currentModuleData[slotIndex] = currentModuleData[slotIndex] or {}
local current = currentModuleData[slotIndex]
current.level = level
current.chassis = chassis
current.slotAllows = slotAllows
current.empty = empty
current.replacementSet = GetNewReplacementSet(level, chassis, slotAllows, slotIndex)
ModuleReplacmentWithButton(slotIndex, moduleDefID)
return currentModuleButton[slotIndex]
end
function SelectNewModule(moduleDefID)
if (not activeSlotIndex) or alreadyOwnedShown then
return
end
ModuleReplacmentWithButton(activeSlotIndex, moduleDefID)
-- Check whether module choices are still valid
local requireUpdate = true
local newCost = 0
for repeatBreak = 1, 2 * #currentModuleData do
newCost = 0
requireUpdate = false
for i = 1, #currentModuleData do
local data = currentModuleData[i]
if ModuleIsValid(data.level, data.chassis, data.slotAllows, i) then
newCost = newCost + moduleDefs[GetSlotModule(i, data.empty)].cost
else
requireUpdate = true
ModuleReplacmentWithButton(i, data.empty)
end
end
if not requireUpdate then
break
end
end
UpdateMorphCost(newCost)
-- Update each replacement set
for i = 1, #currentModuleData do
local data = currentModuleData[i]
data.replacementSet = GetNewReplacementSet(data.level, data.chassis, data.slotAllows, i)
end
ShowModuleSelection(currentModuleData[activeSlotIndex].replacementSet)
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Main Module Window Handling
local mainWindowShown = false
local mainWindow, timeLabel, costLabel, morphBuildPower
function UpdateMorphCost(newCost)
newCost = (newCost or 0) + morphBaseCost
costLabel:SetCaption(math.floor(newCost))
timeLabel:SetCaption(math.floor(newCost/morphBuildPower))
end
local function HideMainWindow()
if mainWindowShown then
SaveModuleLoadout()
screen0:RemoveChild(mainWindow)
mainWindowShown = false
end
HideModuleSelection()
end
local function CreateMainWindow()
local screenWidth, screenHeight = Spring.GetViewGeometry()
local minimapHeight = screenWidth/6 + 45
local mainHeight = math.min(420, math.max(325, screenHeight - 450))
mainWindow = Window:New{
classname = "main_window_small_tall",
name = "CommanderUpgradeWindow",
fontsize = 20,
x = 0,
y = minimapHeight,
width = 201,
height = 332,
minWidth = 201,
minHeight = 332,
resizable = false,
draggable = false,
dockable = true,
dockableSavePositionOnly = true,
tweakDraggable = true,
tweakResizable = true,
parent = screen0,
}
mainWindowShown = true
-- The rest of the window is organized top to bottom
local topLabel = Chili.Label:New{
x = 0,
right = 0,
y = 0,
height = 35,
valign = "center",
align = "center",
caption = "Modules",
autosize = false,
font = {size = 20, outline = true, color = {.8,.8,.8,.9}, outlineWidth = 2, outlineWeight = 2},
parent = mainWindow,
}
currentModuleList = StackPanel:New{
x = 3,
right = 2,
y = 36,
bottom = 0,
padding = {0, 0, 0, 0},
itemPadding = {2,2,2,2},
itemMargin = {0,0,0,0},
backgroundColor = {1, 1, 1, 0.8},
resizeItems = false,
centerItems = false,
parent = mainWindow,
}
local cyan = {0,1,1,1}
local timeImage = Image:New{
x = 15,
bottom = 75,
file ='LuaUI/images/clock.png',
height = 24,
width = 24,
keepAspect = true,
parent = mainWindow,
}
timeLabel = Chili.Label:New{
x = 42,
right = 0,
bottom = 80,
valign = "top",
align = "left",
caption = 0,
autosize = false,
font = {size = 24, outline = true, color = cyan, outlineWidth = 2, outlineWeight = 2},
parent = mainWindow,
}
local costImage = Image:New{
x = 92,
bottom = 75,
file ='LuaUI/images/costIcon.png',
height = 24,
width = 24,
keepAspect = true,
parent = mainWindow,
}
costLabel = Chili.Label:New{
x = 118,
right = 0,
bottom = 80,
valign = "top",
align = "left",
caption = 0,
autosize = false,
font = {size = 24, outline = true, color = cyan, outlineWidth = 2, outlineWeight = 2},
parent = mainWindow,
}
local acceptButton = Button:New{
caption = "",
x = 4,
bottom = 5,
width = 55,
height = 55,
padding = {0, 0, 0, 0},
backgroundColor = {0.5,0.5,0.5,0.5},
tooltip = "Start upgrade",
OnClick = {
function()
if mainWindowShown then
SendUpgradeCommand(GetCurrentModules())
end
end
},
parent = mainWindow,
}
viewAlreadyOwnedButton = Button:New{
caption = "",
x = 63,
bottom = 5,
width = 55,
height = 55,
padding = {0, 0, 0, 0},
backgroundColor = {0.5,0.5,0.5,0.5},
tooltip = "View current modules",
OnClick = {
function(self)
AlreadyOwnedModuleClick(self)
end
},
parent = mainWindow,
}
local cancelButton = Button:New{
caption = "",
x = 121,
bottom = 5,
width = 55,
height = 55,
padding = {0, 0, 0, 0},
backgroundColor = {0.5,0.5,0.5,0.5},
tooltip = "Cancel module selection",
OnClick = {
function()
--Spring.Echo("Upgrade UI Debug - Cancel Clicked")
HideMainWindow()
end
},
parent = mainWindow,
}
Image:New{
x = 2,
right = 2,
y = 0,
bottom = 0,
keepAspect = true,
file = "LuaUI/Images/dynamic_comm_menu/tick.png",
parent = acceptButton,
}
Image:New{
x = 2,
right = 2,
y = 0,
bottom = 0,
keepAspect = true,
file = "LuaUI/Images/dynamic_comm_menu/eye.png",
parent = viewAlreadyOwnedButton,
}
Image:New{
x = 2,
right = 2,
y = 0,
bottom = 0,
keepAspect = true,
file = "LuaUI/Images/commands/Bold/cancel.png",
parent = cancelButton,
}
end
local function ShowModuleListWindow(unitID, slotDefaults, level, chassis, alreadyOwnedModules)
if not currentModuleList then
CreateMainWindow()
end
if level > chassisDefs[chassis].maxNormalLevel then
morphBaseCost = chassisDefs[chassis].extraLevelCostFunction(level)
level = chassisDefs[chassis].maxNormalLevel
morphBuildPower = chassisDefs[chassis].levelDefs[level].morphBuildPower
else
morphBaseCost = chassisDefs[chassis].levelDefs[level].morphBaseCost
morphBuildPower = chassisDefs[chassis].levelDefs[level].morphBuildPower
end
if Spring.ValidUnitID(unitID) then
morphBuildPower = morphBuildPower * (Spring.GetGameRulesParam("econ_mult_" .. (Spring.GetUnitAllyTeam(unitID) or "")) or 1)
end
local slots = chassisDefs[chassis].levelDefs[level].upgradeSlots
if not mainWindowShown then
screen0:AddChild(mainWindow)
mainWindowShown = true
end
-- Removes all previous children
for i = #currentModuleList.children, 1, -1 do
currentModuleList:RemoveChild(currentModuleList.children[i])
end
ClearActiveButton()
HideModuleSelection()
ResetCurrentModuleData()
ResetCurrentModules(alreadyOwnedModules)
-- Data is added here to generate reasonable replacementSets in actual adding.
for i = 1, #slots do
local slotData = slots[i]
UpdateSlotModule(i, (slotDefaults and slotDefaults[i]) or slotData.defaultModule)
end
-- Check that the module in each slot is valid
local requireUpdate = true
local newCost = 0
for repeatBreak = 1, 2 * #slots do
requireUpdate = false
newCost = 0
for i = 1, #slots do
local slotData = slots[i]
if ModuleIsValid(level, chassis, slotData.slotAllows, i) then
newCost = newCost + moduleDefs[GetSlotModule(i, slotData.empty)].cost
else
requireUpdate = true
UpdateSlotModule(i, slotData.empty)
end
end
if not requireUpdate then
break
end
end
UpdateMorphCost(newCost)
-- Actually add the default modules and slot data
for i = 1, #slots do
local slotData = slots[i]
currentModuleList:AddChild(GetCurrentModuleButton(GetSlotModule(i, slotData.empty), i, level, chassis, slotData.slotAllows, slotData.empty))
end
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Command Handling
local upgradeSignature = {}
local savedSlotLoadout = {}
function SendUpgradeCommand(newModules)
-- Find selected eligible units
local units = Spring.GetSelectedUnits()
local upgradableUnits = {}
for i = 1, #units do
local unitID = units[i]
local level = Spring.GetUnitRulesParam(unitID, "comm_level")
local chassis = Spring.GetUnitRulesParam(unitID, "comm_chassis")
if level == upgradeSignature.level and chassis == upgradeSignature.chassis then
local alreadyOwned = {}
local moduleCount = Spring.GetUnitRulesParam(unitID, "comm_module_count")
for i = 1, moduleCount do
local module = Spring.GetUnitRulesParam(unitID, "comm_module_" .. i)
alreadyOwned[#alreadyOwned + 1] = module
end
table.sort(alreadyOwned)
if upgradeUtilities.ModuleSetsAreIdentical(alreadyOwned, upgradeSignature.alreadyOwned) then
upgradableUnits[#upgradableUnits + 1] = unitID
end
end
end
-- Create upgrade command params and issue it to units.
if #upgradableUnits > 0 then
local params = {}
params[1] = upgradeSignature.level
params[2] = upgradeSignature.chassis
params[3] = #upgradeSignature.alreadyOwned
params[4] = #newModules
local index = 5
for j = 1, #upgradeSignature.alreadyOwned do
params[index] = upgradeSignature.alreadyOwned[j]
index = index + 1
end
for j = 1, #newModules do
params[index] = newModules[j]
index = index + 1
end
Spring.GiveOrderToUnitArray(upgradableUnits, CMD_MORPH_UPGRADE_INTERNAL, params, 0)
end
-- Remove main window
--Spring.Echo("Upgrade UI Debug - Upgrade Command Sent")
HideMainWindow()
end
function SaveModuleLoadout()
local currentModules = GetCurrentModules()
if not (upgradeSignature and currentModules) then
return
end
local profileID = upgradeSignature.profileID
local level = upgradeSignature.level
if not (profileID and level) then
return
end
savedSlotLoadout[profileID] = savedSlotLoadout[profileID] or {}
savedSlotLoadout[profileID][level] = GetCurrentModules()
end
local function CreateModuleListWindowFromUnit(unitID)
local level = Spring.GetUnitRulesParam(unitID, "comm_level")
local chassis = Spring.GetUnitRulesParam(unitID, "comm_chassis")
local profileID = Spring.GetUnitRulesParam(unitID, "comm_profileID")
if not (chassisDefs[chassis] and chassisDefs[chassis].levelDefs[math.min(chassisDefs[chassis].maxNormalLevel, level+1)]) then
return
end
-- Find the modules which are already owned
local alreadyOwned = {}
local moduleCount = Spring.GetUnitRulesParam(unitID, "comm_module_count")
for i = 1, moduleCount do
local module = Spring.GetUnitRulesParam(unitID, "comm_module_" .. i)
alreadyOwned[#alreadyOwned + 1] = module
end
table.sort(alreadyOwned)
-- Record the signature of the morphing unit for later application.
upgradeSignature.level = level
upgradeSignature.chassis = chassis
upgradeSignature.profileID = profileID
upgradeSignature.alreadyOwned = alreadyOwned
-- Load default loadout
local slotDefaults = {}
if profileID and level then
if savedSlotLoadout[profileID] and savedSlotLoadout[profileID][level] then
slotDefaults = savedSlotLoadout[profileID][level]
else
local commProfileInfo = WG.ModularCommAPI.GetCommProfileInfo(profileID)
if commProfileInfo and commProfileInfo.modules and commProfileInfo.modules[level + 1] then
local defData = commProfileInfo.modules[level + 1]
for i = 1, #defData do
slotDefaults[i] = moduleDefNames[defData[i]]
end
end
end
end
-- Create the window
ShowModuleListWindow(unitID, slotDefaults, level + 1, chassis, alreadyOwned)
end
local function GetCommanderUpgradeAttributes(unitID, cullMorphing)
local unitDefID = Spring.GetUnitDefID(unitID)
if not commanderUnitDefID[unitDefID] then
return false
end
if cullMorphing and Spring.GetUnitRulesParam(unitID, "morphing") == 1 then
return false
end
local level = Spring.GetUnitRulesParam(unitID, "comm_level")
if not level then
return false
end
local chassis = Spring.GetUnitRulesParam(unitID, "comm_chassis")
local staticLevel = Spring.GetUnitRulesParam(unitID, "comm_staticLevel")
return level, chassis, staticLevel
end
function widget:CommandNotify(cmdID, cmdParams, cmdOptions)
if cmdID ~= CMD_UPGRADE_UNIT then
return false
end
local units = Spring.GetSelectedUnits()
local upgradeID = false
for i = 1, #units do
local unitID = units[i]
local level, chassis, staticLevel = GetCommanderUpgradeAttributes(unitID, true)
if level and (not staticLevel) and chassis and (not LEVEL_BOUND or level < LEVEL_BOUND) then
upgradeID = unitID
break
end
end
if not upgradeID then
return true
end
CreateModuleListWindowFromUnit(upgradeID)
return true
end
local cachedSelectedUnits
function widget:SelectionChanged(selectedUnits)
cachedSelectedUnits = selectedUnits
end
function widget:CommandsChanged()
local units = cachedSelectedUnits or Spring.GetSelectedUnits()
if mainWindowShown then
--Spring.Echo("Upgrade UI Debug - Number of units selected", #units)
local foundMatchingComm = false
for i = 1, #units do
local unitID = units[i]
local level, chassis, staticLevel = GetCommanderUpgradeAttributes(unitID)
if level and (not staticLevel) and level == upgradeSignature.level and chassis == upgradeSignature.chassis then
local alreadyOwned = {}
local moduleCount = Spring.GetUnitRulesParam(unitID, "comm_module_count")
for i = 1, moduleCount do
local module = Spring.GetUnitRulesParam(unitID, "comm_module_" .. i)
alreadyOwned[#alreadyOwned + 1] = module
end
table.sort(alreadyOwned)
if upgradeUtilities.ModuleSetsAreIdentical(alreadyOwned, upgradeSignature.alreadyOwned) then
foundMatchingComm = true
break
end
end
end
if foundMatchingComm then
local customCommands = widgetHandler.customCommands
customCommands[#customCommands+1] = UPGRADE_CMD_DESC
else
----Spring.Echo("Upgrade UI Debug - Commander Deselected")
HideMainWindow() -- Hide window if no commander matching the window is selected
end
end
if not mainWindowShown then
local foundRulesParams = false
for i = 1, #units do
local unitID = units[i]
local level, chassis, staticLevel = GetCommanderUpgradeAttributes(unitID, true)
if level and (not staticLevel) and chassis and (not LEVEL_BOUND or level < LEVEL_BOUND) then
foundRulesParams = true
break
end
end
if foundRulesParams then
local customCommands = widgetHandler.customCommands
customCommands[#customCommands+1] = {
id = CMD_UPGRADE_UNIT,
type = CMDTYPE.ICON,
tooltip = 'Upgrade Commander',
cursor = 'Repair',
action = 'upgradecomm',
params = {},
texture = 'LuaUI/Images/commands/Bold/upgrade.png',
}
end
end
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Callins
function widget:Initialize()
-- setup Chili
Chili = WG.Chili
Button = Chili.Button
Label = Chili.Label
Window = Chili.Window
Panel = Chili.Panel
StackPanel = Chili.StackPanel
LayoutPanel = Chili.LayoutPanel
Image = Chili.Image
Progressbar = Chili.Progressbar
screen0 = Chili.Screen0
if (not Chili) then
widgetHandler:RemoveWidget()
return
end
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
| gpl-2.0 |
daniel-slaney/quadrology | game/src/mode.lua | 1 | 1134 | --
-- lib/mode.lua
--
-- A mode is a high-level state of the game that has love callbacks as events.
--
--[[
usage:
local schema, mode1, mode2, .., modeN = require 'lib/mode' { 'mode1', 'mode2', ..., 'modeN' }
local state = require 'lib/state'
local schema, MainMode = require 'lib/mode' { 'MainMode' }
local machine = state.machine(schema, MainMode, ...)
--]]
local state = require 'src/state'
local schema = state.schema {
draw = true,
focus = true,
keypressed = true,
keyreleased = true,
mousepressed = true,
mousereleased = true,
update = true,
textinput = true,
joystickpressed = true,
joystickreleased = true,
joystickaxis = true,
joystickhat = true,
gamepadpressed = true,
gamepadreleased = true,
gamepadaxis = true,
joystickadded = true,
joystickremoved = true,
mousefocus = true,
visible = true,
}
local modes = {}
local function export( names )
local result = {}
for i, name in ipairs(names) do
local mode = modes[name]
if not mode then
mode = state.state(schema, name)
modes[name] = mode
end
result[#result+1] = mode
end
return schema, unpack(result)
end
return export
| bsd-2-clause |
haswne/IRAQ_BOT | tg/test.lua | 210 | 2571 | started = 0
our_id = 0
function vardump(value, depth, key)
local linePrefix = ""
local spaces = ""
if key ~= nil then
linePrefix = "["..key.."] = "
end
if depth == nil then
depth = 0
else
depth = depth + 1
for i=1, depth do spaces = spaces .. " " end
end
if type(value) == 'table' then
mTable = getmetatable(value)
if mTable == nil then
print(spaces ..linePrefix.."(table) ")
else
print(spaces .."(metatable) ")
value = mTable
end
for tableKey, tableValue in pairs(value) do
vardump(tableValue, depth, tableKey)
end
elseif type(value) == 'function' or
type(value) == 'thread' or
type(value) == 'userdata' or
value == nil
then
print(spaces..tostring(value))
else
print(spaces..linePrefix.."("..type(value)..") "..tostring(value))
end
end
print ("HI, this is lua script")
function ok_cb(extra, success, result)
end
-- Notification code {{{
function get_title (P, Q)
if (Q.type == 'user') then
return P.first_name .. " " .. P.last_name
elseif (Q.type == 'chat') then
return Q.title
elseif (Q.type == 'encr_chat') then
return 'Secret chat with ' .. P.first_name .. ' ' .. P.last_name
else
return ''
end
end
local lgi = require ('lgi')
local notify = lgi.require('Notify')
notify.init ("Telegram updates")
local icon = os.getenv("HOME") .. "/.telegram-cli/telegram-pics/telegram_64.png"
function do_notify (user, msg)
local n = notify.Notification.new(user, msg, icon)
n:show ()
end
-- }}}
function on_msg_receive (msg)
if started == 0 then
return
end
if msg.out then
return
end
do_notify (get_title (msg.from, msg.to), msg.text)
if (msg.text == 'ping') then
if (msg.to.id == our_id) then
send_msg (msg.from.print_name, 'pong', ok_cb, false)
else
send_msg (msg.to.print_name, 'pong', ok_cb, false)
end
return
end
if (msg.text == 'PING') then
if (msg.to.id == our_id) then
fwd_msg (msg.from.print_name, msg.id, ok_cb, false)
else
fwd_msg (msg.to.print_name, msg.id, ok_cb, false)
end
return
end
end
function on_our_id (id)
our_id = id
end
function on_user_update (user, what)
--vardump (user)
end
function on_chat_update (chat, what)
--vardump (chat)
end
function on_secret_chat_update (schat, what)
--vardump (schat)
end
function on_get_difference_end ()
end
function cron()
-- do something
postpone (cron, false, 1.0)
end
function on_binlog_replay_end ()
started = 1
postpone (cron, false, 1.0)
end
| gpl-2.0 |
zain211/zain.aliraqex | tg/test.lua | 210 | 2571 | started = 0
our_id = 0
function vardump(value, depth, key)
local linePrefix = ""
local spaces = ""
if key ~= nil then
linePrefix = "["..key.."] = "
end
if depth == nil then
depth = 0
else
depth = depth + 1
for i=1, depth do spaces = spaces .. " " end
end
if type(value) == 'table' then
mTable = getmetatable(value)
if mTable == nil then
print(spaces ..linePrefix.."(table) ")
else
print(spaces .."(metatable) ")
value = mTable
end
for tableKey, tableValue in pairs(value) do
vardump(tableValue, depth, tableKey)
end
elseif type(value) == 'function' or
type(value) == 'thread' or
type(value) == 'userdata' or
value == nil
then
print(spaces..tostring(value))
else
print(spaces..linePrefix.."("..type(value)..") "..tostring(value))
end
end
print ("HI, this is lua script")
function ok_cb(extra, success, result)
end
-- Notification code {{{
function get_title (P, Q)
if (Q.type == 'user') then
return P.first_name .. " " .. P.last_name
elseif (Q.type == 'chat') then
return Q.title
elseif (Q.type == 'encr_chat') then
return 'Secret chat with ' .. P.first_name .. ' ' .. P.last_name
else
return ''
end
end
local lgi = require ('lgi')
local notify = lgi.require('Notify')
notify.init ("Telegram updates")
local icon = os.getenv("HOME") .. "/.telegram-cli/telegram-pics/telegram_64.png"
function do_notify (user, msg)
local n = notify.Notification.new(user, msg, icon)
n:show ()
end
-- }}}
function on_msg_receive (msg)
if started == 0 then
return
end
if msg.out then
return
end
do_notify (get_title (msg.from, msg.to), msg.text)
if (msg.text == 'ping') then
if (msg.to.id == our_id) then
send_msg (msg.from.print_name, 'pong', ok_cb, false)
else
send_msg (msg.to.print_name, 'pong', ok_cb, false)
end
return
end
if (msg.text == 'PING') then
if (msg.to.id == our_id) then
fwd_msg (msg.from.print_name, msg.id, ok_cb, false)
else
fwd_msg (msg.to.print_name, msg.id, ok_cb, false)
end
return
end
end
function on_our_id (id)
our_id = id
end
function on_user_update (user, what)
--vardump (user)
end
function on_chat_update (chat, what)
--vardump (chat)
end
function on_secret_chat_update (schat, what)
--vardump (schat)
end
function on_get_difference_end ()
end
function cron()
-- do something
postpone (cron, false, 1.0)
end
function on_binlog_replay_end ()
started = 1
postpone (cron, false, 1.0)
end
| gpl-2.0 |
tgp1994/LiquidRP-tgp1994 | gamemode/fadmin/fadmin/playeractions/kickban/sh_shared.lua | 3 | 1288 | function FAdmin.PlayerActions.ConvertBanTime(time)
local Add = ""
time = math.Round(time)
if time <= 0 then return "permanent"
elseif time < 60 then -- minutes
return math.ceil(time) .. " minute(s)"
elseif time >= 60 and time < 1440 then -- hours
if math.floor((time/60 - math.floor(time/60))*60) > 0 then
Add = ", "..FAdmin.PlayerActions.ConvertBanTime((time/60 - math.floor(time/60))*60)
end
return math.floor(time/60).. " hour(s)".. Add
elseif time >= 1440 and time < 10080 then -- days
if math.floor((time/1440 - math.floor(time/1440))*1440) > 0 then
Add = ", "..FAdmin.PlayerActions.ConvertBanTime((time/1440 - math.floor(time/1440))*1440)
end
return math.floor(time/1440).. " day(s)".. Add
elseif time >= 10080 and time < 525948 then -- weeks
if math.floor((time/10080 - math.floor(time/10080))*10080) > 0 then
Add = ", "..FAdmin.PlayerActions.ConvertBanTime((time/10080 - math.floor(time/10080))*10080)
end
return math.floor(time/10080).. " week(s)".. Add
elseif time >= 525948 then -- years
if math.floor((time/525948 - math.floor(time/525948))*525948) > 0 then
Add = ", "..FAdmin.PlayerActions.ConvertBanTime((time/525948 - math.floor(time/525948))*525948)
end
return math.floor(time/525948).. " year(s)".. Add
end
return time
end | gpl-3.0 |
abgoyal/nodemcu-firmware | tools/cross-lua.lua | 19 | 1145 | local args = { ... }
local b = require "tools.build"
local builder = b.new_builder( ".build/cross-lua" )
local utils = b.utils
local sf = string.format
builder:init( args )
builder:set_build_mode( builder.BUILD_DIR_LINEARIZED )
local output = 'luac.cross'
local cdefs = '-DLUA_CROSS_COMPILER -O2'
-- Lua source files and include path
local lua_files = [[
lapi.c lauxlib.c lbaselib.c lcode.c ldblib.c ldebug.c ldo.c ldump.c
lfunc.c lgc.c llex.c lmathlib.c lmem.c loadlib.c lobject.c lopcodes.c
lparser.c lrotable.c lstate.c lstring.c lstrlib.c ltable.c ltablib.c
ltm.c lundump.c lvm.c lzio.c
luac_cross/luac.c luac_cross/loslib.c luac_cross/print.c
../modules/linit.c
]]
lua_files = lua_files:gsub( "\n" , "" )
local lua_full_files = utils.prepend_path( lua_files, "app/lua" )
local local_include = "-Iapp/include -Iinclude -Iapp/lua"
-- Compiler/linker options
builder:set_compile_cmd( sf( "gcc -O2 %s -Wall %s -c $(FIRST) -o $(TARGET)", local_include, cdefs ) )
builder:set_link_cmd( "gcc -o $(TARGET) $(DEPENDS) -lm" )
-- Build everything
builder:make_exe_target( output, lua_full_files )
builder:build()
| mit |
TideSofDarK/DotaCraft | game/dota_addons/dotacraft/scripts/vscripts/units/human/peasant.lua | 1 | 3525 | -- NOTE: There should be a separate Call To Arms ability on each peasant but it's
-- currently not possible because there's not enough ability slots visible
CALL_THINK_INTERVAL = 0.1
function CallToArms( event )
local caster = event.caster
local hero = caster:GetOwner()
local ability = event.ability
local player = caster:GetPlayerOwner()
local units = FindAlliesInRadius(caster, 3000) --Radius of the bell ring
for _,unit in pairs(units) do
if IsValidEntity(unit) and unit:GetUnitName() == "human_peasant" then
local building_pos = caster:GetAbsOrigin()
local collision_size = caster:GetHullRadius()*2 + 64
unit.target_building = caster
if unit.moving_timer then
Timers:RemoveTimer(unit.moving_timer)
end
ability:ApplyDataDrivenModifier(unit, unit, "modifier_on_order_cancel_call_to_arms", {})
-- Start moving towards the city center
unit.moving_timer = Timers:CreateTimer(function()
if not IsValidAlive(unit) then
return
elseif not IsValidAlive(unit.target_building) then
unit.target_building = FindClosestResourceDeposit( unit, "gold" )
return 1/30
elseif unit:HasModifier("modifier_on_order_cancel_call_to_arms") then
local distance = (building_pos - unit:GetAbsOrigin()):Length()
local collision = distance <= collision_size
if not collision then
unit:MoveToPosition(building_pos)
return CALL_THINK_INTERVAL
else
local militia = ReplaceUnit(unit, "human_militia")
ability:ApplyDataDrivenModifier(militia, militia, "modifier_militia", {})
-- Add the units to a table so they are easier to find later
if not player.militia then
player.militia = {}
end
table.insert(player.militia, militia)
table.insert(player.units, militia)
end
end
end)
end
end
end
function CancelCallToArms( event )
local caster = event.caster --Peasant or militia
local ability = event.ability
if caster.moving_timer then
Timers:RemoveTimer(caster.moving_timer)
end
caster.state = "idle"
end
function BackToWork( event )
local unit = event.caster -- The militia unit
local ability = event.ability
local player = unit:GetPlayerOwner()
local building = FindClosestResourceDeposit( unit, "gold" )
local building_pos = building :GetAbsOrigin()
local collision_size = building :GetHullRadius()*2 + 64
unit.target_building = building
if unit.moving_timer then
Timers:RemoveTimer(unit.moving_timer)
end
-- Start moving towards the city center
unit.moving_timer = Timers:CreateTimer(function()
ability:ApplyDataDrivenModifier(unit, unit, "modifier_on_order_back_to_work", {})
if not IsValidAlive(unit) then
return
elseif not IsValidAlive(unit.target_building) then
unit.target_building = FindClosestResourceDeposit( unit, "gold" )
return 1/30
elseif unit:HasModifier("modifier_on_order_back_to_work") then
local distance = (building_pos - unit:GetAbsOrigin()):Length()
local collision = distance <= collision_size
if not collision then
unit:MoveToPosition(building_pos)
return CALL_THINK_INTERVAL
else
local peasant = ReplaceUnit(unit, "human_peasant")
CheckAbilityRequirements(peasant, player)
table.insert(player.units, peasant)
end
end
end)
end
function CallToArmsEnd( event )
local target = event.target
local player = target:GetPlayerOwner()
local peasant = ReplaceUnit( event.target, "human_peasant" )
CheckAbilityRequirements(peasant, player)
table.insert(player.units, peasant)
end | gpl-3.0 |
dinodeck/rpg_conversation_graph | nwn_dialog_advanced/map/map_town.lua | 1 | 154919 | function CreateTownMap(state)
local id = "town"
local townState = state.maps[id]
local OnTalk = function(map, trigger, entity, x, y, layer)
local dialogDef =
{
speakerX = x,
speakerY = y,
graphDef = conversation_5
}
local dialogState = DialogState:Create(dialogDef)
gStack:Push(dialogState)
-- We haven't create this state yet but here's the code to push it
-- on the stack
print("Yo")
--local dialogState = DialogState:Create()
--gStack:Push(dialogState)
end
return {
id = id,
name = "Town",
can_save = true,
version = "1.1",
luaversion = "5.1",
orientation = "orthogonal",
width = 60,
height = 120,
tilewidth = 16,
tileheight = 16,
properties = {},
on_wake =
{
{
id = "AddNPC",
params = {{ def = "npc_major", id ="major", x = 5, y = 4 }}
},
},
actions =
{
talk_action =
{
id = "RunScript",
params = { OnTalk }
},
},
trigger_types =
{
talk = { OnUse = "talk_action" },
},
triggers =
{
-- tile pos 5, 4 is where the NPC is standing
{ trigger = "talk", x = 5, y = 4 },
},
tilesets = {
{
name = "town_tileset",
firstgid = 1,
tilewidth = 16,
tileheight = 16,
spacing = 0,
margin = 0,
image = "town_tileset.png",
imagewidth = 176,
imageheight = 240,
properties = {},
tiles = {}
},
{
name = "collision_graphic",
firstgid = 166,
tilewidth = 16,
tileheight = 16,
spacing = 0,
margin = 0,
image = "collision_graphic.png",
imagewidth = 32,
imageheight = 32,
properties = {},
tiles = {}
}
},
layers = {
{
type = "tilelayer",
name = "0-background",
x = 0,
y = 0,
width = 60,
height = 120,
visible = true,
opacity = 1,
properties = {},
encoding = "lua",
data = {
81, 3, 4, 5, 3, 4, 5, 3, 7, 4, 5, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 1, 2, 3, 4, 5, 6, 11, 81,
81, 12, 15, 16, 14, 15, 16, 14, 18, 15, 22, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 12, 13, 14, 15, 16, 17, 22, 81,
81, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81,
81, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81,
81, 72, 93, 83, 83, 83, 83, 83, 83, 93, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81,
81, 72, 83, 83, 83, 83, 83, 83, 83, 83, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81,
81, 72, 83, 83, 83, 83, 83, 83, 83, 83, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81,
81, 72, 83, 72, 72, 72, 72, 72, 72, 83, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81,
81, 72, 83, 72, 72, 72, 72, 72, 72, 83, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81,
81, 72, 83, 72, 72, 72, 72, 72, 72, 83, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 72, 83, 72, 72, 72, 72, 72, 72, 83, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 72, 93, 72, 72, 72, 72, 93, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 72, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 72, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 1, 2, 3, 4, 5, 6, 11, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 12, 13, 14, 15, 16, 17, 22, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 147, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 1, 7, 7, 4, 6, 7, 11, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 12, 18, 18, 16, 17, 18, 22, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 1, 2, 3, 4, 5, 6, 11, 81,
81, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 12, 13, 14, 15, 16, 17, 22, 81,
81, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 147, 81,
81, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81,
81, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81,
81, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81,
81, 72, 72, 72, 72, 72, 72, 72, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 72, 72, 72, 72, 72, 72, 72, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
144, 144, 144, 144, 144, 145, 145, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 144, 144, 144, 144, 144,
144, 144, 144, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 144, 144, 144, 144, 144, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 144, 144, 145, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 145, 145, 145, 144, 144, 144, 144, 144,
144, 144, 144, 144, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 145, 145, 145, 144, 145, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144,
144, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 144, 144, 144, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 144, 144, 144, 144, 145, 144, 144, 145, 145, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144,
144, 144, 144, 144, 145, 145, 145, 145, 145, 144, 144, 144, 145, 145, 145, 145, 144, 144, 144, 144, 145, 145, 145, 145, 145, 144, 144, 144, 144, 144, 145, 145, 145, 145, 145, 145, 145, 145, 144, 145, 145, 145, 145, 145, 145, 145, 144, 144, 145, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144,
144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144,
144, 144, 144, 144, 144, 144, 145, 145, 145, 145, 145, 145, 145, 145, 144, 145, 144, 144, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 144, 144, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
144, 144, 144, 144, 145, 145, 145, 145, 145, 145, 145, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 144, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
144, 144, 145, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
144, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 144, 144, 144, 144, 144, 144, 144, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 145, 144, 144, 145, 145, 144, 144, 144, 144,
144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 83, 144, 144, 72, 144, 72, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 145, 145, 144, 144, 145, 144,
144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 72, 72, 72, 72, 83, 83, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 145, 144, 145, 145, 145, 145, 144,
144, 144, 144, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 83, 83, 83, 144, 83, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 145, 144, 145, 144, 145, 145, 144, 144, 144,
145, 144, 144, 144, 145, 145, 145, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 83, 144, 144, 144, 144, 144, 140, 140, 140, 140, 144, 144, 144, 145, 145, 145, 144, 144, 144, 144, 144, 145, 144, 145, 144, 145, 145, 144, 144, 144,
145, 144, 144, 144, 144, 145, 145, 145, 144, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 142, 138, 136, 142, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 145, 145, 145, 145, 145, 144, 144, 144, 144,
145, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 142, 138, 139, 142, 144, 144, 145, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144,
145, 145, 145, 145, 145, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 144, 144, 144, 140, 140, 140, 140, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
145, 145, 144, 144, 144, 144, 144, 144, 145, 145, 144, 144, 144, 144, 144, 144, 145, 145, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 145, 145, 145, 145, 145, 144, 144, 144, 144, 140, 140, 144, 144, 144, 145, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
144, 145, 144, 145, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 145, 145, 145, 145, 144, 144, 144, 144, 144, 144, 145, 145, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 140, 140, 144, 145, 144, 145, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 145, 145, 144, 144, 145, 144, 144, 144, 144, 144, 145, 145, 138, 133, 137, 139, 144, 145, 144, 144, 144, 144, 140, 140, 145, 145, 145, 145, 144, 145, 145, 140, 140, 140, 140, 140, 140, 140, 140, 145, 145, 144, 144, 144, 144,
144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 144, 144, 144, 144, 144, 144, 144, 145, 145, 138, 135, 133, 139, 144, 145, 144, 144, 144, 144, 140, 140, 144, 145, 144, 144, 144, 144, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 144, 145, 144, 144, 144,
144, 145, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 144, 144, 144, 144, 142, 144, 144, 144, 144, 144,
144, 145, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 138, 133, 133, 137, 140, 137, 133, 139, 142, 144, 145, 144, 144, 144,
144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 144, 144, 140, 140, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 142, 138, 133, 133, 133, 133, 133, 135, 139, 142, 144, 145, 145, 145, 144,
144, 144, 145, 145, 144, 144, 144, 144, 144, 144, 144, 145, 140, 140, 140, 140, 140, 140, 145, 144, 144, 144, 140, 140, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 144, 144, 144, 140, 141, 141, 141, 141, 140, 140, 141, 141, 140, 140, 144, 145, 144, 144,
144, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 144, 144, 144, 144, 140, 140, 145, 144, 144, 140, 140, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 142, 145, 144, 144, 73, 140, 140, 83, 83, 144, 144, 144, 145, 144, 144,
144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 142, 144, 144, 144, 144, 144, 144, 140, 140, 140, 140, 140, 140, 144, 144, 144, 145, 145, 145, 144, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 142, 145, 145, 144, 144, 140, 140, 83, 144, 144, 144, 145, 144, 144, 144,
144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 142, 144, 144, 144, 144, 144, 144, 140, 140, 140, 140, 140, 140, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 141, 141, 141, 141, 140, 140, 144, 144, 83, 144, 144, 144, 144, 144,
144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 141, 141, 140, 140, 141, 141, 140, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 145, 144, 144, 140, 140, 145, 144, 144, 144, 144, 144, 144, 144,
144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 140, 140, 145, 145, 145, 145, 145, 144, 144, 144, 144, 144, 140, 141, 141, 141, 141, 141, 141, 141, 141, 140, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 145, 145, 144, 144, 140, 140, 145, 145, 144, 144, 144, 144, 144, 144,
144, 145, 145, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 145, 140, 140, 145, 144, 144, 145, 145, 144, 144, 144, 144, 144, 140, 157, 157, 157, 157, 157, 157, 157, 157, 140, 144, 145, 145, 145, 144, 144, 144, 145, 145, 144, 144, 144, 145, 144, 140, 140, 140, 140, 140, 144, 144, 144, 144, 145,
144, 144, 145, 145, 144, 144, 144, 144, 144, 145, 145, 144, 144, 144, 140, 140, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 140, 148, 148, 148, 148, 148, 148, 148, 148, 140, 144, 144, 145, 145, 144, 144, 144, 145, 145, 144, 144, 144, 144, 144, 140, 140, 140, 140, 140, 144, 144, 144, 145, 145,
144, 144, 144, 145, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 140, 140, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 142, 138, 137, 133, 133, 133, 133, 137, 139, 142, 145, 144, 144, 145, 145, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 144, 145, 145, 145, 145,
144, 144, 144, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 144, 144, 145, 145, 144, 144, 144, 144, 144, 144, 142, 138, 133, 133, 135, 135, 133, 133, 139, 142, 145, 145, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 144, 144, 144, 144, 145,
144, 144, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 141, 141, 141, 140, 140, 140, 141, 141, 140, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 144, 144, 144, 144, 144,
144, 144, 145, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 140, 140, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 141, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 138, 139, 144, 144, 144, 144, 144, 140, 140, 144, 144, 144, 144, 144,
145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 138, 139, 144, 144, 144, 144, 144, 140, 140, 144, 144, 144, 144, 144,
144, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 144, 144, 144, 144, 145, 144, 144, 144, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 144, 144, 144, 144, 144,
145, 145, 145, 145, 144, 144, 144, 144, 144, 83, 144, 144, 144, 144, 140, 140, 144, 144, 145, 145, 145, 145, 144, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 144, 144, 144, 144, 144,
145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 83, 140, 140, 145, 145, 145, 144, 144, 144, 144, 140, 140, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 140, 140, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 144, 144, 144, 144, 144,
145, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 83, 83, 83, 140, 140, 145, 145, 145, 144, 144, 144, 144, 140, 140, 145, 145, 145, 145, 145, 144, 145, 144, 145, 145, 145, 140, 140, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 140, 73, 144, 144, 144, 144,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 145, 145, 145, 145, 145, 145, 144, 145, 145, 145, 145, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 145, 145, 145, 145, 145, 144, 144, 145, 145, 145, 145, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
144, 145, 145, 144, 144, 144, 144, 144, 144, 144, 83, 144, 144, 145, 145, 145, 142, 144, 144, 144, 144, 144, 144, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 144, 144, 144, 144, 144, 144, 144, 142, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144,
144, 144, 145, 145, 145, 144, 144, 144, 144, 144, 144, 83, 144, 144, 144, 144, 142, 145, 144, 145, 144, 144, 144, 144, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 145, 144, 144, 144, 144, 144, 144, 144, 142, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144,
144, 144, 144, 144, 144, 144, 144, 144, 144, 83, 144, 144, 144, 144, 144, 144, 142, 145, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 142, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 144, 144,
144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 142, 144, 145, 145, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 142, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 144, 144, 144,
144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 142, 144, 145, 144, 144, 144, 145, 144, 145, 144, 144, 144, 145, 145, 145, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 142, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
144, 144, 144, 144, 145, 144, 144, 144, 145, 144, 145, 144, 144, 144, 144, 144, 142, 144, 144, 144, 144, 144, 145, 144, 144, 145, 140, 140, 148, 148, 133, 133, 148, 148, 140, 140, 144, 144, 144, 144, 144, 144, 144, 144, 145, 142, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
144, 144, 145, 145, 145, 144, 144, 144, 144, 72, 72, 144, 144, 144, 144, 144, 142, 144, 144, 144, 144, 144, 144, 145, 144, 144, 140, 140, 133, 133, 136, 133, 136, 133, 140, 140, 144, 144, 144, 144, 144, 144, 144, 144, 144, 142, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
144, 144, 144, 145, 144, 144, 144, 144, 144, 72, 72, 145, 144, 144, 144, 144, 142, 144, 144, 144, 144, 144, 145, 145, 145, 145, 140, 140, 133, 135, 133, 133, 133, 133, 140, 140, 144, 144, 144, 144, 144, 144, 144, 144, 144, 142, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 140, 141, 141, 141, 141, 141, 141, 141, 141, 141, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 141, 141, 141, 141, 141, 141, 141, 141, 141, 140, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 144, 144, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 144, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 145, 144, 144, 145, 144, 144, 144, 144, 144,
144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 144, 144, 144, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 144, 144, 145, 145, 145, 144, 144, 144, 144, 144, 144,
144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 145, 145, 144, 144, 144, 145, 145, 145, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 145, 145, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145, 145, 144, 144, 145, 144, 144, 145, 145, 145, 144, 144, 144
}
},
{
type = "tilelayer",
name = "1-detail",
x = 0,
y = 0,
width = 60,
height = 120,
visible = true,
opacity = 1,
properties = {},
encoding = "lua",
data = {
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 81, 81, 81, 0, 0, 0, 0, 0, 0, 0,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152,
152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152,
152, 152, 152, 152, 152, 152, 0, 0, 0, 0, 0, 0, 152, 152, 152, 0, 0, 0, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 151, 151, 0, 0, 0, 0, 0, 152, 152, 152, 152, 152, 0, 0, 152, 152, 152, 152, 152, 152,
152, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152, 152, 0, 0, 152, 152, 152,
152, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, 151, 0, 0, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 0, 152, 0, 0, 0, 152, 152, 152,
152, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 0, 0, 0, 0, 0, 152, 0, 0, 151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 151, 0, 0, 0, 0, 151, 151, 0, 0, 0, 0, 152, 0, 0, 0, 152, 152, 152,
152, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 151, 0, 0, 0, 0, 0, 0, 152, 0, 0, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 151, 0, 0, 0, 152, 0, 0, 152, 0, 152, 152, 152,
152, 0, 0, 151, 151, 151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 151, 0, 151, 151, 0, 0, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 0, 0, 152, 152, 152, 152, 152, 0, 0, 152, 152,
152, 0, 0, 151, 151, 151, 151, 151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 152, 0, 0, 151, 151, 151, 0, 0, 0, 151, 152, 152, 151, 151, 151, 0, 0, 151, 151, 151, 151, 151, 151, 151, 151, 0, 0, 0, 0, 151, 151, 151, 0, 152, 0, 0, 0, 151, 0, 0, 152, 152,
152, 0, 151, 151, 151, 151, 151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 152, 152, 152, 151, 152, 152, 152, 152, 152, 152, 152, 0, 0, 0, 0, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 151, 0, 0, 151, 151, 0, 0, 0, 0, 151, 151, 0, 0, 152, 152,
152, 151, 151, 151, 151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152, 152, 145, 0, 152, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 151, 0, 0, 0, 151, 151, 0, 0, 0, 152, 152,
152, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 151, 151, 151, 152, 152, 0, 145, 145, 145, 0, 152, 72, 0, 0, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 0, 152, 152,
152, 0, 151, 151, 151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 151, 151, 152, 152, 152, 152, 0, 0, 0, 0, 72, 72, 0, 0, 73, 73, 73, 0, 72, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152,
152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 0, 152, 0, 0, 152, 0, 72, 0, 72, 93, 0, 0, 73, 0, 0, 0, 93, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 152, 152,
152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 72, 0, 0, 0, 0, 0, 0, 73, 145, 72, 0, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 0, 0, 151, 0, 0, 0, 0, 151, 151, 151, 152, 152,
152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, 145, 0, 93, 73, 0, 0, 152, 152, 152, 0, 0, 152, 0, 0, 0, 0, 0, 0, 0, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 152, 152,
151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 0, 0, 73, 145, 0, 0, 0, 73, 152, 152, 152, 0, 0, 0, 0, 152, 152, 0, 0, 0, 0, 151, 151, 151, 151, 0, 0, 0, 151, 151, 151, 151, 0, 152, 152,
151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 73, 0, 73, 0, 0, 0, 0, 0, 152, 0, 0, 0, 0, 0, 152, 0, 0, 0, 151, 151, 151, 151, 151, 151, 151, 0, 0, 0, 151, 151, 0, 0, 0, 152,
0, 151, 151, 151, 151, 151, 151, 151, 0, 0, 0, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 151, 0, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0,
0, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, 0, 152, 0, 93, 0, 0, 0, 151, 151, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, 0,
151, 151, 0, 0, 0, 0, 0, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 152, 0, 0, 0, 93, 152, 0, 151, 0, 0, 0, 0, 0, 152, 152, 152, 0, 0, 0, 0, 0,
151, 151, 0, 0, 0, 0, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, 0, 152, 152, 152, 146, 0, 146, 152, 152, 152, 152, 0, 0, 0, 0, 0, 0,
151, 151, 151, 0, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 146, 0, 0, 0, 0, 0, 0, 151, 151, 151, 151, 0, 0, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 151, 151, 0, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 146, 0, 0, 0, 0,
151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 146, 151, 151, 0, 0,
151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 0, 0, 151, 151, 151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 146, 0, 0, 0, 0, 0, 0, 0, 151, 0, 151, 151, 0,
151, 151, 151, 151, 0, 151, 0, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151,
151, 151, 151, 151, 0, 0, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152, 0, 0, 0, 0, 93, 0, 0, 0, 0, 146,
151, 151, 152, 152, 152, 151, 151, 0, 0, 0, 0, 0, 0, 0, 138, 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 0, 0, 0, 0, 0, 149, 152, 0, 0, 0, 0, 0, 0, 0, 0, 146, 146,
152, 152, 152, 151, 151, 151, 0, 0, 0, 0, 0, 0, 138, 139, 135, 139, 138, 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 151, 0, 152, 0, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 146, 146,
152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152, 151, 151, 151, 0, 0, 152, 152, 0, 151, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 146,
152, 152, 151, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 151, 151, 151, 151, 0, 0, 152, 152, 152, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152,
0, 152, 152, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 151, 151, 151, 0, 0, 0, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152, 152,
152, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 0, 0, 0, 0, 0, 138, 133, 133, 133, 133, 133, 133, 139, 0, 0, 151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152,
152, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 152, 0, 0, 0, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 151, 151, 151, 0, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152,
152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152, 152, 0, 0, 0, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 151, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152,
0, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 0, 0, 0, 141, 0, 0, 0, 0, 0, 151, 152, 0, 151, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 152,
152, 152, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 130, 0, 0, 130, 0, 0, 0, 0, 152, 0, 0, 0, 0, 151, 0, 0, 141, 141, 141, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152,
0, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, 0, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 146, 0, 0, 152, 0, 0, 145, 145, 145, 0, 146, 0, 0, 141, 73, 0, 0, 0, 0, 0, 0, 0, 152, 152, 152,
152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 146, 0, 0, 0, 0, 0, 0, 145, 0, 145, 141, 145, 145, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152,
152, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152,
152, 152, 0, 0, 0, 0, 0, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 0, 0, 0, 0, 0, 72, 0, 0, 0, 0, 152, 0, 0, 152,
152, 152, 152, 152, 0, 0, 0, 152, 152, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 93, 72, 0, 0, 0, 0,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0, 0, 0, 0, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 151, 0, 0, 152,
151, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 151, 151, 151, 0, 0, 0, 0, 0, 0, 145, 0, 0, 0, 151, 0, 151, 151, 151, 0,
152, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152, 151, 0, 151, 152, 0, 145, 0, 0, 0, 0, 0, 0, 151, 0, 0, 0, 0, 151, 151,
152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 0, 0, 0, 0, 0, 145, 0, 152, 0, 0, 0, 0, 152,
152, 0, 0, 0, 0, 0, 0, 0, 0, 72, 72, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 0, 0, 0, 0, 152, 0, 0, 145, 0, 0, 145, 145, 145, 145, 151, 145, 0, 0, 0, 0, 152,
152, 0, 0, 0, 0, 0, 0, 0, 72, 72, 72, 0, 152, 0, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152, 0, 0, 0, 0, 152, 0, 0, 0, 145, 0, 145, 0, 145, 0, 145, 151, 0, 0, 152, 0, 0, 152,
152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 130, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 152, 0, 0, 0, 152, 151, 0, 0, 152, 0, 0, 0, 152,
152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 151, 152, 0, 0, 0, 0, 151, 0, 0, 152, 152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 152, 0, 0, 0, 0, 0, 0, 0, 152, 152, 152, 0, 0, 0, 0, 0, 152, 0, 0, 152,
151, 151, 0, 151, 0, 0, 152, 0, 0, 152, 152, 151, 151, 151, 151, 151, 151, 0, 0, 0, 0, 151, 151, 152, 152, 0, 0, 0, 151, 152, 152, 152, 0, 0, 0, 0, 0, 0, 152, 152, 152, 152, 0, 0, 0, 0, 0, 152, 152, 152, 152, 151, 0, 0, 152, 0, 0, 0, 152, 152,
0, 0, 151, 152, 152, 152, 152, 152, 152, 152, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 152, 152, 152, 152, 152, 152, 152, 152
}
},
{
type = "tilelayer",
name = "2-collision",
x = 0,
y = 0,
width = 60,
height = 120,
visible = true,
opacity = 0.52,
properties = {},
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,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166,
166, 166, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 166, 166, 166, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166,
166, 166, 166, 0, 0, 0, 0, 0,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166,
166, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166,
166, 166, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 0, 0, 166, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166,
166, 166, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 166, 166, 166, 166, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166,
166, 0, 166, 166, 166, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166,
166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 166, 0, 0, 166, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166,
166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166,
166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 166, 0, 0, 0, 166, 166, 166, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 166, 166, 166, 166, 0, 0, 0, 166, 166, 166,
166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 166, 166, 166, 166, 166, 0, 0, 166, 166, 166, 166, 0, 166, 166,
166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 166, 166, 0, 166, 0, 0, 0, 166, 166, 166, 166, 166, 166, 166, 0, 0, 0, 166, 166, 0, 0, 0, 166,
166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 166, 0, 166, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0,
166, 166, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 166, 0, 166, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0,
166, 166, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 166, 0, 0, 0, 166, 166, 0, 166, 0, 0, 0, 0, 0, 166, 166, 166, 0, 0, 0, 0, 0,
166, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 166, 166, 166, 166, 0, 166, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0,
166, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
166, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 166, 166, 0, 0, 166, 166, 166, 166, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
166, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0,
166, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 166, 166, 166, 166, 166, 0, 166, 166, 166, 0, 0,
166, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 166, 166, 166, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 166, 166, 166, 0, 166, 0, 166, 0, 166, 166, 0,
166, 0, 0, 0, 0, 166, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166,
0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 166, 0, 0, 0, 0, 166,
166, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166,
166, 166, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 166, 166, 0, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 0, 166, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166,
0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 166, 0, 166, 0, 166, 166, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166,
166, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 166, 0, 0, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166,
166, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 166, 166, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166,
166, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 166, 166, 166, 166, 166, 0, 0, 166, 166, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166,
166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 166, 0, 0, 0, 166, 0, 0, 166, 166, 166, 166, 166, 166, 166, 166, 0, 0, 0, 166, 0, 0, 166, 166, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166,
166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 0, 0, 0, 166, 0, 0, 166, 166, 166, 0, 0, 166, 166, 166, 0, 0, 0, 166, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166,
166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 166,
166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 166, 0, 0, 166, 0, 0, 0, 0, 166, 0, 0, 0, 0, 166, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166,
166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 166, 0, 0, 0, 0, 0, 0, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166,
166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166,
166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166,
166, 166, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 166, 166, 166,
166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 166, 166, 166, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 166, 0, 0, 166,
166, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 166, 166, 166, 166,
166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 166, 166,
166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 166,
166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 166, 166, 166, 166, 166, 166, 0, 0, 166, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 166,
166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 166, 166, 166, 166, 0, 0, 166, 166, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 166, 0, 0, 166,
166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 166, 166, 0, 0, 166, 0, 0, 0, 166,
166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 0, 0, 0, 0, 166, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 166, 0, 0, 0, 0, 0, 0, 0, 166, 166, 166, 0, 0, 0, 0, 0, 166, 0, 0, 166,
166, 166, 0, 166, 0, 0, 166, 0, 0, 166, 166, 166, 166, 166, 166, 166, 166, 0, 0, 0, 0, 166, 166, 166, 166, 0, 0, 0, 166, 166, 166, 166, 0, 0, 0, 0, 0, 0, 166, 166, 166, 166, 0, 0, 0, 0, 0, 166, 166, 166, 166, 166, 0, 0, 166, 0, 0, 0, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 0, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166
}
},
{
type = "tilelayer",
name = "3-background",
x = 0,
y = 0,
width = 60,
height = 120,
visible = true,
opacity = 1,
properties = {},
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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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 0, 0, 0, 0, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 150, 150, 150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 150, 0, 0, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 150, 150, 150, 150, 150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 0, 0, 0, 150, 0, 0, 150, 150, 150, 0, 0, 150, 150, 150, 150, 150, 150, 150, 150, 0, 0, 0, 0, 150, 150, 150, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0,
0, 0, 150, 150, 150, 150, 150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 0, 0, 150, 150, 0, 0, 0, 0, 150, 150, 0, 0, 0, 0,
0, 0, 150, 150, 150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 150, 0, 0, 0, 150, 150, 0, 0, 0, 0, 0,
0, 0, 150, 150, 150, 150, 150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 150, 150, 150, 0, 0, 0, 0, 0, 0, 71, 0, 0, 0, 0, 0, 0, 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0,
0, 0, 150, 150, 150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 0, 71, 0, 0, 71, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 0, 0, 150, 0, 0, 0, 0, 150, 150, 150, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 0, 0, 82, 0, 0, 0, 0, 0, 0, 155, 164, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 0, 0,
150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 159, 160, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 150, 150, 0, 0, 150, 150, 150, 150, 0, 0, 0,
150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 136, 139, 0, 0, 0, 0, 0, 150, 150, 150, 150, 150, 150, 150, 0, 0, 0, 150, 150, 0, 0, 0, 0,
0, 150, 150, 150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0,
0, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 0, 0, 0, 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, 0, 0, 0, 0,
150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 158, 159, 160, 161, 158, 159, 160, 161, 0, 0, 150, 150, 0, 0,
150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 150, 150, 150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 136, 0, 0, 133, 0, 0, 0, 0, 150, 0, 150, 150, 0,
150, 150, 150, 150, 0, 150, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 71, 0, 0, 0, 0, 150,
150, 150, 150, 150, 0, 0, 150, 150, 0, 0, 0, 0, 0, 155, 156, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 0, 0, 0, 0, 0,
150, 150, 150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 158, 159, 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 150, 150, 150, 0, 0, 0, 0, 0, 0, 158, 161, 0, 0, 158, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 150, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 150, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 0, 0, 155, 156, 163, 164, 155, 156, 163, 164, 0, 0, 150, 150, 150, 150, 150, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 158, 159, 160, 161, 158, 159, 160, 161, 0, 0, 150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 150, 0, 0, 148, 148, 148, 148, 148, 148, 148, 148, 0, 0, 0, 150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 158, 159, 0, 0, 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
150, 150, 0, 150, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 150, 150, 150, 0, 0, 0, 0, 150, 150, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 150, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}
}
}
}
end
| mit |
mattyx14/otxserver | data/monster/vermins/parasite.lua | 2 | 1898 | local mType = Game.createMonsterType("Parasite")
local monster = {}
monster.description = "a parasite"
monster.experience = 0
monster.outfit = {
lookType = 82,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.health = 550
monster.maxHealth = 550
monster.race = "venom"
monster.corpse = 6023
monster.speed = 175
monster.manaCost = 0
monster.changeTarget = {
interval = 5000,
chance = 0
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = true,
rewardBoss = false,
illusionable = true,
canPushItems = false,
canPushCreatures = false,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = true,
canWalkOnPoison = true
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -100, condition = {type = CONDITION_POISON, totalDamage = 40, interval = 4000}}
}
monster.defenses = {
defense = 15,
armor = 15
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 100},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = -20},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = true},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
zain211/zain.aliraqex | plugins/en-ASD_KARBALA1.lua | 2 | 4364 | --[[
▀▄ ▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀
▀▄ ▄▀ ▀▄ ▄▀
▀▄ ▄▀ BY SAJJAD NOORI ▀▄ ▄▀
▀▄ ▄▀ BY SAJAD NOORI (@SAJJADNOORI) ▀▄ ▄▀
▀▄ ▄▀ JUST WRITED BY SAJJAD NOORI ▀▄ ▄▀
▀▄ ▄▀ help1 : مساعدة ▀▄ ▄▀
▀▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀
--]]
do
local function run(msg, matches)
if is_momod(msg) and matches[1]== "help1" then
return [[ ❣ setadmin : لرفع اداري للمجموعه
❣ demoteadmin : لتنزيل اداري من المجموعه
❣ promote : لرفع او تصعيد ادمن
❣ demote : لتنزيل او حذف الادمن
❣ owner : لعرض المدير
❣ modlist : لاظهار ادمنية المجموعة
❣ admins : اضهار اداريين المجموعه
🔸➖🔹➖🔸➖🔹➖🔸
✔️ Commands for control membee
❣ kick : لطرد العضو
❣ ban : لحظر العظر
❣ unban : فتح الخظر عن العضو
❣ kickme : للخروج من المجموعة
❣ silent : لتفعيل الصمت على احد الاعضاء
❣ clean mutelist: الغاء الصمت على العضو
❣ block : لحضر الكلمة
❣ words : لعرض الكلمات المحظورة
❣ unblock : لفتح حضر الكلمة
❣ me : لمعرفه موقعك في المجموعة
🔸➖🔹➖🔸➖🔹➖🔸
✔️ Commands for control
❣ rules : لاضهار القوانين
❣ setrules : لاظافة القوانين
❣ setphoto : لوضع صورة
❣ setname : لوضع اسم
❣ setusername : لوضع معرف للكروب
❣ setabout : لاظافة الوصف
❣ id : لاظهار الايدي
❣ settings : اضهار اعدادات المجموعة
❣ info : اضهار المعلومات الخاصه بك
❣ info group : اضهار معلومات المجموعة
❣ settings modes : اضهار اعادادات الوسائط
❣ newlink : لصنع الرابط او تغيرة
❣ link : لضهور رابط المجموعه
❣ setlink : لوضع رابط للمجموعه
❣ linksl : للحصول على الرابط في الخاص
🔸➖🔹➖🔸➖🔹➖🔸
✔️ Commands for Security
❣ lock all : لقفل المجموعه باكملها
❣ unlock all : لفتح المجموعه باكملها
❣ lock member : لقفل اضافة المجموعة
❣ unlock member : للفتح اضافة المجموعة
❣ lock text : لقفل دردشة المجموعة
❣ unlock text : فتح الدردشه
❣ lock photo : لمنع إرسال الصور
❣ unlock photo : للسماح بإرسال الصور
❣ lock audio : لمنع البصمات
❣ unlock audio : للسماح بإرسال البصمات
❣ lock video : لمنع ارسال فديو
❣ unlock video : للسماح بإرسال فديو
❣ lock links : لمنع الروابط
❣ unlock links : للسماح بإرسال روابط
❣ lock flood : لمنع التكرار
❣ unlock flood : للسماح بلتكرار
❣ lock sticker : لمنع الملصقات
❣ unlock sticker : للسماح بلملصقات
❣ lock gifs : لمنع الصور المتحركة
❣ unlock gifs : للسماح بالصور المتحركة
❣ lock documents : لمنع ارسال الملفات
❣ unlock documents : للسماح بإرسال الملفات
❣ lock spam : لمنع الكلايش الطويلة
❣ unlock spam : للسماح بلكلايش الطويلة
❣ lock rtl : لمنع اطافة جماعة
❣ unlock rtl : للسماح بإضافة جماعة
❣ lock arabic : لمنع اللغة ألعربيه
❣ unlock arabic : للسماح بلغه ألعربيه
❣ lock fwd : لمنع اعاديت توجيه
❣ unlock fwd : للسماح باعادت توجيه
🔸➖🔹➖🔸➖🔹➖🔸
Version :1.0
#Dev : @AILXXZ
#Dev_bot : @zainty
#Dev_Channel : @zaintyh
]]
end
if not is_momod(msg) then
return "Only admins 😎🖕🏿"
end
end
return {
description = "Help list",
usage = "Help list",
patterns = {
"(help1)"
},
run = run
}
end
| gpl-2.0 |
mattyx14/otxserver | data/monster/vermins/rotworm.lua | 2 | 2727 | local mType = Game.createMonsterType("Rotworm")
local monster = {}
monster.description = "a rotworm"
monster.experience = 40
monster.outfit = {
lookType = 26,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.raceId = 26
monster.Bestiary = {
class = "Vermin",
race = BESTY_RACE_VERMIN,
toKill = 500,
FirstUnlock = 25,
SecondUnlock = 250,
CharmsPoints = 15,
Stars = 2,
Occurrence = 0,
Locations = "Almost everywhere, like Ancient Temple, Vandura, Folda dungeon, Fibula Dungeon, \z
caves connecting Edron and Cormaya, Venore Swamp Troll cave, Thais Troll cave, Ferngrims Gate, \z
Dwarf Mines, Hellgate, below the graves in eastern Rookgaard, spider cave in western Rookgaard, \z
cave northeast of Ab'Dendriel, Darashia Rotworm Caves, Liberty Bay, Fenrock, \z
below Green Claw Swamp and some other places."
}
monster.health = 65
monster.maxHealth = 65
monster.race = "blood"
monster.corpse = 5967
monster.speed = 116
monster.manaCost = 305
monster.changeTarget = {
interval = 4000,
chance = 0
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = true,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = false,
canPushCreatures = false,
staticAttackChance = 70,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
{name = "gold coin", chance = 71760, maxCount = 17},
{id = 3264, chance = 3000}, -- sword
{name = "mace", chance = 4500},
{name = "meat", chance = 20000},
{name = "ham", chance = 20120},
{name = "worm", chance = 3000, maxCount = 3},
{name = "lump of dirt", chance = 10000}
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -40}
}
monster.defenses = {
defense = 10,
armor = 10
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 0},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = false},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
mattyx14/otxserver | data/monster/mammals/stone_rhino.lua | 2 | 2514 | local mType = Game.createMonsterType("Stone Rhino")
local monster = {}
monster.description = "a Stone Rhino"
monster.experience = 1800
monster.outfit = {
lookType = 936,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.raceId = 1395
monster.Bestiary = {
class = "Mammal",
race = BESTY_RACE_MAMMAL,
toKill = 1000,
FirstUnlock = 50,
SecondUnlock = 500,
CharmsPoints = 25,
Stars = 3,
Occurrence = 1,
Locations = "Area before final boss of Forgotten Knowledge Quest."
}
monster.health = 3000
monster.maxHealth = 3000
monster.race = "blood"
monster.corpse = 25082
monster.speed = 290
monster.manaCost = 290
monster.changeTarget = {
interval = 5000,
chance = 0
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = false,
canPushCreatures = false,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 15,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "SNIFF!", yell = false}
}
monster.loot = {
{id = 5925, chance = 50320}, -- hardened bone
{id = 24388, chance = 50320}, -- rhino hide
{id = 24389, chance = 50320}, -- rhino horn
{id = 22186, chance = 50320} -- raw meat
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -280}
}
monster.defenses = {
defense = 10,
armor = 10,
{name ="combat", interval = 2000, chance = 15, type = COMBAT_HEALING, minDamage = 0, maxDamage = 250, effect = CONST_ME_MAGIC_BLUE, target = false}
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 10},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 20},
{type = COMBAT_FIREDAMAGE, percent = 10},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 10},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
mattyx14/otxserver | data/monster/quests/svargrond_arena/greenhorn/achad.lua | 2 | 1968 | local mType = Game.createMonsterType("Achad")
local monster = {}
monster.description = "Achad"
monster.experience = 70
monster.outfit = {
lookType = 146,
lookHead = 95,
lookBody = 93,
lookLegs = 38,
lookFeet = 59,
lookAddons = 3,
lookMount = 0
}
monster.health = 185
monster.maxHealth = 185
monster.race = "blood"
monster.corpse = 7349
monster.speed = 185
monster.manaCost = 0
monster.changeTarget = {
interval = 0,
chance = 0
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = false,
staticAttackChance = 95,
targetDistance = 1,
runHealth = 55,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "You won't pass me.", yell = false},
{text = "I have travelled far to fight here.", yell = false}
}
monster.loot = {
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -80}
}
monster.defenses = {
defense = 19,
armor = 20
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 10},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = true},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
kbara/snabb | src/apps/lwaftr/channel.lua | 2 | 7120 | -- Channels
--
-- A channel is a way for different threads or processes to communicate.
-- Channels are backed by a ring buffer that is mapped into shared
-- memory. Access to a channel will never block or cause a system call.
-- Readers and writers have to agree ahead of time on how to interpret
-- the messages that are written to a channel.
module(..., package.seeall)
local ffi = require('ffi')
local S = require("syscall")
local lib = require('core.lib')
root = "/var/run/snabb"
local ring_buffer_t = ffi.typeof([[struct {
uint32_t read;
uint32_t write;
uint32_t size;
uint32_t flags;
uint8_t buf[?];
}]])
-- Make directories needed for a named object.
-- Given the name "foo/bar/baz" create /var/run/foo and /var/run/foo/bar.
local function mkdir_p (name)
-- Create root with mode "rwxrwxrwt" (R/W for all and sticky) if it
-- does not exist yet.
if not S.stat(root) then
local mask = S.umask(0)
local status, err = S.mkdir(root, "01777")
assert(status, ("Unable to create %s: %s"):format(
root, tostring(err or "unspecified error")))
S.umask(mask)
end
-- Create sub directories
local dir = root
name:gsub("([^/]+)",
function (x) S.mkdir(dir, "rwxu") dir = dir.."/"..x end)
end
local function create_ring_buffer (name, size)
local tail = tostring(S.getpid())..'/channels/'..name
local path = root..'/'..tail
mkdir_p(tail)
local fd, err = S.open(path, "creat, rdwr, excl", '0664')
if not fd then
err = tostring(err or "unknown error")
error('error creating file "'..path..'": '..err)
end
local len = ffi.sizeof(ring_buffer_t, size)
assert(fd:ftruncate(len), "ring buffer: ftruncate failed")
local mem, err = S.mmap(nil, len, "read, write", "shared", fd, 0)
fd:close()
if mem == nil then error("mmap failed: " .. tostring(err)) end
mem = ffi.cast(ffi.typeof("$*", ring_buffer_t), mem)
ffi.gc(mem, function (ptr) S.munmap(ptr, len) end)
mem.size = size
return mem
end
local function open_ring_buffer (pid, name)
local path = root..'/'..tostring(pid)..'/channels/'..name
local fd, err = S.open(path, "rdwr")
if not fd then
err = tostring(err or "unknown error")
error('error opening file "'..path..'": '..err)
end
local stat = S.fstat(fd)
local len = stat and stat.size
if len < ffi.sizeof(ring_buffer_t, 0) then
error("unexpected size for ring buffer")
end
local mem, err = S.mmap(nil, len, "read, write", "shared", fd, 0)
fd:close()
if mem == nil then error("mmap failed: " .. tostring(err)) end
mem = ffi.cast(ffi.typeof("$*", ring_buffer_t), mem)
ffi.gc(mem, function (ptr) S.munmap(ptr, len) end)
if len ~= ffi.sizeof(ring_buffer_t, mem.size) then
error("unexpected ring buffer size: "..tostring(len))
end
return mem
end
local function to_uint32 (num)
local buf = ffi.new('uint32_t[1]')
buf[0] = num
return buf[0]
end
local function read_avail (ring)
lib.compiler_barrier()
return to_uint32(ring.write - ring.read)
end
local function write_avail (ring)
return ring.size - read_avail(ring)
end
-- The coordination needed between the reader and the writer is that:
--
-- 1. If the reader sees a a bumped write pointer, that the data written
-- to the ring buffer will be available to the reader, i.e. the writer
-- has done whatever is needed to synchronize the data.
--
-- 2. It should be possible for the reader to update the read pointer
-- without stompling other memory, notably the write pointer.
--
-- 3. It should be possible for the writer to update the write pointer
-- without stompling other memory, notably the read pointer.
--
-- 4. Updating a write pointer or a read pointer should eventually be
-- visible to the reader or writer, respectively.
--
-- The full memory barrier after updates to the read or write pointer
-- ensures (1). The x86 memory model, and the memory model of C11,
-- guarantee (2) and (3). For (4), the memory barrier on the writer
-- side ensures that updates to the read or write pointers are
-- eventually visible to other CPUs, but we also have to insert a
-- compiler barrier before reading them to prevent LuaJIT from caching
-- their value somewhere else, like in a register. See
-- https://www.kernel.org/doc/Documentation/memory-barriers.txt for more
-- discussion on memory models, and
-- http://www.freelists.org/post/luajit/Compiler-loadstore-barrier-volatile-pointer-barriers-in-general,3
-- for more on compiler barriers in LuaJIT.
--
-- If there are multiple readers or writers, they should serialize their
-- accesses through some other mechanism.
--
local function put_bytes (ring, bytes, count)
local new_write_avail = write_avail(ring) - count
if new_write_avail < 0 then return new_write_avail end
local start = ring.write % ring.size
if start + count > ring.size then
local head = ring.size - start
ffi.copy(ring.buf + start, bytes, head)
ffi.copy(ring.buf, bytes + head, count - head)
else
ffi.copy(ring.buf + start, bytes, count)
end
ring.write = ring.write + count
ffi.C.full_memory_barrier()
return new_write_avail
end
local function get_bytes (ring, count, buf)
if read_avail(ring) < count then return nil end
buf = buf or ffi.new('uint8_t[?]', count)
local start = ring.read % ring.size
if start + count > ring.size then
ffi.copy(buf, ring.buf + start, ring.size - start)
ffi.copy(buf, ring.buf, count - ring.size)
else
ffi.copy(buf, ring.buf + start, count)
end
ring.read = ring.read + count
ffi.C.full_memory_barrier()
return buf
end
Channel = {}
local default_buffer_size = 32
function create(name, type, size)
local ret = {}
size = size or default_buffer_size
ret.ring_buffer = create_ring_buffer(name, ffi.sizeof(type) * size)
ret.type = type
ret.type_ptr = ffi.typeof('$*', type)
return setmetatable(ret, {__index=Channel})
end
function open(pid, name, type)
local ret = {}
ret.ring_buffer = open_ring_buffer(pid, name)
if ret.ring_buffer.size % ffi.sizeof(type) ~= 0 then
error ("Unexpected channel size: "..ret.ring_buffer.size)
end
ret.type = type
return setmetatable(ret, {__index=Channel})
end
function Channel:put(...)
local val = self.type(...)
return put_bytes(self.ring_buffer, val, ffi.sizeof(self.type)) >= 0
end
function Channel:pop()
local ret = get_bytes(self.ring_buffer, ffi.sizeof(self.type))
if ret then return ffi.cast(self.type_ptr, ret) end
end
function selftest()
print('selftest: channel')
local msg_t = ffi.typeof('struct { uint8_t a; uint8_t b; }')
local ch = create('test/control', msg_t, 16)
for i=1,16 do assert(ch:put({i, i+16})) end
assert(not ch:put({0,0}))
local function assert_pop(a, b)
local msg = assert(ch:pop())
assert(msg.a == a)
assert(msg.b == b)
end
assert_pop(1, 17)
assert(ch:put({17, 33}))
assert(not ch:put({0,0}))
for i=2,17 do assert_pop(i, i+16) end
assert(not ch:pop())
print('selftest: channel ok')
end
| apache-2.0 |
imeteora/cocos2d-x-3.x-Qt | tests/lua-tests/src/IntervalTest/IntervalTest.lua | 17 | 4556 | local scheduler = cc.Director:getInstance():getScheduler()
local SID_STEP1 = 100
local SID_STEP2 = 101
local SID_STEP3 = 102
local IDC_PAUSE = 200
local function IntervalLayer()
local ret = cc.Layer:create()
local m_time0 = 0
local m_time1 = 0
local m_time2 = 0
local m_time3 = 0
local m_time4 = 0
local s = cc.Director:getInstance():getWinSize()
-- sun
local sun = cc.ParticleSun:create()
sun:setTexture(cc.Director:getInstance():getTextureCache():addImage("Images/fire.png"))
sun:setPosition( cc.p(VisibleRect:rightTop().x-32,VisibleRect:rightTop().y-32) )
sun:setTotalParticles(130)
sun:setLife(0.6)
ret:addChild(sun)
-- timers
m_label0 = cc.Label:createWithBMFont("fonts/bitmapFontTest4.fnt", "0")
m_label0:setAnchorPoint(cc.p(0.5, 0.5))
m_label1 = cc.Label:createWithBMFont("fonts/bitmapFontTest4.fnt", "0")
m_label1:setAnchorPoint(cc.p(0.5, 0.5))
m_label2 = cc.Label:createWithBMFont("fonts/bitmapFontTest4.fnt", "0")
m_label2:setAnchorPoint(cc.p(0.5, 0.5))
m_label3 = cc.Label:createWithBMFont("fonts/bitmapFontTest4.fnt", "0")
m_label3:setAnchorPoint(cc.p(0.5, 0.5))
m_label4 = cc.Label:createWithBMFont("fonts/bitmapFontTest4.fnt", "0")
m_label4:setAnchorPoint(cc.p(0.5, 0.5))
local function update(dt)
m_time0 = m_time0 + dt
local str = string.format("%2.1f", m_time0)
m_label0:setString(str)
end
ret:scheduleUpdateWithPriorityLua(update, 0)
local function step1(dt)
m_time1 = m_time1 + dt
local str = string.format("%2.1f", m_time1)
m_label1:setString( str )
end
local function step2(dt)
m_time2 = m_time2 + dt
local str = string.format("%2.1f", m_time2)
m_label2:setString( str )
end
local function step3(dt)
m_time3 = m_time3 + dt
local str = string.format("%2.1f", m_time3)
m_label3:setString( str )
end
local function step4(dt)
m_time4 = m_time4 + dt
local str = string.format("%2.1f", m_time4)
m_label4:setString( str )
end
local schedulerEntry1 = nil
local schedulerEntry2 = nil
local schedulerEntry3 = nil
local schedulerEntry4 = nil
local function onNodeEvent(event)
if event == "enter" then
schedulerEntry1 = scheduler:scheduleScriptFunc(step1, 0, false)
schedulerEntry2 = scheduler:scheduleScriptFunc(step2, 0, false)
schedulerEntry3 = scheduler:scheduleScriptFunc(step3, 1.0, false)
schedulerEntry4 = scheduler:scheduleScriptFunc(step4, 2.0, false)
elseif event == "exit" then
scheduler:unscheduleScriptEntry(schedulerEntry1)
scheduler:unscheduleScriptEntry(schedulerEntry2)
scheduler:unscheduleScriptEntry(schedulerEntry3)
scheduler:unscheduleScriptEntry(schedulerEntry4)
if cc.Director:getInstance():isPaused() then
cc.Director:getInstance():resume()
end
end
end
ret:registerScriptHandler(onNodeEvent)
m_label0:setPosition(cc.p(s.width*1/6, s.height/2))
m_label1:setPosition(cc.p(s.width*2/6, s.height/2))
m_label2:setPosition(cc.p(s.width*3/6, s.height/2))
m_label3:setPosition(cc.p(s.width*4/6, s.height/2))
m_label4:setPosition(cc.p(s.width*5/6, s.height/2))
ret:addChild(m_label0)
ret:addChild(m_label1)
ret:addChild(m_label2)
ret:addChild(m_label3)
ret:addChild(m_label4)
-- Sprite
local sprite = cc.Sprite:create(s_pPathGrossini)
sprite:setPosition( cc.p(VisibleRect:left().x + 40, VisibleRect:bottom().y + 50) )
local jump = cc.JumpBy:create(3, cc.p(s.width-80,0), 50, 4)
ret:addChild(sprite)
sprite:runAction( cc.RepeatForever:create(cc.Sequence:create(jump, jump:reverse())))
-- pause button
local item1 = cc.MenuItemFont:create("Pause")
local function onPause(tag, pSender)
if cc.Director:getInstance():isPaused() then
cc.Director:getInstance():resume()
else
cc.Director:getInstance():pause()
end
end
item1:registerScriptTapHandler(onPause)
local menu = cc.Menu:create(item1)
menu:setPosition( cc.p(s.width/2, s.height-50) )
ret:addChild( menu )
return ret
end
function IntervalTestMain()
cclog("IntervalTestMain")
local scene = cc.Scene:create()
local layer = IntervalLayer()
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())
return scene
end
| gpl-2.0 |
CarabusX/Zero-K | LuaRules/Configs/StartBoxes/Archsimkats_Valley_V1.lua | 6 | 4213 | local ret = {
[0] = {
boxes = {
{
{5383, 8188},
{5460, 8030},
{5692, 7970},
{6073, 7809},
{6252, 7594},
{6309, 7174},
{6209, 7132},
{6179, 7002},
{6186, 6819},
{6010, 6691},
{5896, 6562},
{5822, 6358},
{5890, 6179},
{6262, 5935},
{6564, 5755},
{6699, 5768},
{6829, 6009},
{6934, 6029},
{7127, 6045},
{7302, 5973},
{7386, 5784},
{7391, 5641},
{7434, 5586},
{7546, 5514},
{7652, 5288},
{7610, 5216},
{7433, 5230},
{7379, 5166},
{7385, 5105},
{7306, 5029},
{7242, 5033},
{7204, 5000},
{7305, 4811},
{7489, 4771},
{7612, 4798},
{7836, 4687},
{7984, 4487},
{8179, 4460},
{8190, 5053},
{8076, 5080},
{7928, 5251},
{7896, 5404},
{7951, 5560},
{8006, 5776},
{8024, 5879},
{7992, 5917},
{7893, 5907},
{7831, 5956},
{7832, 6136},
{7901, 6203},
{7865, 6279},
{7828, 6375},
{7812, 6520},
{7613, 6719},
{7540, 6858},
{7533, 7071},
{7572, 7249},
{7600, 7329},
{7545, 7530},
{7594, 7595},
{7690, 7611},
{7744, 7668},
{7655, 7724},
{7573, 7698},
{7484, 7642},
{7367, 7722},
{7394, 7802},
{7389, 7855},
{7348, 7931},
{7166, 7848},
{7042, 7885},
{7006, 8014},
{7075, 8187},
{6772, 8184},
{6765, 8076},
{6675, 7984},
{6505, 7956},
{6414, 8061},
{6366, 8057},
{6344, 8027},
{6274, 8028},
{6237, 7989},
{6202, 7986},
{6157, 7939},
{6108, 7948},
{6090, 7977},
{5985, 7971},
{5936, 7993},
{5894, 8041},
{5854, 8050},
{5826, 8096},
{5808, 8191},
}, {
{4619, 8189},
{4586, 7921},
{4640, 7775},
{4804, 7700},
{5023, 7737},
{5088, 7779},
{5076, 7836},
{4942, 7856},
{4833, 7990},
{4792, 8189},
{5216, 8189},
{5318, 7900},
{5391, 7891},
{5451, 7938},
{5507, 7938},
{5532, 7890},
{5549, 7749},
{5627, 7652},
{5800, 7583},
{5861, 7496},
{5856, 7375},
{5848, 7222},
{5910, 7135},
{5759, 6763},
{5679, 6646},
{5659, 6556},
{5583, 6393},
{5638, 6190},
{5873, 5813},
{6051, 5743},
{5979, 5689},
{5597, 5595},
{5336, 5610},
{5050, 5479},
{5026, 5393},
{5044, 5291},
{5003, 5210},
{4923, 5169},
{4737, 5299},
{4665, 5297},
{4624, 5230},
{4587, 5210},
{4523, 5208},
{4439, 5256},
{4424, 5279},
{4494, 5388},
{4585, 5425},
{4633, 5484},
{4610, 5532},
{4535, 5546},
{4448, 5503},
{4405, 5425},
{4309, 5375},
{4209, 5423},
{4138, 5403},
{4029, 5458},
{3980, 5518},
{3963, 5680},
{3965, 5740},
{4043, 5790},
{4135, 5886},
{4263, 6063},
{4237, 6174},
{4242, 6267},
{4313, 6330},
{4434, 6340},
{4478, 6446},
{4493, 6541},
{4459, 6607},
{4384, 6709},
{4380, 6821},
{4475, 6936},
{4443, 7030},
{4250, 7253},
{4115, 7360},
{4107, 7507},
{4166, 7625},
{4151, 7787},
{4242, 7953},
{4249, 8186},
}
},
startpoints = {
{6887, 7714},
{7276, 6523},
{7732, 5111},
{5151, 7299},
{4627, 5791},
},
nameLong = "South-East",
nameShort = "SE",
},
[1] = {
boxes = { },
startpoints = { },
nameLong = "North-West",
nameShort = "NW",
},
}
local sourceConf = ret[0]
local mirrorConf = ret[1]
local sourceBoxes = sourceConf.boxes
local mirrorBoxes = mirrorConf.boxes
local sourceStartpoints = sourceConf.startpoints
local mirrorStartpoints = mirrorConf.startpoints
if not Spring.Utilities.Gametype.isBigTeams() then
sourceBoxes[2] = nil
sourceStartpoints[4] = nil
sourceStartpoints[5] = nil
end
local g = Game
local mapX = g.mapSizeX
local mapZ = g.mapSizeZ
for i = 1, #sourceBoxes do
local sourceBox = sourceBoxes[i]
local mirrorBox = {}
for j = 1, #sourceBox do
local vertex = sourceBox[j]
mirrorBox[j] = { mapX - vertex[1], mapZ - vertex[2] }
end
mirrorBoxes[i] = mirrorBox
end
for i = 1, #sourceStartpoints do
local pos = sourceStartpoints[i]
mirrorStartpoints[i] = { mapX - pos[1], mapZ - pos[2] }
end
return ret, {2}
| gpl-2.0 |
Germanunkol/GridCars | network/examples/dedicated.lua | 4 | 3931 | -- This is a minimal example of how to set up a dedicated server.
-- In this context, dedicated means the server is run
-- a) headless (no Löve dependency)
-- b) in plain Lua.
-- Requirements: Luasocket and Lua must be installed
network = require( "../network" )
local server
local MAX_PLAYERS = 16
local PORT = 3412
local MAIN_SERVER_ADDRESS = "http://germanunkol.de/Affair/advertise.php"
-- COMMANDs are used to identify messages.
-- Custom commands MUST be numbers between (including) 128 and 255.
-- Make sure these are the same on client and server.
-- Ideally, put them into a seperate file and include it from both client
-- and server. Here, I leave it in the main file for readability.
local COMMAND = {
CHAT = 128,
MAP = 129,
}
local myMapString = ""
function startDedicatedServer()
local success
success, server = pcall( function()
return network:startServer( MAX_PLAYERS, PORT )
end)
if success then
-- set callbacks for the newly created server:
setServerCallbacks( server )
network.advertise:setURL( MAIN_SERVER_ADDRESS )
network.advertise:setID( "ExampleServer" )
network.advertise:setInfo( "Players:0" )
network.advertise:start( server, "both" )
else
-- If I can't start a server for some reason, let user know and exit:
print(server)
os.exit()
end
end
function connected( user )
-- Called when new user has fully connected.
print( user.playerName .. " has joined. (ID: " .. user.id .. ")" )
local list, num = network:getUsers()
network.advertise:setInfo( "Players:" .. num )
end
function disconnected( user )
-- Called when user leaves.
print( user.playerName .. " has has left. (ID: " .. user.id .. ")" )
local list, num = network:getUsers()
network.advertise:setInfo( "Players:" .. num )
end
function synchronize( user )
-- Send the map to the new client
server:send( COMMAND.MAP, myMapString, user )
print("sent map")
end
function authorize( user )
-- Authorize everyone! We're a lövely community, after all, everyone is welcome!
return true
end
function received( command, msg, user )
-- If the user sends us some data, then just print it.
print( user.playerName .. " sent: ", command, msg )
-- NOTE: Usually, you would compare "command" to all the values in the COMMAND table, and
-- then act accordingly:
-- if command == COMMAND.
end
function setServerCallbacks( server )
-- Called whenever one of the users is trying to connect:
server.callbacks.authorize = authorized
-- Called during connection process:
server.callbacks.synchronize = synchronize
-- Called when user has connected AND has been synchronized:
server.callbacks.userFullyConnected = connected
-- Called whenever one of the users sends data:
server.callbacks.received = received
-- Called whenever one of the users is disconnected
server.callbacks.disconnectedUser = disconnected
end
-- Sleep time in second - use the socket library to make sure the
-- sleep is a "non busy" sleep, meaning the CPU will NOT be busy during
-- the sleep.
function sleep( sec )
socket.select(nil, nil, sec)
end
-- Fill the map string with something long for testing purposes:
for y = 1, 900 do
for x = 1, 90 do
if math.random(10) == 1 then
myMapString = myMapString .. math.random(9)
else
myMapString = myMapString .. "-"
end
end
myMapString = myMapString .. "\n"
if y % 1000 == 0 then
print(y)
end
end
print( "Map:\n" .. myMapString .. "\nNumber of characters: " .. #myMapString )
startDedicatedServer()
local time = socket.gettime()
local dt = 0
local t = 0
while true do
network:update( dt )
dt = socket.gettime() - time
time = socket.gettime()
-- This is important. Play with this value to fit your need.
-- If you don't use this sleep command, the CPU will be used as much as possible, you'll probably run the game loop WAY more often than on the clients (who also require time to render the picture - something you don't need)
sleep( 0.05 )
end
| mit |
mattyx14/otxserver | data/monster/quests/the_secret_library/the_lily_of_night.lua | 2 | 2223 | local mType = Game.createMonsterType("The Lily of Night")
local monster = {}
monster.description = "a the lily of night"
monster.experience = 0
monster.outfit = {
lookType = 1068,
lookHead = 0,
lookBody = 57,
lookLegs = 90,
lookFeet = 79,
lookAddons = 2,
lookMount = 0
}
monster.health = 10000
monster.maxHealth = 10000
monster.race = "undead"
monster.corpse = 28802
monster.speed = 350
monster.manaCost = 0
monster.changeTarget = {
interval = 5000,
chance = 8
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -200},
{name ="combat", interval = 1000, chance = 15, type = COMBAT_PHYSICALDAMAGE, minDamage = 0, maxDamage = -180, range = 7, shootEffect = CONST_ANI_SNOWBALL, effect = CONST_ME_POFF, target = false},
{name ="combat", interval = 1000, chance = 12, type = COMBAT_ENERGYDAMAGE, minDamage = 0, maxDamage = -175, length = 3, spread = 3, effect = CONST_ME_POFF, target = false}
}
monster.defenses = {
defense = 33,
armor = 28
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 0},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
mattyx14/otxserver | data/monster/quests/cults_of_tibia/misguided_shadow.lua | 2 | 2410 | local mType = Game.createMonsterType("Misguided Shadow")
local monster = {}
monster.description = "a misguided shadow"
monster.experience = 1200
monster.outfit = {
lookType = 985,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.health = 3000
monster.maxHealth = 3000
monster.race = "blood"
monster.corpse = 26125
monster.speed = 240
monster.manaCost = 390
monster.changeTarget = {
interval = 4000,
chance = 20
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = false,
staticAttackChance = 95,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "Aiiiiiiieeeeeeeh...", yell = false}
}
monster.loot = {
{id = 236, chance = 15000}, -- strong health potion
{id = 3039, chance = 6000} -- red gem
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -350},
{name ="combat", interval = 2000, chance = 15, type = COMBAT_ENERGYDAMAGE, minDamage = -180, maxDamage = -220, range = 6, length = 6, spread = 7, shootEffect = CONST_ANI_ENERGY, effect = CONST_ME_ENERGYAREA, target = false}
}
monster.defenses = {
defense = 35,
armor = 35,
{name ="combat", interval = 1000, chance = 20, type = COMBAT_HEALING, minDamage = 200, maxDamage = 450, effect = CONST_ME_MAGIC_BLUE, target = false}
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = -10},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 0},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 10},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
aqasaeed/sparta | plugins/wiki.lua | 735 | 4364 | -- http://git.io/vUA4M
local socket = require "socket"
local JSON = require "cjson"
local wikiusage = {
"!wiki [text]: Read extract from default Wikipedia (EN)",
"!wiki(lang) [text]: Read extract from 'lang' Wikipedia. Example: !wikies hola",
"!wiki search [text]: Search articles on default Wikipedia (EN)",
"!wiki(lang) search [text]: Search articles on 'lang' Wikipedia. Example: !wikies search hola",
}
local Wikipedia = {
-- http://meta.wikimedia.org/wiki/List_of_Wikipedias
wiki_server = "https://%s.wikipedia.org",
wiki_path = "/w/api.php",
wiki_load_params = {
action = "query",
prop = "extracts",
format = "json",
exchars = 300,
exsectionformat = "plain",
explaintext = "",
redirects = ""
},
wiki_search_params = {
action = "query",
list = "search",
srlimit = 20,
format = "json",
},
default_lang = "en",
}
function Wikipedia:getWikiServer(lang)
return string.format(self.wiki_server, lang or self.default_lang)
end
--[[
-- return decoded JSON table from Wikipedia
--]]
function Wikipedia:loadPage(text, lang, intro, plain, is_search)
local request, sink = {}, {}
local query = ""
local parsed
if is_search then
for k,v in pairs(self.wiki_search_params) do
query = query .. k .. '=' .. v .. '&'
end
parsed = URL.parse(self:getWikiServer(lang))
parsed.path = self.wiki_path
parsed.query = query .. "srsearch=" .. URL.escape(text)
else
self.wiki_load_params.explaintext = plain and "" or nil
for k,v in pairs(self.wiki_load_params) do
query = query .. k .. '=' .. v .. '&'
end
parsed = URL.parse(self:getWikiServer(lang))
parsed.path = self.wiki_path
parsed.query = query .. "titles=" .. URL.escape(text)
end
-- HTTP request
request['url'] = URL.build(parsed)
print(request['url'])
request['method'] = 'GET'
request['sink'] = ltn12.sink.table(sink)
local httpRequest = parsed.scheme == 'http' and http.request or https.request
local code, headers, status = socket.skip(1, httpRequest(request))
if not headers or not sink then
return nil
end
local content = table.concat(sink)
if content ~= "" then
local ok, result = pcall(JSON.decode, content)
if ok and result then
return result
else
return nil
end
else
return nil
end
end
-- extract intro passage in wiki page
function Wikipedia:wikintro(text, lang)
local result = self:loadPage(text, lang, true, true)
if result and result.query then
local query = result.query
if query and query.normalized then
text = query.normalized[1].to or text
end
local page = query.pages[next(query.pages)]
if page and page.extract then
return text..": "..page.extract
else
local text = "Extract not found for "..text
text = text..'\n'..table.concat(wikiusage, '\n')
return text
end
else
return "Sorry an error happened"
end
end
-- search for term in wiki
function Wikipedia:wikisearch(text, lang)
local result = self:loadPage(text, lang, true, true, true)
if result and result.query then
local titles = ""
for i,item in pairs(result.query.search) do
titles = titles .. "\n" .. item["title"]
end
titles = titles ~= "" and titles or "No results found"
return titles
else
return "Sorry, an error occurred"
end
end
local function run(msg, matches)
-- TODO: Remember language (i18 on future version)
-- TODO: Support for non Wikipedias but Mediawikis
local search, term, lang
if matches[1] == "search" then
search = true
term = matches[2]
lang = nil
elseif matches[2] == "search" then
search = true
term = matches[3]
lang = matches[1]
else
term = matches[2]
lang = matches[1]
end
if not term then
term = lang
lang = nil
end
if term == "" then
local text = "Usage:\n"
text = text..table.concat(wikiusage, '\n')
return text
end
local result
if search then
result = Wikipedia:wikisearch(term, lang)
else
-- TODO: Show the link
result = Wikipedia:wikintro(term, lang)
end
return result
end
return {
description = "Searches Wikipedia and send results",
usage = wikiusage,
patterns = {
"^![Ww]iki(%w+) (search) (.+)$",
"^![Ww]iki (search) ?(.*)$",
"^![Ww]iki(%w+) (.+)$",
"^![Ww]iki ?(.*)$"
},
run = run
}
| gpl-2.0 |
hacker44-h44/50 | plugins/wiki.lua | 735 | 4364 | -- http://git.io/vUA4M
local socket = require "socket"
local JSON = require "cjson"
local wikiusage = {
"!wiki [text]: Read extract from default Wikipedia (EN)",
"!wiki(lang) [text]: Read extract from 'lang' Wikipedia. Example: !wikies hola",
"!wiki search [text]: Search articles on default Wikipedia (EN)",
"!wiki(lang) search [text]: Search articles on 'lang' Wikipedia. Example: !wikies search hola",
}
local Wikipedia = {
-- http://meta.wikimedia.org/wiki/List_of_Wikipedias
wiki_server = "https://%s.wikipedia.org",
wiki_path = "/w/api.php",
wiki_load_params = {
action = "query",
prop = "extracts",
format = "json",
exchars = 300,
exsectionformat = "plain",
explaintext = "",
redirects = ""
},
wiki_search_params = {
action = "query",
list = "search",
srlimit = 20,
format = "json",
},
default_lang = "en",
}
function Wikipedia:getWikiServer(lang)
return string.format(self.wiki_server, lang or self.default_lang)
end
--[[
-- return decoded JSON table from Wikipedia
--]]
function Wikipedia:loadPage(text, lang, intro, plain, is_search)
local request, sink = {}, {}
local query = ""
local parsed
if is_search then
for k,v in pairs(self.wiki_search_params) do
query = query .. k .. '=' .. v .. '&'
end
parsed = URL.parse(self:getWikiServer(lang))
parsed.path = self.wiki_path
parsed.query = query .. "srsearch=" .. URL.escape(text)
else
self.wiki_load_params.explaintext = plain and "" or nil
for k,v in pairs(self.wiki_load_params) do
query = query .. k .. '=' .. v .. '&'
end
parsed = URL.parse(self:getWikiServer(lang))
parsed.path = self.wiki_path
parsed.query = query .. "titles=" .. URL.escape(text)
end
-- HTTP request
request['url'] = URL.build(parsed)
print(request['url'])
request['method'] = 'GET'
request['sink'] = ltn12.sink.table(sink)
local httpRequest = parsed.scheme == 'http' and http.request or https.request
local code, headers, status = socket.skip(1, httpRequest(request))
if not headers or not sink then
return nil
end
local content = table.concat(sink)
if content ~= "" then
local ok, result = pcall(JSON.decode, content)
if ok and result then
return result
else
return nil
end
else
return nil
end
end
-- extract intro passage in wiki page
function Wikipedia:wikintro(text, lang)
local result = self:loadPage(text, lang, true, true)
if result and result.query then
local query = result.query
if query and query.normalized then
text = query.normalized[1].to or text
end
local page = query.pages[next(query.pages)]
if page and page.extract then
return text..": "..page.extract
else
local text = "Extract not found for "..text
text = text..'\n'..table.concat(wikiusage, '\n')
return text
end
else
return "Sorry an error happened"
end
end
-- search for term in wiki
function Wikipedia:wikisearch(text, lang)
local result = self:loadPage(text, lang, true, true, true)
if result and result.query then
local titles = ""
for i,item in pairs(result.query.search) do
titles = titles .. "\n" .. item["title"]
end
titles = titles ~= "" and titles or "No results found"
return titles
else
return "Sorry, an error occurred"
end
end
local function run(msg, matches)
-- TODO: Remember language (i18 on future version)
-- TODO: Support for non Wikipedias but Mediawikis
local search, term, lang
if matches[1] == "search" then
search = true
term = matches[2]
lang = nil
elseif matches[2] == "search" then
search = true
term = matches[3]
lang = matches[1]
else
term = matches[2]
lang = matches[1]
end
if not term then
term = lang
lang = nil
end
if term == "" then
local text = "Usage:\n"
text = text..table.concat(wikiusage, '\n')
return text
end
local result
if search then
result = Wikipedia:wikisearch(term, lang)
else
-- TODO: Show the link
result = Wikipedia:wikintro(term, lang)
end
return result
end
return {
description = "Searches Wikipedia and send results",
usage = wikiusage,
patterns = {
"^![Ww]iki(%w+) (search) (.+)$",
"^![Ww]iki (search) ?(.*)$",
"^![Ww]iki(%w+) (.+)$",
"^![Ww]iki ?(.*)$"
},
run = run
}
| gpl-2.0 |
rafael/kong | kong/api/app.lua | 7 | 4686 | local lapis = require "lapis"
local utils = require "kong.tools.utils"
local stringy = require "stringy"
local responses = require "kong.tools.responses"
local app_helpers = require "lapis.application"
local app = lapis.Application()
-- Parses a form value, handling multipart/data values
-- @param `v` The value object
-- @return The parsed value
local function parse_value(v)
return type(v) == "table" and v.content or v -- Handle multipart
end
-- Put nested keys in objects:
-- Normalize dotted keys in objects.
-- Example: {["key.value.sub"]=1234} becomes {key = {value = {sub=1234}}
-- @param `obj` Object to normalize
-- @return `normalized_object`
local function normalize_nested_params(obj)
local new_obj = {}
local function attach_dotted_key(keys, attach_to, value)
local current_key = keys[1]
if #keys > 1 then
if not attach_to[current_key] then
attach_to[current_key] = {}
end
table.remove(keys, 1)
attach_dotted_key(keys, attach_to[current_key], value)
else
attach_to[current_key] = value
end
end
for k, v in pairs(obj) do
if type(v) == "table" then
-- normalize arrays since Lapis parses ?key[1]=foo as {["1"]="foo"} instead of {"foo"}
if utils.is_array(v) then
local arr = {}
for _, arr_v in pairs(v) do table.insert(arr, arr_v) end
v = arr
else
v = normalize_nested_params(v) -- recursive call on other table values
end
end
-- normalize sub-keys with dot notation
local keys = stringy.split(k, ".")
if #keys > 1 then -- we have a key containing a dot
attach_dotted_key(keys, new_obj, parse_value(v))
else
new_obj[k] = parse_value(v) -- nothing special with that key, simply attaching the value
end
end
return new_obj
end
local function default_on_error(self)
local err = self.errors[1]
if type(err) == "table" then
if err.database then
return responses.send_HTTP_INTERNAL_SERVER_ERROR(err.message)
elseif err.unique then
return responses.send_HTTP_CONFLICT(err.message)
elseif err.foreign then
return responses.send_HTTP_NOT_FOUND(err.message)
elseif err.invalid_type and err.message.id then
return responses.send_HTTP_BAD_REQUEST(err.message)
else
return responses.send_HTTP_BAD_REQUEST(err.message)
end
end
end
local function parse_params(fn)
return app_helpers.json_params(function(self, ...)
local content_type = self.req.headers["content-type"]
if content_type and string.find(content_type:lower(), "application/json", nil, true) then
if not self.json then
return responses.send_HTTP_BAD_REQUEST("Cannot parse JSON body")
end
end
self.params = normalize_nested_params(self.params)
return fn(self, ...)
end)
end
app.parse_params = parse_params
app.default_route = function(self)
local path = self.req.parsed_url.path:match("^(.*)/$")
if path and self.app.router:resolve(path, self) then
return
elseif self.app.router:resolve(self.req.parsed_url.path.."/", self) then
return
end
return self.app.handle_404(self)
end
app.handle_404 = function(self)
return responses.send_HTTP_NOT_FOUND()
end
app.handle_error = function(self, err, trace)
if stringy.find(err, "don't know how to respond to") ~= nil then
return responses.send_HTTP_METHOD_NOT_ALLOWED()
else
ngx.log(ngx.ERR, err.."\n"..trace)
end
-- We just logged the error so no need to give it to responses and log it twice
return responses.send_HTTP_INTERNAL_SERVER_ERROR()
end
local handler_helpers = {
responses = responses,
yield_error = app_helpers.yield_error
}
local function attach_routes(routes)
for route_path, methods in pairs(routes) do
if not methods.on_error then
methods.on_error = default_on_error
end
for k, v in pairs(methods) do
local method = function(self)
return v(self, dao, handler_helpers)
end
methods[k] = parse_params(method)
end
app:match(route_path, route_path, app_helpers.respond_to(methods))
end
end
-- Load core routes
for _, v in ipairs({"kong", "apis", "consumers", "plugins"}) do
local routes = require("kong.api.routes."..v)
attach_routes(routes)
end
-- Loading plugins routes
if configuration and configuration.plugins_available then
for _, v in ipairs(configuration.plugins_available) do
local loaded, mod = utils.load_module_if_exists("kong.plugins."..v..".api")
if loaded then
ngx.log(ngx.DEBUG, "Loading API endpoints for plugin: "..v)
attach_routes(mod)
else
ngx.log(ngx.DEBUG, "No API endpoints loaded for plugin: "..v)
end
end
end
return app
| apache-2.0 |
ReclaimYourPrivacy/cloak-luci | applications/luci-app-diag-devinfo/luasrc/model/cbi/luci_diag/netdiscover_devinfo_mini.lua | 141 | 1054 | --[[
netdiscover_devinfo - SIP Device Information
(c) 2009 Daniel Dickinson
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.i18n")
require("luci.util")
require("luci.sys")
require("luci.model.uci")
require("luci.controller.luci_diag.netdiscover_common")
require("luci.controller.luci_diag.devinfo_common")
local debug = false
m = SimpleForm("luci_devinfo", translate("Network Device Scan"), translate("Scan for devices on specified networks."))
m.reset = false
m.submit = false
local outnets = luci.controller.luci_diag.netdiscover_common.get_params()
luci.controller.luci_diag.devinfo_common.run_processes(outnets, luci.controller.luci_diag.netdiscover_common.command_function)
luci.controller.luci_diag.devinfo_common.parse_output(m, outnets, false, "netdiscover", true, debug)
luci.controller.luci_diag.netdiscover_common.action_links(m, true)
return m
| apache-2.0 |
awilliamson/Starfall | lua/starfall/libs_sh/trace.lua | 1 | 8489 | -------------------------------------------------------------------------------
-- Trace library
-------------------------------------------------------------------------------
local dgetmeta = debug.getmetatable
--[[
-- Here's a neat little script to convert enumerations wiki.gmod.com-style
-- into something usable in code
local lines = <copy+paste enumeration with trailing \n here>
for line in lines:gmatch("([^\n]*)\n") do
local v = line:match("^.*|%s*(.*)$")
print("trace_library."..v.." = "..v)
end
]]
--- Provides functions for doing line/AABB traces
-- @shared
-- @field MAT_ANTLION
-- @field MAT_BLOODYFLESH
-- @field MAT_CONCRETE
-- @field MAT_DIRT
-- @field MAT_FLESH
-- @field MAT_GRATE
-- @field MAT_ALIENFLESH
-- @field MAT_CLIP
-- @field MAT_PLASTIC
-- @field MAT_METAL
-- @field MAT_SAND
-- @field MAT_FOLIAGE
-- @field MAT_COMPUTER
-- @field MAT_SLOSH
-- @field MAT_TILE
-- @field MAT_VENT
-- @field MAT_WOOD
-- @field MAT_GLASS
-- @field HITGROUP_GENERIC
-- @field HITGROUP_HEAD
-- @field HITGROUP_CHEST
-- @field HITGROUP_STOMACH
-- @field HITGROUP_LEFTARM
-- @field HITGROUP_RIGHTARM
-- @field HITGROUP_LEFTLEG
-- @field HITGROUP_RIGHTLEG
-- @field HITGROUP_GEAR
-- @field MASK_SPLITAREAPORTAL
-- @field MASK_SOLID_BRUSHONLY
-- @field MASK_WATER
-- @field MASK_BLOCKLOS
-- @field MASK_OPAQUE
-- @field MASK_VISIBLE
-- @field MASK_DEADSOLID
-- @field MASK_PLAYERSOLID_BRUSHONLY
-- @field MASK_NPCWORLDSTATIC
-- @field MASK_NPCSOLID_BRUSHONLY
-- @field MASK_CURRENT
-- @field MASK_SHOT_PORTAL
-- @field MASK_SOLID
-- @field MASK_BLOCKLOS_AND_NPCS
-- @field MASK_OPAQUE_AND_NPCS
-- @field MASK_VISIBLE_AND_NPCS
-- @field MASK_PLAYERSOLID
-- @field MASK_NPCSOLID
-- @field MASK_SHOT_HULL
-- @field MASK_SHOT
-- @field MASK_ALL
-- @field CONTENTS_EMPTY
-- @field CONTENTS_SOLID
-- @field CONTENTS_WINDOW
-- @field CONTENTS_AUX
-- @field CONTENTS_GRATE
-- @field CONTENTS_SLIME
-- @field CONTENTS_WATER
-- @field CONTENTS_BLOCKLOS
-- @field CONTENTS_OPAQUE
-- @field CONTENTS_TESTFOGVOLUME
-- @field CONTENTS_TEAM4
-- @field CONTENTS_TEAM3
-- @field CONTENTS_TEAM1
-- @field CONTENTS_TEAM2
-- @field CONTENTS_IGNORE_NODRAW_OPAQUE
-- @field CONTENTS_MOVEABLE
-- @field CONTENTS_AREAPORTAL
-- @field CONTENTS_PLAYERCLIP
-- @field CONTENTS_MONSTERCLIP
-- @field CONTENTS_CURRENT_0
-- @field CONTENTS_CURRENT_90
-- @field CONTENTS_CURRENT_180
-- @field CONTENTS_CURRENT_270
-- @field CONTENTS_CURRENT_UP
-- @field CONTENTS_CURRENT_DOWN
-- @field CONTENTS_ORIGIN
-- @field CONTENTS_MONSTER
-- @field CONTENTS_DEBRIS
-- @field CONTENTS_DETAIL
-- @field CONTENTS_TRANSLUCENT
-- @field CONTENTS_LADDER
-- @field CONTENTS_HITBOX
local trace_library, _ = SF.Libraries.Register("trace")
-- Material Enumeration
trace_library.MAT_ANTLION = MAT_ANTLION
trace_library.MAT_BLOODYFLESH = MAT_BLOODYFLESH
trace_library.MAT_CONCRETE = MAT_CONCRETE
trace_library.MAT_DIRT = MAT_DIRT
trace_library.MAT_FLESH = MAT_FLESH
trace_library.MAT_GRATE = MAT_GRATE
trace_library.MAT_ALIENFLESH = MAT_ALIENFLESH
trace_library.MAT_CLIP = MAT_CLIP
trace_library.MAT_PLASTIC = MAT_PLASTIC
trace_library.MAT_METAL = MAT_METAL
trace_library.MAT_SAND = MAT_SAND
trace_library.MAT_FOLIAGE = MAT_FOLIAGE
trace_library.MAT_COMPUTER = MAT_COMPUTER
trace_library.MAT_SLOSH = MAT_SLOSH
trace_library.MAT_TILE = MAT_TILE
trace_library.MAT_VENT = MAT_VENT
trace_library.MAT_WOOD = MAT_WOOD
trace_library.MAT_GLASS = MAT_GLASS
-- Hithroup Enumeration
trace_library.HITGROUP_GENERIC = HITGROUP_GENERIC
trace_library.HITGROUP_HEAD = HITGROUP_HEAD
trace_library.HITGROUP_CHEST = HITGROUP_CHEST
trace_library.HITGROUP_STOMACH = HITGROUP_STOMACH
trace_library.HITGROUP_LEFTARM = HITGROUP_LEFTARM
trace_library.HITGROUP_RIGHTARM = HITGROUP_RIGHTARM
trace_library.HITGROUP_LEFTLEG = HITGROUP_LEFTLEG
trace_library.HITGROUP_RIGHTLEG = HITGROUP_RIGHTLEG
trace_library.HITGROUP_GEAR = HITGROUP_GEAR
-- Mask Enumerations
trace_library.MASK_SPLITAREAPORTAL = MASK_SPLITAREAPORTAL
trace_library.MASK_SOLID_BRUSHONLY = MASK_SOLID_BRUSHONLY
trace_library.MASK_WATER = MASK_WATER
trace_library.MASK_BLOCKLOS = MASK_BLOCKLOS
trace_library.MASK_OPAQUE = MASK_OPAQUE
trace_library.MASK_VISIBLE = MASK_VISIBLE
trace_library.MASK_DEADSOLID = MASK_DEADSOLID
trace_library.MASK_PLAYERSOLID_BRUSHONLY = MASK_PLAYERSOLID_BRUSHONLY
trace_library.MASK_NPCWORLDSTATIC = MASK_NPCWORLDSTATIC
trace_library.MASK_NPCSOLID_BRUSHONLY = MASK_NPCSOLID_BRUSHONLY
trace_library.MASK_CURRENT = MASK_CURRENT
trace_library.MASK_SHOT_PORTAL = MASK_SHOT_PORTAL
trace_library.MASK_SOLID = MASK_SOLID
trace_library.MASK_BLOCKLOS_AND_NPCS = MASK_BLOCKLOS_AND_NPCS
trace_library.MASK_OPAQUE_AND_NPCS = MASK_OPAQUE_AND_NPCS
trace_library.MASK_VISIBLE_AND_NPCS = MASK_VISIBLE_AND_NPCS
trace_library.MASK_PLAYERSOLID = MASK_PLAYERSOLID
trace_library.MASK_NPCSOLID = MASK_NPCSOLID
trace_library.MASK_SHOT_HULL = MASK_SHOT_HULL
trace_library.MASK_SHOT = MASK_SHOT
trace_library.MASK_ALL = MASK_ALL
-- Content Enumerations
trace_library.CONTENTS_EMPTY = CONTENTS_EMPTY
trace_library.CONTENTS_SOLID = CONTENTS_SOLID
trace_library.CONTENTS_WINDOW = CONTENTS_WINDOW
trace_library.CONTENTS_AUX = CONTENTS_AUX
trace_library.CONTENTS_GRATE = CONTENTS_GRATE
trace_library.CONTENTS_SLIME = CONTENTS_SLIME
trace_library.CONTENTS_WATER = CONTENTS_WATER
trace_library.CONTENTS_BLOCKLOS = CONTENTS_BLOCKLOS
trace_library.CONTENTS_OPAQUE = CONTENTS_OPAQUE
trace_library.CONTENTS_TESTFOGVOLUME = CONTENTS_TESTFOGVOLUME
trace_library.CONTENTS_TEAM4 = CONTENTS_TEAM4
trace_library.CONTENTS_TEAM3 = CONTENTS_TEAM3
trace_library.CONTENTS_TEAM1 = CONTENTS_TEAM1
trace_library.CONTENTS_TEAM2 = CONTENTS_TEAM2
trace_library.CONTENTS_IGNORE_NODRAW_OPAQUE = CONTENTS_IGNORE_NODRAW_OPAQUE
trace_library.CONTENTS_MOVEABLE = CONTENTS_MOVEABLE
trace_library.CONTENTS_AREAPORTAL = CONTENTS_AREAPORTAL
trace_library.CONTENTS_PLAYERCLIP = CONTENTS_PLAYERCLIP
trace_library.CONTENTS_MONSTERCLIP = CONTENTS_MONSTERCLIP
trace_library.CONTENTS_CURRENT_0 = CONTENTS_CURRENT_0
trace_library.CONTENTS_CURRENT_90 = CONTENTS_CURRENT_90
trace_library.CONTENTS_CURRENT_180 = CONTENTS_CURRENT_180
trace_library.CONTENTS_CURRENT_270 = CONTENTS_CURRENT_270
trace_library.CONTENTS_CURRENT_UP = CONTENTS_CURRENT_UP
trace_library.CONTENTS_CURRENT_DOWN = CONTENTS_CURRENT_DOWN
trace_library.CONTENTS_ORIGIN = CONTENTS_ORIGIN
trace_library.CONTENTS_MONSTER = CONTENTS_MONSTER
trace_library.CONTENTS_DEBRIS = CONTENTS_DEBRIS
trace_library.CONTENTS_DETAIL = CONTENTS_DETAIL
trace_library.CONTENTS_TRANSLUCENT = CONTENTS_TRANSLUCENT
trace_library.CONTENTS_LADDER = CONTENTS_LADDER
trace_library.CONTENTS_HITBOX = CONTENTS_HITBOX
-- Local functions
local wrap
local unwrap
local function postload()
wrap = SF.Entities.Wrap
unwrap = SF.Entities.Unwrap
end
SF.Libraries.AddHook("postload",postload)
local function convertFilter(filter)
if unwrap(filter) then
return {filter}
else
local l = {}
local count = 1
for i=1,#filter do
local unwrapped = unwrap(filter[i])
if unwrapped then
l[count] = unwrapped
count = count + 1
end
end
return l
end
end
local function convertResult(res)
if res.Entity then res.Entity = wrap(res.Entity) end
return res
end
--- Does a line trace
-- @param start Start position
-- @param endpos End position
-- @param filter Entity/array of entities to filter
-- @param mask Trace mask
-- @return Result of the trace
function trace_library.trace(start,endpos,filter,mask)
SF.CheckType(start,"Vector")
SF.CheckType(endpos,"Vector")
filter = convertFilter(SF.CheckType(filter,"table",0,{}))
if mask ~= nil then mask = SF.CheckType(mask,"number") end
local trace = {
start = start,
endpos = endpos,
filter = filter,
mask = mask
}
return convertResult(util.TraceLine(trace))
end
--- Does a swept-AABB trace
-- @param start Start position
-- @param endpos End position
-- @param minbox Lower box corner
-- @param maxbox Upper box corner
-- @param filter Entity/array of entities to filter
-- @param mask Trace mask
-- @return Result of the trace
function trace_library.traceHull(start,endpos,minbox,maxbox,filter,mask)
SF.CheckType(start,"Vector")
SF.CheckType(endpos,"Vector")
SF.CheckType(minbox,"Vector")
SF.CheckType(maxbox,"Vector")
filter = convertFilter(SF.CheckType(filter,"table",0,{}))
if mask ~= nil then mask = SF.CheckType(mask,"number") end
local trace = {
start = start,
endpos = endpos,
filter = filter,
mask = mask,
mins = minbox,
maxs = maxbox
}
return convertResult(util.TraceHull(trace))
end
| bsd-3-clause |
CarabusX/Zero-K | units/starlight_satellite.lua | 3 | 5557 | return { starlight_satellite = {
unitname = [[starlight_satellite]],
name = [[Glint]],
description = [[Starlight relay satellite]],
acceleration = 0.456,
brakeRate = 2.736,
buildCostMetal = 300,
builder = false,
buildPic = [[satellite.png]],
canFly = false,
canMove = true,
canSubmerge = false,
category = [[SINK UNARMED]],
collide = false,
corpse = [[DEAD]],
cruiseAlt = 140,
explodeAs = [[GUNSHIPEX]],
floater = true,
footprintX = 0,
footprintZ = 0,
hoverAttack = true,
iconType = [[satellite]],
idleAutoHeal = 5,
idleTime = 1800,
maxDamage = 1500,
maxVelocity = 0.001,
movementClass = [[KBOT2]],
noChaseCategory = [[TERRAFORM SATELLITE FIXEDWING GUNSHIP HOVER SHIP SWIM SUB LAND FLOAT SINK TURRET]],
objectName = [[starlight_satellite.dae]],
script = [[starlight_satellite.lua]],
selfDestructAs = [[GUNSHIPEX]],
customParams = {
dontcount = [[1]],
},
sfxtypes = {
explosiongenerators = {
[[custom:IMMA_LAUNCHIN_MAH_LAZER]],
[[custom:xamelimpact]],
},
},
sightDistance = 0,
turnRate = 1,
weapons = {
{
def = [[LAZER]],
onlyTargetCategory = [[NONE]],
},
{
def = [[CUTTER]],
onlyTargetCategory = [[NONE]],
},
},
weaponDefs = {
LAZER = {
name = [[Craterpuncher]],
alwaysVisible = 0,
areaOfEffect = 140,
avoidFeature = false,
avoidNeutral = false,
avoidGround = false,
beamTime = 1/30,
coreThickness = 0.5,
craterBoost = 6,
craterMult = 14,
customParams = {
light_color = [[5 0.3 6]],
light_radius = 2000,
light_beam_start = 0.8,
gatherradius = [[10]],
smoothradius = [[64]],
smoothmult = [[0.5]],
smoothheightoffset = [[40]],
lups_noshockwave = [[1]],
stats_damage = 18000,
},
damage = {
default = 800,
},
explosionGenerator = [[custom:craterpuncher]],
impulseBoost = 0,
impulseFactor = 0,
interceptedByShieldType = 1,
largeBeamLaser = true,
laserFlareSize = 12,
minIntensity = 1,
range = 10500,
reloadtime = 20,
rgbColor = [[0.25 0 1]],
scrollSpeed = 8,
soundStartVolume = 1,
soundTrigger = true,
texture1 = [[largelaser]],
texture2 = [[flare]],
texture3 = [[flare]],
texture4 = [[smallflare]],
thickness = 100,
tolerance = 65536,
tileLength = 10000,
turret = true,
waterWeapon = true,
weaponType = [[BeamLaser]],
},
CUTTER = {
name = [[Groovecutter]],
alwaysVisible = 0,
areaOfEffect = 140,
avoidFeature = false,
avoidNeutral = false,
avoidGround = false,
beamTime = 1/30,
coreThickness = 0.5,
craterBoost = 4,
craterMult = 8,
customParams = {
light_color = [[3 0.2 4]],
light_radius = 1200,
light_beam_start = 0.8,
},
damage = {
default = 150,
},
explosionGenerator = [[custom:FLASHLAZER]],
impulseBoost = 0,
impulseFactor = 0,
interceptedByShieldType = 1,
largeBeamLaser = true,
laserFlareSize = 12,
minIntensity = 1,
range = 10500,
reloadtime = 20,
rgbColor = [[0.25 0 1]],
scrollSpeed = 8,
soundStartVolume = 1,
soundTrigger = true,
texture1 = [[largelaser]],
texture2 = [[flare]],
texture3 = [[flare]],
texture4 = [[smallflare]],
thickness = 50,
tolerance = 65536,
tileLength = 10000,
turret = true,
waterWeapon = true,
weaponType = [[BeamLaser]],
},
},
featureDefs = {
DEAD = {
blocking = true,
featureDead = [[HEAP]],
footprintX = 3,
footprintZ = 3,
object = [[satellite_d.dae]],
customParams = {
unit = "mahlazer",
},
},
HEAP = {
blocking = false,
footprintX = 3,
footprintZ = 3,
object = [[debris2x2c.s3o]],
customParams = {
unit = "mahlazer",
},
},
},
} }
| gpl-2.0 |
garrysmodlua/wire | lua/wire/gates/logic.lua | 18 | 2870 | --[[
Logic Gates
]]
GateActions("Logic")
GateActions["not"] = {
name = "Not (Invert)",
inputs = { "A" },
output = function(gate, A)
if (A > 0) then return 0 end
return 1
end,
label = function(Out, A)
return "not "..A.." = "..Out
end
}
GateActions["and"] = {
name = "And (All)",
inputs = { "A", "B", "C", "D", "E", "F", "G", "H" },
compact_inputs = 2,
output = function(gate, ...)
for k,v in ipairs({...}) do
if (v) and (v <= 0) then return 0 end
end
return 1
end,
label = function(Out, ...)
local txt = ""
for k,v in ipairs({...}) do
if (v) then txt = txt..v.." and " end
end
return string.sub(txt, 1, -6).." = "..Out
end
}
GateActions["or"] = {
name = "Or (Any)",
inputs = { "A", "B", "C", "D", "E", "F", "G", "H" },
compact_inputs = 2,
output = function(gate, ...)
for k,v in ipairs({...}) do
if (v) and (v > 0) then return 1 end
end
return 0
end,
label = function(Out, ...)
local txt = ""
for k,v in ipairs({...}) do
if (v) then txt = txt..v.." or " end
end
return string.sub(txt, 1, -5).." = "..Out
end
}
GateActions["xor"] = {
name = "Exclusive Or (Odd)",
inputs = { "A", "B", "C", "D", "E", "F", "G", "H" },
compact_inputs = 2,
output = function(gate, ...)
local result = 0
for k,v in ipairs({...}) do
if (v) and (v > 0) then result = (1-result) end
end
return result
end,
label = function(Out, ...)
local txt = ""
for k,v in ipairs({...}) do
if (v) then txt = txt..v.." xor " end
end
return string.sub(txt, 1, -6).." = "..Out
end
}
GateActions["nand"] = {
name = "Not And (Not All)",
inputs = { "A", "B", "C", "D", "E", "F", "G", "H" },
compact_inputs = 2,
output = function(gate, ...)
for k,v in ipairs({...}) do
if (v) and (v <= 0) then return 1 end
end
return 0
end,
label = function(Out, ...)
local txt = ""
for k,v in ipairs({...}) do
if (v) then txt = txt..v.." nand " end
end
return string.sub(txt, 1, -7).." = "..Out
end
}
GateActions["nor"] = {
name = "Not Or (None)",
inputs = { "A", "B", "C", "D", "E", "F", "G", "H" },
compact_inputs = 2,
output = function(gate, ...)
for k,v in ipairs({...}) do
if (v) and (v > 0) then return 0 end
end
return 1
end,
label = function(Out, ...)
local txt = ""
for k,v in ipairs({...}) do
if (v) then txt = txt..v.." nor " end
end
return string.sub(txt, 1, -6).." = "..Out
end
}
GateActions["xnor"] = {
name = "Exclusive Not Or (Even)",
inputs = { "A", "B", "C", "D", "E", "F", "G", "H" },
compact_inputs = 2,
output = function(gate, ...)
local result = 1
for k,v in ipairs({...}) do
if (v) and (v > 0) then result = (1-result) end
end
return result
end,
label = function(Out, ...)
local txt = ""
for k,v in ipairs({...}) do
if (v) then txt = txt..v.." xnor " end
end
return string.sub(txt, 1, -7).." = "..Out
end
}
GateActions()
| apache-2.0 |
mattyx14/otxserver | data/monster/humanoids/insane_siren.lua | 2 | 3466 | local mType = Game.createMonsterType("Insane Siren")
local monster = {}
monster.description = "an insane siren"
monster.experience = 6000
monster.outfit = {
lookType = 1136,
lookHead = 72,
lookBody = 94,
lookLegs = 79,
lookFeet = 4,
lookAddons = 3,
lookMount = 0
}
monster.raceId = 1735
monster.Bestiary = {
class = "Humanoid",
race = BESTY_RACE_HUMANOID,
toKill = 2500,
FirstUnlock = 100,
SecondUnlock = 1000,
CharmsPoints = 50,
Stars = 4,
Occurrence = 0,
Locations = "Court of Summer."
}
monster.health = 6500
monster.maxHealth = 6500
monster.race = "blood"
monster.corpse = 30133
monster.speed = 420
monster.manaCost = 0
monster.changeTarget = {
interval = 4000,
chance = 10
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = true,
canWalkOnFire = true,
canWalkOnPoison = true
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "Dream or nightmare?", yell = false}
}
monster.loot = {
{name = "platinum coin", chance = 100000, maxCount = 12},
{name = "ultimate health potion", chance = 14970},
{name = "miraculum", chance = 13090},
{name = "dream essence egg", chance = 11980},
{name = "wand of draconia", chance = 7700},
{name = "holy orchid", chance = 5650},
{name = "magma amulet", chance = 5130},
{name = "wand of inferno", chance = 4360},
{name = "fire axe", chance = 3590},
{name = "magma coat", chance = 3340},
{name = "wand of dragonbreath", chance = 2650},
{name = "sun fruit", chance = 2570},
{name = "magma legs", chance = 1200},
{name = "magma monocle", chance = 260}
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -530},
{name ="combat", interval = 2000, chance = 20, type = COMBAT_FIREDAMAGE, minDamage = -270, maxDamage = -710, length = 3, spread = 0, effect = CONST_ME_FIREAREA, target = false},
{name ="combat", interval = 2000, chance = 15, type = COMBAT_FIREDAMAGE, minDamage = -250, maxDamage = -300, range = 7, shootEffect = CONST_ANI_FIRE, target = false},
{name ="combat", interval = 2000, chance = 10, type = COMBAT_FIREDAMAGE, minDamage = -350, maxDamage = -380, radius = 5, effect = CONST_ME_EXPLOSIONHIT, target = true},
{name ="combat", interval = 2000, chance = 15, type = COMBAT_FIREDAMAGE, minDamage = -200, maxDamage = -350, radius = 5, effect = CONST_ME_EXPLOSIONAREA, target = true}
}
monster.defenses = {
defense = 20,
armor = 70
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = -10},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 55},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = -20},
{type = COMBAT_HOLYDAMAGE , percent = 25},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = true},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
imeteora/cocos2d-x-3.x-Qt | templates/lua-template-default/src/main.lua | 1 | 8556 | require "Cocos2d"
require "Cocos2dConstants"
-- cclog
cclog = function(...)
print(string.format(...))
end
-- for CCLuaEngine traceback
function __G__TRACKBACK__(msg)
cclog("----------------------------------------")
cclog("LUA ERROR: " .. tostring(msg) .. "\n")
cclog(debug.traceback())
cclog("----------------------------------------")
end
local function main()
collectgarbage("collect")
-- avoid memory leak
collectgarbage("setpause", 100)
collectgarbage("setstepmul", 5000)
cc.FileUtils:getInstance():addSearchResolutionsOrder("src");
cc.FileUtils:getInstance():addSearchResolutionsOrder("res");
local schedulerID = 0
--support debug
local targetPlatform = cc.Application:getInstance():getTargetPlatform()
if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) or
(cc.PLATFORM_OS_ANDROID == targetPlatform) or (cc.PLATFORM_OS_WINDOWS == targetPlatform) or
(cc.PLATFORM_OS_MAC == targetPlatform) then
cclog("result is ")
--require('debugger')()
end
require "hello2"
cclog("result is " .. myadd(1, 1))
---------------
local visibleSize = cc.Director:getInstance():getVisibleSize()
local origin = cc.Director:getInstance():getVisibleOrigin()
-- add the moving dog
local function creatDog()
local frameWidth = 105
local frameHeight = 95
-- create dog animate
local textureDog = cc.Director:getInstance():getTextureCache():addImage("dog.png")
local rect = cc.rect(0, 0, frameWidth, frameHeight)
local frame0 = cc.SpriteFrame:createWithTexture(textureDog, rect)
rect = cc.rect(frameWidth, 0, frameWidth, frameHeight)
local frame1 = cc.SpriteFrame:createWithTexture(textureDog, rect)
local spriteDog = cc.Sprite:createWithSpriteFrame(frame0)
spriteDog.isPaused = false
spriteDog:setPosition(origin.x, origin.y + visibleSize.height / 4 * 3)
--[[
local animFrames = CCArray:create()
animFrames:addObject(frame0)
animFrames:addObject(frame1)
]]--
local animation = cc.Animation:createWithSpriteFrames({frame0,frame1}, 0.5)
local animate = cc.Animate:create(animation);
spriteDog:runAction(cc.RepeatForever:create(animate))
-- moving dog at every frame
local function tick()
if spriteDog.isPaused then return end
local x, y = spriteDog:getPosition()
if x > origin.x + visibleSize.width then
x = origin.x
else
x = x + 1
end
spriteDog:setPositionX(x)
end
schedulerID = cc.Director:getInstance():getScheduler():scheduleScriptFunc(tick, 0, false)
return spriteDog
end
-- create farm
local function createLayerFarm()
local layerFarm = cc.Layer:create()
-- add in farm background
local bg = cc.Sprite:create("farm.jpg")
bg:setPosition(origin.x + visibleSize.width / 2 + 80, origin.y + visibleSize.height / 2)
layerFarm:addChild(bg)
-- add land sprite
for i = 0, 3 do
for j = 0, 1 do
local spriteLand = cc.Sprite:create("land.png")
spriteLand:setPosition(200 + j * 180 - i % 2 * 90, 10 + i * 95 / 2)
layerFarm:addChild(spriteLand)
end
end
-- add crop
local frameCrop = cc.SpriteFrame:create("crop.png", cc.rect(0, 0, 105, 95))
for i = 0, 3 do
for j = 0, 1 do
local spriteCrop = cc.Sprite:createWithSpriteFrame(frameCrop);
spriteCrop:setPosition(10 + 200 + j * 180 - i % 2 * 90, 30 + 10 + i * 95 / 2)
layerFarm:addChild(spriteCrop)
end
end
-- add moving dog
local spriteDog = creatDog()
layerFarm:addChild(spriteDog)
-- handing touch events
local touchBeginPoint = nil
local function onTouchBegan(touch, event)
local location = touch:getLocation()
cclog("onTouchBegan: %0.2f, %0.2f", location.x, location.y)
touchBeginPoint = {x = location.x, y = location.y}
spriteDog.isPaused = true
-- CCTOUCHBEGAN event must return true
return true
end
local function onTouchMoved(touch, event)
local location = touch:getLocation()
cclog("onTouchMoved: %0.2f, %0.2f", location.x, location.y)
if touchBeginPoint then
local cx, cy = layerFarm:getPosition()
layerFarm:setPosition(cx + location.x - touchBeginPoint.x,
cy + location.y - touchBeginPoint.y)
touchBeginPoint = {x = location.x, y = location.y}
end
end
local function onTouchEnded(touch, event)
local location = touch:getLocation()
cclog("onTouchEnded: %0.2f, %0.2f", location.x, location.y)
touchBeginPoint = nil
spriteDog.isPaused = false
end
local listener = cc.EventListenerTouchOneByOne:create()
listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN )
listener:registerScriptHandler(onTouchMoved,cc.Handler.EVENT_TOUCH_MOVED )
listener:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCH_ENDED )
local eventDispatcher = layerFarm:getEventDispatcher()
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, layerFarm)
local function onNodeEvent(event)
if "exit" == event then
cc.Director:getInstance():getScheduler():unscheduleScriptEntry(schedulerID)
end
end
layerFarm:registerScriptHandler(onNodeEvent)
return layerFarm
end
-- create menu
local function createLayerMenu()
local layerMenu = cc.Layer:create()
local menuPopup, menuTools, effectID
local function menuCallbackClosePopup()
-- stop test sound effect
cc.SimpleAudioEngine:getInstance():stopEffect(effectID)
menuPopup:setVisible(false)
end
local function menuCallbackOpenPopup()
-- loop test sound effect
local effectPath = cc.FileUtils:getInstance():fullPathForFilename("effect1.wav")
effectID = cc.SimpleAudioEngine:getInstance():playEffect(effectPath)
menuPopup:setVisible(true)
end
-- add a popup menu
local menuPopupItem = cc.MenuItemImage:create("menu2.png", "menu2.png")
menuPopupItem:setPosition(0, 0)
menuPopupItem:registerScriptTapHandler(menuCallbackClosePopup)
menuPopup = cc.Menu:create(menuPopupItem)
menuPopup:setPosition(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2)
menuPopup:setVisible(false)
layerMenu:addChild(menuPopup)
-- add the left-bottom "tools" menu to invoke menuPopup
local menuToolsItem = cc.MenuItemImage:create("menu1.png", "menu1.png")
menuToolsItem:setPosition(0, 0)
menuToolsItem:registerScriptTapHandler(menuCallbackOpenPopup)
menuTools = cc.Menu:create(menuToolsItem)
local itemWidth = menuToolsItem:getContentSize().width
local itemHeight = menuToolsItem:getContentSize().height
menuTools:setPosition(origin.x + itemWidth/2, origin.y + itemHeight/2)
layerMenu:addChild(menuTools)
return layerMenu
end
-- play background music, preload effect
-- uncomment below for the BlackBerry version
local bgMusicPath = nil
if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) then
bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("res/background.caf")
else
bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("res/background.mp3")
end
cc.SimpleAudioEngine:getInstance():playMusic(bgMusicPath, true)
local effectPath = cc.FileUtils:getInstance():fullPathForFilename("effect1.wav")
cc.SimpleAudioEngine:getInstance():preloadEffect(effectPath)
-- run
local sceneGame = cc.Scene:create()
sceneGame:addChild(createLayerFarm())
sceneGame:addChild(createLayerMenu())
if cc.Director:getInstance():getRunningScene() then
cc.Director:getInstance():replaceScene(sceneGame)
else
cc.Director:getInstance():runWithScene(sceneGame)
end
end
xpcall(main, __G__TRACKBACK__)
| gpl-2.0 |
mattyx14/otxserver | data/monster/demons/askarak_demon.lua | 2 | 3694 | local mType = Game.createMonsterType("Askarak Demon")
local monster = {}
monster.description = "an askarak demon"
monster.experience = 900
monster.outfit = {
lookType = 420,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.raceId = 727
monster.Bestiary = {
class = "Demon",
race = BESTY_RACE_DEMON,
toKill = 1000,
FirstUnlock = 50,
SecondUnlock = 500,
CharmsPoints = 25,
Stars = 3,
Occurrence = 0,
Locations = "Demonwar Crypt (teleporter before vampire shield quest)."
}
monster.health = 1500
monster.maxHealth = 1500
monster.race = "venom"
monster.corpse = 12659
monster.speed = 230
monster.manaCost = 0
monster.changeTarget = {
interval = 4000,
chance = 10
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 80,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = true,
canWalkOnFire = false,
canWalkOnPoison = true
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "DEATH TO THE SHABURAK!", yell = false},
{text = "GREEN WILL RULE!", yell = false},
{text = "ONLY WE ARE TRUE DEMONS!", yell = false},
{text = "RED IS MAD!", yell = false},
{text = "WE RULE!", yell = false}
}
monster.loot = {
{name = "piggy bank", chance = 1052},
{name = "gold coin", chance = 50000, maxCount = 100},
{name = "gold coin", chance = 50000, maxCount = 100},
{name = "gold coin", chance = 40000, maxCount = 35},
{name = "small emerald", chance = 6250, maxCount = 4},
{id = 3051, chance = 961}, -- energy ring
{name = "brown mushroom", chance = 3846, maxCount = 5},
{name = "magic sulphur", chance = 102},
{name = "assassin star", chance = 4761, maxCount = 5},
{name = "mastermind potion", chance = 431},
{name = "strong health potion", chance = 5263},
{name = "strong mana potion", chance = 5263},
{name = "terra legs", chance = 123},
{name = "springsprout rod", chance = 512}
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -143},
{name ="combat", interval = 2000, chance = 20, type = COMBAT_EARTHDAMAGE, minDamage = -20, maxDamage = -60, range = 7, radius = 6, shootEffect = CONST_ANI_POISON, effect = CONST_ME_GREEN_RINGS, target = false},
{name ="askarak wave", interval = 2000, chance = 15, minDamage = -75, maxDamage = -140, target = false},
{name ="combat", interval = 2000, chance = 10, type = COMBAT_EARTHDAMAGE, minDamage = -130, maxDamage = -170, length = 4, spread = 0, effect = CONST_ME_GREEN_RINGS, target = false},
{name ="speed", interval = 2000, chance = 10, speedChange = -600, radius = 1, effect = CONST_ME_MAGIC_RED, target = true, duration = 15000}
}
monster.defenses = {
defense = 15,
armor = 15
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 60},
{type = COMBAT_EARTHDAMAGE, percent = 100},
{type = COMBAT_FIREDAMAGE, percent = -25},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 60},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = -5}
}
monster.immunities = {
{type = "paralyze", condition = true},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
fo369/luci-1505 | modules/luci-base/luasrc/cbi.lua | 3 | 40250 | -- Copyright 2008 Steven Barth <steven@midlink.org>
-- Licensed to the public under the Apache License 2.0.
module("luci.cbi", package.seeall)
require("luci.template")
local util = require("luci.util")
require("luci.http")
--local event = require "luci.sys.event"
local fs = require("nixio.fs")
local uci = require("luci.model.uci")
local datatypes = require("luci.cbi.datatypes")
local dispatcher = require("luci.dispatcher")
local class = util.class
local instanceof = util.instanceof
FORM_NODATA = 0
FORM_PROCEED = 0
FORM_VALID = 1
FORM_DONE = 1
FORM_INVALID = -1
FORM_CHANGED = 2
FORM_SKIP = 4
AUTO = true
CREATE_PREFIX = "cbi.cts."
REMOVE_PREFIX = "cbi.rts."
RESORT_PREFIX = "cbi.sts."
FEXIST_PREFIX = "cbi.cbe."
-- Loads a CBI map from given file, creating an environment and returns it
function load(cbimap, ...)
local fs = require "nixio.fs"
local i18n = require "luci.i18n"
require("luci.config")
require("luci.util")
local upldir = "/lib/uci/upload/"
local cbidir = luci.util.libpath() .. "/model/cbi/"
local func, err
if fs.access(cbidir..cbimap..".lua") then
func, err = loadfile(cbidir..cbimap..".lua")
elseif fs.access(cbimap) then
func, err = loadfile(cbimap)
else
func, err = nil, "Model '" .. cbimap .. "' not found!"
end
assert(func, err)
local env = {
translate=i18n.translate,
translatef=i18n.translatef,
arg={...}
}
setfenv(func, setmetatable(env, {__index =
function(tbl, key)
return rawget(tbl, key) or _M[key] or _G[key]
end}))
local maps = { func() }
local uploads = { }
local has_upload = false
for i, map in ipairs(maps) do
if not instanceof(map, Node) then
error("CBI map returns no valid map object!")
return nil
else
map:prepare()
if map.upload_fields then
has_upload = true
for _, field in ipairs(map.upload_fields) do
uploads[
field.config .. '.' ..
(field.section.sectiontype or '1') .. '.' ..
field.option
] = true
end
end
end
end
if has_upload then
local uci = luci.model.uci.cursor()
local prm = luci.http.context.request.message.params
local fd, cbid
luci.http.setfilehandler(
function( field, chunk, eof )
if not field then return end
if field.name and not cbid then
local c, s, o = field.name:gmatch(
"cbid%.([^%.]+)%.([^%.]+)%.([^%.]+)"
)()
if c and s and o then
local t = uci:get( c, s ) or s
if uploads[c.."."..t.."."..o] then
local path = upldir .. field.name
fd = io.open(path, "w")
if fd then
cbid = field.name
prm[cbid] = path
end
end
end
end
if field.name == cbid and fd then
fd:write(chunk)
end
if eof and fd then
fd:close()
fd = nil
cbid = nil
end
end
)
end
return maps
end
--
-- Compile a datatype specification into a parse tree for evaluation later on
--
local cdt_cache = { }
function compile_datatype(code)
local i
local pos = 0
local esc = false
local depth = 0
local stack = { }
for i = 1, #code+1 do
local byte = code:byte(i) or 44
if esc then
esc = false
elseif byte == 92 then
esc = true
elseif byte == 40 or byte == 44 then
if depth <= 0 then
if pos < i then
local label = code:sub(pos, i-1)
:gsub("\\(.)", "%1")
:gsub("^%s+", "")
:gsub("%s+$", "")
if #label > 0 and tonumber(label) then
stack[#stack+1] = tonumber(label)
elseif label:match("^'.*'$") or label:match('^".*"$') then
stack[#stack+1] = label:gsub("[\"'](.*)[\"']", "%1")
elseif type(datatypes[label]) == "function" then
stack[#stack+1] = datatypes[label]
stack[#stack+1] = { }
else
error("Datatype error, bad token %q" % label)
end
end
pos = i + 1
end
depth = depth + (byte == 40 and 1 or 0)
elseif byte == 41 then
depth = depth - 1
if depth <= 0 then
if type(stack[#stack-1]) ~= "function" then
error("Datatype error, argument list follows non-function")
end
stack[#stack] = compile_datatype(code:sub(pos, i-1))
pos = i + 1
end
end
end
return stack
end
function verify_datatype(dt, value)
if dt and #dt > 0 then
if not cdt_cache[dt] then
local c = compile_datatype(dt)
if c and type(c[1]) == "function" then
cdt_cache[dt] = c
else
error("Datatype error, not a function expression")
end
end
if cdt_cache[dt] then
return cdt_cache[dt][1](value, unpack(cdt_cache[dt][2]))
end
end
return true
end
-- Node pseudo abstract class
Node = class()
function Node.__init__(self, title, description)
self.children = {}
self.title = title or ""
self.description = description or ""
self.template = "cbi/node"
end
-- hook helper
function Node._run_hook(self, hook)
if type(self[hook]) == "function" then
return self[hook](self)
end
end
function Node._run_hooks(self, ...)
local f
local r = false
for _, f in ipairs(arg) do
if type(self[f]) == "function" then
self[f](self)
r = true
end
end
return r
end
-- Prepare nodes
function Node.prepare(self, ...)
for k, child in ipairs(self.children) do
child:prepare(...)
end
end
-- Append child nodes
function Node.append(self, obj)
table.insert(self.children, obj)
end
-- Parse this node and its children
function Node.parse(self, ...)
for k, child in ipairs(self.children) do
child:parse(...)
end
end
-- Render this node
function Node.render(self, scope)
scope = scope or {}
scope.self = self
luci.template.render(self.template, scope)
end
-- Render the children
function Node.render_children(self, ...)
local k, node
for k, node in ipairs(self.children) do
node.last_child = (k == #self.children)
node:render(...)
end
end
--[[
A simple template element
]]--
Template = class(Node)
function Template.__init__(self, template)
Node.__init__(self)
self.template = template
end
function Template.render(self)
luci.template.render(self.template, {self=self})
end
function Template.parse(self, readinput)
self.readinput = (readinput ~= false)
return Map.formvalue(self, "cbi.submit") and FORM_DONE or FORM_NODATA
end
--[[
Map - A map describing a configuration file
]]--
Map = class(Node)
function Map.__init__(self, config, ...)
Node.__init__(self, ...)
self.config = config
self.parsechain = {self.config}
self.template = "cbi/map"
self.apply_on_parse = nil
self.readinput = true
self.proceed = false
self.flow = {}
self.uci = uci.cursor()
self.save = true
self.changed = false
local path = "%s/%s" %{ self.uci:get_confdir(), self.config }
if fs.stat(path, "type") ~= "reg" then
fs.writefile(path, "")
end
local ok, err = self.uci:load(self.config)
if not ok then
local url = dispatcher.build_url(unpack(dispatcher.context.request))
local source = self:formvalue("cbi.source")
if type(source) == "string" then
fs.writefile(path, source:gsub("\r\n", "\n"))
ok, err = self.uci:load(self.config)
if ok then
luci.http.redirect(url)
end
end
self.save = false
end
if not ok then
self.template = "cbi/error"
self.error = err
self.source = fs.readfile(path) or ""
self.pageaction = false
end
end
function Map.formvalue(self, key)
return self.readinput and luci.http.formvalue(key)
end
function Map.formvaluetable(self, key)
return self.readinput and luci.http.formvaluetable(key) or {}
end
function Map.get_scheme(self, sectiontype, option)
if not option then
return self.scheme and self.scheme.sections[sectiontype]
else
return self.scheme and self.scheme.variables[sectiontype]
and self.scheme.variables[sectiontype][option]
end
end
function Map.submitstate(self)
return self:formvalue("cbi.submit")
end
-- Chain foreign config
function Map.chain(self, config)
table.insert(self.parsechain, config)
end
function Map.state_handler(self, state)
return state
end
-- Use optimized UCI writing
function Map.parse(self, readinput, ...)
if self:formvalue("cbi.skip") then
self.state = FORM_SKIP
elseif not self.save then
self.state = FORM_INVALID
elseif not self:submitstate() then
self.state = FORM_NODATA
end
-- Back out early to prevent unauthorized changes on the subsequent parse
if self.state ~= nil then
return self:state_handler(self.state)
end
self.readinput = (readinput ~= false)
self:_run_hooks("on_parse")
Node.parse(self, ...)
self:_run_hooks("on_save", "on_before_save")
for i, config in ipairs(self.parsechain) do
self.uci:save(config)
end
self:_run_hooks("on_after_save")
if (not self.proceed and self.flow.autoapply) or luci.http.formvalue("cbi.apply") then
self:_run_hooks("on_before_commit")
for i, config in ipairs(self.parsechain) do
self.uci:commit(config)
-- Refresh data because commit changes section names
self.uci:load(config)
end
self:_run_hooks("on_commit", "on_after_commit", "on_before_apply")
if self.apply_on_parse then
self.uci:apply(self.parsechain)
self:_run_hooks("on_apply", "on_after_apply")
else
-- This is evaluated by the dispatcher and delegated to the
-- template which in turn fires XHR to perform the actual
-- apply actions.
self.apply_needed = true
end
-- Reparse sections
Node.parse(self, true)
end
for i, config in ipairs(self.parsechain) do
self.uci:unload(config)
end
if type(self.commit_handler) == "function" then
self:commit_handler(self:submitstate())
end
if self.proceed then
self.state = FORM_PROCEED
elseif self.changed then
self.state = FORM_CHANGED
else
self.state = FORM_VALID
end
return self:state_handler(self.state)
end
function Map.render(self, ...)
self:_run_hooks("on_init")
Node.render(self, ...)
end
-- Creates a child section
function Map.section(self, class, ...)
if instanceof(class, AbstractSection) then
local obj = class(self, ...)
self:append(obj)
return obj
else
error("class must be a descendent of AbstractSection")
end
end
-- UCI add
function Map.add(self, sectiontype)
return self.uci:add(self.config, sectiontype)
end
-- UCI set
function Map.set(self, section, option, value)
if type(value) ~= "table" or #value > 0 then
if option then
return self.uci:set(self.config, section, option, value)
else
return self.uci:set(self.config, section, value)
end
else
return Map.del(self, section, option)
end
end
-- UCI del
function Map.del(self, section, option)
if option then
return self.uci:delete(self.config, section, option)
else
return self.uci:delete(self.config, section)
end
end
-- UCI get
function Map.get(self, section, option)
if not section then
return self.uci:get_all(self.config)
elseif option then
return self.uci:get(self.config, section, option)
else
return self.uci:get_all(self.config, section)
end
end
--[[
Compound - Container
]]--
Compound = class(Node)
function Compound.__init__(self, ...)
Node.__init__(self)
self.template = "cbi/compound"
self.children = {...}
end
function Compound.populate_delegator(self, delegator)
for _, v in ipairs(self.children) do
v.delegator = delegator
end
end
function Compound.parse(self, ...)
local cstate, state = 0
for k, child in ipairs(self.children) do
cstate = child:parse(...)
state = (not state or cstate < state) and cstate or state
end
return state
end
--[[
Delegator - Node controller
]]--
Delegator = class(Node)
function Delegator.__init__(self, ...)
Node.__init__(self, ...)
self.nodes = {}
self.defaultpath = {}
self.pageaction = false
self.readinput = true
self.allow_reset = false
self.allow_cancel = false
self.allow_back = false
self.allow_finish = false
self.template = "cbi/delegator"
end
function Delegator.set(self, name, node)
assert(not self.nodes[name], "Duplicate entry")
self.nodes[name] = node
end
function Delegator.add(self, name, node)
node = self:set(name, node)
self.defaultpath[#self.defaultpath+1] = name
end
function Delegator.insert_after(self, name, after)
local n = #self.chain + 1
for k, v in ipairs(self.chain) do
if v == after then
n = k + 1
break
end
end
table.insert(self.chain, n, name)
end
function Delegator.set_route(self, ...)
local n, chain, route = 0, self.chain, {...}
for i = 1, #chain do
if chain[i] == self.current then
n = i
break
end
end
for i = 1, #route do
n = n + 1
chain[n] = route[i]
end
for i = n + 1, #chain do
chain[i] = nil
end
end
function Delegator.get(self, name)
local node = self.nodes[name]
if type(node) == "string" then
node = load(node, name)
end
if type(node) == "table" and getmetatable(node) == nil then
node = Compound(unpack(node))
end
return node
end
function Delegator.parse(self, ...)
if self.allow_cancel and Map.formvalue(self, "cbi.cancel") then
if self:_run_hooks("on_cancel") then
return FORM_DONE
end
end
if not Map.formvalue(self, "cbi.delg.current") then
self:_run_hooks("on_init")
end
local newcurrent
self.chain = self.chain or self:get_chain()
self.current = self.current or self:get_active()
self.active = self.active or self:get(self.current)
assert(self.active, "Invalid state")
local stat = FORM_DONE
if type(self.active) ~= "function" then
self.active:populate_delegator(self)
stat = self.active:parse()
else
self:active()
end
if stat > FORM_PROCEED then
if Map.formvalue(self, "cbi.delg.back") then
newcurrent = self:get_prev(self.current)
else
newcurrent = self:get_next(self.current)
end
elseif stat < FORM_PROCEED then
return stat
end
if not Map.formvalue(self, "cbi.submit") then
return FORM_NODATA
elseif stat > FORM_PROCEED
and (not newcurrent or not self:get(newcurrent)) then
return self:_run_hook("on_done") or FORM_DONE
else
self.current = newcurrent or self.current
self.active = self:get(self.current)
if type(self.active) ~= "function" then
self.active:populate_delegator(self)
local stat = self.active:parse(false)
if stat == FORM_SKIP then
return self:parse(...)
else
return FORM_PROCEED
end
else
return self:parse(...)
end
end
end
function Delegator.get_next(self, state)
for k, v in ipairs(self.chain) do
if v == state then
return self.chain[k+1]
end
end
end
function Delegator.get_prev(self, state)
for k, v in ipairs(self.chain) do
if v == state then
return self.chain[k-1]
end
end
end
function Delegator.get_chain(self)
local x = Map.formvalue(self, "cbi.delg.path") or self.defaultpath
return type(x) == "table" and x or {x}
end
function Delegator.get_active(self)
return Map.formvalue(self, "cbi.delg.current") or self.chain[1]
end
--[[
Page - A simple node
]]--
Page = class(Node)
Page.__init__ = Node.__init__
Page.parse = function() end
--[[
SimpleForm - A Simple non-UCI form
]]--
SimpleForm = class(Node)
function SimpleForm.__init__(self, config, title, description, data)
Node.__init__(self, title, description)
self.config = config
self.data = data or {}
self.template = "cbi/simpleform"
self.dorender = true
self.pageaction = false
self.readinput = true
end
SimpleForm.formvalue = Map.formvalue
SimpleForm.formvaluetable = Map.formvaluetable
function SimpleForm.parse(self, readinput, ...)
self.readinput = (readinput ~= false)
if self:formvalue("cbi.skip") then
return FORM_SKIP
end
if self:formvalue("cbi.cancel") and self:_run_hooks("on_cancel") then
return FORM_DONE
end
if self:submitstate() then
Node.parse(self, 1, ...)
end
local valid = true
for k, j in ipairs(self.children) do
for i, v in ipairs(j.children) do
valid = valid
and (not v.tag_missing or not v.tag_missing[1])
and (not v.tag_invalid or not v.tag_invalid[1])
and (not v.error)
end
end
local state =
not self:submitstate() and FORM_NODATA
or valid and FORM_VALID
or FORM_INVALID
self.dorender = not self.handle
if self.handle then
local nrender, nstate = self:handle(state, self.data)
self.dorender = self.dorender or (nrender ~= false)
state = nstate or state
end
return state
end
function SimpleForm.render(self, ...)
if self.dorender then
Node.render(self, ...)
end
end
function SimpleForm.submitstate(self)
return self:formvalue("cbi.submit")
end
function SimpleForm.section(self, class, ...)
if instanceof(class, AbstractSection) then
local obj = class(self, ...)
self:append(obj)
return obj
else
error("class must be a descendent of AbstractSection")
end
end
-- Creates a child field
function SimpleForm.field(self, class, ...)
local section
for k, v in ipairs(self.children) do
if instanceof(v, SimpleSection) then
section = v
break
end
end
if not section then
section = self:section(SimpleSection)
end
if instanceof(class, AbstractValue) then
local obj = class(self, section, ...)
obj.track_missing = true
section:append(obj)
return obj
else
error("class must be a descendent of AbstractValue")
end
end
function SimpleForm.set(self, section, option, value)
self.data[option] = value
end
function SimpleForm.del(self, section, option)
self.data[option] = nil
end
function SimpleForm.get(self, section, option)
return self.data[option]
end
function SimpleForm.get_scheme()
return nil
end
Form = class(SimpleForm)
function Form.__init__(self, ...)
SimpleForm.__init__(self, ...)
self.embedded = true
end
--[[
AbstractSection
]]--
AbstractSection = class(Node)
function AbstractSection.__init__(self, map, sectiontype, ...)
Node.__init__(self, ...)
self.sectiontype = sectiontype
self.map = map
self.config = map.config
self.optionals = {}
self.defaults = {}
self.fields = {}
self.tag_error = {}
self.tag_invalid = {}
self.tag_deperror = {}
self.changed = false
self.optional = true
self.addremove = false
self.dynamic = false
end
-- Define a tab for the section
function AbstractSection.tab(self, tab, title, desc)
self.tabs = self.tabs or { }
self.tab_names = self.tab_names or { }
self.tab_names[#self.tab_names+1] = tab
self.tabs[tab] = {
title = title,
description = desc,
childs = { }
}
end
-- Check whether the section has tabs
function AbstractSection.has_tabs(self)
return (self.tabs ~= nil) and (next(self.tabs) ~= nil)
end
-- Appends a new option
function AbstractSection.option(self, class, option, ...)
if instanceof(class, AbstractValue) then
local obj = class(self.map, self, option, ...)
self:append(obj)
self.fields[option] = obj
return obj
elseif class == true then
error("No valid class was given and autodetection failed.")
else
error("class must be a descendant of AbstractValue")
end
end
-- Appends a new tabbed option
function AbstractSection.taboption(self, tab, ...)
assert(tab and self.tabs and self.tabs[tab],
"Cannot assign option to not existing tab %q" % tostring(tab))
local l = self.tabs[tab].childs
local o = AbstractSection.option(self, ...)
if o then l[#l+1] = o end
return o
end
-- Render a single tab
function AbstractSection.render_tab(self, tab, ...)
assert(tab and self.tabs and self.tabs[tab],
"Cannot render not existing tab %q" % tostring(tab))
local k, node
for k, node in ipairs(self.tabs[tab].childs) do
node.last_child = (k == #self.tabs[tab].childs)
node:render(...)
end
end
-- Parse optional options
function AbstractSection.parse_optionals(self, section)
if not self.optional then
return
end
self.optionals[section] = {}
local field = self.map:formvalue("cbi.opt."..self.config.."."..section)
for k,v in ipairs(self.children) do
if v.optional and not v:cfgvalue(section) and not self:has_tabs() then
if field == v.option then
field = nil
self.map.proceed = true
else
table.insert(self.optionals[section], v)
end
end
end
if field and #field > 0 and self.dynamic then
self:add_dynamic(field)
end
end
-- Add a dynamic option
function AbstractSection.add_dynamic(self, field, optional)
local o = self:option(Value, field, field)
o.optional = optional
end
-- Parse all dynamic options
function AbstractSection.parse_dynamic(self, section)
if not self.dynamic then
return
end
local arr = luci.util.clone(self:cfgvalue(section))
local form = self.map:formvaluetable("cbid."..self.config.."."..section)
for k, v in pairs(form) do
arr[k] = v
end
for key,val in pairs(arr) do
local create = true
for i,c in ipairs(self.children) do
if c.option == key then
create = false
end
end
if create and key:sub(1, 1) ~= "." then
self.map.proceed = true
self:add_dynamic(key, true)
end
end
end
-- Returns the section's UCI table
function AbstractSection.cfgvalue(self, section)
return self.map:get(section)
end
-- Push events
function AbstractSection.push_events(self)
--luci.util.append(self.map.events, self.events)
self.map.changed = true
end
-- Removes the section
function AbstractSection.remove(self, section)
self.map.proceed = true
return self.map:del(section)
end
-- Creates the section
function AbstractSection.create(self, section)
local stat
if section then
stat = section:match("^[%w_]+$") and self.map:set(section, nil, self.sectiontype)
else
section = self.map:add(self.sectiontype)
stat = section
end
if stat then
for k,v in pairs(self.children) do
if v.default then
self.map:set(section, v.option, v.default)
end
end
for k,v in pairs(self.defaults) do
self.map:set(section, k, v)
end
end
self.map.proceed = true
return stat
end
SimpleSection = class(AbstractSection)
function SimpleSection.__init__(self, form, ...)
AbstractSection.__init__(self, form, nil, ...)
self.template = "cbi/nullsection"
end
Table = class(AbstractSection)
function Table.__init__(self, form, data, ...)
local datasource = {}
local tself = self
datasource.config = "table"
self.data = data or {}
datasource.formvalue = Map.formvalue
datasource.formvaluetable = Map.formvaluetable
datasource.readinput = true
function datasource.get(self, section, option)
return tself.data[section] and tself.data[section][option]
end
function datasource.submitstate(self)
return Map.formvalue(self, "cbi.submit")
end
function datasource.del(...)
return true
end
function datasource.get_scheme()
return nil
end
AbstractSection.__init__(self, datasource, "table", ...)
self.template = "cbi/tblsection"
self.rowcolors = true
self.anonymous = true
end
function Table.parse(self, readinput)
self.map.readinput = (readinput ~= false)
for i, k in ipairs(self:cfgsections()) do
if self.map:submitstate() then
Node.parse(self, k)
end
end
end
function Table.cfgsections(self)
local sections = {}
for i, v in luci.util.kspairs(self.data) do
table.insert(sections, i)
end
return sections
end
function Table.update(self, data)
self.data = data
end
--[[
NamedSection - A fixed configuration section defined by its name
]]--
NamedSection = class(AbstractSection)
function NamedSection.__init__(self, map, section, stype, ...)
AbstractSection.__init__(self, map, stype, ...)
-- Defaults
self.addremove = false
self.template = "cbi/nsection"
self.section = section
end
function NamedSection.parse(self, novld)
local s = self.section
local active = self:cfgvalue(s)
if self.addremove then
local path = self.config.."."..s
if active then -- Remove the section
if self.map:formvalue("cbi.rns."..path) and self:remove(s) then
self:push_events()
return
end
else -- Create and apply default values
if self.map:formvalue("cbi.cns."..path) then
self:create(s)
return
end
end
end
if active then
AbstractSection.parse_dynamic(self, s)
if self.map:submitstate() then
Node.parse(self, s)
end
AbstractSection.parse_optionals(self, s)
if self.changed then
self:push_events()
end
end
end
--[[
TypedSection - A (set of) configuration section(s) defined by the type
addremove: Defines whether the user can add/remove sections of this type
anonymous: Allow creating anonymous sections
validate: a validation function returning nil if the section is invalid
]]--
TypedSection = class(AbstractSection)
function TypedSection.__init__(self, map, type, ...)
AbstractSection.__init__(self, map, type, ...)
self.template = "cbi/tsection"
self.deps = {}
self.anonymous = false
end
-- Return all matching UCI sections for this TypedSection
function TypedSection.cfgsections(self)
local sections = {}
self.map.uci:foreach(self.map.config, self.sectiontype,
function (section)
if self:checkscope(section[".name"]) then
table.insert(sections, section[".name"])
end
end)
return sections
end
-- Limits scope to sections that have certain option => value pairs
function TypedSection.depends(self, option, value)
table.insert(self.deps, {option=option, value=value})
end
function TypedSection.parse(self, novld)
if self.addremove then
-- Remove
local crval = REMOVE_PREFIX .. self.config
local name = self.map:formvaluetable(crval)
for k,v in pairs(name) do
if k:sub(-2) == ".x" then
k = k:sub(1, #k - 2)
end
if self:cfgvalue(k) and self:checkscope(k) then
self:remove(k)
end
end
end
local co
for i, k in ipairs(self:cfgsections()) do
AbstractSection.parse_dynamic(self, k)
if self.map:submitstate() then
Node.parse(self, k, novld)
end
AbstractSection.parse_optionals(self, k)
end
if self.addremove then
-- Create
local created
local crval = CREATE_PREFIX .. self.config .. "." .. self.sectiontype
local origin, name = next(self.map:formvaluetable(crval))
if self.anonymous then
if name then
created = self:create(nil, origin)
end
else
if name then
-- Ignore if it already exists
if self:cfgvalue(name) then
name = nil;
end
name = self:checkscope(name)
if not name then
self.err_invalid = true
end
if name and #name > 0 then
created = self:create(name, origin) and name
if not created then
self.invalid_cts = true
end
end
end
end
if created then
AbstractSection.parse_optionals(self, created)
end
end
if self.sortable then
local stval = RESORT_PREFIX .. self.config .. "." .. self.sectiontype
local order = self.map:formvalue(stval)
if order and #order > 0 then
local sid
local num = 0
for sid in util.imatch(order) do
self.map.uci:reorder(self.config, sid, num)
num = num + 1
end
self.changed = (num > 0)
end
end
if created or self.changed then
self:push_events()
end
end
-- Verifies scope of sections
function TypedSection.checkscope(self, section)
-- Check if we are not excluded
if self.filter and not self:filter(section) then
return nil
end
-- Check if at least one dependency is met
if #self.deps > 0 and self:cfgvalue(section) then
local stat = false
for k, v in ipairs(self.deps) do
if self:cfgvalue(section)[v.option] == v.value then
stat = true
end
end
if not stat then
return nil
end
end
return self:validate(section)
end
-- Dummy validate function
function TypedSection.validate(self, section)
return section
end
--[[
AbstractValue - An abstract Value Type
null: Value can be empty
valid: A function returning the value if it is valid otherwise nil
depends: A table of option => value pairs of which one must be true
default: The default value
size: The size of the input fields
rmempty: Unset value if empty
optional: This value is optional (see AbstractSection.optionals)
]]--
AbstractValue = class(Node)
function AbstractValue.__init__(self, map, section, option, ...)
Node.__init__(self, ...)
self.section = section
self.option = option
self.map = map
self.config = map.config
self.tag_invalid = {}
self.tag_missing = {}
self.tag_reqerror = {}
self.tag_error = {}
self.deps = {}
self.subdeps = {}
--self.cast = "string"
self.track_missing = false
self.rmempty = true
self.default = nil
self.size = nil
self.optional = false
end
function AbstractValue.prepare(self)
self.cast = self.cast or "string"
end
-- Add a dependencie to another section field
function AbstractValue.depends(self, field, value)
local deps
if type(field) == "string" then
deps = {}
deps[field] = value
else
deps = field
end
table.insert(self.deps, {deps=deps, add=""})
end
-- Generates the unique CBID
function AbstractValue.cbid(self, section)
return "cbid."..self.map.config.."."..section.."."..self.option
end
-- Return whether this object should be created
function AbstractValue.formcreated(self, section)
local key = "cbi.opt."..self.config.."."..section
return (self.map:formvalue(key) == self.option)
end
-- Returns the formvalue for this object
function AbstractValue.formvalue(self, section)
return self.map:formvalue(self:cbid(section))
end
function AbstractValue.additional(self, value)
self.optional = value
end
function AbstractValue.mandatory(self, value)
self.rmempty = not value
end
function AbstractValue.add_error(self, section, type, msg)
self.error = self.error or { }
self.error[section] = msg or type
self.section.error = self.section.error or { }
self.section.error[section] = self.section.error[section] or { }
table.insert(self.section.error[section], msg or type)
if type == "invalid" then
self.tag_invalid[section] = true
elseif type == "missing" then
self.tag_missing[section] = true
end
self.tag_error[section] = true
self.map.save = false
end
function AbstractValue.parse(self, section, novld)
local fvalue = self:formvalue(section)
local cvalue = self:cfgvalue(section)
-- If favlue and cvalue are both tables and have the same content
-- make them identical
if type(fvalue) == "table" and type(cvalue) == "table" then
local equal = #fvalue == #cvalue
if equal then
for i=1, #fvalue do
if cvalue[i] ~= fvalue[i] then
equal = false
end
end
end
if equal then
fvalue = cvalue
end
end
if fvalue and #fvalue > 0 then -- If we have a form value, write it to UCI
local val_err
fvalue, val_err = self:validate(fvalue, section)
fvalue = self:transform(fvalue)
if not fvalue and not novld then
self:add_error(section, "invalid", val_err)
end
if fvalue and (self.forcewrite or not (fvalue == cvalue)) then
if self:write(section, fvalue) then
-- Push events
self.section.changed = true
--luci.util.append(self.map.events, self.events)
end
end
else -- Unset the UCI or error
if self.rmempty or self.optional then
if self:remove(section) then
-- Push events
self.section.changed = true
--luci.util.append(self.map.events, self.events)
end
elseif cvalue ~= fvalue and not novld then
-- trigger validator with nil value to get custom user error msg.
local _, val_err = self:validate(nil, section)
self:add_error(section, "missing", val_err)
end
end
end
-- Render if this value exists or if it is mandatory
function AbstractValue.render(self, s, scope)
if not self.optional or self.section:has_tabs() or self:cfgvalue(s) or self:formcreated(s) then
scope = scope or {}
scope.section = s
scope.cbid = self:cbid(s)
Node.render(self, scope)
end
end
-- Return the UCI value of this object
function AbstractValue.cfgvalue(self, section)
local value
if self.tag_error[section] then
value = self:formvalue(section)
else
value = self.map:get(section, self.option)
end
if not value then
return nil
elseif not self.cast or self.cast == type(value) then
return value
elseif self.cast == "string" then
if type(value) == "table" then
return value[1]
end
elseif self.cast == "table" then
return { value }
end
end
-- Validate the form value
function AbstractValue.validate(self, value)
if self.datatype and value then
if type(value) == "table" then
local v
for _, v in ipairs(value) do
if v and #v > 0 and not verify_datatype(self.datatype, v) then
return nil
end
end
else
if not verify_datatype(self.datatype, value) then
return nil
end
end
end
return value
end
AbstractValue.transform = AbstractValue.validate
-- Write to UCI
function AbstractValue.write(self, section, value)
return self.map:set(section, self.option, value)
end
-- Remove from UCI
function AbstractValue.remove(self, section)
return self.map:del(section, self.option)
end
--[[
Value - A one-line value
maxlength: The maximum length
]]--
Value = class(AbstractValue)
function Value.__init__(self, ...)
AbstractValue.__init__(self, ...)
self.template = "cbi/value"
self.keylist = {}
self.vallist = {}
end
function Value.reset_values(self)
self.keylist = {}
self.vallist = {}
end
function Value.value(self, key, val)
val = val or key
table.insert(self.keylist, tostring(key))
table.insert(self.vallist, tostring(val))
end
-- DummyValue - This does nothing except being there
DummyValue = class(AbstractValue)
function DummyValue.__init__(self, ...)
AbstractValue.__init__(self, ...)
self.template = "cbi/dvalue"
self.value = nil
end
function DummyValue.cfgvalue(self, section)
local value
if self.value then
if type(self.value) == "function" then
value = self:value(section)
else
value = self.value
end
else
value = AbstractValue.cfgvalue(self, section)
end
return value
end
function DummyValue.parse(self)
end
--[[
Flag - A flag being enabled or disabled
]]--
Flag = class(AbstractValue)
function Flag.__init__(self, ...)
AbstractValue.__init__(self, ...)
self.template = "cbi/fvalue"
self.enabled = "1"
self.disabled = "0"
self.default = self.disabled
end
-- A flag can only have two states: set or unset
function Flag.parse(self, section)
local fexists = self.map:formvalue(
FEXIST_PREFIX .. self.config .. "." .. section .. "." .. self.option)
if fexists then
local fvalue = self:formvalue(section) and self.enabled or self.disabled
local cvalue = self:cfgvalue(section)
if fvalue ~= self.default or (not self.optional and not self.rmempty) then
self:write(section, fvalue)
else
self:remove(section)
end
if (fvalue ~= cvalue) then self.section.changed = true end
else
self:remove(section)
self.section.changed = true
end
end
function Flag.cfgvalue(self, section)
return AbstractValue.cfgvalue(self, section) or self.default
end
--[[
ListValue - A one-line value predefined in a list
widget: The widget that will be used (select, radio)
]]--
ListValue = class(AbstractValue)
function ListValue.__init__(self, ...)
AbstractValue.__init__(self, ...)
self.template = "cbi/lvalue"
self.keylist = {}
self.vallist = {}
self.size = 1
self.widget = "select"
end
function ListValue.reset_values(self)
self.keylist = {}
self.vallist = {}
end
function ListValue.value(self, key, val, ...)
if luci.util.contains(self.keylist, key) then
return
end
val = val or key
table.insert(self.keylist, tostring(key))
table.insert(self.vallist, tostring(val))
for i, deps in ipairs({...}) do
self.subdeps[#self.subdeps + 1] = {add = "-"..key, deps=deps}
end
end
function ListValue.validate(self, val)
if luci.util.contains(self.keylist, val) then
return val
else
return nil
end
end
--[[
MultiValue - Multiple delimited values
widget: The widget that will be used (select, checkbox)
delimiter: The delimiter that will separate the values (default: " ")
]]--
MultiValue = class(AbstractValue)
function MultiValue.__init__(self, ...)
AbstractValue.__init__(self, ...)
self.template = "cbi/mvalue"
self.keylist = {}
self.vallist = {}
self.widget = "checkbox"
self.delimiter = " "
end
function MultiValue.render(self, ...)
if self.widget == "select" and not self.size then
self.size = #self.vallist
end
AbstractValue.render(self, ...)
end
function MultiValue.reset_values(self)
self.keylist = {}
self.vallist = {}
end
function MultiValue.value(self, key, val)
if luci.util.contains(self.keylist, key) then
return
end
val = val or key
table.insert(self.keylist, tostring(key))
table.insert(self.vallist, tostring(val))
end
function MultiValue.valuelist(self, section)
local val = self:cfgvalue(section)
if not(type(val) == "string") then
return {}
end
return luci.util.split(val, self.delimiter)
end
function MultiValue.validate(self, val)
val = (type(val) == "table") and val or {val}
local result
for i, value in ipairs(val) do
if luci.util.contains(self.keylist, value) then
result = result and (result .. self.delimiter .. value) or value
end
end
return result
end
StaticList = class(MultiValue)
function StaticList.__init__(self, ...)
MultiValue.__init__(self, ...)
self.cast = "table"
self.valuelist = self.cfgvalue
if not self.override_scheme
and self.map:get_scheme(self.section.sectiontype, self.option) then
local vs = self.map:get_scheme(self.section.sectiontype, self.option)
if self.value and vs.values and not self.override_values then
for k, v in pairs(vs.values) do
self:value(k, v)
end
end
end
end
function StaticList.validate(self, value)
value = (type(value) == "table") and value or {value}
local valid = {}
for i, v in ipairs(value) do
if luci.util.contains(self.keylist, v) then
table.insert(valid, v)
end
end
return valid
end
DynamicList = class(AbstractValue)
function DynamicList.__init__(self, ...)
AbstractValue.__init__(self, ...)
self.template = "cbi/dynlist"
self.cast = "table"
self.keylist = {}
self.vallist = {}
end
function DynamicList.reset_values(self)
self.keylist = {}
self.vallist = {}
end
function DynamicList.value(self, key, val)
val = val or key
table.insert(self.keylist, tostring(key))
table.insert(self.vallist, tostring(val))
end
function DynamicList.write(self, section, value)
local t = { }
if type(value) == "table" then
local x
for _, x in ipairs(value) do
if x and #x > 0 then
t[#t+1] = x
end
end
else
t = { value }
end
if self.cast == "string" then
value = table.concat(t, " ")
else
value = t
end
return AbstractValue.write(self, section, value)
end
function DynamicList.cfgvalue(self, section)
local value = AbstractValue.cfgvalue(self, section)
if type(value) == "string" then
local x
local t = { }
for x in value:gmatch("%S+") do
if #x > 0 then
t[#t+1] = x
end
end
value = t
end
return value
end
function DynamicList.formvalue(self, section)
local value = AbstractValue.formvalue(self, section)
if type(value) == "string" then
if self.cast == "string" then
local x
local t = { }
for x in value:gmatch("%S+") do
t[#t+1] = x
end
value = t
else
value = { value }
end
end
return value
end
--[[
TextValue - A multi-line value
rows: Rows
]]--
TextValue = class(AbstractValue)
function TextValue.__init__(self, ...)
AbstractValue.__init__(self, ...)
self.template = "cbi/tvalue"
end
--[[
Button
]]--
Button = class(AbstractValue)
function Button.__init__(self, ...)
AbstractValue.__init__(self, ...)
self.template = "cbi/button"
self.inputstyle = nil
self.rmempty = true
end
FileUpload = class(AbstractValue)
function FileUpload.__init__(self, ...)
AbstractValue.__init__(self, ...)
self.template = "cbi/upload"
if not self.map.upload_fields then
self.map.upload_fields = { self }
else
self.map.upload_fields[#self.map.upload_fields+1] = self
end
end
function FileUpload.formcreated(self, section)
return AbstractValue.formcreated(self, section) or
self.map:formvalue("cbi.rlf."..section.."."..self.option) or
self.map:formvalue("cbi.rlf."..section.."."..self.option..".x")
end
function FileUpload.cfgvalue(self, section)
local val = AbstractValue.cfgvalue(self, section)
if val and fs.access(val) then
return val
end
return nil
end
function FileUpload.formvalue(self, section)
local val = AbstractValue.formvalue(self, section)
if val then
if not self.map:formvalue("cbi.rlf."..section.."."..self.option) and
not self.map:formvalue("cbi.rlf."..section.."."..self.option..".x")
then
return val
end
fs.unlink(val)
self.value = nil
end
return nil
end
function FileUpload.remove(self, section)
local val = AbstractValue.formvalue(self, section)
if val and fs.access(val) then fs.unlink(val) end
return AbstractValue.remove(self, section)
end
FileBrowser = class(AbstractValue)
function FileBrowser.__init__(self, ...)
AbstractValue.__init__(self, ...)
self.template = "cbi/browser"
end
| apache-2.0 |
MRAHS/Backup | plugins/ingroup.lua | 527 | 44020 | do
-- Check Member
local function check_member_autorealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Realm',
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes'
}
}
save_data(_config.moderation.data, data)
local realms = 'realms'
if not data[tostring(realms)] then
data[tostring(realms)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(realms)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Welcome to your new realm !')
end
end
end
local function check_member_realm_add(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Realm',
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes'
}
}
save_data(_config.moderation.data, data)
local realms = 'realms'
if not data[tostring(realms)] then
data[tostring(realms)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(realms)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Realm has been added!')
end
end
end
function check_member_group(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Group',
moderators = {},
set_owner = member_id ,
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes',
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'You have been promoted as the owner.')
end
end
end
local function check_member_modadd(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Group',
moderators = {},
set_owner = member_id ,
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes',
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Group is added and you have been promoted as the owner ')
end
end
end
local function automodadd(msg)
local data = load_data(_config.moderation.data)
if msg.action.type == 'chat_created' then
receiver = get_receiver(msg)
chat_info(receiver, check_member_group,{receiver=receiver, data=data, msg = msg})
end
end
local function autorealmadd(msg)
local data = load_data(_config.moderation.data)
if msg.action.type == 'chat_created' then
receiver = get_receiver(msg)
chat_info(receiver, check_member_autorealm,{receiver=receiver, data=data, msg = msg})
end
end
local function check_member_realmrem(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Realm configuration removal
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local realms = 'realms'
if not data[tostring(realms)] then
data[tostring(realms)] = nil
save_data(_config.moderation.data, data)
end
data[tostring(realms)][tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Realm has been removed!')
end
end
end
local function check_member_modrem(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration removal
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = nil
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Group has been removed')
end
end
end
--End Check Member
local function show_group_settingsmod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['settings']['flood_msg_max'] then
NUM_MSG_MAX = tonumber(data[tostring(msg.to.id)]['settings']['flood_msg_max'])
print('custom'..NUM_MSG_MAX)
else
NUM_MSG_MAX = 5
end
end
local bots_protection = "Yes"
if data[tostring(msg.to.id)]['settings']['lock_bots'] then
bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots']
end
local leave_ban = "no"
if data[tostring(msg.to.id)]['settings']['leave_ban'] then
leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban']
end
local settings = data[tostring(target)]['settings']
local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nLock group leave : "..leave_ban.."\nflood sensitivity : "..NUM_MSG_MAX.."\nBot protection : "..bots_protection--"\nPublic: "..public
return text
end
local function set_descriptionmod(msg, data, target, about)
if not is_momod(msg) then
return "For moderators only!"
end
local data_cat = 'description'
data[tostring(target)][data_cat] = about
save_data(_config.moderation.data, data)
return 'Set group description to:\n'..about
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]
local about = string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about
return 'About '..about
end
local function lock_group_arabic(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'yes' then
return 'Arabic is already locked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'yes'
save_data(_config.moderation.data, data)
return 'Arabic has been locked'
end
end
local function unlock_group_arabic(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'no' then
return 'Arabic is already unlocked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'no'
save_data(_config.moderation.data, data)
return 'Arabic has been unlocked'
end
end
local function lock_group_bots(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'yes' then
return 'Bots protection is already enabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'yes'
save_data(_config.moderation.data, data)
return 'Bots protection has been enabled'
end
end
local function unlock_group_bots(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'no' then
return 'Bots protection is already disabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'no'
save_data(_config.moderation.data, data)
return 'Bots protection has been disabled'
end
end
local function lock_group_namemod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'yes' then
return 'Group name is already locked'
else
data[tostring(target)]['settings']['lock_name'] = 'yes'
save_data(_config.moderation.data, data)
rename_chat('chat#id'..target, group_name_set, ok_cb, false)
return 'Group name has been locked'
end
end
local function unlock_group_namemod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'no' then
return 'Group name is already unlocked'
else
data[tostring(target)]['settings']['lock_name'] = 'no'
save_data(_config.moderation.data, data)
return 'Group name has been unlocked'
end
end
local function lock_group_floodmod(msg, data, target)
if not is_owner(msg) then
return "Only admins can do it for now"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'yes' then
return 'Group flood is locked'
else
data[tostring(target)]['settings']['flood'] = 'yes'
save_data(_config.moderation.data, data)
return 'Group flood has been locked'
end
end
local function unlock_group_floodmod(msg, data, target)
if not is_owner(msg) then
return "Only admins can do it for now"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'no' then
return 'Group flood is not locked'
else
data[tostring(target)]['settings']['flood'] = 'no'
save_data(_config.moderation.data, data)
return 'Group flood has been unlocked'
end
end
local function lock_group_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'yes' then
return 'Group members are already locked'
else
data[tostring(target)]['settings']['lock_member'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group members has been locked'
end
local function unlock_group_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'no' then
return 'Group members are not locked'
else
data[tostring(target)]['settings']['lock_member'] = 'no'
save_data(_config.moderation.data, data)
return 'Group members has been unlocked'
end
end
local function set_public_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['public']
if group_member_lock == 'yes' then
return 'Group is already public'
else
data[tostring(target)]['settings']['public'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group is now: public'
end
local function unset_public_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['public']
if group_member_lock == 'no' then
return 'Group is not public'
else
data[tostring(target)]['settings']['public'] = 'no'
save_data(_config.moderation.data, data)
return 'Group is now: not public'
end
end
local function lock_group_leave(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban']
if leave_ban == 'yes' then
return 'Leaving users will be banned'
else
data[tostring(msg.to.id)]['settings']['leave_ban'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Leaving users will be banned'
end
local function unlock_group_leave(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban']
if leave_ban == 'no' then
return 'Leaving users will not be banned'
else
data[tostring(msg.to.id)]['settings']['leave_ban'] = 'no'
save_data(_config.moderation.data, data)
return 'Leaving users will not be banned'
end
end
local function unlock_group_photomod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'no' then
return 'Group photo is not locked'
else
data[tostring(target)]['settings']['lock_photo'] = 'no'
save_data(_config.moderation.data, data)
return 'Group photo has been unlocked'
end
end
local function set_rulesmod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local data_cat = 'rules'
data[tostring(target)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..rules
end
local function modadd(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if is_group(msg) then
return 'Group is already added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_modadd,{receiver=receiver, data=data, msg = msg})
end
local function realmadd(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if is_realm(msg) then
return 'Realm is already added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_realm_add,{receiver=receiver, data=data, msg = msg})
end
-- Global functions
function modrem(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if not is_group(msg) then
return 'Group is not added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_modrem,{receiver=receiver, data=data, msg = msg})
end
function realmrem(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if not is_realm(msg) then
return 'Realm is not added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_realmrem,{receiver=receiver, data=data, msg = msg})
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 = 'Chat rules:\n'..rules
return rules
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
local function promote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'chat#id', '')
if not data[group] then
return send_large_msg(receiver, 'Group is not added.')
end
if data[group]['moderators'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is already a moderator.')
end
data[group]['moderators'][tostring(member_id)] = member_username
save_data(_config.moderation.data, data)
return send_large_msg(receiver, member_username..' has been promoted.')
end
local function promote_by_reply(extra, success, result)
local msg = result
local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '')
if msg.from.username then
member_username = '@'.. msg.from.username
else
member_username = full_name
end
local member_id = msg.from.id
if msg.to.type == 'chat' then
return promote(get_receiver(msg), member_username, member_id)
end
end
local function demote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'chat#id', '')
if not data[group] then
return send_large_msg(receiver, 'Group is not added.')
end
if not data[group]['moderators'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is not a moderator.')
end
data[group]['moderators'][tostring(member_id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, member_username..' has been demoted.')
end
local function demote_by_reply(extra, success, result)
local msg = result
local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '')
if msg.from.username then
member_username = '@'..msg.from.username
else
member_username = full_name
end
local member_id = msg.from.id
if msg.to.type == 'chat' then
return demote(get_receiver(msg), member_username, member_id)
end
end
local function setowner_by_reply(extra, success, result)
local msg = result
local receiver = get_receiver(msg)
local data = load_data(_config.moderation.data)
local name_log = msg.from.print_name:gsub("_", " ")
data[tostring(msg.to.id)]['set_owner'] = tostring(msg.from.id)
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] setted ["..msg.from.id.."] as owner")
local text = msg.from.print_name:gsub("_", " ").." is the owner now"
return send_large_msg(receiver, text)
end
local function promote_demote_res(extra, success, result)
--vardump(result)
--vardump(extra)
local member_id = result.id
local member_username = "@"..result.username
local chat_id = extra.chat_id
local mod_cmd = extra.mod_cmd
local receiver = "chat#id"..chat_id
if mod_cmd == 'promote' then
return promote(receiver, member_username, member_id)
elseif mod_cmd == 'demote' then
return demote(receiver, member_username, member_id)
end
end
local function modlist(msg)
local data = load_data(_config.moderation.data)
local groups = "groups"
if not data[tostring(groups)][tostring(msg.to.id)] then
return 'Group is not added.'
end
-- determine if table is empty
if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way
return 'No moderator in this group.'
end
local i = 1
local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
message = message ..i..' - '..v..' [' ..k.. '] \n'
i = i + 1
end
return message
end
local function callbackres(extra, success, result)
--vardump(result)
local user = result.id
local name = string.gsub(result.print_name, "_", " ")
local chat = 'chat#id'..extra.chatid
send_large_msg(chat, user..'\n'..name)
return user
end
local function help()
local help_text = tostring(_config.help_text)
return help_text
end
local function cleanmember(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user(v.id, result.id)
end
end
local function killchat(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function killrealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function user_msgs(user_id, chat_id)
local user_info
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..user_id..':'..chat_id
user_info = tonumber(redis:get(um_hash) or 0)
return user_info
end
local function kick_zero(cb_extra, success, result)
local chat_id = cb_extra.chat_id
local chat = "chat#id"..chat_id
local ci_user
local re_user
for k,v in pairs(result.members) do
local si = false
ci_user = v.id
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
for i = 1, #users do
re_user = users[i]
if tonumber(ci_user) == tonumber(re_user) then
si = true
end
end
if not si then
if ci_user ~= our_id then
if not is_momod2(ci_user, chat_id) then
chat_del_user(chat, 'user#id'..ci_user, ok_cb, true)
end
end
end
end
end
local function kick_inactive(chat_id, num, receiver)
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = user_msgs(user_id, chat_id)
local nmsg = user_info
if tonumber(nmsg) < tonumber(num) then
if not is_momod2(user_id, chat_id) then
chat_del_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, true)
end
end
end
return chat_info(receiver, kick_zero, {chat_id = chat_id})
end
local function run(msg, matches)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
local name_log = user_print_name(msg.from)
local group = msg.to.id
if msg.media then
if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_chat_msg(msg) and is_momod(msg) then
load_photo(msg.id, set_group_photo, msg)
end
end
if matches[1] == 'add' and not matches[2] then
if is_realm(msg) then
return 'Error: Already a realm.'
end
print("group "..msg.to.print_name.."("..msg.to.id..") added")
return modadd(msg)
end
if matches[1] == 'add' and matches[2] == 'realm' then
if is_group(msg) then
return 'Error: Already a group.'
end
print("group "..msg.to.print_name.."("..msg.to.id..") added as a realm")
return realmadd(msg)
end
if matches[1] == 'rem' and not matches[2] then
print("group "..msg.to.print_name.."("..msg.to.id..") removed")
return modrem(msg)
end
if matches[1] == 'rem' and matches[2] == 'realm' then
print("group "..msg.to.print_name.."("..msg.to.id..") removed as a realm")
return realmrem(msg)
end
if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "group" then
return automodadd(msg)
end
if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "realm" then
return autorealmadd(msg)
end
if msg.to.id and data[tostring(msg.to.id)] then
local settings = data[tostring(msg.to.id)]['settings']
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 user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if group_member_lock == 'yes' and not is_owner2(msg.action.user.id, msg.to.id) then
chat_del_user(chat, user, ok_cb, true)
elseif group_member_lock == 'yes' and tonumber(msg.from.id) == tonumber(our_id) then
return nil
elseif group_member_lock == 'no' then
return nil
end
end
if matches[1] == 'chat_del_user' then
if not msg.service then
-- return "Are you trying to troll me?"
end
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..user)
end
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
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:incr(picturehash)
---
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
local picprotectionredis = redis:get(picturehash)
if picprotectionredis then
if tonumber(picprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(picprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:set(picturehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to deleted picture but failed ")
chat_set_photo(receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
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
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:incr(picturehash)
---
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
local picprotectionredis = redis:get(picturehash)
if picprotectionredis then
if tonumber(picprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(picprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:set(picturehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change picture but failed ")
chat_set_photo(receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
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
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
redis:incr(namehash)
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
local nameprotectionredis = redis:get(namehash)
if nameprotectionredis then
if tonumber(nameprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(nameprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
redis:set(namehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change name but failed ")
rename_chat(to_rename, group_name_set, ok_cb, false)
end
elseif group_name_lock == 'no' then
return nil
end
end
if matches[1] == 'setname' and is_momod(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)
savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
if matches[1] == 'setphoto' and is_momod(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 matches[1] == 'promote' and not matches[2] then
if not is_owner(msg) then
return "Only the owner can prmote new moderators"
end
if type(msg.reply_id)~="nil" then
msgr = get_message(msg.reply_id, promote_by_reply, false)
end
end
if matches[1] == 'promote' and matches[2] then
if not is_momod(msg) then
return
end
if not is_owner(msg) then
return "Only owner can promote"
end
local member = matches[2]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @".. member)
local cbres_extra = {
chat_id = msg.to.id,
mod_cmd = 'promote',
from_id = msg.from.id
}
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
return res_user(username, promote_demote_res, cbres_extra)
end
if matches[1] == 'demote' and not matches[2] then
if not is_owner(msg) then
return "Only the owner can demote moderators"
end
if type(msg.reply_id)~="nil" then
msgr = get_message(msg.reply_id, demote_by_reply, false)
end
end
if matches[1] == 'demote' and matches[2] then
if not is_momod(msg) then
return
end
if not is_owner(msg) then
return "Only owner can demote"
end
if string.gsub(matches[2], "@", "") == msg.from.username and not is_owner(msg) then
return "You can't demote yourself"
end
local member = matches[2]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @".. member)
local cbres_extra = {
chat_id = msg.to.id,
mod_cmd = 'demote',
from_id = msg.from.id
}
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
return res_user(username, promote_demote_res, cbres_extra)
end
if matches[1] == 'modlist' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist")
return modlist(msg)
end
if matches[1] == 'about' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group description")
return get_description(msg, data)
end
if matches[1] == 'rules' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group rules")
return get_rules(msg, data)
end
if matches[1] == 'set' then
if matches[2] == 'rules' then
rules = matches[3]
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[3].."]")
return set_rulesmod(msg, data, target)
end
if matches[2] == 'about' then
local data = load_data(_config.moderation.data)
local target = msg.to.id
local about = matches[3]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group description to ["..matches[3].."]")
return set_descriptionmod(msg, data, target, about)
end
end
if matches[1] == 'lock' then
local target = msg.to.id
if matches[2] == 'name' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked name ")
return lock_group_namemod(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ")
return lock_group_membermod(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ")
return lock_group_floodmod(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ")
return lock_group_arabic(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots ")
return lock_group_bots(msg, data, target)
end
if matches[2] == 'leave' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked leaving ")
return lock_group_leave(msg, data, target)
end
end
if matches[1] == 'unlock' then
local target = msg.to.id
if matches[2] == 'name' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked name ")
return unlock_group_namemod(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ")
return unlock_group_membermod(msg, data, target)
end
if matches[2] == 'photo' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked photo ")
return unlock_group_photomod(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood ")
return unlock_group_floodmod(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked arabic ")
return unlock_group_arabic(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked bots ")
return unlock_group_bots(msg, data, target)
end
if matches[2] == 'leave' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked leaving ")
return unlock_group_leave(msg, data, target)
end
end
if matches[1] == 'settings' then
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group settings ")
return show_group_settingsmod(msg, data, target)
end
--[[if matches[1] == 'public' then
local target = msg.to.id
if matches[2] == 'yes' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: public")
return set_public_membermod(msg, data, target)
end
if matches[2] == 'no' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: not public")
return unset_public_membermod(msg, data, target)
end
end]]
if matches[1] == 'newlink' and not is_realm(msg) then
if not is_momod(msg) then
return "For moderators only!"
end
local function callback (extra , success, result)
local receiver = 'chat#'..msg.to.id
if success == 0 then
return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.')
end
send_large_msg(receiver, "Created a new link")
data[tostring(msg.to.id)]['settings']['set_link'] = result
save_data(_config.moderation.data, data)
end
local receiver = 'chat#'..msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] revoked group link ")
return export_chat_link(receiver, callback, true)
end
if matches[1] == 'link' then
if not is_momod(msg) then
return "For moderators only!"
end
local group_link = data[tostring(msg.to.id)]['settings']['set_link']
if not group_link then
return "Create a link using /newlink first !"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]")
return "Group link:\n"..group_link
end
if matches[1] == 'setowner' and matches[2] then
if not is_owner(msg) then
return "For owner only!"
end
data[tostring(msg.to.id)]['set_owner'] = matches[2]
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] as owner")
local text = matches[2].." added as owner"
return text
end
if matches[1] == 'setowner' and not matches[2] then
if not is_owner(msg) then
return "only for the owner!"
end
if type(msg.reply_id)~="nil" then
msgr = get_message(msg.reply_id, setowner_by_reply, false)
end
end
if matches[1] == 'owner' then
local group_owner = data[tostring(msg.to.id)]['set_owner']
if not group_owner then
return "no owner,ask admins in support groups to set owner for your group"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner")
return "Group owner is ["..group_owner..']'
end
if matches[1] == 'setgpowner' then
local receiver = "chat#id"..matches[2]
if not is_admin(msg) then
return "For admins only!"
end
data[tostring(matches[2])]['set_owner'] = matches[3]
save_data(_config.moderation.data, data)
local text = matches[3].." added as owner"
send_large_msg(receiver, text)
return
end
if matches[1] == 'setflood' then
if not is_momod(msg) then
return "For moderators only!"
end
if tonumber(matches[2]) < 5 or tonumber(matches[2]) > 20 then
return "Wrong number,range is [5-20]"
end
local flood_max = matches[2]
data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]")
return 'Group flood has been set to '..matches[2]
end
if matches[1] == 'clean' then
if not is_owner(msg) then
return "Only owner can clean"
end
if matches[2] == 'member' then
if not is_owner(msg) then
return "Only admins can clean members"
end
local receiver = get_receiver(msg)
chat_info(receiver, cleanmember, {receiver=receiver})
end
if matches[2] == 'modlist' then
if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way
return 'No moderator in this group.'
end
local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil
save_data(_config.moderation.data, data)
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist")
end
if matches[2] == 'rules' then
local data_cat = 'rules'
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules")
end
if matches[2] == 'about' then
local data_cat = 'description'
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about")
end
end
if matches[1] == 'kill' and matches[2] == 'chat' then
if not is_admin(msg) then
return nil
end
if not is_realm(msg) then
local receiver = get_receiver(msg)
return modrem(msg),
print("Closing Group..."),
chat_info(receiver, killchat, {receiver=receiver})
else
return 'This is a realm'
end
end
if matches[1] == 'kill' and matches[2] == 'realm' then
if not is_admin(msg) then
return nil
end
if not is_group(msg) then
local receiver = get_receiver(msg)
return realmrem(msg),
print("Closing Realm..."),
chat_info(receiver, killrealm, {receiver=receiver})
else
return 'This is a group'
end
end
if matches[1] == 'help' then
if not is_momod(msg) or is_realm(msg) then
return
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help")
return help()
end
if matches[1] == 'res' and is_momod(msg) then
local cbres_extra = {
chatid = msg.to.id
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username)
return res_user(username, callbackres, cbres_extra)
end
if matches[1] == 'kickinactive' then
--send_large_msg('chat#id'..msg.to.id, 'I\'m in matches[1]')
if not is_momod(msg) then
return 'Only a moderator can kick inactive users'
end
local num = 1
if matches[2] then
num = matches[2]
end
local chat_id = msg.to.id
local receiver = get_receiver(msg)
return kick_inactive(chat_id, num, receiver)
end
end
end
return {
patterns = {
"^[!/](add)$",
"^[!/](add) (realm)$",
"^[!/](rem)$",
"^[!/](rem) (realm)$",
"^[!/](rules)$",
"^[!/](about)$",
"^[!/](setname) (.*)$",
"^[!/](setphoto)$",
"^[!/](promote) (.*)$",
"^[!/](promote)",
"^[!/](help)$",
"^[!/](clean) (.*)$",
"^[!/](kill) (chat)$",
"^[!/](kill) (realm)$",
"^[!/](demote) (.*)$",
"^[!/](demote)",
"^[!/](set) ([^%s]+) (.*)$",
"^[!/](lock) (.*)$",
"^[!/](setowner) (%d+)$",
"^[!/](setowner)",
"^[!/](owner)$",
"^[!/](res) (.*)$",
"^[!/](setgpowner) (%d+) (%d+)$",-- (group id) (owner id)
"^[!/](unlock) (.*)$",
"^[!/](setflood) (%d+)$",
"^[!/](settings)$",
-- "^[!/](public) (.*)$",
"^[!/](modlist)$",
"^[!/](newlink)$",
"^[!/](link)$",
"^[!/](kickinactive)$",
"^[!/](kickinactive) (%d+)$",
"%[(photo)%]",
"^!!tgservice (.+)$",
},
run = run
}
end
| gpl-2.0 |
nitheeshkl/kln_awesome | awesome_3.5/blingbling/config_example/rc.lua | 2 | 24560 | -- Standard awesome library
local gears = require("gears")
local awful = require("awful")
awful.rules = require("awful.rules")
require("awful.autofocus")
-- Widget and layout library
local wibox = require("wibox")
-- Theme handling library
local beautiful = require("beautiful")
-- Notification library
local naughty = require("naughty")
local menubar = require("menubar")
-- {{{ Error handling
-- Check if awesome encountered an error during startup and fell back to
-- another config (This code will only ever execute for the fallback config)
if awesome.startup_errors then
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, there were errors during startup!",
text = awesome.startup_errors })
end
-- Handle runtime errors after startup
do
local in_error = false
awesome.connect_signal("debug::error", function (err)
-- Make sure we don't go into an endless error loop
if in_error then return end
in_error = true
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, an error happened!",
text = err })
in_error = false
end)
end
-- }}}
-- {{{ Variable definitions
-- Themes define colours, icons, and wallpapers
local home_dir = os.getenv("HOME")
local themes_dir = home_dir .. "/.config/awesome/themes"
local theme_dir = themes_dir .. "/japanese2"
beautiful.init(theme_dir .. "/theme.lua")
-- This is used later as the default terminal and editor to run.
--terminal = "tortosa -c \"" .. home_dir .. "/.config/tortosa/tortosa_awesome.rc\""
terminal = "tortosa"
editor = os.getenv("EDITOR") or "vim"
editor_cmd = terminal .. " -e "
-- Default modkey.
-- Usually, Mod4 is the key with a logo between Control and Alt.
-- If you do not like this or do not have such a key,
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
-- However, you can use another modifier like Mod1, but it may interact with others.
modkey = "Mod4"
-- Table of layouts to cover with awful.layout.inc, order matters.
local layouts =
{
-- awful.layout.suit.floating,
awful.layout.suit.tile,
awful.layout.suit.tile.left,
awful.layout.suit.tile.bottom,
awful.layout.suit.tile.top,
awful.layout.suit.fair,
awful.layout.suit.fair.horizontal,
awful.layout.suit.spiral,
awful.layout.suit.spiral.dwindle,
awful.layout.suit.max,
awful.layout.suit.max.fullscreen,
awful.layout.suit.magnifier
}
-- }}}
-- {{{ Wallpaper
if beautiful.wallpaper then
for s = 1, screen.count() do
gears.wallpaper.maximized(beautiful.wallpaper, s, true)
end
end
-- }}}
-- {{{ Tags
-- Define a tag table which hold all screen tags.
tags = {}
for s = 1, screen.count() do
-- Each screen has its own tag table.
tags[s] = awful.tag({ " 一⇋ Main ", " 二⇋ Devel. ", " 三⇋ Admin. ", " 四⇋ www/Web ", " 五⇋ Misc ", " 六 " }, s, layouts[1])
--tags[s] = awful.tag({ " [[ ⇋ Main ]]", " [[ ⇋ 四 Devel. ]]", " [[ ⇋ Admin. ]]", " [[ ⇋ www/Web ]]", " [[ ⇋ Misc ]] "}, s, layouts[1])
end
-- }}}
-- {{{ Menu
-- Create a laucher widget and a main menu
myawesomemenu = {
{ "manual", terminal .. " -e \"man awesome\"" },
{ "edit config", terminal .. " -e \"vim " .. awesome.conffile .."\"" },
{ "edit theme", terminal .. " -e \"vim ".. theme_dir .. "/theme.lua" .."\"" },
{ "restart", awesome.restart },
{ "quit", awesome.quit }
}
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
{ "open terminal", terminal }
}
})
mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
menu = mymainmenu })
-- Menubar configuration
menubar.utils.terminal = terminal -- Set the terminal for applications that require it
-- }}}
-- {{{ Wibox
-- Create a textclock widget
local blingbling = require("blingbling")
local cur_day_month =" <span color=\""..beautiful.bright_magenta ..
"\">%d、</span>"
local cur_month = " <span color=\""..beautiful.bright_yellow ..
"\">%m、</span>"
local cur_day_week =" <span color=\""..beautiful.bright_green ..
"\">%w、</span>"
local cur_hour = "<span font_weight=\"bold\">%H<span color=\""..
beautiful.red.."\" font_weight=\"normal\">時</span>%M"..
"<span color=\""..
beautiful.red.."\" font_weight=\"normal\">分</span></span>"
mytextclock = blingbling.clock.japanese( cur_month .. cur_day_month ..
cur_day_week ..
cur_hour,
{ h_margin = 2,
v_margin = 2,
text_background_color = beautiful.widget_background,
rounded_size = 0.3})
--mytextclock = blingbling.clock.japanese()
calendar = blingbling.calendar({ widget = mytextclock})
calendar:set_link_to_external_calendar(true)
--calendar:set_default_info(function()
-- blingbling.clock.get_current_time_in_japanese() .. 'test'
-- blingbling.clock.get_current_day_of_week_in_kanas()
--end)
-- Create a wibox for each screen and add it
mywibox = {}
mypromptbox = {}
mylayoutbox = {}
mytaglist = {}
mytaglist.buttons = awful.util.table.join(
awful.button({ }, 1, awful.tag.viewonly),
awful.button({ modkey }, 1, awful.client.movetotag),
awful.button({ }, 3, awful.tag.viewtoggle),
awful.button({ modkey }, 3, awful.client.toggletag),
awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
)
mytasklist = {}
mytasklist.buttons = awful.util.table.join(
awful.button({ }, 1, function (c)
if c == client.focus then
c.minimized = true
else
-- Without this, the following
-- :isvisible() makes no sense
c.minimized = false
if not c:isvisible() then
awful.tag.viewonly(c:tags()[1])
end
-- This will also un-minimize
-- the client, if needed
client.focus = c
c:raise()
end
end),
awful.button({ }, 3, function ()
if instance then
instance:hide()
instance = nil
else
instance = awful.menu.clients({ width=250 })
end
end),
awful.button({ }, 4, function ()
awful.client.focus.byidx(1)
if client.focus then client.focus:raise() end
end),
awful.button({ }, 5, function ()
awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end))
local vicious = require("vicious")
-- Top widgets:
cpu_graph = blingbling.line_graph({ height = 18,
width = 160,
show_text = true,
label = "Cpu: $percent %",
})
vicious.register(cpu_graph, vicious.widgets.cpu,'$1',2)
mem_graph = blingbling.line_graph({ height = 18,
width = 160,
show_text = true,
label = "Mem: $percent %",
})
vicious.register(mem_graph, vicious.widgets.mem, '$1', 2)
local colors_stops = { {beautiful.green , 0},
{beautiful.yellow, 0.5},
{beautiful.cyan, 0.70},
{beautiful.magenta, 0.79},
{beautiful.red, 0.90}
}
volume_bar = blingbling.volume({height = 18, width = 40, bar =true, show_text = true, label ="Vol"})
volume_bar:update_master()
volume_bar:set_master_control()
home_fs_usage=blingbling.value_text_box({height = 14, width = 40, v_margin = 3})
home_fs_usage:set_text_background_color(beautiful.widget_background)
home_fs_usage:set_values_text_color(colors_stops)
home_fs_usage:set_font_size(8)
home_fs_usage:set_background_color("#00000000")
home_fs_usage:set_label("home: $percent %")
vicious.register(home_fs_usage, vicious.widgets.fs, "${/home used_p}", 120 )
root_fs_usage=blingbling.value_text_box({height = 14, width = 40, v_margin = 3})
root_fs_usage:set_text_background_color(beautiful.widget_background)
root_fs_usage:set_values_text_color(colors_stops)
--root_fs_usage:set_rounded_size(0.4)
root_fs_usage:set_font_size(8)
root_fs_usage:set_background_color("#00000000")
root_fs_usage:set_label("root: $percent %")
vicious.register(root_fs_usage, vicious.widgets.fs, "${/ used_p}", 120 )
data0_fs_usage=blingbling.value_text_box({height = 14, width = 40, v_margin = 3})
data0_fs_usage:set_text_background_color(beautiful.widget_background)
data0_fs_usage:set_values_text_color(colors_stops)
--data0_fs_usage:set_rounded_size(0.4)
data0_fs_usage:set_font_size(8)
data0_fs_usage:set_background_color("#00000000")
data0_fs_usage:set_label("data0: $percent %")
vicious.register(data0_fs_usage, vicious.widgets.fs, "${/mnt/data_0 used_p}", 120 )
data1_fs_usage=blingbling.value_text_box({height = 14, width = 40, v_margin = 3})
data1_fs_usage:set_text_background_color(beautiful.widget_background)
data1_fs_usage:set_values_text_color(colors_stops)
--data1_fs_usage:set_text_color(beautiful.textbox_widget_as_label_font_color)
--data1_fs_usage:set_rounded_size(0.4)
data1_fs_usage:set_font_size(8)
data1_fs_usage:set_background_color("#00000000")
data1_fs_usage:set_label("data1: $percent %")
vicious.register(data1_fs_usage, vicious.widgets.fs, "${/mnt/data_1 used_p}", 120 )
games_fs_usage=blingbling.value_text_box({height = 14, width = 40, v_margin = 3})
games_fs_usage:set_text_background_color(beautiful.widget_background)
games_fs_usage:set_values_text_color(colors_stops)
games_fs_usage:set_font_size(8)
games_fs_usage:set_background_color("#00000000")
games_fs_usage:set_label("games: $percent %")
vicious.register(games_fs_usage, vicious.widgets.fs, "${/home/cedlemo/bin/games used_p}", 120 )
shutdown=blingbling.system.shutdownmenu() --icons have been set in theme
reboot=blingbling.system.rebootmenu() --icons have been set in theme
lock=blingbling.system.lockmenu() --icons have been set in theme
logout=blingbling.system.logoutmenu()
mytag={}
--test = blingbling.text_box()
for s = 1, ( screen.count() - 1) do
mytag[s]=blingbling.tagslist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
-- Create a promptbox for each screen
mypromptbox[s] = awful.widget.prompt()
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
-- We need one layoutbox per screen.
mylayoutbox[s] = awful.widget.layoutbox(s)
mylayoutbox[s]:buttons(awful.util.table.join(
awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
-- Create a taglist widget
--mytag[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
-- Create a tasklist widget
mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
-- Create the wibox
mywibox[s] = awful.wibox({ height = 18, position = "top", screen = s })
-- Widgets that are aligned to the left
local left_layout = wibox.layout.fixed.horizontal()
left_layout:add(mylauncher)
left_layout:add(wibox.layout.margin(mytag[s],0,0,2,2))
--left_layout:add(wibox.layout.margin(mytaglist[s],0,0,1,1))
left_layout:add(mypromptbox[s])
left_layout:add(cpu_graph)
left_layout:add(mem_graph)
left_layout:add(home_fs_usage)
left_layout:add(root_fs_usage)
left_layout:add(data0_fs_usage)
left_layout:add(data1_fs_usage)
left_layout:add(games_fs_usage)
--left_layout:add(mytags)
-- Widgets that are aligned to the right
local right_layout = wibox.layout.fixed.horizontal()
if s == 1 then right_layout:add(wibox.widget.systray()) end
right_layout:add(volume_bar)
--right_layout:add(mytextclock)
right_layout:add(calendar)
right_layout:add(mylayoutbox[s])
right_layout:add(reboot)
right_layout:add(shutdown)
right_layout:add(logout)
right_layout:add(lock)
-- Now bring it all together (with the tasklist in the middle)
local layout = wibox.layout.align.horizontal()
layout:set_left(left_layout)
layout:set_middle(wibox.layout.margin(mytasklist[s],0,0,2,2))
layout:set_right(right_layout)
mywibox[s]:set_widget(layout)
end
-- }}}
-- {{{ Mouse bindings
root.buttons(awful.util.table.join(
awful.button({ }, 3, function () mymainmenu:toggle() end),
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev)
))
-- }}}
-- {{{ Key bindings
globalkeys = awful.util.table.join(
awful.key({ modkey, }, "Left", awful.tag.viewprev ),
awful.key({ modkey, }, "Right", awful.tag.viewnext ),
awful.key({ modkey, }, "Escape", awful.tag.history.restore),
awful.key({ modkey, }, "j",
function ()
awful.client.focus.byidx( 1)
if client.focus then client.focus:raise() end
end),
awful.key({ modkey, }, "k",
function ()
awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end),
awful.key({ modkey, }, "w", function () mymainmenu:show() end),
-- Layout manipulation
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
awful.key({ modkey, }, "Tab",
function ()
awful.client.focus.history.previous()
if client.focus then
client.focus:raise()
end
end),
-- Standard program
awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
awful.key({ modkey, "Control" }, "r", awesome.restart),
awful.key({ modkey, "Shift" }, "q", awesome.quit),
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
awful.key({ modkey, "Control" }, "n", awful.client.restore),
-- Prompt
awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
awful.key({ modkey }, "x",
function ()
awful.prompt.run({ prompt = "Run Lua code: " },
mypromptbox[mouse.screen].widget,
awful.util.eval, nil,
awful.util.getdir("cache") .. "/history_eval")
end),
-- Menubar
awful.key({ modkey }, "p", function() menubar.show() end)
)
clientkeys = awful.util.table.join(
awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
awful.key({ modkey, }, "o", awful.client.movetoscreen ),
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
awful.key({ modkey, }, "n",
function (c)
-- The client currently has the input focus, so it cannot be
-- minimized, since minimized clients can't have the focus.
c.minimized = true
end),
awful.key({ modkey, }, "m",
function (c)
c.maximized_horizontal = not c.maximized_horizontal
c.maximized_vertical = not c.maximized_vertical
end)
)
-- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it works on any keyboard layout.
-- This should map on the top row of your keyboard, usually 1 to 9.
for i = 1, 9 do
globalkeys = awful.util.table.join(globalkeys,
awful.key({ modkey }, "#" .. i + 9,
function ()
local screen = mouse.screen
local tag = awful.tag.gettags(screen)[i]
if tag then
awful.tag.viewonly(tag)
end
end),
awful.key({ modkey, "Control" }, "#" .. i + 9,
function ()
local screen = mouse.screen
local tag = awful.tag.gettags(screen)[i]
if tag then
awful.tag.viewtoggle(tag)
end
end),
awful.key({ modkey, "Shift" }, "#" .. i + 9,
function ()
local tag = awful.tag.gettags(client.focus.screen)[i]
if client.focus and tag then
awful.client.movetotag(tag)
end
end),
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
function ()
local tag = awful.tag.gettags(client.focus.screen)[i]
if client.focus and tag then
awful.client.toggletag(tag)
end
end))
end
clientbuttons = awful.util.table.join(
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
awful.button({ modkey }, 1, awful.mouse.client.move),
awful.button({ modkey }, 3, awful.mouse.client.resize))
-- Set keys
root.keys(globalkeys)
-- }}}
-- {{{ Rules
awful.rules.rules = {
-- All clients will match this rule.
{ rule = { },
properties = { border_width = beautiful.border_width,
border_color = beautiful.border_normal,
focus = awful.client.focus.filter,
keys = clientkeys,
buttons = clientbuttons } },
{ rule = { class = "MPlayer" },
properties = { floating = true } },
{ rule = { class = "pinentry" },
properties = { floating = true } },
{ rule = { class = "gimp" },
properties = { floating = true } },
-- Set Firefox to always map on tags number 2 of screen 1.
{ rule_any = { class = {"Navigator","Firefox", "Chromium" },
properties = { tag = tags[1][2] } }},
{ rule = { class = "Thunderbird" },
properties = { tag = tags[1][3] } },
{ rule = { class = "Tuxguitar" },
properties = { tag = tags[1][6] } },
}
-- }}}
-- {{{ Signals
-- Signal function to execute when a new client appears.
client.connect_signal("manage", function (c, startup)
-- Enable sloppy focus
c:connect_signal("mouse::enter", function(c)
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
and awful.client.focus.filter(c) then
client.focus = c
end
end)
if not startup then
-- Set the windows at the slave,
-- i.e. put it at the end of others instead of setting it master.
-- awful.client.setslave(c)
-- Put windows in a smart way, only if they does not set an initial position.
if not c.size_hints.user_position and not c.size_hints.program_position then
awful.placement.no_overlap(c)
awful.placement.no_offscreen(c)
end
end
local titlebars_enabled = true
if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
-- buttons for the titlebar
local buttons = awful.util.table.join(
awful.button({ }, 1, function()
client.focus = c
c:raise()
awful.mouse.client.move(c)
end),
awful.button({ }, 3, function()
client.focus = c
c:raise()
awful.mouse.client.resize(c)
end)
)
-- Widgets that are aligned to the left
local left_layout = wibox.layout.fixed.horizontal()
left_layout:add(awful.titlebar.widget.iconwidget(c))
left_layout:buttons(buttons)
-- Widgets that are aligned to the right
local right_layout = wibox.layout.fixed.horizontal()
--right_layout:add(awful.titlebar.widget.floatingbutton(c))
right_layout:add(awful.titlebar.widget.maximizedbutton(c))
--right_layout:add(awful.titlebar.widget.stickybutton(c))
--right_layout:add(awful.titlebar.widget.ontopbutton(c))
right_layout:add(awful.titlebar.widget.closebutton(c))
-- The title goes in the middle
local middle_layout = wibox.layout.flex.horizontal()
local title = awful.titlebar.widget.titlewidget(c)
title:set_align("left")
middle_layout:add(title)
middle_layout:buttons(buttons)
-- Now bring it all together
local layout = wibox.layout.align.horizontal()
layout:set_left(left_layout)
layout:set_right(right_layout)
layout:set_middle(middle_layout)
awful.titlebar(c, {size =12} ):set_widget(layout)
end
end)
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
-- }}}
-- {{{
function run_once(cmd)
local findme = cmd
local firstspace = cmd:find(" ")
if firstspace then
findme = cmd:sub(0, firstspace-1)
end
awful.util.spawn_with_shell("pgrep -u $USER -x " .. findme .. " > /dev/null || (" .. cmd .. ")")
end
--run_once("qjackctl")
run_once("volti")
-- }}}
| gpl-2.0 |
christopherjwang/rackspace-monitoring-agent | hostinfo/filesystem.lua | 1 | 1533 | --[[
Copyright 2014 Rackspace
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--]]
local HostInfo = require('./base').HostInfo
local sigar = require('sigar')
local table = require('table')
--[[ Filesystem Info ]]--
local Info = HostInfo:extend()
function Info:initialize()
HostInfo.initialize(self)
local ctx = sigar:new()
local fses = ctx:filesystems()
for i=1, #fses do
local obj = {}
local fs = fses[i]
local info = fs:info()
local usage = fs:usage()
if info then
local info_fields = {
'dir_name',
'dev_name',
'sys_type_name',
'options',
}
for _, v in pairs(info_fields) do
obj[v] = info[v]
end
end
if usage then
local usage_fields = {
'total',
'free',
'used',
'avail',
'files',
'free_files',
}
for _, v in pairs(usage_fields) do
obj[v] = usage[v]
end
end
table.insert(self._params, obj)
end
end
function Info:getType()
return 'FILESYSTEM'
end
return Info
| apache-2.0 |
dickeyf/darkstar | scripts/globals/abilities/light_maneuver.lua | 35 | 1609 | -----------------------------------
-- Ability: Light Maneuver
-- Enhances the effect of light attachments. Must have animator equipped.
-- Obtained: Puppetmaster level 1
-- Recast Time: 10 seconds (shared with all maneuvers)
-- Duration: 1 minute
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------
-- onAbilityCheck
-----------------------------------
function onAbilityCheck(player,target,ability)
if (player:getWeaponSubSkillType(SLOT_RANGED) == 10 and
not player:hasStatusEffect(EFFECT_OVERLOAD)) then
return 0,0;
else
return 71,0;
end
end;
-----------------------------------
-- onUseAbility
-----------------------------------
function onUseAbility(player,target,ability)
local burden = 15;
if (target:getStat(MOD_CHR) < target:getPet():getStat(MOD_CHR)) then
burden = 20;
end
local overload = target:addBurden(ELE_LIGHT-1, burden);
if (overload ~= 0) then
target:removeAllManeuvers();
target:addStatusEffect(EFFECT_OVERLOAD, 0, 0, overload);
else
local level;
if (target:getMainJob() == JOB_PUP) then
level = target:getMainLvl()
else
level = target:getSubLvl()
end
local bonus = 1 + (level/15) + target:getMod(MOD_MANEUVER_BONUS);
if (target:getActiveManeuvers() == 3) then
target:removeOldestManeuver();
end
target:addStatusEffect(EFFECT_LIGHT_MANEUVER, bonus, 0, 60);
end
return EFFECT_LIGHT_MANEUVER;
end; | gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c18517177.lua | 3 | 1616 | --コア・ブラスト
function c18517177.initial_effect(c)
--activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,TIMING_END_PHASE)
c:RegisterEffect(e1)
--maintain
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(18517177,0))
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_PHASE+PHASE_STANDBY)
e2:SetRange(LOCATION_SZONE)
e2:SetCountLimit(1)
e2:SetCondition(c18517177.descon)
e2:SetTarget(c18517177.destg)
e2:SetOperation(c18517177.desop)
c:RegisterEffect(e2)
end
function c18517177.cfilter(c)
return c:IsFaceup() and c:IsSetCard(0x1d)
end
function c18517177.descon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==tp
and Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)<Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE)
and Duel.IsExistingMatchingCard(c18517177.cfilter,tp,LOCATION_MZONE,0,1,nil)
end
function c18517177.destg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local g=Duel.GetMatchingGroup(aux.TRUE,tp,0,LOCATION_ONFIELD,nil)
local ct=Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE)-Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,ct,0,0)
end
function c18517177.desop(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
local g=Duel.GetMatchingGroup(aux.TRUE,tp,0,LOCATION_ONFIELD,nil)
local ct=g:GetCount()-Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)
if ct<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local dg=g:Select(tp,ct,ct,nil)
Duel.Destroy(dg,REASON_EFFECT)
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c28124263.lua | 6 | 2160 | --D・キャメラン
function c28124263.initial_effect(c)
--special summon
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EVENT_LEAVE_FIELD_P)
e1:SetOperation(c28124263.check)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(28124263,0))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_BATTLE_DESTROYED)
e2:SetCondition(c28124263.cona)
e2:SetTarget(c28124263.tga)
e2:SetOperation(c28124263.opa)
e2:SetLabelObject(e1)
c:RegisterEffect(e2)
--untargetable
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
e3:SetRange(LOCATION_MZONE)
e3:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e3:SetCondition(c28124263.cond)
e3:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e3:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x26))
e3:SetValue(1)
c:RegisterEffect(e3)
end
function c28124263.check(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsDisabled() and c:IsAttackPos() then e:SetLabel(1)
else e:SetLabel(0) end
end
function c28124263.cona(e,tp,eg,ep,ev,re,r,rp)
return e:GetLabelObject():GetLabel()==1
end
function c28124263.filter(c,e,tp)
return c:IsLevelBelow(4) and c:IsSetCard(0x26) and not c:IsCode(28124263)
and c:IsCanBeSpecialSummoned(e,0,tp,true,false)
end
function c28124263.tga(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c28124263.filter,tp,LOCATION_HAND+LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND+LOCATION_GRAVE)
end
function c28124263.opa(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(c28124263.filter),tp,LOCATION_HAND+LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
function c28124263.cond(e)
return e:GetHandler():IsDefensePos()
end
| gpl-2.0 |
mitchellwrosen/lua-parser | test/samples/1.lua | 3 | 34547 | --[[
Interpolating Search on a String
LUA 5.1 compatible
Can only search sorted tables with value string
table.intsearchstr( table, value ), for searching a normal sorted table
table.intsearchstrrev( table, value ), for searching a reversed sorted table
If the value is found:
it returns a table holding all the matching indices (e.g. { startindice,endindice } )
endindice may be the same as startindice if only one matching indice was found
Return value:
on success: a table holding matching indices (e.g. { startindice,endindice } )
on failure: nil
]]--
do
-- Avoid heap allocs for performance
local getbytevalue = function( value )
if value then
local num,mul = 0,1
-- set bytedept, 4 or 5 seems appropriate
for i = 4,1,-1 do
local byte = string.byte( string.sub( value,i,i ) ) or -1
byte,num,mul = byte + 1,num + mul*byte,mul*257
end
return num
end
end
-- Load the optimised binary function
-- Avoid heap allocs for performance
local fcompf = function( a,b ) return a < b end
local fcompr = function( a,b ) return a > b end
local function tablebinsearch( t,value,reversed,iStart,iEnd )
-- Initialise functions
local fcomp = reversed and fcompr or fcompf
-- Initialise numbers
local iStart,iEnd,iMid = iStart or 1,iEnd or #t,0
-- Binary Search
while iStart <= iEnd do
-- calculate middle
iMid = math.floor( (iStart+iEnd)/2 )
-- get compare value
local value2 = t[iMid]
-- get all values that match
if value == value2 then
local tfound,num = { iMid,iMid },iMid - 1
while value == t[num] do
tfound[1],num = num,num - 1
end
num = iMid + 1
while value == t[num] do
tfound[2],num = num,num + 1
end
return tfound
-- keep searching
elseif fcomp( value,value2 ) then
iEnd = iMid - 1
else
iStart = iMid + 1
end
end
end
-- The interpolationg Search Function on a String
function table.intsearchstr( t,value )
-- Inistialise numbers
local ilow,ihigh = 1,#t
-- return on empty table
if not t[ilow] then return end
-- get byte values values of indices and searched value
local _ilow,_ihigh,_value = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),getbytevalue(value)
local oldpos = -1
-- make sure slope cannot become 0
while _ilow and _ilow < _ihigh do
-- get interpolated position
local pos = math.floor( (_value-_ilow)*(ihigh-ilow)/(_ihigh-_ilow) ) + ilow
-- check for out of range
if pos < ilow or pos > ihigh then return end
-- check for real match
if value == t[pos] then
-- insert found position
local tfound,num = { pos,pos },pos-1
-- get all values that match
while value == t[num] do
tfound[1],num = num,num-1
end
num = pos+1
while value == t[num] do
tfound[2],num = num,num+1
end
return tfound
-- keep searching,
-- left part of the table,check for real lower
elseif value < t[pos] then
ihigh = pos-1
else
ilow = pos+1
end
-- check if new position is further than 1 away
if oldpos+1 == pos or oldpos-1 == pos then
-- start binary search
return tablebinsearch( t,value,_,ilow,ihigh )
end
_ilow,_ihigh,oldpos = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),pos
end
-- initiate binary seach function here since we could be in a flat for the interpolating search
return tablebinsearch( t,value,_,ilow,ihigh )
end
-- The interpolationg Search Function on a String
function table.intsearchstrrev( t,value )
-- Inistialise numbers
local ilow,ihigh = 1,#t
-- return on empty table
if not t[ilow] then return end
-- get byte values values of indices and searched value
local _ilow,_ihigh,_value = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),getbytevalue(value)
local oldpos = -1
-- make sure slope cannot become 0
while _ilow and _ilow > _ihigh do
-- get interpolated position
local pos = math.floor( (_ihigh-_value)*(ihigh-ilow)/(_ihigh-_ilow) ) + ilow
-- check for out of range
if pos < ilow or pos > ihigh then return end
-- check for real match
if value == t[pos] then
-- insert found position
local tfound,num = { pos,pos },pos-1
-- get all values that match
while value == t[num] do
tfound[1],num = num,num-1
end
num = pos+1
while value == t[num] do
tfound[2],num = num,num+1
end
return tfound
-- keep searching,
-- left part of the table,check for real lower
elseif value > t[pos] then
ihigh = pos-1
else
ilow = pos+1
end
-- check if new position is further than 1 away
if oldpos+1 == pos or oldpos-1 == pos then
-- start binary search
return tablebinsearch( t,value,1,ilow,ihigh )
end
_ilow,_ihigh,oldpos = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),pos
end
-- initiate binary seach function here since we could be in a flat for the interpolating search
return tablebinsearch( t,value,1,ilow,ihigh )
end
end
-- CHILLCODE™
--[[
Interpolating Search on a String
LUA 5.1 compatible
Can only search sorted tables with value string
table.intsearchstr( table, value ), for searching a normal sorted table
table.intsearchstrrev( table, value ), for searching a reversed sorted table
If the value is found:
it returns a table holding all the matching indices (e.g. { startindice,endindice } )
endindice may be the same as startindice if only one matching indice was found
Return value:
on success: a table holding matching indices (e.g. { startindice,endindice } )
on failure: nil
]]--
do
-- Avoid heap allocs for performance
local getbytevalue = function( value )
if value then
local num,mul = 0,1
-- set bytedept, 4 or 5 seems appropriate
for i = 4,1,-1 do
local byte = string.byte( string.sub( value,i,i ) ) or -1
byte,num,mul = byte + 1,num + mul*byte,mul*257
end
return num
end
end
-- Load the optimised binary function
-- Avoid heap allocs for performance
local fcompf = function( a,b ) return a < b end
local fcompr = function( a,b ) return a > b end
local function tablebinsearch( t,value,reversed,iStart,iEnd )
-- Initialise functions
local fcomp = reversed and fcompr or fcompf
-- Initialise numbers
local iStart,iEnd,iMid = iStart or 1,iEnd or #t,0
-- Binary Search
while iStart <= iEnd do
-- calculate middle
iMid = math.floor( (iStart+iEnd)/2 )
-- get compare value
local value2 = t[iMid]
-- get all values that match
if value == value2 then
local tfound,num = { iMid,iMid },iMid - 1
while value == t[num] do
tfound[1],num = num,num - 1
end
num = iMid + 1
while value == t[num] do
tfound[2],num = num,num + 1
end
return tfound
-- keep searching
elseif fcomp( value,value2 ) then
iEnd = iMid - 1
else
iStart = iMid + 1
end
end
end
-- The interpolationg Search Function on a String
function table.intsearchstr( t,value )
-- Inistialise numbers
local ilow,ihigh = 1,#t
-- return on empty table
if not t[ilow] then return end
-- get byte values values of indices and searched value
local _ilow,_ihigh,_value = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),getbytevalue(value)
local oldpos = -1
-- make sure slope cannot become 0
while _ilow and _ilow < _ihigh do
-- get interpolated position
local pos = math.floor( (_value-_ilow)*(ihigh-ilow)/(_ihigh-_ilow) ) + ilow
-- check for out of range
if pos < ilow or pos > ihigh then return end
-- check for real match
if value == t[pos] then
-- insert found position
local tfound,num = { pos,pos },pos-1
-- get all values that match
while value == t[num] do
tfound[1],num = num,num-1
end
num = pos+1
while value == t[num] do
tfound[2],num = num,num+1
end
return tfound
-- keep searching,
-- left part of the table,check for real lower
elseif value < t[pos] then
ihigh = pos-1
else
ilow = pos+1
end
-- check if new position is further than 1 away
if oldpos+1 == pos or oldpos-1 == pos then
-- start binary search
return tablebinsearch( t,value,_,ilow,ihigh )
end
_ilow,_ihigh,oldpos = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),pos
end
-- initiate binary seach function here since we could be in a flat for the interpolating search
return tablebinsearch( t,value,_,ilow,ihigh )
end
-- The interpolationg Search Function on a String
function table.intsearchstrrev( t,value )
-- Inistialise numbers
local ilow,ihigh = 1,#t
-- return on empty table
if not t[ilow] then return end
-- get byte values values of indices and searched value
local _ilow,_ihigh,_value = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),getbytevalue(value)
local oldpos = -1
-- make sure slope cannot become 0
while _ilow and _ilow > _ihigh do
-- get interpolated position
local pos = math.floor( (_ihigh-_value)*(ihigh-ilow)/(_ihigh-_ilow) ) + ilow
-- check for out of range
if pos < ilow or pos > ihigh then return end
-- check for real match
if value == t[pos] then
-- insert found position
local tfound,num = { pos,pos },pos-1
-- get all values that match
while value == t[num] do
tfound[1],num = num,num-1
end
num = pos+1
while value == t[num] do
tfound[2],num = num,num+1
end
return tfound
-- keep searching,
-- left part of the table,check for real lower
elseif value > t[pos] then
ihigh = pos-1
else
ilow = pos+1
end
-- check if new position is further than 1 away
if oldpos+1 == pos or oldpos-1 == pos then
-- start binary search
return tablebinsearch( t,value,1,ilow,ihigh )
end
_ilow,_ihigh,oldpos = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),pos
end
-- initiate binary seach function here since we could be in a flat for the interpolating search
return tablebinsearch( t,value,1,ilow,ihigh )
end
end
-- CHILLCODE™
--[[
Interpolating Search on a String
LUA 5.1 compatible
Can only search sorted tables with value string
table.intsearchstr( table, value ), for searching a normal sorted table
table.intsearchstrrev( table, value ), for searching a reversed sorted table
If the value is found:
it returns a table holding all the matching indices (e.g. { startindice,endindice } )
endindice may be the same as startindice if only one matching indice was found
Return value:
on success: a table holding matching indices (e.g. { startindice,endindice } )
on failure: nil
]]--
do
-- Avoid heap allocs for performance
local getbytevalue = function( value )
if value then
local num,mul = 0,1
-- set bytedept, 4 or 5 seems appropriate
for i = 4,1,-1 do
local byte = string.byte( string.sub( value,i,i ) ) or -1
byte,num,mul = byte + 1,num + mul*byte,mul*257
end
return num
end
end
-- Load the optimised binary function
-- Avoid heap allocs for performance
local fcompf = function( a,b ) return a < b end
local fcompr = function( a,b ) return a > b end
local function tablebinsearch( t,value,reversed,iStart,iEnd )
-- Initialise functions
local fcomp = reversed and fcompr or fcompf
-- Initialise numbers
local iStart,iEnd,iMid = iStart or 1,iEnd or #t,0
-- Binary Search
while iStart <= iEnd do
-- calculate middle
iMid = math.floor( (iStart+iEnd)/2 )
-- get compare value
local value2 = t[iMid]
-- get all values that match
if value == value2 then
local tfound,num = { iMid,iMid },iMid - 1
while value == t[num] do
tfound[1],num = num,num - 1
end
num = iMid + 1
while value == t[num] do
tfound[2],num = num,num + 1
end
return tfound
-- keep searching
elseif fcomp( value,value2 ) then
iEnd = iMid - 1
else
iStart = iMid + 1
end
end
end
-- The interpolationg Search Function on a String
function table.intsearchstr( t,value )
-- Inistialise numbers
local ilow,ihigh = 1,#t
-- return on empty table
if not t[ilow] then return end
-- get byte values values of indices and searched value
local _ilow,_ihigh,_value = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),getbytevalue(value)
local oldpos = -1
-- make sure slope cannot become 0
while _ilow and _ilow < _ihigh do
-- get interpolated position
local pos = math.floor( (_value-_ilow)*(ihigh-ilow)/(_ihigh-_ilow) ) + ilow
-- check for out of range
if pos < ilow or pos > ihigh then return end
-- check for real match
if value == t[pos] then
-- insert found position
local tfound,num = { pos,pos },pos-1
-- get all values that match
while value == t[num] do
tfound[1],num = num,num-1
end
num = pos+1
while value == t[num] do
tfound[2],num = num,num+1
end
return tfound
-- keep searching,
-- left part of the table,check for real lower
elseif value < t[pos] then
ihigh = pos-1
else
ilow = pos+1
end
-- check if new position is further than 1 away
if oldpos+1 == pos or oldpos-1 == pos then
-- start binary search
return tablebinsearch( t,value,_,ilow,ihigh )
end
_ilow,_ihigh,oldpos = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),pos
end
-- initiate binary seach function here since we could be in a flat for the interpolating search
return tablebinsearch( t,value,_,ilow,ihigh )
end
-- The interpolationg Search Function on a String
function table.intsearchstrrev( t,value )
-- Inistialise numbers
local ilow,ihigh = 1,#t
-- return on empty table
if not t[ilow] then return end
-- get byte values values of indices and searched value
local _ilow,_ihigh,_value = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),getbytevalue(value)
local oldpos = -1
-- make sure slope cannot become 0
while _ilow and _ilow > _ihigh do
-- get interpolated position
local pos = math.floor( (_ihigh-_value)*(ihigh-ilow)/(_ihigh-_ilow) ) + ilow
-- check for out of range
if pos < ilow or pos > ihigh then return end
-- check for real match
if value == t[pos] then
-- insert found position
local tfound,num = { pos,pos },pos-1
-- get all values that match
while value == t[num] do
tfound[1],num = num,num-1
end
num = pos+1
while value == t[num] do
tfound[2],num = num,num+1
end
return tfound
-- keep searching,
-- left part of the table,check for real lower
elseif value > t[pos] then
ihigh = pos-1
else
ilow = pos+1
end
-- check if new position is further than 1 away
if oldpos+1 == pos or oldpos-1 == pos then
-- start binary search
return tablebinsearch( t,value,1,ilow,ihigh )
end
_ilow,_ihigh,oldpos = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),pos
end
-- initiate binary seach function here since we could be in a flat for the interpolating search
return tablebinsearch( t,value,1,ilow,ihigh )
end
end
-- CHILLCODE™
--[[
Interpolating Search on a String
LUA 5.1 compatible
Can only search sorted tables with value string
table.intsearchstr( table, value ), for searching a normal sorted table
table.intsearchstrrev( table, value ), for searching a reversed sorted table
If the value is found:
it returns a table holding all the matching indices (e.g. { startindice,endindice } )
endindice may be the same as startindice if only one matching indice was found
Return value:
on success: a table holding matching indices (e.g. { startindice,endindice } )
on failure: nil
]]--
do
-- Avoid heap allocs for performance
local getbytevalue = function( value )
if value then
local num,mul = 0,1
-- set bytedept, 4 or 5 seems appropriate
for i = 4,1,-1 do
local byte = string.byte( string.sub( value,i,i ) ) or -1
byte,num,mul = byte + 1,num + mul*byte,mul*257
end
return num
end
end
-- Load the optimised binary function
-- Avoid heap allocs for performance
local fcompf = function( a,b ) return a < b end
local fcompr = function( a,b ) return a > b end
local function tablebinsearch( t,value,reversed,iStart,iEnd )
-- Initialise functions
local fcomp = reversed and fcompr or fcompf
-- Initialise numbers
local iStart,iEnd,iMid = iStart or 1,iEnd or #t,0
-- Binary Search
while iStart <= iEnd do
-- calculate middle
iMid = math.floor( (iStart+iEnd)/2 )
-- get compare value
local value2 = t[iMid]
-- get all values that match
if value == value2 then
local tfound,num = { iMid,iMid },iMid - 1
while value == t[num] do
tfound[1],num = num,num - 1
end
num = iMid + 1
while value == t[num] do
tfound[2],num = num,num + 1
end
return tfound
-- keep searching
elseif fcomp( value,value2 ) then
iEnd = iMid - 1
else
iStart = iMid + 1
end
end
end
-- The interpolationg Search Function on a String
function table.intsearchstr( t,value )
-- Inistialise numbers
local ilow,ihigh = 1,#t
-- return on empty table
if not t[ilow] then return end
-- get byte values values of indices and searched value
local _ilow,_ihigh,_value = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),getbytevalue(value)
local oldpos = -1
-- make sure slope cannot become 0
while _ilow and _ilow < _ihigh do
-- get interpolated position
local pos = math.floor( (_value-_ilow)*(ihigh-ilow)/(_ihigh-_ilow) ) + ilow
-- check for out of range
if pos < ilow or pos > ihigh then return end
-- check for real match
if value == t[pos] then
-- insert found position
local tfound,num = { pos,pos },pos-1
-- get all values that match
while value == t[num] do
tfound[1],num = num,num-1
end
num = pos+1
while value == t[num] do
tfound[2],num = num,num+1
end
return tfound
-- keep searching,
-- left part of the table,check for real lower
elseif value < t[pos] then
ihigh = pos-1
else
ilow = pos+1
end
-- check if new position is further than 1 away
if oldpos+1 == pos or oldpos-1 == pos then
-- start binary search
return tablebinsearch( t,value,_,ilow,ihigh )
end
_ilow,_ihigh,oldpos = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),pos
end
-- initiate binary seach function here since we could be in a flat for the interpolating search
return tablebinsearch( t,value,_,ilow,ihigh )
end
-- The interpolationg Search Function on a String
function table.intsearchstrrev( t,value )
-- Inistialise numbers
local ilow,ihigh = 1,#t
-- return on empty table
if not t[ilow] then return end
-- get byte values values of indices and searched value
local _ilow,_ihigh,_value = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),getbytevalue(value)
local oldpos = -1
-- make sure slope cannot become 0
while _ilow and _ilow > _ihigh do
-- get interpolated position
local pos = math.floor( (_ihigh-_value)*(ihigh-ilow)/(_ihigh-_ilow) ) + ilow
-- check for out of range
if pos < ilow or pos > ihigh then return end
-- check for real match
if value == t[pos] then
-- insert found position
local tfound,num = { pos,pos },pos-1
-- get all values that match
while value == t[num] do
tfound[1],num = num,num-1
end
num = pos+1
while value == t[num] do
tfound[2],num = num,num+1
end
return tfound
-- keep searching,
-- left part of the table,check for real lower
elseif value > t[pos] then
ihigh = pos-1
else
ilow = pos+1
end
-- check if new position is further than 1 away
if oldpos+1 == pos or oldpos-1 == pos then
-- start binary search
return tablebinsearch( t,value,1,ilow,ihigh )
end
_ilow,_ihigh,oldpos = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),pos
end
-- initiate binary seach function here since we could be in a flat for the interpolating search
return tablebinsearch( t,value,1,ilow,ihigh )
end
end
-- CHILLCODE™
--[[
Interpolating Search on a String
LUA 5.1 compatible
Can only search sorted tables with value string
table.intsearchstr( table, value ), for searching a normal sorted table
table.intsearchstrrev( table, value ), for searching a reversed sorted table
If the value is found:
it returns a table holding all the matching indices (e.g. { startindice,endindice } )
endindice may be the same as startindice if only one matching indice was found
Return value:
on success: a table holding matching indices (e.g. { startindice,endindice } )
on failure: nil
]]--
do
-- Avoid heap allocs for performance
local getbytevalue = function( value )
if value then
local num,mul = 0,1
-- set bytedept, 4 or 5 seems appropriate
for i = 4,1,-1 do
local byte = string.byte( string.sub( value,i,i ) ) or -1
byte,num,mul = byte + 1,num + mul*byte,mul*257
end
return num
end
end
-- Load the optimised binary function
-- Avoid heap allocs for performance
local fcompf = function( a,b ) return a < b end
local fcompr = function( a,b ) return a > b end
local function tablebinsearch( t,value,reversed,iStart,iEnd )
-- Initialise functions
local fcomp = reversed and fcompr or fcompf
-- Initialise numbers
local iStart,iEnd,iMid = iStart or 1,iEnd or #t,0
-- Binary Search
while iStart <= iEnd do
-- calculate middle
iMid = math.floor( (iStart+iEnd)/2 )
-- get compare value
local value2 = t[iMid]
-- get all values that match
if value == value2 then
local tfound,num = { iMid,iMid },iMid - 1
while value == t[num] do
tfound[1],num = num,num - 1
end
num = iMid + 1
while value == t[num] do
tfound[2],num = num,num + 1
end
return tfound
-- keep searching
elseif fcomp( value,value2 ) then
iEnd = iMid - 1
else
iStart = iMid + 1
end
end
end
-- The interpolationg Search Function on a String
function table.intsearchstr( t,value )
-- Inistialise numbers
local ilow,ihigh = 1,#t
-- return on empty table
if not t[ilow] then return end
-- get byte values values of indices and searched value
local _ilow,_ihigh,_value = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),getbytevalue(value)
local oldpos = -1
-- make sure slope cannot become 0
while _ilow and _ilow < _ihigh do
-- get interpolated position
local pos = math.floor( (_value-_ilow)*(ihigh-ilow)/(_ihigh-_ilow) ) + ilow
-- check for out of range
if pos < ilow or pos > ihigh then return end
-- check for real match
if value == t[pos] then
-- insert found position
local tfound,num = { pos,pos },pos-1
-- get all values that match
while value == t[num] do
tfound[1],num = num,num-1
end
num = pos+1
while value == t[num] do
tfound[2],num = num,num+1
end
return tfound
-- keep searching,
-- left part of the table,check for real lower
elseif value < t[pos] then
ihigh = pos-1
else
ilow = pos+1
end
-- check if new position is further than 1 away
if oldpos+1 == pos or oldpos-1 == pos then
-- start binary search
return tablebinsearch( t,value,_,ilow,ihigh )
end
_ilow,_ihigh,oldpos = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),pos
end
-- initiate binary seach function here since we could be in a flat for the interpolating search
return tablebinsearch( t,value,_,ilow,ihigh )
end
-- The interpolationg Search Function on a String
function table.intsearchstrrev( t,value )
-- Inistialise numbers
local ilow,ihigh = 1,#t
-- return on empty table
if not t[ilow] then return end
-- get byte values values of indices and searched value
local _ilow,_ihigh,_value = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),getbytevalue(value)
local oldpos = -1
-- make sure slope cannot become 0
while _ilow and _ilow > _ihigh do
-- get interpolated position
local pos = math.floor( (_ihigh-_value)*(ihigh-ilow)/(_ihigh-_ilow) ) + ilow
-- check for out of range
if pos < ilow or pos > ihigh then return end
-- check for real match
if value == t[pos] then
-- insert found position
local tfound,num = { pos,pos },pos-1
-- get all values that match
while value == t[num] do
tfound[1],num = num,num-1
end
num = pos+1
while value == t[num] do
tfound[2],num = num,num+1
end
return tfound
-- keep searching,
-- left part of the table,check for real lower
elseif value > t[pos] then
ihigh = pos-1
else
ilow = pos+1
end
-- check if new position is further than 1 away
if oldpos+1 == pos or oldpos-1 == pos then
-- start binary search
return tablebinsearch( t,value,1,ilow,ihigh )
end
_ilow,_ihigh,oldpos = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),pos
end
-- initiate binary seach function here since we could be in a flat for the interpolating search
return tablebinsearch( t,value,1,ilow,ihigh )
end
end
-- CHILLCODE™
--[[
Interpolating Search on a String
LUA 5.1 compatible
Can only search sorted tables with value string
table.intsearchstr( table, value ), for searching a normal sorted table
table.intsearchstrrev( table, value ), for searching a reversed sorted table
If the value is found:
it returns a table holding all the matching indices (e.g. { startindice,endindice } )
endindice may be the same as startindice if only one matching indice was found
Return value:
on success: a table holding matching indices (e.g. { startindice,endindice } )
on failure: nil
]]--
do
-- Avoid heap allocs for performance
local getbytevalue = function( value )
if value then
local num,mul = 0,1
-- set bytedept, 4 or 5 seems appropriate
for i = 4,1,-1 do
local byte = string.byte( string.sub( value,i,i ) ) or -1
byte,num,mul = byte + 1,num + mul*byte,mul*257
end
return num
end
end
-- Load the optimised binary function
-- Avoid heap allocs for performance
local fcompf = function( a,b ) return a < b end
local fcompr = function( a,b ) return a > b end
local function tablebinsearch( t,value,reversed,iStart,iEnd )
-- Initialise functions
local fcomp = reversed and fcompr or fcompf
-- Initialise numbers
local iStart,iEnd,iMid = iStart or 1,iEnd or #t,0
-- Binary Search
while iStart <= iEnd do
-- calculate middle
iMid = math.floor( (iStart+iEnd)/2 )
-- get compare value
local value2 = t[iMid]
-- get all values that match
if value == value2 then
local tfound,num = { iMid,iMid },iMid - 1
while value == t[num] do
tfound[1],num = num,num - 1
end
num = iMid + 1
while value == t[num] do
tfound[2],num = num,num + 1
end
return tfound
-- keep searching
elseif fcomp( value,value2 ) then
iEnd = iMid - 1
else
iStart = iMid + 1
end
end
end
-- The interpolationg Search Function on a String
function table.intsearchstr( t,value )
-- Inistialise numbers
local ilow,ihigh = 1,#t
-- return on empty table
if not t[ilow] then return end
-- get byte values values of indices and searched value
local _ilow,_ihigh,_value = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),getbytevalue(value)
local oldpos = -1
-- make sure slope cannot become 0
while _ilow and _ilow < _ihigh do
-- get interpolated position
local pos = math.floor( (_value-_ilow)*(ihigh-ilow)/(_ihigh-_ilow) ) + ilow
-- check for out of range
if pos < ilow or pos > ihigh then return end
-- check for real match
if value == t[pos] then
-- insert found position
local tfound,num = { pos,pos },pos-1
-- get all values that match
while value == t[num] do
tfound[1],num = num,num-1
end
num = pos+1
while value == t[num] do
tfound[2],num = num,num+1
end
return tfound
-- keep searching,
-- left part of the table,check for real lower
elseif value < t[pos] then
ihigh = pos-1
else
ilow = pos+1
end
-- check if new position is further than 1 away
if oldpos+1 == pos or oldpos-1 == pos then
-- start binary search
return tablebinsearch( t,value,_,ilow,ihigh )
end
_ilow,_ihigh,oldpos = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),pos
end
-- initiate binary seach function here since we could be in a flat for the interpolating search
return tablebinsearch( t,value,_,ilow,ihigh )
end
-- The interpolationg Search Function on a String
function table.intsearchstrrev( t,value )
-- Inistialise numbers
local ilow,ihigh = 1,#t
-- return on empty table
if not t[ilow] then return end
-- get byte values values of indices and searched value
local _ilow,_ihigh,_value = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),getbytevalue(value)
local oldpos = -1
-- make sure slope cannot become 0
while _ilow and _ilow > _ihigh do
-- get interpolated position
local pos = math.floor( (_ihigh-_value)*(ihigh-ilow)/(_ihigh-_ilow) ) + ilow
-- check for out of range
if pos < ilow or pos > ihigh then return end
-- check for real match
if value == t[pos] then
-- insert found position
local tfound,num = { pos,pos },pos-1
-- get all values that match
while value == t[num] do
tfound[1],num = num,num-1
end
num = pos+1
while value == t[num] do
tfound[2],num = num,num+1
end
return tfound
-- keep searching,
-- left part of the table,check for real lower
elseif value > t[pos] then
ihigh = pos-1
else
ilow = pos+1
end
-- check if new position is further than 1 away
if oldpos+1 == pos or oldpos-1 == pos then
-- start binary search
return tablebinsearch( t,value,1,ilow,ihigh )
end
_ilow,_ihigh,oldpos = getbytevalue(t[ilow]),getbytevalue(t[ihigh]),pos
end
-- initiate binary seach function here since we could be in a flat for the interpolating search
return tablebinsearch( t,value,1,ilow,ihigh )
end
end
-- CHILLCODE™
| bsd-3-clause |
dickeyf/darkstar | scripts/globals/weaponskills/tachi_hobaku.lua | 1 | 1680 | -----------------------------------
-- Tachi Hobaku
-- Great Katana weapon skill
-- Skill Level: 30
-- Stuns enemy. Chance of stun varies with TP.
-- Will stack with Sneak Attack.
-- Aligned with the Snow Gorget.
-- Aligned with the Snow Belt.
-- Element: None
-- Modifiers: STR:60%
-- 100%TP 200%TP 300%TP
-- 1.00 1.00 1.00
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary)
local params = {};
params.numHits = 1;
params.ftp100 = 1; params.ftp200 = 1; params.ftp300 = 1;
params.str_wsc = 0.3; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
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.atkmulti = 1;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.str_wsc = 0.6; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, primary);
local chance = player:getTP()-100 > math.random()*150;
if (damage > 0 and chance) then
if (target:hasStatusEffect(EFFECT_STUN) == false) then
target:addStatusEffect(EFFECT_STUN, 1, 0, 4);
end
end
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c10117149.lua | 2 | 3492 | --ブンボーグ005
function c10117149.initial_effect(c)
--pendulum summon
aux.EnablePendulumAttribute(c)
--splimit
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetRange(LOCATION_PZONE)
e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_CANNOT_NEGATE)
e2:SetTargetRange(1,0)
e2:SetTarget(c10117149.splimit)
c:RegisterEffect(e2)
--destroy
local e3=Effect.CreateEffect(c)
e3:SetCategory(CATEGORY_DESTROY)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetCode(EVENT_SUMMON_SUCCESS)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
e3:SetTarget(c10117149.destg)
e3:SetOperation(c10117149.desop)
c:RegisterEffect(e3)
local e4=e3:Clone()
e4:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e4)
--atk up
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_SINGLE)
e5:SetCode(EFFECT_UPDATE_ATTACK)
e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e5:SetRange(LOCATION_MZONE)
e5:SetValue(c10117149.atkval)
c:RegisterEffect(e5)
--spsummon
local e6=Effect.CreateEffect(c)
e6:SetCategory(CATEGORY_SPECIAL_SUMMON)
e6:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e6:SetCode(EVENT_DESTROYED)
e6:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
e6:SetCountLimit(1,10117149)
e6:SetCondition(c10117149.spcon)
e6:SetTarget(c10117149.sptg)
e6:SetOperation(c10117149.spop)
c:RegisterEffect(e6)
end
function c10117149.splimit(e,c,tp,sumtp,sumpos)
return not c:IsSetCard(0xab) and bit.band(sumtp,SUMMON_TYPE_PENDULUM)==SUMMON_TYPE_PENDULUM
end
function c10117149.desfilter(c)
return c:IsType(TYPE_SPELL+TYPE_TRAP)
end
function c10117149.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() and c10117149.desfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c10117149.desfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,c10117149.desfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
end
function c10117149.desop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.Destroy(tc,REASON_EFFECT)
end
end
function c10117149.cfilter(c)
return c:IsFaceup() and c:IsSetCard(0xab)
end
function c10117149.atkval(e,c)
return Duel.GetMatchingGroupCount(c10117149.cfilter,c:GetControler(),LOCATION_EXTRA,0,nil)*500
end
function c10117149.spcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsPreviousLocation(LOCATION_SZONE) and (c:GetPreviousSequence()==6 or c:GetPreviousSequence()==7)
end
function c10117149.spfilter(c,e,tp)
return c:IsSetCard(0xab) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c10117149.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c10117149.spfilter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c10117149.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c10117149.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c10117149.spop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c100213059.lua | 2 | 2235 | --螺旋のストライクバースト
--Spiral Flame Strike
--Scripted by Eerie Code
function c100213059.initial_effect(c)
--activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,0x1e0)
e1:SetTarget(c100213059.target)
c:RegisterEffect(e1)
end
function c100213059.desfilter(c)
return c:IsFaceup() and c:IsSetCard(0x99)
end
function c100213059.thfilter(c)
return c:IsSetCard(0x99) and c:GetLevel()==7 and (c:IsFaceup() or not c:IsLocation(LOCATION_EXTRA)) and c:IsAbleToHand()
end
function c100213059.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_ONFIELD) end
local b1=Duel.IsExistingMatchingCard(c100213059.desfilter,tp,LOCATION_ONFIELD,0,1,nil)
and Duel.IsExistingTarget(nil,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,e:GetHandler())
local b2=Duel.IsExistingMatchingCard(c100213059.thfilter,tp,LOCATION_DECK+LOCATION_EXTRA,0,1,nil)
if chk==0 then return b1 or b2 end
local op=0
if b1 and b2 then
op=Duel.SelectOption(tp,aux.Stringid(100213059,0),aux.Stringid(100213059,1))
elseif b1 then
op=Duel.SelectOption(tp,aux.Stringid(100213059,0))
else
op=Duel.SelectOption(tp,aux.Stringid(100213059,1))+1
end
if op==0 then
e:SetCategory(CATEGORY_DESTROY)
e:SetProperty(EFFECT_FLAG_CARD_TARGET)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,nil,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,e:GetHandler())
e:SetOperation(c100213059.desop)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
else
e:SetCategory(CATEGORY_TOHAND)
e:SetProperty(0)
local g=Duel.GetMatchingGroup(c100213059.thfilter,tp,LOCATION_DECK+LOCATION_EXTRA,0,nil)
e:SetOperation(c100213059.thop)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
end
function c100213059.desop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then Duel.Destroy(tc,REASON_EFFECT) end
end
function c100213059.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c100213059.thfilter,tp,LOCATION_DECK+LOCATION_EXTRA,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
| gpl-2.0 |
dickeyf/darkstar | scripts/zones/Heavens_Tower/npcs/Kupipi.lua | 13 | 7287 | -----------------------------------
-- Area: Heaven's Tower
-- NPC: Kupipi
-- Involved in Mission 2-3
-- Involved in Quest: Riding on the Clouds
-- @pos 2 0.1 30 242
-----------------------------------
package.loaded["scripts/zones/Heavens_Tower/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/globals/missions");
require("scripts/zones/Heavens_Tower/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(JEUNO,RIDING_ON_THE_CLOUDS) == QUEST_ACCEPTED and player:getVar("ridingOnTheClouds_4") == 8) then
if (trade:hasItemQty(1127,1) and trade:getItemCount() == 1) then -- Trade Kindred seal
player:setVar("ridingOnTheClouds_4",0);
player:tradeComplete();
player:addKeyItem(SPIRITED_STONE);
player:messageSpecial(KEYITEM_OBTAINED,SPIRITED_STONE);
end
end
if (trade:hasItemQty(4365,1) and trade:getItemCount() == 1 and player:getNation() == WINDURST and player:getRank() >= 2 and player:hasKeyItem(PORTAL_CHARM) == false) then -- Trade Rolanberry
if (player:hasCompletedMission(WINDURST,WRITTEN_IN_THE_STARS)) then
player:startEvent(0x0123); -- Qualifies for the reward immediately
else
player:startEvent(0x0124); -- Kupipi owes you the portal charm later
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local pNation = player:getNation();
local currentMission = player:getCurrentMission(pNation);
local MissionStatus = player:getVar("MissionStatus");
if (pNation == SANDORIA) then
-- San d'Oria Mission 2-3 Part I - Windurst > Bastok
if (currentMission == JOURNEY_TO_WINDURST) then
if (MissionStatus == 4) then
player:startEvent(0x00ee,1,1,1,1,pNation);
elseif (MissionStatus == 5) then
player:startEvent(0x00f0);
elseif (MissionStatus == 6) then
player:startEvent(0x00f1);
end
-- San d'Oria Mission 2-3 Part II - Bastok > Windurst
elseif (currentMission == JOURNEY_TO_WINDURST2) then
if (MissionStatus == 7) then
player:startEvent(0x00f2,1,1,1,1,0);
elseif (MissionStatus == 8) then
player:startEvent(0x00f3);
elseif (MissionStatus == 9) then
player:startEvent(0x00f6);
elseif (MissionStatus == 10) then
player:startEvent(0x00f7);
end
else
player:startEvent(0x00fb);
end
elseif (pNation == BASTOK) then
-- Bastok Mission 2-3 Part I - Windurst > San d'Oria
if (currentMission == THE_EMISSARY_WINDURST) then
if (MissionStatus == 3) then
player:startEvent(0x00ee,1,1,1,1,pNation);
elseif (MissionStatus <= 5) then
player:startEvent(0x00f0);
elseif (MissionStatus == 6) then
player:startEvent(0x00f1);
end
-- Bastok Mission 2-3 Part II - San d'Oria > Windurst
elseif (currentMission == THE_EMISSARY_WINDURST2) then
if (MissionStatus == 7) then
player:startEvent(0x00f2,1,1,1,1,pNation);
elseif (MissionStatus == 8) then
player:startEvent(0x00f3);
elseif (MissionStatus == 9) then
player:startEvent(0x00f4);
elseif (MissionStatus == 10) then
player:startEvent(0x00f5);
end
else
player:startEvent(0x00fb);
end
elseif (pNation == WINDURST) then
if (currentMission == THE_THREE_KINGDOMS and MissionStatus == 0) then
player:startEvent(0x005F,0,0,0,LETTER_TO_THE_CONSULS_WINDURST);
elseif (currentMission == THE_THREE_KINGDOMS and MissionStatus == 11) then
player:startEvent(0x0065,0,0,ADVENTURERS_CERTIFICATE);
elseif (currentMission == THE_THREE_KINGDOMS) then
player:startEvent(0x0061);
elseif (currentMission == TO_EACH_HIS_OWN_RIGHT and MissionStatus == 0) then
player:startEvent(0x0067,0,0,STARWAY_STAIRWAY_BAUBLE);
elseif (currentMission == TO_EACH_HIS_OWN_RIGHT and MissionStatus == 1) then
player:startEvent(0x0068);
elseif (player:getCurrentMission(WINDURST) == THE_JESTER_WHO_D_BE_KING and MissionStatus == 3) then
player:startEvent(0x0146);
elseif (player:hasCompletedMission(WINDURST,WRITTEN_IN_THE_STARS) and player:getVar("OwesPortalCharm") == 1) then
player:startEvent(0x0125); -- Kupipi repays your favor
else
player:startEvent(0x00fb);
end
else
player:startEvent(0x00fb);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x00ee) then
if (player:getNation() == BASTOK) then
player:setVar("MissionStatus",4);
player:addKeyItem(SWORD_OFFERING);
player:messageSpecial(KEYITEM_OBTAINED,SWORD_OFFERING);
else
player:setVar("MissionStatus",5);
player:addKeyItem(SHIELD_OFFERING);
player:messageSpecial(KEYITEM_OBTAINED,SHIELD_OFFERING);
end
elseif (csid == 0x00f4 or csid == 0x00f6) then
player:setVar("MissionStatus",10);
elseif (csid == 0x00f2) then
player:addKeyItem(DARK_KEY);
player:messageSpecial(KEYITEM_OBTAINED,DARK_KEY);
player:setVar("MissionStatus",8);
elseif (csid == 0x005F) then
player:setVar("MissionStatus",1);
player:addKeyItem(LETTER_TO_THE_CONSULS_WINDURST);
player:messageSpecial(KEYITEM_OBTAINED,LETTER_TO_THE_CONSULS_WINDURST);
elseif (csid == 0x0067) then
player:setVar("MissionStatus",1);
player:addKeyItem(STARWAY_STAIRWAY_BAUBLE);
player:messageSpecial(KEYITEM_OBTAINED,STARWAY_STAIRWAY_BAUBLE);
elseif (csid == 0x0065) then
finishMissionTimeline(player,1,csid,option);
elseif (csid == 0x0123) then -- All condition met, grant Portal Charm
player:tradeComplete();
player:addKeyItem(PORTAL_CHARM);
player:messageSpecial(KEYITEM_OBTAINED,PORTAL_CHARM);
elseif (csid == 0x0124) then -- Traded rolanberry, but not all conditions met
player:tradeComplete();
player:setVar("OwesPortalCharm",1);
elseif (csid == 0x0125) then -- Traded rolanberry before, and all conditions are now met
player:setVar("OwesPortalCharm",0);
player:addKeyItem(PORTAL_CHARM);
player:messageSpecial(KEYITEM_OBTAINED,PORTAL_CHARM);
elseif (csid == 0x0146) then
player:setVar("MissionStatus",4);
end
end; | gpl-3.0 |
dickeyf/darkstar | scripts/zones/Northern_San_dOria/npcs/Olbergieut.lua | 1 | 2329 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Olbergieut
-- Type: Quest NPC
-- @zone 231
-- @pos 91 0 121
--
-- Starts and Finishes Quest: Gates of Paradise
-----------------------------------
package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/zones/Northern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
gates = player:getQuestStatus(SANDORIA,GATES_TO_PARADISE);
if (player:hasKeyItem(SCRIPTURE_OF_WATER) == true) then
player:startEvent(0x026c);
elseif (gates == QUEST_ACCEPTED) then
player:showText(npc, OLBERGIEUT_DIALOG, SCRIPTURE_OF_WIND);
elseif (player:getFameLevel(SANDORIA) >= 2 and gates == QUEST_AVAILABLE) then
player:startEvent(0x026b);
else
player:startEvent(0x0264);
end;
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x026b and option == 0) then
player:addQuest(SANDORIA, GATES_TO_PARADISE);
player:addKeyItem(SCRIPTURE_OF_WIND);
player:messageSpecial(KEYITEM_OBTAINED, SCRIPTURE_OF_WIND);
elseif (csid == 0x026c) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED, 13584);
else
player:completeQuest(SANDORIA,GATES_TO_PARADISE);
player:addFame(SANDORIA,SAN_FAME*30);
player:addTitle(THE_PIOUS_ONE);
player:delKeyItem(SCRIPTURE_OF_WATER);
player:addItem(13584,1);
player:messageSpecial(ITEM_OBTAINED,13584);
end;
end;
end;
| gpl-3.0 |
Turttle/darkstar | scripts/zones/Bastok_Mines/npcs/Emaliveulaux.lua | 30 | 1948 | -----------------------------------
-- Area: Bastok Mines
-- NPC: Emaliveulaux
-- Only sells when Bastok controls the Tavnazian Archipelago
-- Only available to those with CoP Ch. 4.1 or higher
-----------------------------------
require("scripts/globals/events/harvest_festivals");
require("scripts/globals/shop");
require("scripts/globals/conquest");
package.loaded["scripts/zones/Bastok_Mines/TextIDs"] = nil;
require("scripts/zones/Bastok_Mines/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
onHalloweenTrade(player,trade,npc)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
RegionOwner = GetRegionOwner(TAVNAZIANARCH);
cop = 40; --player:getVar("chainsOfPromathiaMissions");
if (cop >= 40) then
if (RegionOwner ~= BASTOK) then
player:showText(npc,EMALIVEULAUX_CLOSED_DIALOG);
else
player:showText(npc,EMALIVEULAUX_OPEN_DIALOG);
stock = {0x05f3,290, --Apple Mint
0x142c,1945, --Ground Wasabi
0x426d,99, --Lufaise Fly
0x144b,233} --Misareaux Parsley
showShop(player,BASTOK,stock);
end
else
player:showText(npc,EMALIVEULAUX_COP_NOT_COMPLETED);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
dickeyf/darkstar | scripts/zones/Windurst_Waters_[S]/npcs/Mindala-Andola_CC.lua | 13 | 1074 | -----------------------------------
-- Area: Windurst Waters (S)
-- NPC: Mindala-Andola, C.C.
-- Type: Sigil
-- @zone: 94
-- @pos -31.869 -6.009 226.793
--
-- Auto-Script: Requires Verification (Verified by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters_[S]/TextIDs"] = nil;
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x000d, npc);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
Turttle/darkstar | scripts/zones/Spire_of_Vahzl/Zone.lua | 17 | 1582 | -----------------------------------
--
-- Zone: Spire_of_Vahzl (23)
--
-----------------------------------
package.loaded["scripts/zones/Spire_of_Vahzl/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Spire_of_Vahzl/TextIDs");
require("scripts/globals/missions");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
player:setPos(-0.039,-2.049,293.640,64); -- Floor 1 {R}
end
if (player:getCurrentMission(COP) == DESIRES_OF_EMPTINESS and player:getVar("PromathiaStatus")==7) then
cs = 0x0014;
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x0014) then
player:setVar("PromathiaStatus",8);
end
end;
| gpl-3.0 |
deepmind/meltingpot | meltingpot/lua/levels/coop_mining/components.lua | 1 | 9293 | --[[ Copyright 2022 DeepMind Technologies Limited.
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
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
]]
local args = require 'common.args'
local class = require 'common.class'
local events = require 'system.events'
local helpers = require 'common.helpers'
local log = require 'common.log'
local random = require 'system.random'
local tensor = require 'system.tensor'
local meltingpot = 'meltingpot.lua.modules.'
local component = require(meltingpot .. 'component')
local component_registry = require(meltingpot .. 'component_registry')
local FixedRateRegrow = class.Class(component.Component)
function FixedRateRegrow:__init__(kwargs)
kwargs = args.parse(kwargs, {
{'name', args.default('FixedRateRegrow')},
{'liveStates', args.tableType},
{'liveRates', args.tableType},
{'waitState', args.stringType},
})
self.Base.__init__(self, kwargs)
self._config.liveStates = kwargs.liveStates
self._config.liveRates = kwargs.liveRates
self._config.waitState = kwargs.waitState
end
function FixedRateRegrow:registerUpdaters(updaterRegistry)
for i, rate in ipairs(self._config.liveRates) do
updaterRegistry:registerUpdater{
priority = 200,
state = self._config.waitState,
probability = rate,
updateFn = function()
local transform = self.gameObject:getComponent('Transform')
local maybeAvatar = transform:queryPosition('upperPhysical')
if not maybeAvatar then
self.gameObject:setState(self._config.liveStates[i])
end
end,
}
end
end
local Ore = class.Class(component.Component)
function Ore:__init__(kwargs)
kwargs = args.parse(kwargs, {
{'name', args.default('Ore')},
{'rawState', args.stringType},
{'waitState', args.stringType},
{'partialState', args.stringType},
{'minNumMiners', args.numberType},
{'miningWindow', args.numberType},
})
self.Base.__init__(self, kwargs)
self._config.rawState = kwargs.rawState
self._config.waitState = kwargs.waitState
self._config.partialState = kwargs.partialState
self._config.minNumMiners = kwargs.minNumMiners
self._config.miningWindow = kwargs.miningWindow
end
function Ore:currentMiners()
local count = 0
for k, v in pairs(self._miners) do
count = count + 1
end
return count
end
function Ore:reset()
-- Table tracking which players have attempted mining this resource.
self._miners = {}
self._miningCountdown = 0
if self.gameObject:getState() ~= self._config.waitState then
self.gameObject:setState(self._config.rawState)
end
end
function Ore:update()
self._miningCountdown = self._miningCountdown - 1
if self._miningCountdown == 0 then
-- Clean miners
self:reset()
end
end
function Ore:addMiner(minerId)
self._miningCountdown = self._config.miningWindow
self._miners[minerId] = 1
self.gameObject:setState(self._config.partialState)
end
function Ore:onHit(hitterGameObject, hitName)
if hitName == 'mine' and
(self.gameObject:getState() == self._config.rawState or
self.gameObject:getState() == self._config.partialState) then
local hitterIndex = hitterGameObject:getComponent('Avatar'):getIndex()
self:addMiner(hitterIndex)
local hitterMineBeam = hitterGameObject:getComponent('MineBeam')
hitterMineBeam:processRoleMineEvent(self._config.minNumMiners)
-- If the Ore has enough miners, process rewards.
if self:currentMiners() == self._config.minNumMiners then
for id, _ in pairs(self._miners) do
local avatarGO = self.gameObject.simulation:getAvatarFromIndex(id)
avatarGO:getComponent('MineBeam'):processRoleExtractEvent(
self._config.minNumMiners)
for otherId, _ in pairs(self._miners) do
if otherId ~= id then
avatarGO:getComponent('MineBeam'):processRolePairExtractEvent(
otherId, self._config.minNumMiners)
end
end
end
self:reset()
self.gameObject:setState(self._config.waitState)
end
-- return `true` to prevent the beam from passing through a hit ore.
return true
end
-- Other beams, or if in state not raw nor partial can pass through.
return false
end
--[[ The `MineBeam` component endows an avatar with the ability to fire a beam.
]]
local MineBeam = class.Class(component.Component)
function MineBeam:__init__(kwargs)
kwargs = args.parse(kwargs, {
{'name', args.default('MineBeam')},
{'cooldownTime', args.numberType},
{'beamLength', args.numberType},
{'beamRadius', args.numberType},
{'agentRole', args.stringType},
-- These two must be tables indexed by [role][oreType]
{'roleRewardForMining', args.tableType},
{'roleRewardForExtracting', args.tableType},
})
self.Base.__init__(self, kwargs)
self._config.cooldownTime = kwargs.cooldownTime
self._config.beamLength = kwargs.beamLength
self._config.beamRadius = kwargs.beamRadius
self._config.agentRole = kwargs.agentRole
self._config.roleRewardForMining = kwargs.roleRewardForMining
self._config.roleRewardForExtracting = kwargs.roleRewardForExtracting
self._coolingTimer = 0
end
function MineBeam:readyToShoot()
local normalizedTimeTillReady = self._coolingTimer / self._config.cooldownTime
return 1 - normalizedTimeTillReady
end
function MineBeam:addHits(worldConfig)
worldConfig.hits['mine'] = {
layer = 'beamMine',
sprite = 'beamMine',
}
table.insert(worldConfig.renderOrder, 'beamMine')
end
function MineBeam:addSprites(tileSet)
-- This color is pink.
tileSet:addColor('beamMine', {255, 202, 202})
end
function MineBeam:processRoleMineEvent(oreType)
local amount = self._config.roleRewardForMining[
self._config.agentRole][oreType]
local avatar = self.gameObject:getComponent('Avatar')
avatar:addReward(amount)
events:add("mining", "dict",
"player", avatar:getIndex(),
"ore_type", oreType)
self.playerMined(oreType):add(1)
end
function MineBeam:processRoleExtractEvent(oreType)
local amount = self._config.roleRewardForExtracting[
self._config.agentRole][oreType]
local avatar = self.gameObject:getComponent('Avatar')
avatar:addReward(amount)
local index = avatar:getIndex()
events:add("extraction", "dict",
"player", index,
"ore_type", oreType)
self.playerExtracted(oreType):add(1)
end
function MineBeam:processRolePairExtractEvent(otherId, oreType)
local index = self.gameObject:getComponent('Avatar'):getIndex()
events:add("extraction_pair", "dict",
"player_a", index,
"player_b", otherId,
"ore_type", oreType)
self.coExtracted(otherId, oreType):add(1)
end
function MineBeam:update()
if self._coolingTimer > 0 then
self._coolingTimer = self._coolingTimer - 1
end
-- TODO(b/260338825): It would be good to factor out the firing logic to be in
-- an updater so we can control the exact order of execution within a frame.
-- Right now it depends on the Lua table order that the components are added.
local state = self.gameObject:getComponent('Avatar'):getVolatileData()
local actions = state.actions
-- Execute the beam if applicable.
if actions.mine == 1 and self:readyToShoot() >= 1 then
self._coolingTimer = self._config.cooldownTime
self.gameObject:hitBeam(
'mine', self._config.beamLength, self._config.beamRadius)
end
end
function MineBeam:start()
-- Set the beam cooldown timer to its `ready` state (i.e. coolingTimer = 0).
self._coolingTimer = 0
self.playerMined = self.gameObject:getComponent('MiningTracker').playerMined
self.playerExtracted = self.gameObject:getComponent(
'MiningTracker').playerExtracted
self.coExtracted = self.gameObject:getComponent('MiningTracker').coExtracted
end
--[[ The MiningTracker keeps track of the mining metrics.]]
local MiningTracker = class.Class(component.Component)
function MiningTracker:__init__(kwargs)
kwargs = args.parse(kwargs, {
{'name', args.default('MiningTracker')},
{'numPlayers', args.numberType},
{'numOreTypes', args.numberType},
})
self.Base.__init__(self, kwargs)
self._config.numPlayers = kwargs.numPlayers
self._config.numOreTypes = kwargs.numOreTypes
end
function MiningTracker:reset()
self.playerMined = tensor.Int32Tensor(self._config.numOreTypes)
self.playerExtracted = tensor.Int32Tensor(self._config.numOreTypes)
self.coExtracted = tensor.Int32Tensor(
self._config.numPlayers,
self._config.numOreTypes)
end
function MiningTracker:preUpdate()
self.playerMined:fill(0)
self.playerExtracted:fill(0)
self.coExtracted:fill(0)
end
local allComponents = {
FixedRateRegrow = FixedRateRegrow,
Ore = Ore,
MineBeam = MineBeam,
MiningTracker = MiningTracker,
}
component_registry.registerAllComponents(allComponents)
return allComponents
| apache-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c9888196.lua | 6 | 4233 | --A・O・J ディサイシブ・アームズ
function c9888196.initial_effect(c)
--synchro summon
aux.AddSynchroProcedure(c,nil,aux.NonTuner(nil),2)
c:EnableReviveLimit()
--destroy1
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(9888196,0))
e1:SetCategory(CATEGORY_DESTROY)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE)
e1:SetRange(LOCATION_MZONE)
e1:SetCondition(c9888196.con)
e1:SetTarget(c9888196.destg1)
e1:SetOperation(c9888196.desop1)
c:RegisterEffect(e1)
--destroy2
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(9888196,1))
e2:SetCategory(CATEGORY_DESTROY)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE)
e2:SetRange(LOCATION_MZONE)
e2:SetCondition(c9888196.con)
e2:SetCost(c9888196.descost2)
e2:SetTarget(c9888196.destg2)
e2:SetOperation(c9888196.desop2)
c:RegisterEffect(e2)
--handes
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(9888196,2))
e3:SetCategory(CATEGORY_HANDES+CATEGORY_TOGRAVE+CATEGORY_DAMAGE)
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE)
e3:SetRange(LOCATION_MZONE)
e3:SetCondition(c9888196.con)
e3:SetCost(c9888196.hdcost)
e3:SetTarget(c9888196.hdtg)
e3:SetOperation(c9888196.hdop)
c:RegisterEffect(e3)
end
function c9888196.confilter(c)
return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_LIGHT)
end
function c9888196.con(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsExistingMatchingCard(c9888196.confilter,tp,0,LOCATION_MZONE,1,nil)
end
function c9888196.filter1(c)
return c:IsFacedown()
end
function c9888196.destg1(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(1-tp) and chkc:IsOnField() and c9888196.filter1(chkc) end
if chk==0 then return Duel.IsExistingTarget(c9888196.filter1,tp,0,LOCATION_ONFIELD,1,nil) end
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,c9888196.filter1,tp,0,LOCATION_ONFIELD,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
end
function c9888196.desop1(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsFacedown() then
Duel.Destroy(tc,REASON_EFFECT)
end
end
function c9888196.descost2(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost,tp,LOCATION_HAND,0,1,nil) end
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,Card.IsAbleToGraveAsCost,tp,LOCATION_HAND,0,1,1,nil)
Duel.SendtoGrave(g,REASON_COST)
end
function c9888196.filter2(c)
return c:IsType(TYPE_SPELL+TYPE_TRAP)
end
function c9888196.destg2(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c9888196.filter2,tp,0,LOCATION_ONFIELD,1,nil) end
local g=Duel.GetMatchingGroup(c9888196.filter2,tp,0,LOCATION_ONFIELD,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
end
function c9888196.desop2(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(c9888196.filter2,tp,0,LOCATION_ONFIELD,nil)
Duel.Destroy(g,REASON_EFFECT)
end
function c9888196.hdcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost,tp,LOCATION_HAND,0,1,nil) end
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
local g=Duel.GetFieldGroup(tp,LOCATION_HAND,0)
Duel.SendtoGrave(g,REASON_COST)
end
function c9888196.hdtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetFieldGroupCount(tp,0,LOCATION_HAND)>0 end
Duel.SetOperationInfo(0,CATEGORY_HANDES,nil,0,1-tp,0)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,0,1-tp,LOCATION_HAND)
end
function c9888196.hdop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetFieldGroup(tp,0,LOCATION_HAND)
Duel.ConfirmCards(tp,g)
local sg=g:Filter(Card.IsAttribute,nil,ATTRIBUTE_LIGHT)
if sg:GetCount()>0 then
local atk=0
Duel.SendtoGrave(sg,REASON_EFFECT)
local tc=sg:GetFirst()
while tc do
local tatk=tc:GetAttack()
if tatk<0 then tatk=0 end
atk=atk+tatk
tc=sg:GetNext()
end
Duel.BreakEffect()
Duel.Damage(1-tp,atk,REASON_EFFECT)
end
Duel.ShuffleHand(1-tp)
end
| gpl-2.0 |
fgenesis/Aquaria_experimental | game_scripts/scripts/entities/pet_dumbo.lua | 6 | 4372 | -- Copyright (C) 2007, 2010 - Bit-Blot
--
-- This file is part of Aquaria.
--
-- Aquaria 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, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
if not v then v = {} end
if not AQUARIA_VERSION then dofile("scripts/entities/entityinclude.lua") end
-- P E T D U M BO
local STATE_ATTACKPREP = 1000
local STATE_ATTACK = 1001
v.lungeDelay = 0
v.spinDir = -1
v.rot = 0
v.shotDrop = 0
v.glow = 0
function init(me)
setupBasicEntity(
me,
"", -- texture
4, -- health
1, -- manaballamount
1, -- exp
1, -- money
4, -- collideRadius (only used if hit entities is on)
STATE_IDLE, -- initState
90, -- sprite width
90, -- sprite height
1, -- particle "explosion" type, maps to particleEffects.txt -1 = none
0, -- 0/1 hit other entities off/on (uses collideRadius)
-1, -- updateCull -1: disabled, default: 4000
1
)
entity_initSkeletal(me, "Dumbo")
entity_setDeathParticleEffect(me, "TinyBlueExplode")
v.lungeDelay = 1.0
entity_scale(me, 0.6, 0.6)
v.rot = 0
esetv(me, EV_LOOKAT, 0)
esetv(me, EV_ENTITYDIED, 1)
esetv(me, EV_TYPEID, EVT_PET)
for i=DT_AVATAR,DT_AVATAR_END do
entity_setDamageTarget(me, i, false)
end
--[[
entity_color(me, 1, 1, 1)
entity_color(me, 0.6, 0.6, 0.6, 0.5, -1, 1)
]]--
bone_setSegs(entity_getBoneByName(me, "Body"), 2, 16, 0.3, 0.3, -0.03, 0, 6, 1)
entity_initEmitter(me, 0, "DumboGlow")
entity_startEmitter(me, 0)
entity_setDeathSound(me, "")
end
function postInit(me)
v.n = getNaija()
end
function update(me, dt)
if getPetPower()==1 then
entity_setColor(me, 1, 0.5, 0.5, 0.1)
else
entity_setColor(me, 1, 1, 1, 1)
end
v.glow = createQuad("Naija/LightFormGlow", 13)
quad_scale(v.glow, 5 + (getPetPower()*8), 5 + (getPetPower()*8))
if not isInputEnabled() or not entity_isUnderWater(v.n) then
entity_setPosition(me, entity_x(v.n), entity_y(v.n), 0.3)
entity_alpha(me, 0, 0.1)
entity_stopEmitter(me, 0)
return
else
entity_alpha(me, 1, 0.1)
entity_startEmitter(me, 0)
end
local naijaUnder = entity_y(v.n) > getWaterLevel()
if naijaUnder then
if entity_y(me)-32 < getWaterLevel() then
entity_setPosition(me, entity_x(me), getWaterLevel()+32)
end
else
if entity_isState(me, STATE_FOLLOW) then
entity_setPosition(me, entity_x(v.n), entity_y(v.n), 0.1)
end
end
if entity_isState(me, STATE_FOLLOW) then
v.rot = v.rot + dt*0.2
if v.rot > 1 then
v.rot = v.rot - 1
end
local dist = 100
local t = 0
local x = 0
local y = 0
if avatar_isRolling() then
dist = 90
v.spinDir = -avatar_getRollDirection()
t = v.rot * 6.28
else
t = v.rot * 6.28
end
if not entity_isEntityInRange(me, v.n, 1024) then
entity_setPosition(me, entity_getPosition(v.n))
end
local a = t
x = x + math.sin(a)*dist
y = y + math.cos(a)*dist
if naijaUnder then
entity_setPosition(me, entity_x(v.n)+x, entity_y(v.n)+y, 0.6)
end
--entity_handleShotCollisions(me)
end
if v.glow ~= 0 then
if entity_isInDarkness(me) then
quad_alpha(v.glow, 1, 0.5)
else
quad_alpha(v.glow, 0, 0.5)
end
end
quad_setPosition(v.glow, entity_getPosition(me))
quad_delete(v.glow, 0.1)
v.glow = 0
end
function entityDied(me, ent)
end
function enterState(me)
if entity_isState(me, STATE_IDLE) then
entity_animate(me, "idle", -1)
elseif entity_isState(me, STATE_FOLLOW) then
entity_animate(me, "idle", -1)
elseif entity_isState(me, STATE_DEAD) then
if v.glow ~= 0 then
quad_delete(v.glow)
v.glow = 0
end
end
end
function exitState(me)
end
function damage(me, attacker, bone, damageType, dmg)
return false
end
function hitSurface(me)
end
function shiftWorlds(me, old, new)
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c48928529.lua | 5 | 1306 | --No.83 ギャラクシー・クィーン
function c48928529.initial_effect(c)
--xyz summon
aux.AddXyzProcedure(c,nil,1,3)
c:EnableReviveLimit()
--attack up
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(48928529,0))
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetCountLimit(1)
e1:SetRange(LOCATION_MZONE)
e1:SetCost(c48928529.cost)
e1:SetOperation(c48928529.operation)
c:RegisterEffect(e1)
end
c48928529.xyz_number=83
function c48928529.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end
e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST)
end
function c48928529.operation(e,tp,eg,ep,ev,re,r,rp,chk)
local g=Duel.GetFieldGroup(tp,LOCATION_MZONE,0)
local tc=g:GetFirst()
while tc do
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,2)
e1:SetValue(1)
tc:RegisterEffect(e1)
local e2=Effect.CreateEffect(e:GetHandler())
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetCode(EFFECT_PIERCE)
e2:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,2)
tc:RegisterEffect(e2)
tc=g:GetNext()
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c232.lua | 2 | 1264 | --Doubulldog
function c232.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCondition(c232.condition)
e1:SetTarget(c232.target)
e1:SetOperation(c232.activate)
c:RegisterEffect(e1)
end
function c232.cfilter(c)
return c:IsFaceup() and c:IsRace(RACE_BEAST)
end
function c232.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsExistingMatchingCard(c232.cfilter,tp,LOCATION_ONFIELD,0,1,nil)
end
function c232.filter(c,e,tp)
return c:IsCode(231) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c232.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c232.filter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK+LOCATION_GRAVE)
end
function c232.activate(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c232.filter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
end
| gpl-2.0 |
dickeyf/darkstar | scripts/globals/spells/invisible.lua | 27 | 1280 | -----------------------------------------
-- Spell: Invisible
-- Lessens chance of being detected by sight.
-- Duration is random number between 30 seconds and 5 minutes
-----------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
if (target:hasStatusEffect(EFFECT_INVISIBLE) == false) then
-- last 7-9 minutes
local duration = math.random(420, 540);
if (target:getMainLvl() < 25) then
duration = duration * target:getMainLvl() / 25; -- level adjustment
end
if (caster:hasStatusEffect(EFFECT_COMPOSURE) == true and caster:getID() == target:getID()) then
duration = duration * 3;
end
if (target:getEquipID(15) == 13692) then -- skulker's cape
duration = duration * 1.5;
end
spell:setMsg(230);
target:addStatusEffect(EFFECT_INVISIBLE,0,10,(math.floor(duration) * SNEAK_INVIS_DURATION_MULTIPLIER));
else
spell:setMsg(75); -- no effect.
end
return EFFECT_INVISIBLE;
end;
| gpl-3.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.