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
AlexandreCA/update
scripts/zones/Windurst_Waters_[S]/npcs/Kopol-Rapol.lua
38
1051
----------------------------------- -- Area: Windurst Waters (S) -- NPC: Kopol-Rapol -- Type: Standard NPC -- @zone: 94 -- @pos 131.179 -6.75 172.758 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Windurst_Waters_[S]/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x01a6); 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
abbasgh12345/extremenewedit
plugins/stick.lua
2
2365
local lock = 1 local txt = "\n\nmaked by:@BeatBot_Team" --—-- shared by @BeatBot_Team local function callback(extra, success, result) --— Calback Bara Load Kardn ax if success then local file = 'sticker/sticker.webp' print('File downloaded to:', result) os.rename(result, file) print('File moved to:', file) else print('Error downloading: '..extra) end end —khob berim function run ro benvisim local function run(msg, matches) local file = 'sticker/sticker.webp' if msg.to.type == 'chat' then if matches[1]== "- stick" then if is_sudo(msg) then lock = 1 return "Sticker Maker Locked ! \nNow Only [Sudo,Admin,Owner]'s can Be Use it" else return "Only For Sudo !" end end if matches[1]== "+ stick" then if is_sudo(msg) then lock = 0 return "Sticker Maker Unlocked ! \nNow All Members can Be Use it" else return "Only For Sudo !" end end —------------------------------ if matches[1] == "sticker" then if lock == 0 then send_document(get_receiver(msg), "./"..file, ok_cb, false) return 'بصبر'..txt else if is_momod(msg) then send_document(get_receiver(msg), "./"..file, ok_cb, false) return 'بصبر '..txt end if not is_momod(msg) then return "Sticker Maker Is Locked For Members !"..txt end end end if matches[1] == "Sticker" then if lock == 0 then send_document(get_receiver(msg), "./"..file, ok_cb, false) return 'بصبر '..txt else if is_momod(msg) then send_document(get_receiver(msg), "./"..file, ok_cb, false) return 'بصبر '..txt end if not is_momod(msg) then return "Sticker Maker Is Locked For Members !"..txt end end end if matches[1] == "show sticker" or matches[1] == "Show sticker" then if lock == 1 then return 'Sticker Maker : Lock' else return 'Sticker Maker : Unlock' end end if msg.media then if msg.media.type == 'photo' then load_photo(msg.id, callback, msg.id) if lock == 0 then return 'Photo Saved ! \nFor Get This Photo Sticker Type Sticker And Send To Me'..txt else return '' end end end else return 'Sticker Make Only Work In My Groups !'..text end end return { patterns = { "^[Ss]ticker$", "^[Ss]how sticker$", "^- stick$", "^+ stick$", '%[(photo)%]' }, run = run } --—tnx-- to @xx_mersad_xx
gpl-2.0
zhoukk/skynet
lualib/sproto.lua
19
5654
local core = require "sproto.core" local assert = assert local sproto = {} local host = {} local weak_mt = { __mode = "kv" } local sproto_mt = { __index = sproto } local sproto_nogc = { __index = sproto } local host_mt = { __index = host } function sproto_mt:__gc() core.deleteproto(self.__cobj) end function sproto.new(bin) local cobj = assert(core.newproto(bin)) local self = { __cobj = cobj, __tcache = setmetatable( {} , weak_mt ), __pcache = setmetatable( {} , weak_mt ), } return setmetatable(self, sproto_mt) end function sproto.sharenew(cobj) local self = { __cobj = cobj, __tcache = setmetatable( {} , weak_mt ), __pcache = setmetatable( {} , weak_mt ), } return setmetatable(self, sproto_nogc) end function sproto.parse(ptext) local parser = require "sprotoparser" local pbin = parser.parse(ptext) return sproto.new(pbin) end function sproto:host( packagename ) packagename = packagename or "package" local obj = { __proto = self, __package = assert(core.querytype(self.__cobj, packagename), "type package not found"), __session = {}, } return setmetatable(obj, host_mt) end local function querytype(self, typename) local v = self.__tcache[typename] if not v then v = assert(core.querytype(self.__cobj, typename), "type not found") self.__tcache[typename] = v end return v end function sproto:exist_type(typename) local v = self.__tcache[typename] if not v then return core.querytype(self.__cobj, typename) ~= nil else return true end end function sproto:encode(typename, tbl) local st = querytype(self, typename) return core.encode(st, tbl) end function sproto:decode(typename, ...) local st = querytype(self, typename) return core.decode(st, ...) end function sproto:pencode(typename, tbl) local st = querytype(self, typename) return core.pack(core.encode(st, tbl)) end function sproto:pdecode(typename, ...) local st = querytype(self, typename) return core.decode(st, core.unpack(...)) end local function queryproto(self, pname) local v = self.__pcache[pname] if not v then local tag, req, resp = core.protocol(self.__cobj, pname) assert(tag, pname .. " not found") if tonumber(pname) then pname, tag = tag, pname end v = { request = req, response =resp, name = pname, tag = tag, } self.__pcache[pname] = v self.__pcache[tag] = v end return v end function sproto:exist_proto(pname) local v = self.__pcache[pname] if not v then return core.protocol(self.__cobj, pname) ~= nil else return true end end function sproto:request_encode(protoname, tbl) local p = queryproto(self, protoname) local request = p.request if request then return core.encode(request,tbl) , p.tag else return "" , p.tag end end function sproto:response_encode(protoname, tbl) local p = queryproto(self, protoname) local response = p.response if response then return core.encode(response,tbl) else return "" end end function sproto:request_decode(protoname, ...) local p = queryproto(self, protoname) local request = p.request if request then return core.decode(request,...) , p.name else return nil, p.name end end function sproto:response_decode(protoname, ...) local p = queryproto(self, protoname) local response = p.response if response then return core.decode(response,...) end end sproto.pack = core.pack sproto.unpack = core.unpack function sproto:default(typename, type) if type == nil then return core.default(querytype(self, typename)) else local p = queryproto(self, typename) if type == "REQUEST" then if p.request then return core.default(p.request) end elseif type == "RESPONSE" then if p.response then return core.default(p.response) end else error "Invalid type" end end end local header_tmp = {} local function gen_response(self, response, session) return function(args, ud) header_tmp.type = nil header_tmp.session = session header_tmp.ud = ud local header = core.encode(self.__package, header_tmp) if response then local content = core.encode(response, args) return core.pack(header .. content) else return core.pack(header) end end end function host:dispatch(...) local bin = core.unpack(...) header_tmp.type = nil header_tmp.session = nil header_tmp.ud = nil local header, size = core.decode(self.__package, bin, header_tmp) local content = bin:sub(size + 1) if header.type then -- request local proto = queryproto(self.__proto, header.type) local result if proto.request then result = core.decode(proto.request, content) end if header_tmp.session then return "REQUEST", proto.name, result, gen_response(self, proto.response, header_tmp.session), header.ud else return "REQUEST", proto.name, result, nil, header.ud end else -- response local session = assert(header_tmp.session, "session not found") local response = assert(self.__session[session], "Unknown session") self.__session[session] = nil if response == true then return "RESPONSE", session, nil, header.ud else local result = core.decode(response, content) return "RESPONSE", session, result, header.ud end end end function host:attach(sp) return function(name, args, session, ud) local proto = queryproto(sp, name) header_tmp.type = proto.tag header_tmp.session = session header_tmp.ud = ud local header = core.encode(self.__package, header_tmp) if session then self.__session[session] = proto.response or true end if args then local content = core.encode(proto.request, args) return core.pack(header .. content) else return core.pack(header) end end end return sproto
mit
AlexandreCA/darkstar
scripts/globals/spells/hydrohelix.lua
26
1690
-------------------------------------- -- Spell: Hydrohelix -- Deals water damage that gradually reduces -- a target's HP. Damage dealt is greatly affected by the weather. -------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) -- get helix acc/att merits local merit = caster:getMerit(MERIT_HELIX_MAGIC_ACC_ATT); -- calculate raw damage local dmg = calculateMagicDamage(35,1,caster,spell,target,ELEMENTAL_MAGIC_SKILL,MOD_INT,false); dmg = dmg + caster:getMod(MOD_HELIX_EFFECT); -- get resist multiplier (1x if no resist) local resist = applyResistance(caster,spell,target,caster:getStat(MOD_INT)-target:getStat(MOD_INT),ELEMENTAL_MAGIC_SKILL,merit*3); -- get the resisted damage dmg = dmg*resist; -- add on bonuses (staff/day/weather/jas/mab/etc all go in this function) dmg = addBonuses(caster,spell,target,dmg,merit*2); -- add in target adjustment dmg = adjustForTarget(target,dmg,spell:getElement()); local dot = dmg; -- add in final adjustments dmg = finalMagicAdjustments(caster,target,spell,dmg); -- calculate Damage over time dot = target:magicDmgTaken(dot); local duration = getHelixDuration(caster) + caster:getMod(MOD_HELIX_DURATION); duration = duration * (resist/2); if (dot > 0) then target:addStatusEffect(EFFECT_HELIX,dot,3,duration); end; return dmg; end;
gpl-3.0
AlexandreCA/update
scripts/zones/Al_Zahbi/npcs/Yudi_Yolhbi.lua
53
2326
----------------------------------- -- Area: Al Zahbi -- NPC: Yudi Yolhbi -- Type: Woodworking Normal/Adv. Image Support -- @pos -71.584 -7 -56.018 48 ----------------------------------- package.loaded["scripts/zones/Al_Zahbi/TextIDs"] = nil; ----------------------------------- require("scripts/globals/status"); require("scripts/globals/crafting"); require("scripts/zones/Al_Zahbi/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local guildMember = isGuildMember(player,9); if (guildMember == 1) then if (trade:hasItemQty(2184,1) and trade:getItemCount() == 1) then if (player:hasStatusEffect(EFFECT_WOODWORKING_IMAGERY) == false) then player:tradeComplete(); player:startEvent(0x00EB,8,0,0,0,188,0,1,0); else npc:showText(npc, IMAGE_SUPPORT_ACTIVE); end end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local guildMember = isGuildMember(player,9); local SkillLevel = player:getSkillLevel(SKILL_WOODWORKING); if (guildMember == 1) then if (player:hasStatusEffect(EFFECT_WOODWORKING_IMAGERY) == false) then player:startEvent(0x00EA,8,SkillLevel,0,511,188,0,1,2184); else player:startEvent(0x00EA,8,SkillLevel,0,511,188,7055,1,2184); end else player:startEvent(0x00EA,0,0,0,0,0,0,1,0); -- Standard Dialogue 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 == 0x00EA and option == 1) then player:messageSpecial(IMAGE_SUPPORT,0,1,1); player:addStatusEffect(EFFECT_WOODWORKING_IMAGERY,1,0,120); elseif (csid == 0x00EB) then player:messageSpecial(IMAGE_SUPPORT,0,1,0); player:addStatusEffect(EFFECT_WOODWORKING_IMAGERY,3,0,480); end end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Al_Zahbi/npcs/Yudi_Yolhbi.lua
53
2326
----------------------------------- -- Area: Al Zahbi -- NPC: Yudi Yolhbi -- Type: Woodworking Normal/Adv. Image Support -- @pos -71.584 -7 -56.018 48 ----------------------------------- package.loaded["scripts/zones/Al_Zahbi/TextIDs"] = nil; ----------------------------------- require("scripts/globals/status"); require("scripts/globals/crafting"); require("scripts/zones/Al_Zahbi/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local guildMember = isGuildMember(player,9); if (guildMember == 1) then if (trade:hasItemQty(2184,1) and trade:getItemCount() == 1) then if (player:hasStatusEffect(EFFECT_WOODWORKING_IMAGERY) == false) then player:tradeComplete(); player:startEvent(0x00EB,8,0,0,0,188,0,1,0); else npc:showText(npc, IMAGE_SUPPORT_ACTIVE); end end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local guildMember = isGuildMember(player,9); local SkillLevel = player:getSkillLevel(SKILL_WOODWORKING); if (guildMember == 1) then if (player:hasStatusEffect(EFFECT_WOODWORKING_IMAGERY) == false) then player:startEvent(0x00EA,8,SkillLevel,0,511,188,0,1,2184); else player:startEvent(0x00EA,8,SkillLevel,0,511,188,7055,1,2184); end else player:startEvent(0x00EA,0,0,0,0,0,0,1,0); -- Standard Dialogue 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 == 0x00EA and option == 1) then player:messageSpecial(IMAGE_SUPPORT,0,1,1); player:addStatusEffect(EFFECT_WOODWORKING_IMAGERY,1,0,120); elseif (csid == 0x00EB) then player:messageSpecial(IMAGE_SUPPORT,0,1,0); player:addStatusEffect(EFFECT_WOODWORKING_IMAGERY,3,0,480); end end;
gpl-3.0
focusworld/ffocus
bot/utils.lua
646
23489
URL = require "socket.url" http = require "socket.http" https = require "ssl.https" ltn12 = require "ltn12" serpent = require "serpent" feedparser = require "feedparser" json = (loadfile "./libs/JSON.lua")() mimetype = (loadfile "./libs/mimetype.lua")() redis = (loadfile "./libs/redis.lua")() JSON = (loadfile "./libs/dkjson.lua")() http.TIMEOUT = 10 function get_receiver(msg) if msg.to.type == 'user' then return 'user#id'..msg.from.id end if msg.to.type == 'chat' then return 'chat#id'..msg.to.id end if msg.to.type == 'encr_chat' then return msg.to.print_name end end function is_chat_msg( msg ) if msg.to.type == 'chat' then return true end return false end function string.random(length) local str = ""; for i = 1, length do math.random(97, 122) str = str..string.char(math.random(97, 122)); end return str; end function string:split(sep) local sep, fields = sep or ":", {} local pattern = string.format("([^%s]+)", sep) self:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end -- DEPRECATED function string.trim(s) print("string.trim(s) is DEPRECATED use string:trim() instead") return s:gsub("^%s*(.-)%s*$", "%1") end -- Removes spaces function string:trim() return self:gsub("^%s*(.-)%s*$", "%1") end function get_http_file_name(url, headers) -- Eg: foo.var local file_name = url:match("[^%w]+([%.%w]+)$") -- Any delimited alphanumeric on the url file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$") -- Random name, hope content-type works file_name = file_name or str:random(5) local content_type = headers["content-type"] local extension = nil if content_type then extension = mimetype.get_mime_extension(content_type) end if extension then file_name = file_name.."."..extension end local disposition = headers["content-disposition"] if disposition then -- attachment; filename=CodeCogsEqn.png file_name = disposition:match('filename=([^;]+)') or file_name end return file_name end -- Saves file to /tmp/. If file_name isn't provided, -- will get the text after the last "/" for filename -- and content-type for extension function download_to_file(url, file_name) print("url to download: "..url) local respbody = {} local options = { url = url, sink = ltn12.sink.table(respbody), redirect = true } -- nil, code, headers, status local response = nil if url:starts('https') then options.redirect = false response = {https.request(options)} else response = {http.request(options)} end local code = response[2] local headers = response[3] local status = response[4] if code ~= 200 then return nil end file_name = file_name or get_http_file_name(url, headers) local file_path = "/tmp/"..file_name print("Saved to: "..file_path) file = io.open(file_path, "w+") file:write(table.concat(respbody)) file:close() return file_path end function vardump(value) print(serpent.block(value, {comment=false})) end -- taken from http://stackoverflow.com/a/11130774/3163199 function scandir(directory) local i, t, popen = 0, {}, io.popen for filename in popen('ls -a "'..directory..'"'):lines() do i = i + 1 t[i] = filename end return t end -- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen function run_command(str) local cmd = io.popen(str) local result = cmd:read('*all') cmd:close() return result end -- User has privileges function is_sudo(msg) local var = false -- Check users id in config for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end -- Returns the name of the sender function get_name(msg) local name = msg.from.first_name if name == nil then name = msg.from.id end return name end -- Returns at table of lua files inside plugins function plugins_names( ) local files = {} for k, v in pairs(scandir("plugins")) do -- Ends with .lua if (v:match(".lua$")) then table.insert(files, v) end end return files end -- Function name explains what it does. function file_exists(name) local f = io.open(name,"r") if f ~= nil then io.close(f) return true else return false end end -- Save into file the data serialized for lua. -- Set uglify true to minify the file. function serialize_to_file(data, file, uglify) file = io.open(file, 'w+') local serialized if not uglify then serialized = serpent.block(data, { comment = false, name = '_' }) else serialized = serpent.dump(data) end file:write(serialized) file:close() end -- Returns true if the string is empty function string:isempty() return self == nil or self == '' end -- Returns true if the string is blank function string:isblank() self = self:trim() return self:isempty() end -- DEPRECATED!!!!! function string.starts(String, Start) print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead") return Start == string.sub(String,1,string.len(Start)) end -- Returns true if String starts with Start function string:starts(text) return text == string.sub(self,1,string.len(text)) end -- Send image to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_photo(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function, cb_extra = cb_extra } -- Call to remove with optional callback send_photo(receiver, file_path, cb_function, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_photo_from_url(receiver, url, cb_function, cb_extra) -- If callback not provided cb_function = cb_function or ok_cb cb_extra = cb_extra or false local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, cb_function, cb_extra) else print("File path: "..file_path) _send_photo(receiver, file_path, cb_function, cb_extra) end end -- Same as send_photo_from_url but as callback function function send_photo_from_url_callback(cb_extra, success, result) local receiver = cb_extra.receiver local url = cb_extra.url local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, ok_cb, false) else print("File path: "..file_path) _send_photo(receiver, file_path, ok_cb, false) end end -- Send multiple images asynchronous. -- param urls must be a table. function send_photos_from_url(receiver, urls) local cb_extra = { receiver = receiver, urls = urls, remove_path = nil } send_photos_from_url_callback(cb_extra) end -- Use send_photos_from_url. -- This function might be difficult to understand. function send_photos_from_url_callback(cb_extra, success, result) -- cb_extra is a table containing receiver, urls and remove_path local receiver = cb_extra.receiver local urls = cb_extra.urls local remove_path = cb_extra.remove_path -- The previously image to remove if remove_path ~= nil then os.remove(remove_path) print("Deleted: "..remove_path) end -- Nil or empty, exit case (no more urls) if urls == nil or #urls == 0 then return false end -- Take the head and remove from urls table local head = table.remove(urls, 1) local file_path = download_to_file(head, false) local cb_extra = { receiver = receiver, urls = urls, remove_path = file_path } -- Send first and postpone the others as callback send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra) end -- Callback to remove a file function rmtmp_cb(cb_extra, success, result) local file_path = cb_extra.file_path local cb_function = cb_extra.cb_function or ok_cb local cb_extra = cb_extra.cb_extra if file_path ~= nil then os.remove(file_path) print("Deleted: "..file_path) end -- Finally call the callback cb_function(cb_extra, success, result) end -- Send document to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_document(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function or ok_cb, cb_extra = cb_extra or false } -- Call to remove with optional callback send_document(receiver, file_path, rmtmp_cb, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_document_from_url(receiver, url, cb_function, cb_extra) local file_path = download_to_file(url, false) print("File path: "..file_path) _send_document(receiver, file_path, cb_function, cb_extra) end -- Parameters in ?a=1&b=2 style function format_http_params(params, is_get) local str = '' -- If is get add ? to the beginning if is_get then str = '?' end local first = true -- Frist param for k,v in pairs (params) do if v then -- nil value if first then first = false str = str..k.. "="..v else str = str.."&"..k.. "="..v end end end return str end -- Check if user can use the plugin and warns user -- Returns true if user was warned and false if not warned (is allowed) function warns_user_not_allowed(plugin, msg) if not user_allowed(plugin, msg) then local text = 'This plugin requires privileged user' local receiver = get_receiver(msg) send_msg(receiver, text, ok_cb, false) return true else return false end end -- Check if user can use the plugin function user_allowed(plugin, msg) if plugin.privileged and not is_sudo(msg) then return false end return true end function send_order_msg(destination, msgs) local cb_extra = { destination = destination, msgs = msgs } send_order_msg_callback(cb_extra, true) end function send_order_msg_callback(cb_extra, success, result) local destination = cb_extra.destination local msgs = cb_extra.msgs local file_path = cb_extra.file_path if file_path ~= nil then os.remove(file_path) print("Deleted: " .. file_path) end if type(msgs) == 'string' then send_large_msg(destination, msgs) elseif type(msgs) ~= 'table' then return end if #msgs < 1 then return end local msg = table.remove(msgs, 1) local new_cb_extra = { destination = destination, msgs = msgs } if type(msg) == 'string' then send_msg(destination, msg, send_order_msg_callback, new_cb_extra) elseif type(msg) == 'table' then local typ = msg[1] local nmsg = msg[2] new_cb_extra.file_path = nmsg if typ == 'document' then send_document(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'image' or typ == 'photo' then send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'audio' then send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'video' then send_video(destination, nmsg, send_order_msg_callback, new_cb_extra) else send_file(destination, nmsg, send_order_msg_callback, new_cb_extra) end end end -- Same as send_large_msg_callback but friendly params function send_large_msg(destination, text) local cb_extra = { destination = destination, text = text } send_large_msg_callback(cb_extra, true) end -- If text is longer than 4096 chars, send multiple msg. -- https://core.telegram.org/method/messages.sendMessage function send_large_msg_callback(cb_extra, success, result) local text_max = 4096 local destination = cb_extra.destination local text = cb_extra.text local text_len = string.len(text) local num_msg = math.ceil(text_len / text_max) if num_msg <= 1 then send_msg(destination, text, ok_cb, false) else local my_text = string.sub(text, 1, 4096) local rest = string.sub(text, 4096, text_len) local cb_extra = { destination = destination, text = rest } send_msg(destination, my_text, send_large_msg_callback, cb_extra) end end -- Returns a table with matches or nil function match_pattern(pattern, text, lower_case) if text then local matches = {} if lower_case then matches = { string.match(text:lower(), pattern) } else matches = { string.match(text, pattern) } end if next(matches) then return matches end end -- nil end -- Function to read data from files function load_from_file(file, default_data) local f = io.open(file, "r+") -- If file doesn't exists if f == nil then -- Create a new empty table default_data = default_data or {} serialize_to_file(default_data, file) print ('Created file', file) else print ('Data loaded from file', file) f:close() end return loadfile (file)() end -- See http://stackoverflow.com/a/14899740 function unescape_html(str) local map = { ["lt"] = "<", ["gt"] = ">", ["amp"] = "&", ["quot"] = '"', ["apos"] = "'" } new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s) var = map[s] or n == "#" and string.char(s) var = var or n == "#x" and string.char(tonumber(s,16)) var = var or orig return var end) return new end --Check if this chat is realm or not function is_realm(msg) local var = false local realms = 'realms' local data = load_data(_config.moderation.data) local chat = msg.to.id if data[tostring(realms)] then if data[tostring(realms)][tostring(msg.to.id)] then var = true end return var end end --Check if this chat is a group or not function is_group(msg) local var = false local groups = 'groups' local data = load_data(_config.moderation.data) local chat = msg.to.id if data[tostring(groups)] then if data[tostring(groups)][tostring(msg.to.id)] then var = true end return var end end function savelog(group, logtxt) local text = (os.date("[ %c ]=> "..logtxt.."\n \n")) local file = io.open("./groups/logs/"..group.."log.txt", "a") file:write(text) file:close() end function user_print_name(user) if user.print_name then return user.print_name end local text = '' if user.first_name then text = user.last_name..' ' end if user.lastname then text = text..user.last_name end return text end --Check if user is the owner of that group or not function is_owner(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.from.id if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['set_owner'] then if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then var = true end end end if data['admins'] then if data['admins'][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end function is_owner2(user_id, group_id) local var = false local data = load_data(_config.moderation.data) if data[tostring(group_id)] then if data[tostring(group_id)]['set_owner'] then if data[tostring(group_id)]['set_owner'] == tostring(user_id) then var = true end end end if data['admins'] then if data['admins'][tostring(user_id)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end --Check if user is admin or not function is_admin(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.from.id local admins = 'admins' if data[tostring(admins)] then if data[tostring(admins)][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end function is_admin2(user_id) local var = false local data = load_data(_config.moderation.data) local user = user_id local admins = 'admins' if data[tostring(admins)] then if data[tostring(admins)][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end --Check if user is the mod of that group or not function is_momod(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.from.id if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['moderators'] then if data[tostring(msg.to.id)]['moderators'][tostring(user)] then var = true end end end if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['set_owner'] then if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then var = true end end end if data['admins'] then if data['admins'][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end function is_momod2(user_id, group_id) local var = false local data = load_data(_config.moderation.data) local usert = user_id if data[tostring(group_id)] then if data[tostring(group_id)]['moderators'] then if data[tostring(group_id)]['moderators'][tostring(usert)] then var = true end end end if data[tostring(group_id)] then if data[tostring(group_id)]['set_owner'] then if data[tostring(group_id)]['set_owner'] == tostring(user_id) then var = true end end end if data['admins'] then if data['admins'][tostring(user_id)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == usert then var = true end end return var end -- Returns the name of the sender function kick_user(user_id, chat_id) if tonumber(user_id) == tonumber(our_id) then -- Ignore bot return end if is_owner2(user_id, chat_id) then -- Ignore admins return end local chat = 'chat#id'..chat_id local user = 'user#id'..user_id chat_del_user(chat, user, ok_cb, true) end -- Ban function ban_user(user_id, chat_id) if tonumber(user_id) == tonumber(our_id) then -- Ignore bot return end if is_admin2(user_id) then -- Ignore admins return end -- Save to redis local hash = 'banned:'..chat_id redis:sadd(hash, user_id) -- Kick from chat kick_user(user_id, chat_id) end -- Global ban function banall_user(user_id) if tonumber(user_id) == tonumber(our_id) then -- Ignore bot return end if is_admin2(user_id) then -- Ignore admins return end -- Save to redis local hash = 'gbanned' redis:sadd(hash, user_id) end -- Global unban function unbanall_user(user_id) --Save on redis local hash = 'gbanned' redis:srem(hash, user_id) end -- Check if user_id is banned in chat_id or not function is_banned(user_id, chat_id) --Save on redis local hash = 'banned:'..chat_id local banned = redis:sismember(hash, user_id) return banned or false end -- Check if user_id is globally banned or not function is_gbanned(user_id) --Save on redis local hash = 'gbanned' local banned = redis:sismember(hash, user_id) return banned or false end -- Returns chat_id ban list function ban_list(chat_id) local hash = 'banned:'..chat_id local list = redis:smembers(hash) local text = "Ban list !\n\n" for k,v in pairs(list) do text = text..k.." - "..v.." \n" end return text end -- Returns globally ban list function banall_list() local hash = 'gbanned' local list = redis:smembers(hash) local text = "global bans !\n\n" for k,v in pairs(list) do text = text..k.." - "..v.." \n" end return text end -- /id by reply function get_message_callback_id(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id send_large_msg(chat, result.from.id) else return 'Use This in Your Groups' end end -- kick by reply for mods and owner function Kick_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't kick myself" end if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin return "you can't kick mods,owner and admins" end chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false) else return 'Use This in Your Groups' end end -- Kick by reply for admins function Kick_by_reply_admins(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't kick myself" end if is_admin2(result.from.id) then -- Ignore admins return end chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false) else return 'Use This in Your Groups' end end --Ban by reply for admins function ban_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't ban myself" end if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin return "you can't kick mods,owner and admins" end ban_user(result.from.id, result.to.id) send_large_msg(chat, "User "..result.from.id.." Banned") else return 'Use This in Your Groups' end end -- Ban by reply for admins function ban_by_reply_admins(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't ban myself" end if is_admin2(result.from.id) then -- Ignore admins return end ban_user(result.from.id, result.to.id) send_large_msg(chat, "User "..result.from.id.." Banned") else return 'Use This in Your Groups' end end -- Unban by reply function unban_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't unban myself" end send_large_msg(chat, "User "..result.from.id.." Unbanned") -- Save on redis local hash = 'banned:'..result.to.id redis:srem(hash, result.from.id) else return 'Use This in Your Groups' end end function banall_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't banall myself" end if is_admin2(result.from.id) then -- Ignore admins return end local name = user_print_name(result.from) banall_user(result.from.id) chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false) send_large_msg(chat, "User "..name.."["..result.from.id.."] hammered") else return 'Use This in Your Groups' end end
gpl-2.0
AlexandreCA/darkstar
scripts/zones/Temenos/mobs/Enhanced_Vulture.lua
7
1442
----------------------------------- -- Area: Temenos W T -- NPC: Enhanced_Vulture ----------------------------------- package.loaded["scripts/zones/Temenos/TextIDs"] = nil; ----------------------------------- require("scripts/globals/limbus"); require("scripts/zones/Temenos/TextIDs"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob,target) GetMobByID(16928959):updateEnmity(target); GetMobByID(16928960):updateEnmity(target); GetMobByID(16928961):updateEnmity(target); GetMobByID(16928962):updateEnmity(target); GetMobByID(16928963):updateEnmity(target); GetMobByID(16928964):updateEnmity(target); end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer,ally) local mobX = mob:getXPos(); local mobY = mob:getYPos(); local mobZ = mob:getZPos(); if (IsMobDead(16928959)==true and IsMobDead(16928960)==true and IsMobDead(16928961)==true and IsMobDead(16928962)==true and IsMobDead(16928963)==true and IsMobDead(16928964)==true) then GetNPCByID(16928768+17):setPos(mobX,mobY,mobZ); GetNPCByID(16928768+17):setStatus(STATUS_NORMAL); GetNPCByID(16928770+470):setStatus(STATUS_NORMAL); end end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Ordelles_Caves/npcs/Grounds_Tome.lua
30
1098
----------------------------------- -- Area: Ordelle's Caves -- NPC: Grounds Tome ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/groundsofvalor"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) startGov(GOV_EVENT_ORDELLES_CAVES,player); end; ----------------------------------- -- onEventSelection ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); updateGov(player,csid,option,655,656,657,658,659,660,661,662,0,0); end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); finishGov(player,csid,option,655,656,657,658,659,660,661,662,0,0,GOV_MSG_ORDELLES_CAVES); end;
gpl-3.0
nwf/openwrt-luci
applications/luci-app-asterisk/luasrc/model/cbi/asterisk/trunk_sip.lua
68
2351
-- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org> -- Licensed to the public under the Apache License 2.0. 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
apache-2.0
JiessieDawn/skynet
lualib/skynet/sharetable.lua
7
10876
local skynet = require "skynet" local service = require "skynet.service" local core = require "skynet.sharetable.core" local is_sharedtable = core.is_sharedtable local stackvalues = core.stackvalues local function sharetable_service() local skynet = require "skynet" local core = require "skynet.sharetable.core" local matrix = {} -- all the matrix local files = {} -- filename : matrix local clients = {} local sharetable = {} local function close_matrix(m) if m == nil then return end local ptr = m:getptr() local ref = matrix[ptr] if ref == nil or ref.count == 0 then matrix[ptr] = nil m:close() end end function sharetable.loadfile(source, filename, ...) close_matrix(files[filename]) local m = core.matrix("@" .. filename, ...) files[filename] = m skynet.ret() end function sharetable.loadstring(source, filename, datasource, ...) close_matrix(files[filename]) local m = core.matrix(datasource, ...) files[filename] = m skynet.ret() end local function loadtable(filename, ptr, len) close_matrix(files[filename]) local m = core.matrix([[ local unpack, ptr, len = ... return unpack(ptr, len) ]], skynet.unpack, ptr, len) files[filename] = m end function sharetable.loadtable(source, filename, ptr, len) local ok, err = pcall(loadtable, filename, ptr, len) skynet.trash(ptr, len) assert(ok, err) skynet.ret() end local function query_file(source, filename) local m = files[filename] local ptr = m:getptr() local ref = matrix[ptr] if ref == nil then ref = { filename = filename, count = 0, matrix = m, refs = {}, } matrix[ptr] = ref end if ref.refs[source] == nil then ref.refs[source] = true local list = clients[source] if not list then clients[source] = { ptr } else table.insert(list, ptr) end ref.count = ref.count + 1 end return ptr end function sharetable.query(source, filename) local m = files[filename] if m == nil then skynet.ret() return end local ptr = query_file(source, filename) skynet.ret(skynet.pack(ptr)) end function sharetable.close(source) local list = clients[source] if list then for _, ptr in ipairs(list) do local ref = matrix[ptr] if ref and ref.refs[source] then ref.refs[source] = nil ref.count = ref.count - 1 if ref.count == 0 then if files[ref.filename] ~= ref.matrix then -- It's a history version skynet.error(string.format("Delete a version (%s) of %s", ptr, ref.filename)) ref.matrix:close() matrix[ptr] = nil end end end end clients[source] = nil end -- no return end skynet.dispatch("lua", function(_,source,cmd,...) sharetable[cmd](source,...) end) skynet.info_func(function() local info = {} for filename, m in pairs(files) do info[filename] = { current = m:getptr(), size = m:size(), } end local function address(refs) local keys = {} for addr in pairs(refs) do table.insert(keys, skynet.address(addr)) end table.sort(keys) return table.concat(keys, ",") end for ptr, copy in pairs(matrix) do local v = info[copy.filename] local h = v.history if h == nil then h = {} v.history = h end table.insert(h, string.format("%s [%d]: (%s)", copy.matrix:getptr(), copy.matrix:size(), address(copy.refs))) end for _, v in pairs(info) do if v.history then v.history = table.concat(v.history, "\n\t") end end return info end) end local function load_service(t, key) if key == "address" then t.address = service.new("sharetable", sharetable_service) return t.address else return nil end end local function report_close(t) local addr = rawget(t, "address") if addr then skynet.send(addr, "lua", "close") end end local sharetable = setmetatable ( {} , { __index = load_service, __gc = report_close, }) function sharetable.loadfile(filename, ...) skynet.call(sharetable.address, "lua", "loadfile", filename, ...) end function sharetable.loadstring(filename, source, ...) skynet.call(sharetable.address, "lua", "loadstring", filename, source, ...) end function sharetable.loadtable(filename, tbl) assert(type(tbl) == "table") skynet.call(sharetable.address, "lua", "loadtable", filename, skynet.pack(tbl)) end local RECORD = {} function sharetable.query(filename) local newptr = skynet.call(sharetable.address, "lua", "query", filename) if newptr then local t = core.clone(newptr) local map = RECORD[filename] if not map then map = {} RECORD[filename] = map end map[t] = true return t end end local pairs = pairs local type = type local assert = assert local next = next local rawset = rawset local getuservalue = debug.getuservalue local setuservalue = debug.setuservalue local getupvalue = debug.getupvalue local setupvalue = debug.setupvalue local getlocal = debug.getlocal local setlocal = debug.setlocal local getinfo = debug.getinfo local NILOBJ = {} local function insert_replace(old_t, new_t, replace_map) for k, ov in pairs(old_t) do if type(ov) == "table" then local nv = new_t[k] if nv == nil then nv = NILOBJ end assert(replace_map[ov] == nil) replace_map[ov] = nv nv = type(nv) == "table" and nv or NILOBJ insert_replace(ov, nv, replace_map) end end replace_map[old_t] = new_t return replace_map end local function resolve_replace(replace_map) local match = {} local record_map = {} local function getnv(v) local nv = replace_map[v] if nv then if nv == NILOBJ then return nil end return nv end assert(false) end local function match_value(v) if v == nil or record_map[v] or is_sharedtable(v) then return end local tv = type(v) local f = match[tv] if f then record_map[v] = true return f(v) end end local function match_mt(v) local mt = debug.getmetatable(v) if mt then local nv = replace_map[mt] if nv then nv = getnv(mt) debug.setmetatable(v, nv) else return match_value(mt) end end end local function match_internmt() local internal_types = { pointer = debug.upvalueid(getnv, 1), boolean = false, str = "", number = 42, thread = coroutine.running(), func = getnv, } for _,v in pairs(internal_types) do match_mt(v) end return match_mt(nil) end local function match_table(t) local keys = false for k,v in next, t do local tk = type(k) if match[tk] then keys = keys or {} keys[#keys+1] = k end local nv = replace_map[v] if nv then nv = getnv(v) rawset(t, k, nv) else match_value(v) end end if keys then for _, old_k in ipairs(keys) do local new_k = replace_map[old_k] if new_k then local value = rawget(t, old_k) new_k = getnv(old_k) rawset(t, old_k, nil) if new_k then rawset(t, new_k, value) end else match_value(old_k) end end end return match_mt(t) end local function match_userdata(u) local uv = getuservalue(u) local nv = replace_map[uv] if nv then nv = getnv(uv) setuservalue(u, nv) end return match_mt(u) end local function match_funcinfo(info) local func = info.func local nups = info.nups for i=1,nups do local name, upv = getupvalue(func, i) local nv = replace_map[upv] if nv then nv = getnv(upv) setupvalue(func, i, nv) elseif upv then match_value(upv) end end local level = info.level local curco = info.curco if not level then return end local i = 1 while true do local name, v = getlocal(curco, level, i) if name == nil then break end if replace_map[v] then local nv = getnv(v) setlocal(curco, level, i, nv) elseif v then match_value(v) end i = i + 1 end end local function match_function(f) local info = getinfo(f, "uf") return match_funcinfo(info) end local function match_thread(co, level) -- match stackvalues local values = {} local n = stackvalues(co, values) for i=1,n do local v = values[i] match_value(v) end local uplevel = co == coroutine.running() and 1 or 0 level = level or 1 while true do local info = getinfo(co, level, "uf") if not info then break end info.level = level + uplevel info.curco = co match_funcinfo(info) level = level + 1 end end local function prepare_match() local co = coroutine.running() record_map[co] = true record_map[match] = true record_map[RECORD] = true record_map[record_map] = true record_map[replace_map] = true record_map[insert_replace] = true record_map[resolve_replace] = true assert(getinfo(co, 3, "f").func == sharetable.update) match_thread(co, 5) -- ignore match_thread and match_funcinfo frame end match["table"] = match_table match["function"] = match_function match["userdata"] = match_userdata match["thread"] = match_thread prepare_match() match_internmt() local root = debug.getregistry() assert(replace_map[root] == nil) match_table(root) end function sharetable.update(...) local names = {...} local replace_map = {} for _, name in ipairs(names) do local map = RECORD[name] if map then local new_t = sharetable.query(name) for old_t,_ in pairs(map) do if old_t ~= new_t then insert_replace(old_t, new_t, replace_map) map[old_t] = nil end end end end if next(replace_map) then resolve_replace(replace_map) end end return sharetable
mit
Zakhar-V/Prototypes
1/Code/Source/ThirdParty/glLoadGen/glLoadGen_2_0_3a/modules/NoloadC_Style.lua
1
12668
local util = require "util" local struct = require "NoloadC_Struct" local common = require "CommonStyle" -------------------------------------- -- Common functions. local function GetIncludeGuard(spec, options) local temp = options.prefix .. spec.GetIncludeGuardString() .. "_NOLOAD_STYLE_H" return temp:upper() end local function GetEnumName(enum, spec, options) return options.prefix .. spec.EnumNamePrefix() .. enum.name end local function GetFuncPtrName(func, spec, options) return options.prefix .. "_ptrc_".. spec.FuncNamePrefix() .. func.name end local function GetFuncName(func, spec, options) return options.prefix .. spec.FuncNamePrefix() .. func.name end local function GetFuncPtrTypedefName(func, spec, options) return "PFN" .. GetFuncPtrName(func, spec, options):upper() .. "PROC" end local function WriteFuncPtrTypedefStmt(hFile, func, spec, options) hFile:fmt("typedef %s (%s *%s)(%s);\n", common.GetFuncReturnType(func), spec.GetCodegenPtrType(), GetFuncPtrTypedefName(func, spec, options), common.GetFuncParamList(func)) end local function GetFuncPtrDefDirect(func, spec, options) return string.format("%s (%s *%s)(%s)", common.GetFuncReturnType(func), spec.GetCodegenPtrType(), GetFuncPtrName(func, spec, options), common.GetFuncParamList(func, true)) end local function GetFuncPtrDefTypedef(func, spec, options) return string.format("%s %s", GetFuncPtrTypedefName(func, spec, options), GetFuncPtrName(func, spec, options)) end -------------------------------------- -- All style functions. local my_style = {} function my_style.WriteLargeHeader(hFile, value, options) local len = #value hFile:write("/**", string.rep("*", len), "**/\n") hFile:write("/* ", value, "*/\n") end function my_style.WriteSmallHeader(hFile, value, options) hFile:write("/* ", value, "*/\n") end function my_style.WriteBlockBeginExtVariables(hFile, spec, options) end function my_style.WriteBlockEndExtVariables(hFile, spec, options) end function my_style.WriteBlockBeginSystem(hFile, spec, options) end function my_style.WriteBlockEndSystem(hFile, spec, options) end function my_style.WriteFilePreamble(hFile, specData, spec, options) common.WriteCGeneratorInfo(hFile, specData, spec, options) end --------------------------------------------- -- Header functions. local hdr = {} my_style.hdr = hdr function hdr.GetFilename(basename, spec, options) return basename .. ".h" end function hdr.WriteBlockBeginIncludeGuard(hFile, spec, options) local guard = GetIncludeGuard(spec, options) hFile:fmt("#ifndef %s\n", guard) hFile:fmt("#define %s\n", guard) end function hdr.WriteBlockEndIncludeGuard(hFile, spec, options) hFile:fmt("#endif /*%s*/\n", GetIncludeGuard(spec, options)) end function hdr.WriteGuards(hFile, spec, options) hFile:rawwrite(spec.GetHeaderInit()) end function hdr.WriteTypedefs(hFile, specData, spec, options) local defArray = common.GetStdTypedefs() --Use include-guards for the typedefs, since they're common among --headers in this style. hFile:write("#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS\n") hFile:write("#define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS\n") hFile:write("\n") hFile:inc() for _, def in ipairs(defArray) do hFile:write(def) end hFile:dec() hFile:write("\n") hFile:write("#endif /*GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS*/\n") hFile:write("\n") common.WritePassthruData(hFile, specData.funcData.passthru) end function hdr.WriteExtension(hFile, extName, spec, options) hFile:fmt("extern int %s%sext_%s;\n", options.prefix, spec.DeclPrefix(), extName) end function hdr.WriteBlockBeginEnumerators(hFile, spec, options) end function hdr.WriteBlockEndEnumerators(hFile, spec, options) end function hdr.WriteEnumerator(hFile, enum, enumTable, spec, options, enumSeen) local name = GetEnumName(enum, spec, options) if(enumSeen[enum.name]) then hFile:fmt("/*%s seen in %s*/\n", name, enumSeen[enum.name]) else hFile:fmt("#define %s%s%s\n", name, common.GetNameLengthPadding(name, 33), common.ResolveEnumValue(enum, enumTable)) end end function hdr.WriteBlockBeginExternC(hFile, spec, options) common.WriteExternCStart(hFile) end function hdr.WriteBlockEndExternC(hFile, spec, options) common.WriteExternCEnd(hFile) end function hdr.WriteFunction(hFile, func, spec, options, funcSeen) if(funcSeen[func.name]) then return end hFile:write("extern ", GetFuncPtrDefDirect(func, spec, options), ";\n") hFile:fmt("#define %s %s\n", GetFuncName(func, spec, options), GetFuncPtrName(func, spec, options)) end function hdr.WriteSetupFunction(hFile, specData, spec, options) hFile:fmt("void %sCheckExtensions(%s);\n", spec.DeclPrefix(), spec.GetLoaderParams()) end function hdr.WriteVersionFunctions(hFile, specData, spec, options) end ---------------------------------------- -- Source file. local src = {} my_style.src = src function src.GetFilename(basename, spec, options) return basename .. ".c" end function src.WriteIncludes(hFile, basename, spec, options) hFile:writeblock([[ #include <stdlib.h> #include <string.h> #include <stddef.h> ]]) local base = util.ParsePath(hdr.GetFilename(basename, spec, options)) hFile:fmt('#include "%s"\n', base) end function src.WriteLoaderFunc(hFile, spec, options) hFile:writeblock(spec.GetLoaderFunc()) end function src.WriteExtension(hFile, extName, spec, options) hFile:fmt("int %s%sext_%s = 0;\n", options.prefix, spec.DeclPrefix(), extName) end function src.WriteSetupFunction(hFile, specData, spec, options) hFile:write "static void ClearExtensionVariables(void)\n" hFile:write "{\n" hFile:inc() for _, extName in ipairs(options.extensions) do hFile:fmt("%s%sext_%s = 0;\n", options.prefix, spec.DeclPrefix(), extName) end hFile:dec() hFile:write "}\n" hFile:write "\n" local mapTableName = options.prefix .. spec.DeclPrefix() .. "MapTable" hFile:writeblock([[ typedef struct ]] .. mapTableName .. [[_s { char *extName; int *extVariable; }]] .. mapTableName .. [[; ]]) local arrayLength = #options.extensions if(arrayLength == 0) then arrayLength = 1 end hFile:fmt("static %s g_mappingTable[%i]", mapTableName, arrayLength) if(arrayLength == 1) then hFile:rawwrite "; /*This is intensionally left uninitialized.*/\n" else hFile:rawwrite " = \n" hFile:write "{\n" hFile:inc() for _, extName in ipairs(options.extensions) do hFile:fmt('{"%s%s", &%s%sext_%s},\n', spec.ExtNamePrefix(), extName, options.prefix, spec.DeclPrefix(), extName) end hFile:dec() hFile:write "};\n" end hFile:write "\n" hFile:fmtblock([[ static void LoadExtByName(const char *extensionName) { %s *tableEnd = &g_mappingTable[%i]; %s *entry = &g_mappingTable[0]; for(; entry != tableEnd; ++entry) { if(strcmp(entry->extName, extensionName) == 0) break; } if(entry != tableEnd) *(entry->extVariable) = 1; } ]], mapTableName, #options.extensions, mapTableName) hFile:write "\n" local indexed = spec.GetIndexedExtStringFunc(options); if(indexed) then indexed[1] = specData.functable[indexed[1]] indexed[3] = specData.functable[indexed[3]] for _, enum in ipairs(specData.enumerators) do if(indexed[2] == enum.name) then indexed[2] = enum end if(indexed[4] == enum.name) then indexed[4] = enum end end hFile:writeblock([[ void ProcExtsFromExtList(void) { GLint iLoop; GLint iNumExtensions = 0; ]] .. GetFuncPtrName(indexed[1], spec, options) .. [[(]] .. GetEnumName(indexed[2], spec, options) .. [[, &iNumExtensions); for(iLoop = 0; iLoop < iNumExtensions; iLoop++) { const char *strExtensionName = (const char *)]] .. GetFuncPtrName(indexed[3], spec, options) .. [[(]] .. GetEnumName(indexed[4], spec, options) .. [[, iLoop); LoadExtByName(strExtensionName); } } ]]) else hFile:writeblock( common.GetProcessExtsFromStringFunc("LoadExtByName(%s)")) end hFile:write "\n" hFile:fmt("void %sCheckExtensions(%s)\n", spec.DeclPrefix(), spec.GetLoaderParams()) hFile:write "{\n" hFile:inc() hFile:write "ClearExtensionVariables();\n" hFile:write "\n" if(indexed) then hFile:write("ProcExtsFromExtList();\n") else --First, check if the GetExtStringFuncName is in the specData. hFile:write "{\n" hFile:inc() local funcName = spec.GetExtStringFuncName() if(specData.functable[funcName]) then --Create a function pointer and load it. local func = specData.functable[funcName] funcName = "InternalGetExtensionString" hFile:fmt("typedef %s (%s *MYGETEXTSTRINGPROC)(%s);\n", common.GetFuncReturnType(func), spec.GetCodegenPtrType(), common.GetFuncParamList(func)) hFile:fmt('MYGETEXTSTRINGPROC %s = (MYGETEXTSTRINGPROC)%s("%s%s");\n', funcName, spec.GetPtrLoaderFuncName(), spec.FuncNamePrefix(), func.name) hFile:fmt("if(!%s) return;\n", funcName) end hFile:fmt("ProcExtsFromExtString((const char *)%s(%s));\n", funcName, spec.GetExtStringParamList( function (name) return options.prefix .. spec.EnumNamePrefix() .. name end)) hFile:dec() hFile:write "}\n" end hFile:dec() hFile:write "}\n" end function src.WriteVersionFunctions(hFile, specData, spec, options) end local typedefs = {} src.typedefs = typedefs function typedefs.WriteFunction(hFile, func, spec, options, funcSeen) if(funcSeen[func.name]) then return end WriteFuncPtrTypedefStmt(hFile, func, spec, options) hFile:fmt("static %s %s Switch_%s(%s);\n", common.GetFuncReturnType(func), spec.GetCodegenPtrType(), func.name, common.GetFuncParamList(func, true)) end local defs = {} src.defs = defs function defs.WriteFunction(hFile, func, spec, options, funcSeen) if(funcSeen[func.name]) then return end hFile:fmt("%s = Switch_%s;\n", GetFuncPtrDefTypedef(func, spec, options), func.name) end local switch = {} src.switch = switch function switch.WriteFunction(hFile, func, spec, options, funcSeen) if(funcSeen[func.name]) then return end hFile:fmt("static %s %s Switch_%s(%s)\n", common.GetFuncReturnType(func), spec.GetCodegenPtrType(), func.name, common.GetFuncParamList(func, true)) hFile:write "{\n" hFile:inc() hFile:fmt('%s = (%s)%s("%s%s");\n', GetFuncPtrName(func, spec, options), GetFuncPtrTypedefName(func, spec, options), spec.GetPtrLoaderFuncName(), spec.FuncNamePrefix(), func.name) if(common.DoesFuncReturnSomething(func)) then hFile:fmt('%s(%s);\n', GetFuncPtrName(func, spec, options), common.GetFuncParamCallList(func)) else hFile:fmt('return %s(%s);\n', GetFuncPtrName(func, spec, options), common.GetFuncParamCallList(func)) end hFile:dec() hFile:write "}\n\n" end function switch.WriteGetExtString(hFile, specData, spec, options, funcSeen) if(funcSeen[spec.GetExtStringFuncName()]) then return end local func = specData.funcdefs[spec.GetExtStringFuncName()] if(func) then hFile:write "\n" hFile:fmt("static %s %s(%s)\n", common.GetFuncReturnType(func), func.name, common.GetFuncParamList(func, true)) hFile:write "{\n" hFile:inc() hFile:fmt('%s = (%s)%s("%s%s");\n', GetFuncPtrName(func, spec, options), GetFuncPtrTypedefName(func, spec, options), spec.GetPtrLoaderFuncName(), spec.FuncNamePrefix(), func.name) if(common.DoesFuncReturnSomething(func)) then hFile:fmt('%s(%s);\n', GetFuncPtrName(func, spec, options), common.GetFuncParamCallList(func)) else hFile:fmt('return %s(%s);\n', GetFuncPtrName(func, spec, options), common.GetFuncParamCallList(func)) end hFile:dec() hFile:write "}\n\n" end end local init = {} src.init = init function init.WriteBlockBeginStruct(hFile, spec, options) hFile:write("struct InitializeVariables\n") hFile:write "{\n" hFile:inc() hFile:write("InitializeVariables()\n") hFile:write "{\n" hFile:inc() end function init.WriteBlockEndStruct(hFile, spec, options) hFile:dec() hFile:write "}\n" hFile:dec() hFile:write "};\n\n" hFile:write("InitializeVariables g_initVariables;\n") end function init.WriteFunction(hFile, func, spec, options, funcSeen) hFile:fmt("%s = Switch_%s;\n", func.name, func.name) end local function Create() return util.DeepCopyTable(my_style), struct end return { Create = Create }
mit
AlexandreCA/darkstar
scripts/zones/Temenos/mobs/Temenos_Weapon.lua
7
1276
----------------------------------- -- Area: Temenos Central 1floor -- NPC: Temenos_Weapon ----------------------------------- package.loaded["scripts/zones/Temenos/TextIDs"] = nil; ----------------------------------- require("scripts/globals/limbus"); require("scripts/zones/Temenos/TextIDs"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob,target) if (IsMobDead(16929048)==true) then mob:addStatusEffect(EFFECT_REGAIN,7,3,0); mob:addStatusEffect(EFFECT_REGEN,50,3,0); end end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer,ally) local mobX = mob:getXPos(); local mobY = mob:getYPos(); local mobZ = mob:getZPos(); if (IsMobDead(16929046)==true and IsMobDead(16929047)==true and IsMobDead(16929048)==true and IsMobDead(16929049)==true and IsMobDead(16929050)==true and IsMobDead(16929051)==true) then GetNPCByID(16928768+71):setPos(mobX,mobY,mobZ); GetNPCByID(16928768+71):setStatus(STATUS_NORMAL); GetNPCByID(16928770+471):setStatus(STATUS_NORMAL); end end;
gpl-3.0
AlexandreCA/update
scripts/zones/East_Sarutabaruta/npcs/Taby_Canatahey.lua
34
1067
----------------------------------- -- Area: East Sarutabaruta -- NPC: Taby Canatahey -- @pos -119.119 -4.106 -524.347 116 ----------------------------------- package.loaded["scripts/zones/East_Sarutabaruta/TextIDs"] = nil; ----------------------------------- require("scripts/zones/East_Sarutabaruta/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,TABY_CANATAHEY_DIALOG); 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
AlexandreCA/update
scripts/globals/items/smoldering_salisbury_steak.lua
36
1686
----------------------------------------- -- ID: 5924 -- Item: Smoldering Salisbury Steak -- Food Effect: 180 Min, All Races ----------------------------------------- -- HP +30 -- Strength +7 -- Intelligence -5 -- Attack % 20 Cap 160 -- Ranged Attack %20 Cap 160 -- Dragon Killer +5 ----------------------------------------- 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,10800,5924); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_HP, 30); target:addMod(MOD_STR, 7); target:addMod(MOD_INT, -5); target:addMod(MOD_FOOD_ATTP, 20); target:addMod(MOD_FOOD_ATT_CAP, 160); target:addMod(MOD_FOOD_RATTP, 20); target:addMod(MOD_FOOD_RATT_CAP, 160); target:addMod(MOD_DRAGON_KILLER, 5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_HP, 30); target:delMod(MOD_STR, 7); target:delMod(MOD_INT, -5); target:delMod(MOD_FOOD_ATTP, 20); target:delMod(MOD_FOOD_ATT_CAP, 160); target:delMod(MOD_FOOD_RATTP, 20); target:delMod(MOD_FOOD_RATT_CAP, 160); target:delMod(MOD_DRAGON_KILLER, 5); end;
gpl-3.0
AlexandreCA/darkstar
scripts/globals/items/hellsteak.lua
18
1722
----------------------------------------- -- ID: 5609 -- Item: hellsteak -- Food Effect: 180Min, All Races ----------------------------------------- -- Health 20 -- Strength 6 -- Intelligence -2 -- Health Regen While Healing 2 -- Attack % 19 -- Ranged ATT % 19 -- Dragon Killer 5 -- Demon Killer 5 ----------------------------------------- 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,10800,5609); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_HP, 20); target:addMod(MOD_STR, 6); target:addMod(MOD_INT, -2); target:addMod(MOD_HPHEAL, 2); target:addMod(MOD_ATTP, 19); target:addMod(MOD_RATTP, 19); target:addMod(MOD_DRAGON_KILLER, 5); target:addMod(MOD_DEMON_KILLER, 5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_HP, 20); target:delMod(MOD_STR, 6); target:delMod(MOD_INT, -2); target:delMod(MOD_HPHEAL, 2); target:delMod(MOD_ATTP, 19); target:delMod(MOD_RATTP, 19); target:delMod(MOD_DRAGON_KILLER, 5); target:delMod(MOD_DEMON_KILLER, 5); end;
gpl-3.0
AlexandreCA/update
scripts/zones/Rabao/npcs/Waylea.lua
38
1048
----------------------------------- -- Area: Rabao -- NPC: Waylea -- Type: Reputation -- @zone: 247 -- @pos 12.384 4.658 -32.392 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Rabao/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x0039 + (player:getFameLevel(4) - 1)); 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
SHIELDTM/megashield
plugins/del.lua
3
2561
do local function pre_process(msg) if not msg.text and msg.media then msg.text = '['..msg.media.type..']' end return msg end local function del_by_reply(extra, success, result) vardump(result) if result.to.peer_type == "channel" then delete_msg(result.id, ok_cb, false) end end function status_msg(msg, trigger) local data = load_data(_config.moderation.data) local strict_settings = data[tostring(msg.to.id)]['settings']['strict'] local status = trigger.." is not allowed here\n"..('@'..msg.from.username or msg.from.first_name).."\nStatus:" if strict_settings == "yes" then channel_kick_user("channel#id"..msg.to.id, "user#id"..msg.from.id, ok_cb, false) delete_msg(msg.id, ok_cb, false) status = status.."User kicked/msg deleted" else delete_msg(msg.id, ok_cb, false) status = status.."Mssage deleted" end send_large_msg(get_receiver(msg), status) end local function run(msg, matches) local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['settings']['lock_link'] == "yes" then if msg.text:match("telegram.me") and not is_momod(msg) then delete_msg(msg.id, ok_cb, true) end if msg.media then if msg.media.caption:match("telegram.me") and not is_momod(msg) then delete_msg(msg.id, ok_cb, true) end end end end if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['settings']['lock_sticker'] == "yes" then if msg.media then if msg.media.caption == "sticker.webp" and not is_momod(msg) then delete_msg(msg.id,ok_cb, true) end end end if data[tostring(msg.to.id)]['settings']['lock_arabic'] == "yes" then if msg.text:match('[\216-\219][\128-\191]') and not is_momod(msg) then local trigger = "Persian" status_msg(msg, trigger) end end end if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['settings']['lock_rtl'] == "yes" then if msg.text:match('‮') or msg.text:match('‏') and not is_momod(msg) then local trigger = "RTL characters" status_msg(msg, trigger) end end end if matches[1] == "del" and is_momod(msg) then if type(msg.reply_id)~= "nil" then msgreply = get_message(msg.reply_id, del_by_reply, false) end end return end return { patterns = { "(telegram.me)", '‮', -- rtl '‏', -- other rtl "%[(photo)%]", "([\216-\219][\128-\191])", "^[/!#](del)$", '%[(document)%]', "^!!tgservice (.+)$" }, run = run, pre_process = pre_process } end
gpl-2.0
commodo/packages
utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/ltq-dsl.lua
26
3991
local ubus = require "ubus" local function scrape() local dsl_line_attenuation = metric("dsl_line_attenuation_db", "gauge") local dsl_signal_attenuation = metric("dsl_signal_attenuation_db", "gauge") local dsl_snr = metric("dsl_signal_to_noise_margin_db", "gauge") local dsl_aggregated_transmit_power = metric("dsl_aggregated_transmit_power_db", "gauge") local dsl_latency = metric("dsl_latency_seconds", "gauge") local dsl_datarate = metric("dsl_datarate", "gauge") local dsl_max_datarate = metric("dsl_max_datarate", "gauge") local dsl_error_seconds_total = metric("dsl_error_seconds_total", "counter") local dsl_errors_total = metric("dsl_errors_total", "counter") local dsl_erb_total = metric("dsl_erb_total", "counter") local u = ubus.connect() local m = u:call("dsl", "metrics", {}) -- dsl hardware/firmware information metric("dsl_info", "gauge", { atuc_vendor = m.atu_c.vendor, atuc_system_vendor = m.atu_c.system_vendor, chipset = m.chipset, firmware_version = m.firmware_version, api_version = m.api_version, driver_version = m.driver_version, }, 1) -- dsl line settings information metric("dsl_line_info", "gauge", { annex = m.annex, standard = m.standard, mode = m.mode, profile = m.profile, }, 1) local dsl_up if m.up then dsl_up = 1 else dsl_up = 0 end metric("dsl_up", "gauge", { detail = m.state, }, dsl_up) -- dsl line status data metric("dsl_uptime_seconds", "gauge", {}, m.uptime) -- dsl db measurements dsl_line_attenuation({direction="down"}, m.downstream.latn) dsl_line_attenuation({direction="up"}, m.upstream.latn) dsl_signal_attenuation({direction="down"}, m.downstream.satn) dsl_signal_attenuation({direction="up"}, m.upstream.satn) dsl_snr({direction="down"}, m.downstream.snr) dsl_snr({direction="up"}, m.upstream.snr) dsl_aggregated_transmit_power({direction="down"}, m.downstream.actatp) dsl_aggregated_transmit_power({direction="up"}, m.upstream.actatp) -- dsl performance data if m.downstream.interleave_delay ~= nil then dsl_latency({direction="down"}, m.downstream.interleave_delay / 1000000) dsl_latency({direction="up"}, m.upstream.interleave_delay / 1000000) end dsl_datarate({direction="down"}, m.downstream.data_rate) dsl_datarate({direction="up"}, m.upstream.data_rate) dsl_max_datarate({direction="down"}, m.downstream.attndr) dsl_max_datarate({direction="up"}, m.upstream.attndr) -- dsl errors dsl_error_seconds_total({err="forward error correction", loc="near"}, m.errors.near.fecs) dsl_error_seconds_total({err="forward error correction", loc="far"}, m.errors.far.fecs) dsl_error_seconds_total({err="errored", loc="near"}, m.errors.near.es) dsl_error_seconds_total({err="errored", loc="far"}, m.errors.far.es) dsl_error_seconds_total({err="severely errored", loc="near"}, m.errors.near.ses) dsl_error_seconds_total({err="severely errored", loc="far"}, m.errors.far.ses) dsl_error_seconds_total({err="loss of signal", loc="near"}, m.errors.near.loss) dsl_error_seconds_total({err="loss of signal", loc="far"}, m.errors.far.loss) dsl_error_seconds_total({err="unavailable", loc="near"}, m.errors.near.uas) dsl_error_seconds_total({err="unavailable", loc="far"}, m.errors.far.uas) dsl_errors_total({err="header error code error", loc="near"}, m.errors.near.hec) dsl_errors_total({err="header error code error", loc="far"}, m.errors.far.hec) dsl_errors_total({err="non pre-emptive crc error", loc="near"}, m.errors.near.crc_p) dsl_errors_total({err="non pre-emptive crc error", loc="far"}, m.errors.far.crc_p) dsl_errors_total({err="pre-emptive crc error", loc="near"}, m.errors.near.crcp_p) dsl_errors_total({err="pre-emptive crc error", loc="far"}, m.errors.far.crcp_p) -- dsl error vectors if m.erb ~= nil then dsl_erb_total({counter="sent"}, m.erb.sent) dsl_erb_total({counter="discarded"}, m.erb.discarded) end end return { scrape = scrape }
gpl-2.0
jstewart-amd/premake-core
src/base/container.lua
23
8189
--- -- container.lua -- Implementation of configuration containers. -- Copyright (c) 2014 Jason Perkins and the Premake project --- local p = premake p.container = {} local container = p.container --- -- Keep a master dictionary of container class, so they can be easily looked -- up by name (technically you could look at premake["name"] but that is just -- a coding convention and I don't want to count on it) --- container.classes = {} --- -- Define a new class of containers. -- -- @param name -- The name of the new container class. Used wherever the class needs to -- be shown to the end user in a readable way. -- @param parent (optional) -- If this class of container is intended to be contained within another, -- the containing class object. -- @param extraScopes (optional) -- Each container can hold fields scoped to itself (by putting the container's -- class name into its scope attribute), or any of the container's children. -- If a container can hold scopes other than these (i.e. "config"), it can -- provide a list of those scopes in this argument. -- @return -- If successful, the new class descriptor object (a table). Otherwise, -- returns nil and an error message. --- function container.newClass(name, parent, extraScopes) local class = p.configset.new(parent) class.name = name class.pluralName = name:plural() class.containedClasses = {} class.extraScopes = extraScopes if parent then table.insert(parent.containedClasses, class) end container.classes[name] = class return class end --- -- Create a new instance of a configuration container. This is just the -- generic base implementation, each container class will define their -- own version. -- -- @param parent -- The class of container being instantiated. -- @param name -- The name for the new container instance. -- @return -- A new container instance. --- function container.new(class, name) local self = p.configset.new() setmetatable(self, p.configset.metatable(self)) self.class = class self.name = name self.filename = name self.script = _SCRIPT self.basedir = os.getcwd() self.external = false for childClass in container.eachChildClass(class) do self[childClass.pluralName] = {} end return self end --- -- Add a new child to an existing container instance. -- -- @param self -- The container instance to hold the child. -- @param child -- The child container instance. --- function container.addChild(self, child) local children = self[child.class.pluralName] table.insert(children, child) children[child.name] = child child.parent = self child[self.class.name] = self if self.class.alias then child[self.class.alias] = self end end --- -- Process the contents of a container, which were populated by the project -- script, in preparation for doing work on the results, such as exporting -- project files. --- function container.bake(self) if self._isBaked then return self end self._isBaked = true local ctx = p.context.new(self) for key, value in pairs(self) do ctx[key] = value end local parent = self.parent if parent then ctx[parent.class.name] = parent end for class in container.eachChildClass(self.class) do for child in container.eachChild(self, class) do child.parent = ctx child[self.class.name] = ctx end end if type(self.class.bake) == "function" then self.class.bake(ctx) end return ctx end function container.bakeChildren(self) for class in container.eachChildClass(self.class) do local children = self[class.pluralName] for i = 1, #children do local ctx = container.bake(children[i]) children[i] = ctx children[ctx.name] = ctx end end end --- -- Returns true if the container can hold any of the specified field scopes. -- -- @param class -- The container class to test. -- @param scope -- A scope string (e.g. "project", "config") or an array of scope strings. -- @return -- True if this container can hold any of the specified scopes. --- function container.classCanContain(class, scope) if type(scope) == "table" then for i = 1, #scope do if container.classCanContain(class, scope[i]) then return true end end return false end -- if I have child classes, check with them first, since scopes -- are usually specified for leaf nodes in the hierarchy for child in container.eachChildClass(class) do if (container.classCanContain(child, scope)) then return true end end if class.name == scope or class.alias == scope then return true end -- is it in my extra scopes list? if class.extraScopes and table.contains(class.extraScopes, scope) then return true end return false end --- -- Return true if a container class is or inherits from the -- specified class. -- -- @param class -- The container class to be tested. -- @param scope -- The name of the class to be checked against. If the container -- class matches this scope (i.e. class is a project and the -- scope is "project"), or if it is a parent object of it (i.e. -- class is a workspace and scope is "project"), then returns -- true. --- function container.classIsA(class, scope) while class do if class.name == scope or class.alias == scope then return true end class = class.parent end return false end --- -- Enumerate all of the registered child classes of a specific container class. -- -- @param class -- The container class to be enumerated. -- @return -- An iterator function for the container's child classes. --- function container.eachChildClass(class) local children = class.containedClasses local i = 0 return function () i = i + 1 if i <= #children then return children[i] end end end --- -- Enumerate all of the registered child instances of a specific container. -- -- @param self -- The container to be queried. -- @param class -- The class of child containers to be enumerated. -- @return -- An iterator function for the container's child classes. --- function container.eachChild(self, class) local children = self[class.pluralName] local i = 0 return function () i = i + 1 if i <= #children then return children[i] end end end --- -- Retrieve the child container with the specified class and name. -- -- @param self -- The container instance to query. -- @param class -- The class of the child container to be fetched. -- @param name -- The name of the child container to be fetched. -- @return -- The child instance if it exists, nil otherwise. --- function container.getChild(self, class, name) local children = self[class.pluralName] return children[name] end --- -- Retrieve a container class object. -- -- @param name -- The name of the container class to retrieve. -- @return -- The container class object if it exists, nil otherwise. --- function container.getClass(name) return container.classes[name] end --- -- Determine if the container contains a child of the specified class which -- meets the criteria of a testing function. -- -- @param self -- The container to be queried. -- @param class -- The class of the child containers to be enumerated. -- @param func -- A function that takes a child container as its only argument, and -- returns true if it meets the selection criteria for the call. -- @return -- True if the test function returns true for any child. --- function container.hasChild(self, class, func) for child in container.eachChild(self, class) do if func(child) then return true end end end --- -- Call out to the container validation to make sure everything -- is as it should be before handing off to the actions. --- function container.validate(self) if type(self.class.validate) == "function" then self.class.validate(self) end end function container.validateChildren(self) for class in container.eachChildClass(self.class) do local children = self[class.pluralName] for i = 1, #children do container.validate(children[i]) end end end
bsd-3-clause
AlexandreCA/update
scripts/zones/Xarcabard/npcs/Pelogrant.lua
17
1856
----------------------------------- -- Area: Xarcabard -- NPC: Pelogrant -- Type: Outpost Vendor -- @pos 210 -22 -201 112 ----------------------------------- package.loaded["scripts/zones/Xarcabard/TextIDs"] = nil; ----------------------------------- require("scripts/globals/shop"); require("scripts/globals/conquest"); require("scripts/zones/Xarcabard/TextIDs"); local region = VALDEAUNIA; local csid = 0x7ff4; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local owner = GetRegionOwner(region); local 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
AlexandreCA/update
scripts/zones/Port_Bastok/npcs/Romilda.lua
36
2365
----------------------------------- -- Area: Port Bastok -- NPC: Romilda -- Involved in Quest: Forever to Hold -- Starts & Ends Quest: Till Death Do Us Part ----------------------------------- package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil; ----------------------------------- require("scripts/globals/titles"); require("scripts/globals/quests"); require("scripts/zones/Port_Bastok/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (trade:hasItemQty(12497,1) and trade:getItemCount() == 1) then -- Trade Brass Hairpin if (player:getVar("ForevertoHold_Event") == 2) then player:tradeComplete(); player:startEvent(0x7D); player:setVar("ForevertoHold_Event",3); end elseif (trade:hasItemQty(12721,1) and trade:getItemCount() == 1) then -- Trade Cotton Gloves if (player:getVar("ForevertoHold_Event") == 3) then player:tradeComplete(); player:startEvent(0x81); player:setVar("ForevertoHold_Event",4); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) pFame = player:getFameLevel(BASTOK); ForevertoHold = player:getQuestStatus(BASTOK,FOREVER_TO_HOLD); TilldeathdousPart = player:getQuestStatus(BASTOK,TILL_DEATH_DO_US_PART); if (pFame >= 3 and ForevertoHold == QUEST_COMPLETED and TilldeathdousPart == QUEST_AVAILABLE and player:getVar("ForevertoHold_Event") == 3) then player:startEvent(0x80); else player:startEvent(0x22); 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 == 0x80) then player:addQuest(BASTOK,TILL_DEATH_DO_US_PART); elseif (csid == 0x81) then player:addTitle(QIJIS_RIVAL); player:addGil(GIL_RATE*2000); player:messageSpecial(GIL_OBTAINED,GIL_RATE*2000); player:addFame(BASTOK,BAS_FAME*160); player:completeQuest(BASTOK,TILL_DEATH_DO_US_PART); end end;
gpl-3.0
AlexandreCA/update
scripts/zones/Southern_San_dOria/npcs/Foletta.lua
36
1433
----------------------------------- -- Area: Southern San d'Oria -- NPC: Foletta -- General Info NPC ------------------------------------- package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/zones/Southern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE); if (FlyerForRegine == 1) then count = trade:getItemCount(); MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(FLYER_REFUSED); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x29a); 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
bmharper/tundra
scripts/tundra/syntax/glob.lua
22
3353
-- glob.lua - Glob syntax elements for declarative tundra.lua usage module(..., package.seeall) local util = require "tundra.util" local path = require "tundra.path" local decl = require "tundra.decl" local dirwalk = require "tundra.dirwalk" local ignored_dirs = util.make_lookup_table { ".git", ".svn", "CVS" } local function glob(directory, recursive, filter_fn) local result = {} local function dir_filter(dir_name) if not recursive or ignored_dirs[dir_name] then return false end return true end for _, path in ipairs(dirwalk.walk(directory, dir_filter)) do if filter_fn(path) then result[#result + 1] = string.gsub(path, "\\", "/") end end return result end -- Glob syntax - Search for source files matching extension list -- -- Synopsis: -- Glob { -- Dir = "...", -- Extensions = { ".ext", ... }, -- [Recursive = false,] -- } -- -- Options: -- Dir = "directory" (required) -- - Base directory to search in -- -- Extensions = { ".ext1", ".ext2" } (required) -- - List of file extensions to include -- -- Recursive = boolean (optional, default: true) -- - Specified whether to recurse into subdirectories function Glob(args) local recursive = args.Recursive if type(recursive) == "nil" then recursive = true end if not args.Extensions then croak("no 'Extensions' specified in Glob (Dir is '%s')", args.Dir) end local extensions = assert(args.Extensions) local ext_lookup = util.make_lookup_table(extensions) return glob(args.Dir, recursive, function (fn) local ext = path.get_extension(fn) return ext_lookup[ext] end) end -- FGlob syntax - Search for source files matching extension list with -- configuration filtering -- -- Usage: -- FGlob { -- Dir = "...", -- Extensions = { ".ext", .... }, -- Filters = { -- { Pattern = "/[Ww]in32/", Config = "win32-*-*" }, -- { Pattern = "/[Dd]ebug/", Config = "*-*-debug" }, -- ... -- }, -- [Recursive = false], -- } local function FGlob(args) -- Use the regular glob to fetch the file list. local files = Glob(args) local pats = {} local result = {} -- Construct a mapping from { Pattern = ..., Config = ... } -- to { Pattern = { Config = ... } } with new arrays per config that can be -- embedded in the source result. for _, fitem in ipairs(args.Filters) do if not fitem.Config then croak("no 'Config' specified in FGlob (Pattern is '%s')", fitem.Pattern) end local tab = { Config = assert(fitem.Config) } pats[assert(fitem.Pattern)] = tab result[#result + 1] = tab end -- Traverse all files and see if they match any configuration filters. If -- they do, stick them in matching list. Otherwise, just keep them in the -- main list. This has the effect of returning an array such as this: -- { -- { "foo.c"; Config = "abc-*-*" }, -- { "bar.c"; Config = "*-*-def" }, -- "baz.c", "qux.m" -- } for _, f in ipairs(files) do local filtered = false for filter, list in pairs(pats) do if f:match(filter) then filtered = true list[#list + 1] = f break end end if not filtered then result[#result + 1] = f end end return result end decl.add_function("Glob", Glob) decl.add_function("FGlob", FGlob)
mit
virgo-agent-toolkit/rackspace-monitoring-agent
tests/schedule/init.lua
4
10960
--[[ Copyright 2012 Rackspace Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --]] local path = require('path') local async = require('async') local utils = require('utils') local timer = require('timer') local string = require('string') local Emitter = require('core').Emitter local Scheduler = require('/schedule').Scheduler local BaseCheck = require('/check/base').BaseCheck local ChildCheck = require('/check/base').ChildCheck local NullCheck = require('/check/null').NullCheck local Check = require('/check') local misc = require('/base/util/misc') local PluginCheck = Check.PluginCheck local exports = {} local function make_check(...) local args = unpack({...}) local check_path = path.join(TEST_DIR, string.format("%s.chk", args.check_path or args.id)) local period = args.period or 1 local id = args.id or 'NOID' local state = args.state or 'OK' local test_check = BaseCheck:extend() function test_check:getType() return "test" end return test_check:new({["id"]=id, ["state"]=state, ["period"]=period, ["path"]=check_path}) end exports['test_scheduler_scans'] = function(test, asserts) local checks = { make_check{id='ch0001'}, make_check{id='ch0002'}, make_check{id='ch0003'}, make_check{id='ch0004'}, } local scheduler = Scheduler:new() scheduler:start() scheduler:rebuild(checks) async.waterfall({ function(callback) scheduler:start() local timeout = timer.setTimeout(5000, function() -- they all should have run. asserts.ok(scheduler._runCount > 0) callback() end) end }, function(err) scheduler:stop() asserts.ok(err == nil) test.done() end) end exports['test_scheduler_adds'] = function(test, asserts) local scheduler local checks = { make_check{id='ch0001'} } local new_checks = { make_check{id='ch0001'}, make_check{id='ch0002'} } async.waterfall({ function(callback) scheduler = Scheduler:new() scheduler:start() scheduler:rebuild(checks) process.nextTick(callback) end, function(callback) scheduler:rebuild(new_checks) scheduler:on('check.completed', misc.nCallbacks(callback, 2)) end }, function(err) asserts.equals(scheduler:numChecks(), 2) scheduler:stop() asserts.ok(err == nil) test.done() end) end exports['test_scheduler_timeout'] = function(test, asserts) local scheduler local checks local done = misc.fireOnce(function() scheduler:stop() test.done() end) checks = { NullCheck:new({id='ch0001', state='OK', period=3}), } checks[1]:on('timeout', done) scheduler = Scheduler:new() scheduler:start() scheduler:rebuild(checks) end local CheckCollection = Emitter:extend() function CheckCollection:initialize(scheduler, checks) self.scheduler = scheduler self.checks = checks end local function createWaitForEvent(eventName) return function(self, count, callback) local function done() self.scheduler:removeListener(eventName) process.nextTick(callback) end local cb = misc.nCallbacks(done, count) self.scheduler:on(eventName, cb) end end CheckCollection.waitForCreated = createWaitForEvent('check.created') CheckCollection.waitForModified = createWaitForEvent('check.modified') CheckCollection.waitForDeleted = createWaitForEvent('check.deleted') function CheckCollection:waitForCheckCompleted(count, callback) local function done() self.scheduler:removeListener('check.completed') callback() end local cb = misc.nCallbacks(done, count) self.scheduler:on('check.completed', function(check) local found = false for _, v in ipairs(self.checks) do if v.id == check.id then found = true end end assert(found == true) cb() end) end exports['test_scheduler_custom_check_reload'] = function(test, asserts) local scheduler, create, update, remove scheduler = Scheduler:new() scheduler:start() create = CheckCollection:new(scheduler, { PluginCheck:new({id='ch0001', state='OK', period=3, details={file='plugin_1.sh'}}) }) update = CheckCollection:new(scheduler, { PluginCheck:new({id='ch0001', state='OK', period=3, details={file='plugin_1.sh', args={'arg1'}}}) }) remove = CheckCollection:new(scheduler, {}) async.series({ function(callback) create:waitForCreated(1, callback) scheduler:rebuild(create.checks) end, function(callback) create:waitForCheckCompleted(3, callback) end, function(callback) update:waitForModified(1, callback) scheduler:rebuild(update.checks) end, function(callback) create:waitForCheckCompleted(3, callback) end, function(callback) local checkMap = scheduler:getCheckMap() asserts.ok(checkMap['ch0001']:toString():find('arg1') ~= nil) callback() end, function(callback) remove:waitForDeleted(1, callback) scheduler:rebuild(remove.checks) end, function(callback) asserts.ok(scheduler:numChecks() == 0) asserts.ok(scheduler:runCheck() > 0) callback() end }, function(err) scheduler:stop() test.done() end) end exports['test_scheduler_custom_check_reload_multiple'] = function(test, asserts) local scheduler, create, remove scheduler = Scheduler:new() scheduler:start() create = CheckCollection:new(scheduler, { PluginCheck:new({id='ch0001', state='OK', period=3, details={file='plugin_1.sh'}}), PluginCheck:new({id='ch0002', state='OK', period=3, details={file='plugin_2.sh'}}) }) remove = CheckCollection:new(scheduler, { PluginCheck:new({id='ch0001', state='OK', period=3, details={file='plugin_1.sh', args={'arg1'}}}) }) async.series({ function(callback) create:waitForCreated(2, callback) scheduler:rebuild(create.checks) end, function(callback) remove:waitForModified(1, callback) scheduler:rebuild(remove.checks) end, function(callback) local checkMap = scheduler:getCheckMap() asserts.ok(checkMap['ch0002'] == nil) asserts.ok(checkMap['ch0001']:toString():find('arg1') ~= nil) callback() end, function(callback) remove:waitForCheckCompleted(5, callback) end }, function(err) scheduler:stop() test.done() end) end exports['test_scheduler_custom_check_reload'] = function(test, asserts) local scheduler, create, update, remove scheduler = Scheduler:new() scheduler:start() create = CheckCollection:new(scheduler, { PluginCheck:new({id='ch0001', state='OK', period=3, details={file='plugin_1.sh'}}) }) update = CheckCollection:new(scheduler, { PluginCheck:new({id='ch0001', state='OK', period=3, details={file='plugin_1.sh', args={'arg1'}}}) }) remove = CheckCollection:new(scheduler, {}) async.series({ function(callback) create:waitForCreated(1, callback) scheduler:rebuild(create.checks) end, function(callback) create:waitForCheckCompleted(3, callback) end, function(callback) update:waitForModified(1, callback) scheduler:rebuild(update.checks) end, function(callback) create:waitForCheckCompleted(3, callback) end, function(callback) local checkMap = scheduler:getCheckMap() asserts.ok(checkMap['ch0001']:toString():find('arg1') ~= nil) callback() end, function(callback) remove:waitForDeleted(1, callback) scheduler:rebuild(remove) end, function(callback) asserts.ok(scheduler:numChecks() == 0) asserts.ok(scheduler:runCheck() > 0) callback() end }, function(err) scheduler:stop() test.done() end) end exports['test_scheduler_custom_check_reload_multiple_adds_removes'] = function(test, asserts) local scheduler, create1, remove1, remove2, create2 scheduler = Scheduler:new() scheduler:start() create1 = CheckCollection:new(scheduler, { PluginCheck:new({id='ch0001', state='OK', period=3, details={file='plugin_1.sh'}}), PluginCheck:new({id='ch0002', state='OK', period=3, details={file='plugin_2.sh'}}) }) remove1 = CheckCollection:new(scheduler, { PluginCheck:new({id='ch0001', state='OK', period=3, details={file='plugin_1.sh', args={'arg1'}}}) }) remove2 = CheckCollection:new(scheduler, {}) create2 = CheckCollection:new(scheduler, { PluginCheck:new({id='ch0003', state='OK', period=3, details={file='plugin_3.sh'}}) }) async.series({ function(callback) create1:waitForCreated(2, callback) scheduler:rebuild(create1.checks) end, function(callback) remove1:waitForModified(1, callback) scheduler:rebuild(remove1.checks) end, function(callback) remove1:waitForCheckCompleted(2, callback) end, function(callback) remove2:waitForDeleted(1, callback) scheduler:rebuild(remove2.checks) end, function(callback) create2:waitForCreated(1, callback) scheduler:rebuild(create2.checks) end, function(callback) create2:waitForCheckCompleted(2, callback) end, function(callback) asserts.ok(scheduler:numChecks() == 1) local checkMap = scheduler:getCheckMap() asserts.ok(checkMap['ch0003']:toString() ~= nil) asserts.ok(checkMap['ch0002'] == nil) asserts.ok(checkMap['ch0001'] == nil) callback() end }, function(err) scheduler:stop() test.done() end) end exports['test_scheduler_plugin_file_update'] = function(test, asserts) local scheduler, create, update scheduler = Scheduler:new() scheduler:start() create = CheckCollection:new(scheduler, { PluginCheck:new({id='ch0001', state='OK', period=3, details={file='plugin_1.sh'}}), }) update = CheckCollection:new(scheduler, { PluginCheck:new({id='ch0001', state='OK', period=3, details={file='plugin_2.sh', args={'arg1'}}}) }) async.series({ function(callback) create:waitForCreated(1, callback) scheduler:rebuild(create.checks) end, function(callback) update:waitForModified(1, callback) scheduler:rebuild(update.checks) end, function(callback) local checkMap = scheduler:getCheckMap() asserts.ok(checkMap['ch0001']:toString():find('plugin_2') ~= nil) callback() end, function(callback) update:waitForCheckCompleted(5, callback) end }, function(err) scheduler:stop() test.done() end) end return exports
apache-2.0
AlexandreCA/update
scripts/globals/campaign.lua
18
4903
----------------------------------------------------------------- -- Variable for getNationTeleport and getPoint ----------------------------------------------------------------- ALLIED_NOTES = 11; MAW = 4; PAST_SANDORIA = 5; PAST_BASTOK = 6; PAST_WINDURST = 7; -- ------------------------------------------------------------------- -- getMedalRank() -- Returns the numerical Campaign Medal of the player. -- ------------------------------------------------------------------- function getMedalRank(player) local rank = 0; local medals = { 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, 0x03A1, 0x03A2, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF } while (player:hasKeyItem(medals[rank + 1]) == true) do rank = rank + 1; end; return rank; end; -- ------------------------------------------------------------------- -- get[nation]NotesItem() -- Returns the item ID and cost of the Allied Notes indexed item -- (the same value as that used by the vendor event) -- Format: -- ListName_AN_item[optionID] = itemID; -- ItemName -- ListName_AN_price[optionID] = cost; -- ItemName -- ------------------------------------------------------------------- function getSandOriaNotesItem(i) local SandOria_AN = { [2] = {id = 15754, price = 980}, -- Sprinter's Shoes [258] = {id = 5428, price = 10}, -- Scroll of Instant Retrace [514] = {id = 14584, price = 1500}, -- Iron Ram jack coat [770] = {id = 14587, price = 1500}, -- Pilgrim Tunica [1026] = {id = 16172, price = 4500}, -- Iron Ram Shield [1282] = {id = 15841, price = 5000}, -- Recall Ring: Jugner [1538] = {id = 15842, price = 5000}, -- Recall Ring: Pashow [1794] = {id = 15843, price = 5000}, -- Recall Ring: Meriphataud [2050] = {id = 10116, price = 2000} -- Cipher: Valaineral } local item = SandOria_AN[i]; return item.id, item.price; end; function getBastokNotesItem(i) local Bastok_AN = { [2] = {id = 15754, price = 980}, -- Sprinter's Shoes [258] = {id = 5428, price = 10}, -- Scroll of Instant Retrace -- [514] = {id = ?, price = ?}, -- -- [770] = {id = ?, price = ?}, -- -- [1026] = {id = ?, price = ?}, -- [1282] = {id = 15841, price = 5000}, -- Recall Ring: Jugner [1538] = {id = 15842, price = 5000}, -- Recall Ring: Pashow [1794] = {id = 15843, price = 5000}, -- Recall Ring: Meriphataud [2050] = {id = 10116, price = 2000} -- Cipher: Valaineral } local item = Bastok_AN[i]; return item.id, item.price; end; function getWindurstNotesItem(i) local Windurst_AN = { [2] = {id = 15754, price = 980}, -- Sprinter's Shoes [258] = {id = 5428, price = 10}, -- Scroll of Instant Retrace -- [514] = {id = ?, price = ?}, -- -- [770] = {id = ?, price = ?}, -- -- [1026] = {id = ?, price = ?}, -- [1282] = {id = 15841, price = 5000}, -- Recall Ring: Jugner [1538] = {id = 15842, price = 5000}, -- Recall Ring: Pashow [1794] = {id = 15843, price = 5000}, -- Recall Ring: Meriphataud [2050] = {id = 10116, price = 2000} -- Cipher: Valaineral } local item = Windurst_AN[i]; return item.id, item.price; end; -- ------------------------------------------------------------------- -- getSigilTimeStamp(player) -- This is for the time-stamp telling player what day/time the -- effect will last until, NOT the actual status effect duration. -- ------------------------------------------------------------------- function getSigilTimeStamp(player) local timeStamp = 0; -- zero'd till math is done. -- TODO: calculate time stamp for menu display of when it wears off return timeStamp; end; ----------------------------------- -- hasMawActivated Action ----------------------------------- -- 1st number for hasMawActivated() -- 2nd number for player:addNationTeleport(); -- 0 1 Batallia Downs (S) (H-5) -- 1 2 Rolanberry Fields (S) (H-6) -- 2 4 Sauromugue Champaign (S) (K-9) -- 3 8 Jugner Forest (S) (H-11) -- 4 16 Pashhow Marshlands (S) (K-8) -- 5 32 Meriphataud Mountains (S) (K-6) -- 6 64 East Ronfaure (S) (H-5) -- 7 128 North Gustaberg (S) (K-7) -- 8 256 West Sarutabaruta (S) (H-9) function hasMawActivated(player,portal) local mawActivated = player:getNationTeleport(MAW); local bit = {}; for i = 8,0,-1 do twop = 2^i if (mawActivated >= twop) then bit[i]=true; mawActivated = mawActivated - twop; else bit[i]=false; end end; return bit[portal]; end; -- TODO: -- Past nation teleport
gpl-3.0
tartina/ardour
share/scripts/scl_to_mts.lua
2
10005
ardour { ["type"] = "EditorAction", name = "Scala to MIDI Tuning", license = "MIT", author = "Ardour Team", description = [[Read scala (.scl) tuning from a file, generate MIDI tuning standard (MTS) messages and send them to a MIDI port]] } function factory () return function () -- return table of all MIDI tracks, and all instrument plugins. -- -- MidiTrack::write_immediate_event() injects MIDI events to the track's input -- PluginInsert::write_immediate_event() sends events directly to a plugin function midi_targets () local rv = {} for r in Session:get_tracks():iter() do if not r:to_track():isnil() then local mtr = r:to_track():to_midi_track() if not mtr:isnil() then rv["Track: '" .. r:name() .. "'"] = mtr end end local i = 0; while true do local proc = r:nth_plugin (i) if proc:isnil () then break end local pi = proc:to_plugininsert () if pi:is_instrument () then rv["Track: '" .. r:name() .. "' | Plugin: '" .. pi:name() .. "'"] = pi end i = i + 1 end end return rv end function log2 (v) return math.log (v) / math.log (2) end -- calculate MIDI note-number and cent-offset for a given frequency -- -- "The first byte of the frequency data word specifies the nearest equal-tempered -- semitone below the frequency. The next two bytes (14 bits) specify the fraction -- of 100 cents above the semitone at which the frequency lies." -- -- 68 7F 7F = 439.9984 Hz -- 69 00 00 = 440.0000 Hz -- 69 00 01 = 440.0016 Hz -- -- NB. 7F 7F 7F = no change (reserved) -- function freq_to_mts (hz) local note = math.floor (12. * log2 (hz / 440) + 69.0) local freq = 440.0 * 2.0 ^ ((note - 69) / 12); local cent = 1200.0 * log2 (hz / freq) -- fixup rounding errors if cent >= 99.99 then note = note + 1 cent = 0 end if cent < 0 then cent = 0 end return note, cent end local dialog_options = { { type = "file", key = "file", title = "Select .scl file" }, { type = "checkbox", key = "bulk", default = false, title = "Bulk Transfer (not realtime)" }, { type = "dropdown", key = "tx", title = "MIDI SysEx Target", values = midi_targets () } } local rv = LuaDialog.Dialog ("Select Scala File and MIDI Taget", dialog_options):run () dialog_options = nil -- drop references (track, plugins, shared ptr) collectgarbage () -- and release the references immediately if not rv then return end -- user cancelled -- read the scl file local freqtbl = {} local ln = 0 local expected_len = 0 local f = io.open (rv["file"], "r") if not f then LuaDialog.Message ("Scala to MTS", "File Not Found", LuaDialog.MessageType.Error, LuaDialog.ButtonType.Close):run () return end -- parse scala file and convert all intervals to cents -- http://www.huygens-fokker.org/scala/scl_format.html freqtbl[1] = 0.0 -- implicit for line in f:lines () do line = string.gsub (line, "%s", "") -- remove all whitespace if line:sub(0,1) == '!' then goto nextline end -- comment ln = ln + 1 if ln < 2 then goto nextline end -- name if ln < 3 then expected_len = tonumber (line) -- number of notes on scale if expected_len < 1 or expected_len > 256 then break end -- invalid file goto nextline end local cents if string.find (line, ".", 1, true) then cents = tonumber (line) else local n, d = string.match(line, "(%d+)/(%d+)") if n then cents = 1200 * log2 (n / d) else local n = tonumber (line) cents = 1200 * log2 (n) end end --print ("SCL", ln - 2, cents) freqtbl[ln - 1] = cents ::nextline:: end f:close () -- We need at least one interval. -- While legal in scl, single note scales are not useful here. if expected_len < 1 or expected_len + 2 ~= ln then LuaDialog.Message ("Scala to MTS", "Invalid or unusable scale file.", LuaDialog.MessageType.Error, LuaDialog.ButtonType.Close):run () return end assert (expected_len + 2 == ln) assert (expected_len > 0) ----------------------------------------------------------------------------- -- TODO consider reading a .kbm file or make these configurable in the dialog -- http://www.huygens-fokker.org/scala/help.htm#mappings local ref_note = 69 -- Reference note for which frequency is given local ref_freq = 440.0 -- Frequency to tune the above note to local ref_root = 60 -- root-note of the scale, note where the first entry of the scale is mapped to local note_start = 0 local note_end = 127 ----------------------------------------------------------------------------- -- prepare sending data local send_bulk = rv['bulk'] local tx = rv["tx"] -- output port local parser = ARDOUR.RawMidiParser () -- construct a MIDI parser local checksum = 0 if send_bulk then note_start = 0 note_end = 127 end --local dump = io.open ("/tmp/dump.syx", "wb") -- helper function to send MIDI function tx_midi (syx, len, hdr) for b = 1, len do --dump:write (string.char(syx:byte (b))) -- calculate checksum, xor of all payload data -- (excluding the 0xf0, 0xf7, and the checksum field) if b >= hdr then checksum = checksum ~ syx:byte (b) end -- parse message to C/C++ uint8_t* array (Validate message correctness. This -- also returns C/C++ uint8_t* array for direct use with write_immediate_event.) if parser:process_byte (syx:byte (b)) then tx:write_immediate_event (Evoral.EventType.MIDI_EVENT, parser:buffer_size (), parser:midi_buffer ()) -- Slow things down a bit to ensure that no messages as lost. -- Physical MIDI is sent at 31.25kBaud. -- Every message is sent as 10bit message on the wire, -- so every MIDI byte needs 320usec. ARDOUR.LuaAPI.usleep (400 * parser:buffer_size ()) end end end -- show progress dialog local pdialog = LuaDialog.ProgressWindow ("Scala to MIDI Tuning", true) pdialog:progress (0, "Tuning"); -- calculate frequency at ref_root local delta = ref_note - ref_root local delta_octv = math.floor (delta / expected_len) local delta_note = delta % expected_len -- inverse mapping, ref_note will have the specified frequency in the target scale, -- while the scale itself will start at ref_root local ref_base = ref_freq * 2 ^ ((freqtbl[delta_note + 1] + freqtbl[expected_len + 1] * delta_octv) / -1200) if send_bulk then -- MIDI Tuning message -- http://technogems.blogspot.com/2018/07/using-midi-tuning-specification-mts.html -- http://www.ludovico.net/download/materiale_didattico/midi/08_midi_tuning.pdf local syx = string.char ( 0xf0, 0x7e, -- non-realtime sysex 0x00, -- target-id 0x08, 0x01, -- tuning, bulk dump reply 0x00, -- tuning program number 0 to 127 in hexadecimal -- 16 chars name (zero padded) 0x53, 0x63, 0x6C, 0x2D, 0x4D, 0x54, 0x53, 0x00, -- Scl-MTS 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ) tx_midi (syx, 22, 1) end -- iterate over MIDI notes for nn = note_start, note_end do if pdialog:canceled () then break end -- calculate the note relative to kbm's ref_root delta = nn - ref_root delta_octv = math.floor (delta / expected_len) delta_note = delta % expected_len -- calculate the frequency of the note according to the scl local fq = ref_base * 2 ^ ((freqtbl[delta_note + 1] + freqtbl[expected_len + 1] * delta_octv) / 1200) -- and then convert this frequency to the MIDI note number (and cent offset) local base, cent = freq_to_mts (fq) -- MTS uses two MIDI bytes (2^14) for cents local cc = math.floor (163.83 * cent + 0.5) | 0 local cent_msb = (cc >> 7) & 127 local cent_lsb = cc & 127 --[[ print (string.format ("MIDI-Note %3d | Octv: %+d Note: %2d -> Freq: %8.2f Hz = note: %3d + %6.3f ct (0x%02x 0x%02x 0x%02x)", nn, delta_octv, delta_note, fq, base, cent, base, cent_msb, cent_lsb)) --]] if (base < 0 or base > 127) then if send_bulk then if base < 0 then base = 0 else base = 127 end cent_msb = 0 cent_lsb = 0 else -- skip out of bounds MIDI notes goto continue end end if send_bulk then local syx = string.char ( base, -- semitone (MIDI note number to retune to, unit is 100 cents) cent_msb, -- MSB of fractional part (1/128 semitone = 100/128 cents = .78125 cent units) cent_lsb, -- LSB of fractional part (1/16384 semitone = 100/16384 cents = .0061 cent units) 0xf7 ) tx_midi (syx, 3, 0) else checksum = 0x07 -- really unused -- MIDI Tuning message -- http://www.microtonal-synthesis.com/MIDItuning.html local syx = string.char ( 0xf0, 0x7f, -- realtime sysex 0x7f, -- target-id 0x08, 0x02, -- tuning, note change request 0x00, -- tuning program number 0 to 127 in hexadecimal 0x01, -- number of notes to be changed nn, -- note number to be changed base, -- semitone (MIDI note number to retune to, unit is 100 cents) cent_msb, -- MSB of fractional part (1/128 semitone = 100/128 cents = .78125 cent units) cent_lsb, -- LSB of fractional part (1/16384 semitone = 100/16384 cents = .0061 cent units) 0xf7 ) tx_midi (syx, 12, 0) end -- show progress pdialog:progress (nn / 127, string.format ("Note %d freq: %.2f (%d + %d)", nn, fq, base, cc)) if pdialog:canceled () then break end ::continue:: end if send_bulk and not pdialog:canceled () then tx_midi (string.char ((checksum & 127), 0xf7), 2, 2) end -- hide modal progress dialog and destroy it pdialog:done (); tx = nil parser = nil collectgarbage () -- and release any references --dump:close () end end -- simple icon function icon (params) return function (ctx, width, height, fg) ctx:set_source_rgba (ARDOUR.LuaAPI.color_to_rgba (fg)) local txt = Cairo.PangoLayout (ctx, "ArdourMono ".. math.ceil(math.min (width, height) * .45) .. "px") txt:set_text ("SCL\nMTS") local tw, th = txt:get_pixel_size () ctx:move_to (.5 * (width - tw), .5 * (height - th)) txt:show_in_cairo_context (ctx) end end
gpl-2.0
AlexandreCA/darkstar
scripts/zones/Port_Windurst/npcs/Ten_of_Clubs.lua
13
1054
----------------------------------- -- Area: Port Windurst -- NPC: Ten of Clubs -- Type: Standard NPC -- @zone: 240 -- @pos -229.393 -9.2 182.696 -- -- Auto-Script: Requires Verification (Verfied By Brawndo) ----------------------------------- package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x004b); 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
AlexandreCA/update
scripts/globals/items/dish_of_spaghetti_peperoncino_+1.lua
35
1403
----------------------------------------- -- ID: 5197 -- Item: dish_of_spaghetti_peperoncino_+1 -- Food Effect: 60Min, All Races ----------------------------------------- -- Health % 30 -- Health Cap 75 -- Vitality 2 -- Store TP 6 ----------------------------------------- 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,3600,5197); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_FOOD_HPP, 30); target:addMod(MOD_FOOD_HP_CAP, 75); target:addMod(MOD_VIT, 2); target:addMod(MOD_STORETP, 6); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_FOOD_HPP, 30); target:delMod(MOD_FOOD_HP_CAP, 75); target:delMod(MOD_VIT, 2); target:delMod(MOD_STORETP, 6); end;
gpl-3.0
AlexandreCA/update
scripts/zones/Mount_Zhayolm/npcs/qm4.lua
30
1342
----------------------------------- -- Area: Mount Zhayolm -- NPC: ??? (Spawn Khromasoul Bhurborlor(ZNM T3)) -- @pos 88 -22 70 61 ----------------------------------- package.loaded["scripts/zones/Mount_Zhayolm/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Mount_Zhayolm/TextIDs"); require("scripts/globals/status"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local mobID = 17027474; if (trade:hasItemQty(2585,1) and trade:getItemCount() == 1) then -- Trade Vinegar Pie if (GetMobAction(mobID) == ACTION_NONE) then player:tradeComplete(); SpawnMob(mobID):updateClaim(player); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:messageSpecial(NOTHING_HAPPENS); 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
AlexandreCA/update
scripts/zones/Xarcabard/npcs/Cavernous_Maw.lua
58
1897
----------------------------------- -- Area: Xarcabard -- NPC: Cavernous Maw -- @pos 270 -9 -70 -- Teleports Players to Abyssea - Uleguerand ----------------------------------- package.loaded["scripts/zones/Xarcabard/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/globals/abyssea"); require("scripts/zones/Xarcabard/TextIDs"); ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (ENABLE_ABYSSEA == 1 and player:getMainLvl() >= 30) then local HasStone = getTravStonesTotal(player); if (HasStone >= 1 and player:getQuestStatus(ABYSSEA, DAWN_OF_DEATH) == QUEST_ACCEPTED and player:getQuestStatus(ABYSSEA, A_MAN_EATING_MITE) == QUEST_AVAILABLE) then player:startEvent(58); else player:startEvent(204,0,1); -- No param = no entry. end else player:messageSpecial(NOTHING_HAPPENS); 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 == 58) then player:addQuest(ABYSSEA, A_MAN_EATING_MITE); elseif (csid == 59) then -- Killed Resheph elseif (csid == 204 and option == 1) then player:setPos(-240, -40, -520, 251, 253); end end;
gpl-3.0
AlexandreCA/update
scripts/zones/East_Sarutabaruta/Zone.lua
17
5606
----------------------------------- -- -- Zone: East_Sarutabaruta (116) -- ----------------------------------- package.loaded[ "scripts/zones/East_Sarutabaruta/TextIDs"] = nil; package.loaded["scripts/globals/chocobo_digging"] = nil; ----------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/missions"); require("scripts/globals/icanheararainbow"); require("scripts/zones/East_Sarutabaruta/TextIDs"); require("scripts/globals/zone"); require("scripts/globals/chocobo_digging"); ----------------------------------- -- Chocobo Digging vars ----------------------------------- local itemMap = { -- itemid, abundance, requirement { 689, 132, DIGREQ_NONE }, { 938, 79, DIGREQ_NONE }, { 17296, 132, DIGREQ_NONE }, { 847, 100, DIGREQ_NONE }, { 846, 53, DIGREQ_NONE }, { 833, 100, DIGREQ_NONE }, { 841, 53, DIGREQ_NONE }, { 834, 26, DIGREQ_NONE }, { 772, 50, DIGREQ_NONE }, { 701, 50, DIGREQ_NONE }, { 702, 3, DIGREQ_NONE }, { 4096, 100, DIGREQ_NONE }, -- all crystals { 4545, 200, DIGREQ_BURROW }, { 636, 50, DIGREQ_BURROW }, { 5235, 10, DIGREQ_BURROW }, { 617, 50, DIGREQ_BORE }, { 4570, 10, DIGREQ_MODIFIER }, { 4487, 11, DIGREQ_MODIFIER }, { 4409, 12, DIGREQ_MODIFIER }, { 1188, 10, DIGREQ_MODIFIER }, { 4532, 12, DIGREQ_MODIFIER }, { 572, 100, DIGREQ_NIGHT }, }; 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 = {17253061,17253062,17253063}; SetFieldManual(manuals); end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn( player, prevZone) local cs = -1; if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then player:setPos(305.377,-36.092,660.435,71); end -- Check if we are on Windurst Mission 1-2 if (player:getCurrentMission( WINDURST) == THE_HEART_OF_THE_MATTER and player:getVar( "MissionStatus") == 5 and prevZone == 194) then cs = 0x0030; elseif (triggerLightCutscene(player)) then -- Quest: I Can Hear A Rainbow cs = 0x0032; elseif (player:getCurrentMission(WINDURST) == VAIN and player:getVar("MissionStatus") ==1) then cs = 0x0034; -- go north no parameters (0 = north NE 1 E 2 SE 3 S 4 SW 5 W6 NW 7 @ as the 6th parameter) elseif (player:getCurrentMission(ASA) == BURGEONING_DREAD and prevZone == 241 and player:hasStatusEffect(EFFECT_CHOCOBO) == false ) then cs = 0x0047; 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) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate( player, csid, option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x0032) then lightCutsceneUpdate(player); -- Quest: I Can Hear A Rainbow elseif (csid == 0x0034) then if (player:getPreviousZone() == 241 or player:getPreviousZone() == 115) then if (player:getZPos() < 570) then player:updateEvent(0,0,0,0,0,1); else player:updateEvent(0,0,0,0,0,2); end elseif (player:getPreviousZone() == 194) then if (player:getZPos() > 570) then player:updateEvent(0,0,0,0,0,2); end end elseif (csid == 0x0047) then player:setVar("ASA_Status",option); end end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish( player, csid, option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x0030) then player:setVar( "MissionStatus",6); -- Remove the glowing orb key items player:delKeyItem(FIRST_GLOWING_MANA_ORB); player:delKeyItem(SECOND_GLOWING_MANA_ORB); player:delKeyItem(THIRD_GLOWING_MANA_ORB); player:delKeyItem(FOURTH_GLOWING_MANA_ORB); player:delKeyItem(FIFTH_GLOWING_MANA_ORB); player:delKeyItem(SIXTH_GLOWING_MANA_ORB); elseif (csid == 0x0032) then lightCutsceneFinish(player); -- Quest: I Can Hear A Rainbow elseif (csid == 0x0047) then player:completeMission(ASA,BURGEONING_DREAD); player:addMission(ASA,THAT_WHICH_CURDLES_BLOOD); end end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Arrapago_Reef/npcs/_jic.lua
27
3547
----------------------------------- -- Area: Arrapago Reef -- Door: Runic Seal -- @pos 36 -10 620 54 ----------------------------------- package.loaded["scripts/zones/Arrapago_Reef/TextIDs"] = nil; ----------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/missions"); require("scripts/globals/besieged"); require("scripts/zones/Arrapago_Reef/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:hasKeyItem(ILRUSI_ASSAULT_ORDERS)) then local assaultid = player:getCurrentAssault(); local recommendedLevel = getRecommendedAssaultLevel(assaultid); local armband = 0; if (player:hasKeyItem(ASSAULT_ARMBAND)) then armband = 1; end player:startEvent(0x00DB, assaultid, -4, 0, recommendedLevel, 2, armband); else player:messageSpecial(NOTHING_HAPPENS); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option,target) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); local assaultid = player:getCurrentAssault(); local cap = bit.band(option, 0x03); if (cap == 0) then cap = 99; elseif (cap == 1) then cap = 70; elseif (cap == 2) then cap = 60; else cap = 50; end player:setVar("AssaultCap", cap); local party = player:getParty(); if (party ~= nil) then for i,v in ipairs(party) do if (not (v:hasKeyItem(ILRUSI_ASSAULT_ORDERS) and v:getCurrentAssault() == assaultid)) then player:messageText(target,MEMBER_NO_REQS, false); player:instanceEntry(target,1); return; elseif (v:getZone() == player:getZone() and v:checkDistance(player) > 50) then player:messageText(target,MEMBER_TOO_FAR, false); player:instanceEntry(target,1); return; end end end player:createInstance(player:getCurrentAssault(), 55); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option,target) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x6C or (csid == 0xDB and option == 4)) then player:setPos(0,0,0,0,55); end end; ----------------------------------- -- onInstanceLoaded ----------------------------------- function onInstanceCreated(player,target,instance) if (instance) then instance:setLevelCap(player:getVar("AssaultCap")); player:setVar("AssaultCap", 0); player:setInstance(instance); player:instanceEntry(target,4); player:delKeyItem(ILRUSI_ASSAULT_ORDERS); player:delKeyItem(ASSAULT_ARMBAND); if (party ~= nil) then for i,v in ipairs(party) do if v:getID() ~= player:getID() and v:getZone() == player:getZone() then v:setInstance(instance); v:startEvent(0x6C, 2); v:delKeyItem(ILRUSI_ASSAULT_ORDERS); end end end else player:messageText(target,CANNOT_ENTER, false); player:instanceEntry(target,3); end end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Port_Windurst/npcs/Odilia.lua
13
1044
----------------------------------- -- Area: Port Windurst -- NPC: Odilia -- Type: Standard NPC -- @zone: 240 -- @pos 78.801 -6 118.653 -- -- Auto-Script: Requires Verification (Verfied By Brawndo) ----------------------------------- package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x0121); 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
AlexandreCA/darkstar
scripts/zones/Windurst_Waters/npcs/HomePoint#3.lua
13
1270
----------------------------------- -- Area: Windurst Waters -- NPC: HomePoint#3 -- @pos: 4 -4 -174 238 ----------------------------------- package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil; require("scripts/globals/settings"); require("scripts/zones/Windurst_Waters/TextIDs"); require("scripts/globals/homepoint"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) homepointMenu( player, 0x21fe, 103); 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 == 0x21fe) then if (option == 1) then player:setHomePoint(); player:messageSpecial(HOMEPOINT_SET); else hpTeleport( player, option); end end end;
gpl-3.0
AlexandreCA/update
scripts/zones/Aht_Urhgan_Whitegate/npcs/Naja_Salaheem.lua
18
4974
----------------------------------- -- Area: Aht Urhgan Whitegate -- NPC: Naja Salaheem -- Type: Standard NPC -- @pos 22.700 -8.804 -45.591 50 ----------------------------------- package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil; ----------------------------------- require("scripts/globals/missions"); require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs"); require("scripts/globals/titles"); require("scripts/globals/keyitems"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local TOAUM3_DAY = player:getVar("TOAUM3_STARTDAY"); local realday = tonumber(os.date("%j")); -- %M for next minute, %j for next day local needToZone = player:needToZone(); if (player:getCurrentMission(TOAU) == IMMORTAL_SENTRIES) then if (player:getVar("TOAUM2") == 1 or player:getVar("TOAUM2") == 2) then player:startEvent(0x0BBA,0,0,0,0,0,0,0,0,0); end elseif (player:getCurrentMission(TOAU) == PRESIDENT_SALAHEEM and player:getVar("TOAUM3") == 1) then player:startEvent(0x0049,0,0,0,0,0,0,0,0,0); elseif (player:getCurrentMission(TOAU) == PRESIDENT_SALAHEEM and player:getVar("TOAUM3") == 2 and TOAUM3_DAY ~= realday and needToZone == true) then player:startEvent(0x0BCC,0,0,0,0,0,0,0,0,0); elseif (player:getCurrentMission(TOAU) == KNIGHT_OF_GOLD and player:getVar("TOAUM4") == 0) then player:startEvent(0x0bcd,0,0,0,0,0,0,0,0,0); elseif (player:getCurrentMission(TOAU) == WESTERLY_WINDS and player:getVar("TOAUM7") == 1) then player:startEvent(0x0Bd4,0,0,0,0,0,0,0,0,0); elseif (player:getCurrentMission(TOAU) == UNDERSEA_SCOUTING) then player:startEvent(0x0beb,0,0,0,0,0,0,0,0,0); elseif (player:getCurrentMission(TOAU) == ASTRAL_WAVES) then player:startEvent(0x0bec,0,0,0,0,0,0,0,0,0); elseif (player:getCurrentMission(TOAU) == IMPERIAL_SCHEMES) then player:startEvent(0x0bfe,0,0,0,0,0,0,0,0,0); elseif (player:getCurrentMission(TOAU) == ROYAL_PUPPETEER) then player:startEvent(0x0bff,0,0,0,0,0,0,0,0,0); elseif (player:getCurrentMission(TOAU) == THE_DOLPHIN_CREST) then player:startEvent(0x0c00,0,0,0,0,0,0,0,0,0); elseif (player:getCurrentMission(TOAU) == THE_BLACK_COFFIN) then player:startEvent(0x0c01,0,0,0,0,0,0,0,0,0); elseif (player:getCurrentMission(TOAU) == GHOSTS_OF_THE_PAST) then player:startEvent(0x0c02,0,0,0,0,0,0,0,0,0); else player:startEvent(0x0bbb,1,0,0,0,0,0,0,1,0) -- go back to work -- player:messageSpecial(0);-- need to find correct normal chat CS.. 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 == 0x0BBA) then player:setVar("TOAUM2",0); player:completeMission(TOAU,IMMORTAL_SENTRIES); player:addMission(TOAU,PRESIDENT_SALAHEEM); player:addCurrency("imperial_standing", 150); player:addTitle(PRIVATE_SECOND_CLASS); player:addKeyItem(PSC_WILDCAT_BADGE); player:messageSpecial(KEYITEM_OBTAINED,PSC_WILDCAT_BADGE); elseif (csid == 0x0BCC) then player:completeMission(TOAU,PRESIDENT_SALAHEEM); player:addMission(TOAU,KNIGHT_OF_GOLD); player:setVar("TOAUM3",0); player:setVar("TOAUM3_DAY", 0); elseif (csid == 0x0049) then player:setVar("TOAUM3",2); player:setVar("TOAUM3_DAY", os.date("%j")); -- %M for next minute, %j for next day elseif (csid == 0x0bd4) then player:setVar("TOAUM7",0) player:completeMission(TOAU,WESTERLY_WINDS) player:addMission(TOAU,A_MERCENARY_LIFE) if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,2185); else player:addItem(2185,1) player:messageSpecial(ITEM_OBTAINED,2185) player:addItem(2185,1) end elseif (csid == 0x0bec) then player:completeMission(TOAU,ASTRAL_WAVES); player:addMission(TOAU,IMPERIAL_SCHEMES); elseif (csid == 0x0bfe) then player:completeMission(TOAU,IMPERIAL_SCHEMES); player:addMission(TOAU,ROYAL_PUPPETEER); elseif (csid == 0x0c00) then player:completeMission(TOAU,THE_DOLPHIN_CREST); player:addMission(TOAU,THE_BLACK_COFFIN); elseif (csid == 0x0c02) then player:completeMission(TOAU,GHOSTS_OF_THE_PAST); player:addMission(TOAU,GUESTS_OF_THE_EMPIRE); end end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Bastok_Markets/npcs/Marin.lua
13
1136
----------------------------------- -- Area: Bastok Markets -- NPC: Marin -- Type: Quest Giver -- @zone: 235 -- @pos -340.060 -11.003 -148.181 -- -- Auto-Script: Requires Verification. Verified standard dialog is also "All By Myself" repeatable quest. - thrydwolf 12/18/2011 ----------------------------------- 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:startEvent(0x0169); 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
AlexandreCA/update
scripts/zones/Bostaunieux_Oubliette/npcs/Grounds_Tome.lua
34
1160
----------------------------------- -- Area: Bostaunieux Oubliette -- NPC: Grounds Tome ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/groundsofvalor"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) startGov(GOV_EVENT_BOSTAUNIEUX_OUBLIETTE,player); end; ----------------------------------- -- onEventSelection ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); updateGov(player,csid,option,610,611,612,613,614,615,616,617,0,0); end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); finishGov(player,csid,option,610,611,612,613,614,615,616,617,0,0,GOV_MSG_BOSTAUNIEUX_OUBLIETTE); end;
gpl-3.0
AlexandreCA/update
scripts/zones/Fort_Karugo-Narugo_[S]/npcs/Mortimer.lua
35
1055
---------------------------------- -- Area: Fort Karugo Narugo [S] -- NPC: Mortimer -- Type: Item Deliverer -- @zone: 96 -- @pos -24.08 -68.508 93.88 -- ----------------------------------- package.loaded["scripts/zones/Fort_Karugo-Narugo_[S]/TextIDs"] = nil; require("scripts/zones/Fort_Karugo-Narugo_[S]/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc, ITEM_DELIVERY_DIALOG); player:openSendBox(); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
amirmrbad/paydarbot
plugins/anti_flood.lua
281
2422
local NUM_MSG_MAX = 5 -- Max number of messages per TIME_CHECK seconds local TIME_CHECK = 5 local function kick_user(user_id, chat_id) local chat = 'chat#id'..chat_id local user = 'user#id'..user_id chat_del_user(chat, user, function (data, success, result) if success ~= 1 then local text = 'I can\'t kick '..data.user..' but should be kicked' send_msg(data.chat, '', ok_cb, nil) end end, {chat=chat, user=user}) end local function run (msg, matches) if msg.to.type ~= 'chat' then return 'Anti-flood works only on channels' else local chat = msg.to.id local hash = 'anti-flood:enabled:'..chat if matches[1] == 'enable' then redis:set(hash, true) return 'Anti-flood enabled on chat' end if matches[1] == 'disable' then redis:del(hash) return 'Anti-flood disabled on chat' end end end local function pre_process (msg) -- Ignore service msg if msg.service then print('Service message') return msg end local hash_enable = 'anti-flood:enabled:'..msg.to.id local enabled = redis:get(hash_enable) if enabled then print('anti-flood enabled') -- Check flood if msg.from.type == 'user' then -- Increase the number of messages from the user on the chat local hash = 'anti-flood:'..msg.from.id..':'..msg.to.id..':msg-num' local msgs = tonumber(redis:get(hash) or 0) if msgs > NUM_MSG_MAX then local receiver = get_receiver(msg) local user = msg.from.id local text = 'User '..user..' is flooding' local chat = msg.to.id send_msg(receiver, text, ok_cb, nil) if msg.to.type ~= 'chat' then print("Flood in not a chat group!") elseif user == tostring(our_id) then print('I won\'t kick myself') elseif is_sudo(msg) then print('I won\'t kick an admin!') else -- Ban user -- TODO: Check on this plugin bans local bhash = 'banned:'..msg.to.id..':'..msg.from.id redis:set(bhash, true) kick_user(user, chat) end msg = nil end redis:setex(hash, TIME_CHECK, msgs+1) end end return msg end return { description = 'Plugin to kick flooders from group.', usage = {}, patterns = { '^!antiflood (enable)$', '^!antiflood (disable)$' }, run = run, privileged = true, pre_process = pre_process }
gpl-2.0
AlexandreCA/update
scripts/zones/Temenos/bcnms/Central_Temenos_3rd_Floor.lua
19
1076
----------------------------------- -- 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
yasharsa/yashartg
bot/utils.lua
4
14121
URL = require "socket.url" http = require "socket.http" https = require "ssl.https" ltn12 = require "ltn12" serpent = require "serpent" feedparser = require "feedparser" json = (loadfile "./libs/JSON.lua")() mimetype = (loadfile "./libs/mimetype.lua")() redis = (loadfile "./libs/redis.lua")() http.TIMEOUT = 10 function get_receiver(msg) if msg.to.type == 'user' then return 'user#id'..msg.from.id end if msg.to.type == 'chat' then return 'chat#id'..msg.to.id end if msg.to.type == 'encr_chat' then return msg.to.print_name end if msg.to.type == 'channel' then return 'channel#id'..msg.to.id end end function is_chat_msg( msg ) if msg.to.type == 'chat' then return true end return false end function string.random(length) local str = ""; for i = 1, length do math.random(97, 122) str = str..string.char(math.random(97, 122)); end return str; end function string:split(sep) local sep, fields = sep or ":", {} local pattern = string.format("([^%s]+)", sep) self:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end -- DEPRECATED function string.trim(s) print("string.trim(s) is DEPRECATED use string:trim() instead") return s:gsub("^%s*(.-)%s*$", "%1") end -- Removes spaces function string:trim() return self:gsub("^%s*(.-)%s*$", "%1") end function get_http_file_name(url, headers) -- Eg: foo.var local file_name = url:match("[^%w]+([%.%w]+)$") -- Any delimited alphanumeric on the url file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$") -- Random name, hope content-type works file_name = file_name or str:random(5) local content_type = headers["content-type"] local extension = nil if content_type then extension = mimetype.get_mime_extension(content_type) end if extension then file_name = file_name.."."..extension end local disposition = headers["content-disposition"] if disposition then -- attachment; filename=CodeCogsEqn.png file_name = disposition:match('filename=([^;]+)') or file_name end return file_name end -- Saves file to /tmp/. If file_name isn't provided, -- will get the text after the last "/" for filename -- and content-type for extension function download_to_file(url, file_name) print("url to download: "..url) local respbody = {} local options = { url = url, sink = ltn12.sink.table(respbody), redirect = true } -- nil, code, headers, status local response = nil if url:starts('https') then options.redirect = false response = {https.request(options)} else response = {http.request(options)} end local code = response[2] local headers = response[3] local status = response[4] if code ~= 200 then return nil end file_name = file_name or get_http_file_name(url, headers) local file_path = "/tmp/"..file_name print("Saved to: "..file_path) file = io.open(file_path, "w+") file:write(table.concat(respbody)) file:close() return file_path end function vardump(value) print(serpent.block(value, {comment=false})) end -- taken from http://stackoverflow.com/a/11130774/3163199 function scandir(directory) local i, t, popen = 0, {}, io.popen for filename in popen('ls -a "'..directory..'"'):lines() do i = i + 1 t[i] = filename end return t end -- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen function run_command(str) local cmd = io.popen(str) local result = cmd:read('*all') cmd:close() return result end -- User has privileges function is_sudo(msg) local var = false -- Check users id in config for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end -- Returns the name of the sender function get_name(msg) local name = msg.from.first_name if name == nil then name = msg.from.id end return name end -- Returns at table of lua files inside plugins function plugins_names( ) local files = {} for k, v in pairs(scandir("plugins")) do -- Ends with .lua if (v:match(".lua$")) then table.insert(files, v) end end return files end -- Function name explains what it does. function file_exists(name) local f = io.open(name,"r") if f ~= nil then io.close(f) return true else return false end end -- Save into file the data serialized for lua. -- Set uglify true to minify the file. function serialize_to_file(data, file, uglify) file = io.open(file, 'w+') local serialized if not uglify then serialized = serpent.block(data, { comment = false, name = '_' }) else serialized = serpent.dump(data) end file:write(serialized) file:close() end -- Returns true if the string is empty function string:isempty() return self == nil or self == '' end -- Returns true if the string is blank function string:isblank() self = self:trim() return self:isempty() end -- DEPRECATED!!!!! function string.starts(String, Start) print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead") return Start == string.sub(String,1,string.len(Start)) end -- Returns true if String starts with Start function string:starts(text) return text == string.sub(self,1,string.len(text)) end -- Send image to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_photo(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function, cb_extra = cb_extra } -- Call to remove with optional callback send_photo(receiver, file_path, cb_function, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_photo_from_url(receiver, url, cb_function, cb_extra) -- If callback not provided cb_function = cb_function or ok_cb cb_extra = cb_extra or false local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, cb_function, cb_extra) else print("File path: "..file_path) _send_photo(receiver, file_path, cb_function, cb_extra) end end -- Same as send_photo_from_url but as callback function function send_photo_from_url_callback(cb_extra, success, result) local receiver = cb_extra.receiver local url = cb_extra.url local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, ok_cb, false) else print("File path: "..file_path) _send_photo(receiver, file_path, ok_cb, false) end end -- Send multiple images asynchronous. -- param urls must be a table. function send_photos_from_url(receiver, urls) local cb_extra = { receiver = receiver, urls = urls, remove_path = nil } send_photos_from_url_callback(cb_extra) end -- Use send_photos_from_url. -- This function might be difficult to understand. function send_photos_from_url_callback(cb_extra, success, result) -- cb_extra is a table containing receiver, urls and remove_path local receiver = cb_extra.receiver local urls = cb_extra.urls local remove_path = cb_extra.remove_path -- The previously image to remove if remove_path ~= nil then os.remove(remove_path) print("Deleted: "..remove_path) end -- Nil or empty, exit case (no more urls) if urls == nil or #urls == 0 then return false end -- Take the head and remove from urls table local head = table.remove(urls, 1) local file_path = download_to_file(head, false) local cb_extra = { receiver = receiver, urls = urls, remove_path = file_path } -- Send first and postpone the others as callback send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra) end -- Callback to remove a file function rmtmp_cb(cb_extra, success, result) local file_path = cb_extra.file_path local cb_function = cb_extra.cb_function or ok_cb local cb_extra = cb_extra.cb_extra if file_path ~= nil then os.remove(file_path) print("Deleted: "..file_path) end -- Finally call the callback cb_function(cb_extra, success, result) end -- Send document to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_document(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function or ok_cb, cb_extra = cb_extra or false } -- Call to remove with optional callback send_document(receiver, file_path, rmtmp_cb, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_document_from_url(receiver, url, cb_function, cb_extra) local file_path = download_to_file(url, false) print("File path: "..file_path) _send_document(receiver, file_path, cb_function, cb_extra) end -- Parameters in ?a=1&b=2 style function format_http_params(params, is_get) local str = '' -- If is get add ? to the beginning if is_get then str = '?' end local first = true -- Frist param for k,v in pairs (params) do if v then -- nil value if first then first = false str = str..k.. "="..v else str = str.."&"..k.. "="..v end end end return str end -- Check if user can use the plugin and warns user -- Returns true if user was warned and false if not warned (is allowed) function warns_user_not_allowed(plugin, msg) if not user_allowed(plugin, msg) then local text = 'This plugin requires privileged user' local receiver = get_receiver(msg) send_msg(receiver, text, ok_cb, false) return true else return false end end -- Check if user can use the plugin function user_allowed(plugin, msg) if plugin.privileged and not is_sudo(msg) then return false end return true end function send_order_msg(destination, msgs) local cb_extra = { destination = destination, msgs = msgs } send_order_msg_callback(cb_extra, true) end function send_order_msg_callback(cb_extra, success, result) local destination = cb_extra.destination local msgs = cb_extra.msgs local file_path = cb_extra.file_path if file_path ~= nil then os.remove(file_path) print("Deleted: " .. file_path) end if type(msgs) == 'string' then send_large_msg(destination, msgs) elseif type(msgs) ~= 'table' then return end if #msgs < 1 then return end local msg = table.remove(msgs, 1) local new_cb_extra = { destination = destination, msgs = msgs } if type(msg) == 'string' then send_msg(destination, msg, send_order_msg_callback, new_cb_extra) elseif type(msg) == 'table' then local typ = msg[1] local nmsg = msg[2] new_cb_extra.file_path = nmsg if typ == 'document' then send_document(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'image' or typ == 'photo' then send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'audio' then send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'video' then send_video(destination, nmsg, send_order_msg_callback, new_cb_extra) else send_file(destination, nmsg, send_order_msg_callback, new_cb_extra) end end end -- Same as send_large_msg_callback but friendly params function send_large_msg(destination, text) local cb_extra = { destination = destination, text = text } send_large_msg_callback(cb_extra, true) end -- If text is longer than 4096 chars, send multiple msg. -- https://core.telegram.org/method/messages.sendMessage function send_large_msg_callback(cb_extra, success, result) local text_max = 4096 local destination = cb_extra.destination local text = cb_extra.text local text_len = string.len(text) local num_msg = math.ceil(text_len / text_max) if num_msg <= 1 then send_msg(destination, text, ok_cb, false) else local my_text = string.sub(text, 1, 4096) local rest = string.sub(text, 4096, text_len) local cb_extra = { destination = destination, text = rest } send_msg(destination, my_text, send_large_msg_callback, cb_extra) end end -- Returns a table with matches or nil function match_pattern(pattern, text, lower_case) if text then local matches = {} if lower_case then matches = { string.match(text:lower(), pattern) } else matches = { string.match(text, pattern) } end if next(matches) then return matches end end -- nil end -- Function to read data from files function load_from_file(file, default_data) local f = io.open(file, "r+") -- If file doesn't exists if f == nil then -- Create a new empty table default_data = default_data or {} serialize_to_file(default_data, file) print ('Created file', file) else print ('Data loaded from file', file) f:close() end return loadfile (file)() end -- See http://stackoverflow.com/a/14899740 function unescape_html(str) local map = { ["lt"] = "<", ["gt"] = ">", ["amp"] = "&", ["quot"] = '"', ["apos"] = "'" } new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s) var = map[s] or n == "#" and string.char(s) var = var or n == "#x" and string.char(tonumber(s,16)) var = var or orig return var end) return new end -- Workarrond to format the message as previously was received function backward_msg_format (msg) for k,name in ipairs({'from', 'to'}) do local longid = msg[name].id msg[name].id = msg[name].peer_id msg[name].peer_id = longid msg[name].type = msg[name].peer_type end if msg.action and (msg.action.user or msg.action.link_issuer) then local user = msg.action.user or msg.action.link_issuer local longid = user.id user.id = user.peer_id user.peer_id = longid user.type = user.peer_type end return msg end
gpl-2.0
AlexandreCA/darkstar
scripts/zones/Abyssea-Altepa/npcs/Cavernous_Maw.lua
29
1099
----------------------------------- -- Area: Abyssea Altepa -- NPC: Cavernous Maw -- @pos 444.000 -0.500 320.000 218 -- Notes Teleports Players to South Gustaberg ----------------------------------- package.loaded["scripts/zones/Abyssea-Altepa/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x00C8); 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 == 0x00C8 and option == 1) then player:setPos(343,0,-679,199,107) end end;
gpl-3.0
AlexandreCA/darkstar
scripts/globals/mobskills/Spirits_Within.lua
17
1747
--------------------------------------------- -- Spirits Within -- -- Description: Delivers an unavoidable attack. Damage varies with HP and TP. -- Type: Magical/Breath -- Ignores shadows and most damage reduction. -- Range: Melee --------------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/utils"); require("scripts/globals/monstertpmoves"); require("scripts/zones/Throne_Room/TextIDs"); --------------------------------------------- function onMobSkillCheck(target,mob,skill) if (mob:getFamily() == 482) then target:showText(mob,YOUR_ANSWER); return 0; else return 0; end; function onMobWeaponSkill(target, mob, skill) if (mob:getFamily() == 482) then target:showText(mob,RETURN_TO_THE_DARKNESS); else mob:messageBasic(43, 0, 686+256); end local tp = skill:getTP(); local hp = mob:getHP(); local dmg = 0; -- Should produce 1000 - 3750 @ full HP using the player formula, assuming 8k HP for AA EV. -- dmg * 2.5, as wiki claims ~2500 at 100% HP, until a better formula comes along. if tp <= 2000 then -- 1000 - 2000 dmg = math.floor(hp * (math.floor(0.16 * tp) + 16) / 256); else -- 2001 - 3000 dmg = math.floor(hp * (math.floor(0.72 * tp) - 96) / 256); end dmg = dmg * 2.5; -- Believe it or not, it's been proven to be breath damage. dmg = target:breathDmgTaken(dmg); --handling phalanx dmg = dmg - target:getMod(MOD_PHALANX); if (dmg < 0) then return 0; end dmg = utils.stoneskin(target, dmg); if (dmg > 0) then target:wakeUp(); target:updateEnmityFromDamage(mob,dmg); end target:delHP(dmg); return dmg; end end;
gpl-3.0
AlexandreCA/darkstar
scripts/globals/weaponskills/asuran_fists.lua
11
1670
----------------------------------- -- Asuran Fists -- Hand-to-Hand weapon skill -- Skill Level: 250 -- Delivers an eightfold attack. params.accuracy varies with TP. -- In order to obtain Asuran Fists, the quest The Walls of Your Mind must be completed. -- Due to the 95% params.accuracy cap there is only a 66% chance of all 8 hits landing, so approximately a one third chance of missing some of the hits at the cap. -- Will stack with Sneak Attack. -- Aligned with the Shadow Gorget, Soil Gorget & Flame Gorget. -- Aligned with the Shadow Belt, Soil Belt & Flame Belt. -- Element: None -- Modifiers: STR:10% ; VIT:10% -- 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 = 8; params.ftp100 = 1; params.ftp200 = 1; params.ftp300 = 1; params.str_wsc = 0.1; params.dex_wsc = 0.0; params.vit_wsc = 0.1; 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.8; params.acc200= 0.9; params.acc300= 1; params.atkmulti = 1; if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then params.str_wsc = 0.15; params.vit_wsc = 0.15; end local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, primary); return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
AlexandreCA/update
scripts/globals/spells/poisonga_iii.lua
18
1103
----------------------------------------- -- Spell: Poisonga III ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) local effect = EFFECT_POISON; local duration = 180; local pINT = caster:getStat(MOD_INT); local mINT = target:getStat(MOD_INT); local dINT = (pINT - mINT); local power = caster:getSkillLevel(ENFEEBLING_MAGIC_SKILL) / 10 + 1; if power > 25 then power = 25; end local resist = applyResistanceEffect(caster,spell,target,dINT,ENFEEBLING_MAGIC_SKILL,0,effect); if (resist == 1 or resist == 0.5) then -- effect taken duration = duration * resist; if (target:addStatusEffect(effect,power,3,duration)) then spell:setMsg(236); else spell:setMsg(75); end else -- resist entirely. spell:setMsg(85); end return effect; end;
gpl-3.0
AlexandreCA/update
scripts/zones/La_Theine_Plateau/npcs/Augevinne.lua
17
1569
----------------------------------- -- Area: La Theine Plateau -- NPC: Augevinne -- Involved in Mission: The Rescue Drill -- @pos -361 39 266 102 ----------------------------------- package.loaded["scripts/zones/La_Theine_Plateau/TextIDs"] = nil; ----------------------------------- require("scripts/globals/missions"); require("scripts/zones/La_Theine_Plateau/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getCurrentMission(SANDORIA) == THE_RESCUE_DRILL) then local MissionStatus = player:getVar("MissionStatus"); if (MissionStatus >= 5 and MissionStatus <= 7) then player:startEvent(0x0067); elseif (MissionStatus == 8) then player:showText(npc, RESCUE_DRILL + 21); elseif (MissionStatus >= 9) then player:showText(npc, RESCUE_DRILL + 26); else player:showText(npc, RESCUE_DRILL); end else player:showText(npc, RESCUE_DRILL); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
AlexandreCA/update
scripts/zones/Foret_de_Hennetiel/Zone.lua
34
1255
----------------------------------- -- -- Zone: Foret de Hennetiel -- ----------------------------------- require("scripts/globals/settings"); package.loaded["scripts/zones/Foret_de_Hennetiel/TextIDs"] = nil; require("scripts/zones/Foret_de_Hennetiel/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) cs = -1; if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then player:setPos(360,6,455,93); end return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
boundary/luvit
tests/test-http-response-error-propagation.lua
5
1113
--[[ Copyright 2012 The Luvit Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --]] require('helper') local Emitter = require('core').Emitter local http = require('http') local errorsCaught = 0 -- Mock socket object socket = Emitter:new() -- Verify that Response object correctly propagates errors from the underlying -- socket (e.g. EPIPE, ECONNRESET, etc.) res = http.Response:new(socket) res:on('error', function(err) errorsCaught = errorsCaught + 1 end) socket:emit('error', {}) socket:emit('error', {}) socket:emit('error', {}) process:on('exit', function() assert(errorsCaught == 3) end)
apache-2.0
ld-test/lrexlib-gnu
test/oniguruma_sets.lua
8
5410
-- See Copyright Notice in the file LICENSE local luatest = require "luatest" local N = luatest.NT local unpack = unpack or table.unpack local function norm(a) return a==nil and N or a end local function fill (n, m) local t = {} for i = n, m, -1 do table.insert (t, i) end return t end local function set_named_subpatterns (lib, flg) return { Name = "Named Subpatterns", Func = function (subj, methodname, patt, name1, name2) local r = lib.new (patt) local _,_,caps = r[methodname] (r, subj) return norm(caps[name1]), norm(caps[name2]) end, --{} N.B. subject is always first element { {"abcd", "tfind", "(?<dog>.)b.(?<cat>d)", "dog", "cat"}, {"a","d"} }, { {"abcd", "exec", "(?<dog>.)b.(?<cat>d)", "dog", "cat"}, {"a","d"} }, } end local function set_f_find (lib, flg) local cp1251 = "ÀÁÂÃÄŨÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÜÛÚÝÞßàáâãä叿çèéêëìíîïðñòóôõö÷øùüûúýþÿ" local loc = "CP1251" return { Name = "Function find", Func = lib.find, --{subj, patt, st,cf,ef,lo}, { results } { {"abcd", ".+", 5}, { N } }, -- failing st { {"abcd", ".*?"}, { 1,0 } }, -- non-greedy { {"abc", "aBC", N,flg.IGNORECASE}, { 1,3 } }, -- cf { {"abc", "aBC", N,"i" }, { 1,3 } }, -- cf { {cp1251, "[[:upper:]]+", N,N,N, loc}, { 1,33} }, -- locale { {cp1251, "[[:lower:]]+", N,N,N, loc}, {34,66} }, -- locale { {cp1251, "\\w+", N,N,N, loc}, {1, 66} }, -- locale } end local function set_f_match (lib, flg) return { Name = "Function match", Func = lib.match, --{subj, patt, st,cf,ef,lo}, { results } { {"abcd", ".+", 5}, { N }}, -- failing st { {"abcd", ".*?"}, { "" }}, -- non-greedy { {"abc", "aBC", N,flg.IGNORECASE}, {"abc" }}, -- cf { {"abc", "aBC", N,"i" }, {"abc" }}, -- cf } end local function set_f_gmatch (lib, flg) -- gmatch (s, p, [cf], [ef]) local pCSV = "[^,]*" local F = false local function test_gmatch (subj, patt) local out, guard = {}, 10 for a, b in lib.gmatch (subj, patt) do table.insert (out, { norm(a), norm(b) }) guard = guard - 1 if guard == 0 then break end end return unpack (out) end return { Name = "Function gmatch", Func = test_gmatch, --{ subj patt results } { {"a\0c", "." }, {{"a",N},{"\0",N},{"c",N}} },--nuls in subj { {"", pCSV}, {{"",N}} }, { {"12", pCSV}, {{"12",N}} }, { {",", pCSV}, {{"", N},{"", N}} }, { {"12,,45", pCSV}, {{"12",N},{"",N},{"45",N}} }, { {",,12,45,,ab,", pCSV}, {{"",N},{"",N},{"12",N},{"45",N},{"",N},{"ab",N},{"",N}} }, { {"12345", "(.)(.)"}, {{"1","2"},{"3","4"}} }, { {"12345", "(.)(.?)"}, {{"1","2"},{"3","4"},{"5",""}} }, } end local function set_f_split (lib, flg) -- split (s, p, [cf], [ef]) local function test_split (subj, patt) local out, guard = {}, 10 for a, b, c in lib.split (subj, patt) do table.insert (out, { norm(a), norm(b), norm(c) }) guard = guard - 1 if guard == 0 then break end end return unpack (out) end return { Name = "Function split", Func = test_split, --{ subj patt results } { {"a,\0,c", ","}, {{"a",",",N},{"\0",",",N},{"c",N,N}, } },--nuls in subj { {"ab", "$"}, {{"ab","",N}, {"",N,N} } }, { {"ab", "^|$"}, {{"", "", N}, {"ab","",N}, {"",N,N} } }, { {"ab45ab","(?<=ab).*?"}, {{"ab","",N}, {"45ab","",N}, {"",N,N} } }, { {"ab", "\\b"}, {{"", "", N}, {"ab","",N}, {"",N,N} } }, { {"ab", ".*" }, {{"","ab",N}, {"",N,N} } }, { {"ab", ".*?" }, {{"","",N}, {"a","",N}, {"b","",N}, {"",N,N} } }, { {"ab;de", ";*" }, {{"","",N},{"a","",N},{"b",";",N},{"d","",N},{"e","",N},{"",N,N} }}, } end local function set_m_exec (lib, flg) return { Name = "Method exec", Method = "exec", --{patt,cf,lo}, {subj,st,ef} { results } { {".+"}, {"abcd",5}, { N } }, -- failing st { {".*?"}, {"abcd"}, {1,0,{}} }, -- non-greedy { {"aBC",flg.IGNORECASE}, {"abc"}, {1,3,{}} }, -- cf { {"aBC","i" }, {"abc"}, {1,3,{}} }, -- cf } end local function set_m_tfind (lib, flg) return { Name = "Method tfind", Method = "tfind", --{patt,cf,lo}, {subj,st,ef} { results } { {".+"}, {"abcd",5}, { N } }, -- failing st { {".*?"}, {"abcd"}, {1,0,{}} }, -- non-greedy { {"aBC",flg.IGNORECASE}, {"abc"}, {1,3,{}} }, -- cf { {"aBC","i" }, {"abc"}, {1,3,{}} }, -- cf } end return function (libname) local lib = require (libname) local flags = lib.flags () local sets = { set_f_match (lib, flags), set_f_find (lib, flags), set_f_gmatch (lib, flags), set_f_split (lib, flags), set_m_exec (lib, flags), set_m_tfind (lib, flags), } local MAJOR = tonumber(lib.version():match("%d+")) if MAJOR >= 0 then table.insert (sets, set_named_subpatterns (lib, flags)) end return sets end
mit
AlexandreCA/darkstar
scripts/zones/Northern_San_dOria/npcs/Explorer_Moogle.lua
13
2267
----------------------------------- -- Area: Northern San d'Oria -- NPC: Explorer Moogle -- ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/teleports"); require("scripts/globals/quests"); require("scripts/zones/Northern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE); if (FlyerForRegine == 1) then count = trade:getItemCount(); MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(FLYER_REFUSED); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) accept = 0; event = 0x035e; if (player:getGil() < 300) then accept = 1; end if (player:getMainLvl() < EXPLORER_MOOGLE_LEVELCAP) then event = event + 1; end player:startEvent(event,player:getZoneID(),0,accept); 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); local price = 300; if (csid == 0x035e) then if (option == 1 and player:delGil(price)) then toExplorerMoogle(player,231); elseif (option == 2 and player:delGil(price)) then toExplorerMoogle(player,234); elseif (option == 3 and player:delGil(price)) then toExplorerMoogle(player,240); elseif (option == 4 and player:delGil(price)) then toExplorerMoogle(player,248); elseif (option == 5 and player:delGil(price)) then toExplorerMoogle(player,249); end end end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Windurst_Waters/npcs/Dabido-Sorobido.lua
13
1061
----------------------------------- -- Area: Windurst Waters -- NPC: Dabido-Sorobido -- Type: Standard NPC -- @zone: 238 -- @pos -93.586 -4.499 19.321 -- -- Auto-Script: Requires Verification (Verfied By Brawndo) ----------------------------------- package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x0388); 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
AlexandreCA/update
scripts/zones/The_Garden_of_RuHmet/npcs/HomePoint#1.lua
17
1203
----------------------------------- -- Area: The_Garden_of_RuHmet -- NPC: HomePoint#1 -- @pos ----------------------------------- package.loaded["scripts/zones/The_Garden_of_RuHmet/TextIDs"] = nil; require("scripts/globals/settings"); require("scripts/zones/The_Garden_of_RuHmet/TextIDs"); require("scripts/globals/homepoint"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) homepointMenu( player, 0x21fc, 89); 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
AlexandreCA/darkstar
scripts/zones/RuLude_Gardens/npcs/Perisa-Neburusa.lua
13
1063
----------------------------------- -- Area: Ru'Lude Gardens -- NPC: Perisa-Neburusa -- Type: Residence Renter -- @zone: 243 -- @pos 54.651 8.999 -74.372 -- -- Auto-Script: Requires Verification (Verfied by Brawndo) ----------------------------------- package.loaded["scripts/zones/RuLude_Gardens/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x004c); 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
AlexandreCA/darkstar
scripts/zones/RaKaznar_Inner_Court/Zone.lua
33
1290
----------------------------------- -- -- Zone: Ra’Kanzar Inner Court (276) -- ----------------------------------- package.loaded["scripts/zones/RaKaznar_Inner_Court/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/RaKaznar_Inner_Court/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then player:setPos(-476,-520.5,20,0); end return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Zeruhn_Mines/npcs/Grounds_Tome.lua
30
1079
----------------------------------- -- Area: Zeruhn Mines -- NPC: Grounds Tome ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/groundsofvalor"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) startGov(GOV_EVENT_ZERUHN_MINES,player); end; ----------------------------------- -- onEventSelection ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); updateGov(player,csid,option,626,627,628,629,630,0,0,0,0,0); end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); finishGov(player,csid,option,626,627,628,629,630,0,0,0,0,0,GOV_MSG_ZERUHN_MINES); end;
gpl-3.0
AlexandreCA/darkstar
scripts/globals/spells/bluemagic/hecatomb_wave.lua
25
1913
----------------------------------------- -- Spell: Hecatomb Wave -- Deals wind damage to enemies within a fan-shaped area originating from the caster. Additional effect: Blindness -- Spell cost: 116 MP -- Monster Type: Demons -- Spell Type: Magical (Wind) -- Blue Magic Points: 3 -- Stat Bonus: AGI+1 -- Level: 54 -- Casting Time: 5.25 seconds -- Recast Time: 33.75 seconds -- Magic Bursts on: Detonation, Fragmentation, Light -- Combos: Max MP Boost ----------------------------------------- require("scripts/globals/magic"); require("scripts/globals/status"); require("scripts/globals/bluemagic"); ----------------------------------------- -- OnMagicCastingCheck ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; ----------------------------------------- -- OnSpellCast ----------------------------------------- function onSpellCast(caster,target,spell) local resist = applyResistance(caster,spell,target,caster:getStat(MOD_INT) - target:getStat(MOD_INT),BLUE_SKILL,1.0); local params = {}; -- This data should match information on http://wiki.ffxiclopedia.org/wiki/Calculating_Blue_Magic_Damage params.multiplier = 1.375; params.tMultiplier = 1.0; params.duppercap = 54; params.str_wsc = 0.0; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.3; params.chr_wsc = 0.0; damage = BlueMagicalSpell(caster, target, spell, params, MND_BASED); damage = BlueFinalAdjustments(caster, target, spell, damage, params); if (damage > 0 and resist > 0.125) then local typeEffect = EFFECT_BLINDNESS; target:delStatusEffect(typeEffect); target:addStatusEffect(typeEffect,5,0,getBlueEffectDuration(caster,resist,typeEffect)); end return damage; end;
gpl-3.0
AlexandreCA/update
scripts/globals/items/mushroom_salad.lua
39
1426
----------------------------------------- -- ID: 5678 -- Item: Mushroom Salad -- Food Effect: 3 Hrs, All Races ----------------------------------------- -- MP 14% Cap 85 -- Agility 6 -- Mind 6 -- Strength -5 -- Vitality -5 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0; if (target:hasStatusEffect(EFFECT_FOOD)) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,10800,5678); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_FOOD_MPP, 14); target:addMod(MOD_FOOD_MP_CAP, 85); target:addMod(MOD_AGI, 6); target:addMod(MOD_MND, 6); target:addMod(MOD_STR, -5); target:addMod(MOD_VIT, -5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_FOOD_MPP, 14); target:delMod(MOD_FOOD_MP_CAP, 85); target:delMod(MOD_AGI, 6); target:delMod(MOD_MND, 6); target:delMod(MOD_STR, -5); target:delMod(MOD_VIT, -5); end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Riverne-Site_A01/npcs/_0u3.lua
13
1348
----------------------------------- -- Area: Riverne Site #A01 -- NPC: Unstable Displacement ----------------------------------- package.loaded["scripts/zones/Riverne-Site_A01/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/Riverne-Site_A01/TextIDs"); ----------------------------------- -- onTrade ----------------------------------- function onTrade(player,npc,trade) if (trade:hasItemQty(1691,1) and trade:getItemCount() == 1) then -- Trade Giant Scale player:tradeComplete(); npc:openDoor(RIVERNE_PORTERS); player:messageSpecial(SD_HAS_GROWN); end end; ----------------------------------- -- onTrigger ----------------------------------- function onTrigger(player,npc) if (npc:getAnimation() == 8) then player:startEvent(0x13); else player:messageSpecial(SD_VERY_SMALL); end; return 1; 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
nwf/openwrt-luci
applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/network.lua
20
2738
-- 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("Network Plugin Configuration"), translate( "The network plugin provides network based communication between " .. "different collectd instances. Collectd can operate both in client " .. "and server mode. In client mode locally collected date is " .. "transferred to a collectd server instance, in server mode the " .. "local instance receives data from other hosts." )) -- collectd_network config section s = m:section( NamedSection, "collectd_network", "luci_statistics" ) -- collectd_network.enable enable = s:option( Flag, "enable", translate("Enable this plugin") ) enable.default = 0 -- collectd_network_listen config section (Listen) listen = m:section( TypedSection, "collectd_network_listen", translate("Listener interfaces"), translate( "This section defines on which interfaces collectd will wait " .. "for incoming connections." )) listen.addremove = true listen.anonymous = true -- collectd_network_listen.host listen_host = listen:option( Value, "host", translate("Listen host") ) listen_host.default = "0.0.0.0" -- collectd_network_listen.port listen_port = listen:option( Value, "port", translate("Listen port") ) listen_port.default = 25826 listen_port.isinteger = true listen_port.optional = true -- collectd_network_server config section (Server) server = m:section( TypedSection, "collectd_network_server", translate("server interfaces"), translate( "This section defines to which servers the locally collected " .. "data is sent to." )) server.addremove = true server.anonymous = true -- collectd_network_server.host server_host = server:option( Value, "host", translate("Server host") ) server_host.default = "0.0.0.0" -- collectd_network_server.port server_port = server:option( Value, "port", translate("Server port") ) server_port.default = 25826 server_port.isinteger = true server_port.optional = true -- collectd_network.timetolive (TimeToLive) ttl = s:option( Value, "TimeToLive", translate("TTL for network packets") ) ttl.default = 128 ttl.isinteger = true ttl.optional = true ttl:depends( "enable", 1 ) -- collectd_network.forward (Forward) forward = s:option( Flag, "Forward", translate("Forwarding between listen and server addresses") ) forward.default = 0 forward.optional = true forward:depends( "enable", 1 ) -- collectd_network.cacheflush (CacheFlush) cacheflush = s:option( Value, "CacheFlush", translate("Cache flush interval"), translate("Seconds") ) cacheflush.default = 86400 cacheflush.isinteger = true cacheflush.optional = true cacheflush:depends( "enable", 1 ) return m
apache-2.0
AlexandreCA/update
scripts/zones/Abyssea-Uleguerand/npcs/Cavernous_Maw.lua
17
1247
----------------------------------- -- Area: Abyssea - Uleguerand -- NPC: Cavernous Maw -- @pos -246.000, -40.600, -520.000 253 -- Notes: Teleports Players to Xarcabard ----------------------------------- package.loaded["scripts/zones/Abyssea-Uleguerand/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/Abyssea-Uleguerand/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x00c8); 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 == 0x00c8 and option == 1) then player:setPos(269,-7,-75,192,112); end end;
gpl-3.0
AlexandreCA/update
scripts/zones/Southern_San_dOria_[S]/npcs/Raustigne.lua
16
1506
----------------------------------- -- Area: Southern SandOria [S] -- NPC: Raustigne -- @zone 80 -- @pos 4 -2 44 ----------------------------------- package.loaded["scripts/zones/Southern_San_dOria_[S]/TextIDs"] = nil; require("scripts/zones/Southern_San_dOria_[S]/TextIDs"); require("scripts/globals/quests"); require("scripts/globals/settings"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getQuestStatus(CRYSTAL_WAR, CLAWS_OF_THE_GRIFFON) == QUEST_COMPLETED and player:getVar("BoyAndTheBeast") == 0) then if (player:getCurrentMission(WOTG) == CAIT_SITH or player:hasCompletedMission(WOTG, CAIT_SITH)) then player:startEvent(0x0037); end else player:startEvent(0x0025E); 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 == 0x0037) then player:setVar("BoyAndTheBeast",1); end end;
gpl-3.0
AlexandreCA/update
scripts/globals/pets.lua
37
36137
----------------------------------- -- -- PETS ID -- ----------------------------------- ----------------------------------- -- PETTYPE ----------------------------------- PETTYPE_AVATAR = 0; PETTYPE_WYVERN = 1; PETTYPE_JUGPET = 2; PETTYPE_CHARMED_MOB = 3; PETTYPE_AUTOMATON = 4; PETTYPE_ADVENTURING_FELLOW= 5; PETTYPE_CHOCOBO = 6; ----------------------------------- -- PETNAME ----------------------------------- PETNAME_AZURE = 1; PETNAME_CERULEAN = 2; PETNAME_RYGOR = 3; PETNAME_FIREWING = 4; PETNAME_DELPHYNE = 5; PETNAME_EMBER = 6; PETNAME_ROVER = 7; PETNAME_MAX = 8; PETNAME_BUSTER = 9; PETNAME_DUKE = 10; PETNAME_OSCAR = 11; PETNAME_MAGGIE = 12; PETNAME_JESSIE = 13; PETNAME_LADY = 14; PETNAME_HIEN = 15; PETNAME_RAIDEN = 16; PETNAME_LUMIERE = 17; PETNAME_EISENZAHN = 18; PETNAME_PFEIL = 19; PETNAME_WUFFI = 20; PETNAME_GEORGE = 21; PETNAME_DONRYU = 22; PETNAME_QIQIRU = 23; PETNAME_KARAV_MARAV = 24; PETNAME_OBORO = 25; PETNAME_DARUG_BORUG = 26; PETNAME_MIKAN = 27; PETNAME_VHIKI = 28; PETNAME_SASAVI = 29; PETNAME_TATANG = 30; PETNAME_NANAJA = 31; PETNAME_KHOCHA = 32; PETNAME_DINO = 33; PETNAME_CHOMPER = 34; PETNAME_HUFFY = 35; PETNAME_POUNCER = 36; PETNAME_FIDO = 37; PETNAME_LUCY = 38; PETNAME_JAKE = 39; PETNAME_ROCKY = 40; PETNAME_REX = 41; PETNAME_RUSTY = 42; PETNAME_HIMMELSKRALLE = 43; PETNAME_GIZMO = 44; PETNAME_SPIKE = 45; PETNAME_SYLVESTER = 46; PETNAME_MILO = 47; PETNAME_TOM = 48; PETNAME_TOBY = 49; PETNAME_FELIX = 50; PETNAME_KOMET = 51; PETNAME_BO = 52; PETNAME_MOLLY = 53; PETNAME_UNRYU = 54; PETNAME_DAISY = 55; PETNAME_BARON = 56; PETNAME_GINGER = 57; PETNAME_MUFFIN = 58; PETNAME_LUMINEUX = 59; PETNAME_QUATREVENTS = 60; PETNAME_TORYU = 61; PETNAME_TATABA = 62; PETNAME_ETOILAZUREE = 63; PETNAME_GRISNUAGE = 64; PETNAME_BELORAGE = 65; PETNAME_CENTONNERRE = 66; PETNAME_NOUVELLUNE = 67; PETNAME_MISSY = 68; PETNAME_AMEDEO = 69; PETNAME_TRANCHEVENT = 70; PETNAME_SOUFFLEFEU = 71; PETNAME_ETOILE = 72; PETNAME_TONNERRE = 73; PETNAME_NUAGE = 74; PETNAME_FOUDRE = 75; PETNAME_HYUH = 76; PETNAME_ORAGE = 77; PETNAME_LUNE = 78; PETNAME_ASTRE = 79; PETNAME_WAFFENZAHN = 80; PETNAME_SOLEIL = 81; PETNAME_COURAGEUX = 82; PETNAME_KOFFLA_PAFFLA = 83; PETNAME_VENTEUSE = 84; PETNAME_LUNAIRE = 85; PETNAME_TORA = 86; PETNAME_CELESTE = 87; PETNAME_GALJA_MOGALJA = 88; PETNAME_GABOH = 89; PETNAME_VHYUN = 90; PETNAME_ORAGEUSE = 91; PETNAME_STELLAIRE = 92; PETNAME_SOLAIRE = 93; PETNAME_WIRBELWIND = 94; PETNAME_BLUTKRALLE = 95; PETNAME_BOGEN = 96; PETNAME_JUNKER = 97; PETNAME_FLINK = 98; PETNAME_KNIRPS = 99; PETNAME_BODO = 100; PETNAME_SORYU = 101; PETNAME_WAWARO = 102; PETNAME_TOTONA = 103; PETNAME_LEVIAN_MOVIAN = 104; PETNAME_KAGERO = 105; PETNAME_JOSEPH = 106; PETNAME_PAPARAL = 107; PETNAME_COCO = 108; PETNAME_RINGO = 109; PETNAME_NONOMI = 110; PETNAME_TETER = 111; PETNAME_GIGIMA = 112; PETNAME_GOGODAVI = 113; PETNAME_RURUMO = 114; PETNAME_TUPAH = 115; PETNAME_JYUBIH = 116; PETNAME_MAJHA = 117; PETNAME_LURON = 118; PETNAME_DRILLE = 119; PETNAME_TOURNEFOUX = 120; PETNAME_CHAFOUIN = 121; PETNAME_PLAISANTIN = 122; PETNAME_LOUSTIC = 123; PETNAME_HISTRION = 124; PETNAME_BOBECHE = 125; PETNAME_BOUGRION = 126; PETNAME_ROULETEAU = 127; PETNAME_ALLOUETTE = 128; PETNAME_SERENADE = 129; PETNAME_FICELETTE = 130; PETNAME_TOCADIE = 131; PETNAME_CAPRICE = 132; PETNAME_FOUCADE = 133; PETNAME_CAPILLOTTE = 134; PETNAME_QUENOTTE = 135; PETNAME_PACOTILLE = 136; PETNAME_COMEDIE = 137; PETNAME_KAGEKIYO = 138; PETNAME_TORAOH = 139; PETNAME_GENTA = 140; PETNAME_KINTOKI = 141; PETNAME_KOUMEI = 142; PETNAME_PAMAMA = 143; PETNAME_LOBO = 144; PETNAME_TSUKUSHI = 145; PETNAME_ONIWAKA = 146; PETNAME_KENBISHI = 147; PETNAME_HANNYA = 148; PETNAME_MASHIRA = 149; PETNAME_NADESHIKO = 150; PETNAME_E100 = 151; PETNAME_KOUME = 152; PETNAME_X_32 = 153; PETNAME_POPPO = 154; PETNAME_ASUKA = 155; PETNAME_SAKURA = 156; PETNAME_TAO = 157; PETNAME_MAO = 158; PETNAME_GADGET = 159; PETNAME_MARION = 160; PETNAME_WIDGET = 161; PETNAME_QUIRK = 162; PETNAME_SPROCKET = 163; PETNAME_COGETTE = 164; PETNAME_LECTER = 165; PETNAME_COPPELIA = 166; PETNAME_SPARKY = 167; PETNAME_CLANK = 168; PETNAME_CALCOBRENA = 169; PETNAME_CRACKLE = 170; PETNAME_RICOCHET = 171; PETNAME_JOSETTE = 172; PETNAME_FRITZ = 173; PETNAME_SKIPPY = 174; PETNAME_PINO = 175; PETNAME_MANDARIN = 176; PETNAME_JACKSTRAW = 177; PETNAME_GUIGNOL = 178; PETNAME_MOPPET = 179; PETNAME_NUTCRACKER = 180; PETNAME_ERWIN = 181; PETNAME_OTTO = 182; PETNAME_GUSTAV = 183; PETNAME_MUFFIN = 184; PETNAME_XAVER = 185; PETNAME_TONI = 186; PETNAME_INA = 187; PETNAME_GERDA = 188; PETNAME_PETRA = 189; PETNAME_VERENA = 190; PETNAME_ROSI = 191; PETNAME_SCHATZI = 192; PETNAME_WARASHI = 193; PETNAME_KLINGEL = 194; PETNAME_CLOCHETTE = 195; PETNAME_CAMPANELLO = 196; PETNAME_KAISERIN = 197; PETNAME_PRINCIPESSA = 198; PETNAME_BUTLER = 199; PETNAME_GRAF = 200; PETNAME_CARO = 201; PETNAME_CARA = 202; PETNAME_MADEMOISELLE = 203; PETNAME_HERZOG = 204; PETNAME_TRAMP = 205; PETNAME_V_1000 = 206; PETNAME_HIKOZAEMON = 207; PETNAME_NINE = 208; PETNAME_ACHT = 209; PETNAME_QUATTRO = 210; PETNAME_ZERO = 211; PETNAME_DREIZEHN = 212; PETNAME_SEIZE = 213; PETNAME_FUKUSUKE = 214; PETNAME_MATAEMON = 215; PETNAME_KANSUKE = 216; PETNAME_POLICHINELLE = 217; PETNAME_TOBISUKE = 218; PETNAME_SASUKE = 219; PETNAME_SHIJIMI = 220; PETNAME_CHOBI = 221; PETNAME_AURELIE = 222; PETNAME_MAGALIE = 223; PETNAME_AURORE = 224; PETNAME_CAROLINE = 225; PETNAME_ANDREA = 226; PETNAME_MACHINETTE = 227; PETNAME_CLARINE = 228; PETNAME_ARMELLE = 229; PETNAME_REINETTE = 230; PETNAME_DORLOTE = 231; PETNAME_TURLUPIN = 232; PETNAME_KLAXON = 233; PETNAME_BAMBINO = 234; PETNAME_POTIRON = 235; PETNAME_FUSTIGE = 236; PETNAME_AMIDON = 237; PETNAME_MACHIN = 238; PETNAME_BIDULON = 239; PETNAME_TANDEM = 240; PETNAME_PRESTIDIGE = 241; PETNAME_PURUTE_PORUTE = 242; PETNAME_BITO_RABITO = 243; PETNAME_COCOA = 244; PETNAME_TOTOMO = 245; PETNAME_CENTURION = 246; PETNAME_A7V = 247; PETNAME_SCIPIO = 248; PETNAME_SENTINEL = 249; PETNAME_PIONEER = 250; PETNAME_SENESCHAL = 251; PETNAME_GINJIN = 252; PETNAME_AMAGATSU = 253; PETNAME_DOLLY = 254; PETNAME_FANTOCCINI = 255; PETNAME_JOE = 256; PETNAME_KIKIZARU = 257; PETNAME_WHIPPET = 258; PETNAME_PUNCHINELLO = 259; PETNAME_CHARLIE = 260; PETNAME_MIDGE = 261; PETNAME_PETROUCHKA = 262; PETNAME_SCHNEIDER = 263; PETNAME_USHABTI = 264; PETNAME_NOEL = 265; PETNAME_YAJIROBE = 266; PETNAME_HINA = 267; PETNAME_NORA = 268; PETNAME_SHOKI = 269; PETNAME_KOBINA = 270; PETNAME_KOKESHI = 271; PETNAME_MAME = 272; PETNAME_BISHOP = 273; PETNAME_MARVIN = 274; PETNAME_DORA = 275; PETNAME_DATA = 276; PETNAME_ROBIN = 277; PETNAME_ROBBY = 278; PETNAME_PORLO_MOPERLO = 279; PETNAME_PAROKO_PURONKO= 280; PETNAME_PIPIMA = 281; PETNAME_GAGAJA = 282; PETNAME_MOBIL = 283; PETNAME_DONZEL = 284; PETNAME_ARCHER = 285; PETNAME_SHOOTER = 286; PETNAME_STEPHEN = 287; PETNAME_MK_IV = 288; PETNAME_CONJURER = 289; PETNAME_FOOTMAN = 290; PETNAME_TOKOTOKO = 291; PETNAME_SANCHO = 292; PETNAME_SARUMARO = 293; PETNAME_PICKET = 294; PETNAME_MUSHROOM = 295; PETNAME_G = 296; PETNAME_I = 297; PETNAME_Q = 298; PETNAME_V = 299; PETNAME_X = 300; PETNAME_Z = 301; PETNAME_II = 302; PETNAME_IV = 303; PETNAME_IX = 304; PETNAME_OR = 305; PETNAME_VI = 306; PETNAME_XI = 307; PETNAME_ACE = 308; PETNAME_AIR = 309; PETNAME_AKI = 310; PETNAME_AYU = 311; PETNAME_BAT = 312; PETNAME_BEC = 313; PETNAME_BEL = 314; PETNAME_BIG = 315; PETNAME_BON = 316; PETNAME_BOY = 317; PETNAME_CAP = 318; PETNAME_COQ = 319; PETNAME_CRY = 320; PETNAME_DOM = 321; PETNAME_DUC = 322; PETNAME_DUN = 323; PETNAME_END = 324; PETNAME_ETE = 325; PETNAME_EYE = 326; PETNAME_FAT = 327; PETNAME_FEE = 328; PETNAME_FER = 329; PETNAME_FEU = 330; PETNAME_FOG = 331; PETNAME_FOX = 332; PETNAME_HOT = 333; PETNAME_ICE = 334; PETNAME_ICE = 335; PETNAME_ICY = 336; PETNAME_III = 337; PETNAME_JET = 338; PETNAME_JOY = 339; PETNAME_LEG = 340; PETNAME_MAX = 341; PETNAME_NEO = 342; PETNAME_ONE = 343; PETNAME_PUR = 344; PETNAME_RAY = 345; PETNAME_RED = 346; PETNAME_ROI = 347; PETNAME_SEA = 348; PETNAME_SKY = 349; PETNAME_SUI = 350; PETNAME_SUN = 351; PETNAME_TEN = 352; PETNAME_VIF = 353; PETNAME_VII = 354; PETNAME_XII = 355; PETNAME_AILE = 356; PETNAME_ANGE = 357; PETNAME_ARDI = 358; PETNAME_BEAK = 359; PETNAME_BEAU = 360; PETNAME_BEST = 361; PETNAME_BLEU = 362; PETNAME_BLUE = 363; PETNAME_BONE = 364; PETNAME_CART = 365; PETNAME_CHIC = 366; PETNAME_CIEL = 367; PETNAME_CLAW = 368; PETNAME_COOL = 369; PETNAME_DAME = 370; PETNAME_DARK = 371; PETNAME_DORE = 372; PETNAME_DRAY = 373; PETNAME_DUKE = 374; PETNAME_EASY = 375; PETNAME_EDEL = 376; PETNAME_FACE = 377; PETNAME_FAST = 378; PETNAME_FIER = 379; PETNAME_FINE = 380; PETNAME_FIRE = 381; PETNAME_FOOT = 382; PETNAME_FURY = 383; PETNAME_FUYU = 384; PETNAME_GALE = 385; PETNAME_GIRL = 386; PETNAME_GOER = 387; PETNAME_GOLD = 388; PETNAME_GOOD = 389; PETNAME_GRAF = 390; PETNAME_GRAY = 391; PETNAME_GUST = 392; PETNAME_GUTE = 393; PETNAME_HAOH = 394; PETNAME_HARU = 395; PETNAME_HELD = 396; PETNAME_HERO = 397; PETNAME_HOPE = 398; PETNAME_IDOL = 399; PETNAME_IRIS = 400; PETNAME_IRON = 401; PETNAME_JACK = 402; PETNAME_JADE = 403; PETNAME_JOLI = 404; PETNAME_JUNG = 405; PETNAME_KIKU = 406; PETNAME_KING = 407; PETNAME_KOPF = 408; PETNAME_LADY = 409; PETNAME_LAST = 410; PETNAME_LILI = 411; PETNAME_LILY = 412; PETNAME_LINE = 413; PETNAME_LONG = 414; PETNAME_LORD = 415; PETNAME_LUFT = 416; PETNAME_LUNA = 417; PETNAME_LUNE = 418; PETNAME_MAMA = 419; PETNAME_MARS = 420; PETNAME_MIEL = 421; PETNAME_MISS = 422; PETNAME_MOMO = 423; PETNAME_MOND = 424; PETNAME_MOON = 425; PETNAME_NANA = 426; PETNAME_NICE = 427; PETNAME_NOIR = 428; PETNAME_NONO = 429; PETNAME_NOVA = 430; PETNAME_NUIT = 431; PETNAME_OCRE = 432; PETNAME_OLLE = 433; PETNAME_PAPA = 434; PETNAME_PERS = 435; PETNAME_PHAR = 436; PETNAME_PONY = 437; PETNAME_PURE = 438; PETNAME_RAIN = 439; PETNAME_RICE = 440; PETNAME_RICH = 441; PETNAME_ROAD = 442; PETNAME_ROSE = 443; PETNAME_ROTE = 444; PETNAME_ROUX = 445; PETNAME_RUBY = 446; PETNAME_SAGE = 447; PETNAME_SNOW = 448; PETNAME_STAR = 449; PETNAME_TAIL = 450; PETNAME_TROT = 451; PETNAME_VEGA = 452; PETNAME_VENT = 453; PETNAME_VERT = 454; PETNAME_VIII = 455; PETNAME_VIVE = 456; PETNAME_WAVE = 457; PETNAME_WEST = 458; PETNAME_WILD = 459; PETNAME_WIND = 460; PETNAME_WING = 461; PETNAME_XIII = 462; PETNAME_ZERO = 463; PETNAME_ACIER = 464; PETNAME_AGATE = 465; PETNAME_AGILE = 466; PETNAME_AGNES = 467; PETNAME_AILEE = 468; PETNAME_ALPHA = 469; PETNAME_AMBER = 470; PETNAME_AMBRE = 471; PETNAME_ANGEL = 472; PETNAME_ARDIE = 473; PETNAME_ARKIE = 474; PETNAME_ARROW = 475; PETNAME_AVIAN = 476; PETNAME_AZURE = 477; PETNAME_BARON = 478; PETNAME_BELLE = 479; PETNAME_BERYL = 480; PETNAME_BLACK = 481; PETNAME_BLADE = 482; PETNAME_BLAUE = 483; PETNAME_BLAZE = 484; PETNAME_BLEUE = 485; PETNAME_BLITZ = 486; PETNAME_BLOND = 487; PETNAME_BLOOD = 488; PETNAME_BONNE = 489; PETNAME_BRAVE = 490; PETNAME_BRIAN = 491; PETNAME_BRISE = 492; PETNAME_BURST = 493; PETNAME_CALME = 494; PETNAME_CHAOS = 495; PETNAME_CLAIR = 496; PETNAME_CLOUD = 497; PETNAME_COMET = 498; PETNAME_COMTE = 499; PETNAME_COURT = 500; PETNAME_CRAFT = 501; PETNAME_CRETE = 502; PETNAME_CROWN = 503; PETNAME_DANCE = 504; PETNAME_DANDY = 505; PETNAME_DEVIL = 506; PETNAME_DIANA = 507; PETNAME_DOREE = 508; PETNAME_DREAM = 509; PETNAME_EAGER = 510; PETNAME_EAGLE = 511; PETNAME_EBONY = 512; PETNAME_EISEN = 513; PETNAME_EMBER = 514; PETNAME_ENGEL = 515; PETNAME_FAIRY = 516; PETNAME_FATTY = 517; PETNAME_FEDER = 518; PETNAME_FEUER = 519; PETNAME_FIERE = 520; PETNAME_FIERY = 521; PETNAME_FINAL = 522; PETNAME_FLARE = 523; PETNAME_FLEET = 524; PETNAME_FLEUR = 525; PETNAME_FLIER = 526; PETNAME_FLOOD = 527; PETNAME_FLORA = 528; PETNAME_FLYER = 529; PETNAME_FRAIS = 530; PETNAME_FROST = 531; PETNAME_FUCHS = 532; PETNAME_GALOP = 533; PETNAME_GEIST = 534; PETNAME_GELBE = 535; PETNAME_GHOST = 536; PETNAME_GLORY = 537; PETNAME_GRAND = 538; PETNAME_GREAT = 539; PETNAME_GREEN = 540; PETNAME_GUTER = 541; PETNAME_GUTES = 542; PETNAME_HEART = 543; PETNAME_HELLE = 544; PETNAME_HIDEN = 545; PETNAME_HITEN = 546; PETNAME_HIVER = 547; PETNAME_HOBBY = 548; PETNAME_HYPER = 549; PETNAME_IVORY = 550; PETNAME_JAUNE = 551; PETNAME_JEUNE = 552; PETNAME_JINPU = 553; PETNAME_JOLIE = 554; PETNAME_JOLLY = 555; PETNAME_KLUGE = 556; PETNAME_KNIFE = 557; PETNAME_KOMET = 558; PETNAME_KUGEL = 559; PETNAME_LAHME = 560; PETNAME_LESTE = 561; PETNAME_LIGHT = 562; PETNAME_LILAS = 563; PETNAME_LUCKY = 564; PETNAME_LUNAR = 565; PETNAME_LUTIN = 566; PETNAME_MAGIC = 567; PETNAME_MERRY = 568; PETNAME_METAL = 569; PETNAME_NATSU = 570; PETNAME_NEDDY = 571; PETNAME_NIGHT = 572; PETNAME_NINJA = 573; PETNAME_NOBLE = 574; PETNAME_NOIRE = 575; PETNAME_NUAGE = 576; PETNAME_OCREE = 577; PETNAME_OLIVE = 578; PETNAME_OLLER = 579; PETNAME_OLLES = 580; PETNAME_OMEGA = 581; PETNAME_OPALE = 582; PETNAME_ORAGE = 583; PETNAME_PATTE = 584; PETNAME_PEACE = 585; PETNAME_PENNE = 586; PETNAME_PETIT = 587; PETNAME_PFEIL = 588; PETNAME_PLUIE = 589; PETNAME_PLUME = 590; PETNAME_PLUTO = 591; PETNAME_POINT = 592; PETNAME_POMME = 593; PETNAME_POWER = 594; PETNAME_QUAKE = 595; PETNAME_QUEEN = 596; PETNAME_QUEUE = 597; PETNAME_REINE = 598; PETNAME_REPPU = 599; PETNAME_RICHE = 600; PETNAME_RIEUR = 601; PETNAME_ROTER = 602; PETNAME_ROTES = 603; PETNAME_ROUGE = 604; PETNAME_ROYAL = 605; PETNAME_RUBIN = 606; PETNAME_RUBIS = 607; PETNAME_SAURE = 608; PETNAME_SERRE = 609; PETNAME_SMALT = 610; PETNAME_SNOWY = 611; PETNAME_SOLAR = 612; PETNAME_SPARK = 613; PETNAME_SPEED = 614; PETNAME_STEED = 615; PETNAME_STERN = 616; PETNAME_STONE = 617; PETNAME_STORM = 618; PETNAME_STURM = 619; PETNAME_STUTE = 620; PETNAME_SUPER = 621; PETNAME_SWEEP = 622; PETNAME_SWEET = 623; PETNAME_SWIFT = 624; PETNAME_TALON = 625; PETNAME_TEIOH = 626; PETNAME_TITAN = 627; PETNAME_TURBO = 628; PETNAME_ULTRA = 629; PETNAME_URARA = 630; PETNAME_VENUS = 631; PETNAME_VERTE = 632; PETNAME_VERVE = 633; PETNAME_VIVID = 634; PETNAME_VOGEL = 635; PETNAME_YOUNG = 636; PETNAME_ZIPPY = 637; PETNAME_AIRAIN = 638; PETNAME_AMBREE = 639; PETNAME_AMIRAL = 640; PETNAME_ARASHI = 641; PETNAME_ARCHER = 642; PETNAME_ARDENT = 643; PETNAME_ARGENT = 644; PETNAME_AUDACE = 645; PETNAME_AUTUMN = 646; PETNAME_BATTLE = 647; PETNAME_BEAUTE = 648; PETNAME_BEAUTY = 649; PETNAME_BEETLE = 650; PETNAME_BLAUER = 651; PETNAME_BLAUES = 652; PETNAME_BLEUET = 653; PETNAME_BLONDE = 654; PETNAME_BONBON = 655; PETNAME_BREEZE = 656; PETNAME_BRONZE = 657; PETNAME_BRUMBY = 658; PETNAME_BUCKER = 659; PETNAME_CAESAR = 660; PETNAME_CARMIN = 661; PETNAME_CERISE = 662; PETNAME_CERULE = 663; PETNAME_CHANCE = 664; PETNAME_CINDER = 665; PETNAME_CITRON = 666; PETNAME_CLAIRE = 667; PETNAME_COBALT = 668; PETNAME_CORAIL = 669; PETNAME_COURTE = 670; PETNAME_CUIVRE = 671; PETNAME_DANCER = 672; PETNAME_DARING = 673; PETNAME_DESERT = 674; PETNAME_DOBBIN = 675; PETNAME_DUNKLE = 676; PETNAME_ELANCE = 677; PETNAME_EMBLEM = 678; PETNAME_ENZIAN = 679; PETNAME_ESPRIT = 680; PETNAME_ETOILE = 681; PETNAME_FILANT = 682; PETNAME_FLAMME = 683; PETNAME_FLECHE = 684; PETNAME_FLIGHT = 685; PETNAME_FLINKE = 686; PETNAME_FLOWER = 687; PETNAME_FLURRY = 688; PETNAME_FLYING = 689; PETNAME_FOREST = 690; PETNAME_FREEZE = 691; PETNAME_FREUND = 692; PETNAME_FRIEND = 693; PETNAME_FROSTY = 694; PETNAME_FROZEN = 695; PETNAME_FUBUKI = 696; PETNAME_GALAXY = 697; PETNAME_GANGER = 698; PETNAME_GELBER = 699; PETNAME_GELBES = 700; PETNAME_GINGER = 701; PETNAME_GLOIRE = 702; PETNAME_GLORIE = 703; PETNAME_GOEMON = 704; PETNAME_GRANDE = 705; PETNAME_GRENAT = 706; PETNAME_GROOVE = 707; PETNAME_GROSSE = 708; PETNAME_GRUENE = 709; PETNAME_GUSTAV = 710; PETNAME_HAYATE = 711; PETNAME_HELDIN = 712; PETNAME_HELLER = 713; PETNAME_HELLES = 714; PETNAME_HENGST = 715; PETNAME_HERMES = 716; PETNAME_HERZOG = 717; PETNAME_HIMMEL = 718; PETNAME_HUMBLE = 719; PETNAME_IDATEN = 720; PETNAME_IMPACT = 721; PETNAME_INDIGO = 722; PETNAME_JAGGER = 723; PETNAME_JASMIN = 724; PETNAME_JOYEUX = 725; PETNAME_JUNGLE = 726; PETNAME_KAISER = 727; PETNAME_KEFFEL = 728; PETNAME_KLEINE = 729; PETNAME_KLUGER = 730; PETNAME_KLUGES = 731; PETNAME_KOLOSS = 732; PETNAME_LAHMER = 733; PETNAME_LAHMES = 734; PETNAME_LANCER = 735; PETNAME_LANDER = 736; PETNAME_LAUREL = 737; PETNAME_LEAPER = 738; PETNAME_LEGEND = 739; PETNAME_LIMBER = 740; PETNAME_LONGUE = 741; PETNAME_MELODY = 742; PETNAME_METEOR = 743; PETNAME_MIRAGE = 744; PETNAME_MISTER = 745; PETNAME_MOTION = 746; PETNAME_MUGUET = 747; PETNAME_NATURE = 748; PETNAME_NEBULA = 749; PETNAME_NETHER = 750; PETNAME_NIMBLE = 751; PETNAME_OLYMPE = 752; PETNAME_ORCHID = 753; PETNAME_OUTLAW = 754; PETNAME_PASSER = 755; PETNAME_PASTEL = 756; PETNAME_PELTER = 757; PETNAME_PENSEE = 758; PETNAME_PETITE = 759; PETNAME_PIMENT = 760; PETNAME_POETIC = 761; PETNAME_POULET = 762; PETNAME_PRESTE = 763; PETNAME_PRETTY = 764; PETNAME_PRINCE = 765; PETNAME_PURETE = 766; PETNAME_QUARTZ = 767; PETNAME_QUASAR = 768; PETNAME_RAFALE = 769; PETNAME_RAGING = 770; PETNAME_RAIDEN = 771; PETNAME_RAMAGE = 772; PETNAME_RAPIDE = 773; PETNAME_REICHE = 774; PETNAME_REMIGE = 775; PETNAME_RIEUSE = 776; PETNAME_RISING = 777; PETNAME_ROBUST = 778; PETNAME_ROYALE = 779; PETNAME_RUDOLF = 780; PETNAME_RUNNER = 781; PETNAME_SADDLE = 782; PETNAME_SAFRAN = 783; PETNAME_SAKURA = 784; PETNAME_SAPHIR = 785; PETNAME_SATURN = 786; PETNAME_SCHUSS = 787; PETNAME_SEKITO = 788; PETNAME_SELENE = 789; PETNAME_SENDEN = 790; PETNAME_SEREIN = 791; PETNAME_SHADOW = 792; PETNAME_SHIDEN = 793; PETNAME_SHINPU = 794; PETNAME_SIEGER = 795; PETNAME_SILBER = 796; PETNAME_SILENT = 797; PETNAME_SILVER = 798; PETNAME_SILVER = 799; PETNAME_SOLEIL = 800; PETNAME_SOMBRE = 801; PETNAME_SORREL = 802; PETNAME_SPHENE = 803; PETNAME_SPIRIT = 804; PETNAME_SPRING = 805; PETNAME_STREAM = 806; PETNAME_STRIKE = 807; PETNAME_SUMMER = 808; PETNAME_TEKIRO = 809; PETNAME_TERROR = 810; PETNAME_TICKET = 811; PETNAME_TIMIDE = 812; PETNAME_TOPAZE = 813; PETNAME_TULIPE = 814; PETNAME_TYCOON = 815; PETNAME_ULTIME = 816; PETNAME_URANUS = 817; PETNAME_VELOCE = 818; PETNAME_VELVET = 819; PETNAME_VICTOR = 820; PETNAME_VIOLET = 821; PETNAME_WALKER = 822; PETNAME_WEISSE = 823; PETNAME_WINGED = 824; PETNAME_WINNER = 825; PETNAME_WINNER = 826; PETNAME_WINTER = 827; PETNAME_WONDER = 828; PETNAME_XANTHE = 829; PETNAME_YELLOW = 830; PETNAME_ZEPHYR = 831; PETNAME_ARDENTE = 832; PETNAME_AUTOMNE = 833; PETNAME_AVENGER = 834; PETNAME_BARONNE = 835; PETNAME_BATTANT = 836; PETNAME_BLAZING = 837; PETNAME_BLITZER = 838; PETNAME_CAMELIA = 839; PETNAME_CANDIDE = 840; PETNAME_CARAMEL = 841; PETNAME_CELESTE = 842; PETNAME_CERULEE = 843; PETNAME_CHARBON = 844; PETNAME_CHARGER = 845; PETNAME_CHARIOT = 846; PETNAME_CLIPPER = 847; PETNAME_COUREUR = 848; PETNAME_CRIMSON = 849; PETNAME_CRISTAL = 850; PETNAME_CRYSTAL = 851; PETNAME_CUIVREE = 852; PETNAME_CYCLONE = 853; PETNAME_DANCING = 854; PETNAME_DANSEUR = 855; PETNAME_DIAMANT = 856; PETNAME_DIAMOND = 857; PETNAME_DRAFTER = 858; PETNAME_DUNKLER = 859; PETNAME_DUNKLES = 860; PETNAME_EASTERN = 861; PETNAME_EINHORN = 862; PETNAME_ELANCEE = 863; PETNAME_ELEGANT = 864; PETNAME_EMPEROR = 865; PETNAME_EMPRESS = 866; PETNAME_EXPRESS = 867; PETNAME_FARCEUR = 868; PETNAME_FEATHER = 869; PETNAME_FIGHTER = 870; PETNAME_FILANTE = 871; PETNAME_FLINKER = 872; PETNAME_FLINKES = 873; PETNAME_FORTUNE = 874; PETNAME_FRAICHE = 875; PETNAME_GAGNANT = 876; PETNAME_GALAXIE = 877; PETNAME_GALLANT = 878; PETNAME_GENESIS = 879; PETNAME_GEOELTE = 880; PETNAME_GROSSER = 881; PETNAME_GROSSES = 882; PETNAME_GRUENER = 883; PETNAME_GRUENES = 884; PETNAME_HARMONY = 885; PETNAME_HEROINE = 886; PETNAME_IKEZUKI = 887; PETNAME_IMPULSE = 888; PETNAME_JAVELIN = 889; PETNAME_JOYEUSE = 890; PETNAME_JUMPING = 891; PETNAME_JUPITER = 892; PETNAME_JUSTICE = 893; PETNAME_KLEINER = 894; PETNAME_KLEINES = 895; PETNAME_LAVANDE = 896; PETNAME_LEAPING = 897; PETNAME_LEGENDE = 898; PETNAME_LIBERTY = 899; PETNAME_LICORNE = 900; PETNAME_MAJESTY = 901; PETNAME_MARQUIS = 902; PETNAME_MAXIMAL = 903; PETNAME_MELODIE = 904; PETNAME_MERCURY = 905; PETNAME_MILLION = 906; PETNAME_MIRACLE = 907; PETNAME_MUSASHI = 908; PETNAME_MUSTANG = 909; PETNAME_NACARAT = 910; PETNAME_NATURAL = 911; PETNAME_NEMESIS = 912; PETNAME_NEPTUNE = 913; PETNAME_OEILLET = 914; PETNAME_OPTIMAL = 915; PETNAME_ORAGEUX = 916; PETNAME_OURAGAN = 917; PETNAME_PAPRIKA = 918; PETNAME_PARFAIT = 919; PETNAME_PARTNER = 920; PETNAME_PATIENT = 921; PETNAME_PATURON = 922; PETNAME_PEGASUS = 923; PETNAME_PENSIVE = 924; PETNAME_PERFECT = 925; PETNAME_PEUREUX = 926; PETNAME_PHOENIX = 927; PETNAME_PLUMAGE = 928; PETNAME_POURPRE = 929; PETNAME_POUSSIN = 930; PETNAME_PRANCER = 931; PETNAME_PREMIUM = 932; PETNAME_QUANTUM = 933; PETNAME_RADIANT = 934; PETNAME_RAINBOW = 935; PETNAME_RATTLER = 936; PETNAME_REICHER = 937; PETNAME_REICHES = 938; PETNAME_ROUGHIE = 939; PETNAME_SAMURAI = 940; PETNAME_SAUTANT = 941; PETNAME_SCARLET = 942; PETNAME_SCHWEIF = 943; PETNAME_SEREINE = 944; PETNAME_SERGENT = 945; PETNAME_SHINDEN = 946; PETNAME_SHINING = 947; PETNAME_SHOOTER = 948; PETNAME_SMOKING = 949; PETNAME_SOUFFLE = 950; PETNAME_SPECIAL = 951; PETNAME_STYLISH = 952; PETNAME_SUMPTER = 953; PETNAME_TEMPEST = 954; PETNAME_TEMPETE = 955; PETNAME_THUNDER = 956; PETNAME_TORNADO = 957; PETNAME_TORPEDO = 958; PETNAME_TRISTAN = 959; PETNAME_TROOPER = 960; PETNAME_TROTTER = 961; PETNAME_TYPHOON = 962; PETNAME_UNICORN = 963; PETNAME_VENGEUR = 964; PETNAME_VERMEIL = 965; PETNAME_VICTORY = 966; PETNAME_WARRIOR = 967; PETNAME_WEISSER = 968; PETNAME_WEISSES = 969; PETNAME_WESTERN = 970; PETNAME_WHISPER = 971; PETNAME_WINNING = 972; PETNAME_ZETSUEI = 973; PETNAME_ZILLION = 974; PETNAME_BARONESS = 975; PETNAME_BATTANTE = 976; PETNAME_BLIZZARD = 977; PETNAME_CANNELLE = 978; PETNAME_CAPUCINE = 979; PETNAME_CERULEAN = 980; PETNAME_CHANCEUX = 981; PETNAME_CHARISMA = 982; PETNAME_CHARMANT = 983; PETNAME_CHOCOLAT = 984; PETNAME_CLAYBANK = 985; PETNAME_COMTESSE = 986; PETNAME_COUREUSE = 987; PETNAME_DANSEUSE = 988; PETNAME_DUCHESSE = 989; PETNAME_ECARLATE = 990; PETNAME_ELEGANTE = 991; PETNAME_EMERAUDE = 992; PETNAME_FARCEUSE = 993; PETNAME_FARFADET = 994; PETNAME_FRINGANT = 995; PETNAME_GAGNANTE = 996; PETNAME_GALLOPER = 997; PETNAME_GALOPANT = 998; PETNAME_GEOELTER = 999; PETNAME_GEOELTES = 1000; PETNAME_GESCHOSS = 1001; PETNAME_GORGEOUS = 1002; PETNAME_HANAKAZE = 1003; PETNAME_HIGHLAND = 1004; PETNAME_HYPERION = 1005; PETNAME_ILLUSION = 1006; PETNAME_IMMORTAL = 1007; PETNAME_IMPERIAL = 1008; PETNAME_INCARNAT = 1009; PETNAME_INFINITY = 1010; PETNAME_INNOCENT = 1011; PETNAME_JACINTHE = 1012; PETNAME_KAISERIN = 1013; PETNAME_KRISTALL = 1014; PETNAME_MAHARAJA = 1015; PETNAME_MAHARANI = 1016; PETNAME_MARQUISE = 1017; PETNAME_MATAEMON = 1018; PETNAME_MEILLEUR = 1019; PETNAME_MERCEDES = 1020; PETNAME_MYOSOTIS = 1021; PETNAME_NEBULOUS = 1022; PETNAME_NEGATIVE = 1023; PETNAME_NENUPHAR = 1024; PETNAME_NORTHERN = 1025; PETNAME_NORTHERN = 1026; PETNAME_OBSIDIAN = 1027; PETNAME_ORAGEUSE = 1028; PETNAME_ORCHIDEE = 1029; PETNAME_PARFAITE = 1030; PETNAME_PATIENTE = 1031; PETNAME_PEUREUSE = 1032; PETNAME_POSITIVE = 1033; PETNAME_PRINCELY = 1034; PETNAME_PRINCESS = 1035; PETNAME_PRODIGUE = 1036; PETNAME_PUISSANT = 1037; PETNAME_RESTLESS = 1038; PETNAME_RHAPSODY = 1039; PETNAME_ROADSTER = 1040; PETNAME_RUTILANT = 1041; PETNAME_SAUTANTE = 1042; PETNAME_SCHWARZE = 1043; PETNAME_SHOOTING = 1044; PETNAME_SILBERNE = 1045; PETNAME_SOUTHERN = 1046; PETNAME_SPECIALE = 1047; PETNAME_STALLION = 1048; PETNAME_STARDUST = 1049; PETNAME_SURUSUMI = 1050; PETNAME_TONNERRE = 1051; PETNAME_TROTTEUR = 1052; PETNAME_ULTIMATE = 1053; PETNAME_UNIVERSE = 1054; PETNAME_VAILLANT = 1055; PETNAME_VENGEUSE = 1056; PETNAME_XANTHOUS = 1057; PETNAME_ZEPPELIN = 1058; PETNAME_AMBITIOUS = 1059; PETNAME_AUDACIEUX = 1060; PETNAME_BALLISTIC = 1061; PETNAME_BEAUTIFUL = 1062; PETNAME_BRILLIANT = 1063; PETNAME_CAMPANULE = 1064; PETNAME_CAPITAINE = 1065; PETNAME_CHANCEUSE = 1066; PETNAME_CHARMANTE = 1067; PETNAME_CLEMATITE = 1068; PETNAME_CLOCHETTE = 1069; PETNAME_CORIANDRE = 1070; PETNAME_CRACKLING = 1071; PETNAME_DESTROYER = 1072; PETNAME_EXCELLENT = 1073; PETNAME_FANTASTIC = 1074; PETNAME_FEATHERED = 1075; PETNAME_FRINGANTE = 1076; PETNAME_GALOPANTE = 1077; PETNAME_GINGEMBRE = 1078; PETNAME_HURRICANE = 1079; PETNAME_ICHIMONJI = 1080; PETNAME_IMPETUEUX = 1081; PETNAME_INCARNATE = 1082; PETNAME_LIGHTNING = 1083; PETNAME_MATSUKAZE = 1084; PETNAME_MEILLEURE = 1085; PETNAME_MENESTREL = 1086; PETNAME_MERCILESS = 1087; PETNAME_PENDRAGON = 1088; PETNAME_PRINCESSE = 1089; PETNAME_PRINTEMPS = 1090; PETNAME_PUISSANTE = 1091; PETNAME_QUADRILLE = 1092; PETNAME_ROSINANTE = 1093; PETNAME_RUTILANTE = 1094; PETNAME_SCHWARZER = 1095; PETNAME_SCHWARZES = 1096; PETNAME_SILBERNER = 1097; PETNAME_SILBERNES = 1098; PETNAME_SPARKLING = 1099; PETNAME_SPEEDSTER = 1100; PETNAME_TOURNESOL = 1101; PETNAME_TRANSIENT = 1102; PETNAME_TROTTEUSE = 1103; PETNAME_TURBULENT = 1104; PETNAME_TWINKLING = 1105; PETNAME_VAILLANTE = 1106; PETNAME_VALENTINE = 1107; PETNAME_VELOCIOUS = 1108; PETNAME_VERMEILLE = 1109; PETNAME_WONDERFUL = 1110; PETNAME_AMATSUKAZE = 1111; PETNAME_AUDACIEUSE = 1112; PETNAME_BENEVOLENT = 1113; PETNAME_BLISTERING = 1114; PETNAME_BRILLIANCE = 1115; PETNAME_BUCEPHALUS = 1116; PETNAME_CHALLENGER = 1117; PETNAME_EXCELLENTE = 1118; PETNAME_IMPETUEUSE = 1119; PETNAME_INVINCIBLE = 1120; PETNAME_MALEVOLENT = 1121; PETNAME_MILLENNIUM = 1122; PETNAME_TRANQUILLE = 1123; PETNAME_TURBULENTE = 1124; PETNAME_DESTRUCTION = 1125; PETNAME_FIRECRACKER = 1126; ----------------------------------- -- Summoner ----------------------------------- PET_FIRE_SPIRIT = 0; PET_ICE_SPIRIT = 1; PET_AIR_SPIRIT = 2; PET_EARTH_SPIRIT = 3; PET_THUNDER_SPIRIT = 4; PET_WATER_SPIRIT = 5; PET_LIGHT_SPIRIT = 6; PET_DARK_SPIRIT = 7; PET_CARBUNCLE = 8; PET_FENRIR = 9; PET_IFRIT = 10; PET_TITAN = 11; PET_LEVIATHAN = 12; PET_GARUDA = 13; PET_SHIVA = 14; PET_RAMUH = 15; PET_DIABOLOS = 16; PET_ALEXANDER = 17; PET_ODIN = 18; PET_ATOMOS = 19; PET_CAIT_SITH = 20; PET_AUTOMATON = 69; PET_WYVERN = 48; ----------------------------------- -- Beastmaster ----------------------------------- PET_SHEEP_FAMILIAR = 21; PET_HARE_FAMILIAR = 22; PET_CRAB_FAMILIAR = 23; PET_COURIER_CARRIE = 24; PET_HOMUNCULUS = 25; PET_FLYTRAP_FAMILIAR = 26; PET_TIGER_FAMILIAR = 27; PET_FLOWERPOT_BILL = 28; PET_EFT_FAMILIAR = 29; PET_LIZARD_FAMILIAR = 30; PET_MAYFLY_FAMILIAR = 31; PET_FUNGUAR_FAMILIAR = 32; PET_BEETLE_FAMILIAR = 33; PET_ANTLION_FAMILIAR = 34; PET_MITE_FAMILIAR = 35; PET_LULLABY_MELODIA = 36; PET_KEENEARED_STEFFI = 37; PET_FLOWERPOT_BEN = 38; PET_SABER_SIRAVARDE = 39; PET_COLDBLOOD_COMO = 40; PET_SHELLBUSTER_OROB = 41; PET_VORACIOUS_AUDREY = 42; PET_AMBUSHER_ALLIE = 43; PET_LIFEDRINKER_LARS = 44; PET_PANZER_GALAHAD = 45; PET_CHOPSUEY_CHUCKY = 46; PET_AMIGO_SABOTENDER = 47;
gpl-3.0
annulen/premake-annulen
tests/test_gmake_cpp.lua
1
3993
-- -- tests/test_gmake_cpp.lua -- Automated test suite for GNU Make C/C++ project generation. -- Copyright (c) 2009 Jason Perkins and the Premake project -- T.gmake_cpp = { } -- -- Configure a solution for testing -- local sln, prj function T.gmake_cpp.setup() _ACTION = "gmake" _OPTIONS.os = "linux" sln = solution "MySolution" configurations { "Debug", "Release" } platforms { "native" } prj = project "MyProject" language "C++" kind "ConsoleApp" end local function prepare() premake.bake.buildconfigs() end -- -- Test the header -- function T.gmake_cpp.BasicHeader() prepare() premake.gmake_cpp_header(prj, premake.gcc, sln.platforms) test.capture [[ # GNU Make project makefile autogenerated by Premake ifndef config config=debug endif ifndef verbose SILENT = @ endif ifndef CC CC = gcc endif ifndef CXX CXX = g++ endif ifndef AR AR = ar endif ]] end -- -- Test configuration blocks -- function T.gmake_cpp.BasicCfgBlock() prepare() local cfg = premake.getconfig(prj, "Debug") premake.gmake_cpp_config(cfg, premake.gcc) test.capture [[ ifeq ($(config),debug) OBJDIR = obj/Debug TARGETDIR = . TARGET = $(TARGETDIR)/MyProject DEFINES += INCLUDES += CPPFLAGS += -MMD -MP $(DEFINES) $(INCLUDES) CFLAGS += $(CPPFLAGS) $(ARCH) CXXFLAGS += $(CFLAGS) LDFLAGS += -s LIBS += RESFLAGS += $(DEFINES) $(INCLUDES) LDDEPS += LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS) define PREBUILDCMDS endef define PRELINKCMDS endef define POSTBUILDCMDS endef endif ]] end function T.gmake_cpp.BasicCfgBlockWithPlatformCc() platforms { "ps3" } prepare() local cfg = premake.getconfig(prj, "Debug", "PS3") premake.gmake_cpp_config(cfg, premake.gcc) test.capture [[ ifeq ($(config),debugps3) CC = ppu-lv2-g++ CXX = ppu-lv2-g++ AR = ppu-lv2-ar OBJDIR = obj/PS3/Debug TARGETDIR = . TARGET = $(TARGETDIR)/MyProject.elf DEFINES += INCLUDES += CPPFLAGS += -MMD -MP $(DEFINES) $(INCLUDES) CFLAGS += $(CPPFLAGS) $(ARCH) CXXFLAGS += $(CFLAGS) LDFLAGS += -s LIBS += RESFLAGS += $(DEFINES) $(INCLUDES) LDDEPS += LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS) define PREBUILDCMDS endef define PRELINKCMDS endef define POSTBUILDCMDS endef endif ]] end function T.gmake_cpp.PlatformSpecificBlock() platforms { "x64" } prepare() local cfg = premake.getconfig(prj, "Debug", "x64") premake.gmake_cpp_config(cfg, premake.gcc) test.capture [[ ifeq ($(config),debug64) OBJDIR = obj/x64/Debug TARGETDIR = . TARGET = $(TARGETDIR)/MyProject DEFINES += INCLUDES += CPPFLAGS += -MMD -MP $(DEFINES) $(INCLUDES) CFLAGS += $(CPPFLAGS) $(ARCH) -m64 CXXFLAGS += $(CFLAGS) LDFLAGS += -s -m64 -L/usr/lib64 LIBS += RESFLAGS += $(DEFINES) $(INCLUDES) LDDEPS += LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS) define PREBUILDCMDS endef define PRELINKCMDS endef define POSTBUILDCMDS endef endif ]] end function T.gmake_cpp.UniversalStaticLibBlock() kind "StaticLib" platforms { "universal32" } prepare() local cfg = premake.getconfig(prj, "Debug", "Universal32") premake.gmake_cpp_config(cfg, premake.gcc) test.capture [[ ifeq ($(config),debuguniv32) OBJDIR = obj/Universal32/Debug TARGETDIR = . TARGET = $(TARGETDIR)/libMyProject.a DEFINES += INCLUDES += CPPFLAGS += $(DEFINES) $(INCLUDES) CFLAGS += $(CPPFLAGS) $(ARCH) -arch i386 -arch ppc CXXFLAGS += $(CFLAGS) LDFLAGS += -s -arch i386 -arch ppc LIBS += RESFLAGS += $(DEFINES) $(INCLUDES) LDDEPS += LINKCMD = libtool -o $(TARGET) $(OBJECTS) define PREBUILDCMDS endef define PRELINKCMDS endef define POSTBUILDCMDS endef endif ]] end
bsd-3-clause
AlexandreCA/darkstar
scripts/zones/Lufaise_Meadows/mobs/Leshy.lua
8
1821
----------------------------------- -- Area: Lufaise Meadows -- MOB: Leshy ----------------------------------- function onMobRoam(mob) local Colorful_Leshy = 16875762; local Colorful_Leshy_PH = 0; local Colorful_Leshy_PH_Table = { 16875754, 16875755, 16875756, 16875757, 16875758, 16875759, 16875760, 16875761 }; local Colorful_Leshy_ToD = GetMobByID(Colorful_Leshy):getLocalVar("1"); if (Colorful_Leshy_ToD <= os.time()) then Colorful_Leshy_PH = math.random((0), (table.getn(Colorful_Leshy_PH_Table))); if (Colorful_Leshy_PH_Table[Colorful_Leshy_PH] ~= nil) then if (GetMobAction(Colorful_Leshy) == 0) then SetServerVariable("Colorful_Leshy_PH", Colorful_Leshy_PH_Table[Colorful_Leshy_PH]); DeterMob(Colorful_Leshy_PH_Table[Colorful_Leshy_PH], true); DeterMob(Colorful_Leshy, false); DespawnMob(Colorful_Leshy_PH_Table[Colorful_Leshy_PH]); SpawnMob(Colorful_Leshy, "", 0); end end end end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, killer, ally) local Leshy = mob:getID(); local Colorful_Leshy = 16875762; local Colorful_Leshy_PH_Table = { 16875754, 16875755, 16875756, 16875757, 16875758, 16875759, 16875760, 16875761 }; for i = 1, table.getn(Colorful_Leshy_PH_Table), 1 do if (Colorful_Leshy_PH_Table[i] ~= nil) then if (Leshy == Colorful_Leshy_PH_Table[i]) then GetMobByID(Colorful_Leshy):setLocalVar("1",os.time() + math.random((43200), (86400))); end end end end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Windurst_Woods/npcs/Gioh_Ajihri.lua
28
2994
----------------------------------- -- Area: Windurst Woods -- NPC: Gioh Ajihri -- Starts & Finishes Repeatable Quest: Twinstone Bonding ----------------------------------- package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil; ----------------------------------- require("scripts/globals/quests"); require("scripts/globals/settings"); require("scripts/globals/titles"); require("scripts/zones/Windurst_Woods/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) GiohAijhriSpokenTo = player:getVar("GiohAijhriSpokenTo"); NeedToZone = player:needToZone(); if (GiohAijhriSpokenTo == 1 and NeedToZone == false) then count = trade:getItemCount(); TwinstoneEarring = trade:hasItemQty(13360,1); if (TwinstoneEarring == true and count == 1) then player:startEvent(0x01ea); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) TwinstoneBonding = player:getQuestStatus(WINDURST,TWINSTONE_BONDING); Fame = player:getFameLevel(WINDURST); if (TwinstoneBonding == QUEST_COMPLETED) then if (player:needToZone()) then player:startEvent(0x01eb,0,13360); else player:startEvent(0x01e8,0,13360); end elseif (TwinstoneBonding == QUEST_ACCEPTED) then player:startEvent(0x01e8,0,13360); elseif (TwinstoneBonding == QUEST_AVAILABLE and Fame >= 2) then player:startEvent(0x01e7,0,13360); else player:startEvent(0x01a8); 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 == 0x01e7) then player:addQuest(WINDURST,TWINSTONE_BONDING); player:setVar("GiohAijhriSpokenTo",1); elseif (csid == 0x01ea) then TwinstoneBonding = player:getQuestStatus(WINDURST,TWINSTONE_BONDING); player:tradeComplete(); player:needToZone(true); player:setVar("GiohAijhriSpokenTo",0); if (TwinstoneBonding == QUEST_ACCEPTED) then player:completeQuest(WINDURST,TWINSTONE_BONDING); player:addFame(WINDURST,80); player:addItem(17154); player:messageSpecial(ITEM_OBTAINED,17154); player:addTitle(BOND_FIXER); else player:addFame(WINDURST,10); player:addGil(GIL_RATE*900); player:messageSpecial(GIL_OBTAINED,GIL_RATE*900); end elseif (csid == 0x01e8) then player:setVar("GiohAijhriSpokenTo",1); end end;
gpl-3.0
AlexandreCA/update
scripts/zones/RuAun_Gardens/npcs/HomePoint#4.lua
17
1249
----------------------------------- -- Area: RuAun_Gardens -- NPC: HomePoint#4 -- @pos 500 -42 158 130 ----------------------------------- package.loaded["scripts/zones/RuAun_Gardens/TextIDs"] = nil; require("scripts/globals/settings"); require("scripts/zones/RuAun_Gardens/TextIDs"); require("scripts/globals/homepoint"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) homepointMenu( player, 0x21ff, 62); 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 == 0x21ff) then if (option == 1) then player:setHomePoint(); player:messageSpecial(HOMEPOINT_SET); else hpTeleport( player, option); end end end;
gpl-3.0
AlexandreCA/update
scripts/zones/Aht_Urhgan_Whitegate/npcs/Milazahn.lua
34
1033
----------------------------------- -- Area: Aht Urhgan Whitegate -- NPC: Milazahn -- Standard Info NPC ----------------------------------- 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:startEvent(0x0252); 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
AlexandreCA/update
scripts/zones/Port_San_dOria/npcs/Regine.lua
17
5797
----------------------------------- -- Area: Port San d'Oria -- NPC: Regine -- Standard Merchant NPC ----------------------------------- package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/shop"); require("scripts/globals/quests"); require("scripts/zones/Port_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script local count = trade:getItemCount(); if (player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE) == QUEST_ACCEPTED and trade:getGil() == 10 and trade:getItemCount() == 1) then if (player:getFreeSlotsCount() > 0) then player:addItem(532,1); player:tradeComplete(); player:messageSpecial(ITEM_OBTAINED,532); else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED_2, 532); -- CANNOT_OBTAIN_ITEM end elseif (trade:hasItemQty(532,1) == true and count == 1) then if (player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE) == QUEST_ACCEPTED) then player:messageSpecial(FLYER_REFUSED); end elseif (trade:hasItemQty(593,1) == true and count == 1) then if (player:getQuestStatus(SANDORIA,THE_BRUGAIRE_CONSORTIUM) == QUEST_ACCEPTED) then player:tradeComplete(); player:startEvent(0x0217); player:setVar("TheBrugaireConsortium-Parcels", 11); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getVar("FFR") == 1) then player:startEvent(510,2); elseif (player:getVar("FFR") == 2) then player:startEvent(603); elseif (player:getVar("FFR") > 2 and (not(player:hasItem(532)))) then player:startEvent(510,3); elseif (player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE) == QUEST_AVAILABLE and player:getVar("FFR") == 0) then player:startEvent(601); else player:startEvent(510); 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 == 510 and option == 2) then if (npcUtil.giveItem(player, {{532, 12}, {532, 3}})) then player:addQuest(SANDORIA,FLYERS_FOR_REGINE); player:setVar("FFR",17); end elseif (csid == 601) then player:setVar("FFR",1); elseif (csid == 603) then player:completeQuest(SANDORIA,FLYERS_FOR_REGINE); player:addGil(GIL_RATE*440) player:messageSpecial(GIL_OBTAINED,GIL_RATE*440); player:addTitle(ADVERTISING_EXECUTIVE); player:addFame(SANDORIA,SAN_FAME*30); player:setVar("tradeAnswald",0); player:setVar("tradePrietta",0); player:setVar("tradeMiene",0); player:setVar("tradePortaure",0); player:setVar("tradeAuvare",0); player:setVar("tradeGuilberdrier",0); player:setVar("tradeVilion",0); player:setVar("tradeCapiria",0); player:setVar("tradeBoncort",0); player:setVar("tradeCoullene",0); player:setVar("tradeLeuveret",0); player:setVar("tradeBlendare",0); player:setVar("tradeMaugie",0); player:setVar("tradeAdaunel",0); player:setVar("tradeRosel",0); player:setVar("FFR",0); elseif (csid == 510) then if (option == 0) then local stockA = { 0x1221,1165,1, --Scroll of Diaga 0x1238,837,1, --Scroll of Slow 0x1236,7025,1, --Scroll of Stoneskin 0x121c,140,2, --Scroll of Banish 0x1226,1165,2, --Scroll of Banishga 0x1235,2097,2, --Scroll of Blink 0x1202,585,2, --Scroll of Cure II 0x1237,360,3, --Scroll of Aquaveil 0x1210,990,3, --Scroll of Blindna 0x1207,1363,3, --Scroll of Curaga 0x1201,61,3, --Scroll of Cure 0x1217,82,3, --Scroll of Dia 0x120f,324,3, --Scroll of Paralyna 0x120e,180,3, --Scroll of Poisona 0x122b,219,3, --Scroll of Protect 0x1230,1584,3 --Scroll of Shell } showNationShop(player, SANDORIA, stockA); elseif (option == 1) then local stockB = { 0x12fe,111,1, --Scroll of Blind 0x12e6,360,2, --Scroll of Bio 0x12dc,82,2, --Scroll of Poison 0x12fd,2250,2, --Scroll of Sleep 0x129a,324,3, --Scroll of Aero 0x1295,1584,3, --Scroll of Blizzard 0x12eb,4644,3, --Scroll of Burn 0x12ed,2250,3, --Scroll of Choke 0x12f0,6366,3, --Scroll of Drown 0x1290,837,3, --Scroll of Fire 0x12ec,3688,3, --Scroll of Frost 0x12ee,1827,3, --Scroll of Rasp 0x12ef,1363,3, --Scroll of Shock 0x129f,61,3, --Scroll of Stone 0x12a4,3261,3, --Scroll of Thunder 0x12a9,140,3 --Scroll of Water } showNationShop(player, SANDORIA, stockB); end end end;
gpl-3.0
Dugy/wesnoth-names
data/ai/micro_ais/cas/ca_zone_guardian.lua
4
5322
local H = wesnoth.require "lua/helper.lua" local AH = wesnoth.require "ai/lua/ai_helper.lua" local LS = wesnoth.require "lua/location_set.lua" local function get_guardian(cfg) local filter = H.get_child(cfg, "filter") or { id = cfg.id } local guardian = AH.get_units_with_moves { side = wesnoth.current.side, { "and", filter } }[1] return guardian end local ca_zone_guardian = {} function ca_zone_guardian:evaluation(cfg) if get_guardian(cfg) then return cfg.ca_score end return 0 end function ca_zone_guardian:execution(cfg) local guardian = get_guardian(cfg) local reach = wesnoth.find_reach(guardian) local zone = H.get_child(cfg, "filter_location") local zone_enemy = H.get_child(cfg, "filter_location_enemy") or zone local enemies = wesnoth.get_units { { "filter_side", { { "enemy_of", { side = wesnoth.current.side } } } }, { "filter_location", zone_enemy } } if enemies[1] then local min_dist, target = 9e99 for _,enemy in ipairs(enemies) do local dist = H.distance_between(guardian.x, guardian.y, enemy.x, enemy.y) if (dist < min_dist) then target, min_dist = enemy, dist end end -- If a valid target was found, guardian attacks this target, or moves toward it if target then -- Find tiles adjacent to the target -- Save the one with the highest defense rating that guardian can reach local best_defense, attack_loc = -9e99 for xa,ya in H.adjacent_tiles(target.x, target.y) do -- Only consider unoccupied hexes local occ_hex = wesnoth.get_units { x = xa, y = ya, { "not", { id = guardian.id } } }[1] if not occ_hex then local defense = 100 - wesnoth.unit_defense(guardian, wesnoth.get_terrain(xa, ya)) local nh = AH.next_hop(guardian, xa, ya) if nh then if (nh[1] == xa) and (nh[2] == ya) and (defense > best_defense) then best_defense, attack_loc = defense, { xa, ya } end end end end -- If a valid hex was found: move there and attack if attack_loc then AH.movefull_stopunit(ai, guardian, attack_loc) if (not guardian) or (not guardian.valid) then return end if (not target) or (not target.valid) then return end AH.checked_attack(ai, guardian, target) else -- Otherwise move toward that enemy local reach = wesnoth.find_reach(guardian) -- Go through all hexes the guardian can reach, find closest to target -- Cannot use next_hop here since target hex is occupied by enemy local min_dist, nh = 9e99 for _,hex in ipairs(reach) do -- Only consider unoccupied hexes local occ_hex = wesnoth.get_units { x = hex[1], y = hex[2], { "not", { id = guardian.id } } }[1] if not occ_hex then local dist = H.distance_between(hex[1], hex[2], target.x, target.y) if (dist < min_dist) then min_dist, nh = dist, { hex[1], hex[2] } end end end AH.movefull_stopunit(ai, guardian, nh) end end -- If no enemy around or within the zone, move toward station or zone else local newpos -- If cfg.station_x/y are given, move toward that location if cfg.station_x and cfg.station_y then newpos = { cfg.station_x, cfg.station_y } -- Otherwise choose one randomly from those given in filter_location else local width, height = wesnoth.get_map_size() local locs_map = LS.of_pairs(wesnoth.get_locations { x = '1-' .. width, y = '1-' .. height, { "and", zone } }) -- Check out which of those hexes the guardian can reach local reach_map = LS.of_pairs(wesnoth.find_reach(guardian)) reach_map:inter(locs_map) -- If it can reach some hexes, use only reachable locations, -- otherwise move toward any (random) one from the entire set if (reach_map:size() > 0) then locs_map = reach_map end local locs = locs_map:to_pairs() if (#locs > 0) then local newind = math.random(#locs) newpos = { locs[newind][1], locs[newind][2] } else newpos = { guardian.x, guardian.y } end end -- Next hop toward that position local nh = AH.next_hop(guardian, newpos[1], newpos[2]) if nh then AH.movefull_stopunit(ai, guardian, nh) end end if (not guardian) or (not guardian.valid) then return end AH.checked_stopunit_moves(ai, guardian) -- If there are attacks left and guardian ended up next to an enemy, we'll leave this to RCA AI end return ca_zone_guardian
gpl-2.0
AlexandreCA/update
scripts/zones/The_Garden_of_RuHmet/mobs/Jailer_of_Faith.lua
24
1296
----------------------------------- -- Area: The Garden of Ru'Hmet -- NPC: Jailer_of_Faith ----------------------------------- ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) -- Give it two hour mob:setMod(MOBMOD_MAIN_2HOUR, 1); -- Change animation to open mob:AnimationSub(2); end; ----------------------------------- -- onMobFight Action -- Randomly change forms ----------------------------------- function onMobFight(mob) -- Forms: 0 = Closed 1 = Closed 2 = Open 3 = Closed local randomTime = math.random(45,180); local changeTime = mob:getLocalVar("changeTime"); if (mob:getBattleTime() - changeTime > randomTime) then -- Change close to open. if (mob:AnimationSub() == 1) then mob:AnimationSub(2); else -- Change from open to close mob:AnimationSub(1); end mob:setLocalVar("changeTime", mob:getBattleTime()); end end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, killer, npc) local qm3 = GetNPCByID(Jailer_of_Faith_QM); qm3:hideNPC(900); local qm3position = math.random(1,5); qm3:setPos(Jailer_of_Faith_QM_POS[qm3position][1], Jailer_of_Faith_QM_POS[qm3position][2], Jailer_of_Faith_QM_POS[qm3position][3]); end;
gpl-3.0
shahabsaf1/otouto
plugins/gSearch.lua
6
1944
local command = 'google <query>' local doc = [[``` /google <query> Returns four (if group) or eight (if private message) results from Google. Safe search is enabled by default, use "/gnsfw" to disable it. Alias: /g ```]] local triggers = { '^/g[@'..bot.username..']*$', '^/g[@'..bot.username..']* ', '^/google[@'..bot.username..']*', '^/gnsfw[@'..bot.username..']*' } local action = function(msg) local input = msg.text:input() if not input then if msg.reply_to_message and msg.reply_to_message.text then input = msg.reply_to_message.text else sendMessage(msg.chat.id, doc, true, msg.message_id, true) return end end local url = 'https://ajax.googleapis.com/ajax/services/search/web?v=1.0' if msg.from.id == msg.chat.id then url = url .. '&rsz=8' else url = url .. '&rsz=4' end if not string.match(msg.text, '^/g[oogle]*nsfw') then url = url .. '&safe=active' end url = url .. '&q=' .. URL.escape(input) local jstr, res = HTTPS.request(url) if res ~= 200 then sendReply(msg, config.errors.connection) return end local jdat = JSON.decode(jstr) if not jdat.responseData then sendReply(msg, config.errors.connection) return end if not jdat.responseData.results[1] then sendReply(msg, config.errors.results) return end local output = '*Google: Results for* _' .. input .. '_ *:*\n' for i,v in ipairs(jdat.responseData.results) do local title = jdat.responseData.results[i].titleNoFormatting:gsub('%[.+%]', ''):gsub('&amp;', '&') if title:len() > 48 then title = title:sub(1, 45) .. '...' end local url = jdat.responseData.results[i].unescapedUrl if url:find('%)') then output = output .. '• ' .. title .. '\n' .. url:gsub('_', '\\_') .. '\n' else output = output .. '• [' .. title .. '](' .. url .. ')\n' end end sendMessage(msg.chat.id, output, true, nil, true) end return { action = action, triggers = triggers, doc = doc, command = command }
gpl-2.0
AlexandreCA/darkstar
scripts/globals/effects/aftermath_lv2.lua
30
1456
----------------------------------- -- -- EFFECT_AFTERMATH_LV2 -- ----------------------------------- require("scripts/globals/status"); ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) local power = effect:getPower(); if (effect:getSubPower() == 1) then target:addMod(MOD_ATT,power); elseif (effect:getSubPower() == 2) then target:addMod(MOD_ACC,power) elseif (effect:getSubPower() == 3) then target:addMod(MOD_MATT,power) elseif (effect:getSubPower() == 4) then target:addMod(MOD_RATT,power) elseif (effect:getSubPower() == 5) then target:addMod(MOD_MACC,power) end end; ----------------------------------- -- onEffectTick Action ----------------------------------- function onEffectTick(target,effect) end; ----------------------------------- -- onEffectLose Action ----------------------------------- function onEffectLose(target,effect) local power = effect:getPower(); if (effect:getSubPower() == 1) then target:delMod(MOD_ATT,power); elseif (effect:getSubPower() == 2) then target:delMod(MOD_ACC,power) elseif (effect:getSubPower() == 3) then target:delMod(MOD_RACC,power) elseif (effect:getSubPower() == 4) then target:delMod(MOD_RATT,power) elseif (effect:getSubPower() == 5) then target:delMod(MOD_MACC,power) end end;
gpl-3.0
AlexandreCA/update
scripts/globals/abilities/drain_samba_iii.lua
18
1476
----------------------------------- -- Ability: Drain Samba III -- Inflicts the next target you strike with Drain daze, allowing party members engaged in battle with it to drain its HP. -- Obtained: Dancer Level 65 -- TP Required: 40% -- Recast Time: 1:00 -- Duration: 1:30 ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------- -- onAbilityCheck ----------------------------------- function onAbilityCheck(player,target,ability) if (player:hasStatusEffect(EFFECT_FAN_DANCE)) then return MSGBASIC_UNABLE_TO_USE_JA2, 0; elseif (player:hasStatusEffect(EFFECT_TRANCE)) then return 0,0; elseif (player:getTP() < 40) then return MSGBASIC_NOT_ENOUGH_TP,0; else return 0,0; end; end; ----------------------------------- -- onUseAbility ----------------------------------- function onUseAbility(player,target,ability) -- Only remove TP if the player doesn't have Trance. if not player:hasStatusEffect(EFFECT_TRANCE) then player:delTP(40); end; local duration = 120 + player:getMod(MOD_SAMBA_DURATION); duration = duration * (100 + player:getMod(MOD_SAMBA_PDURATION))/100; player:delStatusEffect(EFFECT_HASTE_SAMBA); player:delStatusEffect(EFFECT_ASPIR_SAMBA); player:addStatusEffect(EFFECT_DRAIN_SAMBA,3,0,duration); end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Port_San_dOria/npcs/Ambleon.lua
13
1061
----------------------------------- -- Area: Port San d'Oria -- NPC: Ambleon -- Type: NPC World Pass Dealer -- @zone: 232 -- @pos 71.622 -17 -137.134 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x02c6); 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
merlight/eso-libAddonKeybinds
libAddonKeybinds.lua
1
7359
--[========================================================================[ This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. 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 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. For more information, please refer to <http://unlicense.org/> --]========================================================================] local myNAME, myVERSION = "libAddonKeybinds", 3 local LAK = LibStub and LibStub:NewLibrary(myNAME, myVERSION) or {} libAddonKeybinds = LAK -- these must match esoui/ingame/keybindings/keyboard/keybindings.lua local LAYER_DATA_TYPE = 1 local CATEGORY_DATA_TYPE = 2 local KEYBIND_DATA_TYPE = 3 LAK.showAddonKeybinds = false local function addGameMenuEntry(panelName) local panelId = KEYBOARD_OPTIONS.currentPanelId KEYBOARD_OPTIONS.currentPanelId = panelId + 1 KEYBOARD_OPTIONS.panelNames[panelId] = panelName local sflist = KEYBINDING_MANAGER.list local savedScrollPos = {[false] = 0, [true] = 0} -- saved keybinding scroll list positions are not forgotten when -- you close the game menu; this was not originally intended, but -- is a pretty neat feature ;) local function setShowAddonKeybinds(state, forceRefresh) if LAK.showAddonKeybinds ~= state then -- save current scroll position for the old state savedScrollPos[not state] = sflist.list.scrollbar:GetValue() -- update state and refresh list LAK.showAddonKeybinds = state sflist:RefreshFilters() -- restore saved scroll position for the new state sflist.list.timeline:Stop() sflist.list.scrollbar:SetValue(savedScrollPos[state]) elseif forceRefresh then sflist:RefreshFilters() end end local function selectedCallback() --df("addon keybinds selected") SCENE_MANAGER:AddFragment(KEYBINDINGS_FRAGMENT) setShowAddonKeybinds(true) end local function unselectedCallback() --df("addon keybinds unselected") SCENE_MANAGER:RemoveFragment(KEYBINDINGS_FRAGMENT) setShowAddonKeybinds(false) end ZO_GameMenu_AddControlsPanel{id = panelId, name = panelName, callback = selectedCallback, unselectedCallback = unselectedCallback} -- gameMenu.navigationTree is rebuilt every time the menu is re-open; -- previously active menu entry's unselectedCallback won't be called, -- because ZO_Tree:Reset() doesn't call any selection callbacks local gameMenu = ZO_GameMenu_InGame.gameMenu -- reset our filter before the menu tree is rebuilt, so that when -- the user clicks on "Controls" (which auto-selects the first entry, -- i.e. built-in "Keybindings"), we will show the correct list ZO_PreHook(gameMenu.navigationTree, "Reset", function(self) setShowAddonKeybinds(false, true) end) end local function hookKeybindingListCallbacks(typeId, setupCallbackName, hideCallbackName) local dataType = ZO_ScrollList_GetDataTypeTable(ZO_KeybindingsList, typeId) local setupCallbackOriginal = dataType.setupCallback local hideCallbackOriginal = dataType.hideCallback local CM = CALLBACK_MANAGER function dataType.setupCallback(control, data, list) setupCallbackOriginal(control, data, list) CM:FireCallbacks(setupCallbackName, control, data) end if hideCallbackOriginal then function dataType.hideCallback(control, data) hideCallbackOriginal(control, data) CM:FireCallbacks(hideCallbackName, control, data) end else function dataType.hideCallback(control, data) CM:FireCallbacks(hideCallbackName, control, data) end end end local function hookKeybindingListFilter() function KEYBINDING_MANAGER.list:FilterScrollList() local scrollData = ZO_ScrollList_GetDataList(self.list) local layerHeader = nil local categoryHeader = nil local lastSI = SI_NONSTR_INGAMESHAREDSTRINGS_LAST_ENTRY ZO_ScrollList_Clear(self.list) for _, dataEntry in ipairs(self.masterList) do if dataEntry.typeId == LAYER_DATA_TYPE then layerHeader, categoryHeader = dataEntry elseif dataEntry.typeId == CATEGORY_DATA_TYPE then categoryHeader = dataEntry else local insertEntry = LAK.showAddonKeybinds local actionSI = _G["SI_BINDING_NAME_" .. dataEntry.data.actionName] if type(actionSI) == "number" and actionSI < lastSI then insertEntry = not insertEntry end if insertEntry then if layerHeader then scrollData[#scrollData + 1], layerHeader = layerHeader end if categoryHeader then scrollData[#scrollData + 1], categoryHeader = categoryHeader end scrollData[#scrollData + 1] = dataEntry end end end end end local function onLoad(eventCode, addonName) if addonName ~= "ZO_Ingame" then return end EVENT_MANAGER:UnregisterForEvent(myNAME, eventCode) local language = GetCVar("Language.2") if language == "de" then SafeAddString(SI_GAME_MENU_KEYBINDINGS, "Standard", 1) addGameMenuEntry("Erweiterungen") elseif language == "fr" then addGameMenuEntry("Extensions") else SafeAddString(SI_GAME_MENU_KEYBINDINGS, "Standard Keybinds", 1) addGameMenuEntry("Addon Keybinds") end hookKeybindingListCallbacks(CATEGORY_DATA_TYPE, "libAddonKeybinds.SetupCategoryHeader", "libAddonKeybinds.HideCategoryHeader") hookKeybindingListCallbacks(KEYBIND_DATA_TYPE, "libAddonKeybinds.SetupKeybindRow", "libAddonKeybinds.HideKeybindRow") hookKeybindingListFilter() end EVENT_MANAGER:UnregisterForEvent(myNAME, EVENT_ADD_ON_LOADED) EVENT_MANAGER:RegisterForEvent(myNAME, EVENT_ADD_ON_LOADED, onLoad)
unlicense
AlexandreCA/update
scripts/globals/spells/raiton_ichi.lua
17
1257
----------------------------------------- -- Spell: Raiton: Ichi -- Deals lightning damage to an enemy and lowers its resistance against earth. ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) --doNinjutsuNuke(V,M,caster,spell,target,hasMultipleTargetReduction,resistBonus) local duration = 15 + caster:getMerit(MERIT_RAITON_EFFECT) -- T1 bonus debuff duration local bonusAcc = 0; local bonusMab = caster:getMerit(MERIT_RAITON_EFFECT) + caster:getMod(MOD_NIN_NUKE_BONUS); -- T1 mag atk + "enhances Ninjustu damage" mod if (caster:isBehind(target,15) and caster:hasStatusEffect(EFFECT_INNIN)) then -- Innin mag atk bonus from behind, guesstimating angle at 15 degrees bonusMab = bonusMab + caster:getStatusEffect(EFFECT_INNIN):getPower(); end local dmg = doNinjutsuNuke(28,1,caster,spell,target,false,bonusAcc,bonusMab); handleNinjutsuDebuff(caster,target,spell,30,duration,MOD_EARTHRES); return dmg; end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Port_Jeuno/npcs/Red_Ghost.lua
13
2080
----------------------------------- -- Area: Port Jeuno -- NPC: Red Ghost -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Port_Jeuno/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Port_Jeuno/TextIDs"); require("scripts/globals/quests"); require("scripts/globals/pathfind"); local path = { -96.823616, 0.001000, -3.722488, -96.761887, 0.001000, -2.632236, -96.698341, 0.001000, -1.490001, -96.636963, 0.001000, -0.363672, -96.508736, 0.001000, 2.080966, -96.290009, 0.001000, 6.895948, -96.262505, 0.001000, 7.935584, -96.282127, 0.001000, 6.815756, -96.569176, 0.001000, -7.781419, -96.256729, 0.001000, 8.059505, -96.568405, 0.001000, -7.745419, -96.254066, 0.001000, 8.195477, -96.567200, 0.001000, -7.685426 }; function onSpawn(npc) npc:initNpcAi(); npc:setPos(pathfind.first(path)); onPath(npc); end; function onPath(npc) pathfind.patrol(npc, path); end; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local WildcatJeuno = player:getVar("WildcatJeuno"); if (player:getQuestStatus(JEUNO,LURE_OF_THE_WILDCAT_JEUNO) == QUEST_ACCEPTED and player:getMaskBit(WildcatJeuno,15) == false) then player:startEvent(314); else player:startEvent(0x22); end -- wait until event is over npc:wait(-1); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option,npc) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if (csid == 314) then player:setMaskBit(player:getVar("WildcatJeuno"),"WildcatJeuno",15,true); end npc:wait(0); end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Palborough_Mines/Zone.lua
17
1607
----------------------------------- -- -- Zone: Palborough_Mines (143) -- ----------------------------------- package.loaded["scripts/zones/Palborough_Mines/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/Palborough_Mines/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) UpdateTreasureSpawnPoint(17363367); end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then player:setPos(114.483,-42,-140,96); 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) 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
AlexandreCA/darkstar
scripts/globals/items/meat_chiefkabob.lua
18
1449
----------------------------------------- -- ID: 4574 -- Item: meat_chiefkabob -- Food Effect: 60Min, All Races ----------------------------------------- -- Strength 5 -- Agility 1 -- Intelligence -2 -- Attack % 22 -- 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,3600,4574); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_STR, 5); target:addMod(MOD_AGI, 1); target:addMod(MOD_INT, -2); target:addMod(MOD_FOOD_ATTP, 22); target:addMod(MOD_FOOD_ATT_CAP, 65); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_STR, 5); target:delMod(MOD_AGI, 1); target:delMod(MOD_INT, -2); target:delMod(MOD_FOOD_ATTP, 22); target:delMod(MOD_FOOD_ATT_CAP, 65); end;
gpl-3.0
csulbacm/LavaWhales
external/Quickie/checkbox.lua
15
2611
--[[ Copyright (c) 2012 Matthias Richter Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ]]-- local BASE = (...):match("(.-)[^%.]+$") local core = require(BASE .. 'core') local group = require(BASE .. 'group') local mouse = require(BASE .. 'mouse') local keyboard = require(BASE .. 'keyboard') -- {checked = status, text = "", algin = "left", pos = {x, y}, size={w, h}, widgetHit=widgetHit, draw=draw} return function(w) assert(type(w) == "table") w.text = w.text or "" local tight = w.size and (w.size[1] == 'tight' or w.size[2] == 'tight') if tight then local f = assert(love.graphics.getFont()) if w.size[1] == 'tight' then w.size[1] = f:getWidth(w.text) end if w.size[2] == 'tight' then w.size[2] = f:getHeight(w.text) end -- account for the checkbox local bw = math.min(w.size[1] or group.size[1], w.size[2] or group.size[2]) w.size[1] = w.size[1] + bw + 4 end local id = w.id or core.generateID() local pos, size = group.getRect(w.pos, w.size) mouse.updateWidget(id, pos, size, w.widgetHit) keyboard.makeCyclable(id) local checked = w.checked local key = keyboard.key if mouse.releasedOn(id) or ((key == 'return' or key == ' ') and keyboard.hasFocus(id)) then w.checked = not w.checked end core.registerDraw(id, w.draw or core.style.Checkbox, w.checked, w.text, w.align or 'left', pos[1], pos[2], size[1], size[2]) return w.checked ~= checked end
mit
AlexandreCA/darkstar
scripts/globals/abilities/wild_flourish.lua
27
2207
----------------------------------- -- Ability: Wild Flourish -- Readies target for a skillchain. Requires at least two Finishing Moves. -- Obtained: Dancer Level 60 -- Finishing Moves Used: 2 -- Recast Time: 0:30 -- Duration: 0:05 ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/weaponskills"); ----------------------------------- -- onAbilityCheck ----------------------------------- function onAbilityCheck(player,target,ability) if (player:getAnimation() ~= 1) then return MSGBASIC_REQUIRES_COMBAT,0; else if (player:hasStatusEffect(EFFECT_FINISHING_MOVE_1)) then return MSGBASIC_NO_FINISHINGMOVES,0; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_2)) then player:delStatusEffect(EFFECT_FINISHING_MOVE_2); return 0,0; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_3)) then player:delStatusEffectSilent(EFFECT_FINISHING_MOVE_3); player:addStatusEffect(EFFECT_FINISHING_MOVE_1,1,0,7200); return 0,0; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_4)) then player:delStatusEffectSilent(EFFECT_FINISHING_MOVE_4); player:addStatusEffect(EFFECT_FINISHING_MOVE_2,1,0,7200); return 0,0; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_5)) then player:delStatusEffectSilent(EFFECT_FINISHING_MOVE_5); player:addStatusEffect(EFFECT_FINISHING_MOVE_3,1,0,7200); return 0,0; else return MSGBASIC_NO_FINISHINGMOVES,0; end end end; ----------------------------------- -- onUseAbility ----------------------------------- function onUseAbility(player,target,ability,action) if (not target:hasStatusEffect(EFFECT_CHAINBOUND, 0) and not target:hasStatusEffect(EFFECT_SKILLCHAIN, 0)) then target:addStatusEffectEx(EFFECT_CHAINBOUND, 0, 1, 0, 5, 0, 1); else ability:setMsg(156); end action:animation(target:getID(), getFlourishAnimation(player:getWeaponSkillType(SLOT_MAIN))) action:speceffect(target:getID(), 1) return 0 end;
gpl-3.0
AlexandreCA/update
scripts/zones/Misareaux_Coast/npcs/Logging_Point.lua
29
1107
----------------------------------- -- Area: Misareaux Coast -- NPC: Logging Point ----------------------------------- package.loaded["scripts/zones/Misareaux_Coast/TextIDs"] = nil; ------------------------------------- require("scripts/globals/logging"); require("scripts/zones/Misareaux_Coast/TextIDs"); ----------------------------------- -- onTrade ----------------------------------- function onTrade(player,npc,trade) startLogging(player,player:getZoneID(),npc,trade,0x022B); end; ----------------------------------- -- onTrigger ----------------------------------- function onTrigger(player,npc) player:messageSpecial(LOGGING_IS_POSSIBLE_HERE,1021); 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
AlexandreCA/darkstar
scripts/zones/Lufaise_Meadows/TextIDs.lua
15
1194
-- Variable TextID Description text -- General Texts ITEM_CANNOT_BE_OBTAINED = 6379; -- You cannot obtain the item <item>. Come back after sorting your inventory. ITEM_OBTAINED = 6384; -- Obtained: <item>. GIL_OBTAINED = 6385; -- Obtained <number> gil. KEYITEM_OBTAINED = 6387; -- Obtained key item: <keyitem>. NOTHING_OUT_OF_THE_ORDINARY = 6398; -- There is nothing out of the ordinary here. FISHING_MESSAGE_OFFSET = 7547; -- You can't fish here. -- Conquest CONQUEST = 7213; -- You've earned conquest points! -- Logging LOGGING_IS_POSSIBLE_HERE = 7719; -- Logging is possible here if you have -- Other Texts SURVEY_THE_SURROUNDINGS = 7726; -- You survey the surroundings but see nothing out of the ordinary. MURDEROUS_PRESENCE = 7727; -- Wait, you sense a murderous presence...! YOU_CAN_SEE_FOR_MALMS = 7728; -- You can see for malms in every direction. SPINE_CHILLING_PRESENCE = 7730; -- You sense a spine-chilling presence! KI_STOLEN = 7671; -- The ?Possible Special Code: 01??Possible Special Code: 05?3??BAD CHAR: 80??BAD CHAR: 80? has been stolen! -- conquest Base CONQUEST_BASE = 7045; -- Tallying conquest results...
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Garlaige_Citadel/npcs/qm10.lua
13
1364
----------------------------------- -- Area: Garlaige Citadel -- NPC: qm10 (???) -- Involved in Quest: Hitting the Marquisate (THF AF3) -- @pos -139.895 -5.500 154.513 200 ----------------------------------- package.loaded["scripts/zones/Garlaige_Citadel/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/zones/Garlaige_Citadel/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local hittingTheMarquisateHagainCS = player:getVar("hittingTheMarquisateHagainCS"); if (hittingTheMarquisateHagainCS == 6) then player:messageSpecial(PRESENCE_FROM_CEILING); player:setVar("hittingTheMarquisateHagainCS",7); 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); end;
gpl-3.0
AlexandreCA/update
scripts/zones/Kuftal_Tunnel/Zone.lua
17
2256
----------------------------------- -- -- Zone: Kuftal_Tunnel (174) -- ----------------------------------- package.loaded["scripts/zones/Kuftal_Tunnel/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/zone"); require("scripts/zones/Kuftal_Tunnel/TextIDs"); require("scripts/globals/weather"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) local tomes = {17490321,17490322,17490323,17490324}; SetGroundsTome(tomes); -- Guivre SetRespawnTime(17490234, 900, 10800); UpdateTreasureSpawnPoint(17490300); 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(20.37,-21.104,275.782,46); end return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onZoneWeatherChange ----------------------------------- function onZoneWeatherChange(weather) if (weather == WEATHER_WIND or weather == WEATHER_GALES) then GetNPCByID(17490280):setAnimation(9); -- Rock Up else GetNPCByID(17490280):setAnimation(8); -- Rock Down end end;
gpl-3.0
AlexandreCA/update
scripts/zones/Port_Bastok/npcs/Bagnobrok.lua
36
1585
----------------------------------- -- Area: Port Bastok -- NPC: Bagnobrok -- Only sells when Bastok controls Movalpolos -- Confirmed shop stock, August 2013 ----------------------------------- require("scripts/globals/shop"); require("scripts/globals/conquest"); package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil; require("scripts/zones/Port_Bastok/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) RegionOwner = GetRegionOwner(MOVALPOLOS); if (RegionOwner ~= BASTOK) then player:showText(npc,BAGNOBROK_CLOSED_DIALOG); else player:showText(npc,BAGNOBROK_OPEN_DIALOG); stock = { 0x0280, 11, --Copper Ore 0x1162, 694, --Coral Fungus 0x1117, 4032, --Danceshroom 0x0672, 6500, --Kopparnickel Ore 0x142D, 736 --Movalpolos Water } showShop(player,BASTOK,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
annulen/premake-annulen
src/actions/vstudio/vs2002_csproj.lua
2
4726
-- -- vs2002_csproj.lua -- Generate a Visual Studio 2002/2003 C# project. -- Copyright (c) 2009-2011 Jason Perkins and the Premake project -- premake.vstudio.cs2002 = { } local vstudio = premake.vstudio local cs2002 = premake.vstudio.cs2002 -- -- Figure out what elements a particular file need in its item block, -- based on its build action and any related files in the project. -- local function getelements(prj, action, fname) if action == "Compile" and fname:endswith(".cs") then return "SubTypeCode" end if action == "EmbeddedResource" and fname:endswith(".resx") then -- is there a matching *.cs file? local basename = fname:sub(1, -6) local testname = path.getname(basename .. ".cs") if premake.findfile(prj, testname) then return "Dependency", testname end end return "None" end -- -- Write out the <Files> element. -- function cs2002.Files(prj) local tr = premake.project.buildsourcetree(prj) premake.tree.traverse(tr, { onleaf = function(node) local action = premake.dotnet.getbuildaction(node.cfg) local fname = path.translate(premake.esc(node.path), "\\") local elements, dependency = getelements(prj, action, node.path) _p(4,'<File') _p(5,'RelPath = "%s"', fname) _p(5,'BuildAction = "%s"', action) if dependency then _p(5,'DependentUpon = "%s"', premake.esc(path.translate(dependency, "\\"))) end if elements == "SubTypeCode" then _p(5,'SubType = "Code"') end _p(4,'/>') end }, false) end -- -- The main function: write the project file. -- function cs2002.generate(prj) io.eol = "\r\n" _p('<VisualStudioProject>') _p(1,'<CSHARP') _p(2,'ProjectType = "Local"') _p(2,'ProductVersion = "%s"', iif(_ACTION == "vs2002", "7.0.9254", "7.10.3077")) _p(2,'SchemaVersion = "%s"', iif(_ACTION == "vs2002", "1.0", "2.0")) _p(2,'ProjectGuid = "{%s}"', prj.uuid) _p(1,'>') _p(2,'<Build>') -- Write out project-wide settings _p(3,'<Settings') _p(4,'ApplicationIcon = ""') _p(4,'AssemblyKeyContainerName = ""') _p(4,'AssemblyName = "%s"', prj.buildtarget.basename) _p(4,'AssemblyOriginatorKeyFile = ""') _p(4,'DefaultClientScript = "JScript"') _p(4,'DefaultHTMLPageLayout = "Grid"') _p(4,'DefaultTargetSchema = "IE50"') _p(4,'DelaySign = "false"') if _ACTION == "vs2002" then _p(4,'NoStandardLibraries = "false"') end _p(4,'OutputType = "%s"', premake.dotnet.getkind(prj)) if _ACTION == "vs2003" then _p(4,'PreBuildEvent = ""') _p(4,'PostBuildEvent = ""') end _p(4,'RootNamespace = "%s"', prj.buildtarget.basename) if _ACTION == "vs2003" then _p(4,'RunPostBuildEvent = "OnBuildSuccess"') end _p(4,'StartupObject = ""') _p(3,'>') -- Write out configuration blocks for cfg in premake.eachconfig(prj) do _p(4,'<Config') _p(5,'Name = "%s"', premake.esc(cfg.name)) _p(5,'AllowUnsafeBlocks = "%s"', iif(cfg.flags.Unsafe, "true", "false")) _p(5,'BaseAddress = "285212672"') _p(5,'CheckForOverflowUnderflow = "false"') _p(5,'ConfigurationOverrideFile = ""') _p(5,'DefineConstants = "%s"', premake.esc(table.concat(cfg.defines, ";"))) _p(5,'DocumentationFile = ""') _p(5,'DebugSymbols = "%s"', iif(cfg.flags.Symbols, "true", "false")) _p(5,'FileAlignment = "4096"') _p(5,'IncrementalBuild = "false"') if _ACTION == "vs2003" then _p(5,'NoStdLib = "false"') _p(5,'NoWarn = ""') end _p(5,'Optimize = "%s"', iif(cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed, "true", "false")) _p(5,'OutputPath = "%s"', premake.esc(cfg.buildtarget.directory)) _p(5,'RegisterForComInterop = "false"') _p(5,'RemoveIntegerChecks = "false"') _p(5,'TreatWarningsAsErrors = "%s"', iif(cfg.flags.FatalWarnings, "true", "false")) _p(5,'WarningLevel = "4"') _p(4,'/>') end _p(3,'</Settings>') -- List assembly references _p(3,'<References>') for _, ref in ipairs(premake.getlinks(prj, "siblings", "object")) do _p(4,'<Reference') _p(5,'Name = "%s"', ref.buildtarget.basename) _p(5,'Project = "{%s}"', ref.uuid) _p(5,'Package = "{%s}"', vstudio.tool(ref)) _p(4,'/>') end for _, linkname in ipairs(premake.getlinks(prj, "system", "fullpath")) do _p(4,'<Reference') _p(5,'Name = "%s"', path.getbasename(linkname)) _p(5,'AssemblyName = "%s"', path.getname(linkname)) if path.getdirectory(linkname) ~= "." then _p(5,'HintPath = "%s"', path.translate(linkname, "\\")) end _p(4,'/>') end _p(3,'</References>') _p(2,'</Build>') -- List source files _p(2,'<Files>') _p(3,'<Include>') cs2002.Files(prj) _p(3,'</Include>') _p(2,'</Files>') _p(1,'</CSHARP>') _p('</VisualStudioProject>') end
bsd-3-clause
KingRaptor/Zero-K-Infrastructure
Benchmarker/Benchmarks/games/path_test.sdd/Luaui/pathTests/Config/Crossing_4_final.lua
12
1412
local test = { { delayToNextTest = 300, unitList = {}, }, { delayToNextTest = 300, unitList = {}, }, { delayToNextTest = 300, unitList = {}, }, { delayToNextTest = 300, unitList = {}, }, } local MAX_DELAY_FACTOR = 1.75 local stepSize = 128 local units = { "corak", "corraid", "corsh", "correap", "corak", "corraid", "corsh", "correap", } local x1 = 128 local x2 = Game.mapSizeX - x1 for testNum = 1,#test do if units[testNum] and UnitDefNames[units[testNum]] then local unitDef = UnitDefNames[units[testNum]] local unitList = test[testNum].unitList local maxTravelTime = ((x1 - x2))/unitDef.speed * 30 * MAX_DELAY_FACTOR if maxTravelTime < 0 then maxTravelTime = -maxTravelTime end for z = stepSize, Game.mapSizeZ - stepSize, stepSize do local y1 = Spring.GetGroundHeight(x1, z) local y2 = Spring.GetGroundHeight(x2, z) unitList[#unitList+1] = { unitName = units[testNum], teamID = 0, startCoordinates = {x1, y1, z}, destinationCoordinates = {{x2, y2, z}}, maxTargetDist = 40, maxTravelTime = maxTravelTime, } end --Spring.Echo("Max travel time for " .. units[testNum] .. ": " .. maxTravelTime) --Spring.Log(widget:GetInfo().name, "info", "Max travel time for " .. units[testNum] .. ": " .. maxTravelTime) else Spring.Log(widget:GetInfo().name, "warning", "invalid unit name for path test") end end return test
gpl-3.0
LuaDist2/tiny-ecs
spec/tiny_spec.lua
2
9627
local GLOBALS = {} for k, v in pairs(_G) do GLOBALS[k] = v end local tiny = require "tiny" local function deep_copy(x) if type(x) == 'table' then local nx = {} for k, v in next, x, nil do nx[deep_copy(k)] = deep_copy(v) end return nx else return x end end local entityTemplate1 = { xform = {x = 0, y = 0}, vel = {x = 1, y = 2}, name = "E1", size = 11, description = "It goes to 11.", spinalTap = true } local entityTemplate2 = { xform = {x = 2, y = 2}, vel = {x = -1, y = 0}, name = "E2", size = 10, description = "It does not go to 11.", onlyTen = true } local entityTemplate3 = { xform = {x = 4, y = 5}, vel = {x = 0, y = 3}, name = "E3", size = 8, description = "The smallest entity.", littleMan = true } describe('tiny-ecs:', function() describe('Filters:', function() local entity1, entity2, entity3 before_each(function() entity1 = deep_copy(entityTemplate1) entity2 = deep_copy(entityTemplate2) entity3 = deep_copy(entityTemplate3) end) it("Default Filters", function() local ftap = tiny.requireAll("spinalTap") local fvel = tiny.requireAll("vel") local fxform = tiny.requireAll("xform") local fall = tiny.requireAny("spinalTap", "onlyTen", "littleMan") -- Only select Entities without "spinalTap" local frtap = tiny.rejectAny("spinalTap") -- Select Entities without all three: "spinalTap", "onlyTen", and -- "littleMan" local frall = tiny.rejectAll("spinalTap", "onlyTen", "littleMan") assert.truthy(fall(nil, entity1)) assert.truthy(ftap(nil, entity1)) assert.falsy(ftap(nil, entity2)) assert.truthy(fxform(nil, entity1)) assert.truthy(fxform(nil, entity2)) assert.truthy(fall(nil, entity1)) assert.truthy(fall(nil, entity2)) assert.truthy(fall(nil, entity3)) assert.falsy(frtap(nil, entity1)) assert.truthy(frtap(nil, entity2)) assert.truthy(frtap(nil, entity3)) assert.truthy(frall(nil, entity1)) assert.truthy(frall(nil, entity2)) assert.truthy(frall(nil, entity3)) end) it("Can use functions as subfilters", function() local f1 = tiny.requireAny('a', 'b', 'c') local f2 = tiny.requireAll('x', 'y', 'z') local f = tiny.requireAll(f1, f2) assert.truthy(f(nil, { x = true, y = true, z = true, a = true, b = true, c = true })) assert.truthy(f(nil, { x = true, y = true, z = true, a = true })) assert.falsy(f(nil, { x = true, y = true, a = true })) assert.falsy(f(nil, { x = true, y = true, z = true })) end) it("Can use string filters", function() local f = tiny.filter('a|b|c') assert.truthy(f(nil, { a = true, b = true, c = true })) assert.truthy(f(nil, { a = true })) assert.truthy(f(nil, { b = true })) assert.truthy(f(nil, { c = true })) assert.falsy(f(nil, { x = true, y = true, z = true })) end) end) describe('World:', function() local world, entity1, entity2, entity3 local moveSystem = tiny.processingSystem() moveSystem.filter = tiny.requireAll("xform", "vel") function moveSystem:process(e, dt) local xform = e.xform local vel = e.vel local x, y = xform.x, xform.y local xvel, yvel = vel.x, vel.y xform.x, xform.y = x + xvel * dt, y + yvel * dt end local timePassed = 0 local oneTimeSystem = tiny.system() function oneTimeSystem:update(dt) timePassed = timePassed + dt end before_each(function() entity1 = deep_copy(entityTemplate1) entity2 = deep_copy(entityTemplate2) entity3 = deep_copy(entityTemplate3) world = tiny.world(moveSystem, oneTimeSystem, entity1, entity2, entity3) timePassed = 0 end) after_each(function() world:clearSystems() world:refresh() end) it("Create World", function() assert.equals(world:getEntityCount(), 3) assert.equals(world:getSystemCount(), 2) end) it("Run simple simulation", function() world:update(1) assert.equals(timePassed, 1) assert.equals(entity1.xform.x, 1) assert.equals(entity1.xform.y, 2) end) it("Remove Entities", function() world:remove(entity1, entity2) world:update(1) assert.equals(timePassed, 1) assert.equals(entity1.xform.x, entityTemplate1.xform.x) assert.equals(entity2.xform.x, entityTemplate2.xform.x) assert.equals(entity3.xform.y, 8) end) it("Remove Systems", function() world:remove(moveSystem, oneTimeSystem) world:update(1) assert.equals(timePassed, 0) assert.equals(entity1.xform.x, entityTemplate1.xform.x) assert.equals(0, world:getSystemCount()) end) it("Deactivate and Activate Systems", function() moveSystem.active = false oneTimeSystem.active = false world:update(1) assert.equals(world:getSystemCount(), 2) assert.equals(timePassed, 0) assert.equals(entity1.xform.x, entityTemplate1.xform.x) moveSystem.active = true oneTimeSystem.active = true world:update(1) assert.equals(timePassed, 1) assert.are_not.equal(entity1.xform.x, entityTemplate1.xform.x) assert.equals(world:getSystemCount(), 2) end) it("Clear Entities", function() world:clearEntities() world:update(1) assert.equals(0, world:getEntityCount()) end) it("Clear Systems", function() world:clearSystems() world:update(1) assert.equals(0, world:getSystemCount()) end) it("Add Entities Multiple Times", function() world:update(1) world:add(entity1, entity2, entity3) world:update(2) assert.equals(2, world:getSystemCount()) assert.equals(3, world:getEntityCount()) end) it("Remove Entities Multiple Times", function() assert.equals(3, world:getEntityCount()) world:update(1) world:remove(entity1, entity2, entity3) world:update(2) assert.equals(0, world:getEntityCount()) world:remove(entity1, entity2, entity3) world:update(2) assert.equals(2, world:getSystemCount()) assert.equals(0, world:getEntityCount()) end) it("Add Systems Multiple Times", function() world:update(1) assert.has_error(function() world:add(moveSystem, oneTimeSystem) end, "System already belongs to a World.") world:update(2) assert.equals(2, world:getSystemCount()) assert.equals(3, world:getEntityCount()) end) it("Remove Systems Multiple Times", function() world:update(1) world:remove(moveSystem) world:update(2) assert.has_error(function() world:remove(moveSystem) end, "System does not belong to this World.") world:update(2) assert.equals(1, world:getSystemCount()) assert.equals(3, world:getEntityCount()) end) it("Reorder Systems", function() world:update(1) world:setSystemIndex(moveSystem, 2) world:update(1) assert.equals(2, moveSystem.index) assert.equals(1, oneTimeSystem.index) end) it("Sorts Entities in Sorting Systems", function() local sortsys = tiny.sortedProcessingSystem() sortsys.filter = tiny.filter("vel|xform") function sortsys:compare(e1, e2) return e1.vel.x < e2.vel.x end world:add(sortsys) world:refresh() assert.equals(sortsys.entities[1], entity2) assert.equals(sortsys.entities[2], entity3) assert.equals(sortsys.entities[3], entity1) end) it("Runs preWrap and postWrap for systems.", function() local str = "" local sys1 = tiny.system() local sys2 = tiny.system() function sys1:preWrap(dt) str = str .. "<" end function sys2:preWrap(dt) str = str .. "{" end function sys1:postWrap(dt) str = str .. ">" end function sys2:postWrap(dt) str = str .. "}" end world:add(sys1, sys2) world:update(1) assert.equals(str, "{<>}") end) end) it("Doesn't pollute the global namespace", function() assert.are.same(_G, GLOBALS) end) end)
mit
paly2/minetest-minetestforfun-server
mods/homedecor_modpack/homedecor/init.lua
1
5322
-- Home Decor mod by VanessaE -- -- Mostly my own code, with bits and pieces lifted from Minetest's default -- lua files and from ironzorg's flowers mod. Many thanks to GloopMaster -- for helping me figure out the inventories used in the nightstands/dressers. -- -- The code for ovens, nightstands, refrigerators are basically modified -- copies of the code for chests and furnaces. homedecor = {} homedecor.debug = 0 -- detail level for roofing slopes and also cobwebs homedecor.detail_level = 16 homedecor.modpath = minetest.get_modpath("homedecor") -- Boilerplate to support localized strings if intllib mod is installed. local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end homedecor.gettext = S -- debug local dbg = function(s) if homedecor.debug == 1 then print('[HomeDecor] ' .. s) end end -- infinite stacks if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then homedecor.expect_infinite_stacks = false else homedecor.expect_infinite_stacks = true end --table copy function homedecor.table_copy(t) local nt = { }; for k, v in pairs(t) do if type(v) == "table" then nt[k] = homedecor.table_copy(v) else nt[k] = v end end return nt end -- Determine if the item being pointed at is the underside of a node (e.g a ceiling) function homedecor.find_ceiling(itemstack, placer, pointed_thing) -- most of this is copied from the rotate-and-place function in builtin local unode = core.get_node_or_nil(pointed_thing.under) if not unode then return end local undef = core.registered_nodes[unode.name] if undef and undef.on_rightclick then undef.on_rightclick(pointed_thing.under, unode, placer, itemstack, pointed_thing) return end local pitch = placer:get_look_pitch() local fdir = core.dir_to_facedir(placer:get_look_dir()) local wield_name = itemstack:get_name() local above = pointed_thing.above local under = pointed_thing.under local iswall = (above.y == under.y) local isceiling = not iswall and (above.y < under.y) local anode = core.get_node_or_nil(above) if not anode then return end local pos = pointed_thing.above local node = anode if undef and undef.buildable_to then pos = pointed_thing.under node = unode iswall = false end if core.is_protected(pos, placer:get_player_name()) then core.record_protection_violation(pos, placer:get_player_name()) return end local ndef = core.registered_nodes[node.name] if not ndef or not ndef.buildable_to then return end return isceiling, pos end screwdriver = screwdriver or {} homedecor.plain_wood = "homedecor_generic_wood_plain.png^".. "(homedecor_generic_wood_boards_overlay.png^[colorize:#a7682020:100)" homedecor.mahogany_wood = "(homedecor_generic_wood_plain.png^[colorize:#401010:125)^".. "(homedecor_generic_wood_boards_overlay.png^[colorize:#66493880:200)" homedecor.white_wood = "(homedecor_generic_wood_plain.png^[colorize:#e0f0ff:200)^".. "(homedecor_generic_wood_boards_overlay.png^[colorize:#ffffff:200)" homedecor.dark_wood = "(homedecor_generic_wood_plain.png^[colorize:#140900:200)^".. "(homedecor_generic_wood_boards_overlay.png^[colorize:#21110180:180)" -- nodebox arithmetics and helpers -- (please keep non-generic nodeboxes with their node definition) dofile(homedecor.modpath.."/handlers/nodeboxes.lua") -- expand and unexpand decor dofile(homedecor.modpath.."/handlers/expansion.lua") -- register nodes that cook stuff dofile(homedecor.modpath.."/handlers/furnaces.lua") -- glue it all together into a registration function dofile(homedecor.modpath.."/handlers/registration.lua") -- some nodes have particle spawners dofile(homedecor.modpath.."/handlers/water_particles.lua") dofile(homedecor.modpath.."/handlers/sit.lua") -- load various other components dofile(homedecor.modpath.."/misc-nodes.lua") -- the catch-all for all misc nodes dofile(homedecor.modpath.."/tables.lua") dofile(homedecor.modpath.."/electronics.lua") dofile(homedecor.modpath.."/shutters.lua") dofile(homedecor.modpath.."/shingles.lua") dofile(homedecor.modpath.."/slopes.lua") dofile(homedecor.modpath.."/doors_and_gates.lua") dofile(homedecor.modpath.."/fences.lua") dofile(homedecor.modpath.."/lighting.lua") dofile(homedecor.modpath.."/kitchen_appliances.lua") dofile(homedecor.modpath.."/kitchen_furniture.lua") dofile(homedecor.modpath.."/bathroom_furniture.lua") dofile(homedecor.modpath.."/bathroom_sanitation.lua") dofile(homedecor.modpath.."/laundry.lua") dofile(homedecor.modpath.."/nightstands.lua") dofile(homedecor.modpath.."/clocks.lua") dofile(homedecor.modpath.."/misc-electrical.lua") dofile(homedecor.modpath.."/window_treatments.lua") dofile(homedecor.modpath.."/furniture.lua") dofile(homedecor.modpath.."/furniture_medieval.lua") dofile(homedecor.modpath.."/furniture_recipes.lua") dofile(homedecor.modpath.."/climate-control.lua") dofile(homedecor.modpath.."/cobweb.lua") dofile(homedecor.modpath.."/beds.lua") dofile(homedecor.modpath.."/books.lua") dofile(homedecor.modpath.."/exterior.lua") dofile(homedecor.modpath.."/trash_cans.lua") dofile(homedecor.modpath.."/wardrobe.lua") dofile(homedecor.modpath.."/handlers/locked.lua") dofile(homedecor.modpath.."/crafts.lua") minetest.log("action", "[HomeDecor] "..S("Loaded!"))
unlicense
Phrozyn/MozDef
examples/heka-lua-bro/bro_ssl.lua
2
4045
-- This Source Code Form is subject to the terms of the Mozilla Public -- License, v. 2.0. If a copy of the MPL was not distributed with this -- file, You can obtain one at http://mozilla.org/MPL/2.0/. -- Copyright (c) 2014 Mozilla Corporation local l=require "lpeg" local string=require "string" l.locale(l) --add locale entries in the lpeg table local space = l.space^0 --define a space constant local sep = l.P"\t" local elem = l.C((1-sep)^0) grammar = l.Ct(elem * (sep * elem)^0) -- split on tabs, return as table function toString(value) if value == "-" then return nil end return value end function nilToString(value) if value == nil then return "" end return value end function toNumber(value) if value == "-" then return nil end return tonumber(value) end function lastField(value) -- remove last "\n" if there's one if value ~= nil and string.len(value) > 1 and string.sub(value, -2) == "\n" then return string.sub(value, 1, -2) end return value end function process_message() local log = read_message("Payload") --set a default msg that heka's --message matcher can ignore via a message matcher: -- message_matcher = "( Type!='heka.all-report' && Type != 'IGNORE' )" local msg = { Type = "IGNORE", Fields={} } local matches = grammar:match(log) if not matches then --return 0 to not propogate errors to heka's log. --return a message with IGNORE type to not match heka's message matcher inject_message(msg) return 0 end if string.sub(log,1,1)=='#' then --it's a comment line inject_message(msg) return 0 end countfields = 0 for index, value in pairs(matches) do countfields = countfields + 1 end function truncate(value) -- truncate the URI if too long (heka limited to 63KiB messages) if toString(value) then if string.len(value) > 10000 then return toString(string.sub(value, 1, 10000)) .. "[truncated]" else return value end end end msg['Type']='brossl' msg['Logger']='nsm' msg['ts'] = toString(matches[1]) msg.Fields['uid'] = toString(matches[2]) msg.Fields['sourceipaddress'] = toString(matches[3]) msg.Fields['sourceport'] = toNumber(matches[4]) msg.Fields['destinationipaddress'] = toString(matches[5]) msg.Fields['destinationport'] = toNumber(matches[6]) msg.Fields['version'] = toString(matches[7]) msg.Fields['cipher'] = truncate(toString(matches[8])) if toString(matches[9]) ~= nil then msg.Fields['curve'] = toString(matches[9]) end msg.Fields['server_name'] = truncate(toString(matches[10])) msg.Fields['resumed'] = truncate(toString(matches[11])) msg.Fields['last_alert'] = toString(matches[12]) msg.Fields['nextprotocol'] = toString(matches[13]) msg.Fields['established'] = toString(matches[14]) msg.Fields['cert_chain_fuids'] = truncate(toString(matches[15])) msg.Fields['client_cert_chain_fuids'] = truncate(toString(matches[16])) msg.Fields['subject'] = truncate(toString(matches[17])) msg.Fields['issuer'] = truncate(toString(matches[18])) msg.Fields['client_subject'] = truncate(toString(matches[19])) msg.Fields['client_issuer'] = truncate(toString(matches[20])) msg.Fields['weak_cipher'] = toString(matches[21]) msg.Fields['pfs'] = lastField(toString(matches[22])) if msg.Fields['server_name'] ~= nil then msg['Payload'] = "SSL: " .. nilToString(msg.Fields['sourceipaddress']) .. " -> " .. nilToString(msg.Fields['destinationipaddress']) .. ":" .. nilToString(msg.Fields['destinationport']) .. " " .. msg.Fields['server_name'] else msg['Payload'] = "SSL: " .. nilToString(msg.Fields['sourceipaddress']) .. " -> " .. nilToString(msg.Fields['destinationipaddress']) .. ":" .. nilToString(msg.Fields['destinationport']) end inject_message(msg) return 0 end
mpl-2.0
AlexandreCA/update
scripts/zones/Gustav_Tunnel/mobs/Macroplasm.lua
18
1100
---------------------------------- -- Area: Gustav Tunnel -- MOB: macroplasm ----------------------------------- package.loaded["scripts/zones/Gustav_Tunnel/TextIDs"] = nil; require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/zones/Gustav_Tunnel/TextIDs"); ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer) local X = GetMobByID(17645795):getXPos(); local Y = GetMobByID(17645795):getYPos(); local Z = GetMobByID(17645795):getZPos(); local A = GetMobByID(17645796):getXPos(); local B = GetMobByID(17645796):getYPos(); local C = GetMobByID(17645796):getZPos(); if (mob:getID() == 17645795) then SpawnMob(17645797):setPos(X,Y,Z); SpawnMob(17645798):setPos(X,Y,Z); GetMobByID(17645797):updateEnmity(killer); GetMobByID(17645798):updateEnmity(killer); elseif (mob:getID() == 17645796) then SpawnMob(17645799):setPos(A,B,C); SpawnMob(17645800):setPos(A,B,C); GetMobByID(17645799):updateEnmity(killer); GetMobByID(17645800):updateEnmity(killer); end end;
gpl-3.0
nwf/openwrt-luci
applications/luci-app-qos/luasrc/model/cbi/qos/qos.lua
17
2481
-- Copyright 2008 Steven Barth <steven@midlink.org> -- Licensed to the public under the Apache License 2.0. local wa = require "luci.tools.webadmin" local fs = require "nixio.fs" m = Map("qos", translate("Quality of Service"), translate("With <abbr title=\"Quality of Service\">QoS</abbr> you " .. "can prioritize network traffic selected by addresses, " .. "ports or services.")) s = m:section(TypedSection, "interface", translate("Interfaces")) s.addremove = true s.anonymous = false e = s:option(Flag, "enabled", translate("Enable")) e.rmempty = false c = s:option(ListValue, "classgroup", translate("Classification group")) c:value("Default", translate("default")) c.default = "Default" s:option(Flag, "overhead", translate("Calculate overhead")) s:option(Flag, "halfduplex", translate("Half-duplex")) dl = s:option(Value, "download", translate("Download speed (kbit/s)")) dl.datatype = "and(uinteger,min(1))" ul = s:option(Value, "upload", translate("Upload speed (kbit/s)")) ul.datatype = "and(uinteger,min(1))" s = m:section(TypedSection, "classify", translate("Classification Rules")) s.template = "cbi/tblsection" s.anonymous = true s.addremove = true s.sortable = true t = s:option(ListValue, "target", translate("Target")) t:value("Priority", translate("priority")) t:value("Express", translate("express")) t:value("Normal", translate("normal")) t:value("Bulk", translate("low")) t.default = "Normal" srch = s:option(Value, "srchost", translate("Source host")) srch.rmempty = true srch:value("", translate("all")) wa.cbi_add_knownips(srch) dsth = s:option(Value, "dsthost", translate("Destination host")) dsth.rmempty = true dsth:value("", translate("all")) wa.cbi_add_knownips(dsth) l7 = s:option(ListValue, "layer7", translate("Service")) l7.rmempty = true l7:value("", translate("all")) local pats = io.popen("find /etc/l7-protocols/ -type f -name '*.pat'") if pats then local l while true do l = pats:read("*l") if not l then break end l = l:match("([^/]+)%.pat$") if l then l7:value(l) end end pats:close() end p = s:option(Value, "proto", translate("Protocol")) p:value("", translate("all")) p:value("tcp", "TCP") p:value("udp", "UDP") p:value("icmp", "ICMP") p.rmempty = true ports = s:option(Value, "ports", translate("Ports")) ports.rmempty = true ports:value("", translate("all")) bytes = s:option(Value, "connbytes", translate("Number of bytes")) comment = s:option(Value, "comment", translate("Comment")) return m
apache-2.0
AlexandreCA/darkstar
scripts/globals/abilities/drain_samba_ii.lua
25
1434
----------------------------------- -- Ability: Drain Samba II -- Inflicts the next target you strike with Drain Daze, allowing all those engaged in battle with it to drain its HP. -- Obtained: Dancer Level 35 -- TP Required: 25% -- Recast Time: 1:00 -- Duration: 1:30 ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------- -- onAbilityCheck ----------------------------------- function onAbilityCheck(player,target,ability) if (player:hasStatusEffect(EFFECT_FAN_DANCE)) then return MSGBASIC_UNABLE_TO_USE_JA2, 0; elseif (player:hasStatusEffect(EFFECT_TRANCE)) then return 0,0; elseif (player:getTP() < 250) then return MSGBASIC_NOT_ENOUGH_TP,0; else return 0,0; end; end; ----------------------------------- -- onUseAbility ----------------------------------- function onUseAbility(player,target,ability) -- Only remove TP if the player doesn't have Trance. if not player:hasStatusEffect(EFFECT_TRANCE) then player:delTP(250); end; local duration = 120 + player:getMod(MOD_SAMBA_DURATION); duration = duration * (100 + player:getMod(MOD_SAMBA_PDURATION))/100; player:delStatusEffect(EFFECT_HASTE_SAMBA); player:delStatusEffect(EFFECT_ASPIR_SAMBA); player:addStatusEffect(EFFECT_DRAIN_SAMBA,2,0,duration); end;
gpl-3.0
nwf/openwrt-luci
applications/luci-app-diag-devinfo/luasrc/model/cbi/luci_diag/smap_devinfo_mini.lua
141
1031
--[[ smap_devinfo - SIP Device Information (c) 2009 Daniel Dickinson Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id$ ]]-- require("luci.i18n") require("luci.util") require("luci.sys") require("luci.model.uci") require("luci.controller.luci_diag.smap_common") require("luci.controller.luci_diag.devinfo_common") local debug = false m = SimpleForm("luci-smap-to-devinfo", translate("Phone Information"), translate("Scan for supported SIP devices on specified networks.")) m.reset = false m.submit = false local outnets = luci.controller.luci_diag.smap_common.get_params() luci.controller.luci_diag.devinfo_common.run_processes(outnets, luci.controller.luci_diag.smap_common.command_function) luci.controller.luci_diag.devinfo_common.parse_output(m, outnets, true, "smap", true, debug) luci.controller.luci_diag.smap_common.action_links(m, true) return m
apache-2.0
AlexandreCA/update
scripts/zones/North_Gustaberg/npcs/Kuleo.lua
17
1867
----------------------------------- -- Area: North Gustaberg -- NPC: Kuleo -- Type: Outpost Vendor -- @pos -586 39 61 106 ----------------------------------- package.loaded["scripts/zones/North_Gustaberg/TextIDs"] = nil; ----------------------------------- require("scripts/globals/shop"); require("scripts/globals/conquest"); require("scripts/zones/North_Gustaberg/TextIDs"); local region = GUSTABERG; local csid = 0x7ff4; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local owner = GetRegionOwner(region); local 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
jstewart-amd/premake-core
modules/d/tests/test_visualstudio.lua
7
1563
--- -- d/tests/test_visualstudio.lua -- Automated test suite for VisualD project generation. -- Copyright (c) 2011-2015 Manu Evans and the Premake project --- local suite = test.declare("visual_d") local m = premake.modules.d --------------------------------------------------------------------------- -- Setup/Teardown --------------------------------------------------------------------------- local wks, prj, cfg function suite.setup() premake.action.set("vs2010") -- premake.escaper(premake.vstudio.vs2005.esc) premake.indent(" ") wks = workspace "MyWorkspace" configurations { "Debug", "Release" } language "D" kind "ConsoleApp" end local function prepare() prj = project "MyProject" end local function prepare_cfg() prj = project "MyProject" cfg = test.getconfig(prj, "Debug") end -- -- Check sln for the proper project entry -- function suite.slnProj() project "MyProject" language "D" premake.vstudio.sln2005.reorderProjects(wks) premake.vstudio.sln2005.projects(wks) test.capture [[ Project("{002A2DE9-8BB6-484D-9802-7E4AD4084715}") = "MyProject", "MyProject.visualdproj", "{42B5DBC6-AE1F-903D-F75D-41E363076E92}" EndProject ]] end -- -- Project tests -- function suite.OnProject_header() prepare() m.visuald.header(prj) test.capture [[ <DProject> ]] end function suite.OnProject_globals() prepare() m.visuald.globals(prj) test.capture [[ <ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid> ]] end -- TODO: break up the project gen and make lots more tests...
bsd-3-clause
AlexandreCA/update
scripts/zones/Bastok_Markets/npcs/Charging_Chocobo.lua
36
1678
----------------------------------- -- Area: Bastok Markets -- NPC: Charging Chocobo -- Standard Merchant NPC -- -- 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,CHARGINGCHOKOBO_SHOP_DIALOG); stock = { 0x3220, 191,3, --Bronze Subligar 0x3210, 1646,3, --Scale Cuisses 0x3211, 14131,3, --Brass Cuisses 0x3200, 34776,3, --Cuisses 0x32A0, 117,3, --Bronze Leggins 0x3290, 998,3, --Scale Greaves 0x3291, 8419,3, --Brass Greaves 0x3280, 21859,3, --Plate Leggins 0x3318, 16891,3, --Gorget 0x3388, 382,3, --Leather Belt 0x338C, 10166,3 --Silver Belt } 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
aschmois/WebTimer
nodeMCU/factoryReset.lua
1
1109
local seconds = 0 local function flashQuickly() local function checkFactoryResetOff() if(gpio.read(3) == 1) then node.restart() end end tmr.stop(4) tmr.stop(5) tmr.stop(6) gpio.mode(gpio1, gpio.OUTPUT) gpio.write(gpio1, gpio.LOW) tmr.alarm(4, 200, 1, toggleGPIO1LED) tmr.alarm(3, 1000, 1, checkFactoryResetOff) end local function checkFactoryReset() if(gpio.read(3) == 0) then if(file.open("config", "r") ~= nil) then if(seconds == 0) then gpio.mode(gpio1, gpio.OUTPUT) gpio.write(gpio1, gpio.LOW) tmr.alarm(4, 2500, 1, toggleGPIO1LED) print("Starting Factory Reset Check") end seconds = seconds + 1 if(seconds == 10) then print("Factory Reset!") file.remove("config") node.restart() end else flashQuickly() end else seconds = 0 end end tmr.alarm(6, 1000, 1, checkFactoryReset) -- If at the time of loading, gpio0 is low, it means a factory reset is in order if(gpio.read(3) == 0) then if(file.open("config", "r") ~= nil) then print("Factory Reset!") file.remove("config") else flashQuickly() end file.close("config") end
mit