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
anshkumar/yugioh-glaze
assets/script/c93483212.lua
3
3833
--極神聖帝オーディン function c93483212.initial_effect(c) --synchro summon aux.AddSynchroProcedure(c,c93483212.tfilter,aux.NonTuner(nil),2) c:EnableReviveLimit() --disable local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(93483212,0)) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1) e1:SetOperation(c93483212.imop) c:RegisterEffect(e1) --special summon local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_TO_GRAVE) e2:SetOperation(c93483212.regop) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(93483212,1)) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_PHASE+PHASE_END) e3:SetRange(LOCATION_GRAVE) e3:SetCountLimit(1) e3:SetCondition(c93483212.spcon) e3:SetCost(c93483212.spcost) e3:SetTarget(c93483212.sptg) e3:SetOperation(c93483212.spop) c:RegisterEffect(e3) --damage local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(93483212,2)) e4:SetCategory(CATEGORY_DRAW) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e4:SetCode(EVENT_SPSUMMON_SUCCESS) e4:SetCondition(c93483212.drcon) e4:SetTarget(c93483212.drtg) e4:SetOperation(c93483212.drop) c:RegisterEffect(e4) end function c93483212.tfilter(c) return c:IsSetCard(0x3042) or c:IsCode(61777313) end function c93483212.imop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsFaceup() and c:IsRelateToEffect(e) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e1:SetRange(LOCATION_MZONE) e1:SetCode(EFFECT_IMMUNE_EFFECT) e1:SetValue(c93483212.imfilter) e1:SetReset(RESET_EVENT+0x1ff0000+RESET_PHASE+PHASE_END) c:RegisterEffect(e1) end end function c93483212.imfilter(e,re) return re:IsActiveType(TYPE_SPELL+TYPE_TRAP) end function c93483212.regop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local pos=c:GetPreviousPosition() if c:IsReason(REASON_BATTLE) then pos=c:GetBattlePosition() end if rp~=tp and c:GetPreviousControler()==tp and c:IsReason(REASON_DESTROY) and c:IsPreviousLocation(LOCATION_ONFIELD) and bit.band(pos,POS_FACEUP)~=0 then c:RegisterFlagEffect(93483212,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1) end end function c93483212.spcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetFlagEffect(93483212)~=0 end function c93483212.cfilter(c) return c:IsSetCard(0x3042) and c:IsType(TYPE_TUNER) and c:IsAbleToRemoveAsCost() end function c93483212.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c93483212.cfilter,tp,LOCATION_GRAVE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c93483212.cfilter,tp,LOCATION_GRAVE,0,1,1,nil) Duel.Remove(g,POS_FACEUP,REASON_COST) end function c93483212.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,1,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function c93483212.spop(e,tp,eg,ep,ev,re,r,rp) if e:GetHandler():IsRelateToEffect(e) then Duel.SpecialSummon(e:GetHandler(),1,tp,tp,false,false,POS_FACEUP) end end function c93483212.drcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetSummonType()==SUMMON_TYPE_SPECIAL+1 end function c93483212.drtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c93483212.drop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c98637386.lua
5
1443
--ゴヨウ・プレデター function c98637386.initial_effect(c) --synchro summon aux.AddSynchroProcedure(c,nil,aux.NonTuner(nil),1) c:EnableReviveLimit() --special summon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(98637386,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetCode(EVENT_BATTLE_DESTROYING) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCountLimit(1,98637386) e1:SetCondition(aux.bdogcon) e1:SetTarget(c98637386.sptg) e1:SetOperation(c98637386.spop) c:RegisterEffect(e1) end function c98637386.sptg(e,tp,eg,ep,ev,re,r,rp,chk) local bc=e:GetHandler():GetBattleTarget() if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and bc:IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetTargetCard(bc) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,bc,1,0,0) end function c98637386.spop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then if Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP) then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e1:SetCode(EVENT_PRE_BATTLE_DAMAGE) e1:SetOperation(c98637386.rdop) e1:SetReset(RESET_EVENT+0x1fe0000) tc:RegisterEffect(e1,true) Duel.SpecialSummonComplete() end end end function c98637386.rdop(e,tp,eg,ep,ev,re,r,rp) Duel.ChangeBattleDamage(ep,ev/2) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c21558682.lua
3
2162
--ディフェンド・スライム function c21558682.initial_effect(c) --activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetHintTiming(0,TIMING_BATTLE_START) e1:SetTarget(c21558682.atktg1) e1:SetOperation(c21558682.atkop) c:RegisterEffect(e1) --change target local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(21558682,0)) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_ATTACK_ANNOUNCE) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetRange(LOCATION_SZONE) e2:SetCondition(c21558682.atkcon) e2:SetTarget(c21558682.atktg2) e2:SetOperation(c21558682.atkop) c:RegisterEffect(e2) end function c21558682.atkcon(e,tp,eg,ep,ev,re,r,rp) return tp~=Duel.GetTurnPlayer() and Duel.GetAttackTarget()~=nil end function c21558682.filter(c) return c:IsFaceup() and c:IsCode(31709826) end function c21558682.atktg1(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c21558682.filter(chkc) end if chk==0 then return true end e:SetProperty(0) if Duel.CheckEvent(EVENT_ATTACK_ANNOUNCE) and tp~=Duel.GetTurnPlayer() then local at=Duel.GetAttackTarget() if at and Duel.IsExistingTarget(c21558682.filter,tp,LOCATION_MZONE,0,1,at) and Duel.SelectYesNo(tp,aux.Stringid(21558682,1)) then e:SetProperty(EFFECT_FLAG_CARD_TARGET) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) Duel.SelectTarget(tp,c21558682.filter,tp,LOCATION_MZONE,0,1,1,at) end end end function c21558682.atktg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c21558682.filter(chkc) end local at=Duel.GetAttackTarget() if chk==0 then return Duel.IsExistingTarget(c21558682.filter,tp,LOCATION_MZONE,0,1,at) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) Duel.SelectTarget(tp,c21558682.filter,tp,LOCATION_MZONE,0,1,1,at) end function c21558682.atkop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local tc=Duel.GetFirstTarget() if tc and tc:IsFaceup() and tc:IsRelateToEffect(e) then Duel.ChangeAttackTarget(tc) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c50474354.lua
9
1915
--武神器-ヤサカニ function c50474354.initial_effect(c) --search local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(50474354,0)) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_HAND) e1:SetCountLimit(1,50474354) e1:SetCondition(c50474354.condition) e1:SetCost(c50474354.cost) e1:SetTarget(c50474354.target) e1:SetOperation(c50474354.operation) c:RegisterEffect(e1) Duel.AddCustomActivityCounter(50474354,ACTIVITY_CHAIN,c50474354.chainfilter) end function c50474354.chainfilter(re,tp,cid) return re:GetHandler():IsSetCard(0x88) end function c50474354.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.GetCurrentPhase()==PHASE_MAIN2 end function c50474354.cost(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return Duel.GetCustomActivityCount(50474354,tp,ACTIVITY_CHAIN)==0 and c:IsAbleToGraveAsCost() end Duel.SendtoGrave(c,REASON_COST) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH) e1:SetCode(EFFECT_CANNOT_ACTIVATE) e1:SetTargetRange(1,0) e1:SetValue(c50474354.aclimit) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end function c50474354.aclimit(e,re,tp) return not re:GetHandler():IsSetCard(0x88) end function c50474354.filter(c) return c:IsSetCard(0x88) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand() end function c50474354.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c50474354.filter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function c50474354.operation(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c50474354.filter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c66127916.lua
3
1860
--融合準備 function c66127916.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetHintTiming(0,TIMING_END_PHASE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(c66127916.target) e1:SetOperation(c66127916.activate) c:RegisterEffect(e1) end function c66127916.filter1(c,tp) return c.material_count and Duel.IsExistingMatchingCard(c66127916.filter2,tp,LOCATION_DECK,0,1,nil,c) end function c66127916.filter2(c,fc) if c:IsHasEffect(EFFECT_FORBIDDEN) or not c:IsAbleToHand() then return false end for i=1,fc.material_count do if c:IsCode(fc.material[i]) then return true end end return false end function c66127916.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c66127916.filter1,tp,LOCATION_EXTRA,0,1,nil,tp) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function c66127916.filter3(c) return c:IsCode(24094653) and c:IsAbleToHand() and not c:IsHasEffect(EFFECT_NECRO_VALLEY) end function c66127916.activate(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONFIRM) local cg=Duel.SelectMatchingCard(tp,c66127916.filter1,tp,LOCATION_EXTRA,0,1,1,nil,tp) if cg:GetCount()==0 then return end Duel.ConfirmCards(1-tp,cg) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c66127916.filter2,tp,LOCATION_DECK,0,1,1,nil,cg:GetFirst()) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) local tg=Duel.GetMatchingGroup(c66127916.filter3,tp,LOCATION_GRAVE,0,nil) if tg:GetCount()>0 and Duel.SelectYesNo(tp,aux.Stringid(66127916,0)) then Duel.BreakEffect() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local sg=tg:Select(tp,1,1,nil) Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) end end end
gpl-2.0
kiarash14/bumper1
bot/seedbot.lua
1
8667
package.path = package.path .. ';.luarocks/share/lua/5.2/?.lua' ..';.luarocks/share/lua/5.2/?/init.lua' package.cpath = package.cpath .. ';.luarocks/lib/lua/5.2/?.so' require("./bot/utils") VERSION = '1.0' -- This function is called when tg receive a msg function on_msg_receive (msg) if not started then return end local receiver = get_receiver(msg) print (receiver) -- vardump(msg) msg = pre_process_service_msg(msg) if msg_valid(msg) then msg = pre_process_msg(msg) if msg then match_plugins(msg) -- mark_read(receiver, ok_cb, false) end end end function ok_cb(extra, success, result) end function on_binlog_replay_end() started = true postpone (cron_plugins, false, 60*5.0) _config = load_config() -- load plugins plugins = {} load_plugins() end function msg_valid(msg) -- Don't process outgoing messages if msg.out then print('\27[36mNot valid: msg from us\27[39m') return false end -- Before bot was started if msg.date < now then print('\27[36mNot valid: old msg\27[39m') return false end if msg.unread == 0 then print('\27[36mNot valid: readed\27[39m') return false end if not msg.to.id then print('\27[36mNot valid: To id not provided\27[39m') return false end if not msg.from.id then print('\27[36mNot valid: From id not provided\27[39m') return false end if msg.from.id == our_id then print('\27[36mNot valid: Msg from our id\27[39m') return false end if msg.to.type == 'encr_chat' then print('\27[36mNot valid: Encrypted chat\27[39m') return false end if msg.from.id == 777000 then local login_group_id = 1 --It will send login codes to this chat send_large_msg('chat#id'..login_group_id, msg.text) end return true end -- function pre_process_service_msg(msg) if msg.service then local action = msg.action or {type=""} -- Double ! to discriminate of normal actions msg.text = "!!tgservice " .. action.type -- wipe the data to allow the bot to read service messages if msg.out then msg.out = false end if msg.from.id == our_id then msg.from.id = 0 end end return msg end -- Apply plugin.pre_process function function pre_process_msg(msg) for name,plugin in pairs(plugins) do if plugin.pre_process and msg then print('Preprocess', name) msg = plugin.pre_process(msg) end end return msg end -- Go over enabled plugins patterns. function match_plugins(msg) for name, plugin in pairs(plugins) do match_plugin(plugin, name, msg) end end -- Check if plugin is on _config.disabled_plugin_on_chat table local function is_plugin_disabled_on_chat(plugin_name, receiver) local disabled_chats = _config.disabled_plugin_on_chat -- Table exists and chat has disabled plugins if disabled_chats and disabled_chats[receiver] then -- Checks if plugin is disabled on this chat for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do if disabled_plugin == plugin_name and disabled then local warning = 'Plugin '..disabled_plugin..' is disabled on this chat' print(warning) send_msg(receiver, warning, ok_cb, false) return true end end end return false end function match_plugin(plugin, plugin_name, msg) local receiver = get_receiver(msg) -- Go over patterns. If one matches it's enough. for k, pattern in pairs(plugin.patterns) do local matches = match_pattern(pattern, msg.text) if matches then print("msg matches: ", pattern) if is_plugin_disabled_on_chat(plugin_name, receiver) then return nil end -- Function exists if plugin.run then -- If plugin is for privileged users only if not warns_user_not_allowed(plugin, msg) then local result = plugin.run(msg, matches) if result then send_large_msg(receiver, result) end end end -- One patterns matches return end end end -- DEPRECATED, use send_large_msg(destination, text) function _send_msg(destination, text) send_large_msg(destination, text) end -- Save the content of _config to config.lua function save_config( ) serialize_to_file(_config, './data/config.lua') print ('saved config into ./data/config.lua') end -- Returns the config from config.lua file. -- If file doesn't exist, create it. function load_config( ) local f = io.open('./data/config.lua', "r") -- If config.lua doesn't exist if not f then print ("Created new config file: data/config.lua") create_config() else f:close() end local config = loadfile ("./data/config.lua")() for v,user in pairs(config.sudo_users) do print("Allowed user: " .. user) end return config end -- Create a basic config.json file and saves it. function create_config( ) -- A simple config with basic plugins and ourselves as privileged user config = { enabled_plugins = { "onservice", "inrealm", "ingroup", "inpm", "banhammer", "stats", "anti_spam", "owners", "arabic_lock", "set", "get", "broadcast", "download_media", "invite", "all", "leave_ban" }, sudo_users = {100096055,116943847,0,tonumber(our_id)},--Sudo users disabled_channels = {}, realm = {data = 'data/moderation.json'},--Realms Id moderation = {data = 'data/moderation.json'}, about_text = [[Teleseed v1 An advance Administration bot based on yagop/telegram-bot Admins @kiarash_gh1 [manage] @Xx_MaMad-ahrimanam_xX [Founder] Special thanks to awkward_potato Siyanew topkecleon Vamptacus ID BOT: @teleBUMPER [English] ]], help_text = [[ Commands list : !kick [username|id] You can also do it by reply !ban [ username|id] You can also do it by reply !unban [id] You can also do it by reply !who Members list !modlist Moderators list !promote [username] Promote someone !demote [username] Demote someone !kickme Will kick user !about Group description !setphoto Set and locks group photo !setname [name] Set group name !rules Group rules !id return group id or user id !help !lock [member|name|bots] Locks [member|name|bots] !unlock [member|name|photo|bots] Unlocks [member|name|photo|bots] !set rules <text> Set <text> as rules !set about <text> Set <text> as about !settings Returns group settings !newlink create/revoke your group link !link returns group link !owner returns group owner id !setowner [id] Will set id as owner !setflood [value] Set [value] as flood sensitivity !stats Simple message statistics !save [value] <text> Save <text> as [value] !get [value] Returns text of [value] !clean [modlist|rules|about] Will clear [modlist|rules|about] and set it to nil !res [username] returns user id "!res @username" !log will return group logs !banlist will return group ban list **U can use both "/" and "!" *Only owner and mods can add bots in group *Only moderators and owner can use kick,ban,unban,newlink,link,setphoto,setname,lock,unlock,set rules,set about and settings commands *Only owner can use res,setowner,promote,demote and log commands ]] } serialize_to_file(config, './data/config.lua') print('saved config into ./data/config.lua') end function on_our_id (id) our_id = id end function on_user_update (user, what) --vardump (user) end function on_chat_update (chat, what) end function on_secret_chat_update (schat, what) --vardump (schat) end function on_get_difference_end () end -- Enable plugins in config.json function load_plugins() for k, v in pairs(_config.enabled_plugins) do print("Loading plugin", v) local ok, err = pcall(function() local t = loadfile("plugins/"..v..'.lua')() plugins[v] = t end) if not ok then print('\27[31mError loading plugin '..v..'\27[39m') print('\27[31m'..err..'\27[39m') end end end -- custom add function load_data(filename) local f = io.open(filename) if not f then return {} end local s = f:read('*all') f:close() local data = JSON.decode(s) return data end function save_data(filename, data) local s = JSON.encode(data) local f = io.open(filename, 'w') f:write(s) f:close() end -- Call and postpone execution for cron plugins function cron_plugins() for name, plugin in pairs(plugins) do -- Only plugins with cron function if plugin.cron ~= nil then plugin.cron() end end -- Called again in 2 mins postpone (cron_plugins, false, 120) end -- Start and load values our_id = 0 now = os.time() math.randomseed(now) started = false
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c64238008.lua
7
1771
--リニアキャノン function c64238008.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DAMAGE) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCost(c64238008.cost) e1:SetTarget(c64238008.target) e1:SetOperation(c64238008.activate) c:RegisterEffect(e1) Duel.AddCustomActivityCounter(64238008,ACTIVITY_CHAIN,c64238008.chainfilter) end function c64238008.chainfilter(re,tp,cid) return not (re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:IsActiveType(TYPE_SPELL)) end function c64238008.cost(e,tp,eg,ep,ev,re,r,rp,chk) e:SetLabel(1) if chk==0 then return Duel.GetCustomActivityCount(64238008,tp,ACTIVITY_CHAIN)==0 and Duel.CheckReleaseGroup(tp,nil,1,nil) end local g=Duel.SelectReleaseGroup(tp,nil,1,1,nil) local atk=g:GetFirst():GetTextAttack()/2 if atk<0 then atk=0 end e:SetLabel(atk) Duel.Release(g,REASON_COST) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EFFECT_CANNOT_ACTIVATE) e1:SetTargetRange(1,1) e1:SetValue(c64238008.aclimit) e1:SetReset(RESET_PHASE+PHASE_END,1) Duel.RegisterEffect(e1,tp) end function c64238008.aclimit(e,re,tp) return re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:IsActiveType(TYPE_SPELL) end function c64238008.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local res=e:GetLabel()~=0 e:SetLabel(0) return res end Duel.SetTargetPlayer(1-tp) Duel.SetTargetParam(e:GetLabel()) Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,e:GetLabel()) e:SetLabel(0) end function c64238008.activate(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Damage(p,d,REASON_EFFECT) end
gpl-2.0
WAKAMAZU/sile_fe
lua-libraries/std/strbuf.lua
6
1203
--[[-- String buffers. @classmod std.strbuf ]] local Object = require "std.object" --- Add a string to a buffer. -- @tparam string s string to add -- @treturn std.strbuf modified buffer local function concat (self, s) table.insert (self, s) return self end --- Convert a buffer to a string. -- @treturn string stringified `self` local function tostring (self) return table.concat (self) end return Object { -- Derived object type. _type = "StrBuf", ------ -- Support concatenation of StrBuf objects. -- buffer = buffer .. str -- @function __concat -- @tparam std.strbuf buffer StrBuf object -- @tparam string str a string or string-like object -- @treturn std.strbuf modified `buffer` -- @see concat __concat = concat, ------ -- Support fast conversion to Lua string. -- str = tostring (buffer) -- @function __tostring -- @tparam std.strbuf buffer Strbuf object -- @treturn string concatenation of buffer contents -- @see tostring __tostring = tostring, --- @export __index = { concat = concat, tostring = tostring, }, -- backwards compatibility. _functions = { new = function () return StrBuf {} end, }, }
mit
fmidev/himan
himan-scripts/nearby-weather.lua
1
11995
function max (...) maxindex = 0 maxvalue = 0 local arg = {...} for i,v in ipairs(arg) do if (v > maxvalue) then maxindex = i maxvalue = v end end return maxindex, maxvalue end --Main program -- local Missing = missing --Get the weather number local w = luatool:FetchInfo(current_time, current_level, param("WEATHERNUMBER-N")) local Weather = w:GetValues() --Get gust local g = luatool:FetchInfo(current_time, level(HPLevelType.kGround,0), param("FFG-MS")) local gust = g:GetValues() if not Weather or not gust then return end local thunder = {} local prec_form = {} local prec_type = {} local prec_intensity = {} local fog = {} local cloud_cover = {} local cloud_type = {} for i=1, #Weather do --chop weather number into pieces thunder[i] = math.floor((Weather[i]/10^6)%10) prec_form[i] = math.floor((Weather[i]/10^5)%10) prec_type[i] = math.floor((Weather[i]/10^4)%10) prec_intensity[i] = math.floor((Weather[i]/10^3)%10) fog[i] = math.floor((Weather[i]/10^2)%10) cloud_cover[i] = math.floor((Weather[i]/10)%10) cloud_type[i] = math.floor(Weather[i]%10) if (prec_intensity[i] == 0 ) then prec_form[i] = Missing prec_type[i] = Missing end end -- todo set a mask matrix to match 50/100km radius in smartmet edited data local rain_radius = matrix(7, 7, 1, Missing) rain_radius:Fill(1) local wind_radius = matrix(13, 13, 1, Missing) wind_radius:Fill(1) ------------- -- THUNDER -- ------------- local tmp = w:GetData() tmp:SetValues(thunder) local thunder_awareness = {} local thunder_percentage = ProbLimitGe2D(tmp, rain_radius, 1):GetValues() for i=1, #thunder_percentage do thunder_awareness[i] = 0 if (thunder_percentage[i] >= 0.05) then thunder_awareness[i] = 1 end if (thunder_percentage[i] >= 0.30) then thunder_awareness[i] = 2 end end ---------- -- RAIN -- ---------- local rain = {} local dry_limit = {} local rainy_weather = {} local rain_frequency = {} tmp:SetValues(prec_intensity) local dry = ProbLimitEq2D(tmp, rain_radius, 0):GetValues() dry_limit = 0.2 for i=1, #dry do rain[i] = 1 - dry[i] if (rain[i] >= dry_limit ) then rainy_weather[i] =1 if(rain[i] < 0.50) then rain_frequency[i] = 1 elseif(rain[i] >= 0.50 and rain[i] < 0.90) then rain_frequency[i] = 2 else rain_frequency[i] = 3 end end end -------------------- -- RAIN INTENSITY -- -------------------- local weak = ProbLimitEq2D(tmp, rain_radius, 1):GetValues() local weak2 = ProbLimitEq2D(tmp, rain_radius, 2):GetValues() for i=1, #weak do weak[i] = weak[i] + weak2[i] end local strong_water = ProbLimitGe2D(tmp, rain_radius, 5):GetValues() local strong_snow = ProbLimitGe2D(tmp, rain_radius, 3):GetValues() ------------------------ -- PRECIPITATION TYPE -- ------------------------ -- Laskee vallitsevan sateen tyypin alueelle tmp:SetValues(prec_type) rain_radius:Fill(1/169) --set weights adding up to 1 for mean filtering local prevalent_type = Filter2D(tmp, rain_radius, false):GetValues() -- round to whole number for i=1, #prevalent_type do prevalent_type[i] = math.floor(prevalent_type[i] + 0.5 ) end ------------------------ -- PRECIPITATION FORM -- ------------------------ local prevalent_form = {} local prevalent_cover = {} tmp:SetValues(prec_form) rain_radius:Fill(1) --reset weights to original state local drizzle = ProbLimitEq2D(tmp, rain_radius, 0):GetValues() local water = ProbLimitEq2D(tmp, rain_radius, 1):GetValues() local sleet = ProbLimitEq2D(tmp, rain_radius, 2):GetValues() local snow = ProbLimitEq2D(tmp, rain_radius, 3):GetValues() local freezingdrizzle = ProbLimitEq2D(tmp, rain_radius, 4):GetValues() local freezingrain = ProbLimitEq2D(tmp, rain_radius, 5):GetValues() local hail = ProbLimitEq2D(tmp, rain_radius, 6):GetValues() local snowgrain = ProbLimitEq2D(tmp, rain_radius, 7):GetValues() local icegrain = ProbLimitEq2D(tmp, rain_radius, 8):GetValues() local p = luatool:FetchInfo(current_time, level(HPLevelType.kHeight,0), param("POTPRECT-N")) local potprect = p:GetValues() -- this can be done by simply picking the one from above with highest probability for i=1, #potprect do hail[i] = hail[i] + snowgrain[i] + freezingrain[i] freezingrain[i] = freezingrain[i] + freezingdrizzle[i] if(prec_intensity[i] > 0) then prevalent_form[i],prevalent_cover[i] = max(drizzle[i],water[i],sleet[i],snow[i],freezingdrizzle[i],freezingrain[i],hail[i],snowgrain[i],icegrain[i]) else prevalent_form[i] = potprect[i] prevalent_cover[i] = Missing end -- does this make sense? icerain is an area-probability, prevalent_form is a numeral. if (freezingrain[i] > drizzle[i] or freezingrain[i] > water[i] or freezingrain[i] > sleet[i] or freezingrain[i] > snow[i]) then prevalent_form[i] = 5 elseif (hail[i] > drizzle[i] or hail[i] > water[i] or hail[i] > sleet[i] or hail[i] > snow[i]) then prevalent_form[i] = 6 end end --------- -- FOG -- --------- local fog_index = {} tmp:SetValues(fog) local fog_share = ProbLimitGe2D(tmp, rain_radius, 1):GetValues() for i=1, #fog_share do fog_index[i] = 0 if (fog_share[i] > 0.20) then if (fog_share[i] < 0.40) then fog_index[i] = 1 else if (fog_share[i] < 0.75) then fog_index[i] = 2 else fog_index[i] = 3 end end end end ----------------------- -- CLOUDINESS AMOUNT -- ----------------------- -- use mean tmp:SetValues(cloud_cover) rain_radius:Fill(1/169) --set weight for mean filter local MedianCloudiness = Filter2D(tmp, rain_radius, false):GetValues() rain_radius:Fill(1) --reset original value local MinCloudiness = Min2D(tmp, rain_radius, false):GetValues() local MaxCloudiness = Max2D(tmp, rain_radius, false):GetValues() -- Pilvinen (pilvisyys >= 7) local Cloudy = ProbLimitGe2D(tmp, rain_radius, 7):GetValues() -- Melkein pilvinen (pilvisyys = 6) local AlmostCloudy = ProbLimitEq2D(tmp, rain_radius, 6):GetValues() -- Puolipilvinen ( 3<= pilvisyys <= 5 ) local HalfCloudy = ProbLimitGe2D(tmp, rain_radius, 3):GetValues() local HalfCloudy2 = ProbLimitGt2D(tmp, rain_radius, 5):GetValues() for i=1, #HalfCloudy do HalfCloudy[i] = HalfCloudy[i] - HalfCloudy2[i] end -- Aurinkoinen (pilvisyys < 2) local Sunny = ProbLimitLt2D(tmp, rain_radius, 2):GetValues() ----------------- -- STRONG GUST -- ----------------- local gust_number = {} -- Tuulenpuuskat >= 15 m/s tmp:SetValues(gust) local windgust1 = ProbLimitGe2D(tmp, wind_radius, 15):GetValues() for i=1, #windgust1 do if(windgust1[i] > 0.20) then gust_number[i] = 1 end end -- Tuulenpuuskat >= 20 m/s local windgust2 = ProbLimitGe2D(tmp, wind_radius, 20):GetValues() for i=1, #windgust2 do if(windgust2[i] > 0.20) then gust_number[i] = 2 end end ----------------------------- -- NEARBY WEATHER CALCULATION local NEIGHBOUR = Weather for i=1, #NEIGHBOUR do if (thunder_percentage[i] > 0) then if (thunder_awareness[i] >= 2) then NEIGHBOUR[i] = 92000 else NEIGHBOUR[i] = 91000 end elseif (rainy_weather[i] == 1) then NEIGHBOUR[i] = 80000 + rain_frequency[i]*1000 if (prevalent_type[i] == 1 or prevalent_form[i] == 0 or prevalent_form[i] == 5) then NEIGHBOUR[i] = NEIGHBOUR[i] + prevalent_form[i]*100+10 else NEIGHBOUR[i] = NEIGHBOUR[i] + prevalent_form[i]*100+20 end -- Yhditelmäsateita OSA 1. Laitetaan kaikki aluksi jatkuvan sateen teksteille if ( (prevalent_form[i] == 1 and snow[i] >= 0.20 and snow[i] >= sleet[i]) or (prevalent_form[i] == 3 and water[i] >= 0.20 and water[i] >= sleet[i]) ) then NEIGHBOUR[i] = 80130 + rain_frequency[i]*1000 -- vesi- tai lumisadetta elseif ( (prevalent_form[i] == 1 and sleet[i] >= 0.20 and sleet[i] > snow[i]) or (prevalent_form[i] == 2 and water[i] >= 0.20 and water[i] > snow[i]) ) then NEIGHBOUR[i] = 80140 + rain_frequency[i]*1000 -- vesi- tai räntäsadetta elseif ( (prevalent_form[i] == 2 and snow[i] >= 0.20 and snow[i] > water[i]) or (prevalent_form[i] == 3 and sleet[i] >= 0.20 and sleet[i] > water[i]) ) then NEIGHBOUR[i] = 80250 + rain_frequency[i]*1000 -- lumi- tai räntäsadetta end -- Yhditelmäsateita OSA 2. ...korvataan edellisiä tarpeen mukaan kuuroteksteillä. if (prevalent_type[i] == 2) then if ( (prevalent_form[i] == 1 and snow[i] >= 0.20 and snow[i] >= sleet[i]) or (prevalent_form[i] == 3 and water[i] >= 0.20 and water[i] >= sleet[i]) ) then NEIGHBOUR[i] = 80160 + rain_frequency[i]*1000 -- vesi- tai lumikuuroja elseif ( (prevalent_form[i] == 1 and sleet[i] >= 0.20 and sleet[i] > snow[i]) or (prevalent_form[i] == 2 and water[i] >= 0.20 and water[i] > snow[i]) ) then NEIGHBOUR[i] = 80170 + rain_frequency[i]*1000 -- vesi- tai räntäkuuroja elseif ( (prevalent_form[i] == 2 and snow[i] >= 0.20 and snow[i] > water[i]) or (prevalent_form[i] == 3 and sleet[i] >= 0.20 and sleet[i] > water[i]) ) then NEIGHBOUR[i] = 80280 + rain_frequency[i]*1000 -- lumi- tai räntäkuuroja end end -- Laitetaan voimakkaiden (sakeiden) sateiden tekstejä (vesisateella rr>=2.0 mm/h, räntä/lumisateella >=0.4 mm/h) if(strong_water[i] >= 0.30 and prevalent_form[i] == 1 and (snow[i] < 0.20 and sleet[i] < 0.20)) then NEIGHBOUR[i] = NEIGHBOUR[i] - 70000 -- Tehdään ykkösellä alkavia numeroita if(strong_snow[i] >= 0.65 and (prevalent_form[i] == 2 or prevalent_form[i] ==3) and water[i] < 0.20) then NEIGHBOUR[i] = NEIGHBOUR[i] - 70000 -- Tehdään ykkösellä alkavia numeroita end end else -- SUMUTEKSTEJÄ if (fog_index[i] > 0 ) then if (fog_index[i] == 1) then NEIGHBOUR[i] = 61000 -- "paikoin sumua" end if (fog_index[i] == 2) then NEIGHBOUR[i] = 62000 -- "monin paikoin sumua" end if (fog_index[i] == 3) then NEIGHBOUR[i] = 63000 -- "sumua" end else -- PILVITEKSTEJÄ if (MedianCloudiness[i] == 3 or MedianCloudiness[i] >= 6) then -- Laitetaan pohjalle pilvisyys mediaanin avulla ja sovitetaan se tässä käytettävään numerointiin NEIGHBOUR[i] = 70000 + (MedianCloudiness[i]+1)*1000 else NEIGHBOUR[i] = 70000 + MedianCloudiness[i]*1000 end if (Cloudy[i] + AlmostCloudy[i] >= 0.65) then -- "Pilvistä tai melkein pilvistä" NEIGHBOUR[i] = 78000 end if (Cloudy[i] >= 0.90) then -- "Pilvistä" NEIGHBOUR[i] = 79000 end if ((HalfCloudy[i] > 0.50 and HalfCloudy[i] <0.80) and Sunny[i] < 0.05) then -- "Puolipilvistä tai pilvistä" NEIGHBOUR[i] = 77000 end if ((Sunny[i] > 0.30 and Sunny[i] < 0.60) and Cloudy[i] < 0.20) then -- "Selkeää tai puolipilvistä" NEIGHBOUR[i] = 73000 end if ((Sunny[i] >= 0.60 and Sunny[i] <= 0.80) and Cloudy[i] < 0.20) then -- "Melkein selkeää" tai "Enimmäkseen selkeää" tai "Pilvisyys on vähäistä" NEIGHBOUR[i] = 72000 end if (Sunny[i] > 0.80) then NEIGHBOUR[i] = 71000 -- "Selkeää" end if ((MaxCloudiness[i] - MinCloudiness[i] >= 0.05) and cloud_cover[i] >= 6 and (Cloudy[i] < 0.75)) then -- "Vaihtelevaa pilvisyyttä" NEIGHBOUR[i] = 70500 end if (cloud_cover[i] <= 2 and (NEIGHBOUR[i] >= 75000 and NEIGHBOUR[i] <= 79000) ) then -- "Vaihtelevaa pilvisyyttä" , kun pisteessä pilvisyys vähäistä, mutta lähellä puolipilvisestä pilviseen NEIGHBOUR[i] = 70500 end if (NEIGHBOUR[i] == 70000 ) then NEIGHBOUR[i] = 71000 end if (NEIGHBOUR[i] == 74000 ) then NEIGHBOUR[i] = 75000 end end end -- PUUSKATEKSTIEN LISÄYS TARVITTAESSA -- Puuskat >= 15 m/s ja >= 20 m/s if (gust_number[i] == 1) then NEIGHBOUR[i] = NEIGHBOUR[i] + 1 -- >= 15 m/s end if (gust_number[i] == 2) then NEIGHBOUR[i] = NEIGHBOUR[i] + 2 -- >= 20 m/s end end result:SetValues(NEIGHBOUR) result:SetParam(param("NEARW-N")) luatool:WriteToFile(result)
mit
madmanteam/vlc
share/lua/meta/art/00_musicbrainz.lua
71
3091
--[[ Gets an artwork from the Cover Art Archive or Amazon $Id$ Copyright © 2007-2010 the VideoLAN team This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. --]] function descriptor() return { scope="network" } end function try_query(mbid) local relquery = "http://mb.videolan.org/ws/2/release/" .. mbid local s = vlc.stream( relquery ) if not s then return nil end local page = s:read( 65653 ) found, _ = string.find( page, "<artwork>true</artwork>" ) if found then return "http://coverartarchive.org/release/"..mbid.."/front-500" end -- FIXME: multiple results may be available _, _, asin = string.find( page, "<asin>(%w+)</asin>" ) if asin then return "http://images.amazon.com/images/P/"..asin..".01._SCLZZZZZZZ_.jpg" end vlc.msg.dbg("Neither coverartarchive.org nor amazon have cover art for this release") return nil end -- Return the mbid for the first release returned by the MusicBrainz search server for query function get_releaseid(query) local s = vlc.stream( query ) if not s then return nil end local page = s:read( 65653 ) -- FIXME: multiple results may be available and the first one is not -- guaranteed to have asin, so if it doesnt, we wouldnt get any art _, _, releaseid = string.find( page, "<release id=\"([%x%-]-)\"" ) if releaseid then return releaseid end return nil end -- Return the artwork function fetch_art() local meta = vlc.item:metas() if meta["Listing Type"] == "radio" or meta["Listing Type"] == "tv" then return nil end local releaseid = nil if meta["MB_ALBUMID"] then releaseid = meta["MB_ALBUMID"] end if not releaseid and meta["artist"] and meta["album"] then query = "artist:\"" .. meta["artist"] .. "\" AND release:\"" .. meta["album"] .. "\"" relquery = "http://mb.videolan.org/ws/2/release/?query=" .. vlc.strings.encode_uri_component( query ) releaseid = get_releaseid( relquery ) end if not releaseid and meta["artist"] and meta["title"] then query = "artist:\"" .. meta["artist"] .. "\" AND recording:\"" .. meta["title"] .. "\"" recquery = "http://mb.videolan.org/ws/2/recording/?query=" .. vlc.strings.encode_uri_component( query ) releaseid = get_releaseid( recquery ) end if releaseid then return try_query( releaseid ) else return nil end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c41855169.lua
5
1606
--昇霊術師 ジョウゲン function c41855169.initial_effect(c) --disable spsummon local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetRange(LOCATION_MZONE) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTargetRange(1,1) c:RegisterEffect(e1) --destroy local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(41855169,0)) e2:SetCategory(CATEGORY_DESTROY) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_MZONE) e2:SetCost(c41855169.cost) e2:SetTarget(c41855169.target) e2:SetOperation(c41855169.operation) c:RegisterEffect(e2) end function c41855169.cfilter(c) return c:IsDiscardable() and c:IsAbleToGraveAsCost() and not c:IsHasEffect(81674782) end function c41855169.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c41855169.cfilter,tp,LOCATION_HAND,0,1,nil) end local g=Duel.GetFieldGroup(tp,LOCATION_HAND,0) local sg=g:RandomSelect(tp,1) Duel.SendtoGrave(sg,REASON_COST+REASON_DISCARD) end function c41855169.filter(c) return bit.band(c:GetSummonType(),SUMMON_TYPE_SPECIAL)~=0 end function c41855169.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c41855169.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end local g=Duel.GetMatchingGroup(c41855169.filter,tp,LOCATION_MZONE,LOCATION_MZONE,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0) end function c41855169.operation(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(c41855169.filter,tp,LOCATION_MZONE,LOCATION_MZONE,nil) Duel.Destroy(g,REASON_EFFECT) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c37412656.lua
3
1607
--ヒーロー・ブラスト function c37412656.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_DESTROY) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetHintTiming(0,0x1e0) e1:SetTarget(c37412656.target) e1:SetOperation(c37412656.activate) c:RegisterEffect(e1) end function c37412656.filter(c) return c:IsSetCard(0x3008) and c:IsType(TYPE_NORMAL) and c:IsAbleToHand() end function c37412656.dfilter(c,atk) return c:IsFaceup() and c:IsDestructable() and c:IsAttackBelow(atk) end function c37412656.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:GetLocation()==LOCATION_GRAVE and chkc:GetControler()==tp and c37412656.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(c37412656.filter,tp,LOCATION_GRAVE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectTarget(tp,c37412656.filter,tp,LOCATION_GRAVE,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0) local tc=g:GetFirst() local dg=Duel.GetMatchingGroup(c37412656.dfilter,tp,0,LOCATION_MZONE,nil,tc:GetAttack()) if dg:GetCount()>0 then Duel.SetOperationInfo(0,CATEGORY_DESTROY,dg,1,0,0) end end function c37412656.activate(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.SendtoHand(tc,nil,REASON_EFFECT) Duel.BreakEffect() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local dg=Duel.SelectMatchingCard(tp,c37412656.dfilter,tp,0,LOCATION_MZONE,1,1,nil,tc:GetAttack()) Duel.Destroy(dg,REASON_EFFECT) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c86474024.lua
3
1283
--共同戦線 function c86474024.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_CHAINING) e1:SetCondition(c86474024.condition) e1:SetTarget(c86474024.target) e1:SetOperation(c86474024.activate) c:RegisterEffect(e1) end function c86474024.filter1(c,tp) local lv1=c:GetLevel() return lv1>0 and c:IsFaceup() and Duel.IsExistingMatchingCard(c86474024.filter2,tp,LOCATION_MZONE,0,1,c,lv1) end function c86474024.filter2(c,lv1) return c:IsFaceup() and c:GetLevel()==lv1 end function c86474024.condition(e,tp,eg,ep,ev,re,r,rp) return re:IsActiveType(TYPE_TRAP) and re:IsHasType(EFFECT_TYPE_ACTIVATE) and Duel.IsChainNegatable(ev) and Duel.IsExistingMatchingCard(c86474024.filter1,tp,LOCATION_MZONE,0,1,nil,tp) end function c86474024.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0) end end function c86474024.activate(e,tp,eg,ep,ev,re,r,rp) Duel.NegateActivation(ev) if re:GetHandler():IsRelateToEffect(re) then Duel.Destroy(eg,REASON_EFFECT) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c75560629.lua
7
2787
--フリント function c75560629.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_EQUIP) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetTarget(c75560629.target) e1:SetOperation(c75560629.operation) c:RegisterEffect(e1) --atkdown local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_EQUIP) e2:SetCode(EFFECT_UPDATE_ATTACK) e2:SetCondition(c75560629.flcon) e2:SetValue(-300) c:RegisterEffect(e2) --cannot attack local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_EQUIP) e3:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE) e3:SetCondition(c75560629.flcon) c:RegisterEffect(e3) --cannot change pos local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_EQUIP) e4:SetCode(EFFECT_CANNOT_CHANGE_POSITION) e4:SetCondition(c75560629.flcon) c:RegisterEffect(e4) --equip limit local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_SINGLE) e5:SetCode(EFFECT_EQUIP_LIMIT) e5:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e5:SetValue(c75560629.eqlimit) c:RegisterEffect(e5) --reequip local e6=Effect.CreateEffect(c) e6:SetDescription(aux.Stringid(75560629,0)) e6:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e6:SetCode(EVENT_TO_GRAVE) e6:SetProperty(EFFECT_FLAG_CARD_TARGET) e6:SetCondition(c75560629.eqcon) e6:SetTarget(c75560629.target) e6:SetOperation(c75560629.operation) c:RegisterEffect(e6) local e7=e6:Clone() e7:SetCode(EVENT_REMOVE) c:RegisterEffect(e7) end function c75560629.flcon(e) local tc=e:GetHandler():GetEquipTarget() return tc:GetCode()~=83812099 or tc:IsDisabled() end function c75560629.eqlimit(e,c) return c:GetCode()~=83812099 or c:IsDisabled() or not c:GetEquipGroup():IsExists(Card.IsCode,1,e:GetHandler(),75560629) end function c75560629.filter(c) return c:IsFaceup() and (c:GetCode()~=83812099 or c:IsDisabled() or not c:GetEquipGroup():IsExists(Card.IsCode,1,nil,75560629)) end function c75560629.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and c75560629.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(c75560629.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP) Duel.SelectTarget(tp,c75560629.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0) end function c75560629.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsFaceup() then Duel.Equip(tp,c,tc) end end function c75560629.eqcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local ec=c:GetPreviousEquipTarget() return c:IsReason(REASON_LOST_TARGET) and ec and ec:IsReason(REASON_DESTROY) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c74069667.lua
3
4679
--DDD壊薙王アビス・ラグナロク function c74069667.initial_effect(c) --pendulum summon aux.AddPendulumProcedure(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) --spsummon local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY) e2:SetRange(LOCATION_PZONE) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:SetCountLimit(1,74069667) e2:SetCondition(c74069667.spcon1) e2:SetTarget(c74069667.sptg1) e2:SetOperation(c74069667.spop1) c:RegisterEffect(e2) --spsummon local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_SUMMON_SUCCESS) e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY) e3:SetCountLimit(1,74069668) e3:SetTarget(c74069667.sptg2) e3:SetOperation(c74069667.spop2) c:RegisterEffect(e3) local e4=e3:Clone() e4:SetCode(EVENT_SPSUMMON_SUCCESS) c:RegisterEffect(e4) --remove local e5=Effect.CreateEffect(c) e5:SetCategory(CATEGORY_REMOVE) e5:SetType(EFFECT_TYPE_IGNITION) e5:SetProperty(EFFECT_FLAG_CARD_TARGET) e5:SetRange(LOCATION_MZONE) e5:SetCountLimit(1) e5:SetCost(c74069667.rmcost) e5:SetTarget(c74069667.rmtg) e5:SetOperation(c74069667.rmop) c:RegisterEffect(e5) end function c74069667.cfilter(c,tp) return c:IsFaceup() and c:IsSetCard(0xaf) and c:GetSummonPlayer()==tp end function c74069667.spcon1(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(c74069667.cfilter,1,nil,tp) end function c74069667.spfilter1(c,e,tp) return c:IsSetCard(0xaf) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c74069667.sptg1(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c74069667.spfilter1(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(c74069667.spfilter1,tp,LOCATION_GRAVE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,c74069667.spfilter1,tp,LOCATION_GRAVE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,tp,1000) end function c74069667.spop1(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)~=0 then Duel.Damage(tp,1000,REASON_EFFECT) end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CHANGE_DAMAGE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTargetRange(0,1) e1:SetValue(c74069667.val) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end function c74069667.val(e,re,dam,r,rp,rc) if bit.band(r,REASON_BATTLE)~=0 then return dam/2 else return dam end end function c74069667.spfilter2(c,e,tp) return c:IsSetCard(0x10af) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c74069667.sptg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c74069667.spfilter2(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(c74069667.spfilter2,tp,LOCATION_GRAVE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,c74069667.spfilter2,tp,LOCATION_GRAVE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) end function c74069667.spop2(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP) end end function c74069667.rmcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckReleaseGroup(tp,Card.IsSetCard,1,e:GetHandler(),0xaf) end local g=Duel.SelectReleaseGroup(tp,Card.IsSetCard,1,1,e:GetHandler(),0xaf) Duel.Release(g,REASON_COST) end function c74069667.rmtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(1-tp) and chkc:IsLocation(LOCATION_MZONE) and chkc:IsAbleToRemove() end if chk==0 then return Duel.IsExistingTarget(Card.IsAbleToRemove,tp,0,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectTarget(tp,Card.IsAbleToRemove,tp,0,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,1,0,0) end function c74069667.rmop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.Remove(tc,POS_FACEUP,REASON_EFFECT) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c73001017.lua
7
1761
--シルフィード function c73001017.initial_effect(c) c:EnableReviveLimit() --special summon local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_SPSUMMON_PROC) e1:SetProperty(EFFECT_FLAG_UNCOPYABLE) e1:SetRange(LOCATION_HAND) e1:SetCondition(c73001017.spcon) e1:SetOperation(c73001017.spop) c:RegisterEffect(e1) --handes local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(73001017,0)) e2:SetCategory(CATEGORY_HANDES) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e2:SetCode(EVENT_BATTLE_DESTROYED) e2:SetCondition(c73001017.condition) e2:SetTarget(c73001017.target) e2:SetOperation(c73001017.operation) c:RegisterEffect(e2) end function c73001017.spfilter(c) return c:IsAttribute(ATTRIBUTE_WIND) and c:IsAbleToRemoveAsCost() end function c73001017.spcon(e,c) if c==nil then return true end local tp=c:GetControler() return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c73001017.spfilter,tp,LOCATION_GRAVE,0,1,nil) end function c73001017.spop(e,tp,eg,ep,ev,re,r,rp,c) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c73001017.spfilter,tp,LOCATION_GRAVE,0,1,1,nil) Duel.Remove(g,POS_FACEUP,REASON_COST) end function c73001017.condition(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsLocation(LOCATION_GRAVE) and e:GetHandler():IsReason(REASON_BATTLE) end function c73001017.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_HANDES,0,0,1-tp,1) end function c73001017.operation(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetFieldGroup(tp,0,LOCATION_HAND) if g:GetCount()==0 then return end local sg=g:RandomSelect(1-tp,1) Duel.SendtoGrave(sg,REASON_DISCARD+REASON_EFFECT) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c10000030.lua
3
3071
--マジマジ☆マジシャンギャル function c10000030.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsRace,RACE_SPELLCASTER),6,2) c:EnableReviveLimit() --effect local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(10000030,1)) e1:SetCategory(CATEGORY_CONTROL) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE) e1:SetCost(c10000030.cost) e1:SetTarget(c10000030.target1) e1:SetOperation(c10000030.operation1) c:RegisterEffect(e1) --spsummon local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(10000030,2)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE) e2:SetCost(c10000030.cost) e2:SetTarget(c10000030.target2) e2:SetOperation(c10000030.operation2) c:RegisterEffect(e2) end function c10000030.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) and Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,LOCATION_HAND,0,1,nil) end Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription()) e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local rg=Duel.SelectMatchingCard(tp,Card.IsAbleToRemove,tp,LOCATION_HAND,0,1,1,nil) Duel.Remove(rg,POS_FACEUP,REASON_COST) end function c10000030.filter1(c) return c:IsControlerCanBeChanged() end function c10000030.filter2(c,e,tp) return c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c10000030.target1(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) and c10000030.filter1(chkc) end if chk==0 then return Duel.IsExistingTarget(c10000030.filter1,tp,0,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONTROL) local g=Duel.SelectTarget(tp,c10000030.filter1,tp,0,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_CONTROL,g,1,0,0) end function c10000030.target2(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(1-tp) and c10000030.filter2(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(c10000030.filter2,tp,0,LOCATION_GRAVE,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,c10000030.filter2,tp,0,LOCATION_GRAVE,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) end function c10000030.operation1(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and not Duel.GetControl(tc,tp,PHASE_END,1) then if not tc:IsImmuneToEffect(e) and tc:IsAbleToChangeControler() then Duel.Destroy(tc,REASON_EFFECT) end end end function c10000030.operation2(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP) end end
gpl-2.0
Arashbrsh/kings-BOT
plugins/groupmanager.lua
8
11449
-- data saved to moderation.json -- check moderation plugin do local function create_group(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "Hi For Creating Group You Have To Pay 2000 Tomans\nEACH MONTH\nFor Order Group Join↙️\nhttps://telegram.me/joinchat/B4ghtgIvpYlMkBZTG57OhQ" end local group_creator = msg.from.print_name create_group_chat (group_creator, group_name, ok_cb, false) return 'Group '..string.gsub(group_name, '_', ' ')..' has been created.' end local function set_description(msg, data) if not is_momod(msg) then return "For moderators only!" end local data_cat = 'description' data[tostring(msg.to.id)][data_cat] = deskripsi save_data(_config.moderation.data, data) return 'Set group description to:\n'..deskripsi end local function get_description(msg, data) local data_cat = 'description' if not data[tostring(msg.to.id)][data_cat] then return 'No description available.' end local about = data[tostring(msg.to.id)][data_cat] local about = string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about return 'About '..about end local function set_rules(msg, data) if not is_momod(msg) then return "For moderators only!" end local data_cat = 'rules' data[tostring(msg.to.id)][data_cat] = rules save_data(_config.moderation.data, data) return 'Set group rules to:\n'..rules end local function get_rules(msg, data) local data_cat = 'rules' if not data[tostring(msg.to.id)][data_cat] then return 'No rules available.' end local rules = data[tostring(msg.to.id)][data_cat] local rules = string.gsub(msg.to.print_name, '_', ' ')..' rules:\n\n'..rules return rules end -- lock/unlock group name. bot automatically change group name when locked local function lock_group_name(msg, data) if not is_momod(msg) then return "For moderators only!" end local group_name_set = data[tostring(msg.to.id)]['settings']['set_name'] local group_name_lock = data[tostring(msg.to.id)]['settings']['lock_name'] if group_name_lock == 'yes' then return 'Group name is already locked' else data[tostring(msg.to.id)]['settings']['lock_name'] = 'yes' save_data(_config.moderation.data, data) data[tostring(msg.to.id)]['settings']['set_name'] = string.gsub(msg.to.print_name, '_', ' ') save_data(_config.moderation.data, data) return 'Group name has been locked' end end local function unlock_group_name(msg, data) if not is_momod(msg) then return "For moderators only!" end local group_name_set = data[tostring(msg.to.id)]['settings']['set_name'] local group_name_lock = data[tostring(msg.to.id)]['settings']['lock_name'] if group_name_lock == 'no' then return 'Group name is already unlocked' else data[tostring(msg.to.id)]['settings']['lock_name'] = 'no' save_data(_config.moderation.data, data) return 'Group name has been unlocked' end end --lock/unlock group member. bot automatically kick new added user when locked local function lock_group_member(msg, data) if not is_momod(msg) then return "For moderators only!" end local group_member_lock = data[tostring(msg.to.id)]['settings']['lock_member'] if group_member_lock == 'yes' then return 'Group members are already locked' else data[tostring(msg.to.id)]['settings']['lock_member'] = 'yes' save_data(_config.moderation.data, data) end return 'Group members has been locked' end local function unlock_group_member(msg, data) if not is_momod(msg) then return "For moderators only!" end local group_member_lock = data[tostring(msg.to.id)]['settings']['lock_member'] if group_member_lock == 'no' then return 'Group members are not locked' else data[tostring(msg.to.id)]['settings']['lock_member'] = 'no' save_data(_config.moderation.data, data) return 'Group members has been unlocked' end end --lock/unlock group photo. bot automatically keep group photo when locked local function lock_group_photo(msg, data) if not is_momod(msg) then return "For moderators only!" end local group_photo_lock = data[tostring(msg.to.id)]['settings']['lock_photo'] if group_photo_lock == 'yes' then return 'Group photo is already locked' else data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting' save_data(_config.moderation.data, data) end return 'Please send me the group photo now' end local function unlock_group_photo(msg, data) if not is_momod(msg) then return "For moderators only!" end local group_photo_lock = data[tostring(msg.to.id)]['settings']['lock_photo'] if group_photo_lock == 'no' then return 'Group photo is not locked' else data[tostring(msg.to.id)]['settings']['lock_photo'] = 'no' save_data(_config.moderation.data, data) return 'Group photo has been unlocked' end end local function set_group_photo(msg, success, result) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) if success then local file = 'data/photos/chat_photo_'..msg.to.id..'.jpg' print('File downloaded to:', result) os.rename(result, file) print('File moved to:', file) chat_set_photo (receiver, file, ok_cb, false) data[tostring(msg.to.id)]['settings']['set_photo'] = file save_data(_config.moderation.data, data) data[tostring(msg.to.id)]['settings']['lock_photo'] = 'yes' save_data(_config.moderation.data, data) send_large_msg(receiver, 'Photo saved!', ok_cb, false) else print('Error downloading: '..msg.id) send_large_msg(receiver, 'Failed, please try again!', ok_cb, false) end end -- show group settings local function show_group_settings(msg, data) if not is_momod(msg) then return "For moderators only!" end local settings = data[tostring(msg.to.id)]['settings'] local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member return text end function run(msg, matches) --vardump(msg) if matches[1] == 'creategroup' and matches[2] then group_name = matches[2] return create_group(msg) end if not is_chat_msg(msg) then return "This is not a group chat." end local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) if msg.media and is_chat_msg(msg) and is_momod(msg) then if msg.media.type == 'photo' and data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' then load_photo(msg.id, set_group_photo, msg) end end end if data[tostring(msg.to.id)] then local settings = data[tostring(msg.to.id)]['settings'] if matches[1] == 'setabout' and matches[2] then deskripsi = matches[2] return set_description(msg, data) end if matches[1] == 'about' then return get_description(msg, data) end if matches[1] == 'setrules' then rules = matches[2] return set_rules(msg, data) end if matches[1] == 'rules' then return get_rules(msg, data) end if matches[1] == 'group' and matches[2] == 'lock' then --group lock * if matches[3] == 'name' then return lock_group_name(msg, data) end if matches[3] == 'member' then return lock_group_member(msg, data) end if matches[3] == 'photo' then return lock_group_photo(msg, data) end end if matches[1] == 'group' and matches[2] == 'unlock' then --group unlock * if matches[3] == 'name' then return unlock_group_name(msg, data) end if matches[3] == 'member' then return unlock_group_member(msg, data) end if matches[3] == 'photo' then return unlock_group_photo(msg, data) end end if matches[1] == 'group' and matches[2] == 'settings' then return show_group_settings(msg, data) end if matches[1] == 'chat_rename' then if not msg.service then return "Are you trying to troll me?" end local group_name_set = settings.set_name local group_name_lock = settings.lock_name local to_rename = 'chat#id'..msg.to.id if group_name_lock == 'yes' then if group_name_set ~= tostring(msg.to.print_name) then rename_chat(to_rename, group_name_set, ok_cb, false) end elseif group_name_lock == 'no' then return nil end end if matches[1] == 'setname' and is_momod(msg) then local new_name = string.gsub(matches[2], '_', ' ') data[tostring(msg.to.id)]['settings']['set_name'] = new_name save_data(_config.moderation.data, data) local group_name_set = data[tostring(msg.to.id)]['settings']['set_name'] local to_rename = 'chat#id'..msg.to.id rename_chat(to_rename, group_name_set, ok_cb, false) end if matches[1] == 'setphoto' and is_momod(msg) then data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting' save_data(_config.moderation.data, data) return 'Please send me new group photo now' end if matches[1] == 'chat_add_user' then if not msg.service then return "Are you trying to troll me?" end local group_member_lock = settings.lock_member local user = 'user#id'..msg.action.user.id local chat = 'chat#id'..msg.to.id if group_member_lock == 'yes' then chat_del_user(chat, user, ok_cb, true) elseif group_member_lock == 'no' then return nil end end if matches[1] == 'chat_delete_photo' then if not msg.service then return "Are you trying to troll me?" end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then chat_set_photo (receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end if matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then if not msg.service then return "Are you trying to troll me?" end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then chat_set_photo (receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end end end return { description = "Plugin to manage group chat.", usage = { "!creategroup <group_name> : Create a new group (admin only)", "!setabout <description> : Set group description", "!about : Read group description", "!setrules <rules> : Set group rules", "!rules : Read group rules", "!setname <new_name> : Set group name", "!setphoto : Set group photo", "!group <lock|unlock> name : Lock/unlock group name", "!group <lock|unlock> photo : Lock/unlock group photo", "!group <lock|unlock> member : Lock/unlock group member", "!group settings : Show group settings" }, patterns = { "^!(creategroup) (.*)$", "^!(setabout) (.*)$", "^!(about)$", "^!(setrules) (.*)$", "^!(rules)$", "^!(setname) (.*)$", "^!(setphoto)$", "^!(group) (lock) (.*)$", "^!(group) (unlock) (.*)$", "^!(group) (settings)$", "^!!tgservice (.+)$", "%[(photo)%]", }, run = run, } end
gpl-2.0
zwhfly/openwrt-luci
libs/nixio/lua/nixio/util.lua
179
5824
--[[ nixio - Linux I/O library for lua Copyright 2009 Steven Barth <steven@midlink.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id$ ]]-- local table = require "table" local nixio = require "nixio" local getmetatable, assert, pairs, type = getmetatable, assert, pairs, type local tostring = tostring module "nixio.util" local BUFFERSIZE = nixio.const.buffersize local ZIOBLKSIZE = 65536 local socket = nixio.meta_socket local tls_socket = nixio.meta_tls_socket local file = nixio.meta_file local uname = nixio.uname() local ZBUG = uname.sysname == "Linux" and uname.release:sub(1, 3) == "2.4" function consume(iter, append) local tbl = append or {} if iter then for obj in iter do tbl[#tbl+1] = obj end end return tbl end local meta = {} function meta.is_socket(self) return (getmetatable(self) == socket) end function meta.is_tls_socket(self) return (getmetatable(self) == tls_socket) end function meta.is_file(self) return (getmetatable(self) == file) end function meta.readall(self, len) local block, code, msg = self:read(len or BUFFERSIZE) if not block then return nil, code, msg, "" elseif #block == 0 then return "", nil, nil, "" end local data, total = {block}, #block while not len or len > total do block, code, msg = self:read(len and (len - total) or BUFFERSIZE) if not block then return nil, code, msg, table.concat(data) elseif #block == 0 then break end data[#data+1], total = block, total + #block end local data = #data > 1 and table.concat(data) or data[1] return data, nil, nil, data end meta.recvall = meta.readall function meta.writeall(self, data) data = tostring(data) local sent, code, msg = self:write(data) if not sent then return nil, code, msg, 0 end local total = sent while total < #data do sent, code, msg = self:write(data, total) if not sent then return nil, code, msg, total end total = total + sent end return total, nil, nil, total end meta.sendall = meta.writeall function meta.linesource(self, limit) limit = limit or BUFFERSIZE local buffer = "" local bpos = 0 return function(flush) local line, endp, _ if flush then line = buffer:sub(bpos + 1) buffer = type(flush) == "string" and flush or "" bpos = 0 return line end while not line do _, endp, line = buffer:find("(.-)\r?\n", bpos + 1) if line then bpos = endp return line elseif #buffer < limit + bpos then local newblock, code, msg = self:read(limit + bpos - #buffer) if not newblock then return nil, code, msg elseif #newblock == 0 then return nil end buffer = buffer:sub(bpos + 1) .. newblock bpos = 0 else return nil, 0 end end end end function meta.blocksource(self, bs, limit) bs = bs or BUFFERSIZE return function() local toread = bs if limit then if limit < 1 then return nil elseif limit < toread then toread = limit end end local block, code, msg = self:read(toread) if not block then return nil, code, msg elseif #block == 0 then return nil else if limit then limit = limit - #block end return block end end end function meta.sink(self, close) return function(chunk, src_err) if not chunk and not src_err and close then if self.shutdown then self:shutdown() end self:close() elseif chunk and #chunk > 0 then return self:writeall(chunk) end return true end end function meta.copy(self, fdout, size) local source = self:blocksource(nil, size) local sink = fdout:sink() local sent, chunk, code, msg = 0 repeat chunk, code, msg = source() sink(chunk, code, msg) sent = chunk and (sent + #chunk) or sent until not chunk return not code and sent or nil, code, msg, sent end function meta.copyz(self, fd, size) local sent, lsent, code, msg = 0 local splicable if not ZBUG and self:is_file() then local ftype = self:stat("type") if nixio.sendfile and fd:is_socket() and ftype == "reg" then repeat lsent, code, msg = nixio.sendfile(fd, self, size or ZIOBLKSIZE) if lsent then sent = sent + lsent size = size and (size - lsent) end until (not lsent or lsent == 0 or (size and size == 0)) if lsent or (not lsent and sent == 0 and code ~= nixio.const.ENOSYS and code ~= nixio.const.EINVAL) then return lsent and sent, code, msg, sent end elseif nixio.splice and not fd:is_tls_socket() and ftype == "fifo" then splicable = true end end if nixio.splice and fd:is_file() and not splicable then splicable = not self:is_tls_socket() and fd:stat("type") == "fifo" end if splicable then repeat lsent, code, msg = nixio.splice(self, fd, size or ZIOBLKSIZE) if lsent then sent = sent + lsent size = size and (size - lsent) end until (not lsent or lsent == 0 or (size and size == 0)) if lsent or (not lsent and sent == 0 and code ~= nixio.const.ENOSYS and code ~= nixio.const.EINVAL) then return lsent and sent, code, msg, sent end end return self:copy(fd, size) end if tls_socket then function tls_socket.close(self) return self.socket:close() end function tls_socket.getsockname(self) return self.socket:getsockname() end function tls_socket.getpeername(self) return self.socket:getpeername() end function tls_socket.getsockopt(self, ...) return self.socket:getsockopt(...) end tls_socket.getopt = tls_socket.getsockopt function tls_socket.setsockopt(self, ...) return self.socket:setsockopt(...) end tls_socket.setopt = tls_socket.setsockopt end for k, v in pairs(meta) do file[k] = v socket[k] = v if tls_socket then tls_socket[k] = v end end
apache-2.0
anshkumar/yugioh-glaze
assets/script/c88305978.lua
3
2057
--BF-陽炎のカーム function c88305978.initial_effect(c) --special summon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(88305978,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_FREE_CHAIN) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetRange(LOCATION_GRAVE) e1:SetCondition(c88305978.condition) e1:SetCost(c88305978.cost) e1:SetTarget(c88305978.target) e1:SetOperation(c88305978.operation) c:RegisterEffect(e1) end function c88305978.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()~=tp and Duel.GetCurrentPhase()==PHASE_BATTLE and Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)==0 end function c88305978.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST) end function c88305978.filter(c,e,tp) return c:IsType(TYPE_SYNCHRO) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c88305978.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c88305978.filter(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(c88305978.filter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,c88305978.filter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) end function c88305978.operation(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)~=0 then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_PHASE+PHASE_BATTLE) e1:SetCountLimit(1) e1:SetRange(LOCATION_MZONE) e1:SetOperation(c88305978.rmop) e1:SetReset(RESET_EVENT+0x1fe0000) tc:RegisterEffect(e1) end end function c88305978.rmop(e,tp,eg,ep,ev,re,r,rp) Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_EFFECT) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c42110604.lua
3
2134
--HSRチャンバライダー function c42110604.initial_effect(c) c:SetSPSummonOnce(42110604) --synchro summon aux.AddSynchroProcedure(c,nil,aux.NonTuner(nil),1) c:EnableReviveLimit() --extra attack local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_EXTRA_ATTACK) e1:SetValue(1) c:RegisterEffect(e1) --attack up local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(42110604,0)) e2:SetCategory(CATEGORY_ATKCHANGE) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e2:SetCode(EVENT_BATTLE_START) e2:SetCondition(c42110604.condition) e2:SetOperation(c42110604.operation) c:RegisterEffect(e2) --tohand local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(42110604,1)) e3:SetCategory(CATEGORY_TOHAND) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_TO_GRAVE) e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY) e3:SetTarget(c42110604.thtg) e3:SetOperation(c42110604.thop) c:RegisterEffect(e3) end function c42110604.condition(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsRelateToBattle() end function c42110604.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsFaceup() and c:IsRelateToEffect(e) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetValue(200) e1:SetReset(RESET_EVENT+0x1ff0000) c:RegisterEffect(e1) end end function c42110604.thfilter(c) return c:IsSetCard(0x2016) and c:IsAbleToHand() end function c42110604.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and c42110604.thfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(c42110604.thfilter,tp,LOCATION_REMOVED,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectTarget(tp,c42110604.thfilter,tp,LOCATION_REMOVED,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0) end function c42110604.thop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.SendtoHand(tc,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,tc) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c5908650.lua
3
1968
--幻奏の音姫ローリイット・フランソワ function c5908650.initial_effect(c) --to hand local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(5908650,0)) e1:SetCategory(CATEGORY_TOHAND) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCountLimit(1) e1:SetCost(c5908650.thcost) e1:SetTarget(c5908650.thtg) e1:SetOperation(c5908650.thop) c:RegisterEffect(e1) Duel.AddCustomActivityCounter(5908650,ACTIVITY_CHAIN,c5908650.chainfilter) end function c5908650.chainfilter(re,tp,cid) return not (re:IsActiveType(TYPE_MONSTER) and not re:GetHandler():IsAttribute(ATTRIBUTE_LIGHT)) end function c5908650.thcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetCustomActivityCount(5908650,tp,ACTIVITY_CHAIN)==0 end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH) e1:SetCode(EFFECT_CANNOT_ACTIVATE) e1:SetTargetRange(1,0) e1:SetValue(c5908650.aclimit) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end function c5908650.aclimit(e,re,tp) return re:IsActiveType(TYPE_MONSTER) and not re:GetHandler():IsAttribute(ATTRIBUTE_LIGHT) end function c5908650.filter(c) return c:IsRace(RACE_FAIRY) and c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsAbleToHand() end function c5908650.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c5908650.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(c5908650.filter,tp,LOCATION_GRAVE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectTarget(tp,c5908650.filter,tp,LOCATION_GRAVE,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0) end function c5908650.thop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.SendtoHand(tc,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,tc) end end
gpl-2.0
adan830/UpAndAway
code/prefabs/turf_test.lua
2
3479
BindGlobal() require "prefabutil" local CFG = TUNING.UPANDAWAY local new_tiles = CFG.NEW_TILES local function test_ground(inst, pt) return GetGroundTypeAtPosition(pt) ~= GROUND.IMPASSABLE end local function ondeploy(inst, pt, deployer) if deployer and deployer.SoundEmitter then deployer.SoundEmitter:PlaySound("dontstarve/wilson/dig") end local ground = GetWorld() if ground then local original_tile_type = ground.Map:GetTileAtPoint(pt.x, pt.y, pt.z) local x, y = ground.Map:GetTileCoordsAtPoint(pt.x, pt.y, pt.z) if x and y then ground.Map:SetTile(x,y, inst.data.tile) ground.Map:RebuildLayer( original_tile_type, x, y ) ground.Map:RebuildLayer( inst.data.tile, x, y ) end local minimap = TheSim:FindFirstEntityWithTag("minimap") if minimap then minimap.MiniMap:RebuildLayer( original_tile_type, x, y ) minimap.MiniMap:RebuildLayer( inst.data.tile, x, y ) end end -- Simply incrementing the stack size (or erasing the remove call below) -- was not working, and I'm not in the mood for digging into the deploy -- action specifics. local callback if inst.components.stackable:StackSize() <= 1 then local prefab = inst.prefab callback = function(deployer) local inv = deployer.components.inventory if inv then inv:SetActiveItem( SpawnPrefab(prefab) ) end end end inst.components.stackable:Get():Remove() if callback then callback(deployer) end end local assets = { Asset("ANIM", "anim/turf.zip"), } local prefabs = { "gridplacer", } local function make_test_turf(name, data) local function fn(Sim) local inst = CreateEntity() inst:AddTag("groundtile") inst.entity:AddTransform() inst.entity:AddAnimState() MakeInventoryPhysics(inst) inst.AnimState:SetBank("turf") data.build = data.build or "turf" inst.AnimState:SetBuild(data.build) data.anim = assert( data.anim ) inst.AnimState:PlayAnimation(data.anim) ------------------------------------------------------------------------ SetupNetwork(inst) ------------------------------------------------------------------------ inst:AddComponent("stackable") inst.components.stackable.maxsize = TUNING.STACK_SIZE_LARGEITEM inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") if data.imagename then inst.components.inventoryitem:ChangeImageName(data.imagename) end data.tile = data.tile or assert( GROUND[name:upper()] ) inst.data = data inst:AddComponent("deployable") inst.components.deployable.ondeploy = ondeploy inst.components.deployable.test = test_ground inst.components.deployable.min_spacing = 0 inst.components.deployable.placer = "gridplacer" --------------------- return inst end STRINGS.NAMES["TURF_" .. name:upper()] = name:gsub("^%a", string.upper) .. " Turf" return Prefab( "common/objects/turf_" .. name, fn, assets, prefabs) end local test_turfs = {} for _, v in ipairs(new_tiles) do table.insert( test_turfs, make_test_turf("poopcloud", {anim = "carpet", imagename = "turf_carpetfloor"}) ) end return test_turfs
gpl-2.0
johnparker007/mame
3rdparty/genie/src/actions/vstudio/vs2019.lua
26
1736
-- -- vs2015.lua -- Baseline support for Visual Studio 2019. -- premake.vstudio.vc2019 = {} local vc2019 = premake.vstudio.vc2019 local vstudio = premake.vstudio --- -- Register a command-line action for Visual Studio 2019. --- newaction { trigger = "vs2019", shortname = "Visual Studio 2019", description = "Generate Microsoft Visual Studio 2019 project files", os = "windows", valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Bundle" }, valid_languages = { "C", "C++", "C#" }, valid_tools = { cc = { "msc" }, dotnet = { "msnet" }, }, onsolution = function(sln) premake.generate(sln, "%%.sln", vstudio.sln2005.generate) end, onproject = function(prj) if premake.isdotnetproject(prj) then premake.generate(prj, "%%.csproj", vstudio.cs2005.generate) premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user) else premake.vstudio.needAppxManifest = false premake.generate(prj, "%%.vcxproj", premake.vs2010_vcxproj) premake.generate(prj, "%%.vcxproj.user", premake.vs2010_vcxproj_user) premake.generate(prj, "%%.vcxproj.filters", vstudio.vc2010.generate_filters) if premake.vstudio.needAppxManifest then premake.generate(prj, "%%/Package.appxmanifest", premake.vs2010_appxmanifest) end end end, oncleansolution = premake.vstudio.cleansolution, oncleanproject = premake.vstudio.cleanproject, oncleantarget = premake.vstudio.cleantarget, vstudio = { solutionVersion = "12", targetFramework = "4.7.2", toolsVersion = "16.0", windowsTargetPlatformVersion = "10.0", supports64bitEditContinue = true, intDirAbsolute = false, } }
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c11961740.lua
3
1739
--タイムカプセル function c11961740.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_REMOVE) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(c11961740.target) e1:SetOperation(c11961740.activate) c:RegisterEffect(e1) end function c11961740.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,LOCATION_DECK) end function c11961740.activate(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,Card.IsAbleToRemove,tp,LOCATION_DECK,0,1,1,nil) local tc=g:GetFirst() if tc then Duel.Remove(tc,POS_FACEDOWN,REASON_EFFECT) tc:RegisterFlagEffect(11961740,RESET_EVENT+0x1fe0000,0,1) c:CancelToGrave() local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetRange(LOCATION_SZONE) e1:SetCode(EVENT_PHASE+PHASE_STANDBY) e1:SetCountLimit(1) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN,2) e1:SetCondition(c11961740.thcon) e1:SetOperation(c11961740.thop) e1:SetLabel(0) e1:SetLabelObject(tc) c:RegisterEffect(e1) end end end function c11961740.thcon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()==tp end function c11961740.thop(e,tp,eg,ep,ev,re,r,rp) local ct=e:GetLabel() e:GetHandler():SetTurnCounter(ct+1) if ct==1 then Duel.Destroy(e:GetHandler(),REASON_RULE) local tc=e:GetLabelObject() if tc:GetFlagEffect(11961740)~=0 then Duel.SendtoHand(tc,nil,REASON_EFFECT) end else e:SetLabel(1) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c57902193.lua
5
1313
--苦渋の転生 function c57902193.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1) e1:SetTarget(c57902193.target) e1:SetOperation(c57902193.activate) c:RegisterEffect(e1) end function c57902193.filter(c) return c:IsType(TYPE_MONSTER) and c:IsAbleToHand() end function c57902193.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c57902193.filter,tp,LOCATION_GRAVE,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_GRAVE) end function c57902193.activate(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,1-tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(1-tp,c57902193.filter,tp,LOCATION_GRAVE,0,1,1,nil) local tc=g:GetFirst() if tc then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_PHASE+PHASE_END) e1:SetRange(LOCATION_GRAVE) e1:SetCountLimit(1) e1:SetOperation(c57902193.thop) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) end end function c57902193.thop(e,tp,eg,ep,ev,re,r,rp) if Duel.SendtoHand(e:GetHandler(),nil,REASON_EFFECT)~=0 then Duel.ConfirmCards(1-tp,e:GetHandler()) end end
gpl-2.0
dwing4g/jane
tool/luainspect/compat_env.lua
5
13632
--[[ compat_env v$(_VERSION) - Lua 5.1/5.2 environment compatibility functions SYNOPSIS -- Get load/loadfile compatibility functions only if using 5.1. local CL = pcall(load, '') and _G or require 'compat_env' local load = CL.load local loadfile = CL.loadfile -- The following now works in both Lua 5.1 and 5.2: assert(load('return 2*pi', nil, 't', {pi=math.pi}))() assert(loadfile('ex.lua', 't', {print=print}))() -- Get getfenv/setfenv compatibility functions only if using 5.2. local getfenv = _G.getfenv or require 'compat_env'.getfenv local setfenv = _G.setfenv or require 'compat_env'.setfenv local function f() return x end setfenv(f, {x=2}) print(x, getfenv(f).x) --> 2, 2 DESCRIPTION This module provides Lua 5.1/5.2 environment related compatibility functions. This includes implementations of Lua 5.2 style `load` and `loadfile` for use in Lua 5.1. It also includes Lua 5.1 style `getfenv` and `setfenv` for use in Lua 5.2. API local CL = require 'compat_env' CL.load (ld [, source [, mode [, env] ] ]) --> f [, err] This behaves the same as the Lua 5.2 `load` in both Lua 5.1 and 5.2. http://www.lua.org/manual/5.2/manual.html#pdf-load CL.loadfile ([filename [, mode [, env] ] ]) --> f [, err] This behaves the same as the Lua 5.2 `loadfile` in both Lua 5.1 and 5.2. http://www.lua.org/manual/5.2/manual.html#pdf-loadfile CL.getfenv ([f]) --> t This is identical to the Lua 5.1 `getfenv` in Lua 5.1. This behaves similar to the Lua 5.1 `getfenv` in Lua 5.2. When a global environment is to be returned, or when `f` is a C function, this returns `_G` since Lua 5.2 doesn't have (thread) global and C function environments. This will also return `_G` if the Lua function `f` lacks an `_ENV` upvalue, but it will raise an error if uncertain due to lack of debug info. It is not normally considered good design to use this function; when possible, use `load` or `loadfile` instead. http://www.lua.org/manual/5.1/manual.html#pdf-getfenv CL.setfenv (f, t) This is identical to the Lua 5.1 `setfenv` in Lua 5.1. This behaves similar to the Lua 5.1 `setfenv` in Lua 5.2. This will do nothing if `f` is a Lua function that lacks an `_ENV` upvalue, but it will raise an error if uncertain due to lack of debug info. See also Design Notes below. It is not normally considered good design to use this function; when possible, use `load` or `loadfile` instead. http://www.lua.org/manual/5.1/manual.html#pdf-setfenv DESIGN NOTES This module intends to provide robust and fairly complete reimplementations of the environment related Lua 5.1 and Lua 5.2 functions. No effort is made, however, to simulate rare or difficult to simulate features, such as thread environments, although this is liable to change in the future. Such 5.1 capabilities are discouraged and ideally removed from 5.1 code, thereby allowing your code to work in both 5.1 and 5.2. In Lua 5.2, a `setfenv(f, {})`, where `f` lacks any upvalues, will be silently ignored since there is no `_ENV` in this function to write to, and the environment will have no effect inside the function anyway. However, this does mean that `getfenv(setfenv(f, t))` does not necessarily equal `t`, which is incompatible with 5.1 code (a possible workaround would be [1]). If `setfenv(f, {})` has an upvalue but no debug info, then this will raise an error to prevent inadvertently executing potentially untrusted code in the global environment. It is not normally considered good design to use `setfenv` and `getfenv` (one reason they were removed in 5.2). When possible, consider replacing these with `load` or `loadfile`, which are more restrictive and have native implementations in 5.2. This module might be merged into a more general Lua 5.1/5.2 compatibility library (e.g. a full reimplementation of Lua 5.2 `_G`). However, `load/loadfile/getfenv/setfenv` perhaps are among the more cumbersome functions not to have. INSTALLATION Download compat_env.lua: wget https://raw.github.com/gist/1654007/compat_env.lua Copy compat_env.lua into your LUA_PATH. Alternately, unpack, test, and install into LuaRocks: wget https://raw.github.com/gist/1422205/sourceunpack.lua lua sourceunpack.lua compat_env.lua (cd out && luarocks make) Related work http://lua-users.org/wiki/LuaVersionCompatibility https://github.com/stevedonovan/Penlight/blob/master/lua/pl/utils.lua - penlight implementations of getfenv/setfenv http://lua-users.org/lists/lua-l/2010-06/msg00313.html - initial getfenv/setfenv implementation References [1] http://lua-users.org/lists/lua-l/2010-06/msg00315.html Copyright (c) 2012 David Manura. Licensed under the same terms as Lua 5.1/5.2 (MIT license). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --]]--------------------------------------------------------------------- local M = {_TYPE='module', _NAME='compat_env', _VERSION='0.2.20120124'} local function check_chunk_type(s, mode) local nmode = mode or 'bt' local is_binary = s and #s > 0 and s:byte(1) == 27 if is_binary and not nmode:match'b' then return nil, ("attempt to load a binary chunk (mode is '%s')"):format(mode) elseif not is_binary and not nmode:match't' then return nil, ("attempt to load a text chunk (mode is '%s')"):format(mode) end return true end local IS_52_LOAD = pcall(load, '') if IS_52_LOAD then M.load = _G.load M.loadfile = _G.loadfile else -- 5.2 style `load` implemented in 5.1 function M.load(ld, source, mode, env) local f if type(ld) == 'string' then local s = ld local ok, err = check_chunk_type(s, mode); if not ok then return ok, err end local err; f, err = loadstring(s, source); if not f then return f, err end elseif type(ld) == 'function' then local ld2 = ld if (mode or 'bt') ~= 'bt' then local first = ld() local ok, err = check_chunk_type(first, mode); if not ok then return ok, err end ld2 = function() if first then local chunk=first; first=nil; return chunk else return ld() end end end local err; f, err = load(ld2, source); if not f then return f, err end else error(("bad argument #1 to 'load' (function expected, got %s)"):format(type(ld)), 2) end if env then setfenv(f, env) end return f end -- 5.2 style `loadfile` implemented in 5.1 function M.loadfile(filename, mode, env) if (mode or 'bt') ~= 'bt' then local ioerr local fh, err = io.open(filename, 'rb'); if not fh then return fh, err end local function ld() local chunk; chunk,ioerr = fh:read(4096); return chunk end local f, err = M.load(ld, filename and '@'..filename, mode, env) fh:close() if not f then return f, err end if ioerr then return nil, ioerr end return f else local f, err = loadfile(filename); if not f then return f, err end if env then setfenv(f, env) end return f end end end if _G.setfenv then -- Lua 5.1 M.setfenv = _G.setfenv M.getfenv = _G.getfenv else -- >= Lua 5.2 -- helper function for `getfenv`/`setfenv` local function envlookup(f) local name, val local up = 0 local unknown repeat up=up+1; name, val = debug.getupvalue(f, up) if name == '' then unknown = true end until name == '_ENV' or name == nil if name ~= '_ENV' then up = nil if unknown then error("upvalues not readable in Lua 5.2 when debug info missing", 3) end end return (name == '_ENV') and up, val, unknown end -- helper function for `getfenv`/`setfenv` local function envhelper(f, name) if type(f) == 'number' then if f < 0 then error(("bad argument #1 to '%s' (level must be non-negative)"):format(name), 3) elseif f < 1 then error("thread environments unsupported in Lua 5.2", 3) --[*] end f = debug.getinfo(f+2, 'f').func elseif type(f) ~= 'function' then error(("bad argument #1 to '%s' (number expected, got %s)"):format(type(name, f)), 2) end return f end -- [*] might simulate with table keyed by coroutine.running() -- 5.1 style `setfenv` implemented in 5.2 function M.setfenv(f, t) local f = envhelper(f, 'setfenv') local up, val, unknown = envlookup(f) if up then debug.upvaluejoin(f, up, function() return up end, 1) -- unique upvalue [*] debug.setupvalue(f, up, t) else local what = debug.getinfo(f, 'S').what if what ~= 'Lua' and what ~= 'main' then -- not Lua func error("'setfenv' cannot change environment of given object", 2) end -- else ignore no _ENV upvalue (warning: incompatible with 5.1) end end -- [*] http://lua-users.org/lists/lua-l/2010-06/msg00313.html -- 5.1 style `getfenv` implemented in 5.2 function M.getfenv(f) if f == 0 or f == nil then return _G end -- simulated behavior local f = envhelper(f, 'setfenv') local up, val = envlookup(f) if not up then return _G end -- simulated behavior [**] return val end -- [**] possible reasons: no _ENV upvalue, C function end return M --[[ FILE rockspec.in package = 'compat_env' version = '$(_VERSION)-1' source = { url = 'https://raw.github.com/gist/1654007/$(GITID)/compat_env.lua', --url = 'https://raw.github.com/gist/1654007/compat_env.lua', -- latest raw --url = 'https://gist.github.com/gists/1654007/download', md5 = '$(MD5)' } description = { summary = 'Lua 5.1/5.2 environment compatibility functions', detailed = [=[ Provides Lua 5.1/5.2 environment related compatibility functions. This includes implementations of Lua 5.2 style `load` and `loadfile` for use in Lua 5.1. It also includes Lua 5.1 style `getfenv` and `setfenv` for use in Lua 5.2. ]=], license = 'MIT/X11', homepage = 'https://gist.github.com/1654007', maintainer = 'David Manura' } dependencies = {} -- Lua 5.1 or 5.2 build = { type = 'builtin', modules = { ['compat_env'] = 'compat_env.lua' } } --]]--------------------------------------------------------------------- --[[ FILE test.lua -- test.lua - test suite for compat_env module. local CL = require 'compat_env' local load = CL.load local loadfile = CL.loadfile local setfenv = CL.setfenv local getfenv = CL.getfenv local function checkeq(a, b, e) if a ~= b then error( 'not equal ['..tostring(a)..'] ['..tostring(b)..'] ['..tostring(e)..']') end end local function checkerr(pat, ok, err) assert(not ok, 'checkerr') assert(type(err) == 'string' and err:match(pat), err) end -- test `load` checkeq(load('return 2')(), 2) checkerr('expected near', load'return 2 2') checkerr('text chunk', load('return 2', nil, 'b')) checkerr('text chunk', load('', nil, 'b')) checkerr('binary chunk', load('\027', nil, 't')) checkeq(load('return 2*x',nil,'bt',{x=5})(), 10) checkeq(debug.getinfo(load('')).source, '') checkeq(debug.getinfo(load('', 'foo')).source, 'foo') -- test `loadfile` local fh = assert(io.open('tmp.lua', 'wb')) fh:write('return (...) or x') fh:close() checkeq(loadfile('tmp.lua')(2), 2) checkeq(loadfile('tmp.lua', 't')(2), 2) checkerr('text chunk', loadfile('tmp.lua', 'b')) checkeq(loadfile('tmp.lua', nil, {x=3})(), 3) checkeq(debug.getinfo(loadfile('tmp.lua')).source, '@tmp.lua') checkeq(debug.getinfo(loadfile('tmp.lua', 't', {})).source, '@tmp.lua') os.remove'tmp.lua' -- test `setfenv`/`getfenv` x = 5 local a,b=true; local function f(c) if a then return x,b,c end end setfenv(f, {x=3}) checkeq(f(), 3) checkeq(getfenv(f).x, 3) checkerr('cannot change', pcall(setfenv, string.len, {})) -- C function checkeq(getfenv(string.len), _G) -- C function local function g() setfenv(1, {x=4}) checkeq(getfenv(1).x, 4) return x end checkeq(g(), 4) -- numeric level if _G._VERSION ~= 'Lua 5.1' then checkerr('unsupported', pcall(setfenv, 0, {})) end checkeq(getfenv(0), _G) checkeq(getfenv(), _G) -- no arg checkeq(x, 5) -- main unaltered setfenv(function()end, {}) -- no upvalues, ignore checkeq(getfenv(function()end), _G) -- no upvaluse if _G._VERSION ~= 'Lua 5.1' then checkeq(getfenv(setfenv(function()end, {})), _G) -- warning: incompatible with 5.1 end x = nil print 'OK' --]]--------------------------------------------------------------------- --[[ FILE CHANGES.txt 0.2.20120124 Renamed module to compat_env (from compat_load) Add getfenv/setfenv functions 0.1.20120121 Initial public release --]]
lgpl-3.0
Tiger66639/premake-core
tests/testfx.lua
1
10190
-- -- tests/testfx.lua -- Automated test framework for Premake. -- Copyright (c) 2008-2015 Jason Perkins and the Premake project -- local p = premake -- -- Define a namespace for the testing functions -- test = {} test.suppressed = {} -- -- Capture stderr for testing. -- local stderr_capture = nil local mt = getmetatable(io.stderr) local builtin_write = mt.write mt.write = function(...) if select(1,...) == io.stderr then stderr_capture = (stderr_capture or "") .. select(2,...) else return builtin_write(...) end end -- -- Assertion functions -- function test.capture(expected) local actual = premake.captured() .. premake.eol() -- create line-by-line iterators for both values local ait = actual:gfind("(.-)" .. premake.eol()) local eit = expected:gfind("(.-)\n") -- compare each value line by line local linenum = 1 local atxt = ait() local etxt = eit() while etxt do if (etxt ~= atxt) then test.fail("(%d) expected:\n%s\n...but was:\n%s", linenum, etxt, atxt) end linenum = linenum + 1 atxt = ait() etxt = eit() end end function test.closedfile(expected) if expected and not test.value_closedfile then test.fail("expected file to be closed") elseif not expected and test.value_closedfile then test.fail("expected file to remain open") end end function test.contains(expected, actual) if type(expected) == "table" then for i, v in ipairs(expected) do test.contains(v, actual) end elseif not table.contains(actual, expected) then test.fail("expected value %s not found", expected) end end function test.excludes(expected, actual) if type(expected) == "table" then for i, v in ipairs(expected) do test.excludes(v, actual) end elseif table.contains(actual, expected) then test.fail("excluded value %s found", expected) end end function test.fail(format, ...) -- if format is a number then it is the stack depth local depth = 3 local arg = {...} if type(format) == "number" then depth = depth + format format = table.remove(arg, 1) end -- convert nils into something more usefuls for i = 1, #arg do if (arg[i] == nil) then arg[i] = "(nil)" elseif (type(arg[i]) == "table") then arg[i] = "{" .. table.concat(arg[i], ", ") .. "}" end end local msg = string.format(format, unpack(arg)) error(debug.traceback(msg, depth), depth) end function test.filecontains(expected, fn) local f = io.open(fn) local actual = f:read("*a") f:close() if (expected ~= actual) then test.fail("expected %s but was %s", expected, actual) end end function test.hasoutput() local actual = premake.captured() if actual == "" then test.fail("expected output, received none"); end end function test.isemptycapture() local actual = premake.captured() if actual ~= "" then test.fail("expected empty capture, but was %s", actual); end end function test.isequal(expected, actual, depth) depth = depth or 0 if type(expected) == "table" then if expected and not actual then test.fail(depth, "expected table, got nil") end if #expected < #actual then test.fail(depth, "expected %d items, got %d", #expected, #actual) end for k,v in pairs(expected) do test.isequal(expected[k], actual[k], depth + 1) end else if (expected ~= actual) then test.fail(depth, "expected %s but was %s", expected, actual) end end return true end function test.isfalse(value) if (value) then test.fail("expected false but was true") end end function test.isnil(value) if (value ~= nil) then test.fail("expected nil but was " .. tostring(value)) end end function test.isnotnil(value) if (value == nil) then test.fail("expected not nil") end end function test.issame(expected, action) if expected ~= action then test.fail("expected same value") end end function test.istrue(value) if (not value) then test.fail("expected true but was false") end end function test.missing(value, actual) if table.contains(actual, value) then test.fail("unexpected value %s found", value) end end function test.openedfile(fname) if fname ~= test.value_openedfilename then local msg = "expected to open file '" .. fname .. "'" if test.value_openedfilename then msg = msg .. ", got '" .. test.value_openedfilename .. "'" end test.fail(msg) end end function test.success(fn, ...) local ok, err = pcall(fn, ...) if not ok then test.fail("call failed: " .. err) end end function test.stderr(expected) if not expected and stderr_capture then test.fail("Unexpected: " .. stderr_capture) elseif expected then if not stderr_capture or not stderr_capture:find(expected) then test.fail(string.format("expected '%s'; got %s", expected, stderr_capture or "(nil)")) end end end function test.notstderr(expected) if not expected and not stderr_capture then test.fail("Expected output on stderr; none received") elseif expected then if stderr_capture and stderr_capture:find(expected) then test.fail(string.format("stderr contains '%s'; was %s", expected, stderr_capture)) end end end -- -- Some helper functions -- function test.createWorkspace() local wks = workspace("MySolution") configurations { "Debug", "Release" } local prj = project("MyProject") language("C++") kind("ConsoleApp") return wks, prj end p.alias(test, "createWorkspace", "createsolution") function test.createproject(sln) local n = #sln.projects + 1 if n == 1 then n = "" end local prj = project ("MyProject" .. n) language "C++" kind "ConsoleApp" return prj end function test.getsolution(sln) p.oven.bake() return p.global.getWorkspace(sln.name) end function test.getproject(sln, i) sln = test.getsolution(sln) return premake.solution.getproject(sln, i or 1) end function test.getconfig(prj, buildcfg, platform) sln = test.getsolution(prj.solution) prj = premake.solution.getproject(sln, prj.name) return premake.project.getconfig(prj, buildcfg, platform) end -- -- Test stubs -- local function stub_io_open(fname, mode) test.value_openedfilename = fname test.value_openedfilemode = mode return { close = function() test.value_closedfile = true end } end local function stub_io_output(f) end local function stub_print(s) end local function stub_os_writefile_ifnotequal(content, fname) test.value_openedfilename = fname; test.value_closedfile = true return 0; end -- -- Define a collection for the test suites -- T = {} -- -- Test execution function -- local _OS_host = _OS local _OPTIONS_host = _OPTIONS local function error_handler(err) local msg = err -- if the error doesn't include a stack trace, add one if not msg:find("stack traceback:", 1, true) then msg = debug.traceback(err, 2) end -- trim of the trailing context of the originating xpcall local i = msg:find("[C]: in function 'xpcall'", 1, true) if i then msg = msg:sub(1, i - 3) end -- if the resulting stack trace is only one level deep, ignore it local n = select(2, msg:gsub('\n', '\n')) if n == 2 then msg = msg:sub(1, msg:find('\n', 1, true) - 1) end return msg end local function test_setup(suite, fn) _ACTION = "test" _OS = _OS_host _OPTIONS = {} setmetatable(_OPTIONS, getmetatable(_OPTIONS_host)) stderr_capture = nil premake.clearWarnings() premake.eol("\n") premake.escaper(nil) premake.indent("\t") premake.api.reset() -- reset captured I/O values test.value_openedfilename = nil test.value_openedfilemode = nil test.value_closedfile = false if suite.setup then return xpcall(suite.setup, error_handler) else return true end end local function test_run(suite, fn) local result, err premake.capture(function() result, err = xpcall(fn, error_handler) end) return result, err end local function test_teardown(suite, fn) if suite.teardown then return xpcall(suite.teardown, error_handler) else return true end end function test.declare(id) if T[id] then error("Duplicate test suite " .. id) end T[id] = { _TESTS_DIR = _TESTS_DIR, _SCRIPT_DIR = _SCRIPT_DIR, } return T[id] end function test.suppress(id) if type(id) == "table" then for i = 1, #id do test.suppress(id[i]) end else test.suppressed[id] = true end end function test.runall(suitename, testname) test.print = print local real_print = print local real_open = io.open local real_output = io.output print = stub_print io.open = stub_io_open io.output = stub_io_output os.writefile_ifnotequal = stub_os_writefile_ifnotequal local numpassed = 0 local numfailed = 0 function runtest(suitename, suitetests, testname, testfunc) if suitetests.setup ~= testfunc and suitetests.teardown ~= testfunc and not test.suppressed[suitename .. "." .. testname] then local ok, err = test_setup(suitetests, testfunc) if ok then ok, err = test_run(suitetests, testfunc) end local tok, terr = test_teardown(suitetests, testfunc) ok = ok and tok err = err or terr if (not ok) then test.print(string.format("%s.%s: %s", suitename, testname, err)) numfailed = numfailed + 1 else numpassed = numpassed + 1 end end end function runsuite(suitename, suitetests, testname) if suitetests and not test.suppressed[suitename] then _TESTS_DIR = suitetests._TESTS_DIR _SCRIPT_DIR = suitetests._SCRIPT_DIR if testname then runtest(suitename, suitetests, testname, suitetests[testname]) else for testname, testfunc in pairs(suitetests) do if type(testfunc) == "function" then runtest(suitename, suitetests, testname, testfunc) end end end end end if suitename then runsuite(suitename, T[suitename], testname) else for suitename, suitetests in pairs(T) do runsuite(suitename, suitetests, testname) end end print = real_print io.open = real_open io.output = real_output return numpassed, numfailed end
bsd-3-clause
MadkaT182/DDR3rdMix
Graphics/Player combo/default.lua
3
1660
local c; local player = Var "Player"; local ShowComboAt = THEME:GetMetric("Combo", "ShowComboAt"); local Pulse = THEME:GetMetric("Combo", "PulseCommand"); local PulseLabel = THEME:GetMetric("Combo", "PulseLabelCommand"); local NumberMinZoom = THEME:GetMetric("Combo", "NumberMinZoom"); local NumberMaxZoom = THEME:GetMetric("Combo", "NumberMaxZoom"); local NumberMaxZoomAt = THEME:GetMetric("Combo", "NumberMaxZoomAt"); local LabelMinZoom = THEME:GetMetric("Combo", "LabelMinZoom"); local LabelMaxZoom = THEME:GetMetric("Combo", "LabelMaxZoom"); local t = Def.ActorFrame { InitCommand=cmd(vertalign,bottom); LoadFont( "Combo", "numbers" ) .. { Name="Number"; OnCommand=THEME:GetMetric("Combo", "NumberOnCommand"); }; LoadActor("_combo") .. { Name="Label"; OnCommand=THEME:GetMetric("Combo", "LabelOnCommand"); }; InitCommand = function(self) c = self:GetChildren(); c.Number:visible(false); c.Label:visible(false); end; ComboCommand=function(self, param) local iCombo = param.Combo; if not iCombo or iCombo < ShowComboAt then c.Number:visible(false); c.Label:visible(false); return; end c.Label:visible(false); param.Zoom = scale( iCombo, 0, NumberMaxZoomAt, NumberMinZoom, NumberMaxZoom ); param.Zoom = clamp( param.Zoom, NumberMinZoom, NumberMaxZoom ); param.LabelZoom = scale( iCombo, 0, NumberMaxZoomAt, LabelMinZoom, LabelMaxZoom ); param.LabelZoom = clamp( param.LabelZoom, LabelMinZoom, LabelMaxZoom ); c.Number:visible(true); c.Label:visible(true); c.Number:settext( string.format("%i", iCombo) ); -- Pulse Pulse( c.Number, param ); PulseLabel( c.Label, param ); end; }; return t;
gpl-3.0
anshkumar/yugioh-glaze
assets/script/c4807253.lua
3
2623
--Emフレイム・イーター function c4807253.initial_effect(c) --spsummon local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_CHAINING) e1:SetRange(LOCATION_HAND) e1:SetCondition(aux.damcon1) e1:SetTarget(c4807253.sptg) e1:SetOperation(c4807253.spop) c:RegisterEffect(e1) --damage local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_DAMAGE) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e2:SetCode(EVENT_SUMMON_SUCCESS) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e2:SetTarget(c4807253.damtg) e2:SetOperation(c4807253.damop) c:RegisterEffect(e2) local e3=e2:Clone() e3:SetCode(EVENT_SPSUMMON_SUCCESS) c:RegisterEffect(e3) end function c4807253.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function c4807253.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)~=0 then local cid=Duel.GetChainInfo(ev,CHAININFO_CHAIN_ID) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CHANGE_DAMAGE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTargetRange(1,0) e1:SetLabel(cid) e1:SetValue(c4807253.damval) e1:SetReset(RESET_CHAIN) Duel.RegisterEffect(e1,tp) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_LEAVE_FIELD_REDIRECT) e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e2:SetReset(RESET_EVENT+0x47e0000) e2:SetValue(LOCATION_REMOVED) c:RegisterEffect(e2,true) end local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e3:SetTargetRange(1,0) e3:SetTarget(c4807253.splimit) e3:SetReset(RESET_PHASE+RESET_END) Duel.RegisterEffect(e3,tp) end function c4807253.damval(e,re,val,r,rp,rc) local cc=Duel.GetCurrentChain() if cc==0 or bit.band(r,REASON_EFFECT)==0 then return val end local cid=Duel.GetChainInfo(0,CHAININFO_CHAIN_ID) if cid~=e:GetLabel() then return val end return 0 end function c4807253.splimit(e,c,sump,sumtype,sumpos,targetp,se) return not c:IsSetCard(0xc6) end function c4807253.damtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,PLAYER_ALL,500) end function c4807253.damop(e,tp,eg,ep,ev,re,r,rp) Duel.Damage(1-tp,500,REASON_EFFECT) Duel.Damage(tp,500,REASON_EFFECT) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c73018302.lua
3
1754
--黒羽を狩る者 function c73018302.initial_effect(c) --destroy local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(73018302,0)) e1:SetCategory(CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetRange(LOCATION_MZONE) e1:SetCondition(c73018302.descon) e1:SetCost(c73018302.descost) e1:SetTarget(c73018302.destg) e1:SetOperation(c73018302.desop) c:RegisterEffect(e1) end function c73018302.check(tp) local g=Duel.GetMatchingGroup(Card.IsFaceup,tp,0,LOCATION_MZONE,nil) if g:GetCount()<2 then return false end local rac=g:GetFirst():GetRace() local tc=g:GetNext() while tc do if tc:GetRace()~=rac then return false end tc=g:GetNext() end return true end function c73018302.descon(e,tp,eg,ep,ev,re,r,rp) return c73018302.check(tp) end function c73018302.descost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost,tp,LOCATION_HAND,0,1,nil) end Duel.DiscardHand(tp,Card.IsAbleToGraveAsCost,1,1,REASON_COST) end function c73018302.filter(c) return c:IsFaceup() and c:IsDestructable() end function c73018302.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(1-tp) and chkc:IsLocation(LOCATION_MZONE) and c73018302.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(c73018302.filter,tp,0,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,c73018302.filter,tp,0,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0) end function c73018302.desop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsFaceup() and tc:IsRelateToEffect(e) and c73018302.check(tp) then Duel.Destroy(tc,REASON_EFFECT) end end
gpl-2.0
shirat74/sile
languages/ga.lua
4
62044
SILE.hyphenator.languages["ga"] = {}; SILE.hyphenator.languages["ga"].patterns = { ".ab4ai", ".ab6ar", ".ab5r", ".ac6ad", ".ach6ar", ".ad6aim", ".ad6am", ".ae5n", ".ag6ar", ".agh4a", ".ag4ó", ".ag5r", ".ag6úi", ".ai6c5", ".ail6te", ".ain3g4", ".ain6te.", ".ain6t5ín", ".air6ní", ".ais3", ".aist4", ".ais6te.", ".aí4", ".ala5m6", ".al5g6", ".allag6", ".alm4ó", ".al2t5a", ".al6t5á", ".am6ac", ".am6á", ".an2a", ".ana5c", ".anach6", ".an2á", ".anc6", ".an6dór", ".an6dr", ".an6fa", ".ang4l", ".an6i", ".an6lain", ".an6lan", ".an6ó", ".an6rai", ".an6sa", ".an2ta", ".ar2", ".aral4", ".aralt3", ".ara5m6", ".ara5s6", ".ard5", ".aró5", ".aróc6", ".art4", ".as6ail", ".as6aim5", ".as6al.", ".as6am", ".asa5m6a", ".asc6ar", ".as6ó", ".as6pa.", ".as2t", ".ast5ai", ".ast5aí", ".ast3ó", ".as6tú", ".as4ú", ".ata6", ".at5ar.", ".at6á", ".áil6te.", ".áil6t5ea", ".áir5ge", ".áir5gí", ".áir6s", ".ál6t", ".ár2a", ".ár6m", ".ba6d", ".bad3á", ".bal6b", ".beo5f", ".beo5g", ".beo5id", ".beo5im", ".bh4", ".bhá5ite.", ".bhá5ití", ".bheo5f", ".bheo5id", ".bheo5im", ".bheo5in", ".bhí5dís", ".bhí5mis", ".bhí5oda", ".bhí5omar", ".bhí5teá", ".bhí5tí", ".bhlí3", ".bhreo5f", ".bhreo5id", ".bhreo5im", ".bhreo5in", ".bhrí3o", ".blí3", ".breo5f", ".breo5id", ".breo5im", ".brí3o", ".ca4", ".cach5", ".cacht6", ".cad5á", ".caí5d", ".caí5gí", ".caí5m", ".caí5o", ".car6t5ar", ".ch4", ".cha4", ".chach5", ".chad5á", ".chaí5d", ".chaí5gí", ".chaí5m", ".chaí5o", ".chaí5teá", ".chaí5tí", ".chan5á", ".char6t5ar", ".char6tá", ".chár5ta.", ".cheil6te.", ".chí6", ".chló5f", ".chló5id", ".chló5im", ".chló5inn", ".chnaí3", ".chnó5", ".chóis5", ".ci6", ".cil6", ".cí6", ".cli6", ".clip5", ".cló5f", ".cló5id", ".cló5im", ".cnaí3", ".cnó5", ".da6", ".dh2", ".dhlí5d", ".dhlí5g", ".dhlí5m", ".dhlí3o", ".dhó5ite.", ".dhó5ití", ".dhreach5", ".dhreacht6", ".dhreo5f", ".dhreo5id", ".dhreo5im", ".dhreo5in", ".dlí5d", ".dlí5g", ".dlí5m", ".dlí5o", ".dó5f", ".dó5idí", ".dó5im", ".dó5ite.", ".dó5ití", ".dreach5", ".dreo5f", ".dreo5id", ".dreo5im", ".ead1", ".ea6g3", ".eal4t3", ".earb5", ".eas3tó", ".ei6", ".eisc3e", ".eis4il", ".éa6b", ".éad6ar", ".éa3g6ó", ".éar5", ".éart6", ".éi5d6r", ".éi5gear", ".éim5í", ".fa6", ".fach3", ".feo5f", ".feo5idí", ".feo5im", ".fhrioch5", ".fhua6fair", ".fhua6fara", ".fhua5im.", ".fí5dí", ".fí5g", ".fí5m", ".fí5odh", ".fí5onn", ".geal6t5aí", ".geat5", ".gh2", ".ghair5t", ".ghlae3", ".ghrá6n", ".góf5", ".ha4", ".hab6ai", ".hab6ar", ".hac6ad", ".hag6ar", ".hag4ó", ".hail6te", ".hain3g", ".hain3t", ".hain6te.", ".hair6ní", ".hais5ce", ".hais5tea", ".hais5t6eo", ".haist6i", ".hais5tig", ".haí4", ".hala5m6", ".halm4ó", ".hal4t3a", ".hal6t5á", ".han2a", ".hana5c", ".hanc6", ".han6fa", ".hang4l", ".han6ó", ".han4ta", ".har2a", ".har6á", ".har6ó5", ".haróc6", ".hart6", ".has6ai", ".has6al.", ".has6am", ".has4ta", ".hat6á", ".há6", ".háil6te.", ".háil6t5ea", ".háir5ge", ".háir5gí", ".háir6s", ".hál6t", ".hár4a", ".hár6m", ".head3", ".heal4t3", ".heis6il", ".héad6ar", ".héa3g6ó", ".héid4e", ".héi5dea", ".hib6é", ".him6ire", ".hios5", ".hiosc6", ".hir4", ".his4", ".hist3", ".hit6eo", ".hit6r", ".hí2", ".híl3", ".híoch5", ".híocht6", ".hoc4r", ".hod6", ".hogh6", ".hoir6n5i", ".hol6ac", ".hom2", ".hor5m", ".hort4", ".hó6", ".hua4f", ".huaf5a", ".huil4e", ".húd4", ".ia5it", ".iat6", ".ib6é", ".ibh5", ".id2", ".il3", ".im6ire", ".in6d5ia", ".in6id", ".in6ín", ".in4ío", ".in6ír", ".in6ste.", ".int6e", ".iomáin5", ".ios3", ".iosc6", ".iost4", ".ir4", ".is4", ".ist6", ".it6", ".íl3", ".ío6", ".íoch5", ".íocht6", ".íos5", ".la4", ".lach6t5", ".lad5a", ".lag5á", ".lait5", ".lan5c", ".lao5n", ".lá5ití", ".leab3ó", ".lea6m", ".leas5", ".leat6aí", ".leo3c", ".leoch4", ".lé5ann.", ".lé5igí", ".li6", ".lib5é", ".lim5", ".lint6", ".lip5", ".lí5d", ".lí5g", ".lí5mi", ".lí5od", ".lí5omar", ".lí5onn", ".lí6t", ".lít5i", ".lú2", ".mad5a", ".mair5tí.", ".maí5d", ".maí5gí", ".maí5mi", ".maí5od", ".maí5oma", ".maí5on", ".maí5teá", ".maí5tí", ".mam5", ".man2t", ".ma6r", ".mar6l5", ".mar6s5ac", ".mar6s5ai", ".mar5ta", ".mar5ú", ".ma6t", ".mat3á", ".mead5a", ".meat5á", ".mh2", ".mhad5a", ".mhais6te.", ".mhais6tí.", ".mhaí5d", ".mhaí5gí", ".mhaí5mi", ".mhaí5od", ".mhaí5oma", ".mhaí5on", ".mhaí5te.", ".mhaí5teá", ".mhaí5tí", ".mhan4t3", ".mhar6l5", ".mhar6sa.", ".mhion6t5a", ".mhí6oc", ".mhú6", ".mhúch5", ".mí6oc", ".mí5st", ".nair5", ".nais5", ".naí3", ".naío5l6", ".nar5", ".nd6", ".ndó5f", ".ndó5idí", ".ndó5im", ".ndó5in", ".neach6", ".neacht5", ".neá6", ".neád5", ".ng4", ".ngóf5", ".nit6", ".ní5d", ".ní5gí", ".ní5m", ".ní6oc", ".ní5od", ".ní5om", ".ní5on", ".nom6", ".och6t5", ".oc4r", ".od6", ".ogh6", ".oilt6", ".oir4n3e", ".oir6n5i", ".oir6ní", ".oir5t", ".ol6ac", ".om6a", ".or6ai", ".ort4", ".or6thu", ".os6ló.", ".ost5a", ".óp6", ".ór4á", ".phor5t6r", ".pist6", ".ra4", ".rad5a", ".rad5ó", ".raf6t5", ".rai6", ".rat5á", ".rá6", ".reas5", ".reo5f", ".reo5id", ".reo5im", ".reo5in", ".réim5i", ".rí5dí", ".rí5gí", ".rí5mi", ".rí6ocha", ".rí5od", ".rí5oma", ".rí5onn", ".rób5a", ".ró5c", ".róch6", ".róst5", ".rua5im.", ".rúm5", ".sa6l", ".sal5a", ".sá5ití", ".sc6", ".sca6", ".scad5á", ".scar5", ".scart6", ".searbh5", ".séa5l6ain", ".shá5inn.", ".si4", ".sim3", ".siún4", ".siúnt3", ".sí4o", ".slios5", ".sm4", ".sní5d", ".sní5g", ".sní5m", ".sní5od", ".sní5oma", ".sní5on", ".só5f", ".só5idí", ".só5im", ".só5inn", ".spléach5", ".st4", ".steam5", ".ta6", ".tach6t5", ".tan5g", ".tap5", ".tar5ta", ".téit5e", ".th2", ".théit5ea", ".thrá5ití", ".thróf5", ".ti6", ".tróf5", ".tsí6o", ".tua5im", ".ua4f", ".uaf5a", ".ua6i", ".uas6ala", ".uil2e", ".uir6t", ".uirthi5", ".un6s5", ".ur5b", ".ur3n4", ".úd2", ".úm5", ".úr6ái", "ab1a", "abac6", "aba5ca", "aba5dá", "ab4airt", "a3b4al", "ab4art", "ab1á", "ab3d", "abh1", "abh6aile", "a3bh6e", "abh6ór", "abh6re", "abh2t", "a5bi", "ab1l", "a5bó.", "ab3óig", "a5bón", "a1br", "ab3rad6", "abra3da", "a5bu", "ab1ú", "ac1a", "ac4adú", "acae6", "ac4aoi", "ac6ard", "aca1s4", "ac4astó", "aca3t4ú", "a3cáid", "acár5", "ac5é", "ach1a", "a4cha.", "acha6d5á", "achar5", "ach4arf", "acharn6", "achart6", "ach1á", "6achár", "6a3che", "ach3í", "4ach1l", "a6chli", "ach3óg", "ach5ór", "ach1r", "6achri", "ach1ú", "ac1l", "3acm", "ac1n", "ac1ó", "ac1ra", "acra3f", "ac4ras", "ac3ré", "a5cró", "ac5ua", "ac5ú", "adag6", "ad1al", "ad1am", "4adamh", "ada5n6ó", "ad3ara", "ad3arl", "ad5art", "ad5áil", "ad5ás", "4adc", "adh1", "adhb1", "a3dhi", "4adhro", "a5dhú", "ad3i", "4ad3l", "4a3d4o", "a1dó", "a4d3ód", "a2dóf", "a2d3óid", "a4d3óig", "a2d3óim", "a4d3óinn", "ad1r", "ad3rog", "ad3u", "ad1ú", "a3d4úr", "ae3a", "ae1á", "aeil3", "aeilg4", "aeilí5te", "af1", "afa3dá", "af5air", "af5art", "afáil3", "afáilt6", "afhol6", "afholt5", "a3f6l", "a3fo", "a3fóib", "a3fóin", "a1f2ón", "af6rá", "af6ú", "agad3á", "agair5n6", "ag2al", "ag5áis", "ag3e", "ag3é", "agh1", "agh4aid", "agh5an", "a5ghi", "ag3i", "ag1l", "a3go", "a3graim", "a3gram", "a6g5re", "ag3ri", "ag5rui", "ag3rú", "ag3ua", "ag3ú", "a1h", "ah6a", "aich6t", "ai5ciú", "aic5r", "6aidear", "4aidhl", "aid1i", "aidít5", "ai3fil", "ai3gin", "6aigis", "ail5bhí", "ailc3ea", "ailp3i", "ailp3ín", "ailt2", "a6imh", "4ai3mia", "aim3ise", "ain5í", "ains5eo", "ain6tean", "ain5té", "air6bh3r", "airb4í", "air4b5r", "air4dé", "airf5ean", "air6f5in.", "airf3í", "air4fín", "4airisc", "airis6t", "air5nín", "air5nío", "air4t5éis", "6aisei", "aisi3n4é", "ai5s6íl", "4aisp", "ais5teog", "ais6ti5s", "ais5t6ín.", "4aitei", "ai5t6il", "aits3e", "4aivi", "aí2c", "4aíní", "aí3o3dó", "aío5l6an", "aí3onna", "aí5ói", "al1a", "ala3b", "alabh4", "al4ainne", "alait4", "al3aí", "alan4a", "alan5d", "al2ann", "alas3", "alasc6", "4al4ath", "al1á", "a3láib", "6alám", "a3lár", "al1có", "6al5e", "al4f3air", "al3gó", "al3i", "a3lí", "a6ll", "al5o", "al1ó", "2alr", "a6lt", "alt3e", "al6t5ód", "al4tóf", "al6t5óid", "al6t5óim", "al6t5óin", "al6tú", "al3ui", "al3ú", "alú3ch4", "ama3b", "ama3d4ú", "am1al", "am5all", "am1an", "am3ara", "ama3raí", "a6mas", "ama5só", "4amál", "am4ána", "4amb", "amh1", "amh5ad", "amhais6t", "a3mhas", "a1mo", "am5óna", "6amp", "amp1a", "amp1á", "am4pr", "4amt", "am5ut", "am3úi", "am5úr", "anac4", "ana3ca", "an6ag", "6anaige", "anaist4", "an3ait", "an5aí", "ana5l6ó", "ana5m6ó", "ana5r6a", "anat6", "an1á", "an5áis", "a5n6áise", "an5ár", "6anb", "anc1a", "anc4aire", "an5cé5", "an2d3á", "andí6", "andíb5", "and3o", "an3dr", "6andu", "an3e", "an6ea", "an3é", "ang1", "ang3a", "anga3rú", "ang3á", "an5gó.", "anin5", "an4ma", "ann5", "6anná", "an3oi", "an5oí", "an1ó", "anód4", "anó3dó", "an4san", "an6sin", "an6tu", "an3u", "anuas6", "an1ú", "aoch3", "aocht6", "6aod", "ao5dar", "ao5idís", "ao5im.", "ao3imi", "aoin6s", "aoin3t2", "ao4l1", "ao5mar", "aon3u", "ao6r1", "aorg4", "aort4", "aos3t", "ap1", "apa5dá", "a3p4ait", "aplais6", "ar1a", "ara3bú", "ar6ac.", "ara3c6á", "arach6t5", "ara5có", "ara3g4a", "araic6í", "ara5l4á", "ara3p4", "ar5as.", "ara5só", "ara3tó", "ar1á", "arbh3a", "ar3bhe", "arch6", "arc1ó", "ar1cr", "ar1e", "ar2f1ó", "ar3i", "arm4ó", "a5ro", "ar1ó", "aróc6ar", "ar5ón", "ar5óp", "ar1p", "ar4p3ó", "ar4s3ál", "ar6sta", "ar3u", "ar3úil", "ar5úl", "ar3úp", "ar5ú5s6", "a5rút", "asa5c6a", "a3s4ae", "asain4", "as5aí", "as6alait", "asal2t", "asa5mait", "as6arb", "asc1", "ascar5", "as5cara", "ascart6", "as3co", "4ascr", "4as3e", "as3é", "as3i", "as3í", "2asl", "as1o", "as1ó", "as6óil", "a3s4ól", "as1ta", "as6t5ais", "ast4aí.", "ast3al", "asta5r6ó", "as6tas", "as3tán.", "as5té", "as3ti", "as5to", "a4stó", "as5tór", "as5tua", "as3tú", "as1u", "as1ú", "asúd6", "asú3it", "asú5m", "at1a", "atac6", "ata5cá", "atad5án", "at4agr", "a5t6aint", "at5a1l2", "ata3m", "atam4á", "a3t4ant", "ata3p4", "at5arn", "at3as", "atá6i", "a5tár", "atá5t", "atáth6", "até3", "atéad6", "ath1", "athrí5d", "athrí5gí", "athrí5m", "athrí5o", "ath6us", "at5ód", "a6tóg", "at3óid", "at3óig", "at3óim", "at5rap", "at1rá", "a6tro", "ats5a", "at6sar", "at1u", "at4ui", "at1ú", "a5vó", "áb3a", "áb4al", "áb1á", "ábh1", "ábht6", "áb1l", "á5bo", "áb3ó", "áb3ú", "ác1a", "ácar5", "ácarn6", "ách5á", "ách5e", "ách5i", "ách3l", "ách5r", "ách4t3", "ác3l", "ác3r", "ác3ú", "ád1", "á3d4ar", "ádh3a", "ádh5ú", "á1fa", "á4fa.", "á6f3ac", "áf5air", "áf5ara", "á3fá", "áf3l", "áf1r", "ága5dá", "á3gó", "ág3r", "ág5u", "á5há", "áib5é", "áid1", "á3idís", "á3igí", "áil5b", "áil3c6", "áilt6eá", "áilt3i", "ái6m", "á3im.", "áim5é", "á6imh", "á1imi", "á6im5ise", "6áinia", "áins4", "áin3te", "áin4teo", "6áip", "4áir4g3", "áirt3", "áisc1", "áist3e", "áist3i", "áis5t6íní", "á3itear", "áit3é", "áit3s", "á5íre", "ál1", "álc6", "ál4s3", "ám3an", "á3mar", "ám3at", "ámh1", "án1", "án6ga", "á3nna", "ánt4", "áp1", "ár1", "árach3", "ár5aim", "ár5am", "ár6ca", "á5r6é", "4árn2", "á3rol", "ár4ta", "árt6ai", "árt6an", "árt6r", "ás3a", "ásc3", "ás5c6á", "ás5e", "ás3í", "ás1ó", "ás1t4a", "ás3tú", "ás3u", "ás3ú", "át3a", "át1á", "áth1", "á3th4e", "át1ó", "át3r", "á5úl", "ba5cas", "4bacá", "bac6s5", "b5adar", "ba3dái", "b3aidí", "b3aig", "b3aim", "bain5t4", "baisc5e", "baist3", "bait3é", "b6aití", "b1aí", "balbh5á", "bamb6", "banais3", "ban3d4", "bar3b", "bar1n2", "b4arr", "bar3ú", "ba5s6áir", "ba5s6ár", "bas5c6ar6", "bascarn5", "bat5a", "bá5inn", "bá5ite.", "bá5iteá", "bá5ití", "bá5í6", "b1ál", "b4ált", "bár4", "bárth5", "b1c", "bc4á", "b5da", "b5dé", "b3dh", "3beab", "bea5bh6", "bea6c", "beal5t6", "bear3bó", "b1eá", "b6eár", "5b4ei", "beif6", "beil6t", "beir5f", "beir5tí", "beo3c", "beoch4", "beo5itea", "beo5m", "3béit", "b1f", "b3gh", "6bh.", "b4ha", "bha6d3á", "bha3g4á", "bh3aig", "bhain3t4", "bhaist3", "bhal6b", "bhalbh5", "bhar3b", "bhar3t4", "bhat5a", "bhá5inn", "bhá5iteá", "bhár6", "bhárth5", "bhc6á", "b4he", "4bhe.", "bh5eam", "3bh4ear", "2bh1eá", "bheif6", "bheil6t", "bheir5f", "bheir5tí", "bheo3c", "bheoch4", "bheo5g", "bhéal5", "bhéalt6", "bhé5ann", "bhia5ta.", "bhia5tac", "3bh4id", "bh3im", "bhin6s3e", "bhin6sí", "bhin6t5e", "bhion5gó", "bhios5", "3bh4irt", "6bh3iú", "4bhíg", "4bh3ím", "bh3ín", "4bhío", "bhí5ot", "4bhít", "bhí6th", "3bh4las", "bhlá6", "bhláf5", "bhlead5", "1bho", "bhol6ta.", "bhol6t5aí", "bhol6tá", "bh1ó", "bhói5s6", "bhó5l6ac", "bhran6d5", "6bhre.", "bh6réa", "bh6ric", "bhrí3oc", "bhrío5mh4", "4bhs", "bh5tí", "1bhu", "bh4ua", "bhua5da", "bhua5im", "bhua5ite.", "bhual5", "4bhuit", "bh3uith", "bhurd5á", "bhur2l3", "bhust5", "bhúir5", "bhúis5", "bhúm5", "bia3l", "bia5ta.", "bia5t6ac", "bia5t6aig", "bia5t6aí", "b1id", "bid5i", "bin4", "bi3né", "bin5i", "bins3", "bint3", "bion5gó", "bios5", "biosc6", "6b1ir", "6bis3", "bist4", "bit5s", "bí3c", "b1ín", "b1ít", "bít5eac", "bí6th5", "bí6tig", "blad5a", "bla3gr", "blas3", "blá4", "bláf3", "blead5", "bl6i", "blim6", "b1lí", "b1ló", "bn6i", "b3ní", "bod3ó", "bol4s", "bol6ta.", "bol6t5aí", "bol4tá", "bord3", "bos5t6", "b1óg", "b3óid", "bó5l6ac", "bó6s5", "bóth5", "bp6á", "bp6i", "bpist6", "b5po", "brad5á", "bran6d5", "bran3g4", "brat5ó", "bré6", "b1rí", "brío3mh4", "b1s2", "b1t", "bth6", "bua5da", "bua3im", "buair3", "bua5ite.", "bua5itear", "buin6t", "bun1", "bur2", "burd3", "burl1", "bust5", "3búid", "búir5", "búis5", "búm3", "cab5al", "c1ac", "c1ad", "ca3dá", "cae4d3", "caib5é", "caidh5ne", "cai5m4é", "cain6d", "cain2t3", "cair6b", "cairbh5", "cair6d5í", "cair6t5e", "c2aisn", "cais3t6", "cait3é", "c1aí", "cal5an", "calbh3a", "cal4m", "ca3mán", "can5c6", "can5s6", "can3t2", "5caod", "c6ara", "3c4ar1b", "carbh4", "card3", "c4arl", "carn5á", "c4ars", "c6arta", "cart6ac", "car3ú", "cas1", "cast6", "cas5tó", "cat5a", "cat3ó", "c1á", "5c6ác", "cá4f3", "cá6i", "c2áid", "cáin6t5eac", "cáin6ti", "c6ánn", "cár5ta.", "c2át", "c3bh6", "c3dh", "2ce", "cea6b", "c3eab5a", "6cead", "cead5as", "c3eadá", "5c6eai", "3ceana", "5ceanó", "cean4tá", "cear3b", "cearbh4", "3ceasm", "ceas6t", "ceast5a", "cea3stá", "ceast5ó", "cea3sú", "c1eá", "5ceá.", "ceá6f5", "ceá3n4", "3c4eána", "c4ei", "ceil4t", "ceir5m4", "ceit6s", "ceo3m", "ce3r4", "céal5", "céalt6", "5céas", "céa3tá", "céi6", "c6éit", "2c1f", "c3gh", "c2h", "4ch.", "6ch5acha", "chacht6", "ch1ad", "chaint3", "chair6d5", "chais5t6", "5ch6aite", "ch5al.", "chal4m", "5champ", "chan5c6", "ch4antó", "char3b", "charbh6", "ch3arf", "charn5", "ch1as1", "chast4", "chat5a", "chat5ó", "chá6", "ch3áir", "ch1ál", "ch1án", "5chár", "2che.", "chear3b", "chearbh6", "cheas6t5", "cheá6", "cheáf5", "cheir5m6", "3ché", "ch1f", "chia6", "chil6", "chin5t", "chíl5", "ch4lasa", "chlas6p5", "ch4lár", "chlé6i", "3ch4lo", "chloch5", "chlocht6", "chlód6", "ch1m2", "ch3nú", "3c4ho", "ch5oba", "choirn6", "cho4m", "chomh3", "chona5m", "chon3c", "chon5g", "chorb5", "chorn5", "chor6p3", "chor5t6", "5chó.", "5chóc", "5chóda", "ch3ódh", "ch3óg.", "ch3óig", "3chóip", "chó1m", "5chórai", "5chóras", "3chót", "5ch6raic", "3ch6rao", "3chrap", "chrá5inn", "chrá5ití", "3ch4re", "chreach5", "chreacht6", "chri6", "3chrio", "ch6rit", "ch4rí6", "chríoch5", "1chro", "chros3", "chrost6", "chrua5im", "4cht", "1chu", "chua6", "chuacht6", "chuil5c", "chuil6t", "chul5", "chulc6", "chur6l5", "chus3", "c6hú", "chú6i", "chúl5", "ch3ús", "cia6f5", "c3iam.", "cid5i", "c1idí", "c3igh", "c1igí", "c4illi", "ci3mé", "cim6p5íní", "cin4d", "cineach5", "cineacht6", "3cint", "3cion", "3cip", "ci6p5é", "ci3p4l", "3cirt", "cis5tear", "cis5teá", "cis3t6in", "c3iú.", "c3iúl", "ci5v", "2cí.", "cíl5", "c1ím", "2c1ín", "3cír", "cít6", "3c4ít.", "3c4íte.", "cí6th", "cla4", "clad5á", "clad3ó", "clas6p5", "cleach6t5", "cleat5a", "clé6i", "clim5", "2clo", "cloch5", "clocht6", "clód4", "cló3dó", "cló5im.", "cló5ití", "4clu", "c1m2", "2cn2", "cna6", "cnag5", "cneá5c", "c2o", "cod3", "cof5", "coil4t3", "coirn4", "co4m", "comh3", "cona6c", "cona3m", "con3c", "con5g", "coran4", "corant3", "corb3", "corn3", "cor6p1", "cor3t4", "5cos", "cosc3", "c6óc", "4c1óf", "c4óip", "cóis3", "cóist4", "3c4ó1m", "có4ma", "3cón", "6cóp", "cór5", "5c6ót3", "c1p", "c3ra.", "crag5", "crai3l4", "crais4", "craist5", "c4rat", "crá5inn", "crá5ití", "c2re", "crea6b", "creab5a", "creach5", "creacht6", "crea5sc", "c5reá", "créal3", "créalt4", "cri5b", "c5ril", "cri6t", "crit5é", "criú5i", "crí6", "críoch5", "croch3", "crocht4", "cros3", "crost4", "cruacht6", "crua5im", "crua5itea", "crú5ití", "c6se.", "csea5g6", "c6s5eal", "c4sic", "csi5d", "c4sig", "c6s5il", "cs4im", "cs5is", "c4s3ít", "c3s4m", "cs3ó", "c3st4", "c6s5tar", "cs3ú", "2c1t", "c6te.", "c4t3eac", "c6t5ean", "c6teái", "c6t5eár", "ct4eo", "cth4", "ct6iú", "ct4ío", "cuacht6", "cuach5taí", "cua6m", "cuil3", "cuilc6", "cuil6t", "cul3", "culc4", "cul6t5ai", "cur6l5", "cus3", "cú6i", "cúl5", "c3úla.", "c4ún", "3cúr", "da6b", "dab5a", "d1ac", "da5c6ac", "da5c6aí", "3d4acs", "d1ad", "dae5", "d3a3g", "dagas5c6", "d1ai", "dai3ghn", "5d6aine", "3d4aing", "dai5p", "3d4air4b", "dairbh5", "3d4airi", "dair4n", "d1aí", "dalbh5", "6da3l4ú", "d1an", "4dann", "dar1", "da3r4ao", "d4ará", "dar6d", "darg4", "darn4", "d3ars", "dar5t4", "da3st", "3d4at", "d6ád", "3dáid", "d5áis", "d4áit", "d1ál", "dár5", "dára5s", "dárt6", "dá3th", "d1b", "dbhin4", "d1c", "4d3ead", "6deag3", "d5eagó", "deal5a", "6deam", "d6eand", "4deann", "5d6eannai", "5d6eannas", "5d6earb6", "dear5ba", "dearbh5", "dear5t6", "deat3", "deá4", "deáth3", "deilbh5", "deil6te.", "3d4eir", "d6em", "d1eo", "4deoir", "4deor", "déam5", "déidlia5", "d4éim", "2d1f", "d1g", "d2h", "6dh.", "dh4ao", "dhar3t4", "dhas5", "dhasc6", "1dhá", "dh2b", "dh6c5a", "dh4cá", "dh4ci", "dhearb6", "dhear5ba", "dhearbh5", "dhear5t6", "dheá6", "dheilbh5", "dheil6te.", "3d6hé", "dh5f", "dhia5f", "dhint5", "dhip5", "dhí4o", "dhí3ré", "dh6l5ean", "dhlío5dó", "dh4n3e", "dh5nu", "dh5nú", "3dho", "dhob4", "dho5chaid", "dho5che", "dho5dh", "dho5ghl", "dhoir4n5", "dhor2", "dho5ré", "dhorn5", "dhosc6a", "dhos5caí", "dho5s6m", "dho5thr", "dho5thu", "dhó3f", "dhó5idí", "dhó3im", "dhó5in", "3dh4ro", "dhró5l6", "dh2s3á", "dh6te", "3dhu", "dhual5", "dhua5m", "dhuamh6", "dhur1", "dhurd4", "dhú5lé", "dhú5rú", "dhú3s", "dia5f6", "6d5iam.", "dia3mh", "4dib", "dic4", "dic5e", "3dict", "d5idh", "d3idí", "d1ig", "di5lé", "d1im", "4din", "d3iné", "di3n4éi", "din6t5", "5dip", "dist5", "d1it", "dí1gh", "dí3le", "dí4lea", "d1ím", "dí2o", "dí3ré", "d2ís", "d1ít", "dí6the", "dít6i", "dív3", "d1la", "d4l3ad", "dlam5pa.", "d3lan", "5d6lá", "d1lé", "dlí3b", "dlío3dó", "d3ló", "3d4lú", "d1m", "dman4", "dmh2", "dm6i", "d1n", "dn4i", "dob4", "do3br", "do5chaid", "do5che", "doch6t5a", "doch6tá", "do3dh", "do3ghl", "d3oif", "doilbh3", "5doir", "doir4n3", "do5lag", "do5le", "do3mhi", "do5mho", "do5mhú", "3dor", "dor2c", "dorch3", "dord3", "do5r6é", "do5ri", "dor6n3", "dosc4a", "dos3caí", "do5s6m", "do3t", "doth4", "do6th5a", "3dó.", "3d4óc", "d1óf", "2d1óg", "5d6óic", "5d6óigh", "dó5im.", "2d3óirs", "5dóiv", "dó5m6", "3dónn", "6d5ós", "dóth3", "6draim", "dra5n6ó", "d1rá", "d3reá", "dreo5it", "3d4reor", "d1rí", "3d2ro", "4drog", "3dróc", "dró3l4", "3dróm", "3d4ru", "dr4ú", "d1s", "ds4a", "ds6r", "d1t2", "dta6", "dtach6t5", "dtaist5", "dtan5g", "dtap5", "dtéit5ea", "dt6i6", "dtrá5ití", "dtróf5", "dtua5im", "dual5", "dua3m", "duamh4", "duar5t", "3d4uc", "duch6", "ducht5", "d1uit", "3d4ul", "dun6s5", "dur1", "durd2", "dú3bh", "dú3l4é", "dú5rú", "dú3sc", "d3ve", "eabh5t6", "ea5car", "each3ó", "ea5c6ló", "ea5co", "ea5có.", "ead1á", "ea6dh", "ea4d3óin", "eaft5", "ea4g3a", "ea3g4ál", "eagh2d3", "6eagm", "eag3ó", "eain5", "eais6t3", "ealbh5ac", "eal6p5", "eal4t3ac", "eal6t5aig", "ealt3á", "eal6tái", "eal6tán", "eam5ait", "eamar4", "eama3ra", "ea3mat", "6eamá", "eam4p3ló", "ean3d4", "ean6táil", "6eanú", "earai5c", "earb3á", "ear3f4", "ear1m2", "earn3", "6earta.", "ea3rúi", "eas3a", "ea3s4áir", "6eash", "4easm", "ea3s2tr", "4easú", "ea4tá.", "ea5táir", "2eá.", "eá5g", "4eáib", "eá3id", "eá1im", "eá3inn", "5eáis", "eá3it", "eáit4e", "eáit6i", "4eám", "eá1t", "eáth2", "e3bh", "e1c", "e1d", "e1f", "e1g", "eg6í", "eib3é", "ei6bh5", "ei4c", "eic4si", "eic6s5í", "4eid", "eidh5n6", "eidh5t6", "eid1i", "eig4eac", "4eil", "eilít6", "eilp5", "eil6t5eac", "eil6t5ean", "eil5tear", "eil5teá", "eil4t3i", "6eimh", "eimin3", "eini3c", "ein2t3e", "ein3t4eá", "4eip", "eips6", "eipt4", "eirbh6i", "eir4bí", "eir6fig", "eirg3", "eir2m", "eirm5é", "eirm5is", "eir5m6ít", "eir6p5", "eir6st", "ei4s", "eisc5eac", "eis5cir", "eis6ean.", "eis6ilid", "eis5in4", "eist3", "eit3é", "eithin6", "eitim6", "eiti5mí", "eits3", "el1a", "e3lá", "el3ó", "e3lu", "e3m4ac", "e5m6aí", "e3mh", "emhá6", "en1", "e5n6i", "eo3dar", "eod5ór", "eo3fad", "eo3fai", "eog4acht", "eo1gh", "eoi3f", "eo3im.", "eo5itear", "eo3iteá", "eo3ití", "eol3c4", "eol5g6", "eo3lu", "eo5mar", "eomh2a", "eo3nna", "eor1", "eorn4", "eo3st", "eó5d", "e5ólac", "e5ólaí", "er1", "era5d6", "era3s4", "eró3b", "e3s4a", "e5se", "e3s4p", "e1t", "ethan5", "éab5ró", "éa2d1", "éag3ói", "éa1gr", "éa1gu", "éal1", "éalbh6", "éalt3", "éal5tar", "éam3at", "é6amh", "4éann", "3éa3p", "éar5g6", "éars5a", "éast4", "éat3a", "é1b", "ébhrí3", "é1c", "éch4", "é3dh", "é1f", "é1g", "é6go", "é3hé", "éic4s3", "éid1", "éi5dei", "éi5d6reo", "éif4ear", "é3if2i", "é5ifí", "éi3g4eal", "éi5g6é", "éi3ghn", "éi5g6ia", "éi3g4il", "éig3in.", "éi3g4rí", "éil5g", "éilips3", "éil4t3", "é6im.", "éim5ir", "é6in", "éint3", "éin6tea", "éin4té", "éip4s", "éir4g3i", "éir2n3", "éir6s5eá", "éisc1", "éi6se", "éist3e", "éist3i", "é6ite.", "é3iteá", "éit3é", "éit6ir", "éit1s", "é3lá", "é5le", "é3lí", "é5mh", "é5n6á", "é1r", "é6rb", "é1s", "é1t", "é5úl", "fa4b", "fab3r", "facht2", "facht5a", "f6ain.", "faist3", "faisti3", "faistic4", "fal3c4", "f6an.", "faois3", "far6am", "far6at", "far3n4", "fas4t", "fáil2t3", "fáir5", "4fás", "f3ch", "fea6", "fead5a", "f6eadh", "4fean", "fear5t6a", "feil6te.", "feis5c6", "f4e3l4", "feo5itea", "6feol", "feo5m", "f4ep", "féach5", "féacht6", "féalt6", "f6éit", "fg4a", "f3gh", "1fh2", "fha6", "fhach3", "fhacht4", "fhair5t", "fhal5c6", "fhas6t", "fháil2", "fháilt3", "fháir5", "f4he", "fhead5a", "fhear5t6a", "fheil6te.", "fheis5c6", "fheo5f", "fheo5idí", "fheo5im", "fheo5in", "fhéach5", "fhéacht6", "fhid5", "fhios5", "fhiosc6", "fhí5dí", "fhí5g", "fhí5m", "fhí4o", "fhí5oda", "fhí5odh", "fhí5om", "fhí5onn", "fho5b", "fho3dh", "fhoil5", "fhoin6", "fhol6ta.", "fhor5b6", "fhor5n6", "fhómh3", "fhraim5", "fhriocht6", "f6hu", "fhua5itea", "fhuir4s3", "fiach5", "fiacht6", "fid5i", "f4ill", "fios3", "fiosc4", "fir6m", "fisc3", "fi3té", "fí4o", "fíod3ó", "f2ís", "fl6i", "flít5", "f4lu", "f1n", "fn4i", "fo3b", "fo1d", "fo6d5a", "f4oi", "foil5", "foin6", "foirn4", "fo3le", "fol6ta.", "fol3u", "f4or", "for3b6", "forch4", "for3n6", "fo3scr", "fost3", "3f4ób", "f4óib", "f4óin", "fóint6", "fómh1", "frai3d", "f6raim5", "5f6ram", "4fri", "fri3d", "frioch3", "friocht4", "f2t", "ft5á", "f5té", "ft3i", "fuad3", "fua6fair", "fua6f5ara", "fua5im.", "fua5itea", "fuir2s3", "fúith6", "f6úl", "fús4", "fúst3", "g1a", "g2ab", "ga5b6a", "gabh5", "gabht6", "ga3dao", "g2ae", "6gaig", "gair4n3e", "gai3sp", "gais5tea", "gais5teá", "gai3té", "g3al.", "5galm6", "4g5amar", "gana3", "g6and", "3g2ao", "gaof3", "g6a5p6", "garbh5á", "gard3", "gar5ma.", "gar1n2", "gar6tú", "gas5c6ar", "gas3c4r", "ga3stá", "g1á", "gáir5", "6gáis", "g3ál", "6g5ánt", "3g4ár", "g1b", "gb6a", "g1c2", "gca4", "gcach5", "gcacht6", "gcad5á", "gcaí5d", "gcaí5gí", "gcaí5m", "gcaí5o", "gcaí5teá", "gcaí5tí", "gcar6t5a", "gcar6tá", "gc6i6", "gcil6", "gcin5t", "gcí6", "gcli6", "gclip5", "gcló5f", "gcló5id", "gcló5im", "gcló5inn", "gcnaí3", "gcnó5", "gc6ú", "g1d", "gd6a", "2ge", "g1eac", "gea4d", "6g5eadar", "gead5as", "6g5eadh", "gead3ó", "g6eaf", "geal5a", "geal5b", "geal6ta.", "gea3nam", "6gear.", "5g6eart.", "gea3st", "geat5a", "g1eá", "g4ec", "geit5", "g1eo", "g6es", "géa5b6", "5g6éas", "2g1f", "g2h", "4gh.", "ghabh3", "ghabht4", "ghair4n5e", "ghais5tea", "ghais5teá", "gh6am.", "gharbh5á", "gháir5", "gh5c6", "6ghd", "ghd3ac", "ghd3á", "gh4de.", "gh2di", "gheal5a", "gheit5", "gh1f", "ghint6i", "ghin5tí", "ghis5", "gh2lu", "3gho", "ghoin5", "ghó6f5", "ghrá5inn.", "ghrá5ití", "ghrá3m", "ghrámh4", "3ghrú6", "6ghrú.", "gh4s3á", "ght4", "ghual5", "g1id", "3g4id.", "g1ig", "gild5", "g4ili", "g1im", "3gine", "3giní", "g3inn.", "3ginnt", "gin5t6í", "1gio", "gios3", "giost4", "gip4", "gip5s", "gipt5", "g1is", "g1it", "g1iú", "giúm5", "giús3", "g1í", "glae1", "g4lán", "gl4i6", "5g6lic", "3glif", "g6lis", "g1lí", "g6lo", "gl6ú", "g1m2", "gmh2", "2g1n2", "g2ná", "gnó3l4", "goin5", "gó1c", "g3ód", "g1ó6f", "g1óg", "g3óid", "g3óig", "g1óim", "góin4", "g3óinn", "góint3", "g4ól", "g3óra.", "g3ra.", "g1rac", "1g4raf", "3graif", "g3raig", "g3rait", "g1raí", "gra6m", "grama5d6", "g5ras", "3grád", "grá5inn.", "grá5ití", "grá3m", "grámh4", "grá4n", "4gri", "g1ró", "3gru", "grú6i", "g1s2", "2g1t", "gth4", "gual5", "g3uc", "g3uir", "1gum", "gust5a", "4gú.", "g5wa", "hab3r", "ha4c", "hach6ar", "hach5ó", "hac6s5", "had6aimh", "had6amh", "ha3dái", "ha3dán.", "hae5nn", "hagá5l", "hag5r", "hag6úis", "hai6c", "haic5í", "haidh5ne", "h1aim", "hain2t", "haint5í", "hain6tín", "hais5t6eor", "hais5tic", "hait3é", "h1aí", "haít5eac", "haí6ti", "hal5a", "halbh3a", "hal5g6", "hallag6", "halt5ar", "ham5at", "hamb6", "ham5ó", "h6ams", "han4á", "han3d4", "han6lain", "han6lan", "han6rai", "han6sa.", "han6sac", "han3t4á", "haof3", "hara5b6", "harai5s6í", "haral4", "haralt3", "hard3á", "h4arg", "har5ma.", "har3n4ó", "h6arr", "har6s5ac", "har6s5aig", "hart4ac", "har3ú", "hasam6a", "ha5s6áir", "ha5s6ár", "hasc6ar", "has5car6n5", "has6pa.", "has6p5aí", "hast5ait", "has6tú.", "hat5ar.", "hat5ra", "hat5ú", "hách1", "háin4t", "háint5eac", "háí6", "há5ío", "h4ár", "h1b", "h2ba", "h5bha", "hbhain6", "h5bhe", "hbheo5f", "hbheo5id", "hbheo5im", "hbheo5in", "hbhuí6", "h1c", "hc4a", "hc4án", "h6cé", "h3ch2", "h4c3í", "h1d", "hd2a", "hd3aim", "hd3an", "hd5eam", "hd3eann", "hdeá5nn", "hd6eog", "hd6eoig", "hdh4", "h5dine", "hd5inn", "hd3iú", "hd4ó", "h4dt", "hea6c", "h3eacn", "hea6g", "heag5r", "heal6ta.", "heana6", "heanad5", "h4eang", "hea6r", "hear5bó", "h4eat", "heat5á", "heat5ó", "heá1c", "h6eána", "heá6t", "heáth5", "heift5", "heod5ó", "heo5itea", "heo3mh", "h6es", "h4éadr", "héidlia5", "héi5gear", "héim5í", "hfach3", "hfair5t", "hfeo5f", "hfeo5idí", "hfeo5im", "hfeo5in", "hfhuad5", "hfhuaf6", "hfí5dí", "hfí5g", "hfí5m", "hfí5oda", "hfí5odh", "hfí5om", "hfí5onn", "h1g", "hgh2", "hghair5t", "hghin5", "h4gí", "hg6n", "hiach5t6", "hiat6ac", "hia5t6aig", "hia5t6aí.", "hi6b", "hibh5", "h1id", "hid4é", "h1ig", "hil3b", "hi4m", "him3é", "hin6d5ia", "h4ine", "hineach5", "hineacht6", "hin6ín", "hin4íon", "hin6ír", "hin6ste.", "hint4e", "hin5teá", "hin4t5iú", "hiosc6á", "hios3t4", "hip4e", "hipi5c6", "hip6id", "hirim5", "hir6im.", "hir6ime", "hir6n", "his5tear", "his5teá", "his3t6in", "hit6eor", "hit5s", "hiúm5", "hiúnt3ó", "hiúr5", "hiús5t", "hí1gh", "hí3leá", "híod5ó", "híol5", "híoll6", "h4íos", "híos5t", "hí5sti", "hí6th5e", "hla6", "hlac5á", "hlad5a", "hlad3á", "hlad5ó", "h1laí", "hlas5t", "h4láir", "hleach6t5", "hleat5a", "hleá5d6", "hléach6", "hléacht5", "hlé5am", "hlé5igí", "hlé5imi", "hl6i6", "hlim6p", "hlin4", "hlip5", "h1lí", "hló5im.", "hló5ití", "hl6ú", "hma6", "hm4ad", "hmad5ó", "hm4aid.", "hm4ain", "hm5ainn", "hm3an", "h1mh", "h4mt", "hn2", "h1na6", "hnag5", "h1ne", "hn6eán", "h1ni", "hniú3c", "hniúch6", "h1ní", "h1nó", "h6nó.", "hnó5l6", "h4nr", "hn5t", "hnua5c", "ho3bró", "hoch6t5a", "hoch6tá", "hod3a", "hod3ó", "hof3a", "h4og", "hoilt6", "hoi4m", "hol4agá", "ho5le", "hol3u", "h4om", "homai3g", "ho5mhú", "h4on", "hon4c3ó", "ho5nu", "horan6", "horant5", "horch3a", "hord3á", "host5ac", "hos6tá", "host5áin", "host5án", "h1óf", "hó5im.", "hóin4s", "hóint6", "hóist6", "hó5l6ain", "hó5l6an", "hó6ma.", "hó6maí", "hóp6a", "hó6s", "hós5a", "h2ót", "hóth1", "h1p", "h2p1e", "h6p5i", "h6pí", "h1ra.", "hrad5á", "h1raí", "hra6m", "hramad6", "hran5g6ó", "hrat5ó", "hrá3th4ó", "h3re.", "hré6i", "h4rio", "hrioch5t6á", "hrí2o", "hrí3r", "h4rís", "hroch3", "hrocht6", "hruac6", "hrua5cá", "hruacht6", "hrua5itea", "hr6ú", "hrú3ití", "h4rúp", "h1s2", "hsc2", "hscar5", "hscart6", "ht1", "h3t4ae", "h3t4aic", "ht4anac", "hta5p6", "h3tar", "h2tái", "h1t2e", "h5th6", "hthor6t", "hthorth5", "ht6i", "h2tó", "h3t2úir", "h1t2úr", "huil5ce", "huil5c6i", "hul6t5ais", "hur5b", "hur3n4", "húch3t6", "húd5aí", "húin5t", "h6úis", "hú5ite.", "húst5", "hút5ó", "h3vó", "ia3chl", "iach3ó", "iacht5aí", "ia5dar", "ia3f4a", "ia5fá", "iag5ó", "ia3gr", "ia3idís", "ia3igí", "4iail", "ia5im.", "ia3imi", "ia5inn", "ia3ite", "iai3t4r", "ialach3", "ialacht4", "ia3l4ain", "ia3lan", "ia3lat", "ia5mar", "iam4b3", "ia4mhai", "ian5a", "ian3g4", "iar3b", "iarbh6", "iarc6", "iar3d2", "iar5m6", "iar3t4", "iast5r", "ia6tá", "ia1t6r", "ib1e", "ib4eab", "ib3éa", "ib5éid", "ib3éil", "ibh1", "ibh5é", "ibhin4", "ibhit4", "ib1i", "ib5ia", "ibia5n", "ib5ir", "ib1í", "ib1l", "ib1r", "ic1", "iceap4", "iceapt5", "i3cei", "icé5an", "ich1", "i5ch6a", "i3chr", "icim4", "ic6iú.", "i3c4íd", "icí5tea", "ic4ri", "ic4st", "id1e", "id1é", "idh3bh", "idhc3", "idh3e", "idh3i", "idh1l", "idh1r", "id1ia", "id3icí", "idi3f4", "id1in", "id1iú", "id3íd", "id3íg", "id1ín", "id1ío", "idí5oc", "id1l", "id1r", "id4ré", "i5éa", "if1", "i6fe", "if5in.", "ifini5", "ifinid6", "ifin6t", "if3ír", "i3fís", "if6ré", "ig1e", "igea3s4", "igea5t", "ig1é", "igh1", "ig3ia", "igi3b", "ig1il", "igi3l4i", "ig1ip", "ig1ir", "ig1l", "ig1r", "i1h", "il3a", "ilbh5in", "il4bh5r", "4ilc", "il1e", "ileac2", "ilea3ca", "ilea3cá", "ilea5có", "il5eá", "il1é", "ilé5an", "il6fr", "il1i", "4ilia", "ilia5n", "ili5bé", "ili3c4é", "il1í", "ilí6f", "il5ío", "il2sc", "im5a", "imar6", "imb3l", "imeach6", "imeacht5", "im3éi", "2img", "imh1", "i3mha", "imhead6", "im3ide", "imig6", "imi5gé", "im3io", "im3ire", "im3irn", "im3irt", "im5isc", "im5írí", "in3á", "ind3eá", "ind5ia.", "ind3iai", "ind3ib", "indí6", "indíl5", "indó1", "in3e", "in5ea", "ineam6", "inea5maí", "inea3mó", "in1é", "i5n6éag", "ing1", "in6gir", "in3i", "in5ic", "in5ig", "iniúch3", "in1í", "in5íoc", "iní6t", "6innis", "in3o", "in4scn", "int3ean", "in2tí.", "ioch5t4óg", "ioch5t6óig", "ioc5s6", "iod1", "iof1", "iogad3á", "iol5g6", "iom3ar", "6iomá", "ion3c6", "iopa5d", "ior3d", "4ios", "iosc6ac", "io6t", "iot6as", "ip1", "ipea3g", "i3péid", "ip5is", "ipist6", "ip3í", "i5plé", "ir1", "ir5ch", "irea5b6", "iream6", "irea5má", "irea5mó", "ir5id", "ir5ip", "ir3í", "irír3", "ir5sc", "irscar5", "irscart6", "ir6ta", "irt3o", "ir4tr", "irt6s5", "i6sc", "isc3ead", "isc5eal", "isc5eam", "isc5eann", "isc1é", "is3céim", "isc3inn", "is1e", "isear3", "isearbh6", "6iseas", "i3sei", "is1é", "iséal5", "is1i", "4isic", "i3sint", "6isis", "is1í", "i5s6ít.", "i5s6íte.", "is3o", "is5pí", "is1ta", "ist4r", "it5ai", "it1ea", "6itean", "it3eart", "it3eán", "ith1", "ithé5an", "ithin6t", "it1i", "itil4t", "i6tínn", "i1to", "it1r", "it6ré", "4its", "its5ean", "iuch3", "iucht4", "iúch3t6", "4iúd", "4iúid", "iú5im", "iú5inn", "iúiré5", "iúir6s", "iúité5", "iúr4s3", "iúst4", "iús5tá", "6iút", "iú5t6ac", "iv1", "í5ba", "í3bea", "íb3eo", "í1bha", "íbh3ei", "í5bheo", "íbh1i", "í5bhr", "íbhuí4", "íb1l", "íb3o", "íb1r", "íc1e", "ícea3s", "í3cei", "íc3éa", "í5céi", "í1ch", "í5cha", "í4ch3eal", "ích6n", "íc1i", "íd1e", "í1dh", "íd1i", "íd3íd", "íd3íg", "íd3ín", "íd1ío", "í1f", "í6fe.", "íf5ean", "í6f5ir", "í6f5is", "íg3e", "ígh4", "íghnaí6", "íg3i", "í5gré", "íg5ri", "í1h", "íl3a", "í1lá", "í6le.", "íl1ea", "íleá5cha", "íleá5ic", "íl3é", "íl3ig", "íl3im", "íl5in", "íl3is", "í1lit", "í4l5ith", "íl5iú", "í3líth", "í5lo", "í1ló", "í1lu", "í4m3é", "í1mh", "í4mhid", "ími3t", "ín1", "í1n2a", "ín5ai", "í3n4á", "í6nn", "í3n4o", "í3n4ó", "ín3t4", "í1oc", "ío3c4á", "ío6có", "íof1", "íoga3dá", "íomh3", "ío4mhe", "í3onna.", "6íop", "2íor1", "íorg4", "íorn6", "íort6", "íot6r", "í5óga", "íp3e", "íp3é", "íp5i", "íp3r", "2ír1", "í1r2a", "í5rá", "ír4easc", "í3rei", "ír2éir", "í1r2ia", "í5r6u", "í5r6ú", "í1sca", "ísc5e", "í3scé", "ísc3ir", "í1scr", "ís1e", "4ís3é", "4ísh", "ís3i", "ís1í", "í1s2p", "ís3ta", "íst5e", "íst5in", "í5stu", "ít4e", "ít5ean", "í4tear", "í3teas", "ít5é", "í1th", "íth5is", "í6th5oin", "í3ti", "í1tr", "í6úi", "í3úl", "la5bas", "4lacá", "la3c4án", "lach5ó", "lach6tá", "ladh2m5", "lae6c", "la3f4á", "la3f6ó", "l4agam", "la1g2á", "l6agh", "laghd6", "lai5d6é", "l4aih", "lai3l4", "lai3m4é", "lain4", "lainc4", "lain5ci", "l4ai3né", "lais1", "laisc3", "laist6", "l4aité", "lai3tín", "la3l4", "l4amo", "lamp1", "la5mú", "lan2d3", "l5ang", "lao3f", "lao5inn", "lao5ire.", "lao5irí", "lao5itea", "lao5iteá", "lao5ití", "lao5nna", "l1ar", "l4ar3n", "la3rúi", "lasar3", "lasarn4", "l4asb", "las6pa.", "las5tó", "lat3á", "lat3ó", "lat5r", "lách5", "l4áib", "l6áim", "láin3", "lá5inn", "láint4", "lá5iteá", "lá5ití.", "1lál", "lámhach5", "lámhacht6", "lár5", "lárt6", "l1b4a", "lba5t", "l3bá", "lbh5acá", "lbh5ad", "l5bhain", "lbh3ait", "l5bhan", "l1bhá", "l4bh5áin.", "l6bh5án.", "lbh5ead", "lbh5ean", "lbh3eo", "l3bhé", "lbh3f", "l6bh5id", "lbhin4", "lbh5ir.", "lbh5ith", "lbh1í", "l1bhr", "l3b6í", "lb3n", "l4b3ó", "lc1a", "l3c4ail", "lca3l4", "l3c4á", "l6c5ánt", "lc3ean", "l3cei", "lc3eo", "l1ch2", "lc5id", "lc3im", "lc5in", "lc3it", "lc3í", "l3cl", "l5cú5", "l1d2", "ld5ean", "ldeighil6", "ldú3", "ldúd4", "leach6tá", "lea5gú", "lea5m6á", "learb3", "leat5ó", "lea3tra", "l4eav", "leách3", "3leáf", "l4ec", "l4ef", "l4ei", "leicead5", "leif5", "leir5c6", "leisc3", "l4e5l", "l4em", "leo6d5", "leomh3", "lé3ad4ar", "lé3adh", "léalaim5", "lé3idís", "lé1if4", "lé5imid.", "lé5imis", "léint6", "lé3itea", "lé3ití", "léit6s", "l6éiv", "l1f", "l4fc", "lf5ean", "l4fg", "lf5ré", "lga3dá", "l1g2am", "lg1e", "l3gé", "l1gh6", "lg3i", "lg3l", "lg3r", "lg6rá", "l3ha", "l5he", "liant3a", "lian4tac", "lias5", "liast6", "liat6", "l4ibh", "li3bhe", "li5b6il", "li5bí.", "li5b6ío", "lic6s5", "l1id", "4l1i1f4", "lig3", "li5g6éa", "li3l6", "li5m6é", "li3mhi", "lim5ir", "limp3í", "li5n6é", "ling6te.", "lin4s", "lint3e", "4liona", "lion4t5", "liost3", "lip4s", "l1ir", "lis1", "list4", "li3té", "li3tiú", "liú5d6ar", "liú5ití.", "liú5ma", "liú3st", "lí3bhé", "lí6ochá", "l1ís", "lí3sé5", "líth6i", "l2l1", "llab6", "lla5ba", "lla3c4á", "lla3g", "llag6ac", "llag6ar", "llai3s", "llait4", "llam6", "lla5má", "l6ló", "llt4", "l1m", "l2ma", "l5ma5n6", "lm6á", "l2me", "lmh2", "l6mia", "lm6í", "l6mí.", "lm4óg", "lm6óig", "l4ms", "l1n", "ln4a", "ln4i", "lod5", "l3oid", "6loine", "loit5e", "lon5c", "lorai5", "loraic6", "ló5dóir", "ló5d6ór", "l6óiní", "5l6óip", "ló3l4", "ló5mh", "5lóp.", "ló1s", "lót3a", "lóth3", "4lóv", "lp1a", "lp3á", "lp1e", "l5pei", "l3pé", "lp5iú", "l5pít", "l3pó", "l1r", "lré5", "l1s2", "l6sc3ai", "lsc4á", "lsc3e", "lsc6ead", "l5scid", "lsc5in", "l5scl", "l5s4e", "l5s6l", "l1t", "lt6air", "lt4ar", "l6tb", "lt2e", "l4t3eann", "lt3eof", "lt2i", "l4tm", "ltor6", "lt6rac", "ltra3l", "lua3im", "lua5itear", "luch6t5", "luí3o", "lus5t", "3lúb", "lúca3", "lúch3t4", "4lúd", "lú4f3", "lúg4", "lúit5é", "l3úl6", "lúm3a", "lúma5n6", "lú4mh5a", "lú4mh3á", "l1ún", "l4úpa", "lús3", "lút3ó", "l1v", "m3ab", "mabh6", "m1ac", "5m6ac.", "mac5a", "m1ad", "m5adar", "ma5das", "ma3dá", "m5adh4", "madhm5", "m3ae", "m3a3f4", "m3ag", "ma5g6l", "ma3gr", "m1ai", "mai5l6ít", "4maim", "maini3c4", "mai3n4id", "maint6i", "main6t5í", "mair6ne", "mair6ní", "maist6e", "mais5teo", "mais5t6ín", "mai3té", "m2aiti", "m1aí", "maí5te.", "maít5eac", "maí6ti", "m5al.", "ma3l6an", "m4alá", "mal5g6", "m1am", "mam5ó", "mam5ú5", "ma5n6am", "5m6an5c", "3m4an3d6", "mant3", "ma3r4ad", "m3ar6b", "marbh3", "m1ar6c5", "m1ard", "mar6f5", "mar3m6", "m3ars", "mar6sa.", "m3art", "m3a3rú", "m1as", "mast4", "ma3tag", "m3a3tó", "mat5óg", "m1á", "mách1", "6mál", "már5", "márt6", "m4át", "m1b2", "mba6d", "mbad3á", "mbal6b", "m6bd", "mbeo5f", "mbeo5g", "mbeo5id", "mbeo5im", "mbeo5in", "mbí5dís", "mbí5mis", "mbí5teá", "mbí5tí", "m4bl", "mblí3", "mb4ó", "mbreo5f", "mbreo5id", "mbreo5im", "mbreo5in", "mbrí3o", "m1c", "mch2", "m3c4í", "m1d", "m1e", "m2eal", "meal6t", "mear5c6", "mear5t6ai", "m2easc", "meas5t", "meat5án", "meá5c", "meir6f5", "meo3nó", "m6es", "1méa", "6m5é5ac", "m5éam", "m3éar", "4méar.", "mé5ic", "mé5igh", "méin6t", "m5éis", "2m1f", "m6fe.", "m1g", "2mh.", "3mh4ac5a", "mh4ad.", "mhadh4", "mh4ag", "mh4aid.", "mhaini5c4", "mhain5te", "mhain5ti", "mhais3", "mhais6c", "mhaist4", "mh6am.", "mhar6b", "mharbh5", "mhar6ca", "mhar6c5r", "mhar4f3", "3mharg", "mhar3m6", "mhar3t4a", "mh3asf", "mh6at.", "mhat3á", "mhat5ó", "mh6ats", "mhár5", "mhárt6", "mhd6", "mhea5dai", "mhead5ar", "mhea5das", "mhear5c6", "mheas3t6", "mheir6f5", "mh4éal", "mh1f", "mh4ill", "mhion6ta.", "mhion6t5aí", "mhis3", "mhist6", "mhí3b", "mhíbh6", "mhí6le", "mhí3ré", "mh1l", "mhluad5", "mh1n", "5mhol5t6", "mhon5c6", "mhong5ó", "mhon6t5", "mhor6c", "mhor5n", "mhor6s5", "mhó5mh", "4mh5r", "mhrí5oc", "mh1t4", "3mhuir", "mhuis5", "mhuisc6", "mhuí6", "mhur5", "mhus3t", "mhúd6", "mh4úin", "m3ia", "m1ic", "mid5i", "m3idí", "m1ig", "m1il", "mi3l4é", "milí6", "milít5", "m1im", "m1in2", "mi3né", "min5se", "min5sí", "mint1", "mion4t5a", "mior5", "mir4c3", "m3i3r4é", "m3irí", "mirt3", "misc3", "m1isi", "m3is3t6", "m1it", "mit6e", "mi3t4i", "m1iú", "3miúd", "m1í", "mí3b", "míbh6", "mí3gh", "mí5gr", "3m4íl", "mí3lít", "mí6na", "míos5", "5míre.", "mí3ré", "3m4ít.", "3m4íte.", "mí3teac", "mít6i", "m1l", "mleat6", "mlua5da", "mlua5itea", "2m1n2", "m5na", "modh5", "m1oi", "mol5t6", "mon5c6", "mong5ó", "mon6t5", "mor2", "morch5", "mor5d", "morf1", "mor5n", "mors5", "m1ó", "4móf", "m4óin.", "m6óiní", "móint6", "mó5m", "m2ón", "3món.", "mór5", "5m6óró", "m4ós", "mp3all", "mpar5", "m3p4arn", "m1pe", "mp3eann", "m5pé.", "m5péar", "mp5éid", "m5péir", "m4pf", "m1pi", "mpis6", "mpi5se", "m3pí", "m1p2l", "m1po", "m1pr", "m6pt", "m1pú", "m1r", "mroch5", "mrocht6", "m1s2", "msc4", "m1t", "mth6", "m1ua", "muilc5", "muis5", "muisc6", "muí6", "5mul", "mur5", "murd6", "mus3t", "m3ú6c", "múch3", "múcht6", "múin5", "m3úl", "m3ús", "mút5", "n1a", "n3abaí", "na3bh4", "nach6ain", "na3ch4an", "na3chl", "na5chr", "na5có", "na3cr", "na3dá", "nae5m6", "n3aer", "naf5", "2nag", "na3g4am", "nag3ó", "na3gr", "nai3l4i", "nai5l6ín", "nail6t", "n4aise", "naist3e", "nais5teo", "naít6", "nal3", "nalbh4", "na3l4óg", "na5mara", "na5mat", "namh5a", "na3mhé", "nan2", "nant1", "nao5nn", "2nap", "narb5a", "narbh6", "na3stá", "nata6", "na5tam", "na3tó", "nava5", "4ná.", "ná4f3", "ná6i", "n1áid", "n1áil", "n5áisc", "n5áí", "n1ál", "n1ár", "6n5ásc", "n1b", "nb6a", "n4b3e", "nbhan6", "nbhand5", "n6bh5ao", "n6b5i", "n6bí", "n1c", "n2ca", "nc5aig", "nc5an", "ncar5", "n5c6ar.", "ncarn6", "n2cá", "n3c4ás", "n6cb", "nc3e", "n3ceas", "n5cei", "n4c3é", "n5céad", "n5céid", "n5ch2", "nchró5", "n6cig", "n5cisí", "nc1lo", "nc3lu", "n4c4s3", "n4c3ú", "n5cún", "n1d2", "nda6g", "n5d6án", "n5dea", "n4deá", "n5dé", "n4diai", "ndic5", "n6dis", "nd5is.", "nd5ise", "ndlí5d", "ndlí5g", "ndlí5m", "ndlí3o", "nd3óg", "ndó5ite.", "ndó5ití", "ndreach5", "ndreacht6", "ndreo5f", "ndreo5id", "ndreo5im", "ndreo5in", "nd6ró", "nea3g4á", "nea5ma.", "nea5s6ár", "neat5", "neá5cha", "n4ed", "n4eg", "n4em", "neo6", "neod5", "n5eoiri", "5n6eot", "néa6", "néal5", "néalt4", "4néas", "n1f", "n6fa.", "nfair6", "nfairt5", "2ng", "nga3dá", "ng4aint", "ngair5t", "ng4aló", "n3g4ant", "ng2á", "ng3án", "ng6eal", "ngear3t4", "ngeat5", "n3g4é", "n1gh6", "ng6ia", "n3g4il", "n4gin", "ng6íne", "ng6íoc", "ng6lí", "ng6óid.", "ng6óide", "ng6ór", "ngt4", "n5g6ún", "n5gús", "n5h6a", "n5há", "n1i", "nia5it", "nib6é", "ni5cíne", "ni3f", "n5igí", "n3il", "6n5im.", "ni6m5é", "4n3imi", "n5in", "nin6d5", "ninít5", "nin4s", "2nio", "nir5b", "nir4i", "nis1", "nist6", "ni3té", "nílim5", "2níomh", "nío3t", "n3ír", "ní4th5", "ní6t5r", "n1l", "nlé5am", "nlé5an", "nlé5igí", "nlé3imi", "nlia5n", "n5lí", "n1m", "nm5an", "n6mc", "n4me", "nmh4", "n6mi", "n6mí", "nm4ó", "n2n1", "2nn.", "nna3b4", "6nnac", "nn3t2", "noch6", "nocht5", "noich4", "nol6", "no5la", "3nom", "n3ord", "noscail4", "5n6ób", "n1óg", "3nóia", "n4óit", "n1ól", "5n6óma", "n1ón", "n1ór", "nór6t5as", "2n2ót", "nó1th2", "n1p", "n1r", "n3ra", "n5ri", "nroch5", "nrocht6", "n6ró.", "nr6ú", "n1s2", "nsab6", "nsa5ba", "ns3ann", "n4s3áil", "nsá5inn", "nsá3it", "n2s3ál", "nsc6á", "nsc6i", "nsc6r", "n5seac", "ns3eá", "ns4eán", "nseir5", "n5sé", "nsin6t", "n5sín", "nst4", "nsúd6", "nsú5ití", "nsú5m", "n1t", "ntai3b", "nt5a5l6ún", "nta5mó", "nta3p", "nt5art", "n5tá.", "nt4ead", "nt3eag", "n5tear", "n2t1eá", "n5teá.", "n5t6eán", "nt6eog", "nt4eol", "n5tia", "nt3ic", "ntil4", "nti3lít", "n3tin", "n5tis", "nt5iúir", "n4t3iúr", "n4t3íl", "nt4ín.", "nt6íni", "nt4íní", "nt4íoc", "n4tm", "nt5oid", "n3tr", "ntra5b", "ntrabh6", "n6trais", "n6tras", "n6ts", "nua5ch4an", "nua3chó", "nua5da", "nua5im", "nuais6l", "nua5itea", "nuan6", "n5uar", "n6uas.", "nua5t", "n1ui", "nú5í", "n1úl", "n1ún", "n1ús", "nút6", "n3ve", "ob1a", "oba3dá", "ob1á", "obh1", "obhar3", "obhard4", "o3bh4e", "o5bhré", "o3bh6ri", "obht4", "ob1l", "ob1ó", "ob1r", "ob3ú", "4oc.", "2oc1a", "ocan4", "oca3t", "oc3á", "2ocf", "och1a", "och1á", "4ochb", "och3eo", "och3i", "och5í", "och1l", "6ochn", "och1ó", "och1r", "och3t4í", "och3ua", "oc1l", "6oc3n", "4oc1ó", "ocó5c", "2oc1r", "2oct", "4oc3u", "oc5ú", "od3al", "od3am", "od3art", "o3das", "od1á", "od5e", "odh1a", "odhear6", "odhearm5", "odh5eo", "o5dhi", "o5dhí", "odh6l", "o5dhó", "odh1r", "odh3ú", "o6d5r", "od3ú", "oen6", "o6f3ac", "of5ó", "of5ra", "og5al", "og3e", "ogh1", "oghair5t", "ogh2e", "og1l", "og3o", "og1ó", "og1r", "og3u", "og1ú", "o3hó", "oid1i", "oif3", "oift4", "o3igí.", "oil5e", "oimead5", "oim3ir", "oimp3é", "oim4p3í", "6oinn", "oint3é", "oi6p5", "6oir.", "oir6bhig", "oir4bhí", "oir3d4", "oirn6eá", "oir6n5it", "oir6niú", "oirn3í", "oir6níd", "oir6níg", "oir4ním", "oir4nío", "oir4nít", "oir4p3í", "6ois", "oisc1", "ois5c4eá", "ois1t4", "ois4t5ín", "oit1é", "oí1", "oí2c", "oíche5", "oíl4", "oí4te.", "ol1a", "o5l6ab", "ola3dá", "ola3f4", "ola1g6", "o5lagh", "ol6aimé", "olai3té", "olan5d", "ol1á", "o5láim", "ol1b", "olbh4", "olc3ó", "ol3eo", "o3lé", "ol4g3a", "o1li", "o3lí", "ol3m2", "o1lo", "ol1ó", "6olt", "ol1úi", "ol3úr", "oma3l4ó", "om1an", "omant4", "om3ao", "om3ará", "om3at", "oma5tá", "omh1", "omhair5t", "o5mhara", "o1mh2e", "o5mhil", "o3mh6í", "om5ó", "om1p", "omp6á", "om3ú", "on5a", "ona3b4", "ona6cra", "ona3g4ó", "ona3l4", "onam4a", "ona5mai", "on1á", "ondu5s", "on3e", "on3é", "on5gab", "ong3á", "ong3l", "ong3ói", "ong5ón", "on5gr", "on5gúi", "on1o", "on1ó", "o3nót", "6onr", "onsc2", "on6t5ail", "on6t5al", "ontar3", "ontarn4", "ont6e", "ont6í", "ont2ó", "on1ú", "op1", "opad6", "opa5dá", "opa3la", "or5a", "ora3dái", "ora3dán", "ora3tó", "or5á", "orb5ad", "or3bá", "or1bh", "or4ca", "orch3ó", "or5có", "or3e", "or1é", "or3i", "o5r6ia", "or6maí", "or3món", "or3ne", "or5ni", "o1ro", "or3oid", "or1ó", "or5pói", "or6s5aí", "or5tas", "orthé3a", "or5u", "or1ú", "osai5l6", "os5am", "osar5", "osarn6", "osa3t", "osc1a", "o5scao", "o5scé", "osc1l", "osc3ói", "oscó3l4", "osc5ór", "osc5ra", "o3scri", "osc3úi", "o5smá", "os1ó", "ospair3", "ospairt4", "o3s4pá", "ost5ad", "ost3ai", "os4t3é", "os3ti", "ost1ó", "ost3ú", "os5t6ún", "os3u", "os1ú", "ot3a", "otam4", "ot4asa", "ot1á", "oth1", "o3thais", "othar3", "oth6as", "o3tháir", "o3th4e", "o3thí", "o3tho", "oth6ri", "oth6us", "ot5i", "ot1ó", "ot1r", "ots5ó", "ot3u", "ot1ú", "ó3ál", "ób3a", "ó6b5ai", "ó1bh", "ób5r", "óc1a", "6ócar", "óch1a", "óch5á", "ó3che", "óch5r", "ócht6a", "óch3ú", "óc3i", "óc5ó", "óc3r", "óc5s6", "óc1ú", "ód1", "4óda", "ódai5d", "ó3d4ar", "ó3dhe", "ó3dhí", "ó5dhó", "4ódó", "ó3fad", "6óf5ag", "ó1fai", "óf5air", "óf5ait", "óf5á", "óf3r", "óg1", "óg3a", "óga3l4", "ó5gó.", "6ógt", "4óia", "óib5é", "óid3i", "ó6igh", "ó3igí.", "óillí4", "ói4m5é", "6ói1mh2", "óin6se.", "óin5si", "óin5sí", "óin3t", "ói3pé", "óir3", "4óireo", "óisc3", "óist1", "óis5teo", "óis6té", "ó3itear", "ó3iteá.", "óit3é", "óits3", "6óiv", "ó5íní", "ól1", "óla5dá", "ó3l4e", "ó5l6é", "ó3l4i", "ó3l4í", "ó3mar", "óma3s4ó", "óm3at", "ómh4aí", "ó5mhao", "ómh5art", "ómh3as", "ómh3á", "ón1", "ón2as", "ón3as.", "óng2", "2ó1nn", "ó3n4o", "2óp1", "óp6al", "ó5p6é", "ór1", "6órais", "6óras", "ór4áid", "órg4", "ór4ma", "órós5", "órt2a", "ór6t5air", "ór4tá", "ós6aise", "ós5am", "ósar5", "ósarn6", "ósc3a", "ós3ó", "óst1", "ós6tr", "ós5u", "ós5ú", "óta1c4", "ót5aig", "ót3air", "ót1aí", "ót5a3m", "ótar3", "ót1á", "óth3á", "ót3ó", "ó3úl", "ó5yó", "p4aca", "p4acr", "pai5g6e", "pair4n3e", "paisi3", "pais3t6i", "4pall", "pana3m4", "pan6t5al", "pa3p4ó", "para5b6", "6parag", "parai3s4", "par3d4", "par3n4", "par2s3", "par6ta", "p6asam", "past4", "3p4at3", "páin4t5", "p1ál", "pás5", "p1c", "p5c6í", "4pe.", "peacht6", "peal5a", "peam6", "pea5mai", "6peann", "pear3", "pearn6", "pea3s4ó", "pea5st", "p4ei", "peil3b", "peilbh6", "pein6t", "4peir", "peir5t", "p4éid", "5péin", "péin6t", "péir6s", "p1f", "1p2h", "ph6a", "phais5t6i", "phana5m6", "phar5d6", "phar6s5", "phast6", "phat3r", "pháint5", "pheil3b", "pheilbh6", "phéin6t", "phéir6s", "ph4i", "phin6se.", "phion6t5", "phis5t6", "ph6l", "phlé5an", "phoin2", "phoint3", "phol5c6", "phonc5", "phór6t5a", "phós3", "phóst6", "phréach5", "phréacht6", "phróis5", "phuin4", "phun4t3", "phúit6", "6pias", "pic6s5", "pi3dé", "pid5i", "pi3le", "p3im", "pin6se.", "pion6t5", "pios5", "piost6", "pirim5", "p6irt", "pist3e", "pis3ti", "p6itei", "p4i3té", "pit3s", "6píl", "6píol", "3pís", "pí6t", "pít5i", "pla4", "4p3lag3", "p6lé", "pléacht6", "plé5am", "plé5an", "plé5igí", "plé5imi", "plim4", "pló3m6", "p1n", "pn6a", "poch5", "pocht6", "poin4", "point5", "poist5", "pol2ag", "pol4aim", "pol5c6", "pon4c3", "por3t4r", "post5ac", "pot3", "5p6ór", "pór4t3a", "pós3", "póst4", "pót3", "praoi5", "préach5", "préacht6", "pré5ad6", "pré5am", "pré5id", "pré5imi", "pré5itea", "pré5ití", "próis5", "p1s", "ps4a", "p6sa.", "psain6", "ps5ean", "p5s6im", "p5sis", "p1t", "p4te.", "pt3ean", "pth4", "pt4ig", "pt3is", "6pu.", "puin2", "pun4", "punt3", "6p6us", "púin4", "púins5", "púit6", "rabh5t6", "ra3bó", "rad5ón", "raf3", "ra3g4á", "ragh4", "raghs5", "rag5o", "6raicn", "raimh4", "rai3mhí", "raimp3", "rain4", "rainc3", "rain5tí", "rais4eol", "rais3t4", "rait3é", "rait5s", "ra5l6aíc", "ra3l4aío", "r6alan", "ra3l4ú", "rama5dac", "rama5daí", "ra3mat", "ra3n4am", "ra5n6óm", "ran4t3á", "rant4ó", "4raob", "4raol", "4rap", "ra3p4ó", "6rasn", "ras1t4", "rata6m", "ra3tá", "ra5té", "rat3óg", "ra3tr", "rábh4ail", "rách5a", "r6áini", "rá3iteá", "rá3ínt", "rb3ac4", "rba3cá", "rb3adh", "r3bair", "rb5ais.", "r5bait", "rb3am", "rb3ann", "r1bar", "rb3as", "rb5a5tr", "r4be", "rb3ea", "rbh3as", "rbh6at", "rbhá5cha", "rbh3án", "r6bh5eas", "r2bh3eo", "r5bhia", "rbh3in", "r6bh5is", "r4bh3it", "rbh5íd", "rbh3íg", "rbh3ío", "rbh3ít", "r2bh1l", "r3bhr", "rbh5uis", "r4b3ia", "rb5is", "rb3l", "r1br", "rb4rí", "r3bú", "rc1a", "r3cais", "rca3s4", "rc1e", "r4c3é", "r1ch", "rch3ac", "rcha3d6", "rchar5t6", "rch4á", "rch6i", "rch5la.", "rch6n", "rch3ra", "r2c1i", "rc4int", "r5cisi", "r5c6isí", "rc1l", "r4cm", "rc3n", "r6cra.", "rc3rá", "rc3s", "rc5ú", "rd1a", "r6d5acht", "rd6air", "r5d6ao", "r5d6ar", "r2d1e", "rd3é", "r1dh4", "rdhó5ití", "r2d1i6", "rdin5é", "r4dí.", "r6d5íd", "r6d5íg", "r4dím", "r6d5ínn", "r4d3ío", "r4dít", "rd3l", "r6dn", "rd5oid", "rd1ó", "r2d3r", "r3d4ré", "r6ds", "r4dt", "rd3u", "rd3ú", "r5d6úin", "r5d4ún", "reag3r", "reas2t", "reast5a", "rea3tá", "reá3ir", "reic5t6", "reo3dó", "reo5ite.", "reo1m", "ré5adh", "réal5a", "réal2t", "ré5ann.", "r6éas", "ré5ife", "réig3", "ré5igí", "réi5mír", "r6éith", "r1f", "rf5eol", "rga5dá", "r3g4as", "r4gd", "r3gead", "rg5eam", "rg5ean4", "rg3eas", "r4g3é", "r1gh6", "rghair5", "rghin5", "r2gi", "r3gint", "r2gí", "r4g1l", "r5góit", "r5gót", "r1gr", "r4g3ru", "r4gs", "r3gú", "r3ha", "riach3", "riacht4", "rias4t5", "4riat", "ribh6i", "ri3ch4", "ridh4", "rid3i", "4righn", "ri5gin", "4rih", "ri5lei", "rin2", "rinc1", "ri3né", "rins3iú", "rint3é", "rion2t3", "rios3t4", "rip4te", "rir4", "ri5rí", "ris3c4é", "ris1t4", "ri3ta", "ri3té", "rit5éa", "rit5éir", "ri5tr", "ríbh3", "rí2c", "rí6ch5e", "rí5chí", "rí3ocht", "río5mhar", "rír2", "rí6the", "rí6thi", "r1l", "rla5m6án", "rleat6", "rlé5ama", "rlé5an", "rlé5igí", "rlé5imi", "r4lg", "rlin6", "r1m2ad", "r5m6ain", "rm6air", "rm3al", "r3man", "r2me", "r3measc", "r1mh6", "r4mig", "rm4il", "r4mim", "r5m6isi", "r4mit", "r2miú", "r2mí", "r4ml", "r4mo", "r3mós", "r4ms", "r4m3u", "rm3ú", "r3n4aca", "r3n4ap", "r3nád", "r3nás", "r6n5eam", "rn5eáilt", "rn3eál", "r4neálf", "rn5eoire", "r4nf", "rn3g", "rn2i", "r6n5ia", "rn5id", "rn3iú", "rn4íne", "rn6íni", "r3no", "rn1ó", "r5n6óin.", "r5n6ón", "rn3ú", "ro4c", "rof5", "roi4", "4roid", "roim3é", "2roí", "r4ol", "rom4p3a", "rost3ac", "rost5al", "rost3á", "rost6ór", "rób4", "4róc", "ró6f", "rói6", "róist5", "4róit", "ró5l6an", "4róm", "rómh5ai", "rómh5ar", "rós6tá", "rót1", "rót5a", "r5pa.", "r5paí", "rp3ar", "r3pán", "r4p3e", "r4p3i", "r6p5óg.", "r5póga", "rp1r", "r2r1", "rra3chó", "rra3l", "rran4", "rrbh4", "rrc4", "rr5d", "rrt4", "r1s2", "rs6ain", "r5san", "rs6áin", "r5s6án", "rsc2á", "r2scn", "r6s3ead", "r4sf", "rshlua5", "rs3im", "rt1a", "rt4agá", "r5t6ail", "rt6ainí", "r3tair.", "rt5aío", "r3t4al", "r3tana", "r1tar", "rt6asó", "rt1á", "r5tá.", "r4tc", "r2te", "rt3eac", "rt5eag", "rt3eam", "rt3ean", "r3t4ear", "r3t4eá.", "r1th2", "rtha3t", "rthéad6", "rthé5id", "rthé5igí", "rthé5imi", "rthé5itea", "rthé5ití", "r2t1i", "r3t4il", "rti3s4", "r2tí", "r4t5l", "r4to", "rt1ó", "rt1r", "r6ts", "rt3u", "rt3úc", "r3túi", "rt5úil", "r6t5úl", "r5túm", "r1tún", "rua5b", "ruad6", "rua3da", "ruai6", "rua3imi", "rua5itear", "ruch3t4ó", "r4ud", "rusc3a", "rus3c4á", "rus4t5", "rúch6t5", "4rúd", "rú3d4ar.", "rú3idí", "rú1im", "r5úine", "rú3inn", "rú3itea", "rú5ití.", "r1úl", "rú3mar", "rúst3a", "r3wi", "s1a", "sa3bá", "sa5c6as", "sa3dá", "sa3fó", "sa5fr", "sa3g4á", "saigh6d5", "sail5b", "sain6t5e", "sair5d6", "s6aisí", "saist3e", "sa3l4ain", "sa3lan", "sal5at", "5salám", "salt3", "s6a5mat", "s2amh", "s6ams", "3s4an.", "san2á", "sant4", "5s6ao.", "sar3b", "sar5c", "s4arl", "sa3r4ó", "s6at.", "sat5a", "sa5tá", "sat5ra", "s6ats", "s1á", "s6áili", "sá5inn.", "sáin6t", "sá5ite.", "sá5iteá.", "s1b", "sb6a", "sbh6", "sbheir5", "6sc.", "sca6b", "scach6", "sca5chá", "s3c4ae", "s3c4aird", "sc6ao", "sc3ar3n4", "s5cat", "scáin5t", "s3cear", "sc1eo", "s3c4eog", "s5c6eoig", "sc4éim", "s1ch4", "3scia", "s6cig", "sc1im", "3scior", "sc3it", "sc3iúil", "2sc1í", "s6cí.", "sc1n", "scoir5", "s4cor", "scor3b4", "s3có.", "s6cói", "3scóip", "s3cól", "1scóp", "s3cós", "sc3raí", "s1cré", "scréach5", "scréacht6", "1scrí", "sc1ró", "sc3um4", "sc3úc", "s3cún", "s1d", "seach6t5a", "6seag", "s5eagá", "5seai", "seal5a", "seal6b", "sealbh5", "sealt6", "seana6", "seanad5", "sean5m", "s5eanna.", "seas5t", "s4eat", "5seáib", "s6eic", "seic6t", "seift5", "seil6f", "seir4f3", "seit5s", "6seo.", "seod3", "séalt6", "séar3", "séir4s5", "s1f", "s3fe", "3s4féa", "3s4féir", "sfhear5", "s3fi", "s1g", "sghair5t", "1sh2", "shaigh6d5", "shail5b", "shair5d6", "shant6", "shar5", "shá5ite.", "shá5iteá.", "shá5ití", "sheach6t5a", "sheal5a", "shean5m", "shearbh5", "sheas5t", "sheic4t", "sheil6f", "sheir6f3", "sheit5s", "shéa5l6ain", "shéir6s", "shib5é", "ship5", "shiún4", "shiúnt3", "shí5bh", "shí6l5", "shí4o", "shí6t", "shlios5", "shlíod5", "shní5d", "shní5g", "shní5m", "shní5od", "shní5oma", "shní5on", "shnua5", "sho5chaid", "sho5gh", "sho3mh6", "shor4", "shorb5", "sho5th", "shó5f", "shó5idí", "shó5im", "shó5inn", "shó5ití", "shó5mh", "shua6i", "shua3l6", "shú5c", "shúch6", "shú5d6ar", "shú5im.", "shú5in", "shú5ití.", "shú5mar", "shús5", "s1ia", "siach6", "siacht5", "sia5it", "si5be", "sib5é", "s1ic", "s1id", "sidh6", "6sif", "si3f4é", "s5i5fr", "s1ig", "si5g6é", "s6ilea", "s4ilf", "s6iligí", "s4ilt", "s1im", "simea5", "s4imé", "5s6ing", "sin6í", "s4int", "sint5iú", "sios5t6", "sis3", "sis6c", "sist4", "s1iú", "6siúd", "5s6iúit", "siúr5", "5siút", "sí3bh", "síl3", "3s4íle", "s5ímea", "síol5", "síoll6", "sí4th5", "s1l", "sla4", "slac5á", "slag3á", "slag3ó", "s4láin", "s6lán", "sleá5d6", "sléach6", "sléacht5", "slíod5ó", "slí6t", "s1m2", "sma5la", "smeach5", "smeacht6", "smead5", "smear5", "smeart6", "smeá6", "smh4", "sm6i", "s1n2", "snit4", "s3nó", "snua5", "sobh6", "so5chaid", "soch6t5", "sod3", "sof3a", "so5gh", "soir6bh", "so5lái", "so3mh4", "so5nu", "sorb5", "sor4c", "sorch5", "so5th6", "s1óf", "s1óg", "sóin4", "3s4óin.", "s6óine", "s6óiní", "só5ití", "só5l6ain", "só5l6an", "só5mh", "3s4ón", "só5tac", "só5t6aí", "s1p", "spad5a", "spad5á", "spair4n5", "s6p5ann", "speach5", "spi6d", "spor5", "sport6", "spór6", "sprae5", "spuir6", "s1r", "sr6ú", "6st.", "sta5dá", "s1tag", "stai6", "st3aig", "staist5", "st1aí", "s1tal", "st5ama", "st3as", "stáin6", "5stáit", "5stát3", "st5eann", "4steo", "s1té", "3stéig", "s4téin", "6sti.", "s3tice", "s5ticig", "s5tile.", "st1im", "s6tio", "s3t4ir", "st6ise", "st3ith", "s3t4íc", "s3t4ís", "s3tóg", "s1tr", "strae5", "s4trala", "st6u", "s3t6úin", "sua6i", "sua3l4", "sú5c", "súch6", "s6úd", "sú5d6ar", "s4úf", "s6úig", "sú5im.", "sú5inn", "s4úit", "sú5ite.", "sú5ití.", "sú5mar", "s1ún", "sús5", "sv4a", "ta4cha", "tach6tá", "ta3cr", "ta5dái", "t3adh.", "tae5n", "3t4aga", "ta3g4á", "tag5á5l", "tagh4", "taghd3", "ta1gó", "5t6aig.", "5t6aige", "3t4ainia", "tain4t3", "tair2b", "tairbh3", "tair6g3", "tair2n3", "taisc5e", "tais5tear", "tais5teá", "taist5il", "tais5tí", "tai3té", "t5aití", "ta4l5a", "tal6c5", "t4all", "6t5a5l6úin", "6talún", "tam4al", "ta5m6ái", "ta3mán", "5tanb", "tan3gó", "t3ann", "4tanna.", "t6annac", "t6annai", "ta5no", "tan4t3", "ta5p6l", "t2ar", "tar1c2", "tar5d6", "tar3g4", "tart4a", "tar5ta.", "ta3s4l", "ta3s4t", "tas5tr", "3t4at", "5tata", "4ta3to", "tat5ú", "3tá.", "tá6d5", "t1áil", "tá6im.", "táir4s3", "táir5t", "t6áit", "t3áiv", "2t1ál", "3t4ás", "t6át", "tá5th6ar", "t1b", "tbh6", "t1c", "t3dh", "3teab", "t3ead", "tea5fa", "tea3g4á", "tea3gr", "t3eal.", "t3eala", "tea5lain", "tea3lan", "t3ealó", "t5ealt", "tea3m4á", "t4eamo", "5teanú", "t2ear", "t3ear3n4", "teas2t5", "teá6", "t1eái", "t1eál", "teám5", "1tei", "t1eo", "5t4eoc", "téach6", "téacht5", "téal2", "téa3la", "téar5t6", "4téig", "té6igh", "4t3éirs", "t4éit", "2t1f", "t1g", "t2h", "4th.", "t6ha", "6thab", "thach6t5", "thagh4", "thaghd3", "thair4b", "thairbh5", "thair6g", "thair6is.", "thair4n", "thairn5e", "thaist5", "th5am.", "than3g", "than2t3", "tha6p5", "tharc6", "thar5g6", "thar3n4", "5tharr", "thar5t6a", "tháin5", "tháir5t", "t4he", "thead5as", "thea3la", "theas4t5", "6theá", "th5eán", "t6hé", "théach6", "théacht5", "théal2", "théa3la", "thé3if", "th1f", "th5in.", "thin6i", "thit3e", "thí6f5", "thío5t", "th6ís", "th1l", "thlua5da", "th5nó", "5thoin6", "thoir4n3", "3thon", "thor4c", "thor5pá", "thost5", "thóch5", "5thógt", "thóir6se", "thóir6sí", "thós4", "thrá5b", "thrá5inn", "thrí3oc", "thros6", "4ths", "thua5da", "thua5im", "thua5itea", "thuar5", "5thuig", "3thur", "thu5sa", "6ti.", "tia5g", "6t5iam", "t1ib2", "tib5é", "tib6éar", "ti1bi", "t1id4", "ti3dé", "ti3di", "ti3f4", "t1ig", "5t6ige", "t3ileo", "t3ilí", "4tilít", "t5ilt", "4t3i1m4é", "ti5míne", "ti5míni", "tin6d5", "t3inea", "t3ini", "t3iní", "tin5t4", "tipi5c6", "tir4i", "tis3", "t3ist6", "tit5ea", "tit5eá", "6t5iteo", "ti5té", "ti3tiú", "t1iú.", "t3iúl", "3tiún", "t1í", "tí4f3", "tíg5", "3t2íl1", "5t6íol", "5tíop", "5tíor", "tío5t6", "3t4íp", "5tír", "6t5íteas", "6t5íti", "2t1l", "t1m", "tm4a", "tm6e", "tm6i", "2t1n2", "t5ne", "t5ní", "tod5ó", "tof5", "6toid", "toin6", "toir2n3", "tom6a", "tor2c", "torch3", "tor3p", "tort5a", "tos6t3", "tóch5", "t1óf", "3tóip", "tóir6se", "tóir6sí", "3tól", "3tóp", "1tós4", "tra6bó", "trac6", "6tra5cá", "trai6m5", "4traip", "6traláib", "t3rar", "trá5b", "trá5inn", "t6ráis", "t4rát", "tream4", "trea3ma", "triach6", "tri3ghn", "trí1r", "tros6", "trost5", "3tróp", "t4ru", "truac4", "trua3cá", "tr6ú", "t6rús", "ts2", "t5sa", "t6sai", "tsa6l", "tsal5a", "tsal6v5", "t1s4ea", "t6sean", "tsearbh5", "t3seo", "t3si", "tsi6m5", "tsiún6", "tsiúnt5", "t1sí", "t3su", "t3sú", "tua5da", "tua5itea", "tuar5", "tuis3", "tuío3", "tur3b", "tur3n4", "t5úid", "tú3m6", "3tús3", "t3vi", "uabh6r", "ua3chl", "uad3á", "ua1f2", "ua6fa.", "6uaid", "ua3idí", "uai5g6é", "ua3igí.", "ua3imid", "ua3imis", "ua3inn.", "uains6", "uain5t4", "uair3c4í", "uairn6", "uair5tí", "uais1", "uaist2", "ua3iteá", "uaith6i5s", "ua3ití.", "uait5s", "uala5t", "ualath6", "ual3g4", "ua3lu", "ua3mar", "uamh6ar", "ua3mhé", "uana5l6", "5uanla", "ua5nós", "uar3g4", "uart4", "uar5tai", "uar5taí.", "uar5tan", "ub1a", "ub5á", "ubh1", "uc1a", "uch1a", "uch3á", "uch3ó", "uch3r", "uc5l", "uc3r", "uc3s", "uc5ú", "ud1", "uf1", "uga5dá", "ug3l", "uic6i5s", "uid1", "uifé5", "6uig3", "uil3p", "ui4m", "uim3p", "uin5c", "uins3iú", "uin3t4", "uint5í", "uin6tín", "ui6p5", "uir5b4", "uirbh6", "uir3c4í", "4uire", "uirn6", "6uirs", "uirs3t", "uir3t", "uirt4í", "ui6s", "uis3cr", "uis5t", "uit3é", "uit3s", "uí3b", "uí3d", "uí1g", "uí5l6e", "uí1m", "uí1od", "uío3dó", "uí3oma", "uí3onn", "uí3ó", "uí5teá", "uíth6", "uí5tí", "ul1a", "ul3á", "ul3g4", "ul3m4", "ul3ó", "ul5p6", "ul6t5as", "ul4tr", "um1a", "umh1", "ump1", "un5a", "un3á", "unc1a", "un5e", "ung1", "un5ga3l", "un3g4ar", "un5gá", "un3o", "un1ó", "un6sa.", "un6s5aí", "un3ú", "unúd4", "uó3t6", "up1", "4ur1a", "urach3", "ur6ag", "ur3á", "urca3m4", "urch4", "ur3d6ú", "urg5ói", "ur5gón", "ur3i", "ur6l3ál", "ur3m4", "6urn", "ur3ó", "ur3p", "urscar6", "urscart5", "ur3t4", "ur5u", "ur3ú", "6us.", "usc5ai", "usc3l", "us3cr", "ust5ac", "ust5ail", "us4t3al", "us3tó", "us5tu", "ust5ún", "ut5a", "u6t5á", "ut3e", "uth1", "uthan5t", "ut3ó", "uz3a", "ú5an", "ú1á", "ú4áil.", "úb1", "úba5dá", "úbail4", "úb4h", "úbh5a", "úc1a", "úca3b", "úcas4t", "úch1a", "ú1ch2á", "ú3che", "ú3chí", "úch5l", "úch5óg", "ú5chr", "úcht4ó", "úc1l", "úc1ó", "úc1r", "úc4rá", "úd1", "ú6dó", "úd5r", "úd5ú", "ú1f", "ú6fó", "ú1gh", "úg1r", "4úid", "ú3idís", "ú3igí", "6úile", "6úili", "úil4t3", "ú3imi", "úint4", "úirt3", "úir2té", "úisc3", "úis3c4é", "ú5itear", "ú3iteá.", "úithi5s", "ú6itín", "úits3eá", "úl1", "ú3l4ag", "ú4l5agá", "úlc4", "ú5l6e", "úl6éim", "ú3l4i", "6úlr", "últ4", "ú3l4ua", "úl5ú", "úlú5l", "ú1mh", "úmh3ac", "ú4mhn", "ú4mh3ú", "ún5a", "ún3á", "úng5á", "úng5u", "6únl", "4ú1nn", "ún3o", "ún1ó", "ún3t2", "úp1", "ú6p5a", "úpa5t6", "ú5p6r", "úr1", "úra3b", "úrabh4", "úra3dá", "úran6", "úr6ana", "úr5ó", "úrt4", "ú3r6u", "úr4ú", "ú5rúi", "ús4air", "ús2á", "ús5án", "úsc1", "ú4sh3l", "ú3s4m", "ús3ó", "ú3s4pé", "ú3sto", "úst3ó", "ús6t3r", "ús3ú", "út3a", "ú6t1á", "úth1", "ú3tho", "út5óg", "út1r", "ú5úi", "ú5úl", "v1a", "vach6", "vac3s4", "v4ad", "vais5", "vaisc6", "var5", "vard6", "3v4at", "v1á", "vean6", "veant5", "vear3", "vearn6", "3v4ei", "veil5b", "v3eo", "véar6", "véis5", "véist6", "5v6ial", "3v4ini", "vios5", "vir5", "virg6", "v6íc", "v3la", "3vol4", "volt3", "vuít5", "x3ac", "x5ai", "x5aí", }; SILE.hyphenator.languages["ga"].exceptions = { "bhrachtaí", "mbrachtaí", "cháintí", "gcáintí", "cheiltí", "gceiltí", "chistí", "gcistí", "choirtí", "gcoirtí", "chreataí", "gcreataí", "dhoirteá", "dhoirtear", "dhoirtí", "doirtear", "ndoirteá", "ndoirtear", "ndoirtí", "bhfuadar", "fhuadar", "bhfuafar", "fhuafar", "fuafar", "ghaistí", "ngaistí", "ghealtaí", "ngealtaí", "ghortaí", "ngortaí", "haistí", "léamar", "luadar", "meataí", "mheataí", "réaltaí", "rífear", "sádar", "shádar", "sáimis", "sháimis", "sáfaí", "sháfaí", "spealta", "dtiom-áintí", "thiom-áintí", };
mit
zwhfly/openwrt-luci
applications/luci-radvd/luasrc/model/cbi/radvd/interface.lua
78
7996
--[[ LuCI - Lua Configuration Interface Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id$ ]]-- local sid = arg[1] local utl = require "luci.util" m = Map("radvd", translatef("Radvd - Interface %q", "?"), translate("Radvd is a router advertisement daemon for IPv6. " .. "It listens to router solicitations and sends router advertisements " .. "as described in RFC 4861.")) m.redirect = luci.dispatcher.build_url("admin/network/radvd") if m.uci:get("radvd", sid) ~= "interface" then luci.http.redirect(m.redirect) return end m.uci:foreach("radvd", "interface", function(s) if s['.name'] == sid and s.interface then m.title = translatef("Radvd - Interface %q", s.interface) return false end end) s = m:section(NamedSection, sid, "interface", translate("Interface Configuration")) s.addremove = false s:tab("general", translate("General")) s:tab("timing", translate("Timing")) s:tab("mobile", translate("Mobile IPv6")) -- -- General -- o = s:taboption("general", Flag, "ignore", translate("Enable")) o.rmempty = false function o.cfgvalue(...) local v = Flag.cfgvalue(...) return v == "1" and "0" or "1" end function o.write(self, section, value) Flag.write(self, section, value == "1" and "0" or "1") end o = s:taboption("general", Value, "interface", translate("Interface"), translate("Specifies the logical interface name this section belongs to")) o.template = "cbi/network_netlist" o.nocreate = true o.optional = false function o.formvalue(...) return Value.formvalue(...) or "-" end function o.validate(self, value) if value == "-" then return nil, translate("Interface required") end return value end function o.write(self, section, value) m.uci:set("radvd", section, "ignore", 0) m.uci:set("radvd", section, "interface", value) end o = s:taboption("general", DynamicList, "client", translate("Clients"), translate("Restrict communication to specified clients, leave empty to use multicast")) o.rmempty = true o.datatype = "ip6addr" o.placeholder = "any" function o.cfgvalue(...) local v = Value.cfgvalue(...) local l = { } for v in utl.imatch(v) do l[#l+1] = v end return l end o = s:taboption("general", Flag, "AdvSendAdvert", translate("Enable advertisements"), translate("Enables router advertisements and solicitations")) o.rmempty = false function o.write(self, section, value) if value == "1" then m.uci:set("radvd", section, "ignore", 0) m.uci:set("radvd", section, "IgnoreIfMissing", 1) end m.uci:set("radvd", section, "AdvSendAdvert", value) end o = s:taboption("general", Flag, "UnicastOnly", translate("Unicast only"), translate("Indicates that the underlying link is not broadcast capable, prevents unsolicited advertisements from being sent")) o:depends("AdvSendAdvert", "1") o = s:taboption("general", Flag, "AdvManagedFlag", translate("Managed flag"), translate("Enables the additional stateful administered autoconfiguration protocol (RFC2462)")) o:depends("AdvSendAdvert", "1") o = s:taboption("general", Flag, "AdvOtherConfigFlag", translate("Configuration flag"), translate("Enables the autoconfiguration of additional, non address information (RFC2462)")) o:depends("AdvSendAdvert", "1") o = s:taboption("general", Flag, "AdvSourceLLAddress", translate("Source link-layer address"), translate("Includes the link-layer address of the outgoing interface in the RA")) o.rmempty = false o.default = "1" o:depends("AdvSendAdvert", "1") o = s:taboption("general", Value, "AdvLinkMTU", translate("Link MTU"), translate("Advertises the given link MTU in the RA if specified. 0 disables MTU advertisements")) o.datatype = "uinteger" o.placeholder = 0 o:depends("AdvSendAdvert", "1") o = s:taboption("general", Value, "AdvCurHopLimit", translate("Current hop limit"), translate("Advertises the default Hop Count value for outgoing unicast packets in the RA. 0 disables hopcount advertisements")) o.datatype = "uinteger" o.optional = false o.placeholder = 64 o:depends("AdvSendAdvert", "1") o = s:taboption("general", ListValue, "AdvDefaultPreference", translate("Default preference"), translate("Advertises the default router preference")) o.optional = false o.default = "medium" o:value("low", translate("low")) o:value("medium", translate("medium")) o:value("high", translate("high")) o:depends("AdvSendAdvert", "1") -- -- Timing -- o = s:taboption("timing", Value, "MinRtrAdvInterval", translate("Minimum advertisement interval"), translate("The minimum time allowed between sending unsolicited multicast router advertisements from the interface, in seconds")) o.datatype = "uinteger" o.optional = false o.placeholder = 198 o:depends("AdvSendAdvert", "1") o = s:taboption("timing", Value, "MaxRtrAdvInterval", translate("Maximum advertisement interval"), translate("The maximum time allowed between sending unsolicited multicast router advertisements from the interface, in seconds")) o.datatype = "uinteger" o.optional = false o.placeholder = 600 o:depends("AdvSendAdvert", "1") o = s:taboption("timing", Value, "MinDelayBetweenRAs", translate("Minimum advertisement delay"), translate("The minimum time allowed between sending multicast router advertisements from the interface, in seconds")) o.datatype = "uinteger" o.optional = false o.placeholder = 3 o:depends("AdvSendAdvert", "1") o = s:taboption("timing", Value, "AdvReachableTime", translate("Reachable time"), translate("Advertises assumed reachability time in milliseconds of neighbours in the RA if specified. 0 disables reachability advertisements")) o.datatype = "uinteger" o.optional = false o.placeholder = 0 o:depends("AdvSendAdvert", "1") o = s:taboption("timing", Value, "AdvRetransTimer", translate("Retransmit timer"), translate("Advertises wait time in milliseconds between Neighbor Solicitation messages in the RA if specified. 0 disables retransmit advertisements")) o.datatype = "uinteger" o.optional = false o.placeholder = 0 o:depends("AdvSendAdvert", "1") o = s:taboption("timing", Value, "AdvDefaultLifetime", translate("Default lifetime"), translate("Advertises the lifetime of the default router in seconds. 0 indicates that the node is no default router")) o.datatype = "uinteger" o.optional = false o.placeholder = 1800 o:depends("AdvSendAdvert", "1") -- -- Mobile -- o = s:taboption("mobile", Flag, "AdvHomeAgentFlag", translate("Advertise Home Agent flag"), translate("Advertises Mobile IPv6 Home Agent capability (RFC3775)")) o:depends("AdvSendAdvert", "1") o = s:taboption("mobile", Flag, "AdvIntervalOpt", translate("Mobile IPv6 interval option"), translate("Include Mobile IPv6 Advertisement Interval option to RA")) o:depends({AdvHomeAgentFlag = "1", AdvSendAdvert = "1"}) o = s:taboption("mobile", Flag, "AdvHomeAgentInfo", translate("Home Agent information"), translate("Include Home Agent Information in the RA")) o:depends({AdvHomeAgentFlag = "1", AdvSendAdvert = "1"}) o = s:taboption("mobile", Flag, "AdvMobRtrSupportFlag", translate("Mobile IPv6 router registration"), translate("Advertises Mobile Router registration capability (NEMO Basic)")) o:depends({AdvHomeAgentInfo = "1", AdvSendAdvert = "1"}) o = s:taboption("mobile", Value, "HomeAgentLifetime", translate("Home Agent lifetime"), translate("Advertises the time in seconds the router is offering Mobile IPv6 Home Agent services")) o.datatype = "uinteger" o.optional = false o.placeholder = 1800 o:depends({AdvHomeAgentInfo = "1", AdvSendAdvert = "1"}) o = s:taboption("mobile", Value, "HomeAgentPreference", translate("Home Agent preference"), translate("The preference for the Home Agent sending this RA")) o.datatype = "uinteger" o.optional = false o.placeholder = 0 o:depends({AdvHomeAgentInfo = "1", AdvSendAdvert = "1"}) return m
apache-2.0
anshkumar/yugioh-glaze
assets/script/c97024987.lua
3
1907
--イグナイト・ドラグノフ function c97024987.initial_effect(c) --pendulum summon aux.AddPendulumProcedure(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) --tohand local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_DESTROY+CATEGORY_TOHAND+CATEGORY_SEARCH) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_PZONE) e2:SetCondition(c97024987.thcon) e2:SetTarget(c97024987.thtg) e2:SetOperation(c97024987.thop) c:RegisterEffect(e2) end function c97024987.thcon(e,tp,eg,ep,ev,re,r,rp) local seq=e:GetHandler():GetSequence() local pc=Duel.GetFieldCard(tp,LOCATION_SZONE,13-seq) return pc and pc:IsSetCard(0xc8) end function c97024987.filter(c) return c:IsRace(RACE_WARRIOR) and c:IsAttribute(ATTRIBUTE_FIRE) and c:IsAbleToHand() end function c97024987.thtg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() local pc=Duel.GetFieldCard(tp,LOCATION_SZONE,13-c:GetSequence()) if chk==0 then return c:IsDestructable() and pc:IsDestructable() and Duel.IsExistingMatchingCard(c97024987.filter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,nil) end local g=Group.FromCards(c,pc) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,2,0,0) Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK+LOCATION_GRAVE) end function c97024987.thop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) then return end local pc=Duel.GetFieldCard(tp,LOCATION_SZONE,13-c:GetSequence()) if not pc then return end local dg=Group.FromCards(c,pc) if Duel.Destroy(dg,REASON_EFFECT)~=2 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c97024987.filter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,1,nil) if g:GetCount()>0 and not g:GetFirst():IsHasEffect(EFFECT_NECRO_VALLEY) then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c71408082.lua
3
2075
--黒竜の聖騎士 function c71408082.initial_effect(c) c:EnableReviveLimit() --destroy local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetCode(EVENT_BATTLE_START) e1:SetCondition(c71408082.descon) e1:SetTarget(c71408082.destg) e1:SetOperation(c71408082.desop) c:RegisterEffect(e1) --spsummon local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1,71408082) e2:SetCost(c71408082.spcost) e2:SetTarget(c71408082.sptg) e2:SetOperation(c71408082.spop) c:RegisterEffect(e2) end function c71408082.descon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetAttackTarget() return tc and tc~=c and tc:IsDefencePos() end function c71408082.destg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end local tc=Duel.GetAttackTarget() Duel.SetOperationInfo(0,CATEGORY_DESTROY,tc,1,0,0) end function c71408082.desop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetAttackTarget() if tc:IsRelateToBattle() then Duel.Destroy(tc,REASON_EFFECT) end end function c71408082.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsReleasable() end Duel.Release(e:GetHandler(),REASON_COST) end function c71408082.spfilter(c,e,tp) return c:IsSetCard(0x3b) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c71408082.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1 and Duel.IsExistingMatchingCard(c71408082.spfilter,tp,LOCATION_DECK+LOCATION_HAND,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK+LOCATION_HAND) end function c71408082.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c71408082.spfilter,tp,LOCATION_DECK+LOCATION_HAND,0,1,1,nil,e,tp) if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end
gpl-2.0
freifunk-gluon/luci
contrib/luadoc/lua/luadoc/taglet/standard.lua
93
16319
------------------------------------------------------------------------------- -- @release $Id: standard.lua,v 1.39 2007/12/21 17:50:48 tomas Exp $ ------------------------------------------------------------------------------- local assert, pairs, tostring, type = assert, pairs, tostring, type local io = require "io" local posix = require "nixio.fs" local luadoc = require "luadoc" local util = require "luadoc.util" local tags = require "luadoc.taglet.standard.tags" local string = require "string" local table = require "table" module 'luadoc.taglet.standard' ------------------------------------------------------------------------------- -- Creates an iterator for an array base on a class type. -- @param t array to iterate over -- @param class name of the class to iterate over function class_iterator (t, class) return function () local i = 1 return function () while t[i] and t[i].class ~= class do i = i + 1 end local v = t[i] i = i + 1 return v end end end -- Patterns for function recognition local identifiers_list_pattern = "%s*(.-)%s*" local identifier_pattern = "[^%(%s]+" local function_patterns = { "^()%s*function%s*("..identifier_pattern..")%s*%("..identifiers_list_pattern.."%)", "^%s*(local%s)%s*function%s*("..identifier_pattern..")%s*%("..identifiers_list_pattern.."%)", "^()%s*("..identifier_pattern..")%s*%=%s*function%s*%("..identifiers_list_pattern.."%)", } ------------------------------------------------------------------------------- -- Checks if the line contains a function definition -- @param line string with line text -- @return function information or nil if no function definition found local function check_function (line) line = util.trim(line) local info = table.foreachi(function_patterns, function (_, pattern) local r, _, l, id, param = string.find(line, pattern) if r ~= nil then return { name = id, private = (l == "local"), param = { } --util.split("%s*,%s*", param), } end end) -- TODO: remove these assert's? if info ~= nil then assert(info.name, "function name undefined") assert(info.param, string.format("undefined parameter list for function `%s'", info.name)) end return info end ------------------------------------------------------------------------------- -- Checks if the line contains a module definition. -- @param line string with line text -- @param currentmodule module already found, if any -- @return the name of the defined module, or nil if there is no module -- definition local function check_module (line, currentmodule) line = util.trim(line) -- module"x.y" -- module'x.y' -- module[[x.y]] -- module("x.y") -- module('x.y') -- module([[x.y]]) -- module(...) local r, _, modulename = string.find(line, "^module%s*[%s\"'(%[]+([^,\"')%]]+)") if r then -- found module definition logger:debug(string.format("found module `%s'", modulename)) return modulename end return currentmodule end -- Patterns for constant recognition local constant_patterns = { "^()%s*([A-Z][A-Z0-9_]*)%s*=", "^%s*(local%s)%s*([A-Z][A-Z0-9_]*)%s*=", } ------------------------------------------------------------------------------- -- Checks if the line contains a constant definition -- @param line string with line text -- @return constant information or nil if no constant definition found local function check_constant (line) line = util.trim(line) local info = table.foreachi(constant_patterns, function (_, pattern) local r, _, l, id = string.find(line, pattern) if r ~= nil then return { name = id, private = (l == "local"), } end end) -- TODO: remove these assert's? if info ~= nil then assert(info.name, "constant name undefined") end return info end ------------------------------------------------------------------------------- -- Extracts summary information from a description. The first sentence of each -- doc comment should be a summary sentence, containing a concise but complete -- description of the item. It is important to write crisp and informative -- initial sentences that can stand on their own -- @param description text with item description -- @return summary string or nil if description is nil local function parse_summary (description) -- summary is never nil... description = description or "" -- append an " " at the end to make the pattern work in all cases description = description.." " -- read until the first period followed by a space or tab local summary = string.match(description, "(.-%.)[%s\t]") -- if pattern did not find the first sentence, summary is the whole description summary = summary or description return summary end ------------------------------------------------------------------------------- -- @param f file handle -- @param line current line being parsed -- @param modulename module already found, if any -- @return current line -- @return code block -- @return modulename if found local function parse_code (f, line, modulename) local code = {} while line ~= nil do if string.find(line, "^[\t ]*%-%-%-") then -- reached another luadoc block, end this parsing return line, code, modulename else -- look for a module definition modulename = check_module(line, modulename) table.insert(code, line) line = f:read() end end -- reached end of file return line, code, modulename end ------------------------------------------------------------------------------- -- Parses the information inside a block comment -- @param block block with comment field -- @return block parameter local function parse_comment (block, first_line, modulename) -- get the first non-empty line of code local code = table.foreachi(block.code, function(_, line) if not util.line_empty(line) then -- `local' declarations are ignored in two cases: -- when the `nolocals' option is turned on; and -- when the first block of a file is parsed (this is -- necessary to avoid confusion between the top -- local declarations and the `module' definition. if (options.nolocals or first_line) and line:find"^%s*local" then return end return line end end) -- parse first line of code if code ~= nil then local func_info = check_function(code) local module_name = check_module(code) local const_info = check_constant(code) if func_info then block.class = "function" block.name = func_info.name block.param = func_info.param block.private = func_info.private elseif const_info then block.class = "constant" block.name = const_info.name block.private = const_info.private elseif module_name then block.class = "module" block.name = module_name block.param = {} else block.param = {} end else -- TODO: comment without any code. Does this means we are dealing -- with a file comment? end -- parse @ tags local currenttag = "description" local currenttext table.foreachi(block.comment, function (_, line) line = util.trim_comment(line) local r, _, tag, text = string.find(line, "@([_%w%.]+)%s+(.*)") if r ~= nil then -- found new tag, add previous one, and start a new one -- TODO: what to do with invalid tags? issue an error? or log a warning? tags.handle(currenttag, block, currenttext) currenttag = tag currenttext = text else currenttext = util.concat(currenttext, line) assert(string.sub(currenttext, 1, 1) ~= " ", string.format("`%s', `%s'", currenttext, line)) end end) tags.handle(currenttag, block, currenttext) -- extracts summary information from the description block.summary = parse_summary(block.description) assert(string.sub(block.description, 1, 1) ~= " ", string.format("`%s'", block.description)) if block.name and block.class == "module" then modulename = block.name end return block, modulename end ------------------------------------------------------------------------------- -- Parses a block of comment, started with ---. Read until the next block of -- comment. -- @param f file handle -- @param line being parsed -- @param modulename module already found, if any -- @return line -- @return block parsed -- @return modulename if found local function parse_block (f, line, modulename, first) local block = { comment = {}, code = {}, } while line ~= nil do if string.find(line, "^[\t ]*%-%-") == nil then -- reached end of comment, read the code below it -- TODO: allow empty lines line, block.code, modulename = parse_code(f, line, modulename) -- parse information in block comment block, modulename = parse_comment(block, first, modulename) return line, block, modulename else table.insert(block.comment, line) line = f:read() end end -- reached end of file -- parse information in block comment block, modulename = parse_comment(block, first, modulename) return line, block, modulename end ------------------------------------------------------------------------------- -- Parses a file documented following luadoc format. -- @param filepath full path of file to parse -- @param doc table with documentation -- @return table with documentation function parse_file (filepath, doc, handle, prev_line, prev_block, prev_modname) local blocks = { prev_block } local modulename = prev_modname -- read each line local f = handle or io.open(filepath, "r") local i = 1 local line = prev_line or f:read() local first = true while line ~= nil do if string.find(line, "^[\t ]*%-%-%-") then -- reached a luadoc block local block, newmodname line, block, newmodname = parse_block(f, line, modulename, first) if modulename and newmodname and newmodname ~= modulename then doc = parse_file( nil, doc, f, line, block, newmodname ) else table.insert(blocks, block) modulename = newmodname end else -- look for a module definition local newmodname = check_module(line, modulename) if modulename and newmodname and newmodname ~= modulename then parse_file( nil, doc, f ) else modulename = newmodname end -- TODO: keep beginning of file somewhere line = f:read() end first = false i = i + 1 end if not handle then f:close() end if filepath then -- store blocks in file hierarchy assert(doc.files[filepath] == nil, string.format("doc for file `%s' already defined", filepath)) table.insert(doc.files, filepath) doc.files[filepath] = { type = "file", name = filepath, doc = blocks, -- functions = class_iterator(blocks, "function"), -- tables = class_iterator(blocks, "table"), } -- local first = doc.files[filepath].doc[1] if first and modulename then doc.files[filepath].author = first.author doc.files[filepath].copyright = first.copyright doc.files[filepath].description = first.description doc.files[filepath].release = first.release doc.files[filepath].summary = first.summary end end -- if module definition is found, store in module hierarchy if modulename ~= nil then if modulename == "..." then assert( filepath, "Can't determine name for virtual module from filepatch" ) modulename = string.gsub (filepath, "%.lua$", "") modulename = string.gsub (modulename, "/", ".") end if doc.modules[modulename] ~= nil then -- module is already defined, just add the blocks table.foreachi(blocks, function (_, v) table.insert(doc.modules[modulename].doc, v) end) else -- TODO: put this in a different module table.insert(doc.modules, modulename) doc.modules[modulename] = { type = "module", name = modulename, doc = blocks, -- functions = class_iterator(blocks, "function"), -- tables = class_iterator(blocks, "table"), author = first and first.author, copyright = first and first.copyright, description = "", release = first and first.release, summary = "", } -- find module description for m in class_iterator(blocks, "module")() do doc.modules[modulename].description = util.concat( doc.modules[modulename].description, m.description) doc.modules[modulename].summary = util.concat( doc.modules[modulename].summary, m.summary) if m.author then doc.modules[modulename].author = m.author end if m.copyright then doc.modules[modulename].copyright = m.copyright end if m.release then doc.modules[modulename].release = m.release end if m.name then doc.modules[modulename].name = m.name end end doc.modules[modulename].description = doc.modules[modulename].description or (first and first.description) or "" doc.modules[modulename].summary = doc.modules[modulename].summary or (first and first.summary) or "" end -- make functions table doc.modules[modulename].functions = {} for f in class_iterator(blocks, "function")() do if f and f.name then table.insert(doc.modules[modulename].functions, f.name) doc.modules[modulename].functions[f.name] = f end end -- make tables table doc.modules[modulename].tables = {} for t in class_iterator(blocks, "table")() do if t and t.name then table.insert(doc.modules[modulename].tables, t.name) doc.modules[modulename].tables[t.name] = t end end -- make constants table doc.modules[modulename].constants = {} for c in class_iterator(blocks, "constant")() do if c and c.name then table.insert(doc.modules[modulename].constants, c.name) doc.modules[modulename].constants[c.name] = c end end end if filepath then -- make functions table doc.files[filepath].functions = {} for f in class_iterator(blocks, "function")() do if f and f.name then table.insert(doc.files[filepath].functions, f.name) doc.files[filepath].functions[f.name] = f end end -- make tables table doc.files[filepath].tables = {} for t in class_iterator(blocks, "table")() do if t and t.name then table.insert(doc.files[filepath].tables, t.name) doc.files[filepath].tables[t.name] = t end end end return doc end ------------------------------------------------------------------------------- -- Checks if the file is terminated by ".lua" or ".luadoc" and calls the -- function that does the actual parsing -- @param filepath full path of the file to parse -- @param doc table with documentation -- @return table with documentation -- @see parse_file function file (filepath, doc) local patterns = { "%.lua$", "%.luadoc$" } local valid = table.foreachi(patterns, function (_, pattern) if string.find(filepath, pattern) ~= nil then return true end end) if valid then logger:info(string.format("processing file `%s'", filepath)) doc = parse_file(filepath, doc) end return doc end ------------------------------------------------------------------------------- -- Recursively iterates through a directory, parsing each file -- @param path directory to search -- @param doc table with documentation -- @return table with documentation function directory (path, doc) for f in posix.dir(path) do local fullpath = path .. "/" .. f local attr = posix.stat(fullpath) assert(attr, string.format("error stating file `%s'", fullpath)) if attr.type == "reg" then doc = file(fullpath, doc) elseif attr.type == "dir" and f ~= "." and f ~= ".." then doc = directory(fullpath, doc) end end return doc end -- Recursively sorts the documentation table local function recsort (tab) table.sort (tab) -- sort list of functions by name alphabetically for f, doc in pairs(tab) do if doc.functions then table.sort(doc.functions) end if doc.tables then table.sort(doc.tables) end end end ------------------------------------------------------------------------------- function start (files, doc) assert(files, "file list not specified") -- Create an empty document, or use the given one doc = doc or { files = {}, modules = {}, } assert(doc.files, "undefined `files' field") assert(doc.modules, "undefined `modules' field") table.foreachi(files, function (_, path) local attr = posix.stat(path) assert(attr, string.format("error stating path `%s'", path)) if attr.type == "reg" then doc = file(path, doc) elseif attr.type == "dir" then doc = directory(path, doc) end end) -- order arrays alphabetically recsort(doc.files) recsort(doc.modules) return doc end
apache-2.0
anshkumar/yugioh-glaze
assets/script/c50920465.lua
3
2025
--ブリザード・サンダーバード function c50920465.initial_effect(c) --spsummon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(50920465,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1,50920465) e1:SetCost(c50920465.cost) e1:SetTarget(c50920465.target) e1:SetOperation(c50920465.operation) c:RegisterEffect(e1) end function c50920465.cfilter(c,e,tp) return c:IsDiscardable() and Duel.IsExistingMatchingCard(c50920465.filter,tp,LOCATION_HAND,0,1,c,e,tp) end function c50920465.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c50920465.cfilter,tp,LOCATION_HAND,0,1,nil,e,tp) end Duel.DiscardHand(tp,c50920465.cfilter,1,1,REASON_COST+REASON_DISCARD,nil,e,tp) end function c50920465.filter(c,e,tp) return c:IsRace(RACE_WINDBEAST) and c:IsAttribute(ATTRIBUTE_WATER) and not c:IsCode(50920465) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and not c:IsHasEffect(EFFECT_NECRO_VALLEY) end function c50920465.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>1 and Duel.IsExistingMatchingCard(c50920465.filter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,2,tp,LOCATION_HAND+LOCATION_GRAVE) end function c50920465.operation(e,tp,eg,ep,ev,re,r,rp,chk) if Duel.GetLocationCount(tp,LOCATION_MZONE)<2 then return end local g1=Duel.GetMatchingGroup(c50920465.filter,tp,LOCATION_HAND,0,nil,e,tp) local g2=Duel.GetMatchingGroup(c50920465.filter,tp,LOCATION_GRAVE,0,nil,e,tp) if g1:GetCount()==0 or g2:GetCount()==0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg1=g1:Select(tp,1,1,nil) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg2=g2:Select(tp,1,1,nil) sg1:Merge(sg2) Duel.SpecialSummon(sg1,0,tp,tp,false,false,POS_FACEUP) if e:GetHandler():IsRelateToEffect(e) then Duel.BreakEffect() Duel.SendtoHand(e:GetHandler(),nil,REASON_EFFECT) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c6544078.lua
9
1112
--伊弉凪 function c6544078.initial_effect(c) --special summon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(6544078,0)) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_SPSUMMON_PROC) e1:SetProperty(EFFECT_FLAG_UNCOPYABLE) e1:SetRange(LOCATION_HAND) e1:SetCondition(c6544078.spcon) e1:SetOperation(c6544078.spop) c:RegisterEffect(e1) --spirit may not return local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_SPIRIT_MAYNOT_RETURN) e2:SetRange(LOCATION_MZONE) e2:SetTargetRange(LOCATION_MZONE,0) c:RegisterEffect(e2) end function c6544078.filter(c) return c:IsType(TYPE_SPIRIT) and c:IsAbleToRemoveAsCost() end function c6544078.spcon(e,c) if c==nil then return true end return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c6544078.filter,c:GetControler(),LOCATION_HAND,0,1,nil) end function c6544078.spop(e,tp,eg,ep,ev,re,r,rp,c) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c6544078.filter,tp,LOCATION_HAND,0,1,1,nil) Duel.Remove(g,POS_FACEUP,REASON_COST) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c89893715.lua
3
1142
--ラヴァルの炎車回し function c89893715.initial_effect(c) --to grave local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(89893715,0)) e1:SetCategory(CATEGORY_TOGRAVE) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_BATTLE_DESTROYED) e1:SetCondition(c89893715.condition) e1:SetTarget(c89893715.target) e1:SetOperation(c89893715.operation) c:RegisterEffect(e1) end function c89893715.condition(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsLocation(LOCATION_GRAVE) and e:GetHandler():IsReason(REASON_BATTLE) end function c89893715.filter(c) return c:IsSetCard(0x39) and c:IsAbleToGrave() end function c89893715.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c89893715.filter,tp,LOCATION_DECK,0,2,nil) end Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,2,tp,LOCATION_DECK) end function c89893715.operation(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(c89893715.filter,tp,LOCATION_DECK,0,nil) if g:GetCount()<2 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local sg=g:Select(tp,2,2,nil) Duel.SendtoGrave(sg,REASON_EFFECT) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c73026394.lua
5
1151
--フュージョン・ガード function c73026394.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_NEGATE+CATEGORY_TOGRAVE) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_CHAINING) e1:SetCondition(c73026394.condition) e1:SetTarget(c73026394.target) e1:SetOperation(c73026394.activate) c:RegisterEffect(e1) end function c73026394.condition(e,tp,eg,ep,ev,re,r,rp) local ex=Duel.GetOperationInfo(ev,CATEGORY_DAMAGE) return ex and (re:IsActiveType(TYPE_MONSTER) or re:IsHasType(EFFECT_TYPE_ACTIVATE)) and Duel.IsChainNegatable(ev) end function c73026394.filter(c) return c:IsType(TYPE_FUSION) and c:IsAbleToGrave() end function c73026394.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c73026394.filter,tp,LOCATION_EXTRA,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_EXTRA) end function c73026394.activate(e,tp,eg,ep,ev,re,r,rp) Duel.NegateActivation(ev) local g=Duel.GetMatchingGroup(c73026394.filter,tp,LOCATION_EXTRA,0,nil):RandomSelect(tp,1) Duel.SendtoGrave(g,REASON_EFFECT) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c98229575.lua
5
1966
--U.A.フィールドゼネラル function c98229575.initial_effect(c) --special summon local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_SPSUMMON_PROC) e1:SetProperty(EFFECT_FLAG_UNCOPYABLE) e1:SetRange(LOCATION_HAND) e1:SetCountLimit(1,98229575) e1:SetCondition(c98229575.spcon) e1:SetOperation(c98229575.spop) c:RegisterEffect(e1) --atk local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_ATKCHANGE) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_ATTACK_ANNOUNCE) e2:SetRange(LOCATION_MZONE) e2:SetCondition(c98229575.atkcon) e2:SetOperation(c98229575.atkop) c:RegisterEffect(e2) end function c98229575.spfilter(c) return c:IsFaceup() and c:IsSetCard(0xb2) and not c:IsCode(98229575) and c:IsAbleToHandAsCost() end function c98229575.spcon(e,c) if c==nil then return true end return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>-1 and Duel.IsExistingMatchingCard(c98229575.spfilter,c:GetControler(),LOCATION_MZONE,0,1,nil) end function c98229575.spop(e,tp,eg,ep,ev,re,r,rp,c) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) local g=Duel.SelectMatchingCard(tp,c98229575.spfilter,tp,LOCATION_MZONE,0,1,1,nil) Duel.SendtoHand(g,nil,REASON_COST) end function c98229575.atkcon(e,tp,eg,ep,ev,re,r,rp) local at=Duel.GetAttacker() return at:IsSetCard(0xb2) and at:IsControler(tp) and at~=e:GetHandler() and e:GetHandler():IsAttackAbove(800) end function c98229575.atkop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local at=Duel.GetAttacker() if c:IsFaceup() and c:IsRelateToEffect(e) and c:IsAttackAbove(800) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetValue(-800) e1:SetReset(RESET_EVENT+0x1fe0000) c:RegisterEffect(e1) if at:IsFaceup() and at:IsRelateToBattle() then local e2=e1:Clone() e2:SetValue(800) at:RegisterEffect(e2) end end end
gpl-2.0
dinodeck/rpg_dialog_script
dialog_runner/code/ActorXPSummary.lua
4
3729
ActorXPSummary = {} ActorXPSummary.__index = ActorXPSummary function ActorXPSummary:Create(actor, layout, layoutId) local this = { mActor = actor, mLayout = layout, mId = layoutId, mXPBar = ProgressBar:Create { value = actor.mXP, maximum = actor.mNextLevelXP, background = Texture.Find("xpbackground.png"), foreground = Texture.Find("xpforeground.png"), }, mPopUpList = {}, mPopUpDisplayTime = 1, -- secs } this.mAvatar = Sprite.Create() this.mAvatar:SetTexture(this.mActor.mPortraitTexture) local avatarScale = 0.8 this.mAvatar:SetScale(avatarScale, avatarScale) this.mActorWidth = actor.mPortraitTexture:GetWidth() * avatarScale setmetatable(this, self) return this end function ActorXPSummary:Update(dt) local popup = self.mPopUpList[1] if popup == nil then --print("popup at 1 is nil") return end if popup:IsFinished() then print("Removed") table.remove(self.mPopUpList, 1) return end popup:Update(dt) if popup.mDisplayTime > self.mPopUpDisplayTime and #self.mPopUpList > 1 then popup:TurnOff() end end function ActorXPSummary:Render(renderer) local statFont = gGame.Font.stat local font = gGame.Font.default renderer:ScaleText(1.25, 1.25) -- Potrait local left = self.mLayout:Left(self.mId) local midY = self.mLayout:MidY(self.mId) local avatarLeft = left + self.mActorWidth/2 + 6 self.mAvatar:SetPosition(avatarLeft , midY) renderer:DrawSprite(self.mAvatar) -- Name local nameX = left + self.mActorWidth + 84 local nameY = self.mLayout:Top(self.mId) - 12 font:AlignText("right", "top") font:DrawText2d(renderer, nameX, nameY, self.mActor.mName) -- Level local strLevelLabel = "Level:" local strLevelValue = string.format("%d", self.mActor.mLevel) local levelY = nameY - 42 font:DrawText2d(renderer, nameX, levelY, strLevelLabel) statFont:AlignText("left", "top") statFont:DrawText2d(renderer, nameX + 12, levelY, strLevelValue) -- XP font:AlignText("right", "top") local strXPLabel = "EXP:" local strXPValue = string.format("%d", self.mActor.mXP) local right = self.mLayout:Right(self.mId) - 18 local rightLabel = right - 96 font:DrawText2d(renderer, rightLabel, nameY, strXPLabel) statFont:AlignText("right", "top") statFont:DrawText2d(renderer, right, nameY, strXPValue) local barX = right - self.mXPBar.mHalfWidth self.mXPBar:SetPosition(barX, nameY - 24) self.mXPBar:SetValue(self.mActor.mXP, self.mActor.mNextLevelXP) self.mXPBar:Render(renderer) local strNextLevelLabel = "Next Level:" local strNextLevelValue = string.format("%d", self.mActor.mNextLevelXP) font:DrawText2d(renderer, rightLabel, levelY, strNextLevelLabel) statFont:DrawText2d(renderer, right, levelY, strNextLevelValue) local popup = self.mPopUpList[1] if popup == nil then return end popup:Render(renderer) end function ActorXPSummary:SetPosition(x, y) self.mX = x self.mY = y end function ActorXPSummary:AddPopUp(text, color) local x = self.mLayout:MidX(self.mId) local y = self.mLayout:MidY(self.mId) local popup = XPPopUp:Create(text, x, y, color) table.insert(self.mPopUpList, popup) popup:TurnOn() Apply(self.mPopUpList, print) end function ActorXPSummary:PopUpCount() return #self.mPopUpList end function ActorXPSummary:CancelPopUp() local popup = self.mPopUpList[1] if popup == nil or popup:IsTurningOff() then return end popup:TurnOff() end
mit
zhaoxin54430/zhaoxin_test
src_luci/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/network.lua
53
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 data 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
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c4906301.lua
3
1221
--ネクロ・ガードナー function c4906301.initial_effect(c) --disable attack local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(4906301,0)) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_FREE_CHAIN) e1:SetHintTiming(0,TIMING_ATTACK) e1:SetRange(LOCATION_GRAVE) e1:SetCondition(c4906301.condition) e1:SetCost(c4906301.cost) e1:SetOperation(c4906301.operation) c:RegisterEffect(e1) end function c4906301.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()~=tp and (Duel.IsAbleToEnterBP() or Duel.GetCurrentPhase()==PHASE_BATTLE) end function c4906301.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST) end function c4906301.operation(e,tp,eg,ep,ev,re,r,rp) if Duel.GetAttacker() then Duel.NegateAttack() else local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_ATTACK_ANNOUNCE) e1:SetReset(RESET_PHASE+PHASE_END) e1:SetCountLimit(1) e1:SetOperation(c4906301.disop) Duel.RegisterEffect(e1,tp) end end function c4906301.disop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_CARD,0,4906301) Duel.NegateAttack() end
gpl-2.0
trakk/fdb
fns.lua
1
2840
-- fdb: streamlined cli budget management -- Copyright (C) 2014 - 2015 David Ulrich -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published -- by the Free Software Foundation, version 3 of the License. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU Affero General Public License for more details. -- -- You should have received a copy of the GNU Affero General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. function between(n,a,b) n = number(n) a = number(a) b = number(b) return (n >= a and n <= b) end function number(n) return tonumber(n) or 0 end function all(input) return (input == "a" or input == "A") end function new(input) return (input == "n" or input == "N") end function quit(input) return (input == "x" or input == "X") end function yes(input) return (input == "y" or input == "Y") end function format_field(k,v) local disp = display[k] local ds = "" if not disp then return v end if disp.align == A.LEFT then ds = "%-" .. disp.right .. "." .. disp.right .. "s" elseif disp.align == A.RIGHT then ds = "%" .. disp.left .. "." .. disp.left .. "s" else ds = "%s" end return string.format(ds,v) end -- SQL Helpers function select_fields(t) local fields = {} local raw_fields = {} local titles = {} local joins = {} local query = "" table.insert(raw_fields,types[t].id_field) table.insert(titles,"ID") table.insert(fields,sql_field(types[t].id_field,types[t].sql_id)) for i,v in ipairs(types[t].names) do if v.type_t then table.insert(raw_fields,types[v.type_t].names[1].field) table.insert(titles,types[v.type_t].names[1].title) table.insert(fields,sql_field( types[v.type_t].names[1].field, types[v.type_t].sql_id )) table.insert(joins,sql_join( types[v.type_t].table, types[v.type_t].sql_id, types[t].sql_id, v.field )) else table.insert(raw_fields,v.field) table.insert(titles,v.title) table.insert(fields,sql_field(v.field,types[t].sql_id)) end end query = "SELECT " .. table.concat(fields,",") .. [[ FROM ]] .. types[t].table .. " " .. types[t].sql_id .. [[ ]] .. table.concat(joins,"\n") .. " ORDER BY " .. types[t].id_field return query, raw_fields, titles end function sql_field(name,letter) return letter .. ".`" .. name .. "`" end function sql_join(table,l1,l2,field) return " LEFT JOIN `" .. table .. "` " .. l1 .. " ON " .. l1 .. ".`" .. field .. "` = " .. l2 .. ".`" .. field .. "` " end function where_id(t,id) return " WHERE `" .. types[t].id_field .. "` = " .. number(id) end
agpl-3.0
dinodeck/rpg_dialog_script
dialog_runner/code/Selection.lua
2
5604
Selection = {} Selection.__index = Selection function Selection:Create(params) local this = { mX = 0, mY = 0, mDataSource = params.data, mColumns = params.columns or 1, mFocusX = 1, mFocusY = 1, mSpacingY = params.spacingY or 24, mSpacingX = params.spacingX or 128, mCursor = Sprite.Create(), mShowCursor = true, mMaxRows = params.rows or #params.data, mDisplayStart = 1, mScale = 1, OnSelection = params.OnSelection or function() end } this.mDisplayRows = params.displayRows or this.mMaxRows local cursorTex = Texture.Find(params.cursor or "cursor.png") this.mCursor:SetTexture(cursorTex) this.mCursorWidth = cursorTex:GetWidth() setmetatable(this, self) this.RenderItem = params.RenderItem or this.RenderItem this.mWidth = this:CalcWidth(gRenderer) this.mHeight = this:CalcHeight() return this end function Selection:GetWidth() return self.mWidth * self.mScale end function Selection:GetHeight() return self.mHeight * self.mScale end -- If the RenderItem function is overwritten -- This won't give the correct result. function Selection:CalcWidth(renderer) if self.mColumns == 1 then local maxEntryWidth = 0 for k, v in ipairs(self.mDataSource) do local width = renderer:MeasureText(tostring(v)):X() maxEntryWidth = math.max(width, maxEntryWidth) end return maxEntryWidth + self.mCursorWidth else return self.mSpacingX * self.mColumns end end function Selection:CalcHeight() local height = self.mDisplayRows * (self.mSpacingY) return height - self.mSpacingY /2 end function Selection:ShowCursor() self.mShowCursor = true end function Selection:HideCursor() self.mShowCursor = false end function Selection:SetPosition(x, y) self.mX = x self.mY = y end function Selection:RenderItem(renderer, x, y, item) local font = gGame.Font.default if not item then font:DrawText2d(renderer, x, y, "--") else font:DrawText2d(renderer, x, y, item) end end function Selection:CursorWidth() return self.mCursorWidth * self.mScale end function Selection:Render(renderer) local displayStart = self.mDisplayStart local displayEnd = displayStart + self.mDisplayRows - 1 local x = self.mX local y = self.mY local cursorWidth = self:CursorWidth() local cursorHalfWidth = cursorWidth / 2 local spacingX = (self.mSpacingX * self.mScale) local rowHeight = (self.mSpacingY * self.mScale) self.mCursor:SetScale(self.mScale, self.mScale) local itemIndex = ((displayStart-1) * self.mColumns) + 1 for i = displayStart, displayEnd do for j = 1, self.mColumns do if i == self.mFocusY and j == self.mFocusX and self.mShowCursor then self.mCursor:SetPosition(x + cursorHalfWidth, y) renderer:DrawSprite(self.mCursor) end local item = self.mDataSource[itemIndex] self:RenderItem(renderer, x + cursorWidth, y, item) x = x + spacingX itemIndex = itemIndex + 1 end y = y - rowHeight x = self.mX end end function Selection:CanScrollUp() return self.mDisplayStart > 1 end function Selection:CanScrollDown() return self.mDisplayStart <= (self.mMaxRows - self.mDisplayRows) end function Selection:JumpToFirstItem() self.mFocusX = 1 self.mFocusY = 1 self.mDisplayStart = 1 end function Selection:MoveUp() self.mFocusY = math.max(self.mFocusY - 1, 1) if self.mFocusY < self.mDisplayStart then self:MoveDisplayUp() end end function Selection:MoveDown() self.mFocusY = math.min(self.mFocusY + 1, self.mMaxRows) if self.mFocusY >= self.mDisplayStart + self.mDisplayRows then self:MoveDisplayDown() end end function Selection:MoveLeft() self.mFocusX = math.max(self.mFocusX - 1, 1) end function Selection:MoveRight() self.mFocusX = math.min(self.mFocusX + 1, self.mColumns) end function Selection:HandleInput() if Keyboard.JustPressed(KEY_UP) then self:MoveUp() elseif Keyboard.JustPressed(KEY_DOWN) then self:MoveDown() elseif Keyboard.JustPressed(KEY_LEFT) then self:MoveLeft() elseif Keyboard.JustPressed(KEY_RIGHT) then self:MoveRight() elseif Keyboard.JustPressed(KEY_SPACE) then self:OnClick() end end function Selection:OnClick() local index = self:GetIndex() self.OnSelection(index, self.mDataSource[index]) end function Selection:MoveDisplayUp() self.mDisplayStart = self.mDisplayStart - 1 end function Selection:MoveDisplayDown() self.mDisplayStart = self.mDisplayStart + 1 end function Selection:GetIndex() return self.mFocusX + ((self.mFocusY - 1) * self.mColumns) end function Selection:PercentageShown() return self.mDisplayRows / self.mMaxRows end function Selection:PercentageScrolled() local onePercent = 1 / self.mMaxRows local currentPercent = self.mFocusY / self.mMaxRows -- Allows a 0 value to be returned. if currentPercent <= onePercent then currentPercent = 0 end return currentPercent end function Selection:SelectedItem() return self.mDataSource[self:GetIndex()] end
mit
WAKAMAZU/sile_fe
languages/fr.lua
3
19085
SILE.hyphenator.languages["fr"] = {}; SILE.hyphenator.languages["fr"].patterns = { ---------------------%-----------------------% -- phonetic patterns % etymological patterns % ---------------------%-----------------------% ----* "2'2", ---------------------%-----------------------% -- phonetic patterns % etymological patterns % ---------------------%-----------------------% ----a ".a4", "'a4", ".â4", "'â4", "ab2h", -- df-bg 1998/02/07 for abhorrer ".ab3réa", "'ab3réa", "ad2h", -- df-bg 1998/02/07 for adhèsion & co "a1è2dre", ".ae3s4ch", "'ae3s4ch", "1alcool", "a2l1algi", ".amino1a2c", "'amino1a2c", ".ana3s4tr", "'ana3s4tr", "1a2nesthési", ".anti1a2", "'anti1a2", ".anti1e2", "'anti1e2", ".anti1é2", ".anti2enne", "'anti2enne", "'anti1é2", ".anti1s2", "'anti1s2", ".apo2s3ta", "'apo2s3ta", "apo2s3tr", "archi1é2pis", ".as2ta", "'as2ta", "a2s3tro", "---------------------%-----------------------%", "-- phonetic patterns % etymological patterns %", "---------------------%-----------------------%", ----b "1ba", "1bâ", ".bai2se3main", -- hyphen disappeared from french 5/2/94 "1be", "1bé", "1bè", "1bê", "4be.", "4bes.", "2bent.",-- mute syllable: tombent (df) 22/02/94 "1bi", "1bî", ".bi1a2c", ".bi1a2t", -- like .tri1a2t for tri-athlon bg 12/27/93 ".bi1au", ".bio1a2", ".bi2s1a2", ".bi1u2", "1b2l", "4ble.", "4bles.", "2blent.", -- mute syllable: troublent (df) 28/02/94 "1bo", "1bô", "1b2r", "4bre.", "4bres.", "2brent.", -- mute syllable: palabrent (df) 28/02/94 "1bu", "1bû", "1by", "---------------------%-----------------------%", "-- phonetic patterns % etymological patterns %", "---------------------%-----------------------%", ----c "1ç", "1ca", "1câ", "ca3ou3t2", -- for caoutchou... added 3/1/94 df-bg "1ce", "1cé", "1cè", "1cê", "4ce.", "4ces.", -- words ending with -cent (df) 22/02/94 "2cent.", "ja3cent.", "ac3cent.", "é3cent.", "munifi3cent.", "réti3cent.", "privatdo3cent.", "inno3cent.", "es3cent.", "acquies4cent.", "is3cent.", "immis4cent.", ".ch4", "1c2h", "4ch.", "2chb", "4che.", "4ches.", "2chent.", -- mute syllable: touchent (df) 22/02/94 ".chè2vre3feuille", -- hyphen disappeared from french 5/2/94 "2chg", "ch2l", "4chle.", "4chles.", "chlo2r3a2c", "chlo2r3é2t", "2chm", "2chn", "2chp", "ch2r", "4chre.", "4chres.", "2chs", "2cht", "2chw", "1ci", "1cî", ".ci2s1alp", "1c2k", "4ck.", "2ckb", "4cke.", "4ckes.", "2ckent.", -- mute syllable: stockent (df) 22/02/94 "2ckf", "2ckg", "2ck3h", "2ckp", "2cks", "2ckt", "1c2l", "4cle.", "4cles.", "2clent.", -- mute syllable: encerclent (df) 28/02/94 "1co", "1cô", "co1acc", "co1acq", "co1a2d", "co1ap", "co1ar", "co1assoc", "co1assur", "co1au", "co1ax", "1cœ", "co1é2", "co1ef", "co1en", "co1ex", ".con4", -- missing from nb list ".cons4", -- missing from nb list ".contre1s2c", ".contre3maître", -- hyphen disappeared from french 5/2/94 "co2nurb", ".co1o2", ".co2o3lie", "1c2r", "4cre.", "4cres.", "2crent.", -- mute syllable: massacrent (df) 28/02/94 "1cu", "1cû", "1cy", ".cul4", -- -- as .con4 .cons4 (march 92) ---------------------%-----------------------%"-- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----d "1d'", "1da", "1dâ", ".dacryo1a2", "d1d2h", "1de", "1dé", "1dè", "1dê", "4de.", "4des.", -- words ending with -dent (df) 22/02/94 "2dent.", "déca3dent.", "é3dent.", "cci3dent.", "inci3dent.", "confi3dent.", "tri3dent.", "dissi3dent.", "chien3dent.", ".ar3dent.", "impu3dent.", "pru3dent.", ".dé1a2", ".dé1io", ".dé1o2", ".dé2s", -- originaly in JD file ".dé3s2a3cr", ".dés2a3m", -- .dés2a2mi introduced 09/17/92 bec. i -- can't see why désamidonner ran in JD. -- Moved to .dés2a3m df 12/27/93 ".dé3s2a3tell", ".dé3s2astr", ".dé3s2c", -- 1 moved 3 due to .dé2s 09/17/92", ".dé2s1é2", ".dé3s2é3gr", ".dé3s2ensib", ".dé3s2ert", ".dé3s2exu", ".dé2s1i2", ".dé3s2i3d", ".dé3s2i3gn", ".dé3s2i3li", ".dé3s2i3nen", ".dé3s2invo", ".dé3s2i3r", ".dé3s2ist", ".dé3s2o3dé", ".dé2s1œ", ".dé3s2o3l", ".dé3s2o3pil", ".dé3s2orm", ".dé3s2orp", ".dé3s2oufr", ".dé3s2p", -- 1 moved 3 due to .dé2s 09/17/92 ".dé3s2t", -- 1 moved 3 due to .dé2s 09/17/92 ".dé2s1u2n", "3d2hal", "3d2houd", "1di", "1dî", "di2s3cop", ".di1a2cé", ".di1a2cid", ".di1ald", ".di1a2mi", ".di1a2tom", ".di1e2n", ".di2s3h", "2dlent.", -- mute syllable: jodlent (df) 28/02/94", "1do", "1dô", "1d2r", "4dre.", "4dres.", "2drent.", -- mute syllable: engendrent (df) 28/02/94", "d1s2", "1du", "1dû", "1dy", ".dy2s3", ".dy2s1a2", ".dy2s1i2", ".dy2s1o2", -- missing from nb list", ".dy2s1u2", ---------------------%-----------------------% -- phonetic patterns -- etymological patterns -- ---------------------%-----------------------% ----e ".e4", "'e4", ".ê4", "'ê4", ".é4", "'é4", ".è4", "'è4", "éd2hi", -- df-bg 1998/02/07 for rédhibitoire "1é2drie", "1é2drique", "1é2lectr", "1é2lément", ".en1a2", "'en1a2", "1é2nerg", "e2n1i2vr", ".en1o2", "'en1o2", "épi2s3cop", "épi3s4cope", "e2s3cop", ".eu2r1a2", "'eu2r1a2", "eu1s2tat", "extra1", "extra2c", "extra2i", ---------------------%------------------------- -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----f "1fa", "1fâ", "1fe", "1fé", "1fè", "1fê", "4fe.", "4fes.", "2fent.", -- mute syllable: agrafent chauffent (df) 22/02/94 "1fi", "1fî", "1f2l", "4fle.", "4fles.", "2flent.", -- mute syllable: gonflent (df) 28/02/94 "1fo", "1fô", "1f2r", "4fre.", "4fres.", "2frent.", -- mute syllable: balafrent (df) 28/02/94 "f1s2", "1fu", "1fû", "1fy", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----g "1ga", "1gâ", "1ge", "1gé", "1gè", "1gê", "4ge.", "4ges.", -- words ending with -gent (df) 22/02/94 "2gent.", "ré3gent.", "entre3gent.", "indi3gent.", "dili3gent.", "intelli3gent.", "indul3gent.", "tan3gent.", "rin3gent.", "contin3gent.", ".ar3gent.", "'ar3gent.", "ser3gent.", "ter3gent.", "résur3gent.", "1gy", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----h "1ha", "1hâ", "1he", "1hé", "1hè", "1hê", "hémi1é", "hémo1p2t", "4he.", "4hes.", "1hi", "1hî", "1ho", "1hô", "1hu", "1hû", "1hy", "hypera2", "hypere2", "hyperé2", "hyperi2", "hypero2", "hypers2", "hype4r1", "hyperu2", "hypo1a2", "hypo1e2", -- missing from nb list "hypo1é2", "hypo1i2", "hypo1o2", "hypo1s2", "hypo1u2", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ----------------------------------------------- ----i ".i4", "'i4", ".î4", "'î4", "i1algi", "i1arthr", "i1è2dre", -- ill patterns missing from nb list "il2l", "cil3l", "rcil4l", "ucil4l", "vacil4l", "gil3l", "hil3l", "lil3l", "l3lion", "mil3l", "mil4let", "émil4l", "semil4l", "rmil4l", "armil5l", "capil3l", "papil3la", "papil3le", "papil3li", "papil3lom", "pupil3l", "piril3l", "thril3l", "cyril3l", "ibril3l", "pusil3l", ".stil3l", "distil3l", "instil3l", "fritil3l", "boutil3l", "vanil3lin", "vanil3lis", "vil3l", "avil4l", "chevil4l", "uevil4l", "uvil4l", "xil3l", -- end of ill patterns "1informat", -- missing from nb list ".in1a2", "'in1a2", ".in2a3nit", "'in2a3nit", ".in2augur", "'in2augur", ".in1e2", "'in1e2", ".in1é2", "'in1é2", ".in2effab", -- missing from nb list "'in2effab", ".in2é3lucta", "'in2é3lucta", ".in2é3narra", "'in2é3narra", ".in2ept", "'in2ept", ".in2er", "'in2er", ".in2exora", -- missing from nb list "'in2exora", ".in1i2", "'in1i2", ".in2i3miti", "'in2i3miti", ".in2i3q", "'in2i3q", ".in2i3t", "'in2i3t", ".in1o2", "'in1o2", ".in2o3cul", "'in2o3cul", ".in2ond", "'in2ond", ".in1s2tab", "'in1s2tab", "'inte4r3", ".intera2", "'intera2", ".intere2", "'intere2", ".interé2", "'interé2", ".interi2", "'interi2", ".intero2", "'intero2", ".inte4r3", ".interu2", "'interu2", ".inters2", "'inters2", ".in1u2", "'in1u2", ".in2uit", "'in2uit", ".in2u3l", "'in2u3l", "io1a2ct", "i1oxy", "i1s2tat", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----j "1j", "2jk", "4je.", "4jes.", "2jent.", -- mute syllable: galèjent (df) 22/02/94 ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----k "1ka", "1kâ", "1ke", "1ké", "1kè", "1kê", "4ke.", "4kes.", "2kent.", -- mute syllable: jerkent (df) 22/02/94 "1k2h", "4kh.", ".kh4", "1ki", "1kî", "1ko", "1kô", "1k2r", "1ku", "1kû", "1ky", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----l "1la", "1lâ", "1là", "la2w3re", "1le", "1lé", "1lè", "1lê", "4le.", "4les.", -- words ending with -lent (df) 22/02/94 "2lent.", ".ta3lent.", "iva3lent.", "équiva4lent.", "monova3lent.", "polyva3lent.", "re3lent.", ".do3lent.", "indo3lent.", "inso3lent.", "turbu3lent.", "succu3lent.", "fécu3lent.", "trucu3lent.", "opu3lent.", "corpu3lent.", "ru3lent.", "sporu4lent.", "1li", "1lî", "1lo", "1lô", "l1s2t", "1lu", "1lû", "1ly", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----m "1ma", "1mâ", ".ma2c3k", ".macro1s2c", ".ma2l1a2dres", ".ma2l1a2dro", ".ma2l1aisé", ".ma2l1ap", ".ma2l1a2v", ".ma2l1en", ".ma2l1int", ".ma2l1oc", ".ma2l1o2d", ".ma2r1x", -- nb (jbb: ?) "1me", "1mé", "1mè", "1mê", ".mé2g1oh", ".mé2sa", -- missing from nb list ".mé3san", -- missing from nb list ".mé2s1es", ".mé2s1i", ".mé2s1u2s", ".méta1s2ta", "4me.", "4mes.", -- words ending with -ment (df) 22/02/94 "â2ment.", "da2ment.", "fa2ment.", "amalga2ment.", "cla2ment.", "ra2ment.", "tempéra3ment.", "ta2ment.", "testa3ment.", "qua2ment.", "è2ment.", "carê2ment.", "diaphrag2ment.", "ryth2ment.", "ai2ment.", "rai3ment.", "abî2ment.", "éci2ment.", "vidi2ment.", "subli2ment.", "éli2ment.", "reli2ment.", "mi2ment.", "ani2ment.", "veni2ment.", "ri2ment.", "détri3ment.", "nutri3ment.", "inti2ment.", "esti2ment.", "l2ment.", "flam2ment.", "gram2ment.", ".gem2ment.", "om2ment.", ".com3ment.", "ô2ment.", "slalo2ment.", "chro2ment.", "to2ment.", "ar2ment.", ".sar3ment.", "er2ment.", "antifer3ment.", ".ser3ment.", "fir2ment.", "or2ment.", "as2ment.", "au2ment.", "écu2ment.", "fu2ment.", "hu2ment.", "fichu3ment.", "llu2ment.", "plu2ment.", "bou2ment.", "bru2ment.", "su2ment.", "tu2ment.", "1mi", "1mî", ".milli1am", "1m2némo", "1m2nès", "1m2nési", "1mo", "1mô", "1mœ", ".mono1a2", ".mono1e2", ".mono1é2", ".mono1i2", ".mono1ï2dé", ".mono1o2", ".mono1u2", ".mono1s2", "mon2t3réal", -- missing from nb list "m1s2", "1mu", "1mû", "1my", "moye2n1â2g", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----n "1na", "1nâ", "1ne", "1né", "1nè", "1nê", "4ne.", "4nes.", -- words ending with -nent (df) 22/02/94 "2nent.", -- fric-tionnent - syllable muette - bg 27/12/93 "réma3nent.", "imma3nent.", "perma3nent.", ".émi3nent.", "préémi3nent.", "proémi3nent.", "surémi3nent.", "immi3nent.", "conti3nent.", "perti3nent.", "absti3nent.", "1ni", "1nî", "1no", "1nô", "1nœ", ".no2n1obs", "1nu", "1nû", "n3s2at.", "n3s2ats.", "n1x", "1ny", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----o ".o4", "'o4", "'ô4", ".ô4", "o2b3long", "1octet", -- missing from nb list "o1d2l", "o1è2dre", "o1ioni", "ombud2s3", "omni1s2", "o1s2tas", "o1s2tat", "o1s2téro", "o1s2tim", "o1s2tom", "o1s2trad", "o1s2tratu", "o1s2triction", ".oua1ou", "'oua1ou", ".ovi1s2c", "'ovi1s2c", "oxy1a2", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----p "1pa", "1pâ", "paléo1é2", ".pa2n1a2f", ".pa2n1a2mé", ".pa2n1a2ra", ".pa2n1is", ".pa2n1o2ph", ".pa2n1opt", ".pa2r1a2che", ".pa2r1a2chè", ".para1s2", ".pa2r3hé", "1pe", "1pé", "1pè", "1pê", "4pe.", "4pes.", -- words ending with -pent (df) 22/02/94 "2pent.", "re3pent.", ".ar3pent.", "'ar3pent.", "ser3pent.", ".pen2ta", -- pent- or penta- but never pen-ta bg 12/27/93 "per3h", "pé2nul", -- pé2n1ul moved back 09/17/92 to JD def. ".pe4r", ".per1a2", ".per1e2", ".per1é2", ".per1i2", ".per1o2", ".per1u2", "pé1r2é2q", -- 2r1 moved 09/17/92 to 1r2(it was a typo) ".péri1os", ".péri1s2", ".péri2s3s", ".péri2s3ta", ".péri1u2", "1p2h", ".ph4", "4ph.", ".phalan3s2t", "4phe.", "4phes.", "2phent.", -- mute syllable: triomphent (df) 22/02/94 "ph2l", "4phle.", "4phles.", "2phn", "photo1s2", "ph2r", "4phre.", "4phres.", "2phs", "2pht", "3ph2talé", "3ph2tis", "1pi", "1pî", "1p2l", "4ple.", "4ples.", "2plent.", -- mute syllable: accouplent (df) 28/02/94 ".pluri1a", "1p2né", "1p2neu", "1po", "1pô", "po1astre", "poly1a2", "poly1e2", "poly1é2", "poly1è2", "poly1i2", "poly1o2", "poly1s2", "poly1u2", ".pon2tet", -- JD hypenated it asis 09/17/92, exception ".pos2t3h", ".pos2t1in", ".pos2t1o2", ".pos2t3r", ".post1s2", "1p2r", "4pre.", "4pres.", "2prent.", -- mute syllable: empourprent (df) 28/02/94 ".pré1a2", ".pré2a3la", -- missing from nb list ".pré2au", ".pré1é2", ".pré1e2", ".pré1i2", ".pré1o2", ".pré1u2", ".pré1s2", ".pro1é2", ".pro1s2cé", "pro2s3tat", ".prou3d2h", "1p2sych", ".psycho1a2n", "1p2tèr", "1p2tér", "1pu", ".pud1d2l", "1pû", "1py", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----q "1q", "4que.", "4ques.", -- words ending with -quent (df) 22/02/94 "2quent.", "é3quent.", "élo3quent.", "grandilo3quent.", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----r "1ra", "1râ", "radio1a2", -- missing from nb list "1re", "1ré", "1rè", "1rê", ".ré1a2", ".ré2a3le", ".ré2a3lis", ".ré2a3lit", ".ré2aux", ".ré1é2", ".ré1e2", ".ré2el", ".ré2er", ".ré2èr", ".ré1i2", ".ré2i3fi", ".ré1o2", ".re1s2", ".re2s3cap", ".re2s3cisi", -- for res-cision 09/17/92 (missing from nb) ".re2s3ciso", -- for res-cisoire 09/17/92(missing from nb) ".re2s3cou", ".re2s3cri", ".re2s3pect", ".re2s3pir", ".re2s3plend", ".re2s3pons", ".re2s3quil", ".re2s3s", ".re2s3t", ".re3s4tab", ".re3s4tag", ".re3s4tand", ".re3s4tat", ".re3s4tén", ".re3s4tér", ".re3s4tim", ".re3s4tip", ".re3s4toc", ".re3s4top", ".re3s4tr", ".re4s5trein", ".re4s5trict", ".re4s5trin", ".re3s4tu", ".re3s4ty", ".réu2", ".ré2uss", ".rétro1a2", "4re.", "4res.", -- words ending with -rent (df) 22/02/94 "2rent.", -- es-pèrent - syllable muette - bg 27/12/93 ".pa3rent.", "appa3rent.", "transpa3rent.", "é3rent.", "tor3rent.", "cur3rent.", "--", "1r2h", "4rhe.", "4rhes.", "2r3heur", "2r3hydr", "1ri", "1rî", "1ro", "1rô", "1ru", "1rû", "1ry", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----s "1sa", "1sâ", ".sch4", "1s2caph", "1s2clér", "1s2cop", "1s2ch", "e2s3ch", "i2s3ché", "i2s3chia", "i2s3chio", "4sch.", "4sche.", "4sches.", "2schs", "1se", "1sé", "1sè", "1sê", "sesqui1a2", "4se.", "4ses.", -- words ending with -sent (df) 22/02/94 "2sent.", -- massent - syllable muette - bg 27/12/93 "ab3sent.", "pré3sent.", ".res3sent.", "--", ".seu2le", -- jbb ".sh4", "1s2h", "4sh.", "4she.", "4shes.", "2shent.", -- mute syllable: smashent (df) 22/02/94 "2shm", "2s3hom", "2shr", "2shs", "1si", "1sî", "1s2lav", "1s2lov", "1so", "1sô", "1sœ", "1s2patia", "1s2perm", "1s2por", "1s2phèr", "1s2phér", "1s2piel", "1s2piros", "1s2tandard", "1s2tein", "stéréo1s2", "1s2tigm", "1s2tock", "1s2tomos", "1s2troph", "1s2tructu", "1s2tyle", "1su", "1sû", ".su2b1a2", ".su3b2alt", ".su2b1é2", ".su3b2é3r", ".su2b1in", ".su2b3limin", ".su2b3lin", ".su2b3lu", "sub1s2", ".su2b1ur", "supero2", "supe4r1", "supers2", ".su2r1a2", "su3r2ah", ".su3r2a3t", ".su2r1e2", ".su3r2eau", ".su3r2ell", ".su3r2et", ".su2r1é2", ".su2r3h", ".su2r1i2m", ".su2r1inf", ".su2r1int", ".su2r1of", ".su2r1ox", "1sy", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----t "1ta", "1tâ", "1tà", "tachy1a2", "tchin3t2", "1te", "1té", "1tè", "1tê", "télé1e2", "télé1i2", "télé1o2b", "télé1o2p", "télé1s2", "4te.", "4tes.", -- words ending with -tent (df) 22/02/94 "2tent.", -- mentent - syllable muette - bg 27/12/93 ".la3tent.", ".pa3tent.", "compé3tent.", "éni3tent.", "mécon3tent.", "omnipo3tent.", "ventripo3tent.", "équipo3tent.", "impo3tent.", "mit3tent.", ".th4", "1t2h", "4th.", "4the.", "4thes.", "thermo1s2", "2t3heur", "2thl", -- th2l was wrong for ...ath-lon (jd said 2thl) df 12/27/93 "2thm", "2thn", "th2r", "4thre.", "4thres.", "2ths", "1ti", "1tî", "1to", "1tô", "1t2r", "tran2s1a2", "tran3s2act", "tran3s2ats", "tran2s3h", "tran2s1o2", "tran2s3p", "tran2s1u2", "4tre.", "4tres.", "2trent.", -- mute syllable: infiltrent (df) 28/02/94 ".tri1a2c", ".tri1a2n", ".tri1a2t", ".tri1o2n", "t1t2l", "1tu", "1tû", "tung2s3", "1ty", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----u ".u4", "'u4", ".û4", "'û4", "uni1o2v", "uni1a2x", "u2s3tr", ----------------------------------------------- -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----v "1va", "1vâ", "1ve", "1vé", "1vè", "1vê", "vélo1s2ki", "4ve.", "4ves.", -- words ending with -vent (df) 22/02/94 "2vent.", "conni3vent.", ".sou3vent.", "--", "1vi", "1vî", "1vo", "1vô", "vol2t1amp", "1v2r", "4vre.", "4vres.", "2vrent.", -- mute syllable: recouvrent (df) 28/02/94 "1vu", "1vû", "1vy", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----w "1wa", "1we", "4we.", "4wes.", "2went.", -- mute syllable: interviewent (df) 22/02/94 "1wi", "1wo", "1wu", "1w2r", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----x "2xent.", -- mute syllable: malaxent (df) 22/02/94 ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----y ".y4", "'y4", "y1asth", "y1s2tom", "y1algi", ------------------------------------------------ -- phonetic patterns -- etymological patterns -- ------------------------------------------------ ----z "1za", "1ze", "1zé", "1zè", "4ze.", "4zes.", -- words ending with -zent (df) 22/02/94 "2zent.", "privatdo3zent.", "1zi", "1zo", "1zu", "1zy", };
mit
anshkumar/yugioh-glaze
assets/script/c4861205.lua
7
1510
--ミイラの呼び声 function c4861205.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) --special summon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(4861205,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetCountLimit(1) e1:SetRange(LOCATION_SZONE) e1:SetCondition(c4861205.condition) e1:SetTarget(c4861205.target) e1:SetOperation(c4861205.operation) c:RegisterEffect(e1) end function c4861205.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)==0 end function c4861205.filter(c,e,sp) return c:IsRace(RACE_ZOMBIE) and c:IsCanBeSpecialSummoned(e,0,sp,false,false) end function c4861205.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c4861205.filter,tp,LOCATION_HAND,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND) end function c4861205.operation(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end if Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)>0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c4861205.filter,tp,LOCATION_HAND,0,1,1,nil,e,tp) if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c60930169.lua
3
2165
--ブロークン・ブロッカー function c60930169.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_BATTLE_DESTROYED) e1:SetCondition(c60930169.condition) e1:SetTarget(c60930169.target) e1:SetOperation(c60930169.activate) c:RegisterEffect(e1) if not c60930169.global_check then c60930169.global_check=true local ge1=Effect.CreateEffect(c) ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) ge1:SetCode(EVENT_BATTLED) ge1:SetOperation(c60930169.checkop) Duel.RegisterEffect(ge1,0) end end function c60930169.checkop(e,tp,eg,ep,ev,re,r,rp) local a=Duel.GetAttacker() local t=Duel.GetAttackTarget() if a and a:IsDefencePos() and a:GetDefence()>a:GetAttack() and a:IsStatus(STATUS_BATTLE_DESTROYED) then a:RegisterFlagEffect(60930169,RESET_PHASE+PHASE_DAMAGE,0,1) end if t and t:IsDefencePos() and t:GetDefence()>t:GetAttack() and t:IsStatus(STATUS_BATTLE_DESTROYED) then t:RegisterFlagEffect(60930169,RESET_PHASE+PHASE_DAMAGE,0,1) end end function c60930169.filter(c,e,tp) if c:GetFlagEffect(60930169)~=0 and c:GetPreviousControler()==tp then e:SetLabel(c:GetCode()) return true else return false end end function c60930169.condition(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(c60930169.filter,1,nil,e,tp) end function c60930169.spfilter(c,e,tp,code) return c:IsCode(code) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c60930169.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c60930169.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp,e:GetLabel()) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function c60930169.activate(e,tp,eg,ep,ev,re,r,rp) local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) if ft<=0 then return end if ft>2 then ft=2 end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c60930169.spfilter,tp,LOCATION_DECK,0,1,ft,nil,e,tp,e:GetLabel()) if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP_DEFENCE) end end
gpl-2.0
zhaoxin54430/zhaoxin_test
src_luci/protocols/luci-proto-ppp/luasrc/model/cbi/admin_network/proto_l2tp.lua
17
1665
-- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org> -- Licensed to the public under the Apache License 2.0. local map, section, net = ... local server, username, password local ipv6, defaultroute, metric, peerdns, dns, mtu server = section:taboption("general", Value, "server", translate("L2TP Server")) server.datatype = "host" username = section:taboption("general", Value, "username", translate("PAP/CHAP username")) password = section:taboption("general", Value, "password", translate("PAP/CHAP password")) password.password = true if luci.model.network:has_ipv6() then ipv6 = section:taboption("advanced", Flag, "ipv6", translate("Enable IPv6 negotiation on the PPP link")) ipv6.default = ipv6.disabled end defaultroute = section:taboption("advanced", Flag, "defaultroute", translate("Use default gateway"), translate("If unchecked, no default route is configured")) defaultroute.default = defaultroute.enabled metric = section:taboption("advanced", Value, "metric", translate("Use gateway metric")) metric.placeholder = "0" metric.datatype = "uinteger" metric:depends("defaultroute", defaultroute.enabled) peerdns = section:taboption("advanced", Flag, "peerdns", translate("Use DNS servers advertised by peer"), translate("If unchecked, the advertised DNS server addresses are ignored")) peerdns.default = peerdns.enabled dns = section:taboption("advanced", DynamicList, "dns", translate("Use custom DNS servers")) dns:depends("peerdns", "") dns.datatype = "ipaddr" dns.cast = "string" mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU")) mtu.placeholder = "1500" mtu.datatype = "max(9200)"
gpl-2.0
Zhu-Zhi-Hao/Droid_Ettercap
src/lua/share/third-party/stdlib/src/mbox.lua
12
1370
--- mbox parser. -- Based on code by Diego Nahab. local function headers (s) local header = {} s = "\n" .. s .. "$$$:\n" local i, j = 1, 1 while true do j = string.find (s, "\n%S-:", i + 1) if not j then break end local _, _, name, val = string.find (string.sub (s, i + 1, j - 1), "(%S-):(.*)") val = string.gsub (val or "", "\r\n", "\n") val = string.gsub (val, "\n%s*", " ") name = string.lower (name) if header[name] then header[name] = header[name] .. ", " .. val else header[name] = val end i, j = j, i end header["$$$"] = nil return header end local function message (s) s = string.gsub (s, "^.-\n", "") local _, s, body _, _, s, body = string.find(s, "^(.-\n)\n(.*)") return {header = headers (s or ""), body = body or ""} end --- Parse a mailbox into messages. -- @param s mailbox as a string -- @return list of messages, each of form <code>{header = {...}, body = "..."}</code> local function parse (s) local mbox = {} s = "\n" .. s .. "\nFrom " local i, j = 1, 1 while true do j = string.find (s, "\nFrom ", i + 1) if not j then break end table.insert (mbox, message (string.sub (s, i + 1, j - 1))) i, j = j, i end return mbox end -- Public interface local M = { parse = parse, } return M
gpl-2.0
anshkumar/yugioh-glaze
assets/single/QB020.lua
1
1603
--wcs2011-06 Debug.SetAIName("高性能电子头脑") Debug.ReloadFieldBegin(DUEL_ATTACK_FIRST_TURN+DUEL_SIMPLE_AI) Debug.SetPlayerInfo(0,1000,0,0) Debug.SetPlayerInfo(1,13600,0,0) Debug.AddCard(81254059,0,0,LOCATION_DECK,0,POS_FACEDOWN) Debug.AddCard(81254059,0,0,LOCATION_DECK,0,POS_FACEDOWN) Debug.AddCard(57543573,0,0,LOCATION_DECK,0,POS_FACEDOWN) Debug.AddCard(57543573,0,0,LOCATION_DECK,0,POS_FACEDOWN) Debug.AddCard(30299166,0,0,LOCATION_DECK,0,POS_FACEDOWN) Debug.AddCard(64973456,0,0,LOCATION_HAND,0,POS_FACEDOWN) Debug.AddCard(97169186,0,0,LOCATION_HAND,0,POS_FACEDOWN) Debug.AddCard(81254059,0,0,LOCATION_HAND,0,POS_FACEDOWN) Debug.AddCard(3204467,0,0,LOCATION_HAND,0,POS_FACEDOWN) Debug.AddCard(45305419,0,0,LOCATION_HAND,0,POS_FACEDOWN) Debug.AddCard(64973456,0,0,LOCATION_HAND,0,POS_FACEDOWN) Debug.AddCard(28506708,0,0,LOCATION_SZONE,2,POS_FACEDUP) Debug.AddCard(27551,0,0,LOCATION_SZONE,3,POS_FACEDOWN) Debug.AddCard(43002864,0,0,LOCATION_GRAVE,0,POS_FACEUP) Debug.AddCard(42303365,0,0,LOCATION_GRAVE,0,POS_FACEUP) Debug.AddCard(70583986,0,0,LOCATION_EXTRA,0,POS_FACEDOWN) Debug.AddCard(62873545,1,1,LOCATION_MZONE,2,POS_FACEUP_ATTACK) Debug.AddCard(62873545,1,1,LOCATION_MZONE,3,POS_FACEUP_ATTACK) Debug.AddCard(85742772,1,1,LOCATION_SZONE,0,POS_FACEUP) Debug.AddCard(85742772,1,1,LOCATION_SZONE,1,POS_FACEUP) Debug.AddCard(85742772,1,1,LOCATION_SZONE,2,POS_FACEUP) Debug.AddCard(85742772,1,1,LOCATION_SZONE,3,POS_FACEUP) Debug.AddCard(85742772,1,1,LOCATION_SZONE,4,POS_FACEUP) Debug.ReloadFieldEnd() Debug.ShowHint("Win in this turn!") aux.BeginPuzzle()
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c44394295.lua
3
3770
--影依融合 function c44394295.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,44394295+EFFECT_COUNT_CODE_OATH) e1:SetTarget(c44394295.target) e1:SetOperation(c44394295.activate) c:RegisterEffect(e1) end function c44394295.filter0(c) return c:IsCanBeFusionMaterial() and c:IsAbleToGrave() end function c44394295.filter1(c,e) return c:IsCanBeFusionMaterial() and c:IsAbleToGrave() and not c:IsImmuneToEffect(e) end function c44394295.filter2(c,e,tp,m,f,chkf) return c:IsType(TYPE_FUSION) and c:IsSetCard(0x9d) and (not f or f(c)) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf) end function c44394295.cfilter(c) return c:GetSummonLocation()==LOCATION_EXTRA end function c44394295.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local chkf=Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and PLAYER_NONE or tp local loc=LOCATION_HAND+LOCATION_MZONE if Duel.IsExistingMatchingCard(c44394295.cfilter,tp,0,LOCATION_MZONE,1,nil) then loc=loc+LOCATION_DECK end local mg1=Duel.GetMatchingGroup(c44394295.filter0,tp,loc,0,nil) local res=Duel.IsExistingMatchingCard(c44394295.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf) if not res then local ce=Duel.GetChainMaterial(tp) if ce~=nil then local fgroup=ce:GetTarget() local mg2=fgroup(ce,e,tp) local mf=ce:GetValue() res=Duel.IsExistingMatchingCard(c44394295.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,mf,chkf) end end return res end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function c44394295.activate(e,tp,eg,ep,ev,re,r,rp) local chkf=Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and PLAYER_NONE or tp local loc=LOCATION_HAND+LOCATION_MZONE if Duel.IsExistingMatchingCard(c44394295.cfilter,tp,0,LOCATION_MZONE,1,nil) then loc=loc+LOCATION_DECK end local mg1=Duel.GetMatchingGroup(c44394295.filter1,tp,loc,0,nil,e) local sg1=Duel.GetMatchingGroup(c44394295.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf) local mg2=nil local sg2=nil local ce=Duel.GetChainMaterial(tp) if ce~=nil then local fgroup=ce:GetTarget() mg2=fgroup(ce,e,tp) local mf=ce:GetValue() sg2=Duel.GetMatchingGroup(c44394295.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,chkf) end if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then local sg=sg1:Clone() if sg2 then sg:Merge(sg2) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tg=sg:Select(tp,1,1,nil) local tc=tg:GetFirst() if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf) tc:SetMaterial(mat1) Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) Duel.BreakEffect() Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP) else local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,nil,chkf) local fop=ce:GetOperation() fop(ce,e,tp,tc,mat2) end tc:CompleteProcedure() else local cg1=Duel.GetFieldGroup(tp,LOCATION_HAND+LOCATION_MZONE,0) local cg2=Duel.GetFieldGroup(tp,LOCATION_DECK,0) local cg3=Duel.GetFieldGroup(tp,LOCATION_EXTRA,0) if cg1:GetCount()>1 and cg3:IsExists(Card.IsFacedown,1,nil) and Duel.IsPlayerCanSpecialSummon(tp) and not Duel.IsPlayerAffectedByEffect(tp,27581098) then Duel.ConfirmCards(1-tp,cg1) if bit.band(loc,LOCATION_DECK)==LOCATION_DECK and not Duel.IsPlayerAffectedByEffect(tp,EFFECT_CANNOT_DISCARD_DECK) then Duel.ConfirmCards(1-tp,cg2) Duel.ShuffleDeck(tp) end Duel.ConfirmCards(1-tp,cg3) Duel.ShuffleHand(tp) end end end
gpl-2.0
zwhfly/openwrt-luci
libs/lucid-rpc/luasrc/lucid/rpc.lua
52
1197
--[[ LuCI - Lua Development Framework Copyright 2009 Steven Barth <steven@midlink.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id$ ]] local require, ipairs, pcall = require, ipairs, pcall local srv = require "luci.lucid.rpc.server" module "luci.lucid.rpc" --- Prepare the RPC-daemon and its associated publishers. -- @param publisher Table of publishers -- @return factory callback or nil, error message function factory(publisher) local root = srv.Module() local server = srv.Server(root) for _, r in ipairs(publisher) do for _, m in ipairs(r.export) do local s, mod = pcall(require, r.namespace .. "." .. m) if s and mod then local module = mod._factory() if r.exec then for _, x in ipairs(r.exec) do if x:sub(1,1) == ":" then module:restrict({interface = x:sub(2)}) else module:restrict({user = x}) end end end root:add(m, module) else return nil, mod end end end return function(...) return server:process(...) end end
apache-2.0
freifunk-gluon/luci
libs/lucid-rpc/luasrc/lucid/rpc.lua
52
1197
--[[ LuCI - Lua Development Framework Copyright 2009 Steven Barth <steven@midlink.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id$ ]] local require, ipairs, pcall = require, ipairs, pcall local srv = require "luci.lucid.rpc.server" module "luci.lucid.rpc" --- Prepare the RPC-daemon and its associated publishers. -- @param publisher Table of publishers -- @return factory callback or nil, error message function factory(publisher) local root = srv.Module() local server = srv.Server(root) for _, r in ipairs(publisher) do for _, m in ipairs(r.export) do local s, mod = pcall(require, r.namespace .. "." .. m) if s and mod then local module = mod._factory() if r.exec then for _, x in ipairs(r.exec) do if x:sub(1,1) == ":" then module:restrict({interface = x:sub(2)}) else module:restrict({user = x}) end end end root:add(m, module) else return nil, mod end end end return function(...) return server:process(...) end end
apache-2.0
anshkumar/yugioh-glaze
assets/script/c23535429.lua
3
1252
--牙城のガーディアン function c23535429.initial_effect(c) --defup local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(23535429,0)) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCategory(CATEGORY_ATKCHANGE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetHintTiming(TIMING_DAMAGE_STEP) e1:SetRange(LOCATION_HAND) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP) e1:SetCondition(c23535429.condition) e1:SetCost(c23535429.cost) e1:SetOperation(c23535429.operation) c:RegisterEffect(e1) end function c23535429.condition(e,tp,eg,ep,ev,re,r,rp) local phase=Duel.GetCurrentPhase() if phase~=PHASE_DAMAGE or Duel.IsDamageCalculated() then return false end local d=Duel.GetAttackTarget() return d and d:IsControler(tp) and d:IsDefencePos() end function c23535429.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToGraveAsCost() end Duel.SendtoGrave(e:GetHandler(),REASON_COST) end function c23535429.operation(e,tp,eg,ep,ev,re,r,rp) local d=Duel.GetAttackTarget() if not d:IsRelateToBattle() then return end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_DEFENCE) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) e1:SetValue(1500) d:RegisterEffect(e1) end
gpl-2.0
shirat74/sile
lua-libraries/repl/plugins/pretty_print.lua
6
6597
-- Copyright (c) 2011-2014 Rob Hoelz <rob@hoelz.ro> -- -- Permission is hereby granted, free of charge, to any person obtaining a copy of -- this software and associated documentation files (the "Software"), to deal in -- the Software without restriction, including without limitation the rights to -- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -- the Software, and to permit persons to whom the Software is furnished to do so, -- subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- Pretty prints expression results (console only) local format = string.format local tconcat = table.concat local tsort = table.sort local tostring = tostring local type = type local floor = math.floor local pairs = pairs local ipairs = ipairs local error = error local stderr = io.stderr pcall(require, 'luarocks.require') local ok, term = pcall(require, 'term') if not ok then term = nil end local keywords = { ['and'] = true, ['break'] = true, ['do'] = true, ['else'] = true, ['elseif'] = true, ['end'] = true, ['false'] = true, ['for'] = true, ['function'] = true, ['if'] = true, ['in'] = true, ['local'] = true, ['nil'] = true, ['not'] = true, ['or'] = true, ['repeat'] = true, ['return'] = true, ['then'] = true, ['true'] = true, ['until'] = true, ['while'] = true, } local function compose(f, g) return function(...) return f(g(...)) end end local emptycolormap = setmetatable({}, { __index = function() return function(s) return s end end}) local colormap = emptycolormap if term then colormap = { ['nil'] = term.colors.blue, string = term.colors.yellow, punctuation = compose(term.colors.green, term.colors.bright), ident = term.colors.red, boolean = term.colors.green, number = term.colors.cyan, path = term.colors.white, misc = term.colors.magenta, } end local function isinteger(n) return type(n) == 'number' and floor(n) == n end local function isident(s) return type(s) == 'string' and not keywords[s] and s:match('^[a-zA-Z_][a-zA-Z0-9_]*$') end -- most of these are arbitrary, I *do* want numbers first, though local type_order = { number = 0, string = 1, userdata = 2, table = 3, thread = 4, boolean = 5, ['function'] = 6, } local function cross_type_order(a, b) local pos_a = type_order[ type(a) ] local pos_b = type_order[ type(b) ] if pos_a == pos_b then return a < b else return pos_a < pos_b end end local function sortedpairs(t) local keys = {} local seen_non_string for k in pairs(t) do keys[#keys + 1] = k if not seen_non_string and type(k) ~= 'string' then seen_non_string = true end end local sort_func = seen_non_string and cross_type_order or nil tsort(keys, sort_func) local index = 1 return function() if keys[index] == nil then return nil else local key = keys[index] local value = t[key] index = index + 1 return key, value end end, keys end local function find_longstring_nest_level(s) local level = 0 while s:find(']' .. string.rep('=', level) .. ']', 1, true) do level = level + 1 end return level end local function dump(params) local pieces = params.pieces local seen = params.seen local path = params.path local v = params.value local indent = params.indent local t = type(v) if t == 'nil' or t == 'boolean' or t == 'number' then pieces[#pieces + 1] = colormap[t](tostring(v)) elseif t == 'string' then if v:match '\n' then local level = find_longstring_nest_level(v) pieces[#pieces + 1] = colormap.string('[' .. string.rep('=', level) .. '[' .. v .. ']' .. string.rep('=', level) .. ']') else pieces[#pieces + 1] = colormap.string(format('%q', v)) end elseif t == 'table' then if seen[v] then pieces[#pieces + 1] = colormap.path(seen[v]) return end seen[v] = path local lastintkey = 0 pieces[#pieces + 1] = colormap.punctuation '{\n' for i, v in ipairs(v) do for j = 1, indent do pieces[#pieces + 1] = ' ' end dump { pieces = pieces, seen = seen, path = path .. '[' .. tostring(i) .. ']', value = v, indent = indent + 1, } pieces[#pieces + 1] = colormap.punctuation ',\n' lastintkey = i end for k, v in sortedpairs(v) do if not (isinteger(k) and k <= lastintkey and k > 0) then for j = 1, indent do pieces[#pieces + 1] = ' ' end if isident(k) then pieces[#pieces + 1] = colormap.ident(k) else pieces[#pieces + 1] = colormap.punctuation '[' dump { pieces = pieces, seen = seen, path = path .. '.' .. tostring(k), value = k, indent = indent + 1, } pieces[#pieces + 1] = colormap.punctuation ']' end pieces[#pieces + 1] = colormap.punctuation ' = ' dump { pieces = pieces, seen = seen, path = path .. '.' .. tostring(k), value = v, indent = indent + 1, } pieces[#pieces + 1] = colormap.punctuation ',\n' end end for j = 1, indent - 1 do pieces[#pieces + 1] = ' ' end pieces[#pieces + 1] = colormap.punctuation '}' else pieces[#pieces + 1] = colormap.misc(tostring(v)) end end repl:requirefeature 'console' function override:displayresults(results) local pieces = {} for i = 1, results.n do dump { pieces = pieces, seen = {}, path = '<topvalue>', value = results[i], indent = 1, } pieces[#pieces + 1] = '\n' end stderr:write(tconcat(pieces, '')) end
mit
anshkumar/yugioh-glaze
assets/single/QB011.lua
1
1152
--wcs2011-02 Debug.SetAIName("高性能电子头脑") Debug.ReloadFieldBegin(DUEL_ATTACK_FIRST_TURN+DUEL_SIMPLE_AI) Debug.SetPlayerInfo(0,100,0,0) Debug.SetPlayerInfo(1,9300,0,0) Debug.AddCard(1353770,0,0,LOCATION_DECK,0,POS_FACEDOWN) Debug.AddCard(74968065,0,0,LOCATION_HAND,0,POS_FACEDOWN) Debug.AddCard(77527210,0,0,LOCATION_HAND,0,POS_FACEDOWN) Debug.AddCard(12493482,0,0,LOCATION_HAND,0,POS_FACEDOWN) Debug.AddCard(66337215,0,0,LOCATION_HAND,0,POS_FACEDOWN) Debug.AddCard(28573958,0,0,LOCATION_HAND,0,POS_FACEDOWN) Debug.AddCard(56433456,0,0,LOCATION_HAND,0,POS_FACEDOWN) Debug.AddCard(80551130,0,0,LOCATION_SZONE,2,POS_FACEDOWN) Debug.AddCard(56830749,0,0,LOCATION_SZONE,3,POS_FACEDOWN) Debug.AddCard(5645210,0,0,LOCATION_GRAVE,0,POS_FACEUP) Debug.AddCard(55794644,0,0,LOCATION_GRAVE,0,POS_FACEUP) Debug.AddCard(62892347,1,1,LOCATION_MZONE,1,POS_FACEUP_DEFENCE) Debug.AddCard(62892347,1,1,LOCATION_MZONE,2,POS_FACEUP_DEFENCE) Debug.AddCard(62892347,1,1,LOCATION_MZONE,3,POS_FACEUP_DEFENCE) Debug.AddCard(51452091,1,1,LOCATION_SZONE,2,POS_FACEUP) Debug.ReloadFieldEnd() Debug.ShowHint("Win in this turn!") aux.BeginPuzzle()
gpl-2.0
MmxBoy/mmx-anti
plugins/banhammer.lua
294
10470
local function is_user_whitelisted(id) local hash = 'whitelist:user#id'..id local white = redis:get(hash) or false return white end local function is_chat_whitelisted(id) local hash = 'whitelist:chat#id'..id local white = redis:get(hash) or false return white end local function kick_user(user_id, chat_id) local chat = 'chat#id'..chat_id local user = 'user#id'..user_id chat_del_user(chat, user, ok_cb, true) end local function ban_user(user_id, chat_id) -- Save to redis local hash = 'banned:'..chat_id..':'..user_id redis:set(hash, true) -- Kick from chat kick_user(user_id, chat_id) end local function superban_user(user_id, chat_id) -- Save to redis local hash = 'superbanned:'..user_id redis:set(hash, true) -- Kick from chat kick_user(user_id, chat_id) end local function is_banned(user_id, chat_id) local hash = 'banned:'..chat_id..':'..user_id local banned = redis:get(hash) return banned or false end local function is_super_banned(user_id) local hash = 'superbanned:'..user_id local superbanned = redis:get(hash) return superbanned or false end local function pre_process(msg) -- SERVICE MESSAGE if msg.action and msg.action.type then local action = msg.action.type -- Check if banned user joins chat if action == 'chat_add_user' or action == 'chat_add_user_link' then local user_id if msg.action.link_issuer then user_id = msg.from.id else user_id = msg.action.user.id end print('Checking invited user '..user_id) local superbanned = is_super_banned(user_id) local banned = is_banned(user_id, msg.to.id) if superbanned or banned then print('User is banned!') kick_user(user_id, msg.to.id) end end -- No further checks return msg end -- BANNED USER TALKING if msg.to.type == 'chat' then local user_id = msg.from.id local chat_id = msg.to.id local superbanned = is_super_banned(user_id) local banned = is_banned(user_id, chat_id) if superbanned then print('SuperBanned user talking!') superban_user(user_id, chat_id) msg.text = '' end if banned then print('Banned user talking!') ban_user(user_id, chat_id) msg.text = '' end end -- WHITELIST local hash = 'whitelist:enabled' local whitelist = redis:get(hash) local issudo = is_sudo(msg) -- Allow all sudo users even if whitelist is allowed if whitelist and not issudo then print('Whitelist enabled and not sudo') -- Check if user or chat is whitelisted local allowed = is_user_whitelisted(msg.from.id) if not allowed then print('User '..msg.from.id..' not whitelisted') if msg.to.type == 'chat' then allowed = is_chat_whitelisted(msg.to.id) if not allowed then print ('Chat '..msg.to.id..' not whitelisted') else print ('Chat '..msg.to.id..' whitelisted :)') end end else print('User '..msg.from.id..' allowed :)') end if not allowed then msg.text = '' end else print('Whitelist not enabled or is sudo') end return msg end local function username_id(cb_extra, success, result) local get_cmd = cb_extra.get_cmd local receiver = cb_extra.receiver local chat_id = cb_extra.chat_id local member = cb_extra.member local text = 'No user @'..member..' in this group.' for k,v in pairs(result.members) do vusername = v.username if vusername == member then member_username = member member_id = v.id if get_cmd == 'kick' then return kick_user(member_id, chat_id) elseif get_cmd == 'ban user' then send_large_msg(receiver, 'User @'..member..' ['..member_id..'] banned') return ban_user(member_id, chat_id) elseif get_cmd == 'superban user' then send_large_msg(receiver, 'User @'..member..' ['..member_id..'] globally banned!') return superban_user(member_id, chat_id) elseif get_cmd == 'whitelist user' then local hash = 'whitelist:user#id'..member_id redis:set(hash, true) return send_large_msg(receiver, 'User @'..member..' ['..member_id..'] whitelisted') elseif get_cmd == 'whitelist delete user' then local hash = 'whitelist:user#id'..member_id redis:del(hash) return send_large_msg(receiver, 'User @'..member..' ['..member_id..'] removed from whitelist') end end end return send_large_msg(receiver, text) end local function run(msg, matches) if matches[1] == 'kickme' then kick_user(msg.from.id, msg.to.id) end if not is_momod(msg) then return nil end local receiver = get_receiver(msg) if matches[4] then get_cmd = matches[1]..' '..matches[2]..' '..matches[3] elseif matches[3] then get_cmd = matches[1]..' '..matches[2] else get_cmd = matches[1] end if matches[1] == 'ban' then local user_id = matches[3] local chat_id = msg.to.id if msg.to.type == 'chat' then if matches[2] == 'user' then if string.match(matches[3], '^%d+$') then ban_user(user_id, chat_id) send_large_msg(receiver, 'User '..user_id..' banned!') else local member = string.gsub(matches[3], '@', '') chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=chat_id, member=member}) end end if matches[2] == 'delete' then local hash = 'banned:'..chat_id..':'..user_id redis:del(hash) return 'User '..user_id..' unbanned' end else return 'This isn\'t a chat group' end end if matches[1] == 'superban' and is_admin(msg) then local user_id = matches[3] local chat_id = msg.to.id if matches[2] == 'user' then if string.match(matches[3], '^%d+$') then superban_user(user_id, chat_id) send_large_msg(receiver, 'User '..user_id..' globally banned!') else local member = string.gsub(matches[3], '@', '') chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=chat_id, member=member}) end end if matches[2] == 'delete' then local hash = 'superbanned:'..user_id redis:del(hash) return 'User '..user_id..' unbanned' end end if matches[1] == 'kick' then if msg.to.type == 'chat' then if string.match(matches[2], '^%d+$') then kick_user(matches[2], msg.to.id) else local member = string.gsub(matches[2], '@', '') chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member}) end else return 'This isn\'t a chat group' end end if matches[1] == 'whitelist' then if matches[2] == 'enable' and is_sudo(msg) then local hash = 'whitelist:enabled' redis:set(hash, true) return 'Enabled whitelist' end if matches[2] == 'disable' and is_sudo(msg) then local hash = 'whitelist:enabled' redis:del(hash) return 'Disabled whitelist' end if matches[2] == 'user' then if string.match(matches[3], '^%d+$') then local hash = 'whitelist:user#id'..matches[3] redis:set(hash, true) return 'User '..matches[3]..' whitelisted' else local member = string.gsub(matches[3], '@', '') chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member}) end end if matches[2] == 'chat' then if msg.to.type ~= 'chat' then return 'This isn\'t a chat group' end local hash = 'whitelist:chat#id'..msg.to.id redis:set(hash, true) return 'Chat '..msg.to.print_name..' ['..msg.to.id..'] whitelisted' end if matches[2] == 'delete' and matches[3] == 'user' then if string.match(matches[4], '^%d+$') then local hash = 'whitelist:user#id'..matches[4] redis:del(hash) return 'User '..matches[4]..' removed from whitelist' else local member = string.gsub(matches[4], '@', '') chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member}) end end if matches[2] == 'delete' and matches[3] == 'chat' then if msg.to.type ~= 'chat' then return 'This isn\'t a chat group' end local hash = 'whitelist:chat#id'..msg.to.id redis:del(hash) return 'Chat '..msg.to.print_name..' ['..msg.to.id..'] removed from whitelist' end end end return { description = "Plugin to manage bans, kicks and white/black lists.", usage = { user = "!kickme : Exit from group", moderator = { "!whitelist <enable>/<disable> : Enable or disable whitelist mode", "!whitelist user <user_id> : Allow user to use the bot when whitelist mode is enabled", "!whitelist user <username> : Allow user to use the bot when whitelist mode is enabled", "!whitelist chat : Allow everybody on current chat to use the bot when whitelist mode is enabled", "!whitelist delete user <user_id> : Remove user from whitelist", "!whitelist delete chat : Remove chat from whitelist", "!ban user <user_id> : Kick user from chat and kicks it if joins chat again", "!ban user <username> : Kick user from chat and kicks it if joins chat again", "!ban delete <user_id> : Unban user", "!kick <user_id> : Kick user from chat group by id", "!kick <username> : Kick user from chat group by username", }, admin = { "!superban user <user_id> : Kick user from all chat and kicks it if joins again", "!superban user <username> : Kick user from all chat and kicks it if joins again", "!superban delete <user_id> : Unban user", }, }, patterns = { "^!(whitelist) (enable)$", "^!(whitelist) (disable)$", "^!(whitelist) (user) (.*)$", "^!(whitelist) (chat)$", "^!(whitelist) (delete) (user) (.*)$", "^!(whitelist) (delete) (chat)$", "^!(ban) (user) (.*)$", "^!(ban) (delete) (.*)$", "^!(superban) (user) (.*)$", "^!(superban) (delete) (.*)$", "^!(kick) (.*)$", "^!(kickme)$", "^!!tgservice (.+)$", }, run = run, pre_process = pre_process }
gpl-2.0
ld-test/chronos
update_rockspec.lua
2
2435
#!/usr/bin/env lua print("enter a new version:") version = string.match(io.read(), "v?([%d]+.[%d]+-[%d]+)") assert(version ~= nil) rockspec = { package = "chronos", version = version, source = { url = "https://github.com/ldrumm/chronos/archive/v" .. version .. ".zip", dir= "chronos-" .. version, tag = "v" .. version }, description = { summary = "High resolution monotonic timers", detailed = [[Wrappers around a number of platform-specific monotonic timers. The highest resolution timer on each platform is used. This is typically clock_gettime, gettimeofday, QueryPerformanceCounter, or similar depending on the capabilities of the host. On a modern Linux system, nanosecond precision is common. ]], homepage = "https://github.com/ldrumm/chronos", license = "MIT/X11" }, dependencies = { "lua >= 5.1" }, build = { type = "builtin", modules = { chronos = "src/chronos.c", } } } do local function writerockspec(file, rockspec, indent) local comma = indent and "," or "" indent = indent or 0 for k, v in pairs(rockspec) do if type(v) == "table" then file:write("\n") file:write(string.rep("\t", indent) .. string.format("%s = {\n", k)) writerockspec(file, v, indent + 1) file:write(string.rep("\t", indent) .. string.format("}%s\n", comma)) else if(type(k) == "string") then file:write(string.rep("\t", indent) .. string.format("%s = %q%s\n", k, v, comma)) elseif(type(k) == "number") then file:write(string.rep("\t", indent) .. string.format("%q%s\n", v, comma)) else file:write("rockspec can't contain key of type:" .. type(k)) end end end end local update_git while update_git == nil do print(string.format("Do 'git add . && commit -a && git tag v%s'?[yes/NO]", version)) update_git = io.read() == "yes" end local out = io.open(string.format("rockspecs/%s-%s.rockspec", rockspec.package, version ), "w") writerockspec(out, rockspec) out:flush() if update_git then os.execute(string.format('git add . && git commit -a && git tag v%s', version)) end end
mit
aliafshar250/tele7
plugins/ins.lua
1
1211
local Arian = 117625029 local function action_by_reply(extra, success, result) local hash = 'rank:variables' local text = '' local value = redis:hget(hash, result.from.id) if not value then if result.from.id == tonumber(Arian) then text = text..'این بابامه\n\n' elseif is_admin2(result.from.id) then text = text..'این ادمین رباته \n\n' elseif is_owner2(result.from.id, result.to.id) then text = text..'این مدیر کل گروهه \n\n' elseif is_momod2(result.from.id, result.to.id) then text = text..'این مدیر گروهه \n\n' else text = text..' این کاربره دیگه\n\n' end else text = text..'این '..value..' هست \n\n' end send_msg(extra.receiver, text, ok_cb, true) end local function run(msg, matches) local receiver = get_receiver(msg) local user = matches[1] local text = '' if msg.reply_id then msgr = get_message(msg.reply_id, action_by_reply, {receiver=receiver}) else return end end return { patterns = { "in kie", "این کیه", "این کیه؟", }, run = run }
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c82052602.lua
3
2398
--ガガガバック function c82052602.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetHintTiming(0,TIMING_END_PHASE) e1:SetCondition(c82052602.condition) e1:SetTarget(c82052602.target) e1:SetOperation(c82052602.activate) c:RegisterEffect(e1) if not c82052602.global_check then c82052602.global_check=true c82052602[0]=false c82052602[1]=false local ge1=Effect.CreateEffect(c) ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) ge1:SetCode(EVENT_BATTLE_DESTROYED) ge1:SetOperation(c82052602.checkop) Duel.RegisterEffect(ge1,0) local ge2=Effect.CreateEffect(c) ge2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) ge2:SetCode(EVENT_PHASE_START+PHASE_DRAW) ge2:SetOperation(c82052602.clear) Duel.RegisterEffect(ge2,0) end end function c82052602.checkop(e,tp,eg,ep,ev,re,r,rp) local tc=eg:GetFirst() while tc do local pos=tc:GetPosition() if tc:IsSetCard(0x54) and tc:IsLocation(LOCATION_GRAVE) and tc:IsReason(REASON_BATTLE) and tc:GetControler()==tc:GetPreviousControler() then c82052602[tc:GetControler()]=true end tc=eg:GetNext() end end function c82052602.clear(e,tp,eg,ep,ev,re,r,rp) c82052602[0]=false c82052602[1]=false end function c82052602.filter(c,id,e,tp) return c:IsReason(REASON_BATTLE) and c:GetTurnID()==id and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c82052602.condition(e,tp,eg,ep,ev,re,r,rp) return c82052602[tp] and Duel.GetFlagEffect(tp,82052602)==0 end function c82052602.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c82052602.filter,tp,LOCATION_GRAVE,0,1,nil,Duel.GetTurnCount(),e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_GRAVE) Duel.RegisterFlagEffect(tp,82052602,RESET_PHASE+PHASE_END,0,1) end function c82052602.activate(e,tp,eg,ep,ev,re,r,rp) local ft1=Duel.GetLocationCount(tp,LOCATION_MZONE) if ft1==0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c82052602.filter,tp,LOCATION_GRAVE,0,ft1,ft1,nil,Duel.GetTurnCount(),e,tp) if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP_DEFENCE) Duel.BreakEffect() Duel.Damage(tp,g:GetCount()*600,REASON_EFFECT) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c87043568.lua
5
3017
--アサルト・スピリッツ function c87043568.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_EQUIP) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(c87043568.target) e1:SetOperation(c87043568.operation) c:RegisterEffect(e1) end function c87043568.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and chkc:IsFaceup() end if chk==0 then return Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP) Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_MZONE,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0) end function c87043568.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsLocation(LOCATION_SZONE) then return end local tc=Duel.GetFirstTarget() if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsFaceup() then Duel.Equip(tp,c,tc) c:CancelToGrave() --atkup local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(87043568,0)) e1:SetCategory(CATEGORY_ATKCHANGE) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_FREE_CHAIN) e1:SetHintTiming(TIMING_DAMAGE_STEP) e1:SetRange(LOCATION_SZONE) e1:SetCountLimit(1) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP) e1:SetCondition(c87043568.atkcon) e1:SetCost(c87043568.atkcost) e1:SetOperation(c87043568.atkop) e1:SetReset(RESET_EVENT+0x1fe0000) c:RegisterEffect(e1) --Equip limit local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_EQUIP_LIMIT) e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e2:SetValue(c87043568.eqlimit) e2:SetReset(RESET_EVENT+0x1fe0000) e2:SetLabelObject(tc) c:RegisterEffect(e2) end end function c87043568.eqlimit(e,c) return c:GetControler()==e:GetOwnerPlayer() and c==e:GetLabelObject() end function c87043568.atkcon(e,tp,eg,ep,ev,re,r,rp) local a=Duel.GetAttacker() local ph=Duel.GetCurrentPhase() return a==e:GetHandler():GetEquipTarget() and ph==PHASE_DAMAGE and not Duel.IsDamageCalculated() end function c87043568.cfilter(c) return c:IsType(TYPE_MONSTER) and c:IsAttackBelow(1000) and c:IsAbleToGraveAsCost() end function c87043568.atkcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c87043568.cfilter,tp,LOCATION_HAND,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,c87043568.cfilter,tp,LOCATION_HAND,0,1,1,nil) e:SetLabel(g:GetFirst():GetAttack()) Duel.SendtoGrave(g,REASON_COST) end function c87043568.atkop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local a=Duel.GetAttacker() if c:IsRelateToEffect(e) and a:IsRelateToBattle() and a:IsFaceup() then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) e1:SetValue(e:GetLabel()) a:RegisterEffect(e1) end end
gpl-2.0
adan830/UpAndAway
wicker/init/kernel_components/import_essentials.lua
5
5618
--[[ Copyright (C) 2013 simplex This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ]]-- return function() local assert = assert local error = assert( _G.error ) local type = assert( _G.type ) local pcall = assert( _G.pcall ) local function import_stdlib_extensions_into(t) local loadfile = assert( t.loadfile ) function t.loadmodfile(fname) assert( type(fname) == "string", "Non-string given as file path." ) return loadfile(MODROOT .. fname) end local loadmodfile = loadmodfile function t.domodfile(fname) return assert( loadmodfile(fname) )() end local domodfile = t.domodfile --[[ -- Mimics Lua 5.2 behaviour, and extends next(). --]] local getmetatable = assert( t.getmetatable ) local rawget = assert( t.rawget ) local oldnext = assert( t.next ) function t.next(u, k) local m = getmetatable(u) if m ~= nil then local n = rawget(m, "__next") if n ~= nil then return n(u, k) end end return oldnext(u, k) end local oldipairs = assert( t.ipairs ) function t.ipairs(u) local m = getmetatable(u) if m ~= nil then local ip = rawget(m, "__ipairs") if ip ~= nil then return ip(u) end end return oldipairs(u) end local oldpairs = assert( t.pairs ) function t.pairs(u) local m = getmetatable(u) if m ~= nil then local p = rawget(m, "__pairs") if p ~= nil then return p(u) end end return oldpairs(u) end end local function import_stdlib_patches_into(t) local function loadfile(fname) assert( type(fname) == "string", "Non-string given as a file path." ) local status, f = pcall(_G.kleiloadlua, fname) if not status or type(f) ~= "function" then if f then return nil, tostring(f) else return nil, ("Can't load " .. fname) end else return f end end t.loadfile = loadfile t.dofile = function(fpath) return assert( loadfile(fpath) )() end end local function import_stdlib_into(t) t.assert = assert( _G.assert ) -- t.collectgarbage = assert( _G.collectgarbage ) -- dofile() gets set up later t.error = assert( _G.error ) t.getfenv = assert( _G.getfenv ) t.getmetatable = assert( _G.getmetatable ) t.ipairs = assert( _G.ipairs ) t.load = assert( _G.load ) -- loadfile() gets set up later t.loadstring = assert( _G.loadstring ) t.module = assert( _G.module ) t.next = assert( _G.next ) t.pairs = assert( _G.pairs ) t.pcall = assert( _G.pcall ) t.print = assert( _G.print ) t.rawequal = assert( _G.rawequal ) t.rawget = assert( _G.rawget ) t.rawset = assert( _G.rawset ) t.require = assert( _G.require ) t.select = assert( _G.select ) t.setfenv = assert( _G.setfenv ) t.setmetatable = assert( _G.setmetatable ) t.tonumber = assert( _G.tonumber ) t.tostring = assert( _G.tostring ) t.type = assert( _G.type ) t.unpack = assert( _G.unpack ) t.xpcall = assert( _G.xpcall ) t.coroutine = assert( _G.coroutine ) t.debug = assert( _G.debug ) t.io = assert( _G.io ) t.math = assert( _G.math ) t.package = assert( _G.package ) t.string = assert( _G.string ) t.table = assert( _G.table ) t.os = {} assert( _G.os ) for _, k in ipairs { "clock", "date", "difftime", "time", } do t.os[k] = assert( _G.os[k] ) end t._G = _G import_stdlib_patches_into(t) end -- Works even if this is called on worldgen, etc. local function import_game_essentials_into(t) --[[ -- These are loaded right away into the environment. -- The main reason for NOT including something here -- is if it doesn't exist during worldgen. --]] local mandatory_imports = { "print", "Class", "Vector3", "Point", "TUNING", "STRINGS", "GROUND", "distsq", "Prefab", } --[[ -- These are loaded on the fly, IF they exist. --]] local optional_imports = { "nolineprint", "TheSim", "WorldSim", "TheFrontEnd", "SaveIndex", "SaveGameIndex", "TheWorld", "TheNet", "LEVELTYPE", "KEYS", "LOCKS", "EntityScript", "CreateEntity", "SpawnPrefab", "DebugSpawn", "PrefabExists", "GetGroundTypeAtPosition", "ACTIONS", "Action", "BufferedAction", "Sleep", "Yield", } local import_filter = {} for _, k in ipairs(mandatory_imports) do import_filter[k] = true end for _, k in ipairs(optional_imports) do import_filter[k] = true end local raw_G = setmetatable({}, { __index = function(_, k) return rawget(_G, k) end, }) AttachMetaIndex(LazyCopier(raw_G, import_filter), t) for _, k in ipairs(mandatory_imports) do assert( rawget(_G, k) ~= nil, ("The mandatory import %q doesn't exist!"):format(k) ) assert( t[k] ~= nil ) end if not VarExists("nolineprint") then function _M.nolineprint(...) return print(...) end end t.GLOBAL = _G end function ImportEssentialsInto(t) import_stdlib_into(t) import_stdlib_extensions_into(t) import_game_essentials_into(t) end AddVariableCleanup("ImportEssentialsInto") end
gpl-2.0
m-a-hicks/Simulacrum
Resources/Lua/ResourceTemplate.lua
1
1452
--============================================================================== ------------------------- Generic Resource Template ---------------------------- --============================================================================== -- Clear and Initialise the resource (called at creation) -- No return value function clear(resource) resource:getRoot():NodeName("ResourceTemplateTest") end -- RETURNS: true if the path is a valid resource of this type, false otherwise function isValid(resource) return true; end -- Load any data that is required for correct behaviour (e.g. meta-data) -- No return value function load(resource) end -- store any data that is required for correct behaviour (e.g. meta-data) -- No return value function store(resource) end -- refresh the state of the object, deep->bool (deep or shallow) -- No return value function refresh(resource, deep) end -- RETURNS: a string containing information about the path within this resource function getInfo(resource, path) return "This is a test piece of resource information." end -- RETURNS: a boolean expressing whether or not path contains an SSpace function hasSSpace(resource, path) return true end -- RETURNS: a boolean expressing whether the meta-data tree represents and arch function hasArchive(resource) return false end -- Loads the SSpace at Path into the target SSpace -- No return value function getSSpaceInto(resource, target, path) end
lgpl-3.0
BenWhitehead/dcos
packages/adminrouter/extra/src/lib/cache.lua
2
23286
local cjson_safe = require "cjson.safe" local shmlock = require "resty.lock" local http = require "resty.http" local resolver = require "resty.resolver" local util = require "util" -- In order to make caching code testable, these constants need to be -- configurable/exposed through env vars. -- -- Values assigned to these variable need to fufil following condition: -- -- CACHE_FIRST_POLL_DELAY << CACHE_EXPIRATION < CACHE_POLL_PERIOD < CACHE_MAX_AGE_SOFT_LIMIT < CACHE_MAX_AGE_HARD_LIMIT -- -- CACHE_BACKEND_REQUEST_TIMEOUT << CACHE_REFRESH_LOCK_TIMEOUT -- -- Before changing CACHE_POLL_INTERVAL, please check the comment for resolver -- statement configuration in includes/http/master.conf -- -- All are in units of seconds. Below are the defaults: local _CONFIG = {} local env_vars = {CACHE_FIRST_POLL_DELAY = 2, CACHE_POLL_PERIOD = 25, CACHE_EXPIRATION = 20, CACHE_MAX_AGE_SOFT_LIMIT = 75, CACHE_MAX_AGE_HARD_LIMIT = 259200, CACHE_BACKEND_REQUEST_TIMEOUT = 10, CACHE_REFRESH_LOCK_TIMEOUT = 20, } for key, value in pairs(env_vars) do -- yep, we are OK with key==nil, tonumber will just return nil local env_var_val = tonumber(os.getenv(key)) if env_var_val == nil or env_var_val == value then ngx.log(ngx.DEBUG, "Using default ".. key .. " value: `" .. value .. "` seconds") _CONFIG[key] = value else ngx.log(ngx.NOTICE, key .. " overridden by ENV to `" .. env_var_val .. "` seconds") _CONFIG[key] = env_var_val end end local function cache_data(key, value) -- Store key/value pair to SHM cache (shared across workers). -- Return true upon success, false otherwise. -- Expected to run within lock context. local cache = ngx.shared.cache local success, err, forcible = cache:set(key, value) if success then return true end ngx.log( ngx.ERR, "Could not store " .. key .. " to state cache: " .. err ) return false end local function request(url, accept_404_reply, auth_token) local headers = {} if auth_token ~= nil then headers = {["Authorization"] = "token=" .. auth_token} end -- Use cosocket-based HTTP library, as ngx subrequests are not available -- from within this code path (decoupled from nginx' request processing). -- The timeout parameter is given in milliseconds. The `request_uri` -- method takes care of parsing scheme, host, and port from the URL. local httpc = http.new() httpc:set_timeout(_CONFIG.CACHE_BACKEND_REQUEST_TIMEOUT * 1000) local res, err = httpc:request_uri(url, { method="GET", headers=headers, ssl_verify=true }) if not res then return nil, err end if res.status ~= 200 then if accept_404_reply and res.status ~= 404 or not accept_404_reply then return nil, "invalid response status: " .. res.status end end ngx.log( ngx.NOTICE, "Request url: " .. url .. " " .. "Response Body length: " .. string.len(res.body) .. " bytes." ) return res, nil end local function is_ip_per_task(app) return app["ipAddress"] ~= nil and app["ipAddress"] ~= cjson_safe.null end local function is_user_network(app) local container = app["container"] return container and container["type"] == "DOCKER" and container["docker"]["network"] == "USER" end local function fetch_and_store_marathon_apps(auth_token) -- Access Marathon through localhost. ngx.log(ngx.NOTICE, "Cache Marathon app state") local appsRes, err = request(UPSTREAM_MARATHON .. "/v2/apps?embed=apps.tasks&label=DCOS_SERVICE_NAME", false, auth_token) if err then ngx.log(ngx.NOTICE, "Marathon app request failed: " .. err) return end local apps, err = cjson_safe.decode(appsRes.body) if not apps then ngx.log(ngx.WARN, "Cannot decode Marathon apps JSON: " .. err) return end local svcApps = {} for _, app in ipairs(apps["apps"]) do local appId = app["id"] local labels = app["labels"] if not labels then ngx.log(ngx.NOTICE, "Labels not found in app '" .. appId .. "'") goto continue end -- Service name should exist as we asked Marathon for it local svcId = util.normalize_service_name(labels["DCOS_SERVICE_NAME"]) local scheme = labels["DCOS_SERVICE_SCHEME"] if not scheme then ngx.log(ngx.NOTICE, "Cannot find DCOS_SERVICE_SCHEME for app '" .. appId .. "'") goto continue end local portIdx = labels["DCOS_SERVICE_PORT_INDEX"] if not portIdx then ngx.log(ngx.NOTICE, "Cannot find DCOS_SERVICE_PORT_INDEX for app '" .. appId .. "'") goto continue end local portIdx = tonumber(portIdx) if not portIdx then ngx.log(ngx.NOTICE, "Cannot convert port to number for app '" .. appId .. "'") goto continue end -- Lua arrays default starting index is 1 not the 0 of marathon portIdx = portIdx + 1 local tasks = app["tasks"] -- Process only tasks in TASK_RUNNING state. -- From http://lua-users.org/wiki/TablesTutorial: "inside a pairs loop, -- it's safe to reassign existing keys or remove them" for i, t in ipairs(tasks) do if t["state"] ~= "TASK_RUNNING" then table.remove(tasks, i) end end -- next() returns nil if table is empty. local i, task = next(tasks) if i == nil then ngx.log(ngx.NOTICE, "No task in state TASK_RUNNING for app '" .. appId .. "'") goto continue end ngx.log( ngx.NOTICE, "Reading state for appId '" .. appId .. "' from task with id '" .. task["id"] .. "'" ) local host_or_ip = task["host"] --take host by default if is_ip_per_task(app) then ngx.log(ngx.NOTICE, "app '" .. appId .. "' is using ip-per-task") -- override with the ip of the task local task_ip_addresses = task["ipAddresses"] if task_ip_addresses then host_or_ip = task_ip_addresses[1]["ipAddress"] else ngx.log(ngx.NOTICE, "no ip address allocated yet for app '" .. appId .. "'") goto continue end end if not host_or_ip then ngx.log(ngx.NOTICE, "Cannot find host or ip for app '" .. appId .. "'") goto continue end local ports = task["ports"] --task host port mapping by default if is_ip_per_task(app) then ports = {} if is_user_network(app) then -- override with ports from the container's portMappings local port_mappings = app["container"]["docker"]["portMappings"] or app["portDefinitions"] or {} local port_attr = app["container"]["docker"]["portMappings"] and "containerPort" or "port" for _, port_mapping in ipairs(port_mappings) do table.insert(ports, port_mapping[port_attr]) end else --override with the discovery ports local discovery_ports = app["ipAddress"]["discovery"]["ports"] for _, discovery_port in ipairs(discovery_ports) do table.insert(ports, discovery_port["number"]) end end end if not ports then ngx.log(ngx.NOTICE, "Cannot find ports for app '" .. appId .. "'") goto continue end local port = ports[portIdx] if not port then ngx.log(ngx.NOTICE, "Cannot find port at Marathon port index '" .. (portIdx - 1) .. "' for app '" .. appId .. "'") goto continue end local url = scheme .. "://" .. host_or_ip .. ":" .. port svcApps[svcId] = {scheme=scheme, url=url} ::continue:: end svcApps_json = cjson_safe.encode(svcApps) ngx.log(ngx.DEBUG, "Storing Marathon apps data to SHM.") if not cache_data("svcapps", svcApps_json) then ngx.log(ngx.ERR, "Storing marathon apps cache failed") return end ngx.update_time() local time_now = ngx.now() if cache_data("svcapps_last_refresh", time_now) then ngx.log(ngx.INFO, "Marathon apps cache has been successfully updated") end return end local function fetch_and_store_marathon_leader(auth_token) -- Fetch Marathon leader address. If successful, store to SHM cache. -- Expected to run within lock context. local mleaderRes, err = request(UPSTREAM_MARATHON .. "/v2/leader", true, auth_token) if err then ngx.log(ngx.WARN, "Marathon leader request failed: " .. err) return end -- We need to translate 404 reply into a JSON that is easy to process for -- endpoints: -- https://mesosphere.github.io/marathon/docs/rest-api.html#get-v2-leader local res_body if mleaderRes.status == 404 then -- Just a hack in order to avoid using gotos - create a substitute JSON -- that can be parsed and processed by normal execution path and at the -- same time passes the information of a missing Marathon leader. ngx.log(ngx.NOTICE, "Using empty Marathon leader JSON") res_body = '{"leader": "not elected:0"}' else res_body = mleaderRes.body end local mleader, err = cjson_safe.decode(res_body) if not mleader then ngx.log(ngx.WARN, "Cannot decode Marathon leader JSON: " .. err) return end local split_mleader = mleader['leader']:split(":") local parsed_mleader = {} parsed_mleader["address"] = split_mleader[1] parsed_mleader["port"] = split_mleader[2] local mleader = cjson_safe.encode(parsed_mleader) ngx.log(ngx.DEBUG, "Storing Marathon leader to SHM") if not cache_data("marathonleader", mleader) then ngx.log(ngx.ERR, "Storing Marathon leader cache failed") return end ngx.update_time() local time_now = ngx.now() if cache_data("marathonleader_last_refresh", time_now) then ngx.log(ngx.INFO, "Marathon leader cache has been successfully updated") end return end local function fetch_and_store_state_mesos(auth_token) -- Fetch state JSON summary from Mesos. If successful, store to SHM cache. -- Expected to run within lock context. local response, err = request(UPSTREAM_MESOS .. "/master/state-summary", false, auth_token) if err then ngx.log(ngx.NOTICE, "Mesos state request failed: " .. err) return end local raw_state_summary, err = cjson_safe.decode(response.body) if not raw_state_summary then ngx.log(ngx.WARN, "Cannot decode Mesos state-summary JSON: " .. err) return end local parsed_state_summary = {} parsed_state_summary['f_by_id'] = {} parsed_state_summary['f_by_name'] = {} parsed_state_summary['agent_pids'] = {} for _, framework in ipairs(raw_state_summary["frameworks"]) do local f_id = framework["id"] local f_name = util.normalize_service_name(framework["name"]) parsed_state_summary['f_by_id'][f_id] = {} parsed_state_summary['f_by_id'][f_id]['webui_url'] = framework["webui_url"] parsed_state_summary['f_by_id'][f_id]['name'] = f_name parsed_state_summary['f_by_name'][f_name] = {} parsed_state_summary['f_by_name'][f_name]['webui_url'] = framework["webui_url"] end for _, agent in ipairs(raw_state_summary["slaves"]) do a_id = agent["id"] parsed_state_summary['agent_pids'][a_id] = agent["pid"] end local parsed_state_summary_json = cjson_safe.encode(parsed_state_summary) ngx.log(ngx.DEBUG, "Storing parsed Mesos state to SHM.") if not cache_data("mesosstate", parsed_state_summary_json) then ngx.log(ngx.WARN, "Storing parsed Mesos state to cache failed") return end ngx.update_time() local time_now = ngx.now() if cache_data("mesosstate_last_refresh", time_now) then ngx.log(ngx.INFO, "Mesos state cache has been successfully updated") end return end local function fetch_and_store_mesos_leader_state() -- Lua forbids jumping over local variables definition, hence we define all -- of them here. local res_body, r, err, answers if HOST_IP == 'unknown' then ngx.log(ngx.ERR, "Local Mesos Master IP address is unknown, cache entry is unusable") res_body = '{"is_local": "unknown", "leader_ip": null}' goto store_cache end -- We want to use Navstar's dual-dispatch approach and get the response -- as fast as possible from any operational MesosDNS. If we set it to local -- instance, its failure will break this part of the cache as well. -- -- As for the DNS TTL - we're on purpose ignoring it and going with own -- refresh cycle period. Assuming that Navstar and MesosDNS do not do -- caching on their own, we just treat DNS as an interface to obtain -- current mesos leader data. How long we cache it is just an internal -- implementation detail of AR. -- -- Also, see https://github.com/openresty/lua-resty-dns#limitations r, err = resolver:new{ nameservers = {{"198.51.100.1", 53}, {"198.51.100.2", 53}, {"198.51.100.3", 53}}, retrans = 3, -- retransmissions on receive timeout timeout = 2000, -- msec } if not r then ngx.log(ngx.ERR, "Failed to instantiate the resolver: " .. err) return end answers, err = r:query("leader.mesos") if not answers then ngx.log(ngx.ERR, "Failed to query the DNS server: " .. err) return end if answers.errcode then ngx.log(ngx.ERR, "DNS server returned error code: " .. answers.errcode .. ": " .. answers.errstr) return end if util.table_len(answers) == 0 then ngx.log(ngx.ERR, "DNS server did not return anything for leader.mesos") return end -- Yes, we are assuming that leader.mesos will always be just one A entry. -- AAAA support is a different thing... if answers[1].address == HOST_IP then res_body = '{"is_local": "yes", "leader_ip": "'.. HOST_IP ..'"}' ngx.log(ngx.INFO, "Mesos Leader is local") else res_body = '{"is_local": "no", "leader_ip": "'.. answers[1].address ..'"}' ngx.log(ngx.INFO, "Mesos Leader is non-local: `" .. answers[1].address .. "`") end ::store_cache:: if not cache_data("mesos_leader", res_body) then ngx.log(ngx.ERR, "Storing `Mesos Leader` state cache failed") return end ngx.update_time() local time_now = ngx.now() if cache_data("mesos_leader_last_refresh", time_now) then ngx.log(ngx.INFO, "`Mesos Leader` state cache has been successfully updated") end return end local function refresh_needed(ts_name) -- ts_name (str): name of the '*_last_refresh' timestamp to check local cache = ngx.shared.cache local last_fetch_time = cache:get(ts_name) -- Handle the special case of first invocation. if not last_fetch_time then ngx.log(ngx.INFO, "Cache `".. ts_name .. "` empty. Fetching.") return true end ngx.update_time() local cache_age = ngx.now() - last_fetch_time if cache_age > _CONFIG.CACHE_EXPIRATION then ngx.log(ngx.INFO, "Cache `".. ts_name .. "` expired. Refresh.") return true end ngx.log(ngx.DEBUG, "Cache `".. ts_name .. "` populated and fresh. NOOP.") return false end local function refresh_cache(from_timer, auth_token) -- Refresh cache in case when it expired or has not been created yet. -- Use SHM-based lock for synchronizing coroutines across worker processes. -- -- This function can be invoked via two mechanisms: -- -- * Via ngx.timer (in a coroutine), which is triggered -- periodically in all worker processes for performing an -- out-of-band cache refresh (this is the usual mode of operation). -- In that case, perform cache invalidation only if no other timer -- instance currently does so (abort if lock cannot immediately be -- acquired). -- -- * During HTTP request processing, when cache content is -- required for answering the request but the cache was not -- populated yet (i.e. usually early after nginx startup). -- In that case, return from this function only after the cache -- has been populated (block on lock acquisition). -- -- Args: -- from_timer: set to true if invoked from a timer -- Acquire lock. local lock -- In order to avoid deadlocks, we are relying on `exptime` param of -- resty.lock (https://github.com/openresty/lua-resty-lock#new) -- -- It's value is maximum time it may take to fetch data from all the -- backends (ATM 2xMarathon + Mesos) plus an arbitrary two seconds period -- just to be on the safe side. local lock_ttl = 3 * (_CONFIG.CACHE_BACKEND_REQUEST_TIMEOUT + 2) if from_timer then ngx.log(ngx.INFO, "Executing cache refresh triggered by timer") -- Fail immediately if another worker currently holds -- the lock, because a single timer-based update at any -- given time suffices. lock = shmlock:new("shmlocks", {timeout=0, exptime=lock_ttl}) local elapsed, err = lock:lock("cache") if elapsed == nil then ngx.log(ngx.INFO, "Timer-based update is in progress. NOOP.") return end else ngx.log(ngx.INFO, "Executing cache refresh triggered by request") -- Cache content is required for current request -- processing. Wait for lock acquisition, for at -- most 20 seconds. lock = shmlock:new("shmlocks", {timeout=_CONFIG.CACHE_REFRESH_LOCK_TIMEOUT, exptime=lock_ttl }) local elapsed, err = lock:lock("cache") if elapsed == nil then ngx.log(ngx.ERR, "Could not acquire lock: " .. err) -- Leave early (did not make sure that cache is populated). return end end if refresh_needed("mesosstate_last_refresh") then fetch_and_store_state_mesos(auth_token) end if refresh_needed("svcapps_last_refresh") then fetch_and_store_marathon_apps(auth_token) end if refresh_needed("marathonleader_last_refresh") then fetch_and_store_marathon_leader(auth_token) end if refresh_needed("mesos_leader_last_refresh") then fetch_and_store_mesos_leader_state() end local ok, err = lock:unlock() if not ok then -- If this fails, an unlock happens automatically via `exptime` lock -- param described earlier. ngx.log(ngx.ERR, "Failed to unlock cache shmlock: " .. err) end end local function periodically_refresh_cache(auth_token) -- This function is invoked from within init_worker_by_lua code. -- ngx.timer.at() can be called here, whereas most of the other ngx.* -- API is not available. timerhandler = function(premature) -- Handler for recursive timer invocation. -- Within a timer callback, plenty of the ngx.* API is available, -- with the exception of e.g. subrequests. As ngx.sleep is also not -- available in the current context, the recommended approach of -- implementing periodic tasks is via recursively defined timers. -- Premature timer execution: worker process tries to shut down. if premature then return end -- Invoke timer business logic. refresh_cache(true, auth_token) -- Register new timer. local ok, err = ngx.timer.at(_CONFIG.CACHE_POLL_PERIOD, timerhandler) if not ok then ngx.log(ngx.ERR, "Failed to create timer: " .. err) else ngx.log(ngx.INFO, "Created recursive timer for cache updating.") end end -- Trigger initial timer, about CACHE_FIRST_POLL_DELAY seconds after -- Nginx startup. local ok, err = ngx.timer.at(_CONFIG.CACHE_FIRST_POLL_DELAY, timerhandler) if not ok then ngx.log(ngx.ERR, "Failed to create timer: " .. err) return else ngx.log(ngx.INFO, "Created initial recursive timer for cache updating.") end end local function get_cache_entry(name, auth_token) local cache = ngx.shared.cache local name_last_refresh = name .. "_last_refresh" -- Handle the special case of very early request - before the first -- timer-based cache refresh local entry_last_refresh = cache:get(name_last_refresh) if entry_last_refresh == nil then refresh_cache(false, auth_token) entry_last_refresh = cache:get(name .. "_last_refresh") if entry_last_refresh == nil then -- Something is really broken, abort! ngx.log(ngx.ERR, "Could not retrieve last refresh time for `" .. name .. "` cache entry") return nil end end -- Check the clock ngx.update_time() local cache_age = ngx.now() - entry_last_refresh -- Cache is too old, we can't use it: if cache_age > _CONFIG.CACHE_MAX_AGE_HARD_LIMIT then ngx.log(ngx.ERR, "Cache entry `" .. name .. "` is too old, aborting request") return nil end -- Cache is stale, but still usable: if cache_age > _CONFIG.CACHE_MAX_AGE_SOFT_LIMIT then ngx.log(ngx.NOTICE, "Cache entry `" .. name .. "` is stale") end local entry_json = cache:get(name) if entry_json == nil then ngx.log(ngx.ERR, "Could not retrieve `" .. name .. "` cache entry from SHM") return nil end local entry, err = cjson_safe.decode(entry_json) if entry == nil then ngx.log(ngx.ERR, "Cannot decode JSON for entry `" .. entry_json .. "`: " .. err) return nil end return entry end -- Expose Admin Router cache interface local _M = {} function _M.init(auth_token) -- At some point auth_token passing will be refactored out in -- favour of service accounts support. local res = {} if auth_token ~= nil then -- auth_token variable is needed by a few functions which are -- nested inside top-level ones. We can either define all the functions -- inside the same lexical block, or we pass it around. Passing it -- around seems cleaner. res.get_cache_entry = function (name) return get_cache_entry(name, auth_token) end res.periodically_refresh_cache = function() return periodically_refresh_cache(auth_token) end else res.get_cache_entry = get_cache_entry res.periodically_refresh_cache = periodically_refresh_cache end return res end return _M
apache-2.0
anshkumar/yugioh-glaze
assets/script/c67616300.lua
3
3631
--チキンレース function c67616300.initial_effect(c) --activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) --change damage local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetRange(LOCATION_FZONE) e2:SetCode(EFFECT_CHANGE_DAMAGE) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e2:SetTargetRange(1,0) e2:SetCondition(c67616300.damcon1) e2:SetValue(0) c:RegisterEffect(e2) local e7=e2:Clone() e7:SetCode(EFFECT_NO_EFFECT_DAMAGE) c:RegisterEffect(e7) local e3=e2:Clone() e3:SetTargetRange(0,1) e3:SetCondition(c67616300.damcon2) c:RegisterEffect(e3) local e8=e3:Clone() e8:SetCode(EFFECT_NO_EFFECT_DAMAGE) c:RegisterEffect(e8) --draw local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(67616300,0)) e4:SetCategory(CATEGORY_DRAW) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetRange(LOCATION_FZONE) e4:SetProperty(EFFECT_FLAG_BOTH_SIDE+EFFECT_FLAG_PLAYER_TARGET) e4:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE) e4:SetCost(c67616300.effcost) e4:SetTarget(c67616300.drtg) e4:SetOperation(c67616300.drop) c:RegisterEffect(e4) --destroy local e5=Effect.CreateEffect(c) e5:SetDescription(aux.Stringid(67616300,1)) e5:SetCategory(CATEGORY_DESTROY) e5:SetType(EFFECT_TYPE_IGNITION) e5:SetRange(LOCATION_FZONE) e5:SetProperty(EFFECT_FLAG_BOTH_SIDE) e5:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE) e5:SetCost(c67616300.effcost) e5:SetTarget(c67616300.destg) e5:SetOperation(c67616300.desop) c:RegisterEffect(e5) --recover local e6=Effect.CreateEffect(c) e6:SetDescription(aux.Stringid(67616300,2)) e6:SetCategory(CATEGORY_RECOVER) e6:SetType(EFFECT_TYPE_IGNITION) e6:SetRange(LOCATION_FZONE) e6:SetProperty(EFFECT_FLAG_BOTH_SIDE+EFFECT_FLAG_PLAYER_TARGET) e6:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE) e6:SetCost(c67616300.effcost) e6:SetTarget(c67616300.rectg) e6:SetOperation(c67616300.recop) c:RegisterEffect(e6) end function c67616300.damcon1(e) local tp=e:GetHandlerPlayer() return Duel.GetLP(tp)<Duel.GetLP(1-tp) end function c67616300.damcon2(e) local tp=e:GetHandlerPlayer() return Duel.GetLP(1-tp)<Duel.GetLP(tp) end function c67616300.effcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckLPCost(tp,1000) end Duel.PayLPCost(tp,1000) Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription()) end function c67616300.drtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) Duel.SetChainLimit(aux.FALSE) end function c67616300.drop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end function c67616300.destg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsDestructable() end Duel.SetOperationInfo(0,CATEGORY_DESTROY,e:GetHandler(),1,0,0) Duel.SetChainLimit(aux.FALSE) end function c67616300.desop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end Duel.Destroy(e:GetHandler(),REASON_EFFECT) end function c67616300.rectg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetTargetPlayer(1-tp) Duel.SetTargetParam(1000) Duel.SetOperationInfo(0,CATEGORY_RECOVER,nil,0,1-tp,1000) Duel.SetChainLimit(aux.FALSE) end function c67616300.recop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Recover(p,d,REASON_EFFECT) end
gpl-2.0
adan830/UpAndAway
code/brains/rambrain.lua
2
2889
BindGlobal() local CFG = TheMod:GetConfig() require "behaviours/wander" require "behaviours/runaway" require "behaviours/doaction" require "behaviours/panic" require "behaviours/chaseandram" require "behaviours/chaseandattack" local RamBrain = Class(Brain, function(self, inst) Brain._ctor(self, inst) end) local function GoHomeAction(inst) if inst.components.homeseeker and inst.components.homeseeker.home and inst.components.homeseeker.home:IsValid() and inst.sg:HasStateTag("trapped") == false then return BufferedAction(inst, inst.components.homeseeker.home, ACTIONS.GOHOME) end end local function GetFaceTargetFn(inst) local homePos = inst.components.knownlocations:GetLocation("home") local myPos = Vector3(inst.Transform:GetWorldPosition() ) if (homePos and distsq(homePos, myPos) > 40*40) then return end local target = GetClosestInstWithTag("player", inst, CFG.RAM.START_FACE_DIST) if target and not target:HasTag("notarget") then return target end end local function KeepFaceTargetFn(inst, target) local homePos = inst.components.knownlocations:GetLocation("home") local myPos = Vector3(inst.Transform:GetWorldPosition() ) if (homePos and distsq(homePos, myPos) > 40*40) then return false end return inst:GetDistanceSqToInst(target) <= CFG.RAM.KEEP_FACE_DIST*CFG.RAM.KEEP_FACE_DIST and not target:HasTag("notarget") end local function EatFoodAction(inst) local target = FindEntity(inst, CFG.RAM.SEE_BAIT_DIST, function(item) return inst.components.eater:CanEat(item) and item.components.bait and not item:HasTag("planted") and not (item.components.inventoryitem and item.components.inventoryitem:IsHeld()) end) if target then local act = BufferedAction(inst, target, ACTIONS.EAT) act.validfn = function() return not (target.components.inventoryitem and target.components.inventoryitem:IsHeld()) end return act end end function RamBrain:OnStart() local clock = GetPseudoClock() local root = PriorityNode( { WhileNode( function() return self.inst.components.combat.target == nil end, "RamAttack", ChaseAndRam(self.inst, CFG.RAM.MAX_CHASE_TIME, CFG.RAM.CHASE_GIVEUP_DIST, CFG.RAM.MAX_CHARGE_DIST) ), WhileNode( function() return self.inst.components.health.takingfiredamage end, "OnFire", Panic(self.inst)), ChaseAndAttack(self.inst, CFG.RAM.MAX_CHASE_TIME, CFG.RAM.MAX_CHASE_DIST), IfNode( function() return self.inst.components.combat.target ~= nil end, "hastarget", AttackWall(self.inst)), DoAction(self.inst, EatFoodAction), Wander(self.inst, function() return self.inst.components.knownlocations:GetLocation("home") end, CFG.RAM.MAX_WANDER_DIST) }, .25) self.bt = BT(self.inst, root) end return RamBrain
gpl-2.0
Arashbrsh/kings-BOT
plugins/anti-spam8.lua
13
2433
local NUM_MSG_MAX = 8 -- Max number of messages per TIME_CHECK seconds local TIME_CHECK = 8 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 'Spam Limit Is now 8' end if matches[1] == 'disable' then redis:del(hash) return 'Spam limit is Not 8 now' 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 Spaming I Will Fuck He/She' 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 -- kick user -- TODO: Check on this plugin kicks local bhash = 'kicked:'..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 = { '^!antiflood8 (enable)$', '^!antiflood8 (disable)$' }, run = run, privileged = true, pre_process = pre_process }
gpl-2.0
WAKAMAZU/sile_fe
packages/features.lua
3
5434
local opentype = { -- Mapping of opentype features to friendly names Ligatures = { Required = "rlig", Common = "liga", Contextual = "clig", Rare = "dlig", Discretionary = "dlig", Historic = "hlig" }, Fractions = { On = "frac", Alternate = "afrc" }, StylisticSet = function(i) return string.format("ss%02i", tonumber(i)) end, Letters = { Uppercase = "case", SmallCaps = "smcp", PetiteCaps = "pcap", UppercaseSmallCaps = "c2sc", UppercasePetiteCaps = "c2pc", Unicase = "unic" }, Numbers = { Uppercase = "lnum", Lining = "lnum", LowerCase = "onum", OldStyle = "onum", Proportional = "pnum", monospaced = "tnum", SlashedZero = "zero", Arabic = "anum" }, Contextuals = { Swash = "cswh", Alternate = "calt", WordInitial = "init", WordFinal = "fina", LineFinal = "falt", Inner = "medi" }, VerticalPosition = { Superior = "sups", Inferior = "subs", Numerator = "numr", Denominator = "dnom", ScientificInferior = "sinf", Ordinal = "ordn" }, -- XXX character variant Style = { Alternate = "salt", Italic= "ital", Ruby= "ruby", Swash= "swsh", Historic= "hist", TitlingCaps= "titl", HorizontalKana= "hkna", VerticalKana= "vkna" }, Diacritics = {MarkToBase = "mark", MarkToMark = "mkmk", AboveBase = "abvm", BelowBase = "blwm" }, Kerning = { Uppercase = "cpsp", On = "kern" }, CJKShape = { Traditional = "trad", Simplified = "smpl", JIS1978 = "jp78", JIS1983 = "jp83", JIS1990 = "jp90", Expert = "expt", NLC = "nlck", }, CharacterWidth = { Proportional = "pwid", Full = "fwid", Half = "hwid", Third = "twid", Quarter = "qwid", AlternateProportional = "palt", AlternateHalf = "halt", }, } -- Parser for feature strings local lpeg = require("lpeg") local featurename = lpeg.C((1-lpeg.S(",;:="))^1) local value = lpeg.C(SILE.parserBits.number.integer) local tag = lpeg.C(lpeg.S("+-")) * featurename * (lpeg.P("=") * value)^0 * lpeg.S(",;:")^-1 / function(pn,key,value) return key, { posneg = pn, value = value} end local featurestring = lpeg.Cf(lpeg.Ct("") * tag^0, rawset) local featurestring2table = function(s) return featurestring:match(s) or SU.error("Unparsable Opentype feature string '"..s.."'") end local table2featurestring = function(t) local t2 = {} for k,v in pairs(t) do t2[#t2+1] = v.posneg..k..(v.value and "="..v.value or "") end return table.concat(t2, ";") end SILE.registerCommand("add-font-feature", function(o,c) local t = featurestring2table(SILE.settings.get("font.features")) for k,v in pairs(o) do if not opentype[k] then SU.warn("Unknown Opentype feature "..k) else local posneg = "+" v = v:gsub("^No", function() posneg= "-"; return "" end) local res if type(opentype[k]) == "function" then res = opentype[k](v) else res = opentype[k][v] end if not res then SU.error("Bad OpenType value "..v.." for feature "..k) end if type(res) == "string" then t[res] = {posneg = posneg} else t[res.key] = { posneg = posneg, value = res.value} end end end SILE.settings.set("font.features", table2featurestring(t)) end) SILE.registerCommand("remove-font-feature", function(o,c) local t = featurestring2table(SILE.settings.get("font.features")) for k,v in pairs(o) do if not opentype[k] then SU.warn("Unknown Opentype feature "..k) else v = v:gsub("^No", "") local res if type(opentype[k]) == "function" then res = opentype[k](v) else res = opentype[k][v] end if not res then SU.error("Bad OpenType value "..v.." for feature "..k) end if type(res) == "string" then t[res] = nil else t[res.key] = nil end end end SILE.settings.set("font.features", table2featurestring(t)) end) return { documentation = [[\begin{document} As mentioned in Chapter 3, SILE automatically applies ligatures defined by the fonts that you use. These ligatures are defined by tables of \em{features} within the font file. As well as ligatures (multiple glyphs displayed as a single glyph), the features tables also declare other glyph substitutions. The \code{features} package provides an interface to selecting the features that you want SILE to apply to a font. The features available will be specific to the font file; some fonts come with documentation explaining their supported features. Discussion of OpenType features is beyond the scope of this manual. These features can be turned on and off by passing ‘raw’ feature names to the \code{\\font} command like so: \begin{verbatim} \line \\font[features="+dlig,+hlig"]{...} \% turn on discretionary and historic ligatures \line \end{verbatim} However, this is unwieldy and requires memorizing the feature codes. \code{features} provides two commands, \code{\\add-font-feature} and \code{\\remove-font-feature}, which make it easier to access OpenType features. The interface is patterned on the TeX package \code{fontspec}; for full documentation of the OpenType features supported, see the documentation for that package.\footnote{\code{http://texdoc.net/texmf-dist/doc/latex/fontspec/fontspec.pdf}} Here is how you would turn on discretionary and historic ligatures with the \code{features} package: \begin{verbatim} \line \\add-font-feature[Ligatures=Rare]\\add-font-feature[Ligatures=Discretionary] ... \\remove-font-feature[Ligatures=Rare]\\remove-font-feature[Ligatures=Discretionary] \line \end{verbatim} \end{document}]] }
mit
anshkumar/yugioh-glaze
assets/script/c2732323.lua
3
1301
--デコイドラゴン function c2732323.initial_effect(c) --change battle target local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(2732323,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCode(EVENT_BE_BATTLE_TARGET) e1:SetRange(LOCATION_MZONE) e1:SetTarget(c2732323.sptg) e1:SetOperation(c2732323.spop) c:RegisterEffect(e1) end function c2732323.spfilter(c,e,tp) return c:IsLevelAbove(7) and c:IsRace(RACE_DRAGON) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c2732323.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c2732323.spfilter(chkc,e,tp) end if chk==0 then return true end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,c2732323.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,g:GetCount(),0,0) end function c2732323.spop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc and tc:IsRelateToEffect(e) and Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)>0 then local a=Duel.GetAttacker() if a:IsAttackable() and not a:IsImmuneToEffect(e) then Duel.CalculateDamage(a,tc) end end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c47017574.lua
3
2957
--CNo.92 偽骸虚龍 Heart-eartH Chaos Dragon function c47017574.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,nil,10,4) c:EnableReviveLimit() --battle local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE) e1:SetValue(1) c:RegisterEffect(e1) --recover local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(47017574,0)) e2:SetCategory(CATEGORY_RECOVER) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e2:SetRange(LOCATION_MZONE) e2:SetCode(EVENT_BATTLE_DAMAGE) e2:SetCondition(c47017574.reccon) e2:SetTarget(c47017574.rectg) e2:SetOperation(c47017574.recop) c:RegisterEffect(e2) --negate local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(47017574,1)) e3:SetCategory(CATEGORY_DISABLE) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e3:SetRange(LOCATION_MZONE) e3:SetCountLimit(1) e3:SetCondition(c47017574.discon) e3:SetCost(c47017574.discost) e3:SetTarget(c47017574.distg) e3:SetOperation(c47017574.disop) c:RegisterEffect(e3) end c47017574.xyz_number=92 function c47017574.reccon(e,tp,eg,ep,ev,re,r,rp) return ep~=tp and eg:GetFirst():IsControler(tp) end function c47017574.rectg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(ev) Duel.SetOperationInfo(0,CATEGORY_RECOVER,nil,0,tp,ev) end function c47017574.recop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Recover(p,d,REASON_EFFECT) end function c47017574.discon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetOverlayGroup():IsExists(Card.IsCode,1,nil,97403510) end function c47017574.discost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST) end function c47017574.distg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(aux.disfilter1,tp,0,LOCATION_ONFIELD,1,nil) end end function c47017574.disop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local g=Duel.GetMatchingGroup(aux.disfilter1,tp,0,LOCATION_ONFIELD,nil) local tc=g:GetFirst() while tc do local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_DISABLE) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_DISABLE_EFFECT) e2:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) tc:RegisterEffect(e2) if tc:IsType(TYPE_TRAPMONSTER) then local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetCode(EFFECT_DISABLE_TRAPMONSTER) e3:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) tc:RegisterEffect(e3) end tc=g:GetNext() end end
gpl-2.0
zvinlong/google-diff-match-patch
lua/diff_match_patch.lua
265
73869
--[[ * Diff Match and Patch * * Copyright 2006 Google Inc. * http://code.google.com/p/google-diff-match-patch/ * * Based on the JavaScript implementation by Neil Fraser. * Ported to Lua by Duncan Cross. * * 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. --]] --[[ -- Lua 5.1 and earlier requires the external BitOp library. -- This library is built-in from Lua 5.2 and later as 'bit32'. require 'bit' -- <http://bitop.luajit.org/> local band, bor, lshift = bit.band, bit.bor, bit.lshift --]] local band, bor, lshift = bit32.band, bit32.bor, bit32.lshift local type, setmetatable, ipairs, select = type, setmetatable, ipairs, select local unpack, tonumber, error = unpack, tonumber, error local strsub, strbyte, strchar, gmatch, gsub = string.sub, string.byte, string.char, string.gmatch, string.gsub local strmatch, strfind, strformat = string.match, string.find, string.format local tinsert, tremove, tconcat = table.insert, table.remove, table.concat local max, min, floor, ceil, abs = math.max, math.min, math.floor, math.ceil, math.abs local clock = os.clock -- Utility functions. local percentEncode_pattern = '[^A-Za-z0-9%-=;\',./~!@#$%&*%(%)_%+ %?]' local function percentEncode_replace(v) return strformat('%%%02X', strbyte(v)) end local function tsplice(t, idx, deletions, ...) local insertions = select('#', ...) for i = 1, deletions do tremove(t, idx) end for i = insertions, 1, -1 do -- do not remove parentheses around select tinsert(t, idx, (select(i, ...))) end end local function strelement(str, i) return strsub(str, i, i) end local function indexOf(a, b, start) if (#b == 0) then return nil end return strfind(a, b, start, true) end local htmlEncode_pattern = '[&<>\n]' local htmlEncode_replace = { ['&'] = '&amp;', ['<'] = '&lt;', ['>'] = '&gt;', ['\n'] = '&para;<br>' } -- Public API Functions -- (Exported at the end of the script) local diff_main, diff_cleanupSemantic, diff_cleanupEfficiency, diff_levenshtein, diff_prettyHtml local match_main local patch_make, patch_toText, patch_fromText, patch_apply --[[ * The data structure representing a diff is an array of tuples: * {{DIFF_DELETE, 'Hello'}, {DIFF_INSERT, 'Goodbye'}, {DIFF_EQUAL, ' world.'}} * which means: delete 'Hello', add 'Goodbye' and keep ' world.' --]] local DIFF_DELETE = -1 local DIFF_INSERT = 1 local DIFF_EQUAL = 0 -- Number of seconds to map a diff before giving up (0 for infinity). local Diff_Timeout = 1.0 -- Cost of an empty edit operation in terms of edit characters. local Diff_EditCost = 4 -- At what point is no match declared (0.0 = perfection, 1.0 = very loose). local Match_Threshold = 0.5 -- How far to search for a match (0 = exact location, 1000+ = broad match). -- A match this many characters away from the expected location will add -- 1.0 to the score (0.0 is a perfect match). local Match_Distance = 1000 -- When deleting a large block of text (over ~64 characters), how close do -- the contents have to be to match the expected contents. (0.0 = perfection, -- 1.0 = very loose). Note that Match_Threshold controls how closely the -- end points of a delete need to match. local Patch_DeleteThreshold = 0.5 -- Chunk size for context length. local Patch_Margin = 4 -- The number of bits in an int. local Match_MaxBits = 32 function settings(new) if new then Diff_Timeout = new.Diff_Timeout or Diff_Timeout Diff_EditCost = new.Diff_EditCost or Diff_EditCost Match_Threshold = new.Match_Threshold or Match_Threshold Match_Distance = new.Match_Distance or Match_Distance Patch_DeleteThreshold = new.Patch_DeleteThreshold or Patch_DeleteThreshold Patch_Margin = new.Patch_Margin or Patch_Margin Match_MaxBits = new.Match_MaxBits or Match_MaxBits else return { Diff_Timeout = Diff_Timeout; Diff_EditCost = Diff_EditCost; Match_Threshold = Match_Threshold; Match_Distance = Match_Distance; Patch_DeleteThreshold = Patch_DeleteThreshold; Patch_Margin = Patch_Margin; Match_MaxBits = Match_MaxBits; } end end -- --------------------------------------------------------------------------- -- DIFF API -- --------------------------------------------------------------------------- -- The private diff functions local _diff_compute, _diff_bisect, _diff_halfMatchI, _diff_halfMatch, _diff_cleanupSemanticScore, _diff_cleanupSemanticLossless, _diff_cleanupMerge, _diff_commonPrefix, _diff_commonSuffix, _diff_commonOverlap, _diff_xIndex, _diff_text1, _diff_text2, _diff_toDelta, _diff_fromDelta --[[ * Find the differences between two texts. Simplifies the problem by stripping * any common prefix or suffix off the texts before diffing. * @param {string} text1 Old string to be diffed. * @param {string} text2 New string to be diffed. * @param {boolean} opt_checklines Has no effect in Lua. * @param {number} opt_deadline Optional time when the diff should be complete * by. Used internally for recursive calls. Users should set DiffTimeout * instead. * @return {Array.<Array.<number|string>>} Array of diff tuples. --]] function diff_main(text1, text2, opt_checklines, opt_deadline) -- Set a deadline by which time the diff must be complete. if opt_deadline == nil then if Diff_Timeout <= 0 then opt_deadline = 2 ^ 31 else opt_deadline = clock() + Diff_Timeout end end local deadline = opt_deadline -- Check for null inputs. if text1 == nil or text1 == nil then error('Null inputs. (diff_main)') end -- Check for equality (speedup). if text1 == text2 then if #text1 > 0 then return {{DIFF_EQUAL, text1}} end return {} end -- LUANOTE: Due to the lack of Unicode support, Lua is incapable of -- implementing the line-mode speedup. local checklines = false -- Trim off common prefix (speedup). local commonlength = _diff_commonPrefix(text1, text2) local commonprefix if commonlength > 0 then commonprefix = strsub(text1, 1, commonlength) text1 = strsub(text1, commonlength + 1) text2 = strsub(text2, commonlength + 1) end -- Trim off common suffix (speedup). commonlength = _diff_commonSuffix(text1, text2) local commonsuffix if commonlength > 0 then commonsuffix = strsub(text1, -commonlength) text1 = strsub(text1, 1, -commonlength - 1) text2 = strsub(text2, 1, -commonlength - 1) end -- Compute the diff on the middle block. local diffs = _diff_compute(text1, text2, checklines, deadline) -- Restore the prefix and suffix. if commonprefix then tinsert(diffs, 1, {DIFF_EQUAL, commonprefix}) end if commonsuffix then diffs[#diffs + 1] = {DIFF_EQUAL, commonsuffix} end _diff_cleanupMerge(diffs) return diffs end --[[ * Reduce the number of edits by eliminating semantically trivial equalities. * @param {Array.<Array.<number|string>>} diffs Array of diff tuples. --]] function diff_cleanupSemantic(diffs) local changes = false local equalities = {} -- Stack of indices where equalities are found. local equalitiesLength = 0 -- Keeping our own length var is faster. local lastequality = nil -- Always equal to diffs[equalities[equalitiesLength]][2] local pointer = 1 -- Index of current position. -- Number of characters that changed prior to the equality. local length_insertions1 = 0 local length_deletions1 = 0 -- Number of characters that changed after the equality. local length_insertions2 = 0 local length_deletions2 = 0 while diffs[pointer] do if diffs[pointer][1] == DIFF_EQUAL then -- Equality found. equalitiesLength = equalitiesLength + 1 equalities[equalitiesLength] = pointer length_insertions1 = length_insertions2 length_deletions1 = length_deletions2 length_insertions2 = 0 length_deletions2 = 0 lastequality = diffs[pointer][2] else -- An insertion or deletion. if diffs[pointer][1] == DIFF_INSERT then length_insertions2 = length_insertions2 + #(diffs[pointer][2]) else length_deletions2 = length_deletions2 + #(diffs[pointer][2]) end -- Eliminate an equality that is smaller or equal to the edits on both -- sides of it. if lastequality and (#lastequality <= max(length_insertions1, length_deletions1)) and (#lastequality <= max(length_insertions2, length_deletions2)) then -- Duplicate record. tinsert(diffs, equalities[equalitiesLength], {DIFF_DELETE, lastequality}) -- Change second copy to insert. diffs[equalities[equalitiesLength] + 1][1] = DIFF_INSERT -- Throw away the equality we just deleted. equalitiesLength = equalitiesLength - 1 -- Throw away the previous equality (it needs to be reevaluated). equalitiesLength = equalitiesLength - 1 pointer = (equalitiesLength > 0) and equalities[equalitiesLength] or 0 length_insertions1, length_deletions1 = 0, 0 -- Reset the counters. length_insertions2, length_deletions2 = 0, 0 lastequality = nil changes = true end end pointer = pointer + 1 end -- Normalize the diff. if changes then _diff_cleanupMerge(diffs) end _diff_cleanupSemanticLossless(diffs) -- Find any overlaps between deletions and insertions. -- e.g: <del>abcxxx</del><ins>xxxdef</ins> -- -> <del>abc</del>xxx<ins>def</ins> -- e.g: <del>xxxabc</del><ins>defxxx</ins> -- -> <ins>def</ins>xxx<del>abc</del> -- Only extract an overlap if it is as big as the edit ahead or behind it. pointer = 2 while diffs[pointer] do if (diffs[pointer - 1][1] == DIFF_DELETE and diffs[pointer][1] == DIFF_INSERT) then local deletion = diffs[pointer - 1][2] local insertion = diffs[pointer][2] local overlap_length1 = _diff_commonOverlap(deletion, insertion) local overlap_length2 = _diff_commonOverlap(insertion, deletion) if (overlap_length1 >= overlap_length2) then if (overlap_length1 >= #deletion / 2 or overlap_length1 >= #insertion / 2) then -- Overlap found. Insert an equality and trim the surrounding edits. tinsert(diffs, pointer, {DIFF_EQUAL, strsub(insertion, 1, overlap_length1)}) diffs[pointer - 1][2] = strsub(deletion, 1, #deletion - overlap_length1) diffs[pointer + 1][2] = strsub(insertion, overlap_length1 + 1) pointer = pointer + 1 end else if (overlap_length2 >= #deletion / 2 or overlap_length2 >= #insertion / 2) then -- Reverse overlap found. -- Insert an equality and swap and trim the surrounding edits. tinsert(diffs, pointer, {DIFF_EQUAL, strsub(deletion, 1, overlap_length2)}) diffs[pointer - 1] = {DIFF_INSERT, strsub(insertion, 1, #insertion - overlap_length2)} diffs[pointer + 1] = {DIFF_DELETE, strsub(deletion, overlap_length2 + 1)} pointer = pointer + 1 end end pointer = pointer + 1 end pointer = pointer + 1 end end --[[ * Reduce the number of edits by eliminating operationally trivial equalities. * @param {Array.<Array.<number|string>>} diffs Array of diff tuples. --]] function diff_cleanupEfficiency(diffs) local changes = false -- Stack of indices where equalities are found. local equalities = {} -- Keeping our own length var is faster. local equalitiesLength = 0 -- Always equal to diffs[equalities[equalitiesLength]][2] local lastequality = nil -- Index of current position. local pointer = 1 -- The following four are really booleans but are stored as numbers because -- they are used at one point like this: -- -- (pre_ins + pre_del + post_ins + post_del) == 3 -- -- ...i.e. checking that 3 of them are true and 1 of them is false. -- Is there an insertion operation before the last equality. local pre_ins = 0 -- Is there a deletion operation before the last equality. local pre_del = 0 -- Is there an insertion operation after the last equality. local post_ins = 0 -- Is there a deletion operation after the last equality. local post_del = 0 while diffs[pointer] do if diffs[pointer][1] == DIFF_EQUAL then -- Equality found. local diffText = diffs[pointer][2] if (#diffText < Diff_EditCost) and (post_ins == 1 or post_del == 1) then -- Candidate found. equalitiesLength = equalitiesLength + 1 equalities[equalitiesLength] = pointer pre_ins, pre_del = post_ins, post_del lastequality = diffText else -- Not a candidate, and can never become one. equalitiesLength = 0 lastequality = nil end post_ins, post_del = 0, 0 else -- An insertion or deletion. if diffs[pointer][1] == DIFF_DELETE then post_del = 1 else post_ins = 1 end --[[ * Five types to be split: * <ins>A</ins><del>B</del>XY<ins>C</ins><del>D</del> * <ins>A</ins>X<ins>C</ins><del>D</del> * <ins>A</ins><del>B</del>X<ins>C</ins> * <ins>A</del>X<ins>C</ins><del>D</del> * <ins>A</ins><del>B</del>X<del>C</del> --]] if lastequality and ( (pre_ins+pre_del+post_ins+post_del == 4) or ( (#lastequality < Diff_EditCost / 2) and (pre_ins+pre_del+post_ins+post_del == 3) )) then -- Duplicate record. tinsert(diffs, equalities[equalitiesLength], {DIFF_DELETE, lastequality}) -- Change second copy to insert. diffs[equalities[equalitiesLength] + 1][1] = DIFF_INSERT -- Throw away the equality we just deleted. equalitiesLength = equalitiesLength - 1 lastequality = nil if (pre_ins == 1) and (pre_del == 1) then -- No changes made which could affect previous entry, keep going. post_ins, post_del = 1, 1 equalitiesLength = 0 else -- Throw away the previous equality. equalitiesLength = equalitiesLength - 1 pointer = (equalitiesLength > 0) and equalities[equalitiesLength] or 0 post_ins, post_del = 0, 0 end changes = true end end pointer = pointer + 1 end if changes then _diff_cleanupMerge(diffs) end end --[[ * Compute the Levenshtein distance; the number of inserted, deleted or * substituted characters. * @param {Array.<Array.<number|string>>} diffs Array of diff tuples. * @return {number} Number of changes. --]] function diff_levenshtein(diffs) local levenshtein = 0 local insertions, deletions = 0, 0 for x, diff in ipairs(diffs) do local op, data = diff[1], diff[2] if (op == DIFF_INSERT) then insertions = insertions + #data elseif (op == DIFF_DELETE) then deletions = deletions + #data elseif (op == DIFF_EQUAL) then -- A deletion and an insertion is one substitution. levenshtein = levenshtein + max(insertions, deletions) insertions = 0 deletions = 0 end end levenshtein = levenshtein + max(insertions, deletions) return levenshtein end --[[ * Convert a diff array into a pretty HTML report. * @param {Array.<Array.<number|string>>} diffs Array of diff tuples. * @return {string} HTML representation. --]] function diff_prettyHtml(diffs) local html = {} for x, diff in ipairs(diffs) do local op = diff[1] -- Operation (insert, delete, equal) local data = diff[2] -- Text of change. local text = gsub(data, htmlEncode_pattern, htmlEncode_replace) if op == DIFF_INSERT then html[x] = '<ins style="background:#e6ffe6;">' .. text .. '</ins>' elseif op == DIFF_DELETE then html[x] = '<del style="background:#ffe6e6;">' .. text .. '</del>' elseif op == DIFF_EQUAL then html[x] = '<span>' .. text .. '</span>' end end return tconcat(html) end -- --------------------------------------------------------------------------- -- UNOFFICIAL/PRIVATE DIFF FUNCTIONS -- --------------------------------------------------------------------------- --[[ * Find the differences between two texts. Assumes that the texts do not * have any common prefix or suffix. * @param {string} text1 Old string to be diffed. * @param {string} text2 New string to be diffed. * @param {boolean} checklines Has no effect in Lua. * @param {number} deadline Time when the diff should be complete by. * @return {Array.<Array.<number|string>>} Array of diff tuples. * @private --]] function _diff_compute(text1, text2, checklines, deadline) if #text1 == 0 then -- Just add some text (speedup). return {{DIFF_INSERT, text2}} end if #text2 == 0 then -- Just delete some text (speedup). return {{DIFF_DELETE, text1}} end local diffs local longtext = (#text1 > #text2) and text1 or text2 local shorttext = (#text1 > #text2) and text2 or text1 local i = indexOf(longtext, shorttext) if i ~= nil then -- Shorter text is inside the longer text (speedup). diffs = { {DIFF_INSERT, strsub(longtext, 1, i - 1)}, {DIFF_EQUAL, shorttext}, {DIFF_INSERT, strsub(longtext, i + #shorttext)} } -- Swap insertions for deletions if diff is reversed. if #text1 > #text2 then diffs[1][1], diffs[3][1] = DIFF_DELETE, DIFF_DELETE end return diffs end if #shorttext == 1 then -- Single character string. -- After the previous speedup, the character can't be an equality. return {{DIFF_DELETE, text1}, {DIFF_INSERT, text2}} end -- Check to see if the problem can be split in two. do local text1_a, text1_b, text2_a, text2_b, mid_common = _diff_halfMatch(text1, text2) if text1_a then -- A half-match was found, sort out the return data. -- Send both pairs off for separate processing. local diffs_a = diff_main(text1_a, text2_a, checklines, deadline) local diffs_b = diff_main(text1_b, text2_b, checklines, deadline) -- Merge the results. local diffs_a_len = #diffs_a diffs = diffs_a diffs[diffs_a_len + 1] = {DIFF_EQUAL, mid_common} for i, b_diff in ipairs(diffs_b) do diffs[diffs_a_len + 1 + i] = b_diff end return diffs end end return _diff_bisect(text1, text2, deadline) end --[[ * Find the 'middle snake' of a diff, split the problem in two * and return the recursively constructed diff. * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations. * @param {string} text1 Old string to be diffed. * @param {string} text2 New string to be diffed. * @param {number} deadline Time at which to bail if not yet complete. * @return {Array.<Array.<number|string>>} Array of diff tuples. * @private --]] function _diff_bisect(text1, text2, deadline) -- Cache the text lengths to prevent multiple calls. local text1_length = #text1 local text2_length = #text2 local _sub, _element local max_d = ceil((text1_length + text2_length) / 2) local v_offset = max_d local v_length = 2 * max_d local v1 = {} local v2 = {} -- Setting all elements to -1 is faster in Lua than mixing integers and nil. for x = 0, v_length - 1 do v1[x] = -1 v2[x] = -1 end v1[v_offset + 1] = 0 v2[v_offset + 1] = 0 local delta = text1_length - text2_length -- If the total number of characters is odd, then -- the front path will collide with the reverse path. local front = (delta % 2 ~= 0) -- Offsets for start and end of k loop. -- Prevents mapping of space beyond the grid. local k1start = 0 local k1end = 0 local k2start = 0 local k2end = 0 for d = 0, max_d - 1 do -- Bail out if deadline is reached. if clock() > deadline then break end -- Walk the front path one step. for k1 = -d + k1start, d - k1end, 2 do local k1_offset = v_offset + k1 local x1 if (k1 == -d) or ((k1 ~= d) and (v1[k1_offset - 1] < v1[k1_offset + 1])) then x1 = v1[k1_offset + 1] else x1 = v1[k1_offset - 1] + 1 end local y1 = x1 - k1 while (x1 <= text1_length) and (y1 <= text2_length) and (strelement(text1, x1) == strelement(text2, y1)) do x1 = x1 + 1 y1 = y1 + 1 end v1[k1_offset] = x1 if x1 > text1_length + 1 then -- Ran off the right of the graph. k1end = k1end + 2 elseif y1 > text2_length + 1 then -- Ran off the bottom of the graph. k1start = k1start + 2 elseif front then local k2_offset = v_offset + delta - k1 if k2_offset >= 0 and k2_offset < v_length and v2[k2_offset] ~= -1 then -- Mirror x2 onto top-left coordinate system. local x2 = text1_length - v2[k2_offset] + 1 if x1 > x2 then -- Overlap detected. return _diff_bisectSplit(text1, text2, x1, y1, deadline) end end end end -- Walk the reverse path one step. for k2 = -d + k2start, d - k2end, 2 do local k2_offset = v_offset + k2 local x2 if (k2 == -d) or ((k2 ~= d) and (v2[k2_offset - 1] < v2[k2_offset + 1])) then x2 = v2[k2_offset + 1] else x2 = v2[k2_offset - 1] + 1 end local y2 = x2 - k2 while (x2 <= text1_length) and (y2 <= text2_length) and (strelement(text1, -x2) == strelement(text2, -y2)) do x2 = x2 + 1 y2 = y2 + 1 end v2[k2_offset] = x2 if x2 > text1_length + 1 then -- Ran off the left of the graph. k2end = k2end + 2 elseif y2 > text2_length + 1 then -- Ran off the top of the graph. k2start = k2start + 2 elseif not front then local k1_offset = v_offset + delta - k2 if k1_offset >= 0 and k1_offset < v_length and v1[k1_offset] ~= -1 then local x1 = v1[k1_offset] local y1 = v_offset + x1 - k1_offset -- Mirror x2 onto top-left coordinate system. x2 = text1_length - x2 + 1 if x1 > x2 then -- Overlap detected. return _diff_bisectSplit(text1, text2, x1, y1, deadline) end end end end end -- Diff took too long and hit the deadline or -- number of diffs equals number of characters, no commonality at all. return {{DIFF_DELETE, text1}, {DIFF_INSERT, text2}} end --[[ * Given the location of the 'middle snake', split the diff in two parts * and recurse. * @param {string} text1 Old string to be diffed. * @param {string} text2 New string to be diffed. * @param {number} x Index of split point in text1. * @param {number} y Index of split point in text2. * @param {number} deadline Time at which to bail if not yet complete. * @return {Array.<Array.<number|string>>} Array of diff tuples. * @private --]] function _diff_bisectSplit(text1, text2, x, y, deadline) local text1a = strsub(text1, 1, x - 1) local text2a = strsub(text2, 1, y - 1) local text1b = strsub(text1, x) local text2b = strsub(text2, y) -- Compute both diffs serially. local diffs = diff_main(text1a, text2a, false, deadline) local diffsb = diff_main(text1b, text2b, false, deadline) local diffs_len = #diffs for i, v in ipairs(diffsb) do diffs[diffs_len + i] = v end return diffs end --[[ * Determine the common prefix of two strings. * @param {string} text1 First string. * @param {string} text2 Second string. * @return {number} The number of characters common to the start of each * string. --]] function _diff_commonPrefix(text1, text2) -- Quick check for common null cases. if (#text1 == 0) or (#text2 == 0) or (strbyte(text1, 1) ~= strbyte(text2, 1)) then return 0 end -- Binary search. -- Performance analysis: http://neil.fraser.name/news/2007/10/09/ local pointermin = 1 local pointermax = min(#text1, #text2) local pointermid = pointermax local pointerstart = 1 while (pointermin < pointermid) do if (strsub(text1, pointerstart, pointermid) == strsub(text2, pointerstart, pointermid)) then pointermin = pointermid pointerstart = pointermin else pointermax = pointermid end pointermid = floor(pointermin + (pointermax - pointermin) / 2) end return pointermid end --[[ * Determine the common suffix of two strings. * @param {string} text1 First string. * @param {string} text2 Second string. * @return {number} The number of characters common to the end of each string. --]] function _diff_commonSuffix(text1, text2) -- Quick check for common null cases. if (#text1 == 0) or (#text2 == 0) or (strbyte(text1, -1) ~= strbyte(text2, -1)) then return 0 end -- Binary search. -- Performance analysis: http://neil.fraser.name/news/2007/10/09/ local pointermin = 1 local pointermax = min(#text1, #text2) local pointermid = pointermax local pointerend = 1 while (pointermin < pointermid) do if (strsub(text1, -pointermid, -pointerend) == strsub(text2, -pointermid, -pointerend)) then pointermin = pointermid pointerend = pointermin else pointermax = pointermid end pointermid = floor(pointermin + (pointermax - pointermin) / 2) end return pointermid end --[[ * Determine if the suffix of one string is the prefix of another. * @param {string} text1 First string. * @param {string} text2 Second string. * @return {number} The number of characters common to the end of the first * string and the start of the second string. * @private --]] function _diff_commonOverlap(text1, text2) -- Cache the text lengths to prevent multiple calls. local text1_length = #text1 local text2_length = #text2 -- Eliminate the null case. if text1_length == 0 or text2_length == 0 then return 0 end -- Truncate the longer string. if text1_length > text2_length then text1 = strsub(text1, text1_length - text2_length + 1) elseif text1_length < text2_length then text2 = strsub(text2, 1, text1_length) end local text_length = min(text1_length, text2_length) -- Quick check for the worst case. if text1 == text2 then return text_length end -- Start by looking for a single character match -- and increase length until no match is found. -- Performance analysis: http://neil.fraser.name/news/2010/11/04/ local best = 0 local length = 1 while true do local pattern = strsub(text1, text_length - length + 1) local found = strfind(text2, pattern, 1, true) if found == nil then return best end length = length + found - 1 if found == 1 or strsub(text1, text_length - length + 1) == strsub(text2, 1, length) then best = length length = length + 1 end end end --[[ * Does a substring of shorttext exist within longtext such that the substring * is at least half the length of longtext? * This speedup can produce non-minimal diffs. * Closure, but does not reference any external variables. * @param {string} longtext Longer string. * @param {string} shorttext Shorter string. * @param {number} i Start index of quarter length substring within longtext. * @return {?Array.<string>} Five element Array, containing the prefix of * longtext, the suffix of longtext, the prefix of shorttext, the suffix * of shorttext and the common middle. Or nil if there was no match. * @private --]] function _diff_halfMatchI(longtext, shorttext, i) -- Start with a 1/4 length substring at position i as a seed. local seed = strsub(longtext, i, i + floor(#longtext / 4)) local j = 0 -- LUANOTE: do not change to 1, was originally -1 local best_common = '' local best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b while true do j = indexOf(shorttext, seed, j + 1) if (j == nil) then break end local prefixLength = _diff_commonPrefix(strsub(longtext, i), strsub(shorttext, j)) local suffixLength = _diff_commonSuffix(strsub(longtext, 1, i - 1), strsub(shorttext, 1, j - 1)) if #best_common < suffixLength + prefixLength then best_common = strsub(shorttext, j - suffixLength, j - 1) .. strsub(shorttext, j, j + prefixLength - 1) best_longtext_a = strsub(longtext, 1, i - suffixLength - 1) best_longtext_b = strsub(longtext, i + prefixLength) best_shorttext_a = strsub(shorttext, 1, j - suffixLength - 1) best_shorttext_b = strsub(shorttext, j + prefixLength) end end if #best_common * 2 >= #longtext then return {best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b, best_common} else return nil end end --[[ * Do the two texts share a substring which is at least half the length of the * longer text? * @param {string} text1 First string. * @param {string} text2 Second string. * @return {?Array.<string>} Five element Array, containing the prefix of * text1, the suffix of text1, the prefix of text2, the suffix of * text2 and the common middle. Or nil if there was no match. * @private --]] function _diff_halfMatch(text1, text2) if Diff_Timeout <= 0 then -- Don't risk returning a non-optimal diff if we have unlimited time. return nil end local longtext = (#text1 > #text2) and text1 or text2 local shorttext = (#text1 > #text2) and text2 or text1 if (#longtext < 4) or (#shorttext * 2 < #longtext) then return nil -- Pointless. end -- First check if the second quarter is the seed for a half-match. local hm1 = _diff_halfMatchI(longtext, shorttext, ceil(#longtext / 4)) -- Check again based on the third quarter. local hm2 = _diff_halfMatchI(longtext, shorttext, ceil(#longtext / 2)) local hm if not hm1 and not hm2 then return nil elseif not hm2 then hm = hm1 elseif not hm1 then hm = hm2 else -- Both matched. Select the longest. hm = (#hm1[5] > #hm2[5]) and hm1 or hm2 end -- A half-match was found, sort out the return data. local text1_a, text1_b, text2_a, text2_b if (#text1 > #text2) then text1_a, text1_b = hm[1], hm[2] text2_a, text2_b = hm[3], hm[4] else text2_a, text2_b = hm[1], hm[2] text1_a, text1_b = hm[3], hm[4] end local mid_common = hm[5] return text1_a, text1_b, text2_a, text2_b, mid_common end --[[ * Given two strings, compute a score representing whether the internal * boundary falls on logical boundaries. * Scores range from 6 (best) to 0 (worst). * @param {string} one First string. * @param {string} two Second string. * @return {number} The score. * @private --]] function _diff_cleanupSemanticScore(one, two) if (#one == 0) or (#two == 0) then -- Edges are the best. return 6 end -- Each port of this function behaves slightly differently due to -- subtle differences in each language's definition of things like -- 'whitespace'. Since this function's purpose is largely cosmetic, -- the choice has been made to use each language's native features -- rather than force total conformity. local char1 = strsub(one, -1) local char2 = strsub(two, 1, 1) local nonAlphaNumeric1 = strmatch(char1, '%W') local nonAlphaNumeric2 = strmatch(char2, '%W') local whitespace1 = nonAlphaNumeric1 and strmatch(char1, '%s') local whitespace2 = nonAlphaNumeric2 and strmatch(char2, '%s') local lineBreak1 = whitespace1 and strmatch(char1, '%c') local lineBreak2 = whitespace2 and strmatch(char2, '%c') local blankLine1 = lineBreak1 and strmatch(one, '\n\r?\n$') local blankLine2 = lineBreak2 and strmatch(two, '^\r?\n\r?\n') if blankLine1 or blankLine2 then -- Five points for blank lines. return 5 elseif lineBreak1 or lineBreak2 then -- Four points for line breaks. return 4 elseif nonAlphaNumeric1 and not whitespace1 and whitespace2 then -- Three points for end of sentences. return 3 elseif whitespace1 or whitespace2 then -- Two points for whitespace. return 2 elseif nonAlphaNumeric1 or nonAlphaNumeric2 then -- One point for non-alphanumeric. return 1 end return 0 end --[[ * Look for single edits surrounded on both sides by equalities * which can be shifted sideways to align the edit to a word boundary. * e.g: The c<ins>at c</ins>ame. -> The <ins>cat </ins>came. * @param {Array.<Array.<number|string>>} diffs Array of diff tuples. --]] function _diff_cleanupSemanticLossless(diffs) local pointer = 2 -- Intentionally ignore the first and last element (don't need checking). while diffs[pointer + 1] do local prevDiff, nextDiff = diffs[pointer - 1], diffs[pointer + 1] if (prevDiff[1] == DIFF_EQUAL) and (nextDiff[1] == DIFF_EQUAL) then -- This is a single edit surrounded by equalities. local diff = diffs[pointer] local equality1 = prevDiff[2] local edit = diff[2] local equality2 = nextDiff[2] -- First, shift the edit as far left as possible. local commonOffset = _diff_commonSuffix(equality1, edit) if commonOffset > 0 then local commonString = strsub(edit, -commonOffset) equality1 = strsub(equality1, 1, -commonOffset - 1) edit = commonString .. strsub(edit, 1, -commonOffset - 1) equality2 = commonString .. equality2 end -- Second, step character by character right, looking for the best fit. local bestEquality1 = equality1 local bestEdit = edit local bestEquality2 = equality2 local bestScore = _diff_cleanupSemanticScore(equality1, edit) + _diff_cleanupSemanticScore(edit, equality2) while strbyte(edit, 1) == strbyte(equality2, 1) do equality1 = equality1 .. strsub(edit, 1, 1) edit = strsub(edit, 2) .. strsub(equality2, 1, 1) equality2 = strsub(equality2, 2) local score = _diff_cleanupSemanticScore(equality1, edit) + _diff_cleanupSemanticScore(edit, equality2) -- The >= encourages trailing rather than leading whitespace on edits. if score >= bestScore then bestScore = score bestEquality1 = equality1 bestEdit = edit bestEquality2 = equality2 end end if prevDiff[2] ~= bestEquality1 then -- We have an improvement, save it back to the diff. if #bestEquality1 > 0 then diffs[pointer - 1][2] = bestEquality1 else tremove(diffs, pointer - 1) pointer = pointer - 1 end diffs[pointer][2] = bestEdit if #bestEquality2 > 0 then diffs[pointer + 1][2] = bestEquality2 else tremove(diffs, pointer + 1, 1) pointer = pointer - 1 end end end pointer = pointer + 1 end end --[[ * Reorder and merge like edit sections. Merge equalities. * Any edit section can move as long as it doesn't cross an equality. * @param {Array.<Array.<number|string>>} diffs Array of diff tuples. --]] function _diff_cleanupMerge(diffs) diffs[#diffs + 1] = {DIFF_EQUAL, ''} -- Add a dummy entry at the end. local pointer = 1 local count_delete, count_insert = 0, 0 local text_delete, text_insert = '', '' local commonlength while diffs[pointer] do local diff_type = diffs[pointer][1] if diff_type == DIFF_INSERT then count_insert = count_insert + 1 text_insert = text_insert .. diffs[pointer][2] pointer = pointer + 1 elseif diff_type == DIFF_DELETE then count_delete = count_delete + 1 text_delete = text_delete .. diffs[pointer][2] pointer = pointer + 1 elseif diff_type == DIFF_EQUAL then -- Upon reaching an equality, check for prior redundancies. if count_delete + count_insert > 1 then if (count_delete > 0) and (count_insert > 0) then -- Factor out any common prefixies. commonlength = _diff_commonPrefix(text_insert, text_delete) if commonlength > 0 then local back_pointer = pointer - count_delete - count_insert if (back_pointer > 1) and (diffs[back_pointer - 1][1] == DIFF_EQUAL) then diffs[back_pointer - 1][2] = diffs[back_pointer - 1][2] .. strsub(text_insert, 1, commonlength) else tinsert(diffs, 1, {DIFF_EQUAL, strsub(text_insert, 1, commonlength)}) pointer = pointer + 1 end text_insert = strsub(text_insert, commonlength + 1) text_delete = strsub(text_delete, commonlength + 1) end -- Factor out any common suffixies. commonlength = _diff_commonSuffix(text_insert, text_delete) if commonlength ~= 0 then diffs[pointer][2] = strsub(text_insert, -commonlength) .. diffs[pointer][2] text_insert = strsub(text_insert, 1, -commonlength - 1) text_delete = strsub(text_delete, 1, -commonlength - 1) end end -- Delete the offending records and add the merged ones. if count_delete == 0 then tsplice(diffs, pointer - count_insert, count_insert, {DIFF_INSERT, text_insert}) elseif count_insert == 0 then tsplice(diffs, pointer - count_delete, count_delete, {DIFF_DELETE, text_delete}) else tsplice(diffs, pointer - count_delete - count_insert, count_delete + count_insert, {DIFF_DELETE, text_delete}, {DIFF_INSERT, text_insert}) end pointer = pointer - count_delete - count_insert + (count_delete>0 and 1 or 0) + (count_insert>0 and 1 or 0) + 1 elseif (pointer > 1) and (diffs[pointer - 1][1] == DIFF_EQUAL) then -- Merge this equality with the previous one. diffs[pointer - 1][2] = diffs[pointer - 1][2] .. diffs[pointer][2] tremove(diffs, pointer) else pointer = pointer + 1 end count_insert, count_delete = 0, 0 text_delete, text_insert = '', '' end end if diffs[#diffs][2] == '' then diffs[#diffs] = nil -- Remove the dummy entry at the end. end -- Second pass: look for single edits surrounded on both sides by equalities -- which can be shifted sideways to eliminate an equality. -- e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC local changes = false pointer = 2 -- Intentionally ignore the first and last element (don't need checking). while pointer < #diffs do local prevDiff, nextDiff = diffs[pointer - 1], diffs[pointer + 1] if (prevDiff[1] == DIFF_EQUAL) and (nextDiff[1] == DIFF_EQUAL) then -- This is a single edit surrounded by equalities. local diff = diffs[pointer] local currentText = diff[2] local prevText = prevDiff[2] local nextText = nextDiff[2] if strsub(currentText, -#prevText) == prevText then -- Shift the edit over the previous equality. diff[2] = prevText .. strsub(currentText, 1, -#prevText - 1) nextDiff[2] = prevText .. nextDiff[2] tremove(diffs, pointer - 1) changes = true elseif strsub(currentText, 1, #nextText) == nextText then -- Shift the edit over the next equality. prevDiff[2] = prevText .. nextText diff[2] = strsub(currentText, #nextText + 1) .. nextText tremove(diffs, pointer + 1) changes = true end end pointer = pointer + 1 end -- If shifts were made, the diff needs reordering and another shift sweep. if changes then -- LUANOTE: no return value, but necessary to use 'return' to get -- tail calls. return _diff_cleanupMerge(diffs) end end --[[ * loc is a location in text1, compute and return the equivalent location in * text2. * e.g. 'The cat' vs 'The big cat', 1->1, 5->8 * @param {Array.<Array.<number|string>>} diffs Array of diff tuples. * @param {number} loc Location within text1. * @return {number} Location within text2. --]] function _diff_xIndex(diffs, loc) local chars1 = 1 local chars2 = 1 local last_chars1 = 1 local last_chars2 = 1 local x for _x, diff in ipairs(diffs) do x = _x if diff[1] ~= DIFF_INSERT then -- Equality or deletion. chars1 = chars1 + #diff[2] end if diff[1] ~= DIFF_DELETE then -- Equality or insertion. chars2 = chars2 + #diff[2] end if chars1 > loc then -- Overshot the location. break end last_chars1 = chars1 last_chars2 = chars2 end -- Was the location deleted? if diffs[x + 1] and (diffs[x][1] == DIFF_DELETE) then return last_chars2 end -- Add the remaining character length. return last_chars2 + (loc - last_chars1) end --[[ * Compute and return the source text (all equalities and deletions). * @param {Array.<Array.<number|string>>} diffs Array of diff tuples. * @return {string} Source text. --]] function _diff_text1(diffs) local text = {} for x, diff in ipairs(diffs) do if diff[1] ~= DIFF_INSERT then text[#text + 1] = diff[2] end end return tconcat(text) end --[[ * Compute and return the destination text (all equalities and insertions). * @param {Array.<Array.<number|string>>} diffs Array of diff tuples. * @return {string} Destination text. --]] function _diff_text2(diffs) local text = {} for x, diff in ipairs(diffs) do if diff[1] ~= DIFF_DELETE then text[#text + 1] = diff[2] end end return tconcat(text) end --[[ * Crush the diff into an encoded string which describes the operations * required to transform text1 into text2. * E.g. =3\t-2\t+ing -> Keep 3 chars, delete 2 chars, insert 'ing'. * Operations are tab-separated. Inserted text is escaped using %xx notation. * @param {Array.<Array.<number|string>>} diffs Array of diff tuples. * @return {string} Delta text. --]] function _diff_toDelta(diffs) local text = {} for x, diff in ipairs(diffs) do local op, data = diff[1], diff[2] if op == DIFF_INSERT then text[x] = '+' .. gsub(data, percentEncode_pattern, percentEncode_replace) elseif op == DIFF_DELETE then text[x] = '-' .. #data elseif op == DIFF_EQUAL then text[x] = '=' .. #data end end return tconcat(text, '\t') end --[[ * Given the original text1, and an encoded string which describes the * operations required to transform text1 into text2, compute the full diff. * @param {string} text1 Source string for the diff. * @param {string} delta Delta text. * @return {Array.<Array.<number|string>>} Array of diff tuples. * @throws {Errorend If invalid input. --]] function _diff_fromDelta(text1, delta) local diffs = {} local diffsLength = 0 -- Keeping our own length var is faster local pointer = 1 -- Cursor in text1 for token in gmatch(delta, '[^\t]+') do -- Each token begins with a one character parameter which specifies the -- operation of this token (delete, insert, equality). local tokenchar, param = strsub(token, 1, 1), strsub(token, 2) if (tokenchar == '+') then local invalidDecode = false local decoded = gsub(param, '%%(.?.?)', function(c) local n = tonumber(c, 16) if (#c ~= 2) or (n == nil) then invalidDecode = true return '' end return strchar(n) end) if invalidDecode then -- Malformed URI sequence. error('Illegal escape in _diff_fromDelta: ' .. param) end diffsLength = diffsLength + 1 diffs[diffsLength] = {DIFF_INSERT, decoded} elseif (tokenchar == '-') or (tokenchar == '=') then local n = tonumber(param) if (n == nil) or (n < 0) then error('Invalid number in _diff_fromDelta: ' .. param) end local text = strsub(text1, pointer, pointer + n - 1) pointer = pointer + n if (tokenchar == '=') then diffsLength = diffsLength + 1 diffs[diffsLength] = {DIFF_EQUAL, text} else diffsLength = diffsLength + 1 diffs[diffsLength] = {DIFF_DELETE, text} end else error('Invalid diff operation in _diff_fromDelta: ' .. token) end end if (pointer ~= #text1 + 1) then error('Delta length (' .. (pointer - 1) .. ') does not equal source text length (' .. #text1 .. ').') end return diffs end -- --------------------------------------------------------------------------- -- MATCH API -- --------------------------------------------------------------------------- local _match_bitap, _match_alphabet --[[ * Locate the best instance of 'pattern' in 'text' near 'loc'. * @param {string} text The text to search. * @param {string} pattern The pattern to search for. * @param {number} loc The location to search around. * @return {number} Best match index or -1. --]] function match_main(text, pattern, loc) -- Check for null inputs. if text == nil or pattern == nil or loc == nil then error('Null inputs. (match_main)') end if text == pattern then -- Shortcut (potentially not guaranteed by the algorithm) return 1 elseif #text == 0 then -- Nothing to match. return -1 end loc = max(1, min(loc, #text)) if strsub(text, loc, loc + #pattern - 1) == pattern then -- Perfect match at the perfect spot! (Includes case of null pattern) return loc else -- Do a fuzzy compare. return _match_bitap(text, pattern, loc) end end -- --------------------------------------------------------------------------- -- UNOFFICIAL/PRIVATE MATCH FUNCTIONS -- --------------------------------------------------------------------------- --[[ * Initialise the alphabet for the Bitap algorithm. * @param {string} pattern The text to encode. * @return {Object} Hash of character locations. * @private --]] function _match_alphabet(pattern) local s = {} local i = 0 for c in gmatch(pattern, '.') do s[c] = bor(s[c] or 0, lshift(1, #pattern - i - 1)) i = i + 1 end return s end --[[ * Locate the best instance of 'pattern' in 'text' near 'loc' using the * Bitap algorithm. * @param {string} text The text to search. * @param {string} pattern The pattern to search for. * @param {number} loc The location to search around. * @return {number} Best match index or -1. * @private --]] function _match_bitap(text, pattern, loc) if #pattern > Match_MaxBits then error('Pattern too long.') end -- Initialise the alphabet. local s = _match_alphabet(pattern) --[[ * Compute and return the score for a match with e errors and x location. * Accesses loc and pattern through being a closure. * @param {number} e Number of errors in match. * @param {number} x Location of match. * @return {number} Overall score for match (0.0 = good, 1.0 = bad). * @private --]] local function _match_bitapScore(e, x) local accuracy = e / #pattern local proximity = abs(loc - x) if (Match_Distance == 0) then -- Dodge divide by zero error. return (proximity == 0) and 1 or accuracy end return accuracy + (proximity / Match_Distance) end -- Highest score beyond which we give up. local score_threshold = Match_Threshold -- Is there a nearby exact match? (speedup) local best_loc = indexOf(text, pattern, loc) if best_loc then score_threshold = min(_match_bitapScore(0, best_loc), score_threshold) -- LUANOTE: Ideally we'd also check from the other direction, but Lua -- doesn't have an efficent lastIndexOf function. end -- Initialise the bit arrays. local matchmask = lshift(1, #pattern - 1) best_loc = -1 local bin_min, bin_mid local bin_max = #pattern + #text local last_rd for d = 0, #pattern - 1, 1 do -- Scan for the best match; each iteration allows for one more error. -- Run a binary search to determine how far from 'loc' we can stray at this -- error level. bin_min = 0 bin_mid = bin_max while (bin_min < bin_mid) do if (_match_bitapScore(d, loc + bin_mid) <= score_threshold) then bin_min = bin_mid else bin_max = bin_mid end bin_mid = floor(bin_min + (bin_max - bin_min) / 2) end -- Use the result from this iteration as the maximum for the next. bin_max = bin_mid local start = max(1, loc - bin_mid + 1) local finish = min(loc + bin_mid, #text) + #pattern local rd = {} for j = start, finish do rd[j] = 0 end rd[finish + 1] = lshift(1, d) - 1 for j = finish, start, -1 do local charMatch = s[strsub(text, j - 1, j - 1)] or 0 if (d == 0) then -- First pass: exact match. rd[j] = band(bor((rd[j + 1] * 2), 1), charMatch) else -- Subsequent passes: fuzzy match. -- Functions instead of operators make this hella messy. rd[j] = bor( band( bor( lshift(rd[j + 1], 1), 1 ), charMatch ), bor( bor( lshift(bor(last_rd[j + 1], last_rd[j]), 1), 1 ), last_rd[j + 1] ) ) end if (band(rd[j], matchmask) ~= 0) then local score = _match_bitapScore(d, j - 1) -- This match will almost certainly be better than any existing match. -- But check anyway. if (score <= score_threshold) then -- Told you so. score_threshold = score best_loc = j - 1 if (best_loc > loc) then -- When passing loc, don't exceed our current distance from loc. start = max(1, loc * 2 - best_loc) else -- Already passed loc, downhill from here on in. break end end end end -- No hope for a (better) match at greater error levels. if (_match_bitapScore(d + 1, loc) > score_threshold) then break end last_rd = rd end return best_loc end -- ----------------------------------------------------------------------------- -- PATCH API -- ----------------------------------------------------------------------------- local _patch_addContext, _patch_deepCopy, _patch_addPadding, _patch_splitMax, _patch_appendText, _new_patch_obj --[[ * Compute a list of patches to turn text1 into text2. * Use diffs if provided, otherwise compute it ourselves. * There are four ways to call this function, depending on what data is * available to the caller: * Method 1: * a = text1, b = text2 * Method 2: * a = diffs * Method 3 (optimal): * a = text1, b = diffs * Method 4 (deprecated, use method 3): * a = text1, b = text2, c = diffs * * @param {string|Array.<Array.<number|string>>} a text1 (methods 1,3,4) or * Array of diff tuples for text1 to text2 (method 2). * @param {string|Array.<Array.<number|string>>} opt_b text2 (methods 1,4) or * Array of diff tuples for text1 to text2 (method 3) or undefined (method 2). * @param {string|Array.<Array.<number|string>>} opt_c Array of diff tuples for * text1 to text2 (method 4) or undefined (methods 1,2,3). * @return {Array.<_new_patch_obj>} Array of patch objects. --]] function patch_make(a, opt_b, opt_c) local text1, diffs local type_a, type_b, type_c = type(a), type(opt_b), type(opt_c) if (type_a == 'string') and (type_b == 'string') and (type_c == 'nil') then -- Method 1: text1, text2 -- Compute diffs from text1 and text2. text1 = a diffs = diff_main(text1, opt_b, true) if (#diffs > 2) then diff_cleanupSemantic(diffs) diff_cleanupEfficiency(diffs) end elseif (type_a == 'table') and (type_b == 'nil') and (type_c == 'nil') then -- Method 2: diffs -- Compute text1 from diffs. diffs = a text1 = _diff_text1(diffs) elseif (type_a == 'string') and (type_b == 'table') and (type_c == 'nil') then -- Method 3: text1, diffs text1 = a diffs = opt_b elseif (type_a == 'string') and (type_b == 'string') and (type_c == 'table') then -- Method 4: text1, text2, diffs -- text2 is not used. text1 = a diffs = opt_c else error('Unknown call format to patch_make.') end if (diffs[1] == nil) then return {} -- Get rid of the null case. end local patches = {} local patch = _new_patch_obj() local patchDiffLength = 0 -- Keeping our own length var is faster. local char_count1 = 0 -- Number of characters into the text1 string. local char_count2 = 0 -- Number of characters into the text2 string. -- Start with text1 (prepatch_text) and apply the diffs until we arrive at -- text2 (postpatch_text). We recreate the patches one by one to determine -- context info. local prepatch_text, postpatch_text = text1, text1 for x, diff in ipairs(diffs) do local diff_type, diff_text = diff[1], diff[2] if (patchDiffLength == 0) and (diff_type ~= DIFF_EQUAL) then -- A new patch starts here. patch.start1 = char_count1 + 1 patch.start2 = char_count2 + 1 end if (diff_type == DIFF_INSERT) then patchDiffLength = patchDiffLength + 1 patch.diffs[patchDiffLength] = diff patch.length2 = patch.length2 + #diff_text postpatch_text = strsub(postpatch_text, 1, char_count2) .. diff_text .. strsub(postpatch_text, char_count2 + 1) elseif (diff_type == DIFF_DELETE) then patch.length1 = patch.length1 + #diff_text patchDiffLength = patchDiffLength + 1 patch.diffs[patchDiffLength] = diff postpatch_text = strsub(postpatch_text, 1, char_count2) .. strsub(postpatch_text, char_count2 + #diff_text + 1) elseif (diff_type == DIFF_EQUAL) then if (#diff_text <= Patch_Margin * 2) and (patchDiffLength ~= 0) and (#diffs ~= x) then -- Small equality inside a patch. patchDiffLength = patchDiffLength + 1 patch.diffs[patchDiffLength] = diff patch.length1 = patch.length1 + #diff_text patch.length2 = patch.length2 + #diff_text elseif (#diff_text >= Patch_Margin * 2) then -- Time for a new patch. if (patchDiffLength ~= 0) then _patch_addContext(patch, prepatch_text) patches[#patches + 1] = patch patch = _new_patch_obj() patchDiffLength = 0 -- Unlike Unidiff, our patch lists have a rolling context. -- http://code.google.com/p/google-diff-match-patch/wiki/Unidiff -- Update prepatch text & pos to reflect the application of the -- just completed patch. prepatch_text = postpatch_text char_count1 = char_count2 end end end -- Update the current character count. if (diff_type ~= DIFF_INSERT) then char_count1 = char_count1 + #diff_text end if (diff_type ~= DIFF_DELETE) then char_count2 = char_count2 + #diff_text end end -- Pick up the leftover patch if not empty. if (patchDiffLength > 0) then _patch_addContext(patch, prepatch_text) patches[#patches + 1] = patch end return patches end --[[ * Merge a set of patches onto the text. Return a patched text, as well * as a list of true/false values indicating which patches were applied. * @param {Array.<_new_patch_obj>} patches Array of patch objects. * @param {string} text Old text. * @return {Array.<string|Array.<boolean>>} Two return values, the * new text and an array of boolean values. --]] function patch_apply(patches, text) if patches[1] == nil then return text, {} end -- Deep copy the patches so that no changes are made to originals. patches = _patch_deepCopy(patches) local nullPadding = _patch_addPadding(patches) text = nullPadding .. text .. nullPadding _patch_splitMax(patches) -- delta keeps track of the offset between the expected and actual location -- of the previous patch. If there are patches expected at positions 10 and -- 20, but the first patch was found at 12, delta is 2 and the second patch -- has an effective expected position of 22. local delta = 0 local results = {} for x, patch in ipairs(patches) do local expected_loc = patch.start2 + delta local text1 = _diff_text1(patch.diffs) local start_loc local end_loc = -1 if #text1 > Match_MaxBits then -- _patch_splitMax will only provide an oversized pattern in -- the case of a monster delete. start_loc = match_main(text, strsub(text1, 1, Match_MaxBits), expected_loc) if start_loc ~= -1 then end_loc = match_main(text, strsub(text1, -Match_MaxBits), expected_loc + #text1 - Match_MaxBits) if end_loc == -1 or start_loc >= end_loc then -- Can't find valid trailing context. Drop this patch. start_loc = -1 end end else start_loc = match_main(text, text1, expected_loc) end if start_loc == -1 then -- No match found. :( results[x] = false -- Subtract the delta for this failed patch from subsequent patches. delta = delta - patch.length2 - patch.length1 else -- Found a match. :) results[x] = true delta = start_loc - expected_loc local text2 if end_loc == -1 then text2 = strsub(text, start_loc, start_loc + #text1 - 1) else text2 = strsub(text, start_loc, end_loc + Match_MaxBits - 1) end if text1 == text2 then -- Perfect match, just shove the replacement text in. text = strsub(text, 1, start_loc - 1) .. _diff_text2(patch.diffs) .. strsub(text, start_loc + #text1) else -- Imperfect match. Run a diff to get a framework of equivalent -- indices. local diffs = diff_main(text1, text2, false) if (#text1 > Match_MaxBits) and (diff_levenshtein(diffs) / #text1 > Patch_DeleteThreshold) then -- The end points match, but the content is unacceptably bad. results[x] = false else _diff_cleanupSemanticLossless(diffs) local index1 = 1 local index2 for y, mod in ipairs(patch.diffs) do if mod[1] ~= DIFF_EQUAL then index2 = _diff_xIndex(diffs, index1) end if mod[1] == DIFF_INSERT then text = strsub(text, 1, start_loc + index2 - 2) .. mod[2] .. strsub(text, start_loc + index2 - 1) elseif mod[1] == DIFF_DELETE then text = strsub(text, 1, start_loc + index2 - 2) .. strsub(text, start_loc + _diff_xIndex(diffs, index1 + #mod[2] - 1)) end if mod[1] ~= DIFF_DELETE then index1 = index1 + #mod[2] end end end end end end -- Strip the padding off. text = strsub(text, #nullPadding + 1, -#nullPadding - 1) return text, results end --[[ * Take a list of patches and return a textual representation. * @param {Array.<_new_patch_obj>} patches Array of patch objects. * @return {string} Text representation of patches. --]] function patch_toText(patches) local text = {} for x, patch in ipairs(patches) do _patch_appendText(patch, text) end return tconcat(text) end --[[ * Parse a textual representation of patches and return a list of patch objects. * @param {string} textline Text representation of patches. * @return {Array.<_new_patch_obj>} Array of patch objects. * @throws {Error} If invalid input. --]] function patch_fromText(textline) local patches = {} if (#textline == 0) then return patches end local text = {} for line in gmatch(textline, '([^\n]*)') do text[#text + 1] = line end local textPointer = 1 while (textPointer <= #text) do local start1, length1, start2, length2 = strmatch(text[textPointer], '^@@ %-(%d+),?(%d*) %+(%d+),?(%d*) @@$') if (start1 == nil) then error('Invalid patch string: "' .. text[textPointer] .. '"') end local patch = _new_patch_obj() patches[#patches + 1] = patch start1 = tonumber(start1) length1 = tonumber(length1) or 1 if (length1 == 0) then start1 = start1 + 1 end patch.start1 = start1 patch.length1 = length1 start2 = tonumber(start2) length2 = tonumber(length2) or 1 if (length2 == 0) then start2 = start2 + 1 end patch.start2 = start2 patch.length2 = length2 textPointer = textPointer + 1 while true do local line = text[textPointer] if (line == nil) then break end local sign; sign, line = strsub(line, 1, 1), strsub(line, 2) local invalidDecode = false local decoded = gsub(line, '%%(.?.?)', function(c) local n = tonumber(c, 16) if (#c ~= 2) or (n == nil) then invalidDecode = true return '' end return strchar(n) end) if invalidDecode then -- Malformed URI sequence. error('Illegal escape in patch_fromText: ' .. line) end line = decoded if (sign == '-') then -- Deletion. patch.diffs[#patch.diffs + 1] = {DIFF_DELETE, line} elseif (sign == '+') then -- Insertion. patch.diffs[#patch.diffs + 1] = {DIFF_INSERT, line} elseif (sign == ' ') then -- Minor equality. patch.diffs[#patch.diffs + 1] = {DIFF_EQUAL, line} elseif (sign == '@') then -- Start of next patch. break elseif (sign == '') then -- Blank line? Whatever. else -- WTF? error('Invalid patch mode "' .. sign .. '" in: ' .. line) end textPointer = textPointer + 1 end end return patches end -- --------------------------------------------------------------------------- -- UNOFFICIAL/PRIVATE PATCH FUNCTIONS -- --------------------------------------------------------------------------- local patch_meta = { __tostring = function(patch) local buf = {} _patch_appendText(patch, buf) return tconcat(buf) end } --[[ * Class representing one patch operation. * @constructor --]] function _new_patch_obj() return setmetatable({ --[[ @type {Array.<Array.<number|string>>} ]] diffs = {}; --[[ @type {?number} ]] start1 = 1; -- nil; --[[ @type {?number} ]] start2 = 1; -- nil; --[[ @type {number} ]] length1 = 0; --[[ @type {number} ]] length2 = 0; }, patch_meta) end --[[ * Increase the context until it is unique, * but don't let the pattern expand beyond Match_MaxBits. * @param {_new_patch_obj} patch The patch to grow. * @param {string} text Source text. * @private --]] function _patch_addContext(patch, text) if (#text == 0) then return end local pattern = strsub(text, patch.start2, patch.start2 + patch.length1 - 1) local padding = 0 -- LUANOTE: Lua's lack of a lastIndexOf function results in slightly -- different logic here than in other language ports. -- Look for the first two matches of pattern in text. If two are found, -- increase the pattern length. local firstMatch = indexOf(text, pattern) local secondMatch = nil if (firstMatch ~= nil) then secondMatch = indexOf(text, pattern, firstMatch + 1) end while (#pattern == 0 or secondMatch ~= nil) and (#pattern < Match_MaxBits - Patch_Margin - Patch_Margin) do padding = padding + Patch_Margin pattern = strsub(text, max(1, patch.start2 - padding), patch.start2 + patch.length1 - 1 + padding) firstMatch = indexOf(text, pattern) if (firstMatch ~= nil) then secondMatch = indexOf(text, pattern, firstMatch + 1) else secondMatch = nil end end -- Add one chunk for good luck. padding = padding + Patch_Margin -- Add the prefix. local prefix = strsub(text, max(1, patch.start2 - padding), patch.start2 - 1) if (#prefix > 0) then tinsert(patch.diffs, 1, {DIFF_EQUAL, prefix}) end -- Add the suffix. local suffix = strsub(text, patch.start2 + patch.length1, patch.start2 + patch.length1 - 1 + padding) if (#suffix > 0) then patch.diffs[#patch.diffs + 1] = {DIFF_EQUAL, suffix} end -- Roll back the start points. patch.start1 = patch.start1 - #prefix patch.start2 = patch.start2 - #prefix -- Extend the lengths. patch.length1 = patch.length1 + #prefix + #suffix patch.length2 = patch.length2 + #prefix + #suffix end --[[ * Given an array of patches, return another array that is identical. * @param {Array.<_new_patch_obj>} patches Array of patch objects. * @return {Array.<_new_patch_obj>} Array of patch objects. --]] function _patch_deepCopy(patches) local patchesCopy = {} for x, patch in ipairs(patches) do local patchCopy = _new_patch_obj() local diffsCopy = {} for i, diff in ipairs(patch.diffs) do diffsCopy[i] = {diff[1], diff[2]} end patchCopy.diffs = diffsCopy patchCopy.start1 = patch.start1 patchCopy.start2 = patch.start2 patchCopy.length1 = patch.length1 patchCopy.length2 = patch.length2 patchesCopy[x] = patchCopy end return patchesCopy end --[[ * Add some padding on text start and end so that edges can match something. * Intended to be called only from within patch_apply. * @param {Array.<_new_patch_obj>} patches Array of patch objects. * @return {string} The padding string added to each side. --]] function _patch_addPadding(patches) local paddingLength = Patch_Margin local nullPadding = '' for x = 1, paddingLength do nullPadding = nullPadding .. strchar(x) end -- Bump all the patches forward. for x, patch in ipairs(patches) do patch.start1 = patch.start1 + paddingLength patch.start2 = patch.start2 + paddingLength end -- Add some padding on start of first diff. local patch = patches[1] local diffs = patch.diffs local firstDiff = diffs[1] if (firstDiff == nil) or (firstDiff[1] ~= DIFF_EQUAL) then -- Add nullPadding equality. tinsert(diffs, 1, {DIFF_EQUAL, nullPadding}) patch.start1 = patch.start1 - paddingLength -- Should be 0. patch.start2 = patch.start2 - paddingLength -- Should be 0. patch.length1 = patch.length1 + paddingLength patch.length2 = patch.length2 + paddingLength elseif (paddingLength > #firstDiff[2]) then -- Grow first equality. local extraLength = paddingLength - #firstDiff[2] firstDiff[2] = strsub(nullPadding, #firstDiff[2] + 1) .. firstDiff[2] patch.start1 = patch.start1 - extraLength patch.start2 = patch.start2 - extraLength patch.length1 = patch.length1 + extraLength patch.length2 = patch.length2 + extraLength end -- Add some padding on end of last diff. patch = patches[#patches] diffs = patch.diffs local lastDiff = diffs[#diffs] if (lastDiff == nil) or (lastDiff[1] ~= DIFF_EQUAL) then -- Add nullPadding equality. diffs[#diffs + 1] = {DIFF_EQUAL, nullPadding} patch.length1 = patch.length1 + paddingLength patch.length2 = patch.length2 + paddingLength elseif (paddingLength > #lastDiff[2]) then -- Grow last equality. local extraLength = paddingLength - #lastDiff[2] lastDiff[2] = lastDiff[2] .. strsub(nullPadding, 1, extraLength) patch.length1 = patch.length1 + extraLength patch.length2 = patch.length2 + extraLength end return nullPadding end --[[ * Look through the patches and break up any which are longer than the maximum * limit of the match algorithm. * Intended to be called only from within patch_apply. * @param {Array.<_new_patch_obj>} patches Array of patch objects. --]] function _patch_splitMax(patches) local patch_size = Match_MaxBits local x = 1 while true do local patch = patches[x] if patch == nil then return end if patch.length1 > patch_size then local bigpatch = patch -- Remove the big old patch. tremove(patches, x) x = x - 1 local start1 = bigpatch.start1 local start2 = bigpatch.start2 local precontext = '' while bigpatch.diffs[1] do -- Create one of several smaller patches. local patch = _new_patch_obj() local empty = true patch.start1 = start1 - #precontext patch.start2 = start2 - #precontext if precontext ~= '' then patch.length1, patch.length2 = #precontext, #precontext patch.diffs[#patch.diffs + 1] = {DIFF_EQUAL, precontext} end while bigpatch.diffs[1] and (patch.length1 < patch_size-Patch_Margin) do local diff_type = bigpatch.diffs[1][1] local diff_text = bigpatch.diffs[1][2] if (diff_type == DIFF_INSERT) then -- Insertions are harmless. patch.length2 = patch.length2 + #diff_text start2 = start2 + #diff_text patch.diffs[#(patch.diffs) + 1] = bigpatch.diffs[1] tremove(bigpatch.diffs, 1) empty = false elseif (diff_type == DIFF_DELETE) and (#patch.diffs == 1) and (patch.diffs[1][1] == DIFF_EQUAL) and (#diff_text > 2 * patch_size) then -- This is a large deletion. Let it pass in one chunk. patch.length1 = patch.length1 + #diff_text start1 = start1 + #diff_text empty = false patch.diffs[#patch.diffs + 1] = {diff_type, diff_text} tremove(bigpatch.diffs, 1) else -- Deletion or equality. -- Only take as much as we can stomach. diff_text = strsub(diff_text, 1, patch_size - patch.length1 - Patch_Margin) patch.length1 = patch.length1 + #diff_text start1 = start1 + #diff_text if (diff_type == DIFF_EQUAL) then patch.length2 = patch.length2 + #diff_text start2 = start2 + #diff_text else empty = false end patch.diffs[#patch.diffs + 1] = {diff_type, diff_text} if (diff_text == bigpatch.diffs[1][2]) then tremove(bigpatch.diffs, 1) else bigpatch.diffs[1][2] = strsub(bigpatch.diffs[1][2], #diff_text + 1) end end end -- Compute the head context for the next patch. precontext = _diff_text2(patch.diffs) precontext = strsub(precontext, -Patch_Margin) -- Append the end context for this patch. local postcontext = strsub(_diff_text1(bigpatch.diffs), 1, Patch_Margin) if postcontext ~= '' then patch.length1 = patch.length1 + #postcontext patch.length2 = patch.length2 + #postcontext if patch.diffs[1] and (patch.diffs[#patch.diffs][1] == DIFF_EQUAL) then patch.diffs[#patch.diffs][2] = patch.diffs[#patch.diffs][2] .. postcontext else patch.diffs[#patch.diffs + 1] = {DIFF_EQUAL, postcontext} end end if not empty then x = x + 1 tinsert(patches, x, patch) end end end x = x + 1 end end --[[ * Emulate GNU diff's format. * Header: @@ -382,8 +481,9 @@ * @return {string} The GNU diff string. --]] function _patch_appendText(patch, text) local coords1, coords2 local length1, length2 = patch.length1, patch.length2 local start1, start2 = patch.start1, patch.start2 local diffs = patch.diffs if length1 == 1 then coords1 = start1 else coords1 = ((length1 == 0) and (start1 - 1) or start1) .. ',' .. length1 end if length2 == 1 then coords2 = start2 else coords2 = ((length2 == 0) and (start2 - 1) or start2) .. ',' .. length2 end text[#text + 1] = '@@ -' .. coords1 .. ' +' .. coords2 .. ' @@\n' local op -- Escape the body of the patch with %xx notation. for x, diff in ipairs(patch.diffs) do local diff_type = diff[1] if diff_type == DIFF_INSERT then op = '+' elseif diff_type == DIFF_DELETE then op = '-' elseif diff_type == DIFF_EQUAL then op = ' ' end text[#text + 1] = op .. gsub(diffs[x][2], percentEncode_pattern, percentEncode_replace) .. '\n' end return text end -- Expose the API local _M = {} _M.DIFF_DELETE = DIFF_DELETE _M.DIFF_INSERT = DIFF_INSERT _M.DIFF_EQUAL = DIFF_EQUAL _M.diff_main = diff_main _M.diff_cleanupSemantic = diff_cleanupSemantic _M.diff_cleanupEfficiency = diff_cleanupEfficiency _M.diff_levenshtein = diff_levenshtein _M.diff_prettyHtml = diff_prettyHtml _M.match_main = match_main _M.patch_make = patch_make _M.patch_toText = patch_toText _M.patch_fromText = patch_fromText _M.patch_apply = patch_apply -- Expose some non-API functions as well, for testing purposes etc. _M.diff_commonPrefix = _diff_commonPrefix _M.diff_commonSuffix = _diff_commonSuffix _M.diff_commonOverlap = _diff_commonOverlap _M.diff_halfMatch = _diff_halfMatch _M.diff_bisect = _diff_bisect _M.diff_cleanupMerge = _diff_cleanupMerge _M.diff_cleanupSemanticLossless = _diff_cleanupSemanticLossless _M.diff_text1 = _diff_text1 _M.diff_text2 = _diff_text2 _M.diff_toDelta = _diff_toDelta _M.diff_fromDelta = _diff_fromDelta _M.diff_xIndex = _diff_xIndex _M.match_alphabet = _match_alphabet _M.match_bitap = _match_bitap _M.new_patch_obj = _new_patch_obj _M.patch_addContext = _patch_addContext _M.patch_splitMax = _patch_splitMax _M.patch_addPadding = _patch_addPadding _M.settings = settings return _M
apache-2.0
anshkumar/yugioh-glaze
assets/script/c78910579.lua
7
1546
--儀水鏡の反魂術 function c78910579.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(c78910579.target) e1:SetOperation(c78910579.activate) c:RegisterEffect(e1) end function c78910579.filter1(c) return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_WATER) and c:IsAbleToDeck() end function c78910579.filter2(c) return c:IsAttribute(ATTRIBUTE_WATER) and c:IsAbleToHand() end function c78910579.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return false end if chk==0 then return Duel.IsExistingTarget(c78910579.filter1,tp,LOCATION_MZONE,0,1,nil) and Duel.IsExistingTarget(c78910579.filter2,tp,LOCATION_GRAVE,0,2,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local g1=Duel.SelectTarget(tp,c78910579.filter1,tp,LOCATION_MZONE,0,1,1,nil) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) local g2=Duel.SelectTarget(tp,c78910579.filter2,tp,LOCATION_GRAVE,0,2,2,nil) Duel.SetOperationInfo(0,CATEGORY_TODECK,g1,1,0,0) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g2,2,0,0) end function c78910579.activate(e,tp,eg,ep,ev,re,r,rp) local ex,g1=Duel.GetOperationInfo(0,CATEGORY_TODECK) local ex,g2=Duel.GetOperationInfo(0,CATEGORY_TOHAND) local tc1=g1:GetFirst() if tc1:IsRelateToEffect(e) and Duel.SendtoDeck(tc1,nil,2,REASON_EFFECT)~=0 then local hg=g2:Filter(Card.IsRelateToEffect,nil,e) Duel.SendtoHand(hg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,hg) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c62701967.lua
5
1529
--ジュラック・ティラヌス function c62701967.initial_effect(c) --atkup local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(62701967,0)) e1:SetCategory(CATEGORY_ATKCHANGE) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetLabel(500) e1:SetCost(c62701967.atkcost) e1:SetOperation(c62701967.operation) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(62701967,0)) e2:SetCategory(CATEGORY_ATKCHANGE) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e2:SetCode(EVENT_BATTLE_DESTROYING) e2:SetLabel(300) e2:SetCondition(c62701967.atkcon) e2:SetOperation(c62701967.operation) c:RegisterEffect(e2) end function c62701967.atkcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckReleaseGroup(tp,Card.IsRace,1,e:GetHandler(),RACE_DINOSAUR) end local sg=Duel.SelectReleaseGroup(tp,Card.IsRace,1,1,e:GetHandler(),RACE_DINOSAUR) Duel.Release(sg,REASON_COST) end function c62701967.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsFaceup() and c:IsRelateToEffect(e) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetValue(e:GetLabel()) e1:SetReset(RESET_EVENT+0x1ff0000) c:RegisterEffect(e1) end end function c62701967.atkcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local bc=c:GetBattleTarget() return c:IsFaceup() and c:IsRelateToBattle() and bc:IsLocation(LOCATION_GRAVE) and bc:IsReason(REASON_BATTLE) and bc:IsType(TYPE_MONSTER) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c35638627.lua
3
1610
--ワーム・ウォーロード function c35638627.initial_effect(c) --cannot special summon local e1=Effect.CreateEffect(c) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_SPSUMMON_CONDITION) c:RegisterEffect(e1) --Disable local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_BATTLED) e2:SetOperation(c35638627.disop) c:RegisterEffect(e2) --chain attack local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(35638627,0)) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_BATTLED) e3:SetCondition(c35638627.atcon) e3:SetOperation(c35638627.atop) c:RegisterEffect(e3) end function c35638627.disop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetAttackTarget() local c=e:GetHandler() if c==tc then tc=Duel.GetAttacker() end if tc and tc:IsType(TYPE_EFFECT) and tc:IsStatus(STATUS_BATTLE_DESTROYED) then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_DISABLE) e1:SetReset(RESET_EVENT+0x17a0000) tc:RegisterEffect(e1) local e2=Effect.CreateEffect(e:GetHandler()) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_DISABLE_EFFECT) e2:SetReset(RESET_EVENT+0x17a0000) tc:RegisterEffect(e2) end end function c35638627.atcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local bc=c:GetBattleTarget() return bc and bc:IsStatus(STATUS_BATTLE_DESTROYED) and c:IsChainAttackable() and c:IsStatus(STATUS_OPPO_BATTLE) end function c35638627.atop(e,tp,eg,ep,ev,re,r,rp) Duel.ChainAttack() end
gpl-2.0
astog/cqui
Assets/UI/Panels/notificationpanel.lua
4
77128
-- =========================================================================== -- Notification Panel -- =========================================================================== include( "ToolTipHelper" ); include( "InstanceManager" ); -- =========================================================================== -- DEBUG -- =========================================================================== local m_debugStrictRemoval :boolean = true; -- (false) Give a warning if a removal occurs and the notification doesn't exist. local m_debugNotificationNum:number = 0; -- (0) The # of fake notifications to fill the panel with; great for testing. -- =========================================================================== -- CONSTANTS -- =========================================================================== local COLOR_PIP_CURRENT :number = 0xffffffff; local COLOR_PIP_OTHER :number = 0xff3c3c3c; local DEBUG_NOTIFICATION_TYPE :number = 999999; local SIZE_TOP_SPACE_Y :number = 140; local TIME_PAUSE_FIRST_SHOW_NOTIFICATION :number = 2; local TIME_PAUSE_MOUSE_OVER_NOTIFICATION :number = 1; local TOPBAR_OFFSET :number = 50; local ACTION_CORNER_OFFSET :number = 300; -- Rail should still visible further down screen even when extended local DATA_ICON_PREFIX :string = "ICON_"; local SCROLLBAR_OFFSET :number = 13; local MAX_WIDTH_INSTANCE :number = 500; local RAIL_OFFSET_ANIM_Y_OFFSET :number = -72; -- =========================================================================== -- VARIABLES -- =========================================================================== local m_groupIM :table = InstanceManager:new( "GroupInstance", "Top", Controls.Groups ); local m_genericItemIM :table = InstanceManager:new( "ItemInstance", "Top", Controls.Items ); local m_screenX, m_screenY :number = UIManager:GetScreenSizeVal(); local _, offsetY :number = 0,0; --Controls.OuterStack:GetOffsetVal(); -- The structure for the handler functions for a notification type. -- Each notification type can override one or more of these handlers, usually the Active handler -- to allow for different functionality hstructure NotificationHandler Add : ifunction; Dismiss : ifunction; TryDismiss : ifunction; Activate : ifunction; OnPhaseBegin : ifunction; OnNextSelect : ifunction; OnPreviousSelect : ifunction; AddSound : string; -- optional: name of sound to trigger each time it end -- The structure that holds the group data for a set of notifications. hstructure NotificationGroupType m_GroupID : number; -- The group ID for all the notifications this group is tracking. m_InstanceManager : table; -- The instance manager that made the control set for the group. m_Instance : table; -- The instanced control set for the group UI. m_PlayerID : number; -- The player who the notification is for m_Notifications : table; -- All the notifications that are in the group. end -- The structure that holds the UI notification data. hstructure NotificationType m_InstanceManager : table; -- The instance manager that made the control set. m_Instance : table; -- The instanced control set. m_kHandlers : NotificationHandler; -- The handler set for the notification m_PlayerID : number; -- The player who the notification is for m_IDs : table; -- The IDs related to this type of notificaiton m_Group : NotificationGroupType; -- The group of the notification, can be nil m_TypeName : string; -- Key for type of notification m_isAuto : boolean; -- If the notification auto re-adds based on per logic frame evaluation m_Index : number; -- Current index of notification being looked at. m_maxWidth : number; -- Largest width of message for this notification (stack). m_wrapWidth : number; -- Largest wrap width for this notification (stack). Used to avoid Y bouncing between messages. end local m_notifications : table = {}; -- All the notification instances local m_notificationGroups : table = {}; -- The grouped notifications local m_notificationHandlers : table = {}; local m_kDebugNotification : table = {}; local m_lastStackSize : number = 0; local m_lastStackDiff : number = 0; local m_ActionPanelGearAnim : table = ContextPtr:LookUpControl( "/InGame/ActionPanel/TickerAnim" ); local m_isLoadComplete : boolean = false; -- ======================================================================================= function GetActiveNotificationFromEntry(notificationEntry : NotificationType) if notificationEntry.m_Index >= 1 and notificationEntry.m_Index <= table.count(notificationEntry.m_IDs) then local notificationID :number = notificationEntry.m_IDs[ notificationEntry.m_Index ]; local pNotification :table = NotificationManager.Find( notificationEntry.m_PlayerID, notificationID ); return pNotification; end return nil; end -- ======================================================================================= function RegisterHandlers() -- Add the table of function handlers for each type of notification m_notificationHandlers[DEBUG_NOTIFICATION_TYPE] = MakeDefaultHandlers(); --DEBUG m_notificationHandlers[NotificationTypes.DEFAULT] = MakeDefaultHandlers(); --DEFAULT m_notificationHandlers[NotificationTypes.CHOOSE_ARTIFACT_PLAYER] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.CHOOSE_BELIEF] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.CHOOSE_CITY_PRODUCTION] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.CHOOSE_CIVIC] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.CHOOSE_PANTHEON] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.CHOOSE_RELIGION] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.CHOOSE_TECH] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.CITY_LOW_AMENITIES] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.CLAIM_GREAT_PERSON] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.COMMAND_UNITS] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.CONSIDER_GOVERNMENT_CHANGE] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.CONSIDER_RAZE_CITY] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.DIPLOMACY_SESSION] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.FILL_CIVIC_SLOT] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.GIVE_INFLUENCE_TOKEN] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.PLAYER_MET] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_CHOOSE_DRAGNET_PRIORITY] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_CHOOSE_ESCAPE_ROUTE] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_KILLED] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.TREASURY_BANKRUPT] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.HOUSING_PREVENTING_GROWTH] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.BARBARIANS_SIGHTED] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.CAPITAL_LOST] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.TRADE_ROUTE_PLUNDERED] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.CITY_STARVING] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.CITY_FOOD_FOCUS] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.CITYSTATE_QUEST_COMPLETED] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.TRADE_ROUTE_CAPACITY_INCREASED] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.RELIC_CREATED] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.REBELLION] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.PLAYER_DEFEATED] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.DISCOVER_CONTINENT] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.UNIT_PROMOTION_AVAILABLE] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.WONDER_COMPLETED] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.ROADS_UPGRADED] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_HEIST_GREAT_WORK] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_RECRUIT_PARTISANS] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_SABOTAGED_PRODUCTION] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_SIPHONED_FUNDS] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_STOLE_TECH_BOOST] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_DISRUPTED_ROCKETRY] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_MISSION_FAILED] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_CAPTURED] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_MISSION_ABORTED] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_COUNTERSPY_PROMOTED] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_CITY_SOURCES_GAINED] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_ESCAPED_CAPTURE] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_LISTENING_POST] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_FLED_CITY] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_ENEMY_HEIST_GREAT_WORK] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_ENEMY_RECRUIT_PARTISANS] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_ENEMY_SABOTAGED_PRODUCTION] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_ENEMY_SIPHONED_FUNDS] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_ENEMY_STOLE_TECH_BOOST] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_ENEMY_DISRUPTED_ROCKETRY] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_ENEMY_CAPTURED] = MakeDefaultHandlers(); m_notificationHandlers[NotificationTypes.SPY_ENEMY_KILLED] = MakeDefaultHandlers(); -- Custom function handlers for the "Activate" signal: m_notificationHandlers[DEBUG_NOTIFICATION_TYPE].Activate = OnDebugActivate; m_notificationHandlers[NotificationTypes.CHOOSE_ARTIFACT_PLAYER].Activate = OnChooseArtifactPlayerActivate; m_notificationHandlers[NotificationTypes.CHOOSE_BELIEF].Activate = OnChooseReligionActivate; m_notificationHandlers[NotificationTypes.CHOOSE_CITY_PRODUCTION].Activate = OnChooseCityProductionActivate; m_notificationHandlers[NotificationTypes.CHOOSE_CIVIC].Activate = OnChooseCivicActivate; m_notificationHandlers[NotificationTypes.CHOOSE_PANTHEON].Activate = OnChooseReligionActivate; m_notificationHandlers[NotificationTypes.CHOOSE_RELIGION].Activate = OnChooseReligionActivate; m_notificationHandlers[NotificationTypes.CHOOSE_TECH].Activate = OnChooseTechActivate; m_notificationHandlers[NotificationTypes.CLAIM_GREAT_PERSON].Activate = OnClaimGreatPersonActivate; m_notificationHandlers[NotificationTypes.COMMAND_UNITS].Activate = OnCommandUnitsActivate; m_notificationHandlers[NotificationTypes.CONSIDER_GOVERNMENT_CHANGE].Activate = OnConsiderGovernmentChangeActivate; m_notificationHandlers[NotificationTypes.CONSIDER_RAZE_CITY].Activate = OnConsiderRazeCityActivate; m_notificationHandlers[NotificationTypes.DIPLOMACY_SESSION].Activate = OnDiplomacySessionActivate; m_notificationHandlers[NotificationTypes.FILL_CIVIC_SLOT].Activate = OnFillCivicSlotActivate; m_notificationHandlers[NotificationTypes.GIVE_INFLUENCE_TOKEN].Activate = OnGiveInfluenceTokenActivate; m_notificationHandlers[NotificationTypes.SPY_CHOOSE_DRAGNET_PRIORITY].Activate = OnChooseEscapeRouteActivate; m_notificationHandlers[NotificationTypes.SPY_CHOOSE_ESCAPE_ROUTE].Activate = OnChooseEscapeRouteActivate; m_notificationHandlers[NotificationTypes.PLAYER_DEFEATED].Activate = OnLookAtAndActivateNotification; m_notificationHandlers[NotificationTypes.DISCOVER_CONTINENT].Activate = OnDiscoverContinentActivateNotification; -- Sound to play when added m_notificationHandlers[NotificationTypes.SPY_KILLED].AddSound = "ALERT_NEGATIVE"; m_notificationHandlers[NotificationTypes.TREASURY_BANKRUPT].AddSound = "ALERT_NEGATIVE"; m_notificationHandlers[NotificationTypes.HOUSING_PREVENTING_GROWTH].AddSound = "ALERT_NEUTRAL"; m_notificationHandlers[NotificationTypes.BARBARIANS_SIGHTED].AddSound = "ALERT_NEGATIVE"; m_notificationHandlers[NotificationTypes.CAPITAL_LOST].AddSound = "ALERT_NEUTRAL"; m_notificationHandlers[NotificationTypes.TRADE_ROUTE_PLUNDERED].AddSound = "ALERT_NEGATIVE"; m_notificationHandlers[NotificationTypes.CITY_STARVING].AddSound = "ALERT_NEUTRAL"; m_notificationHandlers[NotificationTypes.CITY_FOOD_FOCUS].AddSound = "ALERT_NEUTRAL"; m_notificationHandlers[NotificationTypes.CITY_LOW_AMENITIES].AddSound = "ALERT_NEUTRAL"; m_notificationHandlers[NotificationTypes.CITYSTATE_QUEST_COMPLETED].AddSound = "ALERT_POSITIVE"; m_notificationHandlers[NotificationTypes.TRADE_ROUTE_CAPACITY_INCREASED].AddSound = "ALERT_POSITIVE"; m_notificationHandlers[NotificationTypes.RELIC_CREATED].AddSound = "NOTIFICATION_MISC_POSITIVE"; m_notificationHandlers[NotificationTypes.REBELLION].AddSound = "NOTIFICATION_REBELLION"; m_notificationHandlers[NotificationTypes.UNIT_PROMOTION_AVAILABLE].AddSound = "UNIT_PROMOTION_AVAILABLE"; m_notificationHandlers[NotificationTypes.WONDER_COMPLETED].AddSound = "NOTIFICATION_OTHER_CIV_BUILD_WONDER"; m_notificationHandlers[NotificationTypes.SPY_HEIST_GREAT_WORK].AddSound = "NOTIFICATION_ESPIONAGE_OP_SUCCESS"; m_notificationHandlers[NotificationTypes.SPY_RECRUIT_PARTISANS].AddSound = "NOTIFICATION_ESPIONAGE_OP_SUCCESS"; m_notificationHandlers[NotificationTypes.SPY_SABOTAGED_PRODUCTION].AddSound = "NOTIFICATION_ESPIONAGE_OP_SUCCESS"; m_notificationHandlers[NotificationTypes.SPY_SIPHONED_FUNDS].AddSound = "NOTIFICATION_ESPIONAGE_OP_SUCCESS"; m_notificationHandlers[NotificationTypes.SPY_STOLE_TECH_BOOST].AddSound = "NOTIFICATION_ESPIONAGE_OP_SUCCESS"; m_notificationHandlers[NotificationTypes.SPY_DISRUPTED_ROCKETRY].AddSound = "NOTIFICATION_ESPIONAGE_OP_SUCCESS"; m_notificationHandlers[NotificationTypes.SPY_MISSION_FAILED].AddSound = "NOTIFICATION_ESPIONAGE_OP_SUCCESS"; m_notificationHandlers[NotificationTypes.SPY_CAPTURED].AddSound = "NOTIFICATION_ESPIONAGE_OP_FAILED"; m_notificationHandlers[NotificationTypes.SPY_MISSION_ABORTED].AddSound = "NOTIFICATION_ESPIONAGE_OP_FAILED"; m_notificationHandlers[NotificationTypes.SPY_COUNTERSPY_PROMOTED].AddSound = "NOTIFICATION_ESPIONAGE_OP_SUCCESS"; m_notificationHandlers[NotificationTypes.SPY_CITY_SOURCES_GAINED].AddSound = "NOTIFICATION_ESPIONAGE_OP_SUCCESS"; m_notificationHandlers[NotificationTypes.SPY_ESCAPED_CAPTURE].AddSound = "NOTIFICATION_ESPIONAGE_OP_SUCCESS"; m_notificationHandlers[NotificationTypes.SPY_LISTENING_POST].AddSound = "NOTIFICATION_ESPIONAGE_OP_SUCCESS"; m_notificationHandlers[NotificationTypes.SPY_FLED_CITY].AddSound = "NOTIFICATION_ESPIONAGE_OP_FAILED"; m_notificationHandlers[NotificationTypes.SPY_ENEMY_HEIST_GREAT_WORK].AddSound = "NOTIFICATION_ESPIONAGE_OP_FAILED"; m_notificationHandlers[NotificationTypes.SPY_ENEMY_RECRUIT_PARTISANS].AddSound = "NOTIFICATION_ESPIONAGE_OP_FAILED"; m_notificationHandlers[NotificationTypes.SPY_ENEMY_SABOTAGED_PRODUCTION].AddSound = "NOTIFICATION_ESPIONAGE_OP_FAILED"; m_notificationHandlers[NotificationTypes.SPY_ENEMY_SIPHONED_FUNDS].AddSound = "NOTIFICATION_ESPIONAGE_OP_FAILED"; m_notificationHandlers[NotificationTypes.SPY_ENEMY_STOLE_TECH_BOOST].AddSound = "NOTIFICATION_ESPIONAGE_OP_FAILED"; m_notificationHandlers[NotificationTypes.SPY_ENEMY_DISRUPTED_ROCKETRY].AddSound = "NOTIFICATION_ESPIONAGE_OP_FAILED"; m_notificationHandlers[NotificationTypes.SPY_ENEMY_CAPTURED].AddSound = "NOTIFICATION_ESPIONAGE_OP_SUCCESS"; m_notificationHandlers[NotificationTypes.SPY_ENEMY_KILLED].AddSound = "NOTIFICATION_ESPIONAGE_OP_SUCCESS"; -- Custom function handlers for the "Add" signal: m_notificationHandlers[DEBUG_NOTIFICATION_TYPE].Add = OnDebugAdd; m_notificationHandlers[NotificationTypes.PLAYER_MET].Add = OnMetCivAddNotification; -- Custom function handlers for the "Dismiss" signal: m_notificationHandlers[DEBUG_NOTIFICATION_TYPE].Dismiss = OnDebugDismiss; -- Custom function handlers for the "OnPhaseBegin" signal: m_notificationHandlers[DEBUG_NOTIFICATION_TYPE].OnPhaseBegin = OnPhaseBegin; -- Custom function handlers for the "TryDismiss" signal: -- Custom function handlers for the "OnNextSelect" callback: m_notificationHandlers[NotificationTypes.COMMAND_UNITS].OnNextSelect = OnCommandUnitsNextSelect; -- Custom function handlers for the "OnPreviousSelect" callback: m_notificationHandlers[NotificationTypes.COMMAND_UNITS].OnPreviousSelect = OnCommandUnitsPreviousSelect; end -- =========================================================================== function ProcessStackSizes() ProcessNotificationSizes(Game.GetLocalPlayer()); Controls.ScrollStack:CalculateSize(); Controls.ScrollStack:ReprocessAnchoring(); Controls.ScrollPanel:CalculateSize(); local stacksize = Controls.ScrollStack:GetSizeY(); -- Play the gear ticking animation if m_ActionPanelGearAnim ~= nil then m_ActionPanelGearAnim:SetToBeginning(); m_ActionPanelGearAnim:Play(); end -- If the notifications overflow the stack if (stacksize > m_screenY-TOPBAR_OFFSET-ACTION_CORNER_OFFSET) then if (Controls.RailOffsetAnim:GetOffsetX() ~= SCROLLBAR_OFFSET) then Controls.RailOffsetAnim:SetBeginVal(0,0); Controls.RailOffsetAnim:SetEndVal(SCROLLBAR_OFFSET,RAIL_OFFSET_ANIM_Y_OFFSET); Controls.RailOffsetAnim:SetToBeginning(); Controls.RailOffsetAnim:Play(); end else if (Controls.RailOffsetAnim:GetOffsetX() ~= 0) then Controls.RailOffsetAnim:SetBeginVal(SCROLLBAR_OFFSET,0); Controls.RailOffsetAnim:SetEndVal(0,RAIL_OFFSET_ANIM_Y_OFFSET); Controls.RailOffsetAnim:SetToBeginning(); Controls.RailOffsetAnim:Play(); end end Controls.ScrollStack:ReprocessAnchoring(); -- Notifications were added to the stack at the beginning of the turn if (m_lastStackSize == 0 and stacksize ~= m_lastStackSize) then Controls.RailImage:SetSizeY(stacksize+ ACTION_CORNER_OFFSET); Controls.RailAnim:SetSizeY(ACTION_CORNER_OFFSET-stacksize); Controls.RailAnim:SetBeginVal(0,0); Controls.RailAnim:SetEndVal(0,0); Controls.RailAnim:SetToBeginning(); if m_isLoadComplete then UI.PlaySound("UI_Notification_Bar_Notch"); end Controls.RailAnim:Play(); -- A notification was added or dismissed from the stack during the turn elseif (m_lastStackSize ~= 0 and stacksize ~= m_lastStackSize and stacksize ~= 0) then Controls.RailImage:SetSizeY(stacksize+ ACTION_CORNER_OFFSET); Controls.RailAnim:SetBeginVal(0,m_lastStackDiff); Controls.RailAnim:SetEndVal(0,m_lastStackDiff + stacksize-m_lastStackSize); Controls.RailAnim:SetToBeginning(); Controls.RailAnim:Play(); m_lastStackDiff = m_lastStackDiff + stacksize - m_lastStackSize; -- The stack size went from something to zero elseif (stacksize ~= m_lastStackSize and stacksize == 0) then Controls.RailAnim:SetBeginVal(0,m_lastStackDiff); Controls.RailAnim:SetEndVal(0,m_lastStackDiff-ACTION_CORNER_OFFSET); Controls.RailAnim:SetToBeginning(); if m_isLoadComplete then UI.PlaySound("UI_Notification_Bar_Latch"); end Controls.RailAnim:Play(); Controls.RailImage:SetSizeY(100); end m_lastStackSize = stacksize; end -- =========================================================================== -- Get the handler table for a notification type. -- Returns default handler table if one doesn't exist. -- =========================================================================== function GetHandler( notificationType:number ) local handlers = m_notificationHandlers[notificationType]; if (handlers == nil) then handlers = m_notificationHandlers[NotificationTypes.DEFAULT]; end return handlers; end -- =========================================================================== function GetDefaultHandler() return m_notificationHandlers[NotificationTypes.DEFAULT]; end -- =========================================================================== -- Sets width of notifications in the stack to the largest width. -- =========================================================================== function SetWidthNotificationStack( playerID:number, notificationID:number ) -- Spacing details local X_EXTRA :number = 20; -- Needs to cover right (collapsed) side button too. local X_EXTRA_MOUSE_OUT :number = 70; local X_AREA :number = 215; -- Set the extends/bounds of the ExpandedArea of the notification stack local notificationEntry:NotificationType = GetNotificationEntry( playerID, notificationID ); if (notificationEntry ~= nil) and (notificationEntry.m_Instance ~= nil) then for i,id in ipairs(notificationEntry.m_IDs) do local currentEntry :NotificationType = GetNotificationEntry( playerID, id ); currentEntry.m_Instance.ExpandedArea:SetSizeX( currentEntry.m_maxWidth + X_EXTRA); currentEntry.m_Instance.NotificationSlide:SetEndVal( ((currentEntry.m_maxWidth - X_AREA) + X_EXTRA ), 0 ); currentEntry.m_Instance.MouseOutArea:SetSizeX( currentEntry.m_maxWidth + X_EXTRA_MOUSE_OUT); end end end -- =========================================================================== -- Does the list contain the specified notification ID? function HasNotificationID( idList:table, notificationID:number) for i,id in ipairs(idList) do if id == notificationID then return true; end end return false; end -- =========================================================================== -- Add a notification entry to for UI track. This just adds a structure to track -- the UI. The UI itself is not initialized. -- Ok if it already exists. -- =========================================================================== function AddNotificationEntry( playerID:number, typeName:string, notificationID:number, notificationGroupID:number ) -- Obtain existing player table or create one if first time call is made. local playerTable :table = m_notifications[playerID]; if playerTable == nil then m_notifications[playerID] = {}; playerTable = m_notifications[playerID]; end local notificationEntry = playerTable[typeName]; if notificationEntry == nil then playerTable[typeName] = hmake NotificationType { m_IDs = {notificationID}, -- list with 1 item m_PlayerID = playerID, m_TypeName = typeName, m_isAuto = false, m_Group = nil, m_Index = 1, m_maxWidth = 0, m_wrapWidth = 0, }; notificationEntry = playerTable[typeName]; -- Add it to its group, unless it is NONE if notificationGroupID ~= NotificationGroups.NONE then local notificationGroup = m_notificationGroups[notificationGroupID]; if (m_notificationGroups[notificationGroupID] == nil) then m_notificationGroups[notificationGroupID] = hmake NotificationGroupType { m_GroupID = notificationGroupID; m_PlayerID = playerID; m_Notifications = {} }; notificationGroup = m_notificationGroups[notificationGroupID]; end -- Link entry to it's group notificationEntry.m_Group = notificationGroup; -- Add the entry to the group table.insert(notificationGroup.m_Notifications, notificationEntry); end else -- Check if we already have it in there. There is a case where wee will get notification restoration events on player changed and we may have already received a notification add at turn start. if (not HasNotificationID(notificationEntry.m_IDs, notificationID)) then -- Add ID to list table.insert( notificationEntry.m_IDs, notificationID ); -- Sanity check matching groups (better be, they are the same type!) if notificationEntry.m_Group ~= nil and notificationGroupID ~= notificationEntry.m_Group.m_GroupID then error("New notification #"..tostring(notificationID).." ("..typeName.. ")is in group "..notificationGroupID.." but group type already set to "..notificationEntry.m_Group.m_GroupID ); end else return nil; -- Signal that it is already in the list by returning nil end end return notificationEntry; end -- =========================================================================== -- Returns UI entry for the notification or NIL. -- =========================================================================== function GetNotificationEntry( playerID:number, notificationID:number ) local kPlayerTable:table = m_notifications[playerID]; if (kPlayerTable == nil) then return nil; end for _,kNotification in pairs(kPlayerTable) do for _,id in ipairs(kNotification.m_IDs) do if id == notificationID then return kNotification; end end end return nil; end -- =========================================================================== -- Returns UI entry for the notification group or NIL. -- =========================================================================== function GetNotificationGroup(groupID) return m_notificationGroups[groupID]; end -- =========================================================================== -- Release the notification entry. -- =========================================================================== function ReleaseNotificationEntry( playerID:number, notificationID:number ) -- Don't try and get the Game Core notification object, it might be gone local playerTable = m_notifications[playerID]; if playerTable == nil then return; end local notificationEntry:NotificationType = GetNotificationEntry( playerID, notificationID ); if notificationEntry ~= nil then -- Remove this ID instance. local index :number = 1; for _,id in ipairs(notificationEntry.m_IDs) do if id == notificationID then table.remove( notificationEntry.m_IDs, index ); break; end index = index + 1; end -- UI is blown away if last entry is now gone, or if auto-generating (as there is likely another notification for this in the list). if table.count(notificationEntry.m_IDs) == 0 then -- Release it's UI (if it has one) if notificationEntry.m_Instance ~= nil then notificationEntry.m_Instance.ItemButton:ClearMouseOverCallback(); notificationEntry.m_Instance.MouseOutArea:ClearMouseExitCallback(); if (notificationEntry.m_InstanceManager ~= nil) then notificationEntry.m_InstanceManager:ReleaseInstance( notificationEntry.m_Instance ); else local pParent = notificationEntry.m_Instance.Top:GetParent(); if (pParent ~= nil) then pParent:DestroyChild(notificationEntry.m_Instance.Top); else ContextPtr:DestroyChild(notificationEntry.m_Instance.Top); end end end -- Remove group reference (if any) local groupInstance:NotificationGroupType = notificationEntry.m_Group; if groupInstance ~= nil then notificationEntry.m_Group = nil; for i = 1, table.count(groupInstance.m_Notifications), 1 do if (groupInstance.m_Notifications[i] == notificationEntry) then table.remove(groupInstance.m_Notifications, i); break; end end end -- Remove empty group if (groupInstance ~= nil and table.count(groupInstance.m_Notifications) == 0) then if notificationEntry.m_Group ~= nil then m_notificationGroups[notificationEntry.m_Group] = nil; end end -- Remove this local data reference playerTable[notificationEntry.m_TypeName] = nil; else -- In most situations, since there is more than one ID left, it's safe to -- update the UI with the next ID, but there are cases where the engine -- is wiping out a bunch of IDs at once -- (e.g., meeting more than 1 leader in a turn) -- In which case, more dismiss calls are about to be made... so check the -- engine still has a valid notification. local nextID :number = notificationEntry.m_IDs[1]; local pNotification :table = NotificationManager.Find( playerID, nextID ); if pNotification ~= nil then RealizeStandardNotification( playerID, nextID ); SetWidthNotificationStack(playerID, notificationID); end end else error("For player ("..tostring(playerID)..") unable to find notification ("..tostring(notificationID)..") for release."); end end -- =========================================================================== -- Release the notification stack -- =========================================================================== function TryDismissNotificationStack( playerID:number, notificationID:number ) local kPlayerTable:table = m_notifications[playerID]; if (kPlayerTable == nil) then return nil; end local topNotification :NotificationType = GetNotificationEntry( playerID, notificationID ); if (topNotification == nil) then return nil; end local pNotification :table; for _,kNotification in pairs(kPlayerTable) do for _,id in ipairs(kNotification.m_IDs) do pNotification = NotificationManager.Find( playerID, id ); if (pNotification ~= nil) then if ( topNotification.m_TypeName == pNotification:GetTypeName() ) and ( pNotification:CanUserDismiss() ) then NotificationManager.Dismiss( pNotification:GetPlayerID(), pNotification:GetID() ); end end end end end -- =========================================================================== -- Look at the current focus of a notification -- =========================================================================== function LookAtNotification( pNotification:table ) local isLookedAt :boolean = false; if (pNotification == nil) then return; end -- Do we have a valid location? if pNotification:IsLocationValid() then local x, y = pNotification:GetLocation(); -- Look at it. UI.LookAtPlot(x, y); isLookedAt = true; end -- Do we have a valid target? if pNotification:IsTargetValid() then local targetPlayerID, targetID, targetType = pNotification:GetTarget(); -- Is it a unit? if targetType == PlayerComponentTypes.UNIT then local pUnit:table = Players[targetPlayerID]:GetUnits():FindID(targetID); if (pUnit ~= nil) then -- Look at it, if we have not already if (not isLookedAt) then UI.LookAtPlot(pUnit:GetX(), pUnit:GetY()); end -- Select it. UI.DeselectAllUnits(); UI.DeselectAllCities(); UI.SelectUnit(pUnit); end elseif targetType == PlayerComponentTypes.CITY then local pCity = Players[targetPlayerID]:GetCities():FindID(targetID); if (pCity ~= nil) then -- Look at it, if we have not already if (not isLookedAt) then UI.LookAtPlot(pCity:GetX(), pCity:GetY()); end -- Select it. UI.SelectCity(pCity); end end end end -- =========================================================================== -- Look at the notification's supplied location, then call Activate on the object -- =========================================================================== function OnLookAtAndActivateNotification( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then local pNotification :table = GetActiveNotificationFromEntry(notificationEntry); if pNotification ~= nil then LookAtNotification( pNotification ); pNotification:Activate(); end end end -- =========================================================================== -- The default handler for activating a notification. -- Usually called when the user left clicks the notification -- =========================================================================== function OnDefaultActivateNotification( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then local pNotification :table = GetActiveNotificationFromEntry(notificationEntry); if pNotification ~= nil then LookAtNotification( pNotification ); end end end -- =========================================================================== -- Default handler for adding a new notification -- The input is the Game Core notification instance. -- =========================================================================== function OnDefaultAddNotification( pNotification:table ) local typeName :string = pNotification:GetTypeName(); if typeName == nil then UI.DataError("NIL notification type name for notifcation ID:"..tostring(pNotification:GetID())); return; end local playerID :number = pNotification:GetPlayerID(); local notificationID :number = pNotification:GetID(); local notificationGroupID :number = pNotification:GetGroup(); local notificationEntry :NotificationType = AddNotificationEntry(playerID, typeName, notificationID, notificationGroupID); if (notificationEntry == nil) then return; -- Didn't add it for some reason. It was either filtered out or possibly already in the list. end local kHandlers :NotificationHandler= GetHandler( pNotification:GetType() ); notificationEntry.m_kHandlers = kHandlers; -- TODO: If creating custom notification instances based on type: --[[ if (ContextPtr:LookUpControl(typeName) ~= nil) then -- We have a custom UI for the notification type ContextPtr:BuildInstanceForControl( typeName, notificationEntry.m_Instance, Controls.ScrollStack ); else -- Make a generic UI notificationEntry.m_Instance = m_genericItemIM:GetInstance(); notificationEntry.m_InstanceManager = m_genericItemIM; notificationEntry.m_Instance.Top:ChangeParent( Controls.ScrollStack ); end ]] -- Only add a visual entry for this notification if: -- It is not a blocking type (otherwise assume the ActionPanel is displaying it) -- It is the first notification entry in a group if ( table.count(notificationEntry.m_IDs)==1 and pNotification:GetEndTurnBlocking() == EndTurnBlockingTypes.NO_ENDTURN_BLOCKING ) then notificationEntry.m_Instance = m_genericItemIM:GetInstance(); notificationEntry.m_InstanceManager = m_genericItemIM; notificationEntry.m_Instance.Top:ChangeParent( Controls.ScrollStack ); notificationEntry.m_Instance["POINTER_IN"] = false; -- Manually track since 2 different, overlapping objects are tracking if a pointer is in/out if (notificationEntry.m_Instance ~= nil) then if (notificationEntry.m_Instance.ItemButton ~= nil and notificationEntry.m_Instance.ItemButtonInvalidPhase ~= nil) then -- Use the (collapse) button as the actual mouse-in area, but a larger rectangle will -- track the mouse out, since the player may be interacting with the extended -- information that flew out to the left of the notification. notificationEntry.m_Instance.ItemButton:RegisterCallback( Mouse.eLClick, function() kHandlers.Activate(notificationEntry); end ); notificationEntry.m_Instance.ItemButton:RegisterCallback( Mouse.eRClick, function() kHandlers.TryDismiss(notificationEntry); end ); notificationEntry.m_Instance.ItemButton:RegisterMouseEnterCallback( function() OnMouseEnterNotification( notificationEntry.m_Instance ); end ); notificationEntry.m_Instance.MouseOutArea:RegisterMouseExitCallback( function() OnMouseExitNotification( notificationEntry.m_Instance ); end ); --Set the notification icon if(notificationEntry.m_TypeName ~= nil) then local iconName :string = DATA_ICON_PREFIX .. notificationEntry.m_TypeName; local textureOffsetX, textureOffsetY, textureSheet = IconManager:FindIconAtlas(iconName,40); if (textureOffsetX ~= nil) then notificationEntry.m_Instance.Icon:SetTexture( textureOffsetX, textureOffsetY, textureSheet ); end end --A notification in the wrong phase can be dismissed but not activated. local messageName:string = Locale.Lookup(pNotification:GetMessage()); notificationEntry.m_Instance.ItemButtonInvalidPhase:RegisterCallback( Mouse.eLClick, OnDoNothing ); notificationEntry.m_Instance.ItemButtonInvalidPhase:RegisterCallback( Mouse.eRClick, function() kHandlers.TryDismiss(notificationEntry); end ); local toolTip:string = messageName .. "[NEWLINE]" .. Locale.Lookup("LOC_NOTIFICATION_WRONG_PHASE_TT", messageName); notificationEntry.m_Instance.ItemButtonInvalidPhase:SetToolTipString(toolTip); -- If notification is auto generated, it will have an internal count. notificationEntry.m_isAuto = pNotification:IsAutoNotify(); -- Sets current phase state. notificationEntry.m_kHandlers.OnPhaseBegin( playerID, notificationID ); -- Upon creation, animation will automatically reverse and play out after showing. local pAnimControl:table = notificationEntry.m_Instance.NotificationSlide; pAnimControl:SetPauseTime( 0 ); pAnimControl:RegisterEndCallback( function() pAnimControl:ClearEndCallback(); pAnimControl:SetPauseTime( TIME_PAUSE_FIRST_SHOW_NOTIFICATION ); pAnimControl:Reverse(); end ); end end end RealizeStandardNotification( playerID, notificationID ); end -- =========================================================================== -- =========================================================================== function OnMouseEnterNotification( pInstance:table ) local pAnimControl:table = pInstance.NotificationSlide; if pInstance["POINTER_IN"] or pAnimControl:IsInPause() then return; end pInstance["POINTER_IN"] = true; -- Remove any end callbacks and get this out there. pAnimControl:ClearEndCallback(); pAnimControl:SetToBeginning(); pAnimControl:SetPauseTime( 0 ); if pAnimControl:IsStopped() then pAnimControl:Play(); else if pAnimControl:IsReversing() then pAnimControl:Reverse(); end end end -- =========================================================================== -- -- =========================================================================== function OnMouseExitNotification( pInstance:table ) if not pInstance.NotificationSlide:IsStopped() then -- If still playing, apply logic once it's done. local pAnimControl:table = pInstance.NotificationSlide; pAnimControl:RegisterEndCallback( function() pAnimControl:ClearEndCallback(); ApplyCollapseLogic( pInstance ); end ); else -- Done playing, immediately apply collapsing logic. ApplyCollapseLogic( pInstance ); end pInstance["POINTER_IN"] = false; end -- =========================================================================== -- Calculate and set the maximum width for a notification -- =========================================================================== function RealizeMaxWidth( notificationEntry:NotificationType , pNotification:table ) local widthTitle :number = 0; -- Width of the notification title local widthSummary :number = 0; -- Width of the notification summary local titleWidthPadding :number = 0; -- Calculated, adds the width of the arrows and number label local summaryWidthPadding :number = 15; if notificationEntry ~= nil then -- Seeing if the arrow is hidden is a quick way to check that there's more than one notification in this stack if notificationEntry.m_Instance.LeftArrow:IsHidden() == false then titleWidthPadding = (notificationEntry.m_Instance.TitleCount:GetSizeX() + (notificationEntry.m_Instance.LeftArrow:GetSizeX() * 2)); else -- Don't pad out the stack since there aren't extra buttons or a title count summaryWidthPadding = 0; end widthTitle = notificationEntry.m_Instance.TitleInfo:GetSizeX() + titleWidthPadding; widthSummary = notificationEntry.m_Instance.Summary:GetSizeX() + summaryWidthPadding; if widthTitle > notificationEntry.m_maxWidth or widthSummary > notificationEntry.m_maxWidth then if widthTitle > widthSummary then notificationEntry.m_maxWidth = widthTitle; else notificationEntry.m_maxWidth = widthSummary; end end else return; end -- Check to make sure PipStack doesn't overflow the width if notificationEntry.m_maxWidth < notificationEntry.m_Instance.PagePipStack:GetSizeX() then notificationEntry.m_maxWidth = notificationEntry.m_Instance.PagePipStack:GetSizeX(); end -- If the max width is larger than the word wrap width, use that for word wrap instead so text will fill -- the grid and not clump in the middle. if notificationEntry.m_maxWidth > (notificationEntry.m_wrapWidth + summaryWidthPadding) then notificationEntry.m_wrapWidth = notificationEntry.m_maxWidth - summaryWidthPadding; notificationEntry.m_Instance.Summary:SetWrapWidth(notificationEntry.m_wrapWidth); end end -- =========================================================================== -- Assign the notification summary and title to the notification instance, -- and set wrap width if needs to be wrapped -- =========================================================================== function SetNotificationText( notificationEntry:NotificationType , pNotification:table ) if (pNotification ~= nil) then -- Because the notification storage is 'ahead' of the events, the notification may be gone (we will get an event shortly) local messageName:string = Locale.Lookup( pNotification:GetMessage() ); local summary:string = Locale.Lookup(pNotification:GetSummary()); local widthSummary :number = 0; notificationEntry.m_Instance.TitleInfo:SetString( Locale.ToUpper(messageName) ); notificationEntry.m_Instance.Summary:SetString( summary ); widthSummary = notificationEntry.m_Instance.Summary:GetSizeX(); if widthSummary > MAX_WIDTH_INSTANCE then notificationEntry.m_wrapWidth = widthSummary / 1.9; -- Don't quite halve it so it doesn't wrap last word onto third line. else notificationEntry.m_wrapWidth = m_screenX; -- Don't wrap at all. end end end -- =========================================================================== -- Determine contents of this notification. -- Assumes this is a "standard" style. -- =========================================================================== function RealizeStandardNotification( playerID:number, notificationID:number ) local notificationEntry :NotificationType = GetNotificationEntry( playerID, notificationID ); local count :number = table.count(notificationEntry.m_IDs); local pNotification :table = NotificationManager.Find( playerID, notificationID ); if pNotification == nil then if m_debugStrictRemoval then alert("NIL Notification: ",playerID, notificationID ); end return; end -- No instance was generated for this notification, either another notification -- is representing it here or another context (e.g., ActionPanel) is showing it -- on the HUD. if notificationEntry.m_Instance == nil then return; end SetNotificationText(notificationEntry, pNotification); -- Auto generated, obtain the actual count... if notificationEntry.m_isAuto then count = pNotification:GetCount(); end notificationEntry.m_Instance.CountImage:SetHide( count < 2 ); notificationEntry.m_Instance.TitleCount:SetHide( count < 2 ); notificationEntry.m_Instance.LeftArrow:SetHide( count < 2 ); notificationEntry.m_Instance.RightArrow:SetHide( count < 2 ); notificationEntry.m_Instance.PagePipStack:SetHide( count < 2 ); if count > 1 then notificationEntry.m_Instance.Count:SetText( tostring(count) ); notificationEntry.m_Instance.DismissStackButton:RegisterCallback( Mouse.eRClick, function() TryDismissNotificationStack(playerID, notificationID); end ); notificationEntry.m_Instance.TitleCount:SetText( tostring(count) ); notificationEntry.m_Instance.TitleStack:ReprocessAnchoring(); notificationEntry.m_Instance.LeftArrow:RegisterCallback( Mouse.eLClick, function() notificationEntry.m_kHandlers.OnPreviousSelect(pNotification); end ); notificationEntry.m_Instance.RightArrow:RegisterCallback( Mouse.eLClick, function() notificationEntry.m_kHandlers.OnNextSelect(pNotification); end ); -- Prepare the area notificationEntry.m_Instance.PagePipStack:DestroyAllChildren(); for i=1,count,1 do local pipInstance:table = {}; ContextPtr:BuildInstanceForControl("PipInstance", pipInstance, notificationEntry.m_Instance.PagePipStack); pipInstance.Pip:SetColor( i==notificationEntry.m_Index and COLOR_PIP_CURRENT or COLOR_PIP_OTHER ); end else notificationEntry.m_Instance.LeftArrow:ClearCallback( Mouse.eLClick ); notificationEntry.m_Instance.RightArrow:ClearCallback( Mouse.eLClick ); end RealizeMaxWidth(notificationEntry, pNotification); -- Set text again now that calculations are done, text must always match the current index!! SetNotificationText(notificationEntry, NotificationManager.Find(playerID, notificationEntry.m_IDs[ notificationEntry.m_Index ])); end -- =========================================================================== -- Applies collapsing logic onto an instance. -- =========================================================================== function ApplyCollapseLogic( pInstance:table ) if not pInstance.NotificationSlide:IsReversing() then pInstance.NotificationSlide:Reverse(); end pInstance.NotificationSlide:SetPauseTime( TIME_PAUSE_MOUSE_OVER_NOTIFICATION ); end -- =========================================================================== -- Default handler for removing the UI entry. -- =========================================================================== function OnDefaultDismissNotification( playerID:number, notificationID:number ) -- Don't try and get the Game Core notification object, it might be gone ReleaseNotificationEntry( playerID, notificationID ); end -- =========================================================================== -- Default handler for a user request to try and manually dismiss a notification. -- =========================================================================== function OnDefaultTryDismissNotification( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then local pNotification :table = GetActiveNotificationFromEntry(notificationEntry); if (pNotification ~= nil) then if (pNotification:CanUserDismiss()) then NotificationManager.Dismiss( pNotification:GetPlayerID(), pNotification:GetID() ); end end end end -- =========================================================================== -- Default event handler for a turn phase beginning (Multiplayer) -- =========================================================================== function OnDefaultPhaseBeginNotification( playerID:number, notificationID:number ) local pNotification = NotificationManager.Find( playerID, notificationID ); local notificationEntry = GetNotificationEntry( playerID, notificationID ); if (pNotification ~= nil and notificationEntry ~= nil and notificationEntry.m_Instance ~= nil ) then local isValidForPhase :boolean = pNotification:IsValidForPhase(); notificationEntry.m_Instance.ItemButton:SetHide(not isValidForPhase); notificationEntry.m_Instance.ItemButtonInvalidPhase:SetHide(isValidForPhase); end end -- =========================================================================== -- Default event handler for the next notification in a "stacking" -- =========================================================================== function OnDefaultNextSelectNotification( pNotification:table ) local playerID :number = pNotification:GetPlayerID(); local notificationID :number = pNotification:GetID(); local notificationEntry :NotificationType = GetNotificationEntry(playerID, notificationID); notificationEntry.m_Index = notificationEntry.m_Index + 1; if notificationEntry.m_Index > table.count(notificationEntry.m_IDs) then -- Check for wrap around notificationEntry.m_Index = 1; end local nextID :number = notificationEntry.m_IDs[ notificationEntry.m_Index ]; local pNextNotification :table = NotificationManager.Find( playerID, nextID ); LookAtNotification( pNextNotification ); RealizeStandardNotification( playerID, nextID ); -- Buttons map with new ID end -- =========================================================================== -- Default event handler for the previous notification in a "stacking" -- =========================================================================== function OnDefaultPreviousSelectNotification( pNotification:table ) local playerID :number = pNotification:GetPlayerID(); local notificationID :number = pNotification:GetID(); local notificationEntry :NotificationType = GetNotificationEntry(playerID, notificationID); local nextID :number = -1; notificationEntry.m_Index = notificationEntry.m_Index - 1; if notificationEntry.m_Index == 0 then -- Check for wrap around notificationEntry.m_Index = table.count(notificationEntry.m_IDs); end local nextID :number = notificationEntry.m_IDs[ notificationEntry.m_Index ]; local pNextNotification :table = NotificationManager.Find( playerID, nextID ); LookAtNotification( pNextNotification ); RealizeStandardNotification( playerID, nextID ); -- Buttons map with new ID end -- ======================================================================================= -- Empty event handler. -- Used by notifications in the wrong phase so the button efx still trigger. -- ======================================================================================= function OnDoNothing( playerID:number, notificationID:number) end -- ======================================================================================= -- Create a table with the default handlers callbacks -- ======================================================================================= function MakeDefaultHandlers() return hmake NotificationHandler { Add = OnDefaultAddNotification, Dismiss = OnDefaultDismissNotification, TryDismiss = OnDefaultTryDismissNotification, Activate = OnDefaultActivateNotification, OnPhaseBegin = OnDefaultPhaseBeginNotification, OnNextSelect = OnDefaultNextSelectNotification, OnPreviousSelect= OnDefaultPreviousSelectNotification }; end -- ======================================================================================= -- Choose Tech Handlers -- ======================================================================================= function OnChooseTechActivate( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then LuaEvents.ActionPanel_OpenChooseResearch(); end end -- ======================================================================================= -- Choose City Production Handlers -- ======================================================================================= function OnChooseCityProductionActivate( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then local pNotification :table = GetActiveNotificationFromEntry(notificationEntry); if pNotification ~= nil then LookAtNotification( pNotification ); LuaEvents.NotificationPanel_ChooseProduction(); end end end -- ======================================================================================= -- Choose Civic Handlers -- ======================================================================================= function OnChooseCivicActivate( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then LuaEvents.ActionPanel_OpenChooseCivic(); end end -- ======================================================================================= -- Consider Civic Change Handlers -- ======================================================================================= function OnFillCivicSlotActivate( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then LuaEvents.NotificationPanel_GovernmentOpenPolicies(); end end -- ======================================================================================= -- Move or give an operation to a unit -- ======================================================================================= function OnCommandUnitsActivate( notificationEntry : NotificationType ) UI.SelectNextReadyUnit(); end -- ======================================================================================= -- Look at the next unit. -- ======================================================================================= function OnCommandUnitsNextSelect( pNotification:table ) local playerID :number = pNotification:GetPlayerID(); local notificationID :number = pNotification:GetID(); local notificationEntry :NotificationType = GetNotificationEntry(playerID, notificationID); notificationEntry.m_Index = notificationEntry.m_Index + 1; if notificationEntry.m_Index > pNotification:GetCount() then -- Check for wrap around notificationEntry.m_Index = 1; end RealizeStandardNotification( playerID, notificationID ); -- Update pips UI.SelectNextReadyUnit(); -- Engine automatically moves camera end -- ======================================================================================= -- Look at the previous unit. -- ======================================================================================= function OnCommandUnitsPreviousSelect( pNotification:table) local playerID :number = pNotification:GetPlayerID(); local notificationID :number = pNotification:GetID(); local notificationEntry :NotificationType = GetNotificationEntry(playerID, notificationID); notificationEntry.m_Index = notificationEntry.m_Index - 1; if notificationEntry.m_Index == 0 then -- Check for wrap around notificationEntry.m_Index = pNotification:GetCount(); end RealizeStandardNotification( playerID, notificationID ); -- Update pips UI.SelectPrevReadyUnit(); -- Engine automatically moves camera end -- ======================================================================================= -- Consider Government Change Handlers -- ======================================================================================= function OnConsiderGovernmentChangeActivate( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then LuaEvents.NotificationPanel_GovernmentOpenGovernments(); end end -- ======================================================================================= -- Consider Raze City Handlers -- ======================================================================================= function OnConsiderRazeCityActivate( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then local pNotification :table = GetActiveNotificationFromEntry(notificationEntry); if pNotification ~= nil then LookAtNotification( pNotification ); end LuaEvents.NotificationPanel_OpenRazeCityChooser(); end end -- ======================================================================================= -- Choose Religion Handlers -- ======================================================================================= function OnChooseReligionActivate( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then LuaEvents.NotificationPanel_OpenReligionPanel(); end end -- ======================================================================================= -- Archaeology Handlers -- ======================================================================================= function OnChooseArtifactPlayerActivate( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then LuaEvents.NotificationPanel_OpenArtifactPanel(); end end -- ======================================================================================= -- Give Influence Token Handlers -- ======================================================================================= function OnGiveInfluenceTokenActivate( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then LuaEvents.NotificationPanel_OpenCityStatesSendEnvoys(); end end -- ======================================================================================= -- Claim Great Person Handlers -- ======================================================================================= function OnClaimGreatPersonActivate( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then LuaEvents.NotificationPanel_OpenGreatPeoplePopup(); end end -- ======================================================================================= -- Espionage Handlers -- ======================================================================================= function OnChooseEscapeRouteActivate( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then local TEST_PARAM :number = 23; --??TRON: existing test parameter? LuaEvents.NotificationPanel_OpenEspionageEscape( TEST_PARAM ); end end -- ======================================================================================= -- Diplomacy Handlers -- ======================================================================================= function OnDiplomacySessionActivate( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then local pNotification :table = GetActiveNotificationFromEntry(notificationEntry); if pNotification ~= nil then pNotification:Activate(); end end end -- ======================================================================================= -- Discovered Continent Handlers -- ======================================================================================= function OnDiscoverContinentActivateNotification( notificationEntry : NotificationType ) if (notificationEntry ~= nil and notificationEntry.m_PlayerID == Game.GetLocalPlayer()) then local pNotification :table = GetActiveNotificationFromEntry(notificationEntry); if pNotification ~= nil then LookAtNotification( pNotification ); end LuaEvents.NotificationPanel_ShowContinentLens(); end end -- ======================================================================================= function OnMetCivAddNotification( pNotification:table ) if m_isLoadComplete then UI.PlaySound("NOTIFICATION_MISC_NEUTRAL"); end OnDefaultAddNotification( pNotification ); end -- ======================================================================================= function OnDebugAdd( name:string, fakeID:number ) local playerID :number = Game.GetLocalPlayer(); local notificationID :number = m_kDebugNotification[table.count(m_kDebugNotification)]; local notificationEntry :NotificationType = AddNotificationEntry( playerID, name, 1000000 + fakeID, NotificationGroups.NONE ); local kHandlers :NotificationHandler= GetHandler( DEBUG_NOTIFICATION_TYPE ); notificationEntry.m_Instance = m_genericItemIM:GetInstance(); notificationEntry.m_InstanceManager = m_genericItemIM; notificationEntry.m_Instance.Top:ChangeParent( Controls.ScrollStack ); notificationEntry.m_Instance["POINTER_IN"] = false; -- Manually track since 2 different, overlapping objects are tracking if a pointer is in/out if notificationEntry.m_Instance ~= nil then if (notificationEntry.m_Instance.ItemButton ~= nil and notificationEntry.m_Instance.ItemButtonInvalidPhase ~= nil) then notificationEntry.m_Instance.ItemButton:SetVoid1( playerID ); notificationEntry.m_Instance.ItemButton:SetVoid2( notificationID ); notificationEntry.m_Instance.ItemButton:RegisterCallback( Mouse.eLClick, kHandlers.Activate ); notificationEntry.m_Instance.ItemButton:RegisterCallback( Mouse.eRClick, function() kHandlers.Dismiss(playerID, 1000000 + notificationID); end ); notificationEntry.m_Instance.ItemButton:RegisterMouseEnterCallback( function() OnMouseEnterNotification( notificationEntry.m_Instance ); end ); notificationEntry.m_Instance.MouseOutArea:RegisterMouseExitCallback( function() OnMouseExitNotification( notificationEntry.m_Instance ); end ); notificationEntry.m_Instance.ItemButtonInvalidPhase:RegisterCallback( Mouse.eLClick, OnDoNothing ); notificationEntry.m_Instance.ItemButtonInvalidPhase:RegisterCallback( Mouse.eRClick, OnDoNothing ); notificationEntry.m_Instance.ItemButtonInvalidPhase:SetToolTipString("DEBUG"); notificationEntry.m_isAuto = false; --notificationEntry.m_kHandlers.OnPhaseBegin( playerID, notificationID ); notificationEntry.m_Instance.ItemButton:SetHide(false); notificationEntry.m_Instance.ItemButtonInvalidPhase:SetHide(true); -- Upon creation, animation will automatically reverse and play out after showing. local pAnimControl:table = notificationEntry.m_Instance.NotificationSlide; pAnimControl:SetPauseTime( 0 ); pAnimControl:RegisterEndCallback( function() pAnimControl:ClearEndCallback(); pAnimControl:SetPauseTime( TIME_PAUSE_FIRST_SHOW_NOTIFICATION ); pAnimControl:Reverse(); end ); notificationEntry.m_Instance.TitleInfo:SetString( name ); notificationEntry.m_Instance.Summary:SetString( name ); notificationEntry.m_Instance.Summary:SetWrapWidth( notificationEntry.m_Instance.ExpandedArea:GetSizeX() ); notificationEntry.m_Instance.CountImage:SetHide( true ); notificationEntry.m_Instance.TitleCount:SetHide( true ); notificationEntry.m_Instance.LeftArrow:SetHide( true ); notificationEntry.m_Instance.RightArrow:SetHide( true ); notificationEntry.m_Instance.PagePipStack:SetHide( true ); end end end -- ======================================================================================= function OnDebugActivate() end -- ======================================================================================= function OnDebugDismiss(playerID,notificationID) ReleaseNotificationEntry( playerID, notificationID ); ProcessStackSizes(); end -- ======================================================================================= -- Generate a debug event -- ======================================================================================= function MakeDebugNotification( name:string, fakeID:number ) local handler = GetHandler( DEBUG_NOTIFICATION_TYPE ); table.insert(m_kDebugNotification, fakeID); handler.Add( name, fakeID ); end -- =========================================================================== -- ENGINE Event -- A notification was added, if it doesn't block the end-turn; add to notification list. -- =========================================================================== function OnNotificationAdded( playerID:number, notificationID:number ) if (playerID == Game.GetLocalPlayer()) then -- Was it for us? local pNotification = NotificationManager.Find( playerID, notificationID ); if pNotification ~= nil then --print(" OnNotificationAdded():",notificationID, "for type "..tostring(pNotification:GetMessage()) ); --debug local handler = GetHandler( pNotification:GetType() ); handler.Add(pNotification); if handler.AddSound ~= nil and handler.AddSound ~= "" then if m_isLoadComplete then UI.PlaySound(handler.AddSound); end end ProcessStackSizes(); SetWidthNotificationStack(playerID, notificationID); else -- Sanity check UI.DataError("Notification added Event but not found in manager. PlayerID - " .. tostring(playerID) .. " Notification ID - " .. tostring(notificationID)); end if notificationID == 577 then -- CQUI: Notification when a City lost tile by Culture Bomb (Index == 577) LuaEvents.CQUI_CityLostTileByCultureBomb(); end end end -- =========================================================================== -- ENGINE Event -- A notification was dismissed -- =========================================================================== function OnNotificationDismissed( playerID:number, notificationID:number ) if (playerID == Game.GetLocalPlayer()) then -- one of the ones we track? -- Don't try and get the Game Core notification object, it might be gone local notificationEntry:NotificationType = GetNotificationEntry( playerID, notificationID ); if notificationEntry ~= nil then --print("OnNotificationDismissed():",notificationID); --debug local handler = notificationEntry.m_kHandlers; handler.Dismiss( playerID, notificationID ); end ProcessStackSizes(); SetWidthNotificationStack(playerID, notificationID); end end -- =========================================================================== -- ENGINE Event -- All notifications are about to be refreshed -- =========================================================================== function OnNotificationRefreshRequested() Controls.ScrollStack:DestroyAllChildren(); m_genericItemIM:DestroyInstances(); m_groupIM:DestroyInstances(); m_lastStackSize = 0; -- Add debug notifications if m_debugNotificationNum > 0 then for i=1,m_debugNotificationNum,1 do MakeDebugNotification("Debug"..tostring(i), i ); end ProcessStackSizes(); end end -- =========================================================================== -- New turn phase has begun. -- =========================================================================== function OnPhaseBegin() for playerID, playerTable in pairs(m_notifications) do if playerID == Game.GetLocalPlayer() then for typeName, notificationEntry in pairs(playerTable) do for _,notificationID in ipairs(notificationEntry.m_IDs) do if notificationEntry.m_kHandlers.OnPhaseBegin ~= nil then notificationEntry.m_kHandlers.OnPhaseBegin( playerID, notificationID ); end end end end end end -- =========================================================================== -- LUA Event -- A request to activate a notification from another Lua file. -- =========================================================================== function OnLuaActivateNotification( pNotification:table ) if (pNotification ~= nil and pNotification:IsValidForPhase()) then local playerID = pNotification:GetPlayerID(); local notificationID = pNotification:GetID(); local notificationEntry = GetNotificationEntry( playerID, notificationID ); if (notificationEntry ~= nil) then local handler = notificationEntry.m_kHandlers; handler.Activate( notificationEntry ); end end end -- =========================================================================== -- Game Engine Event -- =========================================================================== function OnInterfaceModeChanged(eOldMode:number, eNewMode:number) if eNewMode == InterfaceModeTypes.VIEW_MODAL_LENS then ContextPtr:SetHide(true); end if eOldMode == InterfaceModeTypes.VIEW_MODAL_LENS then ContextPtr:SetHide(false); end end -- =========================================================================== -- Resizes/realigns each notification slide -- =========================================================================== function ProcessNotificationSizes( playerID:number ) local kPlayerTable:table = m_notifications[playerID]; if (kPlayerTable == nil) then return; end for _,kNotification in pairs(kPlayerTable) do local currentEntry :NotificationType = kNotification; if currentEntry.m_Instance ~= nil then currentEntry.m_Instance.Clip:SetSizeX(m_screenX); currentEntry.m_Instance.Clip:CalculateSize(); currentEntry.m_Instance.Clip:ReprocessAnchoring(); if currentEntry.m_Instance.NotificationSlide ~= nil and (currentEntry.m_Instance.NotificationSlide:GetNumChildren() ~= 0) then currentEntry.m_Instance.NotificationSlide:SetToBeginning(); end end SetWidthNotificationStack( playerID, id); end return; end -- =========================================================================== -- Handle a resize -- =========================================================================== function Resize() m_screenX, m_screenY = UIManager:GetScreenSizeVal(); Controls.RailOffsetAnim:ReprocessAnchoring(); Controls.RailAnim:ReprocessAnchoring(); Controls.RailOffsetAnim:SetToBeginning(); Controls.RailOffsetAnim:Play(); Controls.RailAnim:SetBeginVal(0,0); Controls.RailAnim:SetEndVal(0,0); Controls.RailAnim:SetToBeginning(); Controls.RailAnim:Play(); ProcessStackSizes(); end -- =========================================================================== -- On update UI - Handle a resize -- =========================================================================== function OnUpdateUI( type:number, tag:string, iData1:number, iData2:number, strData1:string) if type == SystemUpdateUI.ScreenResize then Resize(); end end -- =========================================================================== -- UI Event -- =========================================================================== function OnInit( isReload:boolean ) if isReload then NotificationManager.RestoreVisualState(Game.GetLocalPlayer()); -- Restore the notifications end end -- =========================================================================== -- Clear all of the notification UI. -- =========================================================================== function ClearNotifications() -- Propery destroy instances; especially so callbacks are destroy... -- otherwise hotloading may not hot load. for playerID,playerTable in pairs(m_notifications) do if playerTable ~= nil then for typeName, notification in pairs( playerTable ) do for _, id in ipairs( notification.m_IDs ) do ReleaseNotificationEntry( playerID, id ); end end end end end -- =========================================================================== -- UI Event -- =========================================================================== function OnShutdown() ClearNotifications(); end -- =========================================================================== -- The local player has changed (hotseat, autoplay) -- =========================================================================== function OnLocalPlayerChanged() m_lastStackDiff = 0; m_lastStackSize = 0; Controls.RailImage:SetSizeY(100); ClearNotifications(); NotificationManager.RestoreVisualState(Game.GetLocalPlayer()); -- Restore the notifications end -- =========================================================================== -- The loading screen has completed -- =========================================================================== function OnLoadGameViewStateDone() m_isLoadComplete = true; end -- =========================================================================== -- Remove notification if the target unit for the notification has been killed -- =========================================================================== function OnUnitKilledInCombat( targetUnit ) local playerID :number = Game.GetLocalPlayer(); local kPlayerTable:table = m_notifications[playerID]; if (kPlayerTable == nil) then return; end for _,kNotification in pairs(kPlayerTable) do local notificationEntry :NotificationType = kNotification; if notificationEntry.m_Instance ~= nil then local pNotification :table = GetActiveNotificationFromEntry(notificationEntry); if (pNotification ~= nil) then local targetPlayerID, targetID, targetType = pNotification:GetTarget(); -- Is it a unit? if targetType == PlayerComponentTypes.UNIT then if pNotification:IsTargetValid() then local pUnit:table = Players[targetPlayerID]:GetUnits():FindID(targetID); if (pUnit == nil) then ReleaseNotificationEntry( playerId, notificationEntry.m_IDs[ notificationEntry.m_Index ]); end end end end end end end function CQUI_AddNotification(description:string, summary:string) local handler = GetHandler( NotificationTypes.DEFAULT ); table.insert(m_kDebugNotification); handler.Add( summary, table.count(m_kDebugNotificaiton)); end -- =========================================================================== -- Setup -- =========================================================================== function Initialize() RegisterHandlers(); ContextPtr:SetInitHandler( OnInit ); ContextPtr:SetShutdown( OnShutdown ); Events.NotificationAdded.Add( OnNotificationAdded ); Events.NotificationDismissed.Add( OnNotificationDismissed ); Events.NotificationRefreshRequested.Add( OnNotificationRefreshRequested ); Events.UnitKilledInCombat.Add( OnUnitKilledInCombat ); Events.SystemUpdateUI.Add( OnUpdateUI ); Events.PhaseBegin.Add( OnPhaseBegin ); Events.LocalPlayerChanged.Add( OnLocalPlayerChanged ); Events.InterfaceModeChanged.Add( OnInterfaceModeChanged ); m_isLoadComplete = false; Events.LoadGameViewStateDone.Add( OnLoadGameViewStateDone ); LuaEvents.ActionPanel_ActivateNotification.Add( OnLuaActivateNotification ); -- CQUI LuaEvents.CQUI_AddNotification.Add( CQUI_AddNotification ); end Initialize();
mit
anshkumar/yugioh-glaze
assets/script/c66235877.lua
6
1222
--デス・デーモン・ドラゴン function c66235877.initial_effect(c) --fusion material c:EnableReviveLimit() aux.AddFusionProcCode2(c,93220472,16475472,false,false) --disable local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_DISABLE) e1:SetRange(LOCATION_MZONE) e1:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE) e1:SetTarget(c66235877.distg) c:RegisterEffect(e1) --disable effect local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_CHAIN_SOLVING) e2:SetRange(LOCATION_MZONE) e2:SetOperation(c66235877.disop) c:RegisterEffect(e2) -- local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(66235877) e3:SetRange(LOCATION_MZONE) e3:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE) c:RegisterEffect(e3) end function c66235877.distg(e,c) return c:IsType(TYPE_FLIP) end function c66235877.disop(e,tp,eg,ep,ev,re,r,rp) if re:IsActiveType(TYPE_FLIP) then Duel.NegateEffect(ev) end if re:IsActiveType(TYPE_TRAP) and re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then local g=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS) if g and g:IsContains(e:GetHandler()) then Duel.NegateEffect(ev) end end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c52068432.lua
3
3326
--トリシューラの影霊衣 function c52068432.initial_effect(c) c:EnableReviveLimit() --cannot special summon local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetCode(EFFECT_SPSUMMON_CONDITION) e1:SetValue(aux.ritlimit) c:RegisterEffect(e1) --negate local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(52068432,0)) e2:SetCategory(CATEGORY_NEGATE) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e2:SetCode(EVENT_CHAINING) e2:SetRange(LOCATION_HAND) e2:SetCountLimit(1,52068432) e2:SetCondition(c52068432.negcon) e2:SetCost(c52068432.negcost) e2:SetTarget(c52068432.negtg) e2:SetOperation(c52068432.negop) c:RegisterEffect(e2) --remove local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(52068432,1)) e3:SetCategory(CATEGORY_REMOVE) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_SPSUMMON_SUCCESS) e3:SetCountLimit(1,52068433) e3:SetCondition(c52068432.remcon) e3:SetTarget(c52068432.remtg) e3:SetOperation(c52068432.remop) c:RegisterEffect(e3) end function c52068432.mat_filter(c) return c:GetLevel()~=9 end function c52068432.tfilter(c,tp) return c:IsFaceup() and c:IsSetCard(0xb4) and c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) end function c52068432.negcon(e,tp,eg,ep,ev,re,r,rp) if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then return false end local g=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS) return g and g:IsExists(c52068432.tfilter,1,nil,tp) and Duel.IsChainNegatable(ev) end function c52068432.negcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsDiscardable() end Duel.SendtoGrave(e:GetHandler(),REASON_COST+REASON_DISCARD) end function c52068432.negtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) end function c52068432.negop(e,tp,eg,ep,ev,re,r,rp) Duel.NegateActivation(ev) end function c52068432.remcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetSummonType()==SUMMON_TYPE_RITUAL end function c52068432.remtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,0,LOCATION_HAND,1,nil) and Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,0,LOCATION_ONFIELD,1,nil) and Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,nil) end Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,0,LOCATION_ONFIELD+LOCATION_GRAVE+LOCATION_HAND) end function c52068432.remop(e,tp,eg,ep,ev,re,r,rp) local g1=Duel.GetMatchingGroup(Card.IsAbleToRemove,tp,0,LOCATION_HAND,nil) local g2=Duel.GetMatchingGroup(Card.IsAbleToRemove,tp,0,LOCATION_ONFIELD,nil) local g3=Duel.GetMatchingGroup(Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,nil) if g1:GetCount()>0 and g2:GetCount()>0 and g3:GetCount()>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local sg1=g1:RandomSelect(tp,1) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local sg2=g2:Select(tp,1,1,nil) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local sg3=g3:Select(tp,1,1,nil) sg1:Merge(sg2) sg1:Merge(sg3) Duel.HintSelection(sg1) Duel.Remove(sg1,POS_FACEUP,REASON_EFFECT) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c22653490.lua
5
2605
--電光千鳥 function c22653490.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsAttribute,ATTRIBUTE_WIND),4,2) c:EnableReviveLimit() --return to deck local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(22653490,0)) e1:SetCategory(CATEGORY_TODECK) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetCondition(c22653490.tdcon1) e1:SetTarget(c22653490.tdtg1) e1:SetOperation(c22653490.tdop1) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(22653490,1)) e2:SetCategory(CATEGORY_TODECK) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetCountLimit(1) e2:SetRange(LOCATION_MZONE) e2:SetCost(c22653490.tdcost2) e2:SetTarget(c22653490.tdtg2) e2:SetOperation(c22653490.tdop2) c:RegisterEffect(e2) end function c22653490.tdcon1(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetSummonType()==SUMMON_TYPE_XYZ end function c22653490.tdfilter1(c) return c:IsFacedown() and c:IsAbleToDeck() end function c22653490.tdtg1(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(1-tp) and chkc:IsOnField() and c22653490.tdfilter1(chkc) end if chk==0 then return true end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local g=Duel.SelectTarget(tp,Card.IsFacedown,tp,0,LOCATION_ONFIELD,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_TODECK,g,g:GetCount(),0,0) end function c22653490.tdop1(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc and tc:IsRelateToEffect(e) and tc:IsControler(1-tp) and tc:IsFacedown() then Duel.SendtoDeck(tc,nil,1,REASON_EFFECT) end end function c22653490.tdcost2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST) end function c22653490.tdfilter2(c) return c:IsFaceup() and c:IsAbleToDeck() end function c22653490.tdtg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(1-tp) and chkc:IsOnField() and c22653490.tdfilter2(chkc) end if chk==0 then return Duel.IsExistingTarget(c22653490.tdfilter2,tp,0,LOCATION_ONFIELD,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local g=Duel.SelectTarget(tp,c22653490.tdfilter2,tp,0,LOCATION_ONFIELD,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_TODECK,g,1,0,0) end function c22653490.tdop2(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and tc:IsControler(1-tp) and tc:IsFaceup() then Duel.SendtoDeck(tc,nil,0,REASON_EFFECT) end end
gpl-2.0
adan830/UpAndAway
code/actions.lua
2
2873
BindGlobal() local ACTIONS = ACTIONS BindTheMod() ACTIONS.DEPLOY.strfn = (function() local oldfn = ACTIONS.DEPLOY.strfn return function(act) if act.invobject and act.invobject:HasTag("portable_structure") then return "PORTABLE_STRUCTURE" else return oldfn(act) end end end)() --- local Climb = Action() Climb.str = "Climb" Climb.id = "CLIMB" Climb.fn = function(act) local doer = act.doer local targ = act.target or act.invobject if doer and doer.components.climbingvoter and targ and targ.components.climbable then if GetClimbingManager():HasRequest() then return false, "INUSE" end return doer.components.climbingvoter:BeginPoll(targ) end end AddAction(Climb) local climb_sg_handler = "doshortaction" AddStategraphActionHandler("wilson", ActionHandler(Climb, climb_sg_handler)) if IsClient() then AddStategraphActionHandler("wilson_client", ActionHandler(Climb, climb_sg_handler)) end --- local Withdraw = Action(1) Withdraw.str = "Withdraw" Withdraw.id = "WITHDRAW" Withdraw.fn = function(act) local doer = act.doer local targ = act.target or act.invobject if doer and targ and targ.components.withdrawable then return targ.components.withdrawable:Withdraw(doer) end end AddAction(Withdraw) local withdraw_sg_handler = "dolongaction" AddStategraphActionHandler("wilson", ActionHandler(Withdraw, withdraw_sg_handler)) if IsClient() then AddStategraphActionHandler("wilson_client", ActionHandler(Withdraw, withdraw_sg_handler)) end --- -- Ugly name, but avoids confusion with vanilla's TALKTO action. local BeginSpeech = Action(-1, false, false, TheMod:GetConfig("SPEECHGIVER", "MAX_DIST")) BeginSpeech.str = ACTIONS.TALKTO.str BeginSpeech.id = "BEGINSPEECH" BeginSpeech.fn = function(act) local doer = act.doer local targ = act.target if doer and targ and targ.components.speechgiver then TheMod:Say "BeginSpeech.fn going forward!" return targ.components.speechgiver:InteractWith(doer) end TheMod:Say "BeginSpeech.fn failed..." end AddAction(BeginSpeech) AddStategraphActionHandler("wilson", ActionHandler(BeginSpeech, function(inst, action) if action.target and action.target.components.speechgiver then inst:PerformBufferedAction() return "idle" end end)) if IsClient() then AddStategraphActionHandler("wilson_client", ActionHandler(BeginSpeech, function(inst, action) if action.target and replica(action.target).speechgiver then inst:PerformPreviewBufferedAction() return "idle" end end)) end --- local Brew = Action() Brew.str = "Brew" Brew.id = "BREW" Brew.fn = function(act) local brewer = act.target.components.brewer if brewer then brewer:StartBrewing( act.doer ) return true end end AddAction(Brew)
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c70902743.lua
3
3078
--レッド・デーモンズ・ドラゴン function c70902743.initial_effect(c) --synchro summon aux.AddSynchroProcedure(c,nil,aux.NonTuner(nil),1) c:EnableReviveLimit() --destroy1 local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(70902743,0)) e1:SetCategory(CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetCode(EVENT_BATTLED) e1:SetCondition(c70902743.condition1) e1:SetTarget(c70902743.target1) e1:SetOperation(c70902743.operation1) c:RegisterEffect(e1) --destroy2 local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(70902743,1)) e2:SetCategory(CATEGORY_DESTROY) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1) e2:SetCode(EVENT_PHASE+PHASE_END) e2:SetCondition(c70902743.condition2) e2:SetTarget(c70902743.target2) e2:SetOperation(c70902743.operation2) c:RegisterEffect(e2) if not c70902743.global_check then c70902743.global_check=true local ge1=Effect.CreateEffect(c) ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) ge1:SetCode(EVENT_ATTACK_ANNOUNCE) ge1:SetOperation(c70902743.check) Duel.RegisterEffect(ge1,0) local ge2=Effect.CreateEffect(c) ge2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) ge2:SetCode(EVENT_ATTACK_DISABLED) ge2:SetOperation(c70902743.check2) Duel.RegisterEffect(ge2,0) end end function c70902743.check(e,tp,eg,ep,ev,re,r,rp) local tc=eg:GetFirst() local ct=tc:GetFlagEffectLabel(70902743) if ct then tc:SetFlagEffectLabel(70902743,ct+1) else tc:RegisterFlagEffect(70902743,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1,1) end end function c70902743.check2(e,tp,eg,ep,ev,re,r,rp) local tc=eg:GetFirst() local ct=tc:GetFlagEffectLabel(70902743) if ct then tc:SetFlagEffectLabel(70902743,ct-1) end end function c70902743.condition1(e,tp,eg,ep,ev,re,r,rp) return Duel.GetAttacker()==e:GetHandler() and Duel.GetAttackTarget() and not Duel.GetAttackTarget():IsAttackPos() end function c70902743.filter1(c) return not c:IsAttackPos() and c:IsDestructable() end function c70902743.target1(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end local g=Duel.GetMatchingGroup(c70902743.filter1,tp,0,LOCATION_MZONE,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0) end function c70902743.operation1(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(c70902743.filter1,tp,0,LOCATION_MZONE,nil) Duel.Destroy(g,REASON_EFFECT) end function c70902743.filter2(c) local ct=c:GetFlagEffectLabel(70902743) return (not ct or ct==0) and c:IsDestructable() end function c70902743.condition2(e,tp,eg,ep,ev,re,r,rp) return tp==Duel.GetTurnPlayer() end function c70902743.target2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end local g=Duel.GetMatchingGroup(c70902743.filter2,tp,LOCATION_MZONE,0,e:GetHandler()) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0) end function c70902743.operation2(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(c70902743.filter2,tp,LOCATION_MZONE,0,e:GetHandler()) Duel.Destroy(g,REASON_EFFECT) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c40061558.lua
3
2826
--アポクリフォート・カーネル function c40061558.initial_effect(c) --cannot special summon local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetCode(EFFECT_SPSUMMON_CONDITION) c:RegisterEffect(e1) --tribute limit local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_TRIBUTE_LIMIT) e2:SetValue(c40061558.tlimit) c:RegisterEffect(e2) --summon with 3 tribute local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e3:SetCode(EFFECT_LIMIT_SUMMON_PROC) e3:SetCondition(c40061558.ttcon) e3:SetOperation(c40061558.ttop) e3:SetValue(SUMMON_TYPE_ADVANCE) c:RegisterEffect(e3) local e4=e3:Clone() e4:SetCode(EFFECT_LIMIT_SET_PROC) c:RegisterEffect(e4) --immune local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_SINGLE) e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_UNCOPYABLE) e5:SetRange(LOCATION_MZONE) e5:SetCode(EFFECT_IMMUNE_EFFECT) e5:SetCondition(c40061558.immcon) e5:SetValue(c40061558.efilter) c:RegisterEffect(e5) --control local e6=Effect.CreateEffect(c) e6:SetCategory(CATEGORY_CONTROL) e6:SetType(EFFECT_TYPE_IGNITION) e6:SetProperty(EFFECT_FLAG_CARD_TARGET) e6:SetRange(LOCATION_MZONE) e6:SetCountLimit(1) e6:SetTarget(c40061558.cttg) e6:SetOperation(c40061558.ctop) c:RegisterEffect(e6) end function c40061558.tlimit(e,c) return not c:IsSetCard(0xaa) end function c40061558.ttcon(e,c) if c==nil then return true end return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>-3 and Duel.GetTributeCount(c)>=3 end function c40061558.ttop(e,tp,eg,ep,ev,re,r,rp,c) local g=Duel.SelectTribute(tp,c,3,3) c:SetMaterial(g) Duel.Release(g,REASON_SUMMON+REASON_MATERIAL) end function c40061558.immcon(e) return bit.band(e:GetHandler():GetSummonType(),SUMMON_TYPE_NORMAL)==SUMMON_TYPE_NORMAL end function c40061558.efilter(e,te) if te:IsActiveType(TYPE_SPELL+TYPE_TRAP) then return true else return aux.qlifilter(e,te) end end function c40061558.cttg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) and chkc:IsControlerCanBeChanged() end if chk==0 then return Duel.IsExistingTarget(Card.IsControlerCanBeChanged,tp,0,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONTROL) local g=Duel.SelectTarget(tp,Card.IsControlerCanBeChanged,tp,0,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_CONTROL,g,1,0,0) end function c40061558.ctop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and not Duel.GetControl(tc,tp,PHASE_END,1) then if not tc:IsImmuneToEffect(e) and tc:IsAbleToChangeControler() then Duel.Destroy(tc,REASON_EFFECT) end end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c79852326.lua
3
2012
--死霊ゾーマ function c79852326.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetHintTiming(0,TIMING_END_PHASE) e1:SetTarget(c79852326.target) e1:SetOperation(c79852326.activate) c:RegisterEffect(e1) end function c79852326.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsPlayerCanSpecialSummonMonster(tp,79852326,0,0x21,1800,500,4,RACE_ZOMBIE,ATTRIBUTE_DARK) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function c79852326.activate(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) then return end if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 or not Duel.IsPlayerCanSpecialSummonMonster(tp,79852326,0,0x21,1800,500,4,RACE_ZOMBIE,ATTRIBUTE_DARK) then return end c:AddTrapMonsterAttribute(TYPE_EFFECT,ATTRIBUTE_DARK,RACE_ZOMBIE,4,1800,500) Duel.SpecialSummon(c,0,tp,tp,true,false,POS_FACEUP_DEFENCE) c:TrapMonsterBlock() --damage local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(79852326,0)) e1:SetCategory(CATEGORY_DAMAGE) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetCode(EVENT_LEAVE_FIELD) e1:SetCondition(c79852326.damcon) e1:SetTarget(c79852326.damtg) e1:SetOperation(c79852326.damop) e1:SetReset(RESET_EVENT+0x17e0000) c:RegisterEffect(e1) end function c79852326.damcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsReason(REASON_BATTLE) end function c79852326.damtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end local bc=e:GetHandler():GetBattleTarget() local dam=bc:GetAttack() if dam<0 then dam=0 end Duel.SetTargetPlayer(1-tp) Duel.SetTargetParam(dam) Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,dam) end function c79852326.damop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Damage(p,d,REASON_EFFECT) end
gpl-2.0
AnySDK/Sample_CPP_Cocos2dx
cocos2d/tools/cocos2d-console/plugins/plugin_luacompile/bin/lua/jit/bc.lua
78
5606
---------------------------------------------------------------------------- -- LuaJIT bytecode listing module. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- Released under the MIT license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- -- -- This module lists the bytecode of a Lua function. If it's loaded by -jbc -- it hooks into the parser and lists all functions of a chunk as they -- are parsed. -- -- Example usage: -- -- luajit -jbc -e 'local x=0; for i=1,1e6 do x=x+i end; print(x)' -- luajit -jbc=- foo.lua -- luajit -jbc=foo.list foo.lua -- -- Default output is to stderr. To redirect the output to a file, pass a -- filename as an argument (use '-' for stdout) or set the environment -- variable LUAJIT_LISTFILE. The file is overwritten every time the module -- is started. -- -- This module can also be used programmatically: -- -- local bc = require("jit.bc") -- -- local function foo() print("hello") end -- -- bc.dump(foo) --> -- BYTECODE -- [...] -- print(bc.line(foo, 2)) --> 0002 KSTR 1 1 ; "hello" -- -- local out = { -- -- Do something with each line: -- write = function(t, ...) io.write(...) end, -- close = function(t) end, -- flush = function(t) end, -- } -- bc.dump(foo, out) -- ------------------------------------------------------------------------------ -- Cache some library functions and objects. local jit = require("jit") assert(jit.version_num == 20001, "LuaJIT core/library version mismatch") local jutil = require("jit.util") local vmdef = require("jit.vmdef") local bit = require("bit") local sub, gsub, format = string.sub, string.gsub, string.format local byte, band, shr = string.byte, bit.band, bit.rshift local funcinfo, funcbc, funck = jutil.funcinfo, jutil.funcbc, jutil.funck local funcuvname = jutil.funcuvname local bcnames = vmdef.bcnames local stdout, stderr = io.stdout, io.stderr ------------------------------------------------------------------------------ local function ctlsub(c) if c == "\n" then return "\\n" elseif c == "\r" then return "\\r" elseif c == "\t" then return "\\t" else return format("\\%03d", byte(c)) end end -- Return one bytecode line. local function bcline(func, pc, prefix) local ins, m = funcbc(func, pc) if not ins then return end local ma, mb, mc = band(m, 7), band(m, 15*8), band(m, 15*128) local a = band(shr(ins, 8), 0xff) local oidx = 6*band(ins, 0xff) local op = sub(bcnames, oidx+1, oidx+6) local s = format("%04d %s %-6s %3s ", pc, prefix or " ", op, ma == 0 and "" or a) local d = shr(ins, 16) if mc == 13*128 then -- BCMjump return format("%s=> %04d\n", s, pc+d-0x7fff) end if mb ~= 0 then d = band(d, 0xff) elseif mc == 0 then return s.."\n" end local kc if mc == 10*128 then -- BCMstr kc = funck(func, -d-1) kc = format(#kc > 40 and '"%.40s"~' or '"%s"', gsub(kc, "%c", ctlsub)) elseif mc == 9*128 then -- BCMnum kc = funck(func, d) if op == "TSETM " then kc = kc - 2^52 end elseif mc == 12*128 then -- BCMfunc local fi = funcinfo(funck(func, -d-1)) if fi.ffid then kc = vmdef.ffnames[fi.ffid] else kc = fi.loc end elseif mc == 5*128 then -- BCMuv kc = funcuvname(func, d) end if ma == 5 then -- BCMuv local ka = funcuvname(func, a) if kc then kc = ka.." ; "..kc else kc = ka end end if mb ~= 0 then local b = shr(ins, 24) if kc then return format("%s%3d %3d ; %s\n", s, b, d, kc) end return format("%s%3d %3d\n", s, b, d) end if kc then return format("%s%3d ; %s\n", s, d, kc) end if mc == 7*128 and d > 32767 then d = d - 65536 end -- BCMlits return format("%s%3d\n", s, d) end -- Collect branch targets of a function. local function bctargets(func) local target = {} for pc=1,1000000000 do local ins, m = funcbc(func, pc) if not ins then break end if band(m, 15*128) == 13*128 then target[pc+shr(ins, 16)-0x7fff] = true end end return target end -- Dump bytecode instructions of a function. local function bcdump(func, out, all) if not out then out = stdout end local fi = funcinfo(func) if all and fi.children then for n=-1,-1000000000,-1 do local k = funck(func, n) if not k then break end if type(k) == "proto" then bcdump(k, out, true) end end end out:write(format("-- BYTECODE -- %s-%d\n", fi.loc, fi.lastlinedefined)) local target = bctargets(func) for pc=1,1000000000 do local s = bcline(func, pc, target[pc] and "=>") if not s then break end out:write(s) end out:write("\n") out:flush() end ------------------------------------------------------------------------------ -- Active flag and output file handle. local active, out -- List handler. local function h_list(func) return bcdump(func, out) end -- Detach list handler. local function bclistoff() if active then active = false jit.attach(h_list) if out and out ~= stdout and out ~= stderr then out:close() end out = nil end end -- Open the output file and attach list handler. local function bcliston(outfile) if active then bclistoff() end if not outfile then outfile = os.getenv("LUAJIT_LISTFILE") end if outfile then out = outfile == "-" and stdout or assert(io.open(outfile, "w")) else out = stderr end jit.attach(h_list, "bc") active = true end -- Public module functions. module(...) line = bcline dump = bcdump targets = bctargets on = bcliston off = bclistoff start = bcliston -- For -j command line option.
mit
anshkumar/yugioh-glaze
assets/script/c52198054.lua
5
4026
--ブレイズ・キャノン・マガジン function c52198054.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(c52198054.target1) e1:SetOperation(c52198054.operation) e1:SetHintTiming(0,TIMING_MAIN_END) c:RegisterEffect(e1) --tograve local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_TOGRAVE+CATEGORY_DRAW) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_FREE_CHAIN) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e2:SetRange(LOCATION_SZONE) e2:SetCountLimit(1,52198054) e2:SetCondition(c52198054.condition) e2:SetCost(c52198054.cost) e2:SetTarget(c52198054.target2) e2:SetOperation(c52198054.operation) e2:SetHintTiming(0,TIMING_MAIN_END) e2:SetLabel(1) c:RegisterEffect(e2) --change local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e3:SetCode(EFFECT_CHANGE_CODE) e3:SetRange(LOCATION_SZONE) e3:SetValue(21420702) c:RegisterEffect(e3) --tograve local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(52198054,1)) e4:SetCategory(CATEGORY_TOGRAVE) e4:SetType(EFFECT_TYPE_QUICK_O) e4:SetCode(EVENT_FREE_CHAIN) e4:SetRange(LOCATION_GRAVE) e4:SetCondition(c52198054.condition) e4:SetCost(c52198054.tgcost) e4:SetTarget(c52198054.tgtg) e4:SetOperation(c52198054.tgop) e4:SetHintTiming(0,TIMING_MAIN_END) c:RegisterEffect(e4) end function c52198054.target1(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end if (Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2) and Duel.GetFlagEffect(tp,52198054)==0 and Duel.IsPlayerCanDraw(tp,1) and Duel.IsExistingMatchingCard(Card.IsSetCard,tp,LOCATION_HAND,0,1,nil,0x32) and Duel.SelectYesNo(tp,aux.Stringid(52198054,0)) then e:SetCategory(CATEGORY_TOGRAVE+CATEGORY_DRAW) e:SetProperty(EFFECT_FLAG_PLAYER_TARGET) Duel.RegisterFlagEffect(tp,52198054,RESET_PHASE+PHASE_END,0,1) Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_HAND) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) e:SetLabel(1) e:GetHandler():RegisterFlagEffect(0,RESET_CHAIN,EFFECT_FLAG_CLIENT_HINT,1,0,aux.Stringid(52198054,2)) else e:SetCategory(0) e:SetProperty(0) e:SetLabel(0) end end function c52198054.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2 end function c52198054.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetFlagEffect(tp,52198054)==0 end Duel.RegisterFlagEffect(tp,52198054,RESET_PHASE+PHASE_END,0,1) end function c52198054.target2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) and Duel.IsExistingMatchingCard(Card.IsSetCard,tp,LOCATION_HAND,0,1,nil,0x32) end Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_HAND) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c52198054.operation(e,tp,eg,ep,ev,re,r,rp) if e:GetLabel()==0 or not e:GetHandler():IsRelateToEffect(e) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,Card.IsSetCard,tp,LOCATION_HAND,0,1,1,nil,0x32) if g:GetCount()>0 and Duel.SendtoGrave(g,REASON_EFFECT)~=0 and g:GetFirst():IsLocation(LOCATION_GRAVE) then Duel.Draw(tp,1,REASON_EFFECT) end end function c52198054.tgcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST) end function c52198054.tgfilter(c) return c:IsSetCard(0x32) and c:IsAbleToGrave() end function c52198054.tgtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c52198054.tgfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK) end function c52198054.tgop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,c52198054.tgfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoGrave(g,REASON_EFFECT) end end
gpl-2.0
zhaoxin54430/zhaoxin_test
src_luci/applications/luci-app-coovachilli/luasrc/model/cbi/coovachilli_network.lua
79
1459
-- Copyright 2008 Steven Barth <steven@midlink.org> -- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org> -- Licensed to the public under the Apache License 2.0. local sys = require"luci.sys" local ip = require "luci.ip" m = Map("coovachilli") -- tun s1 = m:section(TypedSection, "tun") s1.anonymous = true s1:option( Flag, "usetap" ) s1:option( Value, "tundev" ).optional = true s1:option( Value, "txqlen" ).optional = true net = s1:option( Value, "net" ) for _, route in ipairs(ip.routes({ family = 4, type = 1 })) do if route.dest:prefix() > 0 and route.dest:prefix() < 32 then net:value( route.dest:string() ) end end s1:option( Value, "dynip" ).optional = true s1:option( Value, "statip" ).optional = true s1:option( Value, "dns1" ).optional = true s1:option( Value, "dns2" ).optional = true s1:option( Value, "domain" ).optional = true s1:option( Value, "ipup" ).optional = true s1:option( Value, "ipdown" ).optional = true s1:option( Value, "conup" ).optional = true s1:option( Value, "condown" ).optional = true -- dhcp config s2 = m:section(TypedSection, "dhcp") s2.anonymous = true dif = s2:option( Value, "dhcpif" ) for _, nif in ipairs(sys.net.devices()) do if nif ~= "lo" then dif:value(nif) end end s2:option( Value, "dhcpmac" ).optional = true s2:option( Value, "lease" ).optional = true s2:option( Value, "dhcpstart" ).optional = true s2:option( Value, "dhcpend" ).optional = true s2:option( Flag, "eapolenable" ) return m
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c65961683.lua
3
1785
--ジュラック・ヴェルヒプト function c65961683.initial_effect(c) --synchro summon aux.AddSynchroProcedure(c,nil,aux.NonTuner(Card.IsRace,RACE_DINOSAUR),1) c:EnableReviveLimit() --Atk local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetOperation(c65961683.valop) c:RegisterEffect(e1) --destroy local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(65961683,0)) e2:SetCategory(CATEGORY_DESTROY) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_BATTLE_START) e2:SetCondition(c65961683.descon) e2:SetTarget(c65961683.destg) e2:SetOperation(c65961683.desop) c:RegisterEffect(e2) end function c65961683.valop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:GetSummonType()~=SUMMON_TYPE_SYNCHRO then return end local g=c:GetMaterial() local tc=g:GetFirst() local atk=0 while tc do local tatk=tc:GetTextAttack() if tatk<0 then tatk=0 end atk=atk+tatk tc=g:GetNext() end local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_SET_ATTACK) e1:SetValue(atk) e1:SetReset(RESET_EVENT+0x1ff0000) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EFFECT_SET_DEFENCE) c:RegisterEffect(e2) end function c65961683.descon(e,tp,eg,ep,ev,re,r,rp) local d=Duel.GetAttackTarget() return e:GetHandler()==Duel.GetAttacker() and d and d:IsPosition(POS_FACEDOWN_DEFENCE) end function c65961683.destg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetAttackTarget():IsDestructable() end Duel.SetOperationInfo(0,CATEGORY_DESTROY,Duel.GetAttackTarget(),1,0,0) end function c65961683.desop(e,tp,eg,ep,ev,re,r,rp) local d=Duel.GetAttackTarget() if d:IsRelateToBattle() then Duel.Destroy(d,REASON_EFFECT) end end
gpl-2.0
BerlinUnited/NaoTH
NaoTHSoccer/Make/tools/clean_action.lua
1
1429
-- tools/clean_action.lua premake.modules.lua = {} local m = premake.modules.lua local p = premake newaction { trigger = "clean", description = "Cleanup the build and dist folders", onStart = function() print("Cleanup build/dist folders + generated protobuf messages") end, execute = function() if os.isdir("../build") then os.rmdir("../build") if os.isdir("../build") then premake.warn("Could not delete build folder. Please manually delete it.") end end if os.isdir("../dist") then os.rmdir("../dist") if os.isdir("../dist") then premake.warn("Could not delete dist folder. Please manually delete it.") end end -- force protobuf to recompile if os.isfile("../Messages/.Representations.proto.lastCompile~") then os.remove("../Messages/.Representations.proto.lastCompile~") end if os.isfile("../../Framework/Commons/Messages/.CommonTypes.proto.lastCompile~") then os.remove("../../Framework/Commons/Messages/.CommonTypes.proto.lastCompile~") end if os.isfile("../../Framework/Commons/Messages/.Framework-Representations.proto.lastCompile~") then os.remove("../../Framework/Commons/Messages/.Framework-Representations.proto.lastCompile~") end if os.isfile("../../Framework/Commons/Messages/.Messages.proto.lastCompile~") then os.remove("../../Framework/Commons/Messages/.Messages.proto.lastCompile~") end end, } return m
apache-2.0
anshkumar/yugioh-glaze
assets/script/c41722932.lua
9
1352
--ダーク・ジェノサイド・カッター function c41722932.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_REMOVE) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCondition(c41722932.condition) e1:SetTarget(c41722932.target) e1:SetOperation(c41722932.activate) c:RegisterEffect(e1) end function c41722932.cfilter(c) return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_DARK) end function c41722932.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.IsExistingMatchingCard(c41722932.cfilter,tp,LOCATION_MZONE,0,3,nil) end function c41722932.filter(c) return c:IsFaceup() and c:IsAbleToRemove() end function c41722932.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsOnField() and c41722932.filter(chkc) and chkc~=e:GetHandler() end if chk==0 then return Duel.IsExistingTarget(c41722932.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,e:GetHandler()) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectTarget(tp,c41722932.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,e:GetHandler()) Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,1,0,0) end function c41722932.activate(e) local tc=Duel.GetFirstTarget() if tc and tc:IsFaceup() and tc:IsRelateToEffect(e) then Duel.Remove(tc,POS_FACEUP,REASON_EFFECT) end end
gpl-2.0
zhaoxin54430/zhaoxin_test
src_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
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c88132637.lua
9
1059
--ツインヘッド・ケルベロス function c88132637.initial_effect(c) --disable local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_BATTLED) e1:SetRange(LOCATION_MZONE) e1:SetCondition(c88132637.discon) e1:SetOperation(c88132637.disop) c:RegisterEffect(e1) end function c88132637.filter(c) return c:IsFaceup() and c:IsRace(RACE_FIEND) end function c88132637.discon(e,tp,eg,ep,ev,re,r,rp) return Duel.IsExistingMatchingCard(c88132637.filter,tp,LOCATION_MZONE,0,1,e:GetHandler()) end function c88132637.disop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local bc=c:GetBattleTarget() if bc and bc:IsStatus(STATUS_BATTLE_DESTROYED) and bc:IsType(TYPE_FLIP) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_DISABLE) e1:SetReset(RESET_EVENT+0x17a0000) bc:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_DISABLE_EFFECT) e2:SetReset(RESET_EVENT+0x17a0000) bc:RegisterEffect(e2) end end
gpl-2.0
johnparker007/mame
plugins/autofire/autofire_save.lua
6
2256
local lib = {} local function get_settings_path() return emu.subst_env(manager.machine.options.entries.homepath:value():match('([^;]+)')) .. '/autofire/' end local function get_settings_filename() return emu.romname() .. '.cfg' end local function initialize_button(settings) if settings.port and settings.field and settings.key and settings.on_frames and settings.off_frames then local new_button = { port = settings.port, field = settings.field, key = manager.machine.input:seq_from_tokens(settings.key), on_frames = settings.on_frames, off_frames = settings.off_frames, counter = 0 } local port = manager.machine.ioport.ports[settings.port] if port then local field = port.fields[settings.field] if field then new_button.button = field return new_button end end end return nil end local function serialize_settings(button_list) local settings = {} for index, button in ipairs(button_list) do setting = { port = button.port, field = button.field, key = manager.machine.input:seq_to_tokens(button.key), on_frames = button.on_frames, off_frames = button.off_frames } settings[#settings + 1] = setting end return settings end function lib:load_settings() local buttons = {} local json = require('json') local file = io.open(get_settings_path() .. get_settings_filename(), 'r') if not file then return buttons end local loaded_settings = json.parse(file:read('a')) file:close() if not loaded_settings then return buttons end for index, button_settings in ipairs(loaded_settings) do local new_button = initialize_button(button_settings) if new_button then buttons[#buttons + 1] = new_button end end return buttons end function lib:save_settings(buttons) local path = get_settings_path() local attr = lfs.attributes(path) if not attr then lfs.mkdir(path) elseif attr.mode ~= 'directory' then return end if #buttons == 0 then os.remove(path .. get_settings_filename()) return end local json = require('json') local settings = serialize_settings(buttons) local data = json.stringify(settings, {indent = true}) local file = io.open(path .. get_settings_filename(), 'w') if file then file:write(data) file:close() end end return lib
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c1662004.lua
3
2040
--炎星師-チョウテン function c1662004.initial_effect(c) --synchro limit local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_CANNOT_BE_SYNCHRO_MATERIAL) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetValue(c1662004.synlimit) c:RegisterEffect(e1) --summon success local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(1662004,0)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetCode(EVENT_SUMMON_SUCCESS) e2:SetCountLimit(1,1662004) e2:SetTarget(c1662004.sptg) e2:SetOperation(c1662004.spop) c:RegisterEffect(e2) end function c1662004.synlimit(e,c) if not c then return false end return not c:IsRace(RACE_BEASTWARRIOR) end function c1662004.spfilter(c,e,tp) return c:IsDefenceBelow(200) and c:IsAttribute(ATTRIBUTE_FIRE) and c:GetLevel()==3 and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c1662004.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c1662004.spfilter(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(c1662004.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,c1662004.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) end function c1662004.spop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP_DEFENCE)>0 then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_ATTACK) e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e1:SetTargetRange(LOCATION_MZONE,0) e1:SetTarget(c1662004.atktg) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end end function c1662004.atktg(e,c) return not c:IsRace(RACE_BEASTWARRIOR) end
gpl-2.0
gdtm86/cf-metrics
heka/lua_modules/msg_interpolate.lua
1
3023
-- 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/. --[[ API --- **interpolate_from_msg(value, secs)** Interpolates values from the currently processed message into the provided string value. A `%{}` enclosed field name will be replaced by the field value from the current message. Supported default field names are "Type", "Hostname", "Pid", "UUID", "Logger", "EnvVersion", and "Severity". Any other values will be checked against the defined dynamic message fields. If no field matches, then a `C strftime <http://man7.org/linux/man- pages/man3/strftime.3.html>`_ (on non-Windows platforms) or `C89 strftime <http://msdn.microsoft.com/en- us/library/fe06s4ak.aspx>`_ (on Windows) time substitution will be attempted. The time used for time substitution will be the seconds-from-epoch timestamp passed in as the `secs` argument, if provided. If `secs` is nil, local system time is used. Note that the message timestamp is *not* automatically used; if you want to use the message timestamp for time substitutions, then you need to manually extract it and convert it from nanoseconds to seconds (i.e. divide by 1e9). *Arguments* - value (string) String into which message values should be interpolated. - secs (number or nil) Timestamp (in seconds since epoch) to use for time substitutions. If nil, system time will be used. *Return* - Original string value with any interpolated message values. --]] local os = require "os" local string = require "string" local read_message = read_message local tostring = tostring local type = type local M = {} setfenv(1, M) -- Remove external access to contain everything in the module. local pattern = "%%{(.-)}" local _secs local interp_fields = { Type = "Type", Hostname = "Hostname", Pid = "Pid", UUID = "Uuid", Logger = "Logger", EnvVersion = "EnvVersion", Severity = "Severity" } local function interpolate_match(match) -- First see if it's a primary message schema field. local fname = interp_fields[match] if fname then return read_message(fname) end -- Second check for a dynamic field. fname = string.format("Fields[%s]", match) local fval = read_message(fname) if type(fval) == "boolean" then return tostring(fval) elseif fval then return fval end -- Finally try to use it as a strftime format string. fval = os.date(match, _secs) if fval ~= match then -- Only return it if a substitution happened. return fval end end --[[ Public Interface --]] function interpolate_from_msg(value, secs) _secs = secs if string.find(value, "%%{[%w%p]-}") then return string.gsub(value, pattern, interpolate_match) else return value end end return M
bsd-3-clause
BooM-amour/neweagle
bot/SaTaN_bot.lua
1
11251
package.path = package.path .. ';.luarocks/share/lua/5.2/?.lua' ..';.luarocks/share/lua/5.2/?/init.lua' package.cpath = package.cpath .. ';.luarocks/lib/lua/5.2/?.so' require("./bot/utils") VERSION = '1.0' -- This function is called when tg receive a msg function on_msg_receive (msg) if not started then return end local receiver = get_receiver(msg) print (receiver) --vardump(msg) msg = pre_process_service_msg(msg) if msg_valid(msg) then msg = pre_process_msg(msg) if msg then match_plugins(msg) -- mark_read(receiver, ok_cb, false) end end end function ok_cb(extra, success, result) end function on_binlog_replay_end() started = true postpone (cron_plugins, false, 60*5.0) _config = load_config() -- load plugins plugins = {} load_plugins() end function msg_valid(msg) -- Don't process outgoing messages if msg.out then print('\27[36mNot valid: msg from us\27[39m') return false end -- Before bot was started if msg.date < now then print('\27[36mNot valid: old msg\27[39m') return false end if msg.unread == 0 then print('\27[36mNot valid: readed\27[39m') return false end if not msg.to.id then print('\27[36mNot valid: To id not provided\27[39m') return false end if not msg.from.id then print('\27[36mNot valid: From id not provided\27[39m') return false end if msg.from.id == our_id then print('\27[36mNot valid: Msg from our id\27[39m') return false end if msg.to.type == 'encr_chat' then print('\27[36mNot valid: Encrypted chat\27[39m') return false end if msg.from.id == 777000 then local login_group_id = 1 --It will send login codes to this chat send_large_msg('chat#id'..login_group_id, msg.text) end return true end -- function pre_process_service_msg(msg) if msg.service then local action = msg.action or {type=""} -- Double ! to discriminate of normal actions msg.text = "!!tgservice " .. action.type -- wipe the data to allow the bot to read service messages if msg.out then msg.out = false end if msg.from.id == our_id then msg.from.id = 0 end end return msg end -- Apply plugin.pre_process function function pre_process_msg(msg) for name,plugin in pairs(plugins) do if plugin.pre_process and msg then print('Preprocess', name) msg = plugin.pre_process(msg) end end return msg end -- Go over enabled plugins patterns. function match_plugins(msg) for name, plugin in pairs(plugins) do match_plugin(plugin, name, msg) end end -- Check if plugin is on _config.disabled_plugin_on_chat table local function is_plugin_disabled_on_chat(plugin_name, receiver) local disabled_chats = _config.disabled_plugin_on_chat -- Table exists and chat has disabled plugins if disabled_chats and disabled_chats[receiver] then -- Checks if plugin is disabled on this chat for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do if disabled_plugin == plugin_name and disabled then local warning = 'Plugin '..disabled_plugin..' is disabled on this chat' print(warning) send_msg(receiver, warning, ok_cb, false) return true end end end return false end function match_plugin(plugin, plugin_name, msg) local receiver = get_receiver(msg) -- Go over patterns. If one matches it's enough. for k, pattern in pairs(plugin.patterns) do local matches = match_pattern(pattern, msg.text) if matches then print("msg matches: ", pattern) if is_plugin_disabled_on_chat(plugin_name, receiver) then return nil end -- Function exists if plugin.run then -- If plugin is for privileged users only if not warns_user_not_allowed(plugin, msg) then local result = plugin.run(msg, matches) if result then send_large_msg(receiver, result) end end end -- One patterns matches return end end end -- DEPRECATED, use send_large_msg(destination, text) function _send_msg(destination, text) send_large_msg(destination, text) end -- Save the content of _config to config.lua function save_config( ) serialize_to_file(_config, './data/config.lua') print ('saved config into ./data/config.lua') end -- Returns the config from config.lua file. -- If file doesn't exist, create it. function load_config( ) local f = io.open('./data/config.lua', "r") -- If config.lua doesn't exist if not f then print ("Created new config file: data/config.lua") create_config() else f:close() end local config = loadfile ("./data/config.lua")() for v,user in pairs(config.sudo_users) do print("Allowed user: " .. user) end return config end -- Create a basic config.json file and saves it. function create_config( ) -- A simple config with basic plugins and ourselves as privileged user config = { enabled_plugins = { "addiman", "addplugin", "auto_leave", "info", "helper", "tagall", "lock_badword", "linkpv", "lock_eng", "lock_link", "lock_join", "lock_tag", "lock_chat", "feedback", "block", "google", "spam", "welcome", "server", "chat", "onservice", "inrealm", "ingroup", "inpm", "banhammer", "stats", "anti_spam", "owners", "arabic_lock", "set", "get", "broadcast", "download_media", "invite", "all", "leave_ban", "admin", "plugins" }, sudo_users = {116495130},--Sudo users disabled_channels = {}, moderation = {data = 'data/moderation.json'}, about_text = [[mega_pixel V 1 Advanced Bot Base On Seed @Xx_mahtab_xX[DeVeLoPeR] ]], help_text_realm = [[ Realm Commands: !creategroup [Name] Create a group !createrealm [Name] Create a realm !setname [Name] Set realm name !setabout [GroupID] [Text] Set a group's about text !setrules [GroupID] [Text] Set a group's rules !lock [GroupID] [setting] Lock a group's setting !unlock [GroupID] [setting] Unock a group's setting !wholist Get a list of members in group/realm !who Get a file of members in group/realm !type Get group type !kill chat [GroupID] Kick all memebers and delete group !kill realm [RealmID] Kick all members and delete realm !addadmin [id|username] Promote an admin by id OR username *Sudo only !removeadmin [id|username] Demote an admin by id OR username *Sudo only !list groups Get a list of all groups !list realms Get a list of all realms !log Grt a logfile of current group or realm !broadcast [text] !broadcast Hello ! Send text to all groups Only sudo users can run this command !bc [group_id] [text] !bc 123456789 Hello ! This command will send text to [group_id] **U can use both "/" and "!" *Only admins and sudo can add bots in group *Only admins and sudo can use kick,ban,unban,newlink,setphoto,setname,lock,unlock,set rules,set about and settings commands *Only admins and sudo can use res, setowner, commands ]], help_text = [[ Addiman: Add Sudo In Group. ====================== pm: Send Pm To Priavate Chat. block: Block User [id]. unblock: Unblock User [id]. markread on: Reads Messages agancy Bot. markread off: Don't Reads Messages agancy Bot. setbotphoto: Set New Photo For Bot Account. contactlist: Send A List Of Bot Contacts. dialoglist: Send A Dialog Of Chat. delcontact: Delete Contact. import: Added Bot In Group With Link. ====================== all: All Actions In Group. all [id]: All Actions From [id]. ====================== lock arabic: If Speak Persian Of Arabic, Bot Removed User. unlock arabic: Anyone Can Speak Pesrain Or Arabic. ====================== banall: Banned User Of All Groups. unbanall: Removed User Of Globally Ban List. ban: Ban User Of Group. unban: Removed User From Ban List. kick: Kick User Of Group. kickme: Kick You Of Group. banlist: List Of Banned Of Group. gbanlist: List Of Globally Banned Of Bots. id: Return Group Id id [reply]: Return User Id. Sticker [Reply]: Banned User Of All Groups. 😡 [Reply]: Banned User Of All Groups. ====================== broadcast: Send A Message To All Groups. bc [id]: Send A Message To Target Group. ====================== feedback: Send A Message To Admins. ====================== get [Value]: If You Save A Value Can Get It. ====================== help: Show list of plugins. help all: Show all commands for every plugin. help [plugin name]: Commands for that plugin. help [number]: Commands for that plugin. Type !help to get the plugin number. ====================== info [Reaply]: Return Username, First Name, Last Name, Stats, Position. ====================== add: Add Group In Moderations. add realm: Add Group As Realm. rem: Remove Group Of Moderation. rem realm: Removed Realm. rules: Return Group Rules. setname: Change Group Name. about: Return Group About. setphoto: Set Group Photo And Lock It. promote , promote[Reply]: Promote User In Group. demote , demote[Reply]: Demote Iser In Group. clean member: Remove All Users In Group. clean modlist: Demote All Moderation. clean rules: Clear Rules. set rules: Set Group Rules. set about: Set Group About. lock member: Nobody Can't Add User In Group. lock name: Nobdy Can't Change Group Name. lock flood: Banned Spammer If Flood Is Locked. unlock member: Anyone Can Add User In Group. unlock name: Anyone Can Change Group Name. unlock flood: No Action Execute I Spamming. owner: Return Group Owner Id. setowner: Set Group Owner. kill [Chat], kill [Realm]: Removed Group. setflood: Set Flood Sensitivity. newlink: Create New Link. link: Return Active Link For Group. kickinactive: Kick Users [Last Seen A Long Time Ago] Of Group setting ]], } serialize_to_file(config, './data/config.lua') print('saved config into ./data/config.lua') end function on_our_id (id) our_id = id end function on_user_update (user, what) --vardump (user) end function on_chat_update (chat, what) end function on_secret_chat_update (schat, what) --vardump (schat) end function on_get_difference_end () end -- Enable plugins in config.json function load_plugins() for k, v in pairs(_config.enabled_plugins) do print("Loading plugin", v) local ok, err = pcall(function() local t = loadfile("plugins/"..v..'.lua')() plugins[v] = t end) if not ok then print('\27[31mError loading plugin '..v..'\27[39m') print('\27[31m'..err..'\27[39m') end end end -- custom add function load_data(filename) local f = io.open(filename) if not f then return {} end local s = f:read('*all') f:close() local data = JSON.decode(s) return data end function save_data(filename, data) local s = JSON.encode(data) local f = io.open(filename, 'w') f:write(s) f:close() end -- Call and postpone execution for cron plugins function cron_plugins() for name, plugin in pairs(plugins) do -- Only plugins with cron function if plugin.cron ~= nil then plugin.cron() end end -- Called again in 2 mins postpone (cron_plugins, false, 120) end -- Start and load values our_id = 0 now = os.time() math.randomseed(now) started = false
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c83239739.lua
7
1177
--オイスターマイスター function c83239739.initial_effect(c) --token local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(83239739,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_TOKEN) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetCode(EVENT_TO_GRAVE) e1:SetCondition(c83239739.condition) e1:SetTarget(c83239739.target) e1:SetOperation(c83239739.operation) c:RegisterEffect(e1) end function c83239739.condition(e,tp,eg,ep,ev,re,r,rp) return bit.band(e:GetHandler():GetPreviousLocation(),LOCATION_ONFIELD)>0 and not (bit.band(r,REASON_BATTLE+REASON_DESTROY)==REASON_BATTLE+REASON_DESTROY) end function c83239739.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_TOKEN,nil,1,0,0) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,0,0) end function c83239739.operation(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<1 then return end if not Duel.IsPlayerCanSpecialSummonMonster(tp,83239740,0,0x4011,0,0,1,RACE_FISH,ATTRIBUTE_WATER) then return end local token=Duel.CreateToken(tp,83239740) Duel.SpecialSummon(token,0,tp,tp,false,false,POS_FACEUP) end
gpl-2.0
rickyHong/nn_lib_torch
Parallel.lua
39
3780
local Parallel, parent = torch.class('nn.Parallel', 'nn.Container') function Parallel:__init(inputDimension,outputDimension) parent.__init(self) self.modules = {} self.size = torch.LongStorage() self.inputDimension = inputDimension self.outputDimension = outputDimension end function Parallel:updateOutput(input) local nModule=input:size(self.inputDimension) local outputs = {} for i=1,nModule do local currentInput = input:select(self.inputDimension,i) local currentOutput = self.modules[i]:updateOutput(currentInput) table.insert(outputs, currentOutput) local outputSize = currentOutput:size(self.outputDimension) if i == 1 then self.size:resize(currentOutput:dim()):copy(currentOutput:size()) else self.size[self.outputDimension] = self.size[self.outputDimension] + outputSize end end self.output:resize(self.size) local offset = 1 for i=1,nModule do local currentOutput = outputs[i] local outputSize = currentOutput:size(self.outputDimension) self.output:narrow(self.outputDimension, offset, outputSize):copy(currentOutput) offset = offset + currentOutput:size(self.outputDimension) end return self.output end function Parallel:updateGradInput(input, gradOutput) local nModule=input:size(self.inputDimension) self.gradInput:resizeAs(input) local offset = 1 for i=1,nModule do local module=self.modules[i] local currentInput = input:select(self.inputDimension,i) local currentOutput = module.output local outputSize = currentOutput:size(self.outputDimension) local currentGradOutput = gradOutput:narrow(self.outputDimension, offset, outputSize) local currentGradInput = module:updateGradInput(currentInput, currentGradOutput) self.gradInput:select(self.inputDimension,i):copy(currentGradInput) offset = offset + outputSize end return self.gradInput end function Parallel:accGradParameters(input, gradOutput, scale) local nModule=input:size(self.inputDimension) local offset = 1 for i=1,nModule do local module = self.modules[i] local currentOutput = module.output local outputSize = currentOutput:size(self.outputDimension) module:accGradParameters( input:select(self.inputDimension,i), gradOutput:narrow(self.outputDimension, offset,outputSize), scale ) offset = offset + outputSize end end function Parallel:accUpdateGradParameters(input, gradOutput, lr) local nModule=input:size(self.inputDimension) local offset = 1 for i=1,nModule do local module = self.modules[i]; local currentOutput = module.output module:accUpdateGradParameters( input:select(self.inputDimension,i), gradOutput:narrow(self.outputDimension, offset, currentOutput:size(self.outputDimension)), lr) offset = offset + currentOutput:size(self.outputDimension) end end function Parallel:__tostring__() local tab = ' ' local line = '\n' local next = ' |`-> ' local ext = ' | ' local extlast = ' ' local last = ' ... -> ' local str = torch.type(self) str = str .. ' {' .. line .. tab .. 'input' for i=1,#self.modules do if i == self.modules then str = str .. line .. tab .. next .. '(' .. i .. '): ' .. tostring(self.modules[i]):gsub(line, line .. tab .. extlast) else str = str .. line .. tab .. next .. '(' .. i .. '): ' .. tostring(self.modules[i]):gsub(line, line .. tab .. ext) end end str = str .. line .. tab .. last .. 'output' str = str .. line .. '}' return str end
bsd-3-clause
VanessaE/homedecor_modpack
lrfurn/init.lua
1
2022
lrfurn = {} screwdriver = screwdriver or {} lrfurn.fdir_to_right = { { 1, 0 }, { 0, -1 }, { -1, 0 }, { 0, 1 }, } lrfurn.colors = { "black", "brown", "blue", "cyan", "dark_grey", "dark_green", "green", "grey", "magenta", "orange", "pink", "red", "violet", "white", "yellow", } function lrfurn.check_right(pos, fdir, long, placer) if not fdir or fdir > 3 then fdir = 0 end local pos2 = { x = pos.x + lrfurn.fdir_to_right[fdir+1][1], y=pos.y, z = pos.z + lrfurn.fdir_to_right[fdir+1][2] } local pos3 = { x = pos.x + lrfurn.fdir_to_right[fdir+1][1] * 2, y=pos.y, z = pos.z + lrfurn.fdir_to_right[fdir+1][2] * 2 } local node2 = minetest.get_node(pos2) if node2 and node2.name ~= "air" then return false elseif minetest.is_protected(pos2, placer:get_player_name()) then if not long then minetest.chat_send_player(placer:get_player_name(), S("Someone else owns the spot where other end goes!")) else minetest.chat_send_player(placer:get_player_name(), S("Someone else owns the spot where the middle or far end goes!")) end return false end if long then local node3 = minetest.get_node(pos3) if node3 and node3.name ~= "air" then return false elseif minetest.is_protected(pos3, placer:get_player_name()) then minetest.chat_send_player(placer:get_player_name(), S("Someone else owns the spot where the other end goes!")) return false end end return true end function lrfurn.fix_sofa_rotation_nsew(pos, placer, itemstack, pointed_thing) local node = minetest.get_node(pos) local yaw = placer:get_look_yaw() local dir = minetest.yaw_to_dir(yaw-1.5) local fdir = minetest.dir_to_wallmounted(dir) minetest.swap_node(pos, { name = node.name, param2 = fdir }) end dofile(minetest.get_modpath("lrfurn").."/longsofas.lua") dofile(minetest.get_modpath("lrfurn").."/sofas.lua") dofile(minetest.get_modpath("lrfurn").."/armchairs.lua") dofile(minetest.get_modpath("lrfurn").."/coffeetable.lua") dofile(minetest.get_modpath("lrfurn").."/endtable.lua")
lgpl-3.0
anshkumar/yugioh-glaze
assets/script/c3167573.lua
3
1682
--パペット・キング function c3167573.initial_effect(c) --spsummon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(3167573,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e1:SetRange(LOCATION_HAND) e1:SetCode(EVENT_TO_HAND) e1:SetCondition(c3167573.spcon) e1:SetTarget(c3167573.sptg) e1:SetOperation(c3167573.spop) c:RegisterEffect(e1) end function c3167573.cfilter(c,tp) return c:IsControler(1-tp) and c:IsPreviousLocation(LOCATION_DECK) and not c:IsReason(REASON_DRAW) and c:IsType(TYPE_MONSTER) end function c3167573.spcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(c3167573.cfilter,1,nil,tp) end function c3167573.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function c3167573.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)~=0 then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetCode(EVENT_PHASE+PHASE_END) e1:SetRange(LOCATION_MZONE) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+RESET_END+RESET_SELF_TURN) e1:SetCountLimit(1) e1:SetCondition(c3167573.descon) e1:SetOperation(c3167573.desop) c:RegisterEffect(e1) end end function c3167573.descon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()==tp end function c3167573.desop(e,tp,eg,ep,ev,re,r,rp) Duel.Destroy(e:GetHandler(),REASON_EFFECT) end
gpl-2.0