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 |
|---|---|---|---|---|---|
dr01d3r/darkstar | scripts/globals/items/stick_of_cotton_candy.lua | 12 | 1231 | -----------------------------------------
-- ID: 5709
-- Item: Cotton Candy
-- Food Effect: 5 Min, All Races
-----------------------------------------
-- MP % 10 Cap 200
-- MP Healing 3
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD)) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,300,5709);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_FOOD_MPP, 10);
target:addMod(MOD_FOOD_MP_CAP, 200);
target:addMod(MOD_MPHEAL, 3);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_FOOD_MPP, 10);
target:delMod(MOD_FOOD_MP_CAP, 200);
target:delMod(MOD_MPHEAL, 3);
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/globals/items/red_bubble-eye.lua | 12 | 1342 | -----------------------------------------
-- ID: 5446
-- Item: Red Bubble-Eye
-- Food Effect: 5 Min, Mithra only
-----------------------------------------
-- Dexterity 2
-- Mind -4
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:getRace() ~= 7) then
result = 247;
end
if (target:getMod(MOD_EAT_RAW_FISH) == 1) then
result = 0;
end
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,300,5446);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEX, 2);
target:addMod(MOD_MND, -4);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_DEX, 2);
target:delMod(MOD_MND, -4);
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Attohwa_Chasm/npcs/Jakaka.lua | 9 | 2447 | -----------------------------------
-- Area: Attohwa Chasm
-- NPC: Jakaka
-- Type: ENM
-- @pos -144.711 6.246 -250.309 7
-----------------------------------
package.loaded["scripts/zones/Attohwa_Chasm/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Attohwa_Chasm/TextIDs");
require("scripts/globals/keyitems");
require("scripts/globals/settings");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- Trade Parradamo Stones
if (trade:hasItemQty(1778,1) and trade:getItemCount() == 1) then
player:tradeComplete();
player:startEvent(12);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local MiasmaFilterCD = player:getVar("[ENM]MiasmaFilter");
if (player:hasKeyItem(MIASMA_FILTER)) then
player:startEvent(11);
else
if (MiasmaFilterCD >= os.time(t)) then
-- Both Vanadiel time and unix timestamps are based on seconds. Add the difference to the event.
player:startEvent(14, VanadielTime()+(MiasmaFilterCD-os.time(t)));
else
if (player:hasItem(1778)==true or player:hasItem(1777)==true) then -- Parradamo Stones, Flaxen Pouch
player:startEvent(15);
else
player:startEvent(13);
end;
end;
end;
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 12) then
player:addKeyItem(MIASMA_FILTER);
player:messageSpecial(KEYITEM_OBTAINED,MIASMA_FILTER);
player:setVar("[ENM]MiasmaFilter",os.time(t)+(ENM_COOLDOWN*3600)); -- Current time + (ENM_COOLDOWN*1hr in seconds)
elseif (csid == 13) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED, 1777); -- Flaxen Pouch
return;
else
player:addItem(1777);
player:messageSpecial(ITEM_OBTAINED, 1777); -- Flaxen Pouch
end
end
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Port_Bastok/npcs/Carmelo.lua | 14 | 4833 | -----------------------------------
-- Area: Port Bastok
-- NPC: Carmelo
-- Start & Finishes Quest: Love and Ice, A Test of True Love
-- Start Quest: Lovers in the Dusk
-- Involved in Quest: The Siren's Tear
-- @zone 236
-- @pos -146.476 -7.48 -10.889
-----------------------------------
require("scripts/globals/quests");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local SirensTear = player:getQuestStatus(BASTOK,THE_SIREN_S_TEAR);
local SirensTearProgress = player:getVar("SirensTear");
local TheStarsOfIfrit = player:getQuestStatus(BASTOK,THE_STARS_OF_IFRIT);
local LoveAndIce = player:getQuestStatus(BASTOK,LOVE_AND_ICE);
local LoveAndIceProgress = player:getVar("LoveAndIceProgress");
local ATestOfTrueLove = player:getQuestStatus(BASTOK,A_TEST_OF_TRUE_LOVE);
local ATestOfTrueLoveProgress = player:getVar("ATestOfTrueLoveProgress");
local LoversInTheDusk = player:getQuestStatus(BASTOK,LOVERS_IN_THE_DUSK);
if (SirensTear == QUEST_ACCEPTED) then
player:startEvent(0x0006);
elseif (SirensTear == QUEST_COMPLETED and player:hasItem(576) == false and SirensTearProgress < 2) then
player:startEvent(0x0013);
elseif (LoveAndIce == QUEST_AVAILABLE and SirensTear == QUEST_COMPLETED and SirensTear == QUEST_COMPLETED) then
if (player:getFameLevel(BASTOK) >= 5 and player:seenKeyItem(CARRIER_PIGEON_LETTER) == true) then
player:startEvent(0x00b9);
else
player:startEvent(0x00bb);
end
elseif (LoveAndIce == QUEST_ACCEPTED and LoveAndIceProgress == 1) then
player:startEvent(0x00ba);
elseif (player:getFameLevel(BASTOK) >= 7 and ATestOfTrueLove == QUEST_AVAILABLE and LoveAndIce == QUEST_COMPLETED and player:needToZone() == false) then
player:startEvent(0x010e);
elseif (ATestOfTrueLove == QUEST_ACCEPTED and ATestOfTrueLoveProgress < 3) then
player:startEvent(0x010f);
elseif (ATestOfTrueLove == QUEST_ACCEPTED and ATestOfTrueLoveProgress == 3) then
player:startEvent(0x0110);
elseif (ATestOfTrueLove == QUEST_ACCEPTED and ATestOfTrueLoveProgress == 4 and player:needToZone() == true) then
player:startEvent(0x0111);
elseif (ATestOfTrueLove == QUEST_ACCEPTED and ATestOfTrueLoveProgress == 4 and player:needToZone() == false) then
player:startEvent(0x0112);
elseif (LoversInTheDusk == QUEST_AVAILABLE and ATestOfTrueLove == QUEST_COMPLETED and player:needToZone() == false) then
player:startEvent(0x0113);
elseif (LoversInTheDusk == QUEST_ACCEPTED) then
player:startEvent(0x0114);
elseif (LoversInTheDusk == QUEST_COMPLETED) then
player:startEvent(0x0115);
else
player:startEvent(0x00b6);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0006) then
player:setVar("SirensTear",1);
elseif (csid == 0x0013) then
player:setVar("SirensTear",2);
elseif (csid == 0x00b9) then
player:addQuest(BASTOK,LOVE_AND_ICE);
player:addKeyItem(CARMELOS_SONG_SHEET);
player:messageSpecial(KEYITEM_OBTAINED,CARMELOS_SONG_SHEET);
elseif (csid == 0x00ba) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,17356);
else
player:setVar("LoveAndIceProgress",0);
player:needToZone(true);
player:addTitle(SORROW_DROWNER);
player:addItem(17356);
player:messageSpecial(ITEM_OBTAINED,17356); -- Lamia Harp
player:addFame(BASTOK,120);
player:completeQuest(BASTOK,LOVE_AND_ICE);
end
elseif (csid == 0x010e) then
player:addQuest(BASTOK,A_TEST_OF_TRUE_LOVE);
elseif (csid == 0x0110) then
player:setVar("ATestOfTrueLoveProgress",4);
player:needToZone(true);
elseif (csid == 0x0112) then
player:setVar("ATestOfTrueLoveProgress",0);
player:needToZone(true);
player:addFame(BASTOK,120);
player:completeQuest(BASTOK,A_TEST_OF_TRUE_LOVE);
elseif (csid == 0x0113) then
player:addQuest(BASTOK,LOVERS_IN_THE_DUSK);
player:addKeyItem(CHANSON_DE_LIBERTE);
player:messageSpecial(KEYITEM_OBTAINED,CHANSON_DE_LIBERTE);
end
end; | gpl-3.0 |
jonathantompson/nn | SpatialConvolution.lua | 6 | 5890 | local THNN = require 'nn.THNN'
local SpatialConvolution, parent = torch.class('nn.SpatialConvolution', 'nn.Module')
function SpatialConvolution:__init(nInputPlane, nOutputPlane, kW, kH, dW, dH, padW, padH)
parent.__init(self)
dW = dW or 1
dH = dH or 1
self.nInputPlane = nInputPlane
self.nOutputPlane = nOutputPlane
self.kW = kW
self.kH = kH
self.dW = dW
self.dH = dH
self.padW = padW or 0
self.padH = padH or self.padW
self.weight = torch.Tensor(nOutputPlane, nInputPlane, kH, kW)
self.bias = torch.Tensor(nOutputPlane)
self.gradWeight = torch.Tensor(nOutputPlane, nInputPlane, kH, kW)
self.gradBias = torch.Tensor(nOutputPlane)
self:reset()
end
function SpatialConvolution:noBias()
self.bias = nil
self.gradBias = nil
return self
end
function SpatialConvolution:reset(stdv)
if stdv then
stdv = stdv * math.sqrt(3)
else
stdv = 1/math.sqrt(self.kW*self.kH*self.nInputPlane)
end
if nn.oldSeed then
self.weight:apply(function()
return torch.uniform(-stdv, stdv)
end)
if self.bias then
self.bias:apply(function()
return torch.uniform(-stdv, stdv)
end)
end
else
self.weight:uniform(-stdv, stdv)
if self.bias then
self.bias:uniform(-stdv, stdv)
end
end
end
local function backCompatibility(self)
self.finput = self.finput or self.weight.new()
self.fgradInput = self.fgradInput or self.weight.new()
if self.padding then
self.padW = self.padding
self.padH = self.padding
self.padding = nil
else
self.padW = self.padW or 0
self.padH = self.padH or 0
end
if self.weight:dim() == 2 then
self.weight = self.weight:view(self.nOutputPlane, self.nInputPlane, self.kH, self.kW)
end
if self.gradWeight and self.gradWeight:dim() == 2 then
self.gradWeight = self.gradWeight:view(self.nOutputPlane, self.nInputPlane, self.kH, self.kW)
end
end
local function makeContiguous(self, input, gradOutput)
if not input:isContiguous() then
self._input = self._input or input.new()
self._input:resizeAs(input):copy(input)
input = self._input
end
if gradOutput then
if not gradOutput:isContiguous() then
self._gradOutput = self._gradOutput or gradOutput.new()
self._gradOutput:resizeAs(gradOutput):copy(gradOutput)
gradOutput = self._gradOutput
end
end
return input, gradOutput
end
-- function to re-view the weight layout in a way that would make the MM ops happy
local function viewWeight(self)
self.weight = self.weight:view(self.nOutputPlane, self.nInputPlane * self.kH * self.kW)
if self.gradWeight and self.gradWeight:dim() > 0 then
self.gradWeight = self.gradWeight:view(self.nOutputPlane, self.nInputPlane * self.kH * self.kW)
end
end
local function unviewWeight(self)
self.weight = self.weight:view(self.nOutputPlane, self.nInputPlane, self.kH, self.kW)
if self.gradWeight and self.gradWeight:dim() > 0 then
self.gradWeight = self.gradWeight:view(self.nOutputPlane, self.nInputPlane, self.kH, self.kW)
end
end
function SpatialConvolution:updateOutput(input)
assert(input.THNN, torch.type(input)..'.THNN backend not imported')
backCompatibility(self)
viewWeight(self)
input = makeContiguous(self, input)
input.THNN.SpatialConvolutionMM_updateOutput(
input:cdata(),
self.output:cdata(),
self.weight:cdata(),
THNN.optionalTensor(self.bias),
self.finput:cdata(),
self.fgradInput:cdata(),
self.kW, self.kH,
self.dW, self.dH,
self.padW, self.padH
)
unviewWeight(self)
return self.output
end
function SpatialConvolution:updateGradInput(input, gradOutput)
assert(input.THNN, torch.type(input)..'.THNN backend not imported')
if self.gradInput then
backCompatibility(self)
viewWeight(self)
input, gradOutput = makeContiguous(self, input, gradOutput)
input.THNN.SpatialConvolutionMM_updateGradInput(
input:cdata(),
gradOutput:cdata(),
self.gradInput:cdata(),
self.weight:cdata(),
self.finput:cdata(),
self.fgradInput:cdata(),
self.kW, self.kH,
self.dW, self.dH,
self.padW, self.padH
)
unviewWeight(self)
return self.gradInput
end
end
function SpatialConvolution:accGradParameters(input, gradOutput, scale)
assert(input.THNN, torch.type(input)..'.THNN backend not imported')
scale = scale or 1
backCompatibility(self)
input, gradOutput = makeContiguous(self, input, gradOutput)
viewWeight(self)
input.THNN.SpatialConvolutionMM_accGradParameters(
input:cdata(),
gradOutput:cdata(),
self.gradWeight:cdata(),
THNN.optionalTensor(self.gradBias),
self.finput:cdata(),
self.fgradInput:cdata(),
self.kW, self.kH,
self.dW, self.dH,
self.padW, self.padH,
scale
)
unviewWeight(self)
end
function SpatialConvolution:type(type,tensorCache)
self.finput = self.finput and torch.Tensor()
self.fgradInput = self.fgradInput and torch.Tensor()
return parent.type(self,type,tensorCache)
end
function SpatialConvolution:__tostring__()
local s = string.format('%s(%d -> %d, %dx%d', torch.type(self),
self.nInputPlane, self.nOutputPlane, self.kW, self.kH)
if self.dW ~= 1 or self.dH ~= 1 or self.padW ~= 0 or self.padH ~= 0 then
s = s .. string.format(', %d,%d', self.dW, self.dH)
end
if (self.padW or self.padH) and (self.padW ~= 0 or self.padH ~= 0) then
s = s .. ', ' .. self.padW .. ',' .. self.padH
end
if self.bias then
return s .. ')'
else
return s .. ') without bias'
end
end
function SpatialConvolution:clearState()
nn.utils.clear(self, 'finput', 'fgradInput', '_input', '_gradOutput')
return parent.clearState(self)
end
| bsd-3-clause |
kequanJiang/skynet_start | mjlib/gui/one_gui_feng_table.lua | 2 | 4139 | return {[3200000]=true,[2]=true,[3000323]=true,[3030020]=true,[3030023]=true,[3000332]=true,[3020303]=true,[3030032]=true,[20]=true,[30230]=true,[23]=true,[2303000]=true,[30233]=true,[2303003]=true,[320030]=true,[32]=true,[3200033]=true,[20003]=true,[203300]=true,[203303]=true,[233000]=true,[3020330]=true,[233003]=true,[32300]=true,[32303]=true,[2303030]=true,[2003000]=true,[2003003]=true,[20030]=true,[20033]=true,[203330]=true,[233030]=true,[32330]=true,[330320]=true,[2003030]=true,[2003033]=true,[3303002]=true,[3230300]=true,[30302]=true,[303200]=true,[2300003]=true,[3303020]=true,[200303]=true,[3302000]=true,[3302003]=true,[3323000]=true,[3003002]=true,[30332]=true,[2300030]=true,[2000000]=true,[2300033]=true,[2000003]=true,[200330]=true,[3003020]=true,[200333]=true,[230030]=true,[3003023]=true,[3002000]=true,[230033]=true,[3002003]=true,[2033300]=true,[3330200]=true,[3023003]=true,[2000030]=true,[2000033]=true,[3300002]=true,[300200]=true,[300203]=true,[3002030]=true,[3002033]=true,[3300020]=true,[3023030]=true,[3300023]=true,[3030200]=true,[3030203]=true,[2330300]=true,[3320000]=true,[3000002]=true,[3320003]=true,[300230]=true,[200]=true,[300233]=true,[333002]=true,[203]=true,[3000020]=true,[3030230]=true,[3000023]=true,[303320]=true,[2030300]=true,[3320030]=true,[2030303]=true,[332000]=true,[3020003]=true,[3203300]=true,[230]=true,[3233000]=true,[233]=true,[33002]=true,[3032300]=true,[3320]=true,[2030330]=true,[203003]=true,[2300]=true,[3020030]=true,[2303]=true,[32000]=true,[3020033]=true,[32003]=true,[23300]=true,[23303]=true,[33032]=true,[300302]=true,[330002]=true,[203030]=true,[203033]=true,[2330]=true,[2333]=true,[32030]=true,[3303200]=true,[32033]=true,[23330]=true,[300323]=true,[330020]=true,[330023]=true,[320300]=true,[302]=true,[3200303]=true,[3030320]=true,[30002]=true,[3230003]=true,[200000]=true,[323]=true,[2303300]=true,[30023]=true,[2333000]=true,[3200330]=true,[332]=true,[3230030]=true,[20303]=true,[30032]=true,[233300]=true,[200030]=true,[200033]=true,[2003300]=true,[2003303]=true,[2033000]=true,[20330]=true,[3300203]=true,[20333]=true,[3332]=true,[3323]=true,[3233]=true,[30323]=true,[33023]=true,[3203000]=true,[33302]=true,[33203]=true,[33320]=true,[33230]=true,[300332]=true,[303032]=true,[303023]=true,[302033]=true,[303302]=true,[303203]=true,[302303]=true,[303230]=true,[302330]=true,[2003330]=true,[330032]=true,[3200003]=true,[320033]=true,[3300230]=true,[320303]=true,[3000200]=true,[330302]=true,[330203]=true,[3000203]=true,[2300300]=true,[320003]=true,[3020300]=true,[2300303]=true,[2330000]=true,[330230]=true,[320330]=true,[2330003]=true,[230330]=true,[332003]=true,[323003]=true,[3200030]=true,[332300]=true,[20000]=true,[303002]=true,[333020]=true,[230300]=true,[332030]=true,[323030]=true,[230303]=true,[3332000]=true,[333200]=true,[3200300]=true,[323300]=true,[3230000]=true,[3030302]=true,[3000230]=true,[33200]=true,[3003032]=true,[3000233]=true,[2300330]=true,[3203]=true,[303020]=true,[3003200]=true,[2330030]=true,[2000303]=true,[302000]=true,[3003302]=true,[200003]=true,[302003]=true,[30020]=true,[3003203]=true,[3300032]=true,[3003320]=true,[323000]=true,[20300]=true,[3002]=true,[3203003]=true,[3002300]=true,[3003230]=true,[300320]=true,[3002303]=true,[3032000]=true,[30320]=true,[300032]=true,[3032003]=true,[3023300]=true,[320000]=true,[230000]=true,[3033002]=true,[2300000]=true,[2033003]=true,[2000330]=true,[3033020]=true,[3020]=true,[2000333]=true,[2030030]=true,[3023]=true,[2000]=true,[2030033]=true,[3330002]=true,[2003]=true,[3300200]=true,[3230]=true,[3203030]=true,[200300]=true,[330200]=true,[2033030]=true,[3002330]=true,[23003]=true,[3033200]=true,[230003]=true,[3032030]=true,[3300302]=true,[3300320]=true,[3000032]=true,[300002]=true,[3200]=true,[3330020]=true,[3302030]=true,[3302300]=true,[33020]=true,[302030]=true,[3023000]=true,[3032]=true,[2000300]=true,[3320300]=true,[3302]=true,[3000302]=true,[2030000]=true,[203000]=true,[2033]=true,[3030002]=true,[2030003]=true,[300020]=true,[23000]=true,[23030]=true,[300023]=true,[30200]=true,[23033]=true,[320]=true,[30203]=true,[302300]=true,[3020000]=true,[2030]=true,[3000320]=true,} | mit |
kequanJiang/skynet_start | skynet/lualib/skynet/datasheet/init.lua | 11 | 1531 | local skynet = require "skynet"
local service = require "skynet.service"
local core = require "skynet.datasheet.core"
local datasheet_svr
skynet.init(function()
datasheet_svr = service.query "datasheet"
end)
local datasheet = {}
local sheets = setmetatable({}, {
__gc = function(t)
for _,v in pairs(t) do
skynet.send(datasheet_svr, "lua", "release", v.handle)
end
end,
})
local function querysheet(name)
return skynet.call(datasheet_svr, "lua", "query", name)
end
local function updateobject(name)
local t = sheets[name]
if not t.object then
t.object = core.new(t.handle)
end
local function monitor()
local handle = t.handle
local newhandle = skynet.call(datasheet_svr, "lua", "monitor", handle)
core.update(t.object, newhandle)
t.handle = newhandle
skynet.send(datasheet_svr, "lua", "release", handle)
return monitor()
end
skynet.fork(monitor)
end
function datasheet.query(name)
local t = sheets[name]
if not t then
t = {}
sheets[name] = t
end
if t.error then
error(t.error)
end
if t.object then
return t.object
end
if t.queue then
local co = coroutine.running()
table.insert(t.queue, co)
skynet.wait(co)
else
t.queue = {} -- create wait queue for other query
local ok, handle = pcall(querysheet, name)
if ok then
t.handle = handle
updateobject(name)
else
t.error = handle
end
local q = t.queue
t.queue = nil
for _, co in ipairs(q) do
skynet.wakeup(co)
end
end
if t.error then
error(t.error)
end
return t.object
end
return datasheet
| mit |
retep998/Vana | scripts/npcs/contimoveEreOrb.lua | 2 | 2205 | --[[
Copyright (C) 2008-2016 Vana Development 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; version 2
of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
--]]
-- Kiru
dofile("scripts/utils/mapManagerHelper.lua");
dofile("scripts/utils/npcHelper.lua");
price = nil;
if getLevel() < 30 then
price = 100;
else
price = 1000;
end
addText("Hmm... ");
addText("The winds are favorable. ");
addText("Are you thinking of leaving " .. mapRef(130000000) .. " and going somewhere else? ");
addText("This ferry sails to Orbis on the Ossyria Continent. ");
sendNext();
if getLevel() < 30 then
addText("Wait, why are you going to Ossyria whenyou're not even Lv. 30? ");
addText("Do you know how tough the monsters in Orbis are?! ");
addText("Going there at your level is very dangerous. ");
addText("Do you still want to go?");
sendBackNext();
end
addText("Have you taken care of everything you needed to in " .. mapRef(130000000) .. "? ");
addText("If you happen to be headed toward " .. blue(mapRef(200000000)) .. " I can take you there. ");
addText("What do you say? ");
addText("Are you going to go to " .. mapRef(200000000) .. "?\r\n\r\n");
addText("You'll have to pay a fee of " .. blue(price) .. " Mesos.");
answer = askYesNo();
if answer == answer_no then
addText("If not, forget it.");
sendNext();
else
mapId = queryManagedMap("ereveToOrbisTrip");
if mapId == nil then
addText("There are no more boats available right now. ");
addText("Try again later.");
sendNext();
elseif giveMesos(-price) then
setMap(mapId);
else
addText("Hey you don't have enough Mesos with you... the ride will cost you " .. blue(price) .. " Mesos.");
sendNext();
end
end | gpl-2.0 |
dr01d3r/darkstar | scripts/zones/Northern_San_dOria/npcs/Ishwar.lua | 14 | 1035 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Ishwar
-- Type: Standard Dialogue NPC
-- @zone 231
-- @pos -47.103 -1.999 -19.582
--
-----------------------------------
package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil;
require("scripts/zones/Northern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,ISHWAR_DIALOG);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/globals/items/bowl_of_emerald_soup.lua | 12 | 1386 | -----------------------------------------
-- ID: 4327
-- Item: Bowl of Emerald Soup
-- Food Effect: 240Min, All Races
-----------------------------------------
-- Agility 2
-- Vitality -1
-- Health Regen While Healing 3
-- Ranged ACC 6
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,14400,4327);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_AGI, 2);
target:addMod(MOD_VIT, -1);
target:addMod(MOD_HPHEAL, 3);
target:addMod(MOD_RACC, 6);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_AGI, 2);
target:delMod(MOD_VIT, -1);
target:delMod(MOD_HPHEAL, 3);
target:delMod(MOD_RACC, 6);
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Gustav_Tunnel/MobIDs.lua | 28 | 1592 | -----------------------------------
-- Area: Gustav Tunnel (212)
-- Comments: -- posX, posY, posZ
-- (Taken from 'mob_spawn_points' table)
-----------------------------------
Goblinsavior_Heronox = 17645609;
Goblinsavior_Heronox_PH =
{
[17645592] = '1', -- 153.000, -10.000, -53.000
[17645605] = '1', -- 152.325, -10.702, -77.007
[17645604] = '1', -- 165.558, -10.647, -68.537
};
-- Wyvernpoacher Drachlox
Wyvernpoacher_Drachlox = 17645640;
Wyvernpoacher_Drachlox_PH =
{
[17645633] = '1', -- -100.000, 1.000, -44.000
[17645634] = '1', -- -101.000, 1.000, -29.000
[17645644] = '1', -- -165.598, 0.218, -21.966
[17645643] = '1', -- -150.673, -0.067, -20.914
};
-- Baobhan Sith
Baobhan_Sith = 17645719;
Baobhan_Sith_PH =
{
[17645717] = '1', -- 171.000, 9.194, 55.000
[17645718] = '1', -- 187.000, 9.000, 105.000
};
-- Taxim
Taxim = 17645742;
Taxim_PH =
{
[17645731] = '1', -- -172.941, -1.220, 55.577
[17645738] = '1', -- -137.334, -0.108, 48.105
[17645744] = '1', -- -125.000, 0.635, 59.000
[17645739] = '1', -- -118.000, -0.515, 79.000
};
-- Ungur
Ungur = 17645755;
Ungur_PH =
{
[17645764] = '1', -- -242.000, -0.577, 120.000
[17645792] = '1', -- -88.000, 0.735, 190.000
[17645784] = '1', -- -123.856, 0.239, 223.303
[17645758] = '1', -- -277.000, -10.000, -34.000
[17645754] = '1', -- -316.000, -9.000, 3.000
};
-- Amikiri
Amikiri = 17645774;
Amikiri_PH =
{
[17645763] = '1', -- -245.000, -0.045, 146.000
[17645768] = '1', -- -228.872, -0.264, 144.689
[17645772] = '1', -- -209.552, -0.257, 161.728
};
| gpl-3.0 |
dwmw2/domoticz | dzVents/runtime/integration-tests/scriptDelayedVariableScene.lua | 10 | 1595 | local testLastUpdate = function(dz, trigger, expectedDifference)
local now = dz.time.secondsSinceMidnight
local lastUpdate = trigger.lastUpdate.secondsSinceMidnight
local diff = (now - lastUpdate)
print('current: ' .. now .. ', lastUpdate: ' .. lastUpdate .. ', diff: ' .. diff .. ', expected: ' .. expectedDifference)
if math.abs( diff - expectedDifference) > 1 then
print('Difference is: ' .. tostring(diff) .. ', expected to be: ' .. tostring(expectedDifference))
return false
end
print('lastUpdate is as expected')
return true
end
return {
active = true,
on = {
devices = {
'vdScriptStart',
'vdScriptEnd',
},
variables = { 'var' },
scenes = { 'scScene' }
},
data = {
varOk = {initial = false},
sceneOk = {initial = false}
},
execute = function(dz, item)
local var = dz.variables('var')
local scene = dz.scenes('scScene')
if (item.name == 'vdScriptStart') then
if (not testLastUpdate(dz, var, 2)) then
-- oops
return
end
if (not testLastUpdate(dz, scene, 2)) then
-- oops
return
end
var.set('Zork is a dork').afterSec(2)
scene.switchOn().afterSec(3)
dz.devices('vdScriptEnd').switchOn().afterSec(4)
end
if (item.name == 'vdScriptEnd') then
if (dz.data.varOk and dz.data.sceneOk) then
dz.devices('vdScriptOK').switchOn()
end
end
if (item.isVariable) then
local res = testLastUpdate(dz, item, 4)
if (res) then
dz.data.varOk = true
end
end
if (item.isScene) then
local res = testLastUpdate(dz, item, 5)
if (res) then
dz.data.sceneOk = true
end
end
end
}
| gpl-3.0 |
finnw/grodlob | winapi/cairopanel.lua | 1 | 2610 | --cairopanel: provides on_render(surface) event to draw on a cairo pixman surface.
local ffi = require'ffi'
local bit = require'bit'
local winapi = require'winapi'
require'winapi.panelclass'
local cairo = require'cairo'
require'cairo_win32'
local CairoPanel = winapi.class(winapi.Panel)
function CairoPanel:__before_create(info, args)
info.own_dc = true --very important, because we reuse the hdc between WM_PAINTs
CairoPanel.__index.__before_create(self, info, args)
end
function CairoPanel:__init(...)
CairoPanel.__index.__init(self,...)
self:invalidate()
end
function CairoPanel:__create_surface(surface) end --stub
function CairoPanel:__destroy_surface(surface) end --stub
function CairoPanel:on_render(surface) end --stub
function CairoPanel:__free_buffers()
if not self.__pixman_surface then return end
self.__window_cr = self.__window_cr:free()
self.__window_surface = self.__window_surface:free()
self:__destroy_surface(self.__pixman_surface)
self.__pixman_surface = self.__pixman_surface:free()
end
function CairoPanel:on_destroy()
self:__free_buffers()
end
function CairoPanel:WM_ERASEBKGND()
return false --we draw our own background
end
function CairoPanel:on_resized()
self:__free_buffers()
self:invalidate()
end
function CairoPanel:on_paint(window_hdc)
local w, h = self.client_w, self.client_h
if not self.__pixman_surface then
self.__window_surface = cairo.cairo_win32_surface_create(window_hdc)
self.__window_cr = self.__window_surface:create_context()
self.__pixman_surface = cairo.cairo_image_surface_create(cairo.CAIRO_FORMAT_RGB24, w, h)
self:__create_surface(self.__pixman_surface)
--this way, we avoid a copy from the pixman surface to the window surface
self.__window_cr:set_source_surface(self.__pixman_surface, 0, 0)
end
self:on_render(self.__pixman_surface)
self.__window_cr:paint()
end
return CairoPanel
--[[
--from cairo-win32-display-surface.c
local function get_bits(hdc, width, height)
local bitmap_info = ffi.new'BITMAPINFO'
bitmap_info.bmiHeader.biSize = ffi.sizeof'BITMAPINFOHEADER'
bitmap_info.bmiHeader.biWidth = width
bitmap_info.bmiHeader.biHeight = -height --top-down
bitmap_info.bmiHeader.biPlanes = 1
bitmap_info.bmiHeader.biBitCount = 32
bitmap_info.bmiHeader.biCompression = BI_RGB
local dc = CreateCompatibleDC(hdc)
local bmp, bits = CreateDIBSection(dc, bitmap_info, DIB_RGB_COLORS)
GdiFlush()
local last_bmp = SelectObject(dc, bmp)
--TODO: now use cairo_image_surface_create_for_data(bits)
--TODO: save and free these on __free_buffers()
SelectObject(dc, last_bmp)
DeleteObject(bmp)
DeleteDC(dc)
end
]]
| mit |
SalvationDevelopment/Salvation-Scripts-Production | c15767889.lua | 9 | 1362 | --騎士デイ・グレファー
function c15767889.initial_effect(c)
aux.EnableDualAttribute(c)
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(15767889,0))
e1:SetCategory(CATEGORY_TOHAND)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_PHASE+PHASE_END)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1,15767889)
e1:SetCondition(c15767889.thcon)
e1:SetTarget(c15767889.thtg)
e1:SetOperation(c15767889.thop)
c:RegisterEffect(e1)
end
function c15767889.thcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsDualState() and Duel.GetTurnPlayer()==tp
end
function c15767889.filter(c)
return c:IsType(TYPE_EQUIP) and c:IsAbleToHand()
end
function c15767889.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c15767889.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c15767889.filter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local g=Duel.SelectTarget(tp,c15767889.filter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function c15767889.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 |
AutoJames/KkthnxUI_Legion | KkthnxUI/Modules/DataText/Elements/Friends.lua | 1 | 17758 | local K, C, L = select(2, ...):unpack()
local format = format
local BNSetCustomMessage = BNSetCustomMessage
local IsChatAFK = IsChatAFK
local IsChatDND = IsChatDND
local SendChatMessage = SendChatMessage
local levelNameString = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r"
local clientLevelNameString = "%s (|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r%s) |cff%02x%02x%02x%s|r"
local levelNameClassString = "|cff%02x%02x%02x%d|r %s%s%s"
local worldOfWarcraftString = "World of Warcraft"
local battleNetString = "Battle.NET"
local wowString = "WoW"
local totalOnlineString = "Online: " .. "%s/%s"
local tthead, ttsubh, ttoff = {r=0.4, g=0.78, b=1}, {r=0.75, g=0.9, b=1}, {r=.3,g=1,b=.3}
local activezone, inactivezone = {r=0.3, g=1.0, b=0.3}, {r=0.65, g=0.65, b=0.65}
local statusTable = {"|cffff0000[AFK]|r", "|cffff0000[DND]|r", ""}
local groupedTable = {"|cffaaaaaa*|r", ""}
local friendTable, BNTable = {}, {}
local totalOnline, BNTotalOnline = 0, 0
local BNGetGameAccountInfo = BNGetGameAccountInfo
local GetFriendInfo = GetFriendInfo
local BNGetFriendInfo = BNGetFriendInfo
StaticPopupDialogs["BROADCAST"] = {
text = BN_BROADCAST_TOOLTIP,
button1 = ACCEPT,
button2 = CANCEL,
OnAccept = InstallUI,
OnCancel = function(self) BNSetCustomMessage(self.editBox:GetText()) end,
timeout = 0,
showAlert = 1,
whileDead = 1,
hideOnEscape = false,
preferredIndex = 3
}
local DataText = K.DataTexts
local NameColor = DataText.NameColor
local ValueColor = DataText.ValueColor
local menuFrame = CreateFrame("Frame", "KkthnxUIFriendRightClickMenu", UIParent, "UIDropDownMenuTemplate")
local menuList = {
{text = OPTIONS_MENU, isTitle = true, notCheckable=true},
{text = INVITE, hasArrow = true, notCheckable=true,},
{text = CHAT_MSG_WHISPER_INFORM, hasArrow = true, notCheckable=true,},
{text = PLAYER_STATUS, hasArrow = true, notCheckable=true,
menuList = {
{text = "|cff2BC226"..AVAILABLE.."|r", notCheckable=true, func = function()
if IsChatAFK() then
SendChatMessage("", "AFK")
elseif IsChatDND() then
SendChatMessage("", "DND")
end
end},
{text = "|cffE7E716"..DND.."|r", notCheckable=true, func = function()
if not IsChatDND() then
SendChatMessage("", "DND")
end
end},
{text = "|cffFF0000"..AFK.."|r", notCheckable=true, func = function()
if not IsChatAFK() then
SendChatMessage("", "AFK")
end
end},
},
},
{text = BN_BROADCAST_TOOLTIP, notCheckable=true, func = function()
StaticPopup_Show("BROADCAST")
end},
}
local function GetTableIndex(table, fieldIndex, value)
for k, v in ipairs(table) do
if v[fieldIndex] == value then
return k
end
end
return -1
end
local function RemoveTagNumber(tag)
local symbol = string.find(tag, "#")
if (symbol) then
return string.sub(tag, 1, symbol - 1)
else
return tag
end
end
local function inviteClick(self, arg1, arg2, checked)
menuFrame:Hide()
if type(arg1) ~= ("number") then
InviteUnit(arg1)
else
BNInviteFriend(arg1);
end
end
local function whisperClick(self, name, bnet)
menuFrame:Hide()
if bnet then
ChatFrame_SendSmartTell(name)
else
SetItemRef("player:"..name, ("|Hplayer:%1$s|h[%1$s]|h"):format(name), "LeftButton")
end
end
local function BuildFriendTable(total)
totalOnline = 0
wipe(friendTable)
local name, level, class, area, connected, status, note
for i = 1, total do
name, level, class, area, connected, status, note = GetFriendInfo(i)
for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do
if class == v then
class = k
end
end
if status == "<"..AFK..">" then
status = "|cffff0000[AFK]|r"
elseif status == "<"..DND..">" then
status = "|cffff0000[DND]|r"
end
friendTable[i] = {name, level, class, area, connected, status, note}
if connected then
totalOnline = totalOnline + 1
end
end
end
local function UpdateFriendTable(total)
totalOnline = 0
local name, level, class, area, connected, status, note
for i = 1, #friendTable do
name, level, class, area, connected, status, note = GetFriendInfo(i)
for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do
if class == v then
class = k
end
end
-- get the correct index in our table
local index = GetTableIndex(friendTable, 1, name)
-- we cannot find a friend in our table, so rebuild it
if index == -1 then
BuildFriendTable(total)
break
end
-- update on-line status for all members
friendTable[index][5] = connected
-- update information only for on-line members
if connected then
friendTable[index][2] = level
friendTable[index][3] = class
friendTable[index][4] = area
friendTable[index][6] = status
friendTable[index][7] = note
totalOnline = totalOnline + 1
end
end
end
local function BuildBNTable(total)
BNTotalOnline = 0
wipe(BNTable)
for i = 1, total do
local presenceID, presenceName, battleTag, isBattleTagPresence, toonName, toonID, client, isOnline, lastOnline, isAFK, isDND, messageText, noteText, isRIDFriend, messageTime, canSoR = BNGetFriendInfo(i)
local hasFocus, _, _, realmName, realmID, faction, race, class, guild, zoneName, level, gameText = BNGetGameAccountInfo(toonID or presenceID)
for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do
if class == v then
class = k
end
end
BNTable[i] = {presenceID, presenceName, battleTag, toonName, toonID, client, isOnline, isAFK, isDND, noteText, realmName, faction, race, class, zoneName, level}
if isOnline then
BNTotalOnline = BNTotalOnline + 1
end
end
end
local function UpdateBNTable(total)
BNTotalOnline = 0
for i = 1, #BNTable do
-- get guild roster information
local presenceID, presenceName, battleTag, isBattleTagPresence, toonName, toonID, client, isOnline, lastOnline, isAFK, isDND, messageText, noteText, isRIDFriend, messageTime, canSoR = BNGetFriendInfo(i)
local hasFocus, _, _, realmName, realmID, faction, race, class, guild, zoneName, level, gameText = BNGetGameAccountInfo(toonID or presenceID)
for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do
if class == v then
class = k
end
end
-- get the correct index in our table
local index = GetTableIndex(BNTable, 1, presenceID)
-- we cannot find a BN member in our table, so rebuild it
if index == -1 then
BuildBNTable(total)
return
end
-- update on-line status for all members
BNTable[index][7] = isOnline
-- update information only for on-line members
if isOnline then
BNTable[index][2] = presenceName
BNTable[index][3] = RemoveTagNumber(battleTag)
BNTable[index][4] = toonName
BNTable[index][5] = toonID
BNTable[index][6] = client
BNTable[index][8] = isAFK
BNTable[index][9] = isDND
BNTable[index][10] = noteText
BNTable[index][11] = realmName
BNTable[index][12] = faction
BNTable[index][13] = race
BNTable[index][14] = class
BNTable[index][15] = zoneName
BNTable[index][16] = level
BNTable[index][17] = isBattleTagPresence
BNTotalOnline = BNTotalOnline + 1
end
end
end
local OnMouseUp = function(self, btn)
if btn ~= "RightButton" then
return
end
GameTooltip:Hide()
local menuCountWhispers = 0
local menuCountInvites = 0
local classc, levelc
menuList[2].menuList = {}
menuList[3].menuList = {}
if totalOnline > 0 then
for i = 1, #friendTable do
if (friendTable[i][5]) then
menuCountInvites = menuCountInvites + 1
menuCountWhispers = menuCountWhispers + 1
classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[friendTable[i][3]], GetQuestDifficultyColor(friendTable[i][2])
if classc == nil then
classc = GetQuestDifficultyColor(friendTable[i][2])
end
menuList[2].menuList[menuCountInvites] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,friendTable[i][2],classc.r*255,classc.g*255,classc.b*255,friendTable[i][1]), arg1 = friendTable[i][1],notCheckable=true, func = inviteClick}
menuList[3].menuList[menuCountWhispers] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,friendTable[i][2],classc.r*255,classc.g*255,classc.b*255,friendTable[i][1]), arg1 = friendTable[i][1],notCheckable=true, func = whisperClick}
end
end
end
if BNTotalOnline > 0 then
local realID, grouped
for i = 1, #BNTable do
if (BNTable[i][7]) then
realID = BNTable[i][2]
menuCountWhispers = menuCountWhispers + 1
menuList[3].menuList[menuCountWhispers] = {text = realID, arg1 = realID, arg2 = true, notCheckable=true, func = whisperClick}
if BNTable[i][6] == wowString and UnitFactionGroup("player") == BNTable[i][12] then
classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[BNTable[i][14]], GetQuestDifficultyColor(BNTable[i][16])
if classc == nil then
classc = GetQuestDifficultyColor(BNTable[i][16])
end
if UnitInParty(BNTable[i][4]) or UnitInRaid(BNTable[i][4]) then
grouped = 1
else
grouped = 2
end
menuCountInvites = menuCountInvites + 1
menuList[2].menuList[menuCountInvites] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,BNTable[i][16],classc.r*255,classc.g*255,classc.b*255,BNTable[i][4]), arg1 = BNTable[i][5],notCheckable=true, func = inviteClick}
end
end
end
end
Lib_EasyMenu(menuList, menuFrame, "cursor", 0, 0, "MENU", 2)
end
local OnMouseDown = function(self, btn)
if btn == "LeftButton" then
ToggleFriendsFrame()
end
end
local OnLeave = function()
GameTooltip:Hide()
end
local OnEnter = function(self)
if InCombatLockdown() then
return
end
local totalonline = totalOnline + BNTotalOnline
local totalfriends = #friendTable + #BNTable
local zonec, classc, levelc, realmc, grouped
local onWoW, onHS, onD3, onHotS, onOW, onClient, onS2 = 0, 0, 0, 0, 0, 0, 0
if (totalonline > 0) then
GameTooltip:SetOwner(self:GetTooltipAnchor())
GameTooltip:ClearLines()
GameTooltip:AddDoubleLine(FRIENDS_LIST, format(totalOnlineString, totalonline, totalfriends),tthead.r,tthead.g,tthead.b,tthead.r,tthead.g,tthead.b)
if totalOnline > 0 then
GameTooltip:AddLine(" ")
for i = 1, #friendTable do
if friendTable[i][5] then
if GetRealZoneText() == friendTable[i][4] then
zonec = activezone
else
zonec = inactivezone
end
classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[friendTable[i][3]], GetQuestDifficultyColor(friendTable[i][2])
if classc == nil then
classc = GetQuestDifficultyColor(friendTable[i][2])
end
if UnitInParty(friendTable[i][1]) or UnitInRaid(friendTable[i][1]) then
grouped = 1
else
grouped = 2
end
GameTooltip:AddDoubleLine(format(levelNameClassString,levelc.r*255,levelc.g*255,levelc.b*255,friendTable[i][2],friendTable[i][1],groupedTable[grouped]," "..friendTable[i][6]),friendTable[i][4],classc.r,classc.g,classc.b,zonec.r,zonec.g,zonec.b)
end
end
end
if BNTotalOnline > 0 then
GameTooltip:AddLine(" ")
--GameTooltip:AddLine("[".. BATTLETAG .."]------------------------ ".. battleNetString .." ------------------------[".. NAME .."]")
local status = 0
for i = 1, #BNTable do
if BNTable[i][7] then
if BNTable[i][6] == wowString then
onWoW = onWoW + 1
local Client = "World of Warcraft"
local isBattleTag = BNTable[i][17]
if onWoW == 1 then
GameTooltip:AddLine(" ")
GameTooltip:AddLine(Client)
end
if (BNTable[i][8] == true) then
status = 1
elseif (BNTable[i][9] == true) then
status = 2
else
status = 3
end
classc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[BNTable[i][14]]
levelc = GetQuestDifficultyColor(BNTable[i][16])
if not classc then
classc = {r=1, g=1, b=1}
end
if UnitInParty(BNTable[i][4]) or UnitInRaid(BNTable[i][4]) then
grouped = 1
else
grouped = 2
end
GameTooltip:AddDoubleLine(format(clientLevelNameString, BNTable[i][3],levelc.r*255,levelc.g*255,levelc.b*255,BNTable[i][16],classc.r*255,classc.g*255,classc.b*255,BNTable[i][4],groupedTable[grouped], 255, 0, 0, statusTable[status]),isBattleTag == false and BNTable[i][2],238,238,238,238,238,238)
if IsShiftKeyDown() then
if GetRealZoneText() == BNTable[i][15] then
zonec = activezone
else
zonec = inactivezone
end
if GetRealmName() == BNTable[i][11] then
realmc = activezone
else
realmc = inactivezone
end
GameTooltip:AddDoubleLine(" "..BNTable[i][15], BNTable[i][11], zonec.r, zonec.g, zonec.b, realmc.r, realmc.g, realmc.b)
end
end
end
end
for i = 1, #BNTable do
if BNTable[i][7] then
if BNTable[i][6] == "WTCG" then
onHS = onHS + 1
local Client = "Hearthstone"
local isBattleTag = BNTable[i][17]
if onHS == 1 then
GameTooltip:AddDoubleLine(" ", " ")
GameTooltip:AddDoubleLine("|cffD49E43"..Client.."|r", "")
end
GameTooltip:AddDoubleLine("|cffeeeeee"..BNTable[i][3].."|r", isBattleTag == false and BNTable[i][2],238,238,238,238,238,238)
end
end
end
for i = 1, #BNTable do
if BNTable[i][7] then
if BNTable[i][6] == "D3" then
onD3 = onD3 + 1
local Client = "Diablo III"
local isBattleTag = BNTable[i][17]
if onD3 == 1 then
GameTooltip:AddDoubleLine(" ", " ")
GameTooltip:AddDoubleLine("|cffCC2200"..Client.."|r", "")
end
GameTooltip:AddDoubleLine("|cffeeeeee"..BNTable[i][3].."|r", isBattleTag == false and BNTable[i][2],238,238,238,238,238,238)
end
end
end
for i = 1, #BNTable do
if BNTable[i][7] then
if BNTable[i][6] == "Hero" then
onHotS = onHotS + 1
local Client = "Heroes of the Storm"
local isBattleTag = BNTable[i][17]
if onHotS == 1 then
GameTooltip:AddDoubleLine(" ", " ")
GameTooltip:AddDoubleLine("|cffACE5EE"..Client.."|r", "")
end
GameTooltip:AddDoubleLine("|cffeeeeee"..BNTable[i][3].."|r", isBattleTag == false and BNTable[i][2],238,238,238,238,238,238)
end
end
end
for i = 1, #BNTable do
if BNTable[i][7] then
if BNTable[i][6] == "S2" then
onS2 = onS2 + 1
local Client = "Starcraft II"
local isBattleTag = BNTable[i][17]
if onS2 == 1 then
GameTooltip:AddDoubleLine(" ", " ")
GameTooltip:AddDoubleLine("|cffACE5EE".. Client .."|r", "")
end
GameTooltip:AddDoubleLine("|cffeeeeee"..BNTable[i][3].."|r", isBattleTag == false and BNTable[i][2],238,238,238,238,238,238)
end
end
end
for i = 1, #BNTable do
if BNTable[i][7] then
if BNTable[i][6] == "Pro" then
onOW = onOW + 1
local Client = "Overwatch"
local isBattleTag = BNTable[i][17]
if onOW == 1 then
GameTooltip:AddDoubleLine(" ", " ")
GameTooltip:AddDoubleLine("|cffACE5EE".. Client .."|r", "")
end
GameTooltip:AddDoubleLine("|cffeeeeee"..BNTable[i][3].."|r", isBattleTag == false and BNTable[i][2],238,238,238,238,238,238)
end
end
end
for i = 1, #BNTable do
if BNTable[i][7] then
if BNTable[i][6] == "App" then
onClient = onClient + 1
local Client = "Battle.NET Client"
local isBattleTag = BNTable[i][17]
if onClient == 1 then
GameTooltip:AddDoubleLine(" ", " ")
GameTooltip:AddDoubleLine("|cff00B4FF".. Client .."|r", "")
end
GameTooltip:AddDoubleLine("|cffeeeeee"..BNTable[i][3].."|r", isBattleTag == false and BNTable[i][2],238,238,238,238,238,238)
end
end
end
end
GameTooltip:Show()
else
GameTooltip:Hide()
end
end
local OnEvent = function(self, event)
local BNTotal = BNGetNumFriends()
local Total = GetNumFriends()
if BNTotal == #BNTable then
UpdateBNTable(BNTotal)
else
BuildBNTable(BNTotal)
end
if Total == #friendTable then
UpdateFriendTable(Total)
else
BuildFriendTable(Total)
end
self.Text:SetFormattedText("%s: %s%s", NameColor .. FRIENDS .. "|r", ValueColor, totalOnline + BNTotalOnline)
end
local Enable = function(self)
if(not self.Text) then
local Text = self:CreateFontString(nil, "OVERLAY")
Text:SetFont(DataText.Font, DataText.Size, DataText.Flags)
self.Text = Text
end
self:RegisterEvent("BN_FRIEND_ACCOUNT_ONLINE")
self:RegisterEvent("BN_FRIEND_ACCOUNT_OFFLINE")
self:RegisterEvent("BN_FRIEND_TOON_ONLINE")
self:RegisterEvent("BN_FRIEND_TOON_OFFLINE")
self:RegisterEvent("BN_TOON_NAME_UPDATED")
self:RegisterEvent("FRIENDLIST_UPDATE")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("FRIENDLIST_SHOW")
self:RegisterEvent("IGNORELIST_UPDATE")
self:RegisterEvent("MUTELIST_UPDATE")
self:RegisterEvent("PLAYER_FLAGS_CHANGED")
self:RegisterEvent("BN_FRIEND_LIST_SIZE_CHANGED")
self:RegisterEvent("BN_FRIEND_INFO_CHANGED")
self:RegisterEvent("BN_FRIEND_INVITE_LIST_INITIALIZED")
self:RegisterEvent("BN_FRIEND_INVITE_ADDED")
self:RegisterEvent("BN_FRIEND_INVITE_REMOVED")
self:RegisterEvent("BN_SELF_ONLINE")
self:RegisterEvent("BN_BLOCK_LIST_UPDATED")
self:RegisterEvent("BN_CONNECTED")
self:RegisterEvent("BN_DISCONNECTED")
self:RegisterEvent("BN_INFO_CHANGED")
self:RegisterEvent("BATTLETAG_INVITE_SHOW")
self:RegisterEvent("PARTY_REFER_A_FRIEND_UPDATED")
self:SetScript("OnMouseDown", OnMouseDown)
self:SetScript("OnMouseUp", OnMouseUp)
self:SetScript("OnEnter", OnEnter)
self:SetScript("OnLeave", GameTooltip_Hide)
self:SetScript("OnEvent", OnEvent)
self:Update()
end
local Disable = function(self)
self.Text:SetText("")
self:UnregisterAllEvents()
self:SetScript("OnMouseDown", nil)
self:SetScript("OnMouseUp", nil)
self:SetScript("OnEnter", nil)
self:SetScript("OnLeave", nil)
self:SetScript("OnEvent", nil)
end
DataText:Register(FRIENDS, Enable, Disable, OnEvent) | mit |
SalvationDevelopment/Salvation-Scripts-Production | c24903843.lua | 2 | 2698 | --バージェストマ・ピカイア
function c24903843.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_DRAW)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(c24903843.target)
e1:SetOperation(c24903843.activate)
c:RegisterEffect(e1)
--spsummon
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetCode(EVENT_CHAINING)
e2:SetRange(LOCATION_GRAVE)
e2:SetCondition(c24903843.spcon)
e2:SetTarget(c24903843.sptg)
e2:SetOperation(c24903843.spop)
c:RegisterEffect(e2)
end
function c24903843.filter(c)
return c:IsSetCard(0xd4) and c:IsDiscardable(REASON_EFFECT)
end
function c24903843.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsPlayerCanDraw(tp,2)
and Duel.IsExistingMatchingCard(c24903843.filter,tp,LOCATION_HAND,0,1,e:GetHandler()) end
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,2)
end
function c24903843.activate(e,tp,eg,ep,ev,re,r,rp)
if Duel.DiscardHand(tp,c24903843.filter,1,1,REASON_EFFECT+REASON_DISCARD,nil)~=0 then
Duel.BreakEffect()
Duel.Draw(tp,2,REASON_EFFECT)
end
end
function c24903843.spcon(e,tp,eg,ep,ev,re,r,rp)
return re:IsActiveType(TYPE_TRAP) and re:IsHasType(EFFECT_TYPE_ACTIVATE)
end
function c24903843.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:GetFlagEffect(24903843)==0 and Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsPlayerCanSpecialSummonMonster(tp,24903843,0xd4,0x11,1200,0,2,RACE_AQUA,ATTRIBUTE_WATER) end
c:RegisterFlagEffect(24903843,RESET_CHAIN,0,1)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,0)
end
function c24903843.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
local c=e:GetHandler()
if c:IsRelateToEffect(e) and Duel.IsPlayerCanSpecialSummonMonster(tp,24903843,0xd4,0x11,1200,0,2,RACE_AQUA,ATTRIBUTE_WATER) then
c:AddMonsterAttribute(TYPE_NORMAL)
Duel.SpecialSummonStep(c,0,tp,tp,true,false,POS_FACEUP)
c:AddMonsterAttributeComplete()
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_IMMUNE_EFFECT)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetRange(LOCATION_MZONE)
e2:SetValue(c24903843.efilter)
e2:SetReset(RESET_EVENT+0x1fe0000)
c:RegisterEffect(e2,true)
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e3:SetReset(RESET_EVENT+0x47e0000)
e3:SetValue(LOCATION_REMOVED)
c:RegisterEffect(e3,true)
Duel.SpecialSummonComplete()
end
end
function c24903843.efilter(e,re)
return re:IsActiveType(TYPE_MONSTER)
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c86238081.lua | 2 | 4790 | --覇王烈竜オッドアイズ・レイジング・ドラゴン
function c86238081.initial_effect(c)
--xyz summon
aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsRace,RACE_DRAGON),7,2)
c:EnableReviveLimit()
--pendulum summon
aux.EnablePendulumAttribute(c,false)
--pendulum set
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(86238081,0))
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_PZONE)
e1:SetCountLimit(1)
e1:SetTarget(c86238081.pctg)
e1:SetOperation(c86238081.pcop)
c:RegisterEffect(e1)
--summon success
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
e2:SetCondition(c86238081.regcon)
e2:SetOperation(c86238081.regop)
c:RegisterEffect(e2)
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_MATERIAL_CHECK)
e3:SetValue(c86238081.valcheck)
e3:SetLabelObject(e2)
c:RegisterEffect(e3)
--extra attack
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetCode(EFFECT_EXTRA_ATTACK)
e4:SetValue(1)
e4:SetCondition(c86238081.effcon)
c:RegisterEffect(e4)
--destroy
local e5=Effect.CreateEffect(c)
e5:SetDescription(aux.Stringid(86238081,1))
e5:SetCategory(CATEGORY_DESTROY)
e5:SetType(EFFECT_TYPE_IGNITION)
e5:SetRange(LOCATION_MZONE)
e5:SetCountLimit(1)
e5:SetCondition(c86238081.effcon)
e5:SetCost(c86238081.descost)
e5:SetTarget(c86238081.destg)
e5:SetOperation(c86238081.desop)
c:RegisterEffect(e5)
--pendulum
local e6=Effect.CreateEffect(c)
e6:SetDescription(aux.Stringid(86238081,2))
e6:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e6:SetCode(EVENT_DESTROYED)
e6:SetProperty(EFFECT_FLAG_DELAY)
e6:SetCondition(c86238081.pencon)
e6:SetTarget(c86238081.pentg)
e6:SetOperation(c86238081.penop)
c:RegisterEffect(e6)
end
c86238081.pendulum_level=7
function c86238081.pcfilter(c)
return c:IsType(TYPE_PENDULUM) and not c:IsForbidden()
end
function c86238081.pctg(e,tp,eg,ep,ev,re,r,rp,chk)
local seq=e:GetHandler():GetSequence()
if chk==0 then return Duel.CheckLocation(tp,LOCATION_SZONE,13-seq)
and Duel.IsExistingMatchingCard(c86238081.pcfilter,tp,LOCATION_DECK,0,1,nil) end
end
function c86238081.pcop(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
local seq=e:GetHandler():GetSequence()
if not Duel.CheckLocation(tp,LOCATION_SZONE,13-seq) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD)
local g=Duel.SelectMatchingCard(tp,c86238081.pcfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
Duel.MoveToField(g:GetFirst(),tp,tp,LOCATION_SZONE,POS_FACEUP,true)
end
end
function c86238081.regcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():GetSummonType()==SUMMON_TYPE_XYZ and e:GetLabel()==1
end
function c86238081.regop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
c:RegisterFlagEffect(86238081,RESET_EVENT+0x1fe0000,0,1)
c:RegisterFlagEffect(0,RESET_EVENT+0x1fe0000,EFFECT_FLAG_CLIENT_HINT,1,0,aux.Stringid(86238081,3))
end
function c86238081.effcon(e)
return e:GetHandler():GetFlagEffect(86238081)>0
end
function c86238081.descost(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 c86238081.destg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetFieldGroupCount(tp,0,LOCATION_ONFIELD)>0 end
local sg=Duel.GetFieldGroup(tp,0,LOCATION_ONFIELD)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,sg,sg:GetCount(),0,0)
end
function c86238081.desop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local sg=Duel.GetFieldGroup(tp,0,LOCATION_ONFIELD)
local ct=Duel.Destroy(sg,REASON_EFFECT)
if ct>0 and c:IsFaceup() and c:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(ct*200)
e1:SetReset(RESET_EVENT+0x1ff0000+RESET_PHASE+PHASE_END)
c:RegisterEffect(e1)
end
end
function c86238081.valcheck(e,c)
local g=c:GetMaterial()
if g:IsExists(Card.IsType,1,nil,TYPE_XYZ) then
e:GetLabelObject():SetLabel(1)
else
e:GetLabelObject():SetLabel(0)
end
end
function c86238081.pencon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsPreviousLocation(LOCATION_MZONE) and c:IsFaceup()
end
function c86238081.pentg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckLocation(tp,LOCATION_SZONE,6) or Duel.CheckLocation(tp,LOCATION_SZONE,7) end
end
function c86238081.penop(e,tp,eg,ep,ev,re,r,rp)
if not Duel.CheckLocation(tp,LOCATION_SZONE,6) and not Duel.CheckLocation(tp,LOCATION_SZONE,7) then return false end
local c=e:GetHandler()
if c:IsRelateToEffect(e) then
Duel.MoveToField(c,tp,tp,LOCATION_SZONE,POS_FACEUP,true)
end
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/globals/spells/bluemagic/regeneration.lua | 46 | 1483 | -----------------------------------------
-- Spell: Regeneration
-- Gradually restores HP
-- Spell cost: 36 MP
-- Monster Type: Aquans
-- Spell Type: Magical (Light)
-- Blue Magic Points: 2
-- Stat Bonus: MND+2
-- Level: 78
-- Casting Time: 2 Seconds
-- Recast Time: 60 Seconds
-- Spell Duration: 30 ticks, 90 Seconds
--
-- Combos: None
-----------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnMagicCastingCheck
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onSpellCast(caster,target,spell)
local typeEffect = EFFECT_REGEN;
local power = 25;
local duration = 90;
if (caster:hasStatusEffect(EFFECT_DIFFUSION)) then
local diffMerit = caster:getMerit(MERIT_DIFFUSION);
if (diffMerit > 0) then
duration = duration + (duration/100)* diffMerit;
end;
caster:delStatusEffect(EFFECT_DIFFUSION);
end;
if (target:hasStatusEffect(EFFECT_REGEN) and target:getStatusEffect(EFFECT_REGEN):getTier() == 1) then
target:delStatusEffect(EFFECT_REGEN);
end
if (target:addStatusEffect(typeEffect,power,3,duration,0,0,0) == false) then
spell:setMsg(75);
end;
return typeEffect;
end; | gpl-3.0 |
dr01d3r/darkstar | scripts/globals/items/plate_of_royal_sautee.lua | 12 | 1839 | -----------------------------------------
-- ID: 4295
-- Item: plate_of_royal_sautee
-- Food Effect: 240Min, All Races
-----------------------------------------
-- Strength 5
-- Agility 1
-- Intelligence -2
-- Attack +22% (cap 80)
-- Ranged Attack +22% (cap 80)
-- Stun Resist +4
-- HP recovered while healing +1
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,14400,4295);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_STR, 5);
target:addMod(MOD_AGI, 1);
target:addMod(MOD_INT, -2);
target:addMod(MOD_FOOD_ATTP, 22);
target:addMod(MOD_FOOD_ATT_CAP, 80);
target:addMod(MOD_FOOD_RATTP, 22);
target:addMod(MOD_FOOD_RATT_CAP, 80);
target:addMod(MOD_STUNRES, 4);
target:addMod(MOD_HPHEAL, 1);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_STR, 5);
target:delMod(MOD_AGI, 1);
target:delMod(MOD_INT, -2);
target:delMod(MOD_FOOD_ATTP, 22);
target:delMod(MOD_FOOD_ATT_CAP, 80);
target:delMod(MOD_FOOD_RATTP, 22);
target:delMod(MOD_FOOD_RATT_CAP, 80);
target:delMod(MOD_STUNRES, 4);
target:delMod(MOD_HPHEAL, 1);
end;
| gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c100000086.lua | 2 | 1915 | --ミラー・リゾネーター
function c100000086.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:SetCondition(c100000086.spcon)
e1:SetValue(1)
c:RegisterEffect(e1)
--lv
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(100000086,0))
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCondition(c100000086.thcon)
e2:SetTarget(c100000086.thtg)
e2:SetOperation(c100000086.thop)
c:RegisterEffect(e2)
end
function c100000086.filter(c)
return c:IsFaceup() and c:IsType(TYPE_SYNCHRO)
end
function c100000086.spcon(e,c)
if c==nil then return true end
return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c100000086.filter,c:GetControler(),0,LOCATION_MZONE,1,nil)
end
function c100000086.thcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():GetSummonType()==SUMMON_TYPE_SPECIAL+1
end
function c100000086.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) and c100000086.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c100000086.filter,tp,0,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,c100000086.filter,tp,0,LOCATION_MZONE,1,1,nil)
end
function c100000086.thop(e,tp,eg,ep,ev,re,r,rp)
local tc1=Duel.GetFirstTarget()
local lv1=tc1:GetLevel()
local lv2=e:GetHandler():GetLevel()
if lv1==lv2 then return end
if tc1:IsFaceup() and e:GetHandler():IsFaceup() then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CHANGE_LEVEL)
e1:SetValue(lv1)
e1:SetReset(RESET_EVENT+0x1fe0000)
e:GetHandler():RegisterEffect(e1)
end
end | gpl-2.0 |
waruqi/xmake | tests/ui/desktop.lua | 1 | 2689 | --!A cross-platform build utility based on Lua
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you 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.
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
-- @file desktop.lua
--
-- imports
import("core.ui.log")
import("core.ui.rect")
import("core.ui.view")
import("core.ui.label")
import("core.ui.event")
import("core.ui.button")
import("core.ui.application")
-- the demo application
local demo = application()
-- init demo
function demo:init()
-- init name
application.init(self, "demo")
-- show desktop, menubar and statusbar
self:insert(self:desktop())
self:insert(self:menubar())
self:insert(self:statusbar())
-- init title
self:menubar():title():text_set("Menu Bar (Hello)")
-- add title label
self:desktop():insert(label:new("title", rect {0, 0, 12, 1}, "hello ltui!"):textattr_set("white"), {centerx = true})
-- add yes button
self:desktop():insert(button:new("yes", rect {0, 1, 7, 2}, "< Yes >"):textattr_set("white"), {centerx = true})
-- add no button
self:desktop():insert(button:new("no", rect {0, 2, 6, 3}, "< No >"):textattr_set("white"), {centerx = true})
end
-- on event
function demo:on_event(e)
if application.on_event(self, e) then
return true
end
if e.type == event.ev_keyboard then
self:statusbar():info():text_set(e.key_name)
if e.key_name == "s" then
self:statusbar():show(not self:statusbar():state("visible"))
elseif e.key_name == "m" then
self:menubar():show(not self:menubar():state("visible"))
elseif e.key_name == "d" then
self:desktop():show(not self:desktop():state("visible"))
end
end
end
-- on resize
function demo:on_resize()
for v in self:desktop():views() do
self:center(v, {centerx = true})
end
application.on_resize(self)
end
-- main entry
function main(...)
demo:run(...)
end
| apache-2.0 |
dr01d3r/darkstar | scripts/zones/Sauromugue_Champaign/TextIDs.lua | 7 | 1425 | -- Variable TextID Description text
-- General Texts
ITEM_CANNOT_BE_OBTAINED = 6401; -- You cannot obtain the item <item>. Come back after sorting your inventory.
ITEM_OBTAINED = 6407; -- Obtained: <item>.
GIL_OBTAINED = 6408; -- Obtained <number> gil.
KEYITEM_OBTAINED = 6410; -- Obtained key item: <keyitem>.
FISHING_MESSAGE_OFFSET = 7235; -- You can't fish here.
-- Quest Dialogs
MANY_TIGER_BONES = 7227; -- There are many tiger bones here...
OLD_SABERTOOTH_DIALOG_I = 7233; -- You hear the distant roar of a tiger. It sounds as if the beast is approaching slowly...
OLD_SABERTOOTH_DIALOG_II = 7234; -- The sound of the tiger's footsteps is growing louder.
THF_AF_MOB = 7412; -- Something has come down from the tower!
THF_AF_WALL_OFFSET = 7431; -- It is impossible to climb this wall with your bare hands.
-- Other Dialog
NOTHING_HAPPENS = 141; -- Nothing happens...
NOTHING_OUT_OF_ORDINARY = 6421; -- There is nothing out of the ordinary here.
-- conquest Base
CONQUEST_BASE = 7068; -- Tallying conquest results...
-- chocobo digging
DIG_THROW_AWAY = 7248; -- You dig up ?Possible Special Code: 01??Possible Special Code: 01??Possible Special Code: 01? ?Possible Special Code: 01??Possible Special Code: 05?$?BAD CHAR: 8280??BAD CHAR: 80??BAD CHAR: 80?, but your inventory is full.
FIND_NOTHING = 7250; -- You dig and you dig, but find nothing.
| gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c78274190.lua | 4 | 2604 | --超重輝将サン-5
function c78274190.initial_effect(c)
--pendulum summon
aux.EnablePendulumAttribute(c)
--scale
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_CHANGE_LSCALE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetRange(LOCATION_PZONE)
e2:SetCondition(c78274190.sccon)
e2:SetValue(4)
c:RegisterEffect(e2)
local e3=e2:Clone()
e3:SetCode(EFFECT_CHANGE_RSCALE)
c:RegisterEffect(e3)
--chain attack
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(78274190,0))
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e4:SetCode(EVENT_BATTLE_DESTROYING)
e4:SetRange(LOCATION_PZONE)
e4:SetCountLimit(1)
e4:SetTarget(c78274190.catg)
e4:SetOperation(c78274190.caop)
c:RegisterEffect(e4)
--draw
local e5=Effect.CreateEffect(c)
e5:SetDescription(aux.Stringid(78274190,1))
e5:SetCategory(CATEGORY_DRAW)
e5:SetType(EFFECT_TYPE_IGNITION)
e5:SetRange(LOCATION_MZONE)
e5:SetCountLimit(1,78274190)
e5:SetCondition(c78274190.condition)
e5:SetCost(c78274190.cost)
e5:SetTarget(c78274190.target)
e5:SetOperation(c78274190.operation)
c:RegisterEffect(e5)
end
function c78274190.sccon(e)
local tp=e:GetHandlerPlayer()
return Duel.IsExistingMatchingCard(Card.IsType,tp,LOCATION_GRAVE,0,1,nil,TYPE_SPELL+TYPE_TRAP)
end
function c78274190.afilter(c,tp)
return c:IsControler(tp) and c:IsSetCard(0x9a) and c:IsChainAttackable()
end
function c78274190.catg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return eg:IsExists(c78274190.afilter,1,nil,tp) end
local a=eg:Filter(c78274190.afilter,nil,tp):GetFirst()
Duel.SetTargetCard(a)
end
function c78274190.caop(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
local tc=Duel.GetFirstTarget()
if tc:IsFaceup() and tc:IsControler(tp) and tc:IsRelateToBattle() then
Duel.ChainAttack()
end
end
function c78274190.condition(e,tp,eg,ep,ev,re,r,rp)
return not Duel.IsExistingMatchingCard(Card.IsType,tp,LOCATION_GRAVE,0,1,nil,TYPE_SPELL+TYPE_TRAP)
end
function c78274190.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckReleaseGroup(tp,Card.IsSetCard,1,nil,0x9a) end
local ct=Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)
if ct>2 then ct=2 end
local g=Duel.SelectReleaseGroup(tp,Card.IsSetCard,1,ct,nil,0x9a)
local rct=Duel.Release(g,REASON_COST)
e:SetLabel(rct)
end
function c78274190.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,e:GetLabel())
end
function c78274190.operation(e,tp,eg,ep,ev,re,r,rp)
Duel.Draw(tp,e:GetLabel(),REASON_EFFECT)
end
| gpl-2.0 |
waruqi/xmake | xmake/modules/detect/tools/gcc/has_flags.lua | 1 | 3933 | --!A cross-platform build utility based on Lua
--
-- 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.
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
-- @file has_flags.lua
--
-- imports
import("lib.detect.cache")
import("core.language.language")
-- is linker?
function _islinker(flags, opt)
-- the flags is "-Wl,<arg>" or "-Xlinker <arg>"?
local flags_str = table.concat(flags, " ")
if flags_str:startswith("-Wl,") or flags_str:startswith("-Xlinker ") then
return true
end
-- the tool kind is ld or sh?
local toolkind = opt.toolkind or ""
return toolkind == "ld" or toolkind == "sh" or toolkind:endswith("ld") or toolkind:endswith("sh")
end
-- try running
function _try_running(program, argv, opt)
local errors = nil
return try { function () os.runv(program, argv, opt); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors
end
-- attempt to check it from the argument list
function _check_from_arglist(flags, opt, islinker)
-- only for compiler
if islinker or #flags > 1 then
return
end
-- make cache key
local key = "detect.tools.gcc.has_flags"
-- make flags key
local flagskey = opt.program .. "_" .. (opt.programver or "")
-- load cache
local cacheinfo = cache.load(key)
-- get all flags from argument list
local allflags = cacheinfo[flagskey]
if not allflags then
-- get argument list
allflags = {}
local arglist = os.iorunv(opt.program, {"--help"}, {envs = opt.envs})
if arglist then
for arg in arglist:gmatch("%s+(%-[%-%a%d]+)%s+") do
allflags[arg] = true
end
end
-- save cache
cacheinfo[flagskey] = allflags
cache.save(key, cacheinfo)
end
-- ok?
return allflags[flags[1]]
end
-- try running to check flags
function _check_try_running(flags, opt, islinker)
-- get extension
-- @note we need detect extension for ndk/clang++.exe: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
local extension = opt.program:endswith("++") and ".cpp" or (table.wrap(language.sourcekinds()[opt.toolkind or "cc"])[1] or ".c")
-- make an stub source file
local sourcefile = path.join(os.tmpdir(), "detect", "gcc_has_flags" .. extension)
if not os.isfile(sourcefile) then
io.writefile(sourcefile, "int main(int argc, char** argv)\n{return 0;}")
end
-- check flags for linker
if islinker then
return _try_running(opt.program, table.join(flags, "-o", os.tmpfile(), sourcefile), opt)
end
-- check flags for compiler
-- @note we cannot use os.nuldev() as the output file, maybe run failed for some flags, e.g. --coverage
return _try_running(opt.program, table.join(flags, "-S", "-o", os.tmpfile(), sourcefile), opt)
end
-- has_flags(flags)?
--
-- @param opt the argument options, e.g. {toolname = "", program = "", programver = "", toolkind = "[cc|cxx|ld|ar|sh|gc|mm|mxx]"}
--
-- @return true or false
--
function main(flags, opt)
-- is linker?
local islinker = _islinker(flags, opt)
-- attempt to check it from the argument list
if _check_from_arglist(flags, opt, islinker) then
return true
end
-- try running to check it
return _check_try_running(flags, opt, islinker)
end
| apache-2.0 |
dr01d3r/darkstar | scripts/globals/spells/firestorm.lua | 32 | 1180 | --------------------------------------
-- Spell: Firestorm
-- Changes the weather around target party member to "hot."
--------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
target:delStatusEffectSilent(EFFECT_FIRESTORM);
target:delStatusEffectSilent(EFFECT_SANDSTORM);
target:delStatusEffectSilent(EFFECT_RAINSTORM);
target:delStatusEffectSilent(EFFECT_WINDSTORM);
target:delStatusEffectSilent(EFFECT_HAILSTORM);
target:delStatusEffectSilent(EFFECT_THUNDERSTORM);
target:delStatusEffectSilent(EFFECT_AURORASTORM);
target:delStatusEffectSilent(EFFECT_VOIDSTORM);
local merit = caster:getMerit(MERIT_STORMSURGE);
local power = 0;
if merit > 0 then
power = merit + caster:getMod(MOD_STORMSURGE_EFFECT) + 2;
end
target:addStatusEffect(EFFECT_FIRESTORM,power,0,180);
return EFFECT_FIRESTORM;
end; | gpl-3.0 |
AutoJames/KkthnxUI_Legion | KkthnxUI/Modules/Announcements/Spells.lua | 1 | 1805 | local K, C, L = select(2, ...):unpack()
if C.Announcements.Spells ~= true then return end
-- Lua API
local format = string.format
local gsub = string.gsub
local pairs = pairs
-- Wow API
local CreateFrame = CreateFrame
local GetInstanceInfo = GetInstanceInfo
local GetSpellLink = GetSpellLink
local SendChatMessage = SendChatMessage
local UnitGUID = UnitGUID
-- Announce some spells
local AnnounceSpells = CreateFrame("Frame")
AnnounceSpells:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
AnnounceSpells:SetScript("OnEvent", function(self, _, ...)
local _, event, _, sourceGUID, sourceName, _, _, _, destName, _, _, spellID = ...
local spells = K.AnnounceSpells
local _, _, difficultyID = GetInstanceInfo()
if (difficultyID == 0 or event ~= "SPELL_CAST_SUCCESS") then return end
if sourceName then sourceName = sourceName:gsub("%-[^|]+", "") end
if destName then destName = destName:gsub("%-[^|]+", "") end
if (C.Announcements.SpellsFromAll == true) and (not (sourceGUID == UnitGUID("player")) and (sourceName == K.Name)) then
if not sourceName then return end
for i, spells in pairs(spells) do
if spellID == spells then
if destName == nil then
SendChatMessage(format(L.Announce.FPUse, sourceName, GetSpellLink(spellID)), K.CheckChat())
else
SendChatMessage(format(L.Announce.FPUse, sourceName, GetSpellLink(spellID).." -> "..destName), K.CheckChat())
end
end
end
else
if not (sourceGUID == UnitGUID("player") and sourceName == K.Name) then return end
for i, spells in pairs(spells) do
if spellID == spells then
if destName == nil then
SendChatMessage(format(L.Announce.FPUse, sourceName, GetSpellLink(spellID)), K.CheckChat())
else
SendChatMessage(GetSpellLink(spellID).." -> "..destName, K.CheckChat())
end
end
end
end
end) | mit |
thegrb93/wire | lua/entities/gmod_wire_hologrid.lua | 8 | 1770 | AddCSLuaFile()
DEFINE_BASECLASS( "base_wire_entity" )
ENT.PrintName = "Wire Holo Grid"
ENT.Author = "Chad 'Jinto'"
ENT.WireDebugName = "Holo Grid"
if CLIENT then return end -- No more client
function ENT:Initialize( )
self:PhysicsInit( SOLID_VPHYSICS );
self:SetMoveType( MOVETYPE_VPHYSICS );
self:SetSolid( SOLID_VPHYSICS );
self:SetUseType(SIMPLE_USE)
self:Setup(false)
-- create inputs.
self.Inputs = WireLib.CreateSpecialInputs(self, { "UseGPS", "Reference" }, { "NORMAL", "ENTITY" })
self.reference = self
end
function ENT:Setup(UseGPS)
if UseGPS then
self.usesgps = true
self:SetNWEntity( "reference", ents.GetByIndex(-1) )
self:SetOverlayText( "(GPS)" )
else
self.usesgps = false
self:SetNWEntity( "reference", self.reference )
self:SetOverlayText( "(Local)" )
end
end
function ENT:TriggerInput( inputname, value )
-- store values.
if inputname == "UseGPS" then
self:Setup(value ~= 0)
elseif inputname == "Reference" then
if IsValid(value) then
self.reference = value
else
self.reference = self
end
self:Setup(self.usesgps)
end
end
function ENT:Use( activator, caller )
if caller:IsPlayer() then self:Setup(not self.usesgps) end
end
duplicator.RegisterEntityClass("gmod_wire_hologrid", WireLib.MakeWireEnt, "Data", "usegps")
function ENT:BuildDupeInfo()
local info = BaseClass.BuildDupeInfo(self) or {}
info.hologrid_usegps = self.usesgps and 1 or 0
if IsValid(self.reference) then
info.reference = self.reference:EntIndex()
else
info.reference = nil
end
return info
end
function ENT:ApplyDupeInfo(ply, ent, info, GetEntByID)
BaseClass.ApplyDupeInfo(self, ply, ent, info, GetEntByID)
self.reference = GetEntByID(info.reference, self)
self:Setup(info.hologrid_usegps ~= 0)
end
| apache-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c69000994.lua | 2 | 2978 | --炎王獣 バロン
function c69000994.initial_effect(c)
--spsummon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(69000994,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetRange(LOCATION_HAND)
e1:SetCode(EVENT_DESTROYED)
e1:SetCondition(c69000994.spcon)
e1:SetTarget(c69000994.sptg)
e1:SetOperation(c69000994.spop)
c:RegisterEffect(e1)
--search
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetCode(EVENT_TO_GRAVE)
e2:SetOperation(c69000994.threg)
c:RegisterEffect(e2)
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(69000994,1))
e3:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e3:SetRange(LOCATION_GRAVE)
e3:SetCode(EVENT_PHASE+PHASE_STANDBY)
e3:SetCondition(c69000994.thcon)
e3:SetTarget(c69000994.thtg)
e3:SetOperation(c69000994.thop)
e3:SetLabelObject(e2)
c:RegisterEffect(e3)
end
function c69000994.cfilter(c,tp)
return c:IsPreviousLocation(LOCATION_MZONE) and c:IsPreviousPosition(POS_FACEUP) and c:GetPreviousControler()==tp
and c:IsReason(REASON_EFFECT) and c:IsSetCard(0x81)
end
function c69000994.spcon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c69000994.cfilter,1,nil,tp)
end
function c69000994.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsRelateToEffect(e)
and 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 c69000994.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) then
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
end
end
function c69000994.threg(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if bit.band(r,0x41)~=0x41 then return end
if Duel.GetCurrentPhase()==PHASE_STANDBY then
e:SetLabel(Duel.GetTurnCount())
c:RegisterFlagEffect(69000994,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_STANDBY,0,2)
else
e:SetLabel(0)
c:RegisterFlagEffect(69000994,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_STANDBY,0,1)
end
end
function c69000994.thcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetLabelObject():GetLabel()~=Duel.GetTurnCount() and e:GetHandler():GetFlagEffect(69000994)>0
end
function c69000994.thfilter(c)
return c:IsSetCard(0x81) and c:GetCode()~=69000994 and c:IsAbleToHand()
end
function c69000994.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
e:GetHandler():ResetFlagEffect(69000994)
end
function c69000994.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c69000994.thfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/zones/Lower_Jeuno/npcs/Naruru.lua | 24 | 3874 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: Naruru
-- Starts and Finishes Quests: Cook's Pride
-- @pos -56 0.1 -138 245
-----------------------------------
package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/shop");
require("scripts/globals/quests");
require("scripts/zones/Lower_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local TheWonderMagicSet = player:getQuestStatus(JEUNO,THE_WONDER_MAGIC_SET);
local CooksPride = player:getQuestStatus(JEUNO,COOK_S_PRIDE);
local TheKindCardian = player:getQuestStatus(JEUNO,THE_KIND_CARDIAN);
local WildcatJeuno = player:getVar("WildcatJeuno");
if (player:getQuestStatus(JEUNO,LURE_OF_THE_WILDCAT_JEUNO) == QUEST_ACCEPTED and player:getMaskBit(WildcatJeuno,13) == false) then
player:startEvent(10053);
elseif (TheWonderMagicSet == QUEST_COMPLETED and CooksPride == QUEST_AVAILABLE) then
if (player:getVar("CooksPrideVar") == 0) then
player:startEvent(0x00BD); -- Start quest "Cook's pride" Long CS
else
player:startEvent(0x00BC); -- Start quest "Cook's pride" Short CS
end
elseif (CooksPride == QUEST_ACCEPTED and player:hasKeyItem(SUPER_SOUP_POT) == false) then
player:startEvent(0x00BA); -- During quest "Cook's pride"
elseif (player:hasKeyItem(SUPER_SOUP_POT) == true) then
player:startEvent(0x00BB); -- Finish quest "Cook's pride"
elseif (CooksPride == QUEST_COMPLETED and TheKindCardian == QUEST_AVAILABLE) then
if (player:getVar("theLostCardianVar") == 0) then
player:startEvent(0x001f); -- During quests "The lost cardian"
else
player:startEvent(0x0047); -- During quests "The lost cardian"
end
elseif (CooksPride == QUEST_COMPLETED and TheKindCardian ~= QUEST_COMPLETED) then
player:startEvent(0x0047); -- During quests "The kind cardien"
elseif (TheKindCardian == QUEST_COMPLETED) then
player:startEvent(0x0048); -- New standard dialog after the quest "The kind cardien"
else
player:startEvent(0x0062); -- Standard dialog
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if ((csid == 0x00BD or csid == 0x00BC) and option == 0) then
player:addQuest(JEUNO,COOK_S_PRIDE);
elseif (csid == 0x00BD and option == 1) then
player:setVar("CooksPrideVar",1);
elseif (csid == 0x00BB) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,13446);
else
player:addTitle(MERCY_ERRAND_RUNNER);
player:delKeyItem(SUPER_SOUP_POT);
player:setVar("CooksPrideVar",0);
player:addGil(GIL_RATE*3000);
player:messageSpecial(GIL_OBTAINED,GIL_RATE*3000);
player:addItem(13446);
player:messageSpecial(ITEM_OBTAINED,13446); -- Mythril Ring
player:addFame(JEUNO, 30);
player:completeQuest(JEUNO,COOK_S_PRIDE);
end
elseif (csid == 10053) then
player:setMaskBit(player:getVar("WildcatJeuno"),"WildcatJeuno",13,true);
end
end; | gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Castle_Oztroja/npcs/_47d.lua | 14 | 1071 | -----------------------------------
-- Area: Castle Oztroja
-- NPC: _47d
-- @pos 20.000 24.168 -25.000 151
-----------------------------------
package.loaded["scripts/zones/Castle_Oztroja/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Castle_Oztroja/TextIDs");
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if(player:hasKeyItem(OLD_RING) == false) then
player:addKeyItem(OLD_RING);
player:messageSpecial(KEYITEM_OBTAINED,OLD_RING);
end
if (npc:getAnimation() == 9) then
npc:openDoor();
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
waruqi/xmake | xmake/modules/package/tools/xmake.lua | 1 | 3729 | --!A cross-platform build utility based on Lua
--
-- 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.
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
-- @file xmake.lua
--
-- imports
import("core.base.option")
-- get configs
function _get_configs(package, configs)
local configs = configs or {}
local cflags = table.join(table.wrap(package:config("cflags")), get_config("cflags"))
local cxflags = table.join(table.wrap(package:config("cxflags")), get_config("cxflags"))
local cxxflags = table.join(table.wrap(package:config("cxxflags")), get_config("cxxflags"))
local asflags = table.join(table.wrap(package:config("asflags")), get_config("asflags"))
local ldflags = table.join(table.wrap(package:config("ldflags")), get_config("ldflags"))
if package:is_plat("windows") then
local vs_runtime = package:config("vs_runtime")
if vs_runtime then
local vs_runtime_cxflags = "/" .. vs_runtime .. (package:debug() and "d" or "")
table.insert(cxflags, vs_runtime_cxflags)
end
end
table.insert(configs, "--mode=" .. (package:debug() and "debug" or "release"))
if cflags then
table.insert(configs, "--cflags=" .. table.concat(cflags, ' '))
end
if cxflags then
table.insert(configs, "--cxflags=" .. table.concat(cxflags, ' '))
end
if cxxflags then
table.insert(configs, "--cxxflags=" .. table.concat(cxxflags, ' '))
end
if asflags then
table.insert(configs, "--asflags=" .. table.concat(asflags, ' '))
end
if ldflags then
table.insert(configs, "--ldflags=" .. table.concat(ldflags, ' '))
end
return configs
end
-- init arguments and inherit some global options from the parent xmake
function _init_argv(...)
local argv = {...}
for _, name in ipairs({"diagnosis", "verbose", "quiet", "yes", "confirm", "root"}) do
local value = option.get(name)
if type(value) == "boolean" then
table.insert(argv, "--" .. name)
elseif value ~= nil then
table.insert(argv, "--" .. name .. "=" .. value)
end
end
return argv
end
-- install package
function install(package, configs)
-- inherit builtin configs
local argv = _init_argv("f", "-y", "-c")
local names = {"plat", "arch", "ndk", "ndk_sdkver", "vs", "mingw", "sdk", "bin", "cross", "ld", "sh", "ar", "cc", "cxx", "mm", "mxx"}
for _, name in ipairs(names) do
local value = get_config(name)
if value ~= nil then
table.insert(argv, "--" .. name .. "=" .. tostring(value))
end
end
-- pass configurations
for name, value in pairs(_get_configs(package, configs)) do
value = tostring(value):trim()
if type(name) == "number" then
if value ~= "" then
table.insert(argv, value)
end
else
table.insert(argv, "--" .. name .. "=" .. value)
end
end
os.vrunv("xmake", argv)
-- do build
argv = _init_argv()
os.vrunv("xmake", argv)
-- do install
argv = _init_argv("install", "-y", "-o", package:installdir())
os.vrunv("xmake", argv)
end
| apache-2.0 |
Herve-M/OpenRA | mods/ra/maps/production-disruption/production-disruption.lua | 7 | 8379 | --[[
Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
This file is part of OpenRA, which is free software. It is made
available to you under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version. For more
information, see COPYING.
]]
TimerTicks = DateTime.Minutes(12)
LSTType = "lst.reinforcement"
RifleSquad1 = { Rifle1, Rifle2, Rifle3 }
RifleSquad2 = { Rifle4, Rifle5, Rifle6 }
Heavys = { Heavy1, Heavy2 }
FlameTowerWall = { FlameTower1, FlameTower2 }
DemoEngiPath = { WaterEntry1.Location, Beach1.Location }
DemoEngiTeam = { "dtrk", "dtrk", "e6", "e6", "e6" }
SovietWaterEntry1 = { WaterEntry2.Location, Beach2.Location }
SovietWaterEntry2 = { WaterEntry2.Location, Beach3.Location }
SovietSquad = { "e1", "e1", "e1", "e4", "e4" }
V2Squad = { "v2rl", "v2rl" }
SubEscapePath = { SubPath1, SubPath2, SubPath3 }
MissionStart = function()
LZCamera = Actor.Create("camera", true, { Owner = Greece, Location = LZ.Location })
Chalk1.TargetParatroopers(LZ.CenterPosition, Angle.New(740))
if Difficulty == "normal" then
Actor.Create("tsla", true, { Owner = USSR, Location = EasyCamera.Location })
Actor.Create("4tnk", true, { Owner = USSR, Facing = Angle.South, Location = Mammoth.Location })
Actor.Create("4tnk", true, { Owner = USSR, Facing = Angle.South, Location = Mammoth.Location + CVec.New(1,0) })
Actor.Create("v2rl", true, { Owner = USSR, Facing = Angle.South, Location = V2.Location })
end
Trigger.AfterDelay(DateTime.Seconds(1), function()
Chalk2.TargetParatroopers(LZ.CenterPosition, Angle.New(780))
end)
Trigger.AfterDelay(DateTime.Seconds(5), function()
UnitsArrived = true
TeslaCamera = Actor.Create("camera", true, { Owner = Greece, Location = TeslaCam.Location })
end)
Trigger.AfterDelay(DateTime.Seconds(10), function()
LZCamera.Destroy()
Utils.Do(RifleSquad1, function(actor)
if not actor.IsDead then
actor.AttackMove(LZ.Location)
IdleHunt(actor)
end
end)
end)
Trigger.AfterDelay(DateTime.Seconds(15), function()
TeslaCamera.Destroy()
Utils.Do(RifleSquad2, function(actor)
if not actor.IsDead then
actor.AttackMove(LZ.Location)
IdleHunt(actor)
end
end)
end)
end
SetupTriggers = function()
Trigger.OnDamaged(SubPen, function()
Utils.Do(Heavys, function(actor)
if not actor.IsDead then
IdleHunt(actor)
end
end)
end)
Trigger.OnKilled(Church, function()
Actor.Create("healcrate", true, { Owner = Greece, Location = ChurchCrate.Location })
end)
Trigger.OnKilled(ObjectiveDome, function()
if not DomeCaptured == true then
Greece.MarkFailedObjective(CaptureDome)
end
end)
Trigger.OnAllKilled(FlameTowerWall, function()
DomeCam = Actor.Create("camera", true, { Owner = Greece, Location = RadarCam.Location })
Trigger.AfterDelay(DateTime.Seconds(5), function()
DomeCam.Destroy()
end)
end)
Trigger.OnKilledOrCaptured(SubPen, function()
Greece.MarkCompletedObjective(StopProduction)
end)
end
PowerDown = false
PowerDownTeslas = function()
if not PowerDown then
CaptureDome = Greece.AddObjective("Capture the enemy radar dome.", "Secondary", false)
Greece.MarkCompletedObjective(PowerDownTeslaCoils)
Media.PlaySpeechNotification(Greece, "ReinforcementsArrived")
PowerDown = true
local bridge = Utils.Where(Map.ActorsInWorld, function(actor) return actor.Type == "bridge1" end)[1]
if not bridge.IsDead then
bridge.Kill()
end
local demoEngis = Reinforcements.ReinforceWithTransport(Greece, LSTType, DemoEngiTeam, DemoEngiPath, { DemoEngiPath[1] })[2]
Trigger.OnAllRemovedFromWorld(Utils.Where(demoEngis, function(a) return a.Type == "e6" end), function()
if not DomeCaptured then
Greece.MarkFailedObjective(CaptureDome)
end
if not DomeCaptured and bridge.IsDead then
Greece.MarkFailedObjective(StopProduction)
end
end)
Trigger.OnCapture(ObjectiveDome, function()
DomeCaptured = true
Greece.MarkCompletedObjective(CaptureDome)
SendChronos()
end)
FlameTowersCam = Actor.Create("camera", true, { Owner = Greece, Location = FlameCam.Location })
Trigger.AfterDelay(DateTime.Seconds(10), function()
FlameTowersCam.Destroy()
end)
end
end
SendChronos = function()
Trigger.AfterDelay(DateTime.Seconds(3), function()
local sovietWaterSquad1 = Reinforcements.ReinforceWithTransport(USSR, "lst", SovietSquad, { WaterEntry2.Location, Beach2.Location }, { WaterEntry2.Location })[2]
Utils.Do(sovietWaterSquad1, function(a)
Trigger.OnAddedToWorld(a, function()
IdleHunt(a)
end)
end)
Actor.Create("ctnk", true, { Owner = Greece, Location = ChronoSpawn1.Location })
Actor.Create("ctnk", true, { Owner = Greece, Location = ChronoSpawn2.Location })
Actor.Create("ctnk", true, { Owner = Greece, Location = ChronoSpawn3.Location })
Actor.Create("camera", true, { Owner = Greece, Location = EasyCamera.Location })
Media.PlaySound("chrono2.aud")
end)
Trigger.AfterDelay(DateTime.Seconds(5), function()
local sovietWaterSquad2 = Reinforcements.ReinforceWithTransport(USSR, "lst", SovietSquad, { WaterEntry2.Location, Beach3.Location }, { WaterEntry2.Location })[2]
Utils.Do(sovietWaterSquad2, function(a)
Trigger.OnAddedToWorld(a, function()
a.AttackMove(FlameCam.Location)
IdleHunt(a)
end)
end)
end)
Trigger.AfterDelay(DateTime.Seconds(13), function()
local sovietWaterSquad2 = Reinforcements.ReinforceWithTransport(USSR, "lst", V2Squad, { WaterEntry2.Location, Beach2.Location }, { WaterEntry2.Location })[2]
Utils.Do(sovietWaterSquad2, function(a)
Trigger.OnAddedToWorld(a, function()
a.AttackMove(FlameCam.Location)
IdleHunt(a)
end)
end)
end)
end
MissileSubEscape = function()
local missileSub = Actor.Create("msub", true, { Owner = USSR, Location = MissileSubSpawn.Location })
Actor.Create("camera", true, { Owner = Greece, Location = SubPath2.Location })
DestroySub = Greece.AddPrimaryObjective("Destroy the submarine before it escapes!.")
Utils.Do(SubEscapePath, function(waypoint)
missileSub.Move(waypoint.Location)
end)
Trigger.OnEnteredFootprint({ SubPath3.Location }, function(a, id)
if a.Owner == USSR and a.Type == "msub" then
Trigger.RemoveFootprintTrigger(id)
USSR.MarkCompletedObjective(EscapeWithSub)
end
end)
Trigger.OnKilled(missileSub, function()
Greece.MarkCompletedObjective(DestroySub)
end)
end
FinishTimer = function()
for i = 0, 5 do
local c = TimerColor
if i % 2 == 0 then
c = HSLColor.White
end
Trigger.AfterDelay(DateTime.Seconds(i), function() UserInterface.SetMissionText("The sub is heading for open sea!", c) end)
end
Trigger.AfterDelay(DateTime.Seconds(6), function() UserInterface.SetMissionText("") end)
end
UnitsArrived = false
TimerFinished = false
ticked = TimerTicks
Tick = function()
if BadGuy.PowerState ~= "Normal" then
PowerDownTeslas()
end
if Greece.HasNoRequiredUnits() and UnitsArrived then
USSR.MarkCompletedObjective(EscapeWithSub)
end
if ticked > 0 then
UserInterface.SetMissionText("Submarine completes in " .. Utils.FormatTime(ticked), TimerColor)
ticked = ticked - 1
elseif ticked == 0 and not TimerFinished then
MissileSubEscape()
TimerFinished = true
end
end
WorldLoaded = function()
Greece = Player.GetPlayer("Greece")
USSR = Player.GetPlayer("USSR")
BadGuy = Player.GetPlayer("BadGuy")
EscapeWithSub = USSR.AddObjective("Get a missile sub to open waters.")
StopProduction = Greece.AddObjective("Destroy the Soviet sub pen.")
PowerDownTeslaCoils = Greece.AddObjective("Take down power to the tesla coils.")
InitObjectives(Greece)
Trigger.AfterDelay(DateTime.Minutes(2), function()
Media.PlaySpeechNotification(Greece, "TenMinutesRemaining")
end)
Trigger.AfterDelay(DateTime.Minutes(7), function()
Media.PlaySpeechNotification(Greece, "WarningFiveMinutesRemaining")
end)
Trigger.AfterDelay(DateTime.Minutes(9), function()
Media.PlaySpeechNotification(Greece, "WarningThreeMinutesRemaining")
end)
Trigger.AfterDelay(DateTime.Minutes(11), function()
Media.PlaySpeechNotification(Greece, "WarningOneMinuteRemaining")
end)
Camera.Position = DefaultCameraPosition.CenterPosition
TimerColor = USSR.Color
Chalk1 = Actor.Create("chalk1", false, { Owner = Greece })
Chalk2 = Actor.Create("chalk2", false, { Owner = Greece })
MissionStart()
SetupTriggers()
end
| gpl-3.0 |
dr01d3r/darkstar | scripts/globals/weaponskills/tachi_yukikaze.lua | 18 | 1763 | -----------------------------------
-- Tachi Yukikaze
-- Great Katana weapon skill
-- Skill Level: 200 (Samurai only.)
-- Blinds target. Damage varies with TP.
-- Blind effect duration is 60 seconds when unresisted.
-- Will stack with Sneak Attack.
-- Tachi: Yukikaze appears to have an attack bonus of 50%. http://www.bg-wiki.com/bg/Tachi:_Yukikaze
-- Aligned with the Snow Gorget & Breeze Gorget.
-- Aligned with the Snow Belt & Breeze Belt.
-- Element: None
-- Modifiers: STR:75%
-- 100%TP 200%TP 300%TP
-- 1.5625 2.6875 4.125
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar)
local params = {};
params.numHits = 1;
params.ftp100 = 1.5625; params.ftp200 = 1.88; params.ftp300 = 2.5;
params.str_wsc = 0.75; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0;
params.canCrit = false;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1.33;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.ftp200 = 2.6875; params.ftp300 = 4.125;
params.atkmulti = 1.5;
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, tp, primary, action, taChar, params);
if (damage > 0 and target:hasStatusEffect(EFFECT_BLINDNESS) == false) then
target:addStatusEffect(EFFECT_BLINDNESS, 25, 0, 60);
end
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Bastok_Markets/npcs/Zhikkom.lua | 15 | 1475 | -----------------------------------
-- Area: Bastok Markets
-- NPC: Zhikkom
-- Standard Merchant NPC
--
-- Updated Aug-09-2013 by Zerahn, based on bgwiki and gamerescape
-----------------------------------
require("scripts/globals/shop");
package.loaded["scripts/zones/Bastok_Markets/TextIDs"] = nil;
require("scripts/zones/Bastok_Markets/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,ZHIKKOM_SHOP_DIALOG);
stock = {
0x4097, 241,3, --Bronze Sword
0x4098,7128,3, --Iron Sword
0x4085,9201,3, --Degen
0x40A7, 698,3, --Sapara
0x40A8,4072,3, --Scimitar
0x4092, 618,3, --Xiphos
0x40B5,1674,3, --Spatha
0x4080,3215,3 --Bilbo (value may be off)
}
showNationShop(player, NATION_BASTOK, stock);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
TerryE/nodemcu-firmware | lua_examples/lfs/lfs_fragments.lua | 1 | 2651 | -- First time image boot to discover the confuration
--
-- If you want to use absolute address LFS load or SPIFFS imaging, then boot the
-- image for the first time bare, that is without either LFS or SPIFFS preloaded
-- then enter the following commands interactively through the UART:
--
do
local _,ma,fa=node.flashindex()
for n,v in pairs{LFS_MAPPED=ma, LFS_BASE=fa, SPIFFS_BASE=sa} do
print(('export %s=""0x%x"'):format(n, v))
end
end
--
-- This will print out 3 hex constants: the absolute address used in the
-- 'luac.cross -a' options and the flash adresses of the LFS and SPIFFS.
--
--[[ So you would need these commands to image your ESP module:
USB=/dev/ttyUSB0 # or whatever the device of your USB is
NODEMCU=~/nodemcu # The root of your NodeMCU file hierarchy
SRC=$NODEMCU/local/lua # your source directory for your LFS Lua files.
BIN=$NODEMCU/bin
ESPTOOL=$NODEMCU/tools/esptool.py
$ESPTOOL --port $USB erase_flash # Do this is you are having load funnies
$ESPTOOL --port $USB --baud 460800 write_flash -fm dio 0x00000 \
$BIN/0x00000.bin 0x10000 $BIN/0x10000.bin
#
# Now restart your module and use whatever your intective tool is to do the above
# cmds, so if this outputs 0x4027b000, -0x7b000, 0x100000 then you can do
#
$NODEMCU/luac.cross -a 0x4027b000 -o $BIN/0x7b000-flash.img $SRC/*.lua
$ESPTOOL --port $USB --baud 460800 write_flash -fm dio 0x7b000 \
$BIN/0x7b000-flash.img
# and if you've setup a SPIFFS then
$ESPTOOL --port $USB --baud 460800 write_flash -fm dio 0x100000 \
$BIN/0x100000-0x10000.img
# and now you are good to go
]]
-----------------------------------------------------------------------------------
--
-- File: init.lua
--
-- With the previous example you still need an init.lua to bootstrap the _init
-- module in LFS. Here is an example. It's a good idea either to use a timer
-- delay or a GPIO pin during development, so that you as developer can break into
-- the boot sequence if there is a problem with the _init bootstrap that is causing
-- a panic loop. Here is one example of how you might do this. You have a second
-- to inject tmr.stop(0) into UART0. Extend this delay if needed.
--
-- This example will also attempt to automatically load the LFS block from a SPIFFS
-- file named 'flash.img'.
--
if node.flashindex() == nil then
node.flashreload('flash.img')
end
local initTimer = tmr.create()
initTimer:register(1000, tmr.ALARM_SINGLE,
function()
local fi=node.flashindex; return pcall(fi and fi'_init')
end
)
initTimer:start()
| mit |
YelaSeamless/mysql-proxy | tests/suite/base/t/bug_55459-test.lua | 3 | 1461 | --[[ $%BEGINLICENSE%$
Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; version 2 of the
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
$%ENDLICENSE%$ --]]
---
-- forward the query AS IS and add a query to the queue,
-- but don't mark it as "SEND_QUERY"
--
-- the query in the queue will never be touched, as the default behaviour
-- is to just forward the result back to the client without buffering
-- it
function read_query( packet )
if packet:byte() == proxy.COM_QUERY then
proxy.queries:append(1, packet, { resultset_is_needed = true } )
end
-- forward the incoming query AS IS
end
---
-- try access the resultset
--
function read_query_result(inj)
local res = assert(inj.resultset)
if res.query_status == proxy.MYSQLD_PACKET_ERR then
print(("received error-code: %d"):format(
res.raw:byte(2)+(res.raw:byte(3)*256)
))
end
end
| gpl-2.0 |
waruqi/xmake | xmake/core/sandbox/modules/import/core/project/template.lua | 1 | 1253 | --!A cross-platform build utility based on Lua
--
-- 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.
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
-- @file template.lua
--
-- define module
local sandbox_core_project_template = sandbox_core_project_template or {}
-- load modules
local template = require("project/template")
local raise = require("sandbox/modules/raise")
-- get all languages
function sandbox_core_project_template.languages()
return assert(template.languages())
end
-- load all templates from the given language
function sandbox_core_project_template.templates(language)
return assert(template.templates(language))
end
-- return module
return sandbox_core_project_template
| apache-2.0 |
dr01d3r/darkstar | scripts/zones/Apollyon/mobs/Thunder_Elemental.lua | 119 | 2740 | -----------------------------------
-- Area: Apollyon SW
-- NPC: elemental
-----------------------------------
package.loaded["scripts/zones/Apollyon/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/limbus");
require("scripts/zones/Apollyon/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
end;
-----------------------------------
-- onMobDespawn
-----------------------------------
function onMobDespawn(mob)
local mobID = mob:getID();
-- print(mobID);
local mobX = mob:getXPos();
local mobY = mob:getYPos();
local mobZ = mob:getZPos();
local elementalday = GetServerVariable("[SW_Apollyon]ElementalTrigger") - 1;
local correctelement=false;
switch (elementalday): caseof {
[0] = function (x)
if (mobID==16932913 or mobID==16932921 or mobID==16932929) then
correctelement=true;
end
end ,
[1] = function (x)
if (mobID==16932912 or mobID==16932920 or mobID==16932928 ) then
correctelement=true;
end
end ,
[2] = function (x)
if (mobID==16932916 or mobID==16932924 or mobID==16932932 ) then
correctelement=true;
end
end ,
[3] = function (x)
if (mobID==16932910 or mobID==16932918 or mobID==16932926 ) then
correctelement=true;
end
end ,
[4] = function (x)
if (mobID==16932914 or mobID==16932922 or mobID==16932930 ) then
correctelement=true;
end
end ,
[5] = function (x)
if (mobID==16932917 or mobID==16932925 or mobID==16932933 ) then
correctelement=true;
end
end ,
[6] = function (x)
if (mobID==16932931 or mobID==16932915 or mobID==16932923 ) then
correctelement=true;
end
end ,
[7] = function (x)
if (mobID==16932911 or mobID==16932919 or mobID==16932927 ) then
correctelement=true;
end
end ,
};
if (correctelement==true and IselementalDayAreDead()==true) then
GetNPCByID(16932864+313):setPos(mobX,mobY,mobZ);
GetNPCByID(16932864+313):setStatus(STATUS_NORMAL);
end
end; | gpl-3.0 |
mrvigeo/telesalib | bot/utils.lua | 646 | 23489 | URL = require "socket.url"
http = require "socket.http"
https = require "ssl.https"
ltn12 = require "ltn12"
serpent = require "serpent"
feedparser = require "feedparser"
json = (loadfile "./libs/JSON.lua")()
mimetype = (loadfile "./libs/mimetype.lua")()
redis = (loadfile "./libs/redis.lua")()
JSON = (loadfile "./libs/dkjson.lua")()
http.TIMEOUT = 10
function get_receiver(msg)
if msg.to.type == 'user' then
return 'user#id'..msg.from.id
end
if msg.to.type == 'chat' then
return 'chat#id'..msg.to.id
end
if msg.to.type == 'encr_chat' then
return msg.to.print_name
end
end
function is_chat_msg( msg )
if msg.to.type == 'chat' then
return true
end
return false
end
function string.random(length)
local str = "";
for i = 1, length do
math.random(97, 122)
str = str..string.char(math.random(97, 122));
end
return str;
end
function string:split(sep)
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
self:gsub(pattern, function(c) fields[#fields+1] = c end)
return fields
end
-- DEPRECATED
function string.trim(s)
print("string.trim(s) is DEPRECATED use string:trim() instead")
return s:gsub("^%s*(.-)%s*$", "%1")
end
-- Removes spaces
function string:trim()
return self:gsub("^%s*(.-)%s*$", "%1")
end
function get_http_file_name(url, headers)
-- Eg: foo.var
local file_name = url:match("[^%w]+([%.%w]+)$")
-- Any delimited alphanumeric on the url
file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$")
-- Random name, hope content-type works
file_name = file_name or str:random(5)
local content_type = headers["content-type"]
local extension = nil
if content_type then
extension = mimetype.get_mime_extension(content_type)
end
if extension then
file_name = file_name.."."..extension
end
local disposition = headers["content-disposition"]
if disposition then
-- attachment; filename=CodeCogsEqn.png
file_name = disposition:match('filename=([^;]+)') or file_name
end
return file_name
end
-- Saves file to /tmp/. If file_name isn't provided,
-- will get the text after the last "/" for filename
-- and content-type for extension
function download_to_file(url, file_name)
print("url to download: "..url)
local respbody = {}
local options = {
url = url,
sink = ltn12.sink.table(respbody),
redirect = true
}
-- nil, code, headers, status
local response = nil
if url:starts('https') then
options.redirect = false
response = {https.request(options)}
else
response = {http.request(options)}
end
local code = response[2]
local headers = response[3]
local status = response[4]
if code ~= 200 then return nil end
file_name = file_name or get_http_file_name(url, headers)
local file_path = "/tmp/"..file_name
print("Saved to: "..file_path)
file = io.open(file_path, "w+")
file:write(table.concat(respbody))
file:close()
return file_path
end
function vardump(value)
print(serpent.block(value, {comment=false}))
end
-- taken from http://stackoverflow.com/a/11130774/3163199
function scandir(directory)
local i, t, popen = 0, {}, io.popen
for filename in popen('ls -a "'..directory..'"'):lines() do
i = i + 1
t[i] = filename
end
return t
end
-- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen
function run_command(str)
local cmd = io.popen(str)
local result = cmd:read('*all')
cmd:close()
return result
end
-- User has privileges
function is_sudo(msg)
local var = false
-- Check users id in config
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
-- Returns the name of the sender
function get_name(msg)
local name = msg.from.first_name
if name == nil then
name = msg.from.id
end
return name
end
-- Returns at table of lua files inside plugins
function plugins_names( )
local files = {}
for k, v in pairs(scandir("plugins")) do
-- Ends with .lua
if (v:match(".lua$")) then
table.insert(files, v)
end
end
return files
end
-- Function name explains what it does.
function file_exists(name)
local f = io.open(name,"r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
-- Save into file the data serialized for lua.
-- Set uglify true to minify the file.
function serialize_to_file(data, file, uglify)
file = io.open(file, 'w+')
local serialized
if not uglify then
serialized = serpent.block(data, {
comment = false,
name = '_'
})
else
serialized = serpent.dump(data)
end
file:write(serialized)
file:close()
end
-- Returns true if the string is empty
function string:isempty()
return self == nil or self == ''
end
-- Returns true if the string is blank
function string:isblank()
self = self:trim()
return self:isempty()
end
-- DEPRECATED!!!!!
function string.starts(String, Start)
print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead")
return Start == string.sub(String,1,string.len(Start))
end
-- Returns true if String starts with Start
function string:starts(text)
return text == string.sub(self,1,string.len(text))
end
-- Send image to user and delete it when finished.
-- cb_function and cb_extra are optionals callback
function _send_photo(receiver, file_path, cb_function, cb_extra)
local cb_extra = {
file_path = file_path,
cb_function = cb_function,
cb_extra = cb_extra
}
-- Call to remove with optional callback
send_photo(receiver, file_path, cb_function, cb_extra)
end
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_photo_from_url(receiver, url, cb_function, cb_extra)
-- If callback not provided
cb_function = cb_function or ok_cb
cb_extra = cb_extra or false
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Error downloading the image'
send_msg(receiver, text, cb_function, cb_extra)
else
print("File path: "..file_path)
_send_photo(receiver, file_path, cb_function, cb_extra)
end
end
-- Same as send_photo_from_url but as callback function
function send_photo_from_url_callback(cb_extra, success, result)
local receiver = cb_extra.receiver
local url = cb_extra.url
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Error downloading the image'
send_msg(receiver, text, ok_cb, false)
else
print("File path: "..file_path)
_send_photo(receiver, file_path, ok_cb, false)
end
end
-- Send multiple images asynchronous.
-- param urls must be a table.
function send_photos_from_url(receiver, urls)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = nil
}
send_photos_from_url_callback(cb_extra)
end
-- Use send_photos_from_url.
-- This function might be difficult to understand.
function send_photos_from_url_callback(cb_extra, success, result)
-- cb_extra is a table containing receiver, urls and remove_path
local receiver = cb_extra.receiver
local urls = cb_extra.urls
local remove_path = cb_extra.remove_path
-- The previously image to remove
if remove_path ~= nil then
os.remove(remove_path)
print("Deleted: "..remove_path)
end
-- Nil or empty, exit case (no more urls)
if urls == nil or #urls == 0 then
return false
end
-- Take the head and remove from urls table
local head = table.remove(urls, 1)
local file_path = download_to_file(head, false)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = file_path
}
-- Send first and postpone the others as callback
send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra)
end
-- Callback to remove a file
function rmtmp_cb(cb_extra, success, result)
local file_path = cb_extra.file_path
local cb_function = cb_extra.cb_function or ok_cb
local cb_extra = cb_extra.cb_extra
if file_path ~= nil then
os.remove(file_path)
print("Deleted: "..file_path)
end
-- Finally call the callback
cb_function(cb_extra, success, result)
end
-- Send document to user and delete it when finished.
-- cb_function and cb_extra are optionals callback
function _send_document(receiver, file_path, cb_function, cb_extra)
local cb_extra = {
file_path = file_path,
cb_function = cb_function or ok_cb,
cb_extra = cb_extra or false
}
-- Call to remove with optional callback
send_document(receiver, file_path, rmtmp_cb, cb_extra)
end
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_document_from_url(receiver, url, cb_function, cb_extra)
local file_path = download_to_file(url, false)
print("File path: "..file_path)
_send_document(receiver, file_path, cb_function, cb_extra)
end
-- Parameters in ?a=1&b=2 style
function format_http_params(params, is_get)
local str = ''
-- If is get add ? to the beginning
if is_get then str = '?' end
local first = true -- Frist param
for k,v in pairs (params) do
if v then -- nil value
if first then
first = false
str = str..k.. "="..v
else
str = str.."&"..k.. "="..v
end
end
end
return str
end
-- Check if user can use the plugin and warns user
-- Returns true if user was warned and false if not warned (is allowed)
function warns_user_not_allowed(plugin, msg)
if not user_allowed(plugin, msg) then
local text = 'This plugin requires privileged user'
local receiver = get_receiver(msg)
send_msg(receiver, text, ok_cb, false)
return true
else
return false
end
end
-- Check if user can use the plugin
function user_allowed(plugin, msg)
if plugin.privileged and not is_sudo(msg) then
return false
end
return true
end
function send_order_msg(destination, msgs)
local cb_extra = {
destination = destination,
msgs = msgs
}
send_order_msg_callback(cb_extra, true)
end
function send_order_msg_callback(cb_extra, success, result)
local destination = cb_extra.destination
local msgs = cb_extra.msgs
local file_path = cb_extra.file_path
if file_path ~= nil then
os.remove(file_path)
print("Deleted: " .. file_path)
end
if type(msgs) == 'string' then
send_large_msg(destination, msgs)
elseif type(msgs) ~= 'table' then
return
end
if #msgs < 1 then
return
end
local msg = table.remove(msgs, 1)
local new_cb_extra = {
destination = destination,
msgs = msgs
}
if type(msg) == 'string' then
send_msg(destination, msg, send_order_msg_callback, new_cb_extra)
elseif type(msg) == 'table' then
local typ = msg[1]
local nmsg = msg[2]
new_cb_extra.file_path = nmsg
if typ == 'document' then
send_document(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'image' or typ == 'photo' then
send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'audio' then
send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'video' then
send_video(destination, nmsg, send_order_msg_callback, new_cb_extra)
else
send_file(destination, nmsg, send_order_msg_callback, new_cb_extra)
end
end
end
-- Same as send_large_msg_callback but friendly params
function send_large_msg(destination, text)
local cb_extra = {
destination = destination,
text = text
}
send_large_msg_callback(cb_extra, true)
end
-- If text is longer than 4096 chars, send multiple msg.
-- https://core.telegram.org/method/messages.sendMessage
function send_large_msg_callback(cb_extra, success, result)
local text_max = 4096
local destination = cb_extra.destination
local text = cb_extra.text
local text_len = string.len(text)
local num_msg = math.ceil(text_len / text_max)
if num_msg <= 1 then
send_msg(destination, text, ok_cb, false)
else
local my_text = string.sub(text, 1, 4096)
local rest = string.sub(text, 4096, text_len)
local cb_extra = {
destination = destination,
text = rest
}
send_msg(destination, my_text, send_large_msg_callback, cb_extra)
end
end
-- Returns a table with matches or nil
function match_pattern(pattern, text, lower_case)
if text then
local matches = {}
if lower_case then
matches = { string.match(text:lower(), pattern) }
else
matches = { string.match(text, pattern) }
end
if next(matches) then
return matches
end
end
-- nil
end
-- Function to read data from files
function load_from_file(file, default_data)
local f = io.open(file, "r+")
-- If file doesn't exists
if f == nil then
-- Create a new empty table
default_data = default_data or {}
serialize_to_file(default_data, file)
print ('Created file', file)
else
print ('Data loaded from file', file)
f:close()
end
return loadfile (file)()
end
-- See http://stackoverflow.com/a/14899740
function unescape_html(str)
local map = {
["lt"] = "<",
["gt"] = ">",
["amp"] = "&",
["quot"] = '"',
["apos"] = "'"
}
new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s)
var = map[s] or n == "#" and string.char(s)
var = var or n == "#x" and string.char(tonumber(s,16))
var = var or orig
return var
end)
return new
end
--Check if this chat is realm or not
function is_realm(msg)
local var = false
local realms = 'realms'
local data = load_data(_config.moderation.data)
local chat = msg.to.id
if data[tostring(realms)] then
if data[tostring(realms)][tostring(msg.to.id)] then
var = true
end
return var
end
end
--Check if this chat is a group or not
function is_group(msg)
local var = false
local groups = 'groups'
local data = load_data(_config.moderation.data)
local chat = msg.to.id
if data[tostring(groups)] then
if data[tostring(groups)][tostring(msg.to.id)] then
var = true
end
return var
end
end
function savelog(group, logtxt)
local text = (os.date("[ %c ]=> "..logtxt.."\n \n"))
local file = io.open("./groups/logs/"..group.."log.txt", "a")
file:write(text)
file:close()
end
function user_print_name(user)
if user.print_name then
return user.print_name
end
local text = ''
if user.first_name then
text = user.last_name..' '
end
if user.lastname then
text = text..user.last_name
end
return text
end
--Check if user is the owner of that group or not
function is_owner(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['set_owner'] then
if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then
var = true
end
end
end
if data['admins'] then
if data['admins'][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_owner2(user_id, group_id)
local var = false
local data = load_data(_config.moderation.data)
if data[tostring(group_id)] then
if data[tostring(group_id)]['set_owner'] then
if data[tostring(group_id)]['set_owner'] == tostring(user_id) then
var = true
end
end
end
if data['admins'] then
if data['admins'][tostring(user_id)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == user_id then
var = true
end
end
return var
end
--Check if user is admin or not
function is_admin(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
local admins = 'admins'
if data[tostring(admins)] then
if data[tostring(admins)][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_admin2(user_id)
local var = false
local data = load_data(_config.moderation.data)
local user = user_id
local admins = 'admins'
if data[tostring(admins)] then
if data[tostring(admins)][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == user_id then
var = true
end
end
return var
end
--Check if user is the mod of that group or not
function is_momod(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['moderators'] then
if data[tostring(msg.to.id)]['moderators'][tostring(user)] then
var = true
end
end
end
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['set_owner'] then
if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then
var = true
end
end
end
if data['admins'] then
if data['admins'][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_momod2(user_id, group_id)
local var = false
local data = load_data(_config.moderation.data)
local usert = user_id
if data[tostring(group_id)] then
if data[tostring(group_id)]['moderators'] then
if data[tostring(group_id)]['moderators'][tostring(usert)] then
var = true
end
end
end
if data[tostring(group_id)] then
if data[tostring(group_id)]['set_owner'] then
if data[tostring(group_id)]['set_owner'] == tostring(user_id) then
var = true
end
end
end
if data['admins'] then
if data['admins'][tostring(user_id)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == usert then
var = true
end
end
return var
end
-- Returns the name of the sender
function kick_user(user_id, chat_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_owner2(user_id, chat_id) then -- Ignore admins
return
end
local chat = 'chat#id'..chat_id
local user = 'user#id'..user_id
chat_del_user(chat, user, ok_cb, true)
end
-- Ban
function ban_user(user_id, chat_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(user_id) then -- Ignore admins
return
end
-- Save to redis
local hash = 'banned:'..chat_id
redis:sadd(hash, user_id)
-- Kick from chat
kick_user(user_id, chat_id)
end
-- Global ban
function banall_user(user_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(user_id) then -- Ignore admins
return
end
-- Save to redis
local hash = 'gbanned'
redis:sadd(hash, user_id)
end
-- Global unban
function unbanall_user(user_id)
--Save on redis
local hash = 'gbanned'
redis:srem(hash, user_id)
end
-- Check if user_id is banned in chat_id or not
function is_banned(user_id, chat_id)
--Save on redis
local hash = 'banned:'..chat_id
local banned = redis:sismember(hash, user_id)
return banned or false
end
-- Check if user_id is globally banned or not
function is_gbanned(user_id)
--Save on redis
local hash = 'gbanned'
local banned = redis:sismember(hash, user_id)
return banned or false
end
-- Returns chat_id ban list
function ban_list(chat_id)
local hash = 'banned:'..chat_id
local list = redis:smembers(hash)
local text = "Ban list !\n\n"
for k,v in pairs(list) do
text = text..k.." - "..v.." \n"
end
return text
end
-- Returns globally ban list
function banall_list()
local hash = 'gbanned'
local list = redis:smembers(hash)
local text = "global bans !\n\n"
for k,v in pairs(list) do
text = text..k.." - "..v.." \n"
end
return text
end
-- /id by reply
function get_message_callback_id(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
send_large_msg(chat, result.from.id)
else
return 'Use This in Your Groups'
end
end
-- kick by reply for mods and owner
function Kick_by_reply(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't kick myself"
end
if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin
return "you can't kick mods,owner and admins"
end
chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false)
else
return 'Use This in Your Groups'
end
end
-- Kick by reply for admins
function Kick_by_reply_admins(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't kick myself"
end
if is_admin2(result.from.id) then -- Ignore admins
return
end
chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false)
else
return 'Use This in Your Groups'
end
end
--Ban by reply for admins
function ban_by_reply(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't ban myself"
end
if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin
return "you can't kick mods,owner and admins"
end
ban_user(result.from.id, result.to.id)
send_large_msg(chat, "User "..result.from.id.." Banned")
else
return 'Use This in Your Groups'
end
end
-- Ban by reply for admins
function ban_by_reply_admins(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't ban myself"
end
if is_admin2(result.from.id) then -- Ignore admins
return
end
ban_user(result.from.id, result.to.id)
send_large_msg(chat, "User "..result.from.id.." Banned")
else
return 'Use This in Your Groups'
end
end
-- Unban by reply
function unban_by_reply(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't unban myself"
end
send_large_msg(chat, "User "..result.from.id.." Unbanned")
-- Save on redis
local hash = 'banned:'..result.to.id
redis:srem(hash, result.from.id)
else
return 'Use This in Your Groups'
end
end
function banall_by_reply(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't banall myself"
end
if is_admin2(result.from.id) then -- Ignore admins
return
end
local name = user_print_name(result.from)
banall_user(result.from.id)
chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false)
send_large_msg(chat, "User "..name.."["..result.from.id.."] hammered")
else
return 'Use This in Your Groups'
end
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/globals/abilities/animated_flourish.lua | 26 | 2177 | -----------------------------------
-- Ability: Animated Flourish
-- Provokes the target. Requires at least one, but uses two Finishing Moves.
-- Obtained: Dancer Level 20
-- Finishing Moves Used: 1-2
-- Recast Time: 00:30
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
-----------------------------------
-- onAbilityCheck
-----------------------------------
function onAbilityCheck(player,target,ability)
if (player:hasStatusEffect(EFFECT_FINISHING_MOVE_1)) then
return 0,0;
elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_2)) then
return 0,0;
elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_3)) then
return 0,0;
elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_4)) then
return 0,0;
elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_5)) then
return 0,0;
else
return MSGBASIC_NO_FINISHINGMOVES,0;
end;
end;
-----------------------------------
-- onUseAbility
-----------------------------------
function onUseAbility(player,target,ability)
if (player:hasStatusEffect(EFFECT_FINISHING_MOVE_1)) then
player:delStatusEffect(EFFECT_FINISHING_MOVE_1);
--Add extra enmity if 2 finishing moves are used
elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_2)) then
player:delStatusEffect(EFFECT_FINISHING_MOVE_2);
target:addEnmity(player, 0, 500);
elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_3)) then
player:delStatusEffectSilent(EFFECT_FINISHING_MOVE_3);
player:addStatusEffect(EFFECT_FINISHING_MOVE_1,1,0,7200);
target:addEnmity(player, 0, 500);
elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_4)) then
player:delStatusEffectSilent(EFFECT_FINISHING_MOVE_4);
player:addStatusEffect(EFFECT_FINISHING_MOVE_2,1,0,7200);
target:addEnmity(player, 0, 500);
elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_5)) then
player:delStatusEffectSilent(EFFECT_FINISHING_MOVE_5);
player:addStatusEffect(EFFECT_FINISHING_MOVE_3,1,0,7200);
target:addEnmity(player, 0, 500);
end;
end; | gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c78564023.lua | 9 | 1267 | --BF-二の太刀のエテジア
function c78564023.initial_effect(c)
--atkup
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(78564023,0))
e1:SetCategory(CATEGORY_DAMAGE)
e1:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_FIELD)
e1:SetCode(EVENT_DAMAGE_STEP_END)
e1:SetRange(LOCATION_HAND)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetCondition(c78564023.condition)
e1:SetCost(c78564023.cost)
e1:SetTarget(c78564023.target)
e1:SetOperation(c78564023.operation)
c:RegisterEffect(e1)
end
function c78564023.condition(e,tp,eg,ep,ev,re,r,rp)
local a=Duel.GetAttacker()
local d=Duel.GetAttackTarget()
return a:IsControler(tp) and a:IsSetCard(0x33) and a:IsRelateToBattle() and d and d:IsRelateToBattle()
end
function c78564023.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 c78564023.target(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_DAMAGE,nil,0,1-tp,1000)
end
function c78564023.operation(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 |
dr01d3r/darkstar | scripts/zones/Gusgen_Mines/npcs/Clay.lua | 14 | 1229 | -----------------------------------
-- Area: Gusgen Mines
-- NPC: Clay
-- Involved in Quest: A Potter's Preference
-- @pos 117 -21 432 196
-----------------------------------
package.loaded["scripts/zones/Gusgen_Mines/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/titles");
require("scripts/globals/quests");
require("scripts/globals/settings");
require("scripts/zones/Gusgen_Mines/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:addItem(569,1); --569 - dish_of_gusgen_clay
player:messageSpecial(ITEM_OBTAINED,569); -- dish_of_gusgen_clay
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID2: %u",csid);
-- printf("RESULT2: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
pmembrey/wireshark | epan/wslua/dtd_gen.lua | 38 | 8369 | -- dtd_gen.lua
--
-- a DTD generator for wireshark
--
-- (c) 2006 Luis E. Garcia Ontanon <luis@ontanon.org>
--
-- Wireshark - Network traffic analyzer
-- By Gerald Combs <gerald@wireshark.org>
-- Copyright 1998 Gerald Combs
--
-- 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.
if gui_enabled() then
local xml_fld = Field.new("xml")
local function dtd_generator()
local displayed = {} -- whether or not a dtd is already displayed
local dtds = {} -- the dtds
local changed = {} -- whether or not a dtd has been modified
local dtd -- the dtd being dealt with
local dtd_name -- its name
-- we'll tap onto every frame that has xml
local ws = {} -- the windows for each dtd
local w = TextWindow.new("DTD Generator")
local function help()
local wh = TextWindow.new("DTD Generator Help")
-- XXX write help
wh:set('DTD Generator Help\n')
end
local function get_dtd_from_xml(text,d,parent)
-- obtains dtd information from xml
-- text: xml to be parsed
-- d: the current dtd (if any)
-- parent: parent entity (if any)
-- cleanup the text from useless chars
text = string.gsub(text ,"%s*<%s*","<");
text = string.gsub(text ,"%s*>%s*",">");
text = string.gsub(text ,"<%-%-(.-)%-%->"," ");
text = string.gsub(text ,"%s+"," ");
while true do
-- find the first tag
local open_tag = string.match(text,"%b<>")
if open_tag == nil then
-- no more tags, we're done
return true
end
local name = string.match(open_tag,"[%w%d_-]+")
local this_ent = nil
if d == nil then
-- there's no current dtd, this is entity is it
d = dtds[name]
if d == nil then
d = {ents = {}, attrs = {}}
dtds[name] = d
end
dtd = d
dtd_name = name
end
this_ent = d[name]
if this_ent == nil then
-- no entity by this name in this dtd, create it
this_ent = {ents = {}, attrs = {}}
d.ents[name] = this_ent
changed[dtd_name] = true
end
if parent ~= nil then
-- add this entity to its parent
parent.ents[name] = 1
changed[dtd_name] = true
end
-- add the attrs to the entity
for att in string.gmatch(open_tag, "([%w%d_-]+)%s*=") do
if not this_ent.attrs[att] then
changed[dtd_name] = true
this_ent.attrs[att] = true
end
end
if string.match(open_tag,"/>") then
-- this tag is "self closed" just remove it and continue
text = string.gsub(text,"%b<>","",1)
else
local close_tag_pat = "</%s*" .. name .. "%s*>"
if not string.match(text,close_tag_pat) then return false end
local span,left = string.match(text,"%b<>(.-)" .. close_tag_pat .. "(.*)")
if span ~= nil then
-- recurse to find child entities
if not get_dtd_from_xml(span,d,this_ent) then
return false
end
end
-- continue with what's left
text = left
end
end
return true
end
local function entity_tostring(name,entity_data)
-- name: the name of the entity
-- entity_data: a table containg the entity data
-- returns the dtd text for that entity
local text = ''
text = text .. '\t<!ELEMENT ' .. name .. ' (' --)
for e,j in pairs(entity_data.ents) do
text = text .. " " .. e .. ' |'
end
text = text .. " #PCDATA ) >\n"
text = text .. "\t<!ATTLIST " .. name
for a,j in pairs(entity_data.attrs) do
text = text .. "\n\t\t" .. a .. ' CDTATA #IMPLIED'
end
text = text .. " >\n\n"
text = string.gsub(text,"<!ATTLIST " .. name .. " >\n","")
return text
end
local function dtd_tostring(name,doctype)
local text = '<? wireshark:protocol proto_name="' .. name ..'" hierarchy="yes" ?>\n\n'
local root = doctype.ents[name]
doctype.ents[name] = nil
text = text .. entity_tostring(name,root)
for n,es in pairs(doctype.ents) do
text = text .. entity_tostring(n,es)
end
doctype.ents[name] = root
return text
end
local function element_body(name,text)
-- get the entity's children from dtd text
-- name: the name of the element
-- text: the list of children
text = string.gsub(text,"[%s%?%*%#%+%(%)]","")
text = string.gsub(text,"$","|")
text = string.gsub(text,
"^(.-)|",
function(s)
if dtd.ents[name] == nil then
dtd.ents[name] = {ents={},attrs={}}
end
dtd.ents[name].ents[s] = true
return ""
end
)
return ''
end
local function attlist_body(name,text)
-- get the entity's attributes from dtd text
-- name: the name of the element
-- text: the list of attributes
text = string.gsub(text,"([%w%d_-]+) [A-Z]+ #[A-Z]+",
function(s)
dtd.atts[s] = true
return ""
end
)
return ''
end
local function dtd_body(buff)
-- get the dtd's entities from dtd text
-- buff: the dtd text
local old_buff = buff
buff = string.gsub(buff,"<!ELEMENT ([%w%d_-]+) (%b())>%s*",element_body)
buff = string.gsub(buff,"<!ATTLIST ([%w%d_-]+) (.-)>%s*",attlist_body)
end
local function load_dtd(filename)
local dtd_filename = USER_DIR .. "/dtds/" .. filename
local buff = ''
local wireshark_info
dtd_name = nil
dtd = nil
for line in io.lines(dtd_filename) do
buff = buff .. line
end
buff = string.gsub(buff ,"%s*<%!%s*","<!");
buff = string.gsub(buff ,"%s*>%s*",">");
buff = string.gsub(buff ,"<!%-%-(.-)%-%->"," ");
buff = string.gsub(buff ,"%s+"," ");
buff = string.gsub(buff ,"^%s+","");
buff = string.gsub(buff,'(<%?%s*wireshark:protocol%s+.-%s*%?>)',
function(s)
wireshark_info = s
end
)
buff = string.gsub(buff,"^<!DOCTYPE ([%w%d_-]+) (%b[])%s*>",
function(name,body)
dtd = { ents = {}, attrs = {}}
dtd_name = name
dtds[name] = dtd
dtd_body(body)
return ""
end
)
if not dtd then
dtd_body(buff)
end
if wireshark_info then
dtd.wstag = wireshark_info
end
end
local function load_dtds()
-- loads all existing dtds in the user directory
local dirname = persconffile_path("dtds")
local status, dir = pcall(Dir.open,dirname,".dtd")
w:set('Loading DTDs from ' .. dirname .. ' \n')
if not status then
w:append("Error: could not open the directory" .. dirname .. " , make sure it exists.\n")
return
end
for dtd_filename in dir do
w:append("File:" .. dtd_filename .. "\n")
load_dtd(dtd_filename)
end
end
local function dtd_window(name)
return function()
local wd = TextWindow.new(name .. '.dtd')
wd:set(dtd_tostring(name,dtds[name]))
wd:set_editable()
local function save()
local file = io.open(persconffile_path("dtds/") .. name .. ".dtd" ,"w")
file:write(wd:get_text())
file:close()
end
wd:add_button("Save",save)
end
end
local function close()
if li ~= nil then
li:remove()
li = nil
end
end
w:set_atclose(close)
-- w:add_button("Help",help)
load_dtds()
local li = Listener.new("frame","xml")
w:append('Running')
function li.packet()
w:append('.')
local txt = xml_fld().range:string();
get_dtd_from_xml(txt)
end
function li.draw()
for name,j in pairs(changed) do
w:append("\n" .. name .. " has changed\n")
if not displayed[name] then
w:add_button(name,dtd_window(name))
displayed[name] = true
end
end
end
retap_packets()
w:append(t2s(dtds))
w:append('\n')
end
register_menu("DTD Generator",dtd_generator,MENU_TOOLS_UNSORTED)
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c60082869.lua | 3 | 1349 | --砂塵の大竜巻
function c60082869.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,TIMING_END_PHASE)
e1:SetTarget(c60082869.target)
e1:SetOperation(c60082869.activate)
c:RegisterEffect(e1)
end
function c60082869.filter(c)
return c:IsType(TYPE_SPELL+TYPE_TRAP)
end
function c60082869.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() and chkc:IsControler(1-tp) and c60082869.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c60082869.filter,tp,0,LOCATION_ONFIELD,1,e:GetHandler()) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,c60082869.filter,tp,0,LOCATION_ONFIELD,1,1,e:GetHandler())
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
end
function c60082869.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc and tc:IsRelateToEffect(e) and Duel.Destroy(tc,REASON_EFFECT)~=0 then
local g=Duel.GetMatchingGroup(Card.IsSSetable,tp,LOCATION_HAND,0,nil)
if g:GetCount()>0 and Duel.SelectYesNo(tp,aux.Stringid(60082869,0)) then
Duel.BreakEffect()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET)
local sg=g:Select(tp,1,1,nil)
Duel.SSet(tp,sg:GetFirst())
end
end
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/globals/abilities/beast_roll.lua | 19 | 2633 | -----------------------------------
-- Ability: Beast Roll
-- Enhances pet attacks for party members within area of effect
-- Optimal Job: Beastmaster
-- Lucky Number: 4
-- Unlucky Number: 8
-- Level: 34
--
-- Die Roll |No BST |With BST
-- -------- -------- -----------
-- 1 |16 |41
-- 2 |20 |45
-- 3 |24 |49
-- 4 |64 |89
-- 5 |28 |53
-- 6 |32 |57
-- 7 |40 |65
-- 8 |8 |33
-- 9 |44 |69
-- 10 |48 |73
-- 11 |80 |105
-- Bust |-25 |-25
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/ability");
-----------------------------------
-- onAbilityCheck
-----------------------------------
function onAbilityCheck(player,target,ability)
local effectID = EFFECT_BEAST_ROLL
ability:setRange(ability:getRange() + player:getMod(MOD_ROLL_RANGE));
if (player:hasStatusEffect(effectID)) then
return MSGBASIC_ROLL_ALREADY_ACTIVE,0;
elseif atMaxCorsairBusts(player) then
return MSGBASIC_CANNOT_PERFORM,0;
else
return 0,0;
end
end;
-----------------------------------
-- onUseAbility
-----------------------------------
function onUseAbility(caster,target,ability,action)
if (caster:getID() == target:getID()) then
corsairSetup(caster, ability, action, EFFECT_BEAST_ROLL, JOBS.BST);
end
local total = caster:getLocalVar("corsairRollTotal")
return applyRoll(caster,target,ability,action,total)
end;
function applyRoll(caster,target,ability,action,total)
local duration = 300 + caster:getMerit(MERIT_WINNING_STREAK)
local effectpowers = {4, 5, 7, 19, 8, 9, 11, 2, 13, 14, 23, 7}
local effectpower = effectpowers[total];
if (caster:getLocalVar("corsairRollBonus") == 1 and total < 12) then
effectpower = effectpower + 10
end
if (caster:getMainJob() == JOBS.COR and caster:getMainLvl() < target:getMainLvl()) then
effectpower = effectpower * (caster:getMainLvl() / target:getMainLvl());
elseif (caster:getSubJob() == JOBS.COR and caster:getSubLvl() < target:getMainLvl()) then
effectpower = effectpower * (caster:getSubLvl() / target:getMainLvl());
end
if (target:addCorsairRoll(caster:getMainJob(), caster:getMerit(MERIT_BUST_DURATION), EFFECT_BEAST_ROLL, effectpower, 0, duration, caster:getID(), total, MOD_PET_ATTP) == false) then
ability:setMsg(422);
elseif total > 11 then
ability:setMsg(426);
end
return total;
end
| gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c20073910.lua | 2 | 2379 | --天照大神
function c20073910.initial_effect(c)
--spirit
aux.EnableSpiritReturn(c,EVENT_FLIP)
--summon limit
local e1=Effect.CreateEffect(c)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CANNOT_SUMMON)
c:RegisterEffect(e1)
--spsummon limit
local e2=Effect.CreateEffect(c)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_SPSUMMON_CONDITION)
e2:SetValue(aux.FALSE)
c:RegisterEffect(e2)
--be target
local e3=Effect.CreateEffect(c)
e3:SetCategory(CATEGORY_DRAW)
e3:SetType(EFFECT_TYPE_QUICK_O)
e3:SetCode(EVENT_CHAINING)
e3:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
e3:SetRange(LOCATION_MZONE)
e3:SetCondition(c20073910.condition)
e3:SetCost(c20073910.cost)
e3:SetTarget(c20073910.target)
e3:SetOperation(c20073910.operation)
c:RegisterEffect(e3)
--flip
local e4=Effect.CreateEffect(c)
e4:SetCategory(CATEGORY_TOHAND)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e4:SetCode(EVENT_FLIP)
e4:SetTarget(c20073910.thtg)
e4:SetOperation(c20073910.thop)
c:RegisterEffect(e4)
end
function c20073910.condition(e,tp,eg,ep,ev,re,r,rp)
if rp==tp or not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then return false end
local tg=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS)
return tg:IsContains(e:GetHandler()) and e:GetHandler():IsFacedown()
end
function c20073910.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.ChangePosition(e:GetHandler(),POS_FACEUP_DEFENSE)
end
function c20073910.target(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 c20073910.operation(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
function c20073910.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local g=Duel.GetMatchingGroup(Card.IsAbleToRemove,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,e:GetHandler())
Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,g:GetCount(),0,0)
end
function c20073910.thop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(Card.IsAbleToRemove,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,e:GetHandler())
Duel.Remove(g,POS_FACEUP,REASON_EFFECT)
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/zones/Grand_Palace_of_HuXzoi/mobs/Ix_aern_mnk.lua | 17 | 3000 | -----------------------------------
-- Area: Grand Palace of HuXzoi
-- MOB: Ix_aern_mnk
-- ID: 16916815
-----------------------------------
require("scripts/globals/status");
-----------------------------------
-- onMobInitialize Action
-----------------------------------
function onMobInitialize(mob)
end;
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
local QuestionMark = 16916819; -- The ??? that spawned this mob.
local chance = GetNPCByID(QuestionMark):getLocalVar("[SEA]IxAern_DropRate"); -- Adjust drop rate for the items based on the organs traded to the ???.
if (math.random(0,1) > 0) then
SetDropRate(4398,1851,chance*10); -- Deed Of Placidity
SetDropRate(4398,1901,0);
else
SetDropRate(4398,1851,0);
SetDropRate(4398,1901,chance*10); -- Vice of Antipathy
end
GetNPCByID(QuestionMark):setLocalVar("[SEA]IxAern_DropRate", 0); -- Clears the var from the ???.
mob:AnimationSub(1); -- Reset the subanim - otherwise it will respawn with bracers on. Note that Aerns are never actually supposed to be in subanim 0.
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
end;
-----------------------------------
-- onMobFight Action
-----------------------------------
function onMobFight(mob,target)
-- The mob gains a huge boost when it 2hours to attack speed and attack.
-- It forces the minions to 2hour as well. Wiki says 50% but all videos show 60%.
if (mob:getLocalVar("BracerMode") == 0) then
if (mob:getHPP() < math.random(50,60)) then
-- Go into bracer mode
mob:setLocalVar("BracerMode",1);
mob:AnimationSub(2); -- Puts on the bracers! He gonna fuck you up now.
mob:addMod(MOD_ATT, 200);
mob:addMod(MOD_HASTE_ABILITY, 150);
mob:useMobAbility(3411); -- Hundred Fists
-- Force minions to 2hour
if (GetMobAction(mob:getID()+1) ~= 0) then
GetMobByID(mob:getID()+1):useMobAbility(3412); -- Chainspell
end
if (GetMobAction(mob:getID()+2) ~= 0) then
GetMobByID(mob:getID()+2):useMobAbility(3413); -- Benediction
end
end;
end;
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
-- Despawn his minions if they are alive (Qn'aern)
DespawnMob(mob:getID()+1);
DespawnMob(mob:getID()+2);
end;
-----------------------------------
-- onMobDespawn
-----------------------------------
function onMobDespawn(mob)
-- Despawn his minions if they are alive (Qn'aern)
DespawnMob(mob:getID()+1);
DespawnMob(mob:getID()+2);
local QuestionMark = GetNPCByID(16916819); -- The ??? that spawned this mob.
QuestionMark:updateNPCHideTime(FORCE_SPAWN_QM_RESET_TIME);
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Windurst_Waters/npcs/Gantineux.lua | 14 | 2525 | -----------------------------------
-- Area: Windurst Waters
-- NPC: Gantineux
-- Starts Quest: Acting in Good Faith
-- @zone 238
-- @pos -83 -9 3
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/shop");
require("scripts/globals/quests");
require("scripts/zones/Windurst_Waters/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
ActingInGoodFaith = player:getQuestStatus(WINDURST,ACTING_IN_GOOD_FAITH);
if (ActingInGoodFaith == QUEST_AVAILABLE and player:getFameLevel(WINDURST) >= 4 and player:getMainLvl() >= 10) then
player:startEvent(0x2723); -- Start quest "Acting in Good Faith"
elseif (ActingInGoodFaith == QUEST_ACCEPTED) then
if (player:hasKeyItem(SPIRIT_INCENSE) == true) then
player:startEvent(0x2724); -- During quest "Acting in Good Faith" (with Spirit Incense KI)
elseif (player:hasKeyItem(GANTINEUXS_LETTER) == true) then
player:startEvent(0x2726); -- During quest "Acting in Good Faith" (with Gantineux's Letter)
else
player:startEvent(0x2725); -- During quest "Acting in Good Faith" (before Gantineux's Letter)
end
elseif (ActingInGoodFaith == QUEST_COMPLETED) then
player:startEvent(0x2727); -- New standard dialog after "Acting in Good Faith"
else
player:startEvent(0x2722); -- Standard dialog
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x2723 and option == 0) then
player:addQuest(WINDURST,ACTING_IN_GOOD_FAITH);
player:addKeyItem(SPIRIT_INCENSE);
player:messageSpecial(KEYITEM_OBTAINED,SPIRIT_INCENSE);
elseif (csid == 0x2725) then
player:addKeyItem(GANTINEUXS_LETTER);
player:messageSpecial(KEYITEM_OBTAINED,GANTINEUXS_LETTER);
end
end;
| gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c2295831.lua | 2 | 1975 | --ピースの輪
function c2295831.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_TO_HAND)
e1:SetCondition(c2295831.regcon)
e1:SetOperation(c2295831.regop)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e2:SetType(EFFECT_TYPE_ACTIVATE)
e2:SetCode(EVENT_FREE_CHAIN)
e2:SetCondition(c2295831.condition)
e2:SetCost(c2295831.cost)
e2:SetTarget(c2295831.target)
e2:SetOperation(c2295831.activate)
c:RegisterEffect(e2)
end
function c2295831.regcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return Duel.GetFieldGroupCount(tp,LOCATION_ONFIELD,0)==0 and Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE)>=3
and Duel.GetCurrentPhase()==PHASE_DRAW and c:IsReason(REASON_DRAW) and c:IsReason(REASON_RULE)
end
function c2295831.regop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if Duel.SelectYesNo(tp,aux.Stringid(2295831,0)) then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_PUBLIC)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_MAIN1)
c:RegisterEffect(e1)
c:RegisterFlagEffect(2295831,RESET_PHASE+PHASE_MAIN1,EFFECT_FLAG_CLIENT_HINT,1,0,66)
end
end
function c2295831.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()==PHASE_MAIN1
end
function c2295831.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():GetFlagEffect(2295831)~=0 end
end
function c2295831.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToHand,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c2295831.activate(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,Card.IsAbleToHand,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 |
SalvationDevelopment/Salvation-Scripts-Production | c31991800.lua | 2 | 1710 | --マジェスペクター・ラクーン
function c31991800.initial_effect(c)
--pendulum summon
aux.EnablePendulumAttribute(c)
--search
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_SUMMON_SUCCESS)
e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
e2:SetCountLimit(1,31991800)
e2:SetTarget(c31991800.thtg)
e2:SetOperation(c31991800.thop)
c:RegisterEffect(e2)
local e3=e2:Clone()
e3:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e3)
--cannot target
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e4:SetRange(LOCATION_MZONE)
e4:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
e4:SetValue(aux.tgoval)
c:RegisterEffect(e4)
--indes
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_SINGLE)
e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e5:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
e5:SetRange(LOCATION_MZONE)
e5:SetValue(c31991800.indval)
c:RegisterEffect(e5)
end
function c31991800.thfilter(c)
return c:IsSetCard(0xd0) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
end
function c31991800.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c31991800.thfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c31991800.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c31991800.thfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
function c31991800.indval(e,re,tp)
return tp~=e:GetHandlerPlayer()
end
| gpl-2.0 |
koreader/koreader | frontend/apps/reader/modules/readersearch.lua | 4 | 17598 | local BD = require("ui/bidi")
local ButtonDialog = require("ui/widget/buttondialog")
local CheckButton = require("ui/widget/checkbutton")
local Device = require("device")
local InfoMessage = require("ui/widget/infomessage")
local InputDialog = require("ui/widget/inputdialog")
local Notification = require("ui/widget/notification")
local UIManager = require("ui/uimanager")
local WidgetContainer = require("ui/widget/container/widgetcontainer")
local logger = require("logger")
local _ = require("gettext")
local Screen = Device.screen
local T = require("ffi/util").template
local DGENERIC_ICON_SIZE = G_defaults:readSetting("DGENERIC_ICON_SIZE")
local ReaderSearch = WidgetContainer:extend{
direction = 0, -- 0 for search forward, 1 for search backward
case_insensitive = true, -- default to case insensitive
-- For a regex like [a-z\. ] many many hits are found, maybe the number of chars on a few pages.
-- We don't try to catch them all as this is a reader and not a computer science playground. ;)
-- So if some regex gets more than max_hits a notification will be shown.
-- Increasing max_hits will slow down search for nasty regex. There is no slowdown for friendly
-- regexs like `Max|Moritz` for `One|Two|Three`
-- The speed of the search depends on the regexs. Complex ones might need some time, easy ones
-- go with the speed of light.
-- Setting max_hits higher, does not mean to require more memory. More hits means smaller single hits.
max_hits = 2048, -- maximum hits for search; timinges tested on a Tolino
-- internal: whether we expect results on previous pages
-- (can be different from self.direction, if, from a page in the
-- middle of a book, we search forward from start of book)
_expect_back_results = false,
}
function ReaderSearch:init()
self.ui.menu:registerToMainMenu(self)
end
local help_text = _([[
Regular expressions allow you to search for a matching pattern in a text. The simplest pattern is a simple sequence of characters, such as `James Bond`. There are many different varieties of regular expressions, but we support the ECMAScript syntax. The basics will be explained below.
If you want to search for all occurrences of 'Mister Moore', 'Sir Moore' or 'Alfons Moore' but not for 'Lady Moore'.
Enter 'Mister Moore|Sir Moore|Alfons Moore'.
If your search contains a special character from ^$.*+?()[]{}|\/ you have to put a \ before that character.
Examples:
Words containing 'os' -> '[^ ]+os[^ ]+'
Any single character '.' -> 'r.nge'
Any characters '.*' -> 'J.*s'
Numbers -> '[0-9]+'
Character range -> '[a-f]'
Not a space -> '[^ ]'
A word -> '[^ ]*[^ ]'
Last word in a sentence -> '[^ ]*\.'
Complex expressions may lead to an extremely long search time, in which case not all matches will be shown.]])
local SRELL_ERROR_CODES = {}
SRELL_ERROR_CODES[102] = _("Wrong escape '\\'")
SRELL_ERROR_CODES[103] = _("Back reference does not exist.")
SRELL_ERROR_CODES[104] = _("Mismatching brackets '[]'")
SRELL_ERROR_CODES[105] = _("Mismatched parens '()'")
SRELL_ERROR_CODES[106] = _("Mismatched brace '{}'")
SRELL_ERROR_CODES[107] = _("Invalid Range in '{}'")
SRELL_ERROR_CODES[108] = _("Invalid character range")
SRELL_ERROR_CODES[110] = _("No preceding expression in repetition.")
SRELL_ERROR_CODES[111] = _("Expression too complex, some hits will not be shown.")
SRELL_ERROR_CODES[666] = _("Expression may lead to an extremely long search time.")
function ReaderSearch:addToMainMenu(menu_items)
menu_items.fulltext_search = {
text = _("Fulltext search"),
callback = function()
self:onShowFulltextSearchInput()
end,
}
end
-- if reverse ~= 0 search backwards
function ReaderSearch:searchCallback(reverse)
local search_text = self.input_dialog:getInputText()
if search_text == "" then return end
self.last_search_text = search_text
self.use_regex = self.check_button_regex.checked
self.case_insensitive = not self.check_button_case.checked
local regex_error = self.use_regex and self.ui.document:checkRegex(search_text)
if self.use_regex and regex_error ~= 0 then
logger.dbg("ReaderSearch: regex error", regex_error, SRELL_ERROR_CODES[regex_error])
local error_message
if SRELL_ERROR_CODES[regex_error] then
error_message = T(_("Invalid regular expression:\n%1"), SRELL_ERROR_CODES[regex_error])
else
error_message = _("Invalid regular expression.")
end
UIManager:show(InfoMessage:new{ text = error_message })
else
UIManager:close(self.input_dialog)
self:onShowSearchDialog(search_text, reverse, self.use_regex, self.case_insensitive)
end
end
function ReaderSearch:onShowFulltextSearchInput()
local backward_text = "◁"
local forward_text = "▷"
if BD.mirroredUILayout() then
backward_text, forward_text = forward_text, backward_text
end
self.input_dialog = InputDialog:new{
title = _("Enter text to search for"),
width = math.floor(math.min(Screen:getWidth(), Screen:getHeight()) * 0.9),
input = self.last_search_text,
buttons = {
{
{
text = _("Cancel"),
id = "close",
callback = function()
UIManager:close(self.input_dialog)
end,
},
{
text = backward_text,
callback = function()
self:searchCallback(1)
end,
},
{
text = forward_text,
is_enter_default = true,
callback = function()
self:searchCallback(0)
end,
},
},
},
}
self.check_button_case = CheckButton:new{
text = _("Case sensitive"),
checked = not self.case_insensitive,
parent = self.input_dialog,
}
self.input_dialog:addWidget(self.check_button_case)
self.check_button_regex = CheckButton:new{
text = _("Regular expression (long-press for help)"),
checked = self.use_regex,
parent = self.input_dialog,
hold_callback = function()
UIManager:show(InfoMessage:new{
text = help_text,
width = Screen:getWidth() * 0.9,
})
end,
}
if self.ui.rolling then
self.input_dialog:addWidget(self.check_button_regex)
end
UIManager:show(self.input_dialog)
self.input_dialog:onShowKeyboard()
end
function ReaderSearch:onShowSearchDialog(text, direction, regex, case_insensitive)
local neglect_current_location = false
local current_page
local function isSlowRegex(pattern)
if pattern:find("%[") or pattern:find("%*") or pattern:find("%?") or pattern:find("%.") then
return true
end
return false
end
local do_search = function(search_func, search_term, param)
return function()
local no_results = true -- for notification
local res = search_func(self, search_term, param, regex, case_insensitive)
if res then
if self.ui.document.info.has_pages then
no_results = false
self.ui.link:onGotoLink({page = res.page - 1}, neglect_current_location)
self.view.highlight.temp[res.page] = res
else
-- Was previously just:
-- self.ui.link:onGotoLink(res[1].start, neglect_current_location)
-- To avoid problems with edge cases, crengine may now give us links
-- that are on previous/next page of the page we should show. And
-- sometimes even xpointers that resolve to no page.
-- We need to loop thru all the results until we find one suitable,
-- to follow its link and go to the next/prev page with occurences.
local valid_link
-- If backward search, results are already in a reversed order, so we'll
-- start from the nearest to current page one.
for _, r in ipairs(res) do
-- result's start and end may be on different pages, we must
-- consider both
local r_start = r["start"]
local r_end = r["end"]
local r_start_page = self.ui.document:getPageFromXPointer(r_start)
local r_end_page = self.ui.document:getPageFromXPointer(r_end)
logger.dbg("res.start page & xpointer:", r_start_page, r_start)
logger.dbg("res.end page & xpointer:", r_end_page, r_end)
local bounds = {}
if self._expect_back_results then
-- Process end of occurence first, which is nearest to current page
table.insert(bounds, {r_end, r_end_page})
table.insert(bounds, {r_start, r_start_page})
else
table.insert(bounds, {r_start, r_start_page})
table.insert(bounds, {r_end, r_end_page})
end
for _, b in ipairs(bounds) do
local xpointer = b[1]
local page = b[2]
-- Look if it is valid for us
if page then -- it should resolve to a page
if not current_page then -- initial search
-- We can (and should if there are) display results on current page
current_page = self.ui.document:getCurrentPage()
if (self._expect_back_results and page <= current_page) or
(not self._expect_back_results and page >= current_page) then
valid_link = xpointer
end
else -- subsequent searches
-- We must change page, so only consider results from
-- another page, in the adequate search direction
current_page = self.ui.document:getCurrentPage()
if (self._expect_back_results and page < current_page) or
(not self._expect_back_results and page > current_page) then
valid_link = xpointer
end
end
end
if valid_link then
break
end
end
if valid_link then
break
end
end
if valid_link then
no_results = false
self.ui.link:onGotoLink({xpointer=valid_link}, neglect_current_location)
end
end
-- Don't add result pages to location ("Go back") stack
neglect_current_location = true
end
if no_results then
local notification_text
if self._expect_back_results then
notification_text = _("No results on preceding pages")
else
notification_text = _("No results on following pages")
end
UIManager:show(Notification:new{
text = notification_text,
})
end
end
end
local from_start_text = "▕◁"
local backward_text = "◁"
local forward_text = "▷"
local from_end_text = "▷▏"
if BD.mirroredUILayout() then
backward_text, forward_text = forward_text, backward_text
-- Keep the LTR order of |< and >|:
from_start_text, from_end_text = BD.ltr(from_end_text), BD.ltr(from_start_text)
end
self.wait_button = ButtonDialog:new{
buttons = {{{ text = "⌛" }}},
}
local function search(func, pattern, param)
if regex and isSlowRegex(pattern) then
return function()
self.wait_button.alpha = 0.75
self.wait_button.movable:setMovedOffset(self.search_dialog.movable:getMovedOffset())
UIManager:show(self.wait_button)
UIManager:tickAfterNext(function()
do_search(func, pattern, param, regex, case_insensitive)()
UIManager:close(self.wait_button)
end)
end
else
return do_search(func, pattern, param, regex, case_insensitive)
end
end
self.search_dialog = ButtonDialog:new{
-- alpha = 0.7,
buttons = {
{
{
text = from_start_text,
vsync = true,
callback = search(self.searchFromStart, text, nil),
},
{
text = backward_text,
vsync = true,
callback = search(self.searchNext, text, 1),
},
{
icon = "appbar.search",
icon_width = Screen:scaleBySize(DGENERIC_ICON_SIZE * 0.8),
icon_height = Screen:scaleBySize(DGENERIC_ICON_SIZE * 0.8),
callback = function()
self.search_dialog:onClose()
self.last_search_text = text
self:onShowFulltextSearchInput()
end,
},
{
text = forward_text,
vsync = true,
callback = search(self.searchNext, text, 0),
},
{
text = from_end_text,
vsync = true,
callback = search(self.searchFromEnd, text, nil),
},
}
},
tap_close_callback = function()
logger.dbg("highlight clear")
self.ui.highlight:clear()
UIManager:setDirty(self.dialog, "ui")
end,
}
if regex and isSlowRegex(text) then
self.wait_button.alpha = nil
-- initial position: center of the screen
UIManager:show(self.wait_button)
UIManager:tickAfterNext(function()
do_search(self.searchFromCurrent, text, direction, regex, case_insensitive)()
UIManager:close(self.wait_button)
UIManager:show(self.search_dialog)
--- @todo regional
UIManager:setDirty(self.dialog, "partial")
end)
else
do_search(self.searchFromCurrent, text, direction, regex, case_insensitive)()
UIManager:show(self.search_dialog)
--- @todo regional
UIManager:setDirty(self.dialog, "partial")
end
return true
end
-- if regex == true, use regular expression in pattern
-- if case == true or nil, the search is case insensitive
function ReaderSearch:search(pattern, origin, regex, case_insensitive)
logger.dbg("search pattern", pattern)
local direction = self.direction
local page = self.view.state.page
if case_insensitive == nil then
case_insensitive = true
end
Device:setIgnoreInput(true)
local retval, words_found = self.ui.document:findText(pattern, origin, direction, case_insensitive, page, regex, self.max_hits)
Device:setIgnoreInput(false)
local regex_retval = regex and self.ui.document:getAndClearRegexSearchError()
if regex and regex_retval ~= 0 then
local error_message
if SRELL_ERROR_CODES[regex_retval] then
error_message = SRELL_ERROR_CODES[regex_retval]
else
error_message = _("Unspecified error")
end
UIManager:show(Notification:new{
text = error_message,
timeout = false,
})
elseif words_found and words_found > self.max_hits then
UIManager:show(Notification:new{
text =_("Too many hits"),
timeout = 4,
})
end
return retval
end
function ReaderSearch:searchFromStart(pattern, _, regex, case_insensitive)
self.direction = 0
self._expect_back_results = true
return self:search(pattern, -1, regex, case_insensitive)
end
function ReaderSearch:searchFromEnd(pattern, _, regex, case_insensitive)
self.direction = 1
self._expect_back_results = false
return self:search(pattern, -1, regex, case_insensitive)
end
function ReaderSearch:searchFromCurrent(pattern, direction, regex, case_insensitive)
self.direction = direction
self._expect_back_results = direction == 1
return self:search(pattern, 0, regex, case_insensitive)
end
-- ignore current page and search next occurrence
function ReaderSearch:searchNext(pattern, direction, regex, case_insensitive)
self.direction = direction
self._expect_back_results = direction == 1
return self:search(pattern, 1, regex, case_insensitive)
end
return ReaderSearch
| agpl-3.0 |
dr01d3r/darkstar | scripts/zones/Garlaige_Citadel/npcs/qm13.lua | 14 | 1384 | -----------------------------------
-- Area: Garlaige Citadel
-- NPC: qm13 (???)
-- Involved in Quest: Hitting the Marquisate (THF AF3)
-- @pos -194.166 -5.500 139.969 200
-----------------------------------
package.loaded["scripts/zones/Garlaige_Citadel/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/zones/Garlaige_Citadel/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local hittingTheMarquisateHagainCS = player:getVar("hittingTheMarquisateHagainCS");
if (hittingTheMarquisateHagainCS == 5) then
player:messageSpecial(PRESENCE_FROM_CEILING);
player:setVar("hittingTheMarquisateHagainCS",6);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID2: %u",csid);
-- printf("RESULT2: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c97000273.lua | 6 | 1978 | --スクラップ・コング
function c97000273.initial_effect(c)
--destroy
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(97000273,0))
e1:SetCategory(CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetTarget(c97000273.destg)
e1:SetOperation(c97000273.desop)
c:RegisterEffect(e1)
--search
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(97000273,1))
e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_TO_GRAVE)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e2:SetCondition(c97000273.thcon)
e2:SetTarget(c97000273.thtg)
e2:SetOperation(c97000273.thop)
c:RegisterEffect(e2)
end
function c97000273.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_DESTROY,e:GetHandler(),1,0,0)
end
function c97000273.desop(e,tp,eg,ep,ev,re,r,rp)
if e:GetHandler():IsRelateToEffect(e) then
Duel.Destroy(e:GetHandler(),REASON_EFFECT)
end
end
function c97000273.thcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return bit.band(c:GetReason(),0x41)==0x41 and re:GetOwner():IsSetCard(0x24)
end
function c97000273.filter(c)
return c:IsSetCard(0x24) and c:IsType(TYPE_MONSTER) and c:GetCode()~=97000273 and c:IsAbleToHand()
end
function c97000273.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c97000273.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c97000273.filter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectTarget(tp,c97000273.filter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function c97000273.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 |
SalvationDevelopment/Salvation-Scripts-Production | c31531170.lua | 2 | 3155 | --共鳴する振動
function c31531170.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetTarget(c31531170.target)
e1:SetOperation(c31531170.activate)
c:RegisterEffect(e1)
end
function c31531170.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return false end
local tc1=Duel.GetFieldCard(1-tp,LOCATION_SZONE,6)
local tc2=Duel.GetFieldCard(1-tp,LOCATION_SZONE,7)
if chk==0 then return tc1 and tc2 and tc1:IsCanBeEffectTarget(e) and tc2:IsCanBeEffectTarget(e) end
local g=Group.FromCards(tc1,tc2)
Duel.SetTargetCard(g)
end
function c31531170.activate(e,tp,eg,ep,ev,re,r,rp)
local tc1=Duel.GetFieldCard(1-tp,LOCATION_SZONE,6)
local tc2=Duel.GetFieldCard(1-tp,LOCATION_SZONE,7)
if not tc1:IsRelateToEffect(e) or not tc2:IsRelateToEffect(e) then return end
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetDescription(1163)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC_G)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_BOTH_SIDE)
e1:SetRange(LOCATION_PZONE)
e1:SetCountLimit(1,10000000)
e1:SetCondition(c31531170.pendcon)
e1:SetOperation(c31531170.pendop)
e1:SetValue(SUMMON_TYPE_PENDULUM)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
tc1:RegisterEffect(e1)
tc1:RegisterFlagEffect(31531170,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1,tc2:GetFieldID())
tc2:RegisterFlagEffect(31531170,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1,tc1:GetFieldID())
end
function c31531170.pendcon(e,c,og)
if c==nil then return true end
local tp=e:GetOwnerPlayer()
local rpz=Duel.GetFieldCard(1-tp,LOCATION_SZONE,7)
if rpz==nil or rpz:GetFieldID()~=c:GetFlagEffectLabel(31531170) then return false end
local lscale=c:GetLeftScale()
local rscale=rpz:GetRightScale()
if lscale>rscale then lscale,rscale=rscale,lscale end
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
if ft<=0 then return false end
if og then
return og:IsExists(aux.PConditionFilter,1,nil,e,tp,lscale,rscale)
else
return Duel.IsExistingMatchingCard(aux.PConditionFilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,lscale,rscale)
end
end
function c31531170.pendop(e,tp,eg,ep,ev,re,r,rp,c,sg,og)
Duel.Hint(HINT_CARD,0,31531170)
local tp=e:GetOwnerPlayer()
local rpz=Duel.GetFieldCard(1-tp,LOCATION_SZONE,7)
local lscale=c:GetLeftScale()
local rscale=rpz:GetRightScale()
if lscale>rscale then lscale,rscale=rscale,lscale end
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
if Duel.IsPlayerAffectedByEffect(tp,59822133) then ft=1 end
local ect=c29724053 and Duel.IsPlayerAffectedByEffect(tp,29724053) and c29724053[tp]
if ect~=nil then ft=math.min(ft,ect) end
if og then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=og:FilterSelect(tp,aux.PConditionFilter,1,ft,nil,e,tp,lscale,rscale)
sg:Merge(g)
else
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,aux.PConditionFilter,tp,LOCATION_EXTRA,0,1,ft,nil,e,tp,lscale,rscale)
sg:Merge(g)
end
Duel.HintSelection(Group.FromCards(c))
Duel.HintSelection(Group.FromCards(rpz))
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c42940404.lua | 4 | 3841 | --マシンナーズ・ギアフレーム
function c42940404.initial_effect(c)
--equip
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(42940404,0))
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCategory(CATEGORY_EQUIP)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_MZONE)
e1:SetTarget(c42940404.eqtg)
e1:SetOperation(c42940404.eqop)
c:RegisterEffect(e1)
--unequip
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(42940404,1))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_SZONE)
e2:SetCondition(aux.IsUnionState)
e2:SetTarget(c42940404.sptg)
e2:SetOperation(c42940404.spop)
c:RegisterEffect(e2)
--destroy sub
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_EQUIP)
e3:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e3:SetCode(EFFECT_DESTROY_SUBSTITUTE)
e3:SetCondition(aux.IsUnionState)
e3:SetValue(1)
c:RegisterEffect(e3)
--eqlimit
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetCode(EFFECT_EQUIP_LIMIT)
e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e4:SetValue(aux.TargetBoolFunction(Card.IsRace,RACE_MACHINE))
c:RegisterEffect(e4)
--search
local e5=Effect.CreateEffect(c)
e5:SetDescription(aux.Stringid(42940404,2))
e5:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e5:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_SINGLE)
e5:SetCode(EVENT_SUMMON_SUCCESS)
e5:SetTarget(c42940404.stg)
e5:SetOperation(c42940404.sop)
c:RegisterEffect(e5)
end
c42940404.old_union=true
function c42940404.filter(c)
return c:IsFaceup() and c:IsRace(RACE_MACHINE) and c:GetUnionCount()==0
end
function c42940404.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c42940404.filter(chkc) and chkc~=e:GetHandler() end
if chk==0 then return e:GetHandler():GetFlagEffect(42940404)==0 and Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and Duel.IsExistingTarget(c42940404.filter,tp,LOCATION_MZONE,0,1,e:GetHandler()) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
local g=Duel.SelectTarget(tp,c42940404.filter,tp,LOCATION_MZONE,0,1,1,e:GetHandler())
Duel.SetOperationInfo(0,CATEGORY_EQUIP,g,1,0,0)
e:GetHandler():RegisterFlagEffect(42940404,RESET_EVENT+0x7e0000+RESET_PHASE+PHASE_END,0,1)
end
function c42940404.eqop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if not c:IsRelateToEffect(e) or c:IsFacedown() then return end
if not tc:IsRelateToEffect(e) or not c42940404.filter(tc) then
Duel.SendtoGrave(c,REASON_EFFECT)
return
end
if not Duel.Equip(tp,c,tc,false) then return end
aux.SetUnionState(c)
end
function c42940404.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():GetFlagEffect(42940404)==0 and 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)
e:GetHandler():RegisterFlagEffect(42940404,RESET_EVENT+0x7e0000+RESET_PHASE+PHASE_END,0,1)
end
function c42940404.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) then return end
Duel.SpecialSummon(c,0,tp,tp,true,false,POS_FACEUP_ATTACK)
end
function c42940404.sfilter(c)
return c:IsSetCard(0x36) and c:GetCode()~=42940404 and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
end
function c42940404.stg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c42940404.sfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c42940404.sop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c42940404.sfilter,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 |
dr01d3r/darkstar | scripts/zones/West_Ronfaure/npcs/Aaveleon.lua | 14 | 1533 | -----------------------------------
-- Area: West Ronfaure
-- NPC: Aaveleon
-- Involved in Quest: A Sentry's Peril
-- @pos -431 -45 343 100
-----------------------------------
package.loaded["scripts/zones/West_Ronfaure/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/zones/West_Ronfaure/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(SANDORIA,A_SENTRY_S_PERIL) == QUEST_ACCEPTED) then
if (trade:hasItemQty(600,1) and trade:getItemCount() == 1) then
player:startEvent(0x0064);
else
player:startEvent(118);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0065);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0064) then
player:tradeComplete();
player:addItem(601);
player:messageSpecial(ITEM_OBTAINED,601);
end
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Kuftal_Tunnel/mobs/Phantom_Worm.lua | 23 | 1639 | -----------------------------------
-- Area: Kuftal Tunnel (173)
-- Mob: Phantom Worm
-----------------------------------
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
end;
-----------------------------------
-- onMobDespawn
-----------------------------------
function onMobDespawn(mob)
local npc = GetNPCByID(17490253);
npc:updateNPCHideTime(FORCE_SPAWN_QM_RESET_TIME);
local randpos = math.random(1,16);
switch (randpos): caseof
{
[1] = function (x) npc:setPos(75.943,29.969,118.854); end,
[2] = function (x) npc:setPos(75.758,30.000,125.815); end,
[3] = function (x) npc:setPos(65.222,29.364,131.645); end,
[4] = function (x) npc:setPos(53.088,25.033,138.725); end,
[5] = function (x) npc:setPos(85.658,30.155,123.941); end,
[6] = function (x) npc:setPos(91.153,30.146,113.657); end,
[7] = function (x) npc:setPos(86.549,29.875,107.232); end,
[8] = function (x) npc:setPos(94.763,29.054,105.138); end,
[9] = function (x) npc:setPos(102.719,26.751,102.816); end,
[10] = function (x) npc:setPos(71.571,30.241,110.704); end,
[11] = function (x) npc:setPos(65.642,28.018,99.2442); end,
[12] = function (x) npc:setPos(62.090,25.421,93.4702); end,
[13] = function (x) npc:setPos(60.740,22.638,86.1781); end,
[14] = function (x) npc:setPos(80.460,30.293,112.721); end,
[15] = function (x) npc:setPos(76.929,30.050,127.630); end,
[16] = function (x) npc:setPos(68.810,30.175,123.516); end,
}
end; | gpl-3.0 |
BlurryRoots/intergalactic-golf | src/processors/SoundProcessor.lua | 2 | 1482 | require ("lib.lclass")
require ("lib.yanecos.Processor")
local lume = require ("lib.lume")
class "SoundProcessor" ("Processor")
function SoundProcessor:SoundProcessor (assets)
self.assets = assets
self.commands = {
play = {},
pause = {},
resume = {},
stop = {}
}
self.reactions = {
PlaySoundEvent = function (event)
table.insert (self.commands.play, {
key = event.key,
volume = event.volume,
loop = event.loop
})
end,
PauseSoundEvent = function (event)
table.insert (self.commands.pause, {
key = event.key
})
end,
ResumeSoundEvent = function (event)
table.insert (self.commands.resume, {
key = event.key
})
end,
StopSoundEvent = function (event)
table.insert (self.commands.stop, {
key = event.key
})
end
}
end
function SoundProcessor:onUpdate (dt)
lume.each (self.commands.stop, function (cmd)
local sound = self.assets:get (cmd.key)
sound:stop ()
end)
lume.each (self.commands.pause, function (cmd)
local sound = self.assets:get (cmd.key)
sound:pause ()
end)
lume.each (self.commands.resume, function (cmd)
local sound = self.assets:get (cmd.key)
sound:resume ()
end)
lume.each (self.commands.play, function (cmd)
local sound = self.assets:get (cmd.key)
sound:setVolume (cmd.volume)
sound:setLooping (cmd.loop)
sound:play ()
end)
end
function SoundProcessor:handle (event)
local reaction = self.reactions[event:getClass ()]
if reaction then
reaction (event)
end
end
| mit |
SalvationDevelopment/Salvation-Scripts-Production | c10194329.lua | 4 | 1424 | --RR-アベンジ・ヴァルチャー
function c10194329.initial_effect(c)
--spsummon
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_DAMAGE)
e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
e1:SetRange(LOCATION_HAND)
e1:SetCondition(c10194329.condition)
e1:SetTarget(c10194329.target)
e1:SetOperation(c10194329.operation)
c:RegisterEffect(e1)
end
function c10194329.condition(e,tp,eg,ep,ev,re,r,rp)
return ep==tp and bit.band(r,REASON_BATTLE+REASON_EFFECT)~=0
end
function c10194329.target(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 c10194329.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(1,0)
e1:SetTarget(c10194329.splimit)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
if not c:IsRelateToEffect(e) then return end
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
end
function c10194329.splimit(e,c,sump,sumtype,sumpos,targetp,se)
return not c:IsSetCard(0xba) and c:IsLocation(LOCATION_EXTRA)
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/zones/The_Eldieme_Necropolis/npcs/_5fg.lua | 12 | 1097 | -----------------------------------
-- Area: The Eldieme Necropolis
-- NPC: Titan's Gate
-- @pos 100 -34 -71 195
-----------------------------------
package.loaded["scripts/zones/The_Eldieme_Necropolis/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/The_Eldieme_Necropolis/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (npc:getAnimation() == 9) then
player:messageSpecial(SOLID_STONE);
end
return 0;
end;
--
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | 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 |
AutoJames/KkthnxUI_Legion | KkthnxUI/Libraries/oUF/elements/health.lua | 3 | 5912 | --[[ Element: Health Bar
Handles updating of `self.Health` based on the units health.
Widget
Health - A StatusBar used to represent current unit health.
Sub-Widgets
.bg - A Texture which functions as a background. It will inherit the color of
the main StatusBar.
Notes
The default StatusBar texture will be applied if the UI widget doesn't have a
status bar texture or color defined.
Options
The following options are listed by priority. The first check that returns
true decides the color of the bar.
.colorTapping - Use `self.colors.tapping` to color the bar if the unit
isn't tapped by the player.
.colorDisconnected - Use `self.colors.disconnected` to color the bar if the
unit is offline.
.colorClass - Use `self.colors.class[class]` to color the bar based on
unit class. `class` is defined by the second return of
[UnitClass](http://wowprogramming.com/docs/api/UnitClass).
.colorClassNPC - Use `self.colors.class[class]` to color the bar if the
unit is a NPC.
.colorClassPet - Use `self.colors.class[class]` to color the bar if the
unit is player controlled, but not a player.
.colorReaction - Use `self.colors.reaction[reaction]` to color the bar
based on the player's reaction towards the unit.
`reaction` is defined by the return value of
[UnitReaction](http://wowprogramming.com/docs/api/UnitReaction).
.colorSmooth - Use `self.colors.smooth` to color the bar with a smooth
gradient based on the player's current health percentage.
.colorHealth - Use `self.colors.health` to color the bar. This flag is
used to reset the bar color back to default if none of the
above conditions are met.
Sub-Widgets Options
.multiplier - Defines a multiplier, which is used to tint the background based
on the main widgets R, G and B values. Defaults to 1 if not
present.
Examples
-- Position and size
local Health = CreateFrame("StatusBar", nil, self)
Health:SetHeight(20)
Health:SetPoint('TOP')
Health:SetPoint('LEFT')
Health:SetPoint('RIGHT')
-- Add a background
local Background = Health:CreateTexture(nil, 'BACKGROUND')
Background:SetAllPoints(Health)
Background:SetTexture(1, 1, 1, .5)
-- Options
Health.frequentUpdates = true
Health.colorTapping = true
Health.colorDisconnected = true
Health.colorClass = true
Health.colorReaction = true
Health.colorHealth = true
-- Make the background darker.
Background.multiplier = .5
-- Register it with oUF
self.Health = Health
self.Health.bg = Background
Hooks
Override(self) - Used to completely override the internal update function.
Removing the table key entry will make the element fall-back
to its internal function again.
]]
local parent, ns = ...
local oUF = ns.oUF
oUF.colors.health = {49/255, 207/255, 37/255}
local Update = function(self, event, unit)
if(not unit or self.unit ~= unit) then return end
local health = self.Health
if(health.PreUpdate) then health:PreUpdate(unit) end
local min, max = UnitHealth(unit), UnitHealthMax(unit)
local disconnected = not UnitIsConnected(unit)
health:SetMinMaxValues(0, max)
if(disconnected) then
health:SetValue(max)
else
health:SetValue(min)
end
health.disconnected = disconnected
local r, g, b, t
if(health.colorTapping and not UnitPlayerControlled(unit) and UnitIsTapDenied(unit)) then
t = self.colors.tapped
elseif(health.colorDisconnected and not UnitIsConnected(unit)) then
t = self.colors.disconnected
elseif(health.colorClass and UnitIsPlayer(unit)) or
(health.colorClassNPC and not UnitIsPlayer(unit)) or
(health.colorClassPet and UnitPlayerControlled(unit) and not UnitIsPlayer(unit)) then
local _, class = UnitClass(unit)
t = self.colors.class[class]
elseif(health.colorReaction and UnitReaction(unit, 'player')) then
t = self.colors.reaction[UnitReaction(unit, "player")]
elseif(health.colorSmooth) then
r, g, b = self.ColorGradient(min, max, unpack(health.smoothGradient or self.colors.smooth))
elseif(health.colorHealth) then
t = self.colors.health
end
if(t) then
r, g, b = t[1], t[2], t[3]
end
if(b) then
health:SetStatusBarColor(r, g, b)
local bg = health.bg
if(bg) then local mu = bg.multiplier or 1
bg:SetVertexColor(r * mu, g * mu, b * mu)
end
end
if(health.PostUpdate) then
return health:PostUpdate(unit, min, max)
end
end
local Path = function(self, ...)
return (self.Health.Override or Update) (self, ...)
end
local ForceUpdate = function(element)
return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local Enable = function(self, unit)
local health = self.Health
if(health) then
health.__owner = self
health.ForceUpdate = ForceUpdate
if(health.frequentUpdates) then
self:RegisterEvent('UNIT_HEALTH_FREQUENT', Path)
else
self:RegisterEvent('UNIT_HEALTH', Path)
end
self:RegisterEvent("UNIT_MAXHEALTH", Path)
self:RegisterEvent('UNIT_CONNECTION', Path)
-- For tapping.
self:RegisterEvent('UNIT_FACTION', Path)
if(health:IsObjectType'StatusBar' and not health:GetStatusBarTexture()) then
health:SetStatusBarTexture[[Interface\TargetingFrame\UI-StatusBar]]
end
return true
end
end
local Disable = function(self)
local health = self.Health
if(health) then
health:Hide()
self:UnregisterEvent('UNIT_HEALTH_FREQUENT', Path)
self:UnregisterEvent('UNIT_HEALTH', Path)
self:UnregisterEvent('UNIT_MAXHEALTH', Path)
self:UnregisterEvent('UNIT_CONNECTION', Path)
self:UnregisterEvent('UNIT_FACTION', Path)
end
end
oUF:AddElement('Health', Path, Enable, Disable)
| mit |
SalvationDevelopment/Salvation-Scripts-Production | c83682725.lua | 9 | 1517 | --テールスイング
function c83682725.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_TOHAND)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(c83682725.target)
e1:SetOperation(c83682725.activate)
c:RegisterEffect(e1)
end
function c83682725.filter(c,tp)
return c:IsFaceup() and c:IsRace(RACE_DINOSAUR) and c:IsLevelAbove(5)
and Duel.IsExistingMatchingCard(c83682725.dfilter,tp,0,LOCATION_MZONE,1,nil,c:GetLevel())
end
function c83682725.dfilter(c,lv)
return (c:IsFacedown() or c:IsLevelBelow(lv-1)) and c:IsAbleToHand()
end
function c83682725.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c83682725.filter(chkc,tp) end
if chk==0 then return Duel.IsExistingTarget(c83682725.filter,tp,LOCATION_MZONE,0,1,nil,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
local g=Duel.SelectTarget(tp,c83682725.filter,tp,LOCATION_MZONE,0,1,1,nil,tp)
local sg=Duel.GetMatchingGroup(c83682725.dfilter,tp,0,LOCATION_MZONE,nil,g:GetFirst():GetLevel())
Duel.SetOperationInfo(0,CATEGORY_TOHAND,sg,1,0,0)
end
function c83682725.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsFaceup() and tc:IsRelateToEffect(e) then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local sg=Duel.SelectMatchingCard(tp,c83682725.dfilter,tp,0,LOCATION_MZONE,1,2,nil,tc:GetLevel())
Duel.SendtoHand(sg,nil,REASON_EFFECT)
end
end
| gpl-2.0 |
Herve-M/OpenRA | mods/d2k/maps/ordos-06a/ordos06a.lua | 7 | 9427 | --[[
Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
This file is part of OpenRA, which is free software. It is made
available to you under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version. For more
information, see COPYING.
]]
Base =
{
Atreides = { AConyard, APower1, APower2, APower3, APower4, APower5, APower6, APower7, APower8, APower9, APower10, APower11, APower12, ABarracks, ARefinery, ALightFactory, AHeavyFactory, ARepair, AResearch, AGunt1, AGunt2, ARock1, ARock2, ARock3, ARock4 },
Harkonnen = { HConyard, HPower1, HPower2, HPower3, HPower4, HPower5, HPower6, HPower7, HPower8, HPower9, HPower10, HBarracks, HRefinery, HOutpost, HHeavyFactory, HGunt1, HGunt2, HGunt3, HGunt4, HRock, HSilo1, HSilo2, HSilo3 }
}
AtreidesReinforcements =
{
easy =
{
{ "light_inf", "light_inf", "light_inf", "trooper", "trooper" },
{ "quad", "quad", "combat_tank_a" },
{ "light_inf", "light_inf", "light_inf", "trooper", "trooper", "quad", "quad" }
},
normal =
{
{ "light_inf", "light_inf", "light_inf", "trooper", "trooper", "quad", "quad" },
{ "quad", "quad", "combat_tank_a", "combat_tank_a" },
{ "light_inf", "light_inf", "light_inf", "trooper", "trooper", "quad", "quad", "quad" },
{ "combat_tank_a", "combat_tank_a", "combat_tank_a" }
},
hard =
{
{ "light_inf", "light_inf", "light_inf", "trooper", "trooper", "trooper", "quad", "quad" },
{ "quad", "quad", "quad", "combat_tank_a", "combat_tank_a" },
{ "light_inf", "light_inf", "light_inf", "trooper", "trooper", "quad", "quad", "quad", "quad" },
{ "combat_tank_a", "combat_tank_a", "combat_tank_a", "quad" },
{ "combat_tank_a", "combat_tank_a", "missile_tank", "siege_tank" }
}
}
HarkonnenReinforcements =
{
easy =
{
{ "quad", "trike", "trike" },
{ "light_inf", "light_inf", "light_inf", "trooper", "trooper" },
{ "combat_tank_h", "quad" },
{ "trooper", "trooper", "trooper", "trooper", "trooper" }
},
normal =
{
{ "combat_tank_h", "combat_tank_h", "trike", "trike" },
{ "light_inf", "light_inf", "light_inf", "light_inf", "light_inf", "trooper", "trooper" },
{ "combat_tank_h", "quad", "quad" },
{ "trooper", "trooper", "trooper", "trooper", "trooper", "trooper", "trooper" },
{ "trike", "trike", "quad", "siege_tank" }
},
hard =
{
{ "combat_tank_h", "combat_tank_h", "trike", "trike", "trike" },
{ "light_inf", "light_inf", "light_inf", "light_inf", "light_inf", "light_inf", "trooper", "trooper" },
{ "combat_tank_h", "combat_tank_h", "quad", "quad" },
{ "trooper", "trooper", "trooper", "trooper", "trooper", "trooper", "trooper", "trooper" },
{ "trike", "trike", "quad", "quad", "siege_tank" },
{ "missile_tank", "missile_tank", "missile_tank", "missile_tank" }
}
}
IxianReinforcements =
{
easy = { "deviator", "deviator", "missile_tank", "missile_tank", "missile_tank", "siege_tank", "siege_tank", "combat_tank_o", "combat_tank_o" },
normal = { "deviator", "deviator", "missile_tank", "missile_tank", "missile_tank", "siege_tank", "siege_tank", "combat_tank_o" },
hard = { "deviator", "deviator", "missile_tank", "missile_tank", "siege_tank", "siege_tank", "combat_tank_o" }
}
EnemyAttackDelay =
{
easy = DateTime.Minutes(5) + DateTime.Seconds(15),
normal = DateTime.Minutes(3) + DateTime.Seconds(15),
hard = DateTime.Minutes(1) + DateTime.Seconds(30)
}
AtreidesPaths =
{
{ AtreidesEntry2.Location, AtreidesRally2.Location },
{ AtreidesEntry3.Location, AtreidesRally3.Location },
{ AtreidesEntry4.Location, AtreidesRally4.Location }
}
HarkonnenPaths =
{
{ HarkonnenEntry2.Location, HarkonnenRally2.Location },
{ HarkonnenEntry3.Location, HarkonnenRally3.Location },
{ HarkonnenEntry4.Location, HarkonnenRally4.Location },
{ HarkonnenEntry5.Location, HarkonnenRally5.Location },
{ HarkonnenEntry6.Location, HarkonnenRally6.Location },
{ HarkonnenEntry7.Location, HarkonnenRally7.Location }
}
AtreidesAttackWaves =
{
easy = 3,
normal = 4,
hard = 5
}
HarkonnenAttackWaves =
{
easy = 4,
normal = 5,
hard = 6
}
InitialReinforcements =
{
Atreides = { "combat_tank_a", "quad", "quad", "trike", "trike" },
Harkonnen = { "trooper", "trooper", "trooper", "trooper", "trooper", "combat_tank_h" }
}
InitialReinforcementsPaths =
{
Atreides = { AtreidesEntry1.Location, AtreidesRally1.Location },
Harkonnen = { HarkonnenEntry1.Location, HarkonnenRally1.Location }
}
InitialContrabandTimes =
{
easy = DateTime.Minutes(10),
normal = DateTime.Minutes(15),
hard = DateTime.Minutes(20)
}
ContrabandTimes =
{
easy = DateTime.Minutes(4),
normal = DateTime.Minutes(6),
hard = DateTime.Minutes(7)
}
SendContraband = function()
Media.PlaySpeechNotification(player, "Reinforce")
for i = 0, 6 do
local c = player.Color
if i % 2 == 0 then
c = HSLColor.White
end
Trigger.AfterDelay(DateTime.Seconds(i), function() UserInterface.SetMissionText("Ixian reinforcements have arrived!", c) end)
end
Trigger.AfterDelay(DateTime.Seconds(6), function()
TimerTicks = ContrabandTimes[Difficulty]
end)
local entryPath = { CPos.New(82, OStarport.Location.Y + 1), OStarport.Location + CVec.New(1, 1) }
local exitPath = { CPos.New(2, OStarport.Location.Y + 1) }
Reinforcements.ReinforceWithTransport(player, "frigate", IxianReinforcements[Difficulty], entryPath, exitPath)
end
Hunt = function(house)
Trigger.OnAllKilledOrCaptured(Base[house.InternalName], function()
Utils.Do(house.GetGroundAttackers(), IdleHunt)
end)
end
CheckHarvester = function(house)
if DateTime.GameTime % DateTime.Seconds(10) == 0 and LastHarvesterEaten[house] then
local units = house.GetActorsByType("harvester")
if #units > 0 then
LastHarvesterEaten[house] = false
ProtectHarvester(units[1], house, AttackGroupSize[Difficulty])
end
end
end
Tick = function()
if not player.IsObjectiveCompleted(KillAtreides) and atreides.HasNoRequiredUnits() then
Media.DisplayMessage("The Atreides have been annihilated!", "Mentat")
player.MarkCompletedObjective(KillAtreides)
DestroyCarryalls(atreides)
if player.IsObjectiveCompleted(KillHarkonnen) then
player.MarkCompletedObjective(GuardStarport)
end
end
if not player.IsObjectiveCompleted(KillHarkonnen) and harkonnen.HasNoRequiredUnits() then
Media.DisplayMessage("The Harkonnen have been annihilated!", "Mentat")
player.MarkCompletedObjective(KillHarkonnen)
DestroyCarryalls(harkonnen)
if player.IsObjectiveCompleted(KillAtreides) then
player.MarkCompletedObjective(GuardStarport)
end
end
if TimerTicks and TimerTicks > 0 then
TimerTicks = TimerTicks - 1
if TimerTicks == 0 then
if not FirstIxiansArrived then
Media.DisplayMessage("Deliveries beginning to arrive. Massive reinforcements expected!", "Mentat")
end
FirstIxiansArrived = true
SendContraband()
else
local text = "Initial"
if FirstIxiansArrived then
text = "Additional"
end
UserInterface.SetMissionText(text .. " reinforcements will arrive in " .. Utils.FormatTime(TimerTicks), player.Color)
end
end
CheckHarvester(atreides)
CheckHarvester(harkonnen)
end
WorldLoaded = function()
atreides = Player.GetPlayer("Atreides")
harkonnen = Player.GetPlayer("Harkonnen")
player = Player.GetPlayer("Ordos")
InitObjectives(player)
GuardStarport = player.AddObjective("Defend the Starport.")
KillAtreides = player.AddObjective("Destroy the Atreides.")
KillHarkonnen = player.AddObjective("Destroy the Harkonnen.")
Camera.Position = OConyard.CenterPosition
EnemyAttackLocations = { OConyard.Location, OStarport.Location }
Trigger.OnRemovedFromWorld(OStarport, function()
player.MarkFailedObjective(GuardStarport)
end)
Trigger.AfterDelay(DateTime.Seconds(2), function()
TimerTicks = InitialContrabandTimes[Difficulty]
Media.DisplayMessage("The first batch of Ixian reinforcements will arrive in " .. Utils.FormatTime(TimerTicks) .. ".", "Mentat")
end)
Hunt(atreides)
Hunt(harkonnen)
local atreidesPath = function() return Utils.Random(AtreidesPaths) end
local harkonnenPath = function() return Utils.Random(HarkonnenPaths) end
local atreidesCondition = function() return player.IsObjectiveCompleted(KillAtreides) end
local harkonnenCondition = function() return player.IsObjectiveCompleted(KillHarkonnen) end
local huntFunction = function(unit)
unit.AttackMove(Utils.Random(EnemyAttackLocations))
IdleHunt(unit)
end
local announcementFunction = function()
Media.DisplayMessage("Enemy reinforcements have arrived.", "Mentat")
end
SendCarryallReinforcements(atreides, 0, AtreidesAttackWaves[Difficulty], EnemyAttackDelay[Difficulty], atreidesPath, AtreidesReinforcements[Difficulty], atreidesCondition, huntFunction, announcementFunction)
Trigger.AfterDelay(Utils.RandomInteger(DateTime.Seconds(45), DateTime.Minutes(1) + DateTime.Seconds(15)), function()
SendCarryallReinforcements(harkonnen, 0, HarkonnenAttackWaves[Difficulty], EnemyAttackDelay[Difficulty], harkonnenPath, HarkonnenReinforcements[Difficulty], harkonnenCondition, huntFunction, announcementFunction)
end)
Actor.Create("upgrade.barracks", true, { Owner = atreides })
Actor.Create("upgrade.light", true, { Owner = atreides })
Actor.Create("upgrade.heavy", true, { Owner = atreides })
Actor.Create("upgrade.barracks", true, { Owner = harkonnen })
Actor.Create("upgrade.heavy", true, { Owner = harkonnen })
Trigger.AfterDelay(0, ActivateAI)
end
| gpl-3.0 |
koreader/koreader | frontend/apps/reader/modules/readermenu.lua | 3 | 19138 | local BD = require("ui/bidi")
local CenterContainer = require("ui/widget/container/centercontainer")
local ConfirmBox = require("ui/widget/confirmbox")
local Device = require("device")
local Event = require("ui/event")
local InputContainer = require("ui/widget/container/inputcontainer")
local Screensaver = require("ui/screensaver")
local UIManager = require("ui/uimanager")
local logger = require("logger")
local dbg = require("dbg")
local util = require("util")
local Screen = Device.screen
local _ = require("gettext")
local T = require("ffi/util").template
local ReaderMenu = InputContainer:extend{
tab_item_table = nil,
menu_items = nil, -- table, mandatory
registered_widgets = nil, -- array
}
function ReaderMenu:init()
self.menu_items = {
["KOMenu:menu_buttons"] = {
-- top menu
},
-- items in top menu
navi = {
icon = "appbar.navigation",
},
typeset = {
icon = "appbar.typeset",
},
setting = {
icon = "appbar.settings",
},
tools = {
icon = "appbar.tools",
},
search = {
icon = "appbar.search",
},
filemanager = {
icon = "appbar.filebrowser",
remember = false,
callback = function()
self:onTapCloseMenu()
self.ui:onClose()
self.ui:showFileManager()
end,
},
main = {
icon = "appbar.menu",
}
}
self.registered_widgets = {}
self:registerKeyEvents()
if G_reader_settings:has("activate_menu") then
self.activation_menu = G_reader_settings:readSetting("activate_menu")
else
self.activation_menu = "swipe_tap"
end
-- delegate gesture listener to readerui, NOP our own
self.ges_events = nil
end
function ReaderMenu:onGesture() end
function ReaderMenu:registerKeyEvents()
if Device:hasKeys() then
if Device:isTouchDevice() then
self.key_events.PressMenu = { { "Menu" } }
if Device:hasFewKeys() then
self.key_events.PressMenu = { { { "Menu", "Right" } } }
end
else
-- Map Menu key to top menu only, because the bottom menu is only designed for touch devices.
--- @fixme: Is this still the case?
--- (Swapping between top and bottom might not be implemented, though, so it might still be a good idea).
self.key_events.ShowMenu = { { "Menu" } }
if Device:hasFewKeys() then
self.key_events.ShowMenu = { { { "Menu", "Right" } } }
end
end
end
end
ReaderMenu.onPhysicalKeyboardConnected = ReaderMenu.registerKeyEvents
function ReaderMenu:getPreviousFile()
return require("readhistory"):getPreviousFile(self.ui.document.file)
end
function ReaderMenu:onReaderReady()
if not Device:isTouchDevice() then return end
local DTAP_ZONE_MENU = G_defaults:readSetting("DTAP_ZONE_MENU")
local DTAP_ZONE_MENU_EXT = G_defaults:readSetting("DTAP_ZONE_MENU_EXT")
self.ui:registerTouchZones({
{
id = "readermenu_tap",
ges = "tap",
screen_zone = {
ratio_x = DTAP_ZONE_MENU.x, ratio_y = DTAP_ZONE_MENU.y,
ratio_w = DTAP_ZONE_MENU.w, ratio_h = DTAP_ZONE_MENU.h,
},
overrides = {
"tap_forward",
"tap_backward",
},
handler = function(ges) return self:onTapShowMenu(ges) end,
},
{
id = "readermenu_ext_tap",
ges = "tap",
screen_zone = {
ratio_x = DTAP_ZONE_MENU_EXT.x, ratio_y = DTAP_ZONE_MENU_EXT.y,
ratio_w = DTAP_ZONE_MENU_EXT.w, ratio_h = DTAP_ZONE_MENU_EXT.h,
},
overrides = {
"readermenu_tap",
},
handler = function(ges) return self:onTapShowMenu(ges) end,
},
{
id = "readermenu_swipe",
ges = "swipe",
screen_zone = {
ratio_x = DTAP_ZONE_MENU.x, ratio_y = DTAP_ZONE_MENU.y,
ratio_w = DTAP_ZONE_MENU.w, ratio_h = DTAP_ZONE_MENU.h,
},
overrides = {
"rolling_swipe",
"paging_swipe",
},
handler = function(ges) return self:onSwipeShowMenu(ges) end,
},
{
id = "readermenu_ext_swipe",
ges = "swipe",
screen_zone = {
ratio_x = DTAP_ZONE_MENU_EXT.x, ratio_y = DTAP_ZONE_MENU_EXT.y,
ratio_w = DTAP_ZONE_MENU_EXT.w, ratio_h = DTAP_ZONE_MENU_EXT.h,
},
overrides = {
"readermenu_swipe",
},
handler = function(ges) return self:onSwipeShowMenu(ges) end,
},
{
id = "readermenu_pan",
ges = "pan",
screen_zone = {
ratio_x = DTAP_ZONE_MENU.x, ratio_y = DTAP_ZONE_MENU.y,
ratio_w = DTAP_ZONE_MENU.w, ratio_h = DTAP_ZONE_MENU.h,
},
overrides = {
"rolling_pan",
"paging_pan",
},
handler = function(ges) return self:onSwipeShowMenu(ges) end,
},
{
id = "readermenu_ext_pan",
ges = "pan",
screen_zone = {
ratio_x = DTAP_ZONE_MENU_EXT.x, ratio_y = DTAP_ZONE_MENU_EXT.y,
ratio_w = DTAP_ZONE_MENU_EXT.w, ratio_h = DTAP_ZONE_MENU_EXT.h,
},
overrides = {
"readermenu_pan",
},
handler = function(ges) return self:onSwipeShowMenu(ges) end,
},
})
end
function ReaderMenu:setUpdateItemTable()
for _, widget in pairs(self.registered_widgets) do
local ok, err = pcall(widget.addToMainMenu, widget, self.menu_items)
if not ok then
logger.err("failed to register widget", widget.name, err)
end
end
-- typeset tab
self.menu_items.document_settings = {
text = _("Document settings"),
sub_item_table = {
{
text = _("Reset document settings to default"),
keep_menu_open = true,
callback = function()
UIManager:show(ConfirmBox:new{
text = _("Reset current document settings to their default values?\n\nReading position, highlights and bookmarks will be kept.\nThe document will be reloaded."),
ok_text = _("Reset"),
ok_callback = function()
local current_file = self.ui.document.file
self:onTapCloseMenu()
self.ui:onClose()
require("apps/filemanager/filemanagerutil").resetDocumentSettings(current_file)
require("apps/reader/readerui"):showReader(current_file)
end,
})
end,
},
{
text = _("Save document settings as default"),
keep_menu_open = true,
callback = function()
UIManager:show(ConfirmBox:new{
text = _("Save current document settings as default values?"),
ok_text = _("Save"),
ok_callback = function()
self:onTapCloseMenu()
self:saveDocumentSettingsAsDefault()
UIManager:show(require("ui/widget/notification"):new{
text = _("Default settings updated"),
})
end,
})
end,
},
},
}
self.menu_items.page_overlap = require("ui/elements/page_overlap")
-- settings tab
-- insert common settings
for id, common_setting in pairs(dofile("frontend/ui/elements/common_settings_menu_table.lua")) do
self.menu_items[id] = common_setting
end
if Device:isTouchDevice() then
self.menu_items.page_turns = require("ui/elements/page_turns")
else
-- Placed elsewhere than in Taps and gestures, with only a subset of menu items.
self.menu_items.page_turns_non_touch = require("ui/elements/page_turns")
end
-- insert DjVu render mode submenu just before the last entry (show advanced)
-- this is a bit of a hack
if self.ui.document.is_djvu then
self.menu_items.djvu_render_mode = self.view:getRenderModeMenuTable()
end
if Device:supportsScreensaver() then
local ss_book_settings = {
text = _("Exclude this book's cover from screensaver"),
enabled_func = function()
return not (self.ui == nil or self.ui.document == nil)
and G_reader_settings:readSetting("screensaver_type") == "cover"
end,
checked_func = function()
return self.ui and self.ui.doc_settings and self.ui.doc_settings:isTrue("exclude_screensaver")
end,
callback = function()
if Screensaver:isExcluded() then
self.ui.doc_settings:makeFalse("exclude_screensaver")
else
self.ui.doc_settings:makeTrue("exclude_screensaver")
end
self.ui:saveSettings()
end,
added_by_readermenu_flag = true,
}
local screensaver_sub_item_table = require("ui/elements/screensaver_menu")
-- Before inserting this new item, remove any previously added one
for i = #screensaver_sub_item_table, 1, -1 do
if screensaver_sub_item_table[i].added_by_readermenu_flag then
table.remove(screensaver_sub_item_table, i)
end
end
table.insert(screensaver_sub_item_table, ss_book_settings)
self.menu_items.screensaver = {
text = _("Screensaver"),
sub_item_table = screensaver_sub_item_table,
}
end
local PluginLoader = require("pluginloader")
self.menu_items.plugin_management = {
text = _("Plugin management"),
sub_item_table = PluginLoader:genPluginManagerSubItem()
}
-- main menu tab
-- insert common info
for id, common_setting in pairs(dofile("frontend/ui/elements/common_info_menu_table.lua")) do
self.menu_items[id] = common_setting
end
-- insert common exit for reader
for id, common_setting in pairs(dofile("frontend/ui/elements/common_exit_menu_table.lua")) do
self.menu_items[id] = common_setting
end
self.menu_items.open_previous_document = {
text_func = function()
local previous_file = self:getPreviousFile()
if not G_reader_settings:isTrue("open_last_menu_show_filename") or not previous_file then
return _("Open previous document")
end
local path, file_name = util.splitFilePathName(previous_file) -- luacheck: no unused
return T(_("Previous: %1"), BD.filename(file_name))
end,
enabled_func = function()
return self:getPreviousFile() ~= nil
end,
callback = function()
self.ui:onOpenLastDoc()
end,
hold_callback = function()
local previous_file = self:getPreviousFile()
UIManager:show(ConfirmBox:new{
text = T(_("Would you like to open the previous document: %1?"), BD.filepath(previous_file)),
ok_text = _("OK"),
ok_callback = function()
self.ui:switchDocument(previous_file)
end,
})
end
}
local order = require("ui/elements/reader_menu_order")
local MenuSorter = require("ui/menusorter")
self.tab_item_table = MenuSorter:mergeAndSort("reader", self.menu_items, order)
end
dbg:guard(ReaderMenu, 'setUpdateItemTable',
function(self)
local mock_menu_items = {}
for _, widget in pairs(self.registered_widgets) do
-- make sure addToMainMenu works in debug mode
widget:addToMainMenu(mock_menu_items)
end
end)
function ReaderMenu:saveDocumentSettingsAsDefault()
local prefix
if self.ui.rolling then
G_reader_settings:saveSetting("cre_font", self.ui.font.font_face)
G_reader_settings:saveSetting("copt_css", self.ui.document.default_css)
G_reader_settings:saveSetting("style_tweaks", self.ui.styletweak.global_tweaks)
prefix = "copt_"
else
prefix = "kopt_"
end
for k, v in pairs(self.ui.document.configurable) do
G_reader_settings:saveSetting(prefix .. k, v)
end
end
function ReaderMenu:exitOrRestart(callback, force)
if self.menu_container then self:onTapCloseMenu() end
-- Only restart sets a callback, which suits us just fine for this check ;)
if callback and not force and not Device:isStartupScriptUpToDate() then
UIManager:show(ConfirmBox:new{
text = _("KOReader's startup script has been updated. You'll need to completely exit KOReader to finalize the update."),
ok_text = _("Restart anyway"),
ok_callback = function()
self:exitOrRestart(callback, true)
end,
})
return
end
UIManager:nextTick(function()
self.ui:onClose()
if callback ~= nil then
-- show an empty widget so that the callback always happens
local Widget = require("ui/widget/widget")
local widget = Widget:new{
width = Screen:getWidth(),
height = Screen:getHeight(),
}
UIManager:show(widget)
local waiting = function(waiting)
-- if we don't do this you can get a situation where either the
-- program won't exit due to remaining widgets until they're
-- dismissed or if the callback forces all widgets to close,
-- that the save document ConfirmBox is also closed
if self.ui and self.ui.document and self.ui.document:isEdited() then
logger.dbg("waiting for save settings")
UIManager:scheduleIn(1, function() waiting(waiting) end)
else
callback()
UIManager:close(widget)
end
end
UIManager:scheduleIn(1, function() waiting(waiting) end)
end
end)
local FileManager = require("apps/filemanager/filemanager")
if FileManager.instance then
FileManager.instance:onClose()
end
end
function ReaderMenu:onShowMenu(tab_index)
if self.tab_item_table == nil then
self:setUpdateItemTable()
end
if not tab_index then
tab_index = self.last_tab_index
end
local menu_container = CenterContainer:new{
ignore = "height",
dimen = Screen:getSize(),
}
local main_menu
if Device:isTouchDevice() or Device:hasDPad() then
local TouchMenu = require("ui/widget/touchmenu")
main_menu = TouchMenu:new{
width = Screen:getWidth(),
last_index = tab_index,
tab_item_table = self.tab_item_table,
show_parent = menu_container,
}
else
local Menu = require("ui/widget/menu")
main_menu = Menu:new{
title = _("Document menu"),
item_table = Menu.itemTableFromTouchMenu(self.tab_item_table),
width = Screen:getWidth() - 100,
show_parent = menu_container,
}
end
main_menu.close_callback = function()
self:onCloseReaderMenu()
end
main_menu.touch_menu_callback = function ()
self.ui:handleEvent(Event:new("CloseConfigMenu"))
end
menu_container[1] = main_menu
-- maintain a reference to menu_container
self.menu_container = menu_container
UIManager:show(menu_container)
return true
end
function ReaderMenu:onCloseReaderMenu()
if self.menu_container then
self.last_tab_index = self.menu_container[1].last_index
self:onSaveSettings()
UIManager:close(self.menu_container)
end
return true
end
function ReaderMenu:onSetDimensions(dimen)
self:onCloseReaderMenu()
end
function ReaderMenu:onCloseDocument()
if Device:supportsScreensaver() then
-- Remove the item we added (which cleans up references to document
-- and doc_settings embedded in functions)
local screensaver_sub_item_table = require("ui/elements/screensaver_menu")
for i = #screensaver_sub_item_table, 1, -1 do
if screensaver_sub_item_table[i].added_by_readermenu_flag then
table.remove(screensaver_sub_item_table, i)
end
end
end
end
function ReaderMenu:_getTabIndexFromLocation(ges)
if self.tab_item_table == nil then
self:setUpdateItemTable()
end
if not ges then
return self.last_tab_index
-- if the start position is far right
elseif ges.pos.x > Screen:getWidth() * (2/3) then
return BD.mirroredUILayout() and 1 or #self.tab_item_table
-- if the start position is far left
elseif ges.pos.x < Screen:getWidth() * (1/3) then
return BD.mirroredUILayout() and #self.tab_item_table or 1
-- if center return the last index
else
return self.last_tab_index
end
end
function ReaderMenu:onSwipeShowMenu(ges)
if self.activation_menu ~= "tap" and ges.direction == "south" then
if G_reader_settings:nilOrTrue("show_bottom_menu") then
self.ui:handleEvent(Event:new("ShowConfigMenu"))
end
self:onShowMenu(self:_getTabIndexFromLocation(ges))
self.ui:handleEvent(Event:new("HandledAsSwipe")) -- cancel any pan scroll made
return true
end
end
function ReaderMenu:onTapShowMenu(ges)
if self.activation_menu ~= "swipe" then
if G_reader_settings:nilOrTrue("show_bottom_menu") then
self.ui:handleEvent(Event:new("ShowConfigMenu"))
end
self:onShowMenu(self:_getTabIndexFromLocation(ges))
return true
end
end
function ReaderMenu:onPressMenu()
if G_reader_settings:nilOrTrue("show_bottom_menu") then
self.ui:handleEvent(Event:new("ShowConfigMenu"))
end
self:onShowMenu()
return true
end
function ReaderMenu:onTapCloseMenu()
self:onCloseReaderMenu()
self.ui:handleEvent(Event:new("CloseConfigMenu"))
end
function ReaderMenu:onReadSettings(config)
self.last_tab_index = config:readSetting("readermenu_tab_index") or 1
end
function ReaderMenu:onSaveSettings()
self.ui.doc_settings:saveSetting("readermenu_tab_index", self.last_tab_index)
end
function ReaderMenu:registerToMainMenu(widget)
table.insert(self.registered_widgets, widget)
end
return ReaderMenu
| agpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c41113025.lua | 5 | 1119 | --ディスクライダー
function c41113025.initial_effect(c)
--atkup
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(41113025,0))
e1:SetCategory(CATEGORY_ATKCHANGE)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1)
e1:SetCost(c41113025.cost)
e1:SetOperation(c41113025.operation)
c:RegisterEffect(e1)
end
function c41113025.cfilter(c)
return c:GetType()==TYPE_TRAP and c:IsAbleToRemoveAsCost()
end
function c41113025.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c41113025.cfilter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local cg=Duel.SelectMatchingCard(tp,c41113025.cfilter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.Remove(cg,POS_FACEUP,REASON_COST)
end
function c41113025.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(500)
e1:SetReset(RESET_EVENT+0x1ff0000+RESET_PHASE+PHASE_END,2)
c:RegisterEffect(e1)
end
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/zones/Tavnazian_Safehold/Zone.lua | 12 | 3369 | -----------------------------------
--
-- Zone: Tavnazian_Safehold (26)
--
-----------------------------------
package.loaded["scripts/zones/Tavnazian_Safehold/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/missions");
require("scripts/zones/Tavnazian_Safehold/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
zone:registerRegion(1, -5, -24, 18, 5, -20, 27);
zone:registerRegion(2, 104, -42, -88, 113, -38, -77);
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(27.971,-14.068,43.735,66);
end
if (player:getCurrentMission(COP) == AN_INVITATION_WEST) then
if (player:getVar("PromathiaStatus") == 1) then
cs = 0x0065;
end
elseif (player:getCurrentMission(COP) == SHELTERING_DOUBT and player:getVar("PromathiaStatus") == 0) then
cs = 0x006B;
elseif (player:getCurrentMission(COP) == CHAINS_AND_BONDS and player:getVar("PromathiaStatus") == 1) then
cs = 0x0072;
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
switch (region:GetRegionID()): caseof
{
[1] = function (x)
if (player:getCurrentMission(COP) == AN_ETERNAL_MELODY and player:getVar("PromathiaStatus") == 2) then
player:startEvent(0x0069);
end
end,
[2] = function (x)
if (player:getCurrentMission(COP) == SLANDEROUS_UTTERINGS and player:getVar("PromathiaStatus") == 0) then
player:startEvent(0x0070);
end
end,
}
end;
-----------------------------------
-- onRegionLeave
-----------------------------------
function onRegionLeave(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0065) then
player:completeMission(COP,AN_INVITATION_WEST);
player:addMission(COP,THE_LOST_CITY);
player:setVar("PromathiaStatus",0);
elseif (csid == 0x0069) then
player:setVar("PromathiaStatus",0);
player:completeMission(COP,AN_ETERNAL_MELODY);
player:addMission(COP,ANCIENT_VOWS);
elseif (csid == 0x006B) then
player:setVar("PromathiaStatus",1);
elseif (csid == 0x0070) then
player:setVar("PromathiaStatus",1);
elseif (csid == 0x0072) then
player:setVar("PromathiaStatus",2);
end
end; | gpl-3.0 |
koreader/koreader | frontend/ui/widget/openwithdialog.lua | 4 | 3924 | --[[--
This widget displays an open with dialog.
]]
local Blitbuffer = require("ffi/blitbuffer")
local CenterContainer = require("ui/widget/container/centercontainer")
local CheckButton = require("ui/widget/checkbutton")
local FrameContainer = require("ui/widget/container/framecontainer")
local Geom = require("ui/geometry")
local InputDialog = require("ui/widget/inputdialog")
local LineWidget = require("ui/widget/linewidget")
local MovableContainer = require("ui/widget/container/movablecontainer")
local RadioButtonTable = require("ui/widget/radiobuttontable")
local Size = require("ui/size")
local UIManager = require("ui/uimanager")
local VerticalGroup = require("ui/widget/verticalgroup")
local VerticalSpan = require("ui/widget/verticalspan")
local _ = require("gettext")
local Screen = require("device").screen
local OpenWithDialog = InputDialog:extend{}
function OpenWithDialog:init()
-- init title and buttons in base class
InputDialog.init(self)
self.element_width = math.floor(self.width * 0.9)
self.radio_button_table = RadioButtonTable:new{
radio_buttons = self.radio_buttons,
width = self.element_width,
focused = true,
scroll = false,
parent = self,
button_select_callback = function(btn)
if btn.provider.one_time_provider then
self._check_file_button:disable()
self._check_global_button:disable()
else
self._check_file_button:enable()
self._check_global_button:enable()
end
end
}
self.layout = {self.layout[#self.layout]} -- keep bottom buttons
self:mergeLayoutInVertical(self.radio_button_table, #self.layout) -- before bottom buttons
self._input_widget = self.radio_button_table
local vertical_span = VerticalSpan:new{
width = Size.padding.large,
}
self.vgroup = VerticalGroup:new{
align = "left",
self.title_bar,
vertical_span,
CenterContainer:new{
dimen = Geom:new{
w = self.width,
h = self.radio_button_table:getSize().h,
},
self.radio_button_table,
},
CenterContainer:new{
dimen = Geom:new{
w = self.width,
h = Size.padding.large,
},
LineWidget:new{
background = Blitbuffer.COLOR_DARK_GRAY,
dimen = Geom:new{
w = self.element_width,
h = Size.line.medium,
}
},
},
vertical_span,
CenterContainer:new{
dimen = Geom:new{
w = self.title_bar:getSize().w,
h = self.button_table:getSize().h,
},
self.button_table,
}
}
self._check_file_button = self._check_file_button or CheckButton:new{
text = _("Always use this engine for this file"),
parent = self,
}
self:addWidget(self._check_file_button)
self._check_global_button = self._check_global_button or CheckButton:new{
text = _("Always use this engine for file type"),
parent = self,
}
self:addWidget(self._check_global_button)
self.dialog_frame = FrameContainer:new{
radius = Size.radius.window,
bordersize = Size.border.window,
padding = 0,
margin = 0,
background = Blitbuffer.COLOR_WHITE,
self.vgroup,
}
self.movable = MovableContainer:new{
self.dialog_frame,
}
self[1] = CenterContainer:new{
dimen = Geom:new{
w = Screen:getWidth(),
h = Screen:getHeight(),
},
self.movable,
}
self:refocusWidget()
end
function OpenWithDialog:onCloseWidget()
UIManager:setDirty(nil, function()
return "ui", self.dialog_frame.dimen
end)
end
return OpenWithDialog
| agpl-3.0 |
waruqi/xmake | xmake/core/sandbox/modules/interpreter/os.lua | 1 | 2296 | --!A cross-platform build utility based on Lua
--
-- 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.
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
-- @file os.lua
--
-- load modules
local os = require("base/os")
local string = require("base/string")
local interpreter = require("base/interpreter")
-- define module
local sandbox_os = sandbox_os or {}
-- export some readonly interfaces
sandbox_os.host = os.host
sandbox_os.arch = os.arch
sandbox_os.subhost = os.subhost
sandbox_os.subarch = os.subarch
sandbox_os.date = os.date
sandbox_os.time = os.time
sandbox_os.mtime = os.mtime
sandbox_os.mclock = os.mclock
sandbox_os.getenv = os.getenv
sandbox_os.isdir = os.isdir
sandbox_os.isfile = os.isfile
sandbox_os.exists = os.exists
sandbox_os.curdir = os.curdir
sandbox_os.tmpdir = os.tmpdir
sandbox_os.cpuinfo = os.cpuinfo
sandbox_os.filesize = os.filesize
sandbox_os.programdir = os.programdir
sandbox_os.programfile = os.programfile
sandbox_os.projectdir = os.projectdir
sandbox_os.projectfile = os.projectfile
-- match files
function sandbox_os.files(pattern, ...)
return os.files(string.format(pattern, ...))
end
-- match directories
function sandbox_os.dirs(pattern, ...)
return os.dirs(string.format(pattern, ...))
end
-- match file and directories
function sandbox_os.filedirs(pattern, ...)
return os.filedirs(string.format(pattern, ...))
end
-- get the script directory
function sandbox_os.scriptdir()
-- get the current interpreter instance
local instance = interpreter.instance()
assert(instance)
-- get the script directory
return instance:scriptdir()
end
-- return module
return sandbox_os
| apache-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c14550855.lua | 9 | 1251 | --インフェルニティ・インフェルノ
function c14550855.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_HANDES+CATEGORY_TOGRAVE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(c14550855.target)
e1:SetOperation(c14550855.activate)
c:RegisterEffect(e1)
end
function c14550855.filter(c)
return c:IsSetCard(0xb) and c:IsAbleToGrave()
end
function c14550855.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetFieldGroupCount(tp,LOCATION_HAND,0)>0
and Duel.IsExistingMatchingCard(c14550855.filter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_HANDES,nil,0,tp,1)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK)
end
function c14550855.activate(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetFieldGroupCount(tp,LOCATION_HAND,0)==0 then return end
local ac=Duel.GetMatchingGroupCount(c14550855.filter,tp,LOCATION_DECK,0,nil)
if ac==0 then return end
if ac>2 then ac=2 end
local ct=Duel.DiscardHand(tp,aux.TRUE,1,ac,REASON_DISCARD+REASON_EFFECT)
Duel.BreakEffect()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,c14550855.filter,tp,LOCATION_DECK,0,1,ct,nil)
Duel.SendtoGrave(g,REASON_EFFECT)
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c22900598.lua | 2 | 1937 | --ヴァンパイア・シフト
function c22900598.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,22900598+EFFECT_COUNT_CODE_OATH)
e1:SetCondition(c22900598.condition)
e1:SetTarget(c22900598.target)
e1:SetOperation(c22900598.activate)
c:RegisterEffect(e1)
end
function c22900598.condition(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetFieldCard(tp,LOCATION_SZONE,5)~=nil then return false end
local g=Duel.GetMatchingGroup(Card.IsFaceup,tp,LOCATION_MZONE,0,nil)
return g:GetCount()>0 and g:FilterCount(Card.IsRace,nil,RACE_ZOMBIE)==g:GetCount()
end
function c22900598.filter(c,tp)
return c:IsCode(62188962) and c:GetActivateEffect():IsActivatable(tp)
end
function c22900598.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c22900598.filter,tp,LOCATION_DECK,0,1,nil,tp) end
end
function c22900598.spfilter(c,e,tp)
return c:IsSetCard(0x8e) and c:IsAttribute(ATTRIBUTE_DARK) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c22900598.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstMatchingCard(c22900598.filter,tp,LOCATION_DECK,0,nil,tp)
if tc then
Duel.MoveToField(tc,tp,tp,LOCATION_SZONE,POS_FACEUP,true)
local te=tc:GetActivateEffect()
local tep=tc:GetControler()
local cost=te:GetCost()
if cost then cost(te,tep,eg,ep,ev,re,r,rp,1) end
Duel.RaiseEvent(tc,4179255,te,0,tp,tp,Duel.GetCurrentChain())
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
local sg=Duel.GetMatchingGroup(aux.NecroValleyFilter(c22900598.spfilter),tp,LOCATION_GRAVE,0,nil,e,tp)
if sg:GetCount()>0 and Duel.SelectYesNo(tp,aux.Stringid(22900598,0)) then
Duel.BreakEffect()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=sg:Select(tp,1,1,nil)
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP_DEFENSE)
end
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c83519853.lua | 5 | 3141 | --魔聖騎士皇ランスロット
function c83519853.initial_effect(c)
c:SetUniqueOnField(1,0,83519853)
--synchro summon
aux.AddSynchroProcedure(c,nil,aux.NonTuner(Card.IsSetCard,0x107a),1)
c:EnableReviveLimit()
--equip
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(83519853,0))
e1:SetCategory(CATEGORY_EQUIP)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetCondition(c83519853.condition)
e1:SetTarget(c83519853.target)
e1:SetOperation(c83519853.operation)
c:RegisterEffect(e1)
--tohand
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_BATTLE_DESTROYING)
e2:SetCondition(c83519853.regcon)
e2:SetOperation(c83519853.regop)
c:RegisterEffect(e2)
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(83519853,1))
e3:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e3:SetCode(EVENT_PHASE+PHASE_BATTLE)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1)
e3:SetCondition(c83519853.thcon)
e3:SetTarget(c83519853.thtg)
e3:SetOperation(c83519853.thop)
c:RegisterEffect(e3)
end
function c83519853.condition(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():GetSummonType()==SUMMON_TYPE_SYNCHRO
end
function c83519853.filter(c,ec)
return c:IsSetCard(0x207a) and c:IsType(TYPE_EQUIP) and c:CheckEquipTarget(ec)
end
function c83519853.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and Duel.IsExistingMatchingCard(c83519853.filter,tp,LOCATION_DECK,0,1,nil,e:GetHandler()) end
Duel.SetOperationInfo(0,CATEGORY_EQUIP,nil,1,tp,LOCATION_DECK)
end
function c83519853.operation(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end
local c=e:GetHandler()
if c:IsFacedown() or not c:IsRelateToEffect(e) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
local g=Duel.SelectMatchingCard(tp,c83519853.filter,tp,LOCATION_DECK,0,1,1,nil,c)
local tc=g:GetFirst()
if tc then
Duel.Equip(tp,tc,c,true)
end
end
function c83519853.regcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local bc=c:GetBattleTarget()
return c:IsRelateToBattle() and bc:IsLocation(LOCATION_GRAVE) and bc:IsType(TYPE_MONSTER)
end
function c83519853.regop(e,tp,eg,ep,ev,re,r,rp)
e:GetHandler():RegisterFlagEffect(83519853,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1)
end
function c83519853.thcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():GetFlagEffect(83519853)~=0
end
function c83519853.thfilter(c)
return (c:IsSetCard(0x107a) or c:IsSetCard(0x207a)) and c:IsAbleToHand()
end
function c83519853.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c83519853.thfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c83519853.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c83519853.thfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
| gpl-2.0 |
waruqi/xmake | xmake/core/sandbox/modules/import/core/tool/linker.lua | 1 | 3559 | --!A cross-platform build utility based on Lua
--
-- 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.
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
-- @file linker.lua
--
-- define module
local sandbox_core_tool_linker = sandbox_core_tool_linker or {}
-- load modules
local platform = require("platform/platform")
local linker = require("tool/linker")
local raise = require("sandbox/modules/raise")
-- load the linker from the given target kind
function sandbox_core_tool_linker.load(targetkind, sourcekinds, opt)
-- get the linker instance
local instance, errors = linker.load(targetkind, sourcekinds, opt and opt.target or nil)
if not instance then
raise(errors)
end
-- ok
return instance
end
-- make command for linking target file
function sandbox_core_tool_linker.linkcmd(targetkind, sourcekinds, objectfiles, targetfile, opt)
return os.args(table.join(sandbox_core_tool_linker.linkargv(targetkind, sourcekinds, objectfiles, targetfile, opt)))
end
-- make arguments list for linking target file
function sandbox_core_tool_linker.linkargv(targetkind, sourcekinds, objectfiles, targetfile, opt)
-- init options
opt = opt or {}
-- get the linker instance
local instance = sandbox_core_tool_linker.load(targetkind, sourcekinds, opt)
-- make arguments list
return instance:linkargv(objectfiles, targetfile, opt)
end
-- make link flags for the given target
--
-- @param targetkind the target kind
-- @param sourcekinds the source kinds
-- @param opt the argument options (contain all the linker attributes of target),
-- e.g. {target = ..., targetkind = "static", config = {cxflags = "", defines = "", includedirs = "", ...}}
--
function sandbox_core_tool_linker.linkflags(targetkind, sourcekinds, opt)
-- init options
opt = opt or {}
-- get the linker instance
local instance = sandbox_core_tool_linker.load(targetkind, sourcekinds, opt)
-- make flags
return instance:linkflags(opt)
end
-- link target file
function sandbox_core_tool_linker.link(targetkind, sourcekinds, objectfiles, targetfile, opt)
-- init options
opt = opt or {}
-- get the linker instance
local instance = sandbox_core_tool_linker.load(targetkind, sourcekinds, opt)
-- link it
local ok, errors = instance:link(objectfiles, targetfile, opt)
if not ok then
raise(errors)
end
end
-- has the given flags?
--
-- @param targetkind the target kind
-- @param sourcekinds the source kinds
-- @param flags the flags
-- @param opt the options
--
-- @return the supported flags or nil
--
function sandbox_core_tool_linker.has_flags(targetkind, sourcekinds, flags, opt)
-- init options
opt = opt or {}
-- get the linker instance
local instance = sandbox_core_tool_linker.load(targetkind, sourcekinds, opt)
-- has flags?
return instance:has_flags(flags)
end
-- return module
return sandbox_core_tool_linker
| apache-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c49681811.lua | 3 | 3035 | --無敗将軍 フリード
function c49681811.initial_effect(c)
--disable
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_DISABLE)
e1:SetRange(LOCATION_MZONE)
e1:SetTargetRange(LOCATION_SZONE,LOCATION_SZONE)
e1:SetTarget(c49681811.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(c49681811.disop)
c:RegisterEffect(e2)
--self destroy
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(EFFECT_SELF_DESTROY)
e3:SetRange(LOCATION_MZONE)
e3:SetTargetRange(LOCATION_SZONE,LOCATION_SZONE)
e3:SetTarget(c49681811.distg)
c:RegisterEffect(e3)
--search
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(49681811,0))
e4:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e4:SetCode(EVENT_PREDRAW)
e4:SetRange(LOCATION_MZONE)
e4:SetCondition(c49681811.condition)
e4:SetTarget(c49681811.target)
e4:SetOperation(c49681811.operation)
c:RegisterEffect(e4)
end
function c49681811.distg(e,c)
if not c:IsType(TYPE_SPELL) or c:GetCardTargetCount()==0 then return false end
return c:GetCardTarget():IsContains(e:GetHandler())
end
function c49681811.disop(e,tp,eg,ep,ev,re,r,rp)
if not re:IsActiveType(TYPE_SPELL) then return end
if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then return end
local g=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS)
if not g or g:GetCount()==0 then return end
if g:IsContains(e:GetHandler()) then
if Duel.NegateEffect(ev) and re:GetHandler():IsRelateToEffect(re) then
Duel.Destroy(re:GetHandler(),REASON_EFFECT)
end
end
end
function c49681811.condition(e,tp,eg,ep,ev,re,r,rp)
return tp==Duel.GetTurnPlayer() and Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)>0
and Duel.GetDrawCount(tp)>0
end
function c49681811.filter(c)
return c:IsLevelBelow(4) and c:IsRace(RACE_WARRIOR) and c:IsAbleToHand()
end
function c49681811.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c49681811.filter,tp,LOCATION_DECK,0,1,nil) end
local dt=Duel.GetDrawCount(tp)
if dt~=0 then
_replace_count=0
_replace_max=dt
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetCode(EFFECT_DRAW_COUNT)
e1:SetTargetRange(1,0)
e1:SetReset(RESET_PHASE+PHASE_DRAW)
e1:SetValue(0)
Duel.RegisterEffect(e1,tp)
end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,0,LOCATION_DECK)
end
function c49681811.operation(e,tp,eg,ep,ev,re,r,rp)
_replace_count=_replace_count+1
if _replace_count>_replace_max or not e:GetHandler():IsRelateToEffect(e) or e:GetHandler():IsFacedown() then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c49681811.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 |
SalvationDevelopment/Salvation-Scripts-Production | c42502956.lua | 5 | 1694 | --エアーズロック・サンライズ
function c42502956.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1,42502956+EFFECT_COUNT_CODE_OATH)
e1:SetTarget(c42502956.target)
e1:SetOperation(c42502956.activate)
c:RegisterEffect(e1)
end
function c42502956.filter(c,e,tp)
return c:IsRace(RACE_BEAST) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c42502956.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c42502956.filter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c42502956.filter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c42502956.filter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c42502956.activate(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 g=Duel.GetMatchingGroup(Card.IsFaceup,tp,0,LOCATION_MZONE,nil)
local ct=Duel.GetMatchingGroupCount(Card.IsRace,tp,LOCATION_GRAVE,0,nil,RACE_BEAST+RACE_WINDBEAST+RACE_PLANT)
tc=g:GetFirst()
while tc do
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(ct*-200)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
tc=g:GetNext()
end
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c4230620.lua | 5 | 1618 | --サイキックブレイク
function c4230620.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--destroy
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(4230620,0))
e2:SetCategory(CATEGORY_ATKCHANGE)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetRange(LOCATION_SZONE)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCode(EVENT_SUMMON_SUCCESS)
e2:SetCondition(c4230620.atkcon)
e2:SetCost(c4230620.atkcost)
e2:SetTarget(c4230620.atktg)
e2:SetOperation(c4230620.atkop)
c:RegisterEffect(e2)
end
function c4230620.atkcon(e,tp,eg,ep,ev,re,r,rp)
local c=eg:GetFirst()
return c:IsOnField() and c:IsRace(RACE_PSYCHO)
end
function c4230620.atkcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckLPCost(tp,500) end
Duel.PayLPCost(tp,500)
end
function c4230620.atktg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return false end
if chk==0 then return true end
Duel.SetTargetCard(eg)
end
function c4230620.atkop(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
local tc=Duel.GetFirstTarget()
if tc:IsFaceup() and tc:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_LEVEL)
e1:SetValue(1)
e1:SetReset(RESET_EVENT+0x1fe0000)
tc:RegisterEffect(e1)
local e2=Effect.CreateEffect(e:GetHandler())
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_UPDATE_ATTACK)
e2:SetValue(300)
e2:SetReset(RESET_EVENT+0x1fe0000)
tc:RegisterEffect(e2)
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c100331023.lua | 2 | 2104 | --星霜のペンデュラムグラフ
--Pendulumgraph of Ages
--Scripted by Eerie Code
function c100331023.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--Cannot target
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
e2:SetRange(LOCATION_SZONE)
e2:SetTargetRange(LOCATION_MZONE,0)
e2:SetTarget(aux.TargetBoolFunction(Card.IsRace,RACE_SPELLCASTER))
e2:SetValue(c100331023.evalue)
c:RegisterEffect(e2)
--Search
local e3=Effect.CreateEffect(c)
e3:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e3:SetCode(EVENT_LEAVE_FIELD)
e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
e3:SetRange(LOCATION_SZONE)
e3:SetCountLimit(1,100331023)
e3:SetCondition(c100331023.thcon)
e3:SetTarget(c100331023.thtg)
e3:SetOperation(c100331023.thop)
c:RegisterEffect(e3)
end
function c100331023.evalue(e,re,rp)
return re:IsActiveType(TYPE_SPELL) and rp~=e:GetHandlerPlayer()
end
function c100331023.thcfilter(c,tp)
local pl=c:GetPreviousLocation()
local ps=c:GetPreviousSequence()
return c:IsType(TYPE_PENDULUM) and c:IsPreviousSetCard(0x98)
and c:GetPreviousControler()==tp and c:IsPreviousPosition(POS_FACEUP)
and (pl==LOCATION_MZONE or (pl==LOCATION_SZONE and (ps==6 or ps==7)))
end
function c100331023.thcon(e,tp,eg,ep,ev,re,r,rp)
return eg and eg:IsExists(c100331023.thcfilter,1,nil,tp)
end
function c100331023.thfilter(c)
return c:IsType(TYPE_PENDULUM) and c:IsSetCard(0x98) and c:IsAbleToHand()
end
function c100331023.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c100331023.thop(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c100331023.thfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c53819028.lua | 6 | 3027 | --捕食植物セラセニアント
function c53819028.initial_effect(c)
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(53819028,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_ATTACK_ANNOUNCE)
e1:SetRange(LOCATION_HAND)
e1:SetCondition(c53819028.spcon)
e1:SetTarget(c53819028.sptg)
e1:SetOperation(c53819028.spop)
c:RegisterEffect(e1)
--destroy
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(53819028,1))
e2:SetCategory(CATEGORY_DESTROY)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_BATTLED)
e2:SetTarget(c53819028.destg)
e2:SetOperation(c53819028.desop)
c:RegisterEffect(e2)
--search
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(53819028,2))
e3:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetProperty(EFFECT_FLAG_DELAY)
e3:SetCode(EVENT_BATTLE_DESTROYED)
e3:SetCountLimit(1,53819028)
e3:SetTarget(c53819028.thtg)
e3:SetOperation(c53819028.thop)
c:RegisterEffect(e3)
local e4=e3:Clone()
e4:SetCode(EVENT_TO_GRAVE)
e4:SetCondition(c53819028.thcon)
c:RegisterEffect(e4)
end
function c53819028.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetAttacker():GetControler()~=tp and Duel.GetAttackTarget()==nil
end
function c53819028.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,0)
end
function c53819028.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) then return end
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
end
function c53819028.destg(e,tp,eg,ep,ev,re,r,rp,chk)
local tc=Duel.GetAttacker()
if tc==e:GetHandler() then tc=Duel.GetAttackTarget() end
if chk==0 then return tc and tc:IsRelateToBattle() end
Duel.SetOperationInfo(0,CATEGORY_DESTROY,tc,1,0,0)
end
function c53819028.desop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetAttacker()
if tc==e:GetHandler() then tc=Duel.GetAttackTarget() end
if tc:IsRelateToBattle() and tc:IsControler(1-tp) then
Duel.Destroy(tc,REASON_EFFECT)
end
end
function c53819028.thcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsReason(REASON_EFFECT) and c:IsPreviousLocation(LOCATION_ONFIELD)
end
function c53819028.thfilter(c)
return c:IsSetCard(0xf3) and c:IsAbleToHand() and not c:IsCode(53819028)
end
function c53819028.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c53819028.thfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c53819028.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c53819028.thfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
| gpl-2.0 |
pombredanne/libguestfs | lua/tests/070-optargs.lua | 4 | 1059 | #!/bin/sh
# -*- lua -*-
test -z "$LUA" && LUA=lua
exec $LUA << END_OF_FILE
-- libguestfs Lua bindings -*- lua -*-
-- Copyright (C) 2012 Red Hat Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
local G = require "guestfs"
local g = G.create ()
g:add_drive ("/dev/null")
g:add_drive ("/dev/null", { readonly = true })
g:add_drive ("/dev/null", { format = "raw", readonly = false })
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c100000196.lua | 2 | 2205 | --アトリビュート・マスタリー
function c100000196.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(c100000196.target)
e1:SetOperation(c100000196.operation)
c:RegisterEffect(e1)
--race
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_DESTROY)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e2:SetCode(EVENT_BATTLE_START)
e2:SetRange(LOCATION_SZONE)
e2:SetTarget(c100000196.destg)
e2:SetOperation(c100000196.desop)
c:RegisterEffect(e2)
e1:SetLabelObject(e2)
--Equip limit
local e3=Effect.CreateEffect(c)
e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_EQUIP_LIMIT)
e3:SetValue(1)
c:RegisterEffect(e3)
end
function c100000196.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsFaceup() end
if chk==0 then return Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.Hint(HINT_SELECTMSG,tp,562)
local rc=Duel.AnnounceAttribute(tp,1,0xffff)
e:GetLabelObject():SetLabel(rc)
e:GetHandler():SetHint(CHINT_ATTRIBUTE,rc)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
function c100000196.operation(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if e:GetHandler():IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsFaceup() then
Duel.Equip(tp,e:GetHandler(),tc)
end
end
function c100000196.destg(e,tp,eg,ep,ev,re,r,rp,chk)
local q=e:GetLabel()
local c=e:GetHandler():GetEquipTarget()
local tc=Duel.GetAttacker()
if tc==c then tc=Duel.GetAttackTarget() end
if chk==0 then return tc and tc:IsFaceup() and tc:IsAttribute(q) end
Duel.SetOperationInfo(0,CATEGORY_DESTROY,tc,1,0,0)
end
function c100000196.desop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler():GetEquipTarget()
local tc=Duel.GetAttacker()
if tc==c then tc=Duel.GetAttackTarget() end
if tc:IsRelateToBattle() then Duel.Destroy(tc,REASON_EFFECT) end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c5371656.lua | 5 | 1905 | --魂喰らいの魔刀
function c5371656.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(c5371656.target)
e1:SetOperation(c5371656.operation)
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(c5371656.eqlimit)
c:RegisterEffect(e2)
end
function c5371656.eqlimit(e,c)
return c:IsType(TYPE_NORMAL) and c:IsLevelBelow(3)
end
function c5371656.filter(c)
return c:IsFaceup() and c:IsType(TYPE_NORMAL) and c:IsLevelBelow(3)
end
function c5371656.rfilter(c)
local tpe=c:GetType()
return bit.band(tpe,TYPE_NORMAL)~=0 and bit.band(tpe,TYPE_TOKEN)==0 and c:IsReleasable()
end
function c5371656.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c5371656.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c5371656.filter,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
local g=Duel.SelectTarget(tp,c5371656.filter,tp,LOCATION_MZONE,0,1,1,nil)
local rg=Duel.GetMatchingGroup(c5371656.rfilter,tp,LOCATION_MZONE,0,g:GetFirst())
Duel.Release(rg,REASON_COST)
e:SetLabel(rg:GetCount()*1000)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
function c5371656.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() and tc:IsControler(tp) then
Duel.Equip(tp,e:GetHandler(),tc)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_EQUIP)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(e:GetLabel())
e1:SetReset(RESET_EVENT+0x1fe0000)
c:RegisterEffect(e1)
end
end
| gpl-2.0 |
diegonehab/LuaSocket | test/testmesg.lua | 45 | 2957 | -- load the smtp support and its friends
local smtp = require("socket.smtp")
local mime = require("mime")
local ltn12 = require("ltn12")
function filter(s)
if s then io.write(s) end
return s
end
source = smtp.message {
headers = { ['content-type'] = 'multipart/alternative' },
body = {
[1] = {
headers = { ['Content-type'] = 'text/html' },
body = "<html> <body> Hi, <b>there</b>...</body> </html>"
},
[2] = {
headers = { ['content-type'] = 'text/plain' },
body = "Hi, there..."
}
}
}
r, e = smtp.send{
rcpt = {"<diego@tecgraf.puc-rio.br>",
"<diego@princeton.edu>" },
from = "<diego@princeton.edu>",
source = ltn12.source.chain(source, filter),
--server = "mail.cs.princeton.edu"
server = "localhost",
port = 2525
}
print(r, e)
-- creates a source to send a message with two parts. The first part is
-- plain text, the second part is a PNG image, encoded as base64.
source = smtp.message{
headers = {
-- Remember that headers are *ignored* by smtp.send.
from = "Sicrano <sicrano@tecgraf.puc-rio.br>",
to = "Fulano <fulano@tecgraf.puc-rio.br>",
subject = "Here is a message with attachments"
},
body = {
preamble = "If your client doesn't understand attachments, \r\n" ..
"it will still display the preamble and the epilogue.\r\n" ..
"Preamble might show up even in a MIME enabled client.",
-- first part: No headers means plain text, us-ascii.
-- The mime.eol low-level filter normalizes end-of-line markers.
[1] = {
body = mime.eol(0, [[
Lines in a message body should always end with CRLF.
The smtp module will *NOT* perform translation. It will
perform necessary stuffing, though.
]])
},
-- second part: Headers describe content the to be an image,
-- sent under the base64 transfer content encoding.
-- Notice that nothing happens until the message is sent. Small
-- chunks are loaded into memory and translation happens on the fly.
[2] = {
headers = {
["ConTenT-tYpE"] = 'image/png; name="luasocket.png"',
["content-disposition"] = 'attachment; filename="luasocket.png"',
["content-description"] = 'our logo',
["content-transfer-encoding"] = "BASE64"
},
body = ltn12.source.chain(
ltn12.source.file(io.open("luasocket.png", "rb")),
ltn12.filter.chain(
mime.encode("base64"),
mime.wrap()
)
)
},
epilogue = "This might also show up, but after the attachments"
}
}
r, e = smtp.send{
rcpt = {"<diego@tecgraf.puc-rio.br>",
"<diego@princeton.edu>" },
from = "<diego@princeton.edu>",
source = ltn12.source.chain(source, filter),
--server = "mail.cs.princeton.edu",
--port = 25
server = "localhost",
port = 2525
}
print(r, e)
| mit |
retep998/Vana | scripts/npcs/gachapon18.lua | 2 | 7204 | --[[
Copyright (C) 2008-2016 Vana Development 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; version 2
of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
--]]
-- Gachapon - The Nautilus : Mid Floor - Hallway
dofile("scripts/utils/gachaponHelper.lua");
-- General rules:
-- Global item chance is significantly reduced
-- All gear for town class; weight derived at 20 / itemLevel
-- 10 random gears between levels 10 and 40 from other town classes; weight derived at 10 / itemLevel
-- All skills for the town class
-- All weapon scrolls for the town class' weapons
commonEquips = {};
warriorEquips = {
{1060017, ["weight"] = 0.33}, {1072047, ["weight"] = 0.50},
{1302008, ["weight"] = 0.33}, {1072002, ["weight"] = 0.29},
{1002055, ["weight"] = 0.50}, {1040028, ["weight"] = 0.31},
{1041064, ["weight"] = 1.00}, {1072041, ["weight"] = 0.33},
{1072127, ["weight"] = 0.25}, {1092000, ["weight"] = 0.67},
};
magicianEquips = {
{1050010, ["weight"] = 0.77}, {1050008, ["weight"] = 0.77},
{1072006, ["weight"] = 1.00}, {1082053, ["weight"] = 0.33},
{1061022, ["weight"] = 0.77}, {1051026, ["weight"] = 0.26},
{1051003, ["weight"] = 0.43}, {1382015, ["weight"] = 0.33},
{1072074, ["weight"] = 0.40}, {1002013, ["weight"] = 0.33},
};
bowmanEquips = {
{1082048, ["weight"] = 0.33}, {1061061, ["weight"] = 0.29},
{1041056, ["weight"] = 0.33}, {1002161, ["weight"] = 0.33},
{1002157, ["weight"] = 0.40}, {1002162, ["weight"] = 0.33},
{1462048, ["weight"] = 0.25}, {1002158, ["weight"] = 0.40},
{1041054, ["weight"] = 0.33}, {1002120, ["weight"] = 0.50},
};
thiefEquips = {
{1040061, ["weight"] = 0.29}, {1060073, ["weight"] = 0.25},
{1072031, ["weight"] = 0.67}, {1472013, ["weight"] = 0.29},
{1051009, ["weight"] = 0.29}, {1472009, ["weight"] = 0.33},
{1072036, ["weight"] = 0.33}, {1002184, ["weight"] = 0.25},
{1002182, ["weight"] = 0.25}, {1061055, ["weight"] = 0.40},
};
pirateEquips = {
{1002610, ["weight"] = 2.00}, {1002613, ["weight"] = 1.33},
{1002616, ["weight"] = 1.00}, {1002619, ["weight"] = 0.80},
{1002622, ["weight"] = 0.67}, {1002625, ["weight"] = 0.57},
{1002628, ["weight"] = 0.50}, {1002631, ["weight"] = 0.40},
{1002634, ["weight"] = 0.33}, {1002637, ["weight"] = 0.29},
{1002640, ["weight"] = 0.25}, {1002643, ["weight"] = 0.22},
{1002646, ["weight"] = 0.20}, {1002649, ["weight"] = 0.18},
{1002780, ["weight"] = 0.17}, {1002794, ["weight"] = 0.17},
{1052095, ["weight"] = 2.00}, {1052098, ["weight"] = 1.33},
{1052101, ["weight"] = 1.00}, {1052104, ["weight"] = 0.80},
{1052107, ["weight"] = 0.67}, {1052110, ["weight"] = 0.57},
{1052113, ["weight"] = 0.50}, {1052116, ["weight"] = 0.40},
{1052119, ["weight"] = 0.33}, {1052122, ["weight"] = 0.29},
{1052125, ["weight"] = 0.25}, {1052128, ["weight"] = 0.22},
{1052131, ["weight"] = 0.20}, {1052134, ["weight"] = 0.18},
{1052159, ["weight"] = 0.17}, {1052164, ["weight"] = 0.17},
{1072285, ["weight"] = 1.33}, {1072288, ["weight"] = 1.00},
{1072291, ["weight"] = 0.80}, {1072294, ["weight"] = 0.67},
{1072297, ["weight"] = 0.57}, {1072300, ["weight"] = 0.50},
{1072303, ["weight"] = 0.40}, {1072306, ["weight"] = 0.33},
{1072309, ["weight"] = 0.29}, {1072312, ["weight"] = 0.25},
{1072315, ["weight"] = 0.22}, {1072318, ["weight"] = 0.20},
{1072321, ["weight"] = 0.18}, {1072338, ["weight"] = 0.67},
{1072359, ["weight"] = 0.17}, {1072365, ["weight"] = 0.17},
{1082180, ["weight"] = 1.33}, {1082183, ["weight"] = 1.00},
{1082186, ["weight"] = 0.80}, {1082189, ["weight"] = 0.67},
{1082192, ["weight"] = 0.57}, {1082195, ["weight"] = 0.50},
{1082198, ["weight"] = 0.40}, {1082201, ["weight"] = 0.33},
{1082204, ["weight"] = 0.29}, {1082207, ["weight"] = 0.25},
{1082210, ["weight"] = 0.22}, {1082213, ["weight"] = 0.20},
{1082216, ["weight"] = 0.18}, {1082238, ["weight"] = 0.17},
{1082243, ["weight"] = 0.17}, {1482000, ["weight"] = 2.00},
{1482001, ["weight"] = 1.33}, {1482002, ["weight"] = 1.00},
{1482003, ["weight"] = 0.80}, {1482004, ["weight"] = 0.67},
{1482005, ["weight"] = 0.57}, {1482006, ["weight"] = 0.50},
{1482007, ["weight"] = 0.40}, {1482008, ["weight"] = 0.33},
{1482009, ["weight"] = 0.29}, {1482010, ["weight"] = 0.25},
{1482011, ["weight"] = 0.22}, {1482012, ["weight"] = 0.20},
{1482013, ["weight"] = 0.18}, {1482023, ["weight"] = 0.17},
{1482024, ["weight"] = 0.17}, {1482034, ["weight"] = 0.17},
{1492000, ["weight"] = 2.00}, {1492001, ["weight"] = 1.33},
{1492002, ["weight"] = 1.00}, {1492003, ["weight"] = 0.80},
{1492004, ["weight"] = 0.67}, {1492005, ["weight"] = 0.57},
{1492006, ["weight"] = 0.50}, {1492007, ["weight"] = 0.40},
{1492008, ["weight"] = 0.33}, {1492009, ["weight"] = 0.29},
{1492010, ["weight"] = 0.25}, {1492011, ["weight"] = 0.22},
{1492012, ["weight"] = 0.20}, {1492013, ["weight"] = 0.18},
{1492023, ["weight"] = 0.17}, {1492025, ["weight"] = 0.17},
};
scrolls = {
2044800, 2044801, 2044802, 2044803, 2044804, 2044805, 2044807, 2044809, 2044900, 2044901,
2044902, 2044903, 2044904,
};
bullets = {
-- TODO FIXME gachapon
};
skills = {
-- 2290096 (which should be the start of these books given the other classes) is Maple Warrior 20, so obviously not a part of here
{2290097, ["weight"] = mastery_book_20}, {2290098, ["weight"] = mastery_book_30},
{2290099, ["weight"] = mastery_book_20}, {2290100, ["weight"] = mastery_book_30},
{2290101, ["weight"] = mastery_book_20},
{2290102, ["weight"] = mastery_book_20}, {2290103, ["weight"] = mastery_book_30},
{2290104, ["weight"] = mastery_book_20}, {2290105, ["weight"] = mastery_book_30},
{2290106, ["weight"] = mastery_book_20}, {2290107, ["weight"] = mastery_book_30},
{2290108, ["weight"] = mastery_book_20}, --{2290109, ["weight"] = mastery_book_30}, -- Technically this book exists, but it's not used, it's Speed Infusion 30
{2290110, ["weight"] = mastery_book_20}, {2290111, ["weight"] = mastery_book_30},
{2290112, ["weight"] = mastery_book_20}, {2290113, ["weight"] = mastery_book_30},
{2290114, ["weight"] = mastery_book_20},
{2290115, ["weight"] = mastery_book_20}, {2290116, ["weight"] = mastery_book_30},
{2290117, ["weight"] = mastery_book_20}, {2290118, ["weight"] = mastery_book_30},
{2290119, ["weight"] = mastery_book_20}, {2290120, ["weight"] = mastery_book_30},
{2290121, ["weight"] = mastery_book_20}, {2290122, ["weight"] = mastery_book_30},
{2290123, ["weight"] = mastery_book_20},
{2290124, ["weight"] = mastery_book_20},
};
items = merge(commonEquips, warriorEquips, magicianEquips, bowmanEquips, thiefEquips, pirateEquips, scrolls, bullets, skills);
gachapon({
["items"] = items,
-- Decrease the chance of getting things from the global item list
["globalItemWeightModifier"] = .5,
}); | gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c28357177.lua | 9 | 1091 | --派手ハネ
function c28357177.initial_effect(c)
--flip
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(28357177,0))
e1:SetCategory(CATEGORY_TOHAND)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_FLIP+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e1:SetTarget(c28357177.target)
e1:SetOperation(c28357177.operation)
c:RegisterEffect(e1)
end
function c28357177.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsAbleToHand() end
if chk==0 then return Duel.IsExistingTarget(Card.IsAbleToHand,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local g=Duel.SelectTarget(tp,Card.IsAbleToHand,tp,LOCATION_MZONE,LOCATION_MZONE,1,3,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,g:GetCount(),0,0)
end
function c28357177.operation(e,tp,eg,ep,ev,re,r,rp)
local tg=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
if tg then
local g=tg:Filter(Card.IsRelateToEffect,nil,e)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
end
end
end
| gpl-2.0 |
retep998/Vana | scripts/npcs/nautil_black.lua | 2 | 1511 | --[[
Copyright (C) 2008-2016 Vana Development 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; version 2
of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
--]]
-- Muirhat
dofile("scripts/utils/npcHelper.lua");
if not isQuestActive(2175) then
addText("The Black Magician and his followers. ");
addText("Kyrin and the crew of the Nautilus. ");
addText("They'll be chasing one another until one of them doesn't exist, that's for sure.");
sendOk();
else
addText("Are you ready? ");
addText("Good, I'll send you to where the disciples of the Black Magician are. ");
addText("Look for the pigs around the area where I'll be sending you. ");
addText("You'll be able to find it by tracking them.");
sendNext();
addText("When they are weakened, they'll change back to their original state. ");
addText("If you find something suspicious, you must fight them until they are weak. ");
addText("I'll be here awaiting your findings.");
sendBackNext();
setMap(912000000);
end | gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c67381587.lua | 2 | 2217 | --黒猫の睨み
function c67381587.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCondition(c67381587.condition)
e1:SetOperation(c67381587.activate)
c:RegisterEffect(e1)
--position change
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_POSITION)
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetCode(EVENT_FREE_CHAIN)
e2:SetRange(LOCATION_GRAVE)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCost(c67381587.poscost)
e2:SetTarget(c67381587.postg)
e2:SetOperation(c67381587.posop)
c:RegisterEffect(e2)
end
function c67381587.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()~=tp and (Duel.GetCurrentPhase()>=PHASE_BATTLE_START and Duel.GetCurrentPhase()<=PHASE_BATTLE)
and Duel.IsExistingMatchingCard(Card.IsPosition,tp,LOCATION_MZONE,0,2,nil,POS_FACEDOWN_DEFENSE)
end
function c67381587.activate(e,tp,eg,ep,ev,re,r,rp)
Duel.SkipPhase(1-tp,PHASE_BATTLE,RESET_PHASE+PHASE_BATTLE,1)
end
function c67381587.poscost(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 c67381587.posfilter1(c)
return c:IsFaceup() and c:IsSetCard(0xcc) and c:IsCanTurnSet()
and Duel.IsExistingTarget(c67381587.posfilter2,0,LOCATION_MZONE,LOCATION_MZONE,1,c)
end
function c67381587.posfilter2(c)
return c:IsFaceup() and c:IsCanTurnSet()
end
function c67381587.postg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return false end
if chk==0 then return Duel.IsExistingTarget(c67381587.posfilter1,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_POSCHANGE)
local g1=Duel.SelectTarget(tp,c67381587.posfilter1,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_POSCHANGE)
local g2=Duel.SelectTarget(tp,c67381587.posfilter2,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,g1:GetFirst())
g1:Merge(g2)
Duel.SetOperationInfo(0,CATEGORY_POSITION,g1,2,0,0)
end
function c67381587.posop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e)
if g:GetCount()>0 then
Duel.ChangePosition(g,POS_FACEDOWN_DEFENSE)
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c5361647.lua | 7 | 1863 | --BK グラスジョー
function c5361647.initial_effect(c)
--destroy
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(5361647,0))
e1:SetCategory(CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e1:SetCode(EVENT_BE_BATTLE_TARGET)
e1:SetTarget(c5361647.destg)
e1:SetOperation(c5361647.desop)
c:RegisterEffect(e1)
--search
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(5361647,1))
e2:SetCategory(CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_TO_GRAVE)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCondition(c5361647.thcon)
e2:SetTarget(c5361647.thtg)
e2:SetOperation(c5361647.thop)
c:RegisterEffect(e2)
end
function c5361647.destg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_DESTROY,e:GetHandler(),1,0,0)
end
function c5361647.desop(e,tp,eg,ep,ev,re,r,rp)
if e:GetHandler():IsRelateToEffect(e) then
Duel.Destroy(e:GetHandler(),REASON_EFFECT)
end
end
function c5361647.thcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsReason(REASON_EFFECT)
end
function c5361647.filter(c)
return c:IsSetCard(0x84) and c:GetCode()~=5361647 and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
end
function c5361647.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c5361647.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c5361647.filter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectTarget(tp,c5361647.filter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function c5361647.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 |
SalvationDevelopment/Salvation-Scripts-Production | c50615578.lua | 6 | 1628 | --カラクリ忍者 七七四九
function c50615578.initial_effect(c)
--must attack
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_MUST_ATTACK)
c:RegisterEffect(e1)
--pos change
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(50615578,0))
e3:SetCategory(CATEGORY_POSITION)
e3:SetType(EFFECT_TYPE_TRIGGER_F+EFFECT_TYPE_SINGLE)
e3:SetCode(EVENT_BE_BATTLE_TARGET)
e3:SetOperation(c50615578.posop)
c:RegisterEffect(e3)
--draw
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(50615578,1))
e4:SetCategory(CATEGORY_DRAW)
e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e4:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_SINGLE)
e4:SetCode(EVENT_SUMMON_SUCCESS)
e4:SetTarget(c50615578.drtg)
e4:SetOperation(c50615578.drop)
c:RegisterEffect(e4)
end
function c50615578.posop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsFaceup() and c:IsRelateToEffect(e) then
Duel.ChangePosition(c,POS_FACEUP_DEFENSE,0,POS_FACEUP_ATTACK,0)
end
end
function c50615578.drfilter(c)
return c:IsPosition(POS_FACEUP_DEFENSE) and c:IsSetCard(0x11)
end
function c50615578.drtg(e,tp,eg,ep,ev,re,r,rp,chk)
local ct=Duel.GetMatchingGroupCount(c50615578.drfilter,tp,LOCATION_MZONE,0,nil)
if chk==0 then return ct>0 and Duel.IsPlayerCanDraw(tp,ct) end
Duel.SetTargetPlayer(tp)
Duel.SetTargetParam(ct)
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,ct)
end
function c50615578.drop(e,tp,eg,ep,ev,re,r,rp)
local ct=Duel.GetMatchingGroupCount(c50615578.drfilter,tp,LOCATION_MZONE,0,nil)
local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER)
Duel.Draw(p,ct,REASON_EFFECT)
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/globals/items/mithran_tomato.lua | 12 | 1188 | -----------------------------------------
-- ID: 4390
-- Item: mithran_tomato
-- Food Effect: 5Min, All Races
-----------------------------------------
-- Agility -3
-- Intelligence 1
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,300,4390);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_AGI, -3);
target:addMod(MOD_INT, 1);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_AGI, -3);
target:delMod(MOD_INT, 1);
end;
| gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c18803791.lua | 2 | 1185 | --黒竜降臨
function c18803791.initial_effect(c)
aux.AddRitualProcGreaterCode(c,71408082)
--to hand
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_GRAVE)
e1:SetCondition(aux.exccon)
e1:SetCost(c18803791.thcost)
e1:SetTarget(c18803791.thtg)
e1:SetOperation(c18803791.thop)
c:RegisterEffect(e1)
end
function c18803791.thcost(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 c18803791.thfilter(c)
return c:IsSetCard(0x3b) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand()
end
function c18803791.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c18803791.thfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c18803791.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c18803791.thfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
| gpl-2.0 |
YelaSeamless/mysql-proxy | examples/tutorial-keepalive.lua | 6 | 7134 | --[[ $%BEGINLICENSE%$
Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; version 2 of the
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
$%ENDLICENSE%$ --]]
--[[
--]]
---
-- a flexible statement based load balancer with connection pooling
--
-- * build a connection pool of min_idle_connections for each backend and
-- maintain its size
-- * reusing a server-side connection when it is idling
--
--- config
--
-- connection pool
local min_idle_connections = 4
local max_idle_connections = 8
-- debug
local is_debug = true
--- end of config
---
-- read/write splitting sends all non-transactional SELECTs to the slaves
--
-- is_in_transaction tracks the state of the transactions
local is_in_transaction = 0
---
-- get a connection to a backend
--
-- as long as we don't have enough connections in the pool, create new connections
--
function connect_server()
-- make sure that we connect to each backend at least ones to
-- keep the connections to the servers alive
--
-- on read_query we can switch the backends again to another backend
if is_debug then
print()
print("[connect_server] ")
end
local least_idle_conns_ndx = 0
local least_idle_conns = 0
for i = 1, #proxy.global.backends do
local s = proxy.global.backends[i]
local pool = s.pool -- we don't have a username yet, try to find a connections which is idling
local cur_idle = pool.users[""].cur_idle_connections
if is_debug then
print(" [".. i .."].connected_clients = " .. s.connected_clients)
print(" [".. i .."].idling_connections = " .. cur_idle)
print(" [".. i .."].type = " .. s.type)
print(" [".. i .."].state = " .. s.state)
end
if s.state ~= proxy.BACKEND_STATE_DOWN then
-- try to connect to each backend once at least
if cur_idle == 0 then
proxy.connection.backend_ndx = i
if is_debug then
print(" [".. i .."] open new connection")
end
return
end
-- try to open at least min_idle_connections
if least_idle_conns_ndx == 0 or
( cur_idle < min_idle_connections and
cur_idle < least_idle_conns ) then
least_idle_conns_ndx = i
least_idle_conns = s.idling_connections
end
end
end
if least_idle_conns_ndx > 0 then
proxy.connection.backend_ndx = least_idle_conns_ndx
end
if proxy.connection.backend_ndx > 0 then
local s = proxy.global.backends[proxy.connection.backend_ndx]
local pool = s.pool -- we don't have a username yet, try to find a connections which is idling
local cur_idle = pool.users[""].cur_idle_connections
if cur_idle >= min_idle_connections then
-- we have 4 idling connections in the pool, that's good enough
if is_debug then
print(" using pooled connection from: " .. proxy.connection.backend_ndx)
end
return proxy.PROXY_IGNORE_RESULT
end
end
if is_debug then
print(" opening new connection on: " .. proxy.connection.backend_ndx)
end
-- open a new connection
end
---
-- put the successfully authed connection into the connection pool
--
-- @param auth the context information for the auth
--
-- auth.packet is the packet
function read_auth_result( auth )
if auth.packet:byte() == proxy.MYSQLD_PACKET_OK then
-- auth was fine, disconnect from the server
proxy.connection.backend_ndx = 0
elseif auth.packet:byte() == proxy.MYSQLD_PACKET_EOF then
-- we received either a
--
-- * MYSQLD_PACKET_ERR and the auth failed or
-- * MYSQLD_PACKET_EOF which means a OLD PASSWORD (4.0) was sent
print("(read_auth_result) ... not ok yet");
elseif auth.packet:byte() == proxy.MYSQLD_PACKET_ERR then
-- auth failed
end
end
---
-- read/write splitting
function read_query( packet )
if is_debug then
print("[read_query]")
print(" authed backend = " .. proxy.connection.backend_ndx)
print(" used db = " .. proxy.connection.client.default_db)
end
if packet:byte() == proxy.COM_QUIT then
-- don't send COM_QUIT to the backend. We manage the connection
-- in all aspects.
proxy.response = {
type = proxy.MYSQLD_PACKET_OK,
}
return proxy.PROXY_SEND_RESULT
end
if proxy.connection.backend_ndx == 0 then
-- we don't have a backend right now
--
-- let's pick a master as a good default
for i = 1, #proxy.global.backends do
local s = proxy.global.backends[i]
local pool = s.pool -- we don't have a username yet, try to find a connections which is idling
local cur_idle = pool.users[proxy.connection.client.username].cur_idle_connections
if cur_idle > 0 and
s.state ~= proxy.BACKEND_STATE_DOWN and
s.type == proxy.BACKEND_TYPE_RW then
proxy.connection.backend_ndx = i
break
end
end
end
if true or proxy.connection.client.default_db and proxy.connection.client.default_db ~= proxy.connection.server.default_db then
-- sync the client-side default_db with the server-side default_db
proxy.queries:append(2, string.char(proxy.COM_INIT_DB) .. proxy.connection.client.default_db, { resultset_is_needed = true })
end
proxy.queries:append(1, packet, { resultset_is_needed = true })
return proxy.PROXY_SEND_QUERY
end
---
-- as long as we are in a transaction keep the connection
-- otherwise release it so another client can use it
function read_query_result( inj )
local res = assert(inj.resultset)
local flags = res.flags
if inj.id ~= 1 then
-- ignore the result of the USE <default_db>
return proxy.PROXY_IGNORE_RESULT
end
is_in_transaction = flags.in_trans
if not is_in_transaction then
-- release the backend
proxy.connection.backend_ndx = 0
end
end
---
-- close the connections if we have enough connections in the pool
--
-- @return nil - close connection
-- IGNORE_RESULT - store connection in the pool
function disconnect_client()
if is_debug then
print("[disconnect_client]")
end
if proxy.connection.backend_ndx == 0 then
-- currently we don't have a server backend assigned
--
-- pick a server which has too many idling connections and close one
for i = 1, #proxy.global.backends do
local s = proxy.global.backends[i]
local pool = s.pool -- we don't have a username yet, try to find a connections which is idling
local cur_idle = pool.users[proxy.connection.client.username].cur_idle_connections
if s.state ~= proxy.BACKEND_STATE_DOWN and
cur_idle > max_idle_connections then
-- try to disconnect a backend
proxy.connection.backend_ndx = i
if is_debug then
print(" [".. i .."] closing connection, idling: " .. cur_idle)
end
return
end
end
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c65737274.lua | 2 | 2915 | --ドラゴラド
function c65737274.initial_effect(c)
--spsummon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(65737274,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetTarget(c65737274.sptg)
e1:SetOperation(c65737274.spop)
c:RegisterEffect(e1)
--lvatkup
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(65737274,1))
e2:SetCategory(CATEGORY_ATKCHANGE)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCost(c65737274.lvcost)
e2:SetTarget(c65737274.lvtg)
e2:SetOperation(c65737274.lvop)
c:RegisterEffect(e2)
end
function c65737274.spfilter(c,e,tp)
return c:IsAttackBelow(1000) and c:IsType(TYPE_NORMAL) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c65737274.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c65737274.spfilter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c65737274.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c65737274.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c65737274.spop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP_DEFENSE)
end
end
function c65737274.cfilter(c,tp)
return c:IsRace(RACE_DRAGON) and Duel.IsExistingTarget(c65737274.lvfilter,tp,LOCATION_MZONE,0,1,c)
end
function c65737274.lvfilter(c)
local lv=c:GetLevel()
return c:IsFaceup() and lv>0 and lv~=8
end
function c65737274.lvcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckReleaseGroup(tp,c65737274.cfilter,1,nil,tp) end
local g=Duel.SelectReleaseGroup(tp,c65737274.cfilter,1,1,nil,tp)
Duel.Release(g,REASON_COST)
end
function c65737274.lvtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c65737274.lvfilter(chkc) end
if chk==0 then return true end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,c65737274.lvfilter,tp,LOCATION_MZONE,0,1,1,nil)
end
function c65737274.lvop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsFaceup() and tc:GetLevel()~=8 then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EFFECT_CHANGE_LEVEL)
e1:SetValue(8)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EFFECT_UPDATE_ATTACK)
e2:SetValue(800)
tc:RegisterEffect(e2)
end
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/zones/Selbina/npcs/Vuntar.lua | 14 | 3323 | -----------------------------------
-- Area: Selbina
-- NPC: Vuntar
-- Starts and Finishes Quest: Cargo (R)
-- @pos 7 -2 -15 248
-----------------------------------
package.loaded["scripts/zones/Selbina/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Selbina/TextIDs");
require("scripts/globals/settings");
require("scripts/globals/quests");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(OTHER_AREAS,CARGO) ~= QUEST_AVAILABLE) then
realday = tonumber(os.date("%j")); -- %M for next minute, %j for next real day
starttime = player:getVar("VuntarCanBuyItem_date");
if (realday ~= starttime) then
if (trade:hasItemQty(4529,1) == true and trade:getGil() == 0 and trade:getItemCount() == 1) then
player:startEvent(0x0034,1); -- Can Buy rolanberry (881 ce)
elseif (trade:hasItemQty(4530,1) == true and trade:getGil() == 0 and trade:getItemCount() == 1) then
player:startEvent(0x0034,2); -- Can Buy rolanberry (874 ce)
elseif (trade:hasItemQty(4531,1) == true and trade:getGil() == 0 and trade:getItemCount() == 1) then
player:startEvent(0x0034,3); -- Can Buy rolanberry (864 ce)
end
else
player:startEvent(0x046e,4365); -- Can't buy rolanberrys
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getMainLvl() >= 20 and player:getQuestStatus(OTHER_AREAS,CARGO) == QUEST_AVAILABLE) then
player:startEvent(0x0032,4365); -- Start quest "Cargo"
elseif (player:getMainLvl() < 20) then
player:startEvent(0x0035); -- Dialog for low level or low fame
else
player:startEvent(0x0033,4365); -- During & after completed quest "Cargo"
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0032) then
player:addQuest(OTHER_AREAS,CARGO);
elseif (csid == 0x0034) then
player:setVar("VuntarCanBuyItem_date", os.date("%j")); -- %M for next minute, %j for next real day
if (player:getQuestStatus(OTHER_AREAS,CARGO) == QUEST_ACCEPTED) then
player:completeQuest(OTHER_AREAS,CARGO);
player:addFame(OTHER_AREAS,30);
end
if (option == 1) then
player:addGil(800);
player:messageSpecial(GIL_OBTAINED,800);
player:tradeComplete();
elseif (option == 2) then
player:addGil(2000);
player:messageSpecial(GIL_OBTAINED,2000);
player:tradeComplete();
elseif (option == 3) then
player:addGil(3000);
player:messageSpecial(GIL_OBTAINED,3000);
player:tradeComplete();
end
end
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Abyssea-Uleguerand/npcs/qm6.lua | 14 | 1348 | -----------------------------------
-- Zone: Abyssea-Uleguerand
-- NPC: qm6 (???)
-- Spawns Upas-Kamuy
-- @pos ? ? ? 253
-----------------------------------
require("scripts/globals/status");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
--[[
if (trade:hasItemQty(3252,1) and trade:getItemCount() == 1) then -- Player has all the required items.
if (GetMobAction(17813935) == ACTION_NONE) then -- Mob not already spawned from this
SpawnMob(17813935):updateClaim(player); -- Spawn NM, Despawn after inactive for 5 minutes (pt has to reclaim within 5 of a wipe)
player:tradeComplete();
end
end
]]
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(1010, 3252); -- Inform player what items they need.
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c81066751.lua | 3 | 1180 | --神罰
function c81066751.initial_effect(c)
--Activate(effect)
local e4=Effect.CreateEffect(c)
e4:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY)
e4:SetType(EFFECT_TYPE_ACTIVATE)
e4:SetCode(EVENT_CHAINING)
e4:SetCondition(c81066751.condition)
e4:SetTarget(c81066751.target)
e4:SetOperation(c81066751.activate)
c:RegisterEffect(e4)
end
function c81066751.cfilter(c)
return c:IsFaceup() and c:IsCode(56433456)
end
function c81066751.condition(e,tp,eg,ep,ev,re,r,rp)
if not Duel.IsExistingMatchingCard(c81066751.cfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) then return false end
if not Duel.IsChainNegatable(ev) then return false end
return re:IsActiveType(TYPE_MONSTER) or re:IsHasType(EFFECT_TYPE_ACTIVATE)
end
function c81066751.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 c81066751.activate(e,tp,eg,ep,ev,re,r,rp)
if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then
Duel.Destroy(eg,REASON_EFFECT)
end
end
| gpl-2.0 |
Herve-M/OpenRA | mods/ra/maps/allies-05b/allies05b.lua | 7 | 12709 | --[[
Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
This file is part of OpenRA, which is free software. It is made
available to you under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version. For more
information, see COPYING.
]]
SpyType = { "spy" }
SpyEntryPath = { SpyEntry.Location, SpyLoadout.Location }
InsertionTransport = "lst.in"
TrukPath1 = { SpyCamera1, TrukWaypoint1, TrukWaypoint2, TrukWaypoint3, TrukWaypoint4 }
TrukPath2 = { TruckWaypoint5, TruckCrash }
ExtractionHeliType = "tran"
ExtractionPath = { ExtractionEntry.Location, ExtractionLZ.Location }
GreeceReinforcements =
{
{ types = { "e3", "e3", "e1", "e1", "e1" }, entry = { SpyEntry.Location, SpyLoadout.Location } },
{ types = { "jeep", "1tnk", "1tnk", "2tnk", "2tnk" }, entry = { GreeceEntry1.Location, GreeceLoadout1.Location } },
{ types = { "e6", "e6", "e6", "e6", "e6" }, entry = { GreeceEntry2.Location, GreeceLoadout2.Location } }
}
FlameTowerDogs = { FlameTowerDog1, FlameTowerDog2 }
PatrolA = { PatrolA1, PatrolA2, PatrolA3 }
PatrolB = { PatrolB1, PatrolB2, PatrolB3 }
PatrolC = { PatrolC1, PatrolC2, PatrolC3 }
PatrolAPath = { APatrol1.Location, CPatrol1.Location, APatrol2.Location }
PatrolBPath = { BPatrol1.Location, BPatrol2.Location, SpyCamera2.Location }
PatrolCPath = { CPatrol1.Location, CPatrol2.Location, CPatrol3.Location }
CheckpointDogs = { CheckpointDog1, CheckpointDog2 }
CheckpointRifles = { CheckpointRifle1, CheckpointRifle2 }
BridgePatrol = { CheckpointDog1, CheckpointDog2, CheckpointRifle1, CheckpointRifle2 }
BridgePatrolPath = { TrukWaypoint4.Location, BridgePatrolWay.Location }
TanyaVoices = { "tuffguy", "bombit", "laugh", "gotit", "lefty", "keepem" }
SpyVoice = "sking"
CivVoice = "guyokay"
DogBark = "dogy"
SamSites = { Sam1, Sam2, Sam3, Sam4 }
SendSpy = function()
Camera.Position = SpyEntry.CenterPosition
Spy = Reinforcements.ReinforceWithTransport(Greece, InsertionTransport, SpyType, SpyEntryPath, { SpyEntryPath[1] })[2][1]
Trigger.OnKilled(Spy, function() USSR.MarkCompletedObjective(USSRObj) end)
Trigger.AfterDelay(DateTime.Seconds(3), function()
Media.DisplayMessage("Commander! You have to disguise me in order to get through the enemy patrols.", "Spy")
if SpecialCameras then
SpyCameraA = Actor.Create("camera", true, { Owner = Greece, Location = SpyCamera1.Location })
SpyCameraB = Actor.Create("camera", true, { Owner = Greece, Location = SpyCamera2.Location })
SpyCameraC = Actor.Create("camera", true, { Owner = Greece, Location = BPatrol2.Location })
else
SpyCameraHard = Actor.Create("camera.small", true, { Owner = Greece, Location = FlameTowerDogRally.Location + CVec.New(2, 0) })
end
end)
end
ChurchFootprint = function()
Trigger.OnEnteredProximityTrigger(ChurchSpawn.CenterPosition, WDist.FromCells(2), function(actor, id)
if actor.Type == "spy" and not Greece.IsObjectiveCompleted(MainObj) then
Trigger.RemoveProximityTrigger(id)
ChurchSequence()
end
end)
end
ChurchSequence = function()
Media.PlaySoundNotification(Greece, CivVoice)
Hero = Actor.Create("c1", true, { Owner = GoodGuy, Location = ChurchSpawn.Location })
Hero.Attack(TargetBarrel)
Trigger.OnKilled(ResponseBarrel, function()
if not Hero.IsDead then
Hero.Stop()
Hero.Move(SouthVillage.Location)
BarrelsTower.Kill()
Utils.Do(FlameTowerDogs, function(dogs)
if not dogs.IsDead then
dogs.Stop()
dogs.AttackMove(SouthVillage.Location)
end
end)
Utils.Do(PatrolA, function(patrol1)
if not patrol1.IsDead then
patrol1.Stop()
patrol1.AttackMove(SouthVillage.Location)
end
end)
Utils.Do(PatrolB, function(patrol2)
if not patrol2.IsDead then
patrol2.Stop()
patrol2.AttackMove(SouthVillage.Location)
end
end)
end
end)
end
ActivatePatrols = function()
Utils.Do(FlameTowerDogs, function(dogs)
dogs.AttackMove(FlameTowerDogRally.Location)
end)
Trigger.AfterDelay(DateTime.Seconds(3), function()
GroupPatrol(PatrolA, PatrolAPath, DateTime.Seconds(7))
GroupPatrol(PatrolB, PatrolBPath, DateTime.Seconds(6))
GroupPatrol(PatrolC, PatrolCPath, DateTime.Seconds(6))
end)
end
GroupPatrol = function(units, waypoints, delay)
local i = 1
local stop = false
Utils.Do(units, function(unit)
Trigger.OnIdle(unit, function()
if stop then
return
end
if unit.Location == waypoints[i] then
local bool = Utils.All(units, function(actor) return actor.IsIdle end)
if bool then
stop = true
i = i + 1
if i > #waypoints then
i = 1
end
Trigger.AfterDelay(delay, function() stop = false end)
end
else
unit.AttackMove(waypoints[i])
end
end)
end)
end
WarfactoryInfiltrated = function()
FollowTruk = true
Truk.GrantCondition("hijacked")
Truk.Wait(DateTime.Seconds(1))
Utils.Do(TrukPath1, function(waypoint)
Truk.Move(waypoint.Location)
end)
Trigger.AfterDelay(DateTime.Seconds(2), function()
if SpecialCameras then
SpyCameraA.Destroy()
SpyCameraB.Destroy()
SpyCameraC.Destroy()
else
SpyCameraHard.Destroy()
end
end)
Trigger.OnEnteredProximityTrigger(TrukWaypoint4.CenterPosition, WDist.FromCells(1), function(actor, id)
if actor.Type == "truk.mission" then
Trigger.RemoveProximityTrigger(id)
Utils.Do(CheckpointDogs, function(dog)
dog.Move(TrukInspect.Location)
end)
end
end)
Trigger.OnEnteredProximityTrigger(TrukWaypoint4.CenterPosition, WDist.FromCells(1), function(actor, id)
if actor.Type == "dog" then
Trigger.RemoveProximityTrigger(id)
Media.PlaySoundNotification(Greece, DogBark)
Utils.Do(CheckpointRifles, function(guard)
guard.Move(TrukInspect.Location)
end)
Trigger.AfterDelay(DateTime.Seconds(2), function()
Utils.Do(TrukPath2, function(waypoint)
Truk.Move(waypoint.Location)
end)
end)
end
end)
Trigger.OnEnteredFootprint({ SpyJumpOut.Location }, function(a, id)
if a == Truk then
Trigger.RemoveFootprintTrigger(id)
Spy = Actor.Create("spy", true, { Owner = Greece, Location = SpyJumpOut.Location })
Spy.DisguiseAsType("e1", USSR)
Spy.Move(TruckWaypoint5.Location)
Spy.Infiltrate(Prison)
Media.PlaySoundNotification(Greece, SpyVoice)
FollowTruk = false
if SpecialCameras then
PrisonCamera = Actor.Create("camera", true, { Owner = Greece, Location = SpyJumpOut.Location })
else
PrisonCamera = Actor.Create("camera.small", true, { Owner = Greece, Location = Prison.Location + CVec.New(1, 1) })
end
Trigger.OnKilled(Spy, function() USSR.MarkCompletedObjective(USSRObj) end)
end
end)
Trigger.OnEnteredFootprint({ TruckCrash.Location }, function(a, id)
if a == Truk then
Trigger.RemoveFootprintTrigger(id)
Truk.Stop()
Truk.Kill()
CrashTower.Kill()
CrashBarrel.Kill()
end
end)
end
MissInfiltrated = function()
for i = 0, 5, 1 do
local sound = Utils.Random(TanyaVoices)
Trigger.AfterDelay(DateTime.Seconds(i), function()
Media.PlaySoundNotification(Greece, sound)
end)
end
Prison.Attack(Prison)
Trigger.AfterDelay(DateTime.Seconds(6), FreeTanya)
end
FreeTanya = function()
Prison.Stop()
Tanya = Actor.Create(TanyaType, true, { Owner = Greece, Location = Prison.Location + CVec.New(1, 1) })
Tanya.Demolish(Prison)
Tanya.Move(Tanya.Location + CVec.New(Utils.RandomInteger(-1, 2), 1))
GroupPatrol(BridgePatrol, BridgePatrolPath, DateTime.Seconds(7))
if TanyaType == "e7.noautotarget" then
Trigger.AfterDelay(DateTime.Seconds(1), function()
Media.DisplayMessage("According to the rules of engagement I need your explicit orders to fire, Commander!", "Tanya")
end)
end
local escapeResponse1 = Reinforcements.Reinforce(USSR, { "e1", "e2", "e2" }, { RaxSpawn.Location, TrukWaypoint4.Location })
Utils.Do(escapeResponse1, function(units)
IdleHunt(units)
end)
Trigger.AfterDelay(DateTime.Seconds(10), function()
local escapeResponse2 = Reinforcements.Reinforce(USSR, { "e1", "e2", "e2" }, { RaxSpawn.Location, TrukWaypoint4.Location })
Utils.Do(escapeResponse2, function(units)
IdleHunt(units)
end)
end)
KillSams = Greece.AddObjective("Destroy all four SAM sites that block\nthe extraction helicopter.")
Trigger.OnKilled(Tanya, function() USSR.MarkCompletedObjective(USSRObj) end)
if not SpecialCameras and PrisonCamera and PrisonCamera.IsInWorld then
PrisonCamera.Destroy()
end
end
SendReinforcements = function()
GreeceReinforcementsArrived = true
Camera.Position = SpyLoadout.CenterPosition
Greece.Cash = Greece.Cash + ReinforceCash
Utils.Do(GreeceReinforcements, function(reinforcements)
Reinforcements.ReinforceWithTransport(Greece, InsertionTransport, reinforcements.types, reinforcements.entry, { SpyEntry.Location })
end)
Media.PlaySpeechNotification(Greece, "AlliedReinforcementsArrived")
ActivateAI()
end
ExtractUnits = function(extractionUnit, pos, after)
if extractionUnit.IsDead or not extractionUnit.HasPassengers then
return
end
extractionUnit.Move(pos)
extractionUnit.Destroy()
Trigger.OnRemovedFromWorld(extractionUnit, after)
end
InitTriggers = function()
Trigger.OnInfiltrated(Warfactory, function()
if Greece.IsObjectiveCompleted(InfWarfactory) then
return
elseif Truk.IsDead then
if not Greece.IsObjectiveCompleted(MainObj) then
USSR.MarkCompletedObjective(USSRObj)
end
return
end
Trigger.ClearAll(Spy)
Greece.MarkCompletedObjective(InfWarfactory)
WarfactoryInfiltrated()
end)
Trigger.OnKilled(Truk, function()
if not Greece.IsObjectiveCompleted(InfWarfactory) then
Greece.MarkFailedObjective(InfWarfactory)
elseif FollowTruk then
USSR.MarkCompletedObjective(USSRObj)
end
end)
Trigger.OnInfiltrated(Prison, function()
if Greece.IsObjectiveCompleted(MainObj) then
return
end
if not Greece.IsObjectiveCompleted(InfWarfactory) then
Media.DisplayMessage("Good work! But next time skip the heroics!", "Battlefield Control")
Greece.MarkCompletedObjective(InfWarfactory)
end
if not PrisonCamera then
if SpecialCameras then
PrisonCamera = Actor.Create("camera", true, { Owner = Greece, Location = SpyJumpOut.Location })
else
PrisonCamera = Actor.Create("camera.small", true, { Owner = Greece, Location = Prison.Location + CVec.New(1, 1) })
end
end
if SpecialCameras and SpyCameraA and not SpyCameraA.IsDead then
SpyCameraA.Destroy()
SpyCameraB.Destroy()
SpyCameraC.Destroy()
end
Trigger.ClearAll(Spy)
Trigger.AfterDelay(DateTime.Seconds(2), MissInfiltrated)
end)
Trigger.OnAllKilled(SamSites, function()
Greece.MarkCompletedObjective(KillSams)
local flare = Actor.Create("flare", true, { Owner = Greece, Location = ExtractionPath[2] + CVec.New(0, -1) })
Trigger.AfterDelay(DateTime.Seconds(7), flare.Destroy)
Media.PlaySpeechNotification(Greece, "SignalFlare")
ExtractionHeli = Reinforcements.ReinforceWithTransport(Greece, ExtractionHeliType, nil, ExtractionPath)[1]
local exitPos = CPos.New(ExtractionPath[1].X, ExtractionPath[2].Y)
Trigger.OnKilled(ExtractionHeli, function() USSR.MarkCompletedObjective(USSRObj) end)
Trigger.OnRemovedFromWorld(Tanya, function()
ExtractUnits(ExtractionHeli, exitPos, function()
Media.PlaySpeechNotification(Greece, "TanyaRescued")
Greece.MarkCompletedObjective(MainObj)
Trigger.AfterDelay(DateTime.Seconds(2), function()
SendReinforcements()
end)
if PrisonCamera and PrisonCamera.IsInWorld then
PrisonCamera.Destroy()
end
end)
end)
end)
end
Tick = function()
if FollowTruk and not Truk.IsDead then
Camera.Position = Truk.CenterPosition
end
if USSR.HasNoRequiredUnits() then
Greece.MarkCompletedObjective(KillAll)
end
if GreeceReinforcementsArrived and Greece.HasNoRequiredUnits() then
USSR.MarkCompletedObjective(USSRObj)
end
end
WorldLoaded = function()
Greece = Player.GetPlayer("Greece")
USSR = Player.GetPlayer("USSR")
GoodGuy = Player.GetPlayer("GoodGuy")
InitObjectives(Greece)
USSRObj = USSR.AddObjective("Deny the Allies.")
MainObj = Greece.AddObjective("Rescue Tanya.")
KillAll = Greece.AddObjective("Eliminate all Soviet units in this area.")
InfWarfactory = Greece.AddObjective("Infiltrate the Soviet warfactory.", "Secondary", false)
InitTriggers()
SendSpy()
ChurchFootprint()
if Difficulty == "easy" then
TanyaType = "e7"
ReinforceCash = 5000
USSR.Cash = 8000
SpecialCameras = true
elseif Difficulty == "normal" then
TanyaType = "e7.noautotarget"
ReinforceCash = 2250
USSR.Cash = 15000
SpecialCameras = true
else
TanyaType = "e7.noautotarget"
ReinforceCash = 1500
USSR.Cash = 25000
end
Trigger.AfterDelay(DateTime.Seconds(3), ActivatePatrols)
end
| gpl-3.0 |
waruqi/xmake | xmake/rules/utils/merge_archive/xmake.lua | 1 | 2788 | --!A cross-platform build utility based on Lua
--
-- 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.
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
-- @file xmake.lua
--
-- define rule: utils.merge.archive
rule("utils.merge.archive")
-- set extensions
set_extensions(".a", ".lib")
-- on build file
on_build_files(function (target, sourcebatch, opt)
-- imports
import("core.base.option")
import("core.theme.theme")
import("core.project.depend")
import("core.tool.extractor")
import("core.project.target", {alias = "project_target"})
import("private.utils.progress")
-- @note we cannot process archives in parallel because the current directory may be changed
for i = 1, #sourcebatch.sourcefiles do
-- get library source file
local sourcefile_lib = sourcebatch.sourcefiles[i]
-- get object directory of the archive file
local objectdir = target:objectfile(sourcefile_lib) .. ".dir"
-- load dependent info
local dependfile = target:dependfile(objectdir)
local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
-- need build this object?
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(objectdir)}) then
local objectfiles = os.files(path.join(objectdir, "**" .. project_target.filename("", "object")))
table.join2(target:objectfiles(), objectfiles)
return
end
-- trace progress info
progress.show(opt.progress, "${color.build.object}inserting.$(mode) %s", sourcefile_lib)
-- extract the archive library
os.tryrm(objectdir)
extractor.extract(sourcefile_lib, objectdir)
-- add objectfiles
local objectfiles = os.files(path.join(objectdir, "**" .. project_target.filename("", "object")))
table.join2(target:objectfiles(), objectfiles)
-- update files to the dependent file
dependinfo.files = {}
table.insert(dependinfo.files, sourcefile_lib)
depend.save(dependinfo, dependfile)
end
end)
| apache-2.0 |
Leystryku/die_awesomium | code_lua/garrysmod/lua/includes/modules/von.lua | 1 | 15877 | --[[ vON 1.1.1
Copyright 2012-2013 Alexandru-Mihai Maftei
aka Vercas
You may use this for any purpose as long as:
- You don't remove this copyright notice.
- You don't claim this to be your own.
- You properly credit the author (Vercas) if you publish your work based on (and/or using) this.
If you modify the code for any purpose, the above obligations still apply.
Instead of copying this code over for sharing, rather use the link:
https://dl.dropbox.com/u/1217587/GMod/Lua/von%20for%20GMOD.lua
The author may not be held responsible for any damage or losses directly or indirectly caused by
the use of vON.
If you disagree with the above, don't use the code.
-----------------------------------------------------------------------------------------------------------------------------
Thanks to the following people for their contribution:
- Divran Suggested improvements for making the code quicker.
Suggested an excellent new way of deserializing strings.
Lead me to finding an extreme flaw in string parsing.
- pennerlord Provided some performance tests to help me improve the code.
- Chessnut Reported bug with handling of nil values when deserializing array components.
-----------------------------------------------------------------------------------------------------------------------------
The value types supported in this release of vON are:
- table
- number
- boolean
- string
- nil
- Entity
- Player
- Vector
- Angle
These are the native Lua types one would normally serialize.
+ Some very common GMod Lua types.
-----------------------------------------------------------------------------------------------------------------------------
New in this version:
- Fixed problem with handling of nils in array tables.
--]]
local _deserialize, _serialize, _d_meta, _s_meta, d_findVariable, s_anyVariable
local sub, gsub, find, insert, concat, error, tonumber, tostring, type, next, getEnt = string.sub, string.gsub, string.find, table.insert, table.concat, error, tonumber, tostring, type, next, Entity
-- This is kept away from the table for speed.
function d_findVariable(s, i, len, lastType)
local i, c, typeRead, val = i or 1
-- Keep looping through the string.
while true do
-- Stop at the end. Throw an error. This function MUST NOT meet the end!
if i > len then
error("vON: Reached end of string, cannot form proper variable.")
end
-- Cache the character. Nobody wants to look for the same character ten times.
c = sub(s, i, i)
-- If it just read a type definition, then a variable HAS to come after it.
if typeRead then
-- Attempt to deserialize a variable of the freshly read type.
val, i = _deserialize[lastType](s, i, len)
-- Return the value read, the index of the last processed character, and the type of the last read variable.
return val, i, lastType
-- @ means nil. It should not even appear in the output string of the serializer. Nils are useless to store.
elseif c == "@" then
return nil, i, lastType
-- n means a number will follow. Base 10... :C
elseif c == "n" then
lastType = "number"
typeRead = true
-- b means boolean flags.
elseif c == "b" then
lastType = "boolean"
typeRead = true
-- " means the start of a string.
elseif c == "\"" then
lastType = "string"
typeRead = true
-- { means the start of a table!
elseif c == "{" then
lastType = "table"
typeRead = true
-- n means a number will follow. Base 10... :C
elseif c == "e" then
lastType = "Entity"
typeRead = true
-- n means a number will follow. Base 10... :C
elseif c == "p" then
lastType = "Player"
typeRead = true
-- n means a number will follow. Base 10... :C
elseif c == "v" then
lastType = "Vector"
typeRead = true
-- n means a number will follow. Base 10... :C
elseif c == "a" then
lastType = "Angle"
typeRead = true
-- If no type has been found, attempt to deserialize the last type read.
elseif lastType then
val, i = _deserialize[lastType](s, i, len)
return val, i, lastType
-- This will occur if the very first character in the vON code is wrong.
else
error("vON: Malformed data... Can't find a proper type definition. Char#" .. i .. ":" .. c)
end
-- Move the pointer one step forward.
i = i + 1
end
end
-- This is kept away from the table for speed.
-- Yeah, crapload of parameters.
function s_anyVariable(data, lastType, isNumeric, isKey, isLast, nice, indent)
-- Basically, if the type changes.
if lastType ~= type(data) then
-- Remember the new type. Caching the type is useless.
lastType = type(data)
-- Return the serialized data and the (new) last type.
-- The second argument, which is true now, means that the data type was just changed.
return _serialize[lastType](data, true, isNumeric, isKey, isLast, nice, indent), lastType
end
-- Otherwise, simply serialize the data.
return _serialize[lastType](data, false, isNumeric, isKey, isLast, nice, indent), lastType
end
_deserialize = {
-- Well, tables are very loose...
-- The first table doesn't have to begin and end with { and }.
["table"] = function(s, i, len, unnecessaryEnd)
local ret, numeric, i, c, lastType, val, ind, expectValue, key = {}, true, i or 1, nil, nil, nil, 1
-- Locals, locals, locals, locals, locals, locals, locals, locals and locals.
-- Keep looping.
while true do
-- Until it meets the end.
if i > len then
-- Yeah, if the end is unnecessary, it won't spit an error. The main chunk doesn't require an end, for example.
if unnecessaryEnd then
return ret, i
-- Otherwise, the data has to be damaged.
else
error("vON: Reached end of string, incomplete table definition.")
end
end
-- Cache the character.
c = sub(s, i, i)
--print(i, "table char:", c, tostring(unnecessaryEnd))
-- If it's the end of a table definition, return.
if c == "}" then
return ret, i
-- If it's the component separator, switch to key:value pairs.
elseif c == "~" then
numeric = false
elseif c == ";" then
-- Lol, nothing!
-- Remenant from numbers, for faster parsing.
-- OK, now, if it's on the numeric component, simply add everything encountered.
elseif numeric then
-- Find a variable and it's value
val, i, lastType = d_findVariable(s, i, len, lastType)
-- Add it to the table.
ret[ind] = val
ind = ind + 1
-- Otherwise, if it's the key:value component...
else
-- If a value is expected...
if expectValue then
-- Read it.
val, i, lastType = d_findVariable(s, i, len, lastType)
-- Add it?
ret[key] = val
-- Clean up.
expectValue, key = false, nil
-- If it's the separator...
elseif c == ":" then
-- Expect a value next.
expectValue = true
-- But, if there's a key read already...
elseif key then
-- Then this is malformed.
error("vON: Malformed table... Two keys declared successively? Char#" .. i .. ":" .. c)
-- Otherwise the key will be read.
else
-- I love multi-return and multi-assignement.
key, i, lastType = d_findVariable(s, i, len, lastType)
end
end
i = i + 1
end
return nil, i
end,
-- Numbers are weakly defined.
-- The declaration is not very explicit. It'll do it's best to parse the number.
-- Has various endings: \n, }, ~, : and ;, some of which will force the table deserializer to go one char backwards.
["number"] = function(s, i, len)
local i, a = i or 1
-- Locals, locals, locals, locals
a = find(s, "[;:}~]", i)
if a then
return tonumber(sub(s, i, a - 1)), a - 1
end
error("vON: Number definition started... Found no end.")
end,
-- A boolean is A SINGLE CHARACTER, either 1 for true or 0 for false.
-- Any other attempt at boolean declaration will result in a failure.
["boolean"] = function(s, i, len)
local c = sub(s,i,i)
-- Only one character is needed.
-- If it's 1, then it's true
if c == "1" then
return true, i
-- If it's 0, then it's false.
elseif c == "0" then
return false, i
end
-- Any other supposely "boolean" is just a sign of malformed data.
error("vON: Invalid value on boolean type... Char#" .. i .. ": " .. c)
end,
-- Strings are very easy to parse and also very explicit.
-- " simply marks the type of a string.
-- Then it is parsed until an unescaped " is countered.
["string"] = function(s, i, len)
local res, i, a = "", i or 1
-- Locals, locals, locals, locals
while true do
a = find(s, "\"", i, true)
if a then
if sub(s, a - 1, a - 1) == "\\" then
res = res .. sub(s, i, a - 2) .. "\""
i = a + 1
else
return res .. sub(s, i, a - 2), a
end
else
error("vON: String definition started... Found no end.")
end
end
end,
-- Entities are stored simply by the ID. They're meant to be transfered, not stored anyway.
-- Exactly like a number definition, except it begins with "e".
["Entity"] = function(s, i, len)
local i, a = i or 1
-- Locals, locals, locals, locals
a = find(s, "[;:}~]", i)
if a then
return getEnt(tonumber(sub(s, i, a - 1))), a - 1
end
error("vON: Entity ID definition started... Found no end.")
end,
-- Exactly like a entity definition, except it begins with "p".
["Player"] = function(s, i, len)
local i, a = i or 1
-- Locals, locals, locals, locals
a = find(s, "[;:}~]", i)
if a then
return getEnt(tonumber(sub(s, i, a - 1))), a - 1
end
error("vON: Player ID definition started... Found no end.")
end,
-- A pair of 3 numbers separated by a comma (,).
["Vector"] = function(s, i, len)
local i, a, x, y, z = i or 1
-- Locals, locals, locals, locals
a = find(s, ",", i)
if a then
x = tonumber(sub(s, i, a - 1))
i = a + 1
end
a = find(s, ",", i)
if a then
y = tonumber(sub(s, i, a - 1))
i = a + 1
end
a = find(s, "[;:}~]", i)
if a then
z = tonumber(sub(s, i, a - 1))
end
if x and y and z then
return Vector(x, y, z), a - 1
end
error("vON: Vector definition started... Found no end.")
end,
-- A pair of 3 numbers separated by a comma (,).
["Angle"] = function(s, i, len)
local i, a, p, y, r = i or 1
-- Locals, locals, locals, locals
a = find(s, ",", i)
if a then
p = tonumber(sub(s, i, a - 1))
i = a + 1
end
a = find(s, ",", i)
if a then
y = tonumber(sub(s, i, a - 1))
i = a + 1
end
a = find(s, "[;:}~]", i)
if a then
r = tonumber(sub(s, i, a - 1))
end
if p and y and r then
return Angle(p, y, r), a - 1
end
error("vON: Angle definition started... Found no end.")
end
}
_serialize = {
-- Uh. Nothing to comment.
-- Shitload of parameters.
-- Makes shit faster than simply passing it around in locals.
-- table.concat works better than normal concatenations WITH LARGE-ISH STRINGS ONLY.
["table"] = function(data, mustInitiate, isNumeric, isKey, isLast, first)
--print(string.format("data: %s; mustInitiate: %s; isKey: %s; isLast: %s; nice: %s; indent: %s; first: %s", tostring(data), tostring(mustInitiate), tostring(isKey), tostring(isLast), tostring(nice), tostring(indent), tostring(first)))
local result, keyvals, len, keyvalsLen, keyvalsProgress, val, lastType, newIndent, indentString = {}, {}, #data, 0, 0
-- Locals, locals, locals, locals, locals, locals, locals, locals, locals and locals.
-- First thing to be done is separate the numeric and key:value components of the given table in two tables.
-- pairs(data) is slower than next, data as far as my tests tell me.
for k, v in next, data do
-- Skip the numeric keyz.
if type(k) ~= "number" or k < 1 or k > len then
keyvals[#keyvals + 1] = k
end
end
keyvalsLen = #keyvals
-- Main chunk - no initial character.
if not first then
result[#result + 1] = "{"
end
-- Add numeric values.
if len > 0 then
for i = 1, len do
val, lastType = s_anyVariable(data[i], lastType, true, false, i == len and not first, false, 0)
result[#result + 1] = val
end
end
-- If there are key:value pairs.
if keyvalsLen > 0 then
-- Insert delimiter.
result[#result + 1] = "~"
-- Insert key:value pairs.
for _i = 1, keyvalsLen do
keyvalsProgress = keyvalsProgress + 1
val, lastType = s_anyVariable(keyvals[_i], lastType, false, true, false, false, 0)
result[#result + 1] = val..":"
val, lastType = s_anyVariable(data[keyvals[_i]], lastType, false, false, keyvalsProgress == keyvalsLen and not first, false, 0)
result[#result + 1] = val
end
end
-- Main chunk needs no ending character.
if not first then
result[#result + 1] = "}"
end
return concat(result)
end,
-- Normal concatenations is a lot faster with small strings than table.concat
-- Also, not so branched-ish.
["number"] = function(data, mustInitiate, isNumeric, isKey, isLast)
-- If a number hasn't been written before, add the type prefix.
if mustInitiate then
if isKey or isLast then
return "n"..data
else
return "n"..data..";"
end
end
if isKey or isLast then
return "n"..data
else
return "n"..data..";"
end
end,
-- I hope gsub is fast enough.
["string"] = function(data, mustInitiate, isNumeric, isKey, isLast)
return "\"" .. gsub(data, "\"", "\\\"") .. "v\""
end,
-- Fastest.
["boolean"] = function(data, mustInitiate, isNumeric, isKey, isLast)
-- Prefix if we must.
if mustInitiate then
if data then
return "b1"
else
return "b0"
end
end
if data then
return "1"
else
return "0"
end
end,
-- Fastest.
["nil"] = function(data, mustInitiate, isNumeric, isKey, isLast)
return "@"
end,
-- Same as numbers, except they start with "e" instead of "n".
["Entity"] = function(data, mustInitiate, isNumeric, isKey, isLast)
data = data:EntIndex()
if mustInitiate then
if isKey or isLast then
return "e"..data
else
return "e"..data..";"
end
end
if isKey or isLast then
return "e"..data
else
return "e"..data..";"
end
end,
-- Same as entities, except they start with "e" instead of "n".
["Player"] = function(data, mustInitiate, isNumeric, isKey, isLast)
data = data:EntIndex()
if mustInitiate then
if isKey or isLast then
return "p"..data
else
return "p"..data..";"
end
end
if isKey or isLast then
return "p"..data
else
return "p"..data..";"
end
end,
-- 3 numbers separated by a comma.
["Vector"] = function(data, mustInitiate, isNumeric, isKey, isLast)
if mustInitiate then
if isKey or isLast then
return "v"..data.x..","..data.y..","..data.z
else
return "v"..data.x..","..data.y..","..data.z..";"
end
end
if isKey or isLast then
return "v"..data.x..","..data.y..","..data.z
else
return "v"..data.x..","..data.y..","..data.z..";"
end
end,
-- 3 numbers separated by a comma.
["Angle"] = function(data, mustInitiate, isNumeric, isKey, isLast)
if mustInitiate then
if isKey or isLast then
return "a"..data.p..","..data.y..","..data.r
else
return "a"..data.p..","..data.y..","..data.r..";"
end
end
if isKey or isLast then
return "a"..data.p..","..data.y..","..data.r
else
return "a"..data.p..","..data.y..","..data.r..";"
end
end
}
local _s_table = _serialize.table
local _d_table = _deserialize.table
_d_meta = {
__call = function(self, str)
if type(str) == "string" then
return _d_table(str, nil, #str, true)
end
error("vON: You must deserialize a string, not a "..type(str))
end
}
_s_meta = {
__call = function(self, data)
if type(data) == "table" then
return _s_table(data, nil, nil, nil, nil, true)
end
error("vON: You must serialize a table, not a "..type(data))
end
}
von = {}
von.deserialize = setmetatable(_deserialize,_d_meta)
von.serialize = setmetatable(_serialize,_s_meta) | mit |
dr01d3r/darkstar | scripts/globals/spells/chocobo_mazurka.lua | 27 | 1162 | -----------------------------------------
-- Spell: Chocobo Mazurka
-- Gives party members enhanced movement
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
local power = 24;
local iBoost = caster:getMod(MOD_MAZURKA_EFFECT) + caster:getMod(MOD_ALL_SONGS_EFFECT);
local duration = 120;
duration = duration * ((iBoost * 0.1) + (caster:getMod(MOD_SONG_DURATION_BONUS)/100) + 1);
if (caster:hasStatusEffect(EFFECT_SOUL_VOICE)) then
duration = duration * 2;
elseif (caster:hasStatusEffect(EFFECT_MARCATO)) then
duration = duration * 1.5;
end
caster:delStatusEffect(EFFECT_MARCATO);
if (caster:hasStatusEffect(EFFECT_TROUBADOUR)) then
duration = duration * 2;
end
if not (target:addBardSong(caster,EFFECT_MAZURKA,power,0,duration,caster:getID(), 0, 1)) then
spell:setMsg(75);
end
return EFFECT_MAZURKA;
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Den_of_Rancor/TextIDs.lua | 7 | 1121 | -- Variable TextID Description text
-- General Texts
ITEM_CANNOT_BE_OBTAINED = 6379; -- You cannot obtain the item <item> come back again after sorting your inventory
ITEM_OBTAINED = 6385; -- Obtained: <item>
GIL_OBTAINED = 6386; -- Obtained <number> gil
KEYITEM_OBTAINED = 6388; -- Obtained key item: <keyitem>
FISHING_MESSAGE_OFFSET = 7233; -- You can't fish here
HOMEPOINT_SET = 10533; -- Home point set!
-- Treasure Coffer/Chest Dialog
CHEST_UNLOCKED = 7340; -- You unlock the chest!
CHEST_FAIL = 7341; -- Fails to open the chest.
CHEST_TRAP = 7342; -- The chest was trapped!
CHEST_WEAK = 7343; -- You cannot open the chest when you are in a weakened state.
CHEST_MIMIC = 7344; -- The chest was a mimic!
CHEST_MOOGLE = 7345; -- You cannot open the chest while participating in the moogle event.
CHEST_ILLUSION = 7346; -- The chest was but an illusion...
CHEST_LOCKED = 7347; -- The chest appears to be locked.
-- Other dialog
LANTERN_OFFSET = 7205; -- The grating will not budge.
-- conquest Base
CONQUEST_BASE = 7046; -- Tallying conquest results...
| gpl-3.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.