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 |
|---|---|---|---|---|---|
Fenix-XI/Fenix | scripts/zones/Bastok_Markets_[S]/npcs/GentleTiger.lua | 31 | 1775 | ----------------------------------
-- Area: Bastok Markets [S]
-- NPC: GentleTiger
-- Type: Quest
-- @pos -203 -10 1
-----------------------------------
package.loaded["scripts/zones/Bastok_Markets_[S]/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Bastok_Markets_[S]/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local onSabbatical = player:getQuestStatus(CRYSTAL_WAR,ON_SABBATICAL);
local onSabbaticalProgress = player:getVar("OnSabbatical");
if (onSabbatical == QUEST_ACCEPTED) then
if (onSabbaticalProgress == 1) then
player:startEvent(0x002E);
else
player:startEvent(0x002F);
end
elseif (player:getQuestStatus(CRYSTAL_WAR,FIRES_OF_DISCONTENT) == QUEST_ACCEPTED) then
if (player:getVar("FiresOfDiscProg") == 5) then
player:startEvent(0x00A0);
else
player:startEvent(0x00A1);
end
else
player:startEvent(0x006D);
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 == 0x002E) then
player:setVar("OnSabbatical", 2);
elseif (csid == 0x00A0) then
player:setVar("FiresOfDiscProg",6);
end
end;
| gpl-3.0 |
DarkstarProject/darkstar | scripts/globals/mobskills/feather_maelstrom.lua | 11 | 1082 | ---------------------------------------------
-- Feather Maelstrom
-- Sends a storm of feathers to a single target.
-- Additional effect: Bio & Amnesia
---------------------------------------------
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/monstertpmoves")
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
return 0
end
function onMobWeaponSkill(target, mob, skill)
local typeEffect1 = dsp.effect.BIO
local typeEffect2 = dsp.effect.AMNESIA
local numhits = 1
local accmod = 2
local dmgmod = 2.8
local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_DMG_VARIES,1,2,3)
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,dsp.attackType.PHYSICAL,dsp.damageType.PIERCING,info.hitslanded)
MobPhysicalStatusEffectMove(mob, target, skill, typeEffect1, 6, 3, 60)
MobPhysicalStatusEffectMove(mob, target, skill, typeEffect2, 1, 0, 60)
target:takeDamage(dmg, mob, dsp.attackType.PHYSICAL, dsp.damageType.PIERCING)
return dmg
end | gpl-3.0 |
8devices/carambola2-luci | modules/base/luasrc/controller/admin/servicectl.lua | 76 | 1376 | --[[
LuCI - Lua Configuration Interface
Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
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$
]]--
module("luci.controller.admin.servicectl", package.seeall)
function index()
entry({"servicectl"}, alias("servicectl", "status")).sysauth = "root"
entry({"servicectl", "status"}, call("action_status")).leaf = true
entry({"servicectl", "restart"}, call("action_restart")).leaf = true
end
function action_status()
local data = nixio.fs.readfile("/var/run/luci-reload-status")
if data then
luci.http.write("/etc/config/")
luci.http.write(data)
else
luci.http.write("finish")
end
end
function action_restart(args)
local uci = require "luci.model.uci".cursor()
if args then
local service
local services = { }
for service in args:gmatch("[%w_-]+") do
services[#services+1] = service
end
local command = uci:apply(services, true)
if nixio.fork() == 0 then
local i = nixio.open("/dev/null", "r")
local o = nixio.open("/dev/null", "w")
nixio.dup(i, nixio.stdin)
nixio.dup(o, nixio.stdout)
i:close()
o:close()
nixio.exec("/bin/sh", unpack(command))
else
luci.http.write("OK")
os.exit(0)
end
end
end
| apache-2.0 |
tcatm/luci | applications/luci-app-commands/luasrc/controller/commands.lua | 53 | 5756 | -- Copyright 2012 Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
module("luci.controller.commands", package.seeall)
function index()
entry({"admin", "system", "commands"}, firstchild(), _("Custom Commands"), 80)
entry({"admin", "system", "commands", "dashboard"}, template("commands"), _("Dashboard"), 1)
entry({"admin", "system", "commands", "config"}, cbi("commands"), _("Configure"), 2)
entry({"admin", "system", "commands", "run"}, call("action_run"), nil, 3).leaf = true
entry({"admin", "system", "commands", "download"}, call("action_download"), nil, 3).leaf = true
entry({"command"}, call("action_public"), nil, 1).leaf = true
end
--- Decode a given string into arguments following shell quoting rules
--- [[abc \def "foo\"bar" abc'def']] -> [[abc def]] [[foo"bar]] [[abcdef]]
local function parse_args(str)
local args = { }
local function isspace(c)
if c == 9 or c == 10 or c == 11 or c == 12 or c == 13 or c == 32 then
return c
end
end
local function isquote(c)
if c == 34 or c == 39 or c == 96 then
return c
end
end
local function isescape(c)
if c == 92 then
return c
end
end
local function ismeta(c)
if c == 36 or c == 92 or c == 96 then
return c
end
end
--- Convert given table of byte values into a Lua string and append it to
--- the "args" table. Segment byte value sequence into chunks of 256 values
--- to not trip over the parameter limit for string.char()
local function putstr(bytes)
local chunks = { }
local csz = 256
local upk = unpack
local chr = string.char
local min = math.min
local len = #bytes
local off
for off = 1, len, csz do
chunks[#chunks+1] = chr(upk(bytes, off, min(off + csz - 1, len)))
end
args[#args+1] = table.concat(chunks)
end
--- Scan substring defined by the indexes [s, e] of the string "str",
--- perform unquoting and de-escaping on the fly and store the result in
--- a table of byte values which is passed to putstr()
local function unquote(s, e)
local off, esc, quote
local res = { }
for off = s, e do
local byte = str:byte(off)
local q = isquote(byte)
local e = isescape(byte)
local m = ismeta(byte)
if e then
esc = true
elseif esc then
if m then res[#res+1] = 92 end
res[#res+1] = byte
esc = false
elseif q and quote and q == quote then
quote = nil
elseif q and not quote then
quote = q
else
if m then res[#res+1] = 92 end
res[#res+1] = byte
end
end
putstr(res)
end
--- Find substring boundaries in "str". Ignore escaped or quoted
--- whitespace, pass found start- and end-index for each substring
--- to unquote()
local off, esc, start, quote
for off = 1, #str + 1 do
local byte = str:byte(off)
local q = isquote(byte)
local s = isspace(byte) or (off > #str)
local e = isescape(byte)
if esc then
esc = false
elseif e then
esc = true
elseif q and quote and q == quote then
quote = nil
elseif q and not quote then
start = start or off
quote = q
elseif s and not quote then
if start then
unquote(start, off - 1)
start = nil
end
else
start = start or off
end
end
--- If the "quote" is still set we encountered an unfinished string
if quote then
unquote(start, #str)
end
return args
end
local function parse_cmdline(cmdid, args)
local uci = require "luci.model.uci".cursor()
if uci:get("luci", cmdid) == "command" then
local cmd = uci:get_all("luci", cmdid)
local argv = parse_args(cmd.command)
local i, v
if cmd.param == "1" and args then
for i, v in ipairs(parse_args(luci.http.urldecode(args))) do
argv[#argv+1] = v
end
end
for i, v in ipairs(argv) do
if v:match("[^%w%.%-i/]") then
argv[i] = '"%s"' % v:gsub('"', '\\"')
end
end
return argv
end
end
function action_run(...)
local fs = require "nixio.fs"
local argv = parse_cmdline(...)
if argv then
local outfile = os.tmpname()
local errfile = os.tmpname()
local rv = os.execute(table.concat(argv, " ") .. " >%s 2>%s" %{ outfile, errfile })
local stdout = fs.readfile(outfile, 1024 * 512) or ""
local stderr = fs.readfile(errfile, 1024 * 512) or ""
fs.unlink(outfile)
fs.unlink(errfile)
local binary = not not (stdout:match("[%z\1-\8\14-\31]"))
luci.http.prepare_content("application/json")
luci.http.write_json({
command = table.concat(argv, " "),
stdout = not binary and stdout,
stderr = stderr,
exitcode = rv,
binary = binary
})
else
luci.http.status(404, "No such command")
end
end
function action_download(...)
local fs = require "nixio.fs"
local argv = parse_cmdline(...)
if argv then
local fd = io.popen(table.concat(argv, " ") .. " 2>/dev/null")
if fd then
local chunk = fd:read(4096) or ""
local name
if chunk:match("[%z\1-\8\14-\31]") then
luci.http.header("Content-Disposition", "attachment; filename=%s"
% fs.basename(argv[1]):gsub("%W+", ".") .. ".bin")
luci.http.prepare_content("application/octet-stream")
else
luci.http.header("Content-Disposition", "attachment; filename=%s"
% fs.basename(argv[1]):gsub("%W+", ".") .. ".txt")
luci.http.prepare_content("text/plain")
end
while chunk do
luci.http.write(chunk)
chunk = fd:read(4096)
end
fd:close()
else
luci.http.status(500, "Failed to execute command")
end
else
luci.http.status(404, "No such command")
end
end
function action_public(cmdid, args)
local uci = require "luci.model.uci".cursor()
if cmdid and
uci:get("luci", cmdid) == "command" and
uci:get("luci", cmdid, "public") == "1"
then
action_download(cmdid, args)
else
luci.http.status(403, "Access to command denied")
end
end
| apache-2.0 |
madafaker/lol | bot/seedbot.lua | 1 | 11450 | package.path = package.path .. ';.luarocks/share/lua/5.2/?.lua'
..';.luarocks/share/lua/5.2/?/init.lua'
package.cpath = package.cpath .. ';.luarocks/lib/lua/5.2/?.so'
require("./bot/utils")
VERSION = '1.0'
-- This function is called when tg receive a msg
function on_msg_receive (msg)
if not started then
return
end
local receiver = get_receiver(msg)
print (receiver)
-- vardump(msg)
msg = pre_process_service_msg(msg)
if msg_valid(msg) then
msg = pre_process_msg(msg)
if msg then
match_plugins(msg)
-- mark_read(receiver, ok_cb, false)
end
end
end
function ok_cb(extra, success, result)
end
function on_binlog_replay_end()
started = true
postpone (cron_plugins, false, 60*5.0)
_config = load_config()
-- load plugins
plugins = {}
load_plugins()
end
function msg_valid(msg)
-- Don't process outgoing messages
if msg.out then
print('\27[36mNot valid: msg from us\27[39m')
return false
end
-- Before bot was started
if msg.date < now then
print('\27[36mNot valid: old msg\27[39m')
return false
end
if msg.unread == 0 then
print('\27[36mNot valid: readed\27[39m')
return false
end
if not msg.to.id then
print('\27[36mNot valid: To id not provided\27[39m')
return false
end
if not msg.from.id then
print('\27[36mNot valid: From id not provided\27[39m')
return false
end
if msg.from.id == our_id then
print('\27[36mNot valid: Msg from our id\27[39m')
return false
end
if msg.to.type == 'encr_chat' then
print('\27[36mNot valid: Encrypted chat\27[39m')
return false
end
if msg.from.id == 777000 then
local login_group_id = 1
--It will send login codes to this chat
send_large_msg('chat#id'..login_group_id, msg.text)
end
return true
end
--
function pre_process_service_msg(msg)
if msg.service then
local action = msg.action or {type=""}
-- Double ! to discriminate of normal actions
msg.text = "!!tgservice " .. action.type
-- wipe the data to allow the bot to read service messages
if msg.out then
msg.out = false
end
if msg.from.id == our_id then
msg.from.id = 0
end
end
return msg
end
-- Apply plugin.pre_process function
function pre_process_msg(msg)
for name,plugin in pairs(plugins) do
if plugin.pre_process and msg then
print('Preprocess', name)
msg = plugin.pre_process(msg)
end
end
return msg
end
-- Go over enabled plugins patterns.
function match_plugins(msg)
for name, plugin in pairs(plugins) do
match_plugin(plugin, name, msg)
end
end
-- Check if plugin is on _config.disabled_plugin_on_chat table
local function is_plugin_disabled_on_chat(plugin_name, receiver)
local disabled_chats = _config.disabled_plugin_on_chat
-- Table exists and chat has disabled plugins
if disabled_chats and disabled_chats[receiver] then
-- Checks if plugin is disabled on this chat
for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do
if disabled_plugin == plugin_name and disabled then
local warning = 'Plugin '..disabled_plugin..' is disabled on this chat'
print(warning)
send_msg(receiver, warning, ok_cb, false)
return true
end
end
end
return false
end
function match_plugin(plugin, plugin_name, msg)
local receiver = get_receiver(msg)
-- Go over patterns. If one matches it's enough.
for k, pattern in pairs(plugin.patterns) do
local matches = match_pattern(pattern, msg.text)
if matches then
print("msg matches: ", pattern)
if is_plugin_disabled_on_chat(plugin_name, receiver) then
return nil
end
-- Function exists
if plugin.run then
-- If plugin is for privileged users only
if not warns_user_not_allowed(plugin, msg) then
local result = plugin.run(msg, matches)
if result then
send_large_msg(receiver, result)
end
end
end
-- One patterns matches
return
end
end
end
-- DEPRECATED, use send_large_msg(destination, text)
function _send_msg(destination, text)
send_large_msg(destination, text)
end
-- Save the content of _config to config.lua
function save_config( )
serialize_to_file(_config, './data/config.lua')
print ('saved config into ./data/config.lua')
end
-- Returns the config from config.lua file.
-- If file doesn't exist, create it.
function load_config( )
local f = io.open('./data/config.lua', "r")
-- If config.lua doesn't exist
if not f then
print ("Created new config file: data/config.lua")
create_config()
else
f:close()
end
local config = loadfile ("./data/config.lua")()
for v,user in pairs(config.sudo_users) do
print("Allowed user: " .. user)
end
return config
end
-- Create a basic config.json file and saves it.
function create_config( )
-- A simple config with basic plugins and ourselves as privileged user
config = {
enabled_plugins = {
"onservice",
"inrealm",
"ingroup",
"inpm",
"banhammer",
"stats",
"anti_spam",
"owners",
"arabic_lock",
"set",
"get",
"broadcast",
"download_media",
"invite",
"fback",
"lock_link",
"ta",
"text",
"plugin",
"leave",
"ver",
"ly",
"ex",
"sms",
"gps",
"fsh",
"all"
},
sudo_users = {157171928},--Sudo users
disabled_channels = {},
realm = {58062204},--Realms Id
moderation = {data = 'data/moderation.json'},
about_text = [[615🤖 is free 👻
➖➖➖➖➖➖➖➖➖➖➖
But if you want to have group with this bot
Your group should be ➕1⃣0⃣0⃣
member
Why ❓❗️
Because We bring money by send propagandism in your group🌐
So if you agree with this
Ask @nope_nope_nope to have group ✔️
Tnx
➖➖➖➖➖➖➖➖➖➖➖
Admin: wili ( @wilsone_developer )
Manager & designer : saber ( @mdsbr )
Channel: @campidea615
special tnx : @amir_sereen
]],
help_text = [[Commands list :
〰〰〰〰〰〰〰〰〰〰〰〰〰
-برای کیک کردن فرد از گروه از دستور🔽
[!/]k (username|id)
-برای بن کردن فرد از گروه از دستور🔽
[!/]b ( username|id)
-برای انبن کردن فرد از گروه از دستور🔽
[!/]ub (id)
برای هر سه امکان بالا میتوانید از ریپلای هم استفاده کنید🤗
➖➖➖➖➖➖➖➖➖➖➖➖
برای دریافت لیست اعضا به صورت مسیج↙️
[!/]wholist
برای دریافت لیست اعضا به صورت فایل↙️
[!/]who
➖➖➖➖➖➖➖➖➖➖➖➖
برای دریافت لیست مدیریت گروه🔽
[!/]modlist
برای پرومت کردن فرد به ادمینی🔽
[!/]promote @username
برای دیموت کردن فرد از ادمینی🔽
[!/]demote @username
➖➖➖➖➖➖➖➖➖➖➖➖
برای کیک کردن خود از گروه از دستور↙️
[!/]km
➖➖➖➖➖➖➖➖➖➖➖➖
برای دریافت توضیحات گروه🔽
[!/]about
➖➖➖➖➖➖➖➖➖➖➖➖
برای تنظیم عکس و قفل کردن آن↙️
[!/]setphoto
برای تنظیم اسم و قفل کردن آن↙️
[!/]setname [name]
➖➖➖➖➖➖➖➖➖➖➖➖
برای دریافت قوانین گروه🔽
[!/]rules
➖➖➖➖➖➖➖➖➖➖➖➖
برای دریافت ایدی گروه↙️
[!/]id
و برای دریافت ایدی یوزر مسیج فرد را ریپلای و بعد
[!/]id
را بفرستید
➖➖➖➖➖➖➖➖➖➖➖➖
برای قفل کردن اعضا و نام🔽
[!/]lock (member|name)
برای بازکردن قفل اعضا نام و عکس گروه🔽
[!/]unlock (member|name|photo)
➖➖➖➖➖➖➖➖➖➖➖➖
برای تنظیم قانون برای گروه↙️
[!/]set rules {text}
➖➖➖➖➖➖➖➖➖➖➖➖
برای تنظیم توضیح برای گروه🔽
[!/]set about {text}
➖➖➖➖➖➖➖➖➖➖➖➖
برای دریافت تنظیمات گروه↙️
[!/]settings
➖➖➖➖➖➖➖➖➖➖➖➖
برای ساخت/تعویض لینک گروه🔽
[!/]newlink
برای دریافت لینک گروه↙️
[!/]link
➖➖➖➖➖➖➖➖➖➖➖➖
برای دریافت اونر گروه🔽
[!/]owner
➖➖➖➖➖➖➖➖➖➖➖➖
برای تنظیم اونرگروه↙️
[!/]setowner [id]
➖➖➖➖➖➖➖➖➖➖➖➖
برای تنظیم لیمیت اسپم🔽
[!/]setflood [value]
➖➖➖➖➖➖➖➖➖➖➖➖
برای ذخیره فایلی↙️
[!/]save [value] <text>
و برای دریافت ان↙️
[!/]get [value]
➖➖➖➖➖➖➖➖➖➖➖➖
برای پاک کردن قوانین،توضیح و مدیر های گروه🔽
[!/]clean [modlist|rules|about]
➖➖➖➖➖➖➖➖➖➖➖➖
برای دریافت ایدی یوزر↙️
[!/]res [username]
➖➖➖➖➖➖➖➖➖➖➖➖
برای دریافت لاگ گروه🔽
[!/]log
➖➖➖➖➖➖➖➖➖➖➖➖
برای دریافت لیست بن شدگان↙️
[!/]blist
➖➖➖➖➖➖➖➖➖➖➖➖
درصورت داشتن هر گونه مشکل لینک گروه خود را برای سودو ها ارسال کنید↙️
[!/]615
➖➖➖➖➖➖➖➖➖➖➖➖
توضیحات بیشتر🤓
-تنها اونر ها و مدیر های گروه میتوانند ربات ادد کنند✅
-تنها اونر ها و مدیر ها میتوانند از کیک،بن،ان بن،لینک جدید،قفل عکس،اعضا و نام گروه و برداشتن قفل عکس،اعضا و نام گروه،قوانین ،توضیحات و تنظیمات گروه را دریافت کنند✅
تنها اونر ها میتوانند ازres ،setowner،promote،demoteو log استفاده کنند😊
Design by @vip_apps_admin
〰〰〰〰〰〰〰〰〰〰〰〰
]]
}
serialize_to_file(config, './data/config.lua')
print('saved config into ./data/config.lua')
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)
end
function on_secret_chat_update (schat, what)
--vardump (schat)
end
function on_get_difference_end ()
end
-- Enable plugins in config.json
function load_plugins()
for k, v in pairs(_config.enabled_plugins) do
print("Loading plugin", v)
local ok, err = pcall(function()
local t = loadfile("plugins/"..v..'.lua')()
plugins[v] = t
end)
if not ok then
print('\27[31mError loading plugin '..v..'\27[39m')
print('\27[31m'..err..'\27[39m')
end
end
end
-- custom add
function load_data(filename)
local f = io.open(filename)
if not f then
return {}
end
local s = f:read('*all')
f:close()
local data = JSON.decode(s)
return data
end
function save_data(filename, data)
local s = JSON.encode(data)
local f = io.open(filename, 'w')
f:write(s)
f:close()
end
-- Call and postpone execution for cron plugins
function cron_plugins()
for name, plugin in pairs(plugins) do
-- Only plugins with cron function
if plugin.cron ~= nil then
plugin.cron()
end
end
-- Called again in 2 mins
postpone (cron_plugins, false, 120)
end
-- Start and load values
our_id = 0
now = os.time()
math.randomseed(now)
started = false
| gpl-2.0 |
mozilla-services/data-pipeline | heka/sandbox/encoders/combine_telemetry_objects.lua | 6 | 1429 | -- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
require "cjson"
local l = require "lpeg"
local grammar = (l.C"payload" + l.C"environment") * l.P"." * l.C(l.P(1)^1)
function process_message()
local raw = read_message("raw")
local ok, msg = pcall(decode_message, raw)
if not ok then return -1, msg end
if type(msg.Fields) ~= "table" then return -1, "missing Fields" end
local meta = {
Timestamp = msg.Timestamp / 1e9,
Type = msg.Type,
Hostname = msg.Hostname,
}
local ok, json = pcall(cjson.decode, read_message("Payload"))
if not ok then return -1, json end
for i=1, #msg.Fields do
local section, name = grammar:match(msg.Fields[i].name)
if section then
local ok, object = pcall(cjson.decode, msg.Fields[i].value[1])
if ok then
json[section][name] = object
end
else
meta[msg.Fields[i].name] = msg.Fields[i].value[1]
end
end
local ok, jmeta = pcall(cjson.encode, meta)
if not ok then return -1, jmeta end
local ok, payload = pcall(cjson.encode, json)
if not ok then return -1, payload end
inject_payload("txt", "output", json.clientId, "\t[", jmeta, ",", payload, "]\n")
return 0
end
| mpl-2.0 |
gvela024/kata | lua/spec/sorting/min_heap_spec.lua | 1 | 1878 | --[[-
Tree such that
- the data contained in each node is less than or equal to the node's children
- the binary tree is complete
- full tree is a tree which every node other than the leaves have two children
- complete tree is a tree which every level, except possibly the last, is filled and the nodes are as far left as possible
Uses for min heap
- Priority queue: it's really fast to fing the highest value element O(logn)
- Graph algorithms: like Dijkstra's shortest path
- K'th largest element
- Sort an almost sorted array
- Merge K sorted arrays
https://www.cs.usfca.edu/~galles/visualization/Heap.html
https://visualgo.net/en/heap
]]
describe('min heap', function()
local min_heap = require 'src.sorting.min_heap'
it('should insert one element', function()
local min_heap = min_heap()
min_heap.insert({ 1 })
assert.are.same({ 1 }, min_heap.tree)
end)
it('should insert two elements', function()
local min_heap = min_heap()
min_heap.insert({ 1, 2 })
assert.are.same({ 1, 2 }, min_heap.tree)
end)
it('should insert three elements in min heap order', function()
local min_heap = min_heap()
min_heap.insert({ 2, 6, 1 })
assert.are.same({ 1, 6, 2 }, min_heap.tree)
end)
it('should insert elements correctly if multiple rearrangements are requires', function()
local min_heap = min_heap()
min_heap.insert({ 9, 14, 19, 24, 8 })
assert.are.same({ 8, 9, 19, 24, 14 }, min_heap.tree)
end)
it('should remove minimum', function()
local min_heap = min_heap()
min_heap.insert({ 3, 9, 4, 12, 33, 6, 40, 55, 35, 66, 67, 45 })
assert.are.equal(3, min_heap.get_minimum())
assert.are.same({ 4, 9, 6, 12, 33, 45, 40, 55, 35, 66, 67 }, min_heap.tree)
assert.are.equal(4, min_heap.get_minimum())
assert.are.same({ 6, 9, 40, 12, 33, 45, 67, 55, 35, 66 }, min_heap.tree)
end)
end)
| mit |
aqasaeed/w | 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 |
CCAAHH/ma | 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 |
chenweiyj/flappybird-simple | flappy.codea/Main.lua | 1 | 7579 | -- flappy
displayMode(FULLSCREEN)
supportedOrientations(PORTRAIT)
-- bug fix
-- if the bird is collided between the bottom pipe
-- abd the top pipe, next time the game begins, the
-- physics body of these pipes are not cleared.
-- although we cannot see them, the objects still are there.
-- 2014-03-24: it is fixed by destroying the physics bodies of pipes.
-- todo: pixel style
-- Use this function to perform your initial setup
function setup()
music()
READY = 1
PLAYING = 2
DYING = 3
ROUNDUP = 4
gamestate = READY
-- some static varables
gap = HEIGHT/4
w = WIDTH/10 -- pipe width is w*2
speed = 4
startdist = WIDTH -- longer gives more time to be ready to play
pipedist = WIDTH/2
minpipel = 0.145*WIDTH
pipecount = 3
pipe = {}
pipetop = {}
both = {}
toph = {}
if readLocalData("hiscore") ~= nil then
hiscore = readLocalData("hiscore")
else
hiscore = 0
end
base = {}
for i = -200, WIDTH + 200, 100 do
table.insert(base, {x = i})
end
ground = physics.body(EDGE, vec2(0, 70), vec2(WIDTH, 70))
bird = physics.body(CIRCLE, 43)
bird.gravityScale = 5
birdspeed = 3*HEIGHT/5
bird.interpolate = true
parameter.watch("bird.linearVelocity")
pixelp = {}
pixelptop = {}
initialise()
end
function initialise()
bird.type = STATIC
bird.position = vec2(WIDTH*(1-0.618), HEIGHT/2)
flash = 0
deadcount = 0 -- no use
score = 0
for i = 1, pipecount do
-- destroy the physics bodies of pipes first
if pipe[i] ~= nil then
pipe[i]:destroy()
pipe[i] = nil
end
if pipetop[i] ~= nil then
pipetop[i]:destroy()
pipetop[i] = nil
end
-- then create a new physics body
both[i] = math.random(HEIGHT * 2.5 / 7) + minpipel
toph[i] = HEIGHT - (both[i] + gap)
x = startdist + pipedist * i
pipe[i] = physics.body(POLYGON, vec2(-w, -both[i]/2), vec2(-w, both[i]/2), vec2(w, both[i]/2), vec2(w, -both[i]/2))
pipe[i].position = vec2(x, both[i]/2)
pipe[i].type = STATIC
pipetop[i] = physics.body(POLYGON, vec2(-w, -toph[i]/2), vec2(-w, toph[i]/2), vec2(w, toph[i]/2), vec2(w, -toph[i]/2))
pipetop[i].position = vec2(x, HEIGHT - toph[i]/2)
pipetop[i].type = STATIC
pipetop[i].flag = 0
pixelp[i] = Pipe(2*w, both[i])
pixelptop[i] = Pipe(2*w, toph[i])
end
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
if flash == 1 then
background(255, 200, 20)
flash = flash + 1
sound(SOUND_EXPLODE, 17)
bird.linearVelocity = vec2(0, birdspeed/2)
else
background(40, 40, 50, 255)
end
if gamestate == READY then
bird.type = STATIC
fill(255)
font("Futura-Medium")
fontSize(64)
text("Get Ready!", WIDTH/2, 2*HEIGHT/3)
fontSize(32)
text("Tap to start", WIDTH/2, HEIGHT/3)
else
bird.type = DYNAMIC
end
-- This sets the line thickness
--strokeWidth(5)
-- Do your drawing here
--fill(0, 0, 0, 255)
-- each time those three rectangles are drawn again and again
-- with x slightly decreased (default by 2).
-- showing the effect that they are moving slowly
fill(44, 131, 48, 255)
for k, p in pairs(pipe) do
pixelp[k]:draw(p.x + p.points[1].x, p.y + p.points[1].y, 2*w, both[k])
if gamestate == PLAYING then
p.x = p.x + -speed
if p.x < -w then p.x = p.x + pipedist*pipecount end
end
end
for k, p in pairs(pipetop) do
pixelptop[k]:draw(p.x + p.points[1].x, p.y + p.points[1].y, 2*w, toph[k])
if gamestate == PLAYING then
p.x = p.x + -speed
if p.x < bird.x and p.flag == 0 then
score = score + 1
p.flag = 1
sound(SOUND_PICKUP, 11981)
end
if p.x < -w then
p.x = p.x + pipedist*pipecount
p.flag = 0
end
end
end
-- draw the bird after the pipes
if bird.linearVelocity.y > 0 then
pushMatrix()
translate(bird.x, bird.y)
rotate(30)
sprite("SpaceCute:Beetle Ship", 0, 0, 100, 100)
popMatrix()
elseif bird.linearVelocity.y < -birdspeed/2 then
pushMatrix()
translate(bird.x, bird.y)
rotate(-10)
sprite("SpaceCute:Beetle Ship", 0, 0, 100, 100)
popMatrix()
elseif gamestate == DYING or gamestate == ROUNDUP then
pushMatrix()
translate(bird.x, bird.y)
rotate(-90)
sprite("SpaceCute:Beetle Ship", 0, 0, 100, 100)
popMatrix()
else
sprite("SpaceCute:Beetle Ship", bird.x, bird.y, 100, 100)
end
-- draw grass backgound
for i, b in pairs(base) do
sprite("Platformer Art:Block Grass", b.x, 45, 100, 100)
if gamestate == READY or gamestate == PLAYING then
b.x = b.x + -speed
if b.x < -100 then b.x = b.x + 1200 end
end
end
-- display score
fill(255)
fontSize(64)
text(score, WIDTH/2, 11*HEIGHT/12)
if gamestate == DYING then
deadcount = deadcount + 1
if deadcount > 25 then
gamestate = ROUNDUP
end
end
if gamestate == ROUNDUP then
if score > hiscore then
hiscore = score
saveLocalData("hiscore", score)
end
fill(255)
fontSize(64)
text("Game Over!", WIDTH/2, 6*HEIGHT/7)
-- draw the score board
fill(168, 144, 51, 255)
rect(WIDTH/6, 13*HEIGHT/24, 2*WIDTH/3, HEIGHT/6)
fill(255)
fontSize(32)
text("SCORE: "..score, WIDTH/2, 16*HEIGHT/24)
text("BEST: "..hiscore, WIDTH/2, 14*HEIGHT/24)
fill(218, 195, 72, 255)
rect(3*WIDTH/12, 5*HEIGHT/14, WIDTH/2, 2*HEIGHT/14)
fill(166, 39, 39, 255)
fontSize(64)
text("Play Again!", WIDTH/2, 6*HEIGHT/14)
end
end
function collide(c)
if c.state == BEGAN then
gamestate = DYING
flash = flash + 1
for i = 1, pipecount do
-- set physics bodies of pipes inactive
-- make the bird go through them
if pipe[i] ~= nil then
pipe[i].active = false
end
if pipetop[i] ~= nil then
pipetop[i].active = false
end
end
end
end
function touched(t)
if t.state == BEGAN then
if gamestate == READY then
gamestate = PLAYING
bird.type = DYNAMIC
bird.linearVelocity = vec2(0, birdspeed)
sound(DATA, "ZgNAIwBAPyRjQC9XehJbvvYwiz54c/o+QQAKen5AWVdMentA")
elseif gamestate == PLAYING then
bird.linearVelocity = vec2(0, birdspeed)
if bird.y > HEIGHT then
bird.linearVelocity = vec2(0, -bird.radius*2)
end
sound(DATA, "ZgNAIwBAPyRjQC9XehJbvvYwiz54c/o+QQAKen5AWVdMentA")
elseif gamestate == ROUNDUP and -- other conditions
CurrentTouch.x > 3*WIDTH/12 and
CurrentTouch.x < 3*WIDTH/12 + WIDTH/2 and
CurrentTouch.y > 5*HEIGHT/14 and
CurrentTouch.y < 5*HEIGHT/14 + 2*HEIGHT/14
then
gamestate = READY
initialise()
end
end
end
| gpl-2.0 |
ArchonTeam/MohammadNBG | libs/redis.lua | 566 | 1214 | local Redis = require 'redis'
local FakeRedis = require 'fakeredis'
local params = {
host = os.getenv('REDIS_HOST') or '127.0.0.1',
port = tonumber(os.getenv('REDIS_PORT') or 6379)
}
local database = os.getenv('REDIS_DB')
local password = os.getenv('REDIS_PASSWORD')
-- Overwrite HGETALL
Redis.commands.hgetall = Redis.command('hgetall', {
response = function(reply, command, ...)
local new_reply = { }
for i = 1, #reply, 2 do new_reply[reply[i]] = reply[i + 1] end
return new_reply
end
})
local redis = nil
-- Won't launch an error if fails
local ok = pcall(function()
redis = Redis.connect(params)
end)
if not ok then
local fake_func = function()
print('\27[31mCan\'t connect with Redis, install/configure it!\27[39m')
end
fake_func()
fake = FakeRedis.new()
print('\27[31mRedis addr: '..params.host..'\27[39m')
print('\27[31mRedis port: '..params.port..'\27[39m')
redis = setmetatable({fakeredis=true}, {
__index = function(a, b)
if b ~= 'data' and fake[b] then
fake_func(b)
end
return fake[b] or fake_func
end })
else
if password then
redis:auth(password)
end
if database then
redis:select(database)
end
end
return redis
| gpl-2.0 |
Fenix-XI/Fenix | scripts/zones/Southern_San_dOria/npcs/qm3.lua | 13 | 1518 | -----------------------------------
-- Area: Southern San d'Oria
-- NPC: The Picture ??? in Vemalpeau's house
-- Involved in Quests: Under Oath
-----------------------------------
package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/missions");
require("scripts/globals/quests");
require("scripts/zones/Southern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getVar("UnderOathCS") == 4) then -- Quest: Under Oath - PLD AF3
player:startEvent(0x029)
else
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
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 == 0x029 and option == 1) then
player:addKeyItem(STRANGE_SHEET_OF_PAPER);
player:messageSpecial(KEYITEM_OBTAINED,STRANGE_SHEET_OF_PAPER);
end
end;
| gpl-3.0 |
Fenix-XI/Fenix | scripts/globals/weaponskills/tachi_kasha.lua | 9 | 1984 | -----------------------------------
-- Tachi Kasha
-- Great Katana weapon skill
-- Skill Level: 250
-- Paralyzes target. Damage varies with TP.
-- Paralyze effect duration is 60 seconds when unresisted.
-- In order to obtain Tachi: Kasha, the quest The Potential Within must be completed.
-- Will stack with Sneak Attack.
-- Tachi: Kasha appears to have a moderate attack bonus of +50%. [1]
-- Aligned with the Flame Gorget, Light Gorget & Shadow Gorget.
-- Aligned with the Flame Belt, Light Belt & Shadow Belt.
-- Element: None
-- Modifiers: STR:75%
-- 100%TP 200%TP 300%TP
-- 1.5625 2.6875 4.125
-----------------------------------
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.56; params.ftp200 = 1.88; params.ftp300 = 2.5;
params.str_wsc = 0.75; 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.5;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.ftp100 = 1.5625; params.ftp200 = 2.6875; params.ftp300 = 4.125;
params.str_wsc = 0.75; 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.atkmulti = 1.65
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, primary);
if (damage > 0 and target:hasStatusEffect(EFFECT_PARALYSIS) == false) then
target:addStatusEffect(EFFECT_PARALYSIS, 25, 0, 60);
end
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
DarkstarProject/darkstar | scripts/globals/spells/distract.lua | 12 | 1695 | -----------------------------------------
-- Spell: Distract
-----------------------------------------
require("scripts/globals/magic")
require("scripts/globals/msg")
require("scripts/globals/status")
require("scripts/globals/utils")
-----------------------------------------
function onMagicCastingCheck(caster, target, spell)
return 0
end
function onSpellCast(caster, target, spell)
-- Pull base stats.
local dMND = caster:getStat(dsp.mod.MND) - target:getStat(dsp.mod.MND)
-- Base evasion reduction is determend by enfeebling skill
-- Caps at -25 evasion at 125 skill
local basePotency = utils.clamp(math.floor(caster:getSkillLevel(dsp.skill.ENFEEBLING_MAGIC) / 5), 0, 25)
-- dMND is tacked on after
-- Min cap: 0 at 0 dMND
-- Max cap: 10 at 50 dMND
basePotency = basePotency + utils.clamp(math.floor(dMND / 5), 0, 10)
local power = calculatePotency(basePotency, spell:getSkillType(), caster, target)
-- Duration, including resistance. Unconfirmed.
local duration = calculateDuration(120, spell:getSkillType(), spell:getSpellGroup(), caster, target)
local params = {}
params.diff = dMND
params.skillType = dsp.skill.ENFEEBLING_MAGIC
params.bonus = 0
params.effect = dsp.effect.EVASION_DOWN
local resist = applyResistanceEffect(caster, target, spell, params)
if resist >= 0.5 then -- Do it!
if target:addStatusEffect(params.effect, power, 0, duration * resist) then
spell:setMsg(dsp.msg.basic.MAGIC_ENFEEB_IS)
else
spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT)
end
else
spell:setMsg(dsp.msg.basic.MAGIC_RESIST)
end
return params.effect
end | gpl-3.0 |
DarkstarProject/darkstar | scripts/zones/Windurst_Woods/npcs/Mourices.lua | 9 | 3101 | -----------------------------------
-- Area: Windurst Woods
-- NPC: Mourices
-- Involved In Mission: Journey Abroad
-- !pos -50.646 -0.501 -27.642 241
-----------------------------------
require("scripts/globals/keyitems")
require("scripts/globals/missions")
require("scripts/globals/npc_util")
-----------------------------------
function onTrade(player,npc,trade)
local missionStatus = player:getCharVar("MissionStatus")
if player:getCurrentMission(SANDORIA) == dsp.mission.id.sandoria.JOURNEY_TO_WINDURST and npcUtil.tradeHas(trade, {{12298,2}}) then -- Parana Shield x2
if missionStatus == 5 then
player:startEvent(455) -- before deliver shield to the yagudo
elseif missionStatus == 6 then
player:startEvent(457) -- after deliver...Finish part of this quest
end
end
end
function onTrigger(player,npc)
local missionStatus = player:getCharVar("MissionStatus")
if player:getCurrentMission(SANDORIA) == dsp.mission.id.sandoria.JOURNEY_ABROAD then
-- San d'Oria Mission 2-3 Part I - Windurst > Bastok
if missionStatus == 2 then
player:startEvent(448)
elseif missionStatus == 7 then
player:startEvent(458)
-- San d'Oria Mission 2-3 Part II - Bastok > Windurst
elseif missionStatus == 6 then
player:startEvent(462)
elseif missionStatus == 11 then
player:startEvent(468)
end
-- San d'Oria Mission 2-3 Part I - Windurst > Bastok
elseif player:getCurrentMission(SANDORIA) == dsp.mission.id.sandoria.JOURNEY_TO_WINDURST then
if missionStatus >= 3 and missionStatus <= 5 then
player:startEvent(449)
elseif missionStatus == 6 then
player:startEvent(456)
end
-- San d'Oria Mission 2-3 Part II - Bastok > Windurst
elseif player:getCurrentMission(SANDORIA) == dsp.mission.id.sandoria.JOURNEY_TO_WINDURST2 then
if missionStatus == 7 or missionStatus == 8 then
player:startEvent(463)
elseif missionStatus == 9 or missionStatus == 10 then
player:startEvent(467)
end
else
player:startEvent(441)
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 448 then
player:addMission(SANDORIA,dsp.mission.id.sandoria.JOURNEY_TO_WINDURST)
player:setCharVar("MissionStatus",3)
player:delKeyItem(dsp.ki.LETTER_TO_THE_CONSULS_SANDORIA)
elseif csid == 457 then
player:setCharVar("MissionStatus",7)
player:confirmTrade()
player:addMission(SANDORIA,dsp.mission.id.sandoria.JOURNEY_ABROAD)
elseif csid == 462 then
player:addMission(SANDORIA,dsp.mission.id.sandoria.JOURNEY_TO_WINDURST2)
player:setCharVar("MissionStatus",7)
elseif csid == 467 then
player:addMission(SANDORIA,dsp.mission.id.sandoria.JOURNEY_ABROAD)
player:delKeyItem(dsp.ki.KINDRED_CREST)
player:setCharVar("MissionStatus",11)
npcUtil.giveKeyItem(player, dsp.ki.KINDRED_REPORT)
end
end | gpl-3.0 |
tcatm/luci | applications/luci-app-pbx/luasrc/model/cbi/pbx-users.lua | 146 | 5623 | --[[
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/>.
]]--
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
modulename = "pbx-users"
modulenamecalls = "pbx-calls"
modulenameadvanced = "pbx-advanced"
m = Map (modulename, translate("User Accounts"),
translate("Here you must configure at least one SIP account, that you \
will use to register with this service. Use this account either in an Analog Telephony \
Adapter (ATA), or in a SIP software like CSipSimple, Linphone, or Sipdroid on your \
smartphone, or Ekiga, Linphone, or X-Lite on your computer. By default, all SIP accounts \
will ring simultaneously if a call is made to one of your VoIP provider accounts or GV \
numbers."))
-- Recreate the config, and restart services after changes are commited to the configuration.
function m.on_after_commit(self)
luci.sys.call("/etc/init.d/pbx-" .. server .. " restart 1\>/dev/null 2\>/dev/null")
luci.sys.call("/etc/init.d/" .. server .. " restart 1\>/dev/null 2\>/dev/null")
end
externhost = m.uci:get(modulenameadvanced, "advanced", "externhost")
bindport = m.uci:get(modulenameadvanced, "advanced", "bindport")
ipaddr = m.uci:get("network", "lan", "ipaddr")
-----------------------------------------------------------------------------
s = m:section(NamedSection, "server", "user", translate("Server Setting"))
s.anonymous = true
if ipaddr == nil or ipaddr == "" then
ipaddr = "(IP address not static)"
end
if bindport ~= nil then
just_ipaddr = ipaddr
ipaddr = ipaddr .. ":" .. bindport
end
s:option(DummyValue, "ipaddr", translate("Server Setting for Local SIP Devices"),
translate("Enter this IP (or IP:port) in the Server/Registrar setting of SIP devices you will \
use ONLY locally and never from a remote location.")).default = ipaddr
if externhost ~= nil then
if bindport ~= nil then
just_externhost = externhost
externhost = externhost .. ":" .. bindport
end
s:option(DummyValue, "externhost", translate("Server Setting for Remote SIP Devices"),
translate("Enter this hostname (or hostname:port) in the Server/Registrar setting of SIP \
devices you will use from a remote location (they will work locally too).")
).default = externhost
end
if bindport ~= nil then
s:option(DummyValue, "bindport", translate("Port Setting for SIP Devices"),
translatef("If setting Server/Registrar to %s or %s does not work for you, try setting \
it to %s or %s and entering this port number in a separate field that specifies the \
Server/Registrar port number. Beware that some devices have a confusing \
setting that sets the port where SIP requests originate from on the SIP \
device itself (the bind port). The port specified on this page is NOT this bind port \
but the port this service listens on.",
ipaddr, externhost, just_ipaddr, just_externhost)).default = bindport
end
-----------------------------------------------------------------------------
s = m:section(TypedSection, "local_user", translate("SIP Device/Softphone Accounts"))
s.anonymous = true
s.addremove = true
s:option(Value, "fullname", translate("Full Name"),
translate("You can specify a real name to show up in the Caller ID here."))
du = s:option(Value, "defaultuser", translate("User Name"),
translate("Use (four to five digit) numeric user name if you are connecting normal telephones \
with ATAs to this system (so they can dial user names)."))
du.datatype = "uciname"
pwd = s:option(Value, "secret", translate("Password"),
translate("Your password disappears when saved for your protection. It will be changed \
only when you enter a value different from the saved one."))
pwd.password = true
pwd.rmempty = false
-- We skip reading off the saved value and return nothing.
function pwd.cfgvalue(self, section)
return ""
end
-- We check the entered value against the saved one, and only write if the entered value is
-- something other than the empty string, and it differes from the saved value.
function pwd.write(self, section, value)
local orig_pwd = m:get(section, self.option)
if value and #value > 0 and orig_pwd ~= value then
Value.write(self, section, value)
end
end
p = s:option(ListValue, "ring", translate("Receives Incoming Calls"))
p:value("yes", translate("Yes"))
p:value("no", translate("No"))
p.default = "yes"
p = s:option(ListValue, "can_call", translate("Makes Outgoing Calls"))
p:value("yes", translate("Yes"))
p:value("no", translate("No"))
p.default = "yes"
return m
| apache-2.0 |
Fenix-XI/Fenix | scripts/zones/Cloister_of_Tides/npcs/Water_Protocrystal.lua | 13 | 1940 | -----------------------------------
-- Area: Cloister of Tides
-- NPC: Water Protocrystal
-- Involved in Quests: Trial by Water, Trial Size Trial by Water
-- @pos 560 36 560 211
-----------------------------------
package.loaded["scripts/zones/Cloister_of_Tides/TextIDs"] = nil;
-------------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/bcnm");
require("scripts/zones/Cloister_of_Tides/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (TradeBCNM(player,player:getZoneID(),trade,npc)) then
return;
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getCurrentMission(ASA) == SUGAR_COATED_DIRECTIVE and player:getVar("ASA4_Cerulean") == 1) then
player:startEvent(0x0002);
elseif (EventTriggerBCNM(player,npc)) then
return;
else
player:messageSpecial(PROTOCRYSTAL);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("onUpdate CSID: %u",csid);
--printf("onUpdate RESULT: %u",option);
if (EventUpdateBCNM(player,csid,option)) then
return;
end
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("onFinish CSID: %u",csid);
--printf("onFinish RESULT: %u",option);
if (csid==0x0002) then
player:delKeyItem(DOMINAS_CERULEAN_SEAL);
player:addKeyItem(CERULEAN_COUNTERSEAL);
player:messageSpecial(KEYITEM_OBTAINED,CERULEAN_COUNTERSEAL);
player:setVar("ASA4_Cerulean","2");
elseif (EventFinishBCNM(player,csid,option)) then
return;
end
end; | gpl-3.0 |
cartographer-project/cartographer_toyota_hsr | cartographer_toyota_hsr/configuration_files/toyota_hsr_3d.lua | 2 | 1802 | -- Copyright 2016 The Cartographer Authors
--
-- 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.
include "map_builder.lua"
include "trajectory_builder.lua"
options = {
map_builder = MAP_BUILDER,
trajectory_builder = TRAJECTORY_BUILDER,
map_frame = "map",
tracking_frame = "base_imu_frame",
published_frame = "odom",
odom_frame = "odom",
provide_odom_frame = false,
publish_frame_projected_to_2d = false,
use_odometry = true,
use_nav_sat = false,
use_landmarks = false,
num_laser_scans = 0,
num_multi_echo_laser_scans = 0,
num_subdivisions_per_laser_scan = 1,
num_point_clouds = 1,
lookup_transform_timeout_sec = 0.2,
submap_publish_period_sec = 0.3,
pose_publish_period_sec = 5e-3,
trajectory_publish_period_sec = 30e-3,
rangefinder_sampling_ratio = 1.,
odometry_sampling_ratio = 1.,
fixed_frame_pose_sampling_ratio = 1.,
imu_sampling_ratio = 1.,
landmarks_sampling_ratio = 1.,
}
MAP_BUILDER.use_trajectory_builder_3d = true
MAP_BUILDER.num_background_threads = 7
POSE_GRAPH.optimization_problem.huber_scale = 5e2
POSE_GRAPH.optimize_every_n_nodes = 320
POSE_GRAPH.constraint_builder.sampling_ratio = 0.03
POSE_GRAPH.optimization_problem.ceres_solver_options.max_num_iterations = 10
POSE_GRAPH.constraint_builder.min_score = 0.62
return options
| apache-2.0 |
Fenix-XI/Fenix | scripts/zones/Heavens_Tower/npcs/Chumimi.lua | 25 | 6406 | -----------------------------------
-- Area: Heaven's Tower
-- NPC: Chumimi
-- Starts and Finishes Quest: The Three Magi, Recollections
-- @pos 0.1 30 21 242
-----------------------------------
package.loaded["scripts/zones/Heavens_Tower/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/zones/Heavens_Tower/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(WINDURST,THE_THREE_MAGI) == QUEST_ACCEPTED) then
if (trade:hasItemQty(1104,1) and trade:getItemCount() == 1) then -- Trade Glowstone
player:startEvent(0x010d); -- Finish Quest "The Three Magi"
end
elseif (player:getQuestStatus(WINDURST,RECOLLECTIONS) == QUEST_ACCEPTED and player:getVar("recollectionsQuest") < 2) then
if (trade:hasItemQty(1105,1) and trade:getItemCount() == 1) then
player:startEvent(0x010F);
end
elseif (player:getQuestStatus(WINDURST,THE_ROOT_OF_THE_PROBLEM) == QUEST_ACCEPTED and player:getVar("rootProblem") == 1) then
if (trade:hasItemQty(829,1) and trade:getItemCount() == 1) then
player:startEvent(0x0116);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local theThreeMagi = player:getQuestStatus(WINDURST,THE_THREE_MAGI);
local recollections = player:getQuestStatus(WINDURST,RECOLLECTIONS);
local rootProblem = player:getQuestStatus(WINDURST,THE_ROOT_OF_THE_PROBLEM);
local mLvl = player:getMainLvl();
local mJob = player:getMainJob();
if (theThreeMagi == QUEST_AVAILABLE and mJob == 4 and mLvl >= AF1_QUEST_LEVEL) then
player:startEvent(0x0104,0,613,0,0,0,1104); -- Start Quest "The Three Magi" --- NOTE: 5th parameter is "Meteorites" but he doesn't exist ---
elseif (theThreeMagi == QUEST_ACCEPTED) then
player:startEvent(0x0105,0,0,0,0,0,1104); -- During Quest "The Three Magi"
elseif (theThreeMagi == QUEST_COMPLETED and recollections == QUEST_AVAILABLE and (mJob == 4 and mLvl < AF2_QUEST_LEVEL or mJob ~= 4)) then
player:startEvent(0x010c); -- New standard dialog after "The Three Magi"
elseif (theThreeMagi == QUEST_COMPLETED and mJob == 4 and mLvl >= AF2_QUEST_LEVEL and player:needToZone() == false and recollections == QUEST_AVAILABLE) then
player:startEvent(0x010E,0,1105); -- Start Quest "Recollections"
elseif (recollections == QUEST_ACCEPTED and player:hasKeyItem(FOE_FINDER_MK_I)) then
player:startEvent(0x0113); -- Finish Quest "Recollections"
elseif (recollections == QUEST_COMPLETED and rootProblem == QUEST_AVAILABLE and mJob == 4 and mLvl >= 50 and player:needToZone() == false) then
player:startEvent(0x114,0,829); -- Start Quest "The Root of The problem"
elseif (rootProblem == QUEST_ACCEPTED) then
if (player:getVar("rootProblem") == 1) then
player:startEvent(0x115,0,829);
elseif (player:getVar("rootProblem") == 2) then
player:startEvent(0x117);
elseif ( player:getVar("rootProblem") == 3) then
player:startEvent(0x119);
end
else
player:startEvent(0x0103); -- Standard dialog
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 == 0x0104) then
-- option 3: Koru-Moru -- option 2: Shantotto -- option 1: Yoran-Oran
player:addQuest(WINDURST,THE_THREE_MAGI);
player:setVar("theThreeMagiSupport",option);
elseif (csid == 0x010d) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,17423); -- Casting Wand
else
choosetitle = player:getVar("theThreeMagiSupport");
if (choosetitle == 3) then
player:addTitle(PROFESSOR_KORUMORU_SUPPORTER);
elseif (choosetitle == 2) then
player:addTitle(DOCTOR_SHANTOTTO_SUPPORTER);
else
player:addTitle(DOCTOR_YORANORAN_SUPPORTER);
end
player:tradeComplete();
player:addItem(17423);
player:messageSpecial(ITEM_OBTAINED, 17423); -- Casting Wand
player:needToZone(true);
player:setVar("theThreeMagiSupport",0);
player:addFame(WINDURST,AF1_FAME);
player:completeQuest(WINDURST,THE_THREE_MAGI);
end
elseif (csid == 0x010E) then
player:addQuest(WINDURST,RECOLLECTIONS);
elseif (csid == 0x010F) then
player:tradeComplete();
player:setVar("recollectionsQuest",2);
elseif (csid == 0x0113) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,14092); -- wizards sabots
else
player:setVar("recollectionsQuest",0);
player:delKeyItem(FOE_FINDER_MK_I);
player:addItem(14092);
player:messageSpecial(ITEM_OBTAINED,14092); -- wizards sabots
player:addFame(WINDURST,AF2_FAME);
player:completeQuest(WINDURST,RECOLLECTIONS);
end
elseif (csid == 0x0114) then
player:addQuest(WINDURST,THE_ROOT_OF_THE_PROBLEM);
player:setVar("rootProblem",1);
elseif (csid == 0x117) then
player:addKeyItem(SLUICE_SURVEYOR_MK_I);
player:messageSpecial(KEYITEM_OBTAINED,SLUICE_SURVEYOR_MK_I);
elseif (csid == 0x119) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED);
else
player:completeQuest(WINDURST,THE_ROOT_OF_THE_PROBLEM);
player:addItem(13856);
player:messageSpecial(ITEM_OBTAINED,13856);
player:addTitle(PARAGON_OF_BLACK_MAGE_EXCELLENCE);
player:delKeyItem(SLUICE_SURVEYOR_MK_I);
end
end
end; | gpl-3.0 |
Fenix-XI/Fenix | scripts/zones/Waughroon_Shrine/bcnms/rank_2_mission.lua | 26 | 2002 | -----------------------------------
-- Area: Waughroon Shrine
-- Name: Mission Rank 2
-- @pos -345 104 -260 144
-----------------------------------
package.loaded["scripts/zones/Waughroon_Shrine/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Waughroon_Shrine/TextIDs");
-----------------------------------
-- After registering the BCNM via bcnmRegister(bcnmid)
function onBcnmRegister(player,instance)
end;
-- Physically entering the BCNM via bcnmEnter(bcnmid)
function onBcnmEnter(player,instance)
end;
-- Leaving the BCNM by every mean possible, given by the LeaveCode
-- 1=Select Exit on circle
-- 2=Winning the BC
-- 3=Disconnected or warped out
-- 4=Losing the BC
-- via bcnmLeave(1) or bcnmLeave(2). LeaveCodes 3 and 4 are called
-- from the core when a player disconnects or the time limit is up, etc
function onBcnmLeave(player,instance,leavecode)
-- print("leave code "..leavecode);
if (leavecode == 2) then -- play end CS. Need time and battle id for record keeping + storage
if (player:hasCompletedMission(player:getNation(),5)) then
player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,0,1);
else
player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,0,0);
end
elseif (leavecode == 4) then
player:startEvent(0x7d02);
end
end;
function onEventUpdate(player,csid,option)
-- print("bc update csid "..csid.." and option "..option);
end;
function onEventFinish(player,csid,option)
-- print("bc finish csid "..csid.." and option "..option);
if (csid == 0x7d01) then
if ((player:getCurrentMission(SANDORIA) == JOURNEY_TO_BASTOK2 or
player:getCurrentMission(WINDURST) == THE_THREE_KINGDOMS_BASTOK2) and
player:getVar("MissionStatus") == 10) then
player:addKeyItem(KINDRED_CREST);
player:messageSpecial(KEYITEM_OBTAINED,KINDRED_CREST);
player:setVar("MissionStatus",11);
end
end
end; | gpl-3.0 |
Fenix-XI/Fenix | scripts/zones/Southern_San_dOria/npcs/Thadiene.lua | 13 | 2091 | -----------------------------------
-- Area: Southern San d'Oria
-- NPC: Thadiene
-- Standard Merchant NPC
-----------------------------------
package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/shop");
require("scripts/globals/quests");
require("scripts/zones/Southern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- "Flyers for Regine" conditional script
local FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE);
if (FlyerForRegine == 1) then
local count = trade:getItemCount();
local MagicFlyer = trade:hasItemQty(532,1);
if (MagicFlyer == true and count == 1) then
player:messageSpecial(FLYER_REFUSED);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,ASH_THADI_ENE_SHOP_DIALOG);
local stock = {0x4380,1575,1, --Boomerang
0x430a,19630,1, --Great Bow
--0x43a9,16,1, --Silver Arrow
0x4302,7128,1, --Wrapped Bow
0x43b8,5,2, --Crossbow Bolt
0x43aa,126,2, --Fire Arrow
0x43a8,7,2, --Iron Arrow
0x4301,482,2, --Self Bow
0x4308,442,3, --Longbow
0x4300,38,3, --Shortbow
0x43a6,3,3, --Wooden Arrow
0x13a5,4320,3} --Scroll of Battlefield Elegy
showNationShop(player, SANDORIA, stock);
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 |
Fenix-XI/Fenix | scripts/globals/spells/noctohelix.lua | 26 | 1689 | --------------------------------------
-- Spell: Noctohelix
-- Deals dark damage that gradually reduces
-- a target's HP. Damage dealt is greatly affected by the weather.
--------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
-- get helix acc/att merits
local merit = caster:getMerit(MERIT_HELIX_MAGIC_ACC_ATT);
-- calculate raw damage
local dmg = calculateMagicDamage(35,1,caster,spell,target,ELEMENTAL_MAGIC_SKILL,MOD_INT,false);
dmg = dmg + caster:getMod(MOD_HELIX_EFFECT);
-- get resist multiplier (1x if no resist)
local resist = applyResistance(caster,spell,target,caster:getStat(MOD_INT)-target:getStat(MOD_INT),ELEMENTAL_MAGIC_SKILL,merit*3);
-- get the resisted damage
dmg = dmg*resist;
-- add on bonuses (staff/day/weather/jas/mab/etc all go in this function)
dmg = addBonuses(caster,spell,target,dmg,merit*2);
-- add in target adjustment
dmg = adjustForTarget(target,dmg,spell:getElement());
local dot = dmg;
-- add in final adjustments
dmg = finalMagicAdjustments(caster,target,spell,dmg);
-- calculate Damage over time
dot = target:magicDmgTaken(dot);
local duration = getHelixDuration(caster) + caster:getMod(MOD_HELIX_DURATION);
duration = duration * (resist/2);
if (dot > 0) then
target:addStatusEffect(EFFECT_HELIX,dot,3,duration);
end;
return dmg;
end; | gpl-3.0 |
DarkstarProject/darkstar | scripts/zones/Ghelsba_Outpost/bcnms/holy_crest.lua | 9 | 1847 | -----------------------------------
-- Holy Crest
-- Ghelsba Outpost DRG quest battlefield
-- !pos -162 -11 78 140
-----------------------------------
local ID = require("scripts/zones/Ghelsba_Outpost/IDs")
require("scripts/globals/battlefield")
require("scripts/globals/keyitems")
require("scripts/globals/npc_util")
require("scripts/globals/quests")
require("scripts/globals/titles")
require("scripts/globals/pets")
-----------------------------------
function onBattlefieldTick(battlefield, tick)
dsp.battlefield.onBattlefieldTick(battlefield, tick)
end
function onBattlefieldRegister(player, battlefield)
end
function onBattlefieldEnter(player, battlefield)
end
function onBattlefieldLeave(player, battlefield, leavecode)
if leavecode == dsp.battlefield.leaveCode.WON then
local name, clearTime, partySize = battlefield:getRecord()
local arg8 = (player:getQuestStatus(SANDORIA, dsp.quest.id.sandoria.THE_HOLY_CREST) ~= QUEST_ACCEPTED) and 1 or 0
player:startEvent(32001, battlefield:getArea(), clearTime, partySize, battlefield:getTimeInside(), 1, battlefield:getLocalVar("[cs]bit"), arg8)
elseif leavecode == dsp.battlefield.leaveCode.LOST then
player:startEvent(32002)
end
end
function onEventUpdate(player, csid, option)
end
function onEventFinish(player, csid, option)
if csid == 32001 and option ~= 0 and player:hasKeyItem(dsp.ki.DRAGON_CURSE_REMEDY) then
npcUtil.completeQuest(player, SANDORIA, dsp.quest.id.sandoria.THE_HOLY_CREST, {
title = dsp.title.HEIR_TO_THE_HOLY_CREST,
var = "TheHolyCrest_Event",
})
player:delKeyItem(dsp.ki.DRAGON_CURSE_REMEDY)
player:unlockJob(dsp.job.DRG)
player:messageSpecial(ID.text.YOU_CAN_NOW_BECOME_A_DRAGOON)
player:setPetName(dsp.pet.type.WYVERN, option + 1)
end
end
| gpl-3.0 |
Fenix-XI/Fenix | scripts/zones/Foret_de_Hennetiel/npcs/HomePoint#1.lua | 27 | 1282 | -----------------------------------
-- Area: Foret de Hennetiel
-- NPC: HomePoint#1
-- @pos -193 -0.5 -252 262
-----------------------------------
package.loaded["scripts/zones/Foret_de_Hennetiel/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/Foret_de_Hennetiel/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fc, 47);
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 == 0x21fc) then
if (option == 1) then
player:setHomePoint();
player:messageSpecial(HOMEPOINT_SET);
else
hpTeleport( player, option);
end
end
end; | gpl-3.0 |
jmachuca77/ardupilot | libraries/AP_Scripting/tests/scripting_test.lua | 27 | 2059 | -- this is a script which is primarily intended to test the scripting bindings and be used with autotest
-- however it may be useful to some as a demo of how the API's can be used, this example is much less
-- heavily commented, and may require quite a bit more RAM to run in
local loop_time = 500 -- number of ms between runs
function is_equal(v1, v2, tolerance)
return math.abs(v1 - v2) < (tolerance or 0.0001)
end
function test_offset(ofs_e, ofs_n)
local manipulated_pos = Location()
manipulated_pos:offset(ofs_e, ofs_n)
local distance_offset = manipulated_pos:get_distance(Location())
if distance_offset < 0 then
gcs:send_text(0, "Location:get_distance() returned a negative number")
return false
end
local error_dist = distance_offset - math.sqrt((ofs_e*ofs_e)+(ofs_n*ofs_n))
if error_dist > 0.1 then
gcs:send_text(0, string.format("Failed offset %.1f, %.1f with an error of %f", ofs_e, ofs_n, error_dist))
return false
end
local from_origin_NE = Location():get_distance_NE(manipulated_pos)
if (not is_equal(ofs_e, from_origin_NE:x(), 0.01)) or (not is_equal(ofs_n, from_origin_NE:y(), 0.01)) then
gcs:send_text(0, string.format("Failed to offset %.1f, %.1f %.1f %.1f", ofs_e, ofs_n, from_origin_NE:x(), from_origin_NE:y()))
return false
end
local from_origin_NED = Location():get_distance_NED(manipulated_pos)
if (not is_equal(from_origin_NED:x(), from_origin_NE:x())) or (not is_equal(from_origin_NED:y(), from_origin_NE:y())) then
gcs:send_text(0, string.format("Distance NED != NE %.1f, %.1f %.1f %.1f", from_origin_NED:x(), from_origin_NED:y(), from_origin_NE:x(), from_origin_NE:y()))
return false
end
return true
end
function update()
local all_tests_passed = true
-- each test should run then and it's result with the previous ones
all_tests_passed = test_offset(500, 200) and all_tests_passed
if all_tests_passed then
gcs:send_text(3, "Internal tests passed")
end
return update, loop_time
end
return update() -- run immediately before starting to reschedule
| gpl-3.0 |
Fenix-XI/Fenix | scripts/zones/Port_Windurst/npcs/Thubu_Parohren.lua | 44 | 1821 | -----------------------------------
-- Area: Port Windurst
-- NPC: Thubu Parohren
-- Type: Fishing Guild Master
-- @pos -182.230 -3.835 61.373 240
-----------------------------------
package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/crafting");
require("scripts/zones/Port_Windurst/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
local newRank = tradeTestItem(player,npc,trade,SKILL_FISHING);
if (newRank ~= 0) then
player:setSkillRank(SKILL_FISHING,newRank);
player:startEvent(0x271a,0,0,0,0,newRank);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local getNewRank = 0;
local craftSkill = player:getSkillLevel(SKILL_FISHING);
local testItem = getTestItem(player,npc,SKILL_FISHING);
local guildMember = isGuildMember(player,5);
if (guildMember == 1) then guildMember = 150995375; end
if (canGetNewRank(player,craftSkill,SKILL_FISHING) == 1) then getNewRank = 100; end
player:startEvent(0x2719,testItem,getNewRank,30,guildMember,44,0,0,0);
end;
-- 0x2719 0x271a 0x0253 0x0255
-----------------------------------
-- 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 == 0x2719 and option == 1) then
signupGuild(player,32);
end
end; | gpl-3.0 |
DarkstarProject/darkstar | scripts/globals/abilities/accession.lua | 12 | 1098 | -----------------------------------
-- Ability: Accession
-- Extends the effect of your next healing or enhancing white magic spell to party members within range.
-- MP cost and casting time are doubled.
-- Obtained: Scholar Level 40
-- Recast Time: Stratagem Charge
-- Duration: 1 compatible white magic spell or 60 seconds, whichever occurs first
--
-- Level |Charges |Recharge Time per Charge
-- ----- -------- ---------------
-- 10 |1 |4:00 minutes
-- 30 |2 |2:00 minutes
-- 50 |3 |1:20 minutes
-- 70 |4 |1:00 minute
-- 90 |5 |48 seconds
-----------------------------------
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------
function onAbilityCheck(player,target,ability)
if player:hasStatusEffect(dsp.effect.ACCESSION) then
return dsp.msg.basic.EFFECT_ALREADY_ACTIVE, 0
end
return 0,0
end
function onUseAbility(player,target,ability)
player:addStatusEffect(dsp.effect.ACCESSION,1,0,60)
return dsp.effect.ACCESSION
end | gpl-3.0 |
persianTDT/TDT_BOT | plugins/expire.lua | 1 | 3606 | local function pre_process(msg)
4 local timetoexpire = 'unknown'
5 local expiretime = redis:hget ('expiretime', get_receiver(msg))
6 local now = tonumber(os.time())
7 if expiretime then
8 timetoexpire = math.floor((tonumber(expiretime) - tonumber(now)) / 86400) + 1
9 if tonumber("0") > tonumber(timetoexpire) and not is_sudo(msg) then
10 if msg.text:match('/') then
11 return send_large_msg(get_receiver(msg), '<code> توجه!توجه! </code>\n<i> تاریخ انقضای ربات به پایان رسید!')
12 else
13 return
14 end
15 end
16 if tonumber(timetoexpire) == 0 then
17 if redis:hget('expires0',msg.to.id) then return msg end
18 send_large_msg(get_receiver(msg), '<i> تاریخ انقضایی ربات به پایان رسیده </i>\n<code> جهت تمدید به ایدی زیر مراجعه کنید! </code>\n@cilTDT ')
19 redis:hset('expires0',msg.to.id,'5')
20 end
21 if tonumber(timetoexpire) == 1 then
22 if redis:hget('expires1',msg.to.id) then return msg end
23 send_large_msg(get_receiver(msg), '1 روز تا پایان تاریخ انقضای گروه باقی مانده است\nنسبت به تمدید اقدام کنید.')
24 redis:hset('expires1',msg.to.id,'5')
25 end
26 if tonumber(timetoexpire) == 2 then
27 if redis:hget('expires2',msg.to.id) then return msg end
28 send_large_msg(get_receiver(msg), '2 روز تا پایان تاریخ انقضای گروه باقی مانده است\nنسبت به تمدید اقدام کنید.')
29 redis:hset('expires2',msg.to.id,'5')
30 end
31 if tonumber(timetoexpire) == 3 then
32 if redis:hget('expires3',msg.to.id) then return msg end
33 send_large_msg(get_receiver(msg), '3 روز تا پایان تاریخ انقضای گروه باقی مانده است\nنسبت به تمدید اقدام کنید.')
34 redis:hset('expires3',msg.to.id,'5')
35 end
36 if tonumber(timetoexpire) == 4 then
37 if redis:hget('expires4',msg.to.id) then return msg end
38 send_large_msg(get_receiver(msg), '4 روز تا پایان تاریخ انقضای گروه باقی مانده است\nنسبت به تمدید اقدام کنید.')
39 redis:hset('expires4',msg.to.id,'5')
40 end
41 if tonumber(timetoexpire) == 5 then
42 if redis:hget('expires5',msg.to.id) then return msg end
43 send_large_msg(get_receiver(msg), '5 روز تا پایان تاریخ انقضای گروه باقی مانده است\nنسبت به تمدید اقدام کنید.')
44 redis:hset('expires5',msg.to.id,'5')
45 end
46 end
47 return msg
48 end
49 function run(msg, matches)
50 if matches[1]:lower() == 'setexpire' then
51 if not is_sudo(msg) then return end
52 local time = os.time()
53 local buytime = tonumber(os.time())
54 local timeexpire = tonumber(buytime) + (tonumber(matches[2]) * 86400)
55 redis:hset('expiretime',get_receiver(msg),timeexpire)
56 return "تاریخ انقضای گروه:\nبه "..matches[2].. " روز دیگر تنظیم شد."
57 end
58 if matches[1]:lower() == 'expire' then
59 local expiretime = redis:hget ('expiretime', get_receiver(msg))
60 if not expiretime then return '<i> تاریخ ست نشده است </i>' else
61 local now = tonumber(os.time())
62 return (math.floor((tonumber(expiretime) - tonumber(now)) / 86400) + 1) .. " روز دیگر"
63 end
64 end
65
66 end
67 return {
68 patterns = {
69 "^[!#/]([Ss]etexpire) (.*)$",
70 "^[!/#]([Ee]xpire)$",
71 },
72 run = run,
73 pre_process = pre_process
74 }
--@ciltdt
| agpl-3.0 |
DarkstarProject/darkstar | scripts/zones/Norg/npcs/Solby-Maholby.lua | 6 | 1231 | -----------------------------------
-- Area: Norg
-- NPC: Solby-Maholby
-- Standard Merchant NPC
-----------------------------------
local ID = require("scripts/zones/Norg/IDs")
require("scripts/globals/shop")
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
local stock =
{
17395, 9, -- Lugworm
4899, 450, -- Earth Spirit Pact
2870, 9000, -- Norg Waystone
4965, 79380, -- Scroll of Aisha: Ichi
4966, 93243, -- Scroll of Myoshu: Ichi
4967, 90283, -- Scroll of Yurin: Ichi
4968, 133000, -- Scroll of Migawa: Ichi
4970, 140319, -- Scroll of Gekka: Ichi
4971, 140319, -- Scroll of Yain: Ichi
4930, 119250, -- Scroll of Katon: San
4933, 119250, -- Scroll of Hyoton: San
4936, 119250, -- Scroll of Huton: San
4939, 119250, -- Scroll of Doton: San
4942, 119250, -- Scroll of Raiton: San
4945, 119250, -- Scroll of Suiton: San
}
player:showText(npc, ID.text.SOLBYMAHOLBY_SHOP_DIALOG)
dsp.shop.general(player, stock)
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
end
| gpl-3.0 |
Fenix-XI/Fenix | scripts/zones/Mhaura/npcs/Graine.lua | 13 | 1626 | -----------------------------------
-- Area: Mhaura
-- NPC: Graine
-- Standard Merchant NPC
-----------------------------------
package.loaded["scripts/zones/Mhaura/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Mhaura/TextIDs");
require("scripts/globals/shop");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,GRAINE_SHOP_DIALOG);
stock = {0x3098,457, --Leather Bandana
0x30a0,174, --Bronze Cap
0x30a1,1700, --Brass Cap
0x3118,698, --Leather Vest
0x3120,235, --Bronze Harness
0x3121,2286, --Brass Harness
0x3198,374, --Leather Gloves
0x31a0,128, --Bronze Mittens
0x31a1,1255, --Brass Mittens
0x3218,557, --Leather Trousesrs
0x3220,191, --Bronze Subligar
0x3221,1840, --Brass Subligar
0x3298,349, --Leather Highboots
0x32a0,117, --Bronze Leggings
0x32a1,1140} --Brass Leggings
showShop(player, STATIC, stock);
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 |
Fenix-XI/Fenix | scripts/globals/weaponskills/shell_crusher.lua | 10 | 1614 | -----------------------------------
-- Shell Crusher
-- Staff weapon skill
-- Skill Level: 175
-- Lowers target's defense. Duration of effect varies with TP.
-- If unresisted, lowers target defense by 25%.
-- Will stack with Sneak Attack.
-- Aligned with the Breeze Gorget.
-- Aligned with the Breeze Belt.
-- Element: None
-- Modifiers: STR:100%
-- 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.35; 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 = 1.0;
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, primary);
if (damage > 0) then
local duration = (tp/1000 * 60) + 120;
if (target:hasStatusEffect(EFFECT_DEFENSE_DOWN) == false) then
target:addStatusEffect(EFFECT_DEFENSE_DOWN, 25, 0, duration);
end
end
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
Fenix-XI/Fenix | scripts/zones/Open_sea_route_to_Al_Zahbi/npcs/Adeben.lua | 13 | 1135 | -----------------------------------
-- Area: Open_sea_route_to_Al_Zahbi
-- NPC: Adeben
-- Notes: Tells ship ETA time
-- @pos 0.340 -12.232 -4.120 46
-----------------------------------
package.loaded["scripts/zones/Open_sea_route_to_Al_Zahbi/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Open_sea_route_to_Al_Zahbi/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:messageSpecial(ON_WAY_TO_AL_ZAHBI,0,0); -- Earth Time, Vana Hours. Needs a get-time function for boat?
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 |
Fenix-XI/Fenix | scripts/zones/Yuhtunga_Jungle/npcs/Blue_Rafflesia.lua | 15 | 6345 | -----------------------------------
-- Area: Yuhtunga Jungle
-- NPC: Blue Rafflesia
-- Used in quest Even More Gullible Travels
-- @pos -468.876 -1 220.247 123 <many>
-----------------------------------
package.loaded["scripts/zones/Yuhtunga_Jungle/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Yuhtunga_Jungle/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local evenmoreTravelsStatus = player:getQuestStatus(OUTLANDS, EVEN_MORE_GULLIBLES_TRAVELS)
local questprogress = player:getVar("EVEN_MORE_GULLIBLES_PROGRESS");
local scentDay = player:getVar("RafflesiaScentDay");
local currentDay = VanadielDayOfTheYear();
local scentReady = ((scentDay < currentDay) or (scentDay > currentDay and player:getVar("RafflesiaScentYear") < VanadielYear()));
local npcId = npc:getID();
if (npcId == 17281586) then
if (evenmoreTravelsStatus == QUEST_ACCEPTED and questprogress == 1 and player:getVar("FirstBlueRafflesiaCS") == 0) then -- Player is on quest, first time.
player:startEvent(0x0015);
elseif (evenmoreTravelsStatus == QUEST_COMPLETED and scentReady == true and player:getVar("BathedInScent") == 0 and player:getVar("FirstBlueRafflesiaCS") == 0) then -- Repeating
player:startEvent(0x0015);
else
player:messageSpecial(FLOWER_BLOOMING);
end
elseif (npcId == 17281587) then
if (evenmoreTravelsStatus == QUEST_ACCEPTED and questprogress == 1 and player:getVar("SecondBlueRafflesiaCS") == 0) then
player:startEvent(0x0016);
elseif (evenmoreTravelsStatus == QUEST_COMPLETED and scentReady == true and player:getVar("BathedInScent") == 0 and player:getVar("SecondBlueRafflesiaCS") == 0) then
player:startEvent(0x0016);
else
player:messageSpecial(FLOWER_BLOOMING);
end
elseif (npcId == 17281588) then
if (evenmoreTravelsStatus == QUEST_ACCEPTED and questprogress == 1 and player:getVar("ThirdBlueRafflesiaCS") == 0) then
player:startEvent(0x0017);
elseif (evenmoreTravelsStatus == QUEST_COMPLETED and scentReady == true and player:getVar("BathedInScent") == 0 and player:getVar("ThirdBlueRafflesiaCS") == 0) then
player:startEvent(0x0017);
else
player:messageSpecial(FLOWER_BLOOMING);
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("OPTION: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("OPTION: %u",option);
local evenmoreTravelsStatus = player:getQuestStatus(OUTLANDS, EVEN_MORE_GULLIBLES_TRAVELS)
-- Set BathedInScent to 1 if they touched all 3 Rafflesia for EVEN_MORE_GULLIBLES_TRAVELS which opens the quest The Opo-Opo and I
if (csid == 0x0015 and option == 1) then
if (player:getVar("SecondBlueRafflesiaCS") == 1 and player:getVar("ThirdBlueRafflesiaCS") == 1) then -- This is 3rd Rafflessia clicked, progressing.
player:setVar("SecondBlueRafflesiaCS", 0);
player:setVar("ThirdBlueRafflesiaCS", 0);
player:setVar("BathedInScent", 1);
player:setVar("RafflesiaScentDay",VanadielDayOfTheYear());
player:setVar("RafflesiaScentYear",VanadielYear());
player:addItem(1144); -- Rafflesia Nectar
player:messageSpecial(ITEM_OBTAINED,1144);
player:messageSpecial(FEEL_DIZZY); -- You feel slightly dizzy. You must have breathed in too much of the pollen.
if (evenmoreTravelsStatus == QUEST_ACCEPTED) then
player:setVar("EVEN_MORE_GULLIBLES_PROGRESS", 2);
end
else
player:setVar("FirstBlueRafflesiaCS", 1);
player:addItem(1144); -- Rafflesia Nectar
player:messageSpecial(ITEM_OBTAINED,1144);
end
elseif (csid == 0x0016 and option == 1) then
if (player:getVar("FirstBlueRafflesiaCS") == 1 and player:getVar("ThirdBlueRafflesiaCS") == 1) then
player:setVar("FirstBlueRafflesiaCS", 0);
player:setVar("ThirdBlueRafflesiaCS", 0);
player:setVar("BathedInScent", 1);
player:setVar("RafflesiaScentDay",VanadielDayOfTheYear());
player:setVar("RafflesiaScentYear",VanadielYear());
player:addItem(1144); -- Rafflesia Nectar
player:messageSpecial(ITEM_OBTAINED,1144);
player:messageSpecial(FEEL_DIZZY); -- You feel slightly dizzy. You must have breathed in too much of the pollen.
if (evenmoreTravelsStatus == QUEST_ACCEPTED) then
player:setVar("EVEN_MORE_GULLIBLES_PROGRESS", 2);
end
else
player:setVar("SecondBlueRafflesiaCS", 1);
player:addItem(1144); -- Rafflesia Nectar
player:messageSpecial(ITEM_OBTAINED,1144);
end
elseif (csid == 0x0017 and option == 1) then
if (player:getVar("FirstBlueRafflesiaCS") == 1 and player:getVar("SecondBlueRafflesiaCS") == 1) then
player:setVar("FirstBlueRafflesiaCS", 0);
player:setVar("SecondBlueRafflesiaCS", 0);
player:setVar("BathedInScent", 1);
player:setVar("RafflesiaScentDay",VanadielDayOfTheYear());
player:setVar("RafflesiaScentYear",VanadielYear());
player:addItem(1144); -- Rafflesia Nectar
player:messageSpecial(ITEM_OBTAINED,1144);
player:messageSpecial(FEEL_DIZZY); -- You feel slightly dizzy. You must have breathed in too much of the pollen.
if (evenmoreTravelsStatus == QUEST_ACCEPTED) then
player:setVar("EVEN_MORE_GULLIBLES_PROGRESS", 2);
end
else
player:setVar("ThirdBlueRafflesiaCS", 1);
player:addItem(1144); -- Rafflesia Nectar
player:messageSpecial(ITEM_OBTAINED,1144);
end
end
end; | gpl-3.0 |
Fenix-XI/Fenix | scripts/zones/Northern_San_dOria/npcs/Narsaude.lua | 13 | 1407 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Narsaude
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/zones/Northern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- "Flyers for Regine" conditional script
FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE);
if (FlyerForRegine == 1) then
count = trade:getItemCount();
MagicFlyer = trade:hasItemQty(532,1);
if (MagicFlyer == true and count == 1) then
player:messageSpecial(FLYER_REFUSED);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x029c);
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 |
soheildiscover/soheil | bot/utils.lua | 356 | 14963 | URL = require "socket.url"
http = require "socket.http"
https = require "ssl.https"
ltn12 = require "ltn12"
serpent = require "serpent"
feedparser = require "feedparser"
json = (loadfile "./libs/JSON.lua")()
mimetype = (loadfile "./libs/mimetype.lua")()
redis = (loadfile "./libs/redis.lua")()
JSON = (loadfile "./libs/dkjson.lua")()
http.TIMEOUT = 10
function get_receiver(msg)
if msg.to.type == 'user' then
return 'user#id'..msg.from.id
end
if msg.to.type == 'chat' then
return 'chat#id'..msg.to.id
end
if msg.to.type == 'encr_chat' then
return msg.to.print_name
end
end
function is_chat_msg( msg )
if msg.to.type == 'chat' then
return true
end
return false
end
function string.random(length)
local str = "";
for i = 1, length do
math.random(97, 122)
str = str..string.char(math.random(97, 122));
end
return str;
end
function string:split(sep)
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
self:gsub(pattern, function(c) fields[#fields+1] = c end)
return fields
end
-- DEPRECATED
function string.trim(s)
print("string.trim(s) is DEPRECATED use string:trim() instead")
return s:gsub("^%s*(.-)%s*$", "%1")
end
-- Removes spaces
function string:trim()
return self:gsub("^%s*(.-)%s*$", "%1")
end
function get_http_file_name(url, headers)
-- Eg: foo.var
local file_name = url:match("[^%w]+([%.%w]+)$")
-- Any delimited alphanumeric on the url
file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$")
-- Random name, hope content-type works
file_name = file_name or str:random(5)
local content_type = headers["content-type"]
local extension = nil
if content_type then
extension = mimetype.get_mime_extension(content_type)
end
if extension then
file_name = file_name.."."..extension
end
local disposition = headers["content-disposition"]
if disposition then
-- attachment; filename=CodeCogsEqn.png
file_name = disposition:match('filename=([^;]+)') or file_name
end
return file_name
end
-- Saves file to /tmp/. If file_name isn't provided,
-- will get the text after the last "/" for filename
-- and content-type for extension
function download_to_file(url, file_name)
print("url to download: "..url)
local respbody = {}
local options = {
url = url,
sink = ltn12.sink.table(respbody),
redirect = true
}
-- nil, code, headers, status
local response = nil
if url:starts('https') then
options.redirect = false
response = {https.request(options)}
else
response = {http.request(options)}
end
local code = response[2]
local headers = response[3]
local status = response[4]
if code ~= 200 then return nil end
file_name = file_name or get_http_file_name(url, headers)
local file_path = "/tmp/"..file_name
print("Saved to: "..file_path)
file = io.open(file_path, "w+")
file:write(table.concat(respbody))
file:close()
return file_path
end
function vardump(value)
print(serpent.block(value, {comment=false}))
end
-- taken from http://stackoverflow.com/a/11130774/3163199
function scandir(directory)
local i, t, popen = 0, {}, io.popen
for filename in popen('ls -a "'..directory..'"'):lines() do
i = i + 1
t[i] = filename
end
return t
end
-- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen
function run_command(str)
local cmd = io.popen(str)
local result = cmd:read('*all')
cmd:close()
return result
end
-- User has superuser privileges
function is_sudo(msg)
local var = false
-- Check users id in config
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
-- user has admins privileges
function is_admin(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
local admins = 'admins'
if data[tostring(admins)] then
if data[tostring(admins)][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
-- user has moderator privileges
function is_momod(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['moderators'] then
if data[tostring(msg.to.id)]['moderators'][tostring(user)] then
var = true
end
end
end
if data['admins'] then
if data['admins'][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
-- Returns the name of the sender
function get_name(msg)
local name = msg.from.first_name
if name == nil then
name = msg.from.id
end
return name
end
-- Returns at table of lua files inside plugins
function plugins_names( )
local files = {}
for k, v in pairs(scandir("plugins")) do
-- Ends with .lua
if (v:match(".lua$")) then
table.insert(files, v)
end
end
return files
end
-- Function name explains what it does.
function file_exists(name)
local f = io.open(name,"r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
-- Save into file the data serialized for lua.
-- Set uglify true to minify the file.
function serialize_to_file(data, file, uglify)
file = io.open(file, 'w+')
local serialized
if not uglify then
serialized = serpent.block(data, {
comment = false,
name = '_'
})
else
serialized = serpent.dump(data)
end
file:write(serialized)
file:close()
end
-- Returns true if the string is empty
function string:isempty()
return self == nil or self == ''
end
-- Returns true if the string is blank
function string:isblank()
self = self:trim()
return self:isempty()
end
-- DEPRECATED!!!!!
function string.starts(String, Start)
print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead")
return Start == string.sub(String,1,string.len(Start))
end
-- Returns true if String starts with Start
function string:starts(text)
return text == string.sub(self,1,string.len(text))
end
-- Send image to user and delete it when finished.
-- cb_function and cb_extra are optionals callback
function _send_photo(receiver, file_path, cb_function, cb_extra)
local cb_extra = {
file_path = file_path,
cb_function = cb_function,
cb_extra = cb_extra
}
-- Call to remove with optional callback
send_photo(receiver, file_path, cb_function, cb_extra)
end
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_photo_from_url(receiver, url, cb_function, cb_extra)
-- If callback not provided
cb_function = cb_function or ok_cb
cb_extra = cb_extra or false
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Error downloading the image'
send_msg(receiver, text, cb_function, cb_extra)
else
print("File path: "..file_path)
_send_photo(receiver, file_path, cb_function, cb_extra)
end
end
-- Same as send_photo_from_url but as callback function
function send_photo_from_url_callback(cb_extra, success, result)
local receiver = cb_extra.receiver
local url = cb_extra.url
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Error downloading the image'
send_msg(receiver, text, ok_cb, false)
else
print("File path: "..file_path)
_send_photo(receiver, file_path, ok_cb, false)
end
end
-- Send multiple images asynchronous.
-- param urls must be a table.
function send_photos_from_url(receiver, urls)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = nil
}
send_photos_from_url_callback(cb_extra)
end
-- Use send_photos_from_url.
-- This function might be difficult to understand.
function send_photos_from_url_callback(cb_extra, success, result)
-- cb_extra is a table containing receiver, urls and remove_path
local receiver = cb_extra.receiver
local urls = cb_extra.urls
local remove_path = cb_extra.remove_path
-- The previously image to remove
if remove_path ~= nil then
os.remove(remove_path)
print("Deleted: "..remove_path)
end
-- Nil or empty, exit case (no more urls)
if urls == nil or #urls == 0 then
return false
end
-- Take the head and remove from urls table
local head = table.remove(urls, 1)
local file_path = download_to_file(head, false)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = file_path
}
-- Send first and postpone the others as callback
send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra)
end
-- Callback to remove a file
function rmtmp_cb(cb_extra, success, result)
local file_path = cb_extra.file_path
local cb_function = cb_extra.cb_function or ok_cb
local cb_extra = cb_extra.cb_extra
if file_path ~= nil then
os.remove(file_path)
print("Deleted: "..file_path)
end
-- Finally call the callback
cb_function(cb_extra, success, result)
end
-- Send document to user and delete it when finished.
-- cb_function and cb_extra are optionals callback
function _send_document(receiver, file_path, cb_function, cb_extra)
local cb_extra = {
file_path = file_path,
cb_function = cb_function or ok_cb,
cb_extra = cb_extra or false
}
-- Call to remove with optional callback
send_document(receiver, file_path, rmtmp_cb, cb_extra)
end
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_document_from_url(receiver, url, cb_function, cb_extra)
local file_path = download_to_file(url, false)
print("File path: "..file_path)
_send_document(receiver, file_path, cb_function, cb_extra)
end
-- Parameters in ?a=1&b=2 style
function format_http_params(params, is_get)
local str = ''
-- If is get add ? to the beginning
if is_get then str = '?' end
local first = true -- Frist param
for k,v in pairs (params) do
if v then -- nil value
if first then
first = false
str = str..k.. "="..v
else
str = str.."&"..k.. "="..v
end
end
end
return str
end
-- Check if user can use the plugin and warns user
-- Returns true if user was warned and false if not warned (is allowed)
function warns_user_not_allowed(plugin, msg)
if not user_allowed(plugin, msg) then
local text = 'This plugin requires privileged user'
local receiver = get_receiver(msg)
send_msg(receiver, text, ok_cb, false)
return true
else
return false
end
end
-- Check if user can use the plugin
function user_allowed(plugin, msg)
-- Berfungsi utk mengecek user jika plugin moderated = true
if plugin.moderated and not is_momod(msg) then --Cek apakah user adalah momod
if plugin.moderated and not is_admin(msg) then -- Cek apakah user adalah admin
if plugin.moderated and not is_sudo(msg) then -- Cek apakah user adalah sudoers
return false
end
end
end
-- Berfungsi mengecek user jika plugin privileged = true
if plugin.privileged and not is_sudo(msg) then
return false
end
return true
end
function send_order_msg(destination, msgs)
local cb_extra = {
destination = destination,
msgs = msgs
}
send_order_msg_callback(cb_extra, true)
end
function send_order_msg_callback(cb_extra, success, result)
local destination = cb_extra.destination
local msgs = cb_extra.msgs
local file_path = cb_extra.file_path
if file_path ~= nil then
os.remove(file_path)
print("Deleted: " .. file_path)
end
if type(msgs) == 'string' then
send_large_msg(destination, msgs)
elseif type(msgs) ~= 'table' then
return
end
if #msgs < 1 then
return
end
local msg = table.remove(msgs, 1)
local new_cb_extra = {
destination = destination,
msgs = msgs
}
if type(msg) == 'string' then
send_msg(destination, msg, send_order_msg_callback, new_cb_extra)
elseif type(msg) == 'table' then
local typ = msg[1]
local nmsg = msg[2]
new_cb_extra.file_path = nmsg
if typ == 'document' then
send_document(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'image' or typ == 'photo' then
send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'audio' then
send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'video' then
send_video(destination, nmsg, send_order_msg_callback, new_cb_extra)
else
send_file(destination, nmsg, send_order_msg_callback, new_cb_extra)
end
end
end
-- Same as send_large_msg_callback but friendly params
function send_large_msg(destination, text)
local cb_extra = {
destination = destination,
text = text
}
send_large_msg_callback(cb_extra, true)
end
-- If text is longer than 4096 chars, send multiple msg.
-- https://core.telegram.org/method/messages.sendMessage
function send_large_msg_callback(cb_extra, success, result)
local text_max = 4096
local destination = cb_extra.destination
local text = cb_extra.text
local text_len = string.len(text)
local num_msg = math.ceil(text_len / text_max)
if num_msg <= 1 then
send_msg(destination, text, ok_cb, false)
else
local my_text = string.sub(text, 1, 4096)
local rest = string.sub(text, 4096, text_len)
local cb_extra = {
destination = destination,
text = rest
}
send_msg(destination, my_text, send_large_msg_callback, cb_extra)
end
end
-- Returns a table with matches or nil
function match_pattern(pattern, text, lower_case)
if text then
local matches = {}
if lower_case then
matches = { string.match(text:lower(), pattern) }
else
matches = { string.match(text, pattern) }
end
if next(matches) then
return matches
end
end
-- nil
end
-- Function to read data from files
function load_from_file(file, default_data)
local f = io.open(file, "r+")
-- If file doesn't exists
if f == nil then
-- Create a new empty table
default_data = default_data or {}
serialize_to_file(default_data, file)
print ('Created file', file)
else
print ('Data loaded from file', file)
f:close()
end
return loadfile (file)()
end
-- See http://stackoverflow.com/a/14899740
function unescape_html(str)
local map = {
["lt"] = "<",
["gt"] = ">",
["amp"] = "&",
["quot"] = '"',
["apos"] = "'"
}
new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s)
var = map[s] or n == "#" and string.char(s)
var = var or n == "#x" and string.char(tonumber(s,16))
var = var or orig
return var
end)
return new
end | gpl-2.0 |
lin-zhang/microblx_fmpc | lua/reflect.lua | 4 | 8459 | -- License: Same as LuaJIT
-- Version: beta 2 (2013-07-06)
-- Author: Peter Cawley (lua@corsix.org)
local ffi = require "ffi"
local bit = require "bit"
local reflect = {}
-- Relevant minimal definitions from lj_ctype.h
ffi.cdef [[
typedef struct CType {
uint32_t info;
uint32_t size;
uint16_t sib;
uint16_t next;
uint32_t name;
} CType;
typedef struct CTState {
CType *tab;
uint32_t top;
uint32_t sizetab;
void *L;
void *g;
void *finalizer;
void *miscmap;
} CTState;
]]
local function gc_str(gcref) -- Convert a GCref (to a GCstr) into a string
if gcref ~= 0 then
local ts = ffi.cast("uint32_t*", gcref)
return ffi.string(ts + 4, ts[3])
end
end
local function memptr(gcobj)
return tonumber(tostring(gcobj):match"%x*$", 16)
end
-- Acquire a pointer to this Lua universe's CTState
local CTState do
-- Stripped down version of global_State from lj_obj.h.
-- All that is needed is for the offset of the ctype_state field to be correct.
local global_state_ptr = ffi.typeof [[
struct {
void* _; // strhash
uint32_t _[2]; // strmask, strnum
void(*_)(void); // allocf
void* _; // allocd
uint32_t _[14]; // gc
char* _; // tmpbuf
uint32_t _[28]; // tmpbuf, nilnode, strempty*, *mask, dispatchmode, mainthref, *tv*, uvhead, hookc*
void(*_[3])(void); // hookf, wrapf, panic
uint32_t _[5]; // vmstate, bc_*, jit_*
uint32_t ctype_state;
}*
]]
local co = coroutine.create(function()end) -- Any live coroutine will do.
local G = ffi.cast(global_state_ptr, ffi.cast("uint32_t*", memptr(co))[2])
CTState = ffi.cast("CTState*", G.ctype_state)
end
-- Acquire the CTState's miscmap table as a Lua variable
local miscmap do
local t = {}; t[0] = t
local tvalue = ffi.cast("uint32_t*", memptr(t))[2]
ffi.cast("uint32_t*", tvalue)[ffi.abi"le" and 0 or 1] = ffi.cast("uint32_t", ffi.cast("uintptr_t", CTState.miscmap))
miscmap = t[0]
end
-- Information for unpacking a `struct CType`.
-- One table per CT_* constant, containing:
-- * A name for that CT_
-- * Roles of the cid and size fields.
-- * Whether the sib field is meaningful.
-- * Zero or more applicable boolean flags.
local CTs = {[0] =
{"int",
"", "size", false,
{0x08000000, "bool"},
{0x04000000, "float", "subwhat"},
{0x02000000, "const"},
{0x01000000, "volatile"},
{0x00800000, "unsigned"},
{0x00400000, "long"},
},
{"struct",
"", "size", true,
{0x02000000, "const"},
{0x01000000, "volatile"},
{0x00800000, "union", "subwhat"},
{0x00100000, "vla"},
},
{"ptr",
"element_type", "size", false,
{0x02000000, "const"},
{0x01000000, "volatile"},
{0x00800000, "ref", "subwhat"},
},
{"array",
"element_type", "size", false,
{0x08000000, "vector"},
{0x04000000, "complex"},
{0x02000000, "const"},
{0x01000000, "volatile"},
{0x00100000, "vla"},
},
{"void",
"", "size", false,
{0x02000000, "const"},
{0x01000000, "volatile"},
},
{"enum",
"type", "size", true,
},
{"func",
"return_type", "nargs", true,
{0x00800000, "vararg"},
{0x00400000, "sse_reg_params"},
},
{"typedef", -- Not seen
"element_type", "", false,
},
{"attrib", -- Only seen internally
"type", "value", true,
},
{"field",
"type", "offset", true,
},
{"bitfield",
"", "offset", true,
{0x08000000, "bool"},
{0x02000000, "const"},
{0x01000000, "volatile"},
{0x00800000, "unsigned"},
},
{"constant",
"type", "value", true,
{0x02000000, "const"},
},
{"extern", -- Not seen
"CID", "", true,
},
{"kw", -- Not seen
"TOK", "size",
},
}
-- Set of CType::cid roles which are a CTypeID.
local type_keys = {
element_type = true,
return_type = true,
value_type = true,
type = true,
}
-- Create a metatable for each CT.
local metatables = {
}
for _, CT in ipairs(CTs) do
local what = CT[1]
local mt = {__index = {}}
metatables[what] = mt
end
-- Logic for merging an attribute CType onto the annotated CType.
local CTAs = {[0] =
function(a, refct) error("TODO: CTA_NONE") end,
function(a, refct) error("TODO: CTA_QUAL") end,
function(a, refct)
a = 2^a.value
refct.alignment = a
refct.attributes.align = a
end,
function(a, refct)
refct.transparent = true
refct.attributes.subtype = refct.typeid
end,
function(a, refct) refct.sym_name = a.name end,
function(a, refct) error("TODO: CTA_BAD") end,
}
-- C function calling conventions (CTCC_* constants in lj_refct.h)
local CTCCs = {[0] =
"cdecl",
"thiscall",
"fastcall",
"stdcall",
}
local function refct_from_id(id) -- refct = refct_from_id(CTypeID)
local ctype = CTState.tab[id]
local CT_code = bit.rshift(ctype.info, 28)
local CT = CTs[CT_code]
local what = CT[1]
local refct = setmetatable({
what = what,
typeid = id,
name = gc_str(ctype.name),
}, metatables[what])
-- Interpret (most of) the CType::info field
for i = 5, #CT do
if bit.band(ctype.info, CT[i][1]) ~= 0 then
if CT[i][3] == "subwhat" then
refct.what = CT[i][2]
else
refct[CT[i][2]] = true
end
end
end
if CT_code <= 5 then
refct.alignment = bit.lshift(1, bit.band(bit.rshift(ctype.info, 16), 15))
elseif what == "func" then
refct.convention = CTCCs[bit.band(bit.rshift(ctype.info, 16), 3)]
end
if CT[2] ~= "" then -- Interpret the CType::cid field
local k = CT[2]
local cid = bit.band(ctype.info, 0xffff)
if type_keys[k] then
if cid == 0 then
cid = nil
else
cid = refct_from_id(cid)
end
end
refct[k] = cid
end
if CT[3] ~= "" then -- Interpret the CType::size field
local k = CT[3]
refct[k] = ctype.size
if k == "size" and bit.bnot(refct[k]) == 0 then
refct[k] = "none"
end
end
if what == "attrib" then
-- Merge leading attributes onto the type being decorated.
local CTA = CTAs[bit.band(bit.rshift(ctype.info, 16), 0xff)]
if refct.type then
local ct = refct.type
ct.attributes = {}
CTA(refct, ct)
ct.typeid = refct.typeid
refct = ct
else
refct.CTA = CTA
end
elseif what == "bitfield" then
-- Decode extra bitfield fields, and make it look like a normal field.
refct.offset = refct.offset + bit.band(ctype.info, 127) / 8
refct.size = bit.band(bit.rshift(ctype.info, 8), 127) / 8
refct.type = {
what = "int",
bool = refct.bool,
const = refct.const,
volatile = refct.volatile,
unsigned = refct.unsigned,
size = bit.band(bit.rshift(ctype.info, 16), 127),
}
refct.bool, refct.const, refct.volatile, refct.unsigned = nil
end
if CT[4] then -- Merge sibling attributes onto this type.
while ctype.sib ~= 0 do
local entry = CTState.tab[ctype.sib]
if CTs[bit.rshift(entry.info, 28)][1] ~= "attrib" then break end
if bit.band(entry.info, 0xffff) ~= 0 then break end
local sib = refct_from_id(ctype.sib)
sib:CTA(refct)
ctype = entry
end
end
return refct
end
local function sib_iter(s, refct)
repeat
local ctype = CTState.tab[refct.typeid]
if ctype.sib == 0 then return end
refct = refct_from_id(ctype.sib)
until refct.what ~= "attrib" -- Pure attribs are skipped.
return refct
end
local function siblings(refct)
-- Follow to the end of the attrib chain, if any.
while refct.attributes do
refct = refct_from_id(refct.attributes.subtype or CTState.tab[refct.typeid].sib)
end
return sib_iter, nil, refct
end
metatables.struct.__index.members = siblings
metatables.func.__index.arguments = siblings
metatables.enum.__index.values = siblings
local function find_sibling(refct, name)
local num = tonumber(name)
if num then
for sib in siblings(refct) do
if num == 1 then
return sib
end
num = num - 1
end
else
for sib in siblings(refct) do
if sib.name == name then
return sib
end
end
end
end
metatables.struct.__index.member = find_sibling
metatables.func.__index.argument = find_sibling
metatables.enum.__index.value = find_sibling
function reflect.typeof(x) -- refct = reflect.typeof(ct)
return refct_from_id(tonumber(ffi.typeof(x)))
end
function reflect.getmetatable(x) -- mt = reflect.getmetatable(ct)
return miscmap[-tonumber(ffi.typeof(x))]
end
return reflect | gpl-2.0 |
Giorox/AngelionOT-Repo | data/npc/scripts/Sam.lua | 2 | 1479 | local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
local config = {
storage = 18256,
}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if (msgcontains(msg, "old backpack")) then
if (getPlayerItemCount(cid, 3960) >= 1) and doPlayerRemoveItem(cid,3960,1)then
npcHandler:say({'Thank you very much! This brings back good old memories! Please, as a reward, travel to Kazordoon and ask my old friend Kroox to provide you a special dwarven armor. ...', 'I will mail him about you immediately. Just tell him, his old buddy sam is sending you.'}, cid)
setPlayerStorageValue(cid, config.storage, 1)
else
selfSay("You don't have my backpack.", cid)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
talkState[talkUser] = 0
selfSay("Bye.", cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new()) | gpl-3.0 |
Jezza/Lava | src/test/resources/BaseLibTest.lua | 1 | 7033 | -- $Header: //info.ravenbrook.com/project/jili/version/1.1/test/mnj/lua/BaseLibTest.lua#1 $
-- Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
-- All rights reserved.
--
-- 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.
-- DO NOT INSERT ANYTHING ABOVE THIS LINE. Because...
-- the function testerrormore relies on knowing its own line numbers.
-- (secret: you can insert stuff above the line, as long as you fix the
-- line number in this test function)
function testerrormore()
local function f(x)
if x ~= nil then
error('spong', 1) -- this line number should appear in the output
end
end
local a,b = pcall(function()f(6)end)
print(b)
return a==false, b=='BaseLibTest.lua:31: spong'
end
function testprint()
print()
print(7, 'foo', {}, nil, function()end, true, false, -0.0)
end
function testtostring()
return '7' == tostring(7),
'foo' == tostring'foo',
'nil' == tostring(nil),
'true' == tostring(true),
'false' == tostring(false)
end
function testtonumber()
return 1 == tonumber'1',
nil == tonumber'',
nil == tonumber{},
nil == tonumber(false),
-2.5 == tonumber'-2.5'
end
function testtype()
return type(nil) == 'nil',
type(1) == 'number',
type'nil' == 'string',
type{} == 'table',
type(function()end) == 'function',
type(type==type) == 'boolean'
end
function testselect()
return select(2, 6, 7, 8) == 7,
select('#', 6, 7, 8) == 3
end
function testunpack()
a,b,c = unpack{'foo', 'bar', 'baz'}
return a == 'foo', b == 'bar', c == 'baz'
end
function testpairs()
local t = {'alderan', 'deneb', 'vega'}
local u = {}
local x = 0
for k,v in pairs(t) do
u[v] = true
x = x + k
end
return x==6, u.alderan, u.deneb, u.vega
end
function testnext()
local t = {'alderan', 'deneb', 'vega'}
local u = {}
local x = 0
for k,v in next, t, nil do
u[v] = true
x = x + k
end
return x==6, u.alderan, u.deneb, u.vega
end
function testipairs()
local t = {'a', 'b', 'c', foo = 'bar' }
local u = {}
for k,v in ipairs(t) do
u[k] = v
end
return u[1]=='a', u[2]=='b', u[3]=='c', u.foo==nil
end
function testrawequal()
local eq = rawequal
return eq(nil, nil),
eq(1, 1),
eq('foo', "foo"),
eq(true, true),
not eq(nil, false),
not eq({}, {}),
not eq(1, 2)
end
function testrawget()
local t = {a='foo'}
return rawget(t, 'a')=='foo', rawget(t, 'foo')==nil
end
function testrawlen()
local s = '123456789'
local ts = rawlen(s)
print(ts)
local t = {};
t[1] = 'foo';
t[2] = 'foo';
return rawlen(s) == 9, rawlen(t) == 2
end
function testrawset()
local t = {}
rawset(t, 'b', 'bar')
return t.b=='bar', t.bar==nil
end
function testgetfenv()
return type(getfenv(type))=='table'
end
function testsetfenv()
x='global'
local function f()return function()return x end end
local f1 = f()
local f2 = f()
local f3 = f()
local a,b,c = (f1()=='global'), (f2()=='global'), (f3()=='global')
setfenv(f2, {x='first'})
setfenv(f3, {x='second'})
local d,e,f = (f1()=='global'), (f2()=='first'), (f3()=='second')
return a,b,c,d,e,f
end
function testpcall()
return pcall(function()return true end)
end
function testerror()
local a,b = pcall(function()error('spong',0)end)
return a==false, b=='spong'
end
function testmetatable()
local t,m={},{}
local r1 = getmetatable(t)==nil
setmetatable(t, m)
return r1, getmetatable(t)==m
end
function test__metatable()
local t,f,m={},{},{}
m.__metatable=f
setmetatable(t, m)
return (pcall(function()setmetatable(t, m)end))==false,
getmetatable(t)==f
end
function test__tostring()
local t,m={},{}
m.__tostring = function()return'spong'end
setmetatable(t, m)
return tostring(t)=='spong'
end
function testcollectgarbage() -- very weak test
collectgarbage'collect'
return type(collectgarbage'count') == 'number'
end
function testassert()
local a,b = pcall(function()assert(false)end)
local c,d = pcall(function()return assert(1)end)
return a==false, type(b)=='string', c==true, d==1
end
function testloadstring()
local f = loadstring'return 99'
return f()==99
end
testloadfilename='/BaseLibTestLoadfile.luc'
function testloadfile()
local f = loadfile(testloadfilename)
return f()==99
end
function loader(s) -- helper for testload
return function()local x=s s=nil return x end
end
function testload()
local f = load(loader'return 99')
return f()==99
end
function testdofile()
return dofile(testloadfilename)==99
end
function testxpcall()
local function anerror()return {}..{}end
local function seven()return 7 end
local a,b = xpcall(anerror, nil)
local c,d = xpcall(anerror, seven)
local e,f = xpcall(seven, anerror)
return a == false, c == false, d == 7, e == true, f == 7
end
function testpcall2()
local a,b,c,d = pcall(pcall, function()return 1+{}end)
return a == true, b == false, type(c) == 'string', d == nil
end
function testpcall3()
local a,b = pcall(function()end)
return a == true, b == nil
end
-- more of a test of error generation itself than of pcall
function testpcall4()
local a,b = pcall(function()return 1>nil end)
assert(a == false)
assert(type(b) == 'string')
return true
end
function testpcall5()
local c,d = pcall(function()return pcall>_VERSION end)
assert(c == false)
assert(type(d) == 'string')
return true
end
function testunpackbig()
local a = {}
for i = 1,2000 do
a[i] = i
end
local x = {unpack(a)}
return x[2000] == 2000
end
function testloaderr()
local a,b = loadstring("'spong'", '')
assert(a == nil)
assert(type(b) == 'string')
return true
end
-- Test using NaN as a table index. It's here for entirely bogus
-- reasons of convenience.
function testnanindex()
local t = {}
local nan = 0/0
assert(pcall(function()t[nan]=''end) == false)
return true
end
-- Test that 'a99' + '11' is an error.
function testhexerror()
assert(pcall(function()return'a99'+'11'end) == false)
return true
end
| lgpl-3.0 |
DarkstarProject/darkstar | scripts/zones/Windurst_Walls/Zone.lua | 9 | 2709 | -----------------------------------
--
-- Zone: Windurst_Walls (239)
--
-----------------------------------
local ID = require("scripts/zones/Windurst_Walls/IDs")
require("scripts/globals/conquest")
require("scripts/globals/settings")
require("scripts/globals/keyitems")
require("scripts/globals/missions")
require("scripts/globals/quests")
require("scripts/globals/zone")
-----------------------------------
function onInitialize(zone)
zone:registerRegion(1, -2,-17,140, 2,-16,142);
end;
function onZoneIn(player,prevZone)
local cs = -1;
-- MOG HOUSE EXIT
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
position = math.random(1,5) - 123;
player:setPos(-257.5,-5.05,position,0);
if (player:getMainJob() ~= player:getCharVar("PlayerMainJob")) then
cs = 30004;
end
player:setCharVar("PlayerMainJob",0);
elseif (ENABLE_ASA == 1 and player:getCurrentMission(ASA) == dsp.mission.id.asa.A_SHANTOTTO_ASCENSION
and (prevZone == dsp.zone.WINDURST_WATERS or prevZone == dsp.zone.WINDURST_WOODS) and player:getMainLvl()>=10) then
cs = 510;
elseif (player:getCurrentMission(WINDURST) == dsp.mission.id.windurst.MOON_READING and player:getCharVar("MissionStatus") == 4) then
cs = 443;
end
return cs;
end;
function onConquestUpdate(zone, updatetype)
dsp.conq.onConquestUpdate(zone, updatetype)
end;
function onRegionEnter(player,region)
switch (region:GetRegionID()): caseof
{
[1] = function (x) -- Heaven's Tower enter portal
player:startEvent(86);
end,
}
end;
function onRegionLeave(player,region)
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 86) then
player:setPos(0,0,-22.40,192,242);
elseif (csid == 30004 and option == 0) then
player:setHomePoint();
player:messageSpecial(ID.text.HOMEPOINT_SET);
elseif (csid == 510) then
player:startEvent(514);
elseif (csid == 514) then
player:completeMission(ASA,dsp.mission.id.asa.A_SHANTOTTO_ASCENSION);
player:addMission(ASA,dsp.mission.id.asa.BURGEONING_DREAD);
player:setCharVar("ASA_Status",0);
elseif (csid == 443) then
player:completeMission(WINDURST,dsp.mission.id.windurst.MOON_READING);
player:setCharVar("MissionStatus",0);
player:setRank(10);
player:addGil(GIL_RATE*100000);
player:messageSpecial(ID.text.GIL_OBTAINED,GIL_RATE*100000);
player:addItem(183);
player:messageSpecial(ID.text.ITEM_OBTAINED,183);
player:addTitle(dsp.title.VESTAL_CHAMBERLAIN);
end
end;
| gpl-3.0 |
crunchuser/prosody-modules | mod_broadcast/mod_broadcast.lua | 32 | 1043 | local is_admin = require "core.usermanager".is_admin;
local allowed_senders = module:get_option_set("broadcast_senders", {});
local from_address = module:get_option_string("broadcast_from");
local jid_bare = require "util.jid".bare;
function send_to_online(message)
local c = 0;
for hostname, host_session in pairs(hosts) do
if host_session.sessions then
for username in pairs(host_session.sessions) do
c = c + 1;
message.attr.to = username.."@"..hostname;
module:send(message);
end
end
end
return c;
end
function send_message(event)
local stanza = event.stanza;
local from = stanza.attr.from;
if is_admin(from) or allowed_senders:contains(jid_bare(from)) then
if from_address then
stanza = st.clone(stanza);
stanza.attr.from = from_address;
end
local c = send_to_online(stanza);
module:log("debug", "Broadcast stanza from %s to %d online users", from, c);
return true;
else
module:log("warn", "Broadcasting is not allowed for %s", from);
end
end
module:hook("message/bare", send_message);
| mit |
devFRIND/TAEMNEW | plugins/helpsudo.lua | 2 | 2135 | --[[
▀▄ ▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀
▀▄ ▄▀ ▀▄ ▄▀
▀▄ ▄▀ BY TAEMNEW ▀▄ ▄▀
▀▄ ▄▀ BY TAEMNEW (@illOlli) ▀▄ ▄▀
▀▄ ▄▀ JUST WRITED BY TAEMNEW ▀▄ ▄▀
▀▄ ▄▀ م المطور ▀▄ ▄▀
▀▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀
--]]
do
local function BAKURY(msg, matches)
local reply_id = msg['id']
if is_sudo(msg) and matches[1]== "م المطور" then
local S = [[ 💯 اوامر المطورين 💯
🔸➖🔹➖🔸➖🔹➖🔸ـ
🔧 تفعيل 🔧: ↝↜
{لتفعيل البوت ب المجموعه}
⚠ تعطيل ⚠ : ↝↜
{لتعطيل البوت ب المجموعه}
📢 اذاعه 🔊: ↝↜
{لنشر كلمه ب جميع مجموعات البوت}
🚨 تشغيل البوت 🚨: ↝↜
{ لتشغيل البوت ب المجموعه معينه}
❌طرد البوت ❌ : ↝↜
{ لطرد البوت من المجموعه}
📠 جلب ملف 📠: ↝↜
{ لجلب الملف من السيرفر}
💠 صنع مجموعه 💠: ↝↜
{لصنع مجموعه من البوت}
💎 مسح المعرف 💎 : ↝↜
{لمسح معرف المجموعه}
❌مسح الادمنيه ❌: ↝↜
{لمسح الادمنيه في المجموعه}
❌ مسح الاداريين ❌ : ↝↜
{لمسح الاداريين في المجموعه}
➖🚨➖🚨➖🚨➖🚨➖🚨➖🚨➖🚨
💯-ĐEV💀: @illOlli
💯-ĐEV ฿๏T💀: @Twsl_devbot
💯-ĐEV Ϲḫ₳ͷͷєℓ💀:
]]
reply_msg(reply_id, S, ok_cb, false)
end
if not is_sudo(msg) then
local S = "ليش تبحبش😎🖕🏿"
reply_msg(reply_id, S, ok_cb, false)
end
end
return {
description = "Help list",
usage = "Help list",
patterns = {
"^(م المطور)$",
},
run = BAKURY
}
end | gpl-2.0 |
gdewald/Sputter | dev/premake/premake/src/actions/xcode/xcode_common.lua | 2 | 26535 | --
-- xcode_common.lua
-- Functions to generate the different sections of an Xcode project.
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
--
local xcode = premake.xcode
local tree = premake.tree
--
-- Return the Xcode build category for a given file, based on the file extension.
--
-- @param node
-- The node to identify.
-- @returns
-- An Xcode build category, one of "Sources", "Resources", "Frameworks", or nil.
--
function xcode.getbuildcategory(node)
local categories = {
[".a"] = "Frameworks",
[".c"] = "Sources",
[".cc"] = "Sources",
[".cpp"] = "Sources",
[".cxx"] = "Sources",
[".dylib"] = "Frameworks",
[".framework"] = "Frameworks",
[".m"] = "Sources",
[".mm"] = "Sources",
[".strings"] = "Resources",
[".nib"] = "Resources",
[".xib"] = "Resources",
[".icns"] = "Resources",
[".bmp"] = "Resources",
[".wav"] = "Resources",
}
return categories[path.getextension(node.name)]
end
--
-- Return the displayed name for a build configuration, taking into account the
-- configuration and platform, i.e. "Debug 32-bit Universal".
--
-- @param cfg
-- The configuration being identified.
-- @returns
-- A build configuration name.
--
function xcode.getconfigname(cfg)
local name = cfg.name
if #cfg.project.solution.xcode.platforms > 1 then
name = name .. " " .. premake.action.current().valid_platforms[cfg.platform]
end
return name
end
--
-- Return the Xcode type for a given file, based on the file extension.
--
-- @param fname
-- The file name to identify.
-- @returns
-- An Xcode file type, string.
--
function xcode.getfiletype(node)
local types = {
[".c"] = "sourcecode.c.c",
[".cc"] = "sourcecode.cpp.cpp",
[".cpp"] = "sourcecode.cpp.cpp",
[".css"] = "text.css",
[".cxx"] = "sourcecode.cpp.cpp",
[".framework"] = "wrapper.framework",
[".gif"] = "image.gif",
[".h"] = "sourcecode.c.h",
[".html"] = "text.html",
[".lua"] = "sourcecode.lua",
[".m"] = "sourcecode.c.objc",
[".mm"] = "sourcecode.cpp.objc",
[".nib"] = "wrapper.nib",
[".pch"] = "sourcecode.c.h",
[".plist"] = "text.plist.xml",
[".strings"] = "text.plist.strings",
[".xib"] = "file.xib",
[".icns"] = "image.icns",
[".bmp"] = "image.bmp",
[".wav"] = "audio.wav",
}
return types[path.getextension(node.path)] or "text"
end
--
-- Return the Xcode product type, based target kind.
--
-- @param node
-- The product node to identify.
-- @returns
-- An Xcode product type, string.
--
function xcode.getproducttype(node)
local types = {
ConsoleApp = "com.apple.product-type.tool",
WindowedApp = "com.apple.product-type.application",
StaticLib = "com.apple.product-type.library.static",
SharedLib = "com.apple.product-type.library.dynamic",
}
return types[node.cfg.kind]
end
--
-- Return the Xcode target type, based on the target file extension.
--
-- @param node
-- The product node to identify.
-- @returns
-- An Xcode target type, string.
--
function xcode.gettargettype(node)
local types = {
ConsoleApp = "\"compiled.mach-o.executable\"",
WindowedApp = "wrapper.application",
StaticLib = "archive.ar",
SharedLib = "\"compiled.mach-o.dylib\"",
}
return types[node.cfg.kind]
end
--
-- Return a unique file name for a project. Since Xcode uses .xcodeproj's to
-- represent both solutions and projects there is a likely change of a name
-- collision. Tack on a number to differentiate them.
--
-- @param prj
-- The project being queried.
-- @returns
-- A uniqued file name
--
function xcode.getxcodeprojname(prj)
-- if there is a solution with matching name, then use "projectname1.xcodeproj"
-- just get something working for now
local fname = premake.project.getfilename(prj, "%%.xcodeproj")
return fname
end
--
-- Returns true if the file name represents a framework.
--
-- @param fname
-- The name of the file to test.
--
function xcode.isframework(fname)
return (path.getextension(fname) == ".framework")
end
--
-- Retrieves a unique 12 byte ID for an object. This function accepts and ignores two
-- parameters 'node' and 'usage', which are used by an alternative implementation of
-- this function for testing.
--
-- @returns
-- A 24-character string representing the 12 byte ID.
--
function xcode.newid()
return string.format("%04X%04X%04X%04X%04X%04X",
math.random(0, 32767),
math.random(0, 32767),
math.random(0, 32767),
math.random(0, 32767),
math.random(0, 32767),
math.random(0, 32767))
end
--
-- Create a product tree node and all projects in a solution; assigning IDs
-- that are needed for inter-project dependencies.
--
-- @param sln
-- The solution to prepare.
--
function xcode.preparesolution(sln)
-- create and cache a list of supported platforms
sln.xcode = { }
sln.xcode.platforms = premake.filterplatforms(sln, premake.action.current().valid_platforms, "Universal")
for prj in premake.solution.eachproject(sln) do
-- need a configuration to get the target information
local cfg = premake.getconfig(prj, prj.configurations[1], sln.xcode.platforms[1])
-- build the product tree node
local node = premake.tree.new(path.getname(cfg.buildtarget.bundlepath))
node.cfg = cfg
node.id = premake.xcode.newid(node, "product")
node.targetid = premake.xcode.newid(node, "target")
-- attach it to the project
prj.xcode = {}
prj.xcode.projectnode = node
end
end
--
-- Print out a list value in the Xcode format.
--
-- @param list
-- The list of values to be printed.
-- @param tag
-- The Xcode specific list tag.
--
function xcode.printlist(list, tag)
if #list > 0 then
_p(4,'%s = (', tag)
for _, item in ipairs(list) do
_p(5, '"%s",', item)
end
_p(4,');')
end
end
---------------------------------------------------------------------------
-- Section generator functions, in the same order in which they appear
-- in the .pbxproj file
---------------------------------------------------------------------------
function xcode.Header()
_p('// !$*UTF8*$!')
_p('{')
_p(1,'archiveVersion = 1;')
_p(1,'classes = {')
_p(1,'};')
_p(1,'objectVersion = 45;')
_p(1,'objects = {')
_p('')
end
function xcode.PBXBuildFile(tr)
_p('/* Begin PBXBuildFile section */')
tree.traverse(tr, {
onnode = function(node)
if node.buildid then
_p(2,'%s /* %s in %s */ = {isa = PBXBuildFile; fileRef = %s /* %s */; };',
node.buildid, node.name, xcode.getbuildcategory(node), node.id, node.name)
end
end
})
_p('/* End PBXBuildFile section */')
_p('')
end
function xcode.PBXContainerItemProxy(tr)
if #tr.projects.children > 0 then
_p('/* Begin PBXContainerItemProxy section */')
for _, node in ipairs(tr.projects.children) do
_p(2,'%s /* PBXContainerItemProxy */ = {', node.productproxyid)
_p(3,'isa = PBXContainerItemProxy;')
_p(3,'containerPortal = %s /* %s */;', node.id, path.getname(node.path))
_p(3,'proxyType = 2;')
_p(3,'remoteGlobalIDString = %s;', node.project.xcode.projectnode.id)
_p(3,'remoteInfo = "%s";', node.project.xcode.projectnode.name)
_p(2,'};')
_p(2,'%s /* PBXContainerItemProxy */ = {', node.targetproxyid)
_p(3,'isa = PBXContainerItemProxy;')
_p(3,'containerPortal = %s /* %s */;', node.id, path.getname(node.path))
_p(3,'proxyType = 1;')
_p(3,'remoteGlobalIDString = %s;', node.project.xcode.projectnode.targetid)
_p(3,'remoteInfo = "%s";', node.project.xcode.projectnode.name)
_p(2,'};')
end
_p('/* End PBXContainerItemProxy section */')
_p('')
end
end
function xcode.PBXFileReference(tr)
_p('/* Begin PBXFileReference section */')
tree.traverse(tr, {
onleaf = function(node)
-- I'm only listing files here, so ignore anything without a path
if not node.path then
return
end
-- is this the product node, describing the output target?
if node.kind == "product" then
_p(2,'%s /* %s */ = {isa = PBXFileReference; explicitFileType = %s; includeInIndex = 0; name = "%s"; path = "%s"; sourceTree = BUILT_PRODUCTS_DIR; };',
node.id, node.name, xcode.gettargettype(node), node.name, path.getname(node.cfg.buildtarget.bundlepath))
-- is this a project dependency?
elseif node.parent.parent == tr.projects then
local relpath = path.getrelative(tr.project.location, node.parent.project.location)
_p(2,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "%s"; path = "%s"; sourceTree = SOURCE_ROOT; };',
node.parent.id, node.parent.name, node.parent.name, path.join(relpath, node.parent.name))
-- something else
else
local pth, src
if xcode.isframework(node.path) then
--respect user supplied paths
-- look for special variable-starting paths for different sources
local nodePath = node.path
local _, matchEnd, variable = string.find(nodePath, "^%$%((.+)%)/")
if variable then
-- by skipping the last '/' we support the same absolute/relative
-- paths as before
nodePath = string.sub(nodePath, matchEnd + 1)
end
if string.find(nodePath,'/') then
if string.find(nodePath,'^%.')then
error('relative paths are not currently supported for frameworks')
end
pth = nodePath
else
pth = "/System/Library/Frameworks/" .. nodePath
end
-- if it starts with a variable, use that as the src instead
if variable then
src = variable
-- if we are using a different source tree, it has to be relative
-- to that source tree, so get rid of any leading '/'
if string.find(pth, '^/') then
pth = string.sub(pth, 2)
end
else
src = "<absolute>"
end
else
-- something else; probably a source code file
src = "<group>"
-- if the parent node is virtual, it won't have a local path
-- of its own; need to use full relative path from project
if node.parent.isvpath then
pth = node.cfg.name
else
pth = tree.getlocalpath(node)
end
end
_p(2,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = %s; name = "%s"; path = "%s"; sourceTree = "%s"; };',
node.id, node.name, xcode.getfiletype(node), node.name, pth, src)
end
end
})
_p('/* End PBXFileReference section */')
_p('')
end
function xcode.PBXFrameworksBuildPhase(tr)
_p('/* Begin PBXFrameworksBuildPhase section */')
_p(2,'%s /* Frameworks */ = {', tr.products.children[1].fxstageid)
_p(3,'isa = PBXFrameworksBuildPhase;')
_p(3,'buildActionMask = 2147483647;')
_p(3,'files = (')
-- write out library dependencies
tree.traverse(tr.frameworks, {
onleaf = function(node)
_p(4,'%s /* %s in Frameworks */,', node.buildid, node.name)
end
})
-- write out project dependencies
tree.traverse(tr.projects, {
onleaf = function(node)
_p(4,'%s /* %s in Frameworks */,', node.buildid, node.name)
end
})
_p(3,');')
_p(3,'runOnlyForDeploymentPostprocessing = 0;')
_p(2,'};')
_p('/* End PBXFrameworksBuildPhase section */')
_p('')
end
function xcode.PBXGroup(tr)
_p('/* Begin PBXGroup section */')
tree.traverse(tr, {
onnode = function(node)
-- Skip over anything that isn't a proper group
if (node.path and #node.children == 0) or node.kind == "vgroup" then
return
end
-- project references get special treatment
if node.parent == tr.projects then
_p(2,'%s /* Products */ = {', node.productgroupid)
else
_p(2,'%s /* %s */ = {', node.id, node.name)
end
_p(3,'isa = PBXGroup;')
_p(3,'children = (')
for _, childnode in ipairs(node.children) do
_p(4,'%s /* %s */,', childnode.id, childnode.name)
end
_p(3,');')
if node.parent == tr.projects then
_p(3,'name = Products;')
else
_p(3,'name = "%s";', node.name)
if node.path and not node.isvpath then
local p = node.path
if node.parent.path then
p = path.getrelative(node.parent.path, node.path)
end
_p(3,'path = "%s";', p)
end
end
_p(3,'sourceTree = "<group>";')
_p(2,'};')
end
}, true)
_p('/* End PBXGroup section */')
_p('')
end
function xcode.PBXNativeTarget(tr)
_p('/* Begin PBXNativeTarget section */')
for _, node in ipairs(tr.products.children) do
local name = tr.project.name
-- This function checks whether there are build commands of a specific
-- type to be executed; they will be generated correctly, but the project
-- commands will not contain any per-configuration commands, so the logic
-- has to be extended a bit to account for that.
local function hasBuildCommands(which)
-- standard check...this is what existed before
if #tr.project[which] > 0 then
return true
end
-- what if there are no project-level commands? check configs...
for _, cfg in ipairs(tr.configs) do
if #cfg[which] > 0 then
return true
end
end
end
_p(2,'%s /* %s */ = {', node.targetid, name)
_p(3,'isa = PBXNativeTarget;')
_p(3,'buildConfigurationList = %s /* Build configuration list for PBXNativeTarget "%s" */;', node.cfgsection, name)
_p(3,'buildPhases = (')
if hasBuildCommands('prebuildcommands') then
_p(4,'9607AE1010C857E500CD1376 /* Prebuild */,')
end
_p(4,'%s /* Resources */,', node.resstageid)
_p(4,'%s /* Sources */,', node.sourcesid)
if hasBuildCommands('prelinkcommands') then
_p(4,'9607AE3510C85E7E00CD1376 /* Prelink */,')
end
_p(4,'%s /* Frameworks */,', node.fxstageid)
if hasBuildCommands('postbuildcommands') then
_p(4,'9607AE3710C85E8F00CD1376 /* Postbuild */,')
end
_p(3,');')
_p(3,'buildRules = (')
_p(3,');')
_p(3,'dependencies = (')
for _, node in ipairs(tr.projects.children) do
_p(4,'%s /* PBXTargetDependency */,', node.targetdependid)
end
_p(3,');')
_p(3,'name = "%s";', name)
local p
if node.cfg.kind == "ConsoleApp" then
p = "$(HOME)/bin"
elseif node.cfg.kind == "WindowedApp" then
p = "$(HOME)/Applications"
end
if p then
_p(3,'productInstallPath = "%s";', p)
end
_p(3,'productName = "%s";', name)
_p(3,'productReference = %s /* %s */;', node.id, node.name)
_p(3,'productType = "%s";', xcode.getproducttype(node))
_p(2,'};')
end
_p('/* End PBXNativeTarget section */')
_p('')
end
function xcode.PBXProject(tr)
_p('/* Begin PBXProject section */')
_p(2,'08FB7793FE84155DC02AAC07 /* Project object */ = {')
_p(3,'isa = PBXProject;')
_p(3,'buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "%s" */;', tr.name)
_p(3,'compatibilityVersion = "Xcode 3.2";')
_p(3,'hasScannedForEncodings = 1;')
_p(3,'mainGroup = %s /* %s */;', tr.id, tr.name)
_p(3,'projectDirPath = "";')
if #tr.projects.children > 0 then
_p(3,'projectReferences = (')
for _, node in ipairs(tr.projects.children) do
_p(4,'{')
_p(5,'ProductGroup = %s /* Products */;', node.productgroupid)
_p(5,'ProjectRef = %s /* %s */;', node.id, path.getname(node.path))
_p(4,'},')
end
_p(3,');')
end
_p(3,'projectRoot = "";')
_p(3,'targets = (')
for _, node in ipairs(tr.products.children) do
_p(4,'%s /* %s */,', node.targetid, node.name)
end
_p(3,');')
_p(2,'};')
_p('/* End PBXProject section */')
_p('')
end
function xcode.PBXReferenceProxy(tr)
if #tr.projects.children > 0 then
_p('/* Begin PBXReferenceProxy section */')
tree.traverse(tr.projects, {
onleaf = function(node)
_p(2,'%s /* %s */ = {', node.id, node.name)
_p(3,'isa = PBXReferenceProxy;')
_p(3,'fileType = %s;', xcode.gettargettype(node))
_p(3,'path = "%s";', node.path)
_p(3,'remoteRef = %s /* PBXContainerItemProxy */;', node.parent.productproxyid)
_p(3,'sourceTree = BUILT_PRODUCTS_DIR;')
_p(2,'};')
end
})
_p('/* End PBXReferenceProxy section */')
_p('')
end
end
function xcode.PBXResourcesBuildPhase(tr)
_p('/* Begin PBXResourcesBuildPhase section */')
for _, target in ipairs(tr.products.children) do
_p(2,'%s /* Resources */ = {', target.resstageid)
_p(3,'isa = PBXResourcesBuildPhase;')
_p(3,'buildActionMask = 2147483647;')
_p(3,'files = (')
tree.traverse(tr, {
onnode = function(node)
if xcode.getbuildcategory(node) == "Resources" then
_p(4,'%s /* %s in Resources */,', node.buildid, node.name)
end
end
})
_p(3,');')
_p(3,'runOnlyForDeploymentPostprocessing = 0;')
_p(2,'};')
end
_p('/* End PBXResourcesBuildPhase section */')
_p('')
end
function xcode.PBXShellScriptBuildPhase(tr)
local wrapperWritten = false
local function doblock(id, name, which)
-- start with the project-level commands (most common)
local prjcmds = tr.project[which]
local commands = table.join(prjcmds, {})
-- see if there are any config-specific commands to add
for _, cfg in ipairs(tr.configs) do
local cfgcmds = cfg[which]
if #cfgcmds > #prjcmds then
table.insert(commands, 'if [ "${CONFIGURATION}" = "' .. xcode.getconfigname(cfg) .. '" ]; then')
for i = #prjcmds + 1, #cfgcmds do
table.insert(commands, cfgcmds[i])
end
table.insert(commands, 'fi')
end
end
if #commands > 0 then
if not wrapperWritten then
_p('/* Begin PBXShellScriptBuildPhase section */')
wrapperWritten = true
end
_p(2,'%s /* %s */ = {', id, name)
_p(3,'isa = PBXShellScriptBuildPhase;')
_p(3,'buildActionMask = 2147483647;')
_p(3,'files = (')
_p(3,');')
_p(3,'inputPaths = (');
_p(3,');');
_p(3,'name = %s;', name);
_p(3,'outputPaths = (');
_p(3,');');
_p(3,'runOnlyForDeploymentPostprocessing = 0;');
_p(3,'shellPath = /bin/sh;');
_p(3,'shellScript = "%s";', table.concat(commands, "\\n"):gsub('"', '\\"'))
_p(2,'};')
end
end
doblock("9607AE1010C857E500CD1376", "Prebuild", "prebuildcommands")
doblock("9607AE3510C85E7E00CD1376", "Prelink", "prelinkcommands")
doblock("9607AE3710C85E8F00CD1376", "Postbuild", "postbuildcommands")
if wrapperWritten then
_p('/* End PBXShellScriptBuildPhase section */')
end
end
function xcode.PBXSourcesBuildPhase(tr)
_p('/* Begin PBXSourcesBuildPhase section */')
for _, target in ipairs(tr.products.children) do
_p(2,'%s /* Sources */ = {', target.sourcesid)
_p(3,'isa = PBXSourcesBuildPhase;')
_p(3,'buildActionMask = 2147483647;')
_p(3,'files = (')
tree.traverse(tr, {
onleaf = function(node)
if xcode.getbuildcategory(node) == "Sources" then
_p(4,'%s /* %s in Sources */,', node.buildid, node.name)
end
end
})
_p(3,');')
_p(3,'runOnlyForDeploymentPostprocessing = 0;')
_p(2,'};')
end
_p('/* End PBXSourcesBuildPhase section */')
_p('')
end
function xcode.PBXVariantGroup(tr)
_p('/* Begin PBXVariantGroup section */')
tree.traverse(tr, {
onbranch = function(node)
if node.kind == "vgroup" then
_p(2,'%s /* %s */ = {', node.id, node.name)
_p(3,'isa = PBXVariantGroup;')
_p(3,'children = (')
for _, lang in ipairs(node.children) do
_p(4,'%s /* %s */,', lang.id, lang.name)
end
_p(3,');')
_p(3,'name = %s;', node.name)
_p(3,'sourceTree = "<group>";')
_p(2,'};')
end
end
})
_p('/* End PBXVariantGroup section */')
_p('')
end
function xcode.PBXTargetDependency(tr)
if #tr.projects.children > 0 then
_p('/* Begin PBXTargetDependency section */')
tree.traverse(tr.projects, {
onleaf = function(node)
_p(2,'%s /* PBXTargetDependency */ = {', node.parent.targetdependid)
_p(3,'isa = PBXTargetDependency;')
_p(3,'name = "%s";', node.name)
_p(3,'targetProxy = %s /* PBXContainerItemProxy */;', node.parent.targetproxyid)
_p(2,'};')
end
})
_p('/* End PBXTargetDependency section */')
_p('')
end
end
function xcode.XCBuildConfiguration_Target(tr, target, cfg)
local cfgname = xcode.getconfigname(cfg)
_p(2,'%s /* %s */ = {', cfg.xcode.targetid, cfgname)
_p(3,'isa = XCBuildConfiguration;')
_p(3,'buildSettings = {')
_p(4,'ALWAYS_SEARCH_USER_PATHS = NO;')
if not cfg.flags.Symbols then
_p(4,'DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";')
end
if cfg.kind ~= "StaticLib" and cfg.buildtarget.prefix ~= "" then
_p(4,'EXECUTABLE_PREFIX = %s;', cfg.buildtarget.prefix)
end
if cfg.targetextension then
local ext = cfg.targetextension
ext = iif(ext:startswith("."), ext:sub(2), ext)
_p(4,'EXECUTABLE_EXTENSION = %s;', ext)
end
local outdir = path.getdirectory(cfg.buildtarget.bundlepath)
if outdir ~= "." then
_p(4,'CONFIGURATION_BUILD_DIR = %s;', outdir)
end
_p(4,'GCC_DYNAMIC_NO_PIC = NO;')
_p(4,'GCC_MODEL_TUNING = G5;')
if tr.infoplist then
_p(4,'INFOPLIST_FILE = "%s";', tr.infoplist.cfg.name)
end
installpaths = {
ConsoleApp = '/usr/local/bin',
WindowedApp = '"$(HOME)/Applications"',
SharedLib = '/usr/local/lib',
StaticLib = '/usr/local/lib',
}
_p(4,'INSTALL_PATH = %s;', installpaths[cfg.kind])
_p(4,'PRODUCT_NAME = "%s";', cfg.buildtarget.basename)
_p(3,'};')
_p(3,'name = "%s";', cfgname)
_p(2,'};')
end
function xcode.XCBuildConfiguration_Project(tr, cfg)
local cfgname = xcode.getconfigname(cfg)
_p(2,'%s /* %s */ = {', cfg.xcode.projectid, cfgname)
_p(3,'isa = XCBuildConfiguration;')
_p(3,'buildSettings = {')
local archs = {
Native = "$(NATIVE_ARCH_ACTUAL)",
x32 = "i386",
x64 = "x86_64",
Universal32 = "$(ARCHS_STANDARD_32_BIT)",
Universal64 = "$(ARCHS_STANDARD_64_BIT)",
Universal = "$(ARCHS_STANDARD_32_64_BIT)",
}
_p(4,'ARCHS = "%s";', archs[cfg.platform])
local targetdir = path.getdirectory(cfg.buildtarget.bundlepath)
if targetdir ~= "." then
_p(4,'CONFIGURATION_BUILD_DIR = "$(SYMROOT)";');
end
_p(4,'CONFIGURATION_TEMP_DIR = "$(OBJROOT)";')
if cfg.flags.Symbols then
_p(4,'COPY_PHASE_STRIP = NO;')
end
_p(4,'GCC_C_LANGUAGE_STANDARD = gnu99;')
if cfg.flags.NoExceptions then
_p(4,'GCC_ENABLE_CPP_EXCEPTIONS = NO;')
end
if cfg.flags.NoRTTI then
_p(4,'GCC_ENABLE_CPP_RTTI = NO;')
end
if _ACTION ~= "xcode4" and cfg.flags.Symbols and not cfg.flags.NoEditAndContinue then
_p(4,'GCC_ENABLE_FIX_AND_CONTINUE = YES;')
end
if cfg.flags.NoExceptions then
_p(4,'GCC_ENABLE_OBJC_EXCEPTIONS = NO;')
end
if cfg.flags.Optimize or cfg.flags.OptimizeSize then
_p(4,'GCC_OPTIMIZATION_LEVEL = s;')
elseif cfg.flags.OptimizeSpeed then
_p(4,'GCC_OPTIMIZATION_LEVEL = 3;')
else
_p(4,'GCC_OPTIMIZATION_LEVEL = 0;')
end
if cfg.pchheader and not cfg.flags.NoPCH then
_p(4,'GCC_PRECOMPILE_PREFIX_HEADER = YES;')
_p(4,'GCC_PREFIX_HEADER = "%s";', cfg.pchheader)
end
xcode.printlist(cfg.defines, 'GCC_PREPROCESSOR_DEFINITIONS')
_p(4,'GCC_SYMBOLS_PRIVATE_EXTERN = NO;')
if cfg.flags.FatalWarnings then
_p(4,'GCC_TREAT_WARNINGS_AS_ERRORS = YES;')
end
_p(4,'GCC_WARN_ABOUT_RETURN_TYPE = YES;')
_p(4,'GCC_WARN_UNUSED_VARIABLE = YES;')
xcode.printlist(cfg.includedirs, 'HEADER_SEARCH_PATHS')
xcode.printlist(cfg.libdirs, 'LIBRARY_SEARCH_PATHS')
_p(4,'OBJROOT = "%s";', cfg.objectsdir)
_p(4,'ONLY_ACTIVE_ARCH = %s;',iif(premake.config.isdebugbuild(cfg),'YES','NO'))
-- build list of "other" C/C++ flags
local checks = {
["-ffast-math"] = cfg.flags.FloatFast,
["-ffloat-store"] = cfg.flags.FloatStrict,
["-fomit-frame-pointer"] = cfg.flags.NoFramePointer,
}
local flags = { }
for flag, check in pairs(checks) do
if check then
table.insert(flags, flag)
end
end
xcode.printlist(table.join(flags, cfg.buildoptions), 'OTHER_CFLAGS')
-- build list of "other" linked flags. All libraries that aren't frameworks
-- are listed here, so I don't have to try and figure out if they are ".a"
-- or ".dylib", which Xcode requires to list in the Frameworks section
flags = { }
for _, lib in ipairs(premake.getlinks(cfg, "system")) do
if not xcode.isframework(lib) then
table.insert(flags, "-l" .. lib)
end
end
flags = table.join(flags, cfg.linkoptions)
xcode.printlist(flags, 'OTHER_LDFLAGS')
if cfg.flags.StaticRuntime then
_p(4,'STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static;')
end
if targetdir ~= "." then
_p(4,'SYMROOT = "%s";', targetdir)
end
if cfg.flags.ExtraWarnings then
_p(4,'WARNING_CFLAGS = "-Wall";')
end
_p(3,'};')
_p(3,'name = "%s";', cfgname)
_p(2,'};')
end
function xcode.XCBuildConfiguration(tr)
_p('/* Begin XCBuildConfiguration section */')
for _, target in ipairs(tr.products.children) do
for _, cfg in ipairs(tr.configs) do
xcode.XCBuildConfiguration_Target(tr, target, cfg)
end
end
for _, cfg in ipairs(tr.configs) do
xcode.XCBuildConfiguration_Project(tr, cfg)
end
_p('/* End XCBuildConfiguration section */')
_p('')
end
function xcode.XCBuildConfigurationList(tr)
local sln = tr.project.solution
_p('/* Begin XCConfigurationList section */')
for _, target in ipairs(tr.products.children) do
_p(2,'%s /* Build configuration list for PBXNativeTarget "%s" */ = {', target.cfgsection, target.name)
_p(3,'isa = XCConfigurationList;')
_p(3,'buildConfigurations = (')
for _, cfg in ipairs(tr.configs) do
_p(4,'%s /* %s */,', cfg.xcode.targetid, xcode.getconfigname(cfg))
end
_p(3,');')
_p(3,'defaultConfigurationIsVisible = 0;')
_p(3,'defaultConfigurationName = "%s";', xcode.getconfigname(tr.configs[1]))
_p(2,'};')
end
_p(2,'1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "%s" */ = {', tr.name)
_p(3,'isa = XCConfigurationList;')
_p(3,'buildConfigurations = (')
for _, cfg in ipairs(tr.configs) do
_p(4,'%s /* %s */,', cfg.xcode.projectid, xcode.getconfigname(cfg))
end
_p(3,');')
_p(3,'defaultConfigurationIsVisible = 0;')
_p(3,'defaultConfigurationName = "%s";', xcode.getconfigname(tr.configs[1]))
_p(2,'};')
_p('/* End XCConfigurationList section */')
_p('')
end
function xcode.Footer()
_p(1,'};')
_p('\trootObject = 08FB7793FE84155DC02AAC07 /* Project object */;')
_p('}')
end
| mit |
DarkstarProject/darkstar | scripts/globals/abilities/super_jump.lua | 12 | 1039 | -----------------------------------
-- Ability: Super Jump
-- Performs a super jump.
-- Obtained: Dragoon Level 50
-- Recast Time: 3:00
-- Duration: Instant
-----------------------------------
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/pets")
require("scripts/globals/msg")
-----------------------------------
function onAbilityCheck(player,target,ability)
return 0,0
end
function onUseAbility(player,target,ability)
-- Reduce 99% of total accumulated enmity
if (target:isMob()) then
target:lowerEnmity(player, 99)
end
ability:setMsg(dsp.msg.basic.NONE)
-- Prevent the player from performing actions while in the air
player:queue(0, function(player)
player:stun(5000)
end)
-- If the Dragoon's wyvern is out and alive, tell it to use Super Climb
local wyvern = player:getPet()
if (wyvern ~= nil and player:getPetID() == dsp.pet.id.WYVERN and wyvern:getHP() > 0) then
wyvern:useJobAbility(636, wyvern)
end
end
| gpl-3.0 |
Fenix-XI/Fenix | scripts/zones/Waughroon_Shrine/bcnms/up_in_arms.lua | 30 | 1813 | -----------------------------------
-- Area: Waughroon_Shrine
-- Name: up in arms
-- BCNM60
-----------------------------------
package.loaded["scripts/zones/Waughroon_Shrine/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/titles");
require("scripts/globals/quests");
require("scripts/zones/Waughroon_Shrine/TextIDs");
-----------------------------------
-- EXAMPLE SCRIPT
--
-- What should go here:
-- giving key items, playing ENDING cutscenes
--
-- What should NOT go here:
-- Handling of "battlefield" status, spawning of monsters,
-- putting loot into treasure pool,
-- enforcing ANY rules (SJ/number of people/etc), moving
-- chars around, playing entrance CSes (entrance CSes go in bcnm.lua)
-- After registering the BCNM via bcnmRegister(bcnmid)
function onBcnmRegister(player,instance)
end;
-- Physically entering the BCNM via bcnmEnter(bcnmid)
function onBcnmEnter(player,instance)
end;
-- Leaving the BCNM by every mean possible, given by the LeaveCode
-- 1=Select Exit on circle
-- 2=Winning the BC
-- 3=Disconnected or warped out
-- 4=Losing the BC
-- via bcnmLeave(1) or bcnmLeave(2). LeaveCodes 3 and 4 are called
-- from the core when a player disconnects or the time limit is up, etc
function onBcnmLeave(player,instance,leavecode)
-- print("leave code "..leavecode);
if (leavecode == 2) then -- play end CS. Need time and battle id for record keeping + storage
player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,1,0);
elseif (leavecode == 4) then
player:startEvent(0x7d02);
end
end;
function onEventUpdate(player,csid,option)
-- print("bc update csid "..csid.." and option "..option);
end;
function onEventFinish(player,csid,option)
-- print("bc finish csid "..csid.." and option "..option);
end;
| gpl-3.0 |
DarkstarProject/darkstar | scripts/zones/The_Boyahda_Tree/npcs/Mandragora_Warden.lua | 9 | 1224 | -----------------------------------
-- Area: The Boyahda Tree
-- NPC: Mandragora Warden
-- Type: Mission NPC
-- !pos 81.981 7.593 139.556 153
-----------------------------------
local ID = require("scripts/zones/The_Boyahda_Tree/IDs")
require("scripts/globals/keyitems")
require("scripts/globals/missions")
require("scripts/globals/npc_util")
-----------------------------------
function onTrade(player,npc,trade)
local missionStatus = player:getCharVar("MissionStatus")
if player:getCurrentMission(WINDURST) == dsp.mission.id.windurst.DOLL_OF_THE_DEAD and (missionStatus == 4 or missionStatus == 5) and npcUtil.tradeHas(trade, 1181) then
player:startEvent(13)
end
end
function onTrigger(player,npc)
if player:getCharVar("MissionStatus") == 4 or player:getCharVar("MissionStatus") == 5 then
player:messageText(npc, ID.text.WARDEN_SPEECH)
player:messageSpecial(ID.text.WARDEN_TRANSLATION)
else
player:startEvent(10)
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 13 then
player:setCharVar("MissionStatus", 6)
npcUtil.giveKeyItem(player, dsp.ki.LETTER_FROM_ZONPAZIPPA)
end
end
| gpl-3.0 |
DarkstarProject/darkstar | scripts/globals/items/roll_of_buche_au_chocolat.lua | 11 | 1298 | -----------------------------------------
-- ID: 5550
-- Item: Roll of Buche Au Chocolat
-- Food Effect: 3 Hrs, All Races
-----------------------------------------
-- TODO: Group Effect
-- HP +8
-- MP +3% Cap 13
-- Intelligence +2
-- HP Recovered while healing +1
-- MP Recovered while healing +4
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,10800,5550)
end
function onEffectGain(target, effect)
target:addMod(dsp.mod.FOOD_MPP, 3)
target:addMod(dsp.mod.FOOD_MP_CAP, 13)
target:addMod(dsp.mod.HP, 8)
target:addMod(dsp.mod.INT, 2)
target:addMod(dsp.mod.HPHEAL, 1)
target:addMod(dsp.mod.MPHEAL, 4)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.FOOD_MPP, 3)
target:delMod(dsp.mod.FOOD_MP_CAP, 13)
target:delMod(dsp.mod.HP, 8)
target:delMod(dsp.mod.INT, 2)
target:delMod(dsp.mod.HPHEAL, 1)
target:delMod(dsp.mod.MPHEAL, 4)
end
| gpl-3.0 |
Fenix-XI/Fenix | scripts/zones/The_Eldieme_Necropolis/npcs/_5fq.lua | 13 | 2634 | -----------------------------------
-- Area: The Eldieme Necropolis
-- NPC: West Plate
-- @pos 150 -32 14 195
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local state0 = 8;
local state1 = 9;
local DoorOffset = npc:getID() - 25; -- _5f1
if (npc:getAnimation() == 8) then
state0 = 9;
state1 = 8;
end
-- Gates
-- Shiva's Gate
GetNPCByID(DoorOffset):setAnimation(state0);
GetNPCByID(DoorOffset+1):setAnimation(state0);
GetNPCByID(DoorOffset+2):setAnimation(state0);
GetNPCByID(DoorOffset+3):setAnimation(state0);
GetNPCByID(DoorOffset+4):setAnimation(state0);
-- Odin's Gate
GetNPCByID(DoorOffset+5):setAnimation(state1);
GetNPCByID(DoorOffset+6):setAnimation(state1);
GetNPCByID(DoorOffset+7):setAnimation(state1);
GetNPCByID(DoorOffset+8):setAnimation(state1);
GetNPCByID(DoorOffset+9):setAnimation(state1);
-- Leviathan's Gate
GetNPCByID(DoorOffset+10):setAnimation(state0);
GetNPCByID(DoorOffset+11):setAnimation(state0);
GetNPCByID(DoorOffset+12):setAnimation(state0);
GetNPCByID(DoorOffset+13):setAnimation(state0);
GetNPCByID(DoorOffset+14):setAnimation(state0);
-- Titan's Gate
GetNPCByID(DoorOffset+15):setAnimation(state1);
GetNPCByID(DoorOffset+16):setAnimation(state1);
GetNPCByID(DoorOffset+17):setAnimation(state1);
GetNPCByID(DoorOffset+18):setAnimation(state1);
GetNPCByID(DoorOffset+19):setAnimation(state1);
-- Plates
-- East Plate
GetNPCByID(DoorOffset+20):setAnimation(state0);
GetNPCByID(DoorOffset+21):setAnimation(state0);
-- North Plate
GetNPCByID(DoorOffset+22):setAnimation(state0);
GetNPCByID(DoorOffset+23):setAnimation(state0);
-- West Plate
GetNPCByID(DoorOffset+24):setAnimation(state0);
GetNPCByID(DoorOffset+25):setAnimation(state0);
-- South Plate
GetNPCByID(DoorOffset+26):setAnimation(state0);
GetNPCByID(DoorOffset+27):setAnimation(state0);
return 0;
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 |
DarkstarProject/darkstar | scripts/globals/effects/last_resort.lua | 12 | 1102 | -----------------------------------
--
-- dsp.effect.LAST_RESORT
--
-----------------------------------
require("scripts/globals/status")
-----------------------------------
function onEffectGain(target, effect)
target:addMod(dsp.mod.ATTP, 25 + target:getMerit(dsp.merit.LAST_RESORT_EFFECT))
target:addMod(dsp.mod.HASTE_ABILITY, target:getMod(dsp.mod.DESPERATE_BLOWS) + target:getMerit(dsp.merit.DESPERATE_BLOWS))
-- Gear that affects this mod is handled by a Latent Effect because the gear must remain equipped
target:addMod(dsp.mod.DEFP, -25 - target:getMerit(dsp.merit.LAST_RESORT_EFFECT))
end
function onEffectTick(target, effect)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.ATTP, 25 + target:getMerit(dsp.merit.LAST_RESORT_EFFECT))
target:delMod(dsp.mod.HASTE_ABILITY, target:getMod(dsp.mod.DESPERATE_BLOWS) + target:getMerit(dsp.merit.DESPERATE_BLOWS))
-- Gear that affects this mod is handled by a Latent Effect because the gear must remain equipped
target:delMod(dsp.mod.DEFP, -25 - target:getMerit(dsp.merit.LAST_RESORT_EFFECT))
end | gpl-3.0 |
DarkstarProject/darkstar | scripts/globals/mobskills/claw_storm.lua | 11 | 1066 | ---------------------------------------------
-- Claw Storm
--
-- Description: Slashes a single target in a threefold attack. Additional effect: Poison
-- Type: Physical
-- Utsusemi/Blink absorb: 1 shadow
-- Range: Melee
-- Notes:
---------------------------------------------
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/monstertpmoves")
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
return 0
end
function onMobWeaponSkill(target, mob, skill)
local numhits = 3
local accmod = 1
local dmgmod = 1.1
local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_NO_EFFECT)
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,dsp.attackType.PHYSICAL,dsp.damageType.SLASHING,info.hitslanded)
target:takeDamage(dmg, mob, dsp.attackType.PHYSICAL, dsp.damageType.SLASHING)
local typeEffect = dsp.effect.POISON
MobPhysicalStatusEffectMove(mob, target, skill, typeEffect, mob:getMainLvl()/2.5, 3, 30)
return dmg
end | gpl-3.0 |
marcel-sch/luci | applications/luci-app-olsr/luasrc/model/cbi/olsr/olsrdiface6.lua | 68 | 5949 | -- Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
local util = require "luci.util"
local ip = require "luci.ip"
function write_float(self, section, value)
local n = tonumber(value)
if n ~= nil then
return Value.write(self, section, "%.1f" % n)
end
end
m = Map("olsrd6", translate("OLSR Daemon - Interface"),
translate("The OLSR daemon is an implementation of the Optimized Link State Routing protocol. "..
"As such it allows mesh routing for any network equipment. "..
"It runs on any wifi card that supports ad-hoc mode and of course on any ethernet device. "..
"Visit <a href='http://www.olsr.org'>olsrd.org</a> for help and documentation."))
m.redirect = luci.dispatcher.build_url("admin/services/olsrd6")
if not arg[1] or m.uci:get("olsrd6", arg[1]) ~= "Interface" then
luci.http.redirect(m.redirect)
return
end
i = m:section(NamedSection, arg[1], "Interface", translate("Interface"))
i.anonymous = true
i.addremove = false
i:tab("general", translate("General Settings"))
i:tab("addrs", translate("IP Addresses"))
i:tab("timing", translate("Timing and Validity"))
ign = i:taboption("general", Flag, "ignore", translate("Enable"),
translate("Enable this interface."))
ign.enabled = "0"
ign.disabled = "1"
ign.rmempty = false
function ign.cfgvalue(self, section)
return Flag.cfgvalue(self, section) or "0"
end
network = i:taboption("general", Value, "interface", translate("Network"),
translate("The interface OLSRd should serve."))
network.template = "cbi/network_netlist"
network.widget = "radio"
network.nocreate = true
mode = i:taboption("general", ListValue, "Mode", translate("Mode"),
translate("Interface Mode is used to prevent unnecessary packet forwarding on switched ethernet interfaces. "..
"valid Modes are \"mesh\" and \"ether\". Default is \"mesh\"."))
mode:value("mesh")
mode:value("ether")
mode.optional = true
mode.rmempty = true
weight = i:taboption("general", Value, "Weight", translate("Weight"),
translate("When multiple links exist between hosts the weight of interface is used to determine the link to use. "..
"Normally the weight is automatically calculated by olsrd based on the characteristics of the interface, "..
"but here you can specify a fixed value. Olsrd will choose links with the lowest value.<br />"..
"<b>Note:</b> Interface weight is used only when LinkQualityLevel is set to 0. "..
"For any other value of LinkQualityLevel, the interface ETX value is used instead."))
weight.optional = true
weight.datatype = "uinteger"
weight.placeholder = "0"
lqmult = i:taboption("general", DynamicList, "LinkQualityMult", translate("LinkQuality Multiplicator"),
translate("Multiply routes with the factor given here. Allowed values are between 0.01 and 1.0. "..
"It is only used when LQ-Level is greater than 0. Examples:<br />"..
"reduce LQ to fd91:662e:3c58::1 by half: fd91:662e:3c58::1 0.5<br />"..
"reduce LQ to all nodes on this interface by 20%: default 0.8"))
lqmult.optional = true
lqmult.rmempty = true
lqmult.cast = "table"
lqmult.placeholder = "default 1.0"
function lqmult.validate(self, value)
for _, v in pairs(value) do
if v ~= "" then
local val = util.split(v, " ")
local host = val[1]
local mult = val[2]
if not host or not mult then
return nil, translate("LQMult requires two values (IP address or 'default' and multiplicator) seperated by space.")
end
if not (host == "default" or ip.IPv6(host)) then
return nil, translate("Can only be a valid IPv6 address or 'default'")
end
if not tonumber(mult) or tonumber(mult) > 1 or tonumber(mult) < 0.01 then
return nil, translate("Invalid Value for LQMult-Value. Must be between 0.01 and 1.0.")
end
if not mult:match("[0-1]%.[0-9]+") then
return nil, translate("Invalid Value for LQMult-Value. You must use a decimal number between 0.01 and 1.0 here.")
end
end
end
return value
end
ip6m = i:taboption("addrs", Value, "IPv6Multicast", translate("IPv6 multicast"),
translate("IPv6 multicast address. Default is \"FF02::6D\", the manet-router linklocal multicast."))
ip6m.optional = true
ip6m.datatype = "ip6addr"
ip6m.placeholder = "FF02::6D"
ip6s = i:taboption("addrs", Value, "IPv6Src", translate("IPv6 source"),
translate("IPv6 src prefix. OLSRd will choose one of the interface IPs which matches the prefix of this parameter. "..
"Default is \"0::/0\", which triggers the usage of a not-linklocal interface IP."))
ip6s.optional = true
ip6s.datatype = "ip6addr"
ip6s.placeholder = "0::/0"
hi = i:taboption("timing", Value, "HelloInterval", translate("Hello interval"))
hi.optional = true
hi.datatype = "ufloat"
hi.placeholder = "5.0"
hi.write = write_float
hv = i:taboption("timing", Value, "HelloValidityTime", translate("Hello validity time"))
hv.optional = true
hv.datatype = "ufloat"
hv.placeholder = "40.0"
hv.write = write_float
ti = i:taboption("timing", Value, "TcInterval", translate("TC interval"))
ti.optional = true
ti.datatype = "ufloat"
ti.placeholder = "2.0"
ti.write = write_float
tv = i:taboption("timing", Value, "TcValidityTime", translate("TC validity time"))
tv.optional = true
tv.datatype = "ufloat"
tv.placeholder = "256.0"
tv.write = write_float
mi = i:taboption("timing", Value, "MidInterval", translate("MID interval"))
mi.optional = true
mi.datatype = "ufloat"
mi.placeholder = "18.0"
mi.write = write_float
mv = i:taboption("timing", Value, "MidValidityTime", translate("MID validity time"))
mv.optional = true
mv.datatype = "ufloat"
mv.placeholder = "324.0"
mv.write = write_float
ai = i:taboption("timing", Value, "HnaInterval", translate("HNA interval"))
ai.optional = true
ai.datatype = "ufloat"
ai.placeholder = "18.0"
ai.write = write_float
av = i:taboption("timing", Value, "HnaValidityTime", translate("HNA validity time"))
av.optional = true
av.datatype = "ufloat"
av.placeholder = "108.0"
av.write = write_float
return m
| apache-2.0 |
DarkstarProject/darkstar | scripts/globals/mobskills/spirits_within.lua | 11 | 1794 | ---------------------------------------------
-- Spirits Within
--
-- Description: Delivers an unavoidable attack. Damage varies with HP and TP.
-- Type: Magical/Breath
-- Utsusemi/Blink absorb: Ignores shadows and most damage reduction.
-- Range: Melee
---------------------------------------------
require("scripts/globals/monstertpmoves")
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/utils")
require("scripts/globals/msg")
function onMobSkillCheck(target,mob,skill)
if (mob:getPool() ~= 4249) then
mob:messageBasic(dsp.msg.basic.READIES_WS, 0, 39)
end
return 0
end
function onMobWeaponSkill(target, mob, skill)
if (mob:getPool() == 4249) then -- Volker@Throne_Room only
target:showText(mob,zones[dsp.zone.THRONE_ROOM].text.RETURN_TO_THE_DARKNESS)
end
local tp = skill:getTP()
local hp = mob:getHP()
local dmg = 0
-- Should produce 1000 - 3750 @ full HP using the player formula, assuming 8k HP for AA EV.
-- dmg * 2.5, as wiki claims ~2500 at 100% HP, until a better formula comes along.
if (tp <= 2000) then -- 1000 - 2000
dmg = math.floor(hp * (math.floor(0.016 * tp) + 16) / 256)
else -- 2001 - 3000
dmg = math.floor(hp * (math.floor(0.072 * tp) - 96) / 256)
end
dmg = dmg * 2.5
-- Believe it or not, it's been proven to be breath damage.
dmg = target:breathDmgTaken(dmg)
-- Handling phalanx
dmg = dmg - target:getMod(dsp.mod.PHALANX)
if (dmg < 0) then
return 0
end
dmg = utils.stoneskin(target, dmg)
if (dmg > 0) then
target:wakeUp()
target:updateEnmityFromDamage(mob,dmg)
end
target:takeDamage(dmg, mob, dsp.attackType.BREATH, dsp.damageType.ELEMENTAL)
return dmg
end
| gpl-3.0 |
facebokiii/ghosto | plugins/commit.lua | 13 | 12985 | -- Commits from https://github.com/ngerakines/commitment.
local doc = [[
/commit
Returns a commit message from whatthecommit.com.
]]
local triggers = {
'^/commit[@'..bot.username..']*'
}
local commits = {
"One does not simply merge into master",
"Merging the merge",
"Another bug bites the dust",
"de-misunderestimating",
"Some shit.",
"add actual words",
"I CAN HAZ COMMENTZ.",
"giggle.",
"Whatever.",
"Finished fondling.",
"FONDLED THE CODE",
"this is how we generate our shit.",
"unh",
"It works!",
"unionfind is no longer being molested.",
"Well, it's doing something.",
"I'M PUSHING.",
"Whee.",
"Whee, good night.",
"It'd be nice if type errors caused the compiler to issue a type error",
"Fucking templates.",
"I hate this fucking language.",
"marks",
"that coulda been bad",
"hoo boy",
"It was the best of times, it was the worst of times",
"Fucking egotistical bastard. adds expandtab to vimrc",
"if you're not using et, fuck off",
"WHO THE FUCK CAME UP WITH MAKE?",
"This is a basic implementation that works.",
"By works, I meant 'doesnt work'. Works now..",
"Last time I said it works? I was kidding. Try this.",
"Just stop reading these for a while, ok..",
"Give me a break, it's 2am. But it works now.",
"Make that it works in 90% of the cases. 3:30.",
"Ok, 5am, it works. For real.",
"FOR REAL.",
"I don't know what these changes are supposed to accomplish but somebody told me to make them.",
"I don't get paid enough for this shit.",
"fix some fucking errors",
"first blush",
"So my boss wanted this button ...",
"uhhhhhh",
"forgot we're not using a smart language",
"include shit",
"To those I leave behind, good luck!",
"things occurred",
"i dunno, maybe this works",
"8==========D",
"No changes made",
"whooooooooooooooooooooooooooo",
"clarify further the brokenness of C++. why the fuck are we using C++?",
".",
"Friday 5pm",
"changes",
"A fix I believe, not like I tested or anything",
"Useful text",
"pgsql is being a pain",
"pgsql is more strict, increase the hackiness up to 11",
"c&p fail",
"syntax",
"fix",
"just shoot me",
"arrrggghhhhh fixed!",
"someone fails and it isn't me",
"totally more readable",
"better grepping",
"fix",
"fix bug, for realz",
"fix /sigh",
"Does this work",
"MOAR BIFURCATION",
"bifurcation",
"REALLY FUCKING FIXED",
"FIX",
"better ignores",
"More ignore",
"more ignores",
"more ignores",
"more ignores",
"more ignores",
"more ignores",
"more ignored words",
"more fixes",
"really ignore ignored worsd",
"fixes",
"/sigh",
"fix",
"fail",
"pointless limitation",
"omg what have I done?",
"added super-widget 2.0.",
"tagging release w.t.f.",
"I can't believe it took so long to fix this.",
"I must have been drunk.",
"This is why the cat shouldn't sit on my keyboard.",
"This is why git rebase is a horrible horrible thing.",
"ajax-loader hotness, oh yeah",
"small is a real HTML tag, who knew.",
"WTF is this.",
"Do things better, faster, stronger",
"Use a real JS construct, WTF knows why this works in chromium.",
"Added a banner to the default admin page. Please have mercy on me =(",
"needs more cow bell",
"Switched off unit test X because the build had to go out now and there was no time to fix it properly.",
"Updated",
"I must sleep... it's working... in just three hours...",
"I was wrong...",
"Completed with no bugs...",
"Fixed a little bug...",
"Fixed a bug in NoteLineCount... not seriously...",
"woa!! this one was really HARD!",
"Made it to compile...",
"changed things...",
"touched...",
"i think i fixed a bug...",
"perfect...",
"Moved something to somewhere... goodnight...",
"oops, forgot to add the file",
"Corrected mistakes",
"oops",
"oops!",
"put code that worked where the code that didn't used to be",
"Nothing to see here, move along",
"I am even stupider than I thought",
"I don't know what the hell I was thinking.",
"fixed errors in the previous commit",
"Committed some changes",
"Some bugs fixed",
"Minor updates",
"Added missing file in previous commit",
"bug fix",
"typo",
"bara bra grejjor",
"Continued development...",
"Does anyone read this? I'll be at the coffee shop accross the street.",
"That's just how I roll",
"work in progress",
"minor changes",
"some brief changes",
"assorted changes",
"lots and lots of changes",
"another big bag of changes",
"lots of changes after a lot of time",
"LOTS of changes. period",
"Test commit. Please ignore",
"I'm just a grunt. Don't blame me for this awful PoS.",
"I did it for the lulz!",
"I'll explain this when I'm sober .. or revert it",
"Obligatory placeholder commit message",
"A long time ago, in a galaxy far far away...",
"Fixed the build.",
"various changes",
"One more time, but with feeling.",
"Handled a particular error.",
"Fixed unnecessary bug.",
"Removed code.",
"Added translation.",
"Updated build targets.",
"Refactored configuration.",
"Locating the required gigapixels to render...",
"Spinning up the hamster...",
"Shovelling coal into the server...",
"Programming the flux capacitor",
"The last time I tried this the monkey didn't survive. Let's hope it works better this time.",
"I should have had a V8 this morning.",
"640K ought to be enough for anybody",
"pay no attention to the man behind the curtain",
"a few bits tried to escape, but we caught them",
"Who has two thumbs and remembers the rudiments of his linear algebra courses? Apparently, this guy.",
"workaround for ant being a pile of fail",
"Don't push this commit",
"rats",
"squash me",
"fixed mistaken bug",
"Final commit, ready for tagging",
"-m \'So I hear you like commits ...\'",
"epic",
"need another beer",
"Well the book was obviously wrong.",
"lolwhat?",
"Another commit to keep my CAN streak going.",
"I cannot believe that it took this long to write a test for this.",
"TDD: 1, Me: 0",
"Yes, I was being sarcastic.",
"Apparently works-for-me is a crappy excuse.",
"tl;dr",
"I would rather be playing SC2.",
"Crap. Tonight is raid night and I am already late.",
"I know what I am doing. Trust me.",
"You should have trusted me.",
"Is there an award for this?",
"Is there an achievement for this?",
"I'm totally adding this to epic win. +300",
"This really should not take 19 minutes to build.",
"fixed the israeli-palestinian conflict",
"SHIT ===> GOLD",
"Committing in accordance with the prophecy.",
"It compiles! Ship it!",
"LOL!",
"Reticulating splines...",
"SEXY RUSSIAN CODES WAITING FOR YOU TO CALL",
"s/import/include/",
"extra debug for stuff module",
"debug line test",
"debugo",
"remove debug<br/>all good",
"debug suff",
"more debug... who overwrote!",
"these confounded tests drive me nuts",
"For great justice.",
"QuickFix.",
"oops - thought I got that one.",
"removed echo and die statements, lolz.",
"somebody keeps erasing my changes.",
"doh.",
"pam anderson is going to love me.",
"added security.",
"arrgghh... damn this thing for not working.",
"jobs... steve jobs",
"and a comma",
"this is my quickfix branch and i will use to do my quickfixes",
"Fix my stupidness",
"and so the crazy refactoring process sees the sunlight after some months in the dark!",
"gave up and used tables.",
"[Insert your commit message here. Be sure to make it descriptive.]",
"Removed test case since code didn't pass QA",
"removed tests since i can't make them green",
"stuff",
"more stuff",
"Become a programmer, they said. It'll be fun, they said.",
"Same as last commit with changes",
"foo",
"just checking if git is working properly...",
"fixed some minor stuff, might need some additional work.",
"just trolling the repo",
"All your codebase are belong to us.",
"Somebody set up us the bomb.",
"should work I guess...",
"To be honest, I do not quite remember everything I changed here today. But it is all good, I tell ya.",
"well crap.",
"herpderp (redux)",
"herpderp",
"Derp",
"derpherp",
"Herping the derp",
"sometimes you just herp the derp so hard it herpderps",
"Derp. Fix missing constant post rename",
"Herping the fucking derp right here and now.",
"Derp, asset redirection in dev mode",
"mergederp",
"Derp search/replace fuckup",
"Herpy dooves.",
"Derpy hooves",
"derp, helper method rename",
"Herping the derp derp (silly scoping error)",
"Herp derp I left the debug in there and forgot to reset errors.",
"Reset error count between rows. herpderp",
"hey, what's that over there?!",
"hey, look over there!",
"It worked for me...",
"Does not work.",
"Either Hot Shit or Total Bollocks",
"Arrrrgggg",
"Don’t mess with Voodoo",
"I expected something different.",
"Todo!!!",
"This is supposed to crash",
"No changes after this point.",
"I know, I know, this is not how I’m supposed to do it, but I can't think of something better.",
"Don’t even try to refactor it.",
"(c) Microsoft 1988",
"Please no changes this time.",
"Why The Fuck?",
"We should delete this crap before shipping.",
"Shit code!",
"ALL SORTS OF THINGS",
"Herpderp, shoulda check if it does really compile.",
"I CAN HAZ PYTHON, I CAN HAZ INDENTS",
"Major fixup.",
"less french words",
"breathe, =, breathe",
"IEize",
"this doesn't really make things faster, but I tried",
"this should fix it",
"forgot to save that file",
"Glue. Match sticks. Paper. Build script!",
"Argh! About to give up :(",
"Blaming regex.",
"oops",
"it's friday",
"yo recipes",
"Not sure why",
"lol digg",
"grrrr",
"For real, this time.",
"Feed. You. Stuff. No time.",
"I don't give a damn 'bout my reputation",
"DEAL WITH IT",
"commit",
"tunning",
"I really should've committed this when I finished it...",
"It's getting hard to keep up with the crap I've trashed",
"I honestly wish I could remember what was going on here...",
"I must enjoy torturing myself",
"For the sake of my sanity, just ignore this...",
"That last commit message about silly mistakes pales in comparision to this one",
"My bad",
"Still can't get this right...",
"Nitpicking about alphabetizing methods, minor OCD thing",
"Committing fixes in the dark, seriously, who killed my power!?",
"You can't see it, but I'm making a very angry face right now",
"Fix the fixes",
"It's secret!",
"Commit committed....",
"No time to commit.. My people need me!",
"Something fixed",
"I'm hungry",
"asdfasdfasdfasdfasdfasdfadsf",
"hmmm",
"formatted all",
"Replace all whitespaces with tabs.",
"s/ / /g",
"I'm too foo for this bar",
"Things went wrong...",
"??! what the ...",
"This solves it.",
"Working on tests (haha)",
"fixed conflicts (LOL merge -s ours; push -f)",
"last minute fixes.",
"fuckup.",
"Revert \"fuckup\".",
"should work now.",
"final commit.",
"done. going to bed now.",
"buenas those-things.",
"Your commit is writing checks your merge can't cash.",
"This branch is so dirty, even your mom can't clean it.",
"wip",
"Revert \"just testing, remember to revert\"",
"bla",
"harharhar",
"restored deleted entities just to be sure",
"added some filthy stuff",
"bugger",
"lol",
"oopsie B|",
"Copy pasta fail. still had a instead of a",
"Now added delete for real",
"grmbl",
"move your body every every body",
"Trying to fake a conflict",
"And a commit that I don't know the reason of...",
"ffs",
"that's all folks",
"Fucking submodule bull shit",
"apparently i did something…",
"bump to 0.0.3-dev:wq",
"pep8 - cause I fell like doing a barrel roll",
"pep8 fixer",
"it is hump day _^_",
"happy monday _ bleh _",
"after of this commit remember do a git reset hard",
"someday I gonna kill someone for this shit...",
"magic, have no clue but it works",
"I am sorry",
"dirty hack, have a better idea ?",
"Code was clean until manager requested to fuck it up",
" - Temporary commit.",
":(:(",
"...",
"GIT :/",
"stopped caring 10 commits ago",
"Testing in progress ;)",
"Fixed Bug",
"Fixed errors",
"Push poorly written test can down the road another ten years",
"commented out failing tests",
"I'm human",
"TODO: write meaningful commit message",
"Pig",
"SOAP is a piece of shit",
"did everything",
"project lead is allergic to changes...",
"making this thing actually usable.",
"I was told to leave it alone, but I have this thing called OCD, you see",
"Whatever will be, will be 8{",
"It's 2015; why are we using ColdFusion?!",
"#GrammarNazi",
"Future self, please forgive me and don't hit me with the baseball bat again!",
"Hide those navs, boi!",
"Who knows...",
"Who knows WTF?!",
"I should get a raise for this.",
"Done, to whoever merges this, good luck.",
"Not one conflict, today was a good day.",
"First Blood",
"Fixed the fuck out of #526!",
"I'm too old for this shit!",
"One little whitespace gets its very own commit! Oh, life is so erratic!"
}
local action = function(msg)
sendMessage(msg.chat.id, commits[math.random(#commits)])
end
return {
action = action,
triggers = triggers,
doc = doc
}
| gpl-2.0 |
ld-test/versium | lua/versium/filedir.lua | 2 | 10288 | -----------------------------------------------------------------------------
-- Implements Versium API using using the local file system for storage.
--
-- (c) 2007, 2008 Yuri Takhteyev (yuri@freewisdom.org)
-- License: MIT/X, see http://sputnik.freewisdom.org/en/License
-----------------------------------------------------------------------------
module(..., package.seeall)
require("lfs")
local util = require("versium.util")
local errors = require("versium.errors")
-----------------------------------------------------------------------------
-- A table that describes what this versium implementation can and cannot do.
-----------------------------------------------------------------------------
capabilities = {
can_save = true,
has_history = true,
is_persistent = true,
supports_extra_fields = true,
}
-- A template used for generating the index file.
local INDEX_TEMPLATE=[[add_version{
version = %q,
timestamp = %q,
author = %q,
comment = %q,%s
}
]]
-----------------------------------------------------------------------------
-- A table representing the class.
-----------------------------------------------------------------------------
local FileDirVersium = {}
-- And it's metatable
local FileDirVersium_mt = {__metatable={}, __index=FileDirVersium}
-----------------------------------------------------------------------------
-- Instantiates a new FileDirVersium object that represents a connection to
-- a storage system. This is the only function that this module exports.
--
-- @param params a table of params (we expect to find as the first
-- entry the path to the directory where we'll be
-- storing the data.
-- @return a new versium object.
-----------------------------------------------------------------------------
function new(params)
assert(params[1], "the first parameter is required")
local new_versium = {dir=params[1], node_table={}}
local new_versium = setmetatable(new_versium, FileDirVersium_mt)
for x in lfs.dir(new_versium.dir) do
if not (x=="." or x=="..") then
new_versium.node_table[util.fs_unescape_id(x)] = 1
end
end
return new_versium
end
--x--------------------------------------------------------------------------
-- Returns the raw history of the node from the given directory.
------------------------------------------------------------------------------
local function get_raw_history(dir, id)
local path = dir.."/"..util.fs_escape_id(id).."/index"
local raw_history = util.read_file_if_exists(path)
return raw_history
end
--x--------------------------------------------------------------------------
-- Parses raw history file into a table, filters by timestamp prefix.
-----------------------------------------------------------------------------
local function parse_history(raw_history, date_prefix, limit)
date_prefix = date_prefix or ""
local preflen = date_prefix:len()
local f = loadstring(raw_history)
local all_versions = {}
local counter = 0
local environment = {
add_version = function (values)
if not limit or counter <= limit then
if values.timestamp:sub(1, preflen) == date_prefix then
table.insert(all_versions, values)
counter = counter + 1
end
end
end
}
setfenv(f, environment)
f()
return all_versions
end
-----------------------------------------------------------------------------
-- Returns the data stored in the node as a string and a table representing
-- the node's metadata. Returns nil if the node doesn't exist. Throws an
-- error if anything else goes wrong.
--
-- @param id a node id.
-- @param version [optional] the desired version of the node (defaults
-- to latest).
-- @return a byte-string representing the data stored in the
-- node or nil if the node could not be loaded or nil.
-- @see get_node_history
-----------------------------------------------------------------------------
function FileDirVersium:get_node(id, version)
assert(id)
if not self:node_exists(id) then
return nil
end
local metadata = self:get_node_info(id, version)
assert(metadata.version) -- should come from history
local path = self.dir.."/"..util.fs_escape_id(id).."/"..metadata.version
local data = util.read_file(path, id)
assert(data)
return data
end
-----------------------------------------------------------------------------
-- Returns true if the node with this id exists and false otherwise.
--
-- @param id a node id.
-- @return true or false.
-----------------------------------------------------------------------------
function FileDirVersium:node_exists(id)
return self.node_table[id] ~= nil
end
-----------------------------------------------------------------------------
-- Returns a table with the metadata for the latest version of the node. Same
-- as get_node_history(id)[1] in case of this implementation.
--
-- @param id a node id.
-- @param version [optional] the desired version of the node (defaults
-- to latest).
-- @return the metadata for the latest version (see
-- get_node_history()).
-- @see get_node_history
-----------------------------------------------------------------------------
function FileDirVersium:get_node_info(id, version)
assert(id)
local history
if not version then
history = self:get_node_history(id, nil, 1) or {}
else
history = self:get_node_history(id) or {}
end
if not #history==0 then return nil end
if version then
for i, commit in ipairs(history) do
if commit.version == version then
return commit
end
end
else
return history[1] -- i.e., the _latest_ version
end
end
-----------------------------------------------------------------------------
-- Returns a list of existing node ids, up to a certain limit. (If no limit
-- is specified, all ids are returned.) The ids can be optionally filtered
-- by prefix. (In this case, the limit applies to the number of ids that
-- are being _returned_.) The ids can be returned in any order.
--
-- @param prefix [optional] a prefix to filter the ids (defaults to
-- "").
-- @param limit [optional] the maximum number of ids to return.
-- @return a list of node ids.
-- @return true if there are more ids left.
-----------------------------------------------------------------------------
function FileDirVersium:get_node_ids(prefix, limit)
local ids = {}
local counter = 0
prefix = prefix or ""
local preflen = prefix:len()
for id, _ in pairs(self.node_table) do
if id:sub(1, preflen) == prefix then
if counter == limit then
return ids, true
else
table.insert(ids, id)
counter = counter + 1
end
end
end
return ids
end
-----------------------------------------------------------------------------
-- Saves a new version of the node.
--
-- @param id the id of the node.
-- @param data the value to save ("" is ok).
-- @param author the user name to be associated with the change.
-- @param comment [optional] the change comment.
-- @param extra [optional] a table of additional metadata.
-- @param timestamp [optional] a timestamp to use.
-- @return the version id of the new node.
-----------------------------------------------------------------------------
function FileDirVersium:save_version(id, data, author, comment, extra, timestamp)
assert(id)
assert(data)
assert(author)
local node_path = self.dir.."/"..util.fs_escape_id(id)
-- create a directory if necessary
if not self:node_exists(id) then
lfs.mkdir(node_path)
self.node_table[id] = 1
end
-- load history, figure out the new revision ID, write data to file
local raw_history = get_raw_history(self.dir, id)
local history = parse_history(raw_history)
local new_version_id = string.format("%06d", #history + 1)
util.write_file(node_path.."/"..new_version_id, data, id)
-- generate and save the new index
timestamp = timestamp or os.date("!%Y-%m-%d %H:%M:%S") -- default to current time
local extra_buffer = ""
for k,v in pairs(extra or {}) do
extra_buffer = extra_buffer..string.format("\n [%q] = %q, ", k, v)
end
local new_history = string.format(INDEX_TEMPLATE,
new_version_id, timestamp, author,
comment or "", extra_buffer)
util.write_file(self.dir.."/"..util.fs_escape_id(id).."/index", new_history..raw_history, id)
return new_version_id
end
-----------------------------------------------------------------------------
-- Returns the history of the node as a list of tables. Each table
-- represents a revision of the node and has the following fields:
-- "version" (the id of the revision), "author" (the author who made the
-- revision), "comment" (the comment attached to the revision or nil),
-- "extra" (a table of additional fields or nil). The history can be
-- filtered by a time prefix. Returns an empty table if the node does not
-- exist.
--
-- @param id the id of the node.
-- @param date_prefix time prefix.
-- @param limit the max number of history items to return
-- @return a list of tables representing the versions (the list
-- will be empty if the node doesn't exist).
-----------------------------------------------------------------------------
function FileDirVersium:get_node_history(id, date_prefix, limit)
assert(id)
if not self:node_exists(id) then return nil end
local raw_history = get_raw_history(self.dir, id)
assert(raw_history:len() > 0, "Empty history for node '"..id.."'.")
return parse_history(raw_history, date_prefix, limit)
end
| mit |
Fenix-XI/Fenix | scripts/globals/weaponskills/frostbite.lua | 11 | 1225 | -----------------------------------
-- Frostbite
-- Great Sword weapon skill
-- Skill Level: 70
-- Delivers an ice elemental attack. Damage varies with TP.
-- Aligned with the Snow Gorget.
-- Aligned with the Snow Belt.
-- Element: Ice
-- Modifiers: STR:20% ; INT:20%
-- 100%TP 200%TP 300%TP
-- 1.00 2.00 2.50
-----------------------------------
require("scripts/globals/magic");
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary)
local params = {};
params.ftp100 = 1; params.ftp200 = 2; params.ftp300 = 2.5;
params.str_wsc = 0.2; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.2; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.ele = ELE_ICE;
params.skill = SKILL_GSD;
params.includemab = true;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.str_wsc = 0.4; params.int_wsc = 0.4;
end
local damage, criticalHit, tpHits, extraHits = doMagicWeaponskill(player, target, wsID, params, tp, primary);
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
Fenix-XI/Fenix | scripts/globals/abilities/water_maneuver.lua | 35 | 1609 | -----------------------------------
-- Ability: Water Maneuver
-- Enhances the effect of water 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_MND) < target:getPet():getStat(MOD_MND)) then
burden = 20;
end
local overload = target:addBurden(ELE_WATER-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_WATER_MANEUVER, bonus, 0, 60);
end
return EFFECT_WATER_MANEUVER;
end; | gpl-3.0 |
jkprg/prosody-modules | mod_password_policy/mod_password_policy.lua | 32 | 1288 | -- Password policy enforcement for Prosody
--
-- Copyright (C) 2012 Waqas Hussain
--
--
-- Configuration:
-- password_policy = {
-- length = 8;
-- }
local options = module:get_option("password_policy");
options = options or {};
options.length = options.length or 8;
local st = require "util.stanza";
function check_password(password)
return #password >= options.length;
end
function handler(event)
local origin, stanza = event.origin, event.stanza;
if stanza.attr.type == "set" then
local query = stanza.tags[1];
local passwords = {};
local dataform = query:get_child("x", "jabber:x:data");
if dataform then
for _,tag in ipairs(dataform.tags) do
if tag.attr.var == "password" then
table.insert(passwords, tag:get_child_text("value"));
end
end
end
table.insert(passwords, query:get_child_text("password"));
for _,password in ipairs(passwords) do
if password and not check_password(password) then
origin.send(st.error_reply(stanza, "cancel", "not-acceptable", "Please use a longer password."));
return true;
end
end
end
end
module:hook("iq/self/jabber:iq:register:query", handler, 10);
module:hook("iq/host/jabber:iq:register:query", handler, 10);
module:hook("stanza/iq/jabber:iq:register:query", handler, 10);
| mit |
asdofindia/prosody-modules | mod_password_policy/mod_password_policy.lua | 32 | 1288 | -- Password policy enforcement for Prosody
--
-- Copyright (C) 2012 Waqas Hussain
--
--
-- Configuration:
-- password_policy = {
-- length = 8;
-- }
local options = module:get_option("password_policy");
options = options or {};
options.length = options.length or 8;
local st = require "util.stanza";
function check_password(password)
return #password >= options.length;
end
function handler(event)
local origin, stanza = event.origin, event.stanza;
if stanza.attr.type == "set" then
local query = stanza.tags[1];
local passwords = {};
local dataform = query:get_child("x", "jabber:x:data");
if dataform then
for _,tag in ipairs(dataform.tags) do
if tag.attr.var == "password" then
table.insert(passwords, tag:get_child_text("value"));
end
end
end
table.insert(passwords, query:get_child_text("password"));
for _,password in ipairs(passwords) do
if password and not check_password(password) then
origin.send(st.error_reply(stanza, "cancel", "not-acceptable", "Please use a longer password."));
return true;
end
end
end
end
module:hook("iq/self/jabber:iq:register:query", handler, 10);
module:hook("iq/host/jabber:iq:register:query", handler, 10);
module:hook("stanza/iq/jabber:iq:register:query", handler, 10);
| mit |
DarkstarProject/darkstar | scripts/zones/Mhaura/npcs/Take.lua | 9 | 4249 | -----------------------------------
-- Area: Mhaura
-- NPC: Take
-- Involved In Quest: RYCHARDE_THE_CHEF
-- Starts and finishes quest: Expertice
-----------------------------------
require("scripts/globals/titles");
require("scripts/globals/quests");
require("scripts/globals/settings");
local ID = require("scripts/zones/Mhaura/IDs");
-- player:startEvent(59); -- standar dialog
-- player:startEvent(60); -- tell to look for ricarde
--player:startEvent(68); -- not talked to rycharde yet
--player:startEvent(61);-- accept expertice quest
--player:startEvent(62);-- expertice completed
--player:startEvent(63);-- expertice not done yet
--player:startEvent(64); -- after expertice quest
--player:startEvent(65); -- good luck
--player:startEvent(66);-- Valgeir cook was delicious
--player:startEvent(67);-- after back to basics i think
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
if (player:getQuestStatus(OTHER_AREAS_LOG,dsp.quest.id.otherAreas.RYCHARDE_THE_CHEF)==QUEST_AVAILABLE) then -- if available and allready talked to mayor assistant
if (player:getCharVar("QuestRychardetheChef_var") == 1) then
player:startEvent(60); -- tell to look for ricarde
elseif (player:getCharVar("QuestRychardetheChef_var") == 2) then
player:startEvent(68); -- not talked to rycharde yet
else
player:startEvent(59); -- talk abaout something else
end
elseif (player:getQuestStatus(OTHER_AREAS_LOG,dsp.quest.id.otherAreas.EXPERTISE)==QUEST_AVAILABLE and player:getQuestStatus(OTHER_AREAS_LOG,dsp.quest.id.otherAreas.HIS_NAME_IS_VALGEIR )==QUEST_COMPLETED) then --
player:startEvent(61);-- accept expertice quest
elseif (player:getQuestStatus(OTHER_AREAS_LOG,dsp.quest.id.otherAreas.EXPERTISE)==QUEST_ACCEPTED) then --
if (player:hasKeyItem(dsp.ki.LAND_CRAB_BISQUE)) then -- if have the Land Crab Bisque from Valgeir
player:startEvent(62,132);-- expertice completed
else
player:startEvent(63);-- expertice not done yet
end
elseif (player:getQuestStatus(OTHER_AREAS_LOG,dsp.quest.id.otherAreas.EXPERTISE)==QUEST_COMPLETED and player:getQuestStatus(OTHER_AREAS_LOG,dsp.quest.id.otherAreas.THE_CLUE)==QUEST_AVAILABLE) then --
player:startEvent(64); -- after expertice quest
elseif (player:getQuestStatus(OTHER_AREAS_LOG,dsp.quest.id.otherAreas.THE_CLUE)==QUEST_ACCEPTED) then--
player:startEvent(65); -- good luck
elseif (player:getQuestStatus(OTHER_AREAS_LOG,dsp.quest.id.otherAreas.THE_CLUE)==QUEST_COMPLETED and player:getQuestStatus(OTHER_AREAS_LOG,dsp.quest.id.otherAreas.THE_BASICS)==QUEST_AVAILABLE) then --
player:startEvent(66);-- Valgeir cook was delicious
elseif (player:getQuestStatus(OTHER_AREAS_LOG,dsp.quest.id.otherAreas.THE_BASICS)==QUEST_COMPLETED) then--
player:startEvent(67);-- after back to basics i think
else
player:startEvent(59); -- talk abaout something else
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 60) then
player:setCharVar("QuestRychardetheChef_var",2); -- second stage on quest
elseif (csid == 61) then -- accept quest EXPERTICE
player:addQuest(OTHER_AREAS_LOG,dsp.quest.id.otherAreas.EXPERTISE);
elseif (csid == 62) then -- end quest expertice
player:addFame(WINDURST,120);
if (player:getFreeSlotsCount() < 1) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,132);
else
player:addItem(132);
player:messageSpecial(ID.text.ITEM_OBTAINED,132);
player:addTitle(dsp.title.THREESTAR_PURVEYOR);
player:setCharVar("QUEST_EXPERTISE_STATE_var",0); --done cooking
player:setCharVar("QuestHNIVCCompDay_var",0); -- completition day of unending chase
player:setCharVar("QuestHNIVCCompYear_var",0);
player:setCharVar("QuestExpertiseCompDay_var",VanadielDayOfTheYear()); -- completition day of expertise quest
player:setCharVar("QuestExpertiseCompYear_var",VanadielYear());
player:delKeyItem(dsp.ki.LAND_CRAB_BISQUE); --give Land Crab Bisque from Valgeir
player:completeQuest(OTHER_AREAS_LOG,dsp.quest.id.otherAreas.EXPERTISE);
end
end
end;
| gpl-3.0 |
crunchuser/prosody-modules | mod_pubsub_github/mod_pubsub_github.lua | 32 | 1455 | module:depends("http");
local st = require "util.stanza";
local json = require "util.json";
local formdecode = require "net.http".formdecode;
local pubsub_service = module:depends("pubsub").service;
local node = module:get_option("github_node", "github");
function handle_POST(event)
local data = json.decode(event.request.body);
if not data then
return "Invalid JSON. From you of all people...";
end
for _, commit in ipairs(data.commits) do
local ok, err = pubsub_service:publish(node, true, data.repository.name,
st.stanza("item", { id = data.repository.name, xmlns = "http://jabber.org/protocol/pubsub" })
:tag("entry", { xmlns = "http://www.w3.org/2005/Atom" })
:tag("id"):text(commit.id):up()
:tag("title"):text(commit.message):up()
:tag("link", { rel = "alternate", href = commit.url }):up()
:tag("published"):text(commit.timestamp):up()
:tag("author")
:tag("name"):text(commit.author.name):up()
:tag("email"):text(commit.author.email):up()
:up()
);
end
module:log("debug", "Handled POST: \n%s\n", tostring(event.request.body));
return "Thank you Github!";
end
module:provides("http", {
route = {
POST = handle_POST;
};
});
function module.load()
if not pubsub_service.nodes[node] then
local ok, err = pubsub_service:create(node, true);
if not ok then
module:log("error", "Error creating node: %s", err);
else
module:log("debug", "Node %q created", node);
end
end
end
| mit |
DarkstarProject/darkstar | scripts/zones/Southern_San_dOria/npcs/Varchet.lua | 8 | 2244 | -----------------------------------
-- Area: Southern San d'Oria
-- NPC: Varchet
-- !pos 116.484 -1 91.554 230
-----------------------------------
local ID = require("scripts/zones/Southern_San_dOria/IDs")
require("scripts/globals/npc_util")
require("scripts/globals/quests")
-----------------------------------
local GAME_WON = 0
local GAME_LOST = 2
local GAME_TIE = 3
function onTrade(player, npc, trade)
if npcUtil.tradeHas(trade, {{"gil", 5}}) then
player:confirmTrade()
local vdie1 = math.random(1, 6)
local vdie2 = math.random(1, 6)
local vtotal = vdie1 + vdie2
local pdie1 = math.random(1, 6)
local pdie2 = math.random(1, 6)
local ptotal = pdie1 + pdie2
local result = GAME_LOST
if ptotal > vtotal then
result = GAME_WON
elseif ptotal == vtotal then
result = GAME_TIE
end
player:setLocalVar('VarchetGame', result)
player:startEvent(519, vdie1, vdie2, vtotal, pdie1, pdie2, ptotal, result)
else
player:startEvent(608)
end
end
function onTrigger(player, npc)
if player:getQuestStatus(SANDORIA, dsp.quest.id.sandoria.EXIT_THE_GAMBLER) == QUEST_ACCEPTED then
player:startEvent(638)
else
player:startEvent(525)
end
end
function onEventUpdate(player, csid, option)
end
function onEventFinish(player, csid, option)
if csid == 519 then
local result = player:getLocalVar('VarchetGame')
if result == GAME_WON then
local gilPayout = 10
player:addGil(gilPayout)
player:messageSpecial(ID.text.GIL_OBTAINED, gilPayout)
if player:getQuestStatus(SANDORIA, dsp.quest.id.sandoria.EXIT_THE_GAMBLER) == QUEST_ACCEPTED then
player:setCharVar("exitTheGamblerStat", 1)
player:showText(player:getEventTarget(), ID.text.VARCHET_KEEP_PROMISE)
end
elseif result == GAME_TIE then
local gilPayout = 5
player:addGil(gilPayout)
player:messageSpecial(ID.text.GIL_OBTAINED, gilPayout)
else
player:messageSpecial(ID.text.VARCHET_BET_LOST)
end
player:setLocalVar('VarchetGame', 0)
end
end
| gpl-3.0 |
Fenix-XI/Fenix | scripts/zones/Castle_Oztroja/npcs/_47d.lua | 13 | 1051 | -----------------------------------
-- Area: Castle Oztroja
-- NPC: _47d
-- @pos 20.000 24.168 -25.000 151
-----------------------------------
package.loaded["scripts/zones/Castle_Oztroja/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Castle_Oztroja/TextIDs");
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if(player:hasKeyItem(OLD_RING) == false) then
player:addKeyItem(OLD_RING);
player:messageSpecial(KEYITEM_OBTAINED,OLD_RING);
end
if (npc:getAnimation() == 9) then
npc:openDoor();
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end; | gpl-3.0 |
AbolDalton/kia | plugins/botgroup.lua | 5 | 1645 | -- Checks if bot was disabled on specific chat
local function is_channel_disabled( receiver )
if not _config.disabled_channels then
return false
end
if _config.disabled_channels[receiver] == nil then
return false
end
return _config.disabled_channels[receiver]
end
local function enable_channel(receiver)
if not _config.disabled_channels then
_config.disabled_channels = {}
end
if _config.disabled_channels[receiver] == nil then
return 'bot is online'
end
_config.disabled_channels[receiver] = false
save_config()
return "Bot Onned In This Group"
end
local function disable_channel( receiver )
if not _config.disabled_channels then
_config.disabled_channels = {}
end
_config.disabled_channels[receiver] = true
save_config()
return "Bot Offed In This Group"
end
local function pre_process(msg)
local receiver = get_receiver(msg)
-- If sender is moderator then re-enable the channel
--if is_sudo(msg) then
if is_momod(msg) then
if msg.text == "/bot on" then
enable_channel(receiver)
end
end
if is_channel_disabled(receiver) then
msg.text = ""
end
return msg
end
local function run(msg, matches)
local receiver = get_receiver(msg)
-- Enable a channel
if matches[1] == 'on' then
return enable_channel(receiver)
end
-- Disable a channel
if matches[1] == 'off' then
return disable_channel(receiver)
end
end
return {
description = "Robot Switch",
usage = {
"/bot on : enable robot in group",
"/bot off : disable robot in group" },
patterns = {
"^/bot? (on)",
"^/bot? (off)" },
run = run,
privileged = true,
--moderated = true,
pre_process = pre_process
}
| gpl-2.0 |
Fenix-XI/Fenix | scripts/zones/Port_Jeuno/npcs/Veujaie.lua | 13 | 1043 | ----------------------------------
-- Area: Port Jeuno
-- NPC: Veujaie
-- Type: Item Deliverer
-- @zone: 246
-- @pos -20.349 7.999 -2.888
--
-----------------------------------
package.loaded["scripts/zones/Port_Jeuno/TextIDs"] = nil;
require("scripts/zones/Port_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc, ITEM_DELIVERY_DIALOG);
player:openSendBox();
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 |
yangboz/petulant-octo-dubstep | HP_ID_Print_App/cocos2d-x-3.2/cocos/scripting/lua-bindings/auto/api/Menu.lua | 5 | 1735 |
--------------------------------
-- @module Menu
-- @extend Layer
--------------------------------
-- @function [parent=#Menu] setEnabled
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#Menu] alignItemsVertically
-- @param self
--------------------------------
-- @function [parent=#Menu] isEnabled
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#Menu] alignItemsHorizontallyWithPadding
-- @param self
-- @param #float float
--------------------------------
-- @function [parent=#Menu] alignItemsVerticallyWithPadding
-- @param self
-- @param #float float
--------------------------------
-- @function [parent=#Menu] alignItemsHorizontally
-- @param self
--------------------------------
-- overload function: addChild(cc.Node, int)
--
-- overload function: addChild(cc.Node)
--
-- overload function: addChild(cc.Node, int, int)
--
-- @function [parent=#Menu] addChild
-- @param self
-- @param #cc.Node node
-- @param #int int
-- @param #int int
--------------------------------
-- @function [parent=#Menu] isOpacityModifyRGB
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#Menu] getDescription
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#Menu] setOpacityModifyRGB
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#Menu] removeChild
-- @param self
-- @param #cc.Node node
-- @param #bool bool
return nil
| mit |
sundream/gamesrv | script/vote/votemgr.lua | 1 | 7298 | cvotemgr = class("cvotemgr",{
AGREE_VOTE = 0,
})
function cvotemgr:init()
self.type_id_vote = {}
self.type_pid_id = {}
self.voteid = 0
self:check_timeout()
end
function cvotemgr:gen_voteid()
if self.voteid >= MAX_NUMBER then
self.voteid = 0
end
self.voteid = self.voteid + 1
return self.voteid
end
function cvotemgr:newvote(vote)
assert(vote.member_vote)
assert(vote.callback)
local sum_vote = 0
for _,votenum in pairs(vote.member_vote) do
sum_vote = sum_vote + votenum
end
vote.pass_vote = vote.pass_vote or sum_vote
vote.pass_vote = math.min(vote.pass_vote,sum_vote)
vote.giveup_member = vote.giveup_member or {}
vote.candidate = vote.candidate or {[cvotemgr.AGREE_VOTE] = {},}
return vote
end
--/*
-- 新增投票
-- @param typ string/integer 投票类型
-- @param vote table 具体投票信息
-- @e.g
-- votemgr:addvote("罢免帮主",{
-- member_vote = {
-- [10001] = 3, --10001玩家的投票占3票
-- },
-- candidate = { -- 可选字段
-- [10001] = {}, -- 候选人10001的支持者
-- },
-- giveup_member = { -- 弃权成员
-- }
-- allow_voteto_self = false, -- 是否允许投给自己
-- pass_vote = 10, -- 投票数达到一定值则终止投票
-- exceedtime = os.time() + 300, -- 过期时间
-- callback = function (vote,state) -- 投票出结果后的回调函数
-- end,
-- })
--*/
function cvotemgr:addvote(typ,vote)
if not self.type_id_vote[typ] then
self.type_id_vote[typ] = {}
self.type_pid_id[typ] = {}
end
local voteid = self:gen_voteid()
vote.id = voteid
vote.type = typ
logger.log("info","vote",format("[addvote] type=%s id=%s vote=%s",typ,voteid,vote))
self.type_id_vote[typ][voteid] = vote
for pid,votenum in pairs(vote.member_vote) do
self.type_pid_id[typ][pid] = voteid
end
xpcall(self.onaddvote,onerror,self,vote)
end
function cvotemgr:delvote(id,typ)
if typ then
return self:__delvote(id,typ)
else
for typ,_ in pairs(self.type_id_vote) do
local vote = self:__delvote(id,typ)
if vote then
return vote
end
end
end
end
function cvotemgr:__delvote(id,typ)
local id_vote = self.type_id_vote[typ]
if id_vote then
local vote = id_vote[id]
if vote then
logger.log("info","vote",string.format("[delvote] type=%s id=%s",typ,id))
xpcall(self.ondelvote,onerror,self,vote)
id_vote[id] = nil
for pid,_ in pairs(vote.member_vote) do
self.type_pid_id[typ][pid] = nil
end
return vote
end
end
end
function cvotemgr:getvote(id,typ)
if typ then
return self:__getvote(id,typ)
else
for typ,_ in pairs(self.type_id_vote) do
local vote = self:__getvote(id,typ)
if vote then
return vote
end
end
end
end
function cvotemgr:__getvote(id,typ)
local id_vote = self.type_id_vote[typ]
if not id_vote then
return
end
return id_vote[id]
end
function cvotemgr:getvotebypid(typ,pid)
local id
for k,pid_id in pairs(self.type_pid_id) do
if k == typ then
id = pid_id[pid]
break
end
end
if id then
return self:__getvote(id,typ)
end
end
function cvotemgr:isvoted(vote,pid)
for topid,supporter in pairs(vote.candidate) do
if supporter[pid] then
return true,topid
end
end
return false
end
function cvotemgr:isgiveup(vote,pid)
for giveup_pid,_ in pairs(vote.giveup_member) do
if giveup_pid == pid then
return true
end
end
return false
end
function cvotemgr:voteto(typ,pid,topid)
topid = topid or cvotemgr.AGREE_VOTE
local vote = self:getvotebypid(typ,pid)
if not vote then
return false,"未参与投票"
end
if not vote.member_vote[pid] then
return false,"退出后无法继续投票"
end
if self:isgiveup(vote,pid) then
return false,"弃权后无法继续投票"
end
if self:isvoted(vote,pid) then
return false,"无法重复投票"
end
if not vote.allow_voteto_self and pid == topid then
return false,"无法给自身投票"
end
local votenum = vote.member_vote[pid]
if not vote.candidate[topid] then
return false,"未知候选人"
end
vote.candidate[topid][pid] = true
logger.log("info","vote",string.format("[voteto] type=%s pid=%s topid=%s votenum=%s",typ,pid,topid,votenum))
if self:check_endvote(vote) then
self:delvote(vote.id,typ)
else
xpcall(self.onupdatevote,onerror,self,vote)
end
return true
end
function cvotemgr:cancel_voteto(typ,pid)
local vote = self:getvotebypid(typ,pid)
if not vote then
return false,"未参与投票"
end
local isvote,topid = self:isvoted(vote,pid)
if not isvote then
return false,"未投票过,无法取消"
end
local votenum = vote.member_vote[pid]
logger.log("info","vote",string.format("[cancel_voteto] type=%s pid=%s topid=%s votenum=%s",typ,pid,topid,votenum))
vote.candidate[topid][pid] = nil
return true
end
function cvotemgr:giveup_vote(typ,pid)
local vote = self:getvotebypid(typ,pid)
if not vote then
return false,"未参与投票"
end
if not vote.member_vote[pid] then
return false,"退出后无法继续弃权"
end
if self:isgiveup(vote,pid) then
return false,"弃权后无法继续弃权"
end
if self:isvoted(vote,pid) then
return false,"已投过票了,弃权失效"
end
local votenum = vote.member_vote[pid]
logger.log("info","vote",string.format("[giveup_vote] type=%s pid=%s votenum=%s",typ,pid,votenum))
vote.giveup_member[pid] = true
if self:check_endvote(vote) then
self:delvote(vote.id,typ)
else
xpcall(self.onupdatevote,onerror,self,vote)
end
return true
end
function cvotemgr:quit_vote(typ,pid)
local vote = self:getvotebypid(typ,pid)
if not vote then
return
end
logger.log("info","vote",string.format("[quit_vote] type=%s pid=%s",typ,pid))
self:cancel_voteto(typ,pid)
vote.member_vote[pid] = nil
vote.giveup_member[pid] = nil
local sum_vote = 0
for _,votenum in pairs(vote.member_vote) do
sum_vote = sum_vote + votenum
end
vote.pass_vote = math.min(vote.pass_vote,sum_vote)
self.type_pid_id[typ][pid] = nil
if self:check_endvote(vote) then
self:delvote(vote.id,typ)
else
xpcall(self.onupdatevote,onerror,self,vote)
end
return true
end
function cvotemgr:check_endvote(vote)
local has_vote = 0
for _,supporter in pairs(vote.candidate) do
for pid,_ in pairs(supporter) do
local votenum = vote.member_vote[pid]
has_vote = has_vote + votenum
end
end
if has_vote >= vote.pass_vote then
vote.callback(vote,"pass")
return true,"pass"
end
local giveup_vote = 0
for pid,_ in pairs(vote.giveup_member) do
local votenum = vote.member_vote[pid]
giveup_vote = giveup_vote + votenum
end
local sum_vote = 0
for _,votenum in pairs(vote.member_vote) do
sum_vote = sum_vote + votenum
end
if sum_vote - giveup_vote < vote.pass_vote then
vote.callback(vote,"unpass")
return true,"unpass"
end
return false
end
function cvotemgr:check_timeout()
timer.timeout("cvotemgr.check_timeout",10,functor(self.check_timeout,self))
local now = os.time()
for typ,id_vote in pairs(self.type_id_vote) do
for id,vote in pairs(id_vote) do
if vote.exceedtime and now >= vote.exceedtime then
vote.callback(vote,"timeout")
self:delvote(id,typ)
end
end
end
end
function cvotemgr:onaddvote(vote)
--print("onaddvote:",table.dump(vote))
end
function cvotemgr:ondelvote(vote)
--print("ondelvote:",table.dump(vote))
end
function cvotemgr:onupdatevote(vote)
--print("onupdatevote:",table.dump(vote))
end
return cvotemgr
| gpl-2.0 |
caioso/DynASM | dasm_x86.lua | 3 | 58970 | ------------------------------------------------------------------------------
-- DynASM x86/x64 module.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------
local x64 = x64
-- Module information:
local _info = {
arch = x64 and "x64" or "x86",
description = "DynASM x86/x64 module",
version = "1.3.0",
vernum = 10300,
release = "2011-05-05",
author = "Mike Pall",
license = "MIT",
}
-- Exported glue functions for the arch-specific module.
local _M = { _info = _info }
-- Cache library functions.
local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs
local assert, unpack, setmetatable = assert, unpack or table.unpack, setmetatable
local _s = string
local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char
local find, match, gmatch, gsub = _s.find, _s.match, _s.gmatch, _s.gsub
local concat, sort = table.concat, table.sort
local bit = bit or require("bit")
local band, shl, shr = bit.band, bit.lshift, bit.rshift
-- Inherited tables and callbacks.
local g_opt, g_arch
local wline, werror, wfatal, wwarn
-- Action name list.
-- CHECK: Keep this in sync with the C code!
local action_names = {
-- int arg, 1 buffer pos:
"DISP", "IMM_S", "IMM_B", "IMM_W", "IMM_D", "IMM_WB", "IMM_DB",
-- action arg (1 byte), int arg, 1 buffer pos (reg/num):
"VREG", "SPACE", -- !x64: VREG support NYI.
-- ptrdiff_t arg, 1 buffer pos (address): !x64
"SETLABEL", "REL_A",
-- action arg (1 byte) or int arg, 2 buffer pos (link, offset):
"REL_LG", "REL_PC",
-- action arg (1 byte) or int arg, 1 buffer pos (link):
"IMM_LG", "IMM_PC",
-- action arg (1 byte) or int arg, 1 buffer pos (offset):
"LABEL_LG", "LABEL_PC",
-- action arg (1 byte), 1 buffer pos (offset):
"ALIGN",
-- action args (2 bytes), no buffer pos.
"EXTERN",
-- action arg (1 byte), no buffer pos.
"ESC",
-- no action arg, no buffer pos.
"MARK",
-- action arg (1 byte), no buffer pos, terminal action:
"SECTION",
-- no args, no buffer pos, terminal action:
"STOP"
}
-- Maximum number of section buffer positions for dasm_put().
-- CHECK: Keep this in sync with the C code!
local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines.
-- Action name -> action number (dynamically generated below).
local map_action = {}
-- First action number. Everything below does not need to be escaped.
local actfirst = 256-#action_names
-- Action list buffer and string (only used to remove dupes).
local actlist = {}
local actstr = ""
-- Argument list for next dasm_put(). Start with offset 0 into action list.
local actargs = { 0 }
-- Current number of section buffer positions for dasm_put().
local secpos = 1
------------------------------------------------------------------------------
-- Compute action numbers for action names.
for n,name in ipairs(action_names) do
local num = actfirst + n - 1
map_action[name] = num
end
-- Dump action names and numbers.
local function dumpactions(out)
out:write("DynASM encoding engine action codes:\n")
for n,name in ipairs(action_names) do
local num = map_action[name]
out:write(format(" %-10s %02X %d\n", name, num, num))
end
out:write("\n")
end
-- Write action list buffer as a huge static C array.
local function writeactions(out, name)
local nn = #actlist
local last = actlist[nn] or 255
actlist[nn] = nil -- Remove last byte.
if nn == 0 then nn = 1 end
out:write("static const unsigned char ", name, "[", nn, "] = {\n")
local s = " "
for n,b in ipairs(actlist) do
s = s..b..","
if #s >= 75 then
assert(out:write(s, "\n"))
s = " "
end
end
out:write(s, last, "\n};\n\n") -- Add last byte back.
end
------------------------------------------------------------------------------
-- Add byte to action list.
local function wputxb(n)
assert(n >= 0 and n <= 255 and n % 1 == 0, "byte out of range")
actlist[#actlist+1] = n
end
-- Add action to list with optional arg. Advance buffer pos, too.
local function waction(action, a, num)
wputxb(assert(map_action[action], "bad action name `"..action.."'"))
if a then actargs[#actargs+1] = a end
if a or num then secpos = secpos + (num or 1) end
end
-- Add call to embedded DynASM C code.
local function wcall(func, args)
wline(format("dasm_%s(Dst, %s);", func, concat(args, ", ")), true)
end
-- Delete duplicate action list chunks. A tad slow, but so what.
local function dedupechunk(offset)
local al, as = actlist, actstr
local chunk = char(unpack(al, offset+1, #al))
local orig = find(as, chunk, 1, true)
if orig then
actargs[1] = orig-1 -- Replace with original offset.
for i=offset+1,#al do al[i] = nil end -- Kill dupe.
else
actstr = as..chunk
end
end
-- Flush action list (intervening C code or buffer pos overflow).
local function wflush(term)
local offset = actargs[1]
if #actlist == offset then return end -- Nothing to flush.
if not term then waction("STOP") end -- Terminate action list.
dedupechunk(offset)
wcall("put", actargs) -- Add call to dasm_put().
actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put().
secpos = 1 -- The actionlist offset occupies a buffer position, too.
end
-- Put escaped byte.
local function wputb(n)
if n >= actfirst then waction("ESC") end -- Need to escape byte.
wputxb(n)
end
------------------------------------------------------------------------------
-- Global label name -> global label number. With auto assignment on 1st use.
local next_global = 10
local map_global = setmetatable({}, { __index = function(t, name)
if not match(name, "^[%a_][%w_@]*$") then werror("bad global label") end
local n = next_global
if n > 246 then werror("too many global labels") end
next_global = n + 1
t[name] = n
return n
end})
-- Dump global labels.
local function dumpglobals(out, lvl)
local t = {}
for name, n in pairs(map_global) do t[n] = name end
out:write("Global labels:\n")
for i=10,next_global-1 do
out:write(format(" %s\n", t[i]))
end
out:write("\n")
end
-- Write global label enum.
local function writeglobals(out, prefix)
local t = {}
for name, n in pairs(map_global) do t[n] = name end
out:write("enum {\n")
for i=10,next_global-1 do
out:write(" ", prefix, gsub(t[i], "@.*", ""), ",\n")
end
out:write(" ", prefix, "_MAX\n};\n")
end
-- Write global label names.
local function writeglobalnames(out, name)
local t = {}
for name, n in pairs(map_global) do t[n] = name end
out:write("static const char *const ", name, "[] = {\n")
for i=10,next_global-1 do
out:write(" \"", t[i], "\",\n")
end
out:write(" (const char *)0\n};\n")
end
------------------------------------------------------------------------------
-- Extern label name -> extern label number. With auto assignment on 1st use.
local next_extern = -1
local map_extern = setmetatable({}, { __index = function(t, name)
-- No restrictions on the name for now.
local n = next_extern
if n < -256 then werror("too many extern labels") end
next_extern = n - 1
t[name] = n
return n
end})
-- Dump extern labels.
local function dumpexterns(out, lvl)
local t = {}
for name, n in pairs(map_extern) do t[-n] = name end
out:write("Extern labels:\n")
for i=1,-next_extern-1 do
out:write(format(" %s\n", t[i]))
end
out:write("\n")
end
-- Write extern label names.
local function writeexternnames(out, name)
local t = {}
for name, n in pairs(map_extern) do t[-n] = name end
out:write("static const char *const ", name, "[] = {\n")
for i=1,-next_extern-1 do
out:write(" \"", t[i], "\",\n")
end
out:write(" (const char *)0\n};\n")
end
------------------------------------------------------------------------------
-- Arch-specific maps.
local map_archdef = {} -- Ext. register name -> int. name.
local map_reg_rev = {} -- Int. register name -> ext. name.
local map_reg_num = {} -- Int. register name -> register number.
local map_reg_opsize = {} -- Int. register name -> operand size.
local map_reg_valid_base = {} -- Int. register name -> valid base register?
local map_reg_valid_index = {} -- Int. register name -> valid index register?
local map_reg_needrex = {} -- Int. register name -> need rex vs. no rex.
local reg_list = {} -- Canonical list of int. register names.
local map_type = {} -- Type name -> { ctype, reg }
local ctypenum = 0 -- Type number (for _PTx macros).
local addrsize = x64 and "q" or "d" -- Size for address operands.
-- Helper functions to fill register maps.
local function mkrmap(sz, cl, names)
local cname = format("@%s", sz)
reg_list[#reg_list+1] = cname
map_archdef[cl] = cname
map_reg_rev[cname] = cl
map_reg_num[cname] = -1
map_reg_opsize[cname] = sz
if sz == addrsize or sz == "d" then
map_reg_valid_base[cname] = true
map_reg_valid_index[cname] = true
end
if names then
for n,name in ipairs(names) do
local iname = format("@%s%x", sz, n-1)
reg_list[#reg_list+1] = iname
map_archdef[name] = iname
map_reg_rev[iname] = name
map_reg_num[iname] = n-1
map_reg_opsize[iname] = sz
if sz == "b" and n > 4 then map_reg_needrex[iname] = false end
if sz == addrsize or sz == "d" then
map_reg_valid_base[iname] = true
map_reg_valid_index[iname] = true
end
end
end
for i=0,(x64 and sz ~= "f") and 15 or 7 do
local needrex = sz == "b" and i > 3
local iname = format("@%s%x%s", sz, i, needrex and "R" or "")
if needrex then map_reg_needrex[iname] = true end
local name
if sz == "o" then name = format("xmm%d", i)
elseif sz == "f" then name = format("st%d", i)
else name = format("r%d%s", i, sz == addrsize and "" or sz) end
map_archdef[name] = iname
if not map_reg_rev[iname] then
reg_list[#reg_list+1] = iname
map_reg_rev[iname] = name
map_reg_num[iname] = i
map_reg_opsize[iname] = sz
if sz == addrsize or sz == "d" then
map_reg_valid_base[iname] = true
map_reg_valid_index[iname] = true
end
end
end
reg_list[#reg_list+1] = ""
end
-- Integer registers (qword, dword, word and byte sized).
if x64 then
mkrmap("q", "Rq", {"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi"})
end
mkrmap("d", "Rd", {"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"})
mkrmap("w", "Rw", {"ax", "cx", "dx", "bx", "sp", "bp", "si", "di"})
mkrmap("b", "Rb", {"al", "cl", "dl", "bl", "ah", "ch", "dh", "bh"})
map_reg_valid_index[map_archdef.esp] = false
if x64 then map_reg_valid_index[map_archdef.rsp] = false end
map_archdef["Ra"] = "@"..addrsize
-- FP registers (internally tword sized, but use "f" as operand size).
mkrmap("f", "Rf")
-- SSE registers (oword sized, but qword and dword accessible).
mkrmap("o", "xmm")
-- Operand size prefixes to codes.
local map_opsize = {
byte = "b", word = "w", dword = "d", qword = "q", oword = "o", tword = "t",
aword = addrsize,
}
-- Operand size code to number.
local map_opsizenum = {
b = 1, w = 2, d = 4, q = 8, o = 16, t = 10,
}
-- Operand size code to name.
local map_opsizename = {
b = "byte", w = "word", d = "dword", q = "qword", o = "oword", t = "tword",
f = "fpword",
}
-- Valid index register scale factors.
local map_xsc = {
["1"] = 0, ["2"] = 1, ["4"] = 2, ["8"] = 3,
}
-- Condition codes.
local map_cc = {
o = 0, no = 1, b = 2, nb = 3, e = 4, ne = 5, be = 6, nbe = 7,
s = 8, ns = 9, p = 10, np = 11, l = 12, nl = 13, le = 14, nle = 15,
c = 2, nae = 2, nc = 3, ae = 3, z = 4, nz = 5, na = 6, a = 7,
pe = 10, po = 11, nge = 12, ge = 13, ng = 14, g = 15,
}
-- Reverse defines for registers.
function _M.revdef(s)
return gsub(s, "@%w+", map_reg_rev)
end
-- Dump register names and numbers
local function dumpregs(out)
out:write("Register names, sizes and internal numbers:\n")
for _,reg in ipairs(reg_list) do
if reg == "" then
out:write("\n")
else
local name = map_reg_rev[reg]
local num = map_reg_num[reg]
local opsize = map_opsizename[map_reg_opsize[reg]]
out:write(format(" %-5s %-8s %s\n", name, opsize,
num < 0 and "(variable)" or num))
end
end
end
------------------------------------------------------------------------------
-- Put action for label arg (IMM_LG, IMM_PC, REL_LG, REL_PC).
local function wputlabel(aprefix, imm, num)
if type(imm) == "number" then
if imm < 0 then
waction("EXTERN")
wputxb(aprefix == "IMM_" and 0 or 1)
imm = -imm-1
else
waction(aprefix.."LG", nil, num);
end
wputxb(imm)
else
waction(aprefix.."PC", imm, num)
end
end
-- Put signed byte or arg.
local function wputsbarg(n)
if type(n) == "number" then
if n < -128 or n > 127 then
werror("signed immediate byte out of range")
end
if n < 0 then n = n + 256 end
wputb(n)
else waction("IMM_S", n) end
end
-- Put unsigned byte or arg.
local function wputbarg(n)
if type(n) == "number" then
if n < 0 or n > 255 then
werror("unsigned immediate byte out of range")
end
wputb(n)
else waction("IMM_B", n) end
end
-- Put unsigned word or arg.
local function wputwarg(n)
if type(n) == "number" then
if shr(n, 16) ~= 0 then
werror("unsigned immediate word out of range")
end
wputb(band(n, 255)); wputb(shr(n, 8));
else waction("IMM_W", n) end
end
-- Put signed or unsigned dword or arg.
local function wputdarg(n)
local tn = type(n)
if tn == "number" then
wputb(band(n, 255))
wputb(band(shr(n, 8), 255))
wputb(band(shr(n, 16), 255))
wputb(shr(n, 24))
elseif tn == "table" then
wputlabel("IMM_", n[1], 1)
else
waction("IMM_D", n)
end
end
-- Put operand-size dependent number or arg (defaults to dword).
local function wputszarg(sz, n)
if not sz or sz == "d" or sz == "q" then wputdarg(n)
elseif sz == "w" then wputwarg(n)
elseif sz == "b" then wputbarg(n)
elseif sz == "s" then wputsbarg(n)
else werror("bad operand size") end
end
-- Put multi-byte opcode with operand-size dependent modifications.
local function wputop(sz, op, rex)
local r
if rex ~= 0 and not x64 then werror("bad operand size") end
if sz == "w" then wputb(102) end
-- Needs >32 bit numbers, but only for crc32 eax, word [ebx]
if op >= 4294967296 then r = op%4294967296 wputb((op-r)/4294967296) op = r end
if op >= 16777216 then wputb(shr(op, 24)); op = band(op, 0xffffff) end
if op >= 65536 then
if rex ~= 0 then
local opc3 = band(op, 0xffff00)
if opc3 == 0x0f3a00 or opc3 == 0x0f3800 then
wputb(64 + band(rex, 15)); rex = 0
end
end
wputb(shr(op, 16)); op = band(op, 0xffff)
end
if op >= 256 then
local b = shr(op, 8)
if b == 15 and rex ~= 0 then wputb(64 + band(rex, 15)); rex = 0 end
wputb(b)
op = band(op, 255)
end
if rex ~= 0 then wputb(64 + band(rex, 15)) end
if sz == "b" then op = op - 1 end
wputb(op)
end
-- Put ModRM or SIB formatted byte.
local function wputmodrm(m, s, rm, vs, vrm)
assert(m < 4 and s < 16 and rm < 16, "bad modrm operands")
wputb(shl(m, 6) + shl(band(s, 7), 3) + band(rm, 7))
end
-- Put ModRM/SIB plus optional displacement.
local function wputmrmsib(t, imark, s, vsreg)
local vreg, vxreg
local reg, xreg = t.reg, t.xreg
if reg and reg < 0 then reg = 0; vreg = t.vreg end
if xreg and xreg < 0 then xreg = 0; vxreg = t.vxreg end
if s < 0 then s = 0 end
-- Register mode.
if sub(t.mode, 1, 1) == "r" then
wputmodrm(3, s, reg)
if vsreg then waction("VREG", vsreg); wputxb(2) end
if vreg then waction("VREG", vreg); wputxb(0) end
return
end
local disp = t.disp
local tdisp = type(disp)
-- No base register?
if not reg then
local riprel = false
if xreg then
-- Indexed mode with index register only.
-- [xreg*xsc+disp] -> (0, s, esp) (xsc, xreg, ebp)
wputmodrm(0, s, 4)
if imark == "I" then waction("MARK") end
if vsreg then waction("VREG", vsreg); wputxb(2) end
wputmodrm(t.xsc, xreg, 5)
if vxreg then waction("VREG", vxreg); wputxb(3) end
else
-- Pure 32 bit displacement.
if x64 and tdisp ~= "table" then
wputmodrm(0, s, 4) -- [disp] -> (0, s, esp) (0, esp, ebp)
if imark == "I" then waction("MARK") end
wputmodrm(0, 4, 5)
else
riprel = x64
wputmodrm(0, s, 5) -- [disp|rip-label] -> (0, s, ebp)
if imark == "I" then waction("MARK") end
end
if vsreg then waction("VREG", vsreg); wputxb(2) end
end
if riprel then -- Emit rip-relative displacement.
if match("UWSiI", imark) then
werror("NYI: rip-relative displacement followed by immediate")
end
-- The previous byte in the action buffer cannot be 0xe9 or 0x80-0x8f.
wputlabel("REL_", disp[1], 2)
else
wputdarg(disp)
end
return
end
local m
if tdisp == "number" then -- Check displacement size at assembly time.
if disp == 0 and band(reg, 7) ~= 5 then -- [ebp] -> [ebp+0] (in SIB, too)
if not vreg then m = 0 end -- Force DISP to allow [Rd(5)] -> [ebp+0]
elseif disp >= -128 and disp <= 127 then m = 1
else m = 2 end
elseif tdisp == "table" then
m = 2
end
-- Index register present or esp as base register: need SIB encoding.
if xreg or band(reg, 7) == 4 then
wputmodrm(m or 2, s, 4) -- ModRM.
if m == nil or imark == "I" then waction("MARK") end
if vsreg then waction("VREG", vsreg); wputxb(2) end
wputmodrm(t.xsc or 0, xreg or 4, reg) -- SIB.
if vxreg then waction("VREG", vxreg); wputxb(3) end
if vreg then waction("VREG", vreg); wputxb(1) end
else
wputmodrm(m or 2, s, reg) -- ModRM.
if (imark == "I" and (m == 1 or m == 2)) or
(m == nil and (vsreg or vreg)) then waction("MARK") end
if vsreg then waction("VREG", vsreg); wputxb(2) end
if vreg then waction("VREG", vreg); wputxb(1) end
end
-- Put displacement.
if m == 1 then wputsbarg(disp)
elseif m == 2 then wputdarg(disp)
elseif m == nil then waction("DISP", disp) end
end
------------------------------------------------------------------------------
-- Return human-readable operand mode string.
local function opmodestr(op, args)
local m = {}
for i=1,#args do
local a = args[i]
m[#m+1] = sub(a.mode, 1, 1)..(a.opsize or "?")
end
return op.." "..concat(m, ",")
end
-- Convert number to valid integer or nil.
local function toint(expr)
local n = tonumber(expr)
if n then
if n % 1 ~= 0 or n < -2147483648 or n > 4294967295 then
werror("bad integer number `"..expr.."'")
end
return n
end
end
-- Parse immediate expression.
local function immexpr(expr)
-- &expr (pointer)
if sub(expr, 1, 1) == "&" then
return "iPJ", format("(ptrdiff_t)(%s)", sub(expr,2))
end
local prefix = sub(expr, 1, 2)
-- =>expr (pc label reference)
if prefix == "=>" then
return "iJ", sub(expr, 3)
end
-- ->name (global label reference)
if prefix == "->" then
return "iJ", map_global[sub(expr, 3)]
end
-- [<>][1-9] (local label reference)
local dir, lnum = match(expr, "^([<>])([1-9])$")
if dir then -- Fwd: 247-255, Bkwd: 1-9.
return "iJ", lnum + (dir == ">" and 246 or 0)
end
local extname = match(expr, "^extern%s+(%S+)$")
if extname then
return "iJ", map_extern[extname]
end
-- expr (interpreted as immediate)
return "iI", expr
end
-- Parse displacement expression: +-num, +-expr, +-opsize*num
local function dispexpr(expr)
local disp = expr == "" and 0 or toint(expr)
if disp then return disp end
local c, dispt = match(expr, "^([+-])%s*(.+)$")
if c == "+" then
expr = dispt
elseif not c then
werror("bad displacement expression `"..expr.."'")
end
local opsize, tailops = match(dispt, "^(%w+)%s*%*%s*(.+)$")
local ops, imm = map_opsize[opsize], toint(tailops)
if ops and imm then
if c == "-" then imm = -imm end
return imm*map_opsizenum[ops]
end
local mode, iexpr = immexpr(dispt)
if mode == "iJ" then
if c == "-" then werror("cannot invert label reference") end
return { iexpr }
end
return expr -- Need to return original signed expression.
end
-- Parse register or type expression.
local function rtexpr(expr)
if not expr then return end
local tname, ovreg = match(expr, "^([%w_]+):(@[%w_]+)$")
local tp = map_type[tname or expr]
if tp then
local reg = ovreg or tp.reg
local rnum = map_reg_num[reg]
if not rnum then
werror("type `"..(tname or expr).."' needs a register override")
end
if not map_reg_valid_base[reg] then
werror("bad base register override `"..(map_reg_rev[reg] or reg).."'")
end
return reg, rnum, tp
end
return expr, map_reg_num[expr]
end
-- Parse operand and return { mode, opsize, reg, xreg, xsc, disp, imm }.
local function parseoperand(param)
local t = {}
local expr = param
local opsize, tailops = match(param, "^(%w+)%s*(.+)$")
if opsize then
t.opsize = map_opsize[opsize]
if t.opsize then expr = tailops end
end
local br = match(expr, "^%[%s*(.-)%s*%]$")
repeat
if br then
t.mode = "xm"
-- [disp]
t.disp = toint(br)
if t.disp then
t.mode = x64 and "xm" or "xmO"
break
end
-- [reg...]
local tp
local reg, tailr = match(br, "^([@%w_:]+)%s*(.*)$")
reg, t.reg, tp = rtexpr(reg)
if not t.reg then
-- [expr]
t.mode = x64 and "xm" or "xmO"
t.disp = dispexpr("+"..br)
break
end
if t.reg == -1 then
t.vreg, tailr = match(tailr, "^(%b())(.*)$")
if not t.vreg then werror("bad variable register expression") end
end
-- [xreg*xsc] or [xreg*xsc+-disp] or [xreg*xsc+-expr]
local xsc, tailsc = match(tailr, "^%*%s*([1248])%s*(.*)$")
if xsc then
if not map_reg_valid_index[reg] then
werror("bad index register `"..map_reg_rev[reg].."'")
end
t.xsc = map_xsc[xsc]
t.xreg = t.reg
t.vxreg = t.vreg
t.reg = nil
t.vreg = nil
t.disp = dispexpr(tailsc)
break
end
if not map_reg_valid_base[reg] then
werror("bad base register `"..map_reg_rev[reg].."'")
end
-- [reg] or [reg+-disp]
t.disp = toint(tailr) or (tailr == "" and 0)
if t.disp then break end
-- [reg+xreg...]
local xreg, tailx = match(tailr, "^+%s*([@%w_:]+)%s*(.*)$")
xreg, t.xreg, tp = rtexpr(xreg)
if not t.xreg then
-- [reg+-expr]
t.disp = dispexpr(tailr)
break
end
if not map_reg_valid_index[xreg] then
werror("bad index register `"..map_reg_rev[xreg].."'")
end
if t.xreg == -1 then
t.vxreg, tailx = match(tailx, "^(%b())(.*)$")
if not t.vxreg then werror("bad variable register expression") end
end
-- [reg+xreg*xsc...]
local xsc, tailsc = match(tailx, "^%*%s*([1248])%s*(.*)$")
if xsc then
t.xsc = map_xsc[xsc]
tailx = tailsc
end
-- [...] or [...+-disp] or [...+-expr]
t.disp = dispexpr(tailx)
else
-- imm or opsize*imm
local imm = toint(expr)
if not imm and sub(expr, 1, 1) == "*" and t.opsize then
imm = toint(sub(expr, 2))
if imm then
imm = imm * map_opsizenum[t.opsize]
t.opsize = nil
end
end
if imm then
if t.opsize then werror("bad operand size override") end
local m = "i"
if imm == 1 then m = m.."1" end
if imm >= 4294967168 and imm <= 4294967295 then imm = imm-4294967296 end
if imm >= -128 and imm <= 127 then m = m.."S" end
t.imm = imm
t.mode = m
break
end
local tp
local reg, tailr = match(expr, "^([@%w_:]+)%s*(.*)$")
reg, t.reg, tp = rtexpr(reg)
if t.reg then
if t.reg == -1 then
t.vreg, tailr = match(tailr, "^(%b())(.*)$")
if not t.vreg then werror("bad variable register expression") end
end
-- reg
if tailr == "" then
if t.opsize then werror("bad operand size override") end
t.opsize = map_reg_opsize[reg]
if t.opsize == "f" then
t.mode = t.reg == 0 and "fF" or "f"
else
if reg == "@w4" or (x64 and reg == "@d4") then
wwarn("bad idea, try again with `"..(x64 and "rsp'" or "esp'"))
end
t.mode = t.reg == 0 and "rmR" or (reg == "@b1" and "rmC" or "rm")
end
t.needrex = map_reg_needrex[reg]
break
end
-- type[idx], type[idx].field, type->field -> [reg+offset_expr]
if not tp then werror("bad operand `"..param.."'") end
t.mode = "xm"
t.disp = format(tp.ctypefmt, tailr)
else
t.mode, t.imm = immexpr(expr)
if sub(t.mode, -1) == "J" then
if t.opsize and t.opsize ~= addrsize then
werror("bad operand size override")
end
t.opsize = addrsize
end
end
end
until true
return t
end
------------------------------------------------------------------------------
-- x86 Template String Description
-- ===============================
--
-- Each template string is a list of [match:]pattern pairs,
-- separated by "|". The first match wins. No match means a
-- bad or unsupported combination of operand modes or sizes.
--
-- The match part and the ":" is omitted if the operation has
-- no operands. Otherwise the first N characters are matched
-- against the mode strings of each of the N operands.
--
-- The mode string for each operand type is (see parseoperand()):
-- Integer register: "rm", +"R" for eax, ax, al, +"C" for cl
-- FP register: "f", +"F" for st0
-- Index operand: "xm", +"O" for [disp] (pure offset)
-- Immediate: "i", +"S" for signed 8 bit, +"1" for 1,
-- +"I" for arg, +"P" for pointer
-- Any: +"J" for valid jump targets
--
-- So a match character "m" (mixed) matches both an integer register
-- and an index operand (to be encoded with the ModRM/SIB scheme).
-- But "r" matches only a register and "x" only an index operand
-- (e.g. for FP memory access operations).
--
-- The operand size match string starts right after the mode match
-- characters and ends before the ":". "dwb" or "qdwb" is assumed, if empty.
-- The effective data size of the operation is matched against this list.
--
-- If only the regular "b", "w", "d", "q", "t" operand sizes are
-- present, then all operands must be the same size. Unspecified sizes
-- are ignored, but at least one operand must have a size or the pattern
-- won't match (use the "byte", "word", "dword", "qword", "tword"
-- operand size overrides. E.g.: mov dword [eax], 1).
--
-- If the list has a "1" or "2" prefix, the operand size is taken
-- from the respective operand and any other operand sizes are ignored.
-- If the list contains only ".", all operand sizes are ignored.
-- If the list has a "/" prefix, the concatenated (mixed) operand sizes
-- are compared to the match.
--
-- E.g. "rrdw" matches for either two dword registers or two word
-- registers. "Fx2dq" matches an st0 operand plus an index operand
-- pointing to a dword (float) or qword (double).
--
-- Every character after the ":" is part of the pattern string:
-- Hex chars are accumulated to form the opcode (left to right).
-- "n" disables the standard opcode mods
-- (otherwise: -1 for "b", o16 prefix for "w", rex.w for "q")
-- "X" Force REX.W.
-- "r"/"R" adds the reg. number from the 1st/2nd operand to the opcode.
-- "m"/"M" generates ModRM/SIB from the 1st/2nd operand.
-- The spare 3 bits are either filled with the last hex digit or
-- the result from a previous "r"/"R". The opcode is restored.
--
-- All of the following characters force a flush of the opcode:
-- "o"/"O" stores a pure 32 bit disp (offset) from the 1st/2nd operand.
-- "S" stores a signed 8 bit immediate from the last operand.
-- "U" stores an unsigned 8 bit immediate from the last operand.
-- "W" stores an unsigned 16 bit immediate from the last operand.
-- "i" stores an operand sized immediate from the last operand.
-- "I" dito, but generates an action code to optionally modify
-- the opcode (+2) for a signed 8 bit immediate.
-- "J" generates one of the REL action codes from the last operand.
--
------------------------------------------------------------------------------
-- Template strings for x86 instructions. Ordered by first opcode byte.
-- Unimplemented opcodes (deliberate omissions) are marked with *.
local map_op = {
-- 00-05: add...
-- 06: *push es
-- 07: *pop es
-- 08-0D: or...
-- 0E: *push cs
-- 0F: two byte opcode prefix
-- 10-15: adc...
-- 16: *push ss
-- 17: *pop ss
-- 18-1D: sbb...
-- 1E: *push ds
-- 1F: *pop ds
-- 20-25: and...
es_0 = "26",
-- 27: *daa
-- 28-2D: sub...
cs_0 = "2E",
-- 2F: *das
-- 30-35: xor...
ss_0 = "36",
-- 37: *aaa
-- 38-3D: cmp...
ds_0 = "3E",
-- 3F: *aas
inc_1 = x64 and "m:FF0m" or "rdw:40r|m:FF0m",
dec_1 = x64 and "m:FF1m" or "rdw:48r|m:FF1m",
push_1 = (x64 and "rq:n50r|rw:50r|mq:nFF6m|mw:FF6m" or
"rdw:50r|mdw:FF6m").."|S.:6AS|ib:n6Ai|i.:68i",
pop_1 = x64 and "rq:n58r|rw:58r|mq:n8F0m|mw:8F0m" or "rdw:58r|mdw:8F0m",
-- 60: *pusha, *pushad, *pushaw
-- 61: *popa, *popad, *popaw
-- 62: *bound rdw,x
-- 63: x86: *arpl mw,rw
movsxd_2 = x64 and "rm/qd:63rM",
fs_0 = "64",
gs_0 = "65",
o16_0 = "66",
a16_0 = not x64 and "67" or nil,
a32_0 = x64 and "67",
-- 68: push idw
-- 69: imul rdw,mdw,idw
-- 6A: push ib
-- 6B: imul rdw,mdw,S
-- 6C: *insb
-- 6D: *insd, *insw
-- 6E: *outsb
-- 6F: *outsd, *outsw
-- 70-7F: jcc lb
-- 80: add... mb,i
-- 81: add... mdw,i
-- 82: *undefined
-- 83: add... mdw,S
test_2 = "mr:85Rm|rm:85rM|Ri:A9ri|mi:F70mi",
-- 86: xchg rb,mb
-- 87: xchg rdw,mdw
-- 88: mov mb,r
-- 89: mov mdw,r
-- 8A: mov r,mb
-- 8B: mov r,mdw
-- 8C: *mov mdw,seg
lea_2 = "rx1dq:8DrM",
-- 8E: *mov seg,mdw
-- 8F: pop mdw
nop_0 = "90",
xchg_2 = "Rrqdw:90R|rRqdw:90r|rm:87rM|mr:87Rm",
cbw_0 = "6698",
cwde_0 = "98",
cdqe_0 = "4898",
cwd_0 = "6699",
cdq_0 = "99",
cqo_0 = "4899",
-- 9A: *call iw:idw
wait_0 = "9B",
fwait_0 = "9B",
pushf_0 = "9C",
pushfd_0 = not x64 and "9C",
pushfq_0 = x64 and "9C",
popf_0 = "9D",
popfd_0 = not x64 and "9D",
popfq_0 = x64 and "9D",
sahf_0 = "9E",
lahf_0 = "9F",
mov_2 = "OR:A3o|RO:A1O|mr:89Rm|rm:8BrM|rib:nB0ri|ridw:B8ri|mi:C70mi",
movsb_0 = "A4",
movsw_0 = "66A5",
movsd_0 = "A5",
cmpsb_0 = "A6",
cmpsw_0 = "66A7",
cmpsd_0 = "A7",
-- A8: test Rb,i
-- A9: test Rdw,i
stosb_0 = "AA",
stosw_0 = "66AB",
stosd_0 = "AB",
lodsb_0 = "AC",
lodsw_0 = "66AD",
lodsd_0 = "AD",
scasb_0 = "AE",
scasw_0 = "66AF",
scasd_0 = "AF",
-- B0-B7: mov rb,i
-- B8-BF: mov rdw,i
-- C0: rol... mb,i
-- C1: rol... mdw,i
ret_1 = "i.:nC2W",
ret_0 = "C3",
-- C4: *les rdw,mq
-- C5: *lds rdw,mq
-- C6: mov mb,i
-- C7: mov mdw,i
-- C8: *enter iw,ib
leave_0 = "C9",
-- CA: *retf iw
-- CB: *retf
int3_0 = "CC",
int_1 = "i.:nCDU",
into_0 = "CE",
-- CF: *iret
-- D0: rol... mb,1
-- D1: rol... mdw,1
-- D2: rol... mb,cl
-- D3: rol... mb,cl
-- D4: *aam ib
-- D5: *aad ib
-- D6: *salc
-- D7: *xlat
-- D8-DF: floating point ops
-- E0: *loopne
-- E1: *loope
-- E2: *loop
-- E3: *jcxz, *jecxz
-- E4: *in Rb,ib
-- E5: *in Rdw,ib
-- E6: *out ib,Rb
-- E7: *out ib,Rdw
call_1 = x64 and "mq:nFF2m|J.:E8nJ" or "md:FF2m|J.:E8J",
jmp_1 = x64 and "mq:nFF4m|J.:E9nJ" or "md:FF4m|J.:E9J", -- short: EB
-- EA: *jmp iw:idw
-- EB: jmp ib
-- EC: *in Rb,dx
-- ED: *in Rdw,dx
-- EE: *out dx,Rb
-- EF: *out dx,Rdw
lock_0 = "F0",
int1_0 = "F1",
repne_0 = "F2",
repnz_0 = "F2",
rep_0 = "F3",
repe_0 = "F3",
repz_0 = "F3",
-- F4: *hlt
cmc_0 = "F5",
-- F6: test... mb,i; div... mb
-- F7: test... mdw,i; div... mdw
clc_0 = "F8",
stc_0 = "F9",
-- FA: *cli
cld_0 = "FC",
std_0 = "FD",
-- FE: inc... mb
-- FF: inc... mdw
-- misc ops
not_1 = "m:F72m",
neg_1 = "m:F73m",
mul_1 = "m:F74m",
imul_1 = "m:F75m",
div_1 = "m:F76m",
idiv_1 = "m:F77m",
imul_2 = "rmqdw:0FAFrM|rIqdw:69rmI|rSqdw:6BrmS|riqdw:69rmi",
imul_3 = "rmIqdw:69rMI|rmSqdw:6BrMS|rmiqdw:69rMi",
movzx_2 = "rm/db:0FB6rM|rm/qb:|rm/wb:0FB6rM|rm/dw:0FB7rM|rm/qw:",
movsx_2 = "rm/db:0FBErM|rm/qb:|rm/wb:0FBErM|rm/dw:0FBFrM|rm/qw:",
bswap_1 = "rqd:0FC8r",
bsf_2 = "rmqdw:0FBCrM",
bsr_2 = "rmqdw:0FBDrM",
bt_2 = "mrqdw:0FA3Rm|miqdw:0FBA4mU",
btc_2 = "mrqdw:0FBBRm|miqdw:0FBA7mU",
btr_2 = "mrqdw:0FB3Rm|miqdw:0FBA6mU",
bts_2 = "mrqdw:0FABRm|miqdw:0FBA5mU",
shld_3 = "mriqdw:0FA4RmU|mrCqdw:0FA5Rm",
shrd_3 = "mriqdw:0FACRmU|mrCqdw:0FADRm",
rdtsc_0 = "0F31", -- P1+
cpuid_0 = "0FA2", -- P1+
-- floating point ops
fst_1 = "ff:DDD0r|xd:D92m|xq:nDD2m",
fstp_1 = "ff:DDD8r|xd:D93m|xq:nDD3m|xt:DB7m",
fld_1 = "ff:D9C0r|xd:D90m|xq:nDD0m|xt:DB5m",
fpop_0 = "DDD8", -- Alias for fstp st0.
fist_1 = "xw:nDF2m|xd:DB2m",
fistp_1 = "xw:nDF3m|xd:DB3m|xq:nDF7m",
fild_1 = "xw:nDF0m|xd:DB0m|xq:nDF5m",
fxch_0 = "D9C9",
fxch_1 = "ff:D9C8r",
fxch_2 = "fFf:D9C8r|Fff:D9C8R",
fucom_1 = "ff:DDE0r",
fucom_2 = "Fff:DDE0R",
fucomp_1 = "ff:DDE8r",
fucomp_2 = "Fff:DDE8R",
fucomi_1 = "ff:DBE8r", -- P6+
fucomi_2 = "Fff:DBE8R", -- P6+
fucomip_1 = "ff:DFE8r", -- P6+
fucomip_2 = "Fff:DFE8R", -- P6+
fcomi_1 = "ff:DBF0r", -- P6+
fcomi_2 = "Fff:DBF0R", -- P6+
fcomip_1 = "ff:DFF0r", -- P6+
fcomip_2 = "Fff:DFF0R", -- P6+
fucompp_0 = "DAE9",
fcompp_0 = "DED9",
fldenv_1 = "x.:D94m",
fnstenv_1 = "x.:D96m",
fstenv_1 = "x.:9BD96m",
fldcw_1 = "xw:nD95m",
fstcw_1 = "xw:n9BD97m",
fnstcw_1 = "xw:nD97m",
fstsw_1 = "Rw:n9BDFE0|xw:n9BDD7m",
fnstsw_1 = "Rw:nDFE0|xw:nDD7m",
fclex_0 = "9BDBE2",
fnclex_0 = "DBE2",
fnop_0 = "D9D0",
-- D9D1-D9DF: unassigned
fchs_0 = "D9E0",
fabs_0 = "D9E1",
-- D9E2: unassigned
-- D9E3: unassigned
ftst_0 = "D9E4",
fxam_0 = "D9E5",
-- D9E6: unassigned
-- D9E7: unassigned
fld1_0 = "D9E8",
fldl2t_0 = "D9E9",
fldl2e_0 = "D9EA",
fldpi_0 = "D9EB",
fldlg2_0 = "D9EC",
fldln2_0 = "D9ED",
fldz_0 = "D9EE",
-- D9EF: unassigned
f2xm1_0 = "D9F0",
fyl2x_0 = "D9F1",
fptan_0 = "D9F2",
fpatan_0 = "D9F3",
fxtract_0 = "D9F4",
fprem1_0 = "D9F5",
fdecstp_0 = "D9F6",
fincstp_0 = "D9F7",
fprem_0 = "D9F8",
fyl2xp1_0 = "D9F9",
fsqrt_0 = "D9FA",
fsincos_0 = "D9FB",
frndint_0 = "D9FC",
fscale_0 = "D9FD",
fsin_0 = "D9FE",
fcos_0 = "D9FF",
-- SSE, SSE2
andnpd_2 = "rmo:660F55rM",
andnps_2 = "rmo:0F55rM",
andpd_2 = "rmo:660F54rM",
andps_2 = "rmo:0F54rM",
clflush_1 = "x.:0FAE7m",
cmppd_3 = "rmio:660FC2rMU",
cmpps_3 = "rmio:0FC2rMU",
cmpsd_3 = "rrio:F20FC2rMU|rxi/oq:",
cmpss_3 = "rrio:F30FC2rMU|rxi/od:",
comisd_2 = "rro:660F2FrM|rx/oq:",
comiss_2 = "rro:0F2FrM|rx/od:",
cvtdq2pd_2 = "rro:F30FE6rM|rx/oq:",
cvtdq2ps_2 = "rmo:0F5BrM",
cvtpd2dq_2 = "rmo:F20FE6rM",
cvtpd2ps_2 = "rmo:660F5ArM",
cvtpi2pd_2 = "rx/oq:660F2ArM",
cvtpi2ps_2 = "rx/oq:0F2ArM",
cvtps2dq_2 = "rmo:660F5BrM",
cvtps2pd_2 = "rro:0F5ArM|rx/oq:",
cvtsd2si_2 = "rr/do:F20F2DrM|rr/qo:|rx/dq:|rxq:",
cvtsd2ss_2 = "rro:F20F5ArM|rx/oq:",
cvtsi2sd_2 = "rm/od:F20F2ArM|rm/oq:F20F2ArXM",
cvtsi2ss_2 = "rm/od:F30F2ArM|rm/oq:F30F2ArXM",
cvtss2sd_2 = "rro:F30F5ArM|rx/od:",
cvtss2si_2 = "rr/do:F20F2CrM|rr/qo:|rxd:|rx/qd:",
cvttpd2dq_2 = "rmo:660FE6rM",
cvttps2dq_2 = "rmo:F30F5BrM",
cvttsd2si_2 = "rr/do:F20F2CrM|rr/qo:|rx/dq:|rxq:",
cvttss2si_2 = "rr/do:F30F2CrM|rr/qo:|rxd:|rx/qd:",
fxsave_1 = "x.:0FAE0m",
fxrstor_1 = "x.:0FAE1m",
ldmxcsr_1 = "xd:0FAE2m",
lfence_0 = "0FAEE8",
maskmovdqu_2 = "rro:660FF7rM",
mfence_0 = "0FAEF0",
movapd_2 = "rmo:660F28rM|mro:660F29Rm",
movaps_2 = "rmo:0F28rM|mro:0F29Rm",
movd_2 = "rm/od:660F6ErM|rm/oq:660F6ErXM|mr/do:660F7ERm|mr/qo:",
movdqa_2 = "rmo:660F6FrM|mro:660F7FRm",
movdqu_2 = "rmo:F30F6FrM|mro:F30F7FRm",
movhlps_2 = "rro:0F12rM",
movhpd_2 = "rx/oq:660F16rM|xr/qo:n660F17Rm",
movhps_2 = "rx/oq:0F16rM|xr/qo:n0F17Rm",
movlhps_2 = "rro:0F16rM",
movlpd_2 = "rx/oq:660F12rM|xr/qo:n660F13Rm",
movlps_2 = "rx/oq:0F12rM|xr/qo:n0F13Rm",
movmskpd_2 = "rr/do:660F50rM",
movmskps_2 = "rr/do:0F50rM",
movntdq_2 = "xro:660FE7Rm",
movnti_2 = "xrqd:0FC3Rm",
movntpd_2 = "xro:660F2BRm",
movntps_2 = "xro:0F2BRm",
movq_2 = "rro:F30F7ErM|rx/oq:|xr/qo:n660FD6Rm",
movsd_2 = "rro:F20F10rM|rx/oq:|xr/qo:nF20F11Rm",
movss_2 = "rro:F30F10rM|rx/od:|xr/do:F30F11Rm",
movupd_2 = "rmo:660F10rM|mro:660F11Rm",
movups_2 = "rmo:0F10rM|mro:0F11Rm",
orpd_2 = "rmo:660F56rM",
orps_2 = "rmo:0F56rM",
packssdw_2 = "rmo:660F6BrM",
packsswb_2 = "rmo:660F63rM",
packuswb_2 = "rmo:660F67rM",
paddb_2 = "rmo:660FFCrM",
paddd_2 = "rmo:660FFErM",
paddq_2 = "rmo:660FD4rM",
paddsb_2 = "rmo:660FECrM",
paddsw_2 = "rmo:660FEDrM",
paddusb_2 = "rmo:660FDCrM",
paddusw_2 = "rmo:660FDDrM",
paddw_2 = "rmo:660FFDrM",
pand_2 = "rmo:660FDBrM",
pandn_2 = "rmo:660FDFrM",
pause_0 = "F390",
pavgb_2 = "rmo:660FE0rM",
pavgw_2 = "rmo:660FE3rM",
pcmpeqb_2 = "rmo:660F74rM",
pcmpeqd_2 = "rmo:660F76rM",
pcmpeqw_2 = "rmo:660F75rM",
pcmpgtb_2 = "rmo:660F64rM",
pcmpgtd_2 = "rmo:660F66rM",
pcmpgtw_2 = "rmo:660F65rM",
pextrw_3 = "rri/do:660FC5rMU|xri/wo:660F3A15nrMU", -- Mem op: SSE4.1 only.
pinsrw_3 = "rri/od:660FC4rMU|rxi/ow:",
pmaddwd_2 = "rmo:660FF5rM",
pmaxsw_2 = "rmo:660FEErM",
pmaxub_2 = "rmo:660FDErM",
pminsw_2 = "rmo:660FEArM",
pminub_2 = "rmo:660FDArM",
pmovmskb_2 = "rr/do:660FD7rM",
pmulhuw_2 = "rmo:660FE4rM",
pmulhw_2 = "rmo:660FE5rM",
pmullw_2 = "rmo:660FD5rM",
pmuludq_2 = "rmo:660FF4rM",
por_2 = "rmo:660FEBrM",
prefetchnta_1 = "xb:n0F180m",
prefetcht0_1 = "xb:n0F181m",
prefetcht1_1 = "xb:n0F182m",
prefetcht2_1 = "xb:n0F183m",
psadbw_2 = "rmo:660FF6rM",
pshufd_3 = "rmio:660F70rMU",
pshufhw_3 = "rmio:F30F70rMU",
pshuflw_3 = "rmio:F20F70rMU",
pslld_2 = "rmo:660FF2rM|rio:660F726mU",
pslldq_2 = "rio:660F737mU",
psllq_2 = "rmo:660FF3rM|rio:660F736mU",
psllw_2 = "rmo:660FF1rM|rio:660F716mU",
psrad_2 = "rmo:660FE2rM|rio:660F724mU",
psraw_2 = "rmo:660FE1rM|rio:660F714mU",
psrld_2 = "rmo:660FD2rM|rio:660F722mU",
psrldq_2 = "rio:660F733mU",
psrlq_2 = "rmo:660FD3rM|rio:660F732mU",
psrlw_2 = "rmo:660FD1rM|rio:660F712mU",
psubb_2 = "rmo:660FF8rM",
psubd_2 = "rmo:660FFArM",
psubq_2 = "rmo:660FFBrM",
psubsb_2 = "rmo:660FE8rM",
psubsw_2 = "rmo:660FE9rM",
psubusb_2 = "rmo:660FD8rM",
psubusw_2 = "rmo:660FD9rM",
psubw_2 = "rmo:660FF9rM",
punpckhbw_2 = "rmo:660F68rM",
punpckhdq_2 = "rmo:660F6ArM",
punpckhqdq_2 = "rmo:660F6DrM",
punpckhwd_2 = "rmo:660F69rM",
punpcklbw_2 = "rmo:660F60rM",
punpckldq_2 = "rmo:660F62rM",
punpcklqdq_2 = "rmo:660F6CrM",
punpcklwd_2 = "rmo:660F61rM",
pxor_2 = "rmo:660FEFrM",
rcpps_2 = "rmo:0F53rM",
rcpss_2 = "rro:F30F53rM|rx/od:",
rsqrtps_2 = "rmo:0F52rM",
rsqrtss_2 = "rmo:F30F52rM",
sfence_0 = "0FAEF8",
shufpd_3 = "rmio:660FC6rMU",
shufps_3 = "rmio:0FC6rMU",
stmxcsr_1 = "xd:0FAE3m",
ucomisd_2 = "rro:660F2ErM|rx/oq:",
ucomiss_2 = "rro:0F2ErM|rx/od:",
unpckhpd_2 = "rmo:660F15rM",
unpckhps_2 = "rmo:0F15rM",
unpcklpd_2 = "rmo:660F14rM",
unpcklps_2 = "rmo:0F14rM",
xorpd_2 = "rmo:660F57rM",
xorps_2 = "rmo:0F57rM",
-- SSE3 ops
fisttp_1 = "xw:nDF1m|xd:DB1m|xq:nDD1m",
addsubpd_2 = "rmo:660FD0rM",
addsubps_2 = "rmo:F20FD0rM",
haddpd_2 = "rmo:660F7CrM",
haddps_2 = "rmo:F20F7CrM",
hsubpd_2 = "rmo:660F7DrM",
hsubps_2 = "rmo:F20F7DrM",
lddqu_2 = "rxo:F20FF0rM",
movddup_2 = "rmo:F20F12rM",
movshdup_2 = "rmo:F30F16rM",
movsldup_2 = "rmo:F30F12rM",
-- SSSE3 ops
pabsb_2 = "rmo:660F381CrM",
pabsd_2 = "rmo:660F381ErM",
pabsw_2 = "rmo:660F381DrM",
palignr_3 = "rmio:660F3A0FrMU",
phaddd_2 = "rmo:660F3802rM",
phaddsw_2 = "rmo:660F3803rM",
phaddw_2 = "rmo:660F3801rM",
phsubd_2 = "rmo:660F3806rM",
phsubsw_2 = "rmo:660F3807rM",
phsubw_2 = "rmo:660F3805rM",
pmaddubsw_2 = "rmo:660F3804rM",
pmulhrsw_2 = "rmo:660F380BrM",
pshufb_2 = "rmo:660F3800rM",
psignb_2 = "rmo:660F3808rM",
psignd_2 = "rmo:660F380ArM",
psignw_2 = "rmo:660F3809rM",
-- SSE4.1 ops
blendpd_3 = "rmio:660F3A0DrMU",
blendps_3 = "rmio:660F3A0CrMU",
blendvpd_3 = "rmRo:660F3815rM",
blendvps_3 = "rmRo:660F3814rM",
dppd_3 = "rmio:660F3A41rMU",
dpps_3 = "rmio:660F3A40rMU",
extractps_3 = "mri/do:660F3A17RmU|rri/qo:660F3A17RXmU",
insertps_3 = "rrio:660F3A41rMU|rxi/od:",
movntdqa_2 = "rmo:660F382ArM",
mpsadbw_3 = "rmio:660F3A42rMU",
packusdw_2 = "rmo:660F382BrM",
pblendvb_3 = "rmRo:660F3810rM",
pblendw_3 = "rmio:660F3A0ErMU",
pcmpeqq_2 = "rmo:660F3829rM",
pextrb_3 = "rri/do:660F3A14nRmU|rri/qo:|xri/bo:",
pextrd_3 = "mri/do:660F3A16RmU",
pextrq_3 = "mri/qo:660F3A16RmU",
-- pextrw is SSE2, mem operand is SSE4.1 only
phminposuw_2 = "rmo:660F3841rM",
pinsrb_3 = "rri/od:660F3A20nrMU|rxi/ob:",
pinsrd_3 = "rmi/od:660F3A22rMU",
pinsrq_3 = "rmi/oq:660F3A22rXMU",
pmaxsb_2 = "rmo:660F383CrM",
pmaxsd_2 = "rmo:660F383DrM",
pmaxud_2 = "rmo:660F383FrM",
pmaxuw_2 = "rmo:660F383ErM",
pminsb_2 = "rmo:660F3838rM",
pminsd_2 = "rmo:660F3839rM",
pminud_2 = "rmo:660F383BrM",
pminuw_2 = "rmo:660F383ArM",
pmovsxbd_2 = "rro:660F3821rM|rx/od:",
pmovsxbq_2 = "rro:660F3822rM|rx/ow:",
pmovsxbw_2 = "rro:660F3820rM|rx/oq:",
pmovsxdq_2 = "rro:660F3825rM|rx/oq:",
pmovsxwd_2 = "rro:660F3823rM|rx/oq:",
pmovsxwq_2 = "rro:660F3824rM|rx/od:",
pmovzxbd_2 = "rro:660F3831rM|rx/od:",
pmovzxbq_2 = "rro:660F3832rM|rx/ow:",
pmovzxbw_2 = "rro:660F3830rM|rx/oq:",
pmovzxdq_2 = "rro:660F3835rM|rx/oq:",
pmovzxwd_2 = "rro:660F3833rM|rx/oq:",
pmovzxwq_2 = "rro:660F3834rM|rx/od:",
pmuldq_2 = "rmo:660F3828rM",
pmulld_2 = "rmo:660F3840rM",
ptest_2 = "rmo:660F3817rM",
roundpd_3 = "rmio:660F3A09rMU",
roundps_3 = "rmio:660F3A08rMU",
roundsd_3 = "rrio:660F3A0BrMU|rxi/oq:",
roundss_3 = "rrio:660F3A0ArMU|rxi/od:",
-- SSE4.2 ops
crc32_2 = "rmqd:F20F38F1rM|rm/dw:66F20F38F1rM|rm/db:F20F38F0rM|rm/qb:",
pcmpestri_3 = "rmio:660F3A61rMU",
pcmpestrm_3 = "rmio:660F3A60rMU",
pcmpgtq_2 = "rmo:660F3837rM",
pcmpistri_3 = "rmio:660F3A63rMU",
pcmpistrm_3 = "rmio:660F3A62rMU",
popcnt_2 = "rmqdw:F30FB8rM",
-- SSE4a
extrq_2 = "rro:660F79rM",
extrq_3 = "riio:660F780mUU",
insertq_2 = "rro:F20F79rM",
insertq_4 = "rriio:F20F78rMUU",
lzcnt_2 = "rmqdw:F30FBDrM",
movntsd_2 = "xr/qo:nF20F2BRm",
movntss_2 = "xr/do:F30F2BRm",
-- popcnt is also in SSE4.2
}
------------------------------------------------------------------------------
-- Arithmetic ops.
for name,n in pairs{ add = 0, ["or"] = 1, adc = 2, sbb = 3,
["and"] = 4, sub = 5, xor = 6, cmp = 7 } do
local n8 = shl(n, 3)
map_op[name.."_2"] = format(
"mr:%02XRm|rm:%02XrM|mI1qdw:81%XmI|mS1qdw:83%XmS|Ri1qdwb:%02Xri|mi1qdwb:81%Xmi",
1+n8, 3+n8, n, n, 5+n8, n)
end
-- Shift ops.
for name,n in pairs{ rol = 0, ror = 1, rcl = 2, rcr = 3,
shl = 4, shr = 5, sar = 7, sal = 4 } do
map_op[name.."_2"] = format("m1:D1%Xm|mC1qdwb:D3%Xm|mi:C1%XmU", n, n, n)
end
-- Conditional ops.
for cc,n in pairs(map_cc) do
map_op["j"..cc.."_1"] = format("J.:n0F8%XJ", n) -- short: 7%X
map_op["set"..cc.."_1"] = format("mb:n0F9%X2m", n)
map_op["cmov"..cc.."_2"] = format("rmqdw:0F4%XrM", n) -- P6+
end
-- FP arithmetic ops.
for name,n in pairs{ add = 0, mul = 1, com = 2, comp = 3,
sub = 4, subr = 5, div = 6, divr = 7 } do
local nc = 0xc0 + shl(n, 3)
local nr = nc + (n < 4 and 0 or (n % 2 == 0 and 8 or -8))
local fn = "f"..name
map_op[fn.."_1"] = format("ff:D8%02Xr|xd:D8%Xm|xq:nDC%Xm", nc, n, n)
if n == 2 or n == 3 then
map_op[fn.."_2"] = format("Fff:D8%02XR|Fx2d:D8%XM|Fx2q:nDC%XM", nc, n, n)
else
map_op[fn.."_2"] = format("Fff:D8%02XR|fFf:DC%02Xr|Fx2d:D8%XM|Fx2q:nDC%XM", nc, nr, n, n)
map_op[fn.."p_1"] = format("ff:DE%02Xr", nr)
map_op[fn.."p_2"] = format("fFf:DE%02Xr", nr)
end
map_op["fi"..name.."_1"] = format("xd:DA%Xm|xw:nDE%Xm", n, n)
end
-- FP conditional moves.
for cc,n in pairs{ b=0, e=1, be=2, u=3, nb=4, ne=5, nbe=6, nu=7 } do
local nc = 0xdac0 + shl(band(n, 3), 3) + shl(band(n, 4), 6)
map_op["fcmov"..cc.."_1"] = format("ff:%04Xr", nc) -- P6+
map_op["fcmov"..cc.."_2"] = format("Fff:%04XR", nc) -- P6+
end
-- SSE FP arithmetic ops.
for name,n in pairs{ sqrt = 1, add = 8, mul = 9,
sub = 12, min = 13, div = 14, max = 15 } do
map_op[name.."ps_2"] = format("rmo:0F5%XrM", n)
map_op[name.."ss_2"] = format("rro:F30F5%XrM|rx/od:", n)
map_op[name.."pd_2"] = format("rmo:660F5%XrM", n)
map_op[name.."sd_2"] = format("rro:F20F5%XrM|rx/oq:", n)
end
------------------------------------------------------------------------------
-- Process pattern string.
local function dopattern(pat, args, sz, op, needrex)
local digit, addin
local opcode = 0
local szov = sz
local narg = 1
local rex = 0
-- Limit number of section buffer positions used by a single dasm_put().
-- A single opcode needs a maximum of 5 positions.
if secpos+5 > maxsecpos then wflush() end
-- Process each character.
for c in gmatch(pat.."|", ".") do
if match(c, "%x") then -- Hex digit.
digit = byte(c) - 48
if digit > 48 then digit = digit - 39
elseif digit > 16 then digit = digit - 7 end
opcode = opcode*16 + digit
addin = nil
elseif c == "n" then -- Disable operand size mods for opcode.
szov = nil
elseif c == "X" then -- Force REX.W.
rex = 8
elseif c == "r" then -- Merge 1st operand regno. into opcode.
addin = args[1]; opcode = opcode + (addin.reg % 8)
if narg < 2 then narg = 2 end
elseif c == "R" then -- Merge 2nd operand regno. into opcode.
addin = args[2]; opcode = opcode + (addin.reg % 8)
narg = 3
elseif c == "m" or c == "M" then -- Encode ModRM/SIB.
local s
if addin then
s = addin.reg
opcode = opcode - band(s, 7) -- Undo regno opcode merge.
else
s = band(opcode, 15) -- Undo last digit.
opcode = shr(opcode, 4)
end
local nn = c == "m" and 1 or 2
local t = args[nn]
if narg <= nn then narg = nn + 1 end
if szov == "q" and rex == 0 then rex = rex + 8 end
if t.reg and t.reg > 7 then rex = rex + 1 end
if t.xreg and t.xreg > 7 then rex = rex + 2 end
if s > 7 then rex = rex + 4 end
if needrex then rex = rex + 16 end
wputop(szov, opcode, rex); opcode = nil
local imark = sub(pat, -1) -- Force a mark (ugly).
-- Put ModRM/SIB with regno/last digit as spare.
wputmrmsib(t, imark, s, addin and addin.vreg)
addin = nil
else
if opcode then -- Flush opcode.
if szov == "q" and rex == 0 then rex = rex + 8 end
if needrex then rex = rex + 16 end
if addin and addin.reg == -1 then
wputop(szov, opcode - 7, rex)
waction("VREG", addin.vreg); wputxb(0)
else
if addin and addin.reg > 7 then rex = rex + 1 end
wputop(szov, opcode, rex)
end
opcode = nil
end
if c == "|" then break end
if c == "o" then -- Offset (pure 32 bit displacement).
wputdarg(args[1].disp); if narg < 2 then narg = 2 end
elseif c == "O" then
wputdarg(args[2].disp); narg = 3
else
-- Anything else is an immediate operand.
local a = args[narg]
narg = narg + 1
local mode, imm = a.mode, a.imm
if mode == "iJ" and not match("iIJ", c) then
werror("bad operand size for label")
end
if c == "S" then
wputsbarg(imm)
elseif c == "U" then
wputbarg(imm)
elseif c == "W" then
wputwarg(imm)
elseif c == "i" or c == "I" then
if mode == "iJ" then
wputlabel("IMM_", imm, 1)
elseif mode == "iI" and c == "I" then
waction(sz == "w" and "IMM_WB" or "IMM_DB", imm)
else
wputszarg(sz, imm)
end
elseif c == "J" then
if mode == "iPJ" then
waction("REL_A", imm) -- !x64 (secpos)
else
wputlabel("REL_", imm, 2)
end
else
werror("bad char `"..c.."' in pattern `"..pat.."' for `"..op.."'")
end
end
end
end
end
------------------------------------------------------------------------------
-- Mapping of operand modes to short names. Suppress output with '#'.
local map_modename = {
r = "reg", R = "eax", C = "cl", x = "mem", m = "mrm", i = "imm",
f = "stx", F = "st0", J = "lbl", ["1"] = "1",
I = "#", S = "#", O = "#",
}
-- Return a table/string showing all possible operand modes.
local function templatehelp(template, nparams)
if nparams == 0 then return "" end
local t = {}
for tm in gmatch(template, "[^%|]+") do
local s = map_modename[sub(tm, 1, 1)]
s = s..gsub(sub(tm, 2, nparams), ".", function(c)
return ", "..map_modename[c]
end)
if not match(s, "#") then t[#t+1] = s end
end
return t
end
-- Match operand modes against mode match part of template.
local function matchtm(tm, args)
for i=1,#args do
if not match(args[i].mode, sub(tm, i, i)) then return end
end
return true
end
-- Handle opcodes defined with template strings.
map_op[".template__"] = function(params, template, nparams)
if not params then return templatehelp(template, nparams) end
local args = {}
-- Zero-operand opcodes have no match part.
if #params == 0 then
dopattern(template, args, "d", params.op, nil)
return
end
-- Determine common operand size (coerce undefined size) or flag as mixed.
local sz, szmix, needrex
for i,p in ipairs(params) do
args[i] = parseoperand(p)
local nsz = args[i].opsize
if nsz then
if sz and sz ~= nsz then szmix = true else sz = nsz end
end
local nrex = args[i].needrex
if nrex ~= nil then
if needrex == nil then
needrex = nrex
elseif needrex ~= nrex then
werror("bad mix of byte-addressable registers")
end
end
end
-- Try all match:pattern pairs (separated by '|').
local gotmatch, lastpat
for tm in gmatch(template, "[^%|]+") do
-- Split off size match (starts after mode match) and pattern string.
local szm, pat = match(tm, "^(.-):(.*)$", #args+1)
if pat == "" then pat = lastpat else lastpat = pat end
if matchtm(tm, args) then
local prefix = sub(szm, 1, 1)
if prefix == "/" then -- Match both operand sizes.
if args[1].opsize == sub(szm, 2, 2) and
args[2].opsize == sub(szm, 3, 3) then
dopattern(pat, args, sz, params.op, needrex) -- Process pattern.
return
end
else -- Match common operand size.
local szp = sz
if szm == "" then szm = x64 and "qdwb" or "dwb" end -- Default sizes.
if prefix == "1" then szp = args[1].opsize; szmix = nil
elseif prefix == "2" then szp = args[2].opsize; szmix = nil end
if not szmix and (prefix == "." or match(szm, szp or "#")) then
dopattern(pat, args, szp, params.op, needrex) -- Process pattern.
return
end
end
gotmatch = true
end
end
local msg = "bad operand mode"
if gotmatch then
if szmix then
msg = "mixed operand size"
else
msg = sz and "bad operand size" or "missing operand size"
end
end
werror(msg.." in `"..opmodestr(params.op, args).."'")
end
------------------------------------------------------------------------------
-- x64-specific opcode for 64 bit immediates and displacements.
if x64 then
function map_op.mov64_2(params)
if not params then return { "reg, imm", "reg, [disp]", "[disp], reg" } end
if secpos+2 > maxsecpos then wflush() end
local opcode, op64, sz, rex, vreg
local op64 = match(params[1], "^%[%s*(.-)%s*%]$")
if op64 then
local a = parseoperand(params[2])
if a.mode ~= "rmR" then werror("bad operand mode") end
sz = a.opsize
rex = sz == "q" and 8 or 0
opcode = 0xa3
else
op64 = match(params[2], "^%[%s*(.-)%s*%]$")
local a = parseoperand(params[1])
if op64 then
if a.mode ~= "rmR" then werror("bad operand mode") end
sz = a.opsize
rex = sz == "q" and 8 or 0
opcode = 0xa1
else
if sub(a.mode, 1, 1) ~= "r" or a.opsize ~= "q" then
werror("bad operand mode")
end
op64 = params[2]
if a.reg == -1 then
vreg = a.vreg
opcode = 0xb8
else
opcode = 0xb8 + band(a.reg, 7)
end
rex = a.reg > 7 and 9 or 8
end
end
wputop(sz, opcode, rex)
if vreg then waction("VREG", vreg); wputxb(0) end
waction("IMM_D", format("(unsigned int)(%s)", op64))
waction("IMM_D", format("(unsigned int)((%s)>>32)", op64))
end
end
------------------------------------------------------------------------------
-- Pseudo-opcodes for data storage.
local function op_data(params)
if not params then return "imm..." end
local sz = sub(params.op, 2, 2)
if sz == "a" then sz = addrsize end
for _,p in ipairs(params) do
local a = parseoperand(p)
if sub(a.mode, 1, 1) ~= "i" or (a.opsize and a.opsize ~= sz) then
werror("bad mode or size in `"..p.."'")
end
if a.mode == "iJ" then
wputlabel("IMM_", a.imm, 1)
else
wputszarg(sz, a.imm)
end
if secpos+2 > maxsecpos then wflush() end
end
end
map_op[".byte_*"] = op_data
map_op[".sbyte_*"] = op_data
map_op[".word_*"] = op_data
map_op[".dword_*"] = op_data
map_op[".aword_*"] = op_data
------------------------------------------------------------------------------
-- Pseudo-opcode to mark the position where the action list is to be emitted.
map_op[".actionlist_1"] = function(params)
if not params then return "cvar" end
local name = params[1] -- No syntax check. You get to keep the pieces.
wline(function(out) writeactions(out, name) end)
end
-- Pseudo-opcode to mark the position where the global enum is to be emitted.
map_op[".globals_1"] = function(params)
if not params then return "prefix" end
local prefix = params[1] -- No syntax check. You get to keep the pieces.
wline(function(out) writeglobals(out, prefix) end)
end
-- Pseudo-opcode to mark the position where the global names are to be emitted.
map_op[".globalnames_1"] = function(params)
if not params then return "cvar" end
local name = params[1] -- No syntax check. You get to keep the pieces.
wline(function(out) writeglobalnames(out, name) end)
end
-- Pseudo-opcode to mark the position where the extern names are to be emitted.
map_op[".externnames_1"] = function(params)
if not params then return "cvar" end
local name = params[1] -- No syntax check. You get to keep the pieces.
wline(function(out) writeexternnames(out, name) end)
end
------------------------------------------------------------------------------
-- Label pseudo-opcode (converted from trailing colon form).
map_op[".label_2"] = function(params)
if not params then return "[1-9] | ->global | =>pcexpr [, addr]" end
if secpos+2 > maxsecpos then wflush() end
local a = parseoperand(params[1])
local mode, imm = a.mode, a.imm
if type(imm) == "number" and (mode == "iJ" or (imm >= 1 and imm <= 9)) then
-- Local label (1: ... 9:) or global label (->global:).
waction("LABEL_LG", nil, 1)
wputxb(imm)
elseif mode == "iJ" then
-- PC label (=>pcexpr:).
waction("LABEL_PC", imm)
else
werror("bad label definition")
end
-- SETLABEL must immediately follow LABEL_LG/LABEL_PC.
local addr = params[2]
if addr then
local a = parseoperand(addr)
if a.mode == "iPJ" then
waction("SETLABEL", a.imm)
else
werror("bad label assignment")
end
end
end
map_op[".label_1"] = map_op[".label_2"]
------------------------------------------------------------------------------
-- Alignment pseudo-opcode.
map_op[".align_1"] = function(params)
if not params then return "numpow2" end
if secpos+1 > maxsecpos then wflush() end
local align = tonumber(params[1]) or map_opsizenum[map_opsize[params[1]]]
if align then
local x = align
-- Must be a power of 2 in the range (2 ... 256).
for i=1,8 do
x = x / 2
if x == 1 then
waction("ALIGN", nil, 1)
wputxb(align-1) -- Action byte is 2**n-1.
return
end
end
end
werror("bad alignment")
end
-- Spacing pseudo-opcode.
map_op[".space_2"] = function(params)
if not params then return "num [, filler]" end
if secpos+1 > maxsecpos then wflush() end
waction("SPACE", params[1])
local fill = params[2]
if fill then
fill = tonumber(fill)
if not fill or fill < 0 or fill > 255 then werror("bad filler") end
end
wputxb(fill or 0)
end
map_op[".space_1"] = map_op[".space_2"]
------------------------------------------------------------------------------
-- Pseudo-opcode for (primitive) type definitions (map to C types).
map_op[".type_3"] = function(params, nparams)
if not params then
return nparams == 2 and "name, ctype" or "name, ctype, reg"
end
local name, ctype, reg = params[1], params[2], params[3]
if not match(name, "^[%a_][%w_]*$") then
werror("bad type name `"..name.."'")
end
local tp = map_type[name]
if tp then
werror("duplicate type `"..name.."'")
end
if reg and not map_reg_valid_base[reg] then
werror("bad base register `"..(map_reg_rev[reg] or reg).."'")
end
-- Add #type to defines. A bit unclean to put it in map_archdef.
map_archdef["#"..name] = "sizeof("..ctype..")"
-- Add new type and emit shortcut define.
local num = ctypenum + 1
map_type[name] = {
ctype = ctype,
ctypefmt = format("Dt%X(%%s)", num),
reg = reg,
}
wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype))
ctypenum = num
end
map_op[".type_2"] = map_op[".type_3"]
-- Dump type definitions.
local function dumptypes(out, lvl)
local t = {}
for name in pairs(map_type) do t[#t+1] = name end
sort(t)
out:write("Type definitions:\n")
for _,name in ipairs(t) do
local tp = map_type[name]
local reg = tp.reg and map_reg_rev[tp.reg] or ""
out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg))
end
out:write("\n")
end
------------------------------------------------------------------------------
-- Set the current section.
function _M.section(num)
waction("SECTION")
wputxb(num)
wflush(true) -- SECTION is a terminal action.
end
------------------------------------------------------------------------------
-- Dump architecture description.
function _M.dumparch(out)
out:write(format("DynASM %s version %s, released %s\n\n",
_info.arch, _info.version, _info.release))
dumpregs(out)
dumpactions(out)
end
-- Dump all user defined elements.
function _M.dumpdef(out, lvl)
dumptypes(out, lvl)
dumpglobals(out, lvl)
dumpexterns(out, lvl)
end
------------------------------------------------------------------------------
-- Pass callbacks from/to the DynASM core.
function _M.passcb(wl, we, wf, ww)
wline, werror, wfatal, wwarn = wl, we, wf, ww
return wflush
end
-- Setup the arch-specific module.
function _M.setup(arch, opt)
g_arch, g_opt = arch, opt
end
-- Merge the core maps and the arch-specific maps.
function _M.mergemaps(map_coreop, map_def)
setmetatable(map_op, { __index = map_coreop })
setmetatable(map_def, { __index = map_archdef })
return map_op, map_def
end
return _M
------------------------------------------------------------------------------
| mit |
dalvorsn/tests | data/global.lua | 1 | 16057 | dofile('data/compat.lua')
TRUE = true
FALSE = false
LUA_ERROR = false
LUA_NO_ERROR = true
THING_TYPE_PLAYER = 1
THING_TYPE_MONSTER = 2
THING_TYPE_NPC = 3
MAPMARK_TICK = 0
MAPMARK_QUESTION = 1
MAPMARK_EXCLAMATION = 2
MAPMARK_STAR = 3
MAPMARK_CROSS = 4
MAPMARK_TEMPLE = 5
MAPMARK_KISS = 6
MAPMARK_SHOVEL = 7
MAPMARK_SWORD = 8
MAPMARK_FLAG = 9
MAPMARK_LOCK = 10
MAPMARK_BAG = 11
MAPMARK_SKULL = 12
MAPMARK_DOLLAR = 13
MAPMARK_REDNORTH = 14
MAPMARK_REDSOUTH = 15
MAPMARK_REDEAST = 16
MAPMARK_REDWEST = 17
MAPMARK_GREENNORTH = 18
MAPMARK_GREENSOUTH = 19
GUILDLEVEL_MEMBER = 1
GUILDLEVEL_VICE = 2
GUILDLEVEL_LEADER = 3
STACKPOS_GROUND = 0
STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE = 1
STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE = 2
STACKPOS_THIRD_ITEM_ABOVE_GROUNDTILE = 3
STACKPOS_FOURTH_ITEM_ABOVE_GROUNDTILE = 4
STACKPOS_FIFTH_ITEM_ABOVE_GROUNDTILE = 5
STACKPOS_TOP_CREATURE = 253
STACKPOS_TOP_FIELD = 254
STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE = 255
RETURNVALUE_NOERROR = 1
RETURNVALUE_NOTPOSSIBLE = 2
RETURNVALUE_NOTENOUGHROOM = 3
RETURNVALUE_PLAYERISPZLOCKED = 4
RETURNVALUE_PLAYERISNOTINVITED = 5
RETURNVALUE_CANNOTTHROW = 6
RETURNVALUE_THEREISNOWAY = 7
RETURNVALUE_DESTINATIONOUTOFREACH = 8
RETURNVALUE_CREATUREBLOCK = 9
RETURNVALUE_NOTMOVEABLE = 10
RETURNVALUE_DROPTWOHANDEDITEM = 11
RETURNVALUE_BOTHHANDSNEEDTOBEFREE = 12
RETURNVALUE_CANONLYUSEONEWEAPON = 13
RETURNVALUE_NEEDEXCHANGE = 14
RETURNVALUE_CANNOTBEDRESSED = 15
RETURNVALUE_PUTTHISOBJECTINYOURHAND = 16
RETURNVALUE_PUTTHISOBJECTINBOTHHANDS = 17
RETURNVALUE_TOOFARAWAY = 18
RETURNVALUE_FIRSTGODOWNSTAIRS = 19
RETURNVALUE_FIRSTGOUPSTAIRS = 20
RETURNVALUE_CONTAINERNOTENOUGHROOM = 21
RETURNVALUE_NOTENOUGHCAPACITY = 22
RETURNVALUE_CANNOTPICKUP = 23
RETURNVALUE_THISISIMPOSSIBLE = 24
RETURNVALUE_DEPOTISFULL = 25
RETURNVALUE_CREATUREDOESNOTEXIST = 26
RETURNVALUE_CANNOTUSETHISOBJECT = 27
RETURNVALUE_PLAYERWITHTHISNAMEISNOTONLINE = 28
RETURNVALUE_NOTREQUIREDLEVELTOUSERUNE = 29
RETURNVALUE_YOUAREALREADYTRADING = 30
RETURNVALUE_THISPLAYERISALREADYTRADING = 31
RETURNVALUE_YOUMAYNOTLOGOUTDURINGAFIGHT = 32
RETURNVALUE_DIRECTPLAYERSHOOT = 33
RETURNVALUE_NOTENOUGHLEVEL = 34
RETURNVALUE_NOTENOUGHMAGICLEVEL = 35
RETURNVALUE_NOTENOUGHMANA = 36
RETURNVALUE_NOTENOUGHSOUL = 37
RETURNVALUE_YOUAREEXHAUSTED = 38
RETURNVALUE_PLAYERISNOTREACHABLE = 39
RETURNVALUE_CANONLYUSETHISRUNEONCREATURES = 40
RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE = 41
RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER = 42
RETURNVALUE_YOUMAYNOTATTACKAPERSONINPROTECTIONZONE = 43
RETURNVALUE_YOUMAYNOTATTACKAPERSONWHILEINPROTECTIONZONE = 44
RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE = 45
RETURNVALUE_YOUCANONLYUSEITONCREATURES = 46
RETURNVALUE_CREATUREISNOTREACHABLE = 47
RETURNVALUE_TURNSECUREMODETOATTACKUNMARKEDPLAYERS = 48
RETURNVALUE_YOUNEEDPREMIUMACCOUNT = 49
RETURNVALUE_YOUNEEDTOLEARNTHISSPELL = 50
RETURNVALUE_YOURVOCATIONCANNOTUSETHISSPELL = 51
RETURNVALUE_YOUNEEDAWEAPONTOUSETHISSPELL = 52
RETURNVALUE_PLAYERISPZLOCKEDLEAVEPVPZONE = 53
RETURNVALUE_PLAYERISPZLOCKEDENTERPVPZONE = 54
RETURNVALUE_ACTIONNOTPERMITTEDINANOPVPZONE = 55
RETURNVALUE_YOUCANNOTLOGOUTHERE = 56
RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL = 57
RETURNVALUE_CANNOTCONJUREITEMHERE = 58
RETURNVALUE_YOUNEEDTOSPLITYOURSPEARS = 59
RETURNVALUE_NAMEISTOOAMBIGIOUS = 60
RETURNVALUE_CANUSEONLYONESHIELD = 61
RETURNVALUE_NOPARTYMEMBERSINRANGE = 62
RETURNVALUE_YOUARENOTTHEOWNER = 63
ropeSpots = {384, 418, 8278, 8592, 13189, 14435, 14436, 15635, 19518}
doors = {[1209] = 1211, [1210] = 1211, [1212] = 1214, [1213] = 1214, [1219] = 1220, [1221] = 1222, [1231] = 1233, [1232] = 1233, [1234] = 1236, [1235] = 1236, [1237] = 1238, [1239] = 1240, [1249] = 1251, [1250] = 1251, [1252] = 1254, [1253] = 1254, [1539] = 1540, [1541] = 1542, [3535] = 3537, [3536] = 3537, [3538] = 3539, [3544] = 3546, [3545] = 3546, [3547] = 3548, [4913] = 4915, [4914] = 4915, [4916] = 4918, [4917] = 4918, [5082] = 5083, [5084] = 5085, [5098] = 5100, [5099] = 5100, [5101] = 5102, [5107] = 5109, [5108] = 5109, [5110] = 5111, [5116] = 5118, [5117] = 5118, [5119] = 5120, [5125] = 5127, [5126] = 5127, [5128] = 5129, [5134] = 5136, [5135] = 5136, [5137] = 5139, [5138] = 5139, [5140] = 5142, [5141] = 5142, [5143] = 5145, [5144] = 5145, [5278] = 5280, [5279] = 5280, [5281] = 5283, [5282] = 5283, [5284] = 5285, [5286] = 5287, [5515] = 5516, [5517] = 5518, [5732] = 5734, [5733] = 5734, [5735] = 5737, [5736] = 5737, [6192] = 6194, [6193] = 6194, [6195] = 6197, [6196] = 6197, [6198] = 6199, [6200] = 6201, [6249] = 6251, [6250] = 6251, [6252] = 6254, [6253] = 6254, [6255] = 6256, [6257] = 6258, [6795] = 6796, [6797] = 6798, [6799] = 6800, [6801] = 6802, [6891] = 6893, [6892] = 6893, [6894] = 6895, [6900] = 6902, [6901] = 6902, [6903] = 6904, [7033] = 7035, [7034] = 7035, [7036] = 7037, [7042] = 7044, [7043] = 7044, [7045] = 7046, [7054] = 7055, [7056] = 7057, [8541] = 8543, [8542] = 8543, [8544] = 8546, [8545] = 8546, [8547] = 8548, [8549] = 8550, [9165] = 9167, [9166] = 9167, [9168] = 9170, [9169] = 9170, [9171] = 9172, [9173] = 9174, [9267] = 9269, [9268] = 9269, [9270] = 9272, [9271] = 9272, [9273] = 9274, [9275] = 9276, [10276] = 10277, [10274] = 10275, [10268] = 10270, [10269] = 10270, [10271] = 10273, [10272] = 10273, [10471] = 10472, [10480] = 10481, [10477] = 10479, [10478] = 10479, [10468] = 10470, [10469] = 10470, [10775] = 10777, [10776] = 10777, [12092] = 12094, [12093] = 12094, [12188] = 12190, [12189] = 12190, [19840] = 19842, [19841] = 19842, [19843] = 19844, [19980] = 19982, [19981] = 19982, [19983] = 19984, [20273] = 20275, [20274] = 20275, [20276] = 20277, [17235] = 17236, [18208] = 18209, [13022] = 13023, [10784] = 10786, [10785] = 10786, [12099] = 12101, [12100] = 12101, [12197] = 12199, [12198] = 12199, [19849] = 19851, [19850] = 19851, [19852] = 19853, [19989] = 19991, [19990] = 19991, [19992] = 19993, [20282] = 20284, [20283] = 20284, [20285] = 20286, [17237] = 17238, [13020] = 13021, [10780] = 10781, [12095] = 12096, [12195] = 12196, [19845] = 19846, [19985] = 19986, [20278] = 20279, [10789] = 10790, [12102] = 12103, [12204] = 12205, [19854] = 19855, [19994] = 19995, [20287] = 20288, [10782] = 10783, [12097] = 12098, [12193] = 12194, [19847] = 19848, [19987] = 19988, [20280] = 20281, [10791] = 10792, [12104] = 12105, [12202] = 12203, [19856] = 19857, [19996] = 19997, [20289] = 20290}
verticalOpenDoors = {1211, 1220, 1224, 1228, 1233, 1238, 1242, 1246, 1251, 1256, 1260, 1540, 3546, 3548, 3550, 3552, 4915, 5083, 5109, 5111, 5113, 5115, 5127, 5129, 5131, 5133, 5142, 5145, 5283, 5285, 5289, 5293, 5516, 5737, 5749, 6194, 6199, 6203, 6207, 6251, 6256, 6260, 6264, 6798, 6802, 6902, 6904, 6906, 6908, 7044, 7046, 7048, 7050, 7055, 8543, 8548, 8552, 8556, 9167, 9172, 9269, 9274, 9274, 9269, 9278, 9282, 10270, 10275, 10279, 10283, 10479, 10481, 10485, 10483, 10786, 12101, 12199, 19851, 19853, 19991, 19993, 20284, 20286, 17238, 13021, 10790, 12103, 12205, 19855, 19995, 20288, 10792, 12105, 12203, 19857, 19997, 20290}
horizontalOpenDoors = {1214, 1222, 1226, 1230, 1236, 1240, 1244, 1248, 1254, 1258, 1262, 1542, 3537, 3539, 3541, 3543, 4918, 5085, 5100, 5102, 5104, 5106, 5118, 5120, 5122, 5124, 5136, 5139, 5280, 5287, 5291, 5295, 5518, 5734, 5746, 6197, 6201, 6205, 6209, 6254, 6258, 6262, 6266, 6796, 6800, 6893, 6895, 6897, 6899, 7035, 7037, 7039, 7041, 7057, 8546, 8550, 8554, 8558, 9170, 9174, 9272, 9276, 9280, 9284, 10273, 10277, 10281, 10285, 10470, 10472, 10476, 10474, 10777, 12094, 12190, 19842, 19844, 19982, 19984, 20275, 20277, 17236, 18209, 13023, 10781, 12096, 12196, 19846, 19986, 20279, 10783, 12098, 12194, 19848, 19988, 20281}
openSpecialDoors = {1224, 1226, 1228, 1230, 1242, 1244, 1246, 1248, 1256, 1258, 1260, 1262, 3541, 3543, 3550, 3552, 5104, 5106, 5113, 5115, 5122, 5124, 5131, 5133, 5289, 5291, 5293, 5295, 6203, 6205, 6207, 6209, 6260, 6262, 6264, 6266, 6897, 6899, 6906, 6908, 7039, 7041, 7048, 7050, 8552, 8554, 8556, 8558, 9176, 9178, 9180, 9182, 9278, 9280, 9282, 9284, 10279, 10281, 10283, 10285, 10474, 10476, 10483, 10485, 10781, 12096, 12196, 19846, 19986, 20279, 10783, 12098, 12194, 19848, 19988, 20281, 10790, 12103, 12205, 19855, 19995, 20288, 10792, 12105, 12203, 19857, 19997, 20290}
questDoors = {1223, 1225, 1241, 1243, 1255, 1257, 3542, 3551, 5105, 5114, 5123, 5132, 5288, 5290, 5745, 5748, 6202, 6204, 6259, 6261, 6898, 6907, 7040, 7049, 8551, 8553, 9175, 9177, 9277, 9279, 10278, 10280, 10475, 10484, 10782, 12097, 12193, 19847, 19987, 20280, 10791, 12104, 12202, 19856, 19996, 20289}
levelDoors = {1227, 1229, 1245, 1247, 1259, 1261, 3540, 3549, 5103, 5112, 5121, 5130, 5292, 5294, 6206, 6208, 6263, 6265, 6896, 6905, 7038, 7047, 8555, 8557, 9179, 9181, 9281, 9283, 10282, 10284, 10473, 10482, 10780, 10789, 10780, 12095, 12195, 19845, 19985, 20278, 10789, 12102, 12204, 19854, 19994, 20287}
keys = {2086, 2087, 2088, 2089, 2090, 2091, 2092, 10032}
CONTAINER_POSITION = 0xFFFF
ITEMCOUNT_MAX = 100
function doCreatureSayWithRadius(cid, text, type, radiusx, radiusy, position)
if position == nil then
position = getCreaturePosition(cid)
end
local spectators = getSpectators(position, radiusx, radiusy, false, true)
if spectators ~= nil then
for _, spectator in ipairs(spectators) do
doCreatureSay(cid, text, type, false, spectator, position)
end
end
end
function getBlessingsCost(level)
if level <= 30 then
return 2000
elseif level >= 120 then
return 20000
else
return ((level - 20) * 200)
end
end
function getPvpBlessingCost(level)
if level <= 30 then
return 2000
elseif level >= 270 then
return 50000
else
return ((level - 20) * 200)
end
end
function isInRange(pos, fromPos, toPos)
return pos.x >= fromPos.x and pos.y >= fromPos.y and pos.z >= fromPos.z and pos.x <= toPos.x and pos.y <= toPos.y and pos.z <= toPos.z
end
function isPremium(cid)
return getPlayerPremiumDays(cid) > 0
end
function isNumber(str)
return tonumber(str) ~= nil
end
function getDistanceBetween(firstPosition, secondPosition)
local xDif = math.abs(firstPosition.x - secondPosition.x)
local yDif = math.abs(firstPosition.y - secondPosition.y)
local posDif = math.max(xDif, yDif)
if firstPosition.z ~= secondPosition.z then
posDif = posDif + 15
end
return posDif
end
function isSorcerer(cid)
local player = Player(cid)
if player == nil then
return false
end
return isInArray({1, 5}, player:getVocation():getId())
end
function isDruid(cid)
local player = Player(cid)
if player == nil then
return false
end
return isInArray({2, 6}, player:getVocation():getId())
end
function isPaladin(cid)
local player = Player(cid)
if player == nil then
return false
end
return isInArray({3, 7}, player:getVocation():getId())
end
function isKnight(cid)
local player = Player(cid)
if player == nil then
return false
end
return isInArray({4, 8}, player:getVocation():getId())
end
function getTibianTime()
local worldTime = getWorldTime()
local hours = math.floor(worldTime / 60)
local minutes = worldTime % 60
if minutes < 10 then
minutes = '0' .. minutes
end
return hours .. ':' .. minutes
end
function doForceSummonCreature(name, pos)
local creature = doSummonCreature(name, pos)
if creature == false then
pos.stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE
local lastUid = nil
while true do
local thing = getTileThingByPos(pos)
if thing.uid == 0 or thing.uid == lastUid or not isItem(thing.uid) then
break
end
lastUid = thing.uid
doRemoveItem(thing.uid)
end
creature = doSummonCreature(name, pos)
end
return creature
end
--
if not globalStorageTable then
globalStorageTable = {}
end
function Game.getStorageValue(key)
return globalStorageTable[key]
end
function Game.setStorageValue(key, value)
globalStorageTable[key] = value
end
function Game.convertIpToString(ip)
local band = bit.band
local rshift = bit.rshift
return string.format("%d.%d.%d.%d",
band(ip, 0xFF),
band(rshift(ip, 8), 0xFF),
band(rshift(ip, 16), 0xFF),
rshift(ip, 24)
)
end
function Game.getSkillType(weaponType)
if weaponType == WEAPON_CLUB then
return SKILL_CLUB
elseif weaponType == WEAPON_SWORD then
return SKILL_SWORD
elseif weaponType == WEAPON_AXE then
return SKILL_AXE
elseif weaponType == WEAPON_DISTANCE then
return SKILL_DISTANCE
elseif weaponType == WEAPON_SHIELD then
return SKILL_SHIELD
end
return SKILL_FIST
end
function Game.getReverseDirection(direction)
if direction == WEST then
return EAST
elseif direction == EAST then
return WEST
elseif direction == NORTH then
return SOUTH
elseif direction == SOUTH then
return NORTH
elseif direction == NORTHWEST then
return SOUTHEAST
elseif direction == NORTHEAST then
return SOUTHWEST
elseif direction == SOUTHWEST then
return NORTHEAST
elseif direction == SOUTHEAST then
return NORTHWEST
end
return NORTH
end
function Position.getNextPosition(self, direction, steps)
steps = steps or 1
if direction == WEST then
self.x = self.x - steps
elseif direction == EAST then
self.x = self.x + steps
elseif direction == NORTH then
self.y = self.y - steps
elseif direction == SOUTH then
self.y = self.y + steps
elseif direction == NORTHWEST then
self.x = self.x - steps
self.y = self.y - steps
elseif direction == NORTHEAST then
self.x = self.x + steps
self.y = self.y - steps
elseif direction == SOUTHWEST then
self.x = self.x - steps
self.y = self.y + steps
elseif direction == SOUTHEAST then
self.x = self.x + steps
self.y = self.y + steps
end
end
function Player.getClosestFreePosition(self, position, extended)
if self:getAccountType() >= ACCOUNT_TYPE_GOD then
return position
end
return Creature.getClosestFreePosition(self, position, extended)
end
function Creature.getClosestFreePosition(self, position, extended)
local usePosition = Position(position)
local tiles = { usePosition:getTile() }
local length = extended and 2 or 1
local tile
for y = -length, length do
for x = -length, length do
if x ~= 0 or y ~= 0 then
usePosition.x = position.x + x
usePosition.y = position.y + y
tile = usePosition:getTile()
if tile then
tiles[#tiles + 1] = tile
end
end
end
end
for i = 1, #tiles do
tile = tiles[i]
if tile:getCreatureCount() == 0 and not tile:hasProperty(CONST_PROP_BLOCKINGANDNOTMOVEABLE) then
return tile:getPosition()
end
end
return Position()
end
function Player.sendCancelMessage(self, message)
if type(message) == "number" then
message = Game.getReturnMessage(message)
end
return self:sendTextMessage(MESSAGE_STATUS_SMALL, message)
end
local foodCondition = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
function Player.feed(self, food)
local condition = self:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
if condition then
condition:setTicks(condition:getTicks() + (food * 1000))
else
local vocation = self:getVocation()
if not vocation then
return nil
end
foodCondition:setTicks(food * 1000)
foodCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, vocation:getHealthGainAmount())
foodCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, vocation:getHealthGainTicks() * 1000)
foodCondition:setParameter(CONDITION_PARAM_MANAGAIN, vocation:getManaGainAmount())
foodCondition:setParameter(CONDITION_PARAM_MANATICKS, vocation:getManaGainTicks() * 1000)
self:addCondition(foodCondition)
end
return true
end
function Player.getDepotItems(self, depotId)
return self:getDepotChest(depotId, true):getItemHoldingCount()
end
function Player.isUsingOtClient(self)
return self:getClient().os >= CLIENTOS_OTCLIENT_LINUX
end
function Player.sendExtendedOpcode(self, opcode, buffer)
if not self:isUsingOtClient() then
return false
end
local networkMessage = NetworkMessage()
networkMessage:addByte(0x32)
networkMessage:addByte(opcode)
networkMessage:addString(buffer)
networkMessage:sendToPlayer(self)
networkMessage:delete()
return true
end
string.split = function(str, sep)
local res = {}
for v in str:gmatch("([^" .. sep .. "]+)") do
res[#res + 1] = v
end
return res
end
function Position.getTile(self)
return Tile(self)
end
| gpl-2.0 |
tudor-berariu/activity-recognition | src/evaluate.lua | 1 | 1104 | --------------------------------------------------------------------------------
--- 1. Require needed packages
--------------------------------------------------------------------------------
--------------------------------------------------------------------------
--- Compute loss on test set
--------------------------------------------------------------------------
local evaluate = function(dataset, model, criterion, opt)
local testLoss = 0
local confusionMatrix = optim.ConfusionMatrix(dataset.classes)
dataset:resetBatch("test")
confusionMatrix:zero()
repeat
x, t = dataset:updateBatch("test")
prediction = model:forward(x)
testLoss = testLoss + criterion:forward(model:forward(x), t)
for i = 1,dataset.batchSize do
confusionMatrix:add(prediction[i], t[i])
end
until dataset.epochFinished
testLoss = testLoss / dataset.testNo
print("----------------------------------------")
print("Loss on test dataset: " .. testLoss)
print(confusionMatrix)
print("----------------------------------------")
end
return evaluate
| mit |
erfan1292/sezar3 | plugins/export_gban.lua | 82 | 2310 | --------------------------------------------------
-- ____ ____ _____ --
-- | \| _ )_ _|___ ____ __ __ --
-- | |_ ) _ \ | |/ ·__| _ \_| \/ | --
-- |____/|____/ |_|\____/\_____|_/\/\_| --
-- --
--------------------------------------------------
-- --
-- Developers: @Josepdal & @MaSkAoS --
-- Support: @Skneos, @iicc1 & @serx666 --
-- --
--------------------------------------------------
local function run(msg, matches)
if permissions(msg.from.id, msg.to.id, "export_gban") then
if matches[1] == 'gbans' then
local receiver = get_receiver(msg)
if matches[2] == 'installer' then
local text = 'local function run(msg)\nif permissions(msg.from.id, msg.to.id, "gban_installer") then\n'
local count = 0
for v,user in pairs(_gbans.gbans_users) do
text = text..'gban_id('..user..')\n'
count = count + 1
end
local text = text..[[
if msg.to.type == 'chat' then
send_msg('chat#id'..msg.to.id, ']]..count..' '..lang_text(msg.to.id, 'accountsGban')..[[ ☠', ok_cb, false)
elseif msg.to.type == 'channel' then
send_msg('channel#id'..msg.to.id, ']]..count..' '..lang_text(msg.to.id, 'accountsGban')..[[ ☠', ok_cb, false)
end
else
return '🚫 '..lang_text(msg.to.id, 'require_sudo')
end
end
return {
description = 'Add gbans into your bot. A gbanlist command.',
usage = {},
patterns = {
"^#(install) (gbans)$"
},
run = run
}
]]
local file = io.open("./plugins/gban_installer.lua", "w")
file:write(text)
file:close()
send_document(receiver, './plugins/gban_installer.lua', ok_cb, false)
elseif matches[2] == 'list' then
send_document(receiver, './data/gbans.lua', ok_cb, false)
end
end
else
return '🚫 '..lang_text(msg.to.id, 'require_admin')
end
end
return {
patterns = {
"^#(gbans) (.*)$"
},
run = run
}
| gpl-2.0 |
sundream/gamesrv | script/test/test_war2.lua | 1 | 2197 | local skynet = require "skynet"
require "script.playermgr"
require "script.net.war"
require "script.war.auxilary"
local function test(pid1,pid2,race1,cardrace1,race2,cardrace2)
local player1 = playermgr.getplayer(pid1)
local player2 = playermgr.getplayer(pid2)
player1.cardlib:clear()
player1.cardtablelib:clear()
player2.cardlib:clear()
player2.cardtablelib:clear()
local cardsids = {}
local name = string.format("种族:%d",cardrace1)
local cardsids1 = getcards(name,function (cardcls)
return cardcls.race == cardrace1
end)
local name = string.format("种族:%d",cardrace2)
local cardsids2 = getcards(name,function (cardcls)
return cardcls.race == cardrace2
end)
for i,cardsid in ipairs(cardsids1) do
player1.cardlib:addcardbysid(cardsid,1,"test")
end
for i,cardsid in ipairs(cardsids2) do
player2.cardlib:addcardbysid(cardsid,1,"test")
end
local mode = CARDTABLE_MODE_NORMAL
local cardtable1 = {
race = race1,
name = "test",
cards = cardsids1,
}
local cardtable2 = {
race = race2,
name = "test",
cards = cardsids2,
}
pprintf("pid=%s cardtable=%s",pid1,cardtable1)
pprintf("pid=%s cardtable=%s",pid2,cardtable2)
player1.cardtablelib:addcardtable("fight",cardtable1,"test")
player2.cardtablelib:addcardtable("fight",cardtable2,"test")
netwar.REQUEST.unsearch_opponent(player1,{
type = "fight",
})
netwar.REQUEST.unsearch_opponent(player2,{
type = "fight",
})
netwar.REQUEST.selectcardtable(player1,{
type = "fight",
cardtableid = cardtable1.id,
})
netwar.REQUEST.selectcardtable(player2,{
type = "fight",
cardtableid = cardtable2.id,
})
netwar.REQUEST.search_opponent(player1,{
type = "fight",
})
netwar.REQUEST.search_opponent(player2,{
type = "fight",
})
skynet.sleep(200)
local warid = assert(player1:query("fight.warid"))
local warsrvname = assert(player1:query("fight.warsrvname"))
print("startwar",warsrvname,pid1,pid2,warid)
cluster.call(warsrvname,"modmethod","war.ai",".inject_ai",warid,pid1)
cluster.call(warsrvname,"modmethod","war.ai",".inject_ai",warid,pid2)
netwar.REQUEST.confirm_handcard(player1,{
ids = {},
})
netwar.REQUEST.confirm_handcard(player2,{
ids = {},
})
end
return test
| gpl-2.0 |
FizzerWL/ExampleMods | GiftArmiesMod/Client_PresentMenuUI.lua | 1 | 2774 | require('Utilities');
function Client_PresentMenuUI(rootParent, setMaxSize, setScrollable, game)
Game = game;
SubmitBtn = nil;
setMaxSize(450, 280);
vert = UI.CreateVerticalLayoutGroup(rootParent);
if (game.Us == nil) then
UI.CreateLabel(vert).SetText("You cannot gift armies since you're not in the game");
return;
end
local row1 = UI.CreateHorizontalLayoutGroup(vert);
UI.CreateLabel(row1).SetText("Gift armies to this player: ");
TargetPlayerBtn = UI.CreateButton(row1).SetText("Select player...").SetOnClick(TargetPlayerClicked);
local row2 = UI.CreateHorizontalLayoutGroup(vert);
UI.CreateLabel(row2).SetText("Gift armies from this territory: ");
TargetTerritoryBtn = UI.CreateButton(row2).SetText("Select source territory...").SetOnClick(TargetTerritoryClicked);
end
function TargetPlayerClicked()
local players = filter(Game.Game.Players, function (p) return p.ID ~= Game.Us.ID end);
local options = map(players, PlayerButton);
UI.PromptFromList("Select the player you'd like to give armies to", options);
end
function PlayerButton(player)
local name = player.DisplayName(nil, false);
local ret = {};
ret["text"] = name;
ret["selected"] = function()
TargetPlayerBtn.SetText(name);
TargetPlayerID = player.ID;
end
return ret;
end
function TargetTerritoryClicked()
local options = map(filter(Game.LatestStanding.Territories, function(t) return t.OwnerPlayerID == Game.Us.ID end), TerritoryButton);
UI.PromptFromList("Select the territory you'd like to take armies from", options);
end
function TerritoryButton(terr)
local name = Game.Map.Territories[terr.ID].Name;
local ret = {};
ret["text"] = name;
ret["selected"] = function()
TargetTerritoryBtn.SetText(name);
TargetTerritoryID = terr.ID;
CheckCreateFinalStep();
end
return ret;
end
function CheckCreateFinalStep()
if (SubmitBtn == nil) then
local row3 = UI.CreateHorizontalLayoutGroup(vert);
UI.CreateLabel(row3).SetText("How many armies would you like to gift: ");
NumArmiesInput = UI.CreateNumberInputField(row3).SetSliderMinValue(1);
SubmitBtn = UI.CreateButton(vert).SetText("Gift").SetOnClick(SubmitClicked);
end
local maxArmies = Game.LatestStanding.Territories[TargetTerritoryID].NumArmies.NumArmies;
NumArmiesInput.SetSliderMaxValue(maxArmies).SetValue(maxArmies);
end
function SubmitClicked()
local msg = 'Gifting ' .. NumArmiesInput.GetValue() .. ' armies from ' .. Game.Map.Territories[TargetTerritoryID].Name .. ' to ' .. Game.Game.Players[TargetPlayerID].DisplayName(nil, false);
local payload = 'GiftArmies_' .. NumArmiesInput.GetValue() .. ',' .. TargetTerritoryID .. ',' .. TargetPlayerID;
local orders = Game.Orders;
table.insert(orders, WL.GameOrderCustom.Create(Game.Us.ID, msg, payload));
Game.Orders = orders;
end | mit |
letmefly/skynet | gameserver/proto/prototext.lua | 1 | 9400 | local cjson = require "cjson"
local prototext = [[
message userInfo_t {
// player 1, 2, 3
optional string userId = 1;
optional string nickname = 2;
// 1 male or 2 female
optional int32 sexType = 3;
optional string iconUrl = 4;
optional int32 level = 5;
optional int32 roomCardNum = 6;
optional int32 playerId = 7;
optional int32 win = 8;
optional int32 lose = 9;
optional int32 score = 10;
optional string ip = 11;
optional int32 status = 12;
optional int32 isLandlord = 13;
optional int32 boom = 14;
optional int32 leftPoker = 15;
optional int32 hasPlay = 16;
optional int32 userno = 17;
optional int32 redPackVal = 18;
optional int32 score2 = 19;
optional string lastLoginTime = 20;
optional int32 todayRedPackCount = 21;
optional string lastRechargeDate = 22;
optional int32 loginDayCount = 23;
optional int32 rechargeVal = 24;
optional int32 totalGetRedPackVal = 25;
optional int32 todayRechargeVal = 26;
}
message handshake {
optional int32 sn = 1;
}
message clientHandshake {
optional int32 sn = 1;
}
message gameLogin {
optional string userId = 1;
optional string authCode = 2;
optional int32 version = 3;
}
message gameLogin_ack {
// 0 success, -1 auth code invalid, -2 version too low
optional int32 errno = 1;
optional userInfo_t userInfo = 2;
}
message createRoom {
// 3, or 4
optional int32 roomType = 1;
optional int32 playTimes = 2;
// 1 - roll mode, 2 - score mode
optional int32 grabMode = 3;
optional int32 maxBoom = 4;
optional int32 isFree = 5;
}
message createRoom_ack {
// 0 success, -1 room card not enough
optional int32 errno = 1;
optional string roomNo = 2;
}
message joinRoom {
optional string roomNo = 1;
}
message joinRoom_ack {
// 0 success, -1 room number invalid
optional int32 errno = 1;
optional int32 playerId = 2;
optional int32 currPlayTimes = 3;
optional int32 maxPlayTimes = 4;
optional int32 grabMode = 5;
optional int32 roomType = 6;
optional int32 maxBoom = 7;
}
message rejoinRoom {
optional string roomNo = 1;
optional int32 playerId = 2;
}
message rejoinRoom_ack {
optional int32 errno = 1;
}
message joinRoomOk {
optional int32 playerId = 1;
}
message joinRoomOk_ntf {
repeated userInfo_t userInfoList = 1;
optional int32 redpackPoolVal = 2;
}
message reJoinRoomOk_ack {
repeated userInfo_t userInfoList = 1;
repeated int32 pokerList = 2;
repeated int32 bottomList = 3;
optional int32 prevPlayerId = 4;
repeated int32 prevPlayPokerList = 5;
optional int32 currPlayTimes = 6;
optional int32 grabLevel = 7;
optional int32 redpackPoolVal = 8;
}
message leaveRoom {
// player 1, 2, 3
optional int32 playerId = 1;
}
message leaveRoom_ntf {
// player 1, 2, 3
optional int32 playerId = 1;
optional int32 t = 2;
}
// when client load res ok and switch to game screen,
// notify server that client is ready
message getReady {
optional int32 status = 1;
optional int32 playerId = 2;
}
message getReady_ntf {
repeated int32 readyList = 1;
}
message startGame {
optional int32 playerId = 1;
}
message startGame_ntf {
// 17 poker
repeated int32 pokerList = 1;
repeated int32 bottomList = 2;
optional int32 status = 3;
optional int32 currPlayTimes = 4;
}
message restartGame_ntf {
optional int32 errno = 1;
}
message whoGrabLandlord_ntf {
// player 1, 2, 3
optional int32 playerId = 1;
}
message alarmTimer_ntf {
// player 1, 2, 3
optional int32 playerId = 1;
optional int32 timerVal = 2;
optional string timerType = 3;
}
message stopAlarmTimer_ntf {
// player 1, 2, 3
optional int32 playerId = 1;
optional string timerType = 2;
}
message grabLandlord {
// player 1, 2, 3
optional int32 playerId = 1;
// 1, skip, 2 grab level 1, 3 grab level 2
optional int32 grabAction = 2;
}
message grabLandlord_ntf {
// player 1, 2, 3
optional int32 playerId = 1;
// 1, skip, 2 grab level 1, 3 grab level 2
optional int32 grabAction = 2;
optional int32 grabLevel = 3;
}
message landlord_ntf {
optional int32 playerId = 1;
repeated int32 bottomPokerList = 2;
}
// whose token for choosing poker
message whoPlay_ntf {
// player 1, 2, 3
optional int32 playerId = 1;
optional int32 prevPlayerId = 2;
}
message playPoker {
optional int32 playerId = 1;
// 1 skip, 2 play poker
optional int32 playAction = 2;
// 1 - single, 2 - pair, 3 - joker boom, 4 - 3poker, 5 - boom, 6 - 3+1,
// 7 - sequence, 8 - 4+2, 9 - pair sequence, 10 - airplane
optional int32 pokerType = 3;
repeated int32 pokerList = 4;
}
message playPoker_ntf {
// player 1, 2, 3
optional int32 playerId = 1;
// 1 skip, 2 grab landlord, 3 skip
optional int32 playAction = 2;
optional int32 pokerType = 3;
repeated int32 pokerList = 4;
optional int32 grabLevel = 5;
}
message playTimeout_ntf {
// player 1, 2, 3
optional int32 playerId = 1;
}
message lastPoker_ntf {
optional int32 playerId = 1;
// 2 or 1
optional int32 pokerNum = 2;
}
message chat {
optional int32 playerId = 1;
optional string t = 2;
optional string v = 3;
}
message chat_ntf {
optional int32 playerId = 1;
optional string t = 2;
optional string v = 3;
}
message gameResult_ntf {
//optional int32 totalFactor = 1;
//optional int32 visiblePokeFactor = 2;
//optional int32 grapLandlordFactor = 3;
//optional int32 boomFactor = 4;
//optional int32 springFactor = 5;
message GameResultInfo {
optional int32 playerId = 1;
// 1 lose, 2 win
optional int32 result = 2;
optional int32 leftPokerNum = 3;
optional int32 boomNum = 4;
optional int32 score = 5;
optional string nickname = 6;
optional int32 isSpring = 7;
optional int32 totalScore = 8;
}
message PokerList_t {
optional int32 playerId = 1;
repeated int32 pokerList = 2;
}
repeated GameResultInfo resultList = 1;
repeated PokerList_t allPlayerPokerSet = 2;
optional int32 redpackPoolVal = 3;
}
message roomResult_ntf {
message RoomResultItem_t {
optional int32 playerId = 1;
optional int32 totalBoom = 2;
optional int32 maxScore = 3;
optional int32 winTimes = 4;
optional int32 totalScore = 5;
optional string nickname = 6;
optional int32 loseTimes = 7;
}
repeated RoomResultItem_t roomResultList = 1;
}
message dismissRoom_ntf {
message DismissInfo_t {
optional int32 playerId = 1;
optional int32 result = 2;
}
repeated DismissInfo_t dismissInfoList = 1;
optional int32 whoDismiss = 2;
}
message dismissRoom {
optional int32 playerId = 1;
optional int32 result = 2; // 1 refuse, 2 agree
}
message scoreRaceGetRoomNo {
optional int32 maxPlayerNum = 1;
optional int32 coinType = 2;
}
message scoreRaceGetRoomNo_ack {
optional string roomNo = 1;
optional int32 errno = 2;
}
message redPackStart_ack {
optional int32 playerId = 1;
optional int32 redPackVal = 2;
optional int32 coinVal = 3;
}
message redPackOver_ack {
optional int32 playerId = 1;
}
message getRedPack {
optional int32 playerId = 1;
}
message getRedPack_ack {
optional int32 result = 1;
optional int32 redPackVal = 2;
optional int32 coinVal = 3;
}
message changeRoom {
optional int32 playerId = 1;
optional int32 maxPlayerNum = 2;
optional int32 coinType = 3;
}
message changeRoom_ack {
optional string roomNo = 1;
optional int32 errno = 2;
}
]]
local type2name_json = [[
{
"1": "handshake",
"2": "gameLogin",
"3": "gameLogin_ack",
"4": "createRoom",
"5": "createRoom_ack",
"6": "joinRoom",
"7": "joinRoom_ack",
"8": "leaveRoom",
"9": "leaveRoom_ntf",
"10": "getReady",
"11": "getReady_ntf",
"12": "startGame_ntf",
"13": "restartGame_ntf",
"14": "whoGrabLandlord_ntf",
"15": "grabLandlord_ntf",
"16": "landlord_ntf",
"17": "grabLandlord",
"18": "whoPlay_ntf",
"19": "playPoker",
"20": "playPoker_ntf",
"21": "playTimeout_ntf",
"22": "lastPoker_ntf",
"23": "chat",
"24": "chat_ntf",
"25": "gameResult_ntf",
"26": "roomResult_ntf",
"27": "joinRoomOk_ntf",
"28": "joinRoomOk",
"29": "alarmTimer_ntf",
"30": "stopAlarmTimer_ntf",
"31": "reJoinRoomOk_ack",
"32": "clientHandshake",
"33": "dismissRoom_ntf",
"34": "dismissRoom",
"35": "scoreRaceGetRoomNo",
"36": "scoreRaceGetRoomNo_ack",
"37": "redPackStart_ack",
"38": "redPackOver_ack",
"39": "getRedPack",
"40": "getRedPack_ack",
"41": "changeRoom",
"42": "changeRoom_ack"
}
]]
local errno2desp_json = [[
{
"1000": "用户已存在",
"1001": "数据库错误",
"1002": "用户名或者密码错误",
"2000": "好友已存在"
}
]]
PROTO_TYPE2NAME = {}
local type2name = cjson.decode(type2name_json)
for k, v in pairs(type2name) do
PROTO_TYPE2NAME[tonumber(k)] = v
end
-- PROTO_TYPE2NAME = {
-- [1] = "user_register",
-- [2] = "user_register_ack",
-- [3] = "user_login",
-- [4] = "user_login_ack",
-- [5] = "handshake"
-- }
return prototext | mit |
ealegol/kolla-newton | docker/heka/plugins/decoders/os_horizon_apache_log.lua | 6 | 2256 | -- Copyright 2015 Mirantis, Inc.
--
-- 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 l = require 'lpeg'
l.locale(l)
local common_log_format = require 'common_log_format'
local patt = require 'os_patterns'
local utils = require 'os_utils'
local msg = {
Timestamp = nil,
Type = 'log',
Hostname = nil,
Payload = nil,
Pid = nil,
Fields = nil,
Severity = 6,
}
local severity_label = utils.severity_to_label_map[msg.Severity]
local apache_log_pattern = read_config("apache_log_pattern") or error(
"apache_log_pattern configuration must be specificed")
local apache_grammar = common_log_format.build_apache_grammar(apache_log_pattern)
local request_grammar = l.Ct(patt.http_request)
function process_message ()
-- logger is either "horizon-apache-public" or "horizon-apache-admin"
local logger = read_message("Logger")
local log = read_message("Payload")
local m
m = apache_grammar:match(log)
if m then
msg.Logger = 'openstack.horizon'
msg.Payload = log
msg.Timestamp = m.time
msg.Fields = {}
msg.Fields.http_status = m.status
msg.Fields.http_response_time = m.request_time.value / 1e6 -- us to sec
msg.Fields.programname = logger
msg.Fields.severity_label = severity_label
local request = m.request
m = request_grammar:match(request)
if m then
msg.Fields.http_method = m.http_method
msg.Fields.http_url = m.http_url
msg.Fields.http_version = m.http_version
end
return utils.safe_inject_message(msg)
end
return -1, string.format("Failed to parse %s log: %s", logger, string.sub(log, 1, 64))
end
| apache-2.0 |
ElectricPrism/stargus | scripts/protoss/unit-protoss-photon-cannon.lua | 1 | 14227 | DefineAnimations("animations-protoss-photon-cannon", {
Still = {
"frame 0", "wait 125",
},
Attack = {
"unbreakable begin", "frame 2", "wait 2", "frame 1", "wait 2", "frame 3", "wait 2", "sound protoss-photon-cannon-attack", "attack",
"unbreakable end", "wait 5",
},
})
DefineConstruction("construction-protoss-photon-cannon", {
Files = {
File = "zerg/units/building morph.png",
Size = {160, 192}},
ShadowFiles = {
File = "zerg/units/building morph shadow.png",
Size = {160, 192}},
Constructions = {
{Percent = 0,
File = "construction",
Frame = 0},
{Percent = .5,
File = "construction",
Frame = 1},
{Percent = 2,
File = "construction",
Frame = 7},
{Percent = 1.5,
File = "construction",
Frame = 8},
{Percent = 2,
File = "construction",
Frame = 7},
{Percent = 2.5,
File = "construction",
Frame = 8},
{Percent = 3,
File = "construction",
Frame = 9},
{Percent = 3.5,
File = "construction",
Frame = 8},
{Percent = 4,
File = "construction",
Frame = 7},
{Percent = 4.5,
File = "construction",
Frame = 8},
{Percent = 5,
File = "construction",
Frame = 9},
{Percent = 5.5,
File = "construction",
Frame = 8},
{Percent = 6,
File = "construction",
Frame = 7},
{Percent = 6.5,
File = "construction",
Frame = 8},
{Percent = 7,
File = "construction",
Frame = 9},
{Percent = 7.5,
File = "construction",
Frame = 8},
{Percent = 8,
File = "construction",
Frame = 7},
{Percent = 8.5,
File = "construction",
Frame = 8},
{Percent = 9,
File = "construction",
Frame = 9},
{Percent = 9.5,
File = "construction",
Frame = 8},
{Percent = 10,
File = "construction",
Frame = 9},
{Percent = 10.5,
File = "construction",
Frame = 8},
{Percent = 11,
File = "construction",
Frame = 7},
{Percent = 11.5,
File = "construction",
Frame = 8},
{Percent = 12,
File = "construction",
Frame = 9},
{Percent = 13.5,
File = "construction",
Frame = 8},
{Percent = 14,
File = "construction",
Frame = 7},
{Percent = 14.5,
File = "construction",
Frame = 8},
{Percent = 15,
File = "construction",
Frame = 9},
{Percent = 15.5,
File = "construction",
Frame = 8},
{Percent = 16,
File = "construction",
Frame = 7},
{Percent = 16.5,
File = "construction",
Frame = 8},
{Percent = 17.5,
File = "construction",
Frame = 9},
{Percent = 18.5,
File = "construction",
Frame = 8},
{Percent = 19.5,
File = "construction",
Frame = 7},
{Percent = 20,
File = "construction",
Frame = 8},
{Percent = 20.5,
File = "construction",
Frame = 9},
{Percent = 21,
File = "construction",
Frame = 8},
{Percent = 21.5,
File = "construction",
Frame = 7},
{Percent = 22,
File = "construction",
Frame = 8},
{Percent = 22.5,
File = "construction",
Frame = 9},
{Percent = 23,
File = "construction",
Frame = 8},
{Percent = 23.5,
File = "construction",
Frame = 7},
{Percent = 24,
File = "construction",
Frame = 8},
{Percent = 24.5,
File = "construction",
Frame = 9},
{Percent = 25,
File = "construction",
Frame = 8},
{Percent = 25.5,
File = "construction",
Frame = 7},
{Percent = 26,
File = "construction",
Frame = 8},
{Percent = 26.5,
File = "construction",
Frame = 9},
{Percent = 27,
File = "construction",
Frame = 8},
{Percent = 27.5,
File = "construction",
Frame = 7},
{Percent = 28,
File = "construction",
Frame = 8},
{Percent = 28.5,
File = "construction",
Frame = 7},
{Percent = 29,
File = "construction",
Frame = 8},
{Percent = 29.5,
File = "construction",
Frame = 9},
{Percent = 30,
File = "construction",
Frame = 8},
{Percent = 30.5,
File = "construction",
Frame = 7},
{Percent = 31,
File = "construction",
Frame = 8},
{Percent = 31.5,
File = "construction",
Frame = 9},
{Percent = 32,
File = "construction",
Frame = 8},
{Percent = 32.5,
File = "construction",
Frame = 7},
{Percent = 33,
File = "construction",
Frame = 8},
{Percent = 33.5,
File = "construction",
Frame = 9},
{Percent = 34,
File = "construction",
Frame = 8},
{Percent = 34.5,
File = "construction",
Frame = 7},
{Percent = 35,
File = "construction",
Frame = 8},
{Percent = 35.5,
File = "construction",
Frame = 9},
{Percent = 36,
File = "construction",
Frame = 8},
{Percent = 36.5,
File = "construction",
Frame = 9},
{Percent = 37,
File = "construction",
Frame = 8},
{Percent = 37.5,
File = "construction",
Frame = 7},
{Percent = 38,
File = "construction",
Frame = 8},
{Percent = 38.5,
File = "construction",
Frame = 9},
{Percent = 39,
File = "construction",
Frame = 8},
{Percent = 39.5,
File = "construction",
Frame = 7},
{Percent = 40,
File = "construction",
Frame = 8},
{Percent = 40.5,
File = "construction",
Frame = 9},
{Percent = 41,
File = "construction",
Frame = 8},
{Percent = 41.5,
File = "construction",
Frame = 7},
{Percent = 42,
File = "construction",
Frame = 8},
{Percent = 42.5,
File = "construction",
Frame = 9},
{Percent = 43,
File = "construction",
Frame = 8},
{Percent = 43.5,
File = "construction",
Frame = 7},
{Percent = 44,
File = "construction",
Frame = 8},
{Percent = 44.5,
File = "construction",
Frame = 9},
{Percent = 45,
File = "construction",
Frame = 8},
{Percent = 45.5,
File = "construction",
Frame = 7},
{Percent = 46,
File = "construction",
Frame = 8},
{Percent = 46.5,
File = "construction",
Frame = 9},
{Percent = 47,
File = "construction",
Frame = 8},
{Percent = 47.5,
File = "construction",
Frame = 7},
{Percent = 48,
File = "construction",
Frame = 8},
{Percent = 48.5,
File = "construction",
Frame = 9},
{Percent = 49,
File = "construction",
Frame = 8},
{Percent = 49.5,
File = "construction",
Frame = 7},
{Percent = 50,
File = "construction",
Frame = 8},
{Percent = 50.5,
File = "construction",
Frame = 9},
{Percent = 51,
File = "construction",
Frame = 8},
{Percent = 51.5,
File = "construction",
Frame = 7},
{Percent = 52,
File = "construction",
Frame = 8},
{Percent = 52.5,
File = "construction",
Frame = 7},
{Percent = 53,
File = "construction",
Frame = 8},
{Percent = 53.5,
File = "construction",
Frame = 9},
{Percent = 54,
File = "construction",
Frame = 8},
{Percent = 54.5,
File = "construction",
Frame = 7},
{Percent = 55,
File = "construction",
Frame = 8},
{Percent = 55.5,
File = "construction",
Frame = 9},
{Percent = 56,
File = "construction",
Frame = 8},
{Percent = 56.5,
File = "construction",
Frame = 7},
{Percent = 57,
File = "construction",
Frame = 8},
{Percent = 58.5,
File = "construction",
Frame = 9},
{Percent = 59,
File = "construction",
Frame = 8},
{Percent = 59.5,
File = "construction",
Frame = 7},
{Percent = 60,
File = "construction",
Frame = 8},
{Percent = 60.5,
File = "construction",
Frame = 9},
{Percent = 61,
File = "construction",
Frame = 8},
{Percent = 61.5,
File = "construction",
Frame = 9},
{Percent = 62,
File = "construction",
Frame = 8},
{Percent = 62.5,
File = "construction",
Frame = 7},
{Percent = 63,
File = "construction",
Frame = 8},
{Percent = 63.5,
File = "construction",
Frame = 9},
{Percent = 64,
File = "construction",
Frame = 8},
{Percent = 64.5,
File = "construction",
Frame = 7},
{Percent = 65,
File = "construction",
Frame = 8},
{Percent = 65.5,
File = "construction",
Frame = 9},
{Percent = 66,
File = "construction",
Frame = 8},
{Percent = 66.5,
File = "construction",
Frame = 7},
{Percent = 67,
File = "construction",
Frame = 8},
{Percent = 67.5,
File = "construction",
Frame = 9},
{Percent = 68,
File = "construction",
Frame = 8},
{Percent = 68.5,
File = "construction",
Frame = 7},
{Percent = 69,
File = "construction",
Frame = 8},
{Percent = 69.5,
File = "construction",
Frame = 9},
{Percent = 67,
File = "construction",
Frame = 8},
{Percent = 67.5,
File = "construction",
Frame = 7},
{Percent = 68,
File = "construction",
Frame = 8},
{Percent = 68.5,
File = "construction",
Frame = 9},
{Percent = 69,
File = "construction",
Frame = 8},
{Percent = 69.5,
File = "construction",
Frame = 7},
{Percent = 70,
File = "construction",
Frame = 8},
{Percent = 70.5,
File = "construction",
Frame = 9},
{Percent = 71,
File = "construction",
Frame = 8},
{Percent = 71.5,
File = "construction",
Frame = 7},
{Percent = 72,
File = "construction",
Frame = 8},
{Percent = 72.5,
File = "construction",
Frame = 9},
{Percent = 73,
File = "construction",
Frame = 8},
{Percent = 73.5,
File = "construction",
Frame = 7},
{Percent = 74,
File = "construction",
Frame = 8},
{Percent = 74.5,
File = "construction",
Frame = 7},
{Percent = 75,
File = "construction",
Frame = 8},
{Percent = 75.5,
File = "construction",
Frame = 9},
{Percent = 76,
File = "construction",
Frame = 8},
{Percent = 76.5,
File = "construction",
Frame = 7},
{Percent = 77,
File = "construction",
Frame = 8},
{Percent = 77.5,
File = "construction",
Frame = 9},
{Percent = 78,
File = "construction",
Frame = 8},
{Percent = 78.5,
File = "construction",
Frame = 7},
{Percent = 79,
File = "construction",
Frame = 8},
{Percent = 79.5,
File = "construction",
Frame = 9},
{Percent = 80,
File = "construction",
Frame = 8},
{Percent = 80.5,
File = "construction",
Frame = 7},
{Percent = 81,
File = "construction",
Frame = 8},
{Percent = 81.5,
File = "construction",
Frame = 9},
{Percent = 82,
File = "construction",
Frame = 8},
{Percent = 82.5,
File = "construction",
Frame = 9},
{Percent = 83,
File = "construction",
Frame = 7},
{Percent = 83.5,
File = "construction",
Frame = 8},
{Percent = 84,
File = "construction",
Frame = 9},
{Percent = 84.5,
File = "construction",
Frame = 8},
{Percent = 85,
File = "construction",
Frame = 7},
{Percent = 85.5,
File = "construction",
Frame = 8},
{Percent = 86,
File = "construction",
Frame = 9},
{Percent = 86.5,
File = "construction",
Frame = 8},
{Percent = 87,
File = "construction",
Frame = 7},
{Percent = 87.5,
File = "construction",
Frame = 8},
{Percent = 88,
File = "construction",
Frame = 9},
{Percent = 88.5,
File = "construction",
Frame = 8},
{Percent = 89,
File = "construction",
Frame = 7},
{Percent = 89.5,
File = "construction",
Frame = 8},
{Percent = 90,
File = "construction",
Frame = 9},
{Percent = 90.5,
File = "construction",
Frame = 8},
{Percent = 91,
File = "construction",
Frame = 7},
{Percent = 91.5,
File = "construction",
Frame = 8},
{Percent = 92,
File = "construction",
Frame = 9},
{Percent = 92.5,
File = "construction",
Frame = 8},
{Percent = 93,
File = "construction",
Frame = 7},
{Percent = 93.5,
File = "construction",
Frame = 8},
{Percent = 94,
File = "construction",
Frame = 9},
{Percent = 94.5,
File = "construction",
Frame = 8},
{Percent = 95,
File = "construction",
Frame = 7},
{Percent = 95.5,
File = "construction",
Frame = 8},
{Percent = 96,
File = "construction",
Frame = 9},
{Percent = 96.5,
File = "construction",
Frame = 8},
{Percent = 97,
File = "construction",
Frame = 7},
{Percent = 97.5,
File = "construction",
Frame = 8},
{Percent = 98,
File = "construction",
Frame = 8},
{Percent = 98.5,
File = "construction",
Frame = 8},
{Percent = 99,
File = "construction",
Frame = 8},
{Percent = 99.5,
File = "construction",
Frame = 8},
}
})
DefineUnitType("unit-protoss-photon-cannon", { Name = "Photon Canon",
Image = {"file", "protoss/units/photon cannon.png", "size", {64, 128}},
Shadow = {"file", "protoss/units/ppbshad.png", "size", {64, 128}},
Animations = "animations-protoss-photon-cannon", Icon = "icon-terran-bunker",
Costs = {"time", 200, "minerals", 150},
RepairHp = 4,
RepairCosts = {"minerals", 1, "gas", 1},
Construction = "construction-protoss-photon-cannon",
Speed = 0,
HitPoints = 200,
DrawLevel = 30,
TileSize = {2, 2}, BoxSize = {63, 63},
SightRange = 7, ComputerReactionRange = 6, PersonReactionRange = 4,
Armor = 20, BasicDamage = 20, PiercingDamage = 5, Missile = "missile-none",
Priority = 15, AnnoyComputerFactor = 20,
MaxAttackRange = 7,
Points = 170,
--[[Corpse = "unit-destroyed-3x3-place",
ExplodeWhenKilled = "missile-terran-explosion-large",--]]
Type = "land",
RightMouseAction = "attack",
BuilderOutside = true,
AutoBuildRate = 30,
CanAttack = true,
CanTargetLand = true,
Building = true, VisibleUnderFog = true,
BuildingRules = { { "distance", { Distance = 3, DistanceType = "<", Type = "unit-protoss-pylon"} } },
Sounds = {
"selected", "protoss-photon-cannon-selected",
"ready", "protoss-building-ready",
"help", "protoss-base-attacked",
"dead", "protoss-building-blowup"} } )
| gpl-2.0 |
sundream/gamesrv | script/card/fire/card243003.lua | 1 | 2300 | --<<card 导表开始>>
local super = require "script.card.fire.card143003"
ccard243003 = class("ccard243003",super,{
sid = 243003,
race = 4,
name = "照明弹",
type = 101,
magic_immune = 0,
assault = 0,
sneer = 0,
atkcnt = 0,
shield = 0,
warcry = 0,
dieeffect = 0,
sneak = 0,
magic_hurt_adden = 0,
cure_to_hurt = 0,
recoverhp_multi = 1,
magic_hurt_multi = 1,
max_amount = 2,
composechip = 100,
decomposechip = 10,
atk = 0,
maxhp = 0,
crystalcost = 1,
targettype = 0,
halo = nil,
desc = "使所有随从失去潜行效果。摧毁敌方所有奥秘。抽1张牌。",
effect = {
onuse = {pickcard={num=1}},
ondie = nil,
onhurt = nil,
onrecoverhp = nil,
onbeginround = nil,
onendround = nil,
ondelsecret = nil,
onputinwar = nil,
onremovefromwar = nil,
onaddweapon = nil,
onputinhand = nil,
before_die = nil,
after_die = nil,
before_hurt = nil,
after_hurt = nil,
before_recoverhp = nil,
after_recoverhp = nil,
before_beginround = nil,
after_beginround = nil,
before_endround = nil,
after_endround = nil,
before_attack = nil,
after_attack = nil,
before_playcard = nil,
after_playcard = nil,
before_putinwar = nil,
after_putinwar = nil,
before_removefromwar = nil,
after_removefromwar = nil,
before_addsecret = nil,
after_addsecret = nil,
before_delsecret = nil,
after_delsecret = nil,
before_addweapon = nil,
after_addweapon = nil,
before_delweapon = nil,
after_delweapon = nil,
before_putinhand = nil,
after_putinhand = nil,
before_removefromhand = nil,
after_removefromhand = nil,
},
})
function ccard243003:init(conf)
super.init(self,conf)
--<<card 导表结束>>
end --导表生成
function ccard243003:load(data)
if not data or not next(data) then
return
end
super.load(self,data)
-- todo: load data
end
function ccard243003:save()
local data = super.save(self)
-- todo: save data
return data
end
return ccard243003
| gpl-2.0 |
padrinoo1/vagir2 | plugins/inrealm.lua | 287 | 25005 | -- 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 'Group [ '..string.gsub(group_name, '_', ' ')..' ] has been created.'
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 'Realm [ '..string.gsub(group_name, '_', ' ')..' ] has been created.'
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 "For admins 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 set_rules(msg, data, target)
if not is_admin(msg) then
return "For admins 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
-- 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 "For admins 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_name(msg, data, target)
if not is_admin(msg) then
return "For admins 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
--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 "For admins 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_member(msg, data, target)
if not is_admin(msg) then
return "For admins 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
--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 "For admins only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'yes' then
return 'Group photo is already locked'
else
data[tostring(target)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
end
return 'Please send me the group photo now'
end
local function unlock_group_photo(msg, data, target)
if not is_admin(msg) then
return "For admins 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 lock_group_flood(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
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_flood(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
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
-- 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 "For admins only!"
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
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
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
send_large_msg(receiver, text)
local file = io.open("./groups/lists/"..result.id.."memberlist.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
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
local file = io.open("./groups/lists/"..result.id.."memberlist.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 |
sundream/gamesrv | script/card/neutral/card164017.lua | 1 | 2447 | --<<card 导表开始>>
local super = require "script.card.init"
ccard164017 = class("ccard164017",super,{
sid = 164017,
race = 6,
name = "苦痛寺僧",
type = 201,
magic_immune = 0,
assault = 0,
sneer = 0,
atkcnt = 1,
shield = 0,
warcry = 0,
dieeffect = 0,
sneak = 0,
magic_hurt_adden = 0,
cure_to_hurt = 0,
recoverhp_multi = 1,
magic_hurt_multi = 1,
max_amount = 2,
composechip = 100,
decomposechip = 10,
atk = 1,
maxhp = 3,
crystalcost = 3,
targettype = 0,
halo = nil,
desc = "每当该随从受到伤害时,抽一张牌。",
effect = {
onuse = nil,
ondie = nil,
onhurt = {pickcard={num=1}},
onrecoverhp = nil,
onbeginround = nil,
onendround = nil,
ondelsecret = nil,
onputinwar = nil,
onremovefromwar = nil,
onaddweapon = nil,
onputinhand = nil,
before_die = nil,
after_die = nil,
before_hurt = nil,
after_hurt = nil,
before_recoverhp = nil,
after_recoverhp = nil,
before_beginround = nil,
after_beginround = nil,
before_endround = nil,
after_endround = nil,
before_attack = nil,
after_attack = nil,
before_playcard = nil,
after_playcard = nil,
before_putinwar = nil,
after_putinwar = nil,
before_removefromwar = nil,
after_removefromwar = nil,
before_addsecret = nil,
after_addsecret = nil,
before_delsecret = nil,
after_delsecret = nil,
before_addweapon = nil,
after_addweapon = nil,
before_delweapon = nil,
after_delweapon = nil,
before_putinhand = nil,
after_putinhand = nil,
before_removefromhand = nil,
after_removefromhand = nil,
},
})
function ccard164017:init(conf)
super.init(self,conf)
--<<card 导表结束>>
end --导表生成
function ccard164017:load(data)
if not data or not next(data) then
return
end
super.load(self,data)
-- todo: load data
end
function ccard164017:save()
local data = super.save(self)
-- todo: save data
return data
end
function ccard164017:onhurt(hurtval,srcid)
local owner = self:getowner()
local num = ccard164017.effect.onhurt.pickcard.num
for i=1,num do
owner:pickcard_and_putinhand()
end
end
return ccard164017
| gpl-2.0 |
rastin45/waqer12 | plugins/groupmanager.lua | 14 | 16172 | -- data saved to data/moderation.json
do
local function gpadd(msg)
-- because sudo are always has privilege
if not is_sudo(msg) then
return nil
end
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
return 'Group is already added.'
end
-- create data array in moderation.json
data[tostring(msg.to.id)] = {
moderators ={},
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_bots = 'no',
lock_name = 'no',
lock_photo = 'no',
lock_member = 'no',
anti_flood = 'no',
welcome = 'no'
}
}
save_data(_config.moderation.data, data)
return 'Group has been added.'
end
local function gprem(msg)
-- because sudo are always has privilege
if not is_sudo(msg) then
return nil
end
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if not data[tostring(msg.to.id)] then
return 'Group is not added.'
end
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
return 'Group has been removed'
end
local function export_chat_link_callback(extra, success, result)
local receiver = extra.receiver
local data = extra.data
local chat_id = extra.chat_id
local group_name = extra.group_name
if success == 0 then
return send_large_msg(receiver, "Can't generate invite link for this group.\nMake sure you're the admin or sudoer.")
end
data[tostring(chat_id)]['link'] = result
save_data(_config.moderation.data, data)
return send_large_msg(receiver,'Newest generated invite link for '..group_name..' is:\n'..result)
end
local function set_description(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local data_cat = 'description'
data[tostring(msg.to.id)][data_cat] = deskripsi
save_data(_config.moderation.data, data)
return 'Set group description to:\n'..deskripsi
end
local function get_description(msg, data)
local data_cat = 'description'
if not data[tostring(msg.to.id)][data_cat] then
return 'No description available.'
end
local about = data[tostring(msg.to.id)][data_cat]
return string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about
end
local function set_rules(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local data_cat = 'rules'
data[tostring(msg.to.id)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..rules
end
local function get_rules(msg, data)
local data_cat = 'rules'
if not data[tostring(msg.to.id)][data_cat] then
return 'No rules available.'
end
local rules = data[tostring(msg.to.id)][data_cat]
local rules = string.gsub(msg.to.print_name, '_', ' ')..' rules:\n\n'..rules
return rules
end
-- dis/allow APIs bots to enter group. Spam prevention.
local function allow_api_bots(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_bot_lock = data[tostring(msg.to.id)]['settings']['lock_bots']
if group_bot_lock == 'no' then
return 'Bots allowed to enter group.'
else
data[tostring(msg.to.id)]['settings']['lock_bots'] = 'no'
save_data(_config.moderation.data, data)
return 'Group is open for bots.'
end
end
local function disallow_api_bots(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_bot_lock = data[tostring(msg.to.id)]['settings']['lock_bots']
if group_bot_lock == 'yes' then
return 'Group already locked from bots.'
else
data[tostring(msg.to.id)]['settings']['lock_bots'] = 'yes'
save_data(_config.moderation.data, data)
return 'Group is locked from bots.'
end
end
-- lock/unlock group name. bot automatically change group name when locked
local function lock_group_name(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(msg.to.id)]['settings']['set_name']
local group_name_lock = data[tostring(msg.to.id)]['settings']['lock_name']
if group_name_lock == 'yes' then
return 'Group name is already locked'
else
data[tostring(msg.to.id)]['settings']['lock_name'] = 'yes'
save_data(_config.moderation.data, data)
data[tostring(msg.to.id)]['settings']['set_name'] = string.gsub(msg.to.print_name, '_', ' ')
save_data(_config.moderation.data, data)
return 'Group name has been locked'
end
end
local function unlock_group_name(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(msg.to.id)]['settings']['set_name']
local group_name_lock = data[tostring(msg.to.id)]['settings']['lock_name']
if group_name_lock == 'no' then
return 'Group name is already unlocked'
else
data[tostring(msg.to.id)]['settings']['lock_name'] = 'no'
save_data(_config.moderation.data, data)
return 'Group name has been unlocked'
end
end
--lock/unlock group member. bot automatically kick new added user when locked
local function lock_group_member(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(msg.to.id)]['settings']['lock_member']
if group_member_lock == 'yes' then
return 'Group members are already locked'
else
data[tostring(msg.to.id)]['settings']['lock_member'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group members has been locked'
end
local function unlock_group_member(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(msg.to.id)]['settings']['lock_member']
if group_member_lock == 'no' then
return 'Group members are not locked'
else
data[tostring(msg.to.id)]['settings']['lock_member'] = 'no'
save_data(_config.moderation.data, data)
return 'Group members has been unlocked'
end
end
--lock/unlock group photo. bot automatically keep group photo when locked
local function lock_group_photo(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_photo_lock = data[tostring(msg.to.id)]['settings']['lock_photo']
if group_photo_lock == 'yes' then
return 'Group photo is already locked'
else
data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
end
return 'Please send me the group photo now'
end
local function unlock_group_photo(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local group_photo_lock = data[tostring(msg.to.id)]['settings']['lock_photo']
if group_photo_lock == 'no' then
return 'Group photo is not locked'
else
data[tostring(msg.to.id)]['settings']['lock_photo'] = 'no'
save_data(_config.moderation.data, data)
return 'Group photo has been unlocked'
end
end
local function set_group_photo(msg, success, result)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if success then
local file = 'data/photos/chat_photo_'..msg.to.id..'.jpg'
print('File downloaded to:', result)
os.rename(result, file)
print('File moved to:', file)
chat_set_photo (receiver, file, ok_cb, false)
data[tostring(msg.to.id)]['settings']['set_photo'] = file
save_data(_config.moderation.data, data)
data[tostring(msg.to.id)]['settings']['lock_photo'] = 'yes'
save_data(_config.moderation.data, data)
send_large_msg(receiver, 'Photo saved!', ok_cb, false)
else
print('Error downloading: '..msg.id)
send_large_msg(receiver, 'Failed, please try again!', ok_cb, false)
end
end
-- show group settings
local function show_group_settings(msg, data)
if not is_sudo(msg) then
return "For moderators only!"
end
local settings = data[tostring(msg.to.id)]['settings']
if settings.lock_bots == 'yes' then
lock_bots_state = '🔒'
elseif settings.lock_bots == 'no' then
lock_bots_state = '🔓'
end
if settings.lock_name == 'yes' then
lock_name_state = '🔒'
elseif settings.lock_name == 'no' then
lock_name_state = '🔓'
end
if settings.lock_photo == 'yes' then
lock_photo_state = '🔒'
elseif settings.lock_photo == 'no' then
lock_photo_state = '🔓'
end
if settings.lock_member == 'yes' then
lock_member_state = '🔒'
elseif settings.lock_member == 'no' then
lock_member_state = '🔓'
end
if settings.anti_flood ~= 'no' then
antiflood_state = '🔒'
elseif settings.anti_flood == 'no' then
antiflood_state = '🔓'
end
if settings.welcome ~= 'no' then
greeting_state = '🔒'
elseif settings.welcome == 'no' then
greeting_state = '🔓'
end
local text = 'Group settings:\n'
..'\n'..lock_bots_state..' Lock group from bot : '..settings.lock_bots
..'\n'..lock_name_state..' Lock group name : '..settings.lock_name
..'\n'..lock_photo_state..' Lock group photo : '..settings.lock_photo
..'\n'..lock_member_state..' Lock group member : '..settings.lock_member
..'\n'..antiflood_state..' Flood protection : '..settings.anti_flood
..'\n'..greeting_state..' Welcome message : '..settings.welcome
return text
end
-- media handler. needed by group_photo_lock
local function pre_process(msg)
if not msg.text and msg.media then
msg.text = '['..msg.media.type..']'
end
return msg
end
function run(msg, matches)
if not is_chat_msg(msg) then
return "This is not a group chat."
end
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
-- add a group to be moderated
if matches[1] == 'gpadd' then
return gpadd(msg)
end
-- remove group from moderation
if matches[1] == 'gprem' then
return gprem(msg)
end
if msg.media and is_chat_msg(msg) and is_sudo(msg) then
if msg.media.type == 'photo' and data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' then
load_photo(msg.id, set_group_photo, msg)
end
end
end
if data[tostring(msg.to.id)] then
local settings = data[tostring(msg.to.id)]['settings']
if matches[1] == 'setabout' and matches[2] then
deskripsi = matches[2]
return set_description(msg, data)
end
if matches[1] == 'about' then
return get_description(msg, data)
end
if matches[1] == 'setrules' then
rules = matches[2]
return set_rules(msg, data)
end
if matches[1] == 'rules' then
return get_rules(msg, data)
end
-- group link {get|set}
if matches[1] == 'link' then
local chat = 'chat#id'..msg.to.id
if matches[2] == 'get' then
if data[tostring(msg.to.id)]['link'] then
local about = get_description(msg, data)
local link = data[tostring(msg.to.id)]['link']
return about.."\n\n"..link
else
return "Invite link is not exist.\nTry !link set to generate it."
end
end
if matches[2] == 'set' and is_sudo(msg) then
msgr = export_chat_link('chat#id'..msg.to.id, export_chat_link_callback, {receiver=receiver, data=data, chat_id=msg.to.id, group_name=msg.to.print_name})
end
end
-- lock {bot|name|member|photo}
if matches[1] == 'group' and matches[2] == 'lock' then
if matches[3] == 'bot' then
return disallow_api_bots(msg, data)
end
if matches[3] == 'name' then
return lock_group_name(msg, data)
end
if matches[3] == 'member' then
return lock_group_member(msg, data)
end
if matches[3] == 'photo' then
return lock_group_photo(msg, data)
end
end
-- unlock {bot|name|member|photo}
if matches[1] == 'group' and matches[2] == 'unlock' then
if matches[3] == 'bot' then
return allow_api_bots(msg, data)
end
if matches[3] == 'name' then
return unlock_group_name(msg, data)
end
if matches[3] == 'member' then
return unlock_group_member(msg, data)
end
if matches[3] == 'photo' then
return unlock_group_photo(msg, data)
end
end
-- view group settings
if matches[1] == 'group' and matches[2] == 'settings' then
return show_group_settings(msg, data)
end
-- if group name is renamed
if matches[1] == 'chat_rename' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_name_set = settings.set_name
local group_name_lock = settings.lock_name
local to_rename = 'chat#id'..msg.to.id
if group_name_lock == 'yes' then
if group_name_set ~= tostring(msg.to.print_name) then
rename_chat(to_rename, group_name_set, ok_cb, false)
end
elseif group_name_lock == 'no' then
return nil
end
end
-- set group name
if matches[1] == 'setname' and is_sudo(msg) then
local new_name = string.gsub(matches[2], '_', ' ')
data[tostring(msg.to.id)]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(msg.to.id)]['settings']['set_name']
local to_rename = 'chat#id'..msg.to.id
rename_chat(to_rename, group_name_set, ok_cb, false)
end
-- set group photo
if matches[1] == 'setphoto' and is_sudo(msg) then
data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
return 'Please send me new group photo now'
end
-- if a user is added to group
if matches[1] == 'chat_add_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_member_lock = settings.lock_member
local group_bot_lock = settings.lock_bots
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if group_member_lock == 'yes' then
chat_del_user(chat, user, ok_cb, true)
-- no APIs bot are allowed to enter chat group.
elseif group_bot_lock == 'yes' and msg.action.user.flags == 4352 then
chat_del_user(chat, user, ok_cb, true)
elseif group_bot_lock == 'no' or group_member_lock == 'no' then
return nil
end
end
-- if group photo is deleted
if matches[1] == 'chat_delete_photo' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_photo_lock = settings.lock_photo
if group_photo_lock == 'yes' then
chat_set_photo (receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
-- if group photo is changed
if matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then
if not msg.service then
return "Are you trying to troll me?"
end
local group_photo_lock = settings.lock_photo
if group_photo_lock == 'yes' then
chat_set_photo (receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
end
end
return {
description = "Plugin to manage group chat.",
usage = {
"!about : Read group description",
"!group <lock|unlock> bot : {Dis}allow APIs bots",
"!group <lock|unlock> member : Lock/unlock group member",
"!group <lock|unlock> name : Lock/unlock group name",
"!group <lock|unlock> photo : Lock/unlock group photo",
"!group settings : Show group settings",
"!link <get|set> : Get or revoke invite link",
"!rules : Read group rules",
"!setabout <description> : Set group description",
"!setname <new_name> : Set group name",
"!setphoto : Set group photo",
"!setrules <rules> : Set group rules"
},
patterns = {
"^!(about)$",
"%[(audio)%]",
"%[(document)%]",
"^!(gpadd)$",
"^!(gprem)$",
"^!(group) (lock) (.*)$",
"^!(group) (settings)$",
"^!(group) (unlock) (.*)$",
"^!(link) (.*)$",
"%[(photo)%]",
"%[(photo)%]",
"^!(rules)$",
"^!(setabout) (.*)$",
"^!(setname) (.*)$",
"^!(setphoto)$",
"^!(setrules) (.*)$",
"^!!tgservice (.+)$",
"%[(video)%]"
},
run = run,
privileged = true,
hide = true,
pre_process = pre_process
}
end
| gpl-2.0 |
ElectricPrism/stargus | scripts/ui.lua | 1 | 12813 | -- _________ __ __
-- / _____// |_____________ _/ |______ ____ __ __ ______
-- \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
-- / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
-- /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
-- \/ \/ \//_____/ \/
-- ______________________ ______________________
-- T H E W A R B E G I N S
-- Stratagus - A free fantasy real time strategy game engine
--
-- ui.lua - Define the user interface
--
-- (c) Copyright 2004-2006 by Jimmy Salmon
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
Load("scripts/widgets.lua")
Load("scripts/gameui.lua")
--
-- Define Decorations.
--
--ManaSprite("ui/mana.png", -7, -7, 7, 7)
--ManaSprite("ui/ppbrfull.png", 0, -1, 108, 9)
DefineSprites({Name="sprite-mana", File="ui/ppbrfull.png",
Offset={0, -1}, Size={108, 9}})
--HealthSprite("ui/health.png", 1, -7, 7, 7)
--HealthSprite("ui/ppbrfull.png", 0, -1, 108, 9)
DefineSprites({Name="sprite-health", File="ui/ppbrfull.png",
Offset={0, -1}, Size={108, 9}})
--DefineSprites({Name = "sprite-spell", File = "ui/bloodlust,haste,slow,invisible,shield.png",
-- Offset = {1, 1}, Size = {16, 16}})
--DefineDecorations({Index = "Bloodlust", ShowOpponent = true,
-- Offset = {0, 0}, Method = {"static-sprite", {"sprite-spell", 0}}})
--DefineDecorations({Index = "Haste", ShowOpponent = true,
-- Offset = {16, 0}, Method = {"static-sprite", {"sprite-spell", 1}}})
--DefineDecorations({Index = "Slow", ShowOpponent = true,
-- Offset = {16, 0}, Method = {"static-sprite", {"sprite-spell", 2}}})
--DefineDecorations({Index = "Invisible", ShowOpponent = true,
-- Offset = {32, 0}, Method = {"static-sprite", {"sprite-spell", 3}}})
--DefineDecorations({Index = "UnholyArmor", ShowOpponent = true,
-- Offset = {48, 0}, Method = {"static-sprite", {"sprite-spell", 4}}})
--ShowHealthBar()
--ShowHealthVertical()
--ShowHealthHorizontal()
--ShowHealthDot()
DefineDecorations({Index="HitPoints", HideNeutral=true, CenterX=true,
OffsetPercent={50, 100}, Method={"sprite", {"sprite-health"}}})
--ShowManaBar()
--ShowManaVertical()
--ShowManaHorizontal()
--ShowManaDot()
DefineDecorations({Index="Mana", HideNeutral=true, CenterX=true,
OffsetPercent={50, 100}, Method={"sprite", {"sprite-mana"}}})
DefineDecorations({Index="Transport", HideNeutral=true, CenterX=true,
OffsetPercent={50, 100}, Method={"sprite", {"sprite-mana"}}})
DefineDecorations({Index="Research", HideNeutral=true, CenterX=true,
OffsetPercent={50, 100}, Method={"sprite", {"sprite-mana"}}})
DefineDecorations({Index="Training", HideNeutral=true, CenterX=true,
OffsetPercent={50, 100}, Method={"sprite", {"sprite-mana"}}})
DefineDecorations({Index="UpgradeTo", HideNeutral=true, CenterX=true,
OffsetPercent={50, 100}, Method={"sprite", {"sprite-mana"}}})
DefineDecorations({Index="GiveResource", HideNeutral=true, CenterX=true,
OffsetPercent={50, 100}, Method={"sprite", {"sprite-mana"}}})
DefineDecorations({Index="CarryResource", HideNeutral=true, CenterX=true,
OffsetPercent={50, 100}, Method={"sprite", {"sprite-mana"}}})
--ShowNoFull()
--ShowFull()
-- Uncomment next, to show bars and dots always on top.
-- FIXME: planned feature
--DecorationOnTop()
local offx = (Video.Width - 640) / 2
local offy = Video.Height - 480
--
-- Define Panels
--
local info_panel_x = offx + 0
local info_panel_y = offy + 160
local min_damage = Div(ActiveUnitVar("PiercingDamage"), 2)
local max_damage = Add(ActiveUnitVar("PiercingDamage"), ActiveUnitVar("BasicDamage"))
local damage_bonus = Sub(ActiveUnitVar("PiercingDamage", "Value", "Type"),
ActiveUnitVar("PiercingDamage", "Value", "Initial"));
DefinePanelContents(
-- Default presentation. ------------------------
{
Ident = "panel-general-contents",
Pos = {offx, offy}, DefaultFont = "game",
Contents = {
--[[
{ Pos = {10, 48}, Condition = {ShowOpponent = false, HideNeutral = true},
More = {"LifeBar", {Variable = "HitPoints", Height = 7, Width = 45}}
},
]]
{ Pos = {offx + 198, offy + 454}, Condition = {ShowOpponent = false, HideNeutral = true},
More = {"FormattedText2", {
Font = "small", Variable = "HitPoints", Format = "%d/%d",
Component1 = "Value", Component2 = "Max", Centered = true}}
},
{ Pos = {offx + 315, offy + 391}, More = {"Text", {Text = Line(1, UnitName("Active"), 110, "game"), Centered = true}} },
{ Pos = {offx + 315, offy + 405}, More = {"Text", {Text = Line(2, UnitName("Active"), 110, "game"), Centered = true}} },
-- Resource Left
{ Pos = {offx + 88, offy + 86}, Condition = {ShowOpponent = false, GiveResource = "only"},
More = {"FormattedText2", {Format = "%s Left:%d", Variable = "GiveResource",
Component1 = "Name", Component2 = "Value", Centered = true}}
},
-- Construction
{ Pos = {offx + 12, offy + 153}, Condition = {ShowOpponent = false, HideNeutral = true, Build = "only"},
More = {"CompleteBar", {Variable = "Build", Width = 152, Height = 12}}
},
{ Pos = {offx + 50, offy + 154}, Condition = {ShowOpponent = false, HideNeutral = true, Build = "only"},
More = {"Text", "% Complete"}},
{ Pos = {offx + 107, offy + 78}, Condition = {ShowOpponent = false, HideNeutral = true, Build = "only"},
More = {"Icon", {Unit = "Worker"}}}
} },
-- Supply Building constructed.----------------
{
Ident = "panel-building-contents",
Pos = {info_panel_x, info_panel_y}, DefaultFont = "game",
Condition = {ShowOpponent = false, HideNeutral = true, Build = "false", Supply = "only", Training = "false", UpgradeTo = "false"},
-- FIXME more condition. not town hall.
Contents = {
-- Food building
{ Pos = {offx + 16, offy + 71}, More = {"Text", "Usage"} },
{ Pos = {offx + 58, offy + 86}, More = {"Text", {Text = "Supply : ", Variable = "Supply", Component = "Max"}} },
{ Pos = {offx + 51, offy + 102}, More = { "Text", {Text = Concat("Demand : ",
If(GreaterThan(ActiveUnitVar("Demand", "Max"), ActiveUnitVar("Supply", "Max")),
InverseVideo(String(ActiveUnitVar("Demand", "Max"))),
String(ActiveUnitVar("Demand", "Max")) ))}}
}
} },
-- All own unit -----------------
{
Ident = "panel-all-unit-contents",
Pos = {info_panel_x, info_panel_y},
DefaultFont = "game",
Condition = {ShowOpponent = false, HideNeutral = true, Build = "false"},
Contents = {
--[[
{ Pos = {37, 86}, Condition = {PiercingDamage = "only"},
More = {"Text", {Text = Concat("Damage: ", String(min_damage), "-", String(max_damage),
If(Equal(0, damage_bonus), "",
InverseVideo(Concat("+", String(damage_bonus)))) )}}
},
{ Pos = {47, 102}, Condition = {AttackRange = "only"},
More = {"Text", {
Text = "Range: ", Variable = "AttackRange" , Stat = true}}
},
]]
-- Research
{ Pos = {offx + 12, offy + 153}, Condition = {Research = "only"},
More = {"CompleteBar", {Variable = "Research", Width = 152, Height = 12}}
},
{ Pos = {offx + 16, offy + 86}, Condition = {Research = "only"}, More = {"Text", "Researching:"}},
{ Pos = {offx + 50, offy + 154}, Condition = {Research = "only"}, More = {"Text", "% Complete"}},
-- Training
{ Pos = {offx + 12, offy + 153}, Condition = {Training = "only"},
More = {"CompleteBar", {Variable = "Training", Width = 152, Height = 12}}
},
{ Pos = {offx + 50, offy + 154}, Condition = {Training = "only"}, More = {"Text", "% Complete"}},
-- Upgrading To
{ Pos = {offx + 12, offy + 153}, Condition = {UpgradeTo = "only"},
More = {"CompleteBar", {Variable = "UpgradeTo", Width = 152, Height = 12}}
},
{ Pos = {offx + 37, offy + 86}, More = {"Text", "Upgrading:"}, Condition = {UpgradeTo = "only"} },
{ Pos = {offx + 50, offy + 154}, More = {"Text", "% Complete"}, Condition = {UpgradeTo = "only"} },
-- Mana
{ Pos = {offx + 16, offy + 148}, Condition = {Mana = "only"},
More = {"CompleteBar", {Variable = "Mana", Height = 16, Width = 140, Border = true}}
},
{ Pos = {offx + 86, offy + 150}, More = {"Text", {Variable = "Mana"}}, Condition = {Mana = "only"} },
-- Ressource Carry
{ Pos = {offx + 61, offy + 149}, Condition = {CarryResource = "only"},
More = {"FormattedText2", {Format = "Carry: %d %s", Variable = "CarryResource",
Component1 = "Value", Component2 = "Name"}}
}
} }--,
-- Attack Unit -----------------------------
--[[
{
Ident = "panel-attack-unit-contents",
Pos = {info_panel_x, info_panel_y},
DefaultFont = "game",
Condition = {ShowOpponent = false, HideNeutral = true, Building = "false", Build = "false"},
Contents = {
-- Unit caracteristics
{ Pos = {114, 41},
More = {"FormattedText", {Variable = "Level", Format = "Level ~<%d~>"}}
},
{ Pos = {114, 56},
More = {"FormattedText2", {Centered = true,
Variable1 = "Xp", Variable2 = "Kill", Format = "XP:~<%d~> Kills:~<%d~>"}}
},
{ Pos = {47, 71}, Condition = {Armor = "only"},
More = {"Text", {
Text = "Armor: ", Variable = "Armor", Stat = true}}
},
{ Pos = {54, 118}, Condition = {SightRange = "only"},
More = {"Text", {Text = "Sight: ", Variable = "SightRange", Stat = true}}
},
{ Pos = {53, 133}, Condition = {Speed = "only"},
More = {"Text", {Text = "Speed: ", Variable = "Speed", Stat = true}}
} } }
]]
)
UI.MessageFont = Fonts["game"]
UI.MessageScrollSpeed = 5
DefineCursor({
Name = "cursor-point",
Race = "any",
File = "ui/cursors/arrow.png",
Rate = 50,
HotSpot = {63, 63},
Size = {128, 128}})
DefineCursor({
Name = "cursor-glass",
Race = "any",
File = "ui/cursors/magg.png",
Rate = 50,
HotSpot = {63, 63},
Size = {128, 128}})
DefineCursor({
Name = "cursor-cross",
Race = "any",
File = "ui/cursors/drag.png",
Rate = 50,
HotSpot = {63, 63},
Size = {128, 128}})
DefineCursor({
Name = "cursor-scroll",
Race = "any",
File = "ui/cursors/targn.png",
HotSpot = {15, 15},
Size = {32, 32}})
DefineCursor({
Name = "cursor-scroll",
Race = "any",
File = "ui/cursors/targn.png",
HotSpot = {15, 15},
Size = {32, 32}})
DefineCursor({
Name = "cursor-scroll",
Race = "any",
File = "ui/cursors/targn.png",
HotSpot = {15, 15},
Size = {32, 32}})
DefineCursor({
Name = "cursor-scroll",
Race = "any",
File = "ui/cursors/targn.png",
HotSpot = {15, 15},
Size = {32, 32}})
DefineCursor({
Name = "cursor-green-hair",
Race = "any",
File = "ui/cursors/targn.png",
HotSpot = {15, 15},
Size = {32, 32}})
DefineCursor({
Name = "cursor-yellow-hair",
Race = "any",
File = "ui/cursors/targn.png",
HotSpot = {15, 15},
Size = {32, 32}})
DefineCursor({
Name = "cursor-red-hair",
Race = "any",
File = "ui/cursors/targn.png",
HotSpot = {15, 15},
Size = {32, 32}})
DefineCursor({
Name = "cursor-arrow-e",
Race = "any",
File = "ui/cursors/scrollr.png",
Rate = 67,
HotSpot = {63, 63},
Size = {128, 128}})
DefineCursor({
Name = "cursor-arrow-ne",
Race = "any",
File = "ui/cursors/scrollur.png",
Rate = 67,
HotSpot = {63, 63},
Size = {128, 128}})
DefineCursor({
Name = "cursor-arrow-n",
Race = "any",
File = "ui/cursors/scrollu.png",
Rate = 67,
HotSpot = {63, 63},
Size = {128, 128}})
DefineCursor({
Name = "cursor-arrow-nw",
Race = "any",
File = "ui/cursors/scrollul.png",
Rate = 67,
HotSpot = {63, 63},
Size = {128, 128}})
DefineCursor({
Name = "cursor-arrow-w",
Race = "any",
File = "ui/cursors/scrolll.png",
Rate = 67,
HotSpot = {63, 63},
Size = {128, 128}})
DefineCursor({
Name = "cursor-arrow-s",
Race = "any",
File = "ui/cursors/scrolld.png",
Rate = 67,
HotSpot = {63, 63},
Size = {128, 128}})
DefineCursor({
Name = "cursor-arrow-sw",
Race = "any",
File = "ui/cursors/scrolldl.png",
Rate = 67,
HotSpot = {63, 63},
Size = {128, 128}})
DefineCursor({
Name = "cursor-arrow-se",
Race = "any",
File = "ui/cursors/scrolldr.png",
Rate = 67,
HotSpot = {63, 63},
Size = {128, 128}})
| gpl-2.0 |
ashfinal/awesome-hammerspoon | init.lua | 1 | 18662 | hs.hotkey.alertDuration = 0
hs.hints.showTitleThresh = 0
hs.window.animationDuration = 0
-- Use the standardized config location, if present
custom_config = hs.fs.pathToAbsolute(os.getenv("HOME") .. '/.config/hammerspoon/private/config.lua')
if custom_config then
print("Loading custom config")
dofile( os.getenv("HOME") .. "/.config/hammerspoon/private/config.lua")
privatepath = hs.fs.pathToAbsolute(hs.configdir .. '/private/config.lua')
if privatepath then
hs.alert("You have config in both .config/hammerspoon and .hammerspoon/private.\nThe .config/hammerspoon one will be used.")
end
else
-- otherwise fallback to 'classic' location.
if not privatepath then
privatepath = hs.fs.pathToAbsolute(hs.configdir .. '/private')
-- Create `~/.hammerspoon/private` directory if not exists.
hs.fs.mkdir(hs.configdir .. '/private')
end
privateconf = hs.fs.pathToAbsolute(hs.configdir .. '/private/config.lua')
if privateconf then
-- Load awesomeconfig file if exists
require('private/config')
end
end
hsreload_keys = hsreload_keys or {{"cmd", "shift", "ctrl"}, "R"}
if string.len(hsreload_keys[2]) > 0 then
hs.hotkey.bind(hsreload_keys[1], hsreload_keys[2], "Reload Configuration", function() hs.reload() end)
end
-- ModalMgr Spoon must be loaded explicitly, because this repository heavily relies upon it.
hs.loadSpoon("ModalMgr")
-- Define default Spoons which will be loaded later
if not hspoon_list then
hspoon_list = {
"AClock",
"BingDaily",
"CircleClock",
"ClipShow",
"CountDown",
"HCalendar",
"HSaria2",
"HSearch",
"SpeedMenu",
"WinWin",
"FnMate",
}
end
-- Load those Spoons
for _, v in pairs(hspoon_list) do
hs.loadSpoon(v)
end
----------------------------------------------------------------------------------------------------
-- Then we create/register all kinds of modal keybindings environments.
----------------------------------------------------------------------------------------------------
-- Register windowHints (Register a keybinding which is NOT modal environment with modal supervisor)
hswhints_keys = hswhints_keys or {"alt", "tab"}
if string.len(hswhints_keys[2]) > 0 then
spoon.ModalMgr.supervisor:bind(hswhints_keys[1], hswhints_keys[2], 'Show Window Hints', function()
spoon.ModalMgr:deactivateAll()
hs.hints.windowHints()
end)
end
----------------------------------------------------------------------------------------------------
-- appM modal environment
spoon.ModalMgr:new("appM")
local cmodal = spoon.ModalMgr.modal_list["appM"]
cmodal:bind('', 'escape', 'Deactivate appM', function() spoon.ModalMgr:deactivate({"appM"}) end)
cmodal:bind('', 'Q', 'Deactivate appM', function() spoon.ModalMgr:deactivate({"appM"}) end)
cmodal:bind('', 'tab', 'Toggle Cheatsheet', function() spoon.ModalMgr:toggleCheatsheet() end)
if not hsapp_list then
hsapp_list = {
{key = 'f', name = 'Finder'},
{key = 's', name = 'Safari'},
{key = 't', name = 'Terminal'},
{key = 'v', id = 'com.apple.ActivityMonitor'},
{key = 'y', id = 'com.apple.systempreferences'},
}
end
for _, v in ipairs(hsapp_list) do
if v.id then
local located_name = hs.application.nameForBundleID(v.id)
if located_name then
cmodal:bind('', v.key, located_name, function()
hs.application.launchOrFocusByBundleID(v.id)
spoon.ModalMgr:deactivate({"appM"})
end)
end
elseif v.name then
cmodal:bind('', v.key, v.name, function()
hs.application.launchOrFocus(v.name)
spoon.ModalMgr:deactivate({"appM"})
end)
end
end
-- Then we register some keybindings with modal supervisor
hsappM_keys = hsappM_keys or {"alt", "A"}
if string.len(hsappM_keys[2]) > 0 then
spoon.ModalMgr.supervisor:bind(hsappM_keys[1], hsappM_keys[2], "Enter AppM Environment", function()
spoon.ModalMgr:deactivateAll()
-- Show the keybindings cheatsheet once appM is activated
spoon.ModalMgr:activate({"appM"}, "#FFBD2E", true)
end)
end
----------------------------------------------------------------------------------------------------
-- clipshowM modal environment
if spoon.ClipShow then
spoon.ModalMgr:new("clipshowM")
local cmodal = spoon.ModalMgr.modal_list["clipshowM"]
cmodal:bind('', 'escape', 'Deactivate clipshowM', function()
spoon.ClipShow:toggleShow()
spoon.ModalMgr:deactivate({"clipshowM"})
end)
cmodal:bind('', 'Q', 'Deactivate clipshowM', function()
spoon.ClipShow:toggleShow()
spoon.ModalMgr:deactivate({"clipshowM"})
end)
cmodal:bind('', 'N', 'Save this Session', function()
spoon.ClipShow:saveToSession()
end)
cmodal:bind('', 'R', 'Restore last Session', function()
spoon.ClipShow:restoreLastSession()
end)
cmodal:bind('', 'B', 'Open in Browser', function()
spoon.ClipShow:openInBrowserWithRef()
spoon.ClipShow:toggleShow()
spoon.ModalMgr:deactivate({"clipshowM"})
end)
cmodal:bind('', 'S', 'Search with Bing', function()
spoon.ClipShow:openInBrowserWithRef("https://www.bing.com/search?q=")
spoon.ClipShow:toggleShow()
spoon.ModalMgr:deactivate({"clipshowM"})
end)
cmodal:bind('', 'M', 'Open in MacVim', function()
spoon.ClipShow:openWithCommand("/usr/local/bin/mvim")
spoon.ClipShow:toggleShow()
spoon.ModalMgr:deactivate({"clipshowM"})
end)
cmodal:bind('', 'F', 'Save to Desktop', function()
spoon.ClipShow:saveToFile()
spoon.ClipShow:toggleShow()
spoon.ModalMgr:deactivate({"clipshowM"})
end)
cmodal:bind('', 'H', 'Search in Github', function()
spoon.ClipShow:openInBrowserWithRef("https://github.com/search?q=")
spoon.ClipShow:toggleShow()
spoon.ModalMgr:deactivate({"clipshowM"})
end)
cmodal:bind('', 'G', 'Search with Google', function()
spoon.ClipShow:openInBrowserWithRef("https://www.google.com/search?q=")
spoon.ClipShow:toggleShow()
spoon.ModalMgr:deactivate({"clipshowM"})
end)
cmodal:bind('', 'L', 'Open in Sublime Text', function()
spoon.ClipShow:openWithCommand("/usr/local/bin/subl")
spoon.ClipShow:toggleShow()
spoon.ModalMgr:deactivate({"clipshowM"})
end)
-- Register clipshowM with modal supervisor
hsclipsM_keys = hsclipsM_keys or {"alt", "C"}
if string.len(hsclipsM_keys[2]) > 0 then
spoon.ModalMgr.supervisor:bind(hsclipsM_keys[1], hsclipsM_keys[2], "Enter clipshowM Environment", function()
-- We need to take action upon hsclipsM_keys is pressed, since pressing another key to showing ClipShow panel is redundant.
spoon.ClipShow:toggleShow()
-- Need a little trick here. Since the content type of system clipboard may be "URL", in which case we don't need to activate clipshowM.
if spoon.ClipShow.canvas:isShowing() then
spoon.ModalMgr:deactivateAll()
spoon.ModalMgr:activate({"clipshowM"})
end
end)
end
end
----------------------------------------------------------------------------------------------------
-- Register HSaria2
if spoon.HSaria2 then
-- First we need to connect to aria2 rpc host
hsaria2_host = hsaria2_host or "http://localhost:6800/jsonrpc"
hsaria2_secret = hsaria2_secret or "token"
spoon.HSaria2:connectToHost(hsaria2_host, hsaria2_secret)
hsaria2_keys = hsaria2_keys or {"alt", "D"}
if string.len(hsaria2_keys[2]) > 0 then
spoon.ModalMgr.supervisor:bind(hsaria2_keys[1], hsaria2_keys[2], 'Toggle aria2 Panel', function() spoon.HSaria2:togglePanel() end)
end
end
----------------------------------------------------------------------------------------------------
-- Register Hammerspoon Search
if spoon.HSearch then
hsearch_keys = hsearch_keys or {"alt", "G"}
if string.len(hsearch_keys[2]) > 0 then
spoon.ModalMgr.supervisor:bind(hsearch_keys[1], hsearch_keys[2], 'Launch Hammerspoon Search', function() spoon.HSearch:toggleShow() end)
end
end
----------------------------------------------------------------------------------------------------
-- Register Hammerspoon API manual: Open Hammerspoon manual in default browser
hsman_keys = hsman_keys or {"alt", "H"}
if string.len(hsman_keys[2]) > 0 then
spoon.ModalMgr.supervisor:bind(hsman_keys[1], hsman_keys[2], "Read Hammerspoon Manual", function()
hs.doc.hsdocs.forceExternalBrowser(true)
hs.doc.hsdocs.moduleEntitiesInSidebar(true)
hs.doc.hsdocs.help()
end)
end
----------------------------------------------------------------------------------------------------
-- countdownM modal environment
if spoon.CountDown then
spoon.ModalMgr:new("countdownM")
local cmodal = spoon.ModalMgr.modal_list["countdownM"]
cmodal:bind('', 'escape', 'Deactivate countdownM', function() spoon.ModalMgr:deactivate({"countdownM"}) end)
cmodal:bind('', 'Q', 'Deactivate countdownM', function() spoon.ModalMgr:deactivate({"countdownM"}) end)
cmodal:bind('', 'tab', 'Toggle Cheatsheet', function() spoon.ModalMgr:toggleCheatsheet() end)
cmodal:bind('', '0', '5 Minutes Countdown', function()
spoon.CountDown:startFor(5)
spoon.ModalMgr:deactivate({"countdownM"})
end)
for i = 1, 9 do
cmodal:bind('', tostring(i), string.format("%s Minutes Countdown", 10 * i), function()
spoon.CountDown:startFor(10 * i)
spoon.ModalMgr:deactivate({"countdownM"})
end)
end
cmodal:bind('', 'return', '25 Minutes Countdown', function()
spoon.CountDown:startFor(25)
spoon.ModalMgr:deactivate({"countdownM"})
end)
cmodal:bind('', 'space', 'Pause/Resume CountDown', function()
spoon.CountDown:pauseOrResume()
spoon.ModalMgr:deactivate({"countdownM"})
end)
-- Register countdownM with modal supervisor
hscountdM_keys = hscountdM_keys or {"alt", "I"}
if string.len(hscountdM_keys[2]) > 0 then
spoon.ModalMgr.supervisor:bind(hscountdM_keys[1], hscountdM_keys[2], "Enter countdownM Environment", function()
spoon.ModalMgr:deactivateAll()
-- Show the keybindings cheatsheet once countdownM is activated
spoon.ModalMgr:activate({"countdownM"}, "#FF6347", true)
end)
end
end
----------------------------------------------------------------------------------------------------
-- Register lock screen
hslock_keys = hslock_keys or {"alt", "L"}
if string.len(hslock_keys[2]) > 0 then
spoon.ModalMgr.supervisor:bind(hslock_keys[1], hslock_keys[2], "Lock Screen", function()
hs.caffeinate.lockScreen()
end)
end
----------------------------------------------------------------------------------------------------
-- resizeM modal environment
if spoon.WinWin then
spoon.ModalMgr:new("resizeM")
local cmodal = spoon.ModalMgr.modal_list["resizeM"]
cmodal:bind('', 'escape', 'Deactivate resizeM', function() spoon.ModalMgr:deactivate({"resizeM"}) end)
cmodal:bind('', 'Q', 'Deactivate resizeM', function() spoon.ModalMgr:deactivate({"resizeM"}) end)
cmodal:bind('', 'tab', 'Toggle Cheatsheet', function() spoon.ModalMgr:toggleCheatsheet() end)
cmodal:bind('', 'A', 'Move Leftward', function() spoon.WinWin:stepMove("left") end, nil, function() spoon.WinWin:stepMove("left") end)
cmodal:bind('', 'D', 'Move Rightward', function() spoon.WinWin:stepMove("right") end, nil, function() spoon.WinWin:stepMove("right") end)
cmodal:bind('', 'W', 'Move Upward', function() spoon.WinWin:stepMove("up") end, nil, function() spoon.WinWin:stepMove("up") end)
cmodal:bind('', 'S', 'Move Downward', function() spoon.WinWin:stepMove("down") end, nil, function() spoon.WinWin:stepMove("down") end)
cmodal:bind('', 'H', 'Lefthalf of Screen', function() spoon.WinWin:stash() spoon.WinWin:moveAndResize("halfleft") end)
cmodal:bind('', 'L', 'Righthalf of Screen', function() spoon.WinWin:stash() spoon.WinWin:moveAndResize("halfright") end)
cmodal:bind('', 'K', 'Uphalf of Screen', function() spoon.WinWin:stash() spoon.WinWin:moveAndResize("halfup") end)
cmodal:bind('', 'J', 'Downhalf of Screen', function() spoon.WinWin:stash() spoon.WinWin:moveAndResize("halfdown") end)
cmodal:bind('', 'Y', 'NorthWest Corner', function() spoon.WinWin:stash() spoon.WinWin:moveAndResize("cornerNW") end)
cmodal:bind('', 'O', 'NorthEast Corner', function() spoon.WinWin:stash() spoon.WinWin:moveAndResize("cornerNE") end)
cmodal:bind('', 'U', 'SouthWest Corner', function() spoon.WinWin:stash() spoon.WinWin:moveAndResize("cornerSW") end)
cmodal:bind('', 'I', 'SouthEast Corner', function() spoon.WinWin:stash() spoon.WinWin:moveAndResize("cornerSE") end)
cmodal:bind('', 'F', 'Fullscreen', function() spoon.WinWin:stash() spoon.WinWin:moveAndResize("fullscreen") end)
cmodal:bind('', 'C', 'Center Window', function() spoon.WinWin:stash() spoon.WinWin:moveAndResize("center") end)
cmodal:bind('', '=', 'Stretch Outward', function() spoon.WinWin:moveAndResize("expand") end, nil, function() spoon.WinWin:moveAndResize("expand") end)
cmodal:bind('', '-', 'Shrink Inward', function() spoon.WinWin:moveAndResize("shrink") end, nil, function() spoon.WinWin:moveAndResize("shrink") end)
cmodal:bind('shift', 'H', 'Move Leftward', function() spoon.WinWin:stepResize("left") end, nil, function() spoon.WinWin:stepResize("left") end)
cmodal:bind('shift', 'L', 'Move Rightward', function() spoon.WinWin:stepResize("right") end, nil, function() spoon.WinWin:stepResize("right") end)
cmodal:bind('shift', 'K', 'Move Upward', function() spoon.WinWin:stepResize("up") end, nil, function() spoon.WinWin:stepResize("up") end)
cmodal:bind('shift', 'J', 'Move Downward', function() spoon.WinWin:stepResize("down") end, nil, function() spoon.WinWin:stepResize("down") end)
cmodal:bind('', 'left', 'Move to Left Monitor', function() spoon.WinWin:stash() spoon.WinWin:moveToScreen("left") end)
cmodal:bind('', 'right', 'Move to Right Monitor', function() spoon.WinWin:stash() spoon.WinWin:moveToScreen("right") end)
cmodal:bind('', 'up', 'Move to Above Monitor', function() spoon.WinWin:stash() spoon.WinWin:moveToScreen("up") end)
cmodal:bind('', 'down', 'Move to Below Monitor', function() spoon.WinWin:stash() spoon.WinWin:moveToScreen("down") end)
cmodal:bind('', 'space', 'Move to Next Monitor', function() spoon.WinWin:stash() spoon.WinWin:moveToScreen("next") end)
cmodal:bind('', '[', 'Undo Window Manipulation', function() spoon.WinWin:undo() end)
cmodal:bind('', ']', 'Redo Window Manipulation', function() spoon.WinWin:redo() end)
cmodal:bind('', '`', 'Center Cursor', function() spoon.WinWin:centerCursor() end)
-- Register resizeM with modal supervisor
hsresizeM_keys = hsresizeM_keys or {"alt", "R"}
if string.len(hsresizeM_keys[2]) > 0 then
spoon.ModalMgr.supervisor:bind(hsresizeM_keys[1], hsresizeM_keys[2], "Enter resizeM Environment", function()
-- Deactivate some modal environments or not before activating a new one
spoon.ModalMgr:deactivateAll()
-- Show an status indicator so we know we're in some modal environment now
spoon.ModalMgr:activate({"resizeM"}, "#B22222")
end)
end
end
----------------------------------------------------------------------------------------------------
-- cheatsheetM modal environment (Because KSheet Spoon is NOT loaded, cheatsheetM will NOT be activated)
if spoon.KSheet then
spoon.ModalMgr:new("cheatsheetM")
local cmodal = spoon.ModalMgr.modal_list["cheatsheetM"]
cmodal:bind('', 'escape', 'Deactivate cheatsheetM', function()
spoon.KSheet:hide()
spoon.ModalMgr:deactivate({"cheatsheetM"})
end)
cmodal:bind('', 'Q', 'Deactivate cheatsheetM', function()
spoon.KSheet:hide()
spoon.ModalMgr:deactivate({"cheatsheetM"})
end)
-- Register cheatsheetM with modal supervisor
hscheats_keys = hscheats_keys or {"alt", "S"}
if string.len(hscheats_keys[2]) > 0 then
spoon.ModalMgr.supervisor:bind(hscheats_keys[1], hscheats_keys[2], "Enter cheatsheetM Environment", function()
spoon.KSheet:show()
spoon.ModalMgr:deactivateAll()
spoon.ModalMgr:activate({"cheatsheetM"})
end)
end
end
----------------------------------------------------------------------------------------------------
-- Register AClock
if spoon.AClock then
hsaclock_keys = hsaclock_keys or {"alt", "T"}
if string.len(hsaclock_keys[2]) > 0 then
spoon.ModalMgr.supervisor:bind(hsaclock_keys[1], hsaclock_keys[2], "Toggle Floating Clock", function() spoon.AClock:toggleShow() end)
end
end
----------------------------------------------------------------------------------------------------
-- Register browser tab typist: Type URL of current tab of running browser in markdown format. i.e. [title](link)
hstype_keys = hstype_keys or {"alt", "V"}
if string.len(hstype_keys[2]) > 0 then
spoon.ModalMgr.supervisor:bind(hstype_keys[1], hstype_keys[2], "Type Browser Link", function()
local safari_running = hs.application.applicationsForBundleID("com.apple.Safari")
local chrome_running = hs.application.applicationsForBundleID("com.google.Chrome")
if #safari_running > 0 then
local stat, data = hs.applescript('tell application "Safari" to get {URL, name} of current tab of window 1')
if stat then hs.eventtap.keyStrokes("[" .. data[2] .. "](" .. data[1] .. ")") end
elseif #chrome_running > 0 then
local stat, data = hs.applescript('tell application "Google Chrome" to get {URL, title} of active tab of window 1')
if stat then hs.eventtap.keyStrokes("[" .. data[2] .. "](" .. data[1] .. ")") end
end
end)
end
----------------------------------------------------------------------------------------------------
-- Register Hammerspoon console
hsconsole_keys = hsconsole_keys or {"alt", "Z"}
if string.len(hsconsole_keys[2]) > 0 then
spoon.ModalMgr.supervisor:bind(hsconsole_keys[1], hsconsole_keys[2], "Toggle Hammerspoon Console", function() hs.toggleConsole() end)
end
----------------------------------------------------------------------------------------------------
-- Finally we initialize ModalMgr supervisor
spoon.ModalMgr.supervisor:enter()
| mit |
david-xiao/packages | net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/memberconfig.lua | 110 | 1317 | -- ------ extra functions ------ --
function cbi_add_interface(field)
uci.cursor():foreach("mwan3", "interface",
function (section)
field:value(section[".name"])
end
)
end
-- ------ member configuration ------ --
dsp = require "luci.dispatcher"
arg[1] = arg[1] or ""
m5 = Map("mwan3", translate("MWAN Member Configuration - ") .. arg[1])
m5.redirect = dsp.build_url("admin", "network", "mwan", "configuration", "member")
mwan_member = m5:section(NamedSection, arg[1], "member", "")
mwan_member.addremove = false
mwan_member.dynamic = false
interface = mwan_member:option(Value, "interface", translate("Interface"))
cbi_add_interface(interface)
metric = mwan_member:option(Value, "metric", translate("Metric"),
translate("Acceptable values: 1-1000. Defaults to 1 if not set"))
metric.datatype = "range(1, 1000)"
weight = mwan_member:option(Value, "weight", translate("Weight"),
translate("Acceptable values: 1-1000. Defaults to 1 if not set"))
weight.datatype = "range(1, 1000)"
-- ------ currently configured interfaces ------ --
mwan_interface = m5:section(TypedSection, "interface", translate("Currently Configured Interfaces"))
mwan_interface.addremove = false
mwan_interface.dynamic = false
mwan_interface.sortable = false
mwan_interface.template = "cbi/tblsection"
return m5
| gpl-2.0 |
facebokiii/facebookplug | plugins/help.lua | 337 | 5009 | do
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
-- Returns true if is not empty
local function has_usage_data(dict)
if (dict.usage == nil or dict.usage == '') then
return false
end
return true
end
-- Get commands for that plugin
local function plugin_help(name,number,requester)
local plugin = ""
if number then
local i = 0
for name in pairsByKeys(plugins) do
if plugins[name].hidden then
name = nil
else
i = i + 1
if i == tonumber(number) then
plugin = plugins[name]
end
end
end
else
plugin = plugins[name]
if not plugin then return nil end
end
local text = ""
if (type(plugin.usage) == "table") then
for ku,usage in pairs(plugin.usage) do
if ku == 'user' then -- usage for user
if (type(plugin.usage.user) == "table") then
for k,v in pairs(plugin.usage.user) do
text = text..v..'\n'
end
elseif has_usage_data(plugin) then -- Is not empty
text = text..plugin.usage.user..'\n'
end
elseif ku == 'moderator' then -- usage for moderator
if requester == 'moderator' or requester == 'admin' or requester == 'sudo' then
if (type(plugin.usage.moderator) == "table") then
for k,v in pairs(plugin.usage.moderator) do
text = text..v..'\n'
end
elseif has_usage_data(plugin) then -- Is not empty
text = text..plugin.usage.moderator..'\n'
end
end
elseif ku == 'admin' then -- usage for admin
if requester == 'admin' or requester == 'sudo' then
if (type(plugin.usage.admin) == "table") then
for k,v in pairs(plugin.usage.admin) do
text = text..v..'\n'
end
elseif has_usage_data(plugin) then -- Is not empty
text = text..plugin.usage.admin..'\n'
end
end
elseif ku == 'sudo' then -- usage for sudo
if requester == 'sudo' then
if (type(plugin.usage.sudo) == "table") then
for k,v in pairs(plugin.usage.sudo) do
text = text..v..'\n'
end
elseif has_usage_data(plugin) then -- Is not empty
text = text..plugin.usage.sudo..'\n'
end
end
else
text = text..usage..'\n'
end
end
text = text..'======================\n'
elseif has_usage_data(plugin) then -- Is not empty
text = text..plugin.usage..'\n======================\n'
end
return text
end
-- !help command
local function telegram_help()
local i = 0
local text = "Plugins list:\n\n"
-- Plugins names
for name in pairsByKeys(plugins) do
if plugins[name].hidden then
name = nil
else
i = i + 1
text = text..i..'. '..name..'\n'
end
end
text = text..'\n'..'There are '..i..' plugins help available.'
text = text..'\n'..'Write "!help [plugin name]" or "!help [plugin number]" for more info.'
text = text..'\n'..'Or "!help all" to show all info.'
return text
end
-- !help all command
local function help_all(requester)
local ret = ""
for name in pairsByKeys(plugins) do
if plugins[name].hidden then
name = nil
else
ret = ret .. plugin_help(name, nil, requester)
end
end
return ret
end
local function run(msg, matches)
if is_sudo(msg) then
requester = "sudo"
elseif is_admin(msg) then
requester = "admin"
elseif is_momod(msg) then
requester = "moderator"
else
requester = "user"
end
if matches[1] == "!help" then
return telegram_help()
elseif matches[1] == "!help all" then
return help_all(requester)
else
local text = ""
if tonumber(matches[1]) then
text = plugin_help(nil, matches[1], requester)
else
text = plugin_help(matches[1], nil, requester)
end
if not text then
text = telegram_help()
end
return text
end
end
return {
description = "Help plugin. Get info from other plugins. ",
usage = {
"!help: Show list of plugins.",
"!help all: Show all commands for every plugin.",
"!help [plugin name]: Commands for that plugin.",
"!help [number]: Commands for that plugin. Type !help to get the plugin number."
},
patterns = {
"^!help$",
"^!help all",
"^!help (.+)"
},
run = run
}
end
| gpl-2.0 |
tltneon/NutScript | gamemode/core/derma/cl_contextmenu.lua | 5 | 6394 |
local PANEL = {}
AccessorFunc( PANEL, "m_bHangOpen", "HangOpen" )
function PANEL:Init()
--
-- This makes it so that when you're hovering over this panel
-- you can `click` on the world. Your viewmodel will aim etc.
--
self:SetWorldClicker( true )
self.Canvas = vgui.Create( "DCategoryList", self )
self.m_bHangOpen = false
--self.Canvas:EnableVerticalScrollbar( true )
--self.Canvas:SetSpacing( 0 )
--self.Canvas:SetPadding( 5 )
--self.Canvas:SetDrawBackground( false )
end
function PANEL:Open()
self:SetHangOpen( false )
-- If the spawn menu is open, try to close it..
if ( g_SpawnMenu:IsVisible() ) then
g_SpawnMenu:Close( true )
end
if ( self:IsVisible() ) then return end
CloseDermaMenus()
self:MakePopup()
self:SetVisible( true )
self:SetKeyboardInputEnabled( false )
self:SetMouseInputEnabled( true )
RestoreCursorPosition()
local bShouldShow = true;
-- TODO: Any situation in which we shouldn't show the tool menu on the context menu?
-- Set up the active panel..
if ( bShouldShow && IsValid( spawnmenu.ActiveControlPanel() ) ) then
self.OldParent = spawnmenu.ActiveControlPanel():GetParent()
self.OldPosX, self.OldPosY = spawnmenu.ActiveControlPanel():GetPos()
spawnmenu.ActiveControlPanel():SetParent( self )
self.Canvas:Clear()
self.Canvas:AddItem( spawnmenu.ActiveControlPanel() )
self.Canvas:Rebuild()
self.Canvas:SetVisible( true )
else
self.Canvas:SetVisible( false )
end
self:InvalidateLayout( true )
end
function PANEL:Close( bSkipAnim )
if ( self:GetHangOpen() ) then
self:SetHangOpen( false )
return
end
RememberCursorPosition()
CloseDermaMenus()
self:SetKeyboardInputEnabled( false )
self:SetMouseInputEnabled( false )
self:SetAlpha( 255 )
self:SetVisible( false )
self:RestoreControlPanel()
end
function PANEL:PerformLayout()
self:SetPos( 0, -32 )
self:SetSize( ScrW(), ScrH() )
self.Canvas:SetWide( 311 )
self.Canvas:SetPos( ScrW() - self.Canvas:GetWide() - 50, self.y )
if ( IsValid( spawnmenu.ActiveControlPanel() ) ) then
spawnmenu.ActiveControlPanel():InvalidateLayout( true )
local Tall = spawnmenu.ActiveControlPanel():GetTall() + 10
local MaxTall = ScrH() * 0.8
if ( Tall > MaxTall ) then Tall = MaxTall end
self.Canvas:SetTall( Tall )
self.Canvas.y = ScrH() - 50 - Tall
end
self.Canvas:InvalidateLayout( true )
end
function PANEL:StartKeyFocus( pPanel )
self:SetKeyboardInputEnabled( true )
self:SetHangOpen( true )
end
function PANEL:EndKeyFocus( pPanel )
self:SetKeyboardInputEnabled( false )
end
function PANEL:RestoreControlPanel()
-- Restore the active panel
if ( !spawnmenu.ActiveControlPanel() ) then return end
if ( !self.OldParent ) then return end
spawnmenu.ActiveControlPanel():SetParent( self.OldParent )
spawnmenu.ActiveControlPanel():SetPos( self.OldPosX, self.OldPosY )
self.OldParent = nil
end
--
-- Note here: EditablePanel is important! Child panels won't be able to get
-- keyboard input if it's a DPanel or a Panel. You need to either have an EditablePanel
-- or a DFrame (which is derived from EditablePanel) as your first panel attached to the system.
--
vgui.Register( "ContextMenu", PANEL, "EditablePanel" )
function CreateContextMenu()
if ( IsValid( g_ContextMenu ) ) then
g_ContextMenu:Remove()
g_ContextMenu = nil
end
g_ContextMenu = vgui.Create( "ContextMenu" )
g_ContextMenu:SetVisible( false )
--
-- We're blocking clicks to the world - but we don't want to
-- so feed clicks to the proper functions..
--
g_ContextMenu.OnMousePressed = function( p, code )
hook.Run( "GUIMousePressed", code, gui.ScreenToVector( gui.MousePos() ) )
end
g_ContextMenu.OnMouseReleased = function( p, code )
hook.Run( "GUIMouseReleased", code, gui.ScreenToVector( gui.MousePos() ) )
end
hook.Run( "ContextMenuCreated", g_ContextMenu )
local IconLayout = g_ContextMenu:Add( "DIconLayout" )
IconLayout:Dock( LEFT )
IconLayout:SetWorldClicker( true )
IconLayout:SetBorder( 8 )
IconLayout:SetSpaceX( 8 )
IconLayout:SetSpaceY( 8 )
IconLayout:SetWide( 200 )
IconLayout:SetLayoutDir( LEFT )
for k, v in pairs( list.Get( "DesktopWindows" ) ) do
local icon = IconLayout:Add( "DButton" )
icon:SetText( "" )
icon:SetSize( 80, 82 )
icon.Paint = function()end
local label = icon:Add( "DLabel" )
label:Dock( BOTTOM )
label:SetText( v.title )
label:SetContentAlignment( 5 )
label:SetTextColor( Color( 255, 255, 255, 255 ) )
label:SetExpensiveShadow( 1, Color( 0, 0, 0, 200 ) )
local image = icon:Add( "DImage" )
image:SetImage( v.icon )
image:SetSize( 64, 64 )
image:Dock( TOP )
image:DockMargin( 8, 0, 8, 0 )
icon.DoClick = function()
--
-- v might have changed using autorefresh so grab it again
--
local newv = list.Get( "DesktopWindows" )[ k ]
if ( v.onewindow ) then
if ( IsValid( icon.Window ) ) then icon.Window:Center() return end
end
-- Make the window
icon.Window = g_ContextMenu:Add( "DFrame" )
icon.Window:SetSize( newv.width, newv.height )
icon.Window:SetTitle( newv.title )
icon.Window:Center()
newv.init( icon, icon.Window )
end
end
end
function GM:OnContextMenuOpen()
-- Let the gamemode decide whether we should open or not..
if ( !hook.Call( "ContextMenuOpen", GAMEMODE ) ) then return end
if ( IsValid( g_ContextMenu ) && !g_ContextMenu:IsVisible() ) then
g_ContextMenu:Open()
vgui.Create("nutQuick")
menubar.ParentTo( g_ContextMenu )
end
end
function GM:OnContextMenuClose()
if ( IsValid( g_ContextMenu ) ) then
g_ContextMenu:Close()
end
if (IsValid(nut.gui.quick)) then
nut.gui.quick:Remove()
end
end
DMenuBar.AddMenu = function( self, label )
local m = DermaMenu()
m:SetDeleteSelf( false )
m:SetDrawColumn( true )
m:Hide()
self.Menus[ label ] = m
local b = self:Add( "DButton" )
b:SetText( label )
b:Dock( LEFT )
b:SetTextColor(color_black)
b:DockMargin( 5, 0, 0, 0 )
b:SetIsMenu( true )
b:SetDrawBackground( false )
b:SizeToContentsX( 16 )
b.DoClick = function()
if ( m:IsVisible() ) then
m:Hide()
return
end
local x, y = b:LocalToScreen( 0, 0 )
m:Open( x, y + b:GetTall(), false, b )
end
b.OnCursorEntered = function()
local opened = self:GetOpenMenu()
if ( !IsValid( opened ) || opened == m ) then return end
opened:Hide()
b:DoClick()
end
return m
end | mit |
movb/Algorithm-Implementations | Roman_Numerals/Lua/Yonaba/roman.lua | 26 | 1408 | -- Roman numerals encoding/decoding implementation
-- See: http://en.wikipedia.org/wiki/Roman_numerals
-- Roman numerals translation set for encoding
local romans = {
{1000, "M"}, {900, "CM"}, {500, "D"}, {400, "CD"},
{100, "C"}, {90, "XC"}, {50, "L"}, {40, "XL"},
{10, "X"}, {9, "IX"}, {5, "V"}, {4, "IV"},
{1, "I"}
}
-- Decimals set for decoding
local decimals = {}
for i, t in pairs(romans) do
if tostring(t[1]):match('^[15]') then
decimals[t[2]] = t[1]
end
end
-- Converts a number in decimal notation to Roman notation
-- n : a number in decimal notation
-- returns : the Roman representation of n as a string
local function roman_encode(n)
local r = ''
for _, t in ipairs(romans) do
local decimal, roman = t[1], t[2]
while n >= decimal do
r = r .. roman
n = n - decimal
end
end
return r
end
-- Converts a number in Roman notation to decimal notation
-- r : a number in Roman notation (as a string)
-- returns : the decimal representation
local function roman_decode(r)
local i, n = 1, 0
while i < #r do
local d1, d2 = decimals[r:sub(i,i)], decimals[r:sub(i+1,i+1)]
if d1 < d2 then
n = n + (d2-d1)
i = i + 2
else
n = n + d1
i = i + 1
end
end
if i <= #r then n = n + decimals[r:sub(i,i)] end
return n
end
return {
encode = roman_encode,
decode = roman_decode,
} | mit |
Lynx3d/tinker_tools | Defaults/Default_ItemDB.lua | 2 | 83048 | local Dta = select(2, ...)
Dta.Defaults.ItemDB =
{
-- Rivited Metal
["IFC4B896620716CD2,FB8EBAD1EF4F50C4,,,,,,"] =
{
name = "Building Block: Metal Square",
shape = "tile"
},
["IFC4B896518A1F73D,A9255B483DEAB8E9,,,,,,"] =
{
name = "Building Block: Metal Rectangle",
shape = "rectangle"
},
["IFC4B89636C1A7384,B74150E86591A10F,,,,,,"] =
{
name = "Building Block: Metal Plank",
shape = "plank"
},
["IFC4B89626946D626,16A12E12C6A58034,,,,,,"] =
{
name = "Building Block: Metal Cube",
shape = "cube"
},
["I0E057DA266F01278,1362DC0D9B6FAF4D,,,,,,"] =
{
name = "Building Block: Metal Triangle",
shape = "triangle"
},
["IFC4B89642C2BE95C,B407349DADC528F9,,,,,,"] =
{
name = "Building Block: Metal Pole",
shape = "pole"
},
["I40AC238873FE2176,0DBFC34FDAE24B48,,,,,,"] =
{
name = "Building Block: Metal Sphere",
shape = "sphere"
},
["I05D035633B0AA6B9,73A70FE1B9F24527,,,,,,"] =
{
name = "Building Block: Metal Disc",
shape = "disc"
},
-----------
-- Brick --
-----------
-- Brown Brick
["I296C209A26B7D855,07F0B32DA1DB49D2,,,,,,"] =
{
name = "Building Block: Brown Brick Square",
shape = "tile"
},
["I296C20993F79CDBE,D90A2BAE1B474B70,,,,,,"] =
{
name = "Building Block: Brown Brick Rectangle",
shape = "rectangle"
},
["I296C20971A76948D,45D55944C8DB0478,,,,,,"] =
{
name = "Building Block: Brown Brick Plank",
shape = "plank"
},
["I296C20967263B3C3,4BFE645BDD20A963,,,,,,"] =
{
name = "Building Block: Brown Brick Cube",
shape = "cube"
},
["I073E1B3A25ABB71D,29E3DC76D58EDB81,,,,,,"] =
{
name = "Building Block: Brown Brick Triangle",
shape = "triangle"
},
["I296C209846B36DBE,D9AD8F345D5BEF37,,,,,,"] =
{
name = "Building Block: Brown Brick Pole",
shape = "pole"
},
["I43A6E038332DD71C,DC3C5E3A9D3B088A,,,,,,"] =
{
name = "Building Block: Brown Brick Sphere",
shape = "sphere"
},
["IFA704C5663135ADF,070BA63B822BB231,,,,,,"] =
{
name = "Building Block: Brown Brick Disc",
shape = "disc"
},
-- Dark Brick
["I6D568BFE47182F04,1DFD6FE492757B86,,,,,,"] =
{
name = "Building Block: Dark Brick Square",
shape = "tile"
},
["I744AC6D2299A6548,00C5DB25E2471D10,,,,,,"] =
{
name = "Building Block: Dark Brick Rectangle",
shape = "rectangle"
},
["I35CDC7222822084E,0B56463EA48971F7,,,,,,"] =
{
name = "Building Block: Dark Brick Plank",
shape = "plank"
},
["I7F7C60FB317D9615,89E537A4C9D4E200,,,,,,"] =
{
name = "Building Block: Dark Brick Cube",
shape = "cube"
},
["I7DD150DC74862B00,4B23ABF50891F95C,,,,,,"] =
{
name = "Building Block: Dark Brick Triangle",
shape = "triangle"
},
["I6DB2D83700D7C59A,20E4FAC5947B5DF0,,,,,,"] =
{
name = "Building Block: Dark Brick Pole",
shape = "pole"
},
["I5E33C4F876B8130C,261E707F0D86DA95,,,,,,"] =
{
name = "Building Block: Dark Brick Sphere",
shape = "sphere"
},
["I6E1F16D340C19D59,6853D90BFE9644C2,,,,,,"] =
{
name = "Building Block: Dark Brick Disc",
shape = "disc"
},
-- Grey Brick
["I4E10406235D4540A,20E4756DE87B93A8,,,,,,"] =
{
name = "Building Block: Grey Brick Square",
shape = "tile"
},
["I63243ACD6B14FB2E,CCC6908778E4941C,,,,,,"] =
{
name = "Building Block: Grey Brick Rectangle",
shape = "rectangle"
},
["I2990730D3C721518,E70235D65C25DB09,,,,,,"] =
{
name = "Building Block: Grey Brick Plank",
shape = "plank"
},
["I48145FF6021EC006,28398A27D8ECB1C2,,,,,,"] =
{
name = "Building Block: Grey Brick Cube",
shape = "cube"
},
["I7190DD7778307B52,225338DB7F1C91D7,,,,,,"] =
{
name = "Building Block: Grey Brick Triangle",
shape = "triangle"
},
["I4803D7391C67A8A7,1F095A77D139CAED,,,,,,"] =
{
name = "Building Block: Grey Brick Pole",
shape = "pole"
},
["I59C937374D2C35C3,604AE297A10E7EC3,,,,,,"] =
{
name = "Building Block: Grey Brick Sphere",
shape = "sphere"
},
["I7BA38E7E1A110261,8019A72AFD7A8AAC,,,,,,"] =
{
name = "Building Block: Grey Brick Disc",
shape = "disc"
},
-- Mossy Brick"
["I073E1B3F29924608,1CCC2F2CD61807A0,,,,,,"] =
{
name = "Building Block: Mossy Brick Square",
shape = "tile"
},
["I073E1B3E772473D9,3420563DD9F57D68,,,,,,"] =
{
name = "Building Block: Mossy Brick Rectangle",
shape = "rectangle"
},
["I073E1B3C6C1EFF1C,2CECCE90F2B24CE0,,,,,,"] =
{
name = "Building Block: Mossy Brick Plank",
shape = "plank"
},
["I073E1B3B5CE2309B,D8C9E0A8DC225694,,,,,,"] =
{
name = "Building Block: Mossy Brick Cube",
shape = "cube"
},
["I073E1B4021744470,26C13F685E095120,,,,,,"] =
{
name = "Building Block: Mossy Brick Triangle",
shape = "triangle"
},
["I073E1B3D5C2DB9D2,F0BA3A29BBF27856,,,,,,"] =
{
name = "Building Block: Mossy Brick Pole",
shape = "pole"
},
["I53795D7204ABF8FE,B82FA73A39762C6B,,,,,,"] =
{
name = "Building Block: Mossy Brick Sphere",
shape = "sphere"
},
["I28334F4E209BE38E,1B92DA346FB03B0E,,,,,,"] =
{
name = "Building Block: Mossy Brick Disc",
shape = "disc"
},
-- Red Brick
["I3F97A13C3095C5DC,1D458A0CC04B0061,,,,,,"] =
{
name = "Building Block: Red Brick Square",
shape = "tile"
},
["I1BD2BE265E8D9C87,52448B947FE99E82,,,,,,"] =
{
name = "Building Block: Red Brick Rectangle",
shape = "rectangle"
},
["I1BA3B34224BD7009,4F5F957F993387A0,,,,,,"] =
{
name = "Building Block: Red Brick Plank",
shape = "plank"
},
["I17FF59E94974850B,DE2374ACC032A039,,,,,,"] =
{
name = "Building Block: Red Brick Cube",
shape = "cube"
},
["I2E301FE517C6E37F,F25837DF14CE90CB,,,,,,"] =
{
name = "Building Block: Red Brick Triangle",
shape = "triangle"
},
["I3B4A6DE87539A6BC,FEDE1C131B007372,,,,,,"] =
{
name = "Building Block: Red Brick Pole",
shape = "pole"
},
["I116B8078149D9AAD,25BEA3901203D2F2,,,,,,"] =
{
name = "Building Block: Red Brick Sphere",
shape = "sphere"
},
["I1B342F61466138C6,31683C8AB501F5C0,,,,,,"] =
{
name = "Building Block: Red Brick Disc",
shape = "disc"
},
-------------
-- Roofing --
-------------
-- Blue Roof Tile
["I3E35E8BC171BC10D,E28046BA0E806B77,,,,,,"] =
{
name = "Building Block: Blue Roof Tile Square",
shape = "tile"
},
["I06086BDB4FE45C5D,072C387D245670B4,,,,,,"] =
{
name = "Building Block: Blue Roof Tile Rectangle",
shape = "rectangle"
},
["I0F56765F226664F5,CB4EC024EFBD106A,,,,,,"] =
{
name = "Building Block: Blue Roof Tile Plank",
shape = "plank"
},
["I7F4510322733F3CC,63660851FA99C059,,,,,,"] =
{
name = "Building Block: Blue Roof Tile Cube",
shape = "cube"
},
["I5262E04C162C741C,B9781A017A9B2430,,,,,,"] =
{
name = "Building Block: Blue Roof Tile Triangle",
shape = "triangle"
},
["I41093EAA71F5F2B3,A288DF9F6D7D9AF1,,,,,,"] =
{
name = "Building Block: Blue Roof Tile Pole",
shape = "pole"
},
["IFA5DE89B75155960,72219625F23BC4BD,,,,,,"] =
{
name = "Building Block: Blue Roof Tile Sphere",
shape = "sphere"
},
["I324F5C5A29E9ED8A,E88EA3443492A74C,,,,,,"] =
{
name = "Building Block: Blue Roof Tile Disc",
shape = "disc"
},
-- Brown Shingle
["I25BC9D8B72566637,DAAA134487FBFA2D,,,,,,"] =
{
name = "Building Block: Brown Shingle Square",
shape = "tile"
},
["I0A65AAA93E0D4D64,5C0050F32CDD979C,,,,,,"] =
{
name = "Building Block: Brown Shingle Rectangle",
shape = "rectangle"
},
["I084A34F02B5C1FFC,199ADF952878802E,,,,,,"] =
{
name = "Building Block: Brown Shingle Plank",
shape = "plank"
},
["I4D462BB4051508F0,0FB9B0A064C39E45,,,,,,"] =
{
name = "Building Block: Brown Shingle Cube",
shape = "cube"
},
["I4132735A4655AB9F,0DCF86FC541CE2C3,,,,,,"] =
{
name = "Building Block: Brown Shingle Triangle",
shape = "triangle"
},
["IFF269760414DCC14,396357B0227FEB1F,,,,,,"] =
{
name = "Building Block: Brown Shingle Pole",
shape = "pole"
},
["I1828F3EC7322D944,363DEC99C2C358F1,,,,,,"] =
{
name = "Building Block: Brown Shingle Sphere",
shape = "sphere"
},
["I3A7BB8331C181B00,1F525F70F84F9BB6,,,,,,"] =
{
name = "Building Block: Brown Shingle Disc",
shape = "disc"
},
-- Green Scale Roof Tile
["I48B8AABB4842D25D,C44D674FB17E8A81,,,,,,"] =
{
name = "Building Block: Green Scale Roof Tile Square",
shape = "tile"
},
["I427CDFF94E65E1E2,EECEA89C2DB6B3A7,,,,,,"] =
{
name = "Building Block: Green Scale Roof Tile Rectangle",
shape = "rectangle"
},
["I57D52398015CF6D6,E3018CFDFC7CF093,,,,,,"] =
{
name = "Building Block: Green Scale Roof Tile Plank",
shape = "plank"
},
["I2FB10A5836BD72CB,01B138F90A42FA88,,,,,,"] =
{
name = "Building Block: Green Scale Roof Tile Cube",
shape = "cube"
},
["I641BB490325917CD,03712E4901AAA7FD,,,,,,"] =
{
name = "Building Block: Green Scale Roof Tile Triangle",
shape = "triangle"
},
["I12638FC07DA799E5,A5DEAB23075ED77B,,,,,,"] =
{
name = "Building Block: Green Scale Roof Tile Pole",
shape = "pole"
},
["I61A695E004E817AE,EEED4889A85B5E23,,,,,,"] =
{
name = "Building Block: Green Scale Roof Tile Sphere",
shape = "sphere"
},
["I5AE02A1C338F6C6D,29B4A0042732A46B,,,,,,"] =
{
name = "Building Block: Green Scale Roof Tile Disc",
shape = "disc"
},
-- Grey Scale Roof Tile
["I2AF349323B9AFF4E,EF41336E5DB10763,,,,,,"] =
{
name = "Building Block: Grey Scale Roof Tile Square",
shape = "tile"
},
["I29FE763B5E7AB456,404DB270F3DA3529,,,,,,"] =
{
name = "Building Block: Grey Scale Roof Tile Rectangle",
shape = "rectangle"
},
["I13194B5B4FF22CE8,F4ADB7FE0B42AEAE,,,,,,"] =
{
name = "Building Block: Grey Scale Roof Tile Plank",
shape = "plank"
},
["I0AD62A123D46A66C,0169478A7EB29AEA,,,,,,"] =
{
name = "Building Block: Grey Scale Roof Tile Cube",
shape = "cube"
},
["I4BFB945E71789470,D2719C4AB7530DBC,,,,,,"] =
{
name = "Building Block: Grey Scale Roof Tile Triangle",
shape = "triangle"
},
["I5552F6D52EDF1127,5E4E532811128582,,,,,,"] =
{
name = "Building Block: Grey Scale Roof Tile Pole",
shape = "pole"
},
["I462F2D2E7ACE7A58,FB9189ABA5A730A0,,,,,,"] =
{
name = "Building Block: Grey Scale Roof Tile Sphere",
shape = "sphere"
},
["I2C046FC66B0EE399,1E175B72AB17967C,,,,,,"] =
{
name = "Building Block: Grey Scale Roof Tile Disc",
shape = "disc"
},
-- Tin Sheet Roof
["I77E07F3E45A432A8,61D8EC1625CB69C3,,,,,,"] =
{
name = "Building Block: Tin Sheet Roof Square",
shape = "tile"
},
["I56850DD20C132D60,677E54C86C296D09,,,,,,"] =
{
name = "Building Block: Tin Sheet Roof Rectangle",
shape = "rectangle"
},
["I50D79AF475F531D7,FEA06357B94719A3,,,,,,"] =
{
name = "Building Block: Tin Sheet Roof Plank",
shape = "plank"
},
["I771F417C58FF966C,6E435A3032732634,,,,,,"] =
{
name = "Building Block: Tin Sheet Roof Cube",
shape = "cube"
},
["I72D9F4736DE7511F,AF4495716A75A7E0,,,,,,"] =
{
name = "Building Block: Tin Sheet Roof Triangle",
shape = "triangle"
},
["I27D9CB3623DAE6F4,C210A8940B0164EB,,,,,,"] =
{
name = "Building Block: Tin Sheet Roof Pole",
shape = "pole"
},
["I6234450853DD60CD,189DBC0172AC58FB,,,,,,"] =
{
name = "Building Block: Tin Sheet Roof Sphere",
shape = "sphere"
},
["I7A3BACFF7B548667,C6DDAF5A89928AE1,,,,,,"] =
{
name = "Building Block: Tin Sheet Roof Disc",
shape = "disc"
},
-------------
-- Glowing --
-------------
-- Blue Blinking
["I0D6091F5577FC9B8,8977F2BBF1622B54,,,,,,"] =
{
name = "Building Block: Blue Blinking Square",
shape = "tile"
},
["I7EBC874326381067,3B0EDC1C5693A3FB,,,,,,"] =
{
name = "Building Block: Blue Blinking Rectangle",
shape = "rectangle"
},
["I4FBE4CF0733E92F0,C5F0EBF4D4FCBFEC,,,,,,"] =
{
name = "Building Block: Blue Blinking Plank",
shape = "plank"
},
["I6B9DC370498E8EB2,4FDCA10043707C39,,,,,,"] =
{
name = "Building Block: Blue Blinking Cube",
shape = "cube"
},
["I0C052D7247239F80,0336FE69220F5566,,,,,,"] =
{
name = "Building Block: Blue Blinking Triangle",
shape = "triangle"
},
["I6A44ED9E0555B4E2,E679382E3439EDEE,,,,,,"] =
{
name = "Building Block: Blue Blinking Pole",
shape = "pole"
},
["I781D026B30CE59D7,19E5906064D12846,,,,,,"] =
{
name = "Building Block: Blue Blinking Sphere",
shape = "sphere"
},
["I7EC0A8891FB9CA89,39D2723A905B0FD4,,,,,,"] =
{
name = "Building Block: Blue Blinking Disc",
shape = "disc"
},
-- Blue Glowing
["I0F301FDE75740C8C,4D7CC1D2D79CF639,,,,,,"] =
{
name = "Building Block: Blue Glowing Square",
shape = "tile"
},
["I113820C517D3C9FE,3CF58B7266CBD298,,,,,,"] =
{
name = "Building Block: Blue Glowing Rectangle",
shape = "rectangle"
},
["I1DF6D087160B10D5,4157F7BA01FA4EC1,,,,,,"] =
{
name = "Building Block: Blue Glowing Plank",
shape = "plank"
},
["I044DC0F26C4F2294,F8839ECD7CBFA4E2,,,,,,"] =
{
name = "Building Block: Blue Glowing Cube",
shape = "cube"
},
["I5A895ECA0E92CE54,D3BEDC46951A8F96,,,,,,"] =
{
name = "Building Block: Blue Glowing Triangle",
shape = "triangle"
},
["I2925B2AB735F274A,F6C679C8F808BF91,,,,,,"] =
{
name = "Building Block: Blue Glowing Pole",
shape = "pole"
},
["I13512B0645333C92,1E0BCE6CE4BF87D9,,,,,,"] =
{
name = "Building Block: Blue Glowing Sphere",
shape = "sphere"
},
["I4318097900591EE2,B7D8ABB503901AC9,,,,,,"] =
{
name = "Building Block: Blue Glowing Disc",
shape = "disc"
},
-- Green Blinking
["I3D894F0A4F34D392,4CBDB65FD4BFF026,,,,,,"] =
{
name = "Building Block: Green Blinking Square",
shape = "tile"
},
["I62EE36C607F9D626,279F8F713919DD5D,,,,,,"] =
{
name = "Building Block: Green Blinking Rectangle",
shape = "rectangle"
},
["IFE425AA173F0FEC9,3AD9A40A1D03F74A,,,,,,"] =
{
name = "Building Block: Green Blinking Plank",
shape = "plank"
},
["IFF4EEEFD05C7D7F3,4269532B8248E1BB,,,,,,"] =
{
name = "Building Block: Green Blinking Cube",
shape = "cube"
},
["I4464D8CA7270231A,7F2655A16FC47860,,,,,,"] =
{
name = "Building Block: Green Blinking Triangle",
shape = "triangle"
},
["IFCBDC97B0A89DAB2,218B6DA4AD5CD426,,,,,,"] =
{
name = "Building Block: Green Blinking Pole",
shape = "pole"
},
["I4EE83B3C1B96F2E9,41020CA651D0697C,,,,,,"] =
{
name = "Building Block: Green Blinking Sphere",
shape = "sphere"
},
["I3BCB898555FC3FCD,5EB855D9F49B6328,,,,,,"] =
{
name = "Building Block: Green Blinking Disc",
shape = "disc"
},
-- Green Glowing
["IFF3ECC126AEDC433,48BA4E866E92D54F,,,,,,"] =
{
name = "Building Block: Green Glowing Square",
shape = "tile"
},
["I3BB1ECDA3E916BE0,4F120602C2840E5A,,,,,,"] =
{
name = "Building Block: Green Glowing Rectangle",
shape = "rectangle"
},
["I4208B13D15A58794,C2B72B762661E67B,,,,,,"] =
{
name = "Building Block: Green Glowing Plank",
shape = "plank"
},
["IFC4AC24351DBF123,0D199D173B855F2E,,,,,,"] =
{
name = "Building Block: Green Glowing Cube",
shape = "cube"
},
["IFF670DFC2956C5AC,060A3EC7E3ACFE7F,,,,,,"] =
{
name = "Building Block: Green Glowing Triangle",
shape = "triangle"
},
["I409EB7630D748B70,187A5AC75D32A32A,,,,,,"] =
{
name = "Building Block: Green Glowing Pole",
shape = "pole"
},
["I46A4B9414754A0C5,E13E3D4D99C611F0,,,,,,"] =
{
name = "Building Block: Green Glowing Sphere",
shape = "sphere"
},
["I6843A7E24EDB2CF8,7C0A779B593EF447,,,,,,"] =
{
name = "Building Block: Green Glowing Disc",
shape = "disc"
},
-- Grey Blinking
["I2056207661F6B98E,EAD6A204D53698D4,,,,,,"] =
{
name = "Building Block: Grey Blinking Square",
shape = "tile"
},
["I216336C30E5F76DF,372CBF334B163552,,,,,,"] =
{
name = "Building Block: Grey Blinking Rectangle",
shape = "rectangle"
},
["I1E20DAAA0A8D0316,09855856C8CC454E,,,,,,"] =
{
name = "Building Block: Grey Blinking Plank",
shape = "plank"
},
["I351E7C0202FF4871,FD63CF4E23B8ABA2,,,,,,"] =
{
name = "Building Block: Grey Blinking Cube",
shape = "cube"
},
["I324F27DE71B4886F,03F115321D49EF2B,,,,,,"] =
{
name = "Building Block: Grey Blinking Triangle",
shape = "triangle"
},
["I670D3C670041E799,0EC0D800F73DB740,,,,,,"] =
{
name = "Building Block: Grey Blinking Pole",
shape = "pole"
},
["I38B6AAD129669C8A,ECE776B13B30C2C8,,,,,,"] =
{
name = "Building Block: Grey Blinking Sphere",
shape = "sphere"
},
["I1E797E770D36EC1A,166E1C4C5A251E96,,,,,,"] =
{
name = "Building Block: Grey Blinking Disc",
shape = "disc"
},
-- Grey Glowing
["I1133F573658C7042,EAD57D83CDFAC855,,,,,,"] =
{
name = "Building Block: Grey Glowing Square",
shape = "tile"
},
["I2DD9F2C94E6979B7,383F5D46ABF1C010,,,,,,"] =
{
name = "Building Block: Grey Glowing Rectangle",
shape = "rectangle"
},
["I203DBD530460D72D,3177E474A8029E6C,,,,,,"] =
{
name = "Building Block: Grey Glowing Plank",
shape = "plank"
},
["I176C919D075316BD,BDCB646B9D5849C3,,,,,,"] =
{
name = "Building Block: Grey Glowing Cube",
shape = "cube"
},
["I2BA2E3431CBF8446,FA8E8F2851F732EF,,,,,,"] =
{
name = "Building Block: Grey Glowing Triangle",
shape = "triangle"
},
["I2F33BFB877DCAA8D,168BEFA63998388C,,,,,,"] =
{
name = "Building Block: Grey Glowing Pole",
shape = "pole"
},
["I1C4344E0223D3750,29A738CF2EC16BEB,,,,,,"] =
{
name = "Building Block: Grey Glowing Sphere",
shape = "sphere"
},
["I363B83DD6F7F1F98,257185F7E7598CFB,,,,,,"] =
{
name = "Building Block: Grey Glowing Disc",
shape = "disc"
},
-- Light Blue Blinking
["IFDDA850F7EE67CDA,5BF62C5DF610315A,,,,,,"] =
{
name = "Building Block: Light Blue Blinking Square",
shape = "tile"
},
["I52F9E29F40C03D42,0164025B6FDD0989,,,,,,"] =
{
name = "Building Block: Light Blue Blinking Rectangle",
shape = "rectangle"
},
["I6665547154F0663E,55231A6F68926F38,,,,,,"] =
{
name = "Building Block: Light Blue Blinking Plank",
shape = "plank"
},
["I06C410615F1ED45D,3D906D2A4D2DE884,,,,,,"] =
{
name = "Building Block: Light Blue Blinking Cube",
shape = "cube"
},
["I48C331DD6220FD55,F0FD835EF1DC9AD8,,,,,,"] =
{
name = "Building Block: Light Blue Blinking Triangle",
shape = "triangle"
},
["IFE6ABD131F3B92DE,4AC699C87CC3BB90,,,,,,"] =
{
name = "Building Block: Light Blue Blinking Pole",
shape = "pole"
},
["I5886DB2F0B52972F,07C3C67BE0CE9C21,,,,,,"] =
{
name = "Building Block: Light Blue Blinking Sphere",
shape = "sphere"
},
["I3F5E551118C3663E,C8F4645610FA0287,,,,,,"] =
{
name = "Building Block: Light Blue Blinking Disc",
shape = "disc"
},
-- Light Blue Glowing
["I3DECC99E323D824B,1F8296A8E764C228,,,,,,"] =
{
name = "Building Block: Light Blue Glowing Square",
shape = "tile"
},
["I494A9A1659778A00,7DCE163D94247522,,,,,,"] =
{
name = "Building Block: Light Blue Glowing Rectangle",
shape = "rectangle"
},
["IFCF9FB54637B43BB,524C2695838C3057,,,,,,"] =
{
name = "Building Block: Light Blue Glowing Plank",
shape = "plank"
},
["I49D46B776F4D76CB,29550418D2D64ED0,,,,,,"] =
{
name = "Building Block: Light Blue Glowing Cube",
shape = "cube"
},
["I6D562CCE7875D9B3,7C2073F97E5F9EEB,,,,,,"] =
{
name = "Building Block: Light Blue Glowing Triangle",
shape = "triangle"
},
["I4EE95681567E9523,53945A0C93A97CE0,,,,,,"] =
{
name = "Building Block: Light Blue Glowing Pole",
shape = "pole"
},
["I5013CB0D60F06E9E,0210DC1562C03151,,,,,,"] =
{
name = "Building Block: Light Blue Glowing Sphere",
shape = "sphere"
},
["I468BA9EB46F13843,EBEBF22226578D44,,,,,,"] =
{
name = "Building Block: Light Blue Glowing Disc",
shape = "disc"
},
-- Light Green Blinking
["I4183B58D5A9F406D,1B06F3F7F44B9DEA,,,,,,"] =
{
name = "Building Block: Light Green Blinking Square",
shape = "tile"
},
["I779D1F4912AA9548,E2CD0DA699990FBE,,,,,,"] =
{
name = "Building Block: Light Green Blinking Rectangle",
shape = "rectangle"
},
["I1AE9C27106FEB712,DCCE1D0125D93153,,,,,,"] =
{
name = "Building Block: Light Green Blinking Plank",
shape = "plank"
},
["I7E23ADA305709BEB,09F56EA25CE57F6E,,,,,,"] =
{
name = "Building Block: Light Green Blinking Cube",
shape = "cube"
},
["I0A3BD2AA24FBB529,B389D1E59D40472D,,,,,,"] =
{
name = "Building Block: Light Green Blinking Triangle",
shape = "triangle"
},
["I4BDABE1C54D68B5F,4D97258EFBD4D414,,,,,,"] =
{
name = "Building Block: Light Green Blinking Pole",
shape = "pole"
},
["I6B353EAF78334EB9,E930999D429F2E75,,,,,,"] =
{
name = "Building Block: Light Green Blinking Sphere",
shape = "sphere"
},
["I02375D80238E8983,40110850134A17C7,,,,,,"] =
{
name = "Building Block: Light Green Blinking Disc",
shape = "disc"
},
-- Light Green Glowing
["I5D90EDDD78815EBC,BB3CA2044F4E9391,,,,,,"] =
{
name = "Building Block: Light Green Glowing Square",
shape = "tile"
},
["I6D33EE872DEEE619,33BE373165603EDA,,,,,,"] =
{
name = "Building Block: Light Green Glowing Rectangle",
shape = "rectangle"
},
["I11A9E8C710A50D2A,4B0BAAD1B76B6AAB,,,,,,"] =
{
name = "Building Block: Light Green Glowing Plank",
shape = "plank"
},
["I75F42BA5163FB181,F67DA899426F875D,,,,,,"] =
{
name = "Building Block: Light Green Glowing Cube",
shape = "cube"
},
["I7B82FFA365D68CFA,D8579512A532BE10,,,,,,"] =
{
name = "Building Block: Light Green Glowing Triangle",
shape = "triangle"
},
["I56E8F74861E6AD62,F22486B041B5B794,,,,,,"] =
{
name = "Building Block: Light Green Glowing Pole",
shape = "pole"
},
["I66BE88BD3601DCC2,D72E021D1C130327,,,,,,"] =
{
name = "Building Block: Light Green Glowing Sphere",
shape = "sphere"
},
["I755601CD669846EC,11B984DF2B0D02DC,,,,,,"] =
{
name = "Building Block: Light Green Glowing Disc",
shape = "disc"
},
-- Orange Blinking
["I6673DEC7215643B2,7F73B94815406BA1,,,,,,"] =
{
name = "Building Block: Orange Blinking Square",
shape = "tile"
},
["I6B9BA8657F49E91F,89C3A5A621AF82FA,,,,,,"] =
{
name = "Building Block: Orange Blinking Rectangle",
shape = "rectangle"
},
["IFB43FEC519F61110,3D08CB4C98BE59BF,,,,,,"] =
{
name = "Building Block: Orange Blinking Plank",
shape = "plank"
},
["I3CF82F593244B155,A0B65A5573FF2CAA,,,,,,"] =
{
name = "Building Block: Orange Blinking Cube",
shape = "cube"
},
["I5457081251242A63,4C283678D213BA48,,,,,,"] =
{
name = "Building Block: Orange Blinking Triangle",
shape = "triangle"
},
["I49C66518037D5570,49CAE3B63FC43AA6,,,,,,"] =
{
name = "Building Block: Orange Blinking Pole",
shape = "pole"
},
["I5A7F7B4E5352C4C5,2740907B62A97B9C,,,,,,"] =
{
name = "Building Block: Orange Blinking Sphere",
shape = "sphere"
},
["I5C1DA0622AD03111,F6D9F19C4A4AF9B9,,,,,,"] =
{
name = "Building Block: Orange Blinking Disc",
shape = "disc"
},
-- Orange Glowing
["IFE2A6E312F33700E,5B035A04FE131827,,,,,,"] =
{
name = "Building Block: Orange Glowing Square",
shape = "tile"
},
["I511070740B1F83E5,0CC1D62A92317482,,,,,,"] =
{
name = "Building Block: Orange Glowing Rectangle",
shape = "rectangle"
},
["I4557863A3987D200,D4E2B19B479EFB40,,,,,,"] =
{
name = "Building Block: Orange Glowing Plank",
shape = "plank"
},
["I44A72A35369E6F00,63BCB14B4F5707E9,,,,,,"] =
{
name = "Building Block: Orange Glowing Cube",
shape = "cube"
},
["IFFAF08D542524202,3CDB9A5B38ADE780,,,,,,"] =
{
name = "Building Block: Orange Glowing Triangle",
shape = "triangle"
},
["I411FC18B368D9A10,E1E5EFD99F2DCFF9,,,,,,"] =
{
name = "Building Block: Orange Glowing Pole",
shape = "pole"
},
["I4D61F6CF7829FC5D,E64C2E4B8C118FCD,,,,,,"] =
{
name = "Building Block: Orange Glowing Sphere",
shape = "sphere"
},
["I70929DB31A289BA0,1EDBEA3561D21540,,,,,,"] =
{
name = "Building Block: Orange Glowing Disc",
shape = "disc"
},
-- Pink Blinking
["I184AF45E36549923,1E562EC96CF2A820,,,,,,"] =
{
name = "Building Block: Pink Blinking Square",
shape = "tile"
},
["I6E9CA5A55D55EBB7,3143E0F418E04249,,,,,,"] =
{
name = "Building Block: Pink Blinking Rectangle",
shape = "rectangle"
},
["I4DCF714E7537E072,16AC96BFA378DD20,,,,,,"] =
{
name = "Building Block: Pink Blinking Plank",
shape = "plank"
},
["I4FEC176A3A9A44F5,43FDCC49256F39C4,,,,,,"] =
{
name = "Building Block: Pink Blinking Cube",
shape = "cube"
},
["I6BE1788C6BA850D8,FFBC9DD366233130,,,,,,"] =
{
name = "Building Block: Pink Blinking Triangle",
shape = "triangle"
},
["I4C1B42B30E64851C,F39AB88164883124,,,,,,"] =
{
name = "Building Block: Pink Blinking Pole",
shape = "pole"
},
["I6DCEC53B5B66F42A,53A4501105049C06,,,,,,"] =
{
name = "Building Block: Pink Blinking Sphere",
shape = "sphere"
},
["I65910DA26663DF8D,382CBE7C0F6FE86C,,,,,,"] =
{
name = "Building Block: Pink Blinking Disc",
shape = "disc"
},
-- Pink Glowing
["I457B916B34A1ADBE,21E234B5FBDAB077,,,,,,"] =
{
name = "Building Block: Pink Glowing Square",
shape = "tile"
},
["I53DF679B1396F052,C77E96780A418398,,,,,,"] =
{
name = "Building Block: Pink Glowing Rectangle",
shape = "rectangle"
},
["I52F58DE70DD8FA2F,D4D8265918720340,,,,,,"] =
{
name = "Building Block: Pink Glowing Plank",
shape = "plank"
},
["I541F49E7179E7560,BC29281C4FF2356E,,,,,,"] =
{
name = "Building Block: Pink Glowing Cube",
shape = "cube"
},
["I62CC51BA41AE4D0E,13D19D21F18CF3AD,,,,,,"] =
{
name = "Building Block: Pink Glowing Triangle",
shape = "triangle"
},
["I5019D244446BFA4C,0952EAAD6FEBBDA3,,,,,,"] =
{
name = "Building Block: Pink Glowing Pole",
shape = "pole"
},
["I597ACF2004B15A6D,4B0C4868E2C14193,,,,,,"] =
{
name = "Building Block: Pink Glowing Sphere",
shape = "sphere"
},
["I0120B56228F16079,5A1674DE818F8390,,,,,,"] =
{
name = "Building Block: Pink Glowing Disc",
shape = "disc"
},
-- Purple Blinking
["I1A9341BA27CD0B6D,107CAE013B2421F1,,,,,,"] =
{
name = "Building Block: Purple Blinking Square",
shape = "tile"
},
["I71D3721D70012D0B,0634AF37651A268D,,,,,,"] =
{
name = "Building Block: Purple Blinking Rectangle",
shape = "rectangle"
},
["I50D2C1175408C992,2B9BA8D26D835587,,,,,,"] =
{
name = "Building Block: Purple Blinking Plank",
shape = "plank"
},
["I654C92BB6A42B46A,59EDBEC22A7A2DDF,,,,,,"] =
{
name = "Building Block: Purple Blinking Cube",
shape = "cube"
},
["I7D10C4E4029D0CEE,29C68FCB28FE215A,,,,,,"] =
{
name = "Building Block: Purple Blinking Triangle",
shape = "triangle"
},
["I5B1C55EF15337E20,F70D932A4E52ADCF,,,,,,"] =
{
name = "Building Block: Purple Blinking Pole",
shape = "pole"
},
["I0C96462806E72126,E585E07CB90132F4,,,,,,"] =
{
name = "Building Block: Purple Blinking Sphere",
shape = "sphere"
},
["I707EF7577021F1D1,280C4E1CFED08473,,,,,,"] =
{
name = "Building Block: Purple Blinking Disc",
shape = "disc"
},
-- Purple Glowing
["I467AF2FB3E91183B,524C966DC4145D52,,,,,,"] =
{
name = "Building Block: Purple Glowing Square",
shape = "tile"
},
["I65DCBDFC1DEF6E6F,DDDA86916DE73928,,,,,,"] =
{
name = "Building Block: Purple Glowing Rectangle",
shape = "rectangle"
},
["I65BDD56B5A358404,5721D266930C848B,,,,,,"] =
{
name = "Building Block: Purple Glowing Plank",
shape = "plank"
},
["I55A9EF901FC6F190,285EB47B21CC24C9,,,,,,"] =
{
name = "Building Block: Purple Glowing Cube",
shape = "cube"
},
["I72E5F3974CCB8A35,D5FE34E0B313EBA9,,,,,,"] =
{
name = "Building Block: Purple Glowing Triangle",
shape = "triangle"
},
["I66BC01E50CF6A841,3D752F626738C5D5,,,,,,"] =
{
name = "Building Block: Purple Glowing Pole",
shape = "pole"
},
["I11C947F44F5B3EEF,84A41B7F9E583788,,,,,,"] =
{
name = "Building Block: Purple Glowing Sphere",
shape = "sphere"
},
["I7669FF194E55E5D2,491FE391890854AD,,,,,,"] =
{
name = "Building Block: Purple Glowing Disc",
shape = "disc"
},
-- Red Blinking
["I1EDCD3EB034426D0,823142F3C08E10E8,,,,,,"] =
{
name = "Building Block: Red Blinking Square",
shape = "tile"
},
["I2030D4AE5B379522,C5293DDCEF953FBB,,,,,,"] =
{
name = "Building Block: Red Blinking Rectangle",
shape = "rectangle"
},
["I5D2A3BAB26070AA2,37301EEE8D4D2052,,,,,,"] =
{
name = "Building Block: Red Blinking Plank",
shape = "plank"
},
["I1A73997539D0628D,F198964320F42578,,,,,,"] =
{
name = "Building Block: Red Blinking Cube",
shape = "cube"
},
["I226176EB1CC35509,15267D963B83D75E,,,,,,"] =
{
name = "Building Block: Red Blinking Triangle",
shape = "triangle"
},
["I746013632BFD453C,01E015EAD95FCDBF,,,,,,"] =
{
name = "Building Block: Red Blinking Pole",
shape = "pole"
},
["I16D0E97F574AEE21,2CC76CF412015214,,,,,,"] =
{
name = "Building Block: Red Blinking Sphere",
shape = "sphere"
},
-- Red Glowing
["I4E2EE8C656C56F88,349CB0F4ABC52A58,,,,,,"] =
{
name = "Building Block: Red Glowing Square",
shape = "tile"
},
["I79A55C7E4D4CC7F4,01195B2832E4A0C0,,,,,,"] =
{
name = "Building Block: Red Glowing Rectangle",
shape = "rectangle"
},
["I7894DDF476387D1D,12C4F7AD16C68BDD,,,,,,"] =
{
name = "Building Block: Red Glowing Plank",
shape = "plank"
},
["I5832C18D58FFB7F6,E2B8B602AEFEB9DA,,,,,,"] =
{
name = "Building Block: Red Glowing Cube",
shape = "cube"
},
["I1429C29A5BA24624,7887B356A5C73010,,,,,,"] =
{
name = "Building Block: Red Glowing Triangle",
shape = "triangle"
},
["I79ACF21101478C5A,0AF6644FF4C92C3F,,,,,,"] =
{
name = "Building Block: Red Glowing Pole",
shape = "pole"
},
["I1B4E52FD5C9B53F5,7D72C5B170D57B3B,,,,,,"] =
{
name = "Building Block: Red Glowing Sphere",
shape = "sphere"
},
["I23FB3ADD34715732,E846058002715BFD,,,,,,"] =
{
name = "Building Block: Red Glowing Disc",
shape = "disc"
},
-- White Blinking
["I309E2EED0186DE07,EFDF39AD144EB66D,,,,,,"] =
{
name = "Building Block: White Blinking Square",
shape = "tile"
},
["I233E882A73CB075D,BECD299B804D28C8,,,,,,"] =
{
name = "Building Block: White Blinking Rectangle",
shape = "rectangle"
},
["I68DE237765D15DE1,DD11C99FDD6F8E33,,,,,,"] =
{
name = "Building Block: White Blinking Plank",
shape = "plank"
},
["I2004C4BA6EAD0B98,FB69070549F5D711,,,,,,"] =
{
name = "Building Block: White Blinking Cube",
shape = "cube"
},
["I2AEEBA0D525B66CD,60CAB03663593179,,,,,,"] =
{
name = "Building Block: White Blinking Triangle",
shape = "triangle"
},
["I7DCE348601CABA39,39C84F9D931650DB,,,,,,"] =
{
name = "Building Block: White Blinking Pole",
shape = "pole"
},
["I00575AC6550382DD,243437D7E9F91090,,,,,,"] =
{
name = "Building Block: White Blinking Sphere",
shape = "sphere"
},
["I13206FE311C1FFD4,2F4C1F607EAB605D,,,,,,"] =
{
name = "Building Block: White Blinking Disc",
shape = "disc"
},
-- White Glowing
["I6DB7D52C0E831124,16E67D5755EF86F1,,,,,,"] =
{
name = "Building Block: White Glowing Square",
shape = "tile"
},
["I2605A810595AD4CC,2B1F409333A23932,,,,,,"] =
{
name = "Building Block: White Glowing Rectangle",
shape = "rectangle"
},
["I1487FDC14B87AA54,C3886A79BDDA0890,,,,,,"] =
{
name = "Building Block: White Glowing Plank",
shape = "plank"
},
["I5CB8A6800EC13E44,E0D85B8E5F3110C2,,,,,,"] =
{
name = "Building Block: White Glowing Cube",
shape = "cube"
},
["I1A9DBA1B11134E76,EF19D60C052BAE4A,,,,,,"] =
{
name = "Building Block: White Glowing Triangle",
shape = "triangle"
},
["I1D1AB70F2BD642DF,B37ECC9FC0D078F0,,,,,,"] =
{
name = "Building Block: White Glowing Pole",
shape = "pole"
},
["I1DA6C13A701DA513,4F2CF9F211F8FC03,,,,,,"] =
{
name = "Building Block: White Glowing Sphere",
shape = "sphere"
},
["I272B3D145CAA9A90,0BD9FFFB97550D19,,,,,,"] =
{
name = "Building Block: White Glowing Disc",
shape = "disc"
},
-- Yellow Blinking
["I39967D51230A6850,BDBC8F795BB28879,,,,,,"] =
{
name = "Building Block: Yellow Blinking Square",
shape = "tile"
},
["I2DBA5310209F1926,2708041A5064EFF6,,,,,,"] =
{
name = "Building Block: Yellow Blinking Rectangle",
shape = "rectangle"
},
["I1A2D7006241007F3,53CC43307EBFD435,,,,,,"] =
{
name = "Building Block: Yellow Blinking Plank",
shape = "plank"
},
["I042593D34A3D2217,6282EB972A4CF826,,,,,,"] =
{
name = "Building Block: Yellow Blinking Cube",
shape = "cube"
},
["I05C92C7C1BFC0E3A,1061B0D6BF76EC84,,,,,,"] =
{
name = "Building Block: Yellow Blinking Triangle",
shape = "triangle"
},
["I262C6A7F40940A95,5808FACCE2EE6885,,,,,,"] =
{
name = "Building Block: Yellow Blinking Pole",
shape = "pole"
},
["I2AD4F6B17513D658,23560B31D5BFDC3E,,,,,,"] =
{
name = "Building Block: Yellow Blinking Sphere",
shape = "sphere"
},
["I1697133059D3D138,F46A01FF0B282EDD,,,,,,"] =
{
name = "Building Block: Yellow Blinking Disc",
shape = "disc"
},
-- Yellow Glowing
["I327DC08A10394595,D5E0C35880ACF462,,,,,,"] =
{
name = "Building Block: Yellow Glowing Square",
shape = "tile"
},
["I05E680E05B706411,D02A1A3DF361F41F,,,,,,"] =
{
name = "Building Block: Yellow Glowing Rectangle",
shape = "rectangle"
},
["I22F92DE974A7031A,0BAA06AFB4B2DA66,,,,,,"] =
{
name = "Building Block: Yellow Glowing Plank",
shape = "plank"
},
["I6B0E9E2713975781,28B47AF89BE0B704,,,,,,"] =
{
name = "Building Block: Yellow Glowing Cube",
shape = "cube"
},
["I1CACF4DE266F0A1C,592C560510CDEC04,,,,,,"] =
{
name = "Building Block: Yellow Glowing Triangle",
shape = "triangle"
},
["I032659B732D44B5A,2070ACA5D19C4EC5,,,,,,"] =
{
name = "Building Block: Yellow Glowing Pole",
shape = "pole"
},
["I3B8D641C6FFA5D04,775D9699650976B1,,,,,,"] =
{
name = "Building Block: Yellow Glowing Sphere",
shape = "sphere"
},
["I2B2B50943821BABB,1150AD0529D15040,,,,,,"] =
{
name = "Building Block: Yellow Glowing Disc",
shape = "disc"
},
---------------
-- Limestone --
---------------
-- Limestone
["I3818BAD162A76C77,DC1C64A4763AFE8C,,,,,,"] =
{
name = "Building Block: Limestone Square",
shape = "tile"
},
["I3818BAD207A81EB9,EE1EBBB901974266,,,,,,"] =
{
name = "Building Block: Limestone Rectangle",
shape = "rectangle"
},
["I3818BAD530B1947F,E65961B97AA1A075,,,,,,"] =
{
name = "Building Block: Limestone Plank",
shape = "plank"
},
["I3818BAD6412DB4F4,F85BB8CE85FE679E,,,,,,"] =
{
name = "Building Block: Limestone Cube",
shape = "cube"
},
["I3818BAD05D2F4C6F,DAE9E950AF2B7EBE,,,,,,"] =
{
name = "Building Block: Limestone Triangle",
shape = "triangle"
},
["I3818BAD4523D3998,060F153AE1676428,,,,,,"] =
{
name = "Building Block: Limestone Pole",
shape = "pole"
},
["I3818BAD371E4257E,F7513C38B300DBFF,,,,,,"] =
{
name = "Building Block: Limestone Sphere",
shape = "sphere"
},
["I7A2176B11E144AFB,10873940C25619F2,,,,,,"] =
{
name = "Building Block: Limestone Disc",
shape = "disc"
},
-- Baby Blue Limestone
["I1CBA02CA1094C662,0EF972EAA2531CFF,,,,,,"] =
{
name = "Building Block: Baby Blue Limestone Square",
shape = "tile"
},
["I3ECA7BD7754F9216,027A800E2D71B53B,,,,,,"] =
{
name = "Building Block: Baby Blue Limestone Rectangle",
shape = "rectangle"
},
["I64957C922A2CE5C2,11D628E468F6A2D3,,,,,,"] =
{
name = "Building Block: Baby Blue Limestone Plank",
shape = "plank"
},
["I5C3F6A37788F5729,199667A004F02E5D,,,,,,"] =
{
name = "Building Block: Baby Blue Limestone Cube",
shape = "cube"
},
["I546E5F663956487B,08684109C7FE6255,,,,,,"] =
{
name = "Building Block: Baby Blue Limestone Triangle",
shape = "triangle"
},
["I5041D5F94D1B260C,EA3BC84509BEC2C7,,,,,,"] =
{
name = "Building Block: Baby Blue Limestone Pole",
shape = "pole"
},
["I16B87D4950DD6F11,3990C2DCDC8FD86E,,,,,,"] =
{
name = "Building Block: Baby Blue Limestone Sphere",
shape = "sphere"
},
["I7E83975B3167C57B,0B565A1D39E55570,,,,,,"] =
{
name = "Building Block: Baby Blue Limestone Disc",
shape = "disc"
},
-- Lavender Limestone
["IFAADE2B9615824FD,2AE3B547205D4F21,,,,,,"] =
{
name = "Building Block: Lavender Limestone Square",
shape = "tile"
},
["IFB8C87E964E763EB,0EDBFD54E7492DDF,,,,,,"] =
{
name = "Building Block: Lavender Limestone Rectangle",
shape = "rectangle"
},
["I183F23F37125DFE6,DDCB2B6379E95D21,,,,,,"] =
{
name = "Building Block: Lavender Limestone Plank",
shape = "plank"
},
["I35AF4075637378C5,F4A1125AEC3F5916,,,,,,"] =
{
name = "Building Block: Lavender Limestone Cube",
shape = "cube"
},
["I4141F89070E577C9,0B42D92CE3498A58,,,,,,"] =
{
name = "Building Block: Lavender Limestone Triangle",
shape = "triangle"
},
["I256F5322545184EE,3EE070C67B2B7C0A,,,,,,"] =
{
name = "Building Block: Lavender Limestone Pole",
shape = "pole"
},
["I21D1F8154E99388E,2190E9F4B33CE27C,,,,,,"] =
{
name = "Building Block: Lavender Limestone Sphere",
shape = "sphere"
},
["I08A68FED6C110E03,D497E81BCB494E4C,,,,,,"] =
{
name = "Building Block: Lavender Limestone Disc",
shape = "disc"
},
-- Mint Green Limestone
["I0F145A0E3632FC97,1562ADD196E599B2,,,,,,"] =
{
name = "Building Block: Mint Green Limestone Square",
shape = "tile"
},
["I538792E549DA1924,1334E735141425B1,,,,,,"] =
{
name = "Building Block: Mint Green Limestone Rectangle",
shape = "rectangle"
},
["I0A192959721B77F3,224CE60DFB031C92,,,,,,"] =
{
name = "Building Block: Mint Green Limestone Plank",
shape = "plank"
},
["I686B2FBB7DCDA85A,BD3C7FBFE2B3BA87,,,,,,"] =
{
name = "Building Block: Mint Green Limestone Cube",
shape = "cube"
},
["I604E90BA3152F3C0,FEE39772CC7BF154,,,,,,"] =
{
name = "Building Block: Mint Green Limestone Triangle",
shape = "triangle"
},
["I2D2FFBE152E21887,0F8818CC1F9DBC1B,,,,,,"] =
{
name = "Building Block: Mint Green Limestone Pole",
shape = "pole"
},
["I7AFF4E9F6ADCEBCE,6247AFBEE8061B11,,,,,,"] =
{
name = "Building Block: Mint Green Limestone Sphere",
shape = "sphere"
},
["I40416A412B4FE852,33F4DA4989D1D8D3,,,,,,"] =
{
name = "Building Block: Mint Green Limestone Disc",
shape = "disc"
},
-- Pale Yellow Limestone
["I417A0D9B4E287F23,30CD26A3AF4669C1,,,,,,"] =
{
name = "Building Block: Pale Yellow Limestone Square",
shape = "tile"
},
["I2333D52544517C25,6C2FB0DAE56B005E,,,,,,"] =
{
name = "Building Block: Pale Yellow Limestone Rectangle",
shape = "rectangle"
},
["IFEAB6C7D740E1F06,73C9FFF4048D2273,,,,,,"] =
{
name = "Building Block: Pale Yellow Limestone Plank",
shape = "plank"
},
["I7DA36B0710713B3A,2AC79A146AF28630,,,,,,"] =
{
name = "Building Block: Pale Yellow Limestone Cube",
shape = "cube"
},
["I70F84A6A5AD0F270,190008691732F396,,,,,,"] =
{
name = "Building Block: Pale Yellow Limestone Triangle",
shape = "triangle"
},
["I7098CB9126C1FF00,4E48B6BF0F0CEB77,,,,,,"] =
{
name = "Building Block: Pale Yellow Limestone Pole",
shape = "pole"
},
["I68AD214817038F85,91BB9E79D57327FC,,,,,,"] =
{
name = "Building Block: Pale Yellow Limestone Sphere",
shape = "sphere"
},
["I18A8244D3D5817CF,FA67AA1044981ECB,,,,,,"] =
{
name = "Building Block: Pale Yellow Limestone Disc",
shape = "disc"
},
-- Rose Limestone
["I3874323D2E537BA8,EF3AA588502E7F91,,,,,,"] =
{
name = "Building Block: Rose Limestone Square",
shape = "tile"
},
["I16F0248C6AFD8689,CD824DA81F2DC4D2,,,,,,"] =
{
name = "Building Block: Rose Limestone Rectangle",
shape = "rectangle"
},
["I6439F5A36F3F9DA7,2EA84E9B6D99B686,,,,,,"] =
{
name = "Building Block: Rose Limestone Plank",
shape = "plank"
},
["I6FA075CA1D4F4F92,0A8BF790C6B96975,,,,,,"] =
{
name = "Building Block: Rose Limestone Cube",
shape = "cube"
},
["I35D2A968332F00C4,652F4FE4C45E882B,,,,,,"] =
{
name = "Building Block: Rose Limestone Triangle",
shape = "triangle"
},
["I488F12FF6F434FCF,56954C12463DF2D4,,,,,,"] =
{
name = "Building Block: Rose Limestone Pole",
shape = "pole"
},
["I2A1ACD974099E1F0,FA3DC5571511F398,,,,,,"] =
{
name = "Building Block: Rose Limestone Sphere",
shape = "sphere"
},
["I32C7AE1A1EDB5879,EBE598C108998C25,,,,,,"] =
{
name = "Building Block: Rose Limestone Disc",
shape = "disc"
},
-- Tangerine Limestone
["I49BE60B612275BD3,02597159049416B0,,,,,,"] =
{
name = "Building Block: Tangerine Limestone Square",
shape = "tile"
},
["IFE07E0122221B81D,35A90A3D952B2088,,,,,,"] =
{
name = "Building Block: Tangerine Limestone Rectangle",
shape = "rectangle"
},
["I1DA6714059F3E8A0,13D0756B91C12B3D,,,,,,"] =
{
name = "Building Block: Tangerine Limestone Plank",
shape = "plank"
},
["I63C10F0040A96E6D,32D9996B5BB2E9E3,,,,,,"] =
{
name = "Building Block: Tangerine Limestone Cube",
shape = "cube"
},
["I04726E6733582FF8,1548B26BCA593EF2,,,,,,"] =
{
name = "Building Block: Tangerine Limestone Triangle",
shape = "triangle"
},
["I61A62BF447C2B291,0EA73AD3B4AE063B,,,,,,"] =
{
name = "Building Block: Tangerine Limestone Pole",
shape = "pole"
},
["I224D2ED74E1BB0EE,D75995016650FC09,,,,,,"] =
{
name = "Building Block: Tangerine Limestone Sphere",
shape = "sphere"
},
["I74DE447D7222FBDE,58C424E986231736,,,,,,"] =
{
name = "Building Block: Tangerine Limestone Disc",
shape = "disc"
},
-----------
-- Metal --
-----------
-- Ahnkite
["I539425A144DED843,0AF5A2257EAFFA09,,,,,,"] =
{
name = "Building Block: Ahnkite Square",
shape = "tile"
},
["I755733C038C2BB04,077E6A15B73EE19B,,,,,,"] =
{
name = "Building Block: Ahnkite Rectangle",
shape = "rectangle"
},
["I0DA2D2A61680D5B9,346E017C8C99FF2A,,,,,,"] =
{
name = "Building Block: Ahnkite Plank",
shape = "plank"
},
["I6F3859DB36BB2709,DCC9EB93D05BEB46,,,,,,"] =
{
name = "Building Block: Ahnkite Cube",
shape = "cube"
},
["I2188DCEE03B23356,05D897A27E577FD7,,,,,,"] =
{
name = "Building Block: Ahnkite Triangle",
shape = "triangle"
},
["I268EB710194B8C15,0A36BD61D9F7C405,,,,,,"] =
{
name = "Building Block: Ahnkite Pole",
shape = "pole"
},
["I1956045928BEF4F7,0DEC38CA57054E7F,,,,,,"] =
{
name = "Building Block: Ahnkite Sphere",
shape = "sphere"
},
["I763DA1413EC98992,AC41D8816514F954,,,,,,"] =
{
name = "Building Block: Ahnkite Disc",
shape = "disc"
},
-- Atramentium
["I4EFA084E0F8304AF,56A5FC7032C68D88,,,,,,"] =
{
name = "Building Block: Atramentium Square",
shape = "tile"
},
["I505A72820F11C784,07A4F7DC5865CF18,,,,,,"] =
{
name = "Building Block: Atramentium Rectangle",
shape = "rectangle"
},
["I77E1A3AE09E25662,3290E79D3121E2C4,,,,,,"] =
{
name = "Building Block: Atramentium Plank",
shape = "plank"
},
["I5E0D72991E46E7AC,B95B674BB0D4B7AD,,,,,,"] =
{
name = "Building Block: Atramentium Cube",
shape = "cube"
},
["I125A25A30B02815E,B3A2AFCC6022A46B,,,,,,"] =
{
name = "Building Block: Atramentium Triangle",
shape = "triangle"
},
["I576B7FBE7265F50D,D4F63A563059327C,,,,,,"] =
{
name = "Building Block: Atramentium Pole",
shape = "pole"
},
["I08D1F68773CBDDA3,2B5E53B22485AF68,,,,,,"] =
{
name = "Building Block: Atramentium Sphere",
shape = "sphere"
},
["I6ACAD3F6581320B6,6F7F58EEEF661CE0,,,,,,"] =
{
name = "Building Block: Atramentium Disc",
shape = "disc"
},
-- Bolidium
["I46C77D9476FC6915,EAEB857B5EE75F83,,,,,,"] =
{
name = "Building Block: Bolidium Square",
shape = "tile"
},
["I07091771366C0825,058832207FB3EA62,,,,,,"] =
{
name = "Building Block: Bolidium Rectangle",
shape = "rectangle"
},
["I57EBB1970270779A,25325CF23C0AD7D7,,,,,,"] =
{
name = "Building Block: Bolidium Plank",
shape = "plank"
},
["I52C2009C35093DC6,84F1964D1C210F6F,,,,,,"] =
{
name = "Building Block: Bolidium Cube",
shape = "cube"
},
["I65B066F74E00D904,4093EFCDF25876BC,,,,,,"] =
{
name = "Building Block: Bolidium Triangle",
shape = "triangle"
},
["I510561264F1AC8E1,3B1CD9125467538E,,,,,,"] =
{
name = "Building Block: Bolidium Pole",
shape = "pole"
},
["IFE05A0D245C05443,015BB603C278AA0B,,,,,,"] =
{
name = "Building Block: Bolidium Sphere",
shape = "sphere"
},
["I4D02DC18267AEF9C,FAC549A32169368B,,,,,,"] =
{
name = "Building Block: Bolidium Disc",
shape = "disc"
},
-- Bronze
["I5302F994283375AC,FCD4610995B98CBD,,,,,,"] =
{
name = "Building Block: Bronze Square",
shape = "tile"
},
["I3D535EBA5E2A951A,51513FD7EFDC8066,,,,,,"] =
{
name = "Building Block: Bronze Rectangle",
shape = "rectangle"
},
["I6603EC66015333C4,02B0DE81A55D8885,,,,,,"] =
{
name = "Building Block: Bronze Plank",
shape = "plank"
},
["IFDAF85847069ECC2,F38BFD7257173922,,,,,,"] =
{
name = "Building Block: Bronze Cube",
shape = "cube"
},
["I435751FE261A75EB,047248A2AA276B26,,,,,,"] =
{
name = "Building Block: Bronze Triangle",
shape = "triangle"
},
["I5C6C2AE136326474,7979892CF3A0E331,,,,,,"] =
{
name = "Building Block: Bronze Pole",
shape = "pole"
},
["I599DF6F5730EC5F4,F949C4B1D688A2C1,,,,,,"] =
{
name = "Building Block: Bronze Sphere",
shape = "sphere"
},
["I43064738336125F9,F6547E2BE313DB0B,,,,,,"] =
{
name = "Building Block: Bronze Disc",
shape = "disc"
},
-- Copper
["I6AB0C4036E7F55BB,ECE46B0559DD0B8A,,,,,,"] =
{
name = "Building Block: Copper Square",
shape = "tile"
},
["I3DD92F79356E473F,341511B9D21BB771,,,,,,"] =
{
name = "Building Block: Copper Rectangle",
shape = "rectangle"
},
["I789E8BF2611BB593,15AEEC288FDC3434,,,,,,"] =
{
name = "Building Block: Copper Plank",
shape = "plank"
},
["I3F37BC9C16614A67,FE8C91EAE8155D6E,,,,,,"] =
{
name = "Building Block: Copper Cube",
shape = "cube"
},
["I13CC6DDE5EB4CBF3,BEB21B003AA4E8B3,,,,,,"] =
{
name = "Building Block: Copper Triangle",
shape = "triangle"
},
["I617E64B626BC5302,84005283DE7FF744,,,,,,"] =
{
name = "Building Block: Copper Pole",
shape = "pole"
},
["I599DF6F63C7EB5ED,FB2E0073C5AEFECE,,,,,,"] =
{
name = "Building Block: Copper Sphere",
shape = "sphere"
},
["I45BD9AB03F2D8F7A,349417B8B0F64332,,,,,,"] =
{
name = "Building Block: Copper Disc",
shape = "disc"
},
-- Gold
["I79BAED7B03B964C6,C03254E697824186,,,,,,"] =
{
name = "Building Block: Gold Square",
shape = "tile"
},
["I4DBA84834765AD7A,58E33B690A17481A,,,,,,"] =
{
name = "Building Block: Gold Rectangle",
shape = "rectangle"
},
["I15FF4B330B031214,03EC79FD984F30F1,,,,,,"] =
{
name = "Building Block: Gold Plank",
shape = "plank"
},
["I59FCF6C30F39E7EA,DFA261EBA56735FB,,,,,,"] =
{
name = "Building Block: Gold Cube",
shape = "cube"
},
["I2049ED9E6D1B4E0C,E3D9DF961934C432,,,,,,"] =
{
name = "Building Block: Gold Triangle",
shape = "triangle"
},
["I184E28255EAD7124,37A42F8F8E70A0B0,,,,,,"] =
{
name = "Building Block: Gold Pole",
shape = "pole"
},
["I599DF6F71D66415B,328AE63BB06B7052,,,,,,"] =
{
name = "Building Block: Gold Sphere",
shape = "sphere"
},
["I7D978086383E695C,E7CFE3E44685AFE8,,,,,,"] =
{
name = "Building Block: Gold Disc",
shape = "disc"
},
-- Iron
["I7CBC98471899CF5C,8098132ADB130804,,,,,,"] =
{
name = "Building Block: Iron Square",
shape = "tile"
},
["I11B9C2F02179AF9C,53B1A71B1E1D404E,,,,,,"] =
{
name = "Building Block: Iron Rectangle",
shape = "rectangle"
},
["I22EC967F280DD5D2,1D67E0AB94686625,,,,,,"] =
{
name = "Building Block: Iron Plank",
shape = "plank"
},
["I7DFB344B282452DF,22B0E09CFC731091,,,,,,"] =
{
name = "Building Block: Iron Cube",
shape = "cube"
},
["I23C4D1014BDE5382,CF257D294935B5D5,,,,,,"] =
{
name = "Building Block: Iron Triangle",
shape = "triangle"
},
["I1F2A51075E54BF25,36B43EEB150DC716,,,,,,"] =
{
name = "Building Block: Iron Pole",
shape = "pole"
},
["I599DF6F81BB32E78,F8DFF11CAAE71EEC,,,,,,"] =
{
name = "Building Block: Iron Sphere",
shape = "sphere"
},
["I0192B2FE60774270,EC1221D7817CDBBF,,,,,,"] =
{
name = "Building Block: Iron Disc",
shape = "disc"
},
-- Silver
["I7F3829BB2914E927,16963BEEB07956DA,,,,,,"] =
{
name = "Building Block: Silver Square",
shape = "tile"
},
["I1A8E12EF786B7B7D,F7C811C6EB17FC5B,,,,,,"] =
{
name = "Building Block: Silver Rectangle",
shape = "rectangle"
},
["I265CB62B1B03B6EA,4D3FC42904BEDC5B,,,,,,"] =
{
name = "Building Block: Silver Plank",
shape = "plank"
},
["I1CDAD8FB19FA8980,D597CC95E5BEB05B,,,,,,"] =
{
name = "Building Block: Silver Cube",
shape = "cube"
},
["I2C39B78D113CDCE6,0AB510CBF16ED993,,,,,,"] =
{
name = "Building Block: Silver Triangle",
shape = "triangle"
},
["I2AA680953BF81E12,55AB446CA22CFD44,,,,,,"] =
{
name = "Building Block: Silver Pole",
shape = "pole"
},
["I599DF6F91AA8B52A,4153210583FBBF66,,,,,,"] =
{
name = "Building Block: Silver Sphere",
shape = "sphere"
},
["I15288651608C4C0E,30D948AE9ACC207D,,,,,,"] =
{
name = "Building Block: Silver Disc",
shape = "disc"
},
-----------
-- Stone --
-----------
-- Black Marble
["I073E1B4612DE4C8A,F92F979003F4808F,,,,,,"] =
{
name = "Building Block: Black Marble Square",
shape = "tile"
},
["I073E1B4526891DBC,32303483297E6C39,,,,,,"] =
{
name = "Building Block: Black Marble Rectangle",
shape = "rectangle"
},
["I073E1B4205A5AD2C,DBA30B02D2220DFA,,,,,,"] =
{
name = "Building Block: Black Marble Plank",
shape = "plank"
},
["I073E1B415FB61FE2,35D4A7B10CECEB74,,,,,,"] =
{
name = "Building Block: Black Marble Cube",
shape = "cube"
},
["I073E1B47696AE692,1B5009F82B87B2D4,,,,,,"] =
{
name = "Building Block: Black Marble Triangle",
shape = "triangle"
},
["I073E1B4373754E81,4EE757B2984B08C7,,,,,,"] =
{
name = "Building Block: Black Marble Pole",
shape = "pole"
},
["I073E1B4404FD78A3,EECA186F0B7BEA75,,,,,,"] =
{
name = "Building Block: Black Marble Sphere",
shape = "sphere"
},
["I471E8BFC0EA98298,334F6B4E0F979E19,,,,,,"] =
{
name = "Building Block: Black Marble Disc",
shape = "disc"
},
-- Brimstone
["I7C7CB5B52D30D014,F12AEE2144535EB9,,,,,,"] =
{
name = "Building Block: Brimstone Square",
shape = "tile"
},
["I1A295402638F4681,567983771AF82DF8,,,,,,"] =
{
name = "Building Block: Brimstone Rectangle",
shape = "rectangle"
},
["I138D39CE296827F1,110784229FDD7732,,,,,,"] =
{
name = "Building Block: Brimstone Plank",
shape = "plank"
},
["I431E018E3C63C152,DECC88168602FDF7,,,,,,"] =
{
name = "Building Block: Brimstone Cube",
shape = "cube"
},
["I1D145A951FB687F2,3C96582F541042D6,,,,,,"] =
{
name = "Building Block: Brimstone Triangle",
shape = "triangle"
},
["I767ED0A52510D841,3F86E38F6F5298F8,,,,,,"] =
{
name = "Building Block: Brimstone Pole",
shape = "pole"
},
["I6A3D08EF22F07D38,1FBCE085DC4D9188,,,,,,"] =
{
name = "Building Block: Brimstone Sphere",
shape = "sphere"
},
["I7A05F8E16906F813,34D59A9C571DDD4A,,,,,,"] =
{
name = "Building Block: Brimstone Disc",
shape = "disc"
},
-- Granite
["I391DEDBA3602AEE7,0BAE6DA5E14A8F15,,,,,,"] =
{
name = "Building Block: Granite Square",
shape = "tile"
},
["I391DEDBB37D6C62E,209FB386C9208314,,,,,,"] =
{
name = "Building Block: Granite Rectangle",
shape = "rectangle"
},
["I391DEDBE1401B33C,BD07066F4CF5E056,,,,,,"] =
{
name = "Building Block: Granite Plank",
shape = "plank"
},
["I391DEDBF5153A1DF,E8A90FDBF6939FB8,,,,,,"] =
{
name = "Building Block: Granite Cube",
shape = "cube"
},
["I391DEDB9407C540E,E2FB53059425FC88,,,,,,"] =
{
name = "Building Block: Granite Triangle",
shape = "triangle"
},
["I391DEDBD6EDB9940,B6C374BCF8057392,,,,,,"] =
{
name = "Building Block: Granite Pole",
shape = "pole"
},
["I391DEDBC5376E825,07DD708AF171F87F,,,,,,"] =
{
name = "Building Block: Granite Sphere",
shape = "sphere"
},
["I471590822DD4BB08,BBD409F6967FAEA1,,,,,,"] =
{
name = "Building Block: Granite Disc",
shape = "disc"
},
-- Green Marble
["I391DEDB7666F40AB,BBB226C82076B285,,,,,,"] =
{
name = "Building Block: Green Marble Square",
shape = "tile"
},
["I391DEDB60587B53E,C694001D10509F46,,,,,,"] =
{
name = "Building Block: Green Marble Rectangle",
shape = "rectangle"
},
["I391DEDB3402D4989,F3A8CA73730395E0,,,,,,"] =
{
name = "Building Block: Green Marble Plank",
shape = "plank"
},
["I073E1B4815A7BFC4,3EE0BB9C3C5B0811,,,,,,"] =
{
name = "Building Block: Green Marble Cube",
shape = "cube"
},
["I391DEDB80182998A,BFD390E843FEDBDA,,,,,,"] =
{
name = "Building Block: Green Marble Triangle",
shape = "triangle"
},
["I391DEDB47498E0D1,D3F316F28C3CCB90,,,,,,"] =
{
name = "Building Block: Green Marble Pole",
shape = "pole"
},
["I391DEDB559E08ED3,1AF279FEE6B2DFE5,,,,,,"] =
{
name = "Building Block: Green Marble Sphere",
shape = "sphere"
},
["I4F3DEDB24D02A2C2,32478B55CFF44C0F,,,,,,"] =
{
name = "Building Block: Green Marble Disc",
shape = "disc"
},
-- Colored Marble Tiles
["I446B1D966FE150B1,02A43028CD909F80,,,,,,"] =
{
name = "Building Block: Orange Marble Square",
shape = "tile"
},
["I446B1D9B5E06059F,D0F11E304FF428E8,,,,,,"] =
{
name = "Building Block: Grey Marble Square",
shape = "tile"
},
["I446B1D9576850C1F,F0A1D913C233D857,,,,,,"] =
{
name = "Building Block: Mustard Marble Square",
shape = "tile"
},
["I446B1D97357E515A,AA94BB0CC42E0575,,,,,,"] =
{
name = "Building Block: Amber Marble Square",
shape = "tile"
},
["I446B1D9922B2B3AD,C68C225DD77B92CF,,,,,,"] =
{
name = "Building Block: Blood Marble Square",
shape = "tile"
},
["I446B1D9A10E44AE0,2900934C5956C2F3,,,,,,"] =
{
name = "Building Block: White Marble Square",
shape = "tile"
},
["I446B1D9F41049106,B4700BB624CC615C,,,,,,"] =
{
name = "Building Block: Pink Marble Square",
shape = "tile"
},
["I446B1DA058307EF0,D4534FC017FDC659,,,,,,"] =
{
name = "Building Block: Ruby Marble Square",
shape = "tile"
},
["I446B1D947899BFC0,CF9C3E89A374FB16,,,,,,"] =
{
name = "Building Block: Yellow Marble Square",
shape = "tile"
},
["I2F94903B4BE58484,79515EE6968341DA,,,,,,"] =
{
name = "Building Block: Jade Marble Square",
shape = "tile"
},
["I446B1D9D08FBB08D,0BA68FE5287605ED,,,,,,"] =
{
name = "Building Block: Teal Marble Square",
shape = "tile"
},
["I446B1D9E7274313F,12B6E8D1A876D8C9,,,,,,"] =
{
name = "Building Block: Aqua Marble Square",
shape = "tile"
},
["I446B1D9C493E6256,0C4A76B9EA8AA9B5,,,,,,"] =
{
name = "Building Block: Steel Marble Square",
shape = "tile"
},
["I446B1D93333390A3,240CBBBB45970E87,,,,,,"] =
{
name = "Building Block: Purple Marble Square",
shape = "tile"
},
["I446B1D923286C90C,C87BC0C987F220B0,,,,,,"] =
{
name = "Building Block: Violet Marble Square",
shape = "tile"
},
["I446B1D980563F11F,17A59ADDD0E7946C,,,,,,"] =
{
name = "Building Block: Red Marble Square",
shape = "tile"
},
["I446B1DA10511C0A9,E655A6D5235A8D82,,,,,,"] =
{
name = "Building Block: Blue Marble Square",
shape = "tile"
},
["I446B1DA26E22B4E5,D7D1565AF9714BE7,,,,,,"] =
{
name = "Building Block: Navy Marble Square",
shape = "tile"
},
-- Greenstone
["IFF1D8E4A6A25E35C,1F129CFC26DC5AA7,,,,,,"] =
{
name = "Building Block: Greenstone Square",
shape = "tile"
},
["IFF1BEE2F77076368,408BF5DACD6542A7,,,,,,"] =
{
name = "Building Block: Greenstone Rectangle",
shape = "rectangle"
},
["I595317063D221222,BCB1CB6689D600F4,,,,,,"] =
{
name = "Building Block: Greenstone Brick Plank",
shape = "plank"
},
["IFB192CB30B4FFEC2,6BCD9A120AAD91FF,,,,,,"] =
{
name = "Building Block: Greenstone Brick Cube",
shape = "cube"
},
["I0E057DA0036E7490,EF5E2DE384B620FB,,,,,,"] =
{
name = "Building Block: Greenstone Triangle",
shape = "triangle"
},
["I50DE65BA6500E5CB,81098C8575CBD24E,,,,,,"] =
{
name = "Building Block: Greenstone Brick Pole",
shape = "pole"
},
["I6FDA125C5A06218C,AE87F2440AFAB5E1,,,,,,"] =
{
name = "Building Block: Greenstone Brick Sphere",
shape = "sphere"
},
["I671DEC4B6676EC51,09BB5C6E55D78F97,,,,,,"] =
{
name = "Building Block: Greenstone Disc",
shape = "disc"
},
-- Greystone
["IFF1BEE2E068D20E3,DE1784EBCB8A1282,,,,,,"] =
{
name = "Building Block: Greystone Square",
shape = "tile"
},
["IFF1BEE2D5B75764D,2D5723717AF97EFD,,,,,,"] =
{
name = "Building Block: Greystone Rectangle",
shape = "rectangle"
},
["I42857375124AE699,A775AFA6E9819C92,,,,,,"] =
{
name = "Building Block: Greystone Brick Plank",
shape = "plank"
},
["I6E4C20977E99CCB8,DF7542CCA9205752,,,,,,"] =
{
name = "Building Block: Greystone Brick Cube",
shape = "cube"
},
["I0E057DA1730AA5E3,1EF83DBC68DFC413,,,,,,"] =
{
name = "Building Block: Greystone Triangle",
shape = "triangle"
},
["I52C62DA11FFFAF5B,A96959E6E70D4918,,,,,,"] =
{
name = "Building Block: Greystone Brick Pole",
shape = "pole"
},
["I1B1C042B557AED8C,09CFDAA07F60975A,,,,,,"] =
{
name = "Building Block: Greystone Brick Sphere",
shape = "sphere"
},
["I4E582BF15BEDE239,3E82E339D762FEA6,,,,,,"] =
{
name = "Building Block: Greystone Disc",
shape = "disc"
},
-- Plain Stone
["IFC27A53A7D93B3C5,28927815564C4D18,,,,,,"] =
{
name = "Building Block: Stone Square",
shape = "tile"
},
["IFC27A5392C8F2D7D,2011B804CCFA965A,,,,,,"] =
{
name = "Building Block: Stone Rectangle",
shape = "rectangle"
},
["IFC27A5376CAD89FE,0C2B252DD2777324,,,,,,"] =
{
name = "Building Block: Stone Plank",
shape = "plank"
},
["IFC27A53820DB3178,41B0544C88A55715,,,,,,"] =
{
name = "Building Block: Stone Cube",
shape = "cube"
},
["I0E057DA33EC7161D,FCD4C3F5C0E8B7AB,,,,,,"] =
{
name = "Building Block: Stone Triangle",
shape = "triangle"
},
["IFC27A5362A2868B0,FA284ACA471A28AC,,,,,,"] =
{
name = "Building Block: Stone Pole",
shape = "pole"
},
["I40AC238718345605,D83A9430A4B46758,,,,,,"] =
{
name = "Building Block: Stone Sphere",
shape = "sphere"
},
["I28CB06FA7E88F136,3B9939D780AA925B,,,,,,"] =
{
name = "Building Block: Stone Disc",
shape = "disc"
},
-- Tenebrean Sandstone
["I2323CE7A628C486E,FEE278F0CD768E03,,,,,,"] =
{
name = "Building Block: Tenebrean Sandstone Square",
shape = "tile"
},
["I12E712C272394A17,3657F6113CFE0632,,,,,,"] =
{
name = "Building Block: Tenebrean Sandstone Rectangle",
shape = "rectangle"
},
["I3134244129A76F5E,CECA1285064F29C4,,,,,,"] =
{
name = "Building Block: Tenebrean Sandstone Plank",
shape = "plank"
},
["I29B854A41A0B551F,F31AE64B10EAF1E8,,,,,,"] =
{
name = "Building Block: Tenebrean Sandstone Cube",
shape = "cube"
},
["I35F62B284902A864,6ED54694DD1918FA,,,,,,"] =
{
name = "Building Block: Tenebrean Sandstone Triangle",
shape = "triangle"
},
["I279635117C093ADD,0F50AD392EF072EF,,,,,,"] =
{
name = "Building Block: Tenebrean Sandstone Pole",
shape = "pole"
},
["I29D0A9A075AC2DD5,46BC0CBB407E7042,,,,,,"] =
{
name = "Building Block: Tenebrean Sandstone Sphere",
shape = "sphere"
},
["I2AC3ED744F9F36AA,59A3B2B1823C7A23,,,,,,"] =
{
name = "Building Block: Tenebrean Sandstone Disc",
shape = "disc"
},
-- Tenebrean Slate
["I10B1E45F18AFEA75,053DCDADA36D4077,,,,,,"] =
{
name = "Building Block: Tenebrean Slate Square",
shape = "tile"
},
["IFDBE806422C1AA66,CFABBA55AED77940,,,,,,"] =
{
name = "Building Block: Tenebrean Slate Rectangle",
shape = "rectangle"
},
["I738752287EEC5560,7C3E3D5EE8401D86,,,,,,"] =
{
name = "Building Block: Tenebrean Slate Plank",
shape = "plank"
},
["IFD5F53F97C1FC7A2,10E154919495BC50,,,,,,"] =
{
name = "Building Block: Tenebrean Slate Cube",
shape = "cube"
},
["I441BA26A64E7FF3D,F8C05C6D38144115,,,,,,"] =
{
name = "Building Block: Tenebrean Slate Triangle",
shape = "triangle"
},
["I0FC5973452A1EF23,15D057950680E89D,,,,,,"] =
{
name = "Building Block: Tenebrean Slate Pole",
shape = "pole"
},
["I06F20AC82FEB5DE6,35F069DB9DE6220D,,,,,,"] =
{
name = "Building Block: Tenebrean Slate Sphere",
shape = "sphere"
},
["I47B27F9416A476D2,3530A347FE1A3A50,,,,,,"] =
{
name = "Building Block: Tenebrean Slate Disc",
shape = "disc"
},
-- Tenebrean Stone
["I2A38D13C3B04261E,00CC3D795E860D1A,,,,,,"] =
{
name = "Building Block: Tenebrean Stone Square",
shape = "tile"
},
["I0E65F685676C8DEA,BD32BE4948157793,,,,,,"] =
{
name = "Building Block: Tenebrean Stone Rectangle",
shape = "rectangle"
},
["I031A19E3131D6CD0,1FFC2285D9293CE0,,,,,,"] =
{
name = "Building Block: Tenebrean Stone Plank",
shape = "plank"
},
["IFC3AE4BF06AAD56B,247A59D29C57E080,,,,,,"] =
{
name = "Building Block: Tenebrean Stone Cube",
shape = "cube"
},
["I70B62B3F510C7059,C795D40445AB988A,,,,,,"] =
{
name = "Building Block: Tenebrean Stone Triangle",
shape = "triangle"
},
["I340B2C6D7D6FE929,C930AE3EAA8C03C6,,,,,,"] =
{
name = "Building Block: Tenebrean Stone Pole",
shape = "pole"
},
["I265819494FD57C7D,2BAA5E6FBEAA432A,,,,,,"] =
{
name = "Building Block: Tenebrean Stone Sphere",
shape = "sphere"
},
["I4FFFE9DE259B3B55,4B6BCE9C74D70B41,,,,,,"] =
{
name = "Building Block: Tenebrean Stone Disc",
shape = "disc"
},
------------------
-- Painted Wood --
------------------
-- Black Wood
["I225B19741ECF919B,5FCF6985FBE76B7E,,,,,,"] =
{
name = "Building Block: Black Wood Square",
shape = "tile"
},
["I1F41D458736422A4,227CCE6B4903624F,,,,,,"] =
{
name = "Building Block: Black Wood Rectangle",
shape = "rectangle"
},
["I49ED20CF0347AB5E,EDE3E705D657F55B,,,,,,"] =
{
name = "Building Block: Black Wood Plank",
shape = "plank"
},
["I2A71EFE22B8835BC,397C2A0DAEF7C210,,,,,,"] =
{
name = "Building Block: Black Wood Cube",
shape = "cube"
},
["I722CC1EF160F0746,069ECB4F142A3B56,,,,,,"] =
{
name = "Building Block: Black Wood Triangle",
shape = "triangle"
},
["I1277C40C1E1D4109,0768FE1CFD703C82,,,,,,"] =
{
name = "Building Block: Black Wood Pole",
shape = "pole"
},
["I4093793522C0159B,63B88BE7BC4D32AA,,,,,,"] =
{
name = "Building Block: Black Wood Sphere",
shape = "sphere"
},
["I61115417724B0103,3346799ED6917266,,,,,,"] =
{
name = "Building Block: Black Wood Disc",
shape = "disc"
},
-- Blue Wood
["I296C2090527FF26A,36F51BEF35044AFE,,,,,,"] =
{
name = "Building Block: Blue Wood Square",
shape = "tile"
},
["I296C208D1D704C59,11BDF271D73B3CDD,,,,,,"] =
{
name = "Building Block: Blue Wood Rectangle",
shape = "rectangle"
},
["I40AC238F489B44D9,F461A18236849080,,,,,,"] =
{
name = "Building Block: Blue Wood Plank",
shape = "plank"
},
["I40AC238C51DB6536,E3AA0C99702A890F,,,,,,"] =
{
name = "Building Block: Blue Wood Cube",
shape = "cube"
},
["I296C209352FAB5BB,17C13E8EBA267586,,,,,,"] =
{
name = "Building Block: Blue Wood Triangle",
shape = "triangle"
},
["I40AC239212A0FB19,1E545218A1B0F61C,,,,,,"] =
{
name = "Building Block: Blue Wood Pole",
shape = "pole"
},
["I4690F20563706C61,F3186EBB977423AB,,,,,,"] =
{
name = "Building Block: Blue Wood Sphere",
shape = "sphere"
},
["I316E0F501572B1C9,65E15CBC8BA0C01B,,,,,,"] =
{
name = "Building Block: Blue Wood Disc",
shape = "disc"
},
-- Green Wood
["I296C20913F3B871C,E1D4959F081A5A79,,,,,,"] =
{
name = "Building Block: Green Wood Square",
shape = "tile"
},
["I296C208E796419FE,0A211A7DC4570BCE,,,,,,"] =
{
name = "Building Block: Green Wood Rectangle",
shape = "rectangle"
},
["I40AC23904F4F7F9C,E97FC82D46AA206F,,,,,,"] =
{
name = "Building Block: Green Wood Plank",
shape = "plank"
},
["I40AC238D623F33E2,E7CB76B993B22F16,,,,,,"] =
{
name = "Building Block: Green Wood Cube",
shape = "cube"
},
["I296C20946482DFDC,41321904B96A6998,,,,,,"] =
{
name = "Building Block: Green Wood Triangle",
shape = "triangle"
},
["I40AC239314B5AEBA,3056A92D2D0E4094,,,,,,"] =
{
name = "Building Block: Green Wood Pole",
shape = "pole"
},
["I30A3F79C2A4643E7,CFBACFF2921417C2,,,,,,"] =
{
name = "Building Block: Green Wood Sphere",
shape = "sphere"
},
["I3B7236883A273B68,EF464DAFC99F4889,,,,,,"] =
{
name = "Building Block: Green Wood Disc",
shape = "disc"
},
-- Grey Wood
["IFE55763728218075,6E424275E575ED1E,,,,,,"] =
{
name = "Building Block: Grey Wood Square",
shape = "tile"
},
["IFD4FB6B32537401B,2E647DA7A1831AA3,,,,,,"] =
{
name = "Building Block: Grey Wood Rectangle",
shape = "rectangle"
},
["IFBC6132B6514F5F5,4E92801DA5A94749,,,,,,"] =
{
name = "Building Block: Grey Wood Plank",
shape = "plank"
},
["I04CBFEFD21EFBA65,2007E1134147E9EB,,,,,,"] =
{
name = "Building Block: Grey Wood Cube",
shape = "cube"
},
["I1E48A52B523F3CAF,3C9153EBEB6EB00B,,,,,,"] =
{
name = "Building Block: Grey Wood Triangle",
shape = "triangle"
},
["I2A36B24469E9891C,F87CA8DA4D4F25FF,,,,,,"] =
{
name = "Building Block: Grey Wood Pole",
shape = "pole"
},
["I35863C70209BC5BA,2AEA9A4911A81D16,,,,,,"] =
{
name = "Building Block: Grey Wood Sphere",
shape = "sphere"
},
["I08B697CD73E5D284,3EC93269BFC4E3C5,,,,,,"] =
{
name = "Building Block: Grey Wood Disc",
shape = "disc"
},
-- Orange Wood
["I382046281AC59678,21C4738225059BED,,,,,,"] =
{
name = "Building Block: Orange Wood Square",
shape = "tile"
},
["I38B1938F069E41A5,2A135CF2C479FA5A,,,,,,"] =
{
name = "Building Block: Orange Wood Rectangle",
shape = "rectangle"
},
["I2F3B97244D64F18C,FF6F935C882B2ADD,,,,,,"] =
{
name = "Building Block: Orange Wood Plank",
shape = "plank"
},
["I478BFAAF0FAD4C3A,692D9124057CE578,,,,,,"] =
{
name = "Building Block: Orange Wood Cube",
shape = "cube"
},
["I4DC91D0C2351ECB9,E8847230C538EA43,,,,,,"] =
{
name = "Building Block: Orange Wood Triangle",
shape = "triangle"
},
["I3D89997A414C158D,4A201047DA9BAB58,,,,,,"] =
{
name = "Building Block: Orange Wood Pole",
shape = "pole"
},
["I3B1B44CC17FD37AF,35875B84A6D6C7F2,,,,,,"] =
{
name = "Building Block: Orange Wood Sphere",
shape = "sphere"
},
["I4F03BB16771A571E,18C4FC2A162E83F5,,,,,,"] =
{
name = "Building Block: Orange Wood Disc",
shape = "disc"
},
-- Pink Wood
["I6671FD092BBD97AF,0C8AFC14CAAE4D1C,,,,,,"] =
{
name = "Building Block: Pink Wood Square",
shape = "tile"
},
["I4AB2792310D7E971,E5A8D53060EAE97B,,,,,,"] =
{
name = "Building Block: Pink Wood Rectangle",
shape = "rectangle"
},
["I43C6B15B2B94A8EA,348FA72DBA0B243D,,,,,,"] =
{
name = "Building Block: Pink Wood Plank",
shape = "plank"
},
["I4EB5154F67FD7999,0F8802B732943B41,,,,,,"] =
{
name = "Building Block: Pink Wood Cube",
shape = "cube"
},
["I2AE82CE0756220D4,E1EBE48D9F618214,,,,,,"] =
{
name = "Building Block: Pink Wood Triangle",
shape = "triangle"
},
["I4BEF28FA0BA08B69,202ED0238B2BFA19,,,,,,"] =
{
name = "Building Block: Pink Wood Pole",
shape = "pole"
},
["I430ADCEE654B2502,DE443AD8CE6467B7,,,,,,"] =
{
name = "Building Block: Pink Wood Sphere",
shape = "sphere"
},
["I6595EABA50F5F3ED,F8C2DE5A36202291,,,,,,"] =
{
name = "Building Block: Pink Wood Disc",
shape = "disc"
},
-- Purple Wood
["I508B34B957B008DC,317E3892829BB98A,,,,,,"] =
{
name = "Building Block: Purple Wood Square",
shape = "tile"
},
["I724FBE48147B0EB7,CFCCD850D57F148B,,,,,,"] =
{
name = "Building Block: Purple Wood Rectangle",
shape = "rectangle"
},
["I747D2CB03E1D6BAA,CF7D605B9448FE2C,,,,,,"] =
{
name = "Building Block: Purple Wood Plank",
shape = "plank"
},
["I549EF4A046F0819B,F34A11AB87CD1372,,,,,,"] =
{
name = "Building Block: Purple Wood Cube",
shape = "cube"
},
["I4934EEA76311FF33,520D955C50F0A601,,,,,,"] =
{
name = "Building Block: Purple Wood Triangle",
shape = "triangle"
},
["I667069E87DB50E0C,09519BCDBD0F51C3,,,,,,"] =
{
name = "Building Block: Purple Wood Pole",
shape = "pole"
},
["I5B60C49967DBDD46,72BFDD81233568EC,,,,,,"] =
{
name = "Building Block: Purple Wood Sphere",
shape = "sphere"
},
["I7AF14E60724FB700,F2BEE36E0EE4DBC3,,,,,,"] =
{
name = "Building Block: Purple Wood Disc",
shape = "disc"
},
-- Red Wood
["I296C209213A44A57,D229F38471CA2871,,,,,,"] =
{
name = "Building Block: Red Wood Square",
shape = "tile"
},
["I296C208F33BDC5E1,CFB7E23A8CB358E2,,,,,,"] =
{
name = "Building Block: Red Wood Rectangle",
shape = "rectangle"
},
["I40AC23917D1C7144,FB821F425206644A,,,,,,"] =
{
name = "Building Block: Red Wood Plank",
shape = "plank"
},
["I40AC238E2007C28D,E60244E1E5369AE2,,,,,,"] =
{
name = "Building Block: Red Wood Cube",
shape = "cube"
},
["I296C2095060E84F6,F70B8DBB4F162467,,,,,,"] =
{
name = "Building Block: Red Wood Triangle",
shape = "triangle"
},
["I296C208C3E68A987,E2D76AF250A7C1C9,,,,,,"] =
{
name = "Building Block: Red Wood Pole",
shape = "pole"
},
["I775F866D5B818D20,450C14FACAD318B9,,,,,,"] =
{
name = "Building Block: Red Wood Sphere",
shape = "sphere"
},
["I0C5CAF1B26772D55,0CFE78F9847293D1,,,,,,"] =
{
name = "Building Block: Red Wood Disc",
shape = "disc"
},
-- White Wood
["IFC8ABCEB0BDE99BD,08005855E62E2C2D,,,,,,"] =
{
name = "Building Block: White Wood Square",
shape = "tile"
},
["IFA1EC9315434666B,18A8CD0825FFD33E,,,,,,"] =
{
name = "Building Block: White Wood Rectangle",
shape = "rectangle"
},
["IFA1AE7594ADD5456,E4753059B4A878D0,,,,,,"] =
{
name = "Building Block: White Wood Plank",
shape = "plank"
},
["I00343AC1138B4469,CF4DEE0D0937E53F,,,,,,"] =
{
name = "Building Block: White Wood Cube",
shape = "cube"
},
["I06F55391345A6B57,EA9FF73A7C069FF5,,,,,,"] =
{
name = "Building Block: White Wood Triangle",
shape = "triangle"
},
["I2443AC703580D8DF,D9631641F95BE9EB,,,,,,"] =
{
name = "Building Block: White Wood Pole",
shape = "pole"
},
["IFD13525F5A44D6AF,53E92D28B670111F,,,,,,"] =
{
name = "Building Block: White Wood Sphere",
shape = "sphere"
},
["I07137EA27112A05D,3927034D866A25F1,,,,,,"] =
{
name = "Building Block: White Wood Disc",
shape = "disc"
},
-- Yellow Wood
["I79EED1FE12E22261,830E1623B1C381FB,,,,,,"] =
{
name = "Building Block: Yellow Wood Square",
shape = "tile"
},
["I74EEA42D1CFF735F,D66EAB74F966ABE0,,,,,,"] =
{
name = "Building Block: Yellow Wood Rectangle",
shape = "rectangle"
},
["I7FA1E26671F74743,B7EC4F8117B16987,,,,,,"] =
{
name = "Building Block: Yellow Wood Plank",
shape = "plank"
},
["I6C0C73C81B0714D6,4A33BB10576BB5B5,,,,,,"] =
{
name = "Building Block: Yellow Wood Cube",
shape = "cube"
},
["I5369D5E9526A025E,D6344E060047C47A,,,,,,"] =
{
name = "Building Block: Yellow Wood Triangle",
shape = "triangle"
},
["I7BA99FD93FC632EA,254AB326928F05B4,,,,,,"] =
{
name = "Building Block: Yellow Wood Pole",
shape = "pole"
},
["I709DA24B41BCF9F2,D6C9317B1D434C67,,,,,,"] =
{
name = "Building Block: Yellow Wood Sphere",
shape = "sphere"
},
["I7DABF6E013163282,3E95BEC770535E3E,,,,,,"] =
{
name = "Building Block: Yellow Wood Disc",
shape = "disc"
},
----------
-- Wood --
----------
-- Carved Wood
["I3818BADB6A10DCFC,F63E89D9C91C3874,,,,,,"] =
{
name = "Building Block: Carved Wood Square",
shape = "tile"
},
["I3818BADA6ED04521,10D72EFD29EF69EF,,,,,,"] =
{
name = "Building Block: Carved Wood Rectangle",
shape = "rectangle"
},
["I3818BAD86D04D244,348BC924BC59DEB6,,,,,,"] =
{
name = "Building Block: Carved Wood Plank",
shape = "plank"
},
["I3818BAD726D6F247,E9D76853DC14A2B4,,,,,,"] =
{
name = "Building Block: Carved Wood Cube",
shape = "cube"
},
["I3818BADC01097FD6,252511584FB0BA26,,,,,,"] =
{
name = "Building Block: Carved Wood Triangle",
shape = "triangle"
},
["I3818BAD918BD92CD,FCFEF90E156F027F,,,,,,"] =
{
name = "Building Block: Carved Wood Pole",
shape = "pole"
},
["I6846DACA1918E2B7,3F9B19453FC10B42,,,,,,"] =
{
name = "Building Block: Carved Wood Sphere",
shape = "sphere"
},
["I3E9A150B19634F49,3C9DF322C13AA502,,,,,,"] =
{
name = "Building Block: Carved Wood Disc",
shape = "disc"
},
-- Dark Wood
["I4390449D04E5F368,84B928CA65DE0EE0,,,,,,"] =
{
name = "Building Block: Dark Wood Square",
shape = "tile"
},
["I56E5E8EA1EF90962,5D0746BF85DBFC23,,,,,,"] =
{
name = "Building Block: Dark Wood Rectangle",
shape = "rectangle"
},
["I674D9B7F7947C364,489E1D34A1604689,,,,,,"] =
{
name = "Building Block: Dark Wood Plank",
shape = "plank"
},
["I3B304F594D0FB5F3,12B734E4578639B3,,,,,,"] =
{
name = "Building Block: Dark Wood Cube",
shape = "cube"
},
["I3CAAAA3F72DEDC45,11A0FEE90A55ACEF,,,,,,"] =
{
name = "Building Block: Dark Wood Triangle",
shape = "triangle"
},
["I160F9BC315C2E20F,B8E92ED42593AF20,,,,,,"] =
{
name = "Building Block: Dark Wood Pole",
shape = "pole"
},
["I13522A6F0C98AD5E,EFB4D69796ECAC6D,,,,,,"] =
{
name = "Building Block: Dark Wood Sphere",
shape = "sphere"
},
["I0DFFF2E11EEDD6CB,311A4A2E29E699AC,,,,,,"] =
{
name = "Building Block: Dark Wood Disc",
shape = "disc"
},
-- Greywood
["I3818BACE65BAECAE,CB64CFBB2FE0F71C,,,,,,"] =
{
name = "Building Block: Greywood Square",
shape = "tile"
},
["I391DEDC1145BB696,FBDDE244C8FF6361,,,,,,"] =
{
name = "Building Block: Greywood Rectangle",
shape = "rectangle"
},
["I4CF0820D3C7CE954,721EF7930F0633C2,,,,,,"] =
{
name = "Building Block: Greywood Plank",
shape = "plank"
},
["I391DEDC044825E6A,2C0F2BEF9496217D,,,,,,"] =
{
name = "Building Block: Greywood Cube",
shape = "cube"
},
["I5061383166421B87,6A62D6F1ED761E9A,,,,,,"] =
{
name = "Building Block: Greyood Pole",
shape = "pole"
},
["I3818BACF6A31F262,C8E7923BA3CEB795,,,,,,"] =
{
name = "Building Block: Greywood Triangle",
shape = "triangle"
},
["I1D6F773153CDA645,526E57A293BC3A19,,,,,,"] =
{
name = "Building Block: Greywood Sphere",
shape = "sphere"
},
["I3DF6E3CB3779FD8A,4ED9EC2055550794,,,,,,"] =
{
name = "Building Block: Greywood Disc",
shape = "disc"
},
-- Mahogany Wood
["I2B82E9F86386F5C0,33EF1DB6A44B749B,,,,,,"] =
{
name = "Building Block: Mahogany Wood Square",
shape = "tile"
},
["I0A6CB1110E6DBA47,EAC71800AB74AAFD,,,,,,"] =
{
name = "Building Block: Mahogany Wood Rectangle",
shape = "rectangle"
},
["I42EDA2E16662817E,24F3A09411280741,,,,,,"] =
{
name = "Building Block: Mahogany Wood Plank",
shape = "plank"
},
["I52783D8A36AABA62,FA7291F9A70E2039,,,,,,"] =
{
name = "Building Block: Mahogany Wood Cube",
shape = "cube"
},
["I0809AD4A4A1DFC68,2794FDA3E50ABAD3,,,,,,"] =
{
name = "Building Block: Mahogany Wood Triangle",
shape = "triangle"
},
["I01550B255430DCF5,DE4F028308A8A50C,,,,,,"] =
{
name = "Building Block: Mahogany Wood Pole",
shape = "pole"
},
["I085DEFBA22016E61,AFCB722569078453,,,,,,"] =
{
name = "Building Block: Mahogany Wood Sphere",
shape = "sphere"
},
["I658E18495CEDCCC1,0C1822FFF7A3F839,,,,,,"] =
{
name = "Building Block: Mahogany Wood Disc",
shape = "disc"
},
-- Oak Wood
["I30BE36EC507BA0B1,5C09E2E3AE41C009,,,,,,"] =
{
name = "Building Block: Oak Wood Square",
shape = "tile"
},
["I0AE383E32EB63261,C6E67030C0B8CEBA,,,,,,"] =
{
name = "Building Block: Oak Wood Rectangle",
shape = "rectangle"
},
["I222B45C722A64D95,BBB199BC5DAE2D19,,,,,,"] =
{
name = "Building Block: Oak Wood Plank",
shape = "plank"
},
["I48C073E50D8E8B13,FC4F01A4C3E21D6C,,,,,,"] =
{
name = "Building Block: Oak Wood Cube",
shape = "cube"
},
["I69E6D1E217E52D6D,0BFA324F11A2ED9E,,,,,,"] =
{
name = "Building Block: Oak Wood Triangle",
shape = "triangle"
},
["I36B7E40766C21D76,369A1C2AEEFD41F3,,,,,,"] =
{
name = "Building Block: Oak Wood Pole",
shape = "pole"
},
["IFBE7167A6C70F946,2BEB309F51C0C3FB,,,,,,"] =
{
name = "Building Block: Oak Wood Sphere",
shape = "sphere"
},
["I2522F217277071A5,2C7DBB5FA3227FDF,,,,,,"] =
{
name = "Building Block: Oak Wood Disc",
shape = "disc"
},
-- Plain Wood
["IFE33236342049AFE,D721F224FC31EDF2,,,,,,"] =
{
name = "Building Block: Wood Square",
shape = "tile"
},
["IFF73FC9D69486DB4,369028719C371C12,,,,,,"] =
{
name = "Building Block: Wood Rectangle",
shape = "rectangle"
},
["IFA2C50EE0883B241,146F58B81707AFF4,,,,,,"] =
{
name = "Building Block: Wood Plank",
shape = "plank"
},
["IFD1D82C91B96FF04,2DE987CE7FA240C7,,,,,,"] =
{
name = "Building Block: Wood Cube",
shape = "cube"
},
["IFA78D5AE7889F999,4B12478968ABE5AB,,,,,,"] =
{
name = "Building Block: Wood Pole",
shape = "pole"
},
["I0E057DA426550772,4D553AB71D69591C,,,,,,"] =
{
name = "Building Block: Wood Triangle",
shape = "triangle"
},
["I40AC23860DF2E6E5,C349D19DBCDEF6A9,,,,,,"] =
{
name = "Building Block: Wood Sphere",
shape = "sphere"
},
["I3F8EE74E0D145C77,56C322D325A0A49A,,,,,,"] =
{
name = "Building Block: Wood Disc",
shape = "disc"
},
-- Wood Beam
["I40AC238A1D97D570,BFA55E6FD970776E,,,,,,"] =
{
name = "Building Block: Wood Beam Rectangle",
shape = "rectangle"
},
["I785EE30E5A5C8EE5,2DDECF9329ACC08F,,,,,,"] =
{
name = "Building Block: Wood Beam Triangle",
shape = "triangle"
},
["I48810DEB3ED588C4,59BEB80B9B74C380,,,,,,"] =
{
name = "Building Block: Wood Beam Plank",
shape = "plank"
},
["I40AC238B45C0D1CB,2043F0845228074B,,,,,,"] =
{
name = "Building Block: Wood Beam Cube",
shape = "cube"
},
["I5F86754D1DC031C7,448E5E6AF855D9AB,,,,,,"] =
{
name = "Building Block: Wood Beam Pole",
shape = "pole"
},
["I40AC23891893C680,E2A013511D2CFD71,,,,,,"] =
{
name = "Building Block: Wood Beam Square",
shape = "tile"
},
["I3EE00E2311A0E1B8,1411003D9E157F34,,,,,,"] =
{
name = "Building Block: Wood Beam Sphere",
shape = "sphere"
},
["I7225C62478610192,13A8487ED267CDDE,,,,,,"] =
{
name = "Building Block: Wood Beam Disc",
shape = "disc"
},
-----------
-- Misc. --
-----------
-- Ice
["I22A79B1D657B31D9,5A86827970176F3F,,,,,,"] =
{
name = "Building Block: Ice Triangle",
shape = "triangle"
},
["I237032CF70B37A62,4138D47D4E39B99F,,,,,,"] =
{
name = "Building Block: Ice Disc",
shape = "disc"
},
["I6B59D27B2DC1132A,DA0832CD98B12A09,,,,,,"] =
{
name = "Building Block: Ice Plank",
shape = "plank"
},
["I3A506E305876407E,0DB1440928EBF6AA,,,,,,"] =
{
name = "Building Block: Ice Pole",
shape = "pole"
},
["I46DEDDFA1B1EF2B1,12B6DB6640573B89,,,,,,"] =
{
name = "Building Block: Ice Square",
shape = "tile"
},
["I6B41D47E7A06497D,15871F43AB87855A,,,,,,"] =
{
name = "Building Block: Ice Sphere",
shape = "sphere"
},
["I70AAD55D7D382F63,CA0CA796136E401D,,,,,,"] =
{
name = "Building Block: Ice Cube",
shape = "cube"
},
["I1302EFA22521A21B,107FDE65CBEA718C,,,,,,"] =
{
name = "Building Block: Ice Rectangle",
shape = "rectangle"
},
-- Glass
["I784602D1145F1FA3,1C52D7225625EF23,,,,,,"] =
{
name = "Building Block: Glass Cube",
shape = "cube"
},
["I784602CC29D10429,6D0BBDC900615D14,,,,,,"] =
{
name = "Building Block: Glass Disc",
shape = "disc"
},
["I784602D01551C3CA,863977B44C6A4241,,,,,,"] =
{
name = "Building Block: Glass Plank",
shape = "plank"
},
["I784602CD40FD9F07,83D6DDA4B2346984,,,,,,"] =
{
name = "Building Block: Glass Pole",
shape = "pole"
},
["I784602CA53E99F38,3256CF6227E0035F,,,,,,"] =
{
name = "Building Block: Glass Rectangle",
shape = "rectangle"
},
["I784602CF347BE7CF,15325962BAA314BC,,,,,,"] =
{
name = "Building Block: Glass Sphere",
shape = "sphere"
},
["I784602CE13838AA1,556EB47356AF6483,,,,,,"] =
{
name = "Building Block: Glass Square",
shape = "tile"
},
["I784602CB07F3B04F,3333BB6F6E71EDB4,,,,,,"] =
{
name = "Building Block: Glass Triangle",
shape = "triangle"
},
-- Matte Black
["I21F02BCD3E046281,5BF69CFB2BA11883,,,,,,"] =
{
name = "Building Block: Matte Black Square",
shape = "tile"
},
["I02B3816417EF32DF,289F777337601F2B,,,,,,"] =
{
name = "Building Block: Matte Black Rectangle",
shape = "rectangle"
},
["I2FD487046088A2CC,4B09EC43ACD9314D,,,,,,"] =
{
name = "Building Block: Matte Black Plank",
shape = "plank"
},
["I36ADFE527B0ED047,0B3950FD135CDABE,,,,,,"] =
{
name = "Building Block: Matte Black Cube",
shape = "cube"
},
["I3420F93A778D86DE,D5EF41A6CE1F6AAC,,,,,,"] =
{
name = "Building Block: Matte Black Triangle",
shape = "triangle"
},
["I372208105FB7713C,F97B6E2981527076,,,,,,"] =
{
name = "Building Block: Matte Black Pole",
shape = "pole"
},
["I599DF6FA214429BA,F6D85025BA29A356,,,,,,"] =
{
name = "Building Block: Matte Black Sphere",
shape = "sphere"
},
["I3A29DB8F6CCB7C58,191811B1AB90E083,,,,,,"] =
{
name = "Building Block: Matte Black Disc",
shape = "disc"
},
-- Water
["I784602D913007285,4949C035AC42DC57,,,,,,"] =
{
name = "Building Block: Water Cube",
shape = "cube"
},
["I784602D41F00B39A,148CF9D4CF2F4694,,,,,,"] =
{
name = "Building Block: Water Disc",
shape = "disc"
},
["I784602D87B5DFCD4,3AE9E0465AF56A07,,,,,,"] =
{
name = "Building Block: Water Plank",
shape = "plank"
},
["I784602D57AA4DCC1,4360FAB40A02EED5,,,,,,"] =
{
name = "Building Block: Water Pole",
shape = "pole"
},
["I784602D27EC61370,426904BD02C5B958,,,,,,"] =
{
name = "Building Block: Water Rectangle",
shape = "rectangle"
},
["I784602D77AA6302D,37EE4478A3D4311F,,,,,,"] =
{
name = "Building Block: Water Sphere",
shape = "sphere"
},
["I784602D650FF82A7,872E664CD3431A4B,,,,,,"] =
{
name = "Building Block: Water Square",
shape = "tile"
},
["I784602D35A6C051F,546BDF208E228082,,,,,,"] =
{
name = "Building Block: Water Triangle",
shape = "triangle"
},
-- Water (No Collision)
["I4E8218B3662200A6,24942046EA4B026B,,,,,,"] =
{
name = "Building Block: Water Cube (No Collision)",
shape = "cube"
},
["I511B4EA1406AD6CA,B65FFFBCAB30AD86,,,,,,"] =
{
name = "Building Block: Water Disc (No Collision)",
shape = "disc"
},
["I694CB84065D70443,7D2F4E151A093742,,,,,,"] =
{
name = "Building Block: Water Plank (No Collision)",
shape = "plank"
},
["I5BE9C17954CCAC68,1DE9D35FAFB1064B,,,,,,"] =
{
name = "Building Block: Water Pole (No Collision)",
shape = "pole"
},
["IFB8E921A5AE404DD,D984FB1F8F968002,,,,,,"] =
{
name = "Building Block: Water Rectangle (No Collision)",
shape = "rectangle"
},
["I1D712E3D3F5E47D3,D85C7D2BB13DB00F,,,,,,"] =
{
name = "Building Block: Water Sphere (No Collision)",
shape = "sphere"
},
["I783A11337F048555,4F30C26CC3945D5F,,,,,,"] =
{
name = "Building Block: Water Tile (No Collision)",
shape = "tile"
},
["I791185A6354E63A1,EF1EBA549CC8CF54,,,,,,"] =
{
name = "Building Block: Water Triangle (No Collision)",
shape = "triangle"
},
------------
-- FLOORS --
------------
["I3DBC6F813FEE8276,420B925FFB20903A,,,,,,"] =
{
name = "Wood Beam Floor",
shape = "floor"
},
["I3DBC6F8310B56995,5A51FE755B6DC427,,,,,,"] =
{
name = "Wood Beam Hall Floor",
shape = "hall floor"
},
["I3DBC6F8527DC4CE8,07D843A4F431DF96,,,,,,"] =
{
name = "Large Wood Beam Floor",
shape = "large floor"
},
-- Wood Plank
["IFD54E96A6AE1BAF2,F3D460F2A845DAED,,,,,,"] =
{
name = "Wood Beam Floor",
shape = "floor"
},
["IFD54E96C0A53D2BC,1EDF064099D77BCE,,,,,,"] =
{
name = "Wood Beam Hall Floor",
shape = "hall floor"
},
["IFD54E96E041DE463,158AFFC52437895E,,,,,,"] =
{
name = "Large Wood Beam Floor",
shape = "large floor"
},
-- Sandstone Tile
["IFD54E96B6C3D73FC,C758985AE27EC7CF,,,,,,"] =
{
name = "Sandstone Tile Floor",
shape = "floor"
},
["IFD54E96D586523DA,B0E1E0A4253442F8,,,,,,"] =
{
name = "Sandstone Tile Hall Floor",
shape = "hall floor"
},
["IFD54E96F4F9B1759,FCBC3A13C2807981,,,,,,"] =
{
name = "Large Sandstone Tile Floor",
shape = "large floor"
},
-- Slate Tile
["I3DBC6F824393AED5,6533D7CA4B47B0EA,,,,,,"] =
{
name = "Slate Tile Floor",
shape = "floor"
},
["I3DBC6F840948709F,15AAD3B1F60444F4,,,,,,"] =
{
name = "Slate Tile Hall Floor",
shape = "hall floor"
},
["I3DBC6F86700FD32F,2709C7403F4C6855,,,,,,"] =
{
name = "Large Slate Tile Floor",
shape = "large floor"
}
}
for key, details in pairs(Dta.Defaults.ItemDB) do
details.type = key
end
-- Sometimes item type IDs change. This maps [old_ID] = new ID
Dta.Defaults.ItemDB_outdated =
{
["I3818BAD112E22261,DC1C64A4763AFE8C,,,,,,"] = "I3818BAD162A76C77,DC1C64A4763AFE8C,,,,,,"
}
| bsd-3-clause |
sundream/gamesrv | script/card/fire/card244004.lua | 1 | 2334 | --<<card 导表开始>>
local super = require "script.card.fire.card144004"
ccard244004 = class("ccard244004",super,{
sid = 244004,
race = 4,
name = "冰冻陷阱",
type = 102,
magic_immune = 0,
assault = 0,
sneer = 0,
atkcnt = 0,
shield = 0,
warcry = 0,
dieeffect = 0,
sneak = 0,
magic_hurt_adden = 0,
cure_to_hurt = 0,
recoverhp_multi = 1,
magic_hurt_multi = 1,
max_amount = 2,
composechip = 100,
decomposechip = 10,
atk = 0,
maxhp = 0,
crystalcost = 2,
targettype = 0,
halo = nil,
desc = "奥秘:当1个敌对随从攻击时,让其返回到所有者手中,并令其消耗增加(2)",
effect = {
onuse = nil,
ondie = nil,
onhurt = nil,
onrecoverhp = nil,
onbeginround = nil,
onendround = nil,
ondelsecret = nil,
onputinwar = nil,
onremovefromwar = nil,
onaddweapon = nil,
onputinhand = nil,
before_die = nil,
after_die = nil,
before_hurt = nil,
after_hurt = nil,
before_recoverhp = nil,
after_recoverhp = nil,
before_beginround = nil,
after_beginround = nil,
before_endround = nil,
after_endround = nil,
before_attack = {addbuff={addcrystalcost=2}},
after_attack = nil,
before_playcard = nil,
after_playcard = nil,
before_putinwar = nil,
after_putinwar = nil,
before_removefromwar = nil,
after_removefromwar = nil,
before_addsecret = nil,
after_addsecret = nil,
before_delsecret = nil,
after_delsecret = nil,
before_addweapon = nil,
after_addweapon = nil,
before_delweapon = nil,
after_delweapon = nil,
before_putinhand = nil,
after_putinhand = nil,
before_removefromhand = nil,
after_removefromhand = nil,
},
})
function ccard244004:init(conf)
super.init(self,conf)
--<<card 导表结束>>
end --导表生成
function ccard244004:load(data)
if not data or not next(data) then
return
end
super.load(self,data)
-- todo: load data
end
function ccard244004:save()
local data = super.save(self)
-- todo: save data
return data
end
return ccard244004
| gpl-2.0 |
tomm/pioneer | data/libs/EquipSet.lua | 1 | 8517 | -- Copyright © 2008-2016 Pioneer Developers. See AUTHORS.txt for details
-- Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
local utils = import("utils")
local Serializer = import("Serializer")
--
-- Class: EquipSet
--
-- A container for a ship's equipment.
local EquipSet = utils.inherits(nil, "EquipSet")
EquipSet.default = {
cargo=0,
engine=1,
laser_front=1,
laser_rear=0,
missile=0,
ecm=1,
radar=1,
target_scanner=1,
hypercloud=1,
hull_autorepair=1,
energy_booster=1,
atmo_shield=1,
cabin=50,
shield=9999,
scoop=2,
laser_cooler=1,
cargo_life_support=1,
autopilot=1,
trade_computer=1,
sensor = 8,
thruster = 1
}
function EquipSet.New (slots)
local obj = {}
obj.slots = {}
for k, n in pairs(EquipSet.default) do
obj.slots[k] = {__occupied = 0, __limit = n}
end
for k, n in pairs(slots) do
obj.slots[k] = {__occupied = 0, __limit = n}
end
setmetatable(obj, EquipSet.meta)
return obj
end
local listeners = {}
function EquipSet:AddListener(listener)
listeners[self] = listener
end
function EquipSet:CallListener()
if listeners[self] then
listeners[self]()
end
end
--
-- Group: Methods
--
--
-- Method: FreeSpace
--
-- returns the available space in the given slot.
--
-- Parameters:
--
-- slot - The slot name.
--
-- Return:
--
-- free_space - The available space (integer)
--
function EquipSet:FreeSpace (slot)
local s = self.slots[slot]
if not s then
return 0
end
return s.__limit - s.__occupied
end
function EquipSet:SlotSize(slot)
local s = self.slots[slot]
if not s then
return 0
end
return s.__limit
end
--
-- Method: OccupiedSpace
--
-- returns the space occupied in the given slot.
--
-- Parameters:
--
-- slot - The slot name.
--
-- Return:
--
-- occupied_space - The occupied space (integer)
--
function EquipSet:OccupiedSpace (slot)
local s = self.slots[slot]
if not s then
return 0
end
return s.__occupied
end
--
-- Method: Count
--
-- returns the number of occurrences of the given equipment in the specified slot.
--
-- Parameters:
--
-- item - The equipment to count.
--
-- slots - List of the slots to check. You can also provide a string if it
-- is only one slot. If this argument is not provided, all slots
-- will be searched.
--
-- Return:
--
-- free_space - The available space (integer)
--
function EquipSet:Count(item, slots)
local to_check
if type(slots) == "table" then
to_check = {}
for _, s in ipairs(slots) do
table.insert(to_check, self.slots[s])
end
elseif slots == nil then
to_check = self.slots
else
to_check = {self.slots[slots]}
end
local count = 0
for _, slot in pairs(to_check) do
for _, e in pairs(slot) do
if e == item then
count = count + 1
end
end
end
return count
end
function EquipSet:__TriggerCallbacks(ship, slot)
ship:UpdateEquipStats()
if slot == "cargo" then -- TODO: build a proper property system for the slots
ship:setprop("usedCargo", self.slots.cargo.__occupied)
else
ship:setprop("totalCargo", math.min(self.slots.cargo.__limit, self.slots.cargo.__occupied+ship.freeCapacity))
end
self:CallListener()
end
-- Method: __Remove_NoCheck (PRIVATE)
--
-- Remove equipment without checking whether the slot is appropriate nor
-- calling the uninstall hooks nor even checking the arguments sanity.
-- It DOES check the free place in the slot.
--
-- Parameters:
--
-- Please refer to the Remove method.
--
-- Return:
--
-- Please refer to the Remove method.
--
function EquipSet:__Remove_NoCheck (item, num, slot)
local s = self.slots[slot]
if not s or s.__occupied == 0 then
return 0
end
local removed = 0
for i = 1,s.__limit do
if removed >= num or s.__occupied <= 0 then
return removed
end
if s[i] == item then
s[i] = nil
removed = removed + 1
s.__occupied = s.__occupied - 1
end
end
return removed
end
-- Method: __Add_NoCheck (PRIVATE)
--
-- Add equipment without checking whether the slot is appropriate nor
-- calling the install hooks nor even checking the arguments sanity.
-- It DOES check the free place in the slot.
--
-- Parameters:
--
-- Please refer to the Add method.
--
-- Return:
--
-- Please refer to the Add method.
--
function EquipSet:__Add_NoCheck(item, num, slot)
if self:FreeSpace(slot) == 0 then
return 0
end
local s = self.slots[slot]
local added = 0
for i = 1,s.__limit do
if added >= num or s.__occupied >= s.__limit then
return added
end
if not s[i] then
s[i] = item
added = added + 1
s.__occupied = s.__occupied + 1
end
end
return added
end
-- Method: Add
--
-- Add some equipment to the set, filling the specified slot as much as
-- possible.
--
-- Parameters:
--
-- item - the equipment to install
-- num - the number of pieces to install. If nil, only one will be installed.
-- slot - the slot where to install the equipment. It will be checked against
-- the equipment itself, the method will return -1 if the slot isn't
-- valid. If nil, the default slot for the equipment will be used.
--
-- Return:
--
-- installed - the number of pieces actually installed, or -1 if the specified
-- slot is not valid.
--
function EquipSet:Add(ship, item, num, slot)
num = num or 1
if not slot then
slot = item:GetDefaultSlot(ship)
elseif not item:IsValidSlot(slot, ship) then
return -1
end
local added = self:__Add_NoCheck(item, num, slot)
if added == 0 then
return 0
end
local postinst_diff = added - item:Install(ship, added, slot)
if postinst_diff > 0 then
self:__Remove_NoCheck(item, postinst_diff, slot)
added = added-postinst_diff
end
if added > 0 then
self:__TriggerCallbacks(ship, slot)
end
return added
end
-- Method: Remove
--
-- Remove some equipment from the set.
--
-- Parameters:
--
-- item - the equipment to remove.
-- num - the number of pieces to uninstall. If nil, only one will be removed.
-- slot - the slot where to install the equipment. If nil, the default slot
-- for the equipment will be used.
--
-- Return:
--
-- removed - the number of pieces actually removed.
--
function EquipSet:Remove(ship, item, num, slot)
num = num or 1
if not slot then
slot = item:GetDefaultSlot(ship)
end
local removed = self:__Remove_NoCheck(item, num, slot)
if removed == 0 then
return 0
end
local postuninstall_diff = removed - item:Uninstall(ship, removed, slot)
if postuninstall_diff > 0 then
self:__Add_NoCheck(item, postuninstall_diff, slot)
removed = removed-postuninstall_diff
end
if removed > 0 then
self:__TriggerCallbacks(ship, slot)
end
return removed
end
local EquipSet__ClearSlot = function (self, ship, slot)
local s = self.slots[slot]
local item_counts = {}
for k,v in pairs(s) do
if type(k) == 'number' then
item_counts[v] = (item_counts[v] or 0) + 1
end
end
for item, count in pairs(item_counts) do
local uninstalled = item:Uninstall(ship, count, slot)
-- FIXME support failed uninstalls??
-- note that failed uninstalls are almost incompatible with Ship::SetShipType
assert(uninstalled == count)
end
self.slots[slot] = {__occupied = 0, __limit = s.__limit}
self:__TriggerCallbacks(ship, slot)
end
function EquipSet:Clear(ship, slot_names)
if slot_names == nil then
for k,_ in pairs(self.slots) do
EquipSet__ClearSlot(self, ship, k)
end
elseif type(slot_names) == 'string' then
EquipSet__ClearSlot(self, ship, slot_names)
elseif type(slot_names) == 'table' then
for _, s in ipairs(slot_names) do
EquipSet__ClearSlot(self, ship, s)
end
end
end
function EquipSet:Get(slot, index)
if type(index) == "number" then
return self.slots[slot][index]
end
local ret = {}
for i,v in pairs(self.slots[slot]) do
if type(i) == 'number' then
ret[i] = v
end
end
return ret
end
function EquipSet:Set(ship, slot_name, index, item)
local slot = self.slots[slot_name]
if index < 1 or index > slot.__limit then
error("EquipSet:Set(): argument 'index' out of range")
end
local to_remove = slot[index]
if item == to_remove then return end
if not to_remove or to_remove:Uninstall(ship, 1, slot_name) == 1 then
if not item or item:Install(ship, 1, slot_name) == 1 then
if not item then
slot.__occupied = slot.__occupied - 1
elseif not to_remove then
slot.__occupied = slot.__occupied + 1
end
slot[index] = item
self:__TriggerCallbacks(ship, slot_name)
else -- Rollback the uninstall
if to_remove then to_remove:Install(ship, 1, slot_name) end
end
end
end
Serializer:RegisterClass("EquipSet", EquipSet)
return EquipSet
| gpl-3.0 |
dalvorsn/tests | data/spells/scripts/party/protect.lua | 15 | 1808 | local combat = createCombatObject()
local area = createCombatArea(AREA_CROSS5X5)
setCombatArea(combat, area)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_SUBID, 2)
setConditionParam(condition, CONDITION_PARAM_BUFF_SPELL, 1)
setConditionParam(condition, CONDITION_PARAM_TICKS, 2 * 60 * 1000)
setConditionParam(condition, CONDITION_PARAM_SKILL_SHIELD, 2)
local baseMana = 90
function onCastSpell(cid, var)
local pos = getCreaturePosition(cid)
local membersList = getPartyMembers(cid)
if(membersList == nil or type(membersList) ~= 'table' or #membersList <= 1) then
doPlayerSendCancel(cid, "No party members in range.")
doSendMagicEffect(pos, CONST_ME_POFF)
return LUA_ERROR
end
local affectedList = {}
for _, pid in ipairs(membersList) do
if(getDistanceBetween(getCreaturePosition(pid), pos) <= 36) then
table.insert(affectedList, pid)
end
end
local tmp = #affectedList
if(tmp <= 1) then
doPlayerSendCancel(cid, "No party members in range.")
doSendMagicEffect(pos, CONST_ME_POFF)
return LUA_ERROR
end
local mana = math.ceil((0.9 ^ (tmp - 1) * baseMana) * tmp)
if(getPlayerMana(cid) < mana) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHMANA)
doSendMagicEffect(pos, CONST_ME_POFF)
return LUA_ERROR
end
if(doCombat(cid, combat, var) ~= LUA_NO_ERROR) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
doSendMagicEffect(pos, CONST_ME_POFF)
return LUA_ERROR
end
doPlayerAddMana(cid, -(mana - baseMana), FALSE)
doPlayerAddManaSpent(cid, (mana - baseMana))
for _, pid in ipairs(affectedList) do
doAddCondition(pid, condition)
end
return LUA_NO_ERROR
end
| gpl-2.0 |
Lynx3d/tinker_tools | Settings.lua | 2 | 5781 | local addon, Dta = ...
local Lang = Dta.Lang
-- Set English as Default and fallback
function addLangFallback(language)
setmetatable(Lang[language], { __index = Lang["English"] })
for k, v in pairs(Lang[language]) do
if type(v) == "table" then
setmetatable(v, { __index = Lang["English"][k] })
end
end
end
if not Lang[Dta.Language] or Dta.Language == "German" then -- german is w.i.p.
Dta.Language = "English"
end
addLangFallback("French")
addLangFallback("German")
Dta.Locale = Lang[Dta.Language]
Dta.settings = {}
--------------------------------------
--SAVE AND LOAD SETTINGS
--------------------------------------
Dta.settings.savedsets = {}
Dta.settings.saveddefaults = {
SavedSets = {},
}
Dta.settings.settings = {}
Dta.settings.defaults = {
MainbuttonPosX = 10,
MainbuttonPosY = 100,
MainwindowPosX = 0,
MainwindowPosY = 32,
MovewindowPosX = 0,
MovewindowPosY = 370,
ScalewindowPosX = 0,
ScalewindowPosY = 450,
CopyPastewindowPosX = 320,
CopyPastewindowPosY = 410,
RotatewindowPosX = 0,
RotatewindowPosY = 410,
LoSawindowPosX = 320,
LoSawindowPosY = 450,
ExpImpwindowPosX = 320,
ExpImpwindowPosY = 370,
HelpwindowPosX = 650,
HelpwindowPosY = 335,
FlyingwindowPosX = 475,
FlyingwindowPosY = 32,
AlphabetwindowPosX = 0,
AlphabetwindowPosY = 530,
MeasurementswindowPosX = 0,
MeasurementswindowPosY = 490,
ReskinwindowPosX = 5,
ReskinwindowPosY = 400,
SelectionwindowPosX = 320,
SelectionwindowPosY = 100,
ConnectorwindowPosX = 320,
ConnectorwindowPosY = 200,
Language = "Auto",
WindowStyle = "default",
ConsoleOutput = { [1] = true },
RestoreTools = false
}
Dta.settings.revisions = {
[1] = "DT v1.9.10",
[2] = "v1.2.7",
[3] = "v1.3.1" -- sets w. reference points
}
function Dta.settings.main()
Command.Event.Attach(Event.Addon.SavedVariables.Load.End, Dta.settings.loadEnd, "Loaded settings")
Command.Event.Attach(Event.Addon.SavedVariables.Save.Begin, Dta.settings.saveBegin, "Save settings")
end
-- Load the settings into the settings table
function Dta.settings.loadEnd(hEvent, addonID)
if addonID ~= addon.toc.Identifier then return end
if TinkerT_Settings ~= nil then Dta.settings.settings = TinkerT_Settings end
if TinkerT_Sets ~= nil then Dta.settings.savedsets = TinkerT_Sets end
local language = Dta.settings.get("Language")
if language ~= "Auto" then
if not Lang[language] then
Dta.CPrint("Language '" .. language .. "' is not available.")
else
Dta.Language = language
Dta.Locale = Lang[Dta.Language]
end
end
-- correct unintended cross-reference of saved sets in settings
if Dta.settings.settings["SavedSets"] then
Dta.settings.settings["SavedSets"] = nil
end
-- check if outdated item type IDs need to be replaced
local revision = Dta.settings.get("Revision")
local savedSets = Dta.settings.savedsets and Dta.settings.savedsets.SavedSets
if savedSets and (not revision or revision < Dta.SettingsRevision) then
local replaced = 0
for name, set in pairs(savedSets) do
replaced = replaced + Dta.settings.ConvertOldItems(set)
end
print(string.format("Converted %i outdated items", replaced))
end
end
--Save the settings table
function Dta.settings.saveBegin(hEvent, addonID)
if addonID ~= addon.toc.Identifier then return end
-- set a revision to track changes in setting data layout
Dta.settings.set("Revision", Dta.SettingsRevision)
TinkerT_Settings = Dta.settings.settings
TinkerT_Sets = Dta.settings.savedsets
end
function Dta.settings.ConvertOldItems(set)
local outdated_IDs = Dta.Defaults.ItemDB_outdated
local replaced = 0
for idx, item in pairs(set) do
if outdated_IDs[item.type] then
item.type = outdated_IDs[item.type]
replaced = replaced + 1
end
end
return replaced
end
--------------------------------------
--GET AND SET SETTINGS
--------------------------------------
function Dta.settings.get(setting)
if Dta.settings.settings[setting] ~= nil then
return Dta.settings.settings[setting]
elseif Dta.settings.defaults[setting] ~= nil then
return Dta.settings.defaults[setting]
else
return nil
end
end
function Dta.settings.set(setting, value)
if type(value) ~= "table" and Dta.settings.defaults[setting] == value then
Dta.settings.settings[setting] = nil
else
Dta.settings.settings[setting] = value
end
return Dta.settings.settings[setting]
end
--------------------------------------
--GET AND SET SETS
--------------------------------------
function Dta.settings.get_savedsets(setting)
if Dta.settings.savedsets[setting] ~= nil then
return Dta.settings.savedsets[setting]
elseif Dta.settings.saveddefaults[setting] ~= nil then
return Dta.settings.saveddefaults[setting]
else
return nil
end
end
function Dta.settings.get_defaults(setting)
return Dta.Defaults[setting]
end
function Dta.settings.set_savedsets(setting, value)
if Dta.Defaults[setting] == value then
Dta.settings.savedsets[setting] = nil
else
Dta.settings.savedsets[setting] = value
end
return Dta.settings.savedsets[setting]
end
Dta.settings.main()
--------------------------------------
-- Import Dimension Tools settings
--------------------------------------
function Dta.settings.import_dimtools()
if not Dta.settings.savedsets.SavedSets then
Dta.settings.savedsets.SavedSets = {}
end
local tinker_sets = Dta.settings.savedsets.SavedSets
if type(Dta_Sets) == "table" and type(Dta_Sets.SavedSets) == "table" then
for set_name, set_data in pairs(Dta_Sets.SavedSets) do
if tinker_sets[set_name] then
Dta.CPrint(string.format("skipped: %s", set_name))
else
tinker_sets[set_name] = Dta.copyTable(set_data, true)
Dta.CPrint(string.format("copied: %s", set_name))
end
end
end
-- refresh load/save list if window exists
if Dta.ui.windowLoSa then
Dta.losa.refreshLoadSelect()
end
end
| bsd-3-clause |
siggame/Joueur.lua | games/anarchy/warehouse.lua | 1 | 5094 | -- Warehouse: A typical abandoned warehouse that anarchists hang out in and can be bribed to burn down Buildings.
-- DO NOT MODIFY THIS FILE
-- Never try to directly create an instance of this class, or modify its member variables.
-- Instead, you should only be reading its variables and calling its functions.
local class = require("joueur.utilities.class")
local Building = require("games.anarchy.building")
-- <<-- Creer-Merge: requires -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.
-- you can add additional require(s) here
-- <<-- /Creer-Merge: requires -->>
--- A typical abandoned warehouse that anarchists hang out in and can be bribed to burn down Buildings.
-- @classmod Warehouse
local Warehouse = class(Building)
-- initializes a Warehouse with basic logic as provided by the Creer code generator
function Warehouse:init(...)
Building.init(self, ...)
-- The following values should get overridden when delta states are merged, but we set them here as a reference for you to see what variables this class has.
--- How exposed the anarchists in this warehouse are to PoliceDepartments. Raises when bribed to ignite buildings, and drops each turn if not bribed.
self.exposure = 0
--- The amount of fire added to buildings when bribed to ignite a building. Headquarters add more fire than normal Warehouses.
self.fireAdded = 0
--- (inherited) When true this building has already been bribed this turn and cannot be bribed again this turn.
-- @field[bool] self.bribed
-- @see Building.bribed
--- (inherited) The Building directly to the east of this building, or nil if not present.
-- @field[Building] self.buildingEast
-- @see Building.buildingEast
--- (inherited) The Building directly to the north of this building, or nil if not present.
-- @field[Building] self.buildingNorth
-- @see Building.buildingNorth
--- (inherited) The Building directly to the south of this building, or nil if not present.
-- @field[Building] self.buildingSouth
-- @see Building.buildingSouth
--- (inherited) The Building directly to the west of this building, or nil if not present.
-- @field[Building] self.buildingWest
-- @see Building.buildingWest
--- (inherited) How much fire is currently burning the building, and thus how much damage it will take at the end of its owner's turn. 0 means no fire.
-- @field[number] self.fire
-- @see Building.fire
--- (inherited) String representing the top level Class that this game object is an instance of. Used for reflection to create new instances on clients, but exposed for convenience should AIs want this data.
-- @field[string] self.gameObjectName
-- @see GameObject.gameObjectName
--- (inherited) How much health this building currently has. When this reaches 0 the Building has been burned down.
-- @field[number] self.health
-- @see Building.health
--- (inherited) A unique id for each instance of a GameObject or a sub class. Used for client and server communication. Should never change value after being set.
-- @field[string] self.id
-- @see GameObject.id
--- (inherited) True if this is the Headquarters of the owning player, false otherwise. Burning this down wins the game for the other Player.
-- @field[bool] self.isHeadquarters
-- @see Building.isHeadquarters
--- (inherited) Any strings logged will be stored here. Intended for debugging.
-- @field[{string, ...}] self.logs
-- @see GameObject.logs
--- (inherited) The player that owns this building. If it burns down (health reaches 0) that player gets an additional bribe(s).
-- @field[Player] self.owner
-- @see Building.owner
--- (inherited) The location of the Building along the x-axis.
-- @field[number] self.x
-- @see Building.x
--- (inherited) The location of the Building along the y-axis.
-- @field[number] self.y
-- @see Building.y
end
--- Bribes the Warehouse to light a Building on fire. This adds this building's fireAdded to their fire, and then this building's exposure is increased based on the Manhattan distance between the two buildings.
-- @tparam Building building The Building you want to light on fire.
-- @treturn number The exposure added to this Building's exposure. -1 is returned if there was an error.
function Warehouse:ignite(building)
return tonumber(self:_runOnServer("ignite", {
building = building,
}))
end
--- (inherited) Adds a message to this GameObject's logs. Intended for your own debugging purposes, as strings stored here are saved in the gamelog.
-- @function Warehouse:log
-- @see GameObject:log
-- @tparam string message A string to add to this GameObject's log. Intended for debugging.
-- <<-- Creer-Merge: functions -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.
-- if you want to add any client side logic this is where you can add them
-- <<-- /Creer-Merge: functions -->>
return Warehouse
| mit |
v13inc/mal | lua/step5_tco.lua | 3 | 3041 | #!/usr/bin/env lua
local table = require('table')
local readline = require('readline')
local utils = require('utils')
local types = require('types')
local reader = require('reader')
local printer = require('printer')
local Env = require('env')
local core = require('core')
local List, Vector, HashMap = types.List, types.Vector, types.HashMap
-- read
function READ(str)
return reader.read_str(str)
end
-- eval
function eval_ast(ast, env)
if types._symbol_Q(ast) then
return env:get(ast)
elseif types._list_Q(ast) then
return List:new(utils.map(function(x) return EVAL(x,env) end,ast))
elseif types._vector_Q(ast) then
return Vector:new(utils.map(function(x) return EVAL(x,env) end,ast))
elseif types._hash_map_Q(ast) then
local new_hm = {}
for k,v in pairs(ast) do
new_hm[EVAL(k, env)] = EVAL(v, env)
end
return HashMap:new(new_hm)
else
return ast
end
end
function EVAL(ast, env)
while true do
--print("EVAL: "..printer._pr_str(ast,true))
if not types._list_Q(ast) then return eval_ast(ast, env) end
local a0,a1,a2,a3 = ast[1], ast[2],ast[3],ast[4]
local a0sym = types._symbol_Q(a0) and a0.val or ""
if 'def!' == a0sym then
return env:set(a1, EVAL(a2, env))
elseif 'let*' == a0sym then
local let_env = Env:new(env)
for i = 1,#a1,2 do
let_env:set(a1[i], EVAL(a1[i+1], let_env))
end
env = let_env
ast = a2 -- TCO
elseif 'do' == a0sym then
local el = eval_ast(ast:slice(2,#ast-1), env)
ast = ast[#ast] -- TCO
elseif 'if' == a0sym then
local cond = EVAL(a1, env)
if cond == types.Nil or cond == false then
if a3 then ast = a3 else return types.Nil end -- TCO
else
ast = a2 -- TCO
end
elseif 'fn*' == a0sym then
return types.MalFunc:new(function(...)
return EVAL(a2, Env:new(env, a1, arg))
end, a2, env, a1)
else
local args = eval_ast(ast, env)
local f = table.remove(args, 1)
if types._malfunc_Q(f) then
ast = f.ast
env = Env:new(f.env, f.params, args) -- TCO
else
return f(unpack(args))
end
end
end
end
-- print
function PRINT(exp)
return printer._pr_str(exp, true)
end
-- repl
local repl_env = Env:new()
function rep(str)
return PRINT(EVAL(READ(str),repl_env))
end
-- core.lua: defined using Lua
for k,v in pairs(core.ns) do
repl_env:set(types.Symbol:new(k), v)
end
-- core.mal: defined using mal
rep("(def! not (fn* (a) (if a false true)))")
while true do
line = readline.readline("user> ")
if not line then break end
xpcall(function()
print(rep(line))
end, function(exc)
if exc then
if types._malexception_Q(exc) then
exc = printer._pr_str(exc.val, true)
end
print("Error: " .. exc)
print(debug.traceback())
end
end)
end
| mpl-2.0 |
Alireza5928/new1 | plugins/del.lua | 22 | 1098 | local function delmsg (arg,data)
for k,v in pairs(data.messages_) do
tdcli.deleteMessages(v.chat_id_,{[0] = v.id_})
end
end
local function run(msg, matches)
if matches[1] == 'del' then
if msg.chat_id_:match("^-100") then
if is_owner(msg) or is_mod(msg) then
if tonumber(matches[2]) > 100 or tonumber(matches[2]) < 1 then
pm = '_ 100> ÊÚÏÇÏ íÇã åÇí ÞÇÈá ÍÐÝ åÑ ÏÝÚå >1 _'
tdcli.sendMessage(msg.chat_id_, data.msg.id_, 1, pm, 1, 'html')
else
tdcli_function ({
ID = "GetChatHistory",
chat_id_ = msg.chat_id_,
from_message_id_ = 0,
offset_ = 0,
limit_ = tonumber(matches[2])
}, delmsg, nil)
pm ='*'..matches[2]..'* _íÇã ÇÎíÑ Ç ÔÏ_'
tdcli.sendMessage(msg.chat_id_, msg.id_, 1, pm, 1, 'html')
end
end
else pm ='Çíä ÇãÇä ÝÞØ ÏÑ _ÓæÑ Ñæå_ ããä ÇÓÊ.'
tdcli.sendMessage(msg.chat_id_, msg.id_, 1, pm, 1, 'html')
end
end
end
return {
patterns = {
'^[!#/]([Dd][Ee][Ll]) (%d*)$'
},
run = run
}
-- http://permag.ir
-- @permag_ir
-- @permag_bots | gpl-3.0 |
magnum357i/Magnum-s-Aegisub-Scripts | automation/autoload/mag.template.lua | 1 | 6496 | function lang_switch_keys(lang)
local in_lang = {}
local langs =
{
[1] = {lang_key = "tr", lang_name = "Türkçe", script_name = "Şablon"},
[2] = {lang_key = "en", lang_name = "English", script_name = "Template"}
}
local lang_list = {}
local script_name_list = {}
for i = 1, #langs do
lang_list[langs[i].lang_key] = langs[i].lang_name
script_name_list[langs[i].lang_key] = langs[i].script_name
end
if lang == langs[1].lang_key then
in_lang["module_incompatible"] = "Mag modülünün kurulu sürümü bu lua dosyası ile uyumsuz!\n\nModül dosyasının en az \"%s\" sürümü veya daha üstü gerekiyor.\n\n\nŞimdi indirme sayfasına gitmek ister misiniz?"
in_lang["module_not_found"] = "Mag modülü bulunamadı!\n\nBu lua dosyasını kullanmak için Mag modülünü indirip Aegisub programı kapalıyken\n\"Aegisub/automation/include/\" dizinine taşımanız gerekiyor.\n\n\nŞimdi indirme sayfasına gitmek ister misiniz?"
in_lang["module_yes"] = "Git"
in_lang["module_no"] = "Daha Sonra"
in_lang["s_name"] = langs[1].script_name
in_lang["s_desc"] = "Lua dosyalarımın şablonu. Herhangi bir dosyanın çalışıp çalışmamasına etkisi yoktur."
in_lang["buttonKey1"] = "Uygula"
in_lang["buttonKey2"] = "Kapat"
in_lang["progressKey1"] = "Çalışılıyor..."
elseif lang == langs[2].lang_key then
in_lang["module_incompatible"] = "The installed version of the Mag module is incompatible with this lua file!\n\nAt least \"%s\" version or higher of the module file is required.\n\n\nWould you like to go to the download page now?"
in_lang["module_not_found"] = "The module named Mag could not be found!\n\nTo use this file, you need to download the module named mag\nand move it to \"Aegisub/automation/include/\" directory when Aegisub is off.\n\n\nDo you want to go to download page now?"
in_lang["module_yes"] = "Go"
in_lang["module_no"] = "Later"
in_lang["s_name"] = langs[2].script_name
in_lang["s_desc"] = "This a template for my lua files. There is no effect on whether any file work."
in_lang["buttonKey1"] = "Apply"
in_lang["buttonKey2"] = "Close"
in_lang["progressKey1"] = "Working..."
end
return in_lang, lang_list, script_name_list
end
c_lang_switch = "en"
c_lang,
c_lang_list,
c_script_name_list = lang_switch_keys(c_lang_switch)
script_name = c_lang.s_name
script_description = c_lang.s_desc
script_version = "1"
script_author = "Magnum357"
script_mag_version = "1.1.5.0"
script_file_name = "mag.template"
script_file_ext = ".lua"
include_unicode = true
include_clipboard = true
include_karaskel = true
mag_import, mag = pcall(require, "mag")
if mag_import then
mag.lang = c_lang_switch
c_lock_gui = false
c_buttons1 = {c_lang.buttonKey1, c_lang.buttonKey2}
c = {}
c.comment_mode = true
c.empty_mode = true
c.apply = mag.window.lang.message("select")
gui = {
main1 = {
{class = "label", x = 0, y = 0, width = 1, height = 1, label = mag.window.lang.message("apply")},
apply = {class = "dropdown", name = "u_apply_lines", x = 1, y = 0, width = 1, height = 1, hint = mag.window.lang.message("style_hint1")},
comment_mode = {class = "checkbox", name = "u_comment_mode", x = 1, y = 1, width = 1, height = 1, label = mag.window.lang.message("comment_mode")},
empty_mode = {class = "checkbox", name = "u_empty_mode", x = 1, y = 2, width = 1, height = 1, label = mag.window.lang.message("empty_mode")},
}
}
end
function template(subs,sel)
local line, index
local pcs = false
local lines_index = mag.line.index(subs, sel, c.apply, c.comment_mode, c.empty_mode)
local random_text = {
"I like going out to parties with friends or watching TV.",
"Mrs Miller wants the entire house repainted.",
"The student researched the history of that word.",
"My Russian pen pal and I have been corresponding for several years.",
"Fire had devoured our home."}
mag.window.task(c_lang.progressKey1)
for i = 1, #lines_index do
mag.window.progress(i, #lines_index)
local cancel = aegisub.progress.is_cancelled()
if cancel then break end
if not pcs then pcs = true end
index = lines_index[i]
line = subs[index]
line.text = random_text[mag.rand(1, #random_text)]
subs[index] = line
end
mag.show.no_op(pcs)
end
function add_macro1(subs, sel)
local apply_items = mag.list.full_apply(subs, sel, "comment")
c.apply = mag.array.search_apply(apply_items, c.apply)
gui.main1.apply.items = apply_items
local ok, config
repeat
gui.main1.apply.value = c.apply
gui.main1.comment_mode.value = c.comment_mode
gui.main1.empty_mode.value = c.empty_mode
ok, config = mag.window.dialog(gui.main1, c_buttons1)
c.apply = config.u_apply_lines
c.comment_mode = config.u_comment_mode
c.empty_mode = config.u_empty_mode
until ok == mag.convert.ascii(c_buttons1[1]) and c.apply ~= mag.window.lang.message("select") or ok == mag.convert.ascii(c_buttons1[2])
if ok == mag.convert.ascii(c_buttons1[1]) then
template(subs, sel)
end
end
function check_macro1(subs,sel)
mag.window.task()
if c_lock_gui then
mag.show.log(1, mag.window.lang.message("restart_aegisub"))
else
mag.config.get(c)
local fe, fee = pcall(add_macro1, subs, sel)
mag.window.funce(fe, fee)
mag.window.undo_point()
mag.config.set(c)
end
end
function mag_redirect_gui()
local mag_module_link = "https://github.com/magnum357i/Magnum-s-Aegisub-Scripts"
local k = aegisub.dialog.display({{class = "label", label = mag_gui_message}}, {c_lang.module_yes, c_lang.module_no})
if k == c_lang.module_yes then os.execute("start "..mag_module_link) end
end
if mag_import then
if mag_module_version:gsub("%.", "") < script_mag_version:gsub("%.", "") then
mag_gui_message = string.format(c_lang.module_incompatible, script_mag_version)
aegisub.register_macro(script_name, script_desription, mag_redirect_gui)
else
mag.window.register(script_name.."/"..mag.window.lang.message("gui_tabname"), check_macro1)
mag.window.lang.register()
end
else
mag_gui_message = c_lang.module_not_found
aegisub.register_macro(script_name, script_desription, mag_redirect_gui)
end | mit |
david-xiao/packages | net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/member.lua | 111 | 1535 | -- ------ member configuration ------ --
ds = require "luci.dispatcher"
m5 = Map("mwan3", translate("MWAN Member Configuration"))
m5:append(Template("mwan/config_css"))
mwan_member = m5:section(TypedSection, "member", translate("Members"),
translate("Members are profiles attaching a metric and weight to an MWAN interface<br />" ..
"Names may contain characters A-Z, a-z, 0-9, _ and no spaces<br />" ..
"Members may not share the same name as configured interfaces, policies or rules"))
mwan_member.addremove = true
mwan_member.dynamic = false
mwan_member.sectionhead = "Member"
mwan_member.sortable = true
mwan_member.template = "cbi/tblsection"
mwan_member.extedit = ds.build_url("admin", "network", "mwan", "configuration", "member", "%s")
function mwan_member.create(self, section)
TypedSection.create(self, section)
m5.uci:save("mwan3")
luci.http.redirect(ds.build_url("admin", "network", "mwan", "configuration", "member", section))
end
interface = mwan_member:option(DummyValue, "interface", translate("Interface"))
interface.rawhtml = true
function interface.cfgvalue(self, s)
return self.map:get(s, "interface") or "—"
end
metric = mwan_member:option(DummyValue, "metric", translate("Metric"))
metric.rawhtml = true
function metric.cfgvalue(self, s)
return self.map:get(s, "metric") or "1"
end
weight = mwan_member:option(DummyValue, "weight", translate("Weight"))
weight.rawhtml = true
function weight.cfgvalue(self, s)
return self.map:get(s, "weight") or "1"
end
return m5
| gpl-2.0 |
REZATITAN/AntiSpamBot | plugins/stats.lua | 1 | 4013 | -- Saves the number of messages from a user
-- Can check the number of messages with !stats
do
local NUM_MSG_MAX = 5
local TIME_CHECK = 4 -- seconds
local function user_print_name(user)
if user.print_name then
return user.print_name
end
local text = ''
if user.first_name then
text = user.last_name..' '
end
if user.lastname then
text = text..user.last_name
end
return text
end
-- Returns a table with `name` and `msgs`
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)
-- Users on chat
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user 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
-- Sort users by msgs number
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = ''
for k,user in pairs(users_info) do
text = text..'> '..user.name..' PMs:'..user.msgs..'\n'
end
return text
end
-- Save stats, ban user
local function pre_process(msg)
-- Ignore service msg
if msg.service then
print('Service message')
return msg
end
-- Save user on Redis
if msg.from.type == 'user' then
local hash = 'user:'..msg.from.id
print('Saving user', hash)
if msg.from.print_name then
redis:hset(hash, 'print_name', msg.from.print_name)
end
if msg.from.first_name then
redis:hset(hash, 'first_name', msg.from.first_name)
end
if msg.from.last_name then
redis:hset(hash, 'last_name', msg.from.last_name)
end
end
-- Save stats on Redis
if msg.to.type == 'chat' then
-- User is on chat
local hash = 'chat:'..msg.to.id..':users'
redis:sadd(hash, msg.from.id)
end
-- Total user msgs
local hash = 'msgs:'..msg.from.id..':'..msg.to.id
redis:incr(hash)
-- Check flood
if msg.from.type == 'user' then
local hash = 'user:'..msg.from.id..':msgs'
local msgs = tonumber(redis:get(hash) or 0)
if msgs > NUM_MSG_MAX then
print('User '..msg.from.id..'is flooding '..msgs)
msg = nil
end
redis:setex(hash, TIME_CHECK, msgs+1)
end
return msg
end
local function bot_stats()
local redis_scan = [[
local cursor = '0'
local count = 0
repeat
local r = redis.call("SCAN", cursor, "MATCH", KEYS[1])
cursor = r[1]
count = count + #r[2]
until cursor == '0'
return count]]
-- Users
local hash = 'msgs:*:'..our_id
local r = redis:eval(redis_scan, 1, hash)
local text = 'Users: '..r
hash = 'chat:*:users'
r = redis:eval(redis_scan, 1, hash)
text = text..'\nGroups: '..r
return text
end
local function run(msg, matches)
if matches[1]:lower() == "stats" then
if not matches[2] then
if msg.to.type == 'gp' then
local chat_id = msg.to.id
return chat_stats(chat_id)
else
return 'Only work in group'
end
end
if matches[2] == "bot" then
if not is_sudo(msg) then
return "You are not sudo !"
else
return bot_stats()
end
end
if matches[2] == "gp" then
if not is_sudo(msg) then
return "You are not global admin!"
else
return chat_stats(matches[3])
end
end
end
end
return {
description = "bot, Groups and Member Stats",
usage = {
"/stats : number of messages stats",
"/stats gp (id) : other group stats",
"/stats bot : bot stats"
},
patterns = {
"^[!/](stats)$",
"^[!/](stats) (gp) (%d+)",
"^[!/](stats) (bot)"
},
run = run,
pre_process = pre_process
}
end
| gpl-2.0 |
yangboz/petulant-octo-dubstep | HP_ID_Print_App/cocos2d-x-3.2/cocos/scripting/lua-bindings/auto/api/ListView.lua | 1 | 4068 |
--------------------------------
-- @module ListView
-- @extend ScrollView
--------------------------------
-- @function [parent=#ListView] getIndex
-- @param self
-- @param #ccui.Widget widget
-- @return long#long ret (return value: long)
--------------------------------
-- @function [parent=#ListView] removeAllItems
-- @param self
--------------------------------
-- @function [parent=#ListView] setGravity
-- @param self
-- @param #ccui.ListView::Gravity gravity
--------------------------------
-- @function [parent=#ListView] pushBackCustomItem
-- @param self
-- @param #ccui.Widget widget
--------------------------------
-- @function [parent=#ListView] getItems
-- @param self
-- @return array_table#array_table ret (return value: array_table)
--------------------------------
-- @function [parent=#ListView] removeItem
-- @param self
-- @param #long long
--------------------------------
-- @function [parent=#ListView] getCurSelectedIndex
-- @param self
-- @return long#long ret (return value: long)
--------------------------------
-- @function [parent=#ListView] insertDefaultItem
-- @param self
-- @param #long long
--------------------------------
-- @function [parent=#ListView] requestRefreshView
-- @param self
--------------------------------
-- @function [parent=#ListView] setItemsMargin
-- @param self
-- @param #float float
--------------------------------
-- @function [parent=#ListView] refreshView
-- @param self
--------------------------------
-- @function [parent=#ListView] removeLastItem
-- @param self
--------------------------------
-- @function [parent=#ListView] getItemsMargin
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- @function [parent=#ListView] addEventListener
-- @param self
-- @param #function func
--------------------------------
-- @function [parent=#ListView] getItem
-- @param self
-- @param #long long
-- @return Widget#Widget ret (return value: ccui.Widget)
--------------------------------
-- @function [parent=#ListView] setItemModel
-- @param self
-- @param #ccui.Widget widget
--------------------------------
-- @function [parent=#ListView] doLayout
-- @param self
--------------------------------
-- @function [parent=#ListView] pushBackDefaultItem
-- @param self
--------------------------------
-- @function [parent=#ListView] insertCustomItem
-- @param self
-- @param #ccui.Widget widget
-- @param #long long
--------------------------------
-- @function [parent=#ListView] create
-- @param self
-- @return ListView#ListView ret (return value: ccui.ListView)
--------------------------------
-- @function [parent=#ListView] createInstance
-- @param self
-- @return Ref#Ref ret (return value: cc.Ref)
--------------------------------
-- overload function: addChild(cc.Node, int)
--
-- overload function: addChild(cc.Node)
--
-- overload function: addChild(cc.Node, int, int)
--
-- @function [parent=#ListView] addChild
-- @param self
-- @param #cc.Node node
-- @param #int int
-- @param #int int
--------------------------------
-- @function [parent=#ListView] setDirection
-- @param self
-- @param #ccui.ScrollView::Direction direction
--------------------------------
-- @function [parent=#ListView] getDescription
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#ListView] removeAllChildrenWithCleanup
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#ListView] removeAllChildren
-- @param self
--------------------------------
-- @function [parent=#ListView] removeChild
-- @param self
-- @param #cc.Node node
-- @param #bool bool
--------------------------------
-- @function [parent=#ListView] ListView
-- @param self
return nil
| mit |
sundream/gamesrv | script/card/soil/card156014.lua | 1 | 2196 | --<<card 导表开始>>
local super = require "script.card.init"
ccard156014 = class("ccard156014",super,{
sid = 156014,
race = 5,
name = "猎豹",
type = 201,
magic_immune = 0,
assault = 0,
sneer = 0,
atkcnt = 1,
shield = 0,
warcry = 0,
dieeffect = 0,
sneak = 0,
magic_hurt_adden = 0,
cure_to_hurt = 0,
recoverhp_multi = 1,
magic_hurt_multi = 1,
max_amount = 0,
composechip = 0,
decomposechip = 0,
atk = 3,
maxhp = 2,
crystalcost = 2,
targettype = 0,
halo = nil,
desc = "None",
effect = {
onuse = nil,
ondie = nil,
onhurt = nil,
onrecoverhp = nil,
onbeginround = nil,
onendround = nil,
ondelsecret = nil,
onputinwar = nil,
onremovefromwar = nil,
onaddweapon = nil,
onputinhand = nil,
before_die = nil,
after_die = nil,
before_hurt = nil,
after_hurt = nil,
before_recoverhp = nil,
after_recoverhp = nil,
before_beginround = nil,
after_beginround = nil,
before_endround = nil,
after_endround = nil,
before_attack = nil,
after_attack = nil,
before_playcard = nil,
after_playcard = nil,
before_putinwar = nil,
after_putinwar = nil,
before_removefromwar = nil,
after_removefromwar = nil,
before_addsecret = nil,
after_addsecret = nil,
before_delsecret = nil,
after_delsecret = nil,
before_addweapon = nil,
after_addweapon = nil,
before_delweapon = nil,
after_delweapon = nil,
before_putinhand = nil,
after_putinhand = nil,
before_removefromhand = nil,
after_removefromhand = nil,
},
})
function ccard156014:init(conf)
super.init(self,conf)
--<<card 导表结束>>
end --导表生成
function ccard156014:load(data)
if not data or not next(data) then
return
end
super.load(self,data)
-- todo: load data
end
function ccard156014:save()
local data = super.save(self)
-- todo: save data
return data
end
return ccard156014
| gpl-2.0 |
HannesTuhkala/saitohud | src/SaitoHUD/lua/saitohud/modules/overlays.lua | 3 | 8341 | -- SaitoHUD
-- Copyright (c) 2009-2010 sk89q <http://www.sk89q.com>
-- Copyright (c) 2010 BoJaN
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- $Id$
------------------------------------------------------------
-- Triads
------------------------------------------------------------
local triadsFilterGuide = CreateClientConVar("triads_filter_guide", "1", true, false)
--- Draw a triad.
-- @param p1 Point
-- @param ang Angle
local function DrawTriad(p1, ang)
local p2 = p1 + ang:Forward() * 16
local p3 = p1 + ang:Right() * 16
local p4 = p1 + ang:Up() * 16
p1, p2, p3, p4 = p1:ToScreen(), p2:ToScreen(), p3:ToScreen(), p4:ToScreen()
surface.SetDrawColor(255, 0, 0, 255)
surface.DrawLine(p1.x, p1.y, p2.x, p2.y) -- Forward
surface.SetDrawColor(0, 255, 0, 255)
surface.DrawLine(p1.x, p1.y, p3.x, p3.y) -- Right
surface.SetDrawColor(0, 0, 255, 255)
surface.DrawLine(p1.x, p1.y, p4.x, p4.y) -- Up
end
local OVERLAY = {}
function OVERLAY.DrawEnt(ent)
local pos = ent:GetPos()
DrawTriad(pos, ent:GetAngles())
end
function OVERLAY.HUDPaint(ent)
if triadsFilterGuide:GetBool() then
local w = ScrW()
surface.SetDrawColor(255, 0, 0, 255)
surface.DrawLine(w - 20, 30, w - 5, 38) -- Forward
surface.SetDrawColor(0, 200, 0, 255)
surface.DrawLine(w - 35, 38, w - 20, 30) -- Right
surface.SetDrawColor(0, 0, 255, 255)
surface.DrawLine(w - 20, 30, w - 20, 10) -- Up
end
end
SaitoHUD.RegisterOverlay("triads", OVERLAY)
------------------------------------------------------------
-- Bounding boxes
------------------------------------------------------------
local OVERLAY = {}
function OVERLAY.DrawEnt(ent)
local pos = ent:GetPos()
local obbMin = ent:OBBMins()
local obbMax = ent:OBBMaxs()
local p = {
ent:LocalToWorld(Vector(obbMin.x, obbMin.y, obbMin.z)):ToScreen(),
ent:LocalToWorld(Vector(obbMin.x, obbMax.y, obbMin.z)):ToScreen(),
ent:LocalToWorld(Vector(obbMax.x, obbMax.y, obbMin.z)):ToScreen(),
ent:LocalToWorld(Vector(obbMax.x, obbMin.y, obbMin.z)):ToScreen(),
ent:LocalToWorld(Vector(obbMin.x, obbMin.y, obbMax.z)):ToScreen(),
ent:LocalToWorld(Vector(obbMin.x, obbMax.y, obbMax.z)):ToScreen(),
ent:LocalToWorld(Vector(obbMax.x, obbMax.y, obbMax.z)):ToScreen(),
ent:LocalToWorld(Vector(obbMax.x, obbMin.y, obbMax.z)):ToScreen(),
}
local visible = true
for i = 1, 8 do
if not p[i].visible then
visible = false
break
end
end
if visible then
if ent:IsPlayer() then
if ent:Alive() then
surface.SetDrawColor(0, 255, 0, 255)
else
surface.SetDrawColor(0, 0, 255, 255)
end
else
surface.SetDrawColor(255, 0, 0, 255)
end
-- Bottom
surface.DrawLine(p[1].x, p[1].y, p[2].x, p[2].y)
surface.DrawLine(p[2].x, p[2].y, p[3].x, p[3].y)
surface.DrawLine(p[3].x, p[3].y, p[4].x, p[4].y)
surface.DrawLine(p[4].x, p[4].y, p[1].x, p[1].y)
-- Top
surface.DrawLine(p[5].x, p[5].y, p[6].x, p[6].y)
surface.DrawLine(p[6].x, p[6].y, p[7].x, p[7].y)
surface.DrawLine(p[7].x, p[7].y, p[8].x, p[8].y)
surface.DrawLine(p[8].x, p[8].y, p[5].x, p[5].y)
-- Sides
surface.DrawLine(p[1].x, p[1].y, p[5].x, p[5].y)
surface.DrawLine(p[2].x, p[2].y, p[6].x, p[6].y)
surface.DrawLine(p[3].x, p[3].y, p[7].x, p[7].y)
surface.DrawLine(p[4].x, p[4].y, p[8].x, p[8].y)
-- Bottom
--surface.DrawLine(p[1].x, p[1].y, p[3].x, p[3].y)
end
end
SaitoHUD.RegisterOverlay("bbox", OVERLAY)
------------------------------------------------------------
-- Text overlays
------------------------------------------------------------
local overlayFilterText = CreateClientConVar("overlay_filter_text", "class", true, false)
local overlayFilterPrint = CreateClientConVar("overlay_filter_print_removed", "0", true, false)
local peakSpeeds = {}
local peakEntityInfo = {}
function ClearOverlayCaches(ply, cmd, args)
peakSpeeds = {}
peakEntityInfo = {}
end
local OVERLAY = {}
function OVERLAY.DrawEnt(ent)
local refPos = SaitoHUD.GetRefPos()
local ot = overlayFilterText:GetString()
local text = "<INVALID>"
local pos = ent:GetPos()
local screenPos = pos:ToScreen()
if ot == "class" then
text = ent:GetClass()
elseif ot == "model" then
text = ent:GetModel()
elseif ot == "id" then
text = tostring(ent:EntIndex())
elseif ot == "material" then
text = ent:GetMaterial()
elseif ot == "speed" then
local speed = ent:GetVelocity():Length()
if speed == 0 then
text = "Z"
else
text = string.format("%0.1f", speed)
end
elseif ot == "peakspeed" then
local index = ent:EntIndex()
local speed = ent:GetVelocity():Length()
if not peakSpeeds[index] then
peakSpeeds[index] = speed
peakEntityInfo[index] = string.format("%s [%s]",
ent:GetClass(),
ent:GetModel())
else
if speed > peakSpeeds[index] then
peakSpeeds[index] = speed
end
end
if peakSpeeds[index] == 0 then
text = "Z"
else
text = string.format("%0.1f", peakSpeeds[index])
end
end
if text == nil then text = "" end
draw.SimpleText(text, "TabLarge", screenPos.x, screenPos.y,
Color(255, 255, 255, 255), 1, ALIGN_TOP)
end
function OVERLAY.OnPostEvaluate()
-- Clear dead entities from caches
for k, _ in pairs(peakSpeeds) do
local ent = ents.GetByIndex(k)
if not ValidEntity(ent) then
if overlayFilterPrint:GetBool() then
print(string.format("%s removed, peak speed was %f",
peakEntityInfo[k],
peakSpeeds[k]))
end
peakSpeeds[k] = nil
end
end
end
SaitoHUD.RegisterOverlay("overlay", OVERLAY)
concommand.Add("overlay_filter_clear_cache", ClearOverlayCaches)
cvars.AddChangeCallback("overlay_filter_text", ClearOverlayCaches)
------------------------------------------------------------
-- Velocities
------------------------------------------------------------
local OVERLAY = {}
function OVERLAY.DrawEnt(ent)
local pos = ent:GetPos()
local vel = ent:GetVelocity()
local len = vel:Length()
local adjVel = vel / 10
if len > 0 then
local p1 = pos
local p2 = pos + adjVel
local d = math.Clamp(2 * math.exp(0.0004 * len), 5, 20)
p1, p2 = p1:ToScreen(), p2:ToScreen()
surface.SetDrawColor(255, 255, 0, 255)
surface.DrawLine(p1.x, p1.y, p2.x, p2.y)
local ang = math.atan2(p2.y - p1.y, p2.x - p1.x) - math.rad(135)
local x = d * math.cos(ang) + p2.x
local y = d * math.sin(ang) + p2.y
surface.DrawLine(p2.x, p2.y, x, y)
local ang = math.atan2(p2.y - p1.y, p2.x - p1.x) - math.rad(-135)
local x = d * math.cos(ang) + p2.x
local y = d * math.sin(ang) + p2.y
surface.DrawLine(p2.x, p2.y, x, y)
end
end
SaitoHUD.RegisterOverlay("vel_vec", OVERLAY) | gpl-2.0 |
dalvorsn/tests | data/talkactions/scripts/info.lua | 10 | 1587 | function onSay(cid, words, param)
local player = Player(cid)
if not player:getGroup():getAccess() then
return true
end
local target = Player(param)
if not target then
player:sendCancelMessage("Player not found.")
return false
end
if target:getAccountType() > player:getAccountType() then
player:sendCancelMessage("You can not get info about this player.")
return false
end
local targetIp = target:getIp()
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Name: " .. target:getName())
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Access: " .. (target:getGroup():getAccess() and "1" or "0"))
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Level: " .. target:getLevel())
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Magic Level: " .. target:getMagicLevel())
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Speed: " .. getCreatureSpeed(player:getId()))
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Position: " .. string.format("(%0.5d / %0.5d / %0.3d)", target:getPosition().x, target:getPosition().y, target:getPosition().z))
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "IP: " .. Game.convertIpToString(targetIp))
local players = {}
for _, tmpPlayer in ipairs(Game.getPlayers()) do
if tmpPlayer:getIp() == targetIp and tmpPlayer ~= target then
players[#players + 1] = tmpPlayer:getName() .. " [" .. tmpPlayer:getLevel() .. "]"
end
end
if #players > 0 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Other players on same IP: " .. table.concat(players, ", ") .. ".")
end
return false
end
| gpl-2.0 |
porya0909/anti-spam | plugins/plugins.lua | 64 | 6122 | do
-- Returns the key (index) in the config.enabled_plugins table
local function plugin_enabled( name )
for k,v in pairs(_config.enabled_plugins) do
if name == v then
return k
end
end
-- If not found
return false
end
-- Returns true if file exists in plugins folder
local function plugin_exists( name )
for k,v in pairs(plugins_names()) do
if name..'.lua' == v then
return true
end
end
return false
end
local function list_all_plugins(only_enabled)
local text = ''
local nsum = 0
for k, v in pairs( plugins_names( )) do
-- ☑️ enabled, 🔘 disabled
local status = '🔘'
nsum = nsum+1
nact = 0
-- Check if is enabled
for k2, v2 in pairs(_config.enabled_plugins) do
if v == v2..'.lua' then
status = '☑️'
end
nact = nact+1
end
if not only_enabled or status == '✔' then
-- get the name
v = string.match (v, "(.*)%.lua")
text = text..nsum..'. '..v..' '..status..'\n'
end
end
local text = text..'\nThere are '..nsum..' plugins installed.\n'..nact..' plugins enabled and '..nsum-nact..' disabled'
return text
end
local function list_plugins(only_enabled)
local text = ''
local nsum = 0
for k, v in pairs( plugins_names( )) do
-- ☑️ enabled, 🔘 disabled
local status = '🔘'
nsum = nsum+1
nact = 0
-- Check if is enabled
for k2, v2 in pairs(_config.enabled_plugins) do
if v == v2..'.lua' then
status = '☑️'
end
nact = nact+1
end
if not only_enabled or status == '☑️' then
-- get the name
v = string.match (v, "(.*)%.lua")
text = text..v..' '..status..'\n'
end
end
local text = text..'\n'..nact..' plugins enabled from '..nsum..' plugins installed.'
return text
end
local function reload_plugins( )
plugins = {}
load_plugins()
return list_plugins(true)
end
local function enable_plugin( plugin_name )
print('checking if '..plugin_name..' exists')
-- Check if plugin is enabled
if plugin_enabled(plugin_name) then
return 'Plugin '..plugin_name..' is enabled'
end
-- Checks if plugin exists
if plugin_exists(plugin_name) then
-- Add to the config table
table.insert(_config.enabled_plugins, plugin_name)
print(plugin_name..' added to _config table')
save_config()
-- Reload the plugins
return reload_plugins( )
else
return 'Plugin '..plugin_name..' does not exists'
end
end
local function disable_plugin( name, chat )
-- Check if plugins exists
if not plugin_exists(name) then
return 'Plugin '..name..' does not exists'
end
local k = plugin_enabled(name)
-- Check if plugin is enabled
if not k then
return 'Plugin '..name..' not enabled'
end
-- Disable and reload
table.remove(_config.enabled_plugins, k)
save_config( )
return reload_plugins(true)
end
local function disable_plugin_on_chat(receiver, plugin)
if not plugin_exists(plugin) then
return "Plugin doesn't exists"
end
if not _config.disabled_plugin_on_chat then
_config.disabled_plugin_on_chat = {}
end
if not _config.disabled_plugin_on_chat[receiver] then
_config.disabled_plugin_on_chat[receiver] = {}
end
_config.disabled_plugin_on_chat[receiver][plugin] = true
save_config()
return 'Plugin '..plugin..' disabled on this chat'
end
local function reenable_plugin_on_chat(receiver, plugin)
if not _config.disabled_plugin_on_chat then
return 'There aren\'t any disabled plugins'
end
if not _config.disabled_plugin_on_chat[receiver] then
return 'There aren\'t any disabled plugins for this chat'
end
if not _config.disabled_plugin_on_chat[receiver][plugin] then
return 'This plugin is not disabled'
end
_config.disabled_plugin_on_chat[receiver][plugin] = false
save_config()
return 'Plugin '..plugin..' is enabled again'
end
local function run(msg, matches)
-- Show the available plugins
if matches[1] == '!plugins' and is_sudo(msg) then --after changed to moderator mode, set only sudo
return list_all_plugins()
end
-- Re-enable a plugin for this chat
if matches[1] == '+' and matches[3] == 'chat' then
local receiver = get_receiver(msg)
local plugin = matches[2]
print("enable "..plugin..' on this chat')
return reenable_plugin_on_chat(receiver, plugin)
end
-- Enable a plugin
if matches[1] == '+' and is_sudo(msg) then --after changed to moderator mode, set only sudo
local plugin_name = matches[2]
print("enable: "..matches[2])
return enable_plugin(plugin_name)
end
-- Disable a plugin on a chat
if matches[1] == '-' and matches[3] == 'chat' then
local plugin = matches[2]
local receiver = get_receiver(msg)
print("disable "..plugin..' on this chat')
return disable_plugin_on_chat(receiver, plugin)
end
-- Disable a plugin
if matches[1] == '-' and is_sudo(msg) then --after changed to moderator mode, set only sudo
if matches[2] == 'plugins' then
return 'This plugin can\'t be disabled'
end
print("disable: "..matches[2])
return disable_plugin(matches[2])
end
-- Reload all the plugins!
if matches[1] == 'reload' and is_sudo(msg) then --after changed to moderator mode, set only sudo
return reload_plugins(true)
end
end
return {
description = "Plugin to manage other plugins. Enable, disable or reload.",
usage = {
moderator = {
"!plugins - [plugin] chat : disable plugin only this chat.",
"!plugins + [plugin] chat : enable plugin only this chat.",
},
sudo = {
"!plugins : list all plugins.",
"!plugins + [plugin] : enable plugin.",
"!plugins - [plugin] : disable plugin.",
"!plugins reload : reloads all plugins." },
},
patterns = {
"^!plugins$",
"^!plugins? (+) ([%w_%.%-]+)$",
"^!plugins? (-) ([%w_%.%-]+)$",
"^!plugins? (+) ([%w_%.%-]+) (chat)",
"^!plugins? (-) ([%w_%.%-]+) (chat)",
"^!plugins? (reload)$" },
run = run,
moderated = true, -- set to moderator mode
--privileged = true
}
end
| gpl-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.