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 |
|---|---|---|---|---|---|
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/zones/Crawlers_Nest/npcs/Olavia.lua | 4 | 1036 | -----------------------------------
-- Area: Crawlers' Nest
-- NPC: Olavia
-- Type: Escort NPC
-- @zone: 197
-- @pos: 379.638 -33.051 -0.533
--
-- Auto-Script: Requires Verification (Verified by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Crawlers_Nest/TextIDs"] = nil;
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0006);
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 |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/globals/weaponskills/circle_blade.lua | 4 | 1194 | -----------------------------------
-- Circle Blade
-- Sword weapon skill
-- Skill Level: 150
-- Delivers an area of effect attack. Attack radius varies with TP.
-- Aligned with the Aqua Gorget & Thunder Gorget.
-- Aligned with the Aqua Belt & Thunder Belt.
-- Element: None
-- Modifiers: STR:35%
-- 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)
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;
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params);
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
SEEDTEAM/TeleSeed | plugins/ingroup.lua | 371 | 44212 | do
-- Check Member
local function check_member_autorealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Realm',
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes'
}
}
save_data(_config.moderation.data, data)
local realms = 'realms'
if not data[tostring(realms)] then
data[tostring(realms)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(realms)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Welcome to your new realm !')
end
end
end
local function check_member_realm_add(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Realm',
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes'
}
}
save_data(_config.moderation.data, data)
local realms = 'realms'
if not data[tostring(realms)] then
data[tostring(realms)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(realms)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Realm has been added!')
end
end
end
function check_member_group(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Group',
moderators = {},
set_owner = member_id ,
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes',
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'You have been promoted as the owner.')
end
end
end
local function check_member_modadd(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Group',
moderators = {},
set_owner = member_id ,
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes',
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Group is added and you have been promoted as the owner ')
end
end
end
local function automodadd(msg)
local data = load_data(_config.moderation.data)
if msg.action.type == 'chat_created' then
receiver = get_receiver(msg)
chat_info(receiver, check_member_group,{receiver=receiver, data=data, msg = msg})
end
end
local function autorealmadd(msg)
local data = load_data(_config.moderation.data)
if msg.action.type == 'chat_created' then
receiver = get_receiver(msg)
chat_info(receiver, check_member_autorealm,{receiver=receiver, data=data, msg = msg})
end
end
local function check_member_realmrem(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Realm configuration removal
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local realms = 'realms'
if not data[tostring(realms)] then
data[tostring(realms)] = nil
save_data(_config.moderation.data, data)
end
data[tostring(realms)][tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Realm has been removed!')
end
end
end
local function check_member_modrem(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration removal
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = nil
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Group has been removed')
end
end
end
--End Check Member
local function show_group_settingsmod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['settings']['flood_msg_max'] then
NUM_MSG_MAX = tonumber(data[tostring(msg.to.id)]['settings']['flood_msg_max'])
print('custom'..NUM_MSG_MAX)
else
NUM_MSG_MAX = 5
end
end
local bots_protection = "Yes"
if data[tostring(msg.to.id)]['settings']['lock_bots'] then
bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots']
end
local leave_ban = "no"
if data[tostring(msg.to.id)]['settings']['leave_ban'] then
leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban']
end
local settings = data[tostring(target)]['settings']
local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nLock group leave : "..leave_ban.."\nflood sensitivity : "..NUM_MSG_MAX.."\nBot protection : "..bots_protection--"\nPublic: "..public
return text
end
local function set_descriptionmod(msg, data, target, about)
if not is_momod(msg) then
return "For moderators only!"
end
local data_cat = 'description'
data[tostring(target)][data_cat] = about
save_data(_config.moderation.data, data)
return 'Set group description to:\n'..about
end
local function get_description(msg, data)
local data_cat = 'description'
if not data[tostring(msg.to.id)][data_cat] then
return 'No description available.'
end
local about = data[tostring(msg.to.id)][data_cat]
local about = string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about
return 'About '..about
end
local function lock_group_arabic(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'yes' then
return 'Arabic is already locked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'yes'
save_data(_config.moderation.data, data)
return 'Arabic has been locked'
end
end
local function unlock_group_arabic(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'no' then
return 'Arabic is already unlocked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'no'
save_data(_config.moderation.data, data)
return 'Arabic has been unlocked'
end
end
local function lock_group_bots(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'yes' then
return 'Bots protection is already enabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'yes'
save_data(_config.moderation.data, data)
return 'Bots protection has been enabled'
end
end
local function unlock_group_bots(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'no' then
return 'Bots protection is already disabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'no'
save_data(_config.moderation.data, data)
return 'Bots protection has been disabled'
end
end
local function lock_group_namemod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'yes' then
return 'Group name is already locked'
else
data[tostring(target)]['settings']['lock_name'] = 'yes'
save_data(_config.moderation.data, data)
rename_chat('chat#id'..target, group_name_set, ok_cb, false)
return 'Group name has been locked'
end
end
local function unlock_group_namemod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'no' then
return 'Group name is already unlocked'
else
data[tostring(target)]['settings']['lock_name'] = 'no'
save_data(_config.moderation.data, data)
return 'Group name has been unlocked'
end
end
local function lock_group_floodmod(msg, data, target)
if not is_owner(msg) then
return "Only admins can do it for now"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'yes' then
return 'Group flood is locked'
else
data[tostring(target)]['settings']['flood'] = 'yes'
save_data(_config.moderation.data, data)
return 'Group flood has been locked'
end
end
local function unlock_group_floodmod(msg, data, target)
if not is_owner(msg) then
return "Only admins can do it for now"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'no' then
return 'Group flood is not locked'
else
data[tostring(target)]['settings']['flood'] = 'no'
save_data(_config.moderation.data, data)
return 'Group flood has been unlocked'
end
end
local function lock_group_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'yes' then
return 'Group members are already locked'
else
data[tostring(target)]['settings']['lock_member'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group members has been locked'
end
local function unlock_group_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'no' then
return 'Group members are not locked'
else
data[tostring(target)]['settings']['lock_member'] = 'no'
save_data(_config.moderation.data, data)
return 'Group members has been unlocked'
end
end
local function set_public_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['public']
if group_member_lock == 'yes' then
return 'Group is already public'
else
data[tostring(target)]['settings']['public'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group is now: public'
end
local function unset_public_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['public']
if group_member_lock == 'no' then
return 'Group is not public'
else
data[tostring(target)]['settings']['public'] = 'no'
save_data(_config.moderation.data, data)
return 'Group is now: not public'
end
end
local function lock_group_leave(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban']
if leave_ban == 'yes' then
return 'Leaving users will be banned'
else
data[tostring(msg.to.id)]['settings']['leave_ban'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Leaving users will be banned'
end
local function unlock_group_leave(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban']
if leave_ban == 'no' then
return 'Leaving users will not be banned'
else
data[tostring(msg.to.id)]['settings']['leave_ban'] = 'no'
save_data(_config.moderation.data, data)
return 'Leaving users will not be banned'
end
end
local function unlock_group_photomod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'no' then
return 'Group photo is not locked'
else
data[tostring(target)]['settings']['lock_photo'] = 'no'
save_data(_config.moderation.data, data)
return 'Group photo has been unlocked'
end
end
local function set_rulesmod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local data_cat = 'rules'
data[tostring(target)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..rules
end
local function modadd(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if is_group(msg) then
return 'Group is already added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_modadd,{receiver=receiver, data=data, msg = msg})
end
local function realmadd(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if is_realm(msg) then
return 'Realm is already added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_realm_add,{receiver=receiver, data=data, msg = msg})
end
-- Global functions
function modrem(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if not is_group(msg) then
return 'Group is not added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_modrem,{receiver=receiver, data=data, msg = msg})
end
function realmrem(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if not is_realm(msg) then
return 'Realm is not added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_realmrem,{receiver=receiver, data=data, msg = msg})
end
local function get_rules(msg, data)
local data_cat = 'rules'
if not data[tostring(msg.to.id)][data_cat] then
return 'No rules available.'
end
local rules = data[tostring(msg.to.id)][data_cat]
local rules = 'Chat rules:\n'..rules
return rules
end
local function set_group_photo(msg, success, result)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if success then
local file = 'data/photos/chat_photo_'..msg.to.id..'.jpg'
print('File downloaded to:', result)
os.rename(result, file)
print('File moved to:', file)
chat_set_photo (receiver, file, ok_cb, false)
data[tostring(msg.to.id)]['settings']['set_photo'] = file
save_data(_config.moderation.data, data)
data[tostring(msg.to.id)]['settings']['lock_photo'] = 'yes'
save_data(_config.moderation.data, data)
send_large_msg(receiver, 'Photo saved!', ok_cb, false)
else
print('Error downloading: '..msg.id)
send_large_msg(receiver, 'Failed, please try again!', ok_cb, false)
end
end
local function promote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'chat#id', '')
if not data[group] then
return send_large_msg(receiver, 'Group is not added.')
end
if data[group]['moderators'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is already a moderator.')
end
data[group]['moderators'][tostring(member_id)] = member_username
save_data(_config.moderation.data, data)
return send_large_msg(receiver, member_username..' has been promoted.')
end
local function promote_by_reply(extra, success, result)
local msg = result
local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '')
if msg.from.username then
member_username = '@'.. msg.from.username
else
member_username = full_name
end
local member_id = msg.from.id
if msg.to.type == 'chat' then
return promote(get_receiver(msg), member_username, member_id)
end
end
local function demote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'chat#id', '')
if not data[group] then
return send_large_msg(receiver, 'Group is not added.')
end
if not data[group]['moderators'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is not a moderator.')
end
data[group]['moderators'][tostring(member_id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, member_username..' has been demoted.')
end
local function demote_by_reply(extra, success, result)
local msg = result
local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '')
if msg.from.username then
member_username = '@'..msg.from.username
else
member_username = full_name
end
local member_id = msg.from.id
if msg.to.type == 'chat' then
return demote(get_receiver(msg), member_username, member_id)
end
end
local function setowner_by_reply(extra, success, result)
local msg = result
local receiver = get_receiver(msg)
local data = load_data(_config.moderation.data)
local name_log = msg.from.print_name:gsub("_", " ")
data[tostring(msg.to.id)]['set_owner'] = tostring(msg.from.id)
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] setted ["..msg.from.id.."] as owner")
local text = msg.from.print_name:gsub("_", " ").." is the owner now"
return send_large_msg(receiver, text)
end
local function promote_demote_res(extra, success, result)
--vardump(result)
--vardump(extra)
local member_id = result.id
local member_username = "@"..result.username
local chat_id = extra.chat_id
local mod_cmd = extra.mod_cmd
local receiver = "chat#id"..chat_id
if mod_cmd == 'promote' then
return promote(receiver, member_username, member_id)
elseif mod_cmd == 'demote' then
return demote(receiver, member_username, member_id)
end
end
local function modlist(msg)
local data = load_data(_config.moderation.data)
local groups = "groups"
if not data[tostring(groups)][tostring(msg.to.id)] then
return 'Group is not added.'
end
-- determine if table is empty
if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way
return 'No moderator in this group.'
end
local i = 1
local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
message = message ..i..' - '..v..' [' ..k.. '] \n'
i = i + 1
end
return message
end
local function callbackres(extra, success, result)
--vardump(result)
local user = result.id
local name = string.gsub(result.print_name, "_", " ")
local chat = 'chat#id'..extra.chatid
send_large_msg(chat, user..'\n'..name)
return user
end
local function help()
local help_text = tostring(_config.help_text)
return help_text
end
local function cleanmember(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user(v.id, result.id)
end
end
local function killchat(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function killrealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function user_msgs(user_id, chat_id)
local user_info
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..user_id..':'..chat_id
user_info = tonumber(redis:get(um_hash) or 0)
return user_info
end
local function kick_zero(cb_extra, success, result)
local chat_id = cb_extra.chat_id
local chat = "chat#id"..chat_id
local ci_user
local re_user
for k,v in pairs(result.members) do
local si = false
ci_user = v.id
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
for i = 1, #users do
re_user = users[i]
if tonumber(ci_user) == tonumber(re_user) then
si = true
end
end
if not si then
if ci_user ~= our_id then
if not is_momod2(ci_user, chat_id) then
chat_del_user(chat, 'user#id'..ci_user, ok_cb, true)
end
end
end
end
end
local function kick_inactive(chat_id, num, receiver)
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = user_msgs(user_id, chat_id)
local nmsg = user_info
if tonumber(nmsg) < tonumber(num) then
if not is_momod2(user_id, chat_id) then
chat_del_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, true)
end
end
end
return chat_info(receiver, kick_zero, {chat_id = chat_id})
end
local function run(msg, matches)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
local name_log = user_print_name(msg.from)
local group = msg.to.id
if msg.media then
if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_chat_msg(msg) and is_momod(msg) then
load_photo(msg.id, set_group_photo, msg)
end
end
if matches[1] == 'add' and not matches[2] then
if is_realm(msg) then
return 'Error: Already a realm.'
end
print("group "..msg.to.print_name.."("..msg.to.id..") added")
return modadd(msg)
end
if matches[1] == 'add' and matches[2] == 'realm' then
if is_group(msg) then
return 'Error: Already a group.'
end
print("group "..msg.to.print_name.."("..msg.to.id..") added as a realm")
return realmadd(msg)
end
if matches[1] == 'rem' and not matches[2] then
print("group "..msg.to.print_name.."("..msg.to.id..") removed")
return modrem(msg)
end
if matches[1] == 'rem' and matches[2] == 'realm' then
print("group "..msg.to.print_name.."("..msg.to.id..") removed as a realm")
return realmrem(msg)
end
if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "group" then
return automodadd(msg)
end
if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "realm" then
return autorealmadd(msg)
end
if msg.to.id and data[tostring(msg.to.id)] then
local settings = data[tostring(msg.to.id)]['settings']
if matches[1] == 'chat_add_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_member_lock = settings.lock_member
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if group_member_lock == 'yes' and not is_owner2(msg.action.user.id, msg.to.id) then
chat_del_user(chat, user, ok_cb, true)
elseif group_member_lock == 'yes' and tonumber(msg.from.id) == tonumber(our_id) then
return nil
elseif group_member_lock == 'no' then
return nil
end
end
if matches[1] == 'chat_del_user' then
if not msg.service then
-- return "Are you trying to troll me?"
end
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..user)
end
if matches[1] == 'chat_delete_photo' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_photo_lock = settings.lock_photo
if group_photo_lock == 'yes' then
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:incr(picturehash)
---
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
local picprotectionredis = redis:get(picturehash)
if picprotectionredis then
if tonumber(picprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(picprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:set(picturehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to deleted picture but failed ")
chat_set_photo(receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
if matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then
if not msg.service then
return "Are you trying to troll me?"
end
local group_photo_lock = settings.lock_photo
if group_photo_lock == 'yes' then
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:incr(picturehash)
---
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
local picprotectionredis = redis:get(picturehash)
if picprotectionredis then
if tonumber(picprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(picprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:set(picturehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change picture but failed ")
chat_set_photo(receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
if matches[1] == 'chat_rename' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_name_set = settings.set_name
local group_name_lock = settings.lock_name
local to_rename = 'chat#id'..msg.to.id
if group_name_lock == 'yes' then
if group_name_set ~= tostring(msg.to.print_name) then
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
redis:incr(namehash)
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
local nameprotectionredis = redis:get(namehash)
if nameprotectionredis then
if tonumber(nameprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(nameprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
redis:set(namehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change name but failed ")
rename_chat(to_rename, group_name_set, ok_cb, false)
end
elseif group_name_lock == 'no' then
return nil
end
end
if matches[1] == 'setname' and is_momod(msg) then
local new_name = string.gsub(matches[2], '_', ' ')
data[tostring(msg.to.id)]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(msg.to.id)]['settings']['set_name']
local to_rename = 'chat#id'..msg.to.id
rename_chat(to_rename, group_name_set, ok_cb, false)
savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
if matches[1] == 'setphoto' and is_momod(msg) then
data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
return 'Please send me new group photo now'
end
if matches[1] == 'promote' and not matches[2] then
if not is_owner(msg) then
return "Only the owner can prmote new moderators"
end
if type(msg.reply_id)~="nil" then
msgr = get_message(msg.reply_id, promote_by_reply, false)
end
end
if matches[1] == 'promote' and matches[2] then
if not is_momod(msg) then
return
end
if not is_owner(msg) then
return "Only owner can promote"
end
local member = matches[2]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @".. member)
local cbres_extra = {
chat_id = msg.to.id,
mod_cmd = 'promote',
from_id = msg.from.id
}
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
return res_user(username, promote_demote_res, cbres_extra)
end
if matches[1] == 'demote' and not matches[2] then
if not is_owner(msg) then
return "Only the owner can demote moderators"
end
if type(msg.reply_id)~="nil" then
msgr = get_message(msg.reply_id, demote_by_reply, false)
end
end
if matches[1] == 'demote' and matches[2] then
if not is_momod(msg) then
return
end
if not is_owner(msg) then
return "Only owner can demote"
end
if string.gsub(matches[2], "@", "") == msg.from.username and not is_owner(msg) then
return "You can't demote yourself"
end
local member = matches[2]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @".. member)
local cbres_extra = {
chat_id = msg.to.id,
mod_cmd = 'demote',
from_id = msg.from.id
}
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
return res_user(username, promote_demote_res, cbres_extra)
end
if matches[1] == 'modlist' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist")
return modlist(msg)
end
if matches[1] == 'about' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group description")
return get_description(msg, data)
end
if matches[1] == 'rules' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group rules")
return get_rules(msg, data)
end
if matches[1] == 'set' then
if matches[2] == 'rules' then
rules = matches[3]
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[3].."]")
return set_rulesmod(msg, data, target)
end
if matches[2] == 'about' then
local data = load_data(_config.moderation.data)
local target = msg.to.id
local about = matches[3]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group description to ["..matches[3].."]")
return set_descriptionmod(msg, data, target, about)
end
end
if matches[1] == 'lock' then
local target = msg.to.id
if matches[2] == 'name' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked name ")
return lock_group_namemod(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ")
return lock_group_membermod(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ")
return lock_group_floodmod(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ")
return lock_group_arabic(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots ")
return lock_group_bots(msg, data, target)
end
if matches[2] == 'leave' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked leaving ")
return lock_group_leave(msg, data, target)
end
end
if matches[1] == 'unlock' then
local target = msg.to.id
if matches[2] == 'name' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked name ")
return unlock_group_namemod(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ")
return unlock_group_membermod(msg, data, target)
end
if matches[2] == 'photo' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked photo ")
return unlock_group_photomod(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood ")
return unlock_group_floodmod(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked arabic ")
return unlock_group_arabic(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked bots ")
return unlock_group_bots(msg, data, target)
end
if matches[2] == 'leave' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked leaving ")
return unlock_group_leave(msg, data, target)
end
end
if matches[1] == 'settings' then
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group settings ")
return show_group_settingsmod(msg, data, target)
end
--[[if matches[1] == 'public' then
local target = msg.to.id
if matches[2] == 'yes' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: public")
return set_public_membermod(msg, data, target)
end
if matches[2] == 'no' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: not public")
return unset_public_membermod(msg, data, target)
end
end]]
if matches[1] == 'newlink' and not is_realm(msg) then
if not is_momod(msg) then
return "For moderators only!"
end
local function callback (extra , success, result)
local receiver = 'chat#'..msg.to.id
if success == 0 then
return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.')
end
send_large_msg(receiver, "Created a new link")
data[tostring(msg.to.id)]['settings']['set_link'] = result
save_data(_config.moderation.data, data)
end
local receiver = 'chat#'..msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] revoked group link ")
return export_chat_link(receiver, callback, true)
end
if matches[1] == 'link' then
if not is_momod(msg) then
return "For moderators only!"
end
local group_link = data[tostring(msg.to.id)]['settings']['set_link']
if not group_link then
return "Create a link using /newlink first !"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]")
return "Group link:\n"..group_link
end
if matches[1] == 'setowner' and matches[2] then
if not is_owner(msg) then
return "For owner only!"
end
data[tostring(msg.to.id)]['set_owner'] = matches[2]
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] as owner")
local text = matches[2].." added as owner"
return text
end
if matches[1] == 'setowner' and not matches[2] then
if not is_owner(msg) then
return "only for the owner!"
end
if type(msg.reply_id)~="nil" then
msgr = get_message(msg.reply_id, setowner_by_reply, false)
end
end
if matches[1] == 'owner' then
local group_owner = data[tostring(msg.to.id)]['set_owner']
local user_info = redis:hgetall('user:'..group_owner)
if not group_owner then
return "no owner,ask admins in support groups to set owner for your group"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner")
if user_info.username then
return "Group onwer is @"..user_info.username.." ["..group_owner.."]"
else
return "Group owner is ["..group_owner..']'
end
end
if matches[1] == 'setgpowner' then
local receiver = "chat#id"..matches[2]
if not is_admin(msg) then
return "For admins only!"
end
data[tostring(matches[2])]['set_owner'] = matches[3]
save_data(_config.moderation.data, data)
local text = matches[3].." added as owner"
send_large_msg(receiver, text)
return
end
if matches[1] == 'setflood' then
if not is_momod(msg) then
return "For moderators only!"
end
if tonumber(matches[2]) < 5 or tonumber(matches[2]) > 20 then
return "Wrong number,range is [5-20]"
end
local flood_max = matches[2]
data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]")
return 'Group flood has been set to '..matches[2]
end
if matches[1] == 'clean' then
if not is_owner(msg) then
return "Only owner can clean"
end
if matches[2] == 'member' then
if not is_owner(msg) then
return "Only admins can clean members"
end
local receiver = get_receiver(msg)
chat_info(receiver, cleanmember, {receiver=receiver})
end
if matches[2] == 'modlist' then
if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way
return 'No moderator in this group.'
end
local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil
save_data(_config.moderation.data, data)
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist")
end
if matches[2] == 'rules' then
local data_cat = 'rules'
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules")
end
if matches[2] == 'about' then
local data_cat = 'description'
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about")
end
end
if matches[1] == 'kill' and matches[2] == 'chat' then
if not is_admin(msg) then
return nil
end
if not is_realm(msg) then
local receiver = get_receiver(msg)
return modrem(msg),
print("Closing Group..."),
chat_info(receiver, killchat, {receiver=receiver})
else
return 'This is a realm'
end
end
if matches[1] == 'kill' and matches[2] == 'realm' then
if not is_admin(msg) then
return nil
end
if not is_group(msg) then
local receiver = get_receiver(msg)
return realmrem(msg),
print("Closing Realm..."),
chat_info(receiver, killrealm, {receiver=receiver})
else
return 'This is a group'
end
end
if matches[1] == 'help' then
if not is_momod(msg) or is_realm(msg) then
return
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help")
return help()
end
if matches[1] == 'res' and is_momod(msg) then
local cbres_extra = {
chatid = msg.to.id
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username)
return res_user(username, callbackres, cbres_extra)
end
if matches[1] == 'kickinactive' then
--send_large_msg('chat#id'..msg.to.id, 'I\'m in matches[1]')
if not is_momod(msg) then
return 'Only a moderator can kick inactive users'
end
local num = 1
if matches[2] then
num = matches[2]
end
local chat_id = msg.to.id
local receiver = get_receiver(msg)
return kick_inactive(chat_id, num, receiver)
end
end
end
return {
patterns = {
"^[!/](add)$",
"^[!/](add) (realm)$",
"^[!/](rem)$",
"^[!/](rem) (realm)$",
"^[!/](rules)$",
"^[!/](about)$",
"^[!/](setname) (.*)$",
"^[!/](setphoto)$",
"^[!/](promote) (.*)$",
"^[!/](promote)",
"^[!/](help)$",
"^[!/](clean) (.*)$",
"^[!/](kill) (chat)$",
"^[!/](kill) (realm)$",
"^[!/](demote) (.*)$",
"^[!/](demote)",
"^[!/](set) ([^%s]+) (.*)$",
"^[!/](lock) (.*)$",
"^[!/](setowner) (%d+)$",
"^[!/](setowner)",
"^[!/](owner)$",
"^[!/](res) (.*)$",
"^[!/](setgpowner) (%d+) (%d+)$",-- (group id) (owner id)
"^[!/](unlock) (.*)$",
"^[!/](setflood) (%d+)$",
"^[!/](settings)$",
-- "^[!/](public) (.*)$",
"^[!/](modlist)$",
"^[!/](newlink)$",
"^[!/](link)$",
"^[!/](kickinactive)$",
"^[!/](kickinactive) (%d+)$",
"%[(photo)%]",
"^!!tgservice (.+)$",
},
run = run
}
end
| agpl-3.0 |
TienHP/Aquaria | files/scripts/entities/collectibleenergystatue.lua | 6 | 1296 | -- Copyright (C) 2007, 2010 - Bit-Blot
--
-- This file is part of Aquaria.
--
-- Aquaria is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License
-- as published by the Free Software Foundation; either version 2
-- of the License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--
-- See the GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
if not v then v = {} end
-- song cave collectible
dofile("scripts/include/collectibletemplate.lua")
function init(me)
v.commonInit(me, "Collectibles/energystatue", FLAG_COLLECTIBLE_ENERGYSTATUE)
end
function update(me, dt)
v.commonUpdate(me, dt)
end
function enterState(me, state)
v.commonEnterState(me, state)
if entity_isState(me, STATE_COLLECTEDINHOUSE) then
--createEntity("Walker", "", entity_x(me), entity_y(me))
end
end
function exitState(me, state)
v.commonExitState(me, state)
end
| gpl-2.0 |
waytim/darkstar | scripts/zones/Bastok_Mines/npcs/Pavvke.lua | 12 | 2223 | -----------------------------------
-- Area: Bastok Mines
-- NPC: Pavvke
-- Starts Quests: Fallen Comrades (100%)
-----------------------------------
package.loaded["scripts/zones/Bastok_Mines/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/globals/settings");
require("scripts/zones/Bastok_Mines/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
count = trade:getItemCount();
SilverTag = trade:hasItemQty(13116,1);
Fallen = player:getQuestStatus(BASTOK,FALLEN_COMRADES);
if (Fallen == 1 and SilverTag == true and count == 1) then
player:tradeComplete();
player:startEvent(0x005b);
elseif (Fallen == 2 and SilverTag == true and count == 1) then
player:tradeComplete();
player:startEvent(0x005c);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
Fallen = player:getQuestStatus(BASTOK,FALLEN_COMRADES);
pLevel = player:getMainLvl(player);
pFame = player:getFameLevel(BASTOK);
if (Fallen == 0 and pLevel >= 12 and pFame >= 2) then
player:startEvent(0x005a);
else
player:startEvent(0x004b);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID2: %u",csid);
--printf("RESULT2: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x005a) then
player:addQuest(BASTOK,FALLEN_COMRADES);
elseif (csid == 0x005b) then
player:completeQuest(BASTOK,FALLEN_COMRADES);
player:addFame(BASTOK,120);
player:addGil(GIL_RATE*550);
player:messageSpecial(GIL_OBTAINED,GIL_RATE*550);
elseif (csid == 0x005c) then
player:addFame(BASTOK,8);
player:addGil(GIL_RATE*550);
player:messageSpecial(GIL_OBTAINED,GIL_RATE*550);
end
end;
| gpl-3.0 |
pedrohenriquerls/cocos2d_ruby_binding | frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto/api/LinearLayoutParameter.lua | 10 | 1473 |
--------------------------------
-- @module LinearLayoutParameter
-- @extend LayoutParameter
-- @parent_module ccui
--------------------------------
-- Sets LinearGravity parameter for LayoutParameter.<br>
-- see LinearGravity<br>
-- param LinearGravity
-- @function [parent=#LinearLayoutParameter] setGravity
-- @param self
-- @param #int gravity
--------------------------------
-- Gets LinearGravity parameter for LayoutParameter.<br>
-- see LinearGravity<br>
-- return LinearGravity
-- @function [parent=#LinearLayoutParameter] getGravity
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- Allocates and initializes.<br>
-- return A initialized LayoutParameter which is marked as "autorelease".
-- @function [parent=#LinearLayoutParameter] create
-- @param self
-- @return LinearLayoutParameter#LinearLayoutParameter ret (return value: ccui.LinearLayoutParameter)
--------------------------------
--
-- @function [parent=#LinearLayoutParameter] createCloneInstance
-- @param self
-- @return LayoutParameter#LayoutParameter ret (return value: ccui.LayoutParameter)
--------------------------------
--
-- @function [parent=#LinearLayoutParameter] copyProperties
-- @param self
-- @param #ccui.LayoutParameter model
--------------------------------
-- Default constructor
-- @function [parent=#LinearLayoutParameter] LinearLayoutParameter
-- @param self
return nil
| mit |
wanmaple/MWFrameworkForCocosLua | frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto/api/LinearLayoutParameter.lua | 10 | 1473 |
--------------------------------
-- @module LinearLayoutParameter
-- @extend LayoutParameter
-- @parent_module ccui
--------------------------------
-- Sets LinearGravity parameter for LayoutParameter.<br>
-- see LinearGravity<br>
-- param LinearGravity
-- @function [parent=#LinearLayoutParameter] setGravity
-- @param self
-- @param #int gravity
--------------------------------
-- Gets LinearGravity parameter for LayoutParameter.<br>
-- see LinearGravity<br>
-- return LinearGravity
-- @function [parent=#LinearLayoutParameter] getGravity
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- Allocates and initializes.<br>
-- return A initialized LayoutParameter which is marked as "autorelease".
-- @function [parent=#LinearLayoutParameter] create
-- @param self
-- @return LinearLayoutParameter#LinearLayoutParameter ret (return value: ccui.LinearLayoutParameter)
--------------------------------
--
-- @function [parent=#LinearLayoutParameter] createCloneInstance
-- @param self
-- @return LayoutParameter#LayoutParameter ret (return value: ccui.LayoutParameter)
--------------------------------
--
-- @function [parent=#LinearLayoutParameter] copyProperties
-- @param self
-- @param #ccui.LayoutParameter model
--------------------------------
-- Default constructor
-- @function [parent=#LinearLayoutParameter] LinearLayoutParameter
-- @param self
return nil
| apache-2.0 |
waytim/darkstar | scripts/zones/The_Sanctuary_of_ZiTah/Zone.lua | 15 | 4390 | -----------------------------------
--
-- Zone: The_Sanctuary_of_ZiTah (121)
--
-----------------------------------
package.loaded["scripts/zones/The_Sanctuary_of_ZiTah/TextIDs"] = nil;
package.loaded["scripts/globals/chocobo_digging"] = nil;
-----------------------------------
require("scripts/zones/The_Sanctuary_of_ZiTah/TextIDs");
require("scripts/globals/icanheararainbow");
require("scripts/globals/zone");
require("scripts/globals/conquest");
require("scripts/globals/chocobo_digging");
-----------------------------------
-- Chocobo Digging vars
-----------------------------------
local itemMap = {
-- itemid, abundance, requirement
{ 688, 117, DIGREQ_NONE },
{ 17296, 150, DIGREQ_NONE },
{ 880, 100, DIGREQ_NONE },
{ 833, 83, DIGREQ_NONE },
{ 696, 100, DIGREQ_NONE },
{ 690, 33, DIGREQ_NONE },
{ 772, 17, DIGREQ_NONE },
{ 773, 33, DIGREQ_NONE },
{ 4386, 9, DIGREQ_NONE },
{ 703, 7, DIGREQ_NONE },
{ 4096, 100, DIGREQ_NONE }, -- all crystals
{ 1255, 10, DIGREQ_NONE }, -- all ores
{ 656, 117, DIGREQ_BURROW },
{ 750, 133, DIGREQ_BURROW },
{ 749, 117, DIGREQ_BURROW },
{ 748, 8, DIGREQ_BURROW },
{ 751, 14, DIGREQ_BURROW },
{ 720, 1, DIGREQ_BURROW },
{ 699, 9, DIGREQ_BORE },
{ 720, 1, DIGREQ_BORE },
{ 4570, 10, DIGREQ_MODIFIER },
{ 4487, 11, DIGREQ_MODIFIER },
{ 4409, 12, DIGREQ_MODIFIER },
{ 1188, 10, DIGREQ_MODIFIER },
{ 4532, 12, DIGREQ_MODIFIER },
};
local messageArray = { DIG_THROW_AWAY, FIND_NOTHING, ITEM_OBTAINED };
-----------------------------------
-- onChocoboDig
-----------------------------------
function onChocoboDig(player, precheck)
return chocoboDig(player, itemMap, precheck, messageArray);
end;
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
local manuals = {17273417,17273418};
SetFieldManual(manuals);
local Noble_Mold = 17273278;
GetMobByID(Noble_Mold):setLocalVar("ToD",os.time() + math.random((43200), (57600)));
SetRegionalConquestOverseers(zone:getRegionID())
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn( player, prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(539.901, 3.379, -580.218, 126);
end
if (triggerLightCutscene(player)) then -- Quest: I Can Hear A Rainbow
cs = 0x0002;
elseif (player:getCurrentMission(WINDURST) == VAIN and player:getVar("MissionStatus") ==1) then
cs = 0x0004;
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter( player, region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate( player, csid, option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0002) then
lightCutsceneUpdate(player); -- Quest: I Can Hear A Rainbow
elseif (csid == 0x0004) then
if (player:getPreviousZone() == 153) then
player:updateEvent(0,0,0,0,0,7);
elseif (player:getPreviousZone() == 119) then
player:updateEvent(0,0,0,0,0,1);
end
end
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish( player, csid, option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0002) then
lightCutsceneFinish(player); -- Quest: I Can Hear A Rainbow
end
end; | gpl-3.0 |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/zones/West_Ronfaure/npcs/qm2.lua | 2 | 1448 | -----------------------------------
-- Area: West Ronfaure
-- NPC: ???
-- @zone: 100
-- @pos: -550 -0 -542
--
-- Involved in Quest: The Dismayed Customer
-----------------------------------
package.loaded["scripts/zones/West_Ronfaure/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/globals/keyitems");
require("scripts/zones/West_Ronfaure/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getQuestStatus(SANDORIA, THE_DISMAYED_CUSTOMER) == QUEST_ACCEPTED and player:getVar("theDismayedCustomer") == 2) then
player:addKeyItem(GULEMONTS_DOCUMENT);
player:messageSpecial(KEYITEM_OBTAINED, GULEMONTS_DOCUMENT);
player:setVar("theDismayedCustomer", 0);
else
player:messageSpecial(DISMAYED_CUSTOMER);
end;
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
waytim/darkstar | scripts/globals/weaponskills/evisceration.lua | 2 | 1578 | -----------------------------------
-- Evisceration
-- Dagger weapon skill
-- Skill level: 230
-- In order to obtain Evisceration, the quest Cloak and Dagger must be completed.
-- Delivers a fivefold attack. Chance of params.critical hit varies with TP.
-- Will stack with Sneak Attack.
-- Aligned with the Shadow Gorget, Soil Gorget & Light Gorget.
-- Aligned with the Shadow Belt, Soil Belt & Light Belt.
-- Element: None
-- Modifiers: DEX:30%
-- 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 = 5;
params.ftp100 = 1; params.ftp200 = 1; params.ftp300 = 1;
params.str_wsc = 0.0; params.dex_wsc = 0.3; 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.1; params.crit200 = 0.3; params.crit300 = 0.5;
params.canCrit = true;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.ftp100 = 1.25; params.ftp200 = 1.25; params.ftp300 = 1.25;
params.crit200 = 0.25;
params.dex_wsc = 0.5;
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, primary);
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
waytim/darkstar | scripts/zones/Spire_of_Dem/npcs/_0j2.lua | 39 | 1330 | -----------------------------------
-- Area: Spire_of_Dem
-- NPC: web of regret
-----------------------------------
package.loaded["scripts/zones/Spire_of_Dem/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/bcnm");
require("scripts/zones/Spire_of_Dem/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 (EventTriggerBCNM(player,npc)) then
return 1;
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 Action
-----------------------------------
function onEventFinish(player,csid,option)
--printf("onFinish CSID: %u",csid);
--printf("onFinish RESULT: %u",option);
if (EventFinishBCNM(player,csid,option)) then
return;
end
end; | gpl-3.0 |
waytim/darkstar | scripts/zones/Upper_Jeuno/npcs/Emitt.lua | 14 | 3662 | -----------------------------------
-- Area: Upper Jeuno
-- NPC: Emitt
-- @pos -95 0 160 244
-------------------------------------
package.loaded["scripts/zones/Upper_Jeuno/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/conquest");
require("scripts/zones/Upper_Jeuno/TextIDs");
local guardnation = OTHER; -- SANDORIA, BASTOK, WINDURST, OTHER(Jeuno).
local guardtype = 1; -- 1: city, 2: foreign, 3: outpost, 4: border
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
tradeConquestGuard(player,npc,trade,guardnation,guardtype);
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local Menu1 = getArg1(guardnation,player);
local Menu3 = conquestRanking();
local Menu6 = getArg6(player);
local Menu7 = player:getCP();
player:startEvent(0x7ffb,Menu1,0,Menu3,0,0,Menu6,Menu7,0);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("onUpdateCSID: %u",csid);
-- printf("onUpdateOPTION: %u",option);
if (player:getNation() == 0) then
inventory = SandInv;
size = table.getn(SandInv);
elseif (player:getNation() == 1) then
inventory = BastInv;
size = table.getn(BastInv);
else
inventory = WindInv;
size = table.getn(WindInv);
end
if (option >= 32768 and option <= 32944) then
for Item = 1,size,3 do
if (option == inventory[Item]) then
CPVerify = 1;
if (player:getCP() >= inventory[Item + 1]) then
CPVerify = 0;
end;
player:updateEvent(2,CPVerify,inventory[Item + 2]); -- can't equip = 2 ?
break;
end;
end;
end;
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("onFinishCSID: %u",csid);
-- printf("onFinishOPTION: %u",option);
if (option == 1) then
duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600;
player:delStatusEffect(EFFECT_SIGIL);
player:delStatusEffect(EFFECT_SANCTION);
player:delStatusEffect(EFFECT_SIGNET);
player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet
elseif (option >= 32768 and option <= 32944) then
for Item = 1,size,3 do
if (option == inventory[Item]) then
if (player:getFreeSlotsCount() >= 1) then
-- Logic to impose limits on exp bands
if (option >= 32933 and option <= 32935) then
if (checkConquestRing(player) > 0) then
player:messageSpecial(CONQUEST+60,0,0,inventory[Item+2]);
break;
else
player:setVar("CONQUEST_RING_TIMER",getConquestTally());
end
end
itemCP = inventory[Item + 1];
player:delCP(itemCP);
player:addItem(inventory[Item + 2],1);
player:messageSpecial(ITEM_OBTAINED,inventory[Item + 2]);
else
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,inventory[Item + 2]);
end;
break;
end;
end;
end;
end; | gpl-3.0 |
MinFu/luci | applications/luci-app-pbx/luasrc/model/cbi/pbx.lua | 146 | 4360 | --[[
Copyright 2011 Iordan Iordanov <iiordanov (AT) gmail.com>
This file is part of luci-pbx.
luci-pbx is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
luci-pbx is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with luci-pbx. If not, see <http://www.gnu.org/licenses/>.
]]--
modulename = "pbx"
if nixio.fs.access("/etc/init.d/asterisk") then
server = "asterisk"
elseif nixio.fs.access("/etc/init.d/freeswitch") then
server = "freeswitch"
else
server = ""
end
-- Returns formatted output of string containing only the words at the indices
-- specified in the table "indices".
function format_indices(string, indices)
if indices == nil then
return "Error: No indices to format specified.\n"
end
-- Split input into separate lines.
lines = luci.util.split(luci.util.trim(string), "\n")
-- Split lines into separate words.
splitlines = {}
for lpos,line in ipairs(lines) do
splitlines[lpos] = luci.util.split(luci.util.trim(line), "%s+", nil, true)
end
-- For each split line, if the word at all indices specified
-- to be formatted are not null, add the formatted line to the
-- gathered output.
output = ""
for lpos,splitline in ipairs(splitlines) do
loutput = ""
for ipos,index in ipairs(indices) do
if splitline[index] ~= nil then
loutput = loutput .. string.format("%-40s", splitline[index])
else
loutput = nil
break
end
end
if loutput ~= nil then
output = output .. loutput .. "\n"
end
end
return output
end
m = Map (modulename, translate("PBX Main Page"),
translate("This configuration page allows you to configure a phone system (PBX) service which \
permits making phone calls through multiple Google and SIP (like Sipgate, \
SipSorcery, and Betamax) accounts and sharing them among many SIP devices. \
Note that Google accounts, SIP accounts, and local user accounts are configured in the \
\"Google Accounts\", \"SIP Accounts\", and \"User Accounts\" sub-sections. \
You must add at least one User Account to this PBX, and then configure a SIP device or \
softphone to use the account, in order to make and receive calls with your Google/SIP \
accounts. Configuring multiple users will allow you to make free calls between all users, \
and share the configured Google and SIP accounts. If you have more than one Google and SIP \
accounts set up, you should probably configure how calls to and from them are routed in \
the \"Call Routing\" page. If you're interested in using your own PBX from anywhere in the \
world, then visit the \"Remote Usage\" section in the \"Advanced Settings\" page."))
-----------------------------------------------------------------------------------------
s = m:section(NamedSection, "connection_status", "main",
translate("PBX Service Status"))
s.anonymous = true
s:option (DummyValue, "status", translate("Service Status"))
sts = s:option(DummyValue, "_sts")
sts.template = "cbi/tvalue"
sts.rows = 20
function sts.cfgvalue(self, section)
if server == "asterisk" then
regs = luci.sys.exec("asterisk -rx 'sip show registry' | sed 's/peer-//'")
jabs = luci.sys.exec("asterisk -rx 'jabber show connections' | grep onnected")
usrs = luci.sys.exec("asterisk -rx 'sip show users'")
chan = luci.sys.exec("asterisk -rx 'core show channels'")
return format_indices(regs, {1, 5}) ..
format_indices(jabs, {2, 4}) .. "\n" ..
format_indices(usrs, {1} ) .. "\n" .. chan
elseif server == "freeswitch" then
return "Freeswitch is not supported yet.\n"
else
return "Neither Asterisk nor FreeSwitch discovered, please install Asterisk, as Freeswitch is not supported yet.\n"
end
end
return m
| apache-2.0 |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/commands/zone.lua | 2 | 11478 | -----------------------------------
-- [Command name]: zone
-- [Author ]:
-- [Description ]:
-----------------------------------
local placenames = {
xA9 = 1, -- Phanauet Channel
xAA = 2, -- Carpenter's Landing
x84 = 3, -- Manaclipper
x85 = 4, -- Bibiki Bay
x8A = 5, -- Uleguerand Range
x8B = 6, -- Bearclaw Pinnacle
x86 = 7, -- Attohwa Chasm
x87 = 8, -- Boneyard Gully
x88 = 9, -- Pso'Xja
x89 = 10, -- The Shrouded Maw
x8C = 11, -- Oldton Movalpolos
x8D = 12, -- Newton Movalpolos
xDC = 13, -- Mine Shaft #2716
xAB = 14, -- Hall of Transference
x9B = 16, -- Promyvion-Holla
x9C = 17, -- Spire of Holla
x9D = 18, -- Promyvion-Dem
x9E = 19, -- Spire of Dem
xA1 = 20, -- Promyvion-Mea
xA2 = 21, -- Spire of Mea
xA4 = 22, -- Promyvion-Vahzl
xA8 = 23, -- Spire of Vahzl
x90 = 24, -- Lufaise Meadows
x91 = 25, -- Misareaux Coast
x8F = 26, -- Tavnazian Safehold
x93 = 27, -- Phomiuna Aquaducts
x94 = 28, -- Sacrarium
x96 = 29, -- Riverne Site #B01
x98 = 30, -- Riverne Site #A01
x99 = 31, -- Monarch Linn
x92 = 32, -- Sealion's Den
xAC = 33, -- Al'Taieu
xAD = 34, -- Grand Palace of Hu'Xzoi
xAE = 35, -- The Garden of Ru'Hmet
xB0 = 36, -- Empyreal Paradox
xB1 = 37, -- Temenos
xB2 = 38, -- Apollyon
xB4 = 39, -- Dynamis - Valkurm
xB5 = 40, -- Dynamis - Buburimu
xB6 = 41, -- Dynamis - Qufim
xB7 = 42, -- Dynamis - Tavnazia
xAF = 43, -- Diorama Abdhaljs-Ghelsba
xB8 = 44, -- Abhaljs Isle-Purgonorgo
xB9 = 46, -- Open sea route to Al Zhabi
xBA = 47, -- Open sea route to Mhaura
xBB = 48, -- Al Zahbi
xBC = 50, -- Aht Urghan Whitegate
xBD = 51, -- Wajaom Woodlands
xE0 = 52, -- Bhaflau Thickets
xBF = 53, -- Nashmau
xC0 = 54, -- Arrapago Reef
xC1 = 55, -- Ilrusi Atoll
xC2 = 56, -- Periqia
xC3 = 57, -- Talacca Cove
xC4 = 58, -- Silver Sea route to Nashmau
x59 = 59, -- Silver Sea route to Al Zhabi
xC6 = 60, -- The Ashu Talif
xC7 = 61, -- Mount Zhayolm
xC8 = 62, -- Halvung
xC9 = 63, -- Lebros Cavern
xCA = 64, -- Navukgo Execution Chamber
xCB = 65, -- Mamook
xCC = 66, -- Mamool Ja Training Grounds
xCD = 67, -- Jade Sepulcher
xCE = 68, -- Aydeewa Subterrane
xCF = 69, -- Leujaoam Sanctum
xDD = 72, -- Alzadaal Undersea Ruins
xDE = 73, -- Zhayolm Remnants
xDF = 74, -- Arrapago Remnants
xE0 = 75, -- Bhaflau Remnants
xE1 = 76, -- Silver Sea Remnants
xE2 = 77, -- Nyzul Isle
xDA = 78, -- Hazhalm Testing Grounds
xD0 = 79, -- Caedarva Mire
x11 = 100, -- West Ronfaure
x0F = 101, -- East Ronfaure
x51 = 102, -- La Theine Plateau
x60 = 103, -- Valkurm Dunes
x01 = 104, -- Jugner Forest
x02 = 105, -- Batallia Downs
x64 = 106, -- North Gustaberg
x63 = 107, -- South Gustaberg
x69 = 108, -- Konschtat Highlands
x2B = 109, -- Pashhow Marshlands
x07 = 110, -- Rolanberry Fields
x24 = 111, -- Beaucedine Glacier
x4D = 112, -- Xarcabard
x3D = 113, -- Cape Teriggan
x3E = 114, -- Eastern Altepa Desert
x18 = 115, -- West Sarutabaruta
x27 = 116, -- East Sarutabaruta
x17 = 117, -- Tahrongi Canyon
x16 = 118, -- Buburimu Peninsula
x2E = 120, -- Sauromugue Champaign
x3F = 121, -- The Sanctuary of Zi'Tah
x7D = 122, -- Ro'Maeve
x40 = 123, -- Yuhtunga Jungle
x41 = 124, -- Yhoator Jungle
x42 = 125, -- Western Altepa Desert
x08 = 126, -- Qufim Island
x43 = 128, -- Valley of Sorrows
x6F = 130, -- Ru'Aun Gardens
x82 = 134, -- Dynamis - Beaucedine
x83 = 135, -- Dynamis - Xarcabard
x64 = 139, -- Horlais Peak
x6C = 140, -- Ghelsba Outpost
x1F = 141, -- Fort Ghelsba
x5E = 142, -- Yughott Grotto
x66 = 143, -- Palborough Mines
x1A = 144, -- Waughroon Shrine
x21 = 145, -- Giddeus
x19 = 146, -- Balga's Dais
x2A = 147, -- Beadeaux
x28 = 148, -- Qulun Dome
x68 = 149, -- Davoi
x6D = 150, -- Monastic Cavern
x23 = 151, -- Castle Oztroja
x04 = 152, -- Altar Room
x44 = 153, -- The Boyahda Tree
x37 = 154, -- Dragon's Aery
x36 = 159, -- Temple of Uggalepih
x35 = 160, -- Den of Rancor
x25 = 161, -- Castle Zvahl Baileys
x4F = 162, -- Castle Zvahl Keep
x39 = 163, -- Sacrificial Chamber
x5D = 165, -- Throne Room
x2D = 166, -- Ranguemont Pass
x32 = 167, -- Bostaunieux Oubliette
x3B = 168, -- Chamber of Oracles
x1D = 169, -- Toraimarai Canal
x5C = 170, -- Full Moon Fountain
x61 = 172, -- Zehurn Mines
x5B = 173, -- Korroloka Tunnel
x5A = 174, -- Kuftal Tunnel
x59 = 176, -- Sea Serpent Grotto
x71 = 177, -- Ve'Lugannon Palace
x72 = 178, -- The Shrine of Ru'Avitau
xB3 = 179, -- Stellar Fulcrum
x73 = 180, -- La'Loff Amphitheater
x74 = 181, -- The Celestial Nexus
x7E = 185, -- Dynamis - San d'Oria
x7F = 186, -- Dynamis - Bastok
x80 = 187, -- Dynamis - Windurst
x81 = 188, -- Dynamis - Jeuno
x6E = 190, -- King Ranperre's Tomb
x62 = 191, -- Dangruf Wadi
x1C = 192, -- Inner Horutoto Ruins
x03 = 193, -- Ordelle's Caves
x1B = 194, -- Outer Horutoto Ruins
x6A = 195, -- The Eldieme Necropolis
x67 = 196, -- Gusgen Mines
x2C = 197, -- Crawlers' Nest
x15 = 198, -- Maze of Shakhrami
x14 = 200, -- Garlaige Citadel
x77 = 201, -- Cloister of Gales
x75 = 202, -- Cloister of Storms
x7A = 203, -- Cloister of Frost
x4A = 204, -- Fei'Yin
x58 = 205, -- Ifrit's Cauldron
x6B = 206, -- Qu'Bia Arena
x78 = 207, -- Cloister of Flames
x57 = 208, -- Quicksand Caves
x76 = 209, -- Cloister of Tremors
x79 = 211, -- Cloister of Tides
x34 = 212, -- Gustav Tunnel
x33 = 213, -- Labyrinth of Onzozo
x4C = 230, -- Southern San d'Oria
x30 = 231, -- Northern San d'Oria
x52 = 232, -- Port San d'Oria
x22 = 233, -- Chateaux d'Oraguille
x46 = 234, -- Bastok Mines
x56 = 235, -- Bastok Markets
x3C = 236, -- Port Bastok
x2F = 237, -- Metalworks
x3A = 238, -- Windurst Waters
x54 = 239, -- Windurst Walls
x3C = 240, -- Port Windurst
x38 = 241, -- Windurst Woods
x55 = 242, -- Heavens Tower
x13 = 243, -- Ru'Lude Gardens
x4E = 244, -- Upper Jeuno
x0E = 245, -- Lower Jeuno
x06 = 246, -- Port Jeuno
x31 = 247, -- Rabao
x5F = 248, -- Selbina
x1E = 249, -- Mhaura
x29 = 250, -- Kazham
x7B = 251 -- Hall of the Gods
}
local placenames2 = {
x0F = 70, -- Chocobo Circuit
x10 = 71, -- The Colosseum
x11 = 80, -- Southern San d'Oria [S]
x13 = 81, -- East Ronfaure [S]
x15 = 82, -- Jugner Forest [S]
x23 = 83, -- Vunkerl Inlet [S]
x17 = 84, -- Batallia Downs [S]
x3E = 85, -- La Vaule [S]
x19 = 86, -- Everbloom Hollow
x1C = 87, -- Bastok Markets [S]
x1E = 88, -- North Gustaberg [S]
x25 = 91, -- Rolanberry Fields [S]
x42 = 92, -- Beadeaux [S]
x22 = 93, -- Ruhotz Silvermines
x2B = 94, -- Windurst Waters [S]
x2D = 95, -- West Sarutabaruta [S]
x2F = 96, -- Fort Karugo-Narugo [S]
x32 = 97, -- Meriphataud Mountains [S]
x34 = 98, -- Sauromugue Champaign [S]
x44 = 99, -- Castle Oztroja [S]
x31 = 129, -- Ghoyu's Reverie
x46 = 136, -- Beaucedine Glacier [S]
x48 = 137, -- Xarcabard [S]
x36 = 164, -- Garlaige Citadel [S]
x29 = 171, -- Crawler's Nest [S]
x1A = 175, -- The Eldieme Necropolis [S]
x4C = 256, -- Western Adoulin
x4D = 257, -- Eastern Adoulin
x4E = 258, -- Rala Waterways
x4F = 260, -- Yahse Hunting Grounds
x50 = 261, -- Ceizak Battlegrounds
x51 = 262, -- Foret de Hennetiel
x52 = 265, -- Morimar Basalt Fields
x53 = 268, -- Sih Gates
x54 = 269, -- Moh Gates
x55 = 270 -- Cirdas Caverns
}
--[[No recognition for:
15 Abyssea-Konschtat -- No phrase
45 Abyssea-Tahrongi -- No phrase
49 noname
89 Grauberg [S] -- Nil for some reason 0x27 (Einherjar chambers are also nil)
119 Meriphataud Mountains -- Nil for some reason 0x14
127 Behemoth's Dominion -- Nil for some reason 0x14
131 Mordion Gaol -- No phrase
132 Abyssea-La Theine -- No phrase
133 noname
137 Castle Zvahl Baileys [S] -- No phrase
155 Castle Zvahl Keep [S] -- No phrase
156 Throne Room [S] -- No phrase
157 Middle Delkfutt's Tower -- Nil for some reason 0x14
158 Upper Delkfutt's Tower -- Nil for some reason 0x14
182 Walk of Echoes -- No phrase
183 Maquette Abdhaljs Legion -- No phrase
184 Lower Delkfutt's Tower -- Nil for some reason 0x14
189 noname
199 noname
210 noname
214 Residential Area
215 Abyssea-Attohwa -- No phrase
216 Abyssea-Misareaux -- No phrase
217 Abyssea-Vunkerl -- No phrase
218 Abyssea-Altepa -- No phrase
219 noname
220 Ship bound for Selbina -- No phrase
221 Ship bound for Mhaura -- No phrase
222 Provenance -- No phrase
223 San_dOria-Jeuno Airship -- No phrase
224 Bastok-Jeuno Airship -- No phrase
225 Windurst-Jeuno Airship -- No phrase
226 Kazham-Jeuno Airship -- No phrase
227 Ship bound for Selbina -- No phrase
228 Ship bound for Mhaura -- No phrase
229 noname
252 Norg -- Nill for some reason 0x14
253 Abyssea-Uleguerand -- No phrase
254 Abyssea-Grauberg -- No phrase
255 Abyssea-Empyreal Paradox -- No phrase
259 Rala Waterways U -- No phrase
263 Yorcia Weald -- No phrase
264 Yorcia Weald U -- No phrase
266 noname
267 noname
271 Cirdas Caverns U -- No phrase
272 noname
273 noname
274 noname
275 noname
276 noname
277 noname
278 noname
279 noname
280 noname
281 noname
282 noname
283 Silver Knife -- No phrase
284 Celennia Wexworth Memorial Library -- No phrase
]]
-----------------------------------
-- zone Action
-----------------------------------
function onTrigger(player,zoneID)
local word = "";
local i;
local zone = zoneID;
-- Byte 1 == FD means Auto-Translate likely
-- Byte 2 == 02 means Auto-Translate string
-- Byte 3 == Language code. Ignore it for compatibility.
-- Byte 4 == Category. 0x14 is Place Names, 0x27 is Place Names 2
-- Byte 5 == identifier for the phrase. Nils are apparently a thing, so discard those.
-- Byte 6 should be another FD
if (string.byte(zoneID,1) == 0xFD and string.byte(zoneID,2) == 2 and
string.byte(zoneID,5) ~= nil and string.byte(zoneID,6) == 0xFD) then -- Autotranslate string found
word = string.format("%X",string.byte(zoneID,5));
if (string.len(word) == 1) then -- Got a nibble, want a byte.
word = 0 ..word;
end
word = "x"..word;
if (string.byte(zoneID,4) == 0x14) then -- Place Names
-- print("Place Names - 0"..word);
zone = placenames[word]
elseif (string.byte(zoneID,4) == 0x27) then -- Place Names 2
-- print("Place Names 2 - 0"..word);
zone = placenames2[word];
end
--[[ Testing code in case categories change.
else
local byte;
for i = 1, string.len(zoneID) do
byte = string.format("%X",string.byte(zoneID,i));
if (string.len(byte) == 1) then
byte = 0 ..byte;
end
word = word..byte;
end
print("Bad format in @zone! String: 0x"..word);]]
end
player:setPos(0,0,0,0,zone);
end; | gpl-3.0 |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/globals/items/cup_of_chai_+1.lua | 3 | 1105 | -----------------------------------------
-- ID: 5594
-- Item: cup_of_chai_+1
-- Food Effect: 240Min, All Races
-----------------------------------------
-- Vitality -3
-- Charisma 3
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,14400,5594);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_VIT, -3);
target:addMod(MOD_CHR, 3);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_VIT, -3);
target:delMod(MOD_CHR, 3);
end;
| gpl-3.0 |
waytim/darkstar | scripts/zones/AlTaieu/npcs/HomePoint#1.lua | 29 | 1238 | -----------------------------------
-- Area: AlTaieu
-- NPC: HomePoint#1
-- @pos 7 0 709 33
-----------------------------------
package.loaded["scripts/zones/AlTaieu/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/AlTaieu/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fc, 85);
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 |
waytim/darkstar | scripts/globals/items/serving_of_menemen_+1.lua | 18 | 1531 | -----------------------------------------
-- ID: 5587
-- Item: serving_of_menemen_+1
-- Food Effect: 4Hrs, All Races
-----------------------------------------
-- HP 35
-- MP 35
-- Agility 2
-- Intelligence -2
-- HP recovered while healing 2
-- MP recovered while healing 2
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,14400,5587);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 35);
target:addMod(MOD_MP, 35);
target:addMod(MOD_AGI, 2);
target:addMod(MOD_INT, -3);
target:addMod(MOD_HPHEAL, 2);
target:addMod(MOD_MPHEAL, 2);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 35);
target:delMod(MOD_MP, 35);
target:delMod(MOD_AGI, 2);
target:delMod(MOD_INT, -2);
target:delMod(MOD_HPHEAL, 2);
target:delMod(MOD_MPHEAL, 2);
end;
| gpl-3.0 |
Amadiro/debugUI | loveframes/objects/internal/sliderbutton.lua | 3 | 6551 | --[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012-2014 Kenny Shields --
--]]------------------------------------------------
-- get the current require path
local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.sliderbutton"))
local loveframes = require(path .. ".libraries.common")
-- sliderbutton class
local newobject = loveframes.NewObject("sliderbutton", "loveframes_object_sliderbutton", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(parent)
self.type = "sliderbutton"
self.width = 10
self.height = 20
self.staticx = 0
self.staticy = 0
self.startx = 0
self.clickx = 0
self.starty = 0
self.clicky = 0
self.intervals = true
self.internal = true
self.down = false
self.dragging = false
self.parent = parent
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
self:CheckHover()
local x, y = love.mouse.getPosition()
local intervals = self.intervals
local progress = 0
local nvalue = 0
local pvalue = self.parent.value
local hover = self.hover
local down = self.down
local downobject = loveframes.downobject
local parent = self.parent
local slidetype = parent.slidetype
local dragging = self.dragging
local base = loveframes.base
local update = self.Update
if not hover then
self.down = false
if downobject == self then
self.hover = true
end
else
if downobject == self then
self.down = true
end
end
if not down and downobject == self then
self.hover = true
end
-- move to parent if there is a parent
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
-- start calculations if the button is being dragged
if dragging then
-- calculations for horizontal sliders
if slidetype == "horizontal" then
self.staticx = self.startx + (x - self.clickx)
progress = self.staticx/(self.parent.width - self.width)
nvalue = self.parent.min + (self.parent.max - self.parent.min) * progress
nvalue = loveframes.util.Round(nvalue, self.parent.decimals)
-- calculations for vertical sliders
elseif slidetype == "vertical" then
self.staticy = self.starty + (y - self.clicky)
local space = self.parent.height - self.height
local remaining = (self.parent.height - self.height) - self.staticy
local percent = remaining/space
nvalue = self.parent.min + (self.parent.max - self.parent.min) * percent
nvalue = loveframes.util.Round(nvalue, self.parent.decimals)
end
if nvalue > self.parent.max then
nvalue = self.parent.max
end
if nvalue < self.parent.min then
nvalue = self.parent.min
end
self.parent.value = nvalue
if self.parent.value == -0 then
self.parent.value = math.abs(self.parent.value)
end
if nvalue ~= pvalue and nvalue >= self.parent.min and nvalue <= self.parent.max then
if self.parent.OnValueChanged then
self.parent.OnValueChanged(self.parent, self.parent.value)
end
end
loveframes.downobject = self
end
if slidetype == "horizontal" then
if (self.staticx + self.width) > self.parent.width then
self.staticx = self.parent.width - self.width
end
if self.staticx < 0 then
self.staticx = 0
end
end
if slidetype == "vertical" then
if (self.staticy + self.height) > self.parent.height then
self.staticy = self.parent.height - self.height
end
if self.staticy < 0 then
self.staticy = 0
end
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawSliderButton or skins[defaultskin].DrawSliderButton
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
if hover and button == 1 then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
self.down = true
self.dragging = true
self.startx = self.staticx
self.clickx = x
self.starty = self.staticy
self.clicky = y
loveframes.downobject = self
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
local down = self.down
local dragging = self.dragging
if dragging then
local parent = self.parent
local onrelease = parent.OnRelease
if onrelease then
onrelease(parent)
end
end
self.down = false
self.dragging = false
end
--[[---------------------------------------------------------
- func: MoveToX(x)
- desc: moves the object to the specified x position
--]]---------------------------------------------------------
function newobject:MoveToX(x)
self.staticx = x
end
--[[---------------------------------------------------------
- func: MoveToY(y)
- desc: moves the object to the specified y position
--]]---------------------------------------------------------
function newobject:MoveToY(y)
self.staticy = y
end
| mit |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/zones/Aht_Urhgan_Whitegate/npcs/Mulnith.lua | 2 | 1210 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Mulnith
-- Standard Merchant NPC
-----------------------------------
require("scripts/globals/shop");
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,MULNITH_SHOP_DIALOG);
stock = {0x113A,344, -- Roast Mushroom
0x15DE,2000, -- Sis Kebabi (available when AC is in Al Zahbi)
0x15E0,3000} -- Balik Sis (available when AC is in Al Zahbi)
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 |
waytim/darkstar | scripts/zones/Temenos/bcnms/Central_Temenos_3rd_Floor.lua | 35 | 1139 | -----------------------------------
-- Area: Temenos
-- Name:
-----------------------------------
-- After registering the BCNM via bcnmRegister(bcnmid)
function onBcnmRegister(player,instance)
SetServerVariable("[C_Temenos_3rd]UniqueID",GenerateLimbusKey());
HideArmouryCrates(GetInstanceRegion(1305),TEMENOS);
HideTemenosDoor(GetInstanceRegion(1305));
player:setVar("Limbus_Trade_Item-T",0);
end;
-- Physically entering the BCNM via bcnmEnter(bcnmid)
function onBcnmEnter(player,instance)
player:setVar("limbusbitmap",0);
player:setVar("characterLimbusKey",GetServerVariable("[C_Temenos_3rd]UniqueID"));
player:setVar("LimbusID",1305);
player:delKeyItem(COSMOCLEANSE);
player:delKeyItem(WHITE_CARD);
end;
-- Leaving by every mean possible, given by the LeaveCode
-- 3=Disconnected or warped out (if dyna is empty: launch 4 after 3)
-- 4=Finish he dynamis
function onBcnmLeave(player,instance,leavecode)
--print("leave code "..leavecode);
if (leavecode == 4) then
player:setPos(580,-1.5,4.452,192);
ResetPlayerLimbusVariable(player)
end
end; | gpl-3.0 |
TienHP/Aquaria | files/scripts/entities/mutantnaija.lua | 6 | 4573 | -- Copyright (C) 2007, 2010 - Bit-Blot
--
-- This file is part of Aquaria.
--
-- Aquaria is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License
-- as published by the Free Software Foundation; either version 2
-- of the License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--
-- See the GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
if not v then v = {} end
if not AQUARIA_VERSION then dofile("scripts/entities/entityinclude.lua") end
v.n = 0
v.head = 0
local STATE_SWIM = 1000
local STATE_BURST = 1001
v.burstDelay = 0
v.singDelay = 4
v.fireDelay = 3
v.fired = 0
v.fireShotDelay = 0
local function idle(me)
entity_setState(me, STATE_IDLE, math.random(1)+0.5)
end
local function doBurstDelay()
v.burstDelay = math.random(4) + 2
end
function init(me)
setupEntity(me)
entity_setEntityType(me, ET_ENEMY)
entity_initSkeletal(me, "Naija", "Mutant")
--entity_setAllDamageTargets(me, false)
entity_scale(me, 0.7, 0.7)
entity_setCollideRadius(me, 20)
entity_setHealth(me, 20)
bone_alpha(entity_getBoneByName(me, "Fish2"),0)
bone_alpha(entity_getBoneByName(me, "DualFormGlow"),0)
v.head = entity_getBoneByName(me, "Head")
entity_setDeathScene(me, true)
idle(me)
entity_setUpdateCull(me, 1300)
loadSound("mutantnaija-note")
loadSound("mutantnaija-note-hit")
end
function postInit(me)
v.n = getNaija()
entity_setTarget(me, v.n)
end
function update(me, dt)
entity_updateMovement(me, dt)
entity_handleShotCollisions(me)
entity_setLookAtPoint(me, bone_getWorldPosition(v.head))
if entity_isState(me, STATE_IDLE) then
entity_rotate(me, 0, 0.1)
elseif entity_isState(me, STATE_SWIM) then
entity_moveTowardsTarget(me, dt, 500)
v.burstDelay = v.burstDelay - dt
if v.burstDelay < 0 then
doBurstDelay()
entity_setMaxSpeedLerp(me, 2)
entity_setMaxSpeedLerp(me, 1, 4)
entity_moveTowardsTarget(me, 1, 1000)
entity_animate(me, "burst", 0, 1)
end
entity_rotateToVel(me, 0.1)
end
entity_doEntityAvoidance(me, dt, 32, 0.5)
entity_doCollisionAvoidance(me, dt, 4, 0.5)
--[[
v.singDelay = v.singDelay - dt
if v.singDelay < 0 then
v.singDelay = math.random(3) + 3
entity_sound(me, getNoteName(math.random(8)), 1, 3)
local x = entity_x(v.n) - entity_x(me)
local y = entity_y(v.n) - entity_y(me)
x, y = vector_setLength(x, y, 1000)
entity_addVel(v.n, x, y)
end
]]--
if entity_isState(me, STATE_SWIM) then
if v.fired == -1 then
v.fireDelay = v.fireDelay - dt
if v.fireDelay < 0 then
v.fired = 3
v.fireDelay = math.random(2) + 3
v.fireShotDelay = 0
end
end
end
if v.fired > -1 then
v.fireShotDelay = v.fireShotDelay - dt
if v.fireShotDelay < 0 then
local s = createShot("MutantNaija", me, v.n, bone_getWorldPosition(v.head))
v.fired = v.fired - 1
if v.fired == 0 then
v.fired = -1
end
v.fireShotDelay = 0.2
end
end
local thresh = 10
if entity_velx(me) > thresh and not entity_isfh(me) then
entity_fh(me)
end
if entity_velx(me) < -thresh and entity_isfh(me) then
entity_fh(me)
end
entity_touchAvatarDamage(me, 8, 1, 500)
end
function enterState(me)
if entity_isState(me, STATE_IDLE) then
entity_animate(me, "idle", -1)
elseif entity_isState(me, STATE_SWIM) then
entity_animate(me, "swim", -1)
elseif entity_isState(me, STATE_DEATHSCENE) then
entity_setColor(me, 0.3, 0.3, 0.3, 1)
entity_setPosition(me, entity_x(me), entity_y(me)+400, -300)
entity_setStateTime(me, entity_animate(me, "diePainfully", 2))
entity_rotate(me, 0, 0.1)
end
end
function exitState(me)
if entity_isState(me, STATE_IDLE) then
entity_rotate(me, 0, 0.1)
entity_setState(me, STATE_SWIM, math.random(6)+4)
elseif entity_isState(me, STATE_SWIM) then
idle(me)
doBurstDelay()
elseif entity_isState(me, STATE_DEATHSCENE) then
spawnParticleEffect("TinyBlueExplode", entity_getPosition(me))
end
end
function damage(me, attacker, bone, damageType, dmg)
return true
end
function animationKey(me, key)
end
function hitSurface(me)
end
function songNote(me, note)
end
function songNoteDone(me, note)
end
function song(me, song)
end
function activate(me)
end
| gpl-2.0 |
waytim/darkstar | scripts/globals/items/strip_of_buffalo_jerky.lua | 18 | 1385 | -----------------------------------------
-- ID: 5196
-- Item: strip_of_buffalo_jerky
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Strength 4
-- Mind -3
-- Attack % 18
-- Attack Cap 65
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,1800,5196);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_STR, 4);
target:addMod(MOD_MND, -3);
target:addMod(MOD_FOOD_ATTP, 18);
target:addMod(MOD_FOOD_ATT_CAP, 65);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_STR, 4);
target:delMod(MOD_MND, -3);
target:delMod(MOD_FOOD_ATTP, 18);
target:delMod(MOD_FOOD_ATT_CAP, 65);
end;
| gpl-3.0 |
saeqe/nod | plugins/anti_bot.lua | 65 | 3192 |
local function isBotAllowed (userId, chatId)
local hash = 'anti-bot:allowed:'..chatId..':'..userId
local banned = redis:get(hash)
return banned
end
local function allowBot (userId, chatId)
local hash = 'anti-bot:allowed:'..chatId..':'..userId
redis:set(hash, true)
end
local function disallowBot (userId, chatId)
local hash = 'anti-bot:allowed:'..chatId..':'..userId
redis:del(hash)
end
-- Is anti-bot enabled on chat
local function isAntiBotEnabled (chatId)
local hash = 'anti-bot:enabled:'..chatId
local enabled = redis:get(hash)
return enabled
end
local function enableAntiBot (chatId)
local hash = 'anti-bot:enabled:'..chatId
redis:set(hash, true)
end
local function disableAntiBot (chatId)
local hash = 'anti-bot:enabled:'..chatId
redis:del(hash)
end
local function isABot (user)
-- Flag its a bot 0001000000000000
local binFlagIsBot = 4096
local result = bit32.band(user.flags, binFlagIsBot)
return result == binFlagIsBot
end
local function kickUser(userId, chatId)
local chat = 'chat#id'..chatId
local user = 'user#id'..userId
chat_del_user(chat, user, function (data, success, result)
if success ~= 1 then
print('I can\'t kick '..data.user..' but should be kicked')
end
end, {chat=chat, user=user})
end
local function run (msg, matches)
-- We wont return text if is a service msg
if matches[1] ~= 'chat_add_user' and matches[1] ~= 'chat_add_user_link' then
if msg.to.type ~= 'chat' then
return 'Anti-flood works only on channels'
end
end
local chatId = msg.to.id
if matches[1] == 'enable' then
enableAntiBot(chatId)
return 'bot cant come group is safe'
end
if matches[1] == 'disable' then
disableAntiBot(chatId)
return 'bot can come group is NOT safe'
end
if matches[1] == 'allow' then
local userId = matches[2]
allowBot(userId, chatId)
return 'Bot '..userId..' allowed'
end
if matches[1] == 'disallow' then
local userId = matches[2]
disallowBot(userId, chatId)
return 'Bot '..userId..' disallowed'
end
if matches[1] == 'chat_add_user' or matches[1] == 'chat_add_user_link' then
local user = msg.action.user or msg.from
if isABot(user) then
print('It\'s a bot!')
if isAntiBotEnabled(chatId) then
print('Anti bot is enabled')
local userId = user.id
if not isBotAllowed(userId, chatId) then
kickUser(userId, chatId)
else
print('This bot is allowed')
end
end
end
end
end
return {
description = 'When bot enters group kick it.',
usage = {
'!antibot enable: Enable Anti-bot on current chat',
'!antibot disable: Disable Anti-bot on current chat',
'!antibot allow <botId>: Allow <botId> on this chat',
'!antibot disallow <botId>: Disallow <botId> on this chat'
},
patterns = {
'^!antibot (allow) (%d+)$',
'^!antibot (disallow) (%d+)$',
'^!antibot (enable)$',
'^!antibot (disable)$',
'^!!tgservice (chat_add_user)$',
'^!!tgservice (chat_add_user_link)$'
},
run = run
}
--Copyright; @behroozyaghi
--Persian Translate; @behroozyaghi
--ch : @nod32team
--کپی بدون ذکر منبع حرام است
| gpl-2.0 |
TheOnePharaoh/YGOPro-Custom-Cards | script/c100000847.lua | 2 | 4211 | --Created and coded by Rising Phoenix
function c100000847.initial_effect(c)
c:EnableReviveLimit()
--cannot remove
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CANNOT_REMOVE)
e1:SetRange(LOCATION_MZONE)
e1:SetTargetRange(LOCATION_GRAVE,0)
e1:SetCondition(c100000847.contp)
c:RegisterEffect(e1)
--tograve
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(100000847,0))
e3:SetCategory(CATEGORY_TOGRAVE)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetCode(EVENT_SUMMON_SUCCESS)
e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
e3:SetTarget(c100000847.target)
e3:SetOperation(c100000847.operation)
c:RegisterEffect(e3)
local e4=e3:Clone()
e4:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
c:RegisterEffect(e4)
local e5=e3:Clone()
e5:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e5)
--cannot special summon
local e6=Effect.CreateEffect(c)
e6:SetType(EFFECT_TYPE_SINGLE)
e6:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e6:SetCode(EFFECT_SPSUMMON_CONDITION)
c:RegisterEffect(e6)
--special summon
local e7=Effect.CreateEffect(c)
e7:SetDescription(aux.Stringid(100000847,0))
e7:SetType(EFFECT_TYPE_FIELD)
e7:SetCode(EFFECT_SPSUMMON_PROC)
e7:SetProperty(EFFECT_FLAG_UNCOPYABLE)
e7:SetRange(LOCATION_HAND)
e7:SetCondition(c100000847.spcon)
e7:SetOperation(c100000847.spop)
c:RegisterEffect(e7)
--1000atk
local e8=Effect.CreateEffect(c)
e8:SetDescription(aux.Stringid(100000847,0))
e8:SetProperty(EFFECT_FLAG_CARD_TARGET)
e8:SetType(EFFECT_TYPE_IGNITION)
e8:SetRange(LOCATION_GRAVE)
e8:SetCost(c100000847.costat)
e8:SetTarget(c100000847.targetat)
e8:SetOperation(c100000847.operationat)
c:RegisterEffect(e8)
end
function c100000847.contp(e)
return not Duel.IsPlayerAffectedByEffect(e:GetHandler():GetControler(),EFFECT_NECRO_VALLEY_IM)
end
function c100000847.filter(c)
return c:IsSetCard(0x10C) and not c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToDeckAsCost()
end
function c100000847.spcon(e,c)
if c==nil then return true end
return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c100000847.filter,c:GetControler(),LOCATION_GRAVE,0,1,e:GetHandler())
end
function c100000847.spop(e,tp,eg,ep,ev,re,r,rp,c)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local g=Duel.SelectMatchingCard(tp,c100000847.filter,tp,LOCATION_GRAVE,0,1,1,c)
Duel.SendtoDeck(g,nil,2,REASON_COST)
end
function c100000847.gfilter(c)
return c:IsSetCard(0x10C) and not c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToGrave()
end
function c100000847.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c100000847.gfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK)
end
function c100000847.operation(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,c100000847.gfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then end
Duel.SendtoGrave(g,REASON_EFFECT)
if not e:GetHandler():IsRelateToEffect(e) then return end
if Duel.GetFieldGroupCount(tp,0,LOCATION_DECK)==0 then return end
local g=Duel.GetDecktopGroup(1-tp,1)
Duel.DisableShuffleCheck()
Duel.Remove(g,POS_FACEDOWN,REASON_EFFECT)
end
function c100000847.costat(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToDeck() end
Duel.SendtoDeck(e:GetHandler(),nil,2,REASON_COST)
end
function c100000847.targetat(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsFaceup() end
if chk==0 then return Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
end
function c100000847.operationat(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if tc:IsFaceup() and tc:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(-1000)
e1:SetReset(RESET_EVENT+0x1fe0000)
tc:RegisterEffect(e1)
end
end | gpl-3.0 |
TheOnePharaoh/YGOPro-Custom-Cards | script/c512000010.lua | 2 | 3057 | --Draw of Fate
function c512000010.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCategory(CATEGORY_DRAW)
e1:SetCode(EVENT_ATTACK_ANNOUNCE)
e1:SetCondition(c512000010.condition)
e1:SetTarget(c512000010.target)
e1:SetOperation(c512000010.activate)
c:RegisterEffect(e1)
end
function c512000010.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetLP(tp)<=2000 or Duel.GetLP(1-tp)<=2000
end
function c512000010.target(e,tp,eg,ep,ev,re,r,rp,chk)
local tg=Duel.GetAttacker()
if chk==0 then return tg:IsOnField() and Duel.IsPlayerCanDraw(tp,1) and Duel.IsPlayerCanDraw(1-tp,1) end
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,PLAYER_ALL,1)
end
function c512000010.activate(e,tp,eg,ep,ev,re,r,rp)
if Duel.NegateAttack() and Duel.Draw(1-tp,1,REASON_EFFECT)~=0 then
Duel.BreakEffect()
local h1=Duel.GetDecktopGroup(tp,1):GetFirst()
Duel.Draw(tp,1,REASON_EFFECT)
if h1==0 then return end
local h2=Duel.GetDecktopGroup(1-tp,1):GetFirst()
Duel.Draw(1-tp,1,REASON_EFFECT)
if h2==0 then return end
Duel.ConfirmCards(tp,h1)
Duel.ConfirmCards(tp,h2)
local g=Group.FromCards(h1,h2)
g:KeepAlive()
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetOperation(c512000010.regop)
e1:SetLabel(3)
e1:SetLabelObject(g)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
local e2=e1:Clone()
e2:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
e2:SetLabelObject(e1)
e2:SetOperation(c512000010.regop2)
Duel.RegisterEffect(e2,tp)
local e3=e2:Clone()
e3:SetCode(EVENT_SPSUMMON_SUCCESS)
Duel.RegisterEffect(e3,tp)
local e4=e2:Clone()
e4:SetCode(EVENT_CHAINING)
Duel.RegisterEffect(e4,tp)
local e5=Effect.CreateEffect(e:GetHandler())
e5:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e5:SetCode(EVENT_PHASE+PHASE_END)
e5:SetCountLimit(1)
e5:SetOperation(c512000010.winop)
e5:SetReset(RESET_PHASE+PHASE_END)
e5:SetLabelObject(e1)
Duel.RegisterEffect(e5,tp)
end
end
function c512000010.regop(e,tp,eg,ep,ev,re,r,rp)
local g=e:GetLabelObject()
if g:GetCount()==0 then return end
local tc=eg:GetFirst()
if tc==g:GetFirst() and (e:GetLabel()==3 or e:GetLabel()==1) then
e:SetLabel(e:GetLabel()-1)
end
if tc==g:GetNext() and (e:GetLabel()==3 or e:GetLabel()==2) then
e:SetLabel(e:GetLabel()-2)
end
end
function c512000010.regop2(e,tp,eg,ep,ev,re,r,rp)
local g=e:GetLabelObject():GetLabelObject()
if g:GetCount()==0 then return end
local tc=eg:GetFirst()
if tc==g:GetFirst() and (e:GetLabel()==3 or e:GetLabel()==1) then
e:GetLabelObject():SetLabel(e:GetLabel()-1)
end
if tc==g:GetNext() and (e:GetLabel()==3 or e:GetLabel()==2) then
e:GetLabelObject():SetLabel(e:GetLabel()-2)
end
end
function c512000010.winop(e,tp,eg,ep,ev,re,r,rp)
if e:GetLabelObject():GetLabel()==3 then
Duel.Win(PLAYER_NONE,0x55)
end
if e:GetLabelObject():GetLabel()==2 then
Duel.Win(tp,0x55)
end
if e:GetLabelObject():GetLabel()==1 then
Duel.Win(1-tp,0x55)
end
end
| gpl-3.0 |
Guim3/IcGAN | other/alternativeEncoders/trainEncoderE2E.lua | 1 | 13031 | -- This file reads the dataset generated by generateEncoderDataset.lua and
-- trains an encoder net that learns to map an image X to a noise vector Z (encoder Z, type Z)
-- or an encoded that maps an image X to an attribute vector Y (encoder Y, type Y).
require 'image'
require 'nn'
require 'optim'
require 'cunn'
require 'cudnn'
torch.setdefaulttensortype('torch.FloatTensor')
local function getParameters()
opt = {}
-- Type of encoder must be passed as argument to decide what kind of
-- encoder will be trained (encoder Z [type Z] or encoder Y [type Y])
opt.type = os.getenv('type')
opt.type = 'Y'
assert(opt.type, "Parameter 'type' not specified. It is necessary to set the encoder type: 'Z' or 'Y'.\nExample: type=Z th trainEncoder.lua")
assert(string.upper(opt.type)=='Z' or string.upper(opt.type)=='Y',"Parameter 'type' must be 'Z' (encoder Z) or 'Y' (encoder Y).")
-- Load parameters from config file
if string.upper(opt.type)=='Z' then
assert(loadfile("cfg/mainConfig.lua"))(1)
else
assert(loadfile("cfg/mainConfig.lua"))(2)
end
-- one-line argument parser. Parses environment variables to override the defaults
for k,v in pairs(opt) do opt[k] = tonumber(os.getenv(k)) or os.getenv(k) or opt[k] end
print(opt)
if opt.display then display = require 'display' end
return opt
end
local function readDataset(path, imSize)
-- For CelebA: there's expected to find in path a file named images.dmp and imLabels.dmp
-- which contains the images X and attribute vectors Y.
-- images.dmp is obtained running data/preprocess_celebA.lua
-- imLabels.dmp is obtained running trainGAN.lua via data/donkey_celebA.lua
-- For MNIST: It will use the mnist luarocks package
local X, Y
if string.lower(path) == 'mnist' or string.lower(path) == 'mnist/' then
local mnist = require 'mnist'
local trainSet = mnist.traindataset()
X = torch.Tensor(trainSet.data:size(1), 1, imSize, imSize)
local resize = trainSet.data:size(2) ~= imSize
local labels = trainSet.label:int()
Y = torch.IntTensor(trainSet.data:size(1), 10):fill(-1)
for i = 1,trainSet.data:size(1) do
-- Read MNIST images
local im = trainSet.data[{{i}}]
if resize then
im = image.scale(im, imSize, imSize):float()
end
im:div(255):mul(2):add(-1) -- change [0, 255] to [-1, 1]
X[{{i}}]:copy(im)
--Read MNIST labels
local class = trainSet.label[i] -- Convert 0-9 to one-hot vector
Y[{{i},{class+1}}] = 1
end
else
print('Loading images X from '..path..'images.dmp')
local data = torch.load(path..'images.dmp')
print(('Done. Loaded %.2f GB (%d images).'):format((4*data:size(1)*data:size(2)*data:size(3)*data:size(4))/2^30, data:size(1)))
if data:size(3) ~= imSize then
-- Resize images
X = torch.Tensor(data:size(1), imSize, imSize)
for i = 1,data:size(1) do
local im = image.scale(data[{{i}}], imSize, imSize)
im:mul(2):add(-1) -- change [0, 1] -to[-1, 1]
X[{{i}}]:copy(im)
end
else
X = data
X:mul(2):add(-1) -- change [0, 1] to [-1, 1]
end
print('Loading attributes Y from '..path..'imLabels.dmp')
Y = torch.load(path..'imLabels.dmp')
print(('Done. Loaded %d attributes'):format(Y:size(1)))
end
return X, Y
end
local function splitTrainTest(x, y, split)
local xTrain, yTrain, xTest, yTest
local nSamples = x:size(1)
local splitInd = torch.floor(split*nSamples)
xTrain = x[{{1,splitInd}}]
yTrain = y[{{1,splitInd}}]
xTest = x[{{splitInd+1,nSamples}}]
yTest = y[{{splitInd+1,nSamples}}]
return xTrain, yTrain, xTest, yTest
end
local function getEncoder(inputSize, nFiltersBase, nConvLayers, FCsz)
-- Encoder architecture based on Autoencoding beyond pixels using a learned similarity metric (VAE/GAN hybrid)
local encoder = nn.Sequential()
-- Assuming nFiltersBase = 64, nConvLayers = 3
-- 1st Conv layer: 5×5 64 conv. ↓, BNorm, ReLU
-- Data: 32x32 -> 16x16
encoder:add(nn.SpatialConvolution(inputSize[1], nFiltersBase, 5, 5, 2, 2, 2, 2))
encoder:add(nn.SpatialBatchNormalization(nFiltersBase))
encoder:add(nn.ReLU(true))
-- 2nd Conv layer: 5×5 128 conv. ↓, BNorm, ReLU
-- Data: 16x16 -> 8x8
-- 3rd Conv layer: 5×5 256 conv. ↓, BNorm, ReLU
-- Data: 8x8 -> 4x4
local nFilters = nFiltersBase
for j=2,nConvLayers do
encoder:add(nn.SpatialConvolution(nFilters, nFilters*2, 5, 5, 2, 2, 2, 2))
encoder:add(nn.SpatialBatchNormalization(nFilters*2))
encoder:add(nn.ReLU(true))
nFilters = nFilters * 2
end
-- 4th FC layer: 2048 fully-connected
-- Data: 4x4 -> 16
encoder:add(nn.View(-1):setNumInputDims(3)) -- reshape data to 2d tensor (samples x the rest)
-- Assuming squared images and conv layers configuration (kernel, stride and padding) is not changed:
--nFilterFC = (imageSize/2^nConvLayers)²*nFiltersLastConvNet
local inputFilterFC = (inputSize[2]/2^nConvLayers)^2*nFilters
if FCsz == nil then FCsz = inputFilterFC end
encoder:add(nn.Linear(inputFilterFC, FCsz))
encoder:add(nn.BatchNormalization(FCsz))
encoder:add(nn.ReLU(true))
encoder:add(nn.Linear(FCsz, 100)) -- 100 is the size of the Z vector
local criterion = nn.MSECriterion()
return encoder, criterion
end
local function assignBatches(batchX, batchY, x, y, batch, batchSize, shuffle)
data_tm:reset(); data_tm:resume()
batchX:copy(x:index(1, shuffle[{{batch,batch+batchSize-1}}]:long()))
batchY:copy(y:index(1, shuffle[{{batch,batch+batchSize-1}}]:long()))
data_tm:stop()
return batchX, batchY
end
local function displayConfig(disp, title)
-- initialize error display configuration
local errorData, errorDispConfig
if disp then
errorData = {}
errorDispConfig =
{
title = 'Encoder error - ' .. title,
win = 1,
labels = {'Epoch', 'Train error', 'Test error'},
ylabel = "Error",
legend='always'
}
end
return errorData, errorDispConfig
end
function main()
local opt = getParameters()
print(opt)
-- Set timers
local epoch_tm = torch.Timer()
local tm = torch.Timer()
data_tm = torch.Timer()
-- Read images X and labels Y from dataset
local X, Y = readDataset(opt.datasetPath, opt.loadSize)
-- X: #samples x im3 x im2 x im1
-- Y: #samples x ny
-- Split train and test
local xTrain, yTrain, xTest, yTest
xTrain, yTrain, xTest, yTest = splitTrainTest(X, Y, opt.split)
-- Set network architecture
local encoder, criterion = getEncoder(xTrain[1]:size(), opt.nf, opt.nConvLayers, opt.FCsz)
-- Initialize batches
local batchX = torch.Tensor(opt.batchSize, xTrain:size(2), xTrain:size(3), xTrain:size(4))
local batchY = torch.Tensor(opt.batchSize, yTrain:size(2))
-- Load generator
local generator = torch.load('checkpoints/c_celebA_64_filt_Yconv1_noTest_wrongYFixed_24_net_G.t7')
-- Copy variables to GPU
cutorch.setDevice(opt.gpu)
batchX = batchX:cuda(); batchY = batchY:cuda()
if pcall(require, 'cudnn') then
cudnn.benchmark = true
cudnn.convert(encoder, cudnn)
end
generator:cuda()
encoder:cuda()
criterion:cuda()
generator:evaluate()
-- Remove optimization to enable backward step, in case the network is optimized
--local optnet = require 'optnet'
--optnet.removeOptimization(generator)
local params, gradParams = encoder:getParameters() -- This has to be performed always after the cuda call
-- Define optim (general optimizer)
local errorTrain
local errorTest
local function optimFunction(params) -- This function needs to be declared here to avoid using global variables.
-- reset gradients (gradients are always accumulated, to accommodat batch methods)
gradParams:zero()
-- Encode images
local outputs = encoder:forward(batchX)
outputs:resize(outputs:size(1), outputs:size(2), 1, 1) -- Adapt dimensionality to generator input (batchSz x nz x 1 x 1)
-- Reconstruct encoded images
local reconstr = generator:forward{outputs, batchY}
-- Compute error (MSE pixel-wise image reconstruction)
errorTrain = criterion:forward(batchX, reconstr)
-- Compute error gradients w.r.t. generator output
local df_do = criterion:backward(batchX, reconstr)
-- Compute error gradients w.r.t. generator input / encoder output
local df_dg = generator:updateGradInput({outputs, batchY}, df_do)
-- df_dg[1] contains the gradients of the latent space Z (encoder output, generator Z input)
-- which are the ones you need to compute the backward step.
-- df_dg[2] contains the gradients of Y. You don't need them as they are not the encoder output.
df_dg[1]:resize(df_dg[1]:size(1), df_dg[1]:size(2)) -- Adapt dimensionality to encoder output (batchSz x nz)
outputs:resize(outputs:size(1), outputs:size(2))
-- Backpropagate generator gradients to encoder
encoder:backward(batchX, df_dg[1])
return errorTrain, gradParams
end
local optimState = {
learningRate = opt.lr,
beta1 = opt.beta1,
}
local nTrainSamples = xTrain:size(1)
local nTestSamples = xTest:size(1)
-- Initialize display configuration (if enabled)
local errorData, errorDispConfig = displayConfig(opt.display, opt.name)
paths.mkdir(opt.outputPath)
local dispBatchX, dispBatchY
if opt.display == 2 then
dispBatchX = torch.Tensor(opt.batchSize, xTrain:size(2), xTrain:size(3), xTrain:size(4)):cuda()
dispBatchY = torch.Tensor(opt.batchSize, yTrain:size(2)):cuda()
dispBatchX:copy(xTest[{{1,opt.batchSize}}])
dispBatchY:copy(yTest[{{1,opt.batchSize}}])
display.image(image.toDisplayTensor(dispBatchX,0,torch.round(math.sqrt(opt.batchSize))), {win=3, title='Real test images'})
end
-- Train network
local batchIterations = 0 -- for display purposes only
for epoch = 1, opt.nEpochs do
epoch_tm:reset()
local shuffle = torch.randperm(nTrainSamples)
for batch = 1, nTrainSamples-opt.batchSize+1, opt.batchSize do
tm:reset()
batchX, batchY = assignBatches(batchX, batchY, xTrain, yTrain, batch, opt.batchSize, shuffle)
-- Update network
optim.adam(optimFunction, params, optimState)
-- Display train and test error
if opt.display and batchIterations % 20 == 0 then
-- Test error
batchX, batchY = assignBatches(batchX, batchY, xTest, yTest, torch.random(1,nTestSamples-opt.batchSize+1), opt.batchSize, torch.randperm(nTestSamples))
local outputs = encoder:forward(batchX)
outputs:resize(outputs:size(1), outputs:size(2), 1, 1)
local reconstr = generator:forward{outputs, batchY}
errorTest = criterion:forward(batchX, reconstr)
table.insert(errorData,
{
batchIterations/math.ceil(nTrainSamples / opt.batchSize), -- x-axis
errorTrain, -- y-axis for label1
errorTest -- y-axis for label2
})
display.plot(errorData, errorDispConfig)
if opt.display == 2 then
local outputs = encoder:forward(dispBatchX)
outputs:resize(outputs:size(1), outputs:size(2), 1, 1)
local reconstr = generator:forward{outputs, dispBatchY}
display.image(image.toDisplayTensor(reconstr,0,torch.round(math.sqrt(opt.batchSize))), {win=4, title='Reconstructions'})
end
end
-- Verbose
if ((batch-1) / opt.batchSize) % 1 == 0 then
print(('Epoch: [%d][%4d / %4d] Error (train): %.4f Error (test): %.4f '
.. ' Time: %.3f s Data time: %.3f s'):format(
epoch, ((batch-1) / opt.batchSize),
math.ceil(nTrainSamples / opt.batchSize),
errorTrain and errorTrain or -1,
errorTest and errorTest or -1,
tm:time().real, data_tm:time().real))
end
batchIterations = batchIterations + 1
end
print(('End of epoch %d / %d \t Time Taken: %.3f s'):format(
epoch, opt.nEpochs, epoch_tm:time().real))
-- Store network
torch.save(opt.outputPath .. opt.name .. '_' .. epoch .. 'epochs.t7', encoder:clearState())
torch.save('checkpoints/' .. opt.name .. '_error.t7', errorData)
end
end
main() | bsd-3-clause |
zorfmorf/loveprojects | traderun/Client/model/lifeform.lua | 1 | 2148 | -- A lifeform is something that can move around on its own, usually found
-- in a ship. the player is also a lifeform
LIFEFORM_ID = 1 -- every lifeform has it's unique id. needed?
class "Lifeform" {
name = "NPC"; -- lifeform name. May be displayed?
hp = {100, 100}; -- current and max hitpoints. chp == 0? DIES
oxygen = 100; -- the oxygen of this lifeform. zero? DIES
id = nil; -- the unique ID of this object
animCycle = {2, 3, 2, 4};
animDT = 1;
layers = {1};
speed = 0; -- movement speed into direction looked
strafe = 0; -- strafe directions. -1 = left, 1 = right
x = 0; -- the x position (presumably on the ship. nothing to do with game coords)
y = 0; -- the y to the x
o = 0; -- the orientation. has everything to do with game coords
-- initate a new lifeform
__init__ = function(self, name, maxhp)
if name ~= nil then self.name = name end
if maxhp ~= nil then self.hp = {maxhp, maxhp} end
self:createID()
end,
-- take dmg. Returns true if dead
takeDmg = function(self, value)
self.hp[1] = math.max(0, self.hp[1] - value)
return self.hp[1] == 0
end,
-- get self a unique id
createID = function(self)
self.id = LIFEFORM_ID
LIFEFORM_ID = LIFEFORM_ID + 1
end,
-- update animation cycle
update = function(self, dt)
self.animDT = self.animDT + dt * 7
if self.animDT >= 5 or (self.speed == 0) then self.animDT = 1 end
-- position updating? can be found in the corresponding ships update function
-- why? because the ship knows where the floor and the doors are
-- if this lifeform is the player, then (quite dirtly) adjust his orientation, so that he
-- faces the mouse cursor)
if self.id == main_player.id then
-- adjust player orientation
local px, py = drawHandler_calculateDrawPosition(main_ship, self.x, self.y)
local mx, my = drawHandler_convertScreenToWorld(love.mouse.getX(), love.mouse.getY())
-- oh glorious atan2 function
-- what is it I do you ask? I calculate the angle from the player
-- position to the mouse position in radians
self.o = math.atan2(mx - px, py - my)
end
end
}
| apache-2.0 |
TheOnePharaoh/YGOPro-Custom-Cards | script/c86221227.lua | 2 | 3200 | --Vocaloid Megumi/Assault Mode
function c86221227.initial_effect(c)
c:EnableReviveLimit()
--Cannot special summon
local e1=Effect.CreateEffect(c)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
e1:SetValue(aux.FALSE)
c:RegisterEffect(e1)
--immune
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_IMMUNE_EFFECT)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetRange(LOCATION_MZONE)
e2:SetValue(c86221227.efilter)
c:RegisterEffect(e2)
--spsummon
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(86221227,0))
e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetCountLimit(1)
e3:SetRange(LOCATION_MZONE)
e3:SetTarget(c86221227.sptg)
e3:SetOperation(c86221227.spop)
c:RegisterEffect(e3)
--Special summon2
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(86221227,1))
e4:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_SINGLE)
e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
e4:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP)
e4:SetCode(EVENT_LEAVE_FIELD)
e4:SetCondition(c86221227.spcon)
e4:SetTarget(c86221227.sptg2)
e4:SetOperation(c86221227.spop2)
c:RegisterEffect(e4)
end
function c86221227.efilter(e,te)
return te:IsActiveType(TYPE_MONSTER) and te:GetOwnerPlayer()~=e:GetHandlerPlayer()
end
function c86221227.spfilter(c,e,tp)
return c:IsRace(RACE_MACHINE) and c:GetCode()~=97341616
and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and not c:IsHasEffect(EFFECT_NECRO_VALLEY)
end
function c86221227.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c86221227.spfilter,tp,LOCATION_GRAVE+LOCATION_HAND,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_GRAVE+LOCATION_HAND)
Duel.SetChainLimit(aux.FALSE)
end
function c86221227.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c86221227.spfilter,tp,LOCATION_GRAVE+LOCATION_HAND,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
end
function c86221227.spcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsReason(REASON_DESTROY)
end
function c86221227.spfilter2(c,e,tp)
return c:IsCode(97341616) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c86221227.sptg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c86221227.spfilter2(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c86221227.spfilter2,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c86221227.spfilter2,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c86221227.spop2(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
end
end
| gpl-3.0 |
waytim/darkstar | scripts/globals/abilities/pets/tail_whip.lua | 30 | 1284 | ---------------------------------------------------
-- Tail Whip M=5
---------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
require("scripts/globals/summon");
---------------------------------------------------
function onAbilityCheck(player, target, ability)
return 0,0;
end;
function onPetAbility(target, pet, skill)
local numhits = 1;
local accmod = 1;
local dmgmod = 5;
local totaldamage = 0;
local damage = AvatarPhysicalMove(pet,target,skill,numhits,accmod,dmgmod,0,TP_NO_EFFECT,1,2,3);
totaldamage = AvatarFinalAdjustments(damage.dmg,pet,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_PIERCE,numhits);
local duration = 120;
local resm = applyPlayerResistance(pet,-1,target,pet:getStat(MOD_INT)-target:getStat(MOD_INT),ELEMENTAL_MAGIC_SKILL, 5);
if resm < 0.25 then
resm = 0;
end
duration = duration * resm
if (duration > 0 and AvatarPhysicalHit(skill, totaldamage) and target:hasStatusEffect(EFFECT_WEIGHT) == false) then
target:addStatusEffect(EFFECT_WEIGHT, 50, 0, duration);
end
target:delHP(totaldamage);
target:updateEnmityFromDamage(pet,totaldamage);
return totaldamage;
end | gpl-3.0 |
Project-OSRM/osrm-backend | third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.lua | 12 | 1200 | -- automatically generated by the FlatBuffers compiler, do not modify
-- namespace: NamespaceA
local flatbuffers = require('flatbuffers')
local SecondTableInA = {} -- the module
local SecondTableInA_mt = {} -- the class metatable
function SecondTableInA.New()
local o = {}
setmetatable(o, {__index = SecondTableInA_mt})
return o
end
function SecondTableInA.GetRootAsSecondTableInA(buf, offset)
local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
local o = SecondTableInA.New()
o:Init(buf, n + offset)
return o
end
function SecondTableInA_mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function SecondTableInA_mt:ReferToC()
local o = self.view:Offset(4)
if o ~= 0 then
local x = self.view:Indirect(o + self.view.pos)
local obj = require('NamespaceC.TableInC').New()
obj:Init(self.view.bytes, x)
return obj
end
end
function SecondTableInA.Start(builder) builder:StartObject(1) end
function SecondTableInA.AddReferToC(builder, referToC) builder:PrependUOffsetTRelativeSlot(0, referToC, 0) end
function SecondTableInA.End(builder) return builder:EndObject() end
return SecondTableInA -- return the module | bsd-2-clause |
waytim/darkstar | scripts/zones/Port_Windurst/npcs/Sheia_Pohrichamaha.lua | 16 | 1476 | -----------------------------------
-- Area: Port Windurst
-- NPC: Sheia Pohrichamaha
-- Only sells when Windurst controlls Fauregandi Region
-- Confirmed shop stock, August 2013
-----------------------------------
require("scripts/globals/shop");
require("scripts/globals/conquest");
package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil;
require("scripts/zones/Port_Windurst/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
RegionOwner = GetRegionOwner(FAUREGANDI);
if (RegionOwner ~= WINDURST) then
player:showText(npc,SHEIAPOHRICHAMAHA_CLOSED_DIALOG);
else
player:showText(npc,SHEIAPOHRICHAMAHA_OPEN_DIALOG);
stock = {
0x11DB, 90, --Beaugreens
0x110B, 39, --Faerie Apple
0x02B3, 54 --Maple Log
}
showShop(player,WINDURST,stock);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
jixianliang/DBProxy | examples/tutorial-tokenize.lua | 4 | 1591 | --[[ $%BEGINLICENSE%$
Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; version 2 of the
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
$%ENDLICENSE%$ --]]
--[[
--]]
local tokenizer = require("proxy.tokenizer")
function read_query(packet)
if packet:byte() == proxy.COM_QUERY then
local tokens = tokenizer.tokenize(packet:sub(2))
-- just for debug
for i = 1, #tokens do
-- print the token and what we know about it
local token = tokens[i]
local txt = token["text"]
if token["token_name"] == 'TK_STRING' then
txt = string.format("%q", txt)
end
-- print(i .. ": " .. " { " .. token["token_name"] .. ", " .. token["text"] .. " }" )
print(i .. ": " .. " { " .. token["token_name"] .. ", " .. txt .. " }" )
end
print("normalized query: " .. tokenizer.normalize(tokens))
print("")
end
end
| gpl-2.0 |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/globals/items/coeurl_sub.lua | 3 | 1702 | -----------------------------------------
-- ID: 5166
-- Item: coeurl_sub
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Magic 10
-- Strength 5
-- Agility 1
-- Intelligence -2
-- Health Regen While Healing 1
-- Attack % 20
-- Attack Cap 75
-- Ranged ATT % 20
-- Ranged ATT Cap 75
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,1800,5166);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_MP, 10);
target:addMod(MOD_STR, 5);
target:addMod(MOD_AGI, 1);
target:addMod(MOD_INT, -2);
target:addMod(MOD_HPHEAL, 1);
target:addMod(MOD_FOOD_ATTP, 20);
target:addMod(MOD_FOOD_ATT_CAP, 75);
target:addMod(MOD_FOOD_RATTP, 20);
target:addMod(MOD_FOOD_RATT_CAP, 75);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_MP, 10);
target:delMod(MOD_STR, 5);
target:delMod(MOD_AGI, 1);
target:delMod(MOD_INT, -2);
target:delMod(MOD_HPHEAL, 1);
target:delMod(MOD_FOOD_ATTP, 20);
target:delMod(MOD_FOOD_ATT_CAP, 75);
target:delMod(MOD_FOOD_RATTP, 20);
target:delMod(MOD_FOOD_RATT_CAP, 75);
end;
| gpl-3.0 |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/zones/Riverne-Site_B01/npcs/qm1.lua | 2 | 1191 | -----------------------------------
-- Area: Riverne Site #B01
-- NPC: Unstable Displacement
-----------------------------------
package.loaded["scripts/zones/Riverne-Site_B01/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Riverne-Site_B01/TextIDs");
-----------------------------------
-- onTrade
-----------------------------------
function onTrade(player,npc,trade)
if(trade:hasItemQty(1880,1) and trade:getItemCount() == 1) then -- Trade Clustered tar
player:tradeComplete();
SpawnMob(16896155):updateEnmity(player); -- Unstable Cluster
end
end;
-----------------------------------
-- onTrigger
-----------------------------------
function onTrigger(player,npc)
player:messageSpecial(GROUND_GIVING_HEAT);
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 |
TheOnePharaoh/YGOPro-Custom-Cards | script/c22874081.lua | 2 | 2541 | --Vocaloid Namine Ritsu
function c22874081.initial_effect(c)
c:SetUniqueOnField(1,0,22874081)
--synchro summon
aux.AddSynchroProcedure(c,nil,aux.NonTuner(nil),1)
c:EnableReviveLimit()
--cannot special summon
local e1=Effect.CreateEffect(c)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_SINGLE_RANGE)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetRange(LOCATION_EXTRA)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
e1:SetValue(aux.synlimit)
c:RegisterEffect(e1)
--atk def
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetRange(LOCATION_MZONE)
e2:SetTargetRange(LOCATION_MZONE,0)
e2:SetCode(EFFECT_UPDATE_ATTACK)
e2:SetTarget(c22874081.tg)
e2:SetValue(300)
c:RegisterEffect(e2)
local e3=e2:Clone()
e3:SetCode(EFFECT_UPDATE_DEFENSE)
c:RegisterEffect(e3)
--cannot be battle target
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e4:SetRange(LOCATION_MZONE)
e4:SetCode(EFFECT_CANNOT_BE_BATTLE_TARGET)
e4:SetCondition(c22874081.con)
e4:SetValue(1)
c:RegisterEffect(e4)
--atk/def
local e5=Effect.CreateEffect(c)
e5:SetCategory(CATEGORY_ATKCHANGE+CATEGORY_DEFCHANGE)
e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e5:SetCode(EVENT_PRE_DAMAGE_CALCULATE)
e5:SetCondition(c22874081.adcon)
e5:SetCost(c22874081.adcost)
e5:SetOperation(c22874081.adop)
c:RegisterEffect(e5)
end
function c22874081.tg(e,c)
return c:IsType(TYPE_SYNCHRO)
end
function c22874081.filter(c)
return c:IsFaceup() and c:IsSetCard(0x0dac402) and not c:IsCode(22874080)
end
function c22874081.con(e)
local c=e:GetHandler()
return Duel.IsExistingMatchingCard(c22874081.filter,c:GetControler(),LOCATION_MZONE,0,1,c)
end
function c22874081.adcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local bc=c:GetBattleTarget()
return bc and bc:IsFaceup() and not bc:IsRace(RACE_MACHINE)
end
function c22874081.adcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDiscardable,tp,LOCATION_HAND,0,1,e:GetHandler()) end
Duel.DiscardHand(tp,Card.IsDiscardable,1,1,REASON_COST+REASON_DISCARD)
end
function c22874081.adop(e,tp,eg,ep,ev,re,r,rp)
local bc=e:GetHandler():GetBattleTarget()
if bc:IsRelateToBattle() then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SET_ATTACK_FINAL)
e1:SetValue(0)
e1:SetReset(RESET_PHASE+PHASE_DAMAGE_CAL)
bc:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EFFECT_SET_DEFENSE_FINAL)
bc:RegisterEffect(e2)
end
end | gpl-3.0 |
TheOnePharaoh/YGOPro-Custom-Cards | script/c22769905.lua | 2 | 1845 | --Dreadnought Mark - 005 Hector
function c22769905.initial_effect(c)
--spsummon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(22769905,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetRange(LOCATION_HAND)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCountLimit(1,22769905)
e1:SetCondition(c22769905.spcon)
e1:SetTarget(c22769905.sptg)
e1:SetOperation(c22769905.spop)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e2)
--cannot be effect target
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e3:SetRange(LOCATION_MZONE)
e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
e3:SetValue(aux.tgoval)
c:RegisterEffect(e3)
end
function c22769905.spfilter(c,tp)
return c:IsFaceup() and c:IsControler(tp) and c:IsRace(RACE_MACHINE) and c:IsAttribute(ATTRIBUTE_WIND) and c:GetLevel()==10
end
function c22769905.spcon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c22769905.spfilter,1,nil,tp)
end
function c22769905.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function c22769905.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
local c=e:GetHandler()
if c:IsRelateToEffect(e) and Duel.SpecialSummonStep(c,0,tp,tp,false,false,POS_FACEUP_ATTACK) then
local atk=c:GetBaseAttack()
local def=c:GetBaseDefense()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SET_BASE_ATTACK)
e1:SetValue(0)
e1:SetReset(RESET_EVENT+0x1ff0000)
c:RegisterEffect(e1)
end
end
| gpl-3.0 |
forcecore/OpenRA | mods/cnc/maps/nod09/nod09.lua | 5 | 10636 | --[[
Copyright 2007-2017 The OpenRA Developers (see AUTHORS)
This file is part of OpenRA, which is free software. It is made
available to you 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. For more
information, see COPYING.
]]
if Map.LobbyOption("difficulty") == "easy" then
Rambo = "rmbo.easy"
elseif Map.LobbyOption("difficulty") == "hard" then
Rambo = "rmbo.hard"
else
Rambo = "rmbo"
end
WaypointGroup1 = { waypoint0, waypoint3, waypoint2, waypoint4, waypoint5, waypoint7 }
WaypointGroup2 = { waypoint0, waypoint3, waypoint2, waypoint4, waypoint5, waypoint6 }
WaypointGroup3 = { waypoint0, waypoint8, waypoint9, waypoint10, waypoint11, waypoint12, waypoint6, waypoint13 }
Patrol1Waypoints = { waypoint0.Location, waypoint8.Location, waypoint9.Location, waypoint10.Location }
Patrol2Waypoints = { waypoint0.Location, waypoint3.Location, waypoint2.Location, waypoint4.Location }
GDI1 = { units = { ['e2'] = 3, ['e3'] = 2 }, waypoints = WaypointGroup1, delay = 40 }
GDI2 = { units = { ['e1'] = 2, ['e2'] = 4 }, waypoints = WaypointGroup2, delay = 50 }
GDI4 = { units = { ['jeep'] = 2 }, waypoints = WaypointGroup1, delay = 50 }
GDI5 = { units = { ['mtnk'] = 1 }, waypoints = WaypointGroup1, delay = 40 }
Auto1 = { units = { ['e1'] = 2, ['e3'] = 3 }, waypoints = WaypointGroup3, delay = 40 }
Auto2 = { units = { ['e2'] = 2, ['e3'] = 2 }, waypoints = WaypointGroup3, delay = 50 }
Auto3 = { units = { ['e1'] = 3, ['e2'] = 2 }, waypoints = WaypointGroup2, delay = 60 }
Auto4 = { units = { ['mtnk'] = 1 }, waypoints = WaypointGroup1, delay = 50 }
Auto5 = { units = { ['mtnk'] = 1 }, waypoints = WaypointGroup3, delay = 50 }
Auto6 = { units = { ['e1'] = 2, ['e3'] = 2 }, waypoints = WaypointGroup3, delay = 50 }
Auto7 = { units = { ['msam'] = 1 }, waypoints = WaypointGroup1, delay = 40 }
Auto8 = { units = { ['msam'] = 1 }, waypoints = WaypointGroup3, delay = 50 }
RmboReinforcements = { Rambo }
EngineerReinforcements = { "e6", "e6" }
RocketReinforcements = { "e3", "e3", "e3", "e3" }
AutoAttackWaves = { GDI1, GDI2, GDI4, GDI5, Auto1, Auto2, Auto3, Auto4, Auto5, Auto6, Auto7, Auto8 }
NodBaseTrigger = { CPos.New(9, 52), CPos.New(9, 51), CPos.New(9, 50), CPos.New(9, 49), CPos.New(9, 48), CPos.New(9, 47), CPos.New(9, 46), CPos.New(10, 46), CPos.New(11, 46), CPos.New(12, 46), CPos.New(13, 46), CPos.New(14, 46), CPos.New(15, 46), CPos.New(16, 46), CPos.New(17, 46), CPos.New(18, 46), CPos.New(19, 46), CPos.New(20, 46), CPos.New(21, 46), CPos.New(22, 46), CPos.New(23, 46), CPos.New(24, 46), CPos.New(25, 46), CPos.New(25, 47), CPos.New(25, 48), CPos.New(25, 49), CPos.New(25, 50), CPos.New(25, 51), CPos.New(25, 52) }
EngineerTrigger = { CPos.New(5, 13), CPos.New(6, 13), CPos.New(7, 13), CPos.New(8, 13), CPos.New(9, 13), CPos.New(10, 13), CPos.New(16, 7), CPos.New(16, 6), CPos.New(16, 5), CPos.New(16, 4), CPos.New(16, 3)}
RocketTrigger = { CPos.New(20, 15), CPos.New(21, 15), CPos.New(22, 15), CPos.New(23, 15), CPos.New(24, 15), CPos.New(25, 15), CPos.New(26, 15), CPos.New(32, 15), CPos.New(32, 14), CPos.New(32, 13), CPos.New(32, 12), CPos.New(32, 11)}
GunboatPatrolPath = { GunboatLeft.Location, GunboatRight.Location }
AirstrikeDelay = DateTime.Minutes(2) + DateTime.Seconds(30)
CheckForSams = function(player)
local sams = player.GetActorsByType("sam")
return #sams >= 3
end
searches = 0
getAirstrikeTarget = function()
local list = player.GetGroundAttackers()
if #list == 0 then
return
end
local target = list[DateTime.GameTime % #list + 1].CenterPosition
local sams = Map.ActorsInCircle(target, WDist.New(8 * 1024), function(actor)
return actor.Type == "sam" end)
if #sams == 0 then
searches = 0
return target
elseif searches < 6 then
searches = searches + 1
return getAirstrikeTarget()
else
searches = 0
return nil
end
end
SendAttackWave = function(team)
for type, amount in pairs(team.units) do
count = 0
local actors = enemy.GetActorsByType(type)
Utils.Do(actors, function(actor)
if actor.IsIdle and count < amount then
SetAttackWaypoints(actor, team.waypoints)
IdleHunt(actor)
count = count + 1
end
end)
end
end
SetAttackWaypoints = function(actor, waypoints)
if not actor.IsDead then
Utils.Do(waypoints, function(waypoint)
actor.AttackMove(waypoint.Location)
end)
end
end
SendGDIAirstrike = function(hq, delay)
if not hq.IsDead and hq.Owner == enemy then
local target = getAirstrikeTarget()
if target then
hq.SendAirstrike(target, false, Facing.NorthEast + 4)
Trigger.AfterDelay(delay, function() SendGDIAirstrike(hq, delay) end)
else
Trigger.AfterDelay(delay/4, function() SendGDIAirstrike(hq, delay) end)
end
end
end
SendWaves = function(counter, Waves)
if counter <= #Waves then
local team = Waves[counter]
SendAttackWave(team)
Trigger.AfterDelay(DateTime.Seconds(team.delay), function() SendWaves(counter + 1, Waves) end)
end
end
StartPatrols = function()
local mtnks = enemy.GetActorsByType("mtnk")
local msams = enemy.GetActorsByType("msam")
if #mtnks >= 1 then
mtnks[1].Patrol(Patrol1Waypoints, true, 20)
end
if #msams >= 1 then
msams[1].Patrol(Patrol2Waypoints, true, 20)
end
end
StartWaves = function()
SendWaves(1, AutoAttackWaves)
end
Trigger.OnEnteredFootprint(NodBaseTrigger, function(a, id)
if not nodBaseTrigger and a.Owner == player then
nodBaseTrigger = true
player.MarkCompletedObjective(NodObjective3)
NodCYard.Owner = player
local walls = nodBase.GetActorsByType("brik")
Utils.Do(walls, function(actor)
actor.Owner = player
end)
Trigger.AfterDelay(DateTime.Seconds(2), function()
Media.PlaySpeechNotification(player, "NewOptions")
end)
end
end)
Trigger.OnEnteredFootprint(RocketTrigger, function(a, id)
if not rocketTrigger and a.Owner == player then
rocketTrigger = true
player.MarkCompletedObjective(NodObjective1)
Trigger.AfterDelay(DateTime.Seconds(5), function()
Media.PlaySpeechNotification(player, "Reinforce")
Reinforcements.ReinforceWithTransport(player, 'tran.in', RocketReinforcements, { HelicopterEntryRocket.Location, HelicopterGoalRocket.Location }, { HelicopterEntryRocket.Location }, nil, nil)
end)
Trigger.AfterDelay(DateTime.Seconds(10), function()
FlareEngineerCamera1 = Actor.Create("camera", true, { Owner = player, Location = FlareEngineer.Location })
FlareEngineerCamera2 = Actor.Create("camera", true, { Owner = player, Location = CameraEngineerPath.Location })
FlareEngineer = Actor.Create("flare", true, { Owner = player, Location = FlareEngineer.Location })
end)
Trigger.AfterDelay(DateTime.Minutes(1), function()
FlareRocketCamera.Destroy()
FlareRocket.Destroy()
end)
end
end)
Trigger.OnEnteredFootprint(EngineerTrigger, function(a, id)
if not engineerTrigger and a.Owner == player then
engineerTrigger = true
player.MarkCompletedObjective(NodObjective2)
Trigger.AfterDelay(DateTime.Seconds(5), function()
Media.PlaySpeechNotification(player, "Reinforce")
Reinforcements.ReinforceWithTransport(player, 'tran.in', EngineerReinforcements, { HelicopterEntryEngineer.Location, HelicopterGoalEngineer.Location }, { HelicopterEntryEngineer.Location }, nil, nil)
end)
Trigger.AfterDelay(DateTime.Minutes(1), function()
FlareEngineerCamera1.Destroy()
FlareEngineerCamera2.Destroy()
FlareEngineer.Destroy()
end)
end
end)
Trigger.OnKilledOrCaptured(OutpostProc, function()
if not outpostCaptured then
outpostCaptured = true
if OutpostProc.IsDead then
player.MarkFailedObjective(NodObjective4)
else
player.MarkCompletedObjective(NodObjective4)
player.Cash = 1000
end
StartPatrols()
Trigger.AfterDelay(DateTime.Minutes(1), function() StartWaves() end)
Trigger.AfterDelay(AirstrikeDelay, function() SendGDIAirstrike(GDIHQ, AirstrikeDelay) end)
Trigger.AfterDelay(DateTime.Minutes(3), function() ProduceInfantry(GDIPyle) end)
Trigger.AfterDelay(DateTime.Minutes(3), function() ProduceVehicle(GDIWeap) end)
end
end)
Trigger.OnKilled(Gunboat, function()
GunboatCamera.Destroy()
end)
WorldLoaded = function()
player = Player.GetPlayer("Nod")
enemy = Player.GetPlayer("GDI")
nodBase = Player.GetPlayer("NodBase")
Camera.Position = CameraIntro.CenterPosition
Media.PlaySpeechNotification(player, "Reinforce")
Reinforcements.ReinforceWithTransport(player, 'tran.in', RmboReinforcements, { HelicopterEntryRmbo.Location, HelicopterGoalRmbo.Location }, { HelicopterEntryRmbo.Location }, nil, nil)
FlareRocketCamera = Actor.Create("camera", true, { Owner = player, Location = FlareRocket.Location })
FlareRocket = Actor.Create("flare", true, { Owner = player, Location = FlareRocket.Location })
StartAI(GDICYard)
AutoGuard(enemy.GetGroundAttackers())
GunboatCamera = Actor.Create("camera.boat", true, { Owner = player, Location = Gunboat.Location })
Trigger.OnIdle(Gunboat, function() Gunboat.Patrol(GunboatPatrolPath) end)
Trigger.OnObjectiveAdded(player, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective")
end)
Trigger.OnObjectiveCompleted(player, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed")
end)
Trigger.OnObjectiveFailed(player, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed")
end)
Trigger.OnPlayerWon(player, function()
Media.PlaySpeechNotification(player, "Win")
end)
Trigger.OnPlayerLost(player, function()
Media.PlaySpeechNotification(player, "Lose")
end)
NodObjective1 = player.AddPrimaryObjective("Secure the first landing zone.")
NodObjective2 = player.AddPrimaryObjective("Secure the second landing zone.")
NodObjective3 = player.AddPrimaryObjective("Locate the Nod base.")
NodObjective4 = player.AddPrimaryObjective("Capture the refinery.")
NodObjective5 = player.AddPrimaryObjective("Eliminate all GDI forces in the area.")
NodObjective6 = player.AddSecondaryObjective("Build 3 SAMs to fend off the GDI bombers.")
GDIObjective = enemy.AddPrimaryObjective("Eliminate all Nod forces in the area.")
end
Tick = function()
if not Gunboat.IsDead then
GunboatCamera.Teleport(Gunboat.Location)
end
if DateTime.GameTime > 2 and player.HasNoRequiredUnits() then
enemy.MarkCompletedObjective(GDIObjective)
end
if DateTime.GameTime > 2 and enemy.HasNoRequiredUnits() then
player.MarkCompletedObjective(NodObjective5)
end
if not player.IsObjectiveCompleted(NodObjective6) and CheckForSams(player) then
player.MarkCompletedObjective(NodObjective6)
end
end
| gpl-3.0 |
waytim/darkstar | scripts/zones/Southern_San_dOria/npcs/Daggao.lua | 13 | 2011 | -----------------------------------
-- Area: Southern San d'Oria
-- NPC: Daggao
-- Involved in Quest: Peace for the Spirit, Lure of the Wildcat (San d'Oria)
-- @pos 89 0 119 230
-----------------------------------
package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/zones/Southern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE) == QUEST_ACCEPTED) then
if (trade:hasItemQty(532,1) and trade:getItemCount() == 1) then -- Trade Magicmart_flyer
player:messageSpecial(FLYER_REFUSED);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local WildcatSandy = player:getVar("WildcatSandy");
if (player:getQuestStatus(SANDORIA,LURE_OF_THE_WILDCAT_SAN_D_ORIA) == QUEST_ACCEPTED and player:getMaskBit(WildcatSandy,0) == false) then
player:startEvent(0x032a);
elseif (player:getVar("peaceForTheSpiritCS") == 3) then
player:startEvent(0x0048);
elseif (player:getVar("peaceForTheSpiritCS") == 5) then
player:startEvent(0x0049);
else
player:startEvent(0x003c);
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 == 0x032a) then
player:setMaskBit(player:getVar("WildcatSandy"),"WildcatSandy",0,true);
elseif (csid == 0x0048) then
player:setVar("peaceForTheSpiritCS",4);
end
end; | gpl-3.0 |
waytim/darkstar | scripts/zones/Carpenters_Landing/npcs/relic.lua | 13 | 1860 | -----------------------------------
-- Area: Carpenter's Landing
-- NPC: <this space intentionally left blank>
-- @pos -99 -0 -514 2
-----------------------------------
package.loaded["scripts/zones/Carpenters_Landing/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Carpenters_Landing/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- Working on correct relic, 4 items, Stage 4 item, Shard, Necropsyche, currencypiece
if (player:getVar("RELIC_IN_PROGRESS") == 15069 and trade:getItemCount() == 4 and trade:hasItemQty(15069,1) and
trade:hasItemQty(1822,1) and trade:hasItemQty(1589,1) and trade:hasItemQty(1454,1)) then
player:startEvent(44,15070);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
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 == 44) then
if (player:getFreeSlotsCount() < 2) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,15070);
player:messageSpecial(FULL_INVENTORY_AFTER_TRADE,1453);
else
player:tradeComplete();
player:addItem(15070);
player:addItem(1453,30);
player:messageSpecial(ITEM_OBTAINED,15070);
player:messageSpecial(ITEMS_OBTAINED,1453,30);
player:setVar("RELIC_IN_PROGRESS",0);
end
end
end; | gpl-3.0 |
waytim/darkstar | scripts/zones/Northern_San_dOria/npcs/Mevreauche.lua | 44 | 2103 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Mevreauche
-- Type: Smithing Guild Master
-- @pos -193.584 10 148.655 231
-----------------------------------
package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/crafting");
require("scripts/zones/Northern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
local newRank = tradeTestItem(player,npc,trade,SKILL_SMITHING);
if (newRank ~= 0) then
player:setSkillRank(SKILL_SMITHING,newRank);
player:startEvent(0x0273,0,0,0,0,newRank);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local getNewRank = 0;
local craftSkill = player:getSkillLevel(SKILL_SMITHING);
local testItem = getTestItem(player,npc,SKILL_SMITHING);
local guildMember = isGuildMember(player,8);
if (guildMember == 1) then guildMember = 150995375; end
if (canGetNewRank(player,craftSkill,SKILL_SMITHING) == 1) then getNewRank = 100; end
player:startEvent(0x0272,testItem,getNewRank,30,guildMember,44,0,0,0);
end;
-- 0x0272 0x0273 0x0010 0x0000 0x0049 0x004a
-----------------------------------
-- 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 == 0x0272 and option == 1) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,4096);
else
player:addItem(4096);
player:messageSpecial(ITEM_OBTAINED,4096); -- Fire Crystal
signupGuild(player,256);
end
end
end; | gpl-3.0 |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/zones/Windurst_Woods/npcs/Miiri-Wohri.lua | 5 | 1038 | -----------------------------------
-- Area: Windurst Woods
-- NPC: Miiri-Wohri
-- Type: Standard NPC
-- @zone: 241
-- @pos: 106.766 -6 -30.492
--
-- Auto-Script: Requires Verification (Verfied by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil;
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x006f);
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 |
waytim/darkstar | scripts/globals/mobskills/Hellsnap.lua | 31 | 1162 | ---------------------------------------------------
-- Hellsnap
--
---------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------------
function onMobSkillCheck(target,mob,skill)
if(mob:getFamily() == 91) then
local mobSkin = mob:getModelId();
if (mobSkin == 1840) then
return 0;
else
return 1;
end
end
if(mob:getFamily() == 316) then
local mobSkin = mob:getModelId();
if (mobSkin == 1839) then
return 0;
else
return 1;
end
end
return 0;
end;
function onMobWeaponSkill(target, mob, skill)
local numhits = 1;
local accmod = 10;
local dmgmod = 4.0;
local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_NO_EFFECT);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_SLASH,info.hitslanded*math.random(2,3));
local typeEffect = EFFECT_STUN;
MobPhysicalStatusEffectMove(mob, target, skill, typeEffect, 1, 0, 4);
target:delHP(dmg);
return dmg;
end;
| gpl-3.0 |
waytim/darkstar | scripts/globals/abilities/spirit_surge.lua | 11 | 1694 | -----------------------------------
-- Ability: Spirit Surge
-- Adds your wyvern's strength to your own.
-- Obtained: Dragoon Level 1
-- Recast Time: 1:00:00
-- Duration: 1:00
-----------------------------------
require("scripts/globals/status");
-----------------------------------
-- onAbilityCheck
-----------------------------------
function onAbilityCheck(player,target,ability)
-- The wyvern must be present in order to use Spirit Surge
if (target:getPet() == nil) then
return MSGBASIC_REQUIRES_A_PET,0;
else
return 0,0;
end
end;
-----------------------------------
-- onUseAbility
-----------------------------------
function onUseAbility(player,target,ability)
-- Spirit Surge increases dragoon's MAX HP increases by 25% of wyvern MaxHP
-- bg wiki says 25% ffxiclopedia says 15%, going with 25 for now
local mhp_boost = target:getPet():getMaxHP()*0.25;
-- Spirit Surge increases dragoon's Strength
local strBoost = 0;
if (target:getMainJob()==JOB_DRG) then
strBoost = (1 + target:getMainLvl()/5); -- Use Mainjob Lvl
else
strBoost = (1 + target:getSubLvl()/5); -- Use Subjob Lvl
end
-- Spirit Surge lasts 60 seconds, or 20 more if Wyrm Mail+2 is equipped
local duration = 60;
if (target:getEquipID(SLOT_BODY)==10683) then
duration = duration + 20;
end
target:despawnPet();
-- All Jump recast times are reset
target:resetRecast(RECAST_ABILITY,158); -- Jump
target:resetRecast(RECAST_ABILITY,159); -- High Jump
target:resetRecast(RECAST_ABILITY,160); -- Super Jump
target:addStatusEffect(EFFECT_SPIRIT_SURGE, mhp_boost, 0, duration, 0, strBoost);
end; | gpl-3.0 |
narner/Soundpipe | modules/data/expon.lua | 3 | 1382 | sptbl["expon"] = {
files = {
module = "expon.c",
header = "expon.h",
example = "ex_expon.c",
},
func = {
create = "sp_expon_create",
destroy = "sp_expon_destroy",
init = "sp_expon_init",
compute = "sp_expon_compute",
},
params = {
optional = {
{
name = "a",
type = "SPFLOAT",
description = "Inital point.",
default = 1.0
},
{
name = "dur",
type = "SPFLOAT",
description = "Duration (in seconds)",
default = 1.0
},
{
name = "b",
type = "SPFLOAT",
description = "End point",
default = 1.0
}
},
},
modtype = "module",
description = [[Produce a line segment with exponential slope
This will generate a line from value A to value B in given amount of time.
When it reaches it's target, it will stay at that value.
]],
ninputs = 1,
noutputs = 1,
inputs = {
{
name = "trig",
description = "When nonzero, will retrigger line segment"
},
},
outputs = {
{
name = "out",
description = "Signal output."
},
}
}
| mit |
waytim/darkstar | scripts/zones/Port_Bastok/npcs/Yazan.lua | 12 | 2088 | -----------------------------------
-- Area: Port Bastok
-- NPC: Yazan
-- Starts Quests: Bite the Dust (100%)
-----------------------------------
package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil;
------------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/quests");
require("scripts/zones/Port_Bastok/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
BiteDust = player:getQuestStatus(BASTOK,BITE_THE_DUST);
if (BiteDust ~= QUEST_AVAILABLE and trade:hasItemQty(1015,1) and trade:getItemCount() == 1) then
player:tradeComplete();
player:startEvent(0x00c1);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
BiteDust = player:getQuestStatus(BASTOK,BITE_THE_DUST);
if (BiteDust == QUEST_AVAILABLE) then
player:startEvent(0x00bf);
elseif (BiteDust == QUEST_ACCEPTED) then
player:startEvent(0x00c0);
else
player:startEvent(0x00be);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID2: %u",csid);
--printf("RESULT2: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x00bf) then
player:addQuest(BASTOK,BITE_THE_DUST);
elseif (csid == 0x00c1) then
if (player:getQuestStatus(BASTOK,BITE_THE_DUST) == QUEST_ACCEPTED) then
player:addTitle(SAND_BLASTER)
player:addFame(BASTOK,120);
player:completeQuest(BASTOK,BITE_THE_DUST);
else
player:addFame(BASTOK,80);
end
player:addGil(GIL_RATE*350);
player:messageSpecial(GIL_OBTAINED,GIL_RATE*350);
end
end; | gpl-3.0 |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/globals/spells/thundaga.lua | 2 | 1030 | -----------------------------------------
-- Spell: Thundaga
-- Deals thunder damage to an enemy.
-----------------------------------------
require("scripts/globals/magic");
require("scripts/globals/status");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function OnMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
--calculate raw damage
dmg = calculateMagicDamage(172,1,caster,spell,target,ELEMENTAL_MAGIC_SKILL,MOD_INT,false);
--get resist multiplier (1x if no resist)
resist = applyResistance(caster,spell,target,caster:getStat(MOD_INT)-target:getStat(MOD_INT),ELEMENTAL_MAGIC_SKILL,1.0);
--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);
--add in target adjustment
dmg = adjustForTarget(target,dmg);
--add in final adjustments
dmg = finalMagicAdjustments(caster,target,spell,dmg);
return dmg;
end; | gpl-3.0 |
X-Raym/REAPER-ReaScripts | Various/X-Raym_Open project folder in explorer or finder.lua | 1 | 2278 | --[[
* ReaScript Name: Open project folder in explorer or finder
* Author: X-Raym
* Author URI: https://www.extremraym.com
* Repository: GitHub > X-Raym > REAPER-ReaScripts
* Repository URI: https://github.com/X-Raym/REAPER-ReaScripts
* Licence: GPL v3
* Forum Thread: Scripts: Various
* Forum Thread URI: http://forum.cockos.com/showthread.php?p=1622146
* REAPER: 5.0
* Version: 1.1.1
--]]
--[[
* Changelog:
* v1.1.1 (2018-12-08)
# Mac fix fixed
* v1.1 (2018-12-07)
# Mac fix
* v1.0 (2016-01-14)
+ Initial Release
--]]
--------------------------------------------------------
-- DEBUG
-- -----
-- Console Message
function Msg(g)
reaper.ShowConsoleMsg(tostring(g).."\n")
end
--------------------------------------------------------
-- PATHS
-- -----
-- Get Path from file name
function GetPath(str,sep)
return str:match("(.*"..sep..")")
end
-- Check if project has been saved
function IsProjectSaved()
-- OS BASED SEPARATOR
if reaper.GetOS() == "Win32" or reaper.GetOS() == "Win64" then
-- user_folder = buf --"C:\\Users\\[username]" -- need to be test
separator = "\\"
else
-- user_folder = "/USERS/[username]" -- Mac OS. Not tested on Linux.
separator = "/"
end
retval, project_path_name = reaper.EnumProjects(-1, "")
if project_path_name ~= "" then
dir = GetPath(project_path_name, separator)
--msg(name)
name = string.sub(project_path_name, string.len(dir) + 1)
name = string.sub(name, 1, -5)
name = name:gsub(dir, "")
--msg(name)
project_saved = true
return project_saved
else
display = reaper.ShowMessageBox("You need to save the project to execute this script.", "File Export", 1)
if display == 1 then
reaper.Main_OnCommand(40022, 0) -- SAVE AS PROJECT
return IsProjectSaved()
end
end
end
----------------------------------------------------------------
-- MAIN FUNCTION
-- -------------
function main()
reaper.CF_ShellExecute(dir)
end -- ENDFUNCTION MAIN
----------------------------------------------------------------------
-- RUN
-- ---
-- Check if there is selected Items
project_saved = IsProjectSaved() -- See if Project has been save and determine file paths
if project_saved then
main() -- Execute your main function
end | gpl-3.0 |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/zones/Waughroon_Shrine/bcnms/up_in_arms.lua | 4 | 1775 | -----------------------------------
-- 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 |
waytim/darkstar | scripts/zones/Bastok_Markets/npcs/Balthilda.lua | 13 | 1711 | -----------------------------------
-- Area: Bastok Markets
-- NPC: Balthilda
-- Type: Merchant
-- @zone: 235
-- @pos -300 -10 -161
--
-- NPC not found in 'npc_list'
--
-- Auto-Script: Requires Verification. Verified standard dialog - thrydwolf 12/18/2011
--
-- Updated Aug-09-2013 by Zerahn, based on bgwiki and gamerescape
-----------------------------------
require("scripts/globals/shop");
package.loaded["scripts/zones/Bastok_Markets/TextIDs"] = nil;
require("scripts/zones/Bastok_Markets/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc, BALTHILDA_SHOP_DIALOG);
stock = {
0x30B9, 1904,3, --Poet's Circlet
0x3140, 1288,3, --Tunic
0x3139, 2838,3, --Linen Robe
0x31C0, 602,3, --Mitts
0x31B9, 1605,3, --Linen Cuffs
0x3240, 860,3, --Slacks
0x3239, 2318,3, --Linen Slops
0x32C0, 556,3, --Solea
0x32B9, 1495,3, --Holly Clogs
0x349D, 1150,3 --Leather Ring
}
showNationShop(player, BASTOK, 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 |
MinFu/luci | applications/luci-app-upnp/luasrc/controller/upnp.lua | 39 | 1886 | -- Copyright 2008 Steven Barth <steven@midlink.org>
-- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
module("luci.controller.upnp", package.seeall)
function index()
if not nixio.fs.access("/etc/config/upnpd") then
return
end
local page
page = entry({"admin", "services", "upnp"}, cbi("upnp/upnp"), _("UPNP"))
page.dependent = true
entry({"admin", "services", "upnp", "status"}, call("act_status")).leaf = true
entry({"admin", "services", "upnp", "delete"}, call("act_delete")).leaf = true
end
function act_status()
local ipt = io.popen("iptables --line-numbers -t nat -xnvL MINIUPNPD 2>/dev/null")
if ipt then
local fwd = { }
while true do
local ln = ipt:read("*l")
if not ln then
break
elseif ln:match("^%d+") then
local num, proto, extport, intaddr, intport =
ln:match("^(%d+).-([a-z]+).-dpt:(%d+) to:(%S-):(%d+)")
if num and proto and extport and intaddr and intport then
num = tonumber(num)
extport = tonumber(extport)
intport = tonumber(intport)
fwd[#fwd+1] = {
num = num,
proto = proto:upper(),
extport = extport,
intaddr = intaddr,
intport = intport
}
end
end
end
ipt:close()
luci.http.prepare_content("application/json")
luci.http.write_json(fwd)
end
end
function act_delete(num)
local idx = tonumber(num)
local uci = luci.model.uci.cursor()
if idx and idx > 0 then
luci.sys.call("iptables -t filter -D MINIUPNPD %d 2>/dev/null" % idx)
luci.sys.call("iptables -t nat -D MINIUPNPD %d 2>/dev/null" % idx)
local lease_file = uci:get("upnpd", "config", "upnp_lease_file")
if lease_file and nixio.fs.access(lease_file) then
luci.sys.call("sed -i -e '%dd' %q" %{ idx, lease_file })
end
luci.http.status(200, "OK")
return
end
luci.http.status(400, "Bad request")
end
| apache-2.0 |
waytim/darkstar | scripts/zones/Sauromugue_Champaign/npcs/qm2.lua | 11 | 3923 | -----------------------------------
-- Area: Sauromugue Champaign
-- NPC: qm2 (???) (Tower 2)
-- Involved in Quest: THF AF "As Thick As Thieves"
-- @pos 196.830 31.300 206.078 120
-----------------------------------
package.loaded["scripts/zones/Sauromugue_Champaign/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/globals/keyitems");
require("scripts/globals/status");
require("scripts/zones/Sauromugue_Champaign/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
local thickAsThievesGrapplingCS = player:getVar("thickAsThievesGrapplingCS");
if (thickAsThievesGrapplingCS >= 2 and thickAsThievesGrapplingCS <= 7) then
if (trade:hasItemQty(17474,1) and trade:getItemCount() == 1) then -- Trade grapel
if (player:getEquipID(SLOT_MAIN) == 0 and player:getEquipID(SLOT_SUB) == 0 and
player:getEquipID(SLOT_RANGED) == 0 and player:getEquipID(SLOT_AMMO) == 0 and
player:getEquipID(SLOT_HEAD) == 0 and player:getEquipID(SLOT_BODY) == 0 and
player:getEquipID(SLOT_HANDS) == 0 and player:getEquipID(SLOT_LEGS) == 0 and
player:getEquipID(SLOT_FEET) == 0 and player:getEquipID(SLOT_NECK) == 0 and
player:getEquipID(SLOT_WAIST) == 0 and player:getEquipID(SLOT_EAR1) == 0 and
player:getEquipID(SLOT_EAR2) == 0 and player:getEquipID(SLOT_RING1) == 0 and
player:getEquipID(SLOT_RING2) == 0 and player:getEquipID(SLOT_BACK) == 0) then
player:startEvent(0x0002); -- complete grappling part of the quest
else
player:messageSpecial(THF_AF_WALL_OFFSET+2,0,17474); -- You try climbing the wall using the [Grapnel], but you are too heavy.
end
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local thickAsThieves = player:getQuestStatus(WINDURST,AS_THICK_AS_THIEVES);
local thickAsThievesGrapplingCS = player:getVar("thickAsThievesGrapplingCS");
if (thickAsThieves == QUEST_ACCEPTED) then
if (thickAsThievesGrapplingCS == 2) then
player:messageSpecial(THF_AF_MOB);
GetMobByID(17269107):setSpawn(193,32,211);
SpawnMob(17269107,120):updateClaim(player); -- Climbpix Highrise
elseif (thickAsThievesGrapplingCS == 0 or thickAsThievesGrapplingCS == 1 or
thickAsThievesGrapplingCS == 3 or thickAsThievesGrapplingCS == 4 or
thickAsThievesGrapplingCS == 5 or thickAsThievesGrapplingCS == 6 or
thickAsThievesGrapplingCS == 7) then
player:messageSpecial(THF_AF_WALL_OFFSET); -- It is impossible to climb this wall with your bare hands.
elseif (thickAsThievesGrapplingCS == 8) then
player:messageSpecial(THF_AF_WALL_OFFSET+1); -- There is no longer any need to climb the tower.
end
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 == 0x0002) then
player:setVar("thickAsThievesGrapplingCS",8);
player:delKeyItem(FIRST_FORGED_ENVELOPE);
player:addKeyItem(FIRST_SIGNED_FORGED_ENVELOPE);
player:messageSpecial(KEYITEM_OBTAINED,FIRST_SIGNED_FORGED_ENVELOPE);
player:tradeComplete();
end
end; | gpl-3.0 |
TheOnePharaoh/YGOPro-Custom-Cards | script/c77777757.lua | 2 | 1479 | --Peaceful Eternity
function c77777757.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCategory(CATEGORY_TODECK)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1,77777757+EFFECT_COUNT_CODE_DUEL)
e1:SetCondition(c77777757.condition)
e1:SetTarget(c77777757.target)
e1:SetOperation(c77777757.activate)
c:RegisterEffect(e1)
end
function c77777757.filter(c)
return c:IsType(TYPE_MONSTER+TYPE_TRAP+TYPE_SPELL)
end
function c77777757.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsExistingMatchingCard(c77777757.filter,tp,0,LOCATION_DECK,5,nil)
end
function c77777757.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chk==0 then return true end
local t={}
local i=1
local p=1
local lv=e:GetHandler():GetLevel()
for i=1,4 do
t[p]=i p=p+1
end
t[p]=nil
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(77777757,0))
e:SetLabel(Duel.AnnounceNumber(tp,table.unpack(t)))
end
function c77777757.activate(e,tp,eg,ep,ev,re,r,rp)
local d2=Duel.Draw(1-tp,e:GetLabel(),REASON_EFFECT)
if d1==0 or d2==0 then return end
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CHANGE_DAMAGE)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(1,1)
e1:SetValue(0)
e1:SetReset(RESET_PHASE+PHASE_END,e:GetLabel()*2)
Duel.RegisterEffect(e1,tp)
local e2=e1:Clone()
e2:SetCode(EFFECT_NO_EFFECT_DAMAGE)
e2:SetReset(RESET_PHASE+PHASE_END,e:GetLabel()*2)
Duel.RegisterEffect(e2,tp)
end | gpl-3.0 |
waytim/darkstar | scripts/zones/The_Shrine_of_RuAvitau/Zone.lua | 12 | 5750 | -----------------------------------
--
-- Zone: The_Shrine_of_RuAvitau (178)
--
-----------------------------------
package.loaded["scripts/zones/The_Shrine_of_RuAvitau/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/missions");
require("scripts/globals/keyitems");
require("scripts/globals/zone");
require("scripts/zones/The_Shrine_of_RuAvitau/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
local tomes = {17506822,17506823,17506824,17506825,17506826,17506827,17506828};
SetGroundsTome(tomes);
-- MAP 1 ------------------------
zone:registerRegion(1, -21, 29, -61, -16, 31, -57); --> F (H-10)
zone:registerRegion(2, 16, 29, 57, 21, 31, 61); --> E (H-7)
-- MAP 3 ------------------------
zone:registerRegion(3, -89, -19, 83, -83, -15, 89); --> L (F-5)
zone:registerRegion(3, -143, -19, -22, -137, -15, -16); --> L (D-8)
zone:registerRegion(4, -143, -19, 55, -137, -15, 62); --> G (D-6)
zone:registerRegion(4, 83, -19, -89, 89, -15, -83); --> G (J-10)
zone:registerRegion(5, -89, -19, -89, -83, -15, -83); --> J (F-10)
zone:registerRegion(6, 137, -19, -22, 143, -15, -16); --> H (L-8)
zone:registerRegion(7, 136, -19, 56, 142, -15, 62); --> I (L-6)
zone:registerRegion(8, 83, -19, 83, 89, -15, 89); --> K (J-5)
-- MAP 4 ------------------------
zone:registerRegion(9, 723, 96, 723, 729, 100, 729); --> L'(F-5)
zone:registerRegion(10, 870, 96, 723, 876, 100, 729); --> O (J-5)
zone:registerRegion(6, 870, 96, 470, 876, 100, 476); --> H (J-11)
zone:registerRegion(11, 723, 96, 470, 729, 100, 476); --> N (F-11)
-- MAP 5 ------------------------
zone:registerRegion(12, 817, -3, 57, 823, 1, 63); --> D (I-7)
zone:registerRegion(13, 736, -3, 16, 742, 1, 22); --> P (F-8)
zone:registerRegion(14, 857, -3, -23, 863, 1, -17); --> M (J-9)
zone:registerRegion(15, 776, -3, -63, 782, 1, -57); --> C (G-10)
-- MAP 6 ------------------------
zone:registerRegion(2, 777, -103, -503, 783, -99, -497); --> E (G-6)
zone:registerRegion(1, 816, -103, -503, 822, -99, -497); --> F (I-6)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
local xPos = player:getXPos();
local yPos = player:getYPos();
local zPos = player:getZPos();
local ZilartMission = player:getCurrentMission(ZILART);
-- Checked here to be fair to new players
local DMEarrings = 0;
for i=14739, 14743 do
if (player:hasItem(i)) then
DMEarrings = DMEarrings + 1;
end
end
-- ZM 15 -> ZM 16
if (ZilartMission == THE_SEALED_SHRINE and player:getVar("ZilartStatus") == 1 and
xPos >= -45 and yPos >= -4 and zPos >= -240 and
xPos <= -33 and yPos <= 0 and zPos <= -226 and DMEarrings <= NUMBER_OF_DM_EARRINGS) then -- Entered through main gate
cs = 51;
end
if ((xPos == 0) and (yPos == 0) and (zPos == 0)) then
player:setPos(-3.38,46.326,60,122);
end
return cs;
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
switch (region:GetRegionID()): caseof
{
[1] = function (x)
player:startEvent(17); --> F
end,
[2] = function (x)
player:startEvent(16); --> E
end,
[3] = function (x)
player:startEvent(5); --> L --> Kirin !
end,
[4] = function (x)
player:startEvent(4); --> G
end,
[5] = function (x)
player:startEvent(1); --> J
end,
[6] = function (x)
player:startEvent(3); --> H
end,
[7] = function (x)
player:startEvent(7); --> I
end,
[8] = function (x)
player:startEvent(6); --> K
end,
[9] = function (x)
player:startEvent(10); --> L'
end,
[10] = function (x)
player:startEvent(11);
end,
[11] = function (x)
player:startEvent(8);
end,
[12] = function (x)
player:startEvent(15); --> D
end,
[13] = function (x)
player:startEvent(14); --> P
end,
[14] = function (x)
player:startEvent(13); --> M
end,
[15] = function (x)
player:startEvent(12); --> C
end,
default = function (x)
end,
}
end;
-----------------------------------
-- onRegionLeave
-----------------------------------
function onRegionLeave(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 51) then
player:completeMission(ZILART,THE_SEALED_SHRINE);
player:addMission(ZILART,THE_CELESTIAL_NEXUS);
player:setVar("ZilartStatus",0);
end
end; | gpl-3.0 |
waytim/darkstar | scripts/globals/spells/phalanx.lua | 27 | 1151 | -----------------------------------------
-- Spell: PHALANX
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
local enhskill = caster:getSkillLevel(ENHANCING_MAGIC_SKILL);
local final = 0;
local duration = 180;
if (caster:hasStatusEffect(EFFECT_COMPOSURE) == true and caster:getID() == target:getID()) then
duration = duration * 3;
end
if (enhskill<=300) then
final = (enhskill/10) -2;
if (final<0) then
final = 0;
end
elseif (enhskill>300) then
final = ((enhskill-300)/29) + 28;
else
print("Warning: Unknown enhancing magic skill for phalanx.");
end
if (final>35) then
final = 35;
end
if (target:addStatusEffect(EFFECT_PHALANX,final,0,duration)) then
spell:setMsg(230);
else
spell:setMsg(75);
end
return EFFECT_PHALANX;
end; | gpl-3.0 |
waytim/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Zabahf.lua | 13 | 1714 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Zabahf
-- Type: Standard NPC
-- @pos -90.070 -1 10.140 50
-----------------------------------
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local gotItAllProg = player:getVar("gotitallCS");
if (gotItAllProg == 1 or gotItAllProg == 3) then
player:startEvent(0x0215);
elseif (gotItAllProg == 2) then
player:startEvent(0x020b);
elseif (gotItAllProg == 5) then
player:startEvent(0x021a);
elseif (gotItAllProg == 6) then
player:startEvent(0x021c);
elseif (gotItAllProg == 7) then
player:startEvent(0x0217);
elseif (player:getQuestStatus(AHT_URHGAN,GOT_IT_ALL) == QUEST_COMPLETED) then
player:startEvent(0x0212);
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 == 0x020b) then
player:setVar("gotitallCS",3);
end
end;
| gpl-3.0 |
waytim/darkstar | scripts/zones/Bastok_Markets/npcs/Zon-Fobun.lua | 12 | 2514 | -----------------------------------
-- Area: Bastok Markets
-- NPC: Zon-Fobun
-- Type: Quest Giver
-- @zone: 235
-- @pos -241.293 -3 63.406
--
-- Auto-Script: Requires Verification. Verified standard dialog - thrydwolf 12/18/2011
-----------------------------------
package.loaded["scripts/zones/Bastok_Markets/TextIDs"] = nil;
package.loaded["scripts/globals/quests"] = nil;
require("scripts/zones/Bastok_Markets/TextIDs");
require("scripts/globals/quests");
require("scripts/globals/keyitems");
require("scripts/globals/settings");
require("scripts/globals/player");
require("scripts/globals/titles");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local cCollector = player:getQuestStatus(BASTOK,THE_CURSE_COLLECTOR);
if (cCollector == QUEST_AVAILABLE and player:getFameLevel(BASTOK) >=4) then
player:startEvent(0x00fb); -- Quest Start Dialogue
elseif (cCollector == QUEST_ACCEPTED and player:hasKeyItem(CURSEPAPER) == true and player:getVar("cCollectSilence") == 1 and player:getVar("cCollectCurse") == 1) then
player:startEvent(0x00fc); -- Quest Completion Dialogue
else
player:startEvent(0x00fa);
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 == 0x00fb) then
player:addQuest(BASTOK,THE_CURSE_COLLECTOR);
player:addKeyItem(CURSEPAPER); -- Cursepaper
player:messageSpecial(KEYITEM_OBTAINED,CURSEPAPER);
elseif (csid == 0x00fc) then
if (player:getFreeSlotsCount() >= 1) then
player:delKeyItem(CURSEPAPER);
player:setVar("cCollectSilence",0);
player:setVar("cCollectCurse",0);
player:addFame(BASTOK,30);
player:completeQuest(BASTOK,THE_CURSE_COLLECTOR);
player:messageSpecial(ITEM_OBTAINED,16387); -- Poison Cesti
player:addItem(16387,1);
else
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,16387);
end
end
end; | gpl-3.0 |
TheOnePharaoh/YGOPro-Custom-Cards | script/c78360180.lua | 2 | 2722 | --Vocaloid Xinhua
function c78360180.initial_effect(c)
--spsummon proc
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
e1:SetRange(LOCATION_HAND)
e1:SetCondition(c78360180.hspcon)
e1:SetOperation(c78360180.hspop)
c:RegisterEffect(e1)
--lv up
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(78360180,0))
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1,78360180)
e2:SetOperation(c78360180.lvop)
c:RegisterEffect(e2)
--search
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(78360180,1))
e3:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1,78360180)
e3:SetCost(c78360180.cost)
e3:SetTarget(c78360180.target)
e3:SetOperation(c78360180.operation)
c:RegisterEffect(e3)
end
function c78360180.lvop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
local c=e:GetHandler()
if c:IsFaceup() and c:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_LEVEL)
e1:SetReset(RESET_EVENT+0x1ff0000+RESET_PHASE+PHASE_END)
e1:SetValue(3)
c:RegisterEffect(e1)
end
end
function c78360180.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsReleasable() end
Duel.Release(e:GetHandler(),REASON_COST)
end
function c78360180.thfilter(c)
return c:IsType(TYPE_MONSTER) and c:IsSetCard(0x0dac405) and c:GetCode()~=78360180 and c:IsAbleToHand()
end
function c78360180.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c78360180.thfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c78360180.operation(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c78360180.thfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
function c78360180.spfilter(c)
return c:IsFaceup() and c:IsRace(RACE_MACHINE) and c:IsAbleToRemoveAsCost()
end
function c78360180.hspcon(e,c)
if c==nil then return true end
return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>-1
and Duel.IsExistingMatchingCard(c78360180.spfilter,c:GetControler(),LOCATION_MZONE,0,1,nil)
end
function c78360180.hspop(e,tp,eg,ep,ev,re,r,rp,c)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectMatchingCard(tp,c78360180.spfilter,c:GetControler(),LOCATION_MZONE,0,1,1,nil)
Duel.Remove(g,POS_FACEUP,REASON_COST)
end
| gpl-3.0 |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/zones/Dynamis-Xarcabard/mobs/Prince_Seere.lua | 2 | 1088 | -----------------------------------
-- Area: Dynamis Xarcabard
-- NPC: Prince Seere
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/dynamis");
-----------------------------------
-- onMobInitialize Action
-----------------------------------
function onMobInitialize(mob,target)
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
end;
-----------------------------------
-- onMobFight Action
-----------------------------------
function onMobFight(mob,target)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob,killer)
SetServerVariable("[DynaXarcabard]Boss_Trigger",GetServerVariable("[DynaXarcabard]Boss_Trigger") + 8);
if(GetServerVariable("[DynaXarcabard]Boss_Trigger") == 32767) then
SpawnMob(17330911); -- 142
SpawnMob(17330912); -- 143
SpawnMob(17330183); -- 177
SpawnMob(17330184); -- 178
activateAnimatedWeapon(); -- Change subanim of all animated weapon
end
end; | gpl-3.0 |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/zones/Jugner_Forest/npcs/CavernousMaw.lua | 2 | 1212 | -----------------------------------
-- Cavernous Maw
-- Teleports Players to aby vunk
-----------------------------------
package.loaded["scripts/zones/Jugner_Forest/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/teleports");
require("scripts/globals/campaign");
require("scripts/zones/Jugner_Forest/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x002f,1,1,1,1,1,1,1);
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);
if(csid == 0x002f and option == 1) then
player:setPos(-351,-46.750,699,12,217);
end
end; | gpl-3.0 |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/zones/Nashmau/npcs/Pipiroon.lua | 2 | 1134 | -----------------------------------
-- Area: Nashmau
-- NPC: Pipiroon
-- Standard Merchant NPC
-----------------------------------
require("scripts/globals/shop");
package.loaded["scripts/zones/Nashmau/TextIDs"] = nil;
require("scripts/zones/Nashmau/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,PIPIROON_SHOP_DIALOG);
stock = {0x43A1,1204, -- Grenade
0x43A3,6000, -- Riot Grenade
0x03A0,515, -- Bomb Ash
0x0b39,10000} -- Nashmau Waystone
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 |
delaram16/DelaramBot | plugins/inpm.lua | 1114 | 3008 | do
local function pairsByKeys (t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0 -- iterator variable
local iter = function () -- iterator function
i = i + 1
if a[i] == nil then return nil
else return a[i], t[a[i]]
end
end
return iter
end
local function chat_list(msg)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] then
return 'No groups at the moment'
end
local message = 'List of Groups:\n*Use /join (ID) to join*\n\n '
for k,v in pairs(data[tostring(groups)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairsByKeys(settings) do
if m == 'set_name' then
name = n
end
end
message = message .. '👥 '.. name .. ' (ID: ' .. v .. ')\n\n '
end
local file = io.open("./groups/lists/listed_groups.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function run(msg, matches)
if msg.to.type ~= 'chat' or is_sudo(msg) or is_admin(msg) and is_realm(msg) then
local data = load_data(_config.moderation.data)
if matches[1] == 'join' and data[tostring(matches[2])] then
if is_banned(msg.from.id, matches[2]) then
return 'You are banned.'
end
if is_gbanned(msg.from.id) then
return 'You are globally banned.'
end
if data[tostring(matches[2])]['settings']['lock_member'] == 'yes' and not is_owner2(msg.from.id, matches[2]) then
return 'Group is private.'
end
local chat_id = "chat#id"..matches[2]
local user_id = "user#id"..msg.from.id
chat_add_user(chat_id, user_id, ok_cb, false)
local group_name = data[tostring(matches[2])]['settings']['set_name']
return "Added you to chat:\n\n👥"..group_name.." (ID:"..matches[2]..")"
elseif matches[1] == 'join' and not data[tostring(matches[2])] then
return "Chat not found."
end
if matches[1] == 'chats'then
if is_admin(msg) and msg.to.type == 'chat' then
return chat_list(msg)
elseif msg.to.type ~= 'chat' then
return chat_list(msg)
end
end
if matches[1] == 'chatlist'then
if is_admin(msg) and msg.to.type == 'chat' then
send_document("chat#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false)
elseif msg.to.type ~= 'chat' then
send_document("user#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false)
end
end
end
end
return {
patterns = {
"^[/!](chats)$",
"^[/!](chatlist)$",
"^[/!](join) (.*)$",
"^[/!](kickme) (.*)$",
"^!!tgservice (chat_add_user)$"
},
run = run,
}
end
| gpl-2.0 |
icoowner/icorobot | plugins/inpm.lua | 1114 | 3008 | do
local function pairsByKeys (t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0 -- iterator variable
local iter = function () -- iterator function
i = i + 1
if a[i] == nil then return nil
else return a[i], t[a[i]]
end
end
return iter
end
local function chat_list(msg)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] then
return 'No groups at the moment'
end
local message = 'List of Groups:\n*Use /join (ID) to join*\n\n '
for k,v in pairs(data[tostring(groups)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairsByKeys(settings) do
if m == 'set_name' then
name = n
end
end
message = message .. '👥 '.. name .. ' (ID: ' .. v .. ')\n\n '
end
local file = io.open("./groups/lists/listed_groups.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function run(msg, matches)
if msg.to.type ~= 'chat' or is_sudo(msg) or is_admin(msg) and is_realm(msg) then
local data = load_data(_config.moderation.data)
if matches[1] == 'join' and data[tostring(matches[2])] then
if is_banned(msg.from.id, matches[2]) then
return 'You are banned.'
end
if is_gbanned(msg.from.id) then
return 'You are globally banned.'
end
if data[tostring(matches[2])]['settings']['lock_member'] == 'yes' and not is_owner2(msg.from.id, matches[2]) then
return 'Group is private.'
end
local chat_id = "chat#id"..matches[2]
local user_id = "user#id"..msg.from.id
chat_add_user(chat_id, user_id, ok_cb, false)
local group_name = data[tostring(matches[2])]['settings']['set_name']
return "Added you to chat:\n\n👥"..group_name.." (ID:"..matches[2]..")"
elseif matches[1] == 'join' and not data[tostring(matches[2])] then
return "Chat not found."
end
if matches[1] == 'chats'then
if is_admin(msg) and msg.to.type == 'chat' then
return chat_list(msg)
elseif msg.to.type ~= 'chat' then
return chat_list(msg)
end
end
if matches[1] == 'chatlist'then
if is_admin(msg) and msg.to.type == 'chat' then
send_document("chat#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false)
elseif msg.to.type ~= 'chat' then
send_document("user#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false)
end
end
end
end
return {
patterns = {
"^[/!](chats)$",
"^[/!](chatlist)$",
"^[/!](join) (.*)$",
"^[/!](kickme) (.*)$",
"^!!tgservice (chat_add_user)$"
},
run = run,
}
end
| agpl-3.0 |
waytim/darkstar | scripts/zones/RoMaeve/npcs/qm2.lua | 13 | 2069 | -----------------------------------
-- Area: Ro'Maeve
-- NPC: qm2 (???)
-- Involved in Mission: Bastok 7-1
-- @pos 102 -4 -114 122 and <many pos>
-----------------------------------
package.loaded["scripts/zones/RoMaeve/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/missions");
require("scripts/zones/RoMaeve/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getCurrentMission(BASTOK) == THE_FINAL_IMAGE and player:getVar("MissionStatus") == 1) then
if (GetMobAction(17276929) == 0 and GetMobAction(17276930) == 0) then
if (player:getVar("Mission7-1MobKilled") >= 1) then
player:addKeyItem(REINFORCED_CERMET);
player:messageSpecial(KEYITEM_OBTAINED,REINFORCED_CERMET);
player:setVar("Mission7-1MobKilled",0);
player:setVar("MissionStatus",2);
else
-- Position of npc can change
local x = npc:getXPos();
local y = npc:getYPos();
local z = npc:getZPos();
SpawnMob(17276929):setPos(x+1,y,z+1);
GetMobByID(17276929):updateClaim(player);
SpawnMob(17276930):setPos(x-1,y,z-1);
GetMobByID(17276930):updateClaim(player);
end
end
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);
end; | gpl-3.0 |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/zones/Dynamis-Valkurm/Zone.lua | 2 | 1068 | -----------------------------------
--
-- Zone: Dynamis-Valkurm
--
-----------------------------------
require("scripts/globals/settings");
package.loaded["scripts/zones/Dynamis-Valkurm/TextIDs"] = nil;
require("scripts/zones/Dynamis-Valkurm/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
cs = -1;
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
MinFu/luci | applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/tcpconns.lua | 68 | 1143 | -- Copyright 2008 Freifunk Leipzig / Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
m = Map("luci_statistics",
translate("TCPConns Plugin Configuration"),
translate(
"The tcpconns plugin collects informations about open tcp " ..
"connections on selected ports."
))
-- collectd_tcpconns config section
s = m:section( NamedSection, "collectd_tcpconns", "luci_statistics" )
-- collectd_tcpconns.enable
enable = s:option( Flag, "enable", translate("Enable this plugin") )
enable.default = 0
-- collectd_tcpconns.listeningports (ListeningPorts)
listeningports = s:option( Flag, "ListeningPorts", translate("Monitor all local listen ports") )
listeningports.default = 1
listeningports:depends( "enable", 1 )
-- collectd_tcpconns.localports (LocalPort)
localports = s:option( Value, "LocalPorts", translate("Monitor local ports") )
localports.optional = true
localports:depends( "enable", 1 )
-- collectd_tcpconns.remoteports (RemotePort)
remoteports = s:option( Value, "RemotePorts", translate("Monitor remote ports") )
remoteports.optional = true
remoteports:depends( "enable", 1 )
return m
| apache-2.0 |
TheOnePharaoh/YGOPro-Custom-Cards | script/c90000018.lua | 2 | 2431 | --Night Clock Sound Wave
function c90000018.initial_effect(c)
--Negate Effect
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_CHAINING)
e1:SetCondition(c90000018.condition)
e1:SetTarget(c90000018.target)
e1:SetOperation(c90000018.operation)
c:RegisterEffect(e1)
--Negate Effect
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_NEGATE+CATEGORY_TODECK)
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetCode(EVENT_CHAINING)
e2:SetRange(LOCATION_GRAVE)
e2:SetCondition(c90000018.condition2)
e2:SetCost(c90000018.cost)
e2:SetTarget(c90000018.target2)
e2:SetOperation(c90000018.operation2)
c:RegisterEffect(e2)
end
function c90000018.filter(c)
return c:IsFaceup() and c:IsSetCard(0x3)
end
function c90000018.condition(e,tp,eg,ep,ev,re,r,rp)
return rp~=tp and re:IsHasType(EFFECT_TYPE_ACTIVATE) and Duel.IsChainNegatable(ev)
and Duel.IsExistingMatchingCard(c90000018.filter,tp,LOCATION_ONFIELD,0,1,nil)
end
function c90000018.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0)
if re:GetHandler():IsRelateToEffect(re) and re:GetHandler():IsDestructable() then
Duel.SetOperationInfo(0,CATEGORY_DESTROY,re:GetHandler(),1,0,0)
end
end
function c90000018.operation(e,tp,eg,ep,ev,re,r,rp)
Duel.NegateActivation(ev)
if re:GetHandler():IsRelateToEffect(re) then
Duel.Destroy(re:GetHandler(),REASON_EFFECT)
end
end
function c90000018.filter2(c,tp)
return c:IsSetCard(0x3) and c:IsType(TYPE_MONSTER)
end
function c90000018.condition2(e,tp,eg,ep,ev,re,r,rp)
return rp~=tp and re:GetActivateLocation()==LOCATION_GRAVE and Duel.IsChainNegatable(ev)
and Duel.IsExistingMatchingCard(c90000018.filter2,tp,LOCATION_GRAVE,0,1,nil)
end
function c90000018.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end
Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST)
end
function c90000018.target2(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0)
if re:GetHandler():IsRelateToEffect(re) then
Duel.SetOperationInfo(0,CATEGORY_TODECK,eg,1,0,0)
end
end
function c90000018.operation2(e,tp,eg,ep,ev,re,r,rp)
Duel.NegateActivation(ev)
if re:GetHandler():IsRelateToEffect(re) then
re:GetHandler():CancelToGrave()
Duel.SendtoDeck(re:GetHandler(),nil,2,REASON_EFFECT)
end
end | gpl-3.0 |
TheOnePharaoh/YGOPro-Custom-Cards | script/c89990019.lua | 2 | 2411 | --Nexomystis
function c89990019.initial_effect(c)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcCode2(c,89990031,89990007,false,false)
--spsummon condition
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
e1:SetValue(aux.fuslimit)
c:RegisterEffect(e1)
--shuffle grave to deck
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_TODECK)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetCountLimit(1,89990019+EFFECT_COUNT_CODE_DUEL)
e2:SetRange(LOCATION_MZONE)
e2:SetCost(c89990019.cost)
e2:SetTarget(c89990019.target)
e2:SetOperation(c89990019.operation)
c:RegisterEffect(e2)
--return
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(40854197,0))
e3:SetCategory(CATEGORY_TODECK)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e3:SetCode(EVENT_TO_GRAVE)
e3:SetCondition(c89990019.retcon)
e3:SetTarget(c89990019.rettg)
e3:SetOperation(c89990019.retop)
c:RegisterEffect(e3)
local e4=e3:Clone()
e4:SetCode(EVENT_REMOVE)
c:RegisterEffect(e4)
local e5=e3:Clone()
e5:SetCode(EVENT_TO_DECK)
c:RegisterEffect(e5)
end
function c89990019.filter(c)
return c:IsType(TYPE_MONSTER) and c:IsAbleToDeck()
end
function c89990019.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsReleasable() end
Duel.Release(e:GetHandler(),REASON_COST)
end
function c89990019.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c89990019.filter,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,nil) end
local g=Duel.GetMatchingGroup(c89990019.filter,tp,LOCATION_GRAVE,LOCATION_GRAVE,nil)
Duel.SetOperationInfo(0,CATEGORY_TODECK,g,g:GetCount(),0,0)
end
function c89990019.operation(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(c89990019.filter,tp,LOCATION_GRAVE,LOCATION_GRAVE,nil)
Duel.SendtoDeck(g,nil,2,REASON_EFFECT)
end
function c89990019.retcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsPreviousPosition(POS_FACEUP) and e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD)
end
function c89990019.rettg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_TODECK,e:GetHandler(),1,0,0)
end
function c89990019.retop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) and c:IsAbleToDeck() then
Duel.SendtoDeck(c,nil,2,REASON_EFFECT)
end
end
| gpl-3.0 |
TheEggi/FTCCustom | lang/German.lua | 1 | 22128 |
--[[----------------------------------------------------------
GERMAN TRANSLATIONS
-- Special thanks are due to MerlinGer, Rakke, Xianlung, and Rial for their assistance with German localization.
à : \195\160 è : \195\168 ì : \195\172 ò : \195\178 ù : \195\185
á : \195\161 é : \195\169 í : \195\173 ó : \195\179 ú : \195\186
â : \195\162 ê : \195\170 î : \195\174 ô : \195\180 û : \195\187
ã : \195\163 ë : \195\171 ï : \195\175 õ : \195\181 ü : \195\188
ä : \195\164 ñ : \195\177 ö : \195\182
æ : \195\166 ø : \195\184
ç : \195\167 : \197\147
Ä : \195\132 Ö : \195\150 Ü : \195\156 ß : \195\159
-- TODO: FTC configuration settings in German
-- TODO: remainder of skill names in German translation
]]----------------------------------------------------------
FTC.German = {
--[[---------------------------------
CONFIGURATION NOTICES
-----------------------------------]]
["You are using Foundry Tactical Combat version"] = "Du benutzt die Foundry Tactical Combat version",
["FTC configuration settings have moved to the normal game settings interface!"] = "FTC Konfigurationseinstellungen sind nun im Einstellungsmen\195\188 des Spiels!",
--[[---------------------------------
SETTINGS MENU
-----------------------------------]]
["FTC Settings"] = "FTC Einstellungen",
["Please use this menu to configure addon options."] = "Bitte benutze dieses Men\195\188 um die optionen zu konfigurieren.",
["Reloads UI"] = "Oberfl\195\164che neu laden",
["Configure Components"] = "Allgemeine Konfiguration",
["Enable Frames"] = "Anzeigeelemente aktivieren",
["Enable custom unit frames component?"] = "Aktiviert die FTC Anzeigeelemente",
["Enable Buffs"] = "Buffs aktivieren",
["Enable active buff tracking component?"] = "Aktiviert die Anzeige der aktiven Buffs",
["Enable Damage Statistics"] = "Schadensstatistik aktivieren",
["Enable damage statistics?"] = "Aktiviert die Anzeige der Schadensstatistik",
["Enable Combat Text"] = "Schadenswerte aktivieren",
["Enable scrolling combat text component?"] = "Aktiviert die Anzeige der Schadenswerte",
["Unit Frames Settings"] = "Anzeigeeinstellungen",
["Show Default Target Frame"] = "Standard Zielanzeige anzeigen",
["Show the default ESO target unit frame?"] = "Standard ESO Zielanzeige anzeigen",
["Default Unit Frames Text"] = "Text in Standard Anzeigeelementen anzeigen",
["Display text attribute values on default unit frames?"] = "Attribut-Werte in Standard Anzeigeelementen anzeigen",
["Show Player Nameplate"] = "Spieler Namen anzeigen",
["Show your own character's nameplate?"] = "Eigenen Namen anzeigen",
["Enable Mini Experience Bar"] = "Mini Erfahrungsleiste aktivieren",
["Show a small experience bar on the player frame?"] = "Zeigt eine kleine Erfahrungsleiste unter dem Spielerelement an",
--["In Combat Opacity"] = "",
--["Adjust the in-combat transparency of unit frames."] = "",
--["Non-Combat Opacity"] = "",
--["Adjust the out-of-combat transparency of unit frames."] = "",
["Buff Tracker Settings"] = "Buff Anzeigeeinstellungen",
["Anchor Buffs"] = "Buff-Anzeige ausrichten",
["Anchor buffs to unit frames?"] = "Richtet die Buff-Anzeige an den Anzeigeelementen aus",
["Display Long Buffs"] = "Lang anhaltende Buffs anzeigen",
["Track long duration player buffs?"] = "Zeigt lang anhaltende Spieler Buffs an",
["Scrolling Combat Text Settings"] = "Einstellungen zur Anzeige der Schadenswerte",
["Combat Text Scroll Speed"] = "Scroll Geschwindigkeit der Schadenswerte",
["Adjust combat text scroll speed."] = "Ver\195\164nderung der Scroll Geschwindigkeit der Schadenswerte",
["Display Ability Names"] = "Namen der F\195\164higkeiten anzeigen",
["Display ability names in combat text?"] = "Zeigt die Namen der F\195\164higkeiten an",
["Scroll Path Animation"] = "Scroll Animation",
["Choose scroll animation."] = "Scroll Animation ausw\195\164hlen",
["Damage Tracker Settings"] = "Einstellungen zur Schadensermittlung",
["Timeout Threshold"] = "Zeit\195\188berschreitung in Sekunden",
["Number of seconds without damage to signal encounter termination."] = "Anzahl von Sekunden ohne Schaden bevor ein Ende des Kampfes festgestellt wird",
["Reposition FTC Elements"] = "FTC Elemente neu positionieren",
["Lock Positions"] = "Positionen sperren",
["Modify FTC frame positions?"] = "FTC Anzeigepositionen ver\195\164ndern",
["Reset Settings"] = "Einstellungen zur\195\188cksetzen",
["Restore Defaults"] = "Standard wiederherstellen",
["Restore FTC to default settings."] = "Stellt die FTC Standardeinstellungen wieder her",
--[[---------------------------------
GAME TRANSLATIONS
-----------------------------------]]
["Drachenritter^m"] = "Dragonknight",
["Drachenritterin^f"] = "Dragonknight",
["Nachtklinge^m"] = "Nightblade",
["Nachtklinge^f"] = "Nightblade",
["Zauberer^m"] = "Sorcerer",
["Zauberin^f"] = "Sorcerer",
["Templer^m"] = "Templar",
["Templerin^f"] = "Templar",
--[[---------------------------------
WEAPON ABILITIES
-----------------------------------]]
-- Sword and Shield
["Durchsto\195\159^m"] = "Puncture",
["Durchw\195\188hlen^n"] = "Ransack",
["Durchschlag^m"] = "Pierce Armor",
["niederer Schnitt^m"] = "Low Slash",
["tiefer Schlag^m"] = "Deep Slash",
["verkr\195\188ppelnder Schlag^m"] = "Crippling Slash",
["Schildlauf^m"] = "Shield Charge",
["Invasion^f"] = "Invasion",
["Schildsturm^m"] = "Shielded Assault",
["Schildsto\195\159^m"] = "Power Bash",
["Schildschlag^m"] = "Power Slam",
["widerhallender Schlag^m"] = "Reverberating Bash",
-- Dual Wield
["Doppelschnitte^p"] = "Twin Slashes",
["Blutwahn^m"] = "Blood Craze",
["Trennschnitte^p"] = "Rending Slashes",
["schnelle St\195\182\195\159e^p"] = "Rapid Strikes",
["blitzende Klingen^p"] = "Sparks",
["spr\195\188hende Klingen^p"] = "Heated Blades",
["Glutexplosion^p"] = "Ember Explosion",
["wirbelnde Klingen^p"] = "Whirling Blades",
["verborgene Klinge^f"] = "Hidden Blade",
["fliegende Klinge^f"] = "Flying Blade",
--[""] = "Shrouded Daggers",
-- Two Handed
["Trennen^n"] = "Cleave",
["Schl\195\164ger^m"] = "Brawler",
["Schnitzen^n"] = "Carve",
["kritisches Toben^n"] = "Stampede",
["Aufw\195\164rtsschnitt^m"] = "Uppercut",
["vernichtender Schlag^m"] = "Wrecking Blow",
--[""] = "Dizzying Swing",
["Momentum^n"] = "Momentum",
--[""] = "Forward Momentum",
["ruhendes Momentum^n"] = "Rally",
-- Bow
["Giftpfeil^m"] = "Poison Arrow",
--[""] = "Venom Arrow",
["Giftinjektion^f"] = "Poison Injection",
["Pfeilsalve^f"] = "Volley",
--[""] = "Scorched Earth",
--[""] = "Arrow Barrage",
["Trennschuss^m"] = "Scatter Shot",
--[""] = "Magnum Shot",
--[""] = "Draining Shot",
["Pfeilf\195\164cher^m"] = "Arrow Spray",
--[""] = "Bombard",
--[""] = "Acid Spray",
--[""] = "Lethal Arrow",
["geziehlter Schuss^m"] = "Focused Aim",
-- Restoration Staff
["gro\195\159e Heilung^f"] = "Grand Healing",
["heilende Quellen^f"] = "Healing Springs",
["erhabene Heilung^f"] = "Illustrious Healing",
["Regeneration^f"] = "Regeneration",
["Mutagen^n"] = "Mutagen",
["rasche Regeneration^f"] = "Rapid Regeneration",
["Segen des Schutzes^m"] = "Blessing of Protection",
["Segen der Wiederherstellung^m"] = "Blessing of Restoration",
["Kampfgebet^m"] = "Combat Prayer",
["standhafter Schutz^m"] = "Steadfast Ward",
["verb\195\188ndeten sch\195\188tzen^m"] = "Ward Ally",
["heilender Schutz^m"] = "Healing Ward",
["Kraftabsaugung^f"] = "Force Siphon",
["Geistabsaugung^f"] = "Siphon Spirit",
["schnelle Absaugung^f"] = "Quick Siphon",
-- Destruction Staff
["Schw\195\164che gegen die Elemente^f"] = "Weakness to Elements",
["elementare Anf\195\164lligkeit^f"] = "Elemental Succeptibility",
["elementarer Entzug^m"] = "Elemental Drain",
["Schockber\195\188hrung^f"] = "Destructive Touch",
["Kraftschlag^m"] = "Force Shock",
--[[---------------------------------
SORCERER
-----------------------------------]]
-- Daedric Summoning
["daedrischer Fluch^m"] = "Daedric Curse",
["b\195\182sartiger Fluch^m"] = "Velocious Curse",
["explosiver Fluch^m"] = "Explosive Curse",
["beschworener Schutz^m"] = "Conjured Ward",
["bem\195\164chtigter Schutz^m"] = "Empowered Ward",
["geh\195\164rteter Schutz^m"] = "Hardened Ward",
["instabiler Begleiter^m"] = "Unstable Familiar",
["instabiler Clannbann^m"] = "Unstable Clannfear",
["explosiver Begleiter^m"] = "Volatile Familiar",
["Zwielichtschwinge beschw\195\182ren^N"] = "Summon Winged Twilight",
["Zwielichtmatriarchin beschw\195\182ren^N"] = "Summon Restoring Twilight",
["Zwielichtwahrerin beschw\195\182ren^N"] = "Summon Twilight Matriarch",
["Bound Armor"] = "Bound Armor",
["Bound Armaments"] = "Bound Armaments",
["Bound Aegis"] = "Bound Aegis",
["Sturmatronachen beschw\195\182ren^N"] = "Summon Storm Atronach",
["gr\195\182\195\159erer Sturmatronach^N"] = "Greater Storm Atronach",
["geladenen Atronachen beschw\195\182ren^N"] = "Summon Charged Atronach",
-- Storm Calling
["Magierzorn^m"] = "Mages Fury",
["Magierrage^m"] = "Mages Wrath",
["endloser Zorn^m"] = "Endless Fury",
["Blitzgestalt^f"] = "Lightning Form",
["donnernde Pr\195\164senz^m"] = "Boundless Storm",
["grenzenloser Sturm^m"] = "Thundering Presence",
["Blitzfeld^n"] = "Lightning Splash",
["Blitzfluss^m"] = "Liquid Lightning",
["Blitzflut^f"] = "Lightning Flood",
["Woge^f"] = "Surge",
["kritische Woge^f"] = "Critical Surge",
["Kraftwoge^f"] = "Power Surge",
["Funkenschlag^m"] = "Bolt Escape",
["Blitzschlag^m"] = "Streak",
["Funkenzug^m"] = "Ball of Lightning",
-- Dark Magic
["Kristallscherbe^f"] = "Crystal Shard",
["Kristallfragmente^p"] = "Crystal Fragments",
["Kristallexplosion^p"] = "Crystal Blast",
["Einh\195\188llen^n"] = "Encase",
["zersplitterndes Gef\195\164ngnis^n"] = "Restraining Prison",
["zur\195\188ckhaltendes Gef\195\164ngnis^n"] = "Shattering Prison",
["Runengef\195\164ngnis^n"] = "Rune Prison",
["schw\195\164chendes Gef\195\164ngnis^n"] = "Weakening Prison",
["Runenk\195\164fig^m"] = "Rune Cage",
["daedrische Minen^p"] = "Daedric Mines",
["daedrisches Minenfeld^p"] = "Daedric Minefield",
["daedrisches Grabmal^p"] = "Daedric Tomb",
["dunkler Austausch^m"] = "Dark Exchange",
["dunkle Umwandlung^f"] = "Dark Conversion",
["dunkles Abkommen^n"] = "Dark Deal",
["Magienegation^f"] = "Negate Magic",
["Unterdr\195\188ckungsfeld^n"] = "Suppression Field",
["Absorbtionsfeld^n"] = "Absorption Field",
--[[---------------------------------
DRAGONKNIGHT
-----------------------------------]]
-- Ardent Flame
["st\195\164rkende Ketten^p"] = "Empowering Chains",
["versengender Schlag^m"] = "Searing Strike",
["instabile Flamme^f"] = "Unstable Flame",
["brennende Glut^f"] = "Burning Embers",
["feuriger Odem^m"] = "Fiery Breath",
["brennender Odem^m"] = "Burning Breath",
["einh\195\188llende Flammen^p"] = "Engulfing Flames",
["Drachenritter-Standarte^f"] = "Dragonknight Standard",
["Standarte der Macht^f"] = "Standard of Might",
["bewegliche Standarte^f"] = "Shifting Standard",
["Inferno^n"] = "Inferno",
--[""] = "Flames Of Oblivion",
--[""] = "Sea Of Flames",
-- Earthen Heart
["Steinfaust^f"] = "Stonefist",
["Steinriese^m"] = "Stone Giant",
["Obsidianscherbe^f"] = "Obsidian Shard",
["Obsidianschild^m"] = "Obsidian Shield",
["eruptiver Schild^m"] = "Igneous Shield",
["fragmentierter Schild^m"] = "Fragmented Shield",
["Versteinern^n"] = "Petrify",
["Fossilieren^n"] = "Fossilize",
["berstende Felsen^f"] = "Shattering Rocks",
["Aschenwolke^f"] = "Ash Cloud",
["Schlackensturm^m"] = "Cinder Storm",
["Eruption^f"] = "Eruption",
["Magmar\195\188stung"] = "Magma Armor",
["Magmaschale^f"] = "Magma Shell",
["korrosive R\195\188stung^f"] = "Corrosive Armor",
-- Draconic Power
["gespickte R\195\188stung^f"] = "Spiked Armor",
["Klingenr\195\188stung^f"] = "Razor Armor",
["explosive R\195\188stung^f"] = "Volatile Armor",
["dunkle Krallen^p"] = "Dark Talons",
["brennende Krallen^p"] = "Burning Talons",
["w\195\188rgende Krallen^p"] = "Choking Talons",
["Drachenblut^n"] = "Dragon Blood",
["gr\195\188nes Drachenblut^n"] = "Green Dragon Blood",
["gerinnendes Blut^n"] = "Coagulating Blood",
["reflektierende Schuppe^f"] = "Reflective Scale",
["Drachenfeuerschuppe^f"] = "Dragon Fire Scale",
--[""] = "Reflective Plate",
--[[---------------------------------
NIGHTBLADE
-----------------------------------]]
-- Assassination
["Teleportationsschlag^m"] = "Teleport Strike",
["Hinterhalt^m"] = "Ambush",
["Lotusf\195\164cher^m"] = "Lotus Fan",
["Verschwimmen^n"] = "Blur",
--[""] = "Mirage",
--[""] = "Double Take",
["Zielmarkierung^f"] = "Mark Target",
["durchdringende Markierung^f"] = "Piercing Mark",
--[""] = "Reaper's Mark",
["Hast^f"] = "Haste",
--[""] = "Focused Attacks",
--[""] = "Incapacitate",
["Todesstoß^m"] = "Death Stroke",
--[""] = "Incapacitating Strike",
["Seelenernte^f"] = "Soul Harvest",
-- Siphoning
["Unfriede^m"] = "Strife",
["Seelenschlingen^n"] = "Swallow Soul",
["Lebensflu\195\159^m"] = "Funnel Health",
["Qual^f"] = "Agony",
["verl\195\164ngertes Leiden^n"] = "Prolonged Suffering",
--[""] = "Malefic Wreath",
["Verkr\195\188ppeln^n"] = "Cripple",
--[""] = "Debilitate",
["verkr\195\188elnder Griff^m"] = "Crippling Grasp",
["Kraftentzug^m"] = "Drain Power",
["Essenzentzug^m"] = "Power Extraction",
["Essenzsog^m"] = "Sap Essence",
["auslaugende Schl\195\164ge^p"] = "Siphoning Strikes",
["entziehende Angriffe^p"] = "Leeching Strikes",
["auslaugende Angriffe^p"] = "Siphoning Attacks",
["Seelenfetzen^n"] = "Soul Shred",
["Seelenfessel^n"] = "Soul Tether",
--[""] = "Soul Siphon",
-- Shadow
["Schattenmantel^m"] = "Shadow Cloak",
["Schattenkleid^n"] = "Shadowy Disguise",
["dunkler Mantel^m"] = "Dark Cloak",
["verschleierter Schlag^m"] = "Veiled Strike",
--[""] = "Surprise Attack",
["verborgene Waffe^f"] = "Concealed Weapon",
["Pfad der Dunkelheit^m"] = "Path of Darkness",
--[""] = "Twisting Path",
["erneuernder Pfad^m"] = "Refreshing Path",
["Aspekt des Schreckens^m"] = "Aspect of Terror",
--[""] = "Mass Hysteria",
--[""] = "Manifestation of Terror",
["Schatten beschw\195\182ren^N"] = "Summon Shade",
["Dunkle Schatten^n"] = "Dark Shades",
--[""] = "Shadow Image",
["verschlingende Finsternis^f"] = "Consuming Darkness",
--[""] = "Bolstering Darkness",
["Schleier der Klingen^m"] = "Veil of Blades",
--[[---------------------------------
TEMPLAR
-----------------------------------]]
-- Aedric Spear
["durchdringender Wurfspeer^m"] = "Piercing Javelin",
["Polarlich-Wurfspeer^m"] = "Aurora Javelin",
["bindender Wurfspeer^m"] = "Binding Javelin",
--[""] = "Empowering Sweep",
["fokussierter Ansturm^m"] = "Focused Charge",
["explosiver Ansturm^m"] = "Explosive Charge",
--[""] = "Toppling Charge",
["Speerscherben^p"] = "Spear Shards",
--[""] = "Luminous Shards",
["lodernder Speer^m"] = "Blazing Spear",
["Sonnenschild^m"] = "Sun Shield",
--[""] = "Radiant Ward",
--[""] = "Blazing Shield",
-- Dawn's Wrath
["Nova^f"] = "Nova",
--[""] = "Solar Prison",
--[""] = "Solar Disturbance",
["Sonnenfeuer^n"] = "Sun Fire",
--[""] = "Reflective Light",
["Fluch der Vampire^m"] = "Vampire's Bane",
["dunkles Aufleuchten^n"] = "Dark Flare",
["Eklipse^f"] = "Eclipse",
--[""] = "Total Dark",
["instabiles Zentrum^n"] = "Unstable Core",
["R\195\188ckwirkung^f"] = "Backlash",
--[""] = "Power of the Light",
["reinigendes Licht^n"] = "Purifying Light",
-- Restoring Light
["Ehrung der Toten^f"] = "Honor The Dead",
["best\195\164ndiges Ritual^n"] = "Lingering Ritual",
["Ritus des \195\156bergangs^m"] = "Rite of Passage",
["Gedenken^n"] = "Remembrance",
--[""] = "Practiced Incarnation",
["wiederherstellende Aura^f"] = "Restoring Aura",
["Bu\195\159e^f"] = "Repentance",
--[""] = "Radiant Aura",
["reinigendes Ritual^n"] = "Cleansing Ritual",
["heilendes Ritual^n"] = "Purifying Ritual",
--[""] = "Extended Ritual",
["Runenfokus^m"] = "Rune Focus",
--[""] = "Channeled Focus",
--[""] = "Restoring Focus",
--[[---------------------------------
ARMOR
-----------------------------------]]
-- Heavy Armour
["fester Stand^m"] = "Immovable",
["sicherer Stand^m"] = "Immovable Brute",
--[""] = "Unstoppable",
-- Medium Armour
["Ausweichen^n"] = "Evasion",
--[""] = "Elude",
--[""] = "Shuffle",
-- Light Armour
["neutralisierende Magie^f"] = "Annulment",
["dämpfende Magie^f"] = "Dampen Magic",
["absorbierende Magie^f"] = "Harness Magicka",
--[[---------------------------------
GUILDS
-----------------------------------]]
-- Fighters Guild
["Meisterj\195\164ger^m"] = "Expert Hunter",
["J\195\164ger des B\195\182sen^m"] = "Evil Hunter",
--[""] = "Camouflaged Hunter",
["Silberbolzen^p"] = "Silver Bolts",
["Silbersplitter"] = "Silver Shards",
--[""] = "Silver Leash",
-- Mages Guild
["Entropie^f"] = "Entropy",
["Degeneration^f"] = "Degeneration",
["strukturierte Entropie^f"] = "Structured Entropy",
["Magierlicht^n"] = "Magelight",
["inneres Licht^n"] = "Inner Light",
["strahlendes Magierlicht^n"] = "Radiant Magelight",
["Feuerrune^f"] = "Fire Rune",
["Vulkanrune^f"] = "Volcanic Rune",
["Sengrune^f"] = "Scalding Rune",
-- Undaunted
["inneres Feuer^n"] = "Inner Fire",
--[""] = "Inner Rage",
--[""] = "Inner Beast",
--[[---------------------------------
WORLD
-----------------------------------]]
-- Vampire
["Essenzentzug^m"] = "Drain Essence",
["erfrischender Entzug^m"] = "Invigorating Drain",
["mittern\195\164chtlicher Entzug^m"] = "Midnight Drain",
["Nebelgestalt^f"] = "Mist Form",
["fl\195\188chtiger Nebel^m"] = "Elusive Mist",
["giftiger Nebel^m"] = "Poison Mist",
["Fledermausschwarm^m"] = "Bat Swarm",
["verschlingender Schwarm^m"] = "Devouring Swarm",
["einh\195\188llender Schwarm^m"] = "Clouding Swarm",
-- Soul Magic
["Seelenfalle^f"] = "Soul Trap",
["trennende Seelenfalle^f"] = "Soul Splitting Trap",
["erholende Seelenfalle^f"] = "Consuming Trap",
["Seelenschlag^m"] = "Soul Strike",
--[""] = "Shatter Soul",
["Seelenangriff^m"] = "Soul Assault",
--[[---------------------------------
AVA
-----------------------------------]]
-- Support
["L\195\164uterung^f"] = "Purge",
--[""] = "Efficient Purge",
--[""] = "Cleanse",
["Belagerungsschild^m"] = "Siege Shield",
--[""] = "Siege Weapon Shield",
--[""] = "Propelling Shield",
["Barriere^f"] = "Barrier",
--[""] = "Reviving Barrier",
--[""] = "Replenishing Barrier",
-- Assault
["hastiges Man\195\182ver^n"] = "Rapid Maneuver",
--[""] = "Retreating Maneuver",
--[""] = "Charging Maneuver",
["Kr\195\164henf\195\188sse^p"] = "Caltrops",
--[""] = "Anti-Cavalry Caltrops",
--[""] = "Razor Caltrops",
["Kriegshorn^n"] = "War Horn",
--[""] = "Aggressive Horn",
--[""] = "Sturdy Horn",
--[[---------------------------------
EFFECT FILTERS
-----------------------------------]]
["Segen:"] = "Boon:",
["Vampirismus^m"] = "Vampirisim",
["Lykanthropie^f"] = "Lycanthropy",
["Spirit Armor"] = "Spirit Armor",
["Wehren^n"] = "Brace (Generic)",
["Kampfgeist^m"] = "Keep Bonus",
["Schriften"] = "Scroll Bonus",
["Kaiserlich"] = "Emperorship",
--[""] = "Increase Max",
["\195\188bernat\195\188rliche Erholung^f"] = "Supernatural Recovery",
} | apache-2.0 |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/zones/Beaucedine_Glacier/npcs/Trail_Markings.lua | 4 | 2569 | -----------------------------------
-- Area: Beaucedine Glacier
-- NPC: Trail Markings
-- Dynamis-Beaucedine Enter
-- @pos -284 -39 -422 111
-----------------------------------
package.loaded["scripts/zones/Beaucedine_Glacier/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/dynamis");
require("scripts/zones/Beaucedine_Glacier/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if(player:getVar("DynaBeaucedine_Win") == 1) then
player:startEvent(0x0086,HYDRA_CORPS_INSIGNIA); -- Win CS
elseif(player:hasKeyItem(HYDRA_CORPS_COMMAND_SCEPTER) and
player:hasKeyItem(HYDRA_CORPS_EYEGLASS) and
player:hasKeyItem(HYDRA_CORPS_LANTERN) and
player:hasKeyItem(HYDRA_CORPS_TACTICAL_MAP)) then
local firstDyna = 0;
local realDay = os.time();
local dynaWaitxDay = player:getVar("dynaWaitxDay");
if(checkFirstDyna(player,4)) then -- First Dyna-Bastok => CS
firstDyna = 1;
end
if(player:getMainLvl() < DYNA_LEVEL_MIN) then
player:messageSpecial(PLAYERS_HAVE_NOT_REACHED_LEVEL,DYNA_LEVEL_MIN);
elseif((dynaWaitxDay + (BETWEEN_2DYNA_WAIT_TIME * 24 * 60 * 60)) < realDay or player:getVar("DynamisID") == GetServerVariable("[DynaBeaucedine]UniqueID")) then
player:startEvent(0x0077,5,firstDyna,0,BETWEEN_2DYNA_WAIT_TIME,64,VIAL_OF_SHROUDED_SAND,4236,4237);
else
dayRemaining = math.floor(((dynaWaitxDay + (BETWEEN_2DYNA_WAIT_TIME * 24 * 60 * 60)) - realDay)/3456);
player:messageSpecial(YOU_CANNOT_ENTER_DYNAMIS,dayRemaining,5);
end
else
player:messageSpecial(UNUSUAL_ARRANGEMENT_PEBBLES);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("updateRESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("finishRESULT: %u",option);
if(csid == 0x0086) then
player:setVar("DynaBeaucedine_Win",0);
elseif(csid == 0x0077 and option == 0) then
if(checkFirstDyna(player,4)) then
player:setVar("Dynamis_Status",player:getVar("Dynamis_Status") + 8);
end
player:setPos(-284.751,-39.923,-422.948,235,0x86);
end
end; | gpl-3.0 |
waytim/darkstar | scripts/zones/Apollyon/mobs/Sirin.lua | 4 | 1133 | -----------------------------------
-- Area: Apollyon NE
-- NPC: Sirin
-----------------------------------
package.loaded["scripts/zones/Apollyon/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/limbus");
require("scripts/zones/Apollyon/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
local mobID = mob:getID();
-- print(mobID);
local mobX = mob:getXPos();
local mobY = mob:getYPos();
local mobZ = mob:getZPos();
if (mobID ==16933072) then -- time T1
GetNPCByID(16932864+125):setPos(mobX,mobY,mobZ);
GetNPCByID(16932864+125):setStatus(STATUS_NORMAL);
elseif (mobID ==16933071) then -- time T2
GetNPCByID(16932864+83):setPos(mobX,mobY,mobZ);
GetNPCByID(16932864+83):setStatus(STATUS_NORMAL);
end
end; | gpl-3.0 |
pvvx/EspLua | lua_examples/mcp23008/mcp23008_buttons.lua | 82 | 1801 | ---
-- @description Shows how to read 8 GPIO pins/buttons via I2C with the MCP23008 I/O expander.
-- Tested on NodeMCU 0.9.5 build 20150213.
-- @circuit
-- Connect GPIO0 of the ESP8266-01 module to the SCL pin of the MCP23008.
-- Connect GPIO2 of the ESP8266-01 module to the SDA pin of the MCP23008.
-- Use 3.3V for VCC.
-- Connect switches or buttons to the GPIOs of the MCP23008 and GND.
-- Connect two 4.7k pull-up resistors on SDA and SCL
-- We will enable the internal pull up resistors for the GPIOS of the MCP23008.
-- @author Miguel (AllAboutEE)
-- GitHub: https://github.com/AllAboutEE
-- YouTube: https://www.youtube.com/user/AllAboutEE
-- Website: http://AllAboutEE.com
---------------------------------------------------------------------------------------------
require ("mcp23008")
-- ESP-01 GPIO Mapping as per GPIO Table in https://github.com/nodemcu/nodemcu-firmware
gpio0, gpio2 = 3, 4
-- Setup the MCP23008
mcp23008.begin(0x0,gpio2,gpio0,i2c.SLOW)
mcp23008.writeIODIR(0xff)
mcp23008.writeGPPU(0xff)
---
-- @name showButtons
-- @description Shows the state of each GPIO pin
-- @return void
---------------------------------------------------------
function showButtons()
local gpio = mcp23008.readGPIO() -- read the GPIO/buttons states
-- get/extract the state of one pin at a time
for pin=0,7 do
local pinState = bit.band(bit.rshift(gpio,pin),0x1) -- extract one pin state
-- change to string state (HIGH, LOW) instead of 1 or 0 respectively
if(pinState == mcp23008.HIGH) then
pinState = "HIGH"
else
pinState = "LOW"
end
print("Pin ".. pin .. ": ".. pinState)
end
print("\r\n")
end
tmr.alarm(0,2000,1,showButtons) -- run showButtons() every 2 seconds
| mit |
waytim/darkstar | scripts/zones/West_Ronfaure/npcs/Yoshihiro_IM.lua | 13 | 3319 | -----------------------------------
-- Area: West Ronfaure
-- NPC: Yoshihiro, I.M.
-- Outpost Conquest Guards
-- @pos -450.571 -20.807 -219.970 100
-----------------------------------
package.loaded["scripts/zones/West_Ronfaure/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/conquest");
require("scripts/zones/West_Ronfaure/TextIDs");
local guardnation = BASTOK; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno
local guardtype = 3; -- 1: city, 2: foreign, 3: outpost, 4: border
local region = RONFAURE;
local csid = 0x7ff9;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
tradeConquestGuard(player,npc,trade,guardnation,guardtype);
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:hasKeyItem(getSupplyKey(region)) and player:getNation() == guardnation) then
if (supplyRunFresh(player) == 1) then
player:startEvent(csid,16,0,0,0,1,0,0,255); -- you have brought us supplies !
else
player:showText(npc, CONQUEST - 1); -- "Hmm... These supplies you have brought us are too old to be of any use."
player:delKeyItem(getSupplyKey(region));
player:messageSpecial(KEYITEM_OBTAINED + 1, getSupplyKey(region));
player:setVar("supplyQuest_region",0);
end
else
local arg1 = getArg1(guardnation, player) - 1;
if (arg1 >= 1792) then -- foreign, non-allied
player:startEvent(csid,1808,0,0,0,0,player:getRank(),0,0);
else -- citizen or allied
player:startEvent(csid,arg1,0,0x3F0000,0,0,getArg6(player),0,0);
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);
if (option == 1) then
local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600;
player:delStatusEffect(EFFECT_SIGIL);
player:delStatusEffect(EFFECT_SANCTION);
player:delStatusEffect(EFFECT_SIGNET);
player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet
elseif (option == 2) then
player:delKeyItem(getSupplyKey(region));
player:addCP(supplyReward[region + 1])
player:messageSpecial(CONQUEST); -- "You've earned conquest points!"
if (hasOutpost(player, region+5) == 0) then
local supply_quests = 2^(region+5);
player:addNationTeleport(guardnation,supply_quests);
player:setVar("supplyQuest_region",0);
end
elseif (option == 4) then
if (player:delGil(giltosetHP(guardnation,player))) then
player:setHomePoint();
player:messageSpecial(CONQUEST + 94); -- "Your home point has been set."
else
player:messageSpecial(CONQUEST + 95); -- "You do not have enough gil to set your home point here."
end
end
end; | gpl-3.0 |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/globals/abilities/spectral_jig.lua | 2 | 1226 | -----------------------------------
-- Ability: Spectral jig
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
-----------------------------------
-- OnUseAbility
-----------------------------------
function OnAbilityCheck(player,target,ability)
return 0,0;
end;
function OnUseAbility(player, target, ability)
local baseDuration = math.random(30,90);
local finalDuration = baseDuration;
local legs = target:getEquipID(SLOT_LEGS);
local feet = target:getEquipID(SLOT_FEET);
-- Reports have been changed from +30 sec to "extends duration by 100%"
if(legs == 16360 or legs == 16361 or legs == 10728) then
finalDuration = finalDuration + baseDuration;
end
if(feet == 15746 or feet == 15747 or feet == 11393 or feet == 11394) then
finalDuration = finalDuration + baseDuration;
end
if(player:hasStatusEffect(EFFECT_SNEAK) == false) then
player:addStatusEffect(EFFECT_SNEAK,0,10,finalDuration);
player:addStatusEffect(EFFECT_INVISIBLE,0,10,finalDuration);
ability:setMsg(532); -- Gains the effect of sneak and invisible
else
ability:setMsg(283); -- no effect on player.
end
return 1;
end; | gpl-3.0 |
Amadiro/debugUI | loveframes/objects/internal/columnlist/columnlistheader.lua | 3 | 5893 | --[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012-2014 Kenny Shields --
--]]------------------------------------------------
-- get the current require path
local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.columnlist.columnlistheader"))
local loveframes = require(path .. ".libraries.common")
-- columnlistheader class
local newobject = loveframes.NewObject("columnlistheader", "loveframes_object_columnlistheader", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: intializes the element
--]]---------------------------------------------------------
function newobject:initialize(name, parent)
self.type = "columnlistheader"
self.parent = parent
self.name = name
self.state = parent.state
self.width = parent.defaultcolumnwidth
self.height = parent.columnheight
self.columnid = 0
self.hover = false
self.down = false
self.clickable = true
self.enabled = true
self.descending = true
self.resizebox = nil
self.internal = true
table.insert(parent.children, self)
local key = 0
for k, v in ipairs(parent.children) do
if v == self then
key = k
end
end
self.OnClick = function(object)
local descending = object.descending
local parent = object.parent
local pinternals = parent.internals
local list = pinternals[1]
if descending then
object.descending = false
else
object.descending = true
end
list:Sort(key, object.descending)
end
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
if not self.visible then
if not self.alwaysupdate then
return
end
end
local update = self.Update
local parent = self.parent
local list = parent.internals[1]
local vbody = list:GetVerticalScrollBody()
local width = list.width
if vbody then
width = width - vbody.width
end
self.clickbounds = {x = list.x, y = list.y, width = width, height = list.height}
self:CheckHover()
if not self.hover then
self.down = false
else
if loveframes.downobject == self then
self.down = true
end
end
-- move to parent if there is a parent
if parent ~= loveframes.base then
self.x = (parent.x + self.staticx) - parent.internals[1].offsetx
self.y = parent.y + self.staticy
end
local resizecolumn = parent.resizecolumn
if resizecolumn and resizecolumn == self then
local x, y = love.mouse.getPosition()
local start = false
self.width = x - self.x
if self.width < 20 then
self.width = 20
end
parent.startadjustment = true
parent.internals[1]:CalculateSize()
parent.internals[1]:RedoLayout()
elseif resizecolumn and parent.startadjustment then
local header = parent.children[self.columnid - 1]
self.staticx = header.staticx + header.width
end
self.resizebox = {x = self.x + (self.width - 2), y = self.y, width = 4, height = self.height}
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
if not self.visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawColumnListHeader or skins[defaultskin].DrawColumnListHeader
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
if not self.parent.resizecolumn and self.parent.canresizecolumns then
local box = self.resizebox
local col = loveframes.util.BoundingBox(x, box.x, y, box.y, 1, box.width, 1, box.height)
if col then
self.resizing = true
self.parent.resizecolumn = self
end
end
if self.hover and button == 1 then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" and button == 1 then
baseparent:MakeTop()
end
self.down = true
loveframes.downobject = self
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
if not self.visible then
return
end
local hover = self.hover
local down = self.down
local clickable = self.clickable
local enabled = self.enabled
local onclick = self.OnClick
if hover and down and clickable and button == 1 then
if enabled then
onclick(self, x, y)
end
end
local resizecolumn = self.parent.resizecolumn
if resizecolumn and resizecolumn == self then
self.parent.resizecolumn = nil
end
self.down = false
end
--[[---------------------------------------------------------
- func: SetName(name)
- desc: sets the object's name
--]]---------------------------------------------------------
function newobject:SetName(name)
self.name = name
return self
end
--[[---------------------------------------------------------
- func: GetName()
- desc: gets the object's name
--]]---------------------------------------------------------
function newobject:GetName()
return self.name
end
| mit |
dmccuskey/dmc-sockets | dmc_corona/lib/dmc_lua/lib/bit/numberlua.lua | 115 | 13399 | --[[
LUA MODULE
bit.numberlua - Bitwise operations implemented in pure Lua as numbers,
with Lua 5.2 'bit32' and (LuaJIT) LuaBitOp 'bit' compatibility interfaces.
SYNOPSIS
local bit = require 'bit.numberlua'
print(bit.band(0xff00ff00, 0x00ff00ff)) --> 0xffffffff
-- Interface providing strong Lua 5.2 'bit32' compatibility
local bit32 = require 'bit.numberlua'.bit32
assert(bit32.band(-1) == 0xffffffff)
-- Interface providing strong (LuaJIT) LuaBitOp 'bit' compatibility
local bit = require 'bit.numberlua'.bit
assert(bit.tobit(0xffffffff) == -1)
DESCRIPTION
This library implements bitwise operations entirely in Lua.
This module is typically intended if for some reasons you don't want
to or cannot install a popular C based bit library like BitOp 'bit' [1]
(which comes pre-installed with LuaJIT) or 'bit32' (which comes
pre-installed with Lua 5.2) but want a similar interface.
This modules represents bit arrays as non-negative Lua numbers. [1]
It can represent 32-bit bit arrays when Lua is compiled
with lua_Number as double-precision IEEE 754 floating point.
The module is nearly the most efficient it can be but may be a few times
slower than the C based bit libraries and is orders or magnitude
slower than LuaJIT bit operations, which compile to native code. Therefore,
this library is inferior in performane to the other modules.
The `xor` function in this module is based partly on Roberto Ierusalimschy's
post in http://lua-users.org/lists/lua-l/2002-09/msg00134.html .
The included BIT.bit32 and BIT.bit sublibraries aims to provide 100%
compatibility with the Lua 5.2 "bit32" and (LuaJIT) LuaBitOp "bit" library.
This compatbility is at the cost of some efficiency since inputted
numbers are normalized and more general forms (e.g. multi-argument
bitwise operators) are supported.
STATUS
WARNING: Not all corner cases have been tested and documented.
Some attempt was made to make these similar to the Lua 5.2 [2]
and LuaJit BitOp [3] libraries, but this is not fully tested and there
are currently some differences. Addressing these differences may
be improved in the future but it is not yet fully determined how to
resolve these differences.
The BIT.bit32 library passes the Lua 5.2 test suite (bitwise.lua)
http://www.lua.org/tests/5.2/ . The BIT.bit library passes the LuaBitOp
test suite (bittest.lua). However, these have not been tested on
platforms with Lua compiled with 32-bit integer numbers.
API
BIT.tobit(x) --> z
Similar to function in BitOp.
BIT.tohex(x, n)
Similar to function in BitOp.
BIT.band(x, y) --> z
Similar to function in Lua 5.2 and BitOp but requires two arguments.
BIT.bor(x, y) --> z
Similar to function in Lua 5.2 and BitOp but requires two arguments.
BIT.bxor(x, y) --> z
Similar to function in Lua 5.2 and BitOp but requires two arguments.
BIT.bnot(x) --> z
Similar to function in Lua 5.2 and BitOp.
BIT.lshift(x, disp) --> z
Similar to function in Lua 5.2 (warning: BitOp uses unsigned lower 5 bits of shift),
BIT.rshift(x, disp) --> z
Similar to function in Lua 5.2 (warning: BitOp uses unsigned lower 5 bits of shift),
BIT.extract(x, field [, width]) --> z
Similar to function in Lua 5.2.
BIT.replace(x, v, field, width) --> z
Similar to function in Lua 5.2.
BIT.bswap(x) --> z
Similar to function in Lua 5.2.
BIT.rrotate(x, disp) --> z
BIT.ror(x, disp) --> z
Similar to function in Lua 5.2 and BitOp.
BIT.lrotate(x, disp) --> z
BIT.rol(x, disp) --> z
Similar to function in Lua 5.2 and BitOp.
BIT.arshift
Similar to function in Lua 5.2 and BitOp.
BIT.btest
Similar to function in Lua 5.2 with requires two arguments.
BIT.bit32
This table contains functions that aim to provide 100% compatibility
with the Lua 5.2 "bit32" library.
bit32.arshift (x, disp) --> z
bit32.band (...) --> z
bit32.bnot (x) --> z
bit32.bor (...) --> z
bit32.btest (...) --> true | false
bit32.bxor (...) --> z
bit32.extract (x, field [, width]) --> z
bit32.replace (x, v, field [, width]) --> z
bit32.lrotate (x, disp) --> z
bit32.lshift (x, disp) --> z
bit32.rrotate (x, disp) --> z
bit32.rshift (x, disp) --> z
BIT.bit
This table contains functions that aim to provide 100% compatibility
with the LuaBitOp "bit" library (from LuaJIT).
bit.tobit(x) --> y
bit.tohex(x [,n]) --> y
bit.bnot(x) --> y
bit.bor(x1 [,x2...]) --> y
bit.band(x1 [,x2...]) --> y
bit.bxor(x1 [,x2...]) --> y
bit.lshift(x, n) --> y
bit.rshift(x, n) --> y
bit.arshift(x, n) --> y
bit.rol(x, n) --> y
bit.ror(x, n) --> y
bit.bswap(x) --> y
DEPENDENCIES
None (other than Lua 5.1 or 5.2).
DOWNLOAD/INSTALLATION
If using LuaRocks:
luarocks install lua-bit-numberlua
Otherwise, download <https://github.com/davidm/lua-bit-numberlua/zipball/master>.
Alternately, if using git:
git clone git://github.com/davidm/lua-bit-numberlua.git
cd lua-bit-numberlua
Optionally unpack:
./util.mk
or unpack and install in LuaRocks:
./util.mk install
REFERENCES
[1] http://lua-users.org/wiki/FloatingPoint
[2] http://www.lua.org/manual/5.2/
[3] http://bitop.luajit.org/
LICENSE
(c) 2008-2011 David Manura. Licensed under the same terms as Lua (MIT).
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.
(end license)
--]]
local M = {_TYPE='module', _NAME='bit.numberlua', _VERSION='0.3.1.20120131'}
local floor = math.floor
local MOD = 2^32
local MODM = MOD-1
local function memoize(f)
local mt = {}
local t = setmetatable({}, mt)
function mt:__index(k)
local v = f(k); t[k] = v
return v
end
return t
end
local function make_bitop_uncached(t, m)
local function bitop(a, b)
local res,p = 0,1
while a ~= 0 and b ~= 0 do
local am, bm = a%m, b%m
res = res + t[am][bm]*p
a = (a - am) / m
b = (b - bm) / m
p = p*m
end
res = res + (a+b)*p
return res
end
return bitop
end
local function make_bitop(t)
local op1 = make_bitop_uncached(t,2^1)
local op2 = memoize(function(a)
return memoize(function(b)
return op1(a, b)
end)
end)
return make_bitop_uncached(op2, 2^(t.n or 1))
end
-- ok? probably not if running on a 32-bit int Lua number type platform
function M.tobit(x)
return x % 2^32
end
M.bxor = make_bitop {[0]={[0]=0,[1]=1},[1]={[0]=1,[1]=0}, n=4}
local bxor = M.bxor
function M.bnot(a) return MODM - a end
local bnot = M.bnot
function M.band(a,b) return ((a+b) - bxor(a,b))/2 end
local band = M.band
function M.bor(a,b) return MODM - band(MODM - a, MODM - b) end
local bor = M.bor
local lshift, rshift -- forward declare
function M.rshift(a,disp) -- Lua5.2 insipred
if disp < 0 then return lshift(a,-disp) end
return floor(a % 2^32 / 2^disp)
end
rshift = M.rshift
function M.lshift(a,disp) -- Lua5.2 inspired
if disp < 0 then return rshift(a,-disp) end
return (a * 2^disp) % 2^32
end
lshift = M.lshift
function M.tohex(x, n) -- BitOp style
n = n or 8
local up
if n <= 0 then
if n == 0 then return '' end
up = true
n = - n
end
x = band(x, 16^n-1)
return ('%0'..n..(up and 'X' or 'x')):format(x)
end
local tohex = M.tohex
function M.extract(n, field, width) -- Lua5.2 inspired
width = width or 1
return band(rshift(n, field), 2^width-1)
end
local extract = M.extract
function M.replace(n, v, field, width) -- Lua5.2 inspired
width = width or 1
local mask1 = 2^width-1
v = band(v, mask1) -- required by spec?
local mask = bnot(lshift(mask1, field))
return band(n, mask) + lshift(v, field)
end
local replace = M.replace
function M.bswap(x) -- BitOp style
local a = band(x, 0xff); x = rshift(x, 8)
local b = band(x, 0xff); x = rshift(x, 8)
local c = band(x, 0xff); x = rshift(x, 8)
local d = band(x, 0xff)
return lshift(lshift(lshift(a, 8) + b, 8) + c, 8) + d
end
local bswap = M.bswap
function M.rrotate(x, disp) -- Lua5.2 inspired
disp = disp % 32
local low = band(x, 2^disp-1)
return rshift(x, disp) + lshift(low, 32-disp)
end
local rrotate = M.rrotate
function M.lrotate(x, disp) -- Lua5.2 inspired
return rrotate(x, -disp)
end
local lrotate = M.lrotate
M.rol = M.lrotate -- LuaOp inspired
M.ror = M.rrotate -- LuaOp insipred
function M.arshift(x, disp) -- Lua5.2 inspired
local z = rshift(x, disp)
if x >= 0x80000000 then z = z + lshift(2^disp-1, 32-disp) end
return z
end
local arshift = M.arshift
function M.btest(x, y) -- Lua5.2 inspired
return band(x, y) ~= 0
end
--
-- Start Lua 5.2 "bit32" compat section.
--
M.bit32 = {} -- Lua 5.2 'bit32' compatibility
local function bit32_bnot(x)
return (-1 - x) % MOD
end
M.bit32.bnot = bit32_bnot
local function bit32_bxor(a, b, c, ...)
local z
if b then
a = a % MOD
b = b % MOD
z = bxor(a, b)
if c then
z = bit32_bxor(z, c, ...)
end
return z
elseif a then
return a % MOD
else
return 0
end
end
M.bit32.bxor = bit32_bxor
local function bit32_band(a, b, c, ...)
local z
if b then
a = a % MOD
b = b % MOD
z = ((a+b) - bxor(a,b)) / 2
if c then
z = bit32_band(z, c, ...)
end
return z
elseif a then
return a % MOD
else
return MODM
end
end
M.bit32.band = bit32_band
local function bit32_bor(a, b, c, ...)
local z
if b then
a = a % MOD
b = b % MOD
z = MODM - band(MODM - a, MODM - b)
if c then
z = bit32_bor(z, c, ...)
end
return z
elseif a then
return a % MOD
else
return 0
end
end
M.bit32.bor = bit32_bor
function M.bit32.btest(...)
return bit32_band(...) ~= 0
end
function M.bit32.lrotate(x, disp)
return lrotate(x % MOD, disp)
end
function M.bit32.rrotate(x, disp)
return rrotate(x % MOD, disp)
end
function M.bit32.lshift(x,disp)
if disp > 31 or disp < -31 then return 0 end
return lshift(x % MOD, disp)
end
function M.bit32.rshift(x,disp)
if disp > 31 or disp < -31 then return 0 end
return rshift(x % MOD, disp)
end
function M.bit32.arshift(x,disp)
x = x % MOD
if disp >= 0 then
if disp > 31 then
return (x >= 0x80000000) and MODM or 0
else
local z = rshift(x, disp)
if x >= 0x80000000 then z = z + lshift(2^disp-1, 32-disp) end
return z
end
else
return lshift(x, -disp)
end
end
function M.bit32.extract(x, field, ...)
local width = ... or 1
if field < 0 or field > 31 or width < 0 or field+width > 32 then error 'out of range' end
x = x % MOD
return extract(x, field, ...)
end
function M.bit32.replace(x, v, field, ...)
local width = ... or 1
if field < 0 or field > 31 or width < 0 or field+width > 32 then error 'out of range' end
x = x % MOD
v = v % MOD
return replace(x, v, field, ...)
end
--
-- Start LuaBitOp "bit" compat section.
--
M.bit = {} -- LuaBitOp "bit" compatibility
function M.bit.tobit(x)
x = x % MOD
if x >= 0x80000000 then x = x - MOD end
return x
end
local bit_tobit = M.bit.tobit
function M.bit.tohex(x, ...)
return tohex(x % MOD, ...)
end
function M.bit.bnot(x)
return bit_tobit(bnot(x % MOD))
end
local function bit_bor(a, b, c, ...)
if c then
return bit_bor(bit_bor(a, b), c, ...)
elseif b then
return bit_tobit(bor(a % MOD, b % MOD))
else
return bit_tobit(a)
end
end
M.bit.bor = bit_bor
local function bit_band(a, b, c, ...)
if c then
return bit_band(bit_band(a, b), c, ...)
elseif b then
return bit_tobit(band(a % MOD, b % MOD))
else
return bit_tobit(a)
end
end
M.bit.band = bit_band
local function bit_bxor(a, b, c, ...)
if c then
return bit_bxor(bit_bxor(a, b), c, ...)
elseif b then
return bit_tobit(bxor(a % MOD, b % MOD))
else
return bit_tobit(a)
end
end
M.bit.bxor = bit_bxor
function M.bit.lshift(x, n)
return bit_tobit(lshift(x % MOD, n % 32))
end
function M.bit.rshift(x, n)
return bit_tobit(rshift(x % MOD, n % 32))
end
function M.bit.arshift(x, n)
return bit_tobit(arshift(x % MOD, n % 32))
end
function M.bit.rol(x, n)
return bit_tobit(lrotate(x % MOD, n % 32))
end
function M.bit.ror(x, n)
return bit_tobit(rrotate(x % MOD, n % 32))
end
function M.bit.bswap(x)
return bit_tobit(bswap(x % MOD))
end
return M
| mit |
ffxinfinity/ffxinfinity | FFXI Server-Development/Build Files/scripts/zones/Yuhtunga_Jungle/npcs/Robino-Mobino.lua | 2 | 1754 | -----------------------------------
-- Area: Yuhtunga Jungle
-- NPC: Robino-Mobino
-- @pos -244 0 -401 123
-----------------------------------
package.loaded["scripts/zones/Yuhtunga_Jungle/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/shop");
require("scripts/globals/conquest");
require("scripts/zones/Yuhtunga_Jungle/TextIDs");
region = ELSHIMOLOWLANDS;
csid = 0x7ff4;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
owner = GetRegionOwner(region);
arg1 = getArg1(owner,player);
if(owner == player:getNation()) then
nation = 1;
elseif(arg1 < 1792) then
nation = 2;
else
nation = 0;
end
player:startEvent(csid,nation,OP_TeleFee(player,region),0,OP_TeleFee(player,region),player:getCP(),0,0,0);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("OPTION: %u",option);
player:updateEvent(player:getGil(),OP_TeleFee(player,region),0,OP_TeleFee(player,region),player:getCP());
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("OPTION: %u",option);
if(option == 1) then
ShowOPVendorShop(player);
elseif(option == 2) then
if (player:delGil(OP_TeleFee(player,region))) then
toHomeNation(player);
end
elseif(option == 6) then
player:delCP(OP_TeleFee(player,region));
toHomeNation(player);
end
end; | gpl-3.0 |
galek/crown | 3rdparty/bgfx/3rdparty/spirv-headers/include/spirv/unified1/spirv.lua | 4 | 54799 | -- Copyright (c) 2014-2020 The Khronos Group Inc.
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and/or associated documentation files (the "Materials"),
-- to deal in the Materials without restriction, including without limitation
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Materials, and to permit persons to whom the
-- Materials are 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 Materials.
--
-- MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
-- STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
-- HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
--
-- THE MATERIALS ARE 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 MATERIALS OR THE USE OR OTHER DEALINGS
-- IN THE MATERIALS.
-- This header is automatically generated by the same tool that creates
-- the Binary Section of the SPIR-V specification.
-- Enumeration tokens for SPIR-V, in various styles:
-- C, C++, C++11, JSON, Lua, Python, C#, D
--
-- - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL
-- - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL
-- - C++11 will use enum classes in the spv namespace, e.g.: spv::SourceLanguage::GLSL
-- - Lua will use tables, e.g.: spv.SourceLanguage.GLSL
-- - Python will use dictionaries, e.g.: spv['SourceLanguage']['GLSL']
-- - C# will use enum classes in the Specification class located in the "Spv" namespace,
-- e.g.: Spv.Specification.SourceLanguage.GLSL
-- - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL
--
-- Some tokens act like mask values, which can be OR'd together,
-- while others are mutually exclusive. The mask-like ones have
-- "Mask" in their name, and a parallel enum that has the shift
-- amount (1 << x) for each corresponding enumerant.
spv = {
MagicNumber = 0x07230203,
Version = 0x00010500,
Revision = 4,
OpCodeMask = 0xffff,
WordCountShift = 16,
SourceLanguage = {
Unknown = 0,
ESSL = 1,
GLSL = 2,
OpenCL_C = 3,
OpenCL_CPP = 4,
HLSL = 5,
},
ExecutionModel = {
Vertex = 0,
TessellationControl = 1,
TessellationEvaluation = 2,
Geometry = 3,
Fragment = 4,
GLCompute = 5,
Kernel = 6,
TaskNV = 5267,
MeshNV = 5268,
RayGenerationKHR = 5313,
RayGenerationNV = 5313,
IntersectionKHR = 5314,
IntersectionNV = 5314,
AnyHitKHR = 5315,
AnyHitNV = 5315,
ClosestHitKHR = 5316,
ClosestHitNV = 5316,
MissKHR = 5317,
MissNV = 5317,
CallableKHR = 5318,
CallableNV = 5318,
},
AddressingModel = {
Logical = 0,
Physical32 = 1,
Physical64 = 2,
PhysicalStorageBuffer64 = 5348,
PhysicalStorageBuffer64EXT = 5348,
},
MemoryModel = {
Simple = 0,
GLSL450 = 1,
OpenCL = 2,
Vulkan = 3,
VulkanKHR = 3,
},
ExecutionMode = {
Invocations = 0,
SpacingEqual = 1,
SpacingFractionalEven = 2,
SpacingFractionalOdd = 3,
VertexOrderCw = 4,
VertexOrderCcw = 5,
PixelCenterInteger = 6,
OriginUpperLeft = 7,
OriginLowerLeft = 8,
EarlyFragmentTests = 9,
PointMode = 10,
Xfb = 11,
DepthReplacing = 12,
DepthGreater = 14,
DepthLess = 15,
DepthUnchanged = 16,
LocalSize = 17,
LocalSizeHint = 18,
InputPoints = 19,
InputLines = 20,
InputLinesAdjacency = 21,
Triangles = 22,
InputTrianglesAdjacency = 23,
Quads = 24,
Isolines = 25,
OutputVertices = 26,
OutputPoints = 27,
OutputLineStrip = 28,
OutputTriangleStrip = 29,
VecTypeHint = 30,
ContractionOff = 31,
Initializer = 33,
Finalizer = 34,
SubgroupSize = 35,
SubgroupsPerWorkgroup = 36,
SubgroupsPerWorkgroupId = 37,
LocalSizeId = 38,
LocalSizeHintId = 39,
PostDepthCoverage = 4446,
DenormPreserve = 4459,
DenormFlushToZero = 4460,
SignedZeroInfNanPreserve = 4461,
RoundingModeRTE = 4462,
RoundingModeRTZ = 4463,
StencilRefReplacingEXT = 5027,
OutputLinesNV = 5269,
OutputPrimitivesNV = 5270,
DerivativeGroupQuadsNV = 5289,
DerivativeGroupLinearNV = 5290,
OutputTrianglesNV = 5298,
PixelInterlockOrderedEXT = 5366,
PixelInterlockUnorderedEXT = 5367,
SampleInterlockOrderedEXT = 5368,
SampleInterlockUnorderedEXT = 5369,
ShadingRateInterlockOrderedEXT = 5370,
ShadingRateInterlockUnorderedEXT = 5371,
SharedLocalMemorySizeINTEL = 5618,
RoundingModeRTPINTEL = 5620,
RoundingModeRTNINTEL = 5621,
FloatingPointModeALTINTEL = 5622,
FloatingPointModeIEEEINTEL = 5623,
MaxWorkgroupSizeINTEL = 5893,
MaxWorkDimINTEL = 5894,
NoGlobalOffsetINTEL = 5895,
NumSIMDWorkitemsINTEL = 5896,
SchedulerTargetFmaxMhzINTEL = 5903,
},
StorageClass = {
UniformConstant = 0,
Input = 1,
Uniform = 2,
Output = 3,
Workgroup = 4,
CrossWorkgroup = 5,
Private = 6,
Function = 7,
Generic = 8,
PushConstant = 9,
AtomicCounter = 10,
Image = 11,
StorageBuffer = 12,
CallableDataKHR = 5328,
CallableDataNV = 5328,
IncomingCallableDataKHR = 5329,
IncomingCallableDataNV = 5329,
RayPayloadKHR = 5338,
RayPayloadNV = 5338,
HitAttributeKHR = 5339,
HitAttributeNV = 5339,
IncomingRayPayloadKHR = 5342,
IncomingRayPayloadNV = 5342,
ShaderRecordBufferKHR = 5343,
ShaderRecordBufferNV = 5343,
PhysicalStorageBuffer = 5349,
PhysicalStorageBufferEXT = 5349,
CodeSectionINTEL = 5605,
DeviceOnlyINTEL = 5936,
HostOnlyINTEL = 5937,
},
Dim = {
Dim1D = 0,
Dim2D = 1,
Dim3D = 2,
Cube = 3,
Rect = 4,
Buffer = 5,
SubpassData = 6,
},
SamplerAddressingMode = {
None = 0,
ClampToEdge = 1,
Clamp = 2,
Repeat = 3,
RepeatMirrored = 4,
},
SamplerFilterMode = {
Nearest = 0,
Linear = 1,
},
ImageFormat = {
Unknown = 0,
Rgba32f = 1,
Rgba16f = 2,
R32f = 3,
Rgba8 = 4,
Rgba8Snorm = 5,
Rg32f = 6,
Rg16f = 7,
R11fG11fB10f = 8,
R16f = 9,
Rgba16 = 10,
Rgb10A2 = 11,
Rg16 = 12,
Rg8 = 13,
R16 = 14,
R8 = 15,
Rgba16Snorm = 16,
Rg16Snorm = 17,
Rg8Snorm = 18,
R16Snorm = 19,
R8Snorm = 20,
Rgba32i = 21,
Rgba16i = 22,
Rgba8i = 23,
R32i = 24,
Rg32i = 25,
Rg16i = 26,
Rg8i = 27,
R16i = 28,
R8i = 29,
Rgba32ui = 30,
Rgba16ui = 31,
Rgba8ui = 32,
R32ui = 33,
Rgb10a2ui = 34,
Rg32ui = 35,
Rg16ui = 36,
Rg8ui = 37,
R16ui = 38,
R8ui = 39,
R64ui = 40,
R64i = 41,
},
ImageChannelOrder = {
R = 0,
A = 1,
RG = 2,
RA = 3,
RGB = 4,
RGBA = 5,
BGRA = 6,
ARGB = 7,
Intensity = 8,
Luminance = 9,
Rx = 10,
RGx = 11,
RGBx = 12,
Depth = 13,
DepthStencil = 14,
sRGB = 15,
sRGBx = 16,
sRGBA = 17,
sBGRA = 18,
ABGR = 19,
},
ImageChannelDataType = {
SnormInt8 = 0,
SnormInt16 = 1,
UnormInt8 = 2,
UnormInt16 = 3,
UnormShort565 = 4,
UnormShort555 = 5,
UnormInt101010 = 6,
SignedInt8 = 7,
SignedInt16 = 8,
SignedInt32 = 9,
UnsignedInt8 = 10,
UnsignedInt16 = 11,
UnsignedInt32 = 12,
HalfFloat = 13,
Float = 14,
UnormInt24 = 15,
UnormInt101010_2 = 16,
},
ImageOperandsShift = {
Bias = 0,
Lod = 1,
Grad = 2,
ConstOffset = 3,
Offset = 4,
ConstOffsets = 5,
Sample = 6,
MinLod = 7,
MakeTexelAvailable = 8,
MakeTexelAvailableKHR = 8,
MakeTexelVisible = 9,
MakeTexelVisibleKHR = 9,
NonPrivateTexel = 10,
NonPrivateTexelKHR = 10,
VolatileTexel = 11,
VolatileTexelKHR = 11,
SignExtend = 12,
ZeroExtend = 13,
},
ImageOperandsMask = {
MaskNone = 0,
Bias = 0x00000001,
Lod = 0x00000002,
Grad = 0x00000004,
ConstOffset = 0x00000008,
Offset = 0x00000010,
ConstOffsets = 0x00000020,
Sample = 0x00000040,
MinLod = 0x00000080,
MakeTexelAvailable = 0x00000100,
MakeTexelAvailableKHR = 0x00000100,
MakeTexelVisible = 0x00000200,
MakeTexelVisibleKHR = 0x00000200,
NonPrivateTexel = 0x00000400,
NonPrivateTexelKHR = 0x00000400,
VolatileTexel = 0x00000800,
VolatileTexelKHR = 0x00000800,
SignExtend = 0x00001000,
ZeroExtend = 0x00002000,
},
FPFastMathModeShift = {
NotNaN = 0,
NotInf = 1,
NSZ = 2,
AllowRecip = 3,
Fast = 4,
AllowContractFastINTEL = 16,
AllowReassocINTEL = 17,
},
FPFastMathModeMask = {
MaskNone = 0,
NotNaN = 0x00000001,
NotInf = 0x00000002,
NSZ = 0x00000004,
AllowRecip = 0x00000008,
Fast = 0x00000010,
AllowContractFastINTEL = 0x00010000,
AllowReassocINTEL = 0x00020000,
},
FPRoundingMode = {
RTE = 0,
RTZ = 1,
RTP = 2,
RTN = 3,
},
LinkageType = {
Export = 0,
Import = 1,
LinkOnceODR = 2,
},
AccessQualifier = {
ReadOnly = 0,
WriteOnly = 1,
ReadWrite = 2,
},
FunctionParameterAttribute = {
Zext = 0,
Sext = 1,
ByVal = 2,
Sret = 3,
NoAlias = 4,
NoCapture = 5,
NoWrite = 6,
NoReadWrite = 7,
},
Decoration = {
RelaxedPrecision = 0,
SpecId = 1,
Block = 2,
BufferBlock = 3,
RowMajor = 4,
ColMajor = 5,
ArrayStride = 6,
MatrixStride = 7,
GLSLShared = 8,
GLSLPacked = 9,
CPacked = 10,
BuiltIn = 11,
NoPerspective = 13,
Flat = 14,
Patch = 15,
Centroid = 16,
Sample = 17,
Invariant = 18,
Restrict = 19,
Aliased = 20,
Volatile = 21,
Constant = 22,
Coherent = 23,
NonWritable = 24,
NonReadable = 25,
Uniform = 26,
UniformId = 27,
SaturatedConversion = 28,
Stream = 29,
Location = 30,
Component = 31,
Index = 32,
Binding = 33,
DescriptorSet = 34,
Offset = 35,
XfbBuffer = 36,
XfbStride = 37,
FuncParamAttr = 38,
FPRoundingMode = 39,
FPFastMathMode = 40,
LinkageAttributes = 41,
NoContraction = 42,
InputAttachmentIndex = 43,
Alignment = 44,
MaxByteOffset = 45,
AlignmentId = 46,
MaxByteOffsetId = 47,
NoSignedWrap = 4469,
NoUnsignedWrap = 4470,
ExplicitInterpAMD = 4999,
OverrideCoverageNV = 5248,
PassthroughNV = 5250,
ViewportRelativeNV = 5252,
SecondaryViewportRelativeNV = 5256,
PerPrimitiveNV = 5271,
PerViewNV = 5272,
PerTaskNV = 5273,
PerVertexNV = 5285,
NonUniform = 5300,
NonUniformEXT = 5300,
RestrictPointer = 5355,
RestrictPointerEXT = 5355,
AliasedPointer = 5356,
AliasedPointerEXT = 5356,
SIMTCallINTEL = 5599,
ReferencedIndirectlyINTEL = 5602,
ClobberINTEL = 5607,
SideEffectsINTEL = 5608,
VectorComputeVariableINTEL = 5624,
FuncParamIOKindINTEL = 5625,
VectorComputeFunctionINTEL = 5626,
StackCallINTEL = 5627,
GlobalVariableOffsetINTEL = 5628,
CounterBuffer = 5634,
HlslCounterBufferGOOGLE = 5634,
HlslSemanticGOOGLE = 5635,
UserSemantic = 5635,
UserTypeGOOGLE = 5636,
FunctionRoundingModeINTEL = 5822,
FunctionDenormModeINTEL = 5823,
RegisterINTEL = 5825,
MemoryINTEL = 5826,
NumbanksINTEL = 5827,
BankwidthINTEL = 5828,
MaxPrivateCopiesINTEL = 5829,
SinglepumpINTEL = 5830,
DoublepumpINTEL = 5831,
MaxReplicatesINTEL = 5832,
SimpleDualPortINTEL = 5833,
MergeINTEL = 5834,
BankBitsINTEL = 5835,
ForcePow2DepthINTEL = 5836,
BurstCoalesceINTEL = 5899,
CacheSizeINTEL = 5900,
DontStaticallyCoalesceINTEL = 5901,
PrefetchINTEL = 5902,
StallEnableINTEL = 5905,
FuseLoopsInFunctionINTEL = 5907,
BufferLocationINTEL = 5921,
IOPipeStorageINTEL = 5944,
FunctionFloatingPointModeINTEL = 6080,
SingleElementVectorINTEL = 6085,
VectorComputeCallableFunctionINTEL = 6087,
},
BuiltIn = {
Position = 0,
PointSize = 1,
ClipDistance = 3,
CullDistance = 4,
VertexId = 5,
InstanceId = 6,
PrimitiveId = 7,
InvocationId = 8,
Layer = 9,
ViewportIndex = 10,
TessLevelOuter = 11,
TessLevelInner = 12,
TessCoord = 13,
PatchVertices = 14,
FragCoord = 15,
PointCoord = 16,
FrontFacing = 17,
SampleId = 18,
SamplePosition = 19,
SampleMask = 20,
FragDepth = 22,
HelperInvocation = 23,
NumWorkgroups = 24,
WorkgroupSize = 25,
WorkgroupId = 26,
LocalInvocationId = 27,
GlobalInvocationId = 28,
LocalInvocationIndex = 29,
WorkDim = 30,
GlobalSize = 31,
EnqueuedWorkgroupSize = 32,
GlobalOffset = 33,
GlobalLinearId = 34,
SubgroupSize = 36,
SubgroupMaxSize = 37,
NumSubgroups = 38,
NumEnqueuedSubgroups = 39,
SubgroupId = 40,
SubgroupLocalInvocationId = 41,
VertexIndex = 42,
InstanceIndex = 43,
SubgroupEqMask = 4416,
SubgroupEqMaskKHR = 4416,
SubgroupGeMask = 4417,
SubgroupGeMaskKHR = 4417,
SubgroupGtMask = 4418,
SubgroupGtMaskKHR = 4418,
SubgroupLeMask = 4419,
SubgroupLeMaskKHR = 4419,
SubgroupLtMask = 4420,
SubgroupLtMaskKHR = 4420,
BaseVertex = 4424,
BaseInstance = 4425,
DrawIndex = 4426,
PrimitiveShadingRateKHR = 4432,
DeviceIndex = 4438,
ViewIndex = 4440,
ShadingRateKHR = 4444,
BaryCoordNoPerspAMD = 4992,
BaryCoordNoPerspCentroidAMD = 4993,
BaryCoordNoPerspSampleAMD = 4994,
BaryCoordSmoothAMD = 4995,
BaryCoordSmoothCentroidAMD = 4996,
BaryCoordSmoothSampleAMD = 4997,
BaryCoordPullModelAMD = 4998,
FragStencilRefEXT = 5014,
ViewportMaskNV = 5253,
SecondaryPositionNV = 5257,
SecondaryViewportMaskNV = 5258,
PositionPerViewNV = 5261,
ViewportMaskPerViewNV = 5262,
FullyCoveredEXT = 5264,
TaskCountNV = 5274,
PrimitiveCountNV = 5275,
PrimitiveIndicesNV = 5276,
ClipDistancePerViewNV = 5277,
CullDistancePerViewNV = 5278,
LayerPerViewNV = 5279,
MeshViewCountNV = 5280,
MeshViewIndicesNV = 5281,
BaryCoordNV = 5286,
BaryCoordNoPerspNV = 5287,
FragSizeEXT = 5292,
FragmentSizeNV = 5292,
FragInvocationCountEXT = 5293,
InvocationsPerPixelNV = 5293,
LaunchIdKHR = 5319,
LaunchIdNV = 5319,
LaunchSizeKHR = 5320,
LaunchSizeNV = 5320,
WorldRayOriginKHR = 5321,
WorldRayOriginNV = 5321,
WorldRayDirectionKHR = 5322,
WorldRayDirectionNV = 5322,
ObjectRayOriginKHR = 5323,
ObjectRayOriginNV = 5323,
ObjectRayDirectionKHR = 5324,
ObjectRayDirectionNV = 5324,
RayTminKHR = 5325,
RayTminNV = 5325,
RayTmaxKHR = 5326,
RayTmaxNV = 5326,
InstanceCustomIndexKHR = 5327,
InstanceCustomIndexNV = 5327,
ObjectToWorldKHR = 5330,
ObjectToWorldNV = 5330,
WorldToObjectKHR = 5331,
WorldToObjectNV = 5331,
HitTNV = 5332,
HitKindKHR = 5333,
HitKindNV = 5333,
IncomingRayFlagsKHR = 5351,
IncomingRayFlagsNV = 5351,
RayGeometryIndexKHR = 5352,
WarpsPerSMNV = 5374,
SMCountNV = 5375,
WarpIDNV = 5376,
SMIDNV = 5377,
},
SelectionControlShift = {
Flatten = 0,
DontFlatten = 1,
},
SelectionControlMask = {
MaskNone = 0,
Flatten = 0x00000001,
DontFlatten = 0x00000002,
},
LoopControlShift = {
Unroll = 0,
DontUnroll = 1,
DependencyInfinite = 2,
DependencyLength = 3,
MinIterations = 4,
MaxIterations = 5,
IterationMultiple = 6,
PeelCount = 7,
PartialCount = 8,
InitiationIntervalINTEL = 16,
MaxConcurrencyINTEL = 17,
DependencyArrayINTEL = 18,
PipelineEnableINTEL = 19,
LoopCoalesceINTEL = 20,
MaxInterleavingINTEL = 21,
SpeculatedIterationsINTEL = 22,
NoFusionINTEL = 23,
},
LoopControlMask = {
MaskNone = 0,
Unroll = 0x00000001,
DontUnroll = 0x00000002,
DependencyInfinite = 0x00000004,
DependencyLength = 0x00000008,
MinIterations = 0x00000010,
MaxIterations = 0x00000020,
IterationMultiple = 0x00000040,
PeelCount = 0x00000080,
PartialCount = 0x00000100,
InitiationIntervalINTEL = 0x00010000,
MaxConcurrencyINTEL = 0x00020000,
DependencyArrayINTEL = 0x00040000,
PipelineEnableINTEL = 0x00080000,
LoopCoalesceINTEL = 0x00100000,
MaxInterleavingINTEL = 0x00200000,
SpeculatedIterationsINTEL = 0x00400000,
NoFusionINTEL = 0x00800000,
},
FunctionControlShift = {
Inline = 0,
DontInline = 1,
Pure = 2,
Const = 3,
},
FunctionControlMask = {
MaskNone = 0,
Inline = 0x00000001,
DontInline = 0x00000002,
Pure = 0x00000004,
Const = 0x00000008,
},
MemorySemanticsShift = {
Acquire = 1,
Release = 2,
AcquireRelease = 3,
SequentiallyConsistent = 4,
UniformMemory = 6,
SubgroupMemory = 7,
WorkgroupMemory = 8,
CrossWorkgroupMemory = 9,
AtomicCounterMemory = 10,
ImageMemory = 11,
OutputMemory = 12,
OutputMemoryKHR = 12,
MakeAvailable = 13,
MakeAvailableKHR = 13,
MakeVisible = 14,
MakeVisibleKHR = 14,
Volatile = 15,
},
MemorySemanticsMask = {
MaskNone = 0,
Acquire = 0x00000002,
Release = 0x00000004,
AcquireRelease = 0x00000008,
SequentiallyConsistent = 0x00000010,
UniformMemory = 0x00000040,
SubgroupMemory = 0x00000080,
WorkgroupMemory = 0x00000100,
CrossWorkgroupMemory = 0x00000200,
AtomicCounterMemory = 0x00000400,
ImageMemory = 0x00000800,
OutputMemory = 0x00001000,
OutputMemoryKHR = 0x00001000,
MakeAvailable = 0x00002000,
MakeAvailableKHR = 0x00002000,
MakeVisible = 0x00004000,
MakeVisibleKHR = 0x00004000,
Volatile = 0x00008000,
},
MemoryAccessShift = {
Volatile = 0,
Aligned = 1,
Nontemporal = 2,
MakePointerAvailable = 3,
MakePointerAvailableKHR = 3,
MakePointerVisible = 4,
MakePointerVisibleKHR = 4,
NonPrivatePointer = 5,
NonPrivatePointerKHR = 5,
},
MemoryAccessMask = {
MaskNone = 0,
Volatile = 0x00000001,
Aligned = 0x00000002,
Nontemporal = 0x00000004,
MakePointerAvailable = 0x00000008,
MakePointerAvailableKHR = 0x00000008,
MakePointerVisible = 0x00000010,
MakePointerVisibleKHR = 0x00000010,
NonPrivatePointer = 0x00000020,
NonPrivatePointerKHR = 0x00000020,
},
Scope = {
CrossDevice = 0,
Device = 1,
Workgroup = 2,
Subgroup = 3,
Invocation = 4,
QueueFamily = 5,
QueueFamilyKHR = 5,
ShaderCallKHR = 6,
},
GroupOperation = {
Reduce = 0,
InclusiveScan = 1,
ExclusiveScan = 2,
ClusteredReduce = 3,
PartitionedReduceNV = 6,
PartitionedInclusiveScanNV = 7,
PartitionedExclusiveScanNV = 8,
},
KernelEnqueueFlags = {
NoWait = 0,
WaitKernel = 1,
WaitWorkGroup = 2,
},
KernelProfilingInfoShift = {
CmdExecTime = 0,
},
KernelProfilingInfoMask = {
MaskNone = 0,
CmdExecTime = 0x00000001,
},
Capability = {
Matrix = 0,
Shader = 1,
Geometry = 2,
Tessellation = 3,
Addresses = 4,
Linkage = 5,
Kernel = 6,
Vector16 = 7,
Float16Buffer = 8,
Float16 = 9,
Float64 = 10,
Int64 = 11,
Int64Atomics = 12,
ImageBasic = 13,
ImageReadWrite = 14,
ImageMipmap = 15,
Pipes = 17,
Groups = 18,
DeviceEnqueue = 19,
LiteralSampler = 20,
AtomicStorage = 21,
Int16 = 22,
TessellationPointSize = 23,
GeometryPointSize = 24,
ImageGatherExtended = 25,
StorageImageMultisample = 27,
UniformBufferArrayDynamicIndexing = 28,
SampledImageArrayDynamicIndexing = 29,
StorageBufferArrayDynamicIndexing = 30,
StorageImageArrayDynamicIndexing = 31,
ClipDistance = 32,
CullDistance = 33,
ImageCubeArray = 34,
SampleRateShading = 35,
ImageRect = 36,
SampledRect = 37,
GenericPointer = 38,
Int8 = 39,
InputAttachment = 40,
SparseResidency = 41,
MinLod = 42,
Sampled1D = 43,
Image1D = 44,
SampledCubeArray = 45,
SampledBuffer = 46,
ImageBuffer = 47,
ImageMSArray = 48,
StorageImageExtendedFormats = 49,
ImageQuery = 50,
DerivativeControl = 51,
InterpolationFunction = 52,
TransformFeedback = 53,
GeometryStreams = 54,
StorageImageReadWithoutFormat = 55,
StorageImageWriteWithoutFormat = 56,
MultiViewport = 57,
SubgroupDispatch = 58,
NamedBarrier = 59,
PipeStorage = 60,
GroupNonUniform = 61,
GroupNonUniformVote = 62,
GroupNonUniformArithmetic = 63,
GroupNonUniformBallot = 64,
GroupNonUniformShuffle = 65,
GroupNonUniformShuffleRelative = 66,
GroupNonUniformClustered = 67,
GroupNonUniformQuad = 68,
ShaderLayer = 69,
ShaderViewportIndex = 70,
FragmentShadingRateKHR = 4422,
SubgroupBallotKHR = 4423,
DrawParameters = 4427,
WorkgroupMemoryExplicitLayoutKHR = 4428,
WorkgroupMemoryExplicitLayout8BitAccessKHR = 4429,
WorkgroupMemoryExplicitLayout16BitAccessKHR = 4430,
SubgroupVoteKHR = 4431,
StorageBuffer16BitAccess = 4433,
StorageUniformBufferBlock16 = 4433,
StorageUniform16 = 4434,
UniformAndStorageBuffer16BitAccess = 4434,
StoragePushConstant16 = 4435,
StorageInputOutput16 = 4436,
DeviceGroup = 4437,
MultiView = 4439,
VariablePointersStorageBuffer = 4441,
VariablePointers = 4442,
AtomicStorageOps = 4445,
SampleMaskPostDepthCoverage = 4447,
StorageBuffer8BitAccess = 4448,
UniformAndStorageBuffer8BitAccess = 4449,
StoragePushConstant8 = 4450,
DenormPreserve = 4464,
DenormFlushToZero = 4465,
SignedZeroInfNanPreserve = 4466,
RoundingModeRTE = 4467,
RoundingModeRTZ = 4468,
RayQueryProvisionalKHR = 4471,
RayQueryKHR = 4472,
RayTraversalPrimitiveCullingKHR = 4478,
RayTracingKHR = 4479,
Float16ImageAMD = 5008,
ImageGatherBiasLodAMD = 5009,
FragmentMaskAMD = 5010,
StencilExportEXT = 5013,
ImageReadWriteLodAMD = 5015,
Int64ImageEXT = 5016,
ShaderClockKHR = 5055,
SampleMaskOverrideCoverageNV = 5249,
GeometryShaderPassthroughNV = 5251,
ShaderViewportIndexLayerEXT = 5254,
ShaderViewportIndexLayerNV = 5254,
ShaderViewportMaskNV = 5255,
ShaderStereoViewNV = 5259,
PerViewAttributesNV = 5260,
FragmentFullyCoveredEXT = 5265,
MeshShadingNV = 5266,
ImageFootprintNV = 5282,
FragmentBarycentricNV = 5284,
ComputeDerivativeGroupQuadsNV = 5288,
FragmentDensityEXT = 5291,
ShadingRateNV = 5291,
GroupNonUniformPartitionedNV = 5297,
ShaderNonUniform = 5301,
ShaderNonUniformEXT = 5301,
RuntimeDescriptorArray = 5302,
RuntimeDescriptorArrayEXT = 5302,
InputAttachmentArrayDynamicIndexing = 5303,
InputAttachmentArrayDynamicIndexingEXT = 5303,
UniformTexelBufferArrayDynamicIndexing = 5304,
UniformTexelBufferArrayDynamicIndexingEXT = 5304,
StorageTexelBufferArrayDynamicIndexing = 5305,
StorageTexelBufferArrayDynamicIndexingEXT = 5305,
UniformBufferArrayNonUniformIndexing = 5306,
UniformBufferArrayNonUniformIndexingEXT = 5306,
SampledImageArrayNonUniformIndexing = 5307,
SampledImageArrayNonUniformIndexingEXT = 5307,
StorageBufferArrayNonUniformIndexing = 5308,
StorageBufferArrayNonUniformIndexingEXT = 5308,
StorageImageArrayNonUniformIndexing = 5309,
StorageImageArrayNonUniformIndexingEXT = 5309,
InputAttachmentArrayNonUniformIndexing = 5310,
InputAttachmentArrayNonUniformIndexingEXT = 5310,
UniformTexelBufferArrayNonUniformIndexing = 5311,
UniformTexelBufferArrayNonUniformIndexingEXT = 5311,
StorageTexelBufferArrayNonUniformIndexing = 5312,
StorageTexelBufferArrayNonUniformIndexingEXT = 5312,
RayTracingNV = 5340,
VulkanMemoryModel = 5345,
VulkanMemoryModelKHR = 5345,
VulkanMemoryModelDeviceScope = 5346,
VulkanMemoryModelDeviceScopeKHR = 5346,
PhysicalStorageBufferAddresses = 5347,
PhysicalStorageBufferAddressesEXT = 5347,
ComputeDerivativeGroupLinearNV = 5350,
RayTracingProvisionalKHR = 5353,
CooperativeMatrixNV = 5357,
FragmentShaderSampleInterlockEXT = 5363,
FragmentShaderShadingRateInterlockEXT = 5372,
ShaderSMBuiltinsNV = 5373,
FragmentShaderPixelInterlockEXT = 5378,
DemoteToHelperInvocationEXT = 5379,
SubgroupShuffleINTEL = 5568,
SubgroupBufferBlockIOINTEL = 5569,
SubgroupImageBlockIOINTEL = 5570,
SubgroupImageMediaBlockIOINTEL = 5579,
RoundToInfinityINTEL = 5582,
FloatingPointModeINTEL = 5583,
IntegerFunctions2INTEL = 5584,
FunctionPointersINTEL = 5603,
IndirectReferencesINTEL = 5604,
AsmINTEL = 5606,
AtomicFloat32MinMaxEXT = 5612,
AtomicFloat64MinMaxEXT = 5613,
AtomicFloat16MinMaxEXT = 5616,
VectorComputeINTEL = 5617,
VectorAnyINTEL = 5619,
ExpectAssumeKHR = 5629,
SubgroupAvcMotionEstimationINTEL = 5696,
SubgroupAvcMotionEstimationIntraINTEL = 5697,
SubgroupAvcMotionEstimationChromaINTEL = 5698,
VariableLengthArrayINTEL = 5817,
FunctionFloatControlINTEL = 5821,
FPGAMemoryAttributesINTEL = 5824,
FPFastMathModeINTEL = 5837,
ArbitraryPrecisionIntegersINTEL = 5844,
UnstructuredLoopControlsINTEL = 5886,
FPGALoopControlsINTEL = 5888,
KernelAttributesINTEL = 5892,
FPGAKernelAttributesINTEL = 5897,
FPGAMemoryAccessesINTEL = 5898,
FPGAClusterAttributesINTEL = 5904,
LoopFuseINTEL = 5906,
FPGABufferLocationINTEL = 5920,
USMStorageClassesINTEL = 5935,
IOPipesINTEL = 5943,
BlockingPipesINTEL = 5945,
FPGARegINTEL = 5948,
AtomicFloat32AddEXT = 6033,
AtomicFloat64AddEXT = 6034,
LongConstantCompositeINTEL = 6089,
},
RayFlagsShift = {
OpaqueKHR = 0,
NoOpaqueKHR = 1,
TerminateOnFirstHitKHR = 2,
SkipClosestHitShaderKHR = 3,
CullBackFacingTrianglesKHR = 4,
CullFrontFacingTrianglesKHR = 5,
CullOpaqueKHR = 6,
CullNoOpaqueKHR = 7,
SkipTrianglesKHR = 8,
SkipAABBsKHR = 9,
},
RayFlagsMask = {
MaskNone = 0,
OpaqueKHR = 0x00000001,
NoOpaqueKHR = 0x00000002,
TerminateOnFirstHitKHR = 0x00000004,
SkipClosestHitShaderKHR = 0x00000008,
CullBackFacingTrianglesKHR = 0x00000010,
CullFrontFacingTrianglesKHR = 0x00000020,
CullOpaqueKHR = 0x00000040,
CullNoOpaqueKHR = 0x00000080,
SkipTrianglesKHR = 0x00000100,
SkipAABBsKHR = 0x00000200,
},
RayQueryIntersection = {
RayQueryCandidateIntersectionKHR = 0,
RayQueryCommittedIntersectionKHR = 1,
},
RayQueryCommittedIntersectionType = {
RayQueryCommittedIntersectionNoneKHR = 0,
RayQueryCommittedIntersectionTriangleKHR = 1,
RayQueryCommittedIntersectionGeneratedKHR = 2,
},
RayQueryCandidateIntersectionType = {
RayQueryCandidateIntersectionTriangleKHR = 0,
RayQueryCandidateIntersectionAABBKHR = 1,
},
FragmentShadingRateShift = {
Vertical2Pixels = 0,
Vertical4Pixels = 1,
Horizontal2Pixels = 2,
Horizontal4Pixels = 3,
},
FragmentShadingRateMask = {
MaskNone = 0,
Vertical2Pixels = 0x00000001,
Vertical4Pixels = 0x00000002,
Horizontal2Pixels = 0x00000004,
Horizontal4Pixels = 0x00000008,
},
FPDenormMode = {
Preserve = 0,
FlushToZero = 1,
},
FPOperationMode = {
IEEE = 0,
ALT = 1,
},
Op = {
OpNop = 0,
OpUndef = 1,
OpSourceContinued = 2,
OpSource = 3,
OpSourceExtension = 4,
OpName = 5,
OpMemberName = 6,
OpString = 7,
OpLine = 8,
OpExtension = 10,
OpExtInstImport = 11,
OpExtInst = 12,
OpMemoryModel = 14,
OpEntryPoint = 15,
OpExecutionMode = 16,
OpCapability = 17,
OpTypeVoid = 19,
OpTypeBool = 20,
OpTypeInt = 21,
OpTypeFloat = 22,
OpTypeVector = 23,
OpTypeMatrix = 24,
OpTypeImage = 25,
OpTypeSampler = 26,
OpTypeSampledImage = 27,
OpTypeArray = 28,
OpTypeRuntimeArray = 29,
OpTypeStruct = 30,
OpTypeOpaque = 31,
OpTypePointer = 32,
OpTypeFunction = 33,
OpTypeEvent = 34,
OpTypeDeviceEvent = 35,
OpTypeReserveId = 36,
OpTypeQueue = 37,
OpTypePipe = 38,
OpTypeForwardPointer = 39,
OpConstantTrue = 41,
OpConstantFalse = 42,
OpConstant = 43,
OpConstantComposite = 44,
OpConstantSampler = 45,
OpConstantNull = 46,
OpSpecConstantTrue = 48,
OpSpecConstantFalse = 49,
OpSpecConstant = 50,
OpSpecConstantComposite = 51,
OpSpecConstantOp = 52,
OpFunction = 54,
OpFunctionParameter = 55,
OpFunctionEnd = 56,
OpFunctionCall = 57,
OpVariable = 59,
OpImageTexelPointer = 60,
OpLoad = 61,
OpStore = 62,
OpCopyMemory = 63,
OpCopyMemorySized = 64,
OpAccessChain = 65,
OpInBoundsAccessChain = 66,
OpPtrAccessChain = 67,
OpArrayLength = 68,
OpGenericPtrMemSemantics = 69,
OpInBoundsPtrAccessChain = 70,
OpDecorate = 71,
OpMemberDecorate = 72,
OpDecorationGroup = 73,
OpGroupDecorate = 74,
OpGroupMemberDecorate = 75,
OpVectorExtractDynamic = 77,
OpVectorInsertDynamic = 78,
OpVectorShuffle = 79,
OpCompositeConstruct = 80,
OpCompositeExtract = 81,
OpCompositeInsert = 82,
OpCopyObject = 83,
OpTranspose = 84,
OpSampledImage = 86,
OpImageSampleImplicitLod = 87,
OpImageSampleExplicitLod = 88,
OpImageSampleDrefImplicitLod = 89,
OpImageSampleDrefExplicitLod = 90,
OpImageSampleProjImplicitLod = 91,
OpImageSampleProjExplicitLod = 92,
OpImageSampleProjDrefImplicitLod = 93,
OpImageSampleProjDrefExplicitLod = 94,
OpImageFetch = 95,
OpImageGather = 96,
OpImageDrefGather = 97,
OpImageRead = 98,
OpImageWrite = 99,
OpImage = 100,
OpImageQueryFormat = 101,
OpImageQueryOrder = 102,
OpImageQuerySizeLod = 103,
OpImageQuerySize = 104,
OpImageQueryLod = 105,
OpImageQueryLevels = 106,
OpImageQuerySamples = 107,
OpConvertFToU = 109,
OpConvertFToS = 110,
OpConvertSToF = 111,
OpConvertUToF = 112,
OpUConvert = 113,
OpSConvert = 114,
OpFConvert = 115,
OpQuantizeToF16 = 116,
OpConvertPtrToU = 117,
OpSatConvertSToU = 118,
OpSatConvertUToS = 119,
OpConvertUToPtr = 120,
OpPtrCastToGeneric = 121,
OpGenericCastToPtr = 122,
OpGenericCastToPtrExplicit = 123,
OpBitcast = 124,
OpSNegate = 126,
OpFNegate = 127,
OpIAdd = 128,
OpFAdd = 129,
OpISub = 130,
OpFSub = 131,
OpIMul = 132,
OpFMul = 133,
OpUDiv = 134,
OpSDiv = 135,
OpFDiv = 136,
OpUMod = 137,
OpSRem = 138,
OpSMod = 139,
OpFRem = 140,
OpFMod = 141,
OpVectorTimesScalar = 142,
OpMatrixTimesScalar = 143,
OpVectorTimesMatrix = 144,
OpMatrixTimesVector = 145,
OpMatrixTimesMatrix = 146,
OpOuterProduct = 147,
OpDot = 148,
OpIAddCarry = 149,
OpISubBorrow = 150,
OpUMulExtended = 151,
OpSMulExtended = 152,
OpAny = 154,
OpAll = 155,
OpIsNan = 156,
OpIsInf = 157,
OpIsFinite = 158,
OpIsNormal = 159,
OpSignBitSet = 160,
OpLessOrGreater = 161,
OpOrdered = 162,
OpUnordered = 163,
OpLogicalEqual = 164,
OpLogicalNotEqual = 165,
OpLogicalOr = 166,
OpLogicalAnd = 167,
OpLogicalNot = 168,
OpSelect = 169,
OpIEqual = 170,
OpINotEqual = 171,
OpUGreaterThan = 172,
OpSGreaterThan = 173,
OpUGreaterThanEqual = 174,
OpSGreaterThanEqual = 175,
OpULessThan = 176,
OpSLessThan = 177,
OpULessThanEqual = 178,
OpSLessThanEqual = 179,
OpFOrdEqual = 180,
OpFUnordEqual = 181,
OpFOrdNotEqual = 182,
OpFUnordNotEqual = 183,
OpFOrdLessThan = 184,
OpFUnordLessThan = 185,
OpFOrdGreaterThan = 186,
OpFUnordGreaterThan = 187,
OpFOrdLessThanEqual = 188,
OpFUnordLessThanEqual = 189,
OpFOrdGreaterThanEqual = 190,
OpFUnordGreaterThanEqual = 191,
OpShiftRightLogical = 194,
OpShiftRightArithmetic = 195,
OpShiftLeftLogical = 196,
OpBitwiseOr = 197,
OpBitwiseXor = 198,
OpBitwiseAnd = 199,
OpNot = 200,
OpBitFieldInsert = 201,
OpBitFieldSExtract = 202,
OpBitFieldUExtract = 203,
OpBitReverse = 204,
OpBitCount = 205,
OpDPdx = 207,
OpDPdy = 208,
OpFwidth = 209,
OpDPdxFine = 210,
OpDPdyFine = 211,
OpFwidthFine = 212,
OpDPdxCoarse = 213,
OpDPdyCoarse = 214,
OpFwidthCoarse = 215,
OpEmitVertex = 218,
OpEndPrimitive = 219,
OpEmitStreamVertex = 220,
OpEndStreamPrimitive = 221,
OpControlBarrier = 224,
OpMemoryBarrier = 225,
OpAtomicLoad = 227,
OpAtomicStore = 228,
OpAtomicExchange = 229,
OpAtomicCompareExchange = 230,
OpAtomicCompareExchangeWeak = 231,
OpAtomicIIncrement = 232,
OpAtomicIDecrement = 233,
OpAtomicIAdd = 234,
OpAtomicISub = 235,
OpAtomicSMin = 236,
OpAtomicUMin = 237,
OpAtomicSMax = 238,
OpAtomicUMax = 239,
OpAtomicAnd = 240,
OpAtomicOr = 241,
OpAtomicXor = 242,
OpPhi = 245,
OpLoopMerge = 246,
OpSelectionMerge = 247,
OpLabel = 248,
OpBranch = 249,
OpBranchConditional = 250,
OpSwitch = 251,
OpKill = 252,
OpReturn = 253,
OpReturnValue = 254,
OpUnreachable = 255,
OpLifetimeStart = 256,
OpLifetimeStop = 257,
OpGroupAsyncCopy = 259,
OpGroupWaitEvents = 260,
OpGroupAll = 261,
OpGroupAny = 262,
OpGroupBroadcast = 263,
OpGroupIAdd = 264,
OpGroupFAdd = 265,
OpGroupFMin = 266,
OpGroupUMin = 267,
OpGroupSMin = 268,
OpGroupFMax = 269,
OpGroupUMax = 270,
OpGroupSMax = 271,
OpReadPipe = 274,
OpWritePipe = 275,
OpReservedReadPipe = 276,
OpReservedWritePipe = 277,
OpReserveReadPipePackets = 278,
OpReserveWritePipePackets = 279,
OpCommitReadPipe = 280,
OpCommitWritePipe = 281,
OpIsValidReserveId = 282,
OpGetNumPipePackets = 283,
OpGetMaxPipePackets = 284,
OpGroupReserveReadPipePackets = 285,
OpGroupReserveWritePipePackets = 286,
OpGroupCommitReadPipe = 287,
OpGroupCommitWritePipe = 288,
OpEnqueueMarker = 291,
OpEnqueueKernel = 292,
OpGetKernelNDrangeSubGroupCount = 293,
OpGetKernelNDrangeMaxSubGroupSize = 294,
OpGetKernelWorkGroupSize = 295,
OpGetKernelPreferredWorkGroupSizeMultiple = 296,
OpRetainEvent = 297,
OpReleaseEvent = 298,
OpCreateUserEvent = 299,
OpIsValidEvent = 300,
OpSetUserEventStatus = 301,
OpCaptureEventProfilingInfo = 302,
OpGetDefaultQueue = 303,
OpBuildNDRange = 304,
OpImageSparseSampleImplicitLod = 305,
OpImageSparseSampleExplicitLod = 306,
OpImageSparseSampleDrefImplicitLod = 307,
OpImageSparseSampleDrefExplicitLod = 308,
OpImageSparseSampleProjImplicitLod = 309,
OpImageSparseSampleProjExplicitLod = 310,
OpImageSparseSampleProjDrefImplicitLod = 311,
OpImageSparseSampleProjDrefExplicitLod = 312,
OpImageSparseFetch = 313,
OpImageSparseGather = 314,
OpImageSparseDrefGather = 315,
OpImageSparseTexelsResident = 316,
OpNoLine = 317,
OpAtomicFlagTestAndSet = 318,
OpAtomicFlagClear = 319,
OpImageSparseRead = 320,
OpSizeOf = 321,
OpTypePipeStorage = 322,
OpConstantPipeStorage = 323,
OpCreatePipeFromPipeStorage = 324,
OpGetKernelLocalSizeForSubgroupCount = 325,
OpGetKernelMaxNumSubgroups = 326,
OpTypeNamedBarrier = 327,
OpNamedBarrierInitialize = 328,
OpMemoryNamedBarrier = 329,
OpModuleProcessed = 330,
OpExecutionModeId = 331,
OpDecorateId = 332,
OpGroupNonUniformElect = 333,
OpGroupNonUniformAll = 334,
OpGroupNonUniformAny = 335,
OpGroupNonUniformAllEqual = 336,
OpGroupNonUniformBroadcast = 337,
OpGroupNonUniformBroadcastFirst = 338,
OpGroupNonUniformBallot = 339,
OpGroupNonUniformInverseBallot = 340,
OpGroupNonUniformBallotBitExtract = 341,
OpGroupNonUniformBallotBitCount = 342,
OpGroupNonUniformBallotFindLSB = 343,
OpGroupNonUniformBallotFindMSB = 344,
OpGroupNonUniformShuffle = 345,
OpGroupNonUniformShuffleXor = 346,
OpGroupNonUniformShuffleUp = 347,
OpGroupNonUniformShuffleDown = 348,
OpGroupNonUniformIAdd = 349,
OpGroupNonUniformFAdd = 350,
OpGroupNonUniformIMul = 351,
OpGroupNonUniformFMul = 352,
OpGroupNonUniformSMin = 353,
OpGroupNonUniformUMin = 354,
OpGroupNonUniformFMin = 355,
OpGroupNonUniformSMax = 356,
OpGroupNonUniformUMax = 357,
OpGroupNonUniformFMax = 358,
OpGroupNonUniformBitwiseAnd = 359,
OpGroupNonUniformBitwiseOr = 360,
OpGroupNonUniformBitwiseXor = 361,
OpGroupNonUniformLogicalAnd = 362,
OpGroupNonUniformLogicalOr = 363,
OpGroupNonUniformLogicalXor = 364,
OpGroupNonUniformQuadBroadcast = 365,
OpGroupNonUniformQuadSwap = 366,
OpCopyLogical = 400,
OpPtrEqual = 401,
OpPtrNotEqual = 402,
OpPtrDiff = 403,
OpTerminateInvocation = 4416,
OpSubgroupBallotKHR = 4421,
OpSubgroupFirstInvocationKHR = 4422,
OpSubgroupAllKHR = 4428,
OpSubgroupAnyKHR = 4429,
OpSubgroupAllEqualKHR = 4430,
OpSubgroupReadInvocationKHR = 4432,
OpTraceRayKHR = 4445,
OpExecuteCallableKHR = 4446,
OpConvertUToAccelerationStructureKHR = 4447,
OpIgnoreIntersectionKHR = 4448,
OpTerminateRayKHR = 4449,
OpTypeRayQueryKHR = 4472,
OpRayQueryInitializeKHR = 4473,
OpRayQueryTerminateKHR = 4474,
OpRayQueryGenerateIntersectionKHR = 4475,
OpRayQueryConfirmIntersectionKHR = 4476,
OpRayQueryProceedKHR = 4477,
OpRayQueryGetIntersectionTypeKHR = 4479,
OpGroupIAddNonUniformAMD = 5000,
OpGroupFAddNonUniformAMD = 5001,
OpGroupFMinNonUniformAMD = 5002,
OpGroupUMinNonUniformAMD = 5003,
OpGroupSMinNonUniformAMD = 5004,
OpGroupFMaxNonUniformAMD = 5005,
OpGroupUMaxNonUniformAMD = 5006,
OpGroupSMaxNonUniformAMD = 5007,
OpFragmentMaskFetchAMD = 5011,
OpFragmentFetchAMD = 5012,
OpReadClockKHR = 5056,
OpImageSampleFootprintNV = 5283,
OpGroupNonUniformPartitionNV = 5296,
OpWritePackedPrimitiveIndices4x8NV = 5299,
OpReportIntersectionKHR = 5334,
OpReportIntersectionNV = 5334,
OpIgnoreIntersectionNV = 5335,
OpTerminateRayNV = 5336,
OpTraceNV = 5337,
OpTypeAccelerationStructureKHR = 5341,
OpTypeAccelerationStructureNV = 5341,
OpExecuteCallableNV = 5344,
OpTypeCooperativeMatrixNV = 5358,
OpCooperativeMatrixLoadNV = 5359,
OpCooperativeMatrixStoreNV = 5360,
OpCooperativeMatrixMulAddNV = 5361,
OpCooperativeMatrixLengthNV = 5362,
OpBeginInvocationInterlockEXT = 5364,
OpEndInvocationInterlockEXT = 5365,
OpDemoteToHelperInvocationEXT = 5380,
OpIsHelperInvocationEXT = 5381,
OpSubgroupShuffleINTEL = 5571,
OpSubgroupShuffleDownINTEL = 5572,
OpSubgroupShuffleUpINTEL = 5573,
OpSubgroupShuffleXorINTEL = 5574,
OpSubgroupBlockReadINTEL = 5575,
OpSubgroupBlockWriteINTEL = 5576,
OpSubgroupImageBlockReadINTEL = 5577,
OpSubgroupImageBlockWriteINTEL = 5578,
OpSubgroupImageMediaBlockReadINTEL = 5580,
OpSubgroupImageMediaBlockWriteINTEL = 5581,
OpUCountLeadingZerosINTEL = 5585,
OpUCountTrailingZerosINTEL = 5586,
OpAbsISubINTEL = 5587,
OpAbsUSubINTEL = 5588,
OpIAddSatINTEL = 5589,
OpUAddSatINTEL = 5590,
OpIAverageINTEL = 5591,
OpUAverageINTEL = 5592,
OpIAverageRoundedINTEL = 5593,
OpUAverageRoundedINTEL = 5594,
OpISubSatINTEL = 5595,
OpUSubSatINTEL = 5596,
OpIMul32x16INTEL = 5597,
OpUMul32x16INTEL = 5598,
OpConstFunctionPointerINTEL = 5600,
OpFunctionPointerCallINTEL = 5601,
OpAsmTargetINTEL = 5609,
OpAsmINTEL = 5610,
OpAsmCallINTEL = 5611,
OpAtomicFMinEXT = 5614,
OpAtomicFMaxEXT = 5615,
OpAssumeTrueKHR = 5630,
OpExpectKHR = 5631,
OpDecorateString = 5632,
OpDecorateStringGOOGLE = 5632,
OpMemberDecorateString = 5633,
OpMemberDecorateStringGOOGLE = 5633,
OpVmeImageINTEL = 5699,
OpTypeVmeImageINTEL = 5700,
OpTypeAvcImePayloadINTEL = 5701,
OpTypeAvcRefPayloadINTEL = 5702,
OpTypeAvcSicPayloadINTEL = 5703,
OpTypeAvcMcePayloadINTEL = 5704,
OpTypeAvcMceResultINTEL = 5705,
OpTypeAvcImeResultINTEL = 5706,
OpTypeAvcImeResultSingleReferenceStreamoutINTEL = 5707,
OpTypeAvcImeResultDualReferenceStreamoutINTEL = 5708,
OpTypeAvcImeSingleReferenceStreaminINTEL = 5709,
OpTypeAvcImeDualReferenceStreaminINTEL = 5710,
OpTypeAvcRefResultINTEL = 5711,
OpTypeAvcSicResultINTEL = 5712,
OpSubgroupAvcMceGetDefaultInterBaseMultiReferencePenaltyINTEL = 5713,
OpSubgroupAvcMceSetInterBaseMultiReferencePenaltyINTEL = 5714,
OpSubgroupAvcMceGetDefaultInterShapePenaltyINTEL = 5715,
OpSubgroupAvcMceSetInterShapePenaltyINTEL = 5716,
OpSubgroupAvcMceGetDefaultInterDirectionPenaltyINTEL = 5717,
OpSubgroupAvcMceSetInterDirectionPenaltyINTEL = 5718,
OpSubgroupAvcMceGetDefaultIntraLumaShapePenaltyINTEL = 5719,
OpSubgroupAvcMceGetDefaultInterMotionVectorCostTableINTEL = 5720,
OpSubgroupAvcMceGetDefaultHighPenaltyCostTableINTEL = 5721,
OpSubgroupAvcMceGetDefaultMediumPenaltyCostTableINTEL = 5722,
OpSubgroupAvcMceGetDefaultLowPenaltyCostTableINTEL = 5723,
OpSubgroupAvcMceSetMotionVectorCostFunctionINTEL = 5724,
OpSubgroupAvcMceGetDefaultIntraLumaModePenaltyINTEL = 5725,
OpSubgroupAvcMceGetDefaultNonDcLumaIntraPenaltyINTEL = 5726,
OpSubgroupAvcMceGetDefaultIntraChromaModeBasePenaltyINTEL = 5727,
OpSubgroupAvcMceSetAcOnlyHaarINTEL = 5728,
OpSubgroupAvcMceSetSourceInterlacedFieldPolarityINTEL = 5729,
OpSubgroupAvcMceSetSingleReferenceInterlacedFieldPolarityINTEL = 5730,
OpSubgroupAvcMceSetDualReferenceInterlacedFieldPolaritiesINTEL = 5731,
OpSubgroupAvcMceConvertToImePayloadINTEL = 5732,
OpSubgroupAvcMceConvertToImeResultINTEL = 5733,
OpSubgroupAvcMceConvertToRefPayloadINTEL = 5734,
OpSubgroupAvcMceConvertToRefResultINTEL = 5735,
OpSubgroupAvcMceConvertToSicPayloadINTEL = 5736,
OpSubgroupAvcMceConvertToSicResultINTEL = 5737,
OpSubgroupAvcMceGetMotionVectorsINTEL = 5738,
OpSubgroupAvcMceGetInterDistortionsINTEL = 5739,
OpSubgroupAvcMceGetBestInterDistortionsINTEL = 5740,
OpSubgroupAvcMceGetInterMajorShapeINTEL = 5741,
OpSubgroupAvcMceGetInterMinorShapeINTEL = 5742,
OpSubgroupAvcMceGetInterDirectionsINTEL = 5743,
OpSubgroupAvcMceGetInterMotionVectorCountINTEL = 5744,
OpSubgroupAvcMceGetInterReferenceIdsINTEL = 5745,
OpSubgroupAvcMceGetInterReferenceInterlacedFieldPolaritiesINTEL = 5746,
OpSubgroupAvcImeInitializeINTEL = 5747,
OpSubgroupAvcImeSetSingleReferenceINTEL = 5748,
OpSubgroupAvcImeSetDualReferenceINTEL = 5749,
OpSubgroupAvcImeRefWindowSizeINTEL = 5750,
OpSubgroupAvcImeAdjustRefOffsetINTEL = 5751,
OpSubgroupAvcImeConvertToMcePayloadINTEL = 5752,
OpSubgroupAvcImeSetMaxMotionVectorCountINTEL = 5753,
OpSubgroupAvcImeSetUnidirectionalMixDisableINTEL = 5754,
OpSubgroupAvcImeSetEarlySearchTerminationThresholdINTEL = 5755,
OpSubgroupAvcImeSetWeightedSadINTEL = 5756,
OpSubgroupAvcImeEvaluateWithSingleReferenceINTEL = 5757,
OpSubgroupAvcImeEvaluateWithDualReferenceINTEL = 5758,
OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminINTEL = 5759,
OpSubgroupAvcImeEvaluateWithDualReferenceStreaminINTEL = 5760,
OpSubgroupAvcImeEvaluateWithSingleReferenceStreamoutINTEL = 5761,
OpSubgroupAvcImeEvaluateWithDualReferenceStreamoutINTEL = 5762,
OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminoutINTEL = 5763,
OpSubgroupAvcImeEvaluateWithDualReferenceStreaminoutINTEL = 5764,
OpSubgroupAvcImeConvertToMceResultINTEL = 5765,
OpSubgroupAvcImeGetSingleReferenceStreaminINTEL = 5766,
OpSubgroupAvcImeGetDualReferenceStreaminINTEL = 5767,
OpSubgroupAvcImeStripSingleReferenceStreamoutINTEL = 5768,
OpSubgroupAvcImeStripDualReferenceStreamoutINTEL = 5769,
OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeMotionVectorsINTEL = 5770,
OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeDistortionsINTEL = 5771,
OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeReferenceIdsINTEL = 5772,
OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeMotionVectorsINTEL = 5773,
OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeDistortionsINTEL = 5774,
OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeReferenceIdsINTEL = 5775,
OpSubgroupAvcImeGetBorderReachedINTEL = 5776,
OpSubgroupAvcImeGetTruncatedSearchIndicationINTEL = 5777,
OpSubgroupAvcImeGetUnidirectionalEarlySearchTerminationINTEL = 5778,
OpSubgroupAvcImeGetWeightingPatternMinimumMotionVectorINTEL = 5779,
OpSubgroupAvcImeGetWeightingPatternMinimumDistortionINTEL = 5780,
OpSubgroupAvcFmeInitializeINTEL = 5781,
OpSubgroupAvcBmeInitializeINTEL = 5782,
OpSubgroupAvcRefConvertToMcePayloadINTEL = 5783,
OpSubgroupAvcRefSetBidirectionalMixDisableINTEL = 5784,
OpSubgroupAvcRefSetBilinearFilterEnableINTEL = 5785,
OpSubgroupAvcRefEvaluateWithSingleReferenceINTEL = 5786,
OpSubgroupAvcRefEvaluateWithDualReferenceINTEL = 5787,
OpSubgroupAvcRefEvaluateWithMultiReferenceINTEL = 5788,
OpSubgroupAvcRefEvaluateWithMultiReferenceInterlacedINTEL = 5789,
OpSubgroupAvcRefConvertToMceResultINTEL = 5790,
OpSubgroupAvcSicInitializeINTEL = 5791,
OpSubgroupAvcSicConfigureSkcINTEL = 5792,
OpSubgroupAvcSicConfigureIpeLumaINTEL = 5793,
OpSubgroupAvcSicConfigureIpeLumaChromaINTEL = 5794,
OpSubgroupAvcSicGetMotionVectorMaskINTEL = 5795,
OpSubgroupAvcSicConvertToMcePayloadINTEL = 5796,
OpSubgroupAvcSicSetIntraLumaShapePenaltyINTEL = 5797,
OpSubgroupAvcSicSetIntraLumaModeCostFunctionINTEL = 5798,
OpSubgroupAvcSicSetIntraChromaModeCostFunctionINTEL = 5799,
OpSubgroupAvcSicSetBilinearFilterEnableINTEL = 5800,
OpSubgroupAvcSicSetSkcForwardTransformEnableINTEL = 5801,
OpSubgroupAvcSicSetBlockBasedRawSkipSadINTEL = 5802,
OpSubgroupAvcSicEvaluateIpeINTEL = 5803,
OpSubgroupAvcSicEvaluateWithSingleReferenceINTEL = 5804,
OpSubgroupAvcSicEvaluateWithDualReferenceINTEL = 5805,
OpSubgroupAvcSicEvaluateWithMultiReferenceINTEL = 5806,
OpSubgroupAvcSicEvaluateWithMultiReferenceInterlacedINTEL = 5807,
OpSubgroupAvcSicConvertToMceResultINTEL = 5808,
OpSubgroupAvcSicGetIpeLumaShapeINTEL = 5809,
OpSubgroupAvcSicGetBestIpeLumaDistortionINTEL = 5810,
OpSubgroupAvcSicGetBestIpeChromaDistortionINTEL = 5811,
OpSubgroupAvcSicGetPackedIpeLumaModesINTEL = 5812,
OpSubgroupAvcSicGetIpeChromaModeINTEL = 5813,
OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL = 5814,
OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL = 5815,
OpSubgroupAvcSicGetInterRawSadsINTEL = 5816,
OpVariableLengthArrayINTEL = 5818,
OpSaveMemoryINTEL = 5819,
OpRestoreMemoryINTEL = 5820,
OpLoopControlINTEL = 5887,
OpPtrCastToCrossWorkgroupINTEL = 5934,
OpCrossWorkgroupCastToPtrINTEL = 5938,
OpReadPipeBlockingINTEL = 5946,
OpWritePipeBlockingINTEL = 5947,
OpFPGARegINTEL = 5949,
OpRayQueryGetRayTMinKHR = 6016,
OpRayQueryGetRayFlagsKHR = 6017,
OpRayQueryGetIntersectionTKHR = 6018,
OpRayQueryGetIntersectionInstanceCustomIndexKHR = 6019,
OpRayQueryGetIntersectionInstanceIdKHR = 6020,
OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR = 6021,
OpRayQueryGetIntersectionGeometryIndexKHR = 6022,
OpRayQueryGetIntersectionPrimitiveIndexKHR = 6023,
OpRayQueryGetIntersectionBarycentricsKHR = 6024,
OpRayQueryGetIntersectionFrontFaceKHR = 6025,
OpRayQueryGetIntersectionCandidateAABBOpaqueKHR = 6026,
OpRayQueryGetIntersectionObjectRayDirectionKHR = 6027,
OpRayQueryGetIntersectionObjectRayOriginKHR = 6028,
OpRayQueryGetWorldRayDirectionKHR = 6029,
OpRayQueryGetWorldRayOriginKHR = 6030,
OpRayQueryGetIntersectionObjectToWorldKHR = 6031,
OpRayQueryGetIntersectionWorldToObjectKHR = 6032,
OpAtomicFAddEXT = 6035,
OpTypeBufferSurfaceINTEL = 6086,
OpTypeStructContinuedINTEL = 6090,
OpConstantCompositeContinuedINTEL = 6091,
OpSpecConstantCompositeContinuedINTEL = 6092,
},
}
| mit |
Amadiro/debugUI | init.lua | 1 | 5792 |
--initialize EVERYTHING
local dpath = ...
if dpath == "." then dpath = "" else dpath = dpath .. "." end
debugUI = {windows = {}}
debugUI.loveframes = require(dpath .. "loveframes")
debugUI.windowPosition = 0
debugUI.getfield = function(f)
local v = _G -- start with the table of globals
for w in string.gfind(f, "[%w_]+") do
v = v[w]
end
return v
end
debugUI.setfield = function(f, v)
local t = _G -- start with the table of globals
for w, d in string.gfind(f, "([%w_]+)(.?)") do
if d == "." then -- not last field?
t[w] = t[w] or {} -- create table if absent
t = t[w] -- get the table
else -- last field
t[w] = v -- do the assignment
end
end
end
local opath = string.gsub(dpath,"%.","/")
local objectFiles = love.filesystem.getDirectoryItems(opath .. "objects")
for k, file in ipairs(objectFiles) do
local objectName = file:sub(1,file:len()-4)
debugUI[objectName] = love.filesystem.load(opath .. "objects/" .. file)();
end
debugUI.update = function(dt)
debugUI.loveframes.update(dt)
for i,v in ipairs(debugUI.windows) do
v:update()
end
end
debugUI.draw = function()
debugUI.loveframes.draw()
end
debugUI.hookCallbacks = function()
-- Hook into the love callback functions we need.
-- These variable names will show up in error traces,
-- so we need to make sure they are recognizable.
debugUI.hooked = {update = love.update,
draw = love.draw,
mousepressed = love.mousepressed,
mousereleased = love.mousereleased,
keypressed = love.keypressed,
keyreleased = love.keyreleased}
-- We wrap the users original functions, calling our
-- own callbacks afterwards. We need to check whether
-- any given function is defined before calling it, and
-- for future compatibility, we preserve parameters and
-- return values exactly.
love.update = function(...)
local ret
if debugUI.hooked.update then ret = debugUI.hooked.update(...) end
debugUI.update(...)
return ret
end
love.draw = function(...)
local ret
if debugUI.hooked.draw then ret = debugUI.hooked.draw(...) end
debugUI.draw(...)
return ret
end
love.mousepressed = function(...)
local ret
if debugUI.hooked.mousepressed then ret = debugUI.hooked.mousepressed(...) end
debugUI.mousepressed(...)
return ret
end
love.mousereleased = function(...)
local ret
if debugUI.hooked.mousereleased then ret = debugUI.hooked.mousereleased(...) end
debugUI.mousereleased(...)
return ret
end
love.keypressed = function(...)
local ret
if debugUI.hooked.keypressed then ret = debugUI.hooked.keypressed(...) end
debugUI.keypressed(...)
return ret
end
love.keyreleased = function(...)
local ret
if debugUI.hooked.keyreleased then ret = debugUI.hooked.keyreleased(...) end
debugUI.keyreleased(...)
return ret
end
end
debugUI.new = function(t)
local single = (type(t[1]) ~= "table")
local tabbed = (type(t[1]) == "table") and (type(t[1][1]) == "table")
local mainTable = {update = function(self) for i,v in ipairs(self) do v:update() end end}
local totalheight = 0
local wname = t.name
local maxheight = t.maxheight or 400
if single then
local debugObject = debugUI[t.type](t)
table.insert(mainTable,debugObject)
totalheight = debugObject.height
elseif tabbed then
subheights = {}
subnames = {}
for j,u in ipairs(t) do
local subTable = {update = function(self) for i,v in ipairs(self) do v:update() end end}
local subheight = 0
for i,v in ipairs(u) do
local debugObject = debugUI[v.type](v)
table.insert(subTable,debugObject)
subheight = subheight + debugObject.height
end
local name = u.name
mainTable[j] = subTable
subheights[j] = subheight
subnames[j] = name
end
totalheight = math.max(unpack(subheights))
else
for i,v in ipairs(t) do
local debugObject = debugUI[v.type](v)
table.insert(mainTable,debugObject)
totalheight = totalheight + debugObject.height
end
end
maxheight = math.min(maxheight,totalheight+45,love.graphics.getHeight())
local window = debugUI.loveframes.Create("frame")
if wname then window:SetName(wname) end
window:SetPos(debugUI.windowPosition,0)
window:SetSize(165,maxheight)
window.xpos = debugUI.windowPosition
debugUI.windowPosition = debugUI.windowPosition + 165
window.OnClose = function(object)
if object:GetY() > love.graphics.getHeight() - 25 then
object:SetPos(object.xpos,0)
else
object:SetPos(object.xpos,love.graphics.getHeight()-20)
end
return false
end
local tabs = nil
local loops = 1
if tabbed then
loops = #t
tabs = debugUI.loveframes.Create("tabs",window)
tabs:SetPos(0,25)
tabs:SetSize(165,maxheight-20)
tabs:SetPadding(0)
end
for j = 1,loops do
local horizontalsList = debugUI.loveframes.Create("list")
horizontalsList:SetDisplayType("vertical")
horizontalsList:SetSize(165,maxheight-45)
if tabbed then
tabs:AddTab(subnames[j] or ("Tab" ..j),horizontalsList)
else
horizontalsList:SetParent(window)
horizontalsList:SetPos(0,50)
end
local searchable = tabbed and mainTable[j] or mainTable
for i,debugObject in ipairs(searchable) do
local panel = debugObject:setup()
horizontalsList:AddItem(panel)
end
end
table.insert(debugUI.windows,mainTable)
return window
end
function debugUI.mousepressed(x, y, button)
debugUI.loveframes.mousepressed(x, y, button)
end
function debugUI.mousereleased(x, y, button)
debugUI.loveframes.mousereleased(x, y, button)
end
function debugUI.keypressed(key, unicode)
if key == "f12" then
for i,v in ipairs(debugUI.windows) do
end
end
debugUI.loveframes.keypressed(key, unicode)
end
function debugUI.keyreleased(key,unicode)
debugUI.loveframes.keyreleased(key)
end
| mit |
Oxygem/Oxycore | modules/admin/get/groups.lua | 1 | 1504 | -- Oxypanel Core/Admin
-- File: get/groups.lua
-- Desc: add/edit/list user groups
local template, database, request, user = oxy.template, luawa.database, luawa.request, luawa.user
--add group?
if request.get.action == 'add' then
if not user:checkPermission('AddUserGroup') then return template:error('You don\'t have permission to do that') end
return template:wrap('admin', 'groups/add')
--edit
elseif request.get.action == 'edit' then
if not user:checkPermission('EditUserGroup') then return template:error('You don\'t have permission to do that') end
if not request.get.id then return template:error('You must specify a group ID') end
--select group
local group, err = database:select('user_groups', '*', { id = request.get.id })
if err then return template:error(err) end
template:set('group', group[1])
return template:wrap('admin', 'groups/edit')
end
--default: list groups
--permission?
if not user:checkPermission('ViewUserGroup') then
return template:error('You don\'t have permission to do that')
end
--filters
local wheres = {}
if request.get.id then
wheres.id = request.get.id
end
local groups = database:select('user_groups', '*', wheres)
template:set('page_title', 'User Groups')
template:set('groups', groups)
if user:checkPermission('AddUserGroup') then
template:add('page_title_buttons', { { text = 'Add Group', link = '/admin/groups/add', class = 'admin' } })
end
--header+footer+template
template:wrap('admin', 'groups/list') | mit |
yetsky/extra | luci/applications/luci-ser2net/luasrc/model/cbi/ser2net.lua | 1 | 4954 | m = Map("ser2net", translate("Ser2net"),
translate("The ser2net allows telnet and tcp sessions to be established with a unit's serial ports.<br/>"))
function m.on_after_commit(self)
luci.sys.call("/etc/init.d/ser2net enable 1\>/dev/null 2\>/dev/null")
luci.sys.call("/etc/init.d/ser2net restart 1\>/dev/null 2\>/dev/null")
end
s = m:section(TypedSection, "proxy", translate("Proxies"),
translate("The program comes up normally as a service, opens the TCP ports specified in the configuration file, and waits for connections.<br/>Once a connection occurs, the program attempts to set up the connection and open the serial port.<br/>If another user is already using the connection or serial port, the connection is refused with an error message."))
s.anonymous = true
s.addremove = true
tcpport = s:option(Value, "tcpport", translate("TCP Port"),
translate("Name or number of the TCP/IP port to accept connections from for this device.<br/>A port number may be of the form [host,]port, such as 127.0.0.1,2000 or localhost,2000.<br/>If this is specified, it will only bind to the IP address specified for the port.<br/>Otherwise, it will bind to all the ports on the machine."))
tcpport.rmempty = false
tcpport.default = "127.0.0.1,8000"
state = s:option(Value, "state", translate("State"),
translate("Either raw or rawlp or telnet or off. off disables the port from accepting connections.<br/>It can be turned on later from the control port.<br/>raw enables the port and transfers all data as-is between the port and the long.<br/>rawlp enables the port and transfers all input data to device, device is open without any termios setting.<br/>It allow to use /dev/lpX devices and printers connected to them.<br/>telnet enables the port and runs the telnet protocol on the port to set up telnet parameters. This is most useful for using telnet."))
state.rmempty = false
state:value("raw", translate("Raw"))
state:value("rawlp", translate("Rawlp"))
state:value("telnet", translate("Telnet"))
state:value("off", translate("Off"))
state.default = "raw"
timeout = s:option(Value, "timeout", translate("Timeout"),
translate("The time (in seconds) before the port will be disconnected if there is no activity on it.<br/>A zero value disables this funciton."))
timeout.rmempty = false
timeout.default = "30"
device = s:option(Value, "device", translate("Device"),
translate("The name of the device to connect to.<br/>This must be in the form of /dev/<device>."))
device.rmempty = false
device.default = "/dev/ttyUSB0"
options = s:option(Value, "options", translate("Options"),
translate("Sets operational parameters for the serial port.<br/>Values may be separated by spaces or commas.<br/>Options 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 set the various baud rates. EVEN, ODD, NONE set the parity.<br/>1STOPBIT, 2STOPBITS set the number of stop bits.<br/>7DATABITS, 8DATABITS set the number of data bits. [-]XONXOFF turns on (- off) XON/XOFF support.<br/>[-]RTSCTS turns on (- off) hardware flow control.<br/>[-]LOCAL ignores (- checks) the modem control lines (DCD, DTR, etc.) [-]HANGUP_WHEN_DONE lowers (- does not lower) the modem control lines (DCD, DTR, etc.) when the connection closes.<br/>NOBREAK Disables automatic clearing of the break setting of the port.<br/>remctl allows remote control of the serial port parameters via RFC 2217.<br/><br/> the README for more info. <banner name> displays the given banner when a user connects to the port.<br/><br/>" ..
"tr=<filename> When the port is opened, open the given tracefile and store all data read from the physical device (and thus written to the user's TCP port) in the file. The actual filename is specified in the TRACEFILE directive. If the file already exists, it is appended.<br/> The file is closed when the port is closed.<br/><br/>" ..
"tw=<filename> Like tr, but traces data written to the device.<br/><br/>" ..
"tb=<filename> trace both read and written data to the same file.<br/>Note that this is independent of tr and tw, so you may be tracing read, write, and both to different files.<br/><br/>" ..
"banner name<br/>" ..
"A name for the banner; this may be used in the options of a port.<br/><br/>" ..
"banner text<br/>" ..
"The text to display as the banner. It takes escape sequences for substituting strings, see 'FILENAME AND BANNER FORMATTING' for details.<br/><br/>" ..
"tracefile name<br/>" ..
"A name for the tracefile, this is used in the tw, tr, and tb options of a port.<br/><br/>" ..
"tracefile<br/>" ..
"The file to send the trace into. Note that this takes escape sequences for substituting strings, see 'FILENAME AND BANNER FORMATTING' for details.<br/>Note that when using the time escape sequences, the time is read once at port startup, so if you use both tw and tr they will have the same date and time."))
options.rmempty = true
options.default = ""
return m
| gpl-2.0 |
otland/forgottenserver | data/lib/core/itemtype.lua | 5 | 3079 | function ItemType:isItemType()
return true
end
do
local slotBits = {
[CONST_SLOT_HEAD] = SLOTP_HEAD,
[CONST_SLOT_NECKLACE] = SLOTP_NECKLACE,
[CONST_SLOT_BACKPACK] = SLOTP_BACKPACK,
[CONST_SLOT_ARMOR] = SLOTP_ARMOR,
[CONST_SLOT_RIGHT] = SLOTP_RIGHT,
[CONST_SLOT_LEFT] = SLOTP_LEFT,
[CONST_SLOT_LEGS] = SLOTP_LEGS,
[CONST_SLOT_FEET] = SLOTP_FEET,
[CONST_SLOT_RING] = SLOTP_RING,
[CONST_SLOT_AMMO] = SLOTP_AMMO
}
function ItemType:usesSlot(slot)
return bit.band(self:getSlotPosition(), slotBits[slot] or 0) ~= 0
end
end
function ItemType:isHelmet()
return self:usesSlot(CONST_SLOT_HEAD)
end
function ItemType:isArmor()
return self:usesSlot(CONST_SLOT_ARMOR)
end
function ItemType:isLegs()
return self:usesSlot(CONST_SLOT_LEGS)
end
function ItemType:isBoots()
return self:usesSlot(CONST_SLOT_FEET)
end
local notWeapons = {WEAPON_NONE, WEAPON_SHIELD, WEAPON_AMMO}
function ItemType:isWeapon()
return not table.contains(notWeapons, self:getWeaponType())
end
function ItemType:isTwoHanded()
return bit.band(self:getSlotPosition(), SLOTP_TWO_HAND) ~= 0
end
function ItemType:isBow()
local ammoType = self:getAmmoType()
return self:getWeaponType() == WEAPON_DISTANCE and (ammoType == AMMO_ARROW or ammoType == AMMO_BOLT)
end
function ItemType:isMissile()
local ammoType = self:getAmmoType()
return self:getWeaponType() == WEAPON_DISTANCE and ammoType ~= AMMO_ARROW and ammoType ~= AMMO_BOLT
end
function ItemType:isQuiver()
return self:getWeaponType() == WEAPON_QUIVER
end
function ItemType:isWand()
return self:getWeaponType() == WEAPON_WAND
end
function ItemType:isShield()
return self:getWeaponType() == WEAPON_SHIELD
end
function ItemType:isBackpack()
return self:usesSlot(CONST_SLOT_BACKPACK)
end
function ItemType:isNecklace()
return self:usesSlot(CONST_SLOT_NECKLACE)
end
function ItemType:isRing()
return self:usesSlot(CONST_SLOT_RING)
end
function ItemType:isAmmo()
return self:getWeaponType() == WEAPON_AMMO
end
function ItemType:isTrinket()
return self:usesSlot(CONST_SLOT_AMMO) and self:getWeaponType() == WEAPON_NONE
end
function ItemType:isKey()
return self:getType() == ITEM_TYPE_KEY
end
function ItemType:isBed()
return self:getType() == ITEM_TYPE_BED
end
function ItemType:isSplash()
return self:getGroup() == ITEM_GROUP_SPLASH
end
function ItemType:isPodium()
return self:getGroup() == ITEM_GROUP_PODIUM
end
function ItemType:getWeaponString()
local weaponType = self:getWeaponType()
local weaponString = "unknown"
if weaponType == WEAPON_CLUB then
weaponString = "blunt instrument"
elseif weaponType == WEAPON_SWORD then
weaponString = "stabbing weapon"
elseif weaponType == WEAPON_AXE then
weaponString = "cutting weapon"
elseif weaponType == WEAPON_DISTANCE then
weaponString = self:isBow() and "firearm" or "missile"
elseif weaponType == WEAPON_WAND then
weaponString = "wand/rod"
elseif weaponType == WEAPON_QUIVER then
weaponString = "quiver"
end
if self:isTwoHanded() then
weaponString = string.format("%s, two-handed", weaponString)
end
return weaponString
end
| gpl-2.0 |
m-creations/openwrt | feeds/luci/applications/luci-app-ocserv/luasrc/controller/ocserv.lua | 11 | 1838 | -- Copyright 2014 Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
-- Licensed to the public under the Apache License 2.0.
module("luci.controller.ocserv", package.seeall)
function index()
if not nixio.fs.access("/etc/config/ocserv") then
return
end
local page
page = entry({"admin", "services", "ocserv"}, alias("admin", "services", "ocserv", "main"),
_("OpenConnect VPN"))
page.dependent = true
page = entry({"admin", "services", "ocserv", "main"},
cbi("ocserv/main"),
_("Server Settings"), 200)
page.dependent = true
page = entry({"admin", "services", "ocserv", "users"},
cbi("ocserv/users"),
_("User Settings"), 300)
page.dependent = true
entry({"admin", "services", "ocserv", "status"},
call("ocserv_status")).leaf = true
entry({"admin", "services", "ocserv", "disconnect"},
call("ocserv_disconnect")).leaf = true
end
function ocserv_status()
local ipt = io.popen("/usr/bin/occtl show users");
if ipt then
local fwd = { }
while true do
local ln = ipt:read("*l")
if not ln then break end
local id, user, group, vpn_ip, ip, device, time, cipher, status =
ln:match("^%s*(%d+)%s+([-_%w]+)%s+([%(%)%.%*-_%w]+)%s+([%:%.-_%w]+)%s+([%:%.-_%w]+)%s+([%:%.-_%w]+)%s+([%:%.-_%w]+)%s+([%(%)%:%.-_%w]+)%s+([%:%.-_%w]+).*")
if id then
fwd[#fwd+1] = {
id = id,
user = user,
group = group,
vpn_ip = vpn_ip,
ip = ip,
device = device,
time = time,
cipher = cipher,
status = status
}
end
end
ipt:close()
luci.http.prepare_content("application/json")
luci.http.write_json(fwd)
end
end
function ocserv_disconnect(num)
local idx = tonumber(num)
if idx and idx > 0 then
luci.sys.call("/usr/bin/occtl disconnect id %d" % idx)
luci.http.status(200, "OK")
return
end
luci.http.status(400, "Bad request")
end
| gpl-2.0 |
ferstar/openwrt-dreambox | feeds/luci/luci/luci/applications/luci-asterisk/luasrc/model/cbi/asterisk/trunk_sip.lua | 11 | 2607 | --[[
LuCI - Lua Configuration Interface
Copyright 2008 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: trunk_sip.lua 4274 2009-02-24 01:09:51Z jow $
]]--
local ast = require("luci.asterisk")
--
-- SIP trunk info
--
if arg[2] == "info" then
form = SimpleForm("asterisk", "SIP Trunk Information")
form.reset = false
form.submit = "Back to overview"
local info, keys = ast.sip.peer(arg[1])
local data = { }
for _, key in ipairs(keys) do
data[#data+1] = {
key = key,
val = type(info[key]) == "boolean"
and ( info[key] and "yes" or "no" )
or ( info[key] == nil or #info[key] == 0 )
and "(none)"
or tostring(info[key])
}
end
itbl = form:section(Table, data, "SIP Trunk %q" % arg[1])
itbl:option(DummyValue, "key", "Key")
itbl:option(DummyValue, "val", "Value")
function itbl.parse(...)
luci.http.redirect(
luci.dispatcher.build_url("admin", "asterisk", "trunks")
)
end
return form
--
-- SIP trunk config
--
elseif arg[1] then
cbimap = Map("asterisk", "Edit SIP Trunk")
peer = cbimap:section(NamedSection, arg[1])
peer.hidden = {
type = "peer",
qualify = "yes",
}
back = peer:option(DummyValue, "_overview", "Back to trunk overview")
back.value = ""
back.titleref = luci.dispatcher.build_url("admin", "asterisk", "trunks")
sipdomain = peer:option(Value, "host", "SIP Domain")
sipport = peer:option(Value, "port", "SIP Port")
function sipport.cfgvalue(...)
return AbstractValue.cfgvalue(...) or "5060"
end
username = peer:option(Value, "username", "Authorization ID")
password = peer:option(Value, "secret", "Authorization Password")
password.password = true
outboundproxy = peer:option(Value, "outboundproxy", "Outbound Proxy")
outboundport = peer:option(Value, "outboundproxyport", "Outbound Proxy Port")
register = peer:option(Flag, "register", "Register with peer")
register.enabled = "yes"
register.disabled = "no"
regext = peer:option(Value, "registerextension", "Extension to register (optional)")
regext:depends({register="1"})
didval = peer:option(ListValue, "_did", "Number of assigned DID numbers")
didval:value("", "(none)")
for i=1,24 do didval:value(i) end
dialplan = peer:option(ListValue, "context", "Dialplan Context")
dialplan:value(arg[1] .. "_inbound", "(default)")
cbimap.uci:foreach("asterisk", "dialplan",
function(s) dialplan:value(s['.name']) end)
return cbimap
end
| gpl-2.0 |
ziz/solarus | quests/zsdx/data/maps/map0019.lua | 1 | 1736 | ----------------------
-- Cake shop script --
----------------------
function event_map_started(destination_point_name)
if not has_obtained_bottle() or not sol.game.is_dungeon_finished(1) then
sol.map.shop_item_remove("apple_pie")
end
end
function has_talked_about_apples()
return sol.game.savegame_get_boolean(46)
end
function has_obtained_bottle()
return sol.game.savegame_get_boolean(32)
end
function event_hero_on_sensor(sensor_name)
if not has_obtained_bottle() and not has_talked_about_apples() then
sol.map.dialog_start("cake_shop.dont_leave")
end
end
function event_dialog_finished(first_message_id, answer)
if first_message_id == "cake_shop.dont_leave"
or first_message_id == "cake_shop.seller.ask_apples_again" then
sol.game.savegame_set_boolean(46, true)
if answer == 0 then
if sol.game.has_item("apples_counter") then
if sol.game.get_item_amount("apples_counter") >= 6 then
sol.map.dialog_start("cake_shop.thank_you")
sol.game.remove_item_amount("apples_counter", 6)
else
sol.map.dialog_start("cake_shop.not_enough_apples")
end
else
sol.map.dialog_start("cake_shop.no_apples")
end
end
elseif first_message_id == "cake_shop.thank_you" then
sol.map.treasure_give("bottle_1", 1, 32)
end
end
function event_npc_dialog(npc)
if npc == "seller" then
talk_to_seller()
end
end
function event_hero_interaction(entity_name)
if entity_name == "seller_talking_place" then
talk_to_seller()
end
end
function talk_to_seller()
if not has_talked_about_apples() or has_obtained_bottle() then
sol.map.dialog_start("cake_shop.seller.choose_item")
else
sol.map.dialog_start("cake_shop.seller.ask_apples_again")
end
end
| gpl-3.0 |
ferstar/openwrt-dreambox | feeds/luci/luci/luci/libs/web/luasrc/cbi/datatypes.lua | 3 | 4867 | --[[
LuCI - Configuration Bind Interface - Datatype Tests
(c) 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: datatypes.lua 7458 2011-09-04 12:07:43Z jow $
]]--
local fs = require "nixio.fs"
local ip = require "luci.ip"
local math = require "math"
local util = require "luci.util"
local tonumber, type = tonumber, type
module "luci.cbi.datatypes"
function bool(val)
if val == "1" or val == "yes" or val == "on" or val == "true" then
return true
elseif val == "0" or val == "no" or val == "off" or val == "false" then
return true
elseif val == "" or val == nil then
return true
end
return false
end
function uinteger(val)
local n = tonumber(val)
if n ~= nil and math.floor(n) == n and n >= 0 then
return true
end
return false
end
function integer(val)
local n = tonumber(val)
if n ~= nil and math.floor(n) == n then
return true
end
return false
end
function ufloat(val)
local n = tonumber(val)
return ( n ~= nil and n >= 0 )
end
function float(val)
return ( tonumber(val) ~= nil )
end
function ipaddr(val)
return ip4addr(val) or ip6addr(val)
end
function neg_ipaddr(v)
if type(v) == "string" then
v = v:gsub("^%s*!", "")
end
return v and ipaddr(v)
end
function ip4addr(val)
if val then
return ip.IPv4(val) and true or false
end
return false
end
function neg_ip4addr(v)
if type(v) == "string" then
v = v:gsub("^%s*!", "")
end
return v and ip4addr(v)
end
function ip4prefix(val)
val = tonumber(val)
return ( val and val >= 0 and val <= 32 )
end
function ip6addr(val)
if val then
return ip.IPv6(val) and true or false
end
return false
end
function ip6prefix(val)
val = tonumber(val)
return ( val and val >= 0 and val <= 128 )
end
function port(val)
val = tonumber(val)
return ( val and val >= 0 and val <= 65535 )
end
function portrange(val)
local p1, p2 = val:match("^(%d+)%-(%d+)$")
if p1 and p2 and port(p1) and port(p2) then
return true
else
return port(val)
end
end
function macaddr(val)
if val and val:match(
"^[a-fA-F0-9]+:[a-fA-F0-9]+:[a-fA-F0-9]+:" ..
"[a-fA-F0-9]+:[a-fA-F0-9]+:[a-fA-F0-9]+$"
) then
local parts = util.split( val, ":" )
for i = 1,6 do
parts[i] = tonumber( parts[i], 16 )
if parts[i] < 0 or parts[i] > 255 then
return false
end
end
return true
end
return false
end
function hostname(val)
if val and (#val < 254) and val.match(val, "^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$") then
return true
end
return false
end
function host(val)
return hostname(val) or ipaddr(val)
end
function wpakey(val)
if #val == 64 then
return (val:match("^[a-fA-F0-9]+$") ~= nil)
else
return (#val >= 8) and (#val <= 63)
end
end
function wepkey(val)
if val:sub(1, 2) == "s:" then
val = val:sub(3)
end
if (#val == 10) or (#val == 26) then
return (val:match("^[a-fA-F0-9]+$") ~= nil)
else
return (#val == 5) or (#val == 13)
end
end
function string(val)
return true -- Everything qualifies as valid string
end
function directory( val, seen )
local s = fs.stat(val)
seen = seen or { }
if s and not seen[s.ino] then
seen[s.ino] = true
if s.type == "dir" then
return true
elseif s.type == "lnk" then
return directory( fs.readlink(val), seen )
end
end
return false
end
function file( val, seen )
local s = fs.stat(val)
seen = seen or { }
if s and not seen[s.ino] then
seen[s.ino] = true
if s.type == "reg" then
return true
elseif s.type == "lnk" then
return file( fs.readlink(val), seen )
end
end
return false
end
function device( val, seen )
local s = fs.stat(val)
seen = seen or { }
if s and not seen[s.ino] then
seen[s.ino] = true
if s.type == "chr" or s.type == "blk" then
return true
elseif s.type == "lnk" then
return device( fs.readlink(val), seen )
end
end
return false
end
function uciname(val)
return (val:match("^[a-zA-Z0-9_]+$") ~= nil)
end
function neg_network_ip4addr(val)
if type(v) == "string" then
v = v:gsub("^%s*!", "")
return (uciname(v) or ip4addr(v))
end
end
function range(val, min, max)
val = tonumber(val)
min = tonumber(min)
max = tonumber(max)
if val ~= nil and min ~= nil and max ~= nil then
return ((val >= min) and (val <= max))
end
return false
end
function min(val, min)
val = tonumber(val)
min = tonumber(min)
if val ~= nil and min ~= nil then
return (val >= min)
end
return false
end
function max(val, max)
val = tonumber(val)
max = tonumber(max)
if val ~= nil and max ~= nil then
return (val <= max)
end
return false
end
function neg(val, what)
if what and type(_M[what]) == "function" then
return _M[what](val:gsub("^%s*!%s*", ""))
end
return false
end
| gpl-2.0 |
comitservice/nodmcu | lua_modules/ds3231/ds3231-web.lua | 84 | 1338 | require('ds3231')
port = 80
-- ESP-01 GPIO Mapping
gpio0, gpio2 = 3, 4
days = {
[1] = "Sunday",
[2] = "Monday",
[3] = "Tuesday",
[4] = "Wednesday",
[5] = "Thursday",
[6] = "Friday",
[7] = "Saturday"
}
months = {
[1] = "January",
[2] = "Febuary",
[3] = "March",
[4] = "April",
[5] = "May",
[6] = "June",
[7] = "July",
[8] = "August",
[9] = "September",
[10] = "October",
[11] = "November",
[12] = "December"
}
ds3231.init(gpio0, gpio2)
srv=net.createServer(net.TCP)
srv:listen(port,
function(conn)
second, minute, hour, day, date, month, year = ds3231.getTime()
prettyTime = string.format("%s, %s %s %s %s:%s:%s", days[day], date, months[month], year, hour, minute, second)
conn:send("HTTP/1.1 200 OK\nContent-Type: text/html\nRefresh: 5\n\n" ..
"<!DOCTYPE HTML>" ..
"<html><body>" ..
"<b>ESP8266</b></br>" ..
"Time and Date: " .. prettyTime .. "<br>" ..
"Node ChipID : " .. node.chipid() .. "<br>" ..
"Node MAC : " .. wifi.sta.getmac() .. "<br>" ..
"Node Heap : " .. node.heap() .. "<br>" ..
"Timer Ticks : " .. tmr.now() .. "<br>" ..
"</html></body>")
conn:on("sent",function(conn) conn:close() end)
end
) | mit |
pintor/lispy-lua | lisp.lua | 1 | 2146 | function parse(s)
return read_from_tokens(tokenize(s))
end
function tokenize(s)
s = s:gsub("%(", " ( ")
s = s:gsub("%)", " ) ")
t = {}
for w in s:gmatch("%S+") do table.insert(t, w) end
return t
end
function read_from_tokens(tokens)
if #tokens == 0 then
error('unexpected EOF while reading')
end
token = table.remove(tokens, 1)
if token == "(" then
l = {}
while tokens[1] ~= ')' do
table.insert(l, read_from_tokens(tokens))
end
table.remove(tokens, 1)
return l
elseif token == ')' then
error('Unexpected closing paren')
else
return atom(token)
end
end
function atom(token)
n = tonumber(token)
if not n then
return {content = token, type = "symbol"}
else
return n
end
end
function Env(o)
return {inner = {}, outer = o}
end
function Env_find(e, var)
if e['inner'][var] ~= nil then
return e
else
return Env_find(e['outer'], var)
end
end
function Procedure(params, body, env)
local e = Env(env)
return function (...)
for i = 1, #params do
e.inner[params[i]] = arg[i]
end
return eval(body, e)
end
end
function eval(x, env)
if type(x) ~= "table" then
return x
end
if x.type == "symbol" then
return Env_find(env, x.content).inner[x.content]
end
x[1] = x[1].content
if x[1] == "quote" then
table.remove(x, 1)
return x
elseif x[1] == "if" then
if eval(x[1], env) then
return eval(x[2], env)
else
return eval(x[3], env)
end
elseif x[1] == "define" then
local var = x[2].content
local exp = x[3]
env.inner[var] = eval(exp, env)
elseif x[1] == "set!" then
local var = x[2]
local exp = x[3]
Env_find(env, var).inner[var] = eval(exp, var)
elseif x[1] == "lambda" then
local params = x[2]
local body = x[3]
return Procedure(params, body, env)
else
local proc = eval(x[1], env)
local args = {}
for i = 2, #x do
table.insert(args, eval(x[i], env))
end
proc(unpack(args))
end
end
function repl()
io.write("> ")
local env = Env({})
while true do
local s = eval(parse(io.read()), env)
print(s)
io.write("> ")
end
end
repl()
| mit |
m-creations/openwrt | feeds/packages/net/smartsnmpd/files/mibs/interfaces.lua | 158 | 4833 | --
-- This file is part of SmartSNMP
-- Copyright (C) 2014, Credo Semiconductor Inc.
--
-- 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.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--
local mib = require "smartsnmp"
require "ubus"
require "uloop"
uloop.init()
local conn = ubus.connect()
if not conn then
error("Failed to connect to ubusd")
end
local if_cache = {}
local if_status_cache = {}
local if_index_cache = {}
local last_load_time = os.time()
local function need_to_reload()
if os.time() - last_load_time >= 3 then
last_load_time = os.time()
return true
else
return false
end
end
local function load_config()
if need_to_reload() == true then
if_cache = {}
if_status_cache = {}
if_index_cache = {}
-- if description
for k, v in pairs(conn:call("network.device", "status", {})) do
if_status_cache[k] = {}
end
for name_ in pairs(if_status_cache) do
for k, v in pairs(conn:call("network.device", "status", { name = name_ })) do
if k == 'mtu' then
if_status_cache[name_].mtu = v
elseif k == 'macaddr' then
if_status_cache[name_].macaddr = v
elseif k == 'up' then
if v == true then
if_status_cache[name_].up = 1
else
if_status_cache[name_].up = 2
end
elseif k == 'statistics' then
for item, stat in pairs(v) do
if item == 'rx_bytes' then
if_status_cache[name_].in_octet = stat
elseif item == 'tx_bytes' then
if_status_cache[name_].out_octet = stat
elseif item == 'rx_errors' then
if_status_cache[name_].in_errors = stat
elseif item == 'tx_errors' then
if_status_cache[name_].out_errors = stat
elseif item == 'rx_dropped' then
if_status_cache[name_].in_discards = stat
elseif item == 'tx_dropped' then
if_status_cache[name_].out_discards = stat
end
end
end
end
end
if_cache['desc'] = {}
for name, status in pairs(if_status_cache) do
table.insert(if_cache['desc'], name)
for k, v in pairs(status) do
if if_cache[k] == nil then if_cache[k] = {} end
table.insert(if_cache[k], v)
end
end
-- if index
for i in ipairs(if_cache['desc']) do
table.insert(if_index_cache, i)
end
end
end
mib.module_methods.or_table_reg("1.3.6.1.2.1.2", "The MIB module for managing Interfaces implementations")
local ifGroup = {
[1] = mib.ConstInt(function () load_config() return #if_index_cache end),
[2] = {
[1] = {
[1] = mib.ConstIndex(function () load_config() return if_index_cache end),
[2] = mib.ConstString(function (i) load_config() return if_cache['desc'][i] end),
[4] = mib.ConstInt(function (i) load_config() return if_cache['mtu'][i] end),
[6] = mib.ConstString(function (i) load_config() return if_cache['macaddr'][i] end),
[8] = mib.ConstInt(function (i) load_config() return if_cache['up'][i] end),
[10] = mib.ConstCount(function (i) load_config() return if_cache['in_octet'][i] end),
[13] = mib.ConstCount(function (i) load_config() return if_cache['in_discards'][i] end),
[14] = mib.ConstCount(function (i) load_config() return if_cache['in_errors'][i] end),
[16] = mib.ConstCount(function (i) load_config() return if_cache['out_octet'][i] end),
[19] = mib.ConstCount(function (i) load_config() return if_cache['out_discards'][i] end),
[20] = mib.ConstCount(function (i) load_config() return if_cache['out_errors'][i] end),
}
}
}
return ifGroup
| gpl-2.0 |
nekromant/aura-old | lua/init.lua | 1 | 2578 | require "lfs"
print("aura: Warming up lua environment");
function azra_gc()
before = collectgarbage("count");
collectgarbage();
after = collectgarbage("count");
echon("aura: Collecting garbage: "..before.."K -> "..after.."K");
--TODO: Call C function to clean up things
end
function azra_memusage()
after = collectgarbage("count");
echon("aura: Memory usage: "..after.."K");
end
-- Library byte-compiling routines
function check_lib(path,lib)
local lua = path..'/'..lib..".lua"
local luac = path..'/'..lib..".luac"
local attr = lfs.attributes (lua)
local attrc = lfs.attributes (luac)
assert (type(attr) == "table")
if type(attrc) ~= "table" or attr.change>attrc.change then
echon("compiling library "..path.."/"..lib.."...");
return os.execute("luac -o "..path.."/"..lib..".luac "..path.."/"..lib..".lua")
end
return 0
end
function libload(file)
if (config.bytecompile) then
local r = check_lib("lua/lib",file)
if (0~=r) then
echon("byte-compile failed, trying regular runfile");
runfile("lua/lib/"..file..".lua")
else
runfile("lua/lib/"..file..".luac")
end
else
runfile("lua/lib/"..file..".lua")
end
end
function echo(...)
io.stdout:write(...);
end
function echon(...)
echo(....."\n");
end
function runfile(file)
echon("loading: "..file);
dofile(file);
end
-- Gets called each time a client connects
function hook_login()
echon("Run help(); to get help. -- Cpt. Obvious");
end
function load_plugin(name)
for i,j in pairs(config.pluginpaths) do
if nil ~= do_aura_load_plugin(j.."lib"..name..".so") then
return true
end
end
print("Failed to load plugin: "..name);
end
runfile(configfile)
-- Now, let's load plugins, if any
print("Loading plugins")
for i,j in pairs(config.plugins) do
load_plugin(j)
end
function urpc_open(name, ...)
local node = { }
tr = __urpc_transports[name]
if nil == tr then
print("fatal: transport is not avaliable")
return nil;
end
node.__transport = tr;
node.__instance = __urpc_open(tr, ...);
if nil == node.__instance then
print("fatal: call to open the instance failed");
return nil
end
n = __urpc_discovery(node.__instance)
for i,j in pairs(n) do
if j['is_method'] then
node[j['name']] = function(...)
return __urpc_call(node.__instance, i-1, ...)
end
end
if j['is_event'] then
node[j['name']] = function(...)
print("Event "..j['name'].." occured")
print(unpack(arg))
end
end
end
return node
end
print("aura: environment ready");
| gpl-3.0 |
C3MA/WorldDominationSwitch | initTemplate.lua | 1 | 2094 | -- Tell the chip to connect to thi access point
wifi.setmode(wifi.STATION)
wifi.sta.setip({ip="10.23.42.22",netmask="255.255.254.0",gateway="10.23.42.1"})
wifi.sta.config("SSID","PASSWORD")
-- All global Variables
sollich=1
maintenanceMode=0
-- The Mqtt logic
m = mqtt.Client("ESP8266", 120, "user", "pass")
global_c=nil
function sleepnode()
if maintenanceMode==1 then
print("Maintenance Mode starting...")
s=net.createServer(net.TCP, 180)
s:listen(2323,function(c)
global_c=c
function s_output(str)
if(global_c~=nil)
then global_c:send(str)
end
end
node.output(s_output, 0)
c:on("receive",function(c,l)
node.input(l)
end)
c:on("disconnection",function(c)
node.output(nil)
global_c=nil
end)
print("Welcome to the Switch")
end)
else
print("Good Night")
v=node.readvdd33()
print(v)
tmr.alarm(4,400,0,function()
m:publish("/room/switch/voltage",v,0,0,node.dsleep(0))
end)
end
end
function mqttsubscribe()
tmr.alarm(1,50,0,function()
m:subscribe("/room/light/#",0, function(conn) print("subscribe /room/light success") end)
end)
end
m:on("connect", mqttsubscribe)
m:on("offline", function(con) print ("offline") end)
m:on("message", function(conn, topic, data)
if topic=="/room/light/workshop/state" and sollich==1 then
sollich=0
if data=="on" then
print("Es war An!")
m:publish("/room/light/workshop/command","off",0,0,sleepnode)
else
print("Es war Aus!")
m:publish("/room/light/workshop/command","on",0,0,sleepnode)
end
elseif topic=="/room/light/debug" then
if data=="enabled" then
maintenanceMode=1
end
end
end)
-- Wait to be connect to the WiFi access point.
tmr.alarm(0, 100, 1, function()
if wifi.sta.status() ~= 5 then
print("Connecting to AP...")
-- sleep, if no wifi after 10seconds runtime
if tmr.now() > 10000000 then
tmr.stop(0)
print("No Wifi - Damn - Good night")
sleepnode()
end
else
tmr.stop(0)
print('IP: ',wifi.sta.getip())
m:connect("10.23.42.10",1883,0)
end
end)
| gpl-2.0 |
xinjuncoding/skynet | service/cslave.lua | 19 | 6492 | local skynet = require "skynet"
local socket = require "socket"
require "skynet.manager" -- import skynet.launch, ...
local table = table
local slaves = {}
local connect_queue = {}
local globalname = {}
local queryname = {}
local harbor = {}
local harbor_service
local monitor = {}
local monitor_master_set = {}
local function read_package(fd)
local sz = socket.read(fd, 1)
assert(sz, "closed")
sz = string.byte(sz)
local content = assert(socket.read(fd, sz), "closed")
return skynet.unpack(content)
end
local function pack_package(...)
local message = skynet.packstring(...)
local size = #message
assert(size <= 255 , "too long")
return string.char(size) .. message
end
local function monitor_clear(id)
local v = monitor[id]
if v then
monitor[id] = nil
for _, v in ipairs(v) do
v(true)
end
end
end
local function connect_slave(slave_id, address)
local ok, err = pcall(function()
if slaves[slave_id] == nil then
local fd = assert(socket.open(address), "Can't connect to "..address)
skynet.error(string.format("Connect to harbor %d (fd=%d), %s", slave_id, fd, address))
slaves[slave_id] = fd
monitor_clear(slave_id)
socket.abandon(fd)
skynet.send(harbor_service, "harbor", string.format("S %d %d",fd,slave_id))
end
end)
if not ok then
skynet.error(err)
end
end
local function ready()
local queue = connect_queue
connect_queue = nil
for k,v in pairs(queue) do
connect_slave(k,v)
end
for name,address in pairs(globalname) do
skynet.redirect(harbor_service, address, "harbor", 0, "N " .. name)
end
end
local function response_name(name)
local address = globalname[name]
if queryname[name] then
local tmp = queryname[name]
queryname[name] = nil
for _,resp in ipairs(tmp) do
resp(true, address)
end
end
end
local function monitor_master(master_fd)
while true do
local ok, t, id_name, address = pcall(read_package,master_fd)
if ok then
if t == 'C' then
if connect_queue then
connect_queue[id_name] = address
else
connect_slave(id_name, address)
end
elseif t == 'N' then
globalname[id_name] = address
response_name(id_name)
if connect_queue == nil then
skynet.redirect(harbor_service, address, "harbor", 0, "N " .. id_name)
end
elseif t == 'D' then
local fd = slaves[id_name]
slaves[id_name] = false
if fd then
monitor_clear(id_name)
socket.close(fd)
end
end
else
skynet.error("Master disconnect")
for _, v in ipairs(monitor_master_set) do
v(true)
end
socket.close(master_fd)
break
end
end
end
local function accept_slave(fd)
socket.start(fd)
local id = socket.read(fd, 1)
if not id then
skynet.error(string.format("Connection (fd =%d) closed", fd))
socket.close(fd)
return
end
id = string.byte(id)
if slaves[id] ~= nil then
skynet.error(string.format("Slave %d exist (fd =%d)", id, fd))
socket.close(fd)
return
end
slaves[id] = fd
monitor_clear(id)
socket.abandon(fd)
skynet.error(string.format("Harbor %d connected (fd = %d)", id, fd))
skynet.send(harbor_service, "harbor", string.format("A %d %d", fd, id))
end
skynet.register_protocol {
name = "harbor",
id = skynet.PTYPE_HARBOR,
pack = function(...) return ... end,
unpack = skynet.tostring,
}
skynet.register_protocol {
name = "text",
id = skynet.PTYPE_TEXT,
pack = function(...) return ... end,
unpack = skynet.tostring,
}
local function monitor_harbor(master_fd)
return function(session, source, command)
local t = string.sub(command, 1, 1)
local arg = string.sub(command, 3)
if t == 'Q' then
-- query name
if globalname[arg] then
skynet.redirect(harbor_service, globalname[arg], "harbor", 0, "N " .. arg)
else
socket.write(master_fd, pack_package("Q", arg))
end
elseif t == 'D' then
-- harbor down
local id = tonumber(arg)
if slaves[id] then
monitor_clear(id)
end
slaves[id] = false
else
skynet.error("Unknown command ", command)
end
end
end
function harbor.REGISTER(fd, name, handle)
assert(globalname[name] == nil)
globalname[name] = handle
response_name(name)
socket.write(fd, pack_package("R", name, handle))
skynet.redirect(harbor_service, handle, "harbor", 0, "N " .. name)
end
function harbor.LINK(fd, id)
if slaves[id] then
if monitor[id] == nil then
monitor[id] = {}
end
table.insert(monitor[id], skynet.response())
else
skynet.ret()
end
end
function harbor.LINKMASTER()
table.insert(monitor_master_set, skynet.response())
end
function harbor.CONNECT(fd, id)
if not slaves[id] then
if monitor[id] == nil then
monitor[id] = {}
end
table.insert(monitor[id], skynet.response())
else
skynet.ret()
end
end
function harbor.QUERYNAME(fd, name)
if name:byte() == 46 then -- "." , local name
skynet.ret(skynet.pack(skynet.localname(name)))
return
end
local result = globalname[name]
if result then
skynet.ret(skynet.pack(result))
return
end
local queue = queryname[name]
if queue == nil then
socket.write(fd, pack_package("Q", name))
queue = { skynet.response() }
queryname[name] = queue
else
table.insert(queue, skynet.response())
end
end
skynet.start(function()
local master_addr = skynet.getenv "master"
local harbor_id = tonumber(skynet.getenv "harbor")
local slave_address = assert(skynet.getenv "address")
local slave_fd = socket.listen(slave_address)
skynet.error("slave connect to master " .. tostring(master_addr))
local master_fd = assert(socket.open(master_addr), "Can't connect to master")
skynet.dispatch("lua", function (_,_,command,...)
local f = assert(harbor[command])
f(master_fd, ...)
end)
skynet.dispatch("text", monitor_harbor(master_fd))
harbor_service = assert(skynet.launch("harbor", harbor_id, skynet.self()))
local hs_message = pack_package("H", harbor_id, slave_address)
socket.write(master_fd, hs_message)
local t, n = read_package(master_fd)
assert(t == "W" and type(n) == "number", "slave shakehand failed")
skynet.error(string.format("Waiting for %d harbors", n))
skynet.fork(monitor_master, master_fd)
if n > 0 then
local co = coroutine.running()
socket.start(slave_fd, function(fd, addr)
skynet.error(string.format("New connection (fd = %d, %s)",fd, addr))
if pcall(accept_slave,fd) then
local s = 0
for k,v in pairs(slaves) do
s = s + 1
end
if s >= n then
skynet.wakeup(co)
end
end
end)
skynet.wait()
end
socket.close(slave_fd)
skynet.error("Shakehand ready")
skynet.fork(ready)
end)
| mit |
Crazy-Duck/junglenational | game/dota_addons/junglenational/scripts/vscripts/libraries/playertables.lua | 1 | 13974 | PLAYERTABLES_VERSION = "0.90"
--[[
PlayerTables: Player-specific shared state/nettable Library by BMD
PlayerTables sets up a table that is shared between server (lua) and client (javascript) between specific (but changeable) clients.
It is very similar in concept to nettables, but is built on being player-specific state (not sent to all players).
Like nettables, PlayerTable state adjustments are mirrored to clients (that are currently subscribed).
If players disconnect and then reconnect, PlayerTables automatically transmits their subscribed table states to them when they connect.
PlayerTables only support sending numbers, strings, and tables of numbers/strings/tables to clients.
Installation
-"require" this file inside your code in order to gain access to the PlayerTables global table.
-Ensure that you have the playertables/playertables_base.js in your panorama content scripts folder.
-Ensure that playertables/playertables_base.js script is included in your custom_ui_manifest.xml with
<scripts>
<include src="file://{resources}/scripts/playertables/playertables_base.js" />
</scripts>
Library Usage
-Lua
-void PlayerTables:CreateTable(tableName, tableContents, pids)
Creates a new PlayerTable with the given name, default table contents, and automatically sets up a subscription
for all playerIDs in the "pids" object.
-void PlayerTables:DeleteTable(tableName)
Deletes a table by the given name, alerting any subscribed clients.
-bool PlayerTables:TableExists(tableName)
Returns whether a table currently exists with the given name
-void PlayerTables:SetPlayerSubscriptions(tableName, pids)
Clear and reset all player subscriptions based on the "pids" object.
-void PlayerTables:AddPlayerSubscription(tableName, pid)
Adds a subscription for the given player ID.
-void PlayerTables:RemovePlayerSubscription(tableName, pid)
Removes a subscription for the given player ID.
-<> PlayerTables:GetTableValue(tableName, key)
Returns the current value for this PlayerTable for the given "key", or nil if the key doesn't exist.
-<> PlayerTables:GetAllTableValues(tableName)
Returns the current keys and values for the given table.
-void PlayerTables:DeleteTableValue(tableName, key)
Delete a key from a playertable.
-void PlayerTables:DeleteTableValues(tableName, keys)
Delete the keys from a playertable given in the keys object.
-void PlayerTables:SetTableValue(tableName, key, value)
Set a value for the given key.
-void PlayerTables:SetTableValues(tableName, changes)
Set a all of the given key-value pairs in the changes object.
-Javascript: include the javascript API with "var PlayerTables = GameUI.CustomUIConfig().PlayerTables" at the top of your file.
-void PlayerTables.GetAllTableValues(tableName)
Returns the current keys and values of all keys within the table "tableName".
Returns null if no table exists with that name.
-void PlayerTables.GetTableValue(tableName, keyName)
Returns the current value for the key given by "keyName" if it exists on the table given by "tableName".
Returns null if no table exists, or undefined if the key does not exist.
-int PlayerTables.SubscribeNetTableListener(tableName, callback)
Sets up a callback for when this playertable is changed. The callback is of the form:
function(tableName, changesObject, deletionsObject).
changesObject contains the key-value pairs that were changed
deletionsObject contains the keys that were deleted.
If changesObject and deletionsObject are both null, then the entire table was deleted.
Returns an integer value representing this subscription.
-void PlayerTables.UnsubscribeNetTableListener(callbackID)
Remvoes the existing subscription as given by the callbackID (the integer returned from SubscribeNetTableListener)
Examples:
--Create a Table and set a few values.
PlayerTables:CreateTable("new_table", {initial="initial value"}, {0})
PlayerTables:SetTableValue("new_table", "count", 0)
PlayerTables:SetTableValues("new_table", {val1=1, val2=2})
--Change player subscriptions
PlayerTables:RemovePlayerSubscription("new_table", 0)
PlayerTables:SetPlayerSubscriptions("new_table", {[1]=true,[3]=true}) -- the pids object can be a map or array type table
--Retrieve values on the client
var PlayerTables = GameUI.CustomUIConfig().PlayerTables;
$.Msg(PlayerTables.GetTableVaue("new_table", "count"));
--Subscribe to changes on the client
var PlayerTables = GameUI.CustomUIConfig().PlayerTables;
PlayerTables.SubscribeNetTableListener("new_table", function(tableName, changes, deletions){
$.Msg(tableName + " changed: " + changes + " -- " + deletions);
});
]]
if not PlayerTables then
PlayerTables = class({})
end
function PlayerTables:start()
self.tables = {}
self.subscriptions = {}
CustomGameEventManager:RegisterListener("PlayerTables_Connected", Dynamic_Wrap(PlayerTables, "PlayerTables_Connected"))
end
function PlayerTables:equals(o1, o2, ignore_mt)
if o1 == o2 then return true end
local o1Type = type(o1)
local o2Type = type(o2)
if o1Type ~= o2Type then return false end
if o1Type ~= 'table' then return false end
if not ignore_mt then
local mt1 = getmetatable(o1)
if mt1 and mt1.__eq then
--compare using built in method
return o1 == o2
end
end
local keySet = {}
for key1, value1 in pairs(o1) do
local value2 = o2[key1]
if value2 == nil or self:equals(value1, value2, ignore_mt) == false then
return false
end
keySet[key1] = true
end
for key2, _ in pairs(o2) do
if not keySet[key2] then return false end
end
return true
end
function PlayerTables:copy(obj, seen)
if type(obj) ~= 'table' then return obj end
if seen and seen[obj] then return seen[obj] end
local s = seen or {}
local res = setmetatable({}, getmetatable(obj))
s[obj] = res
for k, v in pairs(obj) do res[self:copy(k, s)] = self:copy(v, s) end
return res
end
function PlayerTables:PlayerTables_Connected(args)
--print('PlayerTables_Connected')
--PrintTable(args)
local pid = args.pid
if not pid then
return
end
local player = PlayerResource:GetPlayer(pid)
--print('player: ', player)
for k,v in pairs(PlayerTables.subscriptions) do
if v[pid] then
if player then
CustomGameEventManager:Send_ServerToPlayer(player, "pt_fu", {name=k, table=PlayerTables.tables[k]} )
end
end
end
end
function PlayerTables:CreateTable(tableName, tableContents, pids)
tableContents = tableContents or {}
pids = pids or {}
if pids == true then
pids = {}
for i=0,DOTA_MAX_TEAM_PLAYERS-1 do
pids[#pids+1] = i
end
end
if self.tables[tableName] then
print("[playertables.lua] Warning: player table '" .. tableName .. "' already exists. Overriding.")
end
self.tables[tableName] = tableContents
self.subscriptions[tableName] = {}
for k,v in pairs(pids) do
local pid = k
if type(v) == "number" then
pid = v
end
if pid >= 0 and pid < DOTA_MAX_TEAM_PLAYERS then
self.subscriptions[tableName][pid] = true
local player = PlayerResource:GetPlayer(pid)
if player then
CustomGameEventManager:Send_ServerToPlayer(player, "pt_fu", {name=tableName, table=tableContents} )
end
else
print("[playertables.lua] Warning: Pid value '" .. pid .. "' is not an integer between [0," .. DOTA_MAX_TEAM_PLAYERS .. "]. Ignoring.")
end
end
end
function PlayerTables:DeleteTable(tableName)
if not self.tables[tableName] then
print("[playertables.lua] Warning: Table '" .. tableName .. "' does not exist.")
return
end
local table = self.tables[tableName]
local pids = self.subscriptions[tableName]
for k,v in pairs(pids) do
local player = PlayerResource:GetPlayer(k)
if player then
CustomGameEventManager:Send_ServerToPlayer(player, "pt_fu", {name=tableName, table=nil} )
end
end
self.tables[tableName] = nil
self.subscriptions[tableName] = nil
end
function PlayerTables:TableExists(tableName)
return self.tables[tableName] ~= nil
end
function PlayerTables:SetPlayerSubscriptions(tableName, pids)
if not self.tables[tableName] then
print("[playertables.lua] Warning: Table '" .. tableName .. "' does not exist.")
return
end
local table = self.tables[tableName]
local oldPids = self.subscriptions[tableName]
self.subscriptions[tableName] = {}
for k,v in pairs(pids) do
local pid = k
if type(v) == "number" then
pid = v
end
if pid >= 0 and pid < DOTA_MAX_TEAM_PLAYERS then
self.subscriptions[tableName][pid] = true
local player = PlayerResource:GetPlayer(pid)
if player and oldPids[pid] == nil then
CustomGameEventManager:Send_ServerToPlayer(player, "pt_fu", {name=tableName, table=table} )
end
else
print("[playertables.lua] Warning: Pid value '" .. pid .. "' is not an integer between [0," .. DOTA_MAX_TEAM_PLAYERS .. "]. Ignoring.")
end
end
end
function PlayerTables:AddPlayerSubscription(tableName, pid)
if not self.tables[tableName] then
print("[playertables.lua] Warning: Table '" .. tableName .. "' does not exist.")
return
end
local table = self.tables[tableName]
local oldPids = self.subscriptions[tableName]
if not oldPids[pid] then
if pid >= 0 and pid < DOTA_MAX_TEAM_PLAYERS then
self.subscriptions[tableName][pid] = true
local player = PlayerResource:GetPlayer(pid)
if player then
CustomGameEventManager:Send_ServerToPlayer(player, "pt_fu", {name=tableName, table=table} )
end
else
print("[playertables.lua] Warning: Pid value '" .. v .. "' is not an integer between [0," .. DOTA_MAX_TEAM_PLAYERS .. "]. Ignoring.")
end
end
end
function PlayerTables:RemovePlayerSubscription(tableName, pid)
if not self.tables[tableName] then
print("[playertables.lua] Warning: Table '" .. tableName .. "' does not exist.")
return
end
local table = self.tables[tableName]
local oldPids = self.subscriptions[tableName]
oldPids[pid] = nil
end
function PlayerTables:GetTableValue(tableName, key)
if not self.tables[tableName] then
print("[playertables.lua] Warning: Table '" .. tableName .. "' does not exist.")
return
end
local ret = self.tables[tableName][key]
if type(ret) == "table" then
return self:copy(ret)
end
return ret
end
function PlayerTables:GetAllTableValues(tableName)
if not self.tables[tableName] then
print("[playertables.lua] Warning: Table '" .. tableName .. "' does not exist.")
return
end
local ret = self.tables[tableName]
if type(ret) == "table" then
return self:copy(ret)
end
return ret
end
function PlayerTables:DeleteTableKey(tableName, key)
if not self.tables[tableName] then
print("[playertables.lua] Warning: Table '" .. tableName .. "' does not exist.")
return
end
local table = self.tables[tableName]
local pids = self.subscriptions[tableName]
if table[key] ~= nil then
table[key] = nil
for pid,v in pairs(pids) do
local player = PlayerResource:GetPlayer(pid)
if player then
CustomGameEventManager:Send_ServerToPlayer(player, "pt_kd", {name=tableName, keys={[key]=true}} )
end
end
end
end
function PlayerTables:DeleteTableKeys(tableName, keys)
if not self.tables[tableName] then
print("[playertables.lua] Warning: Table '" .. tableName .. "' does not exist.")
return
end
local table = self.tables[tableName]
local pids = self.subscriptions[tableName]
local deletions = {}
local notempty = false
for k,v in pairs(keys) do
if type(k) == "string" then
if table[k] ~= nil then
deletions[k] = true
table[k] = nil
notempty = true
end
elseif type(v) == "string" then
if table[v] ~= nil then
deletions[v] = true
table[v] = nil
notempty = true
end
end
end
if notempty then
for pid,v in pairs(pids) do
local player = PlayerResource:GetPlayer(pid)
if player then
CustomGameEventManager:Send_ServerToPlayer(player, "pt_kd", {name=tableName, keys=deletions} )
end
end
end
end
function PlayerTables:SetTableValue(tableName, key, value)
if value == nil then
self:DeleteTableKey(tableName, key)
return
end
if not self.tables[tableName] then
print("[playertables.lua] Warning: Table '" .. tableName .. "' does not exist.")
return
end
local table = self.tables[tableName]
local pids = self.subscriptions[tableName]
if not self:equals(table[key], value) then
table[key] = value
for pid,v in pairs(pids) do
local player = PlayerResource:GetPlayer(pid)
if player then
CustomGameEventManager:Send_ServerToPlayer(player, "pt_uk", {name=tableName, changes={[key]=value}} )
end
end
end
end
function PlayerTables:SetTableValues(tableName, changes)
if not self.tables[tableName] then
print("[playertables.lua] Warning: Table '" .. tableName .. "' does not exist.")
return
end
local table = self.tables[tableName]
local pids = self.subscriptions[tableName]
for k,v in pairs(changes) do
if self:equals(table[k], v) then
changes[k] = nil
else
table[k] = v
end
end
local notempty, _ = next(changes, nil)
if notempty then
for pid,v in pairs(pids) do
local player = PlayerResource:GetPlayer(pid)
if player then
CustomGameEventManager:Send_ServerToPlayer(player, "pt_uk", {name=tableName, changes=changes} )
end
end
end
end
if not PlayerTables.tables then PlayerTables:start() end
| mit |
justbennet/lua | 16.0.1.lua | 1 | 1358 | -- should go into a dir call intel somewhere on the MODULEPATH
local helpMsg = [[
Some help I am
]]
package.path = package.path .. ";./.Info/?.lua"
local Info = require("pkgInfo");
helpMsg = Info.helpMessage();
------------------------------------------------------------------------
-- Intel Compilers support
------------------------------------------------------------------------
help(helpMsg)
whatis("Name: Intel Compiler ")
whatis("Version: 16.0.0 ")
whatis("Category: compiler, runtime support ")
whatis("Description: Intel Compiler Family (C/C++/Fortran for x86_64) ")
whatis("URL: http://software.intel.com/en-us/articles/intel-compilers/ ")
local base = "/opt/apps/intel/16"
local full_xe = "composer_xe_2016.0.000"
local arch = "intel64"
local installDir = pathJoin(base,full_xe)
local mklRoot = pathJoin(installDir,"mkl")
whatis("Description: Intel Compiler Collection")
-- general
prepend_path('LD_LIBRARY_PATH', pathJoin(installDir,"compiler/lib",arch))
prepend_path('MIC_LD_LIBRARY_PATH', pathJoin(installDir,"compiler/lib",mic))
prepend_path('LIBRARY_PATH', pathJoin(installDir,"compiler/lib",arch))
prepend_path("INFOPATH", pathJoin(installDir,"debugger/gdb",arch,"/share/info"))
setenv( "INTEL_PYTHONHOME", pathJoin(installDir,"debugger/python",arch))
family("compiler")
| gpl-2.0 |
paulmarsy/Console | Libraries/nmap/App/nselib/ssh1.lua | 2 | 9096 | ---
-- Functions for the SSH-1 protocol. This module also contains functions for
-- formatting key fingerprints.
--
-- @author Sven Klemm <sven@c3d2.de>
-- @copyright Same as Nmap--See http://nmap.org/book/man-legal.html
local bin = require "bin"
local bit = require "bit"
local io = require "io"
local math = require "math"
local nmap = require "nmap"
local os = require "os"
local stdnse = require "stdnse"
local string = require "string"
local table = require "table"
local openssl = stdnse.silent_require "openssl"
_ENV = stdnse.module("ssh1", stdnse.seeall)
--- Retrieve the size of the packet that is being received
-- and checks if it is fully received
--
-- This function is very similar to the function generated
-- with match.numbytes(num) function, except that this one
-- will check for the number of bytes on-the-fly, based on
-- the written on the SSH packet.
--
-- @param buffer The receive buffer
-- @return packet_length, packet_length or nil
-- the return is similar to the lua function string:find()
check_packet_length = function( buffer )
if #buffer < 4 then return nil end
local payload_length, packet_length, offset
offset, payload_length = bin.unpack( ">I", buffer )
local padding = 8 - payload_length % 8
assert(payload_length)
local total = 4+payload_length+padding;
if total > #buffer then return nil end
return total, total;
end
--- Receives a complete SSH packet, even if fragmented
--
-- This function is an abstraction layer to deal with
-- checking the packet size to know if there is any more
-- data to receive.
--
-- @param socket The socket used to receive the data
-- @return status True or false
-- @return packet The packet received
receive_ssh_packet = function( socket )
local status, packet = socket:receive_buf(check_packet_length, true)
return status, packet
end
--- Fetch an SSH-1 host key.
-- @param host Nmap host table.
-- @param port Nmap port table.
-- @return A table with the following fields: <code>exp</code>,
-- <code>mod</code>, <code>bits</code>, <code>key_type</code>,
-- <code>fp_input</code>, <code>full_key</code>, <code>algorithm</code>, and
-- <code>fingerprint</code>.
fetch_host_key = function(host, port)
local socket = nmap.new_socket()
local status, _
status = socket:connect(host, port)
if not status then return end
-- fetch banner
status = socket:receive_lines(1)
if not status then socket:close(); return end
-- send our banner
status = socket:send("SSH-1.5-Nmap-SSH1-Hostkey\r\n")
if not status then socket:close(); return end
local data, packet_length, padding, offset
status,data = receive_ssh_packet( socket )
socket:close()
if not status then return end
offset, packet_length = bin.unpack( ">i", data )
padding = 8 - packet_length % 8
offset = offset + padding
if padding + packet_length + 4 == #data then
-- seems to be a proper SSH1 packet
local msg_code,host_key_bits,exp,mod,length,fp_input
offset, msg_code = bin.unpack( ">c", data, offset )
if msg_code == 2 then -- 2 => SSH_SMSG_PUBLIC_KEY
-- ignore cookie and server key bits
offset, _, _ = bin.unpack( ">A8i", data, offset )
-- skip server key exponent and modulus
offset, length = bin.unpack( ">S", data, offset )
offset = offset + math.ceil( length / 8 )
offset, length = bin.unpack( ">S", data, offset )
offset = offset + math.ceil( length / 8 )
offset, host_key_bits = bin.unpack( ">i", data, offset )
offset, length = bin.unpack( ">S", data, offset )
offset, exp = bin.unpack( ">A" .. math.ceil( length / 8 ), data, offset )
exp = openssl.bignum_bin2bn( exp )
offset, length = bin.unpack( ">S", data, offset )
offset, mod = bin.unpack( ">A" .. math.ceil( length / 8 ), data, offset )
mod = openssl.bignum_bin2bn( mod )
fp_input = mod:tobin()..exp:tobin()
return {exp=exp,mod=mod,bits=host_key_bits,key_type='rsa1',fp_input=fp_input,
full_key=('%d %s %s'):format(host_key_bits, exp:todec(), mod:todec()),
key=('%s %s'):format(exp:todec(), mod:todec()), algorithm="RSA1",
fingerprint=openssl.md5(fp_input)}
end
end
end
--- Format a key fingerprint in hexadecimal.
-- @param fingerprint Key fingerprint.
-- @param algorithm Key algorithm.
-- @param bits Key size in bits.
fingerprint_hex = function( fingerprint, algorithm, bits )
fingerprint = stdnse.tohex(fingerprint,{separator=":",group=2})
return ("%d %s (%s)"):format( bits, fingerprint, algorithm )
end
--- Format a key fingerprint in Bubble Babble.
-- @param fingerprint Key fingerprint.
-- @param algorithm Key algorithm.
-- @param bits Key size in bits.
fingerprint_bubblebabble = function( fingerprint, algorithm, bits )
local vowels = {'a','e','i','o','u','y'}
local consonants = {'b','c','d','f','g','h','k','l','m','n','p','r','s','t','v','z','x'}
local s = "x"
local seed = 1
for i=1,#fingerprint+2,2 do
local in1,in2,idx1,idx2,idx3,idx4,idx5
if i < #fingerprint or #fingerprint / 2 % 2 ~= 0 then
in1 = fingerprint:byte(i)
idx1 = (bit.band(bit.rshift(in1,6),3) + seed) % 6 + 1
idx2 = bit.band(bit.rshift(in1,2),15) + 1
idx3 = (bit.band(in1,3) + math.floor(seed/6)) % 6 + 1
s = s .. vowels[idx1] .. consonants[idx2] .. vowels[idx3]
if i < #fingerprint then
in2 = fingerprint:byte(i+1)
idx4 = bit.band(bit.rshift(in2,4),15) + 1
idx5 = bit.band(in2,15) + 1
s = s .. consonants[idx4] .. '-' .. consonants[idx5]
seed = (seed * 5 + in1 * 7 + in2) % 36
end
else
idx1 = seed % 6 + 1
idx2 = 16 + 1
idx3 = math.floor(seed/6) + 1
s = s .. vowels[idx1] .. consonants[idx2] .. vowels[idx3]
end
end
s = s .. 'x'
return ("%d %s (%s)"):format( bits, s, algorithm )
end
--- Format a key fingerprint into a visual ASCII art representation.
--
-- Ported from http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/usr.bin/ssh/key.c.
-- @param fingerprint Key fingerprint.
-- @param algorithm Key algorithm.
-- @param bits Key size in bits.
fingerprint_visual = function( fingerprint, algorithm, bits )
local i,j,field,characters,input,fieldsize_x,fieldsize_y,s
fieldsize_x, fieldsize_y = 17, 9
characters = {' ','.','o','+','=','*','B','O','X','@','%','&','#','/','^','S','E'}
-- initialize drawing area
field = {}
for i=1,fieldsize_x do
field[i]={}
for j=1,fieldsize_y do field[i][j]=1 end
end
-- we start in the center and mark it
local x, y = math.ceil(fieldsize_x/2), math.ceil(fieldsize_y/2)
field[x][y] = #characters - 1;
-- iterate over fingerprint
for i=1,#fingerprint do
input = fingerprint:byte(i)
-- each byte conveys four 2-bit move commands
for j=1,4 do
if bit.band( input, 1) == 1 then x = x + 1 else x = x - 1 end
if bit.band( input, 2) == 2 then y = y + 1 else y = y - 1 end
x = math.max(x,1); x = math.min(x,fieldsize_x)
y = math.max(y,1); y = math.min(y,fieldsize_y)
if field[x][y] < #characters - 2 then
field[x][y] = field[x][y] + 1
end
input = bit.rshift( input, 2 )
end
end
-- mark end point
field[x][y] = #characters;
-- build output
s = ('\n+--[%4s %4d]----+\n'):format( algorithm, bits )
for i=1,fieldsize_y do
s = s .. '|'
for j=1,fieldsize_x do s = s .. characters[ field[j][i] ] end
s = s .. '|\n'
end
s = s .. '+-----------------+\n'
return s
end
-- A lazy parsing function for known_hosts_file.
-- The script checks for the known_hosts file in this order:
--
-- (1) If known_hosts is specified in a script arg, use that. If turned
-- off (false), then don't do any known_hosts checking.
-- (2) Look at ~/.ssh/config to see if user known_hosts is in an
-- alternate location*. Look for "UserKnownHostsFile". If
-- UserKnownHostsFile is specified, open that known_hosts.
-- (3) Otherwise, open ~/.ssh/known_hosts.
parse_known_hosts_file = function(path)
local common_paths = {}
local f, knownhostspath
if path and io.open(path) then
knownhostspath = path
end
if not knownhostspath then
for l in io.lines(os.getenv("HOME") .. "/.ssh/config") do
if l and string.find(l, "UserKnownHostsFile") then
knownhostspath = string.match(l, "UserKnownHostsFile%s(.*)")
if string.sub(knownhostspath,1,1)=="~" then
knownhostspath = os.getenv("HOME") .. string.sub(knownhostspath, 2)
end
end
end
end
if not knownhostspath then
knownhostspath = os.getenv("HOME") .."/.ssh/known_hosts"
end
if not knownhostspath then
return
end
local known_host_entries = {}
local lnumber = 0
for l in io.lines(knownhostspath) do
lnumber = lnumber + 1
if l and string.sub(l, 1, 1) ~= "#" then
local parts = stdnse.strsplit(" ", l)
table.insert(known_host_entries, {entry=parts, linenumber=lnumber})
end
end
return known_host_entries
end
return _ENV;
| mit |
wan-qy/waifu2x | cleanup_model.lua | 34 | 1775 | require './lib/portable'
require './lib/LeakyReLU'
torch.setdefaulttensortype("torch.FloatTensor")
-- ref: https://github.com/torch/nn/issues/112#issuecomment-64427049
local function zeroDataSize(data)
if type(data) == 'table' then
for i = 1, #data do
data[i] = zeroDataSize(data[i])
end
elseif type(data) == 'userdata' then
data = torch.Tensor():typeAs(data)
end
return data
end
-- Resize the output, gradInput, etc temporary tensors to zero (so that the
-- on disk size is smaller)
local function cleanupModel(node)
if node.output ~= nil then
node.output = zeroDataSize(node.output)
end
if node.gradInput ~= nil then
node.gradInput = zeroDataSize(node.gradInput)
end
if node.finput ~= nil then
node.finput = zeroDataSize(node.finput)
end
if tostring(node) == "nn.LeakyReLU" then
if node.negative ~= nil then
node.negative = zeroDataSize(node.negative)
end
end
if tostring(node) == "nn.Dropout" then
if node.noise ~= nil then
node.noise = zeroDataSize(node.noise)
end
end
-- Recurse on nodes with 'modules'
if (node.modules ~= nil) then
if (type(node.modules) == 'table') then
for i = 1, #node.modules do
local child = node.modules[i]
cleanupModel(child)
end
end
end
collectgarbage()
end
local cmd = torch.CmdLine()
cmd:text()
cmd:text("cleanup model")
cmd:text("Options:")
cmd:option("-model", "./model.t7", 'path of model file')
cmd:option("-iformat", "binary", 'input format')
cmd:option("-oformat", "binary", 'output format')
local opt = cmd:parse(arg)
local model = torch.load(opt.model, opt.iformat)
if model then
cleanupModel(model)
torch.save(opt.model, model, opt.oformat)
else
error("model not found")
end
| mit |
rigeirani/sg1 | plugins/groupmanager.lua | 12 | 16925 | -- data saved to data/moderation.json
do
local function export_chat_link_cb(extra, success, result)
local msg = extra.msg
local data = extra.data
if success == 0 then
return send_large_msg(get_receiver(msg), 'Cannot generate invite link for this group.\nMake sure you are an admin or a sudoer.')
end
data[tostring(msg.to.id)]['link'] = result
save_data(_config.moderation.data, data)
return send_large_msg(get_receiver(msg),'Newest generated invite link for '..msg.to.title..' is:\n'..result)
end
local function set_group_photo(msg, success, result)
local data = load_data(_config.moderation.data)
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 (get_receiver(msg), 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(get_receiver(msg), 'Photo saved!', ok_cb, false)
else
print('Error downloading: '..msg.id)
send_large_msg(get_receiver(msg), 'Failed, please try again!', ok_cb, false)
end
end
local function get_description(msg, data)
local about = data[tostring(msg.to.id)]['description']
if not about then
return 'No description available.'
end
return string.gsub(msg.to.print_name, '_', ' ')..':\n\n'..about
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 is_chat_msg(msg) then
local data = load_data(_config.moderation.data)
-- create a group
if matches[1] == 'cgroup' and matches[2] and is_mod(msg) then
create_group_chat (msg.from.print_name, matches[2], ok_cb, false)
return 'Group '..string.gsub(matches[2], '_', ' ')..' has been created.'
-- add a group to be moderated
elseif matches[1] == 'addgp' and is_admin(msg) then
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 = 'yes',
lock_photo = 'no',
lock_member = 'no',
anti_flood = 'ban',
welcome = 'group',
sticker = 'ok',
}
}
save_data(_config.moderation.data, data)
return 'Group has been added.'
-- remove group from moderation
elseif matches[1] == 'remgp' and is_admin(msg) then
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
if msg.media and is_chat_msg(msg) and is_mod(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] and is_mod(msg) then
data[tostring(msg.to.id)]['description'] = matches[2]
save_data(_config.moderation.data, data)
return 'Set group description to:\n'..matches[2]
elseif matches[1] == 'about' then
return get_description(msg, data)
elseif matches[1] == 'setrules' and is_mod(msg) then
data[tostring(msg.to.id)]['rules'] = matches[2]
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..matches[2]
elseif matches[1] == 'rules' then
if not data[tostring(msg.to.id)]['rules'] then
return 'No rules available.'
end
local rules = data[tostring(msg.to.id)]['rules']
local rules = string.gsub(msg.to.print_name, '_', ' ')..' rules:\n\n'..rules
return rules
-- group link {get|set}
elseif matches[1] == 'link' then
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 does not exist.\nTry !link set to generate.'
end
elseif matches[2] == 'set' and is_mod(msg) then
msgr = export_chat_link(get_receiver(msg), export_chat_link_cb, {data=data, msg=msg})
end
elseif matches[1] == 'group' then
-- lock {bot|name|member|photo|sticker}
if matches[2] == 'lock' then
if matches[3] == 'bot' and is_mod(msg) then
if settings.lock_bots == 'yes' then
return 'Group is already locked from bots.'
else
settings.lock_bots = 'yes'
save_data(_config.moderation.data, data)
return 'Group is locked from bots.'
end
elseif matches[3] == 'name' and is_mod(msg) then
if settings.lock_name == 'yes' then
return 'Group name is already locked'
else
settings.lock_name = 'yes'
save_data(_config.moderation.data, data)
settings.set_name = string.gsub(msg.to.print_name, '_', ' ')
save_data(_config.moderation.data, data)
return 'Group name has been locked'
end
elseif matches[3] == 'member' and is_mod(msg) then
if settings.lock_member == 'yes' then
return 'Group members are already locked'
else
settings.lock_member = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group members has been locked'
elseif matches[3] == 'photo' and is_mod(msg) then
if settings.lock_photo == 'yes' then
return 'Group photo is already locked'
else
settings.set_photo = 'waiting'
save_data(_config.moderation.data, data)
end
return 'Please send me the group photo now'
end
-- unlock {bot|name|member|photo|sticker}
elseif matches[2] == 'unlock' then
if matches[3] == 'bot' and is_mod(msg) then
if settings.lock_bots == 'no' then
return 'Bots are allowed to enter group.'
else
settings.lock_bots = 'no'
save_data(_config.moderation.data, data)
return 'Group is open for bots.'
end
elseif matches[3] == 'name' and is_mod(msg) then
if settings.lock_name == 'no' then
return 'Group name is already unlocked'
else
settings.lock_name = 'no'
save_data(_config.moderation.data, data)
return 'Group name has been unlocked'
end
elseif matches[3] == 'member' and is_mod(msg) then
if settings.lock_member == 'no' then
return 'Group members are not locked'
else
settings.lock_member = 'no'
save_data(_config.moderation.data, data)
return 'Group members has been unlocked'
end
elseif matches[3] == 'photo' and is_mod(msg) then
if settings.lock_photo == 'no' then
return 'Group photo is not locked'
else
settings.lock_photo = 'no'
save_data(_config.moderation.data, data)
return 'Group photo has been unlocked'
end
end
-- view group settings
elseif matches[2] == 'settings' and is_mod(msg) then
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
antispam_state = '🔒'
elseif settings.anti_flood == 'no' then
antispam_state = '🔓'
end
if settings.welcome ~= 'no' then
greeting_state = '🔒'
elseif settings.welcome == 'no' then
greeting_state = '🔓'
end
if settings.sticker ~= 'ok' then
sticker_state = '🔒'
elseif settings.sticker == 'ok' then
sticker_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'..antispam_state..' Spam and Flood protection : '..settings.anti_flood
..'\n'..sticker_state..' Sticker policy : '..settings.sticker
..'\n'..greeting_state..' Welcome message : '..settings.welcome
return text
end
elseif matches[1] == 'sticker' then
if matches[2] == 'warn' then
if settings.sticker ~= 'warn' then
settings.sticker = 'warn'
save_data(_config.moderation.data, data)
end
return 'Stickers already prohibited.\n'
..'Sender will be warned first, then kicked for second violation.'
elseif matches[2] == 'kick' then
if settings.sticker ~= 'kick' then
settings.sticker = 'kick'
save_data(_config.moderation.data, data)
end
return 'Stickers already prohibited.\nSender will be kicked!'
elseif matches[2] == 'ok' then
if settings.sticker == 'ok' then
return 'Sticker restriction is not enabled.'
else
settings.sticker = 'ok'
save_data(_config.moderation.data, data)
return 'Sticker restriction has been disabled.'
end
end
-- if group name is renamed
elseif matches[1] == 'chat_rename' then
if not msg.service then
return 'Are you trying to troll me?'
end
if settings.lock_name == 'yes' then
if settings.set_name ~= tostring(msg.to.print_name) then
rename_chat(get_receiver(msg), settings.set_name, ok_cb, false)
end
elseif settings.lock_name == 'no' then
return nil
end
-- set group name
elseif matches[1] == 'setname' and is_mod(msg) then
settings.set_name = string.gsub(matches[2], '_', ' ')
save_data(_config.moderation.data, data)
rename_chat(get_receiver(msg), settings.set_name, ok_cb, false)
-- set group photo
elseif matches[1] == 'setphoto' and is_mod(msg) then
settings.set_photo = 'waiting'
save_data(_config.moderation.data, data)
return 'Please send me new group photo now'
-- if a user is added to group
elseif 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
if settings.lock_member == 'yes' then
chat_del_user(get_receiver(msg), user, ok_cb, true)
-- no APIs bot are allowed to enter chat group, except invited by mods.
elseif settings.lock_bots == 'yes' and msg.action.user.flags == 4352 and not is_mod(msg) then
chat_del_user(get_receiver(msg), user, ok_cb, true)
elseif settings.lock_bots == 'no' or settings.lock_member == 'no' then
return nil
end
-- if sticker is sent
elseif msg.media and msg.media.caption == 'sticker.webp' and not is_sudo(msg) then
local user_id = msg.from.id
local chat_id = msg.to.id
local sticker_hash = 'mer_sticker:'..chat_id..':'..user_id
local is_sticker_offender = redis:get(sticker_hash)
if settings.sticker == 'warn' then
if is_sticker_offender then
chat_del_user(get_receiver(msg), 'user#id'..user_id, ok_cb, true)
redis:del(sticker_hash)
return 'You have been warned to not sending sticker into this group!'
elseif not is_sticker_offender then
redis:set(sticker_hash, true)
return 'DO NOT send sticker into this group!\nThis is a WARNING, next time you will be kicked!'
end
elseif settings.sticker == 'kick' then
chat_del_user(get_receiver(msg), 'user#id'..user_id, ok_cb, true)
return 'DO NOT send sticker into this group!'
elseif settings.sticker == 'ok' then
return nil
end
-- if group photo is deleted
elseif matches[1] == 'chat_delete_photo' then
if not msg.service then
return 'Are you trying to troll me?'
end
if settings.lock_photo == 'yes' then
chat_set_photo (get_receiver(msg), settings.set_photo, ok_cb, false)
elseif settings.lock_photo == 'no' then
return nil
end
-- if group photo is changed
elseif matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then
if not msg.service then
return 'Are you trying to troll me?'
end
if settings.lock_photo == 'yes' then
chat_set_photo (get_receiver(msg), settings.set_photo, ok_cb, false)
elseif settings.lock_photo == 'no' then
return nil
end
end
end
else
print '>>> This is not a chat group.'
end
end
return {
description = 'Plugin to manage group chat.',
usage = {
admin = {
'!mkgroup <group_name> : Make/create a new group.',
'!addgroup : Add group to moderation list.',
'!remgroup : Remove group from moderation list.'
},
moderator = {
'!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 <set> : Generate/revoke invite link.',
'!setabout <description> : Set group description.',
'!setname <new_name> : Set group name.',
'!setphoto : Set group photo.',
'!setrules <rules> : Set group rules.',
'!sticker warn : Sticker restriction, sender will be warned for the first violation.',
'!sticker kick : Sticker restriction, sender will be kick.',
'!sticker ok : Disable sticker restriction.'
},
user = {
'!about : Read group description',
'!rules : Read group rules',
'!link <get> : Print invite link'
},
},
patterns = {
'^!(about)$',
'^!(addgp)$',
'%[(audio)%]',
'%[(document)%]',
'^!(group) (lock) (.*)$',
'^!(group) (settings)$',
'^!(group) (unlock) (.*)$',
'^!(link) (.*)$',
'^!(cgroup) (.*)$',
'%[(photo)%]',
'^!(remgp)$',
'^!(rules)$',
'^!(setabout) (.*)$',
'^!(setname) (.*)$',
'^!(setphoto)$',
'^!(setrules) (.*)$',
'^!(sticker) (.*)$',
'^!!tgservice (.+)$',
'%[(video)%]'
},
run = run,
pre_process = pre_process
}
end
| gpl-2.0 |
Murfalo/game-off-2016 | xl/SpritePiece.lua | 1 | 5645 | ----
-- xl/SpritePiece.lua
----
local Sprite = require "xl.Sprite"
local Scene = require "xl.Scene"
local anim8 = require "anim8"
local lume = lume
local WHITE = {255, 255, 255, 255}
local SpritePiece = Class.create("SpritePiece", Sprite)
function SpritePiece:init(image, frameWidth, frameHeight, border, z,name)
Sprite.init(self,image, frameWidth, frameHeight, border, z)
self.frameWidth = frameWidth
self.name = name
self.attachPoints = {}
self.attachPoints["default"] = {}
self.attachPoints["default"].offX = 0
self.attachPoints["default"].offY = 0
self.attachPoints["default"].attachF = 0
self.attachPoints["default"].start = 1
self.attachPoints["default"].attachMod = {{x=0,y=0}}
self.rootSprite = nil
self.ZangleType = "none"
self.priority = self.priority or 0
self.attachF = 0
self.modDepth = 0
self.offAngle = 0
self.currentAnim = "default"
self.attachX = self.attachX or self.ox
self.attachY = self.attachY or self.oy
self.dir = 1
self.mDir = 1
self.hubbub = "SpritePiece"
end
function SpritePiece:addPoint( name, px, py )
self.attachPoints[name] = {x = px, y = py,offX = 0,offY = 0,offAngle = 0,attachMod = {{x=0,y=0}},attachF = 1,start=1}
end
function SpritePiece:setZAngleType( ztype )
self.ZangleType = zType or "none"
end
function SpritePiece:updateAttach( updateTable )
if updateTable then
for i=1, #updateTable do
local pointTable = updateTable[i]
local pointID = pointTable[1]
if type(pointID) ~= "string" then
self.attachPoints["default"].attachMod = pointTable
self.attachPoints["default"].start = 1
self.attachPoints["default"].attachF = 0
else
self.attachPoints[pointID].attachMod = pointTable
--self.attachPoints[pointID].attachF = 1
self.attachPoints[pointID].start = 2
end
end
end
end
function SpritePiece:onUpdate( )
for key, value in pairs(self.attachPoints) do
value.attachF = self.index + value.start
if value.attachF > #value.attachMod then
value.attachF = value.start
end
if value.attachMod[value.attachF] then
value.offX = value.attachMod[value.attachF].x
value.offY = value.attachMod[value.attachF].y
local angle = value.attachMod[value.attachF].angle or 0
if self.dir == -1 and angle ~= 0 then
angle = 360 - angle
end
angle = angle/180
angle = angle * math.pi
value.offAngle = angle
value.modDepth = self.z
if value.attachMod[value.attachF].z then
value.modDepth = self.z + value.attachMod[value.attachF].z
end
else
value.offX = 0
value.offY = 0
value.offAngle = 0
end
end
-- local value = self.attachPoints["default"]
-- value.attachF = self.index + 1
-- if value.attachF > #value.attachMod then
-- value.attachF = value.start
-- end
-- value.offX = value.attachMod[value.attachF].x
-- value.offY = value.attachMod[value.attachF].y
if self.frozen then
self.priority = 3
end
end
function SpritePiece:freezeAnimation( dt )
self.frozen = dt
end
function SpritePiece:addConnectPoint( sprite, pointName ,selfPoint)
for key, mPoint in pairs(self.attachPoints) do
if key == selfPoint then
self.attachX = mPoint.x
self.attachY = mPoint.y
end
end
if self.attachPoints then
for key, point in pairs(sprite.attachPoints) do
if key == pointName then
self.rootSprite = sprite
self.rootPoint = pointName
break
end
end
end
end
function SpritePiece:updatePos(px,py,depth)
local currAttach = {}
if self.rootSprite then
local x = self.rootSprite.x
local y = self.rootSprite.y
local offX = self.rootSprite.attachPoints[self.rootPoint].offX
if offX == 0 then
offX = self.rootSprite.attachPoints["default"].offX
end
if self.rootSprite.dir == -1 then offX = offX - 1 end
local offY = self.rootSprite.attachPoints[self.rootPoint].offY
if offY == 0 then
offY =self.rootSprite.attachPoints["default"].offY
end
local xOffset = ((self.rootSprite.attachPoints[self.rootPoint].x/2) + offX )*self.rootSprite.dir
xOffset = xOffset - (((self.attachX)/2) *self.dir * self.mDir)--* self.dir)
local yOffset = (self.rootSprite.attachPoints[self.rootPoint].y/2) - offY - (self.attachY/2)
local newAngle = self.rootSprite.angle
x = x + math.floor((xOffset * math.cos(newAngle)) - (yOffset * math.sin(newAngle)))
y = y + math.floor((xOffset * math.sin(newAngle)) + (yOffset * math.cos(newAngle)))
self:setPosition(x,y)
local offAngle = self.rootSprite.attachPoints[self.rootPoint].offAngle
if offAngle == 0 then
offAngle = self.rootSprite.attachPoints["default"].offAngle or 0
end
newAngle = newAngle + offAngle
self:setAngle(newAngle)
local z = self.rootSprite.attachPoints[self.rootPoint].modDepth or self.z
Game.scene:move(self,z)
--self:setDepth(self.modDepth)
for k,v in pairs(self.attachPoints) do
if v.offX and v.offY then
if not currAttach[k] then currAttach[k] = {} end
-- lume.trace("X: ", (v.x * math.cos(newAngle)), "Y: ",(v.y * math.sin(newAngle)))
currAttach[k].x = x + offX --self.rootSprite.x
currAttach[k].y = y + offY --self.rootSprite.y
-- lume.trace("k: ", k , v.offX,v.offY)
-- currAttach[k].x =x + (v.x * math.cos(newAngle))
-- currAttach[k].y =y + (v.y * math.sin(newAngle))
-- currAttach[k].x = x
-- currAttach[k].y = y
end
end
else
self.z = (depth or self.z)
self:setDepth(self.z)
Game.scene:move(self,self.z);
self:setPosition(px,py - 4 - self.sizey/2)
for k,v in pairs(self.attachPoints) do
if v.x and v.y then
if not currAttach[k] then currAttach[k] = {} end
currAttach[k].x = px + v.x
currAttach[k].y = py + v.y
end
end
end
return currAttach
end
return SpritePiece
| mit |
topkecleon/otouto | otouto/bot.lua | 1 | 12959 | --[[
bot.lua
The heart and soul of otouto, i.e. the init and main loop.
Copyright 2016 topkecleon <drew@otou.to>
This code is licensed under the GNU AGPLv3. See /LICENSE for details.
]]--
local bot = {}
local bindings -- Bot API bindings.
local utilities -- Miscellaneous and shared functions.
local anise -- More utility functions.
local autils -- Administration-related functions.
bot.version = '4.0'
-- Function to be run on start and reload.
function bot:init()
assert(self.config.bot_api_key, 'You didn\'t set your bot token in config.lua!')
assert(self.config.admin, 'You didn\'t set your admin ID in config.lua!')
bindings = require('extern.bindings').set_token(self.config.bot_api_key)
utilities = require('otouto.utilities')
anise = require('anise')
autils = require('otouto.autils')
-- Fetch bot information. Try until it succeeds.
local success
repeat
io.write('Fetching bot information...\n')
success, self.info = bindings.getMe()
until success
self.info = self.info.result
io.write(string.format('%s [%s] @%s\n',
self.info.first_name, self.info.id, self.info.username))
-- todo: use a real database
self.database_name = self.config.database_name or self.info.username .. '.json'
if not self.database then
self.database = utilities.load_data(self.database_name)
end
-- Save the bot's version in the database to make migration simpler.
self.database.version = self.version
-- Database table to store user-specific information, such as nicknames or
-- API usernames.
if not self.database.userdata then
self.database.userdata = { hammered = {}, administrator = {} }
end
-- Database table to store disabled plugins for chats.
self.database.disabled_plugins = self.database.disabled_plugins or {}
if not self.database.groupdata then
self.database.groupdata = { admin = {} }
end
-- administration
self.database.administration = self.database.administration or {}
-- do_later stuff
self.database.later = self.database.later or {}
self.plugins = {}
self.named_plugins = {}
self:load_plugins(self.config.plugins)
-- Set loop variables.
self.last_update = self.last_update or 0 -- Update offset.
self.last_database_save = self.last_database_save or os.date('%H') -- Last db save.
self.is_started = true
end
function bot:load_plugins(pnames, pos)
local loaded = {}
local errors = {}
for _, pname in ipairs(pnames) do
local success, plugin = xpcall(function ()
return assert(require('otouto.plugins.'..pname), pname .. ' is falsy')
end, function (msg) return debug.traceback(msg) end)
if not success then
table.insert(errors, {pname, plugin})
else
if pos == nil then
table.insert(self.plugins, plugin)
else
table.insert(self.plugins, pos + 1, plugin)
end
table.insert(loaded, plugin)
self.named_plugins[pname] = plugin
plugin.name = pname
if plugin.init then plugin:init(self) end
if not plugin.triggers then plugin.triggers = {} end
end
end
if #errors > 0 then
local text = "Error(s) loading the following plugin(s):"
for _, error in ipairs(errors) do
text = text .. "\n" .. "=> " .. tostring(error[1]) .. "\n" .. tostring(error[2])
end
utilities.log_error(text, self.config.log_chat)
end
for _, plugin in ipairs(self.plugins) do
if plugin.on_plugins_load then
plugin:on_plugins_load(self, loaded)
end
end
end
function bot:unload_plugins(pnames)
local unloaded = {}
local not_found = {}
for _, pname in ipairs(pnames) do
local found = nil
for i, plugin in ipairs(self.plugins) do
if pname == plugin.name then
found = table.remove(self.plugins, i)
break
end
end
if found then
self.named_plugins[pname] = nil
table.insert(unloaded, found)
else
table.insert(not_found, pname)
end
end
if #not_found > 0 then
local text = "The following plugin(s) could not be found: " .. table.concat(not_found, ", ")
utilities.log_error(text, self.config.log_chat)
end
for _, plugin in ipairs(self.plugins) do
if plugin.on_plugins_unload then
plugin:on_plugins_unload(self, unloaded)
end
end
end
-- Function to be run on each new message.
function bot:on_message(msg)
-- Do not process old messages.
if msg.date < os.time() - 15 then return end
-- If no text, use captions. If neither, blank string.
if msg.caption then
msg.text = msg.caption
msg.entities = msg.caption_entities
elseif not msg.text then
msg.text = ''
end
if msg.reply_to_message then
if msg.reply_to_message.caption then
msg.reply_to_message.text = msg.reply_to_message.caption
msg.reply_to_message.entities = msg.reply_to_message.caption_entities
elseif not msg.reply_to_message.text then
msg.reply_to_message.text = ''
end
end
-- Support deep linking.
local payload = msg.text:match('^/start (.+)$')
if payload then
msg.text = self.config.cmd_pat .. payload
end
msg.text_lower = msg.text:lower()
local disabled_plugins = self.database.disabled_plugins[tostring(msg.chat.id)]
local user = utilities.user(self, msg.from.id)
local group
if msg.chat.type ~= 'private' then
group = utilities.group(self, msg.chat.id)
end
-- Do the thing.
for _, plugin in ipairs(self.plugins) do
if
(not (disabled_plugins and disabled_plugins[plugin.name])) and
((not plugin.administration or (group and group.data.admin))
and user:rank(self, msg.chat.id) >= (plugin.privilege or 0))
then
for _, trigger in ipairs(plugin.triggers) do
if string.match(msg.text_lower, trigger) then
local success, result = xpcall(function ()
return plugin:action(self, msg, group, user)
end, function (message) return debug.traceback(message) end)
if not success then
-- If the plugin has an error message, send it. If it does
-- not, use the generic one specified in config. If it's set
-- to false, do nothing.
if plugin.error then
utilities.send_reply(msg, plugin.error)
elseif plugin.error == nil then
utilities.send_reply(msg, self.config.errors.generic)
end
-- The message contents are included for debugging purposes.
utilities.log_error(result..'\n'..msg.text, self.config.log_chat)
return
-- Continue if the return value is 'continue'.
elseif result ~= 'continue' then
return
end
end
end
end
end
end
function bot:on_edit(msg)
if msg.edit_date < os.time() - 15 then return end
msg.text = msg.text or msg.caption or ''
if msg.reply_to_message then
msg.reply_to_message.text = msg.reply_to_message.text or msg.reply_to_message.caption or ''
end
msg.text_lower = msg.text:lower()
local user = utilities.user(self, msg.from.id)
local group
if msg.chat.type ~= 'private' then
group = utilities.group(self, msg.chat.id)
end
for _, plugin in ipairs(self.plugins) do
if
plugin.edit_action and
((not plugin.administration or (group and group.data.admin))
and user:rank(self, msg.chat.id) >= (plugin.privilege or 0))
then
for _, trigger in ipairs(plugin.triggers) do
if string.match(msg.text_lower, trigger) then
local success, result = xpcall(function ()
return plugin:edit_action(self, msg, group, user)
end, function (message) return debug.traceback(message) end)
if not success then
-- The message contents are included for debugging purposes.
utilities.log_error(result..'\n'..msg.text, self.config.log_chat)
return
-- Continue if the return value is true.
elseif result ~= true then
return
end
end
end
end
end
end
function bot:on_callback_query(query)
local msg = query.message
local user = utilities.user(self, query.from.id)
if query.data then
local pname = query.data:match('^%g+')
local p = self.named_plugins[pname]
if p and p.callback_action then
if p.privilege and p.privilege > user:rank(self, msg.chat.id) then
bindings.answerCallbackQuery{
callback_query_id = query.id,
text = 'You have insufficient privileges.'
}
else
local plugin = self.named_plugins[pname]
local success, result = xpcall(function()
return plugin:callback_action(self, query)
end, function(msg) return debug.traceback(msg) end)
if not success then
utilities.log_error(result..'\ncallback_action for '..pname,
self.config.log_chat)
end
end
return
end
bindings.answerCallbackQuery{
callback_query_id = query.id,
text = "Something went wrong! It's been noted."
}
utilities.log_error('Orphaned callback query: ' .. query.data,
self.config.log_chat)
elseif query.game_short_name then
-- to do
end
end
-- main
function bot:run()
self:init()
while self.is_started do
-- Update loop.
local success, result = bindings.getUpdates{
timeout = 5, -- change the global http/s timeout in utilities.lua
offset = self.last_update + 1,
allowed_updates = '["message","edited_message","callback_query"]'
}
if success then
-- Iterate over every new message.
for _,v in ipairs(result.result) do
self.last_update = v.update_id
if v.message then
self:on_message(v.message)
elseif v.edited_message then
self:on_edit(v.edited_message)
elseif v.callback_query then
self:on_callback_query(v.callback_query)
end
end
else
io.write('[' .. os.date('%F %T') .. '] Error while fetching updates.\n')
end
local now = os.time()
local delete_this = {}
for i, thing in ipairs(self.database.later) do
if now >= thing.when then
local plugin = self.named_plugins[thing.pname]
if plugin then
local suc, err = xpcall(function()
plugin:later(self, thing.param)
end, function(msg) return debug.traceback(msg) end)
if suc then
table.insert(delete_this, i)
else
utilities.log_error(err, self.config.log_chat)
end
else
table.insert(delete_this, i)
utilities.log_error(
'Later job discarded for missing plugin: '..thing.pname,
self.config.log_chat
)
end
end
end
for i = #delete_this, 1, -1 do
table.remove(self.database.later, delete_this[i])
end
-- Save the "database" every hour.
if self.last_database_save ~= os.date('%H') then
utilities.save_data(self.database_name, self.database)
self.last_database_save = os.date('%H')
end
end
-- Save the database before exiting.
utilities.save_data(self.database_name, self.database)
io.write('Halted.\n')
end
-- Schedule a plugin's later function to be run after the given interval.
-- "when" is a Unix timestamp.
function bot:do_later(pname, when, param)
table.insert(self.database.later, {
pname = pname,
when = when,
param = param
})
end
return bot
| agpl-3.0 |
gtaylormb/fpga_nes | sw/scripts/cpu_nop_hlt.lua | 3 | 7384 | ----------------------------------------------------------------------------------------------------
-- Script: cpu_nop_hlt.lua
-- Description: CPU test. Sanity test for NOP instructions, HLT instructions, and querying the PC.
----------------------------------------------------------------------------------------------------
dofile("../scripts/inc/nesdbg.lua")
local results = {}
local testTbl =
{
-- Test 1
{ code = { Ops.HLT },
pcOffset = 1 },
-- Test 2
{ code = { Ops.NOP, Ops.HLT },
pcOffset = 2 },
-- Test 3
{ code = { Ops.NOP, Ops.NOP, Ops.HLT },
pcOffset = 3 },
-- Test 4
{ code = { Ops.NOP, Ops.NOP, Ops.HLT, Ops.NOP, Ops.NOP },
pcOffset = 3 },
-- Test 5
{ code = { Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.HLT },
pcOffset = 8 },
-- Test 6
{ code = { Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.HLT,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP },
pcOffset = 8 },
-- Test 7
{ code = { Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.HLT,
Ops.HLT, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.HLT },
pcOffset = 48 },
-- Test 7
{ code = { Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP,
Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.NOP, Ops.HLT },
pcOffset = 456 },
}
for subTestIdx = 1, #testTbl do
local curTest = testTbl[subTestIdx]
local startPc = GetPc()
nesdbg.CpuMemWr(startPc, #curTest.code, curTest.code)
nesdbg.DbgRun()
nesdbg.WaitForHlt()
local endPc = GetPc()
if ((startPc + curTest.pcOffset) == endPc) then
results[subTestIdx] = ScriptResult.Pass
else
results[subTestIdx] = ScriptResult.Fail
end
ReportSubTestResult(subTestIdx, results[subTestIdx])
end
return ComputeOverallResult(results)
| bsd-2-clause |
deepak78/new-luci | applications/luci-app-ocserv/luasrc/model/cbi/ocserv/user-config.lua | 79 | 4831 | -- Copyright 2014 Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
-- Licensed to the public under the Apache License 2.0.
local fs = require "nixio.fs"
local has_ipv6 = fs.access("/proc/net/ipv6_route")
m = Map("ocserv", translate("OpenConnect VPN"))
s = m:section(TypedSection, "ocserv", "OpenConnect")
s.anonymous = true
s:tab("general", translate("General Settings"))
s:tab("ca", translate("CA certificate"))
s:tab("template", translate("Edit Template"))
local e = s:taboption("general", Flag, "enable", translate("Enable server"))
e.rmempty = false
e.default = "1"
function m.on_commit(map)
luci.sys.call("/usr/bin/occtl reload >/dev/null 2>&1")
end
function e.write(self, section, value)
if value == "0" then
luci.sys.call("/etc/init.d/ocserv stop >/dev/null 2>&1")
luci.sys.call("/etc/init.d/ocserv disable >/dev/null 2>&1")
else
luci.sys.call("/etc/init.d/ocserv enable >/dev/null 2>&1")
luci.sys.call("/etc/init.d/ocserv restart >/dev/null 2>&1")
end
Flag.write(self, section, value)
end
local o
o = s:taboption("general", ListValue, "auth", translate("User Authentication"),
translate("The authentication method for the users. The simplest is plain with a single username-password pair. Use PAM modules to authenticate using another server (e.g., LDAP, Radius)."))
o.rmempty = false
o.default = "plain"
o:value("plain")
o:value("PAM")
o = s:taboption("general", Value, "zone", translate("Firewall Zone"),
translate("The firewall zone that the VPN clients will be set to"))
o.nocreate = true
o.default = "lan"
o.template = "cbi/firewall_zonelist"
s:taboption("general", Value, "port", translate("Port"),
translate("The same UDP and TCP ports will be used"))
s:taboption("general", Value, "max_clients", translate("Max clients"))
s:taboption("general", Value, "max_same", translate("Max same clients"))
s:taboption("general", Value, "dpd", translate("Dead peer detection time (secs)"))
local pip = s:taboption("general", Flag, "predictable_ips", translate("Predictable IPs"),
translate("The assigned IPs will be selected deterministically"))
pip.default = "1"
local udp = s:taboption("general", Flag, "udp", translate("Enable UDP"),
translate("Enable UDP channel support; this must be enabled unless you know what you are doing"))
udp.default = "1"
local cisco = s:taboption("general", Flag, "cisco_compat", translate("AnyConnect client compatibility"),
translate("Enable support for CISCO AnyConnect clients"))
cisco.default = "1"
ipaddr = s:taboption("general", Value, "ipaddr", translate("VPN <abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Network-Address"))
ipaddr.default = "192.168.100.1"
ipaddr.datatype = "ip4addr"
nm = s:taboption("general", Value, "netmask", translate("VPN <abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask"))
nm.default = "255.255.255.0"
nm.datatype = "ip4addr"
nm:value("255.255.255.0")
nm:value("255.255.0.0")
nm:value("255.0.0.0")
if has_ipv6 then
ip6addr = s:taboption("general", Value, "ip6addr", translate("VPN <abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Network-Address"), translate("<abbr title=\"Classless Inter-Domain Routing\">CIDR</abbr>-Notation: address/prefix"))
end
tmpl = s:taboption("template", Value, "_tmpl",
translate("Edit the template that is used for generating the ocserv configuration."))
tmpl.template = "cbi/tvalue"
tmpl.rows = 20
function tmpl.cfgvalue(self, section)
return nixio.fs.readfile("/etc/ocserv/ocserv.conf.template")
end
function tmpl.write(self, section, value)
value = value:gsub("\r\n?", "\n")
nixio.fs.writefile("/etc/ocserv/ocserv.conf.template", value)
end
ca = s:taboption("ca", Value, "_ca",
translate("View the CA certificate used by this server. You will need to save it as 'ca.pem' and import it into the clients."))
ca.template = "cbi/tvalue"
ca.rows = 20
function ca.cfgvalue(self, section)
return nixio.fs.readfile("/etc/ocserv/ca.pem")
end
--[[DNS]]--
s = m:section(TypedSection, "dns", translate("DNS servers"),
translate("The DNS servers to be provided to clients; can be either IPv6 or IPv4"))
s.anonymous = true
s.addremove = true
s.template = "cbi/tblsection"
s:option(Value, "ip", translate("IP Address")).rmempty = true
s.datatype = "ipaddr"
--[[Routes]]--
s = m:section(TypedSection, "routes", translate("Routing table"),
translate("The routing table to be provided to clients; you can mix IPv4 and IPv6 routes, the server will send only the appropriate. Leave empty to set a default route"))
s.anonymous = true
s.addremove = true
s.template = "cbi/tblsection"
s:option(Value, "ip", translate("IP Address")).rmempty = true
s.datatype = "ipaddr"
o = s:option(Value, "netmask", translate("Netmask (or IPv6-prefix)"))
o.default = "255.255.255.0"
o:value("255.255.255.0")
o:value("255.255.0.0")
o:value("255.0.0.0")
return m
| apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.