repo_name stringlengths 6 78 | path stringlengths 4 206 | copies stringclasses 281
values | size stringlengths 4 7 | content stringlengths 625 1.05M | license stringclasses 15
values |
|---|---|---|---|---|---|
dr01d3r/darkstar | scripts/zones/Port_Windurst/npcs/Martin.lua | 30 | 1273 | -----------------------------------
-- Area: Port Windurst
-- NPC: Martin
-- Type: Standard NPC
-----------------------------------
package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil;
require("scripts/zones/Port_Windurst/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local vHour = VanadielHour();
local vMin = VanadielMinute();
while vHour >= 4 do
vHour = vHour - 6;
end
if ( vHour == -2) then vHour = 4;
elseif ( vHour == -1) then vHour = 5;
end
local seconds = math.floor(2.4 * ((vHour * 60) + vMin));
player:startEvent( 0x0274, seconds, 0, 0, 0, 0, 0, 0, 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 | c21954587.lua | 2 | 3515 | --水精鱗-メガロアビス
function c21954587.initial_effect(c)
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(21954587,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_HAND)
e1:SetCost(c21954587.spcost)
e1:SetTarget(c21954587.sptg)
e1:SetOperation(c21954587.spop)
c:RegisterEffect(e1)
--search
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(21954587,1))
e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
e2:SetCondition(c21954587.thcon)
e2:SetTarget(c21954587.thtg)
e2:SetOperation(c21954587.thop)
c:RegisterEffect(e2)
--multiatk
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(21954587,2))
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetRange(LOCATION_MZONE)
e3:SetCondition(c21954587.atkcon)
e3:SetCost(c21954587.atkcost)
e3:SetTarget(c21954587.atktg)
e3:SetOperation(c21954587.atkop)
c:RegisterEffect(e3)
end
function c21954587.cfilter(c)
return c:IsAttribute(ATTRIBUTE_WATER) and c:IsDiscardable() and c:IsAbleToGraveAsCost()
end
function c21954587.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c21954587.cfilter,tp,LOCATION_HAND,0,2,e:GetHandler()) end
Duel.DiscardHand(tp,c21954587.cfilter,2,2,REASON_COST+REASON_DISCARD,e:GetHandler())
end
function c21954587.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function c21954587.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) then return end
Duel.SpecialSummon(c,1,tp,tp,false,false,POS_FACEUP)
end
function c21954587.thcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():GetSummonType()==SUMMON_TYPE_SPECIAL+1
end
function c21954587.thfilter(c)
return c:IsSetCard(0x75) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand()
end
function c21954587.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c21954587.thfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c21954587.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c21954587.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 c21954587.atkcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsAbleToEnterBP()
end
function c21954587.rfilter(c)
return c:IsPosition(POS_FACEUP_ATTACK) and c:IsAttribute(ATTRIBUTE_WATER)
end
function c21954587.atkcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckReleaseGroup(tp,c21954587.rfilter,1,e:GetHandler()) end
local g=Duel.SelectReleaseGroup(tp,c21954587.rfilter,1,1,e:GetHandler())
Duel.Release(g,REASON_COST)
end
function c21954587.atktg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():GetEffectCount(EFFECT_EXTRA_ATTACK)==0 end
end
function c21954587.atkop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EFFECT_EXTRA_ATTACK)
e1:SetValue(1)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
c:RegisterEffect(e1)
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c41930553.lua | 5 | 2810 | --暗黒の瘴気
function c41930553.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,TIMING_END_PHASE)
e1:SetTarget(c41930553.target1)
e1:SetOperation(c41930553.operation)
c:RegisterEffect(e1)
--remove
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(41930553,1))
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetRange(LOCATION_SZONE)
e2:SetCode(EVENT_FREE_CHAIN)
e2:SetHintTiming(0,TIMING_END_PHASE)
e2:SetTarget(c41930553.target2)
e2:SetOperation(c41930553.operation)
c:RegisterEffect(e2)
end
function c41930553.cfilter(c)
return c:IsRace(RACE_FIEND) and c:IsDiscardable()
end
function c41930553.rfilter(c)
return c:IsType(TYPE_MONSTER) and c:IsAbleToRemove()
end
function c41930553.target1(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(1-tp) and c41930553.rfilter(chkc) end
if chk==0 then return true end
if Duel.IsExistingMatchingCard(c41930553.cfilter,tp,LOCATION_HAND,0,1,nil)
and Duel.IsExistingTarget(c41930553.rfilter,tp,0,LOCATION_GRAVE,1,nil) and Duel.SelectYesNo(tp,aux.Stringid(41930553,0)) then
e:SetProperty(EFFECT_FLAG_CARD_TARGET)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectTarget(tp,c41930553.rfilter,tp,0,LOCATION_GRAVE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_HANDES,nil,0,tp,1)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,1,0,0)
e:GetHandler():RegisterFlagEffect(41930553,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1)
else e:SetProperty(0) end
end
function c41930553.target2(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(1-tp) and c41930553.rfilter(chkc) end
if chk==0 then return e:GetHandler():GetFlagEffect(41930553)==0
and Duel.IsExistingMatchingCard(c41930553.cfilter,tp,LOCATION_HAND,0,1,nil)
and Duel.IsExistingTarget(c41930553.rfilter,tp,0,LOCATION_GRAVE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectTarget(tp,c41930553.rfilter,tp,0,LOCATION_GRAVE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_HANDES,nil,0,tp,1)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,1,0,0)
e:GetHandler():RegisterFlagEffect(41930553,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1)
end
function c41930553.operation(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
local tc=Duel.GetFirstTarget()
if not tc then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISCARD)
local cg=Duel.SelectMatchingCard(tp,c41930553.cfilter,tp,LOCATION_HAND,0,1,1,nil)
if cg:GetCount()==0 then return end
Duel.SendtoGrave(cg,REASON_EFFECT+REASON_DISCARD)
if tc:IsRelateToEffect(e) then
Duel.Remove(tc,POS_FACEUP,REASON_EFFECT)
end
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/zones/Port_Windurst/npcs/Sheia_Pohrichamaha.lua | 17 | 1503 | -----------------------------------
-- Area: Port Windurst
-- NPC: Sheia Pohrichamaha
-- Only sells when Windurst controlls Fauregandi Region
-- Confirmed shop stock, August 2013
-----------------------------------
require("scripts/globals/shop");
require("scripts/globals/conquest");
package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil;
require("scripts/zones/Port_Windurst/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
RegionOwner = GetRegionOwner(FAUREGANDI);
if (RegionOwner ~= NATION_WINDURST) then
player:showText(npc,SHEIAPOHRICHAMAHA_CLOSED_DIALOG);
else
player:showText(npc,SHEIAPOHRICHAMAHA_OPEN_DIALOG);
stock = {
0x11DB, 90, --Beaugreens
0x110B, 39, --Faerie Apple
0x02B3, 54 --Maple Log
}
showShop(player,WINDURST,stock);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/PsoXja/npcs/_094.lua | 14 | 2879 | -----------------------------------
-- Area: Pso'Xja
-- NPC: _094 (Stone Gate)
-- Notes: Spawns Gargoyle when triggered
-- @pos 310.000 -1.925 -101.600 9
-----------------------------------
package.loaded["scripts/zones/PsoXja/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/status");
require("scripts/zones/PsoXja/TextIDs");
require("scripts/globals/keyitems");
-----------------------------------
-- onTrade
-----------------------------------
function onTrade(player,npc,trade)
if ((trade:hasItemQty(1115,1) or trade:hasItemQty(1023,1) or trade:hasItemQty(1022,1)) and trade:getItemCount() == 1 and player:getMainJob() == JOBS.THF) then
local Z=player:getZPos();
if (npc:getAnimation() == 9) then
if (Z >= -101) then
if (GetMobAction(16814085) == 0) then
local Rand = math.random(1,2); -- estimated 50% success as per the wiki
if (Rand == 1) then -- Spawn Gargoyle
player:messageSpecial(DISCOVER_DISARM_FAIL + 0x8000, 0, 0, 0, 0, true);
SpawnMob(16814085):updateClaim(player); -- Gargoyle
else
player:messageSpecial(DISCOVER_DISARM_SUCCESS + 0x8000, 0, 0, 0, 0, true);
npc:openDoor(30);
end
player:tradeComplete();
else
player:messageSpecial(DOOR_LOCKED);
end
end
end
end
end;
-----------------------------------
-- onTrigger
-----------------------------------
function onTrigger(player,npc)
local Z=player:getZPos();
if (npc:getAnimation() == 9) then
if (Z >= -101) then
if (GetMobAction(16814085) == 0) then
local Rand = math.random(1,10);
if (Rand <=9) then -- Spawn Gargoyle
player:messageSpecial(TRAP_ACTIVATED + 0x8000, 0, 0, 0, 0, true);
SpawnMob(16814085):updateClaim(player); -- Gargoyle
else
player:messageSpecial(TRAP_FAILS + 0x8000, 0, 0, 0, 0, true);
npc:openDoor(30);
end
else
player:messageSpecial(DOOR_LOCKED);
end
elseif (Z <= -102) then
player:startEvent(0x001A);
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
if (csid == 0x001A and option == 1) then
player:setPos(260,-0.25,-20,254,111);
end
end; | gpl-3.0 |
TcT2k/wxFormBuilder | build/premake/4.3/src/base/help.lua | 26 | 1220 | --
-- help.lua
-- User help, displayed on /help option.
-- Copyright (c) 2002-2008 Jason Perkins and the Premake project
--
function premake.showhelp()
-- display the basic usage
printf("Premake %s, a build script generator", _PREMAKE_VERSION)
printf(_PREMAKE_COPYRIGHT)
printf("%s %s", _VERSION, _COPYRIGHT)
printf("")
printf("Usage: premake4 [options] action [arguments]")
printf("")
-- display all options
printf("OPTIONS")
printf("")
for option in premake.option.each() do
local trigger = option.trigger
local description = option.description
if (option.value) then trigger = trigger .. "=" .. option.value end
if (option.allowed) then description = description .. "; one of:" end
printf(" --%-15s %s", trigger, description)
if (option.allowed) then
for _, value in ipairs(option.allowed) do
printf(" %-14s %s", value[1], value[2])
end
end
printf("")
end
-- display all actions
printf("ACTIONS")
printf("")
for action in premake.action.each() do
printf(" %-17s %s", action.trigger, action.description)
end
printf("")
-- see more
printf("For additional information, see http://industriousone.com/premake")
end
| gpl-2.0 |
PaulBernier/castl | lua/castl/modules/error_helper.lua | 1 | 2754 | --[[
Copyright (c) 2014, Paul Bernier
CASTL is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CASTL 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with CASTL. If not, see <http://www.gnu.org/licenses/>.
--]]
local errorHelper = {}
local new
local Error, TypeError, SyntaxError, RangeError, ReferenceError, URIError, EvalError
local require = require
_ENV = nil
local loadError = function()
new = new or require("castl.core_objects").new
Error = Error or require("castl.constructor.error.error")
end
local loadTypeError = function()
new = new or require("castl.core_objects").new
TypeError = TypeError or require("castl.constructor.error.type_error")
end
local loadSyntaxError = function()
new = new or require("castl.core_objects").new
SyntaxError = SyntaxError or require("castl.constructor.error.syntax_error")
end
local loadRangeError = function()
new = new or require("castl.core_objects").new
RangeError = RangeError or require("castl.constructor.error.range_error")
end
local loadReferenceError = function()
new = new or require("castl.core_objects").new
ReferenceError = ReferenceError or require("castl.constructor.error.reference_error")
end
local loadEvalError = function()
new = new or require("castl.core_objects").new
EvalError = EvalError or require("castl.constructor.error.eval_error")
end
local loadURIError = function()
new = new or require("castl.core_objects").new
URIError = URIError or require("castl.constructor.error.uri_error")
end
function errorHelper.newError(message)
loadError()
return new(Error, message)
end
function errorHelper.newTypeError(message)
loadTypeError()
return new(TypeError, message)
end
function errorHelper.newSyntaxError(message)
loadSyntaxError()
return new(SyntaxError, message)
end
function errorHelper.newRangeError(message)
loadRangeError()
return new(RangeError, message)
end
function errorHelper.newReferenceError(message)
loadReferenceError()
return new(ReferenceError, message)
end
function errorHelper.newURIError(message)
loadURIError()
return new(URIError, message)
end
function errorHelper.newEvalError(message)
loadEvalError()
return new(EvalError, message)
end
return errorHelper
| lgpl-3.0 |
OliRM/ch2d | lua/ch2d/lib/sprite.lua | 1 | 1330 | local Sprite = {}
Sprite.__index = Sprite
function Sprite.create()
local sprite = {}
setmetatable(sprite, Sprite)
sprite.id = ch2d.sprite.create()
return sprite
end
function Sprite:remove()
return ch2d.sprite.remove(self.id)
end
function Sprite:draw()
return ch2d.window.draw(self.id)
end
function Sprite:remove()
return ch2d.sprite.remove(self.id)
end
function Sprite:setPosition(_x, _y)
return ch2d.sprite.setPosition(self.id, _x, _y)
end
function Sprite:setOrigin(_x, _y)
return ch2d.sprite.setOrigin(self.id, _x, _y)
end
function Sprite:setRotation(_degrees)
return ch2d.sprite.setRotation(self.id, _degrees)
end
function Sprite:setScale(_x, _y)
return ch2d.sprite.setScale(self.id, _x, _y)
end
function Sprite:setTexture(_textureId)
return ch2d.sprite.setTexture(self.id, _textureId)
end
function Sprite:setTextureRect(_top, _left, _width, _height)
return ch2d.sprite.setTextureRect(self.id, _top, _left, _width, _height)
end
function Sprite:getPosition()
return ch2d.sprite.getPosition(self.id)
end
function Sprite:getOrigin()
return ch2d.sprite.getOrigin(self.id)
end
function Sprite:getRotation()
return ch2d.sprite.getRotation(self.id)
end
function Sprite:getScale()
return ch2d.sprite.getScale(self.id)
end
return Sprite
| mit |
sidsatx102/cardpeek | dot_cardpeek_dir/scripts/lib/strict.lua | 17 | 1194 | ------------------------------------------------------------
-- NOTE: This file was taken from the LUA 5.1 distribution
-- It is public domain
------------------------------------------------------------
--
-- strict.lua
-- checks uses of undeclared global variables
-- All global variables must be 'declared' through a regular assignment
-- (even assigning nil will do) in a main chunk before being used
-- anywhere or assigned to inside a function.
--
local mt = getmetatable(_G)
if mt == nil then
mt = {}
setmetatable(_G, mt)
end
__STRICT = true
mt.__declared = {}
mt.__newindex = function (t, n, v)
if __STRICT and not mt.__declared[n] and not string.sub(n,1,2) == "__" then
local w = debug.getinfo(2, "S").what
if w ~= "main" and w ~= "C" then
error("assign to undeclared variable '"..n.."'", 2)
end
mt.__declared[n] = true
end
rawset(t, n, v)
end
mt.__index = function (t, n)
if not mt.__declared[n] and string.sub(n,1,2) ~= "__" and debug.getinfo(2, "S").what ~= "C" then
error("variable '"..n.."' is not declared", 2)
end
return rawget(t, n)
end
function global(...)
for _, v in ipairs{...} do mt.__declared[v] = true end
end
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Hall_of_the_Gods/npcs/Shimmering_Circle.lua | 14 | 1814 | -----------------------------------
-- Area: Hall of the Gods
-- NPC: Shimmering Circle
-- Lifts players up to the sky!
-- @pos 0 -20 147 251
-----------------------------------
package.loaded["scripts/zones/Hall_of_the_Gods/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/missions");
require("scripts/zones/Hall_of_the_Gods/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local ZilartProgress = player:getCurrentMission(ZILART);
local ZVar = player:getVar("ZilartStatus");
if (player:getZPos() < 200) then
if (ZilartProgress == THE_GATE_OF_THE_GODS and ZVar == 0) then
player:startEvent(0x0003); -- First time.
elseif (ZilartProgress ~= 255 and ZilartProgress > THE_GATE_OF_THE_GODS or -- If player has not done any ZM, Progress == 255
(ZilartProgress == THE_GATE_OF_THE_GODS and ZVar > 0)) then
player:startEvent(0x000a);
else
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
end
else
player:startEvent(0x000b);
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 == 0x0003) then
player:setVar("ZilartStatus",1);
end
end; | gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c90960358.lua | 2 | 3352 | --トゥーン・ブラック・マジシャン・ガール
function c90960358.initial_effect(c)
c:EnableReviveLimit()
--special summon
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_SPSUMMON_PROC)
e2:SetProperty(EFFECT_FLAG_UNCOPYABLE)
e2:SetRange(LOCATION_HAND)
e2:SetCondition(c90960358.spcon)
e2:SetOperation(c90960358.spop)
c:RegisterEffect(e2)
--destroy
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e3:SetRange(LOCATION_MZONE)
e3:SetCode(EVENT_LEAVE_FIELD)
e3:SetCondition(c90960358.sdescon)
e3:SetOperation(c90960358.sdesop)
c:RegisterEffect(e3)
--direct attack
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetCode(EFFECT_DIRECT_ATTACK)
e4:SetCondition(c90960358.dircon)
c:RegisterEffect(e4)
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_SINGLE)
e5:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
e5:SetCondition(c90960358.atcon)
e5:SetValue(c90960358.atlimit)
c:RegisterEffect(e5)
local e6=Effect.CreateEffect(c)
e6:SetType(EFFECT_TYPE_SINGLE)
e6:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
e6:SetCondition(c90960358.atcon)
c:RegisterEffect(e6)
--cannot attack
local e7=Effect.CreateEffect(c)
e7:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e7:SetCode(EVENT_SUMMON_SUCCESS)
e7:SetOperation(c90960358.atklimit)
c:RegisterEffect(e7)
--atkup
local e8=Effect.CreateEffect(c)
e8:SetType(EFFECT_TYPE_SINGLE)
e8:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e8:SetCode(EFFECT_UPDATE_ATTACK)
e8:SetRange(LOCATION_MZONE)
e8:SetValue(c90960358.val)
c:RegisterEffect(e8)
end
function c90960358.cfilter(c)
return c:IsFaceup() and c:IsCode(15259703)
end
function c90960358.spcon(e,c)
if c==nil then return true end
local tp=c:GetControler()
return Duel.IsExistingMatchingCard(c90960358.cfilter,tp,LOCATION_ONFIELD,0,1,nil)
and Duel.GetLocationCount(tp,LOCATION_MZONE)>-1 and Duel.CheckReleaseGroup(tp,nil,1,nil)
end
function c90960358.spop(e,tp,eg,ep,ev,re,r,rp,c)
local tp=c:GetControler()
local g=Duel.SelectReleaseGroup(tp,nil,1,1,nil)
Duel.Release(g,REASON_COST)
end
function c90960358.sfilter(c)
return c:IsReason(REASON_DESTROY) and c:IsPreviousPosition(POS_FACEUP) and c:GetPreviousCodeOnField()==15259703 and c:IsPreviousLocation(LOCATION_ONFIELD)
end
function c90960358.sdescon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c90960358.sfilter,1,nil)
end
function c90960358.sdesop(e,tp,eg,ep,ev,re,r,rp)
Duel.Destroy(e:GetHandler(),REASON_EFFECT)
end
function c90960358.atkfilter(c)
return c:IsFaceup() and c:IsType(TYPE_TOON)
end
function c90960358.dircon(e)
return not Duel.IsExistingMatchingCard(c90960358.atkfilter,e:GetHandlerPlayer(),0,LOCATION_MZONE,1,nil)
end
function c90960358.atcon(e)
return Duel.IsExistingMatchingCard(c90960358.atkfilter,e:GetHandlerPlayer(),0,LOCATION_MZONE,1,nil)
end
function c90960358.atlimit(e,c)
return not c:IsType(TYPE_TOON) or c:IsFacedown()
end
function c90960358.atklimit(e,tp,eg,ep,ev,re,r,rp)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CANNOT_ATTACK)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
e:GetHandler():RegisterEffect(e1)
end
function c90960358.val(e,c)
return Duel.GetMatchingGroupCount(Card.IsCode,c:GetControler(),LOCATION_GRAVE,LOCATION_GRAVE,nil,46986414,30208479)*300
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c19019586.lua | 6 | 1962 | --ジェムエレファント
function c19019586.initial_effect(c)
--to hand
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetDescription(aux.Stringid(19019586,0))
e1:SetCategory(CATEGORY_TOHAND)
e1:SetRange(LOCATION_MZONE)
e1:SetTarget(c19019586.thtg)
e1:SetOperation(c19019586.thop)
c:RegisterEffect(e1)
--defup
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(19019586,1))
e2:SetCategory(CATEGORY_DEFCHANGE)
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetCode(EVENT_PRE_DAMAGE_CALCULATE)
e2:SetRange(LOCATION_MZONE)
e2:SetCondition(c19019586.defcon)
e2:SetCost(c19019586.defcost)
e2:SetOperation(c19019586.defop)
c:RegisterEffect(e2)
end
function c19019586.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToHand() end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,e:GetHandler(),1,0,0)
end
function c19019586.thop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsFaceup() and c:IsRelateToEffect(e) then
Duel.SendtoHand(c,nil,REASON_EFFECT)
end
end
function c19019586.cfilter(c)
return c:IsType(TYPE_NORMAL) and c:IsAbleToGraveAsCost()
end
function c19019586.defcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c==Duel.GetAttacker() or c==Duel.GetAttackTarget()
end
function c19019586.defcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():GetFlagEffect(19019586)==0
and Duel.IsExistingMatchingCard(c19019586.cfilter,tp,LOCATION_HAND,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,c19019586.cfilter,tp,LOCATION_HAND,0,1,1,nil)
Duel.SendtoGrave(g,REASON_COST)
e:GetHandler():RegisterFlagEffect(19019586,RESET_PHASE+PHASE_DAMAGE_CAL,0,1)
end
function c19019586.defop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_DEFENSE)
e1:SetReset(RESET_PHASE+PHASE_DAMAGE_CAL)
e1:SetValue(1000)
c:RegisterEffect(e1)
end
| gpl-2.0 |
asmagill/hammerspoon-config | _scratch/tm.lua | 1 | 9182 | -- Time Machine widget
--
-- Based HEAVILY on Übersicht Widget at https://github.com/ttscoff/ubersicht-widgets/tree/master/timemachine
local webview = require "hs.webview"
local timer = require "hs.timer"
local inspect = require "hs.inspect"
local frequency = 5 -- in seconds
local command = "/usr/bin/tmutil status"
local frame = { x = 20, y = 350, h = 300, w = 300 }
local module = {}
local PRIMARY_HTML = [==[
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<!-- style: section of original Übersicht widget -->
<style>
border none {
box-sizing: border-box;
color: #141f33;
font-family: Helvetica Neue;
font-weight: 300;
line-height: 1.5;
padding: 0;
left: 20px;
top: 30px;
height: auto;
opacity: 1;
}
@font-face {
font-family: 'arcfontregular';
src: url("data:font/woff;base64,d09GRgABAAAAAAvkAA4AAAAAWBAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABRAAAABwAAAAcZ5bVDkdERUYAAAFgAAAAHQAAACAAZQAET1MvMgAAAYAAAABBAAAAVlWziD5jbWFwAAABxAAAAIsAAAFigi+N+Wdhc3AAAAJQAAAACAAAAAj//wADZ2x5ZgAAAlgAAAaoAABPlFOuIHpoZWFkAAAJAAAAACsAAAA2A0CXb2hoZWEAAAksAAAAGwAAACQIRQQ5aG10eAAACUgAAABZAAAA4NoNMJNsb2NhAAAJpAAAAHIAAABydDphFG1heHAAAAoYAAAAHQAAACAAfAExbmFtZQAACjgAAAC5AAABVBaSMyRwb3N0AAAK9AAAAOUAAAJkwcCc0ndlYmYAAAvcAAAABgAAAAZ4u1P3AAAAAQAAAADMPaLPAAAAAMs8CQYAAAAA0B0pOHjaY2BkYGDgA2IJBhBgYmAEQnMgZgHzGAAGpwBqAAAAeNpjYGT+xjiBgZWBhWkm0xkGBoZ+CM34msGYkZOBgYmBFUhCASMDEghIc01hcGDgVf3DbPzfmCGGBUkNABN2CsYAAAB42mNgYGBmgGAZBkYGEIgB8hjBfBYGByDNw8DBwARkMzDwMkQyVKn++f8frI6XwZEhEcL7/+3/4f97bllDTYADRjYGuBAjE9QeFAUMhAELKxs7BycXNw8vH7+AoJCwiKiYuISklLQMVF5WTl5BUUlZRVVNXUNTS1tHV0/fwNDI2MTUjGEwAAD+shUpAAAAAAH//wACeNrlXE+IG1UYf9+8SWazO5M0u03HsNGw5hAtSJAwnQrSgG0PHlYPWz0JBS0U2vXiaaHgZdlLhYJ40B6UhcWDWIqlrgj2Il0QthSKbunSQlspSA+e1IMHC37fm0lm8m9m8ncmkzwSdpL3fu/3/b7fe/Myb7IMGD74UxlfGHt1KbvEn/73HB4BM9gyvy6dYF8xtpCBIpSKsqkUszXI1eSyXsuWcliUklLGZykDZYWKgQeGeBNLBgw8oDdFKWEpG2UTn0YFzDKVKh5UxZtYKlDFA3pTFKNqHJUAOCSSMyl1a0vNZObnD+YO6fl8fnFxsSAe+Ed+eTmf1w/lDs7PZzKqmppJyhweAz4kbCxjc0iCAjMpSM3CLMxhUTVNAy1tPSAtjrCoMIc1sB7MgEKtEticIwzSkE549udFM3gnATkzJz8X2NciP6WwUlQ1q+bxpAzRyRTBSRd8eh1rvjBj9XxdY99Svnio+dLxeYp0iFjWCE665tv3mHOHcM54e8K+o/wlQs9ftQarliARTCLCSU8CEBh/JjUnl3yBbVMuU6EnUsc/LgZTJaRsEhxfCEQjjJwSnJPXY+wnyutcJPKqmznzalB9QswuwvFjAbmElWKCc9Y+/Az7mfKsRSbPVXzeCy5VuNlGOH4mMKEwU441GjnfYL+gATKZSOWc3gS5F8lCTz3B8Y0eaIVsAKzX8MAmu00eyEbOA1TgSG/aRcIJBMc3eyIXvh8IruGJbbZHngC9HE1fIBUTzvUuZWTsoWl8u2eK0TAJtmr45Ca7Tz7hUfZJjqaRzX40jZBbsDm/2QfPyFiG4Jy15i57TL5JRN039Ar7/ckbLfek03yXy5PuIIJjru8st9gf5KPkJPgIS9WEfwrxcBM++C2Ih6OwPHJ76s+J8hQWHUHi5Kz04UIhTu7CxwOZN81bf02cx3K6gj7jsfIZwp0kcjEzG8HtEcHmc+W/E+k5ejUribj5TtNOWwRj6D2C27Vouv33bFL9VwSa+pT4WRCP1uosY+pD/OBGnavjReCT7EVFnIpTsfQjwV1yuMbXlQR3xWHs8mZq0r1ZEqfsudj6E+G23ITjbVKsdtlN272mhEwcvGr5VYuzXxFuu5l17E2Lldebubt8m4uLb621QCbm3iW4nVbu0+BggjvfGoHLx4U4+VgpYqeKWTkwBW5GuDudQpgWUyPcSqdAXN5+MWbeLuGBWZGmx+AEt985kCmyuaaZnYNxr6NfiqHXFeF3ebr8TnAPu4UzVa5HuK4R4XdIqXFd+EN4xcP9lSQZSOnFdKJEa9CMYgB4eCnKphjJjQPdmz2EyM4TCIPGl+5KCv9BUuk3o5CrGtLd3yU1kRB7d9KvsMev42dJ+qyUQ1NJv8FDpKGmcXQVRJ3b8KWoo1p1yPV6jWM9IrpPylHtdNokobD+DpwV9eed+mXRJmG3oeDuWJpbLTGQFUtn6u9HMER7vbk9jjK9prggUJ+deu4aOJp2vp4zwvoGEgLr+TYsGqN6LdWMR3pvO45woZLM644fCPtzdl9glzpi08DXa3Pt+JjPLbftWjqhXF52W0/kYJ19L/p6uWtfJdGf1rE/9M+lZq936BQNdKXZ9NjvKvtM9Fvx7LcktMx065u8u9Y62jozwOo3Wscexb/C1gQPw5eHldesFxcaR6fbx39XRjSodtvnBOL1GvtA8Ho9CC86I+AIKwegp2knO09SniQRaK/z/EVcX2DvCK5vBOVqCCl5ML5I5nC3mdWPNE1XD7pNvcL/EntLcH+zF+70iudH6zwfKIJ0uvuaIlAUNOk+8jiPIH3YF79NVdnbvcZCqwgyUI8RiZl84KjoLjbPUyTlCTbt2N7tJzZaISm0+uojRLqna0hhitupfH6nS7Ges2N9r99YaeGnFKU+A67fXDS8qOv39QSI/Ygd+/uDxE6vSlHuP/7GTS7D1cC5v8RXCdJCtrU4O6AW9K1AKSYHkcN9w8XwNXHd6+AvDLB7ti6rQ9DFFENldhBhWnb+RyJPy6a7v0ZXbY0+GpJGVTGk1EF1at2BHplYrZu/3ooBu2jrtTZEvSzN0kPQrH0XdJTCtW9A+vtt1dbv4yHrZ43PA8PRsONu3IiV7LgR5q/nKVvPjRHoaVbovkD3taqBVe22KzQGcbttyPhrfNzW+JPRaExX23AVNnShPXYnxiN3140B/zUNO2pr/unoNDeF7vJIdPe8Sj4u9b0uUPud5wxb/y8YWxj/jo0RjS0TSY3GngUT/3dP0iSNrqFml7JLkvbsb3oy9j/CTZzreNpjYGRgYADi3ZW1s+L5bb4ycLMwgMAFWU1LZJr5BVicg4EJRAEA9+gHkwB42mNgZGBgYQCCGDDJwPyCgZEBFVgAABygAYoAeNpjYYAAFgQ2pT1mugrEl4D4LBAfAeIdQLwSiKcDcTMQ5wBxMBBbArEcEDOxMDDeAOIFQJwFxGZAzAI06zoQrwPiLiAG6mEIAWJnILYA2cPEy8AAAKoGEpoAAAAAAAAMAAwADAAMANwBtAKUA3oEZgVaBlQHVghgCXQKkAu0DN4OEA9KEIoR0BMeFHQV0Bc0GKIaGBuWHRodKB06HVIdch2YHcYd/B44HnweyB8eH3wf4iBQIMYhRCHKIlYi6COAJCAkyCV6JjQm9Ce8J8oAAHjaY2BkYGCwYNRjYGIAARDJyAAScwDzGQAM5wCvAAAAeNpdjk0KgmAQhh/TojbSqlWEFzBMo7+dBNK6Ra2LVIQosLpAp+gInaJ13arxY2rhYmaeeecXaJNhYzkdLFxQbgi7yjYr+soOAw7KTXrclVt0eSi/RX8qfwh4EbNmScKZE1fhlJwbR3aUf7WKpegpHiFDmfNYiGVaj5iLRaqOmOGL96U3kBjWbni1KxvJSi4Upl7NVxfqu7fStf+rv65EJgvJYtmWm+9CU4vkk4Cp8ROjV5+MvzyOKdcAAAB42n3Rx04DQRCEYf9LWJNzDjY5w3ZPz3o5g3gVQEKICwfeHgRTV0ZqVZ0+lTS9qvf/636OXkXFGONMMElNnymmmWGWOeZZYJEllllhlTXW2WCTLbbZYZc99hkw5IBDjjjmhFPOOOeCS6645oZb7mgwnESQaevP99emaR77z29fHy9DH6l0KvelpEbFVFwlqYRKVmlVJCfJSXJIDskhOSSH5JAckkNySA7JWXK2+q8ovWQqGSVzybbkqGRXUrJJNm02bTZtNm02bTZtNm02bTbJLtklu2SX7JJdsv/+pOenh29E7ZKEAAAAAAFT93i6AAA=") format("woff");
font-weight: normal;
font-style: normal;
}
border none h1 {
line-height: 1;
position: absolute;
font-size: 100px;
font-weight: 700;
margin: 0;
padding: 0;
font-family: arcfontregular;
color: rgba(255,255,255,0.1);
animation-direction: alternate;
border: solid 1px rgba(255,255,255,0);
border-radius: 100px;
}
border none h1.spinning {
animation-direction: reverse;
animation-timing-function: linear !important;
animation: spinning 2s infinite;
}
border none h1.background {
border: solid 1px rgba(255,255,255,0.2);
border-radius: 100px;
}
border none h1.background.prepping {
border-color: rgba(195,59,59,0.5);
box-shadow: 0 0 15px rgba(195,59,59,0.35);
animation-timing-function: linear;
animation: prepping 3s infinite;
}
border none h1.background.starting {
border-color: rgba(206,154,84,0.5);
box-shadow: 0 0 15px rgba(206,154,84,0.5);
animation-timing-function: ease !important;
}
border none h1.background.running {
border-color: rgba(96,210,255,0.5);
box-shadow: 0 0 8px rgba(96,210,255,0.4);
}
border none h1.background.finishing {
border-color: rgba(96,255,137,0.5);
box-shadow: 0 0 15px rgba(96,255,137,0.35);
}
border none h1.background.spinning {
color: rgba(255,255,255,0);
}
border none h1.starting {
animation-timing-function: ease-in-out;
animation: starting 2s infinite;
}
border none h1.running {
animation-timing-function: ease-out;
animation: running 4s infinite;
}
</style>
<!-- update: (output, domEl) -> section of original widget as javascript function -->
<script type="text/javascript">
function doMyUpdate(output, domEl) {
document.write(output)
}
</script>
<!-- render: (output) ->
since the original didn't actually do anything but build the page framework I'm not
bothering with treating it as a function... maybe when I have more experience with
converting widgets I might attempt a more generic parser or interpreter...
For now I'm just trying to see if I can make it work!
-->
<style>
@-webkit-keyframes prepping
{
0% {opacity: 1;}
50% {opacity: .7; box-shadow: none;}
100% {opacity: 1;}
}
@-webkit-keyframes starting
{
0% {
-webkit-transform: scale(1);
opacity: 1;
}
50% {
-webkit-transform: scale(1.2) ;
opacity: .85;
box-shadow: none;
}
100% {
-webkit-transform: scale(1);
opacity: 1;
}
}
@-webkit-keyframes running
{
0% {-webkit-transform: scale(1); opacity: 1;}
50% {-webkit-transform: scale(1.1) ; opacity: .9; box-shadow: none;}
100% {-webkit-transform: scale(1); opacity: 1;}
}
@-webkit-keyframes spinning
{
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
</style>
<!-- so we can see it during testing -->
<style>
body {
background-color:rgba(0, 225, 0, 0.3)
}
</style>
<h1 class="background">Y</h1>
<h1 class="progress"></h1>
]==]
--module.ucc = webview.usercontent.new("TMWidget")
module.webview = webview.new(
frame,
{ developerExtrasEnabled = true, privateBrowsing = true, }--,
-- module.ucc
):behaviorAsLabels{ "canJoinAllSpaces" }
:bringToFront(true)
:transparent(true)
:html(PRIMARY_HTML)
:show()
timer.waitWhile(function()
return module.webview:loading()
end, function(self)
module.timer = timer.doEvery(frequency, function()
local o, s, t, r = hs.execute(command)
if s then
-- o = o:match("^(.*)\n")
print(o)
module.webview:evaluateJavaScript([[doMyUpdate("]] .. o:gsub([["]], [[\"]]) .. [[", document)]], function(result, err)
if result then
print(result)
-- module.webview:html(result)
else
print("~~ TimeMachine widget error evaluating javascript: " .. inspect(err))
end
end)
else
print("~~ TimeMachine widget error executing " .. command ..": type = " .. t .. ", code = " .. tostring(r) .. ", with output of " .. inspect(o))
end
end)
end)
return module
| mit |
SalvationDevelopment/Salvation-Scripts-Production | c80637190.lua | 6 | 1432 | --スパイダー・スパイダー
function c80637190.initial_effect(c)
--spsummon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(80637190,0))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCode(EVENT_BATTLE_DESTROYING)
e2:SetCondition(c80637190.spcon)
e2:SetTarget(c80637190.sptg)
e2:SetOperation(c80637190.spop)
c:RegisterEffect(e2)
end
function c80637190.spcon(e,tp,eg,ep,ev,re,r,rp)
local tc=e:GetHandler():GetBattleTarget()
return bit.band(tc:GetBattlePosition(),POS_DEFENSE)~=0
end
function c80637190.filter(c,e,tp)
return c:IsLevelBelow(4) and c:IsRace(RACE_INSECT) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c80637190.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c80637190.filter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c80637190.filter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c80637190.filter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c80637190.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)
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c77414722.lua | 6 | 1320 | --マジック・ジャマー
function c77414722.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_CHAINING)
e1:SetCondition(c77414722.condition)
e1:SetCost(c77414722.cost)
e1:SetTarget(c77414722.target)
e1:SetOperation(c77414722.activate)
c:RegisterEffect(e1)
end
function c77414722.condition(e,tp,eg,ep,ev,re,r,rp)
return re:IsActiveType(TYPE_SPELL) and re:IsHasType(EFFECT_TYPE_ACTIVATE) and Duel.IsChainNegatable(ev)
end
function c77414722.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if Duel.IsPlayerAffectedByEffect(tp,EFFECT_DISCARD_COST_CHANGE) then return true end
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDiscardable,tp,LOCATION_HAND,0,1,e:GetHandler()) end
Duel.DiscardHand(tp,Card.IsDiscardable,1,1,REASON_COST+REASON_DISCARD)
end
function c77414722.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 c77414722.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 |
ZACTELEGRAM1/Death-Robot-Anti-spamer | plugins/admin.lua | 46 | 6101 | local function set_bot_photo(msg, success, result)
local receiver = get_receiver(msg)
if success then
local file = 'data/photos/bot.jpg'
print('File downloaded to:', result)
os.rename(result, file)
print('File moved to:', file)
set_profile_photo(file, ok_cb, false)
send_large_msg(receiver, 'Photo changed!', ok_cb, false)
redis:del("bot:photo")
else
print('Error downloading: '..msg.id)
send_large_msg(receiver, 'Failed, please try again!', ok_cb, false)
end
end
local function parsed_url(link)
local parsed_link = URL.parse(link)
local parsed_path = URL.parse_path(parsed_link.path)
return parsed_path[2]
end
local function get_contact_list_callback (cb_extra, success, result)
local text = " "
for k,v in pairs(result) do
if v.print_name and v.id and v.phone then
text = text..string.gsub(v.print_name , "_" , " ").." ["..v.id.."] = "..v.phone.."\n"
end
end
local file = io.open("contact_list.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("user#id"..cb_extra.target,"contact_list.txt", ok_cb, false)--.txt format
local file = io.open("contact_list.json", "w")
file:write(json:encode_pretty(result))
file:flush()
file:close()
send_document("user#id"..cb_extra.target,"contact_list.json", ok_cb, false)--json format
end
local function user_info_callback(cb_extra, success, result)
result.access_hash = nil
result.flags = nil
result.phone = nil
if result.username then
result.username = '@'..result.username
end
result.print_name = result.print_name:gsub("_","")
local text = serpent.block(result, {comment=false})
text = text:gsub("[{}]", "")
text = text:gsub('"', "")
text = text:gsub(",","")
if cb_extra.msg.to.type == "chat" then
send_large_msg("chat#id"..cb_extra.msg.to.id, text)
else
send_large_msg("user#id"..cb_extra.msg.to.id, text)
end
end
local function get_dialog_list_callback(cb_extra, success, result)
local text = ""
for k,v in pairs(result) do
if v.peer then
if v.peer.type == "chat" then
text = text.."group{"..v.peer.title.."}["..v.peer.id.."]("..v.peer.members_num..")"
else
if v.peer.print_name and v.peer.id then
text = text.."user{"..v.peer.print_name.."}["..v.peer.id.."]"
end
if v.peer.username then
text = text.."("..v.peer.username..")"
end
if v.peer.phone then
text = text.."'"..v.peer.phone.."'"
end
end
end
if v.message then
text = text..'\nlast msg >\nmsg id = '..v.message.id
if v.message.text then
text = text .. "\n text = "..v.message.text
end
if v.message.action then
text = text.."\n"..serpent.block(v.message.action, {comment=false})
end
if v.message.from then
if v.message.from.print_name then
text = text.."\n From > \n"..string.gsub(v.message.from.print_name, "_"," ").."["..v.message.from.id.."]"
end
if v.message.from.username then
text = text.."( "..v.message.from.username.." )"
end
if v.message.from.phone then
text = text.."' "..v.message.from.phone.." '"
end
end
end
text = text.."\n\n"
end
local file = io.open("dialog_list.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("user#id"..cb_extra.target,"dialog_list.txt", ok_cb, false)--.txt format
local file = io.open("dialog_list.json", "w")
file:write(json:encode_pretty(result))
file:flush()
file:close()
send_document("user#id"..cb_extra.target,"dialog_list.json", ok_cb, false)--json format
end
local function run(msg,matches)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
local group = msg.to.id
if not is_admin(msg) then
return
end
if msg.media then
if msg.media.type == 'photo' and redis:get("bot:photo") then
if redis:get("bot:photo") == 'waiting' then
load_photo(msg.id, set_bot_photo, msg)
end
end
end
if matches[1] == "setbotphoto" then
redis:set("bot:photo", "waiting")
return 'Please send me bot photo now'
end
if matches[1] == "markread" then
if matches[2] == "on" then
redis:set("bot:markread", "on")
return "Mark read > on"
end
if matches[2] == "off" then
redis:del("bot:markread")
return "Mark read > off"
end
return
end
if matches[1] == "pm" then
send_large_msg("user#id"..matches[2],matches[3])
return "Msg sent"
end
if matches[1] == "block" then
if is_admin2(matches[2]) then
return "You can't block admins"
end
block_user("user#id"..matches[2],ok_cb,false)
return "User blocked"
end
if matches[1] == "unblock" then
unblock_user("user#id"..matches[2],ok_cb,false)
return "User unblocked"
end
if matches[1] == "import" then--join by group link
local hash = parsed_url(matches[2])
import_chat_link(hash,ok_cb,false)
end
if matches[1] == "contactlist" then
get_contact_list(get_contact_list_callback, {target = msg.from.id})
return "I've sent contact list with both json and text format to your private"
end
if matches[1] == "delcontact" then
del_contact("user#id"..matches[2],ok_cb,false)
return "User "..matches[2].." removed from contact list"
end
if matches[1] == "dialoglist" then
get_dialog_list(get_dialog_list_callback, {target = msg.from.id})
return "I've sent dialog list with both json and text format to your private"
end
if matches[1] == "whois" then
user_info("user#id"..matches[2],user_info_callback,{msg=msg})
end
return
end
return {
patterns = {
"^[!/](pm) (%d+) (.*)$",
"^[!/](import) (.*)$",
"^[!/](unblock) (%d+)$",
"^[!/](block) (%d+)$",
"^[!/](markread) (on)$",
"^[!/](markread) (off)$",
"^[!/](setbotphoto)$",
"%[(photo)%]",
"^[!/](contactlist)$",
"^[!/](dialoglist)$",
"^[!/](delcontact) (%d+)$",
"^[!/](whois) (%d+)$"
},
run = run,
}
| gpl-2.0 |
dr01d3r/darkstar | scripts/zones/Apollyon/mobs/Ice_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 |
joev/SVUI-Temp | SVUI_!Core/libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua | 30 | 7163 | --[[-----------------------------------------------------------------------------
EditBox Widget
-------------------------------------------------------------------------------]]
local Type, Version = "EditBox", 25
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local tostring, pairs = tostring, pairs
-- WoW APIs
local PlaySound = PlaySound
local GetCursorInfo, ClearCursor, GetSpellInfo = GetCursorInfo, ClearCursor, GetSpellInfo
local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: AceGUIEditBoxInsertLink, ChatFontNormal, OKAY
--[[-----------------------------------------------------------------------------
Support functions
-------------------------------------------------------------------------------]]
if not AceGUIEditBoxInsertLink then
-- upgradeable hook
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end)
end
function _G.AceGUIEditBoxInsertLink(text)
for i = 1, AceGUI:GetWidgetCount(Type) do
local editbox = _G["AceGUI-3.0EditBox"..i]
if editbox and editbox:IsVisible() and editbox:HasFocus() then
editbox:Insert(text)
return true
end
end
end
local function ShowButton(self)
if not self.disablebutton then
self.button:Show()
self.editbox:SetTextInsets(0, 20, 3, 3)
end
end
local function HideButton(self)
self.button:Hide()
self.editbox:SetTextInsets(0, 0, 3, 3)
end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
end
local function Frame_OnShowFocus(frame)
frame.obj.editbox:SetFocus()
frame:SetScript("OnShow", nil)
end
local function EditBox_OnEscapePressed(frame)
AceGUI:ClearFocus()
end
local function EditBox_OnEnterPressed(frame)
local self = frame.obj
local value = frame:GetText()
local cancel = self:Fire("OnEnterPressed", value)
if not cancel then
PlaySound("igMainMenuOptionCheckBoxOn")
HideButton(self)
end
end
local function EditBox_OnReceiveDrag(frame)
local self = frame.obj
local type, id, info = GetCursorInfo()
if type == "item" then
self:SetText(info)
self:Fire("OnEnterPressed", info)
ClearCursor()
elseif type == "spell" then
local name = GetSpellInfo(id, info)
self:SetText(name)
self:Fire("OnEnterPressed", name)
ClearCursor()
elseif type == "macro" then
local name = GetMacroInfo(id)
self:SetText(name)
self:Fire("OnEnterPressed", name)
ClearCursor()
end
HideButton(self)
AceGUI:ClearFocus()
end
local function EditBox_OnTextChanged(frame)
local self = frame.obj
local value = frame:GetText()
if tostring(value) ~= tostring(self.lasttext) then
self:Fire("OnTextChanged", value)
self.lasttext = value
ShowButton(self)
end
end
local function EditBox_OnFocusGained(frame)
AceGUI:SetFocus(frame.obj)
end
local function Button_OnClick(frame)
local editbox = frame.obj.editbox
editbox:ClearFocus()
EditBox_OnEnterPressed(editbox)
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
-- height is controlled by SetLabel
self:SetWidth(200)
self:SetDisabled(false)
self:SetLabel()
self:SetText()
self:DisableButton(false)
self:SetMaxLetters(0)
end,
["OnRelease"] = function(self)
self:ClearFocus()
end,
["SetDisabled"] = function(self, disabled)
self.disabled = disabled
if disabled then
self.editbox:EnableMouse(false)
self.editbox:ClearFocus()
self.editbox:SetTextColor(0.5,0.5,0.5)
self.label:SetTextColor(0.5,0.5,0.5)
else
self.editbox:EnableMouse(true)
self.editbox:SetTextColor(1,1,1)
self.label:SetTextColor(1,.82,0)
end
end,
["SetText"] = function(self, text)
self.lasttext = text or ""
self.editbox:SetText(text or "")
self.editbox:SetCursorPosition(0)
HideButton(self)
end,
["GetText"] = function(self, text)
return self.editbox:GetText()
end,
["SetLabel"] = function(self, text)
if text and text ~= "" then
self.label:SetText(text)
self.label:Show()
self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,-18)
self:SetHeight(44)
self.alignoffset = 30
else
self.label:SetText("")
self.label:Hide()
self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,0)
self:SetHeight(26)
self.alignoffset = 12
end
end,
["DisableButton"] = function(self, disabled)
self.disablebutton = disabled
if disabled then
HideButton(self)
end
end,
["SetMaxLetters"] = function (self, num)
self.editbox:SetMaxLetters(num or 0)
end,
["ClearFocus"] = function(self)
self.editbox:ClearFocus()
self.frame:SetScript("OnShow", nil)
end,
["SetFocus"] = function(self)
self.editbox:SetFocus()
if not self.frame:IsShown() then
self.frame:SetScript("OnShow", Frame_OnShowFocus)
end
end
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local num = AceGUI:GetNextWidgetNum(Type)
local frame = CreateFrame("Frame", nil, UIParent)
frame:Hide()
local editbox = CreateFrame("EditBox", "AceGUI-3.0EditBox"..num, frame, "InputBoxTemplate")
editbox:SetAutoFocus(false)
editbox:SetFontObject(ChatFontNormal)
editbox:SetScript("OnEnter", Control_OnEnter)
editbox:SetScript("OnLeave", Control_OnLeave)
editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed)
editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed)
editbox:SetScript("OnTextChanged", EditBox_OnTextChanged)
editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag)
editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag)
editbox:SetScript("OnEditFocusGained", EditBox_OnFocusGained)
editbox:SetTextInsets(0, 0, 3, 3)
editbox:SetMaxLetters(256)
editbox:SetPoint("BOTTOMLEFT", 6, 0)
editbox:SetPoint("BOTTOMRIGHT")
editbox:SetHeight(19)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
label:SetPoint("TOPLEFT", 0, -2)
label:SetPoint("TOPRIGHT", 0, -2)
label:SetJustifyH("LEFT")
label:SetHeight(18)
local button = CreateFrame("Button", nil, editbox, "UIPanelButtonTemplate")
button:SetWidth(40)
button:SetHeight(20)
button:SetPoint("RIGHT", -2, 0)
button:SetText(OKAY)
button:SetScript("OnClick", Button_OnClick)
button:Hide()
local widget = {
alignoffset = 30,
editbox = editbox,
label = label,
button = button,
frame = frame,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
editbox.obj, button.obj = widget, widget
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
| mit |
dr01d3r/darkstar | scripts/zones/Wajaom_Woodlands/mobs/Zoraal_Ja_s_Pkuucha.lua | 12 | 1662 | -----------------------------------
-- Area: Wajaom Woodlands
-- Mob: Zoraal Ja's Pkuucha
-----------------------------------
require("scripts/zones/Wajaom_Woodlands/MobIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
mob:setLocalVar("Pop_Zoraal_Ja", math.random(20,50));
end;
-----------------------------------
-- OnMobFight Action
-----------------------------------
function onMobFight(mob, target)
if (mob:getHPP() <= mob:getLocalVar("Pop_Zoraal_Ja") and GetMobAction(Percipient_Zoraal_Ja) == ACTION_NONE
and GetServerVariable("[POP]Percipient_Zoraal_Ja") == 0) then
GetMobByID(Percipient_Zoraal_Ja):setSpawn(mob:getXPos()+math.random(1,5), mob:getYPos(), mob:getZPos()+math.random(1,5));
SpawnMob(Percipient_Zoraal_Ja):updateEnmity(target);
mob:setHP(mob:getMaxHP());
mob:setUnkillable(true);
SetServerVariable("[POP]Percipient_Zoraal_Ja", os.time());
end
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
end;
-----------------------------------
-- onMobDespawn
-----------------------------------
function onMobDespawn(mob)
SetServerVariable("[POP]Percipient_Zoraal_Ja", 0 );
SetServerVariable("[POP]Zoraal_Ja_s_Pkuucha", os.time(t) + math.random(1800, 43200)); -- 30min to 12h
DeterMob(mob:getID(), true);
local PH = GetServerVariable("[PH]Zoraal_Ja_s_Pkuucha");
SetServerVariable("[PH]Zoraal_Ja_s_Pkuucha", 0);
DeterMob(PH, false);
GetMobByID(PH):setRespawnTime(GetMobRespawnTime(PH));
end;
| gpl-3.0 |
x-a-n-a-x/OpenRA | mods/cnc/maps/gdi02/gdi02.lua | 8 | 3298 | nodInBaseTeam = { RushBuggy, RushRifle1, RushRifle2, RushRifle3 }
MobileConstructionVehicle = { "mcv" }
EngineerReinforcements = { "e6", "e6", "e6" }
VehicleReinforcements = { "jeep" }
AttackerSquadSize = 3
ReinforceWithLandingCraft = function(units, transportStart, transportUnload, rallypoint)
local transport = Actor.Create("oldlst", true, { Owner = player, Facing = 0, Location = transportStart })
local subcell = 0
Utils.Do(units, function(a)
transport.LoadPassenger(Actor.Create(a, false, { Owner = transport.Owner, Facing = transport.Facing, Location = transportUnload, SubCell = subcell }))
subcell = subcell + 1
end)
transport.ScriptedMove(transportUnload)
transport.CallFunc(function()
Utils.Do(units, function()
local a = transport.UnloadPassenger()
a.IsInWorld = true
a.MoveIntoWorld(transport.Location - CVec.New(0, 1))
if rallypoint ~= nil then
a.Move(rallypoint)
end
end)
end)
transport.Wait(5)
transport.ScriptedMove(transportStart)
transport.Destroy()
end
Reinforce = function(units)
Media.PlaySpeechNotification(player, "Reinforce")
ReinforceWithLandingCraft(units, lstStart.Location, lstEnd.Location)
end
BridgeheadSecured = function()
Reinforce(MobileConstructionVehicle)
Trigger.AfterDelay(DateTime.Seconds(15), NodAttack)
Trigger.AfterDelay(DateTime.Seconds(30), function() Reinforce(EngineerReinforcements) end)
Trigger.AfterDelay(DateTime.Seconds(120), function() Reinforce(VehicleReinforcements) end)
end
NodAttack = function()
local nodUnits = enemy.GetGroundAttackers()
if #nodUnits > AttackerSquadSize * 2 then
local attackers = Utils.Skip(nodUnits, #nodUnits - AttackerSquadSize)
Utils.Do(attackers, function(unit)
unit.AttackMove(NodAttackWaypoint.Location)
Trigger.OnIdle(unit, unit.Hunt)
end)
Trigger.OnAllKilled(attackers, function() Trigger.AfterDelay(DateTime.Seconds(15), NodAttack) end)
end
end
WorldLoaded = function()
player = Player.GetPlayer("GDI")
enemy = Player.GetPlayer("Nod")
Trigger.OnObjectiveAdded(player, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective")
end)
Trigger.OnObjectiveCompleted(player, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed")
end)
Trigger.OnObjectiveFailed(player, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed")
end)
Trigger.OnPlayerWon(player, function()
Media.PlaySpeechNotification(player, "Win")
end)
Trigger.OnPlayerLost(player, function()
Media.PlaySpeechNotification(player, "Lose")
end)
nodObjective = enemy.AddPrimaryObjective("Destroy all GDI troops")
gdiObjective1 = player.AddPrimaryObjective("Eliminate all Nod forces in the area")
gdiObjective2 = player.AddSecondaryObjective("Capture the Tiberium Refinery")
Trigger.OnCapture(NodRefinery, function() player.MarkCompletedObjective(gdiObjective2) end)
Trigger.OnKilled(NodRefinery, function() player.MarkFailedObjective(gdiObjective2) end)
Trigger.OnAllKilled(nodInBaseTeam, BridgeheadSecured)
end
Tick = function()
if player.HasNoRequiredUnits() then
enemy.MarkCompletedObjective(nodObjective)
end
if enemy.HasNoRequiredUnits() then
player.MarkCompletedObjective(gdiObjective1)
end
end
| gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c39037517.lua | 4 | 2578 | --コアキメイル・ビートル
function c39037517.initial_effect(c)
--cost
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EVENT_PHASE+PHASE_END)
e1:SetCountLimit(1)
e1:SetRange(LOCATION_MZONE)
e1:SetCondition(c39037517.mtcon)
e1:SetOperation(c39037517.mtop)
c:RegisterEffect(e1)
--poschange
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(39037517,3))
e2:SetCategory(CATEGORY_POSITION)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
e2:SetRange(LOCATION_MZONE)
e2:SetTarget(c39037517.target)
e2:SetOperation(c39037517.operation)
c:RegisterEffect(e2)
end
function c39037517.mtcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==tp
end
function c39037517.cfilter1(c)
return c:IsCode(36623431) and c:IsAbleToGraveAsCost()
end
function c39037517.cfilter2(c)
return c:IsType(TYPE_MONSTER) and c:IsRace(RACE_INSECT) and not c:IsPublic()
end
function c39037517.mtop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
Duel.HintSelection(Group.FromCards(c))
local g1=Duel.GetMatchingGroup(c39037517.cfilter1,tp,LOCATION_HAND,0,nil)
local g2=Duel.GetMatchingGroup(c39037517.cfilter2,tp,LOCATION_HAND,0,nil)
local select=2
if g1:GetCount()>0 and g2:GetCount()>0 then
select=Duel.SelectOption(tp,aux.Stringid(39037517,0),aux.Stringid(39037517,1),aux.Stringid(39037517,2))
elseif g1:GetCount()>0 then
select=Duel.SelectOption(tp,aux.Stringid(39037517,0),aux.Stringid(39037517,2))
if select==1 then select=2 end
elseif g2:GetCount()>0 then
select=Duel.SelectOption(tp,aux.Stringid(39037517,1),aux.Stringid(39037517,2))+1
else
select=Duel.SelectOption(tp,aux.Stringid(39037517,2))
select=2
end
if select==0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=g1:Select(tp,1,1,nil)
Duel.SendtoGrave(g,REASON_COST)
elseif select==1 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONFIRM)
local g=g2:Select(tp,1,1,nil)
Duel.ConfirmCards(1-tp,g)
Duel.ShuffleHand(tp)
else
Duel.Destroy(c,REASON_COST)
end
end
function c39037517.filter(c,e)
return c:IsPosition(POS_FACEUP_ATTACK) and c:IsAttribute(ATTRIBUTE_LIGHT+ATTRIBUTE_DARK)
and (not e or c:IsRelateToEffect(e))
end
function c39037517.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return eg:IsExists(c39037517.filter,1,nil) end
Duel.SetTargetCard(eg)
end
function c39037517.operation(e,tp,eg,ep,ev,re,r,rp)
local g=eg:Filter(c39037517.filter,nil,e)
Duel.ChangePosition(g,POS_FACEUP_DEFENSE)
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/globals/items/truelove_chocolate.lua | 12 | 1219 | -----------------------------------------
-- ID: 5231
-- Item: truelove_chocolate
-- Food Effect: 4Hrs, All Races
-----------------------------------------
-- MP 10
-- MP Recovered While Healing 4
-----------------------------------------
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,5231);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_MP, 10);
target:addMod(MOD_MPHEAL, 4);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_MP, 10);
target:delMod(MOD_MPHEAL, 4);
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Castle_Zvahl_Keep/Zone.lua | 13 | 3875 | -----------------------------------
--
-- Zone: Castle_Zvahl_Keep (162)
--
-----------------------------------
package.loaded["scripts/zones/Castle_Zvahl_Keep/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Castle_Zvahl_Keep/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
zone:registerRegion(1, -301,-50,-22, -297,-49,-17); -- central porter on map 3
zone:registerRegion(2, -275,-54,3, -271,-53,7); -- NE porter on map 3
zone:registerRegion(3, -275,-54,-47, -271,-53,-42); -- SE porter on map 3
zone:registerRegion(4, -330,-54,3, -326,-53,7); -- NW porter on map 3
zone:registerRegion(5, -328,-54,-47, -324,-53,-42); -- SW porter on map 3
zone:registerRegion(6, -528,-74,84, -526,-73,89); -- N porter on map 4
zone:registerRegion(7, -528,-74,30, -526,-73,36); -- S porter on map 4
UpdateTreasureSpawnPoint(17441088);
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(-555.996,-71.691,59.989,254);
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
switch (region:GetRegionID()): caseof
{
---------------------------------
[1] = function (x) --
---------------------------------
player:startEvent(0x0000); -- ports player to far NE corner
end,
---------------------------------
[2] = function (x) --
---------------------------------
player:startEvent(0x0002); -- ports player to
end,
---------------------------------
[3] = function (x) --
---------------------------------
player:startEvent(0x0001); -- ports player to far SE corner
end,
---------------------------------
[4] = function (x) --
---------------------------------
player:startEvent(0x0001); -- ports player to far SE corner
end,
---------------------------------
[5] = function (x) --
---------------------------------
player:startEvent(0x0005); -- ports player to H-7 on map 4 (south or north part, randomly)
end,
---------------------------------
[6] = function (x) --
---------------------------------
player:startEvent(0x0006); -- ports player to position "A" on map 2
end,
---------------------------------
[7] = function (x) --
---------------------------------
player:startEvent(0x0007); -- ports player to position G-8 on map 2
end,
default = function (x)
-- print("default");
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);
end; | gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Grauberg_[S]/npcs/qm1.lua | 30 | 1695 | -----------------------------------
-- Area: Grauberg [S]
-- NPC: ???
-- Quest - DNC AF1
-----------------------------------
package.loaded["scripts/zones/Grauberg_[S]/TextIDs"] = nil;
-------------------------------------
require("scripts/globals/harvesting");
require("scripts/zones/Grauberg_[S]/TextIDs");
-----------------------------------
-- onTrade
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger
-----------------------------------
function onTrigger(player,npc)
if (player:getQuestStatus(JEUNO,THE_UNFINISHED_WALTZ) == QUEST_ACCEPTED and player:getVar("QuestStatus_DNC_AF1")==2) then
player:startEvent(0x0C);
elseif (player:getQuestStatus(JEUNO,THE_UNFINISHED_WALTZ) == QUEST_ACCEPTED and player:getVar("QuestStatus_DNC_AF1")==3) then
if (GetMobAction(17142108) == 0) then
SpawnMob(17142108):updateEnmity(player);
end
elseif (player:getQuestStatus(JEUNO,THE_UNFINISHED_WALTZ) == QUEST_ACCEPTED and player:getVar("QuestStatus_DNC_AF1")==4) then
player:startEvent(0x0D);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
if (csid==0x0C) then
player:setVar("QuestStatus_DNC_AF1", 3);
elseif (csid==0x0D) then
player:addKeyItem(THE_ESSENCE_OF_DANCE);
player:messageSpecial(KEYITEM_OBTAINED,THE_ESSENCE_OF_DANCE);
player:setVar("QuestStatus_DNC_AF1", 5);
end
end; | gpl-3.0 |
diegonehab/LuaSocket | test/smtptest.lua | 44 | 5376 | local sent = {}
local from = "diego@localhost"
local server = "localhost"
local rcpt = "luasocket@localhost"
local files = {
"/var/spool/mail/luasocket",
"/var/spool/mail/luasock1",
"/var/spool/mail/luasock2",
"/var/spool/mail/luasock3",
}
local t = socket.time()
local err
dofile("mbox.lua")
local parse = mbox.parse
dofile("testsupport.lua")
local total = function()
local t = 0
for i = 1, #sent do
t = t + sent[i].count
end
return t
end
local similar = function(s1, s2)
return
string.lower(string.gsub(s1, "%s", "")) ==
string.lower(string.gsub(s2, "%s", ""))
end
local fail = function(s)
s = s or "failed!"
print(s)
os.exit()
end
local readfile = function(name)
local f = io.open(name, "r")
if not f then
fail("unable to open file!")
return nil
end
local s = f:read("*a")
f:close()
return s
end
local empty = function()
for i,v in ipairs(files) do
local f = io.open(v, "w")
if not f then
fail("unable to open file!")
end
f:close()
end
end
local get = function()
local s = ""
for i,v in ipairs(files) do
s = s .. "\n" .. readfile(v)
end
return s
end
local check_headers = function(sent, got)
sent = sent or {}
got = got or {}
for i,v in pairs(sent) do
if not similar(v, got[i]) then fail("header " .. v .. "failed!") end
end
end
local check_body = function(sent, got)
sent = sent or ""
got = got or ""
if not similar(sent, got) then fail("bodies differ!") end
end
local check = function(sent, m)
io.write("checking ", m.headers.title, ": ")
for i = 1, #sent do
local s = sent[i]
if s.title == m.headers.title and s.count > 0 then
check_headers(s.headers, m.headers)
check_body(s.body, m.body)
s.count = s.count - 1
print("ok")
return
end
end
fail("not found")
end
local insert = function(sent, message)
if type(message.rcpt) == "table" then
message.count = #message.rcpt
else message.count = 1 end
message.headers = message.headers or {}
message.headers.title = message.title
table.insert(sent, message)
end
local mark = function()
local time = socket.time()
return { time = time }
end
local wait = function(sentinel, n)
local to
io.write("waiting for ", n, " messages: ")
while 1 do
local mbox = parse(get())
if n == #mbox then break end
if socket.time() - sentinel.time > 50 then
to = 1
break
end
socket.sleep(1)
io.write(".")
io.stdout:flush()
end
if to then fail("timeout")
else print("ok") end
end
local stuffed_body = [[
This message body needs to be
stuffed because it has a dot
.
by itself on a line.
Otherwise the mailer would
think that the dot
.
is the end of the message
and the remaining text would cause
a lot of trouble.
]]
insert(sent, {
from = from,
rcpt = {
"luasocket@localhost",
"luasock3@dell-diego.cs.princeton.edu",
"luasock1@dell-diego.cs.princeton.edu"
},
body = "multiple rcpt body",
title = "multiple rcpt",
})
insert(sent, {
from = from,
rcpt = {
"luasock2@localhost",
"luasock3",
"luasock1"
},
headers = {
header1 = "header 1",
header2 = "header 2",
header3 = "header 3",
header4 = "header 4",
header5 = "header 5",
header6 = "header 6",
},
body = stuffed_body,
title = "complex message",
})
insert(sent, {
from = from,
rcpt = rcpt,
server = server,
body = "simple message body",
title = "simple message"
})
insert(sent, {
from = from,
rcpt = rcpt,
server = server,
body = stuffed_body,
title = "stuffed message body"
})
insert(sent, {
from = from,
rcpt = rcpt,
headers = {
header1 = "header 1",
header2 = "header 2",
header3 = "header 3",
header4 = "header 4",
header5 = "header 5",
header6 = "header 6",
},
title = "multiple headers"
})
insert(sent, {
from = from,
rcpt = rcpt,
title = "minimum message"
})
io.write("testing host not found: ")
local c, e = socket.connect("wrong.host", 25)
local ret, err = socket.smtp.mail{
from = from,
rcpt = rcpt,
server = "wrong.host"
}
if ret or e ~= err then fail("wrong error message")
else print("ok") end
io.write("testing invalid from: ")
local ret, err = socket.smtp.mail{
from = ' " " (( _ * ',
rcpt = rcpt,
}
if ret or not err then fail("wrong error message")
else print(err) end
io.write("testing no rcpt: ")
local ret, err = socket.smtp.mail{
from = from,
}
if ret or not err then fail("wrong error message")
else print(err) end
io.write("clearing mailbox: ")
empty()
print("ok")
io.write("sending messages: ")
for i = 1, #sent do
ret, err = socket.smtp.mail(sent[i])
if not ret then fail(err) end
io.write("+")
io.stdout:flush()
end
print("ok")
wait(mark(), total())
io.write("parsing mailbox: ")
local mbox = parse(get())
print(#mbox .. " messages found!")
for i = 1, #mbox do
check(sent, mbox[i])
end
print("passed all tests")
print(string.format("done in %.2fs", socket.time() - t))
| mit |
SalvationDevelopment/Salvation-Scripts-Production | c7817703.lua | 5 | 2650 | --D・パワーユニット
function c7817703.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(c7817703.target)
e1:SetOperation(c7817703.operation)
c:RegisterEffect(e1)
--Atk Change
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_EQUIP)
e2:SetCode(EFFECT_SET_ATTACK)
e2:SetValue(c7817703.value)
c:RegisterEffect(e2)
--Equip limit
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_EQUIP_LIMIT)
e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e3:SetValue(c7817703.eqlimit)
c:RegisterEffect(e3)
end
function c7817703.eqlimit(e,c)
return c:IsSetCard(0x26) and c:GetLevel()==3
end
function c7817703.filter(c)
return c:IsFaceup() and c:IsSetCard(0x26) and c:GetLevel()==3
end
function c7817703.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c7817703.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c7817703.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,c7817703.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
function c7817703.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)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetCategory(CATEGORY_DESTROY+CATEGORY_DAMAGE)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e1:SetCode(EVENT_PHASE+PHASE_STANDBY)
e1:SetRange(LOCATION_SZONE)
e1:SetCountLimit(1)
e1:SetLabel(Duel.GetTurnCount())
e1:SetCondition(c7817703.descon)
e1:SetTarget(c7817703.destg)
e1:SetOperation(c7817703.desop)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END+RESET_SELF_TURN,3)
e:GetHandler():RegisterEffect(e1)
end
end
function c7817703.value(e,c)
return c:GetBaseAttack()*2
end
function c7817703.descon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnCount()-e:GetLabel()==4
end
function c7817703.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)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,tp,0)
end
function c7817703.desop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) then
local dam=c:GetEquipTarget():GetBaseAttack()
if Duel.Destroy(e:GetHandler(),REASON_EFFECT)==0 then return end
Duel.Damage(tp,dam,REASON_EFFECT)
end
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/globals/items/pork_cutlet.lua | 12 | 1737 | -----------------------------------------
-- ID: 6394
-- Item: pork_cutlet
-- Food Effect: 180Min, All Races
-----------------------------------------
-- HP +40
-- STR +7
-- INT -7
-- Fire resistance +20
-- Attack +20% (cap 120)
-- Ranged Attack +20% (cap 120)
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,10800,6394);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 40);
target:addMod(MOD_STR, 7);
target:addMod(MOD_INT, -7);
target:addMod(MOD_FIRERES, 20);
target:addMod(MOD_FOOD_ATTP, 20);
target:addMod(MOD_FOOD_ATT_CAP, 120);
target:addMod(MOD_FOOD_RATTP, 20);
target:addMod(MOD_FOOD_RATT_CAP, 120);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 40);
target:delMod(MOD_STR, 7);
target:delMod(MOD_INT, -7);
target:delMod(MOD_FIRERES, 20);
target:delMod(MOD_FOOD_ATTP, 20);
target:delMod(MOD_FOOD_ATT_CAP, 120);
target:delMod(MOD_FOOD_RATTP, 20);
target:delMod(MOD_FOOD_RATT_CAP, 120);
end;
| gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c20932152.lua | 6 | 1410 | --クイック・シンクロン
function c20932152.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(c20932152.spcon)
e1:SetOperation(c20932152.spop)
c:RegisterEffect(e1)
--
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_CANNOT_BE_SYNCHRO_MATERIAL)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e2:SetValue(c20932152.synlimit)
c:RegisterEffect(e2)
--
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e3:SetCode(20932152)
c:RegisterEffect(e3)
end
function c20932152.synlimit(e,c)
if not c then return false end
return not aux.IsMaterialListSetCard(c,0x1017)
end
function c20932152.spfilter(c)
return c:IsType(TYPE_MONSTER) and c:IsAbleToGraveAsCost()
end
function c20932152.spcon(e,c)
if c==nil then return true end
local tp=c:GetControler()
return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c20932152.spfilter,tp,LOCATION_HAND,0,1,c)
end
function c20932152.spop(e,tp,eg,ep,ev,re,r,rp,c)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,c20932152.spfilter,tp,LOCATION_HAND,0,1,1,c)
Duel.SendtoGrave(g,REASON_COST)
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c85718645.lua | 5 | 1761 | --闇帝ディルグ
function c85718645.initial_effect(c)
--remove
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(85718645,0))
e1:SetCategory(CATEGORY_REMOVE+CATEGORY_DECKDES)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetTarget(c85718645.target)
e1:SetOperation(c85718645.operation)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e2)
--cannot attack
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e3:SetCode(EVENT_SUMMON_SUCCESS)
e3:SetOperation(c85718645.disatt)
c:RegisterEffect(e3)
local e4=e3:Clone()
e4:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e4)
end
function c85718645.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(1-tp) and chkc:IsAbleToRemove() end
if chk==0 then return Duel.IsExistingTarget(Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectTarget(tp,Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,2,nil)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,g:GetCount(),0,0)
end
function c85718645.operation(e,tp,eg,ep,ev,re,r,rp)
local tg=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
local sg=tg:Filter(Card.IsRelateToEffect,nil,e)
local count=Duel.Remove(sg,POS_FACEUP,REASON_EFFECT)
if count>0 then Duel.DiscardDeck(1-tp,count,REASON_EFFECT) end
end
function c85718645.disatt(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CANNOT_ATTACK)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
c:RegisterEffect(e1)
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c33550694.lua | 2 | 2903 | --フュージョン・ゲート
function c33550694.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--fusion
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(33550694,0))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_FZONE)
e2:SetProperty(EFFECT_FLAG_BOTH_SIDE)
e2:SetTarget(c33550694.target)
e2:SetOperation(c33550694.operation)
c:RegisterEffect(e2)
end
function c33550694.filter1(c,e)
return c:IsAbleToRemove() and not c:IsImmuneToEffect(e)
end
function c33550694.filter2(c,e,tp,m,f,chkf)
return c:IsType(TYPE_FUSION) and (not f or f(c))
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf)
end
function c33550694.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local chkf=Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and PLAYER_NONE or tp
local mg1=Duel.GetFusionMaterial(tp):Filter(Card.IsAbleToRemove,nil)
local res=Duel.IsExistingMatchingCard(c33550694.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf)
if not res then
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
local mg2=fgroup(ce,e,tp)
local mf=ce:GetValue()
res=Duel.IsExistingMatchingCard(c33550694.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,mf,chkf)
end
end
return res
end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function c33550694.operation(e,tp,eg,ep,ev,re,r,rp)
local chkf=Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and PLAYER_NONE or tp
if not e:GetHandler():IsRelateToEffect(e) then return end
local mg1=Duel.GetFusionMaterial(tp):Filter(c33550694.filter1,nil,e)
local sg1=Duel.GetMatchingGroup(c33550694.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf)
local mg2=nil
local sg2=nil
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
mg2=fgroup(ce,e,tp)
local mf=ce:GetValue()
sg2=Duel.GetMatchingGroup(c33550694.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,chkf)
end
if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then
local sg=sg1:Clone()
if sg2 then sg:Merge(sg2) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tg=sg:Select(tp,1,1,nil)
local tc=tg:GetFirst()
if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
tc:SetMaterial(mat1)
Duel.Remove(mat1,POS_FACEUP,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
Duel.BreakEffect()
Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
else
local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,nil,chkf)
local fop=ce:GetOperation()
fop(ce,e,tp,tc,mat2)
end
tc:CompleteProcedure()
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c94212438.lua | 2 | 3498 | --ウィジャ盤
function c94212438.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,TIMING_END_PHASE)
e1:SetTarget(c94212438.target)
c:RegisterEffect(e1)
--place card
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(94212438,0))
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e2:SetRange(LOCATION_SZONE)
e2:SetCode(EVENT_PHASE+PHASE_END)
e2:SetCountLimit(1)
e2:SetLabel(94212438)
e2:SetCondition(c94212438.plcon)
e2:SetTarget(c94212438.pltg)
e2:SetOperation(c94212438.plop)
c:RegisterEffect(e2)
--tograve
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e3:SetRange(LOCATION_SZONE)
e3:SetCode(EVENT_LEAVE_FIELD)
e3:SetCondition(c94212438.tgcon)
e3:SetOperation(c94212438.tgop)
c:RegisterEffect(e3)
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e4:SetCode(EVENT_LEAVE_FIELD)
e4:SetOperation(c94212438.tgop)
c:RegisterEffect(e4)
--win
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e5:SetCode(EVENT_ADJUST)
e5:SetRange(LOCATION_SZONE)
e5:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE)
e5:SetOperation(c94212438.winop)
c:RegisterEffect(e5)
end
function c94212438.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
if Duel.GetCurrentPhase()==PHASE_END and c94212438.plcon(e,tp,eg,ep,ev,re,r,rp) and Duel.SelectYesNo(tp,94) then
e:SetLabel(94212438)
e:SetOperation(c94212438.plop)
e:GetHandler():RegisterFlagEffect(0,RESET_CHAIN,EFFECT_FLAG_CLIENT_HINT,1,0,65)
e:GetHandler():RegisterFlagEffect(94212439,RESET_PHASE+PHASE_END,0,1)
else
e:SetLabel(0)
e:SetOperation(nil)
end
end
function c94212438.plcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()~=tp and e:GetHandler():GetFlagEffect(94212438)<4
end
function c94212438.pltg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():GetFlagEffect(94212439)==0 end
end
function c94212438.plop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) then return end
if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end
local ids={31893528,67287533,94772232,30170981}
local id=ids[c:GetFlagEffect(94212438)+1]
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(94212438,1))
local g=Duel.SelectMatchingCard(tp,Card.IsCode,tp,LOCATION_DECK+LOCATION_HAND,0,1,1,nil,id)
if g:GetCount()>0 and Duel.MoveToField(g:GetFirst(),tp,tp,LOCATION_SZONE,POS_FACEUP,true) then
c:RegisterFlagEffect(94212438,RESET_EVENT+0x1fe0000,0,0)
end
end
function c94212438.cfilter1(c,tp)
return c:IsControler(tp) and c:IsCode(94212438,31893528,67287533,94772232,30170981)
end
function c94212438.cfilter2(c)
return c:IsFaceup() and c:IsCode(94212438,31893528,67287533,94772232,30170981)
end
function c94212438.tgcon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c94212438.cfilter1,1,nil,tp)
end
function c94212438.tgop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(c94212438.cfilter2,tp,LOCATION_ONFIELD,0,nil)
Duel.SendtoGrave(g,REASON_EFFECT)
end
function c94212438.cfilter3(c)
return c:IsFaceup() and c:IsCode(31893528,67287533,94772232,30170981)
end
function c94212438.winop(e,tp,eg,ep,ev,re,r,rp)
local WIN_REASON_DESTINY_BOARD=0x15
local g=Duel.GetMatchingGroup(c94212438.cfilter3,tp,LOCATION_ONFIELD,0,e:GetHandler())
if g:GetClassCount(Card.GetCode)==4 then
Duel.Win(tp,WIN_REASON_DESTINY_BOARD)
end
end
| gpl-2.0 |
x-a-n-a-x/OpenRA | mods/ra/maps/allies-05a/allies05a.lua | 8 | 8576 | if Map.Difficulty == "Easy" then
TanyaType = "e7"
ReinforceCash = 5000
HoldAITime = DateTime.Minutes(3)
else
TanyaType = "e7.noautotarget"
ChangeStance = true
ReinforceCash = 2500
HoldAITime = DateTime.Minutes(2)
end
SpyType = { "spy" }
SpyEntryPath = { SpyEntry.Location, SpyLoadout.Location }
InsertionTransport = "lst"
TrukPath = { TrukWaypoint1, TrukWaypoint2, TrukWaypoint3, TrukWaypoint4, TrukWaypoint5, TrukWaypoint6 }
ExtractionHeliType = "tran"
ExtractionPath = { ExtractionEntry.Location, ExtractionLZ.Location }
GreeceReinforcements =
{
{ { "2tnk", "2tnk", "2tnk", "arty", "arty" }, { SpyEntry.Location, SpyLoadout.Location } },
{ { "e3", "e3", "e3", "e6", "e6" }, { SpyEntry.Location, GreeceLoadout1.Location } },
{ { "jeep", "jeep", "e1", "e1", "2tnk" }, { SpyEntry.Location, GreeceLoadout2.Location } }
}
DogPatrol = { Dog1, Dog2 }
PatrolA = { PatrolA1, PatrolA2, PatrolA3, PatrolA4, PatrolA5 }
PatrolB = { PatrolB1, PatrolB2, PatrolB3 }
DogPatrolPath = { DogPatrolRally1.Location, DogPatrolRally2.Location, DogPatrolRally3.Location }
PatrolAPath = { PatrolRally.Location, PatrolARally1.Location, PatrolARally2.Location, PatrolARally3.Location }
PatrolBPath = { PatrolBRally1.Location, PatrolBRally2.Location, PatrolBRally3.Location, PatrolRally.Location }
TanyaVoices = { "tuffguy", "bombit", "laugh", "gotit", "lefty", "keepem" }
SamSites = { Sam1, Sam2, Sam3, Sam4 }
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
Tick = function()
if FollowTruk then
TrukCamera.Teleport(Truk.Location)
Camera.Position = Truk.CenterPosition
end
if ussr.HasNoRequiredUnits() then
greece.MarkCompletedObjective(KillAll)
end
if GreeceReinforcementsArrived and greece.HasNoRequiredUnits() then
ussr.MarkCompletedObjective(ussrObj)
end
end
SendReinforcements = function()
GreeceReinforcementsArrived = true
Camera.Position = ReinforceCamera.CenterPosition
greece.Cash = greece.Cash + ReinforceCash
Utils.Do(GreeceReinforcements, function(reinforceTable)
Reinforcements.ReinforceWithTransport(greece, InsertionTransport, reinforceTable[1], reinforceTable[2], { SpyEntry.Location })
end)
Media.PlaySpeechNotification(greece, "AlliedReinforcementsArrived")
ActivateAI()
end
ExtractTanya = function()
if ExtractionHeli.IsDead or not ExtractionHeli.HasPassengers then
return
end
ExtractionHeli.Move(CPos.New(ExtractionPath[1].X, ExtractionHeli.Location.Y))
ExtractionHeli.Destroy()
Trigger.OnRemovedFromWorld(ExtractionHeli, function()
greece.MarkCompletedObjective(mainObj)
SendReinforcements()
PrisonCamera.Destroy()
end)
end
WarfactoryInfiltrated = function()
FollowTruk = true
TrukCamera = Actor.Create("camera.truk", true, { Owner = greece, Location = Truk.Location })
Truk.Wait(DateTime.Seconds(1))
Utils.Do(TrukPath, function(waypoint)
Truk.Move(waypoint.Location)
end)
Trigger.AfterDelay(DateTime.Seconds(2), function()
SpyCameraA.Destroy()
SpyCameraB.Destroy()
end)
end
MissInfiltrated = function()
CloakProvider.Destroy()
for i = 0, 5, 1 do
local sound = Utils.Random(TanyaVoices)
Trigger.AfterDelay(DateTime.Seconds(i), function()
Media.PlaySoundNotification(greece, sound)
end)
end
TanyasColt = Actor.Create("Colt", true, { Owner = greece, Location = Prison.Location + CVec.New(1, 6) })
Trigger.AfterDelay(DateTime.Seconds(6), FreeTanya)
end
FreeTanya = function()
TanyasColt.Destroy()
Tanya = Actor.Create(TanyaType, true, { Owner = greece, Location = Prison.Location + CVec.New(1, 1) })
Prison.Kill()
Tanya.Scatter()
if ChangeStance then
Tanya.Stance = "HoldFire"
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
Trigger.OnKilled(Tanya, function() ussr.MarkCompletedObjective(ussrObj) end)
KillSams = greece.AddPrimaryObjective("Destroy all four SAM Sites that block\nthe extraction helicopter.")
end
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)
SpyCameraA = Actor.Create("camera", true, { Owner = greece, Location = SpyCamera1.Location })
SpyCameraB = Actor.Create("camera", true, { Owner = greece, Location = SpyCamera2.Location })
end
ActivatePatrols = function()
GroupPatrol(DogPatrol, DogPatrolPath, DateTime.Seconds(2))
Trigger.AfterDelay(DateTime.Seconds(3), function()
GroupPatrol(PatrolA, PatrolAPath, DateTime.Seconds(7))
GroupPatrol(PatrolB, PatrolBPath, DateTime.Seconds(6))
end)
local units = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(self) return self.Owner == soviets and self.HasProperty("AutoTarget") end)
Utils.Do(units, function(unit)
unit.Stance = "Defend"
end)
end
InitTriggers = function()
Trigger.OnInfiltrated(Warfactory, function()
Trigger.ClearAll(Spy)
greece.MarkCompletedObjective(infWarfactory)
WarfactoryInfiltrated()
end)
Trigger.OnInfiltrated(Prison, function()
Trigger.ClearAll(Spy)
Trigger.AfterDelay(DateTime.Seconds(2), MissInfiltrated)
end)
Trigger.OnEnteredFootprint({ TrukWaypoint5.Location }, function(a, id)
if a == Truk then
Trigger.RemoveFootprintTrigger(id)
CloakProvider = Actor.Create("CloakUpgrade", true, { Owner = greece, Location = Prison.Location })
Spy = Actor.Create("spy", true, { Owner = greece, Location = TrukWaypoint5.Location })
Spy.Move(SpyWaypoint.Location)
Spy.Move(Prison.Location, 3)
FollowTruk = false
TrukCamera.Destroy()
PrisonCamera = Actor.Create("camera", true, { Owner = greece, Location = TrukWaypoint5.Location })
Trigger.OnKilled(Spy, function() ussr.MarkCompletedObjective(ussrObj) end)
end
end)
Trigger.OnEnteredFootprint({ TrukWaypoint6.Location }, function(a, id)
if a == Truk then
Trigger.RemoveFootprintTrigger(id)
Truk.Stop()
Truk.Kill()
ExplosiveBarrel.Kill()
end
end)
Trigger.OnKilled(Mammoth, function()
Trigger.AfterDelay(HoldAITime - DateTime.Seconds(45), function() HoldProduction = false end)
Trigger.AfterDelay(HoldAITime, function() Attacking = true end)
end)
Trigger.OnKilled(FlameBarrel, function()
if not FlameTower.IsDead then
FlameTower.Kill()
end
end)
Trigger.OnKilled(SamBarrel, Sam1.Kill)
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]
Trigger.OnKilled(ExtractionHeli, function() ussr.MarkCompletedObjective(ussrObj) end)
Trigger.OnRemovedFromWorld(Tanya, ExtractTanya)
end)
end
InitObjectives = function()
Trigger.OnObjectiveAdded(greece, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective")
end)
ussrObj = ussr.AddPrimaryObjective("Deny the allies.")
mainObj = greece.AddPrimaryObjective("Rescue Tanya.")
KillAll = greece.AddPrimaryObjective("Eliminate all soviet units in this area.")
infWarfactory = greece.AddPrimaryObjective("Infiltrate the soviet warfactory")
Trigger.OnObjectiveCompleted(greece, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed")
end)
Trigger.OnObjectiveFailed(greece, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed")
end)
Trigger.OnPlayerLost(greece, function()
Media.PlaySpeechNotification(player, "Lose")
end)
Trigger.OnPlayerWon(greece, function()
Media.PlaySpeechNotification(player, "Win")
end)
end
WorldLoaded = function()
greece = Player.GetPlayer("Greece")
ussr = Player.GetPlayer("USSR")
InitObjectives()
InitTriggers()
SendSpy()
Trigger.AfterDelay(DateTime.Seconds(3), ActivatePatrols)
end
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Upper_Jeuno/npcs/Areebah.lua | 17 | 1314 | -----------------------------------
-- Area: Upper Jeuno
-- NPC: Areebah
-- Standard Merchant NPC
-----------------------------------
require("scripts/globals/shop");
package.loaded["scripts/zones/Upper_Jeuno/TextIDs"] = nil;
require("scripts/zones/Upper_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,AREEBAH_SHOP_DIALOG);
stock = {0x027C,119, --Chamomile
0x03B7,110, --Wijnruit
0x03B4,60, --Carnation
0x03AD,80, --Red Rose
0x03B5,96, --Rain Lily
0x03BC,120, --Lilac
0x03BD,120, --Amaryllis
0x03BE,120, --Marguerite
0x1199,520} --Flower Seeds
showShop(player, STATIC, stock);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
joev/SVUI-Temp | SVUI_UnitFrames/libs/oUF/elements/power.lua | 1 | 3865 | local parent, ns = ...
local oUF = ns.oUF
oUF.colors.power = {}
for power, color in next, PowerBarColor do
if(type(power) == 'string') then
oUF.colors.power[power] = {color.r, color.g, color.b}
end
end
local GetDisplayPower = function(power, unit)
if not unit then return; end
local _, _, _, _, _, _, showOnRaid = UnitAlternatePowerInfo(unit)
if(power.displayAltPower and showOnRaid) then
return ALTERNATE_POWER_INDEX
else
return (UnitPowerType(unit))
end
end
local Update = function(self, event, unit)
if(self.unit ~= unit) or not unit then return end
local power = self.Power
if(power.PreUpdate) then power:PreUpdate(unit) end
local displayType = GetDisplayPower(power, unit);
local min = UnitPower(unit, displayType);
local max = UnitPowerMax(unit, displayType);
local disconnected = not UnitIsConnected(unit)
if max == 0 then
max = 1
end
power:SetMinMaxValues(0, max)
if(disconnected) then
power:SetValue(max)
else
power:SetValue(min)
end
power.disconnected = disconnected
if power.frequentUpdates ~= power.__frequentUpdates then
power.__frequentUpdates = power.frequentUpdates
end
local r, g, b, t
if(power.colorTapping and not UnitPlayerControlled(unit) and UnitIsTapDenied(unit)) then
t = self.colors.tapped
elseif(power.colorDisconnected and not UnitIsConnected(unit)) then
t = self.colors.disconnected
elseif(power.colorPower) then
local ptype, ptoken, altR, altG, altB = UnitPowerType(unit)
t = self.colors.power[ptoken]
if(not t and altR) then
r, g, b = altR, altG, altB
end
elseif(power.colorClass and UnitIsPlayer(unit)) or
(power.colorClassNPC and not UnitIsPlayer(unit)) or
(power.colorClassPet and UnitPlayerControlled(unit) and not UnitIsPlayer(unit)) then
local _, class = UnitClass(unit)
t = self.colors.class[class]
elseif(power.colorReaction and UnitReaction(unit, 'player')) then
t = self.colors.reaction[UnitReaction(unit, "player")]
elseif(power.colorSmooth) then
r, g, b = self.ColorGradient(min, max, unpack(power.smoothGradient or self.colors.smooth))
end
if(t) then
r, g, b = t[1], t[2], t[3]
end
if(b) then
power:SetStatusBarColor(r, g, b)
local bg = power.bg
if(bg) then
local mu = bg.multiplier or 1
bg:SetVertexColor(r * mu, g * mu, b * mu)
end
end
if(power.PostUpdate) then
return power:PostUpdate(unit, min, max)
end
end
local Path = function(self, ...)
return (self.Power.Override or Update) (self, ...)
end
local ForceUpdate = function(element)
return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local Enable = function(self, unit)
local power = self.Power
if(power) then
power.__owner = self
power.ForceUpdate = ForceUpdate
power.__frequentUpdates = power.frequentUpdates
self:RegisterEvent('UNIT_POWER_BAR_SHOW', Path)
self:RegisterEvent('UNIT_POWER_BAR_HIDE', Path)
self:RegisterEvent('UNIT_DISPLAYPOWER', Path)
self:RegisterEvent('UNIT_CONNECTION', Path)
self:RegisterEvent('UNIT_FACTION', Path)
self:RegisterEvent('UNIT_MAXPOWER', Path)
self:RegisterEvent('UNIT_POWER', Path)
self:RegisterUnitEvent("UNIT_POWER", unit);
self:RegisterUnitEvent("UNIT_MAXPOWER", unit);
if(power:IsObjectType'StatusBar' and not power:GetStatusBarTexture()) then
power:SetStatusBarTexture[[Interface\TargetingFrame\UI-StatusBar]]
end
return true
end
end
local Disable = function(self)
local power = self.Power
if(power) then
self:UnregisterEvent('UNIT_POWER_FREQUENT', Path)
self:UnregisterEvent('UNIT_POWER', Path)
self:UnregisterEvent('UNIT_POWER_BAR_SHOW', Path)
self:UnregisterEvent('UNIT_POWER_BAR_HIDE', Path)
self:UnregisterEvent('UNIT_DISPLAYPOWER', Path)
self:UnregisterEvent('UNIT_CONNECTION', Path)
self:UnregisterEvent('UNIT_MAXPOWER', Path)
self:UnregisterEvent('UNIT_FACTION', Path)
end
end
oUF:AddElement('Power', Path, Enable, Disable)
| mit |
dr01d3r/darkstar | scripts/zones/Southern_San_dOria_[S]/npcs/Nembet.lua | 14 | 1024 | -----------------------------------
-- Area: Southern SandOria [S]
-- NPC: Nembet
-- @zone 80
-- @pos 147 -3 110
-----------------------------------
package.loaded["scripts/zones/Southern_San_dOria_[S]/TextIDs"] = nil;
require("scripts/zones/Southern_San_dOria_[S]/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc, ITEM_DELIVERY_DIALOG);
player:openSendBox();
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
shillcock/lmk | scripts/src/obj.lua | 2 | 5343 | require "lmkbuild"
local append = lmkbuild.append_local
local exec = lmkbuild.exec
local file_newer = lmkbuild.file_newer
local function gset (name, value)
lmkbuild.set_global (name, value, true)
end
local lset = lmk.set_local
local get_var = lmkbuild.get_var
local ipairs = ipairs
local is_valid = lmkbuild.is_valid
local print = print
local resolve = lmkbuild.resolve
local rm = lmkbuild.rm
local set = lmkbuild.set_local
local sys = lmkbuild.system ()
local table = table
if sys == "win32" then
gset ("lmk.link", {
"$(lmk.$(type).linker.$(lmk.buildMode))",
"$(lmk.$(type).linkerFlags)",
"$(lmk.$(lmk.buildMode).linkerFlags)",
"$(localLibPaths)",
"$(lmk.libPaths)",
"$(localLibs)",
"$(objList)",
"$(lmk.$(type).extraFiles)",
"/out:$(localBinTarget)",
})
gset ("lmk.libPathFlag", "/LIBPATH:")
gset ("lmk.libSuffix", ".lib")
gset ("lmk.shared.prefix", "")
gset ("lmk.shared.ext", ".dll")
gset ("lmk.plugin.ext", ".dll")
gset ("lmk.exe.ext", ".exe")
local linker = "link.exe"
local bclinker = "nmlink.exe bcinterf.lib"
gset ("lmk.exe.linker.opt", linker)
gset ("lmk.exe.linker.debug", linker)
gset ("lmk.exe.linker.bc", bclinker)
gset ("lmk.exe.linkerFlags", "/nologo")
gset ("lmk.shared.linker.opt", linker)
gset ("lmk.shared.linker.debug", linker)
gset ("lmk.shared.linker.bc", bclinker)
gset ("lmk.shared.linkerFlags", "/nologo /DLL")
gset ("lmk.shared.extraFiles", "/IMPLIB:$(lmk.libDir)$(name)$(lmk.libSuffix)")
gset ("lmk.plugin.linker.opt", linker)
gset ("lmk.plugin.linker.debug", linker)
gset ("lmk.plugin.linker.bc", bclinker)
gset ("lmk.plugin.linkerFlags", "/nologo /DLL")
gset ("lmk.debug.linkerFlags", "/DEBUG /INCREMENTAL:no /FIXED:no")
gset ("lmk.bc.linkerFlags", "/DEBUG /INCREMENTAL:no /FIXED:no")
gset ("lmk.bc.testExec", "bc.exe /NOLOGO /W $(localPwd) ")
else -- unix
gset ("lmk.link", {
"$(lmk.$(type).linker)",
"$(lmk.$(type).linkerFlags)",
"$(localLibPaths)",
"$(lmk.libPaths)",
"$(localLibs)",
"$(objList)",
"-o $(localBinTarget)",
})
gset ("lmk.libPathFlag", "-L")
gset ("lmk.libPrefix", "-l")
gset ("lmk.shared.prefix", "lib")
gset ("lmk.shared.ext", ".so")
gset ("lmk.plugin.ext", ".plugin")
if sys == "macos" then
local linker = "g++ -m32 -header_pad_max_install_names"
--if is_valid ("/usr/bin/llvm-g++") then linker = "llvm-" .. linker end
local outFlag = "-o "
gset ("lmk.exe.linker", linker)
gset ("lmk.shared.linker", linker)
gset (
"lmk.shared.linkerFlags",
"-dynamiclib " ..
"-install_name @executable_path/../Frameworks/$(localBinName)")
gset ("lmk.shared.ext", ".dylib")
gset ("lmk.plugin.linker", linker)
gset ("lmk.plugin.linkerFlags", "-bundle")
elseif sys == "linux" then
local linker = "g++"
local outFlag = "-o "
gset ("lmk.exe.linker", linker)
gset ("lmk.shared.linker", linker)
gset (
"lmk.shared.linkerFlags",
"-shared -Xlinker -E -Xlinker -rpath-link -Xlinker $(lmk.binDir)")
gset ("lmk.plugin.linker", linker)
gset (
"lmk.plugin.linkerFlags",
"-shared -Xlinker -E -Xlinker -rpath-link -Xlinker $(lmk.binDir)")
gset (
"lmk.exe.linkerFlags",
"-Xlinker -rpath-link -Xlinker $(lmk.binDir)")
end
end
module (...)
function main (files)
local binName =
resolve ("$(lmk.$(type).prefix)$(name)$(lmk.$(type).ext)")
set ("localBinName", binName)
local binTarget =
resolve ("$(lmk.binDir)" .. binName)
set ("localBinTarget", binTarget)
local build = false
if not is_valid (binTarget) then build = true
else
local objFiles = {}
local tmpDir = resolve "$(localTmpDir)"
for index, item in ipairs (files) do
objFiles[index] = tmpDir .. item
end
if file_newer (objFiles, binTarget) then build = true end
end
if build then
if sys == "win32" then
append ("localLibPaths", "$(lmk.libPathFlag)$(localTmpDir)")
set ("objList", files)
else
local objList = {}
for ix, item in ipairs (files) do
objList[#objList + 1] = "$(localTmpDir)" .. item
end
set ("objList", objList)
end
local libs = get_var ("libs")
if libs then
local libList = {}
for index, item in ipairs (libs) do
libList[index] = "$(lmk.libPrefix)" .. item .. "$(lmk.libSuffix)"
end
append ("localLibs", libList)
end
exec ("$(lmk.link)")
if (sys == "win32") and is_valid (binTarget .. ".manifest") then
local mt = "mt.exe -nologo -manifest " .. binTarget ..
".manifest -outputresource:" .. binTarget .. ";"
if resolve ("$(type)") == "exe" then mt = mt .. "1" else mt = mt .. "2" end
exec (mt)
end
end
end
function test (files)
main (files)
local testDefined = resolve ("$(test)")
if testDefined ~= "" then exec ("$(lmk.$(lmk.buildMode).testExec)$(test)") end
end
function clobber (files)
local binTarget =
resolve ("$(lmk.binDir)$(lmk.$(type).prefix)$(name)$(lmk.$(type).ext)")
rm (binTarget)
-- will need to remove windows specific files here
end
| mit |
SalvationDevelopment/Salvation-Scripts-Production | c96148285.lua | 9 | 1373 | --誘発召喚
function c96148285.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetCondition(c96148285.condition)
e1:SetOperation(c96148285.activate)
c:RegisterEffect(e1)
end
function c96148285.condition(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(Card.IsControler,1,nil,1-tp)
end
function c96148285.filter(c,e,tp)
return c:IsLevelBelow(4) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c96148285.activate(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then
local g=Duel.GetMatchingGroup(c96148285.filter,tp,LOCATION_HAND,0,nil,e,tp)
if g:GetCount()>0 and Duel.SelectYesNo(tp,aux.Stringid(96148285,0)) then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tc=g:Select(tp,1,1,nil):GetFirst()
Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP)
end
end
if Duel.GetLocationCount(1-tp,LOCATION_MZONE,1-tp)>0 then
local g=Duel.GetMatchingGroup(c96148285.filter,1-tp,LOCATION_HAND,0,nil,e,1-tp)
if g:GetCount()>0 and Duel.SelectYesNo(1-tp,aux.Stringid(96148285,0)) then
Duel.Hint(HINT_SELECTMSG,1-tp,HINTMSG_SPSUMMON)
local tc=g:Select(1-tp,1,1,nil):GetFirst()
Duel.SpecialSummonStep(tc,0,1-tp,1-tp,false,false,POS_FACEUP)
end
end
Duel.SpecialSummonComplete()
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c53315891.lua | 2 | 4580 | --合神竜ティマイオス
function c53315891.initial_effect(c)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcCode3(c,80019195,85800949,84565800,true,true)
--spsummon condition
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
c:RegisterEffect(e1)
--special summon rule
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_SPSUMMON_PROC)
e2:SetProperty(EFFECT_FLAG_UNCOPYABLE)
e2:SetRange(LOCATION_EXTRA)
e2:SetCondition(c53315891.sprcon)
e2:SetOperation(c53315891.sprop)
c:RegisterEffect(e2)
--immune
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_IMMUNE_EFFECT)
e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e3:SetRange(LOCATION_MZONE)
e3:SetValue(c53315891.efilter)
c:RegisterEffect(e3)
--atk & def
local e4=Effect.CreateEffect(c)
e4:SetCategory(CATEGORY_ATKCHANGE+CATEGORY_DEFCHANGE)
e4:SetType(EFFECT_TYPE_QUICK_O)
e4:SetCode(EVENT_PRE_DAMAGE_CALCULATE)
e4:SetRange(LOCATION_MZONE)
e4:SetCondition(c53315891.atkcon)
e4:SetTarget(c53315891.atktg)
e4:SetOperation(c53315891.atkop)
c:RegisterEffect(e4)
--spsummon
local e5=Effect.CreateEffect(c)
e5:SetCategory(CATEGORY_SPECIAL_SUMMON)
e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e5:SetCode(EVENT_BATTLE_DESTROYED)
e5:SetTarget(c53315891.sptg)
e5:SetOperation(c53315891.spop)
c:RegisterEffect(e5)
end
function c53315891.sprfilter(c,code)
return c:IsFusionCode(code) and c:IsAbleToGraveAsCost()
end
function c53315891.sprcon(e,c)
if c==nil then return true end
local tp=c:GetControler()
return Duel.GetLocationCount(tp,LOCATION_MZONE)>-3
and Duel.IsExistingMatchingCard(c53315891.sprfilter,tp,LOCATION_ONFIELD,0,1,nil,80019195)
and Duel.IsExistingMatchingCard(c53315891.sprfilter,tp,LOCATION_ONFIELD,0,1,nil,85800949)
and Duel.IsExistingMatchingCard(c53315891.sprfilter,tp,LOCATION_ONFIELD,0,1,nil,84565800)
end
function c53315891.sprop(e,tp,eg,ep,ev,re,r,rp,c)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g1=Duel.SelectMatchingCard(tp,c53315891.sprfilter,tp,LOCATION_ONFIELD,0,1,1,nil,80019195)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g2=Duel.SelectMatchingCard(tp,c53315891.sprfilter,tp,LOCATION_ONFIELD,0,1,1,nil,85800949)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g3=Duel.SelectMatchingCard(tp,c53315891.sprfilter,tp,LOCATION_ONFIELD,0,1,1,nil,84565800)
g1:Merge(g2)
g1:Merge(g3)
Duel.SendtoGrave(g1,REASON_COST)
end
function c53315891.efilter(e,te)
return te:GetOwner()~=e:GetOwner()
end
function c53315891.atkcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c==Duel.GetAttacker() or c==Duel.GetAttackTarget()
end
function c53315891.atktg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then
local g=Duel.GetMatchingGroup(Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,c)
if g:GetCount()==0 then return false end
local g1,atk=g:GetMaxGroup(Card.GetAttack)
return c:GetAttack()~=atk and c:GetFlagEffect(53315891)==0
end
c:RegisterFlagEffect(53315891,RESET_CHAIN,0,1)
end
function c53315891.atkop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local g=Duel.GetMatchingGroup(Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,c)
if g:GetCount()==0 then return end
local g1,atk=g:GetMaxGroup(Card.GetAttack)
if c:IsRelateToEffect(e) and c:IsFaceup() and atk>0 then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SET_ATTACK_FINAL)
e1:SetReset(RESET_EVENT+0x1fe0000)
e1:SetValue(atk)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EFFECT_SET_DEFENSE_FINAL)
c:RegisterEffect(e2)
end
end
function c53315891.spfilter(c,e,tp)
return c:IsSetCard(0xa0) and c:IsCanBeSpecialSummoned(e,0,tp,true,true)
end
function c53315891.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return not Duel.IsPlayerAffectedByEffect(tp,59822133)
and Duel.GetLocationCount(tp,LOCATION_MZONE)>=3
and Duel.IsExistingMatchingCard(c53315891.spfilter,tp,0x13,0,3,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,3,tp,0x13)
end
function c53315891.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.IsPlayerAffectedByEffect(tp,59822133) then return end
if Duel.GetLocationCount(tp,LOCATION_MZONE)<3 then return end
local g=Duel.GetMatchingGroup(aux.NecroValleyFilter(c53315891.spfilter),tp,0x13,0,nil,e,tp)
if g:GetCount()>2 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=g:Select(tp,3,3,nil)
Duel.SpecialSummon(sg,0,tp,tp,true,true,POS_FACEUP)
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c464362.lua | 2 | 1849 | --デストーイ・シザー・タイガー
function c464362.initial_effect(c)
c:SetUniqueOnField(1,0,464362)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcCodeFunRep(c,30068120,aux.FilterBoolFunction(Card.IsFusionSetCard,0xa9),1,63,true,true)
--destroy
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_DESTROY)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
e2:SetCondition(c464362.descon)
e2:SetTarget(c464362.destg)
e2:SetOperation(c464362.desop)
c:RegisterEffect(e2)
--atk
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(EFFECT_UPDATE_ATTACK)
e3:SetRange(LOCATION_MZONE)
e3:SetTargetRange(LOCATION_MZONE,0)
e3:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0xad))
e3:SetValue(c464362.atkval)
c:RegisterEffect(e3)
end
function c464362.descon(e,tp,eg,ep,ev,re,r,rp)
return bit.band(e:GetHandler():GetSummonType(),SUMMON_TYPE_FUSION)==SUMMON_TYPE_FUSION
end
function c464362.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() end
if chk==0 then return Duel.IsExistingTarget(aux.TRUE,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) end
local ct=e:GetHandler():GetMaterialCount()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,aux.TRUE,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,ct,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
end
function c464362.desop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e)
Duel.Destroy(g,REASON_EFFECT)
end
function c464362.atkfilter(c)
return c:IsFaceup() and (c:IsSetCard(0xa9) or c:IsSetCard(0xad))
end
function c464362.atkval(e,c)
return Duel.GetMatchingGroupCount(c464362.atkfilter,c:GetControler(),LOCATION_MZONE,0,nil)*300
end
| gpl-2.0 |
waruqi/xmake | core/src/demo/xmake.lua | 1 | 1491 | -- add target
target("demo")
-- disable this target if only build libaries
if has_config("onlylib") then
set_default(false)
end
-- add deps
add_deps("xmake")
-- make as a binary
set_kind("binary")
-- add defines
add_defines("__tb_prefix__=\"xmake\"")
-- add includes directory
add_includedirs("$(projectdir)", "$(projectdir)/src")
-- add the common source files
add_files("**.c")
-- add the resource files (it will be enabled after publishing new version)
if is_plat("windows") then
add_files("*.rc")
end
-- add links
if is_plat("windows") then
add_links("ws2_32", "advapi32", "shell32")
add_ldflags("/export:malloc", "/export:free")
elseif is_plat("android") then
add_links("m", "c")
elseif is_plat("macosx") then
add_ldflags("-all_load", "-pagezero_size 10000", "-image_base 100000000")
elseif is_plat("mingw") then
add_ldflags("-static-libgcc", {force = true})
else
add_links("pthread", "dl", "m", "c")
end
-- enable xp compatibility mode
if is_plat("windows") then
if is_arch("x86") then
add_ldflags("/subsystem:console,5.01")
else
add_ldflags("/subsystem:console,5.02")
end
end
-- copy target to the build directory
after_build(function (target)
os.cp(target:targetfile(), "$(buildir)/xmake" .. (is_plat("windows") and ".exe" or ""))
end)
| apache-2.0 |
dr01d3r/darkstar | scripts/globals/items/steamed_catfish.lua | 12 | 1795 | -----------------------------------------
-- ID: 4557
-- Item: steamed_catfish
-- Food Effect: 180Min, All Races
-----------------------------------------
-- Health 30
-- Magic % 1 (cap 110)
-- Dex 3
-- Intelligence 1
-- Mind -3
-- Earth Res 10
-- Ranged Accuracy +6% (cap 15)
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,10800,4557);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 30);
target:addMod(MOD_FOOD_MPP, 1);
target:addMod(MOD_FOOD_MP_CAP, 110);
target:addMod(MOD_DEX, 3);
target:addMod(MOD_INT, 1);
target:addMod(MOD_MND, -3);
target:addMod(MOD_EARTHRES, 10);
target:addMod(MOD_FOOD_RACCP, 6);
target:addMod(MOD_FOOD_RACC_CAP, 15);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 30);
target:delMod(MOD_FOOD_MPP, 1);
target:delMod(MOD_FOOD_MP_CAP, 110);
target:delMod(MOD_DEX, 3);
target:delMod(MOD_INT, 1);
target:delMod(MOD_MND, -3);
target:delMod(MOD_EARTHRES, 10);
target:delMod(MOD_FOOD_RACCP, 6);
target:delMod(MOD_FOOD_RACC_CAP, 15);
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Xarcabard/mobs/Biast.lua | 12 | 1296 | -----------------------------------
-- Area: Xarcabard
-- NM: Biast
-- ID: 17235988
-----------------------------------
require("scripts/globals/status");
-----------------------------------
-----------------------------------
-- onMobInitialize
-----------------------------------
function onMobInitialize(mob)
mob:setMobMod(MOBMOD_ADD_EFFECT,mob:getShortID());
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
end;
-----------------------------------
-- onMobDespawn
-----------------------------------
function onMobDespawn(mob)
-- Set Biast's ToD
SetServerVariable("[POP]Biast", os.time(t) + 75600); -- 21 hour
DeterMob(mob:getID()-1, false);
GetMobByID(mob:getID()-1):setRespawnTime(GetMobRespawnTime(mob:getID()-1));
end;
-----------------------------------
-- onAdditionalEffect Action
-----------------------------------
function onAdditionalEffect(mob,target,damage)
if ((math.random(1,15) ~= 5) or (target:hasStatusEffect(EFFECT_TERROR) == true)) then
return 0,0,0;
else
local duration = 5;
target:addStatusEffect(EFFECT_TERROR,1,0,duration);
mob:resetEnmity(target);
return SUBEFFECT_NONE,0,EFFECT_TERROR;
end
end; | gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c15978426.lua | 5 | 1584 | --EMセカンドンキー
function c15978426.initial_effect(c)
--tograve
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(15978426,0))
e1:SetCategory(CATEGORY_TOGRAVE+CATEGORY_SEARCH+CATEGORY_TOHAND)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetTarget(c15978426.tgtg)
e1:SetOperation(c15978426.tgop)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e2)
end
function c15978426.filter(c,tohand)
return c:IsSetCard(0x9f) and not c:IsCode(15978426) and c:IsType(TYPE_MONSTER)
and (c:IsAbleToGrave() or (tohand and c:IsAbleToHand()))
end
function c15978426.tgtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local tohand=Duel.GetFieldCard(tp,LOCATION_SZONE,6) and Duel.GetFieldCard(tp,LOCATION_SZONE,7)
return Duel.IsExistingMatchingCard(c15978426.filter,tp,LOCATION_DECK,0,1,nil,tohand)
end
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK)
end
function c15978426.tgop(e,tp,eg,ep,ev,re,r,rp)
local tohand=Duel.GetFieldCard(tp,LOCATION_SZONE,6) and Duel.GetFieldCard(tp,LOCATION_SZONE,7)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,c15978426.filter,tp,LOCATION_DECK,0,1,1,nil,tohand)
local tc=g:GetFirst()
if not tc then return end
if tohand and tc:IsAbleToHand() and (not tc:IsAbleToGrave() or Duel.SelectYesNo(tp,aux.Stringid(15978426,1))) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,tc)
else
Duel.SendtoGrave(tc,REASON_EFFECT)
end
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/zones/Northern_San_dOria/npcs/Macuillie.lua | 11 | 2571 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Macuillie
-- Type: Guildworker's Union Representative
-- @zone 231
-- @pos -191.738 11.001 138.656
-----------------------------------
package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil;
require("scripts/globals/keyitems");
require("scripts/globals/crafting");
require("scripts/zones/Northern_San_dOria/TextIDs");
local keyitems = {
[0] = {
id = METAL_PURIFICATION,
rank = 3,
cost = 40000
},
[1] = {
id = METAL_ENSORCELLMENT,
rank = 3,
cost = 40000
},
[2] = {
id = CHAINWORK,
rank = 3,
cost = 10000
},
[3] = {
id = SHEETING,
rank = 3,
cost = 10000
},
[4] = {
id = WAY_OF_THE_BLACKSMITH,
rank = 9,
cost = 20000
}
};
local items = {
[2] = {
id = 15445,
rank = 3,
cost = 10000
},
[3] = {
id = 14831,
rank = 5,
cost = 70000
},
[4] = {
id = 14393,
rank = 7,
cost = 100000
},
[5] = {
id = 153,
rank = 9,
cost = 150000
},
[6] = {
id = 334,
rank = 9,
cost = 200000
},
[7] = {
id = 15820,
rank = 6,
cost = 80000
},
[8] = {
id = 3661,
rank = 7,
cost = 50000
},
[9] = {
id = 3324,
rank = 9,
cost = 15000
}
};
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
unionRepresentativeTrade(player, npc, trade, 0x02da, 2);
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
unionRepresentativeTrigger(player, 2, 0x02d9, "guild_smithing", keyitems);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option,target)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x02d9) then
unionRepresentativeTriggerFinish(player, option, target, 2, "guild_smithing", keyitems, items);
elseif (csid == 0x02da) then
player:messageSpecial(GP_OBTAINED, option);
end
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/La_Theine_Plateau/npcs/Faurbellant.lua | 14 | 1777 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Faurbellant
-- Type: Quest NPC
-- Involved in Quest: Gates of Paradise
-- @pos 484 24 -89 102
-----------------------------------
package.loaded["scripts/zones/La_Theine_Plateau/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/globals/keyitems");
require("scripts/zones/La_Theine_Plateau/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local gates = player:getQuestStatus(SANDORIA,GATES_TO_PARADISE);
if (gates == QUEST_COMPLETED) then
player:showText(npc, FAURBELLANT_4);
elseif (gates == QUEST_ACCEPTED) then
if (player:hasKeyItem(SCRIPTURE_OF_WIND) == true) then
player:showText(npc, FAURBELLANT_2, 0, SCRIPTURE_OF_WIND);
player:delKeyItem(SCRIPTURE_OF_WIND);
player:addKeyItem(SCRIPTURE_OF_WATER);
player:messageSpecial(KEYITEM_OBTAINED, SCRIPTURE_OF_WATER)
else
player:showText(npc, FAURBELLANT_3, SCRIPTURE_OF_WATER);
end;
else
player:showText(npc, FAURBELLANT_1);
end;
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Horlais_Peak/npcs/Hot_springs.lua | 9 | 1978 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Hot Springs
-- @zone 139
-- @pos 444 -37 -18
-----------------------------------
package.loaded["scripts/zones/Horlais_Peak/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/settings");
require("scripts/zones/Horlais_Peak/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(OUTLANDS,SECRET_OF_THE_DAMP_SCROLL) == QUEST_ACCEPTED and trade:hasItemQty(1210,1) and trade:getItemCount() == 1) then
player:startEvent(0x0002,1210);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getQuestStatus(SANDORIA,THE_GENERAL_S_SECRET) == 1) and (player:hasKeyItem(CURILLAS_BOTTLE_EMPTY) == true) then
player:addKeyItem(CURILLAS_BOTTLE_FULL)
player:messageSpecial(KEYITEM_OBTAINED,CURILLAS_BOTTLE_FULL);
player:delKeyItem(CURILLAS_BOTTLE_EMPTY);
else
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0002) then
player:tradeComplete();
player:addItem(4949); -- Scroll of Jubaku: Ichi
player:messageSpecial(ITEM_OBTAINED, 4949);
player:addFame(NORG,75);
player:addTitle(CRACKER_OF_THE_SECRET_CODE);
player:completeQuest(OUTLANDS,SECRET_OF_THE_DAMP_SCROLL);
end
end; | gpl-3.0 |
waruqi/xmake | xmake/core/tool/compiler.lua | 1 | 10659 | --!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 compiler.lua
--
-- define module
local compiler = compiler or {}
-- load modules
local io = require("base/io")
local path = require("base/path")
local utils = require("base/utils")
local table = require("base/table")
local string = require("base/string")
local option = require("base/option")
local tool = require("tool/tool")
local builder = require("tool/builder")
local config = require("project/config")
local sandbox = require("sandbox/sandbox")
local language = require("language/language")
local platform = require("platform/platform")
-- get the language of compiler
function compiler:_language()
return self._LANGUAGE
end
-- add flags from the toolchains
function compiler:_add_flags_from_toolchains(flags, targetkind, target)
-- add flags for platform with the given target kind, e.g. binary.gcc.cxflags or binary.cxflags
if targetkind then
local toolname = self:name()
if target and target:type() == "target" then
for _, flagkind in ipairs(self:_flagkinds()) do
local toolflags = target:toolconfig(targetkind .. '.' .. toolname .. '.' .. flagkind)
table.join2(flags, toolflags or target:toolconfig(targetkind .. '.' .. flagkind))
end
else
for _, flagkind in ipairs(self:_flagkinds()) do
local toolflags = platform.toolconfig(targetkind .. '.' .. toolname .. '.' .. flagkind)
table.join2(flags, toolflags or platform.toolconfig(targetkind .. '.' .. flagkind))
end
end
end
end
-- add flags from the compiler
function compiler:_add_flags_from_compiler(flags, targetkind)
for _, flagkind in ipairs(self:_flagkinds()) do
-- add compiler, e.g. cxflags
table.join2(flags, self:get(flagkind))
-- add compiler, e.g. targetkind.cxflags
if targetkind then
table.join2(flags, self:get(targetkind .. '.' .. flagkind))
end
end
end
-- load compiler tool
function compiler._load_tool(sourcekind, target)
-- get program from target
local program, toolname, toolchain_info
if target and target:type() == "target" then
program, toolname, toolchain_info = target:tool(sourcekind)
end
-- load the compiler tool from the source kind
local result, errors = tool.load(sourcekind, {program = program, toolname = toolname, toolchain_info = toolchain_info})
if not result then
return nil, errors
end
-- done
return result, program
end
-- load the compiler from the given source kind
function compiler.load(sourcekind, target)
-- load compiler tool first (with cache)
local compiler_tool, program_or_errors = compiler._load_tool(sourcekind, target)
if not compiler_tool then
return nil, program_or_errors
end
-- init cache key
local cachekey = sourcekind .. (program_or_errors or "") .. (config.get("arch") or os.arch())
-- get it directly from cache dirst
compiler._INSTANCES = compiler._INSTANCES or {}
if compiler._INSTANCES[cachekey] then
return compiler._INSTANCES[cachekey]
end
-- new instance
local instance = table.inherit(compiler, builder)
-- save the compiler tool
instance._TOOL = compiler_tool
-- load the compiler language from the source kind
local result, errors = language.load_sk(sourcekind)
if not result then
return nil, errors
end
instance._LANGUAGE = result
-- init target kind
instance._TARGETKIND = "object"
-- init name flags
instance._NAMEFLAGS = result:nameflags()[instance:_targetkind()]
-- init flag kinds
instance._FLAGKINDS = table.wrap(result:sourceflags()[sourcekind])
-- save this instance
compiler._INSTANCES[cachekey] = instance
-- add toolchains flags to the compiler tool, e.g. gcc.cxflags or cxflags
local toolname = compiler_tool:name()
if target and target:type() == "target" then
for _, flagkind in ipairs(instance:_flagkinds()) do
compiler_tool:add(flagkind, target:toolconfig(toolname .. '.' .. flagkind) or target:toolconfig(flagkind))
end
else
for _, flagkind in ipairs(instance:_flagkinds()) do
compiler_tool:add(flagkind, platform.toolconfig(toolname .. '.' .. flagkind) or platform.toolconfig(flagkind))
end
end
return instance
end
-- build the source files (compile and link)
function compiler:build(sourcefiles, targetfile, opt)
-- init options
opt = opt or {}
-- get compile flags
local compflags = opt.compflags
if not compflags then
-- patch sourcefile to get flags of the given source file
if type(sourcefiles) == "string" then
opt.sourcefile = sourcefiles
end
compflags = self:compflags(opt)
end
-- make flags
local flags = compflags
if opt.target then
flags = table.join(flags, opt.target:linkflags())
end
-- get target kind
local targetkind = opt.targetkind
if not targetkind and opt.target and opt.target.targetkind then
targetkind = opt.target:targetkind()
end
-- get it
return sandbox.load(self:_tool().build, self:_tool(), sourcefiles, targetkind or "binary", targetfile, flags)
end
-- get the build arguments list (compile and link)
function compiler:buildargv(sourcefiles, targetfile, opt)
-- init options
opt = opt or {}
-- get compile flags
local compflags = opt.compflags
if not compflags then
-- patch sourcefile to get flags of the given source file
if type(sourcefiles) == "string" then
opt.sourcefile = sourcefiles
end
compflags = self:compflags(opt)
end
-- make flags
local flags = compflags
if opt.target then
flags = table.join(flags, opt.target:linkflags())
end
-- get target kind
local targetkind = opt.targetkind
if not targetkind and opt.target and opt.target.targetkind then
targetkind = opt.target:targetkind()
end
-- get it
return self:_tool():buildargv(sourcefiles, targetkind or "binary", targetfile, flags)
end
-- get the build command
function compiler:buildcmd(sourcefiles, targetfile, opt)
return os.args(table.join(self:buildargv(sourcefiles, targetfile, opt)))
end
-- compile the source files
function compiler:compile(sourcefiles, objectfile, opt)
-- init options
opt = opt or {}
-- get compile flags
local compflags = opt.compflags
if not compflags then
-- patch sourcefile to get flags of the given source file
if type(sourcefiles) == "string" then
opt.sourcefile = sourcefiles
end
compflags = self:compflags(opt)
end
-- compile it
return sandbox.load(self:_tool().compile, self:_tool(), sourcefiles, objectfile, opt.dependinfo, compflags, opt)
end
-- get the compile arguments list
function compiler:compargv(sourcefiles, objectfile, opt)
-- init options
opt = opt or {}
-- get compile flags
local compflags = opt.compflags
if not compflags then
-- patch sourcefile to get flags of the given source file
if type(sourcefiles) == "string" then
opt.sourcefile = sourcefiles
end
compflags = self:compflags(opt)
end
return self:_tool():compargv(sourcefiles, objectfile, compflags, opt)
end
-- get the compile command
function compiler:compcmd(sourcefiles, objectfile, opt)
return os.args(table.join(self:compargv(sourcefiles, objectfile, opt)))
end
-- add flags from the sourcefile config
function builder:_add_flags_from_fileconfig(flags, target, sourcefile, fileconfig)
-- add flags from the current compiler
local add_sourceflags = self:_tool().add_sourceflags
if add_sourceflags then
local flag = add_sourceflags(self:_tool(), sourcefile, fileconfig, target, self:_targetkind())
if flag and flag ~= "" then
table.join2(flags, flag)
end
end
-- add flags from the common argument option
self:_add_flags_from_argument(flags, target, fileconfig)
end
-- get the compling flags
--
-- @param opt the argument options (contain all the compiler attributes of target),
-- e.g.
-- {target = ..., targetkind = "static", configs = {defines = "", cxflags = "", includedirs = ""}}
--
-- @return flags string, flags list
--
function compiler:compflags(opt)
-- init options
opt = opt or {}
-- get target
local target = opt.target
-- get target kind
local targetkind = opt.targetkind
if not targetkind and target and target.targetkind then
targetkind = target:targetkind()
end
-- add flags from compiler/toolchains
--
-- we need to add toolchain flags at the beginning to allow users to override them.
-- but includedirs/links/syslinks/linkdirs will still be placed last, they are in the order defined in languages/xmake.lua
--
-- @see https://github.com/xmake-io/xmake/issues/978
--
local flags = {}
self:_add_flags_from_compiler(flags, targetkind)
self:_add_flags_from_toolchains(flags, targetkind, target)
-- add flags from user configuration
self:_add_flags_from_config(flags)
-- add flags from target
self:_add_flags_from_target(flags, target)
-- add flags from source file configuration
if opt.sourcefile and target and target.fileconfig then
local fileconfig = target:fileconfig(opt.sourcefile)
if fileconfig then
self:_add_flags_from_fileconfig(flags, target, opt.sourcefile, fileconfig)
end
end
-- add flags from argument
local configs = opt.configs or opt.config
if configs then
self:_add_flags_from_argument(flags, target, configs)
end
-- preprocess flags
return self:_preprocess_flags(flags)
end
-- return module
return compiler
| apache-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c95362816.lua | 9 | 1167 | --E・HERO レディ・オブ・ファイア
function c95362816.initial_effect(c)
--damage
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(95362816,0))
e1:SetCategory(CATEGORY_DAMAGE)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetCode(EVENT_PHASE+PHASE_END)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1)
e1:SetCondition(c95362816.condition)
e1:SetTarget(c95362816.target)
e1:SetOperation(c95362816.operation)
c:RegisterEffect(e1)
end
function c95362816.condition(e,tp,eg,ep,ev,re,r,rp)
return tp==Duel.GetTurnPlayer()
end
function c95362816.filter(c)
return c:IsFaceup() and c:IsSetCard(0x3008)
end
function c95362816.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local ct=Duel.GetMatchingGroupCount(c95362816.filter,tp,LOCATION_MZONE,0,nil)
Duel.SetTargetPlayer(1-tp)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,ct*200)
end
function c95362816.operation(e,tp,eg,ep,ev,re,r,rp)
local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER)
local ct=Duel.GetMatchingGroupCount(c95362816.filter,tp,LOCATION_MZONE,0,nil)
Duel.Damage(p,ct*200,REASON_EFFECT)
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c30435145.lua | 5 | 1816 | --古代の機械工場
function c30435145.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(c30435145.target)
e1:SetOperation(c30435145.operation)
c:RegisterEffect(e1)
end
function c30435145.filter(c,g)
return c:GetLevel()>4 and c:IsSetCard(0x7) and g:CheckWithSumEqual(Card.GetLevel,c:GetLevel()*2,1,99)
end
function c30435145.rfilter(c)
return c:GetLevel()>0 and c:IsSetCard(0x7) and c:IsAbleToRemove()
end
function c30435145.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local rg=Duel.GetMatchingGroup(c30435145.rfilter,tp,LOCATION_GRAVE,0,nil)
return Duel.IsExistingMatchingCard(c30435145.filter,tp,LOCATION_HAND,0,1,nil,rg)
end
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,LOCATION_GRAVE)
end
function c30435145.operation(e,tp,eg,ep,ev,re,r,rp)
local rg=Duel.GetMatchingGroup(c30435145.rfilter,tp,LOCATION_GRAVE,0,nil)
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(30435145,1))
local g=Duel.SelectMatchingCard(tp,c30435145.filter,tp,LOCATION_HAND,0,1,1,nil,rg)
local tc=g:GetFirst()
if tc then
Duel.ConfirmCards(1-tp,tc)
Duel.ShuffleHand(tp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local sg=rg:SelectWithSumEqual(tp,Card.GetLevel,tc:GetLevel()*2,1,99)
Duel.Remove(sg,POS_FACEUP,REASON_EFFECT)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetDescription(aux.Stringid(30435145,0))
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SUMMON_PROC)
e1:SetCondition(c30435145.ntcon)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
end
end
function c30435145.ntcon(e,c,minc)
if c==nil then return true end
return minc==0 and c:GetLevel()>4 and Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0
end
| gpl-2.0 |
diogo24/gamecode4 | Extra/UtilityDemo/utility.lua | 44 | 7963 | -- Utility.lua
-- A simple utility game
-- A "better" random seed. This was taken from http://lua-users.org/wiki/MathLibraryTutorial
math.randomseed(tonumber(tostring(os.time()):reverse():sub(1,6)))
-----------------------------------------------------------------------------------------------------------------------
-- Actor
-----------------------------------------------------------------------------------------------------------------------
Actor = class(nil,
{
_name = "<unnamed>",
_hp = 100,
_mp = 3,
_minDamage = nil, -- must be overridden
_maxDamage = nil, -- must be overridden
_minHeal = 20,
_maxHeal = 45,
});
function Actor:DoAction(action, opponent)
if (action == "attack") then
local dead = self:_Attack(opponent);
return dead;
elseif (action == "run") then
local success = self:_Run();
return success;
elseif (action == "heal") then
self:_Heal();
return false;
else
print("Unknown action: " .. action);
return false;
end
end
function Actor:PrintStatus()
print(self._name .. "; hp = " .. self._hp .. "; mp = " .. self._mp);
end
function Actor:Hit(damage)
self._hp = self._hp - damage;
if (self._hp < 0) then
print(self._name .. " is dead!");
return true;
end
return false;
end
function Actor:GetHp()
return self._hp;
end
function Actor:GetMp()
return self._mp;
end
function Actor:GetMinDamage()
return self._minDamage;
end
function Actor:GetMaxDamage()
return self._maxDamage;
end
function Actor:GetMinHeal()
return self._minHeal;
end
function Actor:GetMaxHeal()
return self._maxHeal;
end
function Actor:_Attack(opponent)
assert(self._minDamage ~= nil and self._maxDamage ~= nil);
local damage = math.random(self._minDamage, self._maxDamage);
print(self._name .. " struck for " .. damage .. " damage");
return opponent:Hit(damage);
end
function Actor:_Run()
if (math.random() > 0.5) then
print(self._name .. " ran away!");
return true;
else
print(self._name .. " failed to run away!");
return false;
end
end
function Actor:_Heal()
if (self._mp > 0) then
local healAmount = math.random(self._minHeal, self._maxHeal);
print(self._name .. " healed " .. healAmount .. " hp.");
self._hp = self._hp + healAmount;
self._mp = self._mp - 1;
else
print(self._name .. " attempted to heal but had no MP left");
end
end
-----------------------------------------------------------------------------------------------------------------------
-- Teapot
-----------------------------------------------------------------------------------------------------------------------
Teapot = class(Actor,
{
_name = "Teapot",
_minDamage = 10,
_maxDamage = 20,
_mp = 5, -- teapots are more magical
_actions = { "attack", "heal", "run" };
});
function Teapot:Decide(opponent)
local bestUtility = 0;
local bestAction = nil;
for i, action in ipairs(self._actions) do
-- build the world state
local tempWorldState = WorldState:Create();
tempWorldState:Build(self, opponent);
-- apply the action
tempWorldState:ApplyAction(action, self, opponent);
-- grab the utility
local utility = tempWorldState:GetUtility();
if (utility > bestUtility) then
bestUtility = utility;
bestAction = action;
end
print("\tScoring action '" .. action .. "': utility = " .. utility);
end
print("\tChose " .. bestAction);
return bestAction;
end
-- This is the world state object used by the teapot
WorldState = class(nil,
{
opponentHp = nil,
opponentMp = nil,
survivalChance = nil, -- the chance that we won't die next attack, from 0 - 1
});
function WorldState:Build(teapot, opponent)
self.opponentHp = opponent:GetHp();
self.opponentMp = opponent:GetMp();
self.survivalChance = self:_CalculateSurvivalChance(teapot:GetHp(), opponent);
self.killChance = 1 - self:_CalculateSurvivalChance(opponent:GetHp(), teapot);
end
function WorldState:ApplyAction(action, teapot, opponent)
if (action == "attack") then
local averageDamage = ((teapot:GetMaxDamage() - teapot:GetMinDamage()) / 2) + teapot:GetMinDamage();
self.opponentHp = self.opponentHp - averageDamage;
self.killChance = 1 - self:_CalculateSurvivalChance(self.opponentHp, teapot);
elseif (action == "run") then
self.survivalChance = 0.5;
elseif (action == "heal") then
if (teapot:GetMp() > 0) then
local averageHeal = ((teapot:GetMaxHeal() - teapot:GetMinHeal()) / 2) + teapot:GetMinHeal();
local newHp = teapot:GetHp() + averageHeal;
self.survivalChance = self:_CalculateSurvivalChance(newHp, opponent);
end
else
print("Unknown action: " .. action);
return false;
end
end
function WorldState:GetUtility()
local lifeScore = 100 * self.survivalChance; -- a state in which we're alive grants 100 points, modified by the chance that we might survive
local attackScore = 100 - self.opponentHp; -- a state in which the opponent is hurt is always good; teapot will get more aggressive as player is hurt
attackScore = attackScore + (attackScore * self.killChance); -- adjust the attack score by up to double if the opponent is within a turn of death
return lifeScore + attackScore;
end
function WorldState:_CalculateSurvivalChance(defenderHp, attacker)
if (defenderHp > attacker:GetMaxDamage()) then
return 1;
elseif (defenderHp <= attacker:GetMinDamage()) then
return 0;
else
local range = attacker:GetMaxDamage() - attacker:GetMinDamage();
local percentage = (defenderHp - attacker:GetMinDamage()) / range;
return percentage;
end
end
-----------------------------------------------------------------------------------------------------------------------
-- Player
-----------------------------------------------------------------------------------------------------------------------
Player = class(Actor,
{
_name = "Player",
_minDamage = 15,
_maxDamage = 30,
});
-----------------------------------------------------------------------------------------------------------------------
-- Game class
-----------------------------------------------------------------------------------------------------------------------
Game = class(nil,
{
_player = nil,
_teapot = nil,
});
function Game:Start()
self._player = Player:Create();
self._teapot = Teapot:Create();
print("A Teapot draws near! Command?");
print("1) Attack");
print("2) Run");
print("3) Heal");
print("4) Status");
print("Q to quit");
end
function Game:Update(action)
-- player runs action
local gameOver = self._player:DoAction(action, self._teapot);
-- check for game end
if (gameOver) then
self:_Reset();
return;
end
-- teapot action
action = self._teapot:Decide(self._player);
gameOver = self._teapot:DoAction(action, self._player);
-- check for game end
if (gameOver) then
self:_Reset();
return;
end
self:ShowStatus();
end
function Game:ShowStatus()
self._player:PrintStatus();
self._teapot:PrintStatus();
end
function Game:_Reset()
print("Game over!\n\n");
self:Start();
end
-----------------------------------------------------------------------------------------------------------------------
-- Global game object
-----------------------------------------------------------------------------------------------------------------------
g_game = Game:Create();
g_game:Start();
-----------------------------------------------------------------------------------------------------------------------
-- Player commands
-----------------------------------------------------------------------------------------------------------------------
function Attack()
g_game:Update("attack");
end
function Run()
g_game:Update("run");
end
function Heal()
g_game:Update("heal");
end
function Status()
g_game:ShowStatus();
end
| lgpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c31247589.lua | 2 | 1854 | --剣闘獣ディカエリィ
function c31247589.initial_effect(c)
--double attack
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_EXTRA_ATTACK)
e1:SetCondition(c31247589.dacon)
e1:SetValue(1)
c:RegisterEffect(e1)
--special summon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(31247589,0))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_PHASE+PHASE_BATTLE)
e2:SetRange(LOCATION_MZONE)
e2:SetCondition(c31247589.spcon)
e2:SetCost(c31247589.spcost)
e2:SetTarget(c31247589.sptg)
e2:SetOperation(c31247589.spop)
c:RegisterEffect(e2)
end
function c31247589.dacon(e)
return e:GetHandler():GetFlagEffect(31247589)>0
end
function c31247589.spcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():GetBattledGroupCount()>0
end
function c31247589.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:IsAbleToDeckAsCost() end
Duel.SendtoDeck(c,nil,2,REASON_COST)
end
function c31247589.filter(c,e,tp)
return not c:IsCode(31247589) and c:IsSetCard(0x19) and c:IsCanBeSpecialSummoned(e,107,tp,false,false)
end
function c31247589.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1
and Duel.IsExistingMatchingCard(c31247589.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,0,LOCATION_DECK)
end
function c31247589.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c31247589.filter,tp,LOCATION_DECK,0,1,1,nil,e,tp)
local tc=g:GetFirst()
if tc then
Duel.SpecialSummon(tc,107,tp,tp,false,false,POS_FACEUP)
tc:RegisterFlagEffect(tc:GetOriginalCode(),RESET_EVENT+0x1ff0000,0,0)
end
end
| gpl-2.0 |
finnw/grodlob | winapi/debug.lua | 1 | 1426 | --core/debug: strict mode and some debug tools. entirely optional module.
setfenv(1, require'winapi.namespace')
require'glue'
--disable stdout buffering so we can print-debug stuff
io.stdout:setvbuf'no'
--set strict mode for the whole winapi namespace
local _G = _G
local declared = {}
function _M:__index(k)
if declared[k] then return nil end
if _G[k] ~= nil then return _G[k] end
error('Undefined winapi global %s' % k, 2)
end
function _M:__newindex(k,v)
local w = debug.getinfo(2, 'S').what
if w == 'main' or w == 'C' or declared[k] then
declared[k] = true
rawset(self, k, v)
else
error('Assignment to undeclared winapi global %s' % k, 2)
end
end
--utility to search the name of a constant in the winapi namespace
function findname(prefix, value)
for k,v in pairs(_M) do
if k:match('^'..prefix) and type(v) ~= 'cdata' and type(value) ~= 'cdata' and v == value then return k end
end
return tonumber(value) ~= nil and '%x' % value or value
end
--print that can be used in expressions and recurses into tables
_print = print
local function __print(indent,...)
if indent ~= '' then _print(indent,...) else _print(...) end
for i=1,select('#',...) do
local t = select(i,...)
if type(t) == 'table' and (not getmetatable(t) or not getmetatable(t).__tostring) then
for k,v in pairs(t) do __print(indent..' ',k,v) end
end
end
return ...
end
function print(...) return __print('',...) end
| mit |
SalvationDevelopment/Salvation-Scripts-Production | c28355718.lua | 2 | 2201 | --D-HERO ダブルガイ
function c28355718.initial_effect(c)
--cannot special summon
local e1=Effect.CreateEffect(c)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
c:RegisterEffect(e1)
--multiattack
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_EXTRA_ATTACK)
e2:SetValue(1)
c:RegisterEffect(e2)
--token
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e3:SetCode(EVENT_TO_GRAVE)
e3:SetOperation(c28355718.regop)
c:RegisterEffect(e3)
end
function c28355718.regop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsReason(REASON_DESTROY) then
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(28355718,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_TOKEN)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetRange(LOCATION_GRAVE)
e1:SetCountLimit(1)
e1:SetCode(EVENT_PHASE+PHASE_STANDBY)
e1:SetCondition(c28355718.spcon)
e1:SetTarget(c28355718.sptg)
e1:SetOperation(c28355718.spop)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN,1)
c:RegisterEffect(e1)
end
end
function c28355718.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==tp
end
function c28355718.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return not Duel.IsPlayerAffectedByEffect(tp,59822133)
and Duel.GetLocationCount(tp,LOCATION_MZONE)>1
and Duel.IsPlayerCanSpecialSummonMonster(tp,28355719,0,0x4011,1000,1000,4,RACE_WARRIOR,ATTRIBUTE_DARK) end
Duel.SetOperationInfo(0,CATEGORY_TOKEN,nil,2,0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,2,0,0)
end
function c28355718.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.IsPlayerAffectedByEffect(tp,59822133) then return end
if Duel.GetLocationCount(tp,LOCATION_MZONE)<2 then return end
if not Duel.IsPlayerCanSpecialSummonMonster(tp,28355719,0,0x4011,1000,1000,4,RACE_WARRIOR,ATTRIBUTE_DARK) then return end
for i=1,2 do
local token=Duel.CreateToken(tp,28355719)
Duel.SpecialSummonStep(token,0,tp,tp,false,false,POS_FACEUP)
end
Duel.SpecialSummonComplete()
end
| gpl-2.0 |
Herve-M/OpenRA | mods/ra/maps/soviet-soldier-volkov-n-chitzkoi/soviet-soldier-volkov-n-chitzkoi-AI.lua | 7 | 3093 | --[[
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.
]]
AlliedInfantryTypes = { "e1", "e3" }
if Difficulty == "easy" then
AlliedArmorTypes = { "1tnk", "1tnk" }
else
AlliedArmorTypes = { "1tnk", "2tnk" }
end
if Difficulty == "hard" then
AlliedNavyGuard = { "ca", "ca" }
else
AlliedNavyGuard = { "ca" }
end
ArmorAttackNumbers =
{
easy = 2,
normal = 5,
hard = 8
}
ArmorAttackDelays =
{
easy = DateTime.Seconds(45),
normal = DateTime.Seconds(30),
hard = DateTime.Seconds(10)
}
AlliedWarFactRally = { waypoint2, waypoint9, waypoint10, waypoint11 }
InfAttack = { }
ArmorAttack = { }
SendAttackToBase = function(units)
Utils.Do(units, function(unit)
if not unit.IsDead and unit.HasProperty("Hunt") then
unit.AttackMove(waypoint77.Location, 2)
Trigger.OnIdle(unit, unit.Hunt)
end
end)
end
UnitsJustHunt = function(units)
Utils.Do(units, function(unit)
if not unit.IsDead and unit.HasProperty("Hunt") then
Trigger.OnIdle(unit, unit.Hunt)
end
end)
end
ProduceInfantry = function()
if AlliedBarracks01.IsDead then
return
elseif (OreRefinery01.IsDead and OreRefinery02.IsDead or GreeceHarvestersAreDead) and greece.Resources <= 299 then
return
end
local delay = Utils.RandomInteger(DateTime.Seconds(1), DateTime.Seconds(2))
local toBuild = { Utils.Random(AlliedInfantryTypes) }
greece.Build(toBuild, function(unit)
InfAttack[#InfAttack + 1] = unit[1]
if #InfAttack >= 5 then
UnitsJustHunt(InfAttack)
InfAttack = { }
Trigger.AfterDelay(DateTime.Seconds(1), ProduceInfantry)
else
Trigger.AfterDelay(delay, ProduceInfantry)
end
end)
end
ProduceArmor = function()
if AlliedWarFact01.IsDead and AlliedWarFact02.IsDead then
return
elseif (OreRefinery01.IsDead and OreRefinery02.IsDead or GreeceHarvestersAreDead) and greece.Resources <= 699 then
return
end
local delay = Utils.RandomInteger(DateTime.Seconds(7), DateTime.Seconds(10))
local toBuild = { Utils.Random(AlliedArmorTypes) }
local Rally = Utils.Random(AlliedWarFactRally)
Utils.Do(AlliedWarFact, function(fact) fact.RallyPoint = Rally.Location end)
greece.Build(toBuild, function(unit)
ArmorAttack[#ArmorAttack + 1] = unit[1]
if #ArmorAttack >= ArmorAttackNumbers[Difficulty] then
SendAttackToBase(ArmorAttack)
ArmorAttack = { }
Trigger.AfterDelay(ArmorAttackDelays[Difficulty], ProduceArmor)
else
Trigger.AfterDelay(delay, ProduceArmor)
end
end)
end
ProduceNavyGuard = function()
if NavalYard01.IsDead then
return
elseif (OreRefinery01.IsDead and OreRefinery02.IsDead or GreeceHarvestersAreDead) and greece.Resources <= 2399 then
return
end
NavalYard01.RallyPoint = waypoint26.Location
greece.Build(AlliedNavyGuard, function(nvgrd)
Utils.Do(nvgrd, function(unit)
Trigger.OnKilled(unit, ProduceNavyGuard)
end)
end)
end
| gpl-3.0 |
ld-test/util | util/file.lua | 3 | 2060 | require 'os'
require 'fs'
require 'paths'
-- Boolean predicate to determine if a path points to a valid file or directory.
function is_file(path)
return paths.filep(path) or paths.dirp(path)
end
-- Assert that a file exists.
function assert_file(path, msg)
if not is_file(path) then
assert(false, msg)
end
end
-- Check that a data directory exists, and create it if not.
function check_and_mkdir(dir)
if not paths.filep(dir) then
fs.mkdir(dir)
end
end
-- Decompress a .tgz or .tar.gz file.
function decompress_tarball(path)
os.execute('tar -xvzf ' .. path)
end
-- unzip a .zip file
function unzip(path)
os.execute('unzip ' .. path)
end
-- gunzip a .gz file
function gunzip(path)
os.execute('gunzip ' .. path)
end
-- Decompress tarballs and zip files, using the suffix to determine which
-- method to use.
function decompress_file(path)
if string.find(path, "%.tar%.gz$") or string.find(path, "%.tgz$") then
decompress_tarball(path)
elseif string.find(path, "%.zip$") or string.find(path, "%.gz$") then
unzip(path)
elseif string.find(path, "%.gz$") or string.find(path, "%.gzip$") then
gunzip(path)
else
print("Don't know how to decompress file: ", path)
end
end
-- Download the file at location url.
function download_file(url)
local protocol, scpurl, filename = url:match('(.-)://(.*)/(.-)$')
if protocol == 'scp' then
os.execute(string.format('%s %s %s', 'scp', scpurl .. '/' .. filename, filename))
else
os.execute('wget ' .. url)
end
end
-- Temporarily changes the current working directory to call fn, returning its
-- result.
function do_with_cwd(path, fn)
local cur_dir = fs.cwd()
fs.chdir(path)
local res = fn()
fs.chdir(cur_dir)
return res
end
-- Check that a file exists at path, and if not downloads it from url.
function check_and_download_file(path, url)
if not paths.filep(path) then
do_with_cwd(paths.dirname(path), function() download_file(url) end)
end
return path
end
| bsd-3-clause |
dr01d3r/darkstar | scripts/zones/Castle_Oztroja/npcs/_479.lua | 14 | 1722 | -----------------------------------
-- Area: Castle Oztroja
-- NPC: _479 (Brass Door)
-- Involved in Mission "Saintly Invitation"
-- @pos -99 -59 84 151
-----------------------------------
package.loaded["scripts/zones/Castle_Oztroja/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Castle_Oztroja/TextIDs")
require("scripts/globals/settings");
require("scripts/globals/missions");
require("scripts/globals/keyitems");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (trade:hasItemQty(1142,1) and trade:getItemCount() == 1) then -- check for Judgment Key
if (player:getCurrentMission(WINDURST) == SAINTLY_INVITATION and player:hasKeyItem(BALGA_CHAMPION_CERTIFICATE)) then
if (player:getZPos() >= 80 and player:getZPos() < 86) then
npc:openDoor(2.5);
player:tradeComplete();
else
player:messageSpecial(ITS_LOCKED);
end
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (npc:getAnimation() == 9) then
player:messageSpecial(ITS_LOCKED);
return 1;
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 |
dr01d3r/darkstar | scripts/zones/Port_Jeuno/npcs/Horst.lua | 29 | 3441 | -----------------------------------
-- Area: Port Jeuno
-- NPC: Horst
-- Type: Abyssea Warp NPC
-- @pos -54.379 0.001 -10.061 246
-----------------------------------
package.loaded["scripts/zones/Port_Jeuno/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Port_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local CRUOR = player:getCurrency("cruor");
if (player:getQuestStatus(ABYSSEA, THE_TRUTH_BECKONS) == QUEST_ACCEPTED) then
player:startEvent(0x0153,1,CRUOR,7,7,7); -- Temp activated all locations till param handling sorted out.
elseif (player:getQuestStatus(ABYSSEA, THE_TRUTH_BECKONS) == QUEST_COMPLETED) then
player:startEvent(0x0153,2,CRUOR,7,7,7); -- Temp activated all locations till param handling sorted out.
else
player:startEvent(0x0153, 0);
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);
local CRUOR = player:getCurrency("cruor");
if (csid == 0x0153) then
if (option == 260) then
if (CRUOR >= 200) then
player:delCurrency("cruor", 200);
player:setPos(-562,0.001,640,26,102); -- La Theine Plateau
end
elseif (option == 264) then
if (CRUOR >= 200) then
player:delCurrency("cruor", 200);
player:setPos(91,-68,-582,237,108); -- Konshtat Highlands
end
elseif (option == 268) then
if (CRUOR >= 200) then
player:delCurrency("cruor", 200);
player:setPos(-28,46,-680,76,117); -- Tahrongi Canyon
end
elseif (option == 272) then
if (CRUOR >= 200) then
player:delCurrency("cruor", 200);
player:setPos(241,0.001,11,42,104); -- Jugner Forest
end
elseif (option == 276) then
if (CRUOR >= 200) then
player:delCurrency("cruor", 200);
player:setPos(362,0.001,-119,4,103); -- Valkrum
end
elseif (option == 280) then
if (CRUOR >= 200) then
player:delCurrency("cruor", 200);
player:setPos(-338,-23,47,167,118); -- Buburimu Peninsula
end
elseif (option == 288) then
if (CRUOR >= 200) then
player:delCurrency("cruor", 200);
player:setPos(269,-7,-75,192,112); -- Xarcabard
end
elseif (option == 284) then
if (CRUOR >= 200) then
player:delCurrency("cruor", 200);
player:setPos(337,0.001,-675,52,107); -- South Gustaberg
end
elseif (option == 292) then
if (CRUOR >= 200) then
player:delCurrency("cruor", 200);
player:setPos(-71,0.001,601,126,106); -- North Gustaberg
end
end
end
end; | gpl-3.0 |
dr01d3r/darkstar | scripts/globals/items/serving_of_mont_blanc.lua | 12 | 1483 | -----------------------------------------
-- ID: 5557
-- Item: Serving of Mont Blanc
-- Food Effect: 3 Hrs, All Races
-----------------------------------------
-- TODO: Group Effect
-- HP +8
-- MP +10
-- Intelligence +1
-- HP Recoverd while healing 1
-- MP 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,10800,5557);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 8);
target:addMod(MOD_MP, 10);
target:addMod(MOD_INT, 1);
target:addMod(MOD_HPHEAL, 1);
target:addMod(MOD_MPHEAL, 1);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 8);
target:delMod(MOD_MP, 10);
target:delMod(MOD_INT, 1);
target:delMod(MOD_HPHEAL, 1);
target:delMod(MOD_MPHEAL, 1);
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Port_Windurst/npcs/Honorio.lua | 14 | 1406 | -----------------------------------
-- Area: Port Windurst
-- NPC: Honorio
-- @zone 240
-- @pos 218 -5 114
-----------------------------------
package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/zones/Port_Windurst/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:hasKeyItem(AIRSHIP_PASS) == true and player:getGil() >= 200) then
player:startEvent(0x00b5,0,8,0,0,0,0,0,200);
else
player:startEvent(0x00b7,0,8);
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 == 0x00b5) then
X = player:getXPos();
if (X >= 222 and X <= 225) then
player:delGil(200);
end
end
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/globals/items/slice_of_giant_sheep_meat.lua | 12 | 1358 | -----------------------------------------
-- ID: 4372
-- Item: slice_of_giant_sheep_meat
-- Food Effect: 5Min, Galka only
-----------------------------------------
-- Strength 2
-- Intelligence -4
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:getRace() ~= 8) then
result = 247;
end
if (target:getMod(MOD_EAT_RAW_MEAT) == 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,4372);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_STR, 2);
target:addMod(MOD_INT, -4);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_STR, 2);
target:delMod(MOD_INT, -4);
end;
| gpl-3.0 |
Dauthdaert/Dauth-Lua | Lua-Examples/Example(LOVE Main)/e0101.lua | 2 | 2266 | -- Example: Mini Physics Callbacks
-- Updated 0.8.0 by Bartoleo
text = "No collision yet."
function love.load()
-- One meter is 32px in physics engine
love.physics.setMeter( 32 )
-- Create a world with standard gravity
world = love.physics.newWorld(0, 9.81*32, true)
-- Create the ground body at (0, 0) static
ground = love.physics.newBody(world, 0, 0, "static")
-- Create the ground shape at (400,500) with size (600,10).
ground_shape = love.physics.newRectangleShape(400, 500, 600, 10)
-- Create fixture between body and shape
ground_fixture = love.physics.newFixture( ground, ground_shape)
ground_fixture:setUserData("Ground") -- Set a string userdata
-- Load the image of the ball.
ball = love.graphics.newImage("images/love-ball.png")
-- Create a Body for the circle.
body = love.physics.newBody(world, 400, 200, "dynamic")
-- Attatch a shape to the body.
circle_shape = love.physics.newCircleShape(0,0, 32)
-- Create fixture between body and shape
fixture = love.physics.newFixture( body, circle_shape)
fixture:setUserData("Ball") -- Set a string userdata
-- Calculate the mass of the body based on attatched shapes.
-- This gives realistic simulations.
body:setMassData(circle_shape:computeMass( 1 ))
-- Set the collision callback.
world:setCallbacks(beginContact,endContact)
end
function love.update(dt)
-- Update the world.
world:update(dt)
end
function love.draw()
-- Draws the ground.
love.graphics.polygon("line", ground_shape:getPoints())
-- Draw the circle.
love.graphics.draw(ball,body:getX(), body:getY(), body:getAngle(),1,1,32,32)
-- Instructions
love.graphics.print("space: Apply a random impulse",5,5)
-- Draw text.
love.graphics.print(text, 5, 25)
end
function love.keypressed(k)
if k == " " then
-- Apply a random impulse
body:applyLinearImpulse(150-math.random(0, 300),-math.random(0, 1500))
end
end
-- This is called every time a collision begin.
function beginContact(a, b, c)
local aa=a:getUserData()
local bb=b:getUserData()
text = "Collided: " .. aa .. " and " .. bb
end
-- This is called every time a collision end.
function endContact(a, b, c)
local aa=a:getUserData()
local bb=b:getUserData()
text = "Collision ended: " .. aa .. " and " .. bb
end
| gpl-2.0 |
RezaLunatic/Unknown | plugins/invite.lua | 47 | 1193 | do
local function callbackres(extra, success, result) -- Callback for res_user in line 27
local user = 'user#id'..result.id
local chat = 'chat#id'..extra.chatid
if is_banned(result.id, extra.chatid) then -- Ignore bans
send_large_msg(chat, 'User is banned.')
elseif is_gbanned(result.id) then -- Ignore globall bans
send_large_msg(chat, 'User is globaly banned.')
else
chat_add_user(chat, user, ok_cb, false) -- Add user on chat
end
end
function run(msg, matches)
local data = load_data(_config.moderation.data)
if not is_realm(msg) then
if data[tostring(msg.to.id)]['settings']['lock_member'] == 'yes' and not is_admin(msg) then
return 'Group is private.'
end
end
if msg.to.type ~= 'chat' then
return
end
if not is_momod(msg) then
return
end
--if not is_admin(msg) then -- For admins only !
--return 'Only admins can invite.'
--end
local cbres_extra = {chatid = msg.to.id}
local username = matches[1]
local username = username:gsub("@","")
res_user(username, callbackres, cbres_extra)
end
return {
patterns = {
"^دعوت (.*)$"
},
run = run
}
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/globals/items/dish_of_homemade_carbonara.lua | 12 | 1870 | -----------------------------------------
-- ID: 5706
-- Item: dish_of_homemade_carbonara
-- Food Effect: 30Min, All Races
-----------------------------------------
-- CHR +1
-- Accuracy +12% (cap 80)
-- Attack +10% (cap 40)
-- Ranged Accuracy +12% (cap 80)
-- Ranged Attack +10% (cap 40)
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,1800,5706);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_CHR, 1);
target:addMod(MOD_FOOD_ACCP, 12);
target:addMod(MOD_FOOD_ACC_CAP, 80);
target:addMod(MOD_FOOD_ATTP, 10);
target:addMod(MOD_FOOD_ATT_CAP, 40);
target:addMod(MOD_FOOD_RACCP, 12);
target:addMod(MOD_FOOD_RACC_CAP, 80);
target:addMod(MOD_FOOD_RATTP, 10);
target:addMod(MOD_FOOD_RATT_CAP, 40);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_CHR, 1);
target:delMod(MOD_FOOD_ACCP, 12);
target:delMod(MOD_FOOD_ACC_CAP, 80);
target:delMod(MOD_FOOD_ATTP, 10);
target:delMod(MOD_FOOD_ATT_CAP, 40);
target:delMod(MOD_FOOD_RACCP, 12);
target:delMod(MOD_FOOD_RACC_CAP, 80);
target:delMod(MOD_FOOD_RATTP, 10);
target:delMod(MOD_FOOD_RATT_CAP, 40);
end;
| gpl-3.0 |
TheRealMaxion/Automato-ATITD | scripts/CarpBlades.lua | 1 | 11390 | -- Note that anvils need to have been rotated 180 degrees from the default rotation when built, so the sharp edge of the carp blade is to the left.
dofile("screen_reader_common.inc");
dofile("ui_utils.inc");
dofile("common.inc");
foundBladePos = {};
offset = {};
function doit()
promptOkay("Make sure you are in the F8F8 view, zoomed all the way in, with the anvil menu pinned where it does not overlap the anvil.");
promptOkay("Stand to the left of the anvil without any part of your body overlapping the anvil.");
local howMany = promptNumber("How many?",10);
if(howMany < 1) then
fatalError("Must make at least one.");
end
askForWindow("Make sure your chats are minimized, then hover ATITD window and press Shift to continue.");
click_delay = 150;
per_click_delay = click_delay;
checkAnvil();
findAnvil();
local numMade;
for numMade=1, howMany do
statusScreen("Making blade " .. numMade .. " of " .. howMany .. " with " .. (howMany - numMade) .. " to go after this one.");
checkBreak();
loadAnvil();
makeBlade();
checkBlade();
takeBlade();
end
end
function mouseHome()
srSetMousePos(0,0);
end
function checkAnvil()
mouseHome();
srReadScreen();
local pos = findText("This is [a-z]+ Anvil", nil, REGEX);
if(not pos) then
fatalError("Unable to find the anvil menu, in checkAnvil().");
end
local pos = findText("Complete Project");
if(pos) then
fatalError("The anvil already has a project loaded. Clear the anvil and try again.");
end
end
function findAnvil()
mouseHome();
srReadScreen();
local pos = findText("Load Anvil...");
if(not pos) then
fatalError("Unable to find the Load Anvil menu item.");
end
clickText(pos);
srReadScreen();
pos = findText("Copper...");
if(not pos) then
fatalError("Unable to find the Copper menu item.");
end
clickText(pos);
srReadScreen();
pos = findText("Resin Wedge");
if(not pos) then
fatalError("Unable to find the Resin Wedge menu item.");
end
clickText(pos);
findResinWedgeRightTop();
srReadScreen();
local pos = findText("This is [a-z]+ Anvil", nil, REGEX);
if(not pos) then
fatalError("Unable to find the anvil menu, in findAnvil().");
end
clickText(pos);
srReadScreen();
local pos = findText("Discard Project");
if(not pos) then
fatalError("Unable to find the Discard Project menu item.");
end
clickText(pos);
srReadScreen();
local pos = findText("Really scrap");
if(not pos) then
fatalError("Unable to find the scrap confirmation dialog.");
end
pos[0] = pos[0] + 10;
local pos2 = waitForImage("Yes3.png", 500);
if(not pos2) then
pos2 = waitForImage("Yes4.png", 500);
end
if(not pos2) then
srSetMousePos(foundBladePos[0], foundBladePos[1]);
fatalError("Unable to find the Yes button.");
end
clickText(pos2);
srReadScreen();
local pos = findText("This is [a-z]+ Anvil", nil, REGEX);
if(not pos) then
fatalError("Unable to find the anvil menu, in findAnvil().");
end
clickText(pos);
end
function findResinWedgeRightTop()
mouseHome();
srReadScreen();
local xyWindowSize = srGetWindowSize();
local mid = {};
mid[0] = xyWindowSize[0] / 2;
mid[1] = xyWindowSize[1] / 2;
local bestX = mid[0];
local bestY = mid[1] - 400;
local count = 220;
local step = 64;
local currX = bestX;
local currY = bestY;
local x;
local maxHue = 0;
for x = mid[0], mid[0] + 600, step do
checkBreak();
local y;
for y = mid[1] - 400, mid[1], step do
count = count - 1;
local rgb = parseColor(srReadPixel(x,y));
if(math.min(rgb[0]-rgb[2],rgb[1]-rgb[2]) >= 44) then
if(x > bestX or (x == bestX and y < bestY)) then
bestX = x;
bestY = y;
srSetMousePos(x,y);
lsSleep(100);
end
end
statusScreen("Finding reference point... " .. count);
end
end
step = 32;
while(step >= 1) do
local currX = bestX;
local currY = bestY;
local x;
local maxHue = 0;
for x = currX - (step * 2), currX + (step * 2), step do
checkBreak();
local y;
for y = currY - (step * 2), currY + (step * 2), step do
count = count - 1;
local rgb = parseColor(srReadPixel(x,y));
if(math.min(rgb[0]-rgb[2],rgb[1]-rgb[2]) >= 40) then
if(x > bestX or (x == bestX and y < bestY)) then
bestX = x;
bestY = y;
srSetMousePos(x,y);
end
end
statusScreen("Finding reference point... " .. count);
end
end
step = step / 2;
end
foundBladePos[0] = bestX;
foundBladePos[1] = bestY;
srSetMousePos(bestX, bestY);
-- lsClipboardSet(bestX .. ", " .. bestY);
-- fatalError(bestX .. ", " .. bestY);
mouseHome();
end
function loadAnvil()
mouseHome();
srReadScreen();
local pos = findText("Load Anvil...");
if(not pos) then
fatalError("Unable to find the Load Anvil menu item.");
end
clickText(pos);
lsSleep(50);
srReadScreen();
pos = findText("Copper...");
if(not pos) then
fatalError("Unable to find the Copper menu item.");
end
clickText(pos);
lsSleep(50);
srReadScreen();
pos = findText("Carpentry Blade");
if(not pos) then
fatalError("Unable to find the Carpentry Blade menu item.");
end
clickText(pos);
lsSleep(250);
srReadScreen();
local pos = findText("This is [a-z]+ Anvil", nil, REGEX);
if(not pos) then
fatalError("Unable to find the anvil menu, in loadAnvil().");
end
clickText(pos);
end
function setShapingMallet()
mouseHome();
srReadScreen();
local pos = findText("Tools...");
if(not pos) then
fatalError("Unable to find the Tools menu item.");
end
clickText(pos);
lsSleep(50);
srReadScreen();
pos = findText("Shaping Mallet");
if(not pos) then
fatalError("Unable to find the Shaping Mallet menu item.");
end
clickText(pos);
end
function setChisel()
mouseHome();
srReadScreen();
local pos = findText("Tools...");
if(not pos) then
fatalError("Unable to find the Tools menu item.");
end
clickText(pos);
lsSleep(50);
srReadScreen();
pos = findText("Wide Chisel");
if(not pos) then
fatalError("Unable to find the Wide Chisel menu item.");
end
clickText(pos);
end
function setBallPeen()
mouseHome();
srReadScreen();
local pos = findText("Tools...");
if(not pos) then
fatalError("Unable to find the Tools menu item.");
end
clickText(pos);
lsSleep(50);
srReadScreen();
pos = findText("Ball Peen");
if(not pos) then
fatalError("Unable to find the Ball Peen menu item.");
end
clickText(pos);
end
function setForce(force)
mouseHome();
srReadScreen();
local pos = findText("Tools...");
if(not pos) then
fatalError("Unable to find the Tools menu item.");
end
clickText(pos);
lsSleep(50);
srReadScreen();
pos = findText("Force Level");
if(not pos) then
fatalError("Unable to find the Force Level menu item.");
end
clickText(pos);
lsSleep(50);
srReadScreen();
pos = findText("[" .. force .. "]");
if(not pos) then
fatalError("Unable to find the Force Level menu item.");
end
clickText(pos);
end
function makeBlade()
mouseHome();
checkBreak();
srReadScreen();
click_delay = 200;
local recordedBladePos = { 1261, 408 };
offset[0] = foundBladePos[0] - recordedBladePos[1];
offset[1] = foundBladePos[1] - recordedBladePos[2];
setShapingMallet();
setForce(8);
clickXY(1046, 435, offset[0], offset[1]);
checkBreak();
clickXY(1046, 479, offset[0], offset[1]);
checkBreak();
clickXY(1046, 523, offset[0], offset[1]);
checkBreak();
clickXY(1046, 567, offset[0], offset[1]);
checkBreak();
clickXY(1046, 611, offset[0], offset[1]);
checkBreak();
clickXY(1046, 655, offset[0], offset[1]);
checkBreak();
clickXY(1046, 699, offset[0], offset[1]);
checkBreak();
clickXY(1046, 745, offset[0], offset[1]);
checkBreak();
setChisel();
setForce(9);
clickXY(1046, 435, offset[0], offset[1]);
checkBreak();
clickXY(1046, 745, offset[0], offset[1]);
checkBreak();
clickXY(1046, 538, offset[0], offset[1]);
checkBreak();
clickXY(1046, 642, offset[0], offset[1]);
checkBreak();
setForce(4);
clickXY(1145, 534, offset[0], offset[1]);
checkBreak();
clickXY(1145, 590, offset[0], offset[1]);
checkBreak();
clickXY(1145, 652, offset[0], offset[1]);
checkBreak();
setBallPeen();
setForce(9);
clickXY(1164, 462, offset[0], offset[1]);
checkBreak();
clickXY(1162, 722, offset[0], offset[1]);
checkBreak();
clickXY(1258, 463, offset[0], offset[1]);
checkBreak();
clickXY(1261, 721, offset[0], offset[1]);
checkBreak();
clickXY(1236, 463, offset[0], offset[1]);
checkBreak();
clickXY(1239, 730, offset[0], offset[1]);
checkBreak();
clickXY(1237, 490, offset[0], offset[1]);
checkBreak();
clickXY(1236, 700, offset[0], offset[1]);
checkBreak();
clickXY(1250, 490, offset[0], offset[1]);
checkBreak();
clickXY(1255, 700, offset[0], offset[1]);
checkBreak();
end
function checkBlade()
mouseHome();
srReadScreen();
local pos = findText("Tools...");
if(not pos) then
fatalError("Unable to find the Tools menu item.");
end
clickText(pos);
lsSleep(50);
srReadScreen();
pos = findText("Quality Check");
if(not pos) then
fatalError("Unable to find the Quality Check menu item.");
end
clickText(pos);
end
function takeBlade()
mouseHome();
srReadScreen();
local pos = findText("Complete Project");
if(not pos) then
fatalError("Unable to find the Complete Project menu item.");
end
clickText(pos);
lsSleep(50);
srReadScreen();
pos = findText("Ready to Unload");
if(not pos) then
fatalError("Unable to find the Ready to Unload confirmation dialog.");
end
pos[0] = pos[0] + 10;
local pos2 = waitForImage("Yes3.png", 500);
if(not pos2) then
pos2 = waitForImage("Yes4.png", 500);
end
if(not pos2) then
fatalError("Unable to find the Yes button.");
end
clickText(pos2);
srReadScreen();
pos = waitForImage("ok.png", 1000);
if(pos) then
clickText(pos);
end
srReadScreen();
local pos = findText("This is [a-z]+ Anvil", nil, REGEX);
if(not pos) then
fatalError("Unable to find the anvil menu, in findAnvil().");
end
clickText(pos);
end
| mit |
dr01d3r/darkstar | scripts/zones/Port_Windurst/npcs/HomePoint#1.lua | 27 | 1275 | -----------------------------------
-- Area: Port Windurst
-- NPC: HomePoint#1
-- @pos -68.216 -4.000 111.761 240
-----------------------------------
package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/Port_Windurst/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fc, 22);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x21fc) then
if (option == 1) then
player:setHomePoint();
player:messageSpecial(HOMEPOINT_SET);
else
hpTeleport( player, option);
end
end
end; | gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Windurst_Waters/npcs/Furakku-Norakku.lua | 25 | 4882 | -----------------------------------
-- Area: Windurst Waters
-- NPC: Furakku-Norakku
-- Involved in Quests: Early Bird Catches the Bookworm, Chasing Tales, Class Reunion
-- @pos -19 -5 101 238
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Windurst_Waters/TextIDs");
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/titles");
require("scripts/globals/quests");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local bookwormStatus = player:getQuestStatus(WINDURST,EARLY_BIRD_CATCHES_THE_BOOKWORM);
local chasingStatus = player:getQuestStatus(WINDURST,CHASING_TALES);
local bookNotifications = player:hasKeyItem(OVERDUE_BOOK_NOTIFICATIONS);
local ClassReunion = player:getQuestStatus(WINDURST,CLASS_REUNION);
local ClassReunionProgress = player:getVar("ClassReunionProgress");
local talk2 = player:getVar("ClassReunion_TalkedToFurakku");
if (bookwormStatus == QUEST_ACCEPTED and bookNotifications == false) then
player:startEvent(0x0185); -- During Quest "Early Bird Catches the Bookworm" 1
elseif (bookwormStatus == QUEST_ACCEPTED and bookNotifications and player:getVar("EARLY_BIRD_TRACK_BOOK") == 0) then
player:startEvent(0x0186); -- During Quest "Early Bird Catches the Bookworm" 2
elseif (bookwormStatus == QUEST_ACCEPTED and player:getVar("EARLY_BIRD_TRACK_BOOK") == 1) then
player:startEvent(0x018d); -- During Quest "Early Bird Catches the Bookworm" 3
elseif (bookwormStatus == QUEST_ACCEPTED and player:getVar("EARLY_BIRD_TRACK_BOOK") >= 2) then
player:startEvent(0x0190); -- Finish Quest "Early Bird Catches the Bookworm"
elseif (bookwormStatus == QUEST_COMPLETED and player:needToZone()) then
player:startEvent(0x0191); -- Standard dialog before player zone
elseif (chasingStatus == QUEST_ACCEPTED and player:hasKeyItem(OVERDUE_BOOK_NOTIFICATION) == false) then
player:startEvent(0x0194,0,126); -- During Quest "Chasing Tales", tells you the book "A Song of Love" is overdue
elseif (player:hasKeyItem(OVERDUE_BOOK_NOTIFICATION) and player:hasKeyItem(A_SONG_OF_LOVE) == false) then
player:startEvent(0x0195,0,126);
elseif (player:getVar("CHASING_TALES_TRACK_BOOK") == 1 and player:hasKeyItem(A_SONG_OF_LOVE) == false) then
player:startEvent(0x0199);
elseif (player:hasKeyItem(A_SONG_OF_LOVE)) then
player:startEvent(0x019a);
elseif (chasingStatus == QUEST_COMPLETED and player:needToZone() == true) then
player:startEvent(0x019b);
-----------------------------------------------------------------
-- Class Reunion
elseif (ClassReunion == 1 and ClassReunionProgress >= 3 and talk2 ~= 1) then
player:startEvent(0x0330); -- he tells you about Uran-Mafran
-----------------------------------------------------------------
else
player:startEvent(0x0173);
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 == 0x0185) then
player:addKeyItem(OVERDUE_BOOK_NOTIFICATIONS);
player:messageSpecial(KEYITEM_OBTAINED,OVERDUE_BOOK_NOTIFICATIONS);
elseif (csid == 0x0190) then
player:needToZone(true);
player:addTitle(SAVIOR_OF_KNOWLEDGE);
player:addGil(GIL_RATE*1500);
player:messageSpecial(GIL_OBTAINED,GIL_RATE*1500);
player:setVar("EARLY_BIRD_TRACK_BOOK",0);
player:addFame(WINDURST,120);
player:completeQuest(WINDURST,EARLY_BIRD_CATCHES_THE_BOOKWORM);
elseif (csid == 0x0194) then
player:addKeyItem(OVERDUE_BOOK_NOTIFICATION);
player:messageSpecial(KEYITEM_OBTAINED,OVERDUE_BOOK_NOTIFICATION);
elseif (csid == 0x019a) then
player:needToZone(true);
player:addGil(GIL_RATE*2800);
player:messageSpecial(GIL_OBTAINED,GIL_RATE*2800);
player:addTitle(SAVIOR_OF_KNOWLEDGE);
player:delKeyItem(OVERDUE_BOOK_NOTIFICATION);
player:delKeyItem(A_SONG_OF_LOVE);
player:setVar("CHASING_TALES_TRACK_BOOK",0);
player:addFame(WINDURST,120);
player:completeQuest(WINDURST,CHASING_TALES);
elseif (csid == 0x0330) then
player:setVar("ClassReunion_TalkedToFurakku",1);
end
end; | gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c92807548.lua | 6 | 1057 | --堕天使ユコバック
function c92807548.initial_effect(c)
--tograve
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(92807548,0))
e1:SetCategory(CATEGORY_TOGRAVE)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetCountLimit(1,92807548)
e1:SetTarget(c92807548.tgtg)
e1:SetOperation(c92807548.tgop)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e2)
end
function c92807548.tgfilter(c)
return c:IsSetCard(0xef) and c:IsAbleToGrave()
end
function c92807548.tgtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c92807548.tgfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK)
end
function c92807548.tgop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,c92807548.tgfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoGrave(g,REASON_EFFECT)
end
end
| gpl-2.0 |
amirrobot1/amirrobot | plugins/anti_flood.lua | 281 | 2422 | local NUM_MSG_MAX = 5 -- Max number of messages per TIME_CHECK seconds
local TIME_CHECK = 5
local function kick_user(user_id, chat_id)
local chat = 'chat#id'..chat_id
local user = 'user#id'..user_id
chat_del_user(chat, user, function (data, success, result)
if success ~= 1 then
local text = 'I can\'t kick '..data.user..' but should be kicked'
send_msg(data.chat, '', ok_cb, nil)
end
end, {chat=chat, user=user})
end
local function run (msg, matches)
if msg.to.type ~= 'chat' then
return 'Anti-flood works only on channels'
else
local chat = msg.to.id
local hash = 'anti-flood:enabled:'..chat
if matches[1] == 'enable' then
redis:set(hash, true)
return 'Anti-flood enabled on chat'
end
if matches[1] == 'disable' then
redis:del(hash)
return 'Anti-flood disabled on chat'
end
end
end
local function pre_process (msg)
-- Ignore service msg
if msg.service then
print('Service message')
return msg
end
local hash_enable = 'anti-flood:enabled:'..msg.to.id
local enabled = redis:get(hash_enable)
if enabled then
print('anti-flood enabled')
-- Check flood
if msg.from.type == 'user' then
-- Increase the number of messages from the user on the chat
local hash = 'anti-flood:'..msg.from.id..':'..msg.to.id..':msg-num'
local msgs = tonumber(redis:get(hash) or 0)
if msgs > NUM_MSG_MAX then
local receiver = get_receiver(msg)
local user = msg.from.id
local text = 'User '..user..' is flooding'
local chat = msg.to.id
send_msg(receiver, text, ok_cb, nil)
if msg.to.type ~= 'chat' then
print("Flood in not a chat group!")
elseif user == tostring(our_id) then
print('I won\'t kick myself')
elseif is_sudo(msg) then
print('I won\'t kick an admin!')
else
-- Ban user
-- TODO: Check on this plugin bans
local bhash = 'banned:'..msg.to.id..':'..msg.from.id
redis:set(bhash, true)
kick_user(user, chat)
end
msg = nil
end
redis:setex(hash, TIME_CHECK, msgs+1)
end
end
return msg
end
return {
description = 'Plugin to kick flooders from group.',
usage = {},
patterns = {
'^!antiflood (enable)$',
'^!antiflood (disable)$'
},
run = run,
privileged = true,
pre_process = pre_process
}
| gpl-2.0 |
koreader/koreader | spec/unit/luadata_spec.lua | 4 | 5436 | describe("luadata module", function()
local Settings, lfs
setup(function()
require("commonrequire")
lfs = require("libs/libkoreader-lfs")
Settings = require("frontend/luadata"):open("this-is-not-a-valid-file")
end)
it("should handle undefined keys", function()
Settings:delSetting("abc")
assert.True(Settings:hasNot("abc"))
assert.True(Settings:nilOrTrue("abc"))
assert.False(Settings:isTrue("abc"))
Settings:saveSetting("abc", true)
assert.True(Settings:has("abc"))
assert.True(Settings:nilOrTrue("abc"))
assert.True(Settings:isTrue("abc"))
end)
it("should flip bool values", function()
Settings:delSetting("abc")
assert.True(Settings:hasNot("abc"))
Settings:flipNilOrTrue("abc")
assert.False(Settings:nilOrTrue("abc"))
assert.True(Settings:has("abc"))
assert.False(Settings:isTrue("abc"))
Settings:flipNilOrTrue("abc")
assert.True(Settings:nilOrTrue("abc"))
assert.True(Settings:hasNot("abc"))
assert.False(Settings:isTrue("abc"))
Settings:flipTrue("abc")
assert.True(Settings:has("abc"))
assert.True(Settings:isTrue("abc"))
assert.True(Settings:nilOrTrue("abc"))
Settings:flipTrue("abc")
assert.False(Settings:has("abc"))
assert.False(Settings:isTrue("abc"))
assert.True(Settings:nilOrTrue("abc"))
end)
it("should create child settings", function()
Settings:delSetting("key")
Settings:saveSetting("key", {
a = "b",
c = "True",
d = false,
})
local child = Settings:child("key")
assert.is_not_nil(child)
assert.True(child:has("a"))
assert.are.equal(child:readSetting("a"), "b")
assert.True(child:has("c"))
assert.False(child:isTrue("c")) -- It's a string, not a bool!
assert.True(child:has("d"))
assert.True(child:isFalse("d"))
assert.False(child:isTrue("e"))
child:flipTrue("e")
child:close()
child = Settings:child("key")
assert.True(child:isTrue("e"))
end)
describe("table wrapper", function()
Settings:delSetting("key")
it("should add item to table", function()
Settings:addTableItem("key", 1)
Settings:addTableItem("key", 2)
Settings:addTableItem("key", 3)
assert.are.equal(1, Settings:readSetting("key")[1])
assert.are.equal(2, Settings:readSetting("key")[2])
assert.are.equal(3, Settings:readSetting("key")[3])
end)
it("should remove item from table", function()
Settings:removeTableItem("key", 1)
assert.are.equal(2, Settings:readSetting("key")[1])
assert.are.equal(3, Settings:readSetting("key")[2])
end)
end)
describe("backup data file", function()
local file = "dummy-test-file"
local d = Settings:open(file)
it("should generate data file", function()
d:saveSetting("a", "a")
assert.Equals("file", lfs.attributes(d.file, "mode"))
end)
it("should generate backup data file on flush", function()
d:flush()
-- file and file.old.1 should be generated.
assert.Equals("file", lfs.attributes(d.file, "mode"))
assert.Equals("file", lfs.attributes(d.file .. ".old.1", "mode"))
d:close()
end)
it("should remove garbage data file", function()
-- write some garbage to sidecar-file.
local f_out = io.open(d.file, "w")
f_out:write("bla bla bla")
f_out:close()
d = Settings:open(file)
-- file should be removed.
assert.are.not_equal("file", lfs.attributes(d.file, "mode"))
assert.Equals("file", lfs.attributes(d.file .. ".old.2", "mode"))
assert.Equals("a", d:readSetting("a"))
d:saveSetting("a", "b")
d:close()
-- backup should be generated.
assert.Equals("file", lfs.attributes(d.file, "mode"))
assert.Equals("file", lfs.attributes(d.file .. ".old.1", "mode"))
-- The contents in file and file.old.1 are different.
-- a:b v.s. a:a
end)
it("should open backup data file after garbage removal", function()
d = Settings:open(file)
-- We should get the right result.
assert.Equals("b", d:readSetting("a"))
-- write some garbage to file.
local f_out = io.open(d.file, "w")
f_out:write("bla bla bla")
f_out:close()
-- do not flush the result, open docsettings again.
d = Settings:open(file)
-- data file should be removed.
assert.are.not_equal("file", lfs.attributes(d.file, "mode"))
assert.Equals("file", lfs.attributes(d.file .. ".old.2", "mode"))
-- The content should come from file.old.2.
assert.Equals("a", d:readSetting("a"))
d:close()
-- data file should be generated and last good backup should not change name.
assert.Equals("file", lfs.attributes(d.file, "mode"))
assert.Equals("file", lfs.attributes(d.file .. ".old.2", "mode"))
end)
end)
end)
| agpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c61344030.lua | 5 | 2871 | --輝光子パラディオス
function c61344030.initial_effect(c)
--xyz summon
aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsAttribute,ATTRIBUTE_LIGHT),4,2)
c:EnableReviveLimit()
--negate
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(61344030,0))
e1:SetCategory(CATEGORY_DISABLE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1)
e1:SetCost(c61344030.cost)
e1:SetTarget(c61344030.target)
e1:SetOperation(c61344030.operation)
c:RegisterEffect(e1)
--draw
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(61344030,1))
e2:SetCategory(CATEGORY_DRAW)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e2:SetCode(EVENT_TO_GRAVE)
e2:SetCondition(c61344030.drcon)
e2:SetTarget(c61344030.drtg)
e2:SetOperation(c61344030.drop)
c:RegisterEffect(e2)
end
function c61344030.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,2,REASON_COST) end
e:GetHandler():RemoveOverlayCard(tp,2,2,REASON_COST)
end
function c61344030.filter(c)
return c:IsFaceup() and c:GetAttack()>0
end
function c61344030.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(1-tp) and chkc:IsLocation(LOCATION_MZONE) and c61344030.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c61344030.filter,tp,0,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
local g=Duel.SelectTarget(tp,c61344030.filter,tp,0,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_DISABLE,g,1,0,0)
end
function c61344030.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if tc:IsFaceup() and tc:IsRelateToEffect(e) and tc:GetAttack()>0 then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SET_ATTACK_FINAL)
e1:SetValue(0)
e1:SetReset(RESET_EVENT+0x1fe0000)
tc:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_DISABLE)
e2:SetReset(RESET_EVENT+0x1fe0000)
tc:RegisterEffect(e2)
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_DISABLE_EFFECT)
e3:SetValue(RESET_TURN_SET)
e3:SetReset(RESET_EVENT+0x1fe0000)
tc:RegisterEffect(e3)
end
end
function c61344030.drcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsPreviousLocation(LOCATION_ONFIELD) and c:IsReason(REASON_DESTROY)
and c:GetPreviousControler()==tp and c:GetReasonPlayer()==1-tp
end
function c61344030.drtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetTargetPlayer(tp)
Duel.SetTargetParam(1)
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1)
end
function c61344030.drop(e,tp,eg,ep,ev,re,r,rp)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Draw(p,d,REASON_EFFECT)
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/zones/Southern_San_dOria/npcs/Endracion.lua | 9 | 6381 | -----------------------------------
-- Area: Southern San d'Oria
-- NPC: Endracion
-- @pos -110 1 -34 230
-----------------------------------
package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Southern_San_dOria/TextIDs");
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/missions");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
CurrentMission = player:getCurrentMission(SANDORIA);
OrcishScoutCompleted = player:hasCompletedMission(SANDORIA,SMASH_THE_ORCISH_SCOUTS);
BatHuntCompleted = player:hasCompletedMission(SANDORIA,BAT_HUNT);
TheCSpringCompleted = player:hasCompletedMission(SANDORIA,THE_CRYSTAL_SPRING);
MissionStatus = player:getVar("MissionStatus");
Count = trade:getItemCount();
if (CurrentMission ~= 255) then
if (CurrentMission == SMASH_THE_ORCISH_SCOUTS and trade:hasItemQty(16656,1) and Count == 1 and OrcishScoutCompleted == false) then -- Trade Orcish Axe
player:startEvent(0x03fc); -- Finish Mission "Smash the Orcish scouts" (First Time)
elseif (CurrentMission == SMASH_THE_ORCISH_SCOUTS and trade:hasItemQty(16656,1) and Count == 1) then -- Trade Orcish Axe
player:startEvent(0x03ea); -- Finish Mission "Smash the Orcish scouts" (Repeat)
elseif (CurrentMission == BAT_HUNT and trade:hasItemQty(1112,1) and Count == 1 and BatHuntCompleted == false and MissionStatus == 2) then -- Trade Orcish Mail Scales
player:startEvent(0x03ff); -- Finish Mission "Bat Hunt"
elseif (CurrentMission == BAT_HUNT and trade:hasItemQty(891,1) and Count == 1 and BatHuntCompleted == true) then -- Trade Bat Fang
player:startEvent(0x03eb); -- Finish Mission "Bat Hunt" (repeat)
elseif (CurrentMission == THE_CRYSTAL_SPRING and trade:hasItemQty(4528,1) and Count == 1 and TheCSpringCompleted == false) then -- Trade Crystal Bass
player:startEvent(0x0406); -- Dialog During Mission "The Crystal Spring"
elseif (CurrentMission == THE_CRYSTAL_SPRING and trade:hasItemQty(4528,1) and Count == 1 and TheCSpringCompleted) then -- Trade Crystal Bass
player:startEvent(0x03f5); -- Finish Mission "The Crystal Spring" (repeat)
else
player:startEvent(0x03f0); -- Wrong Item
end
else
player:startEvent(0x03f2); -- Mission not activated
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local PresOfPapsqueCompleted = player:hasCompletedMission(SANDORIA,PRESTIGE_OF_THE_PAPSQUE);
if (player:getNation() ~= NATION_SANDORIA) then
player:startEvent(0x03F3); -- for Non-San d'Orians
else
CurrentMission = player:getCurrentMission(SANDORIA);
MissionStatus = player:getVar("MissionStatus");
pRank = player:getRank();
cs, p, offset = getMissionOffset(player,1,CurrentMission,MissionStatus);
if (CurrentMission <= 15 and (cs ~= 0 or offset ~= 0 or (CurrentMission == 0 and offset == 0))) then
if (cs == 0) then
player:showText(npc,ORIGINAL_MISSION_OFFSET + offset); -- dialog after accepting mission
else
player:startEvent(cs,p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8]);
end
elseif (pRank == 1 and player:hasCompletedMission(SANDORIA,SMASH_THE_ORCISH_SCOUTS) == false) then
player:startEvent(0x03e8); -- Start First Mission "Smash the Orcish scouts"
elseif (player:hasKeyItem(ANCIENT_SANDORIAN_BOOK)) then
player:startEvent(0x040b);
elseif (CurrentMission == RANPERRE_S_FINAL_REST and player:getVar("MissionStatus",4) and tonumber(os.date("%j")) == player:getVar("Wait1DayForRanperre_date")) then
player:startEvent(0x040d);
elseif (CurrentMission == RANPERRE_S_FINAL_REST and player:getVar("MissionStatus") == 4 and tonumber(os.date("%j")) ~= player:getVar("Wait1DayForRanperre_date")) then -- Ready now.
player:startEvent(0x040f);
elseif (CurrentMission == RANPERRE_S_FINAL_REST and player:getVar("MissionStatus") == 6) then
player:startEvent(0x040f);
elseif (CurrentMission == RANPERRE_S_FINAL_REST and player:getVar("MissionStatus") == 9) then
player:startEvent(0x0409);
elseif (CurrentMission ~= THE_SECRET_WEAPON and pRank == 7 and PresOfPapsqueCompleted == true and getMissionRankPoints(player,19) == 1 and player:getVar("SecretWeaponStatus") == 0) then
player:startEvent(0x003d);
elseif (CurrentMission == THE_SECRET_WEAPON and player:getVar("SecretWeaponStatus") == 3) then
player:startEvent(0x0413);
elseif ((CurrentMission ~= 255) and not (player:getVar("MissionStatus") == 8)) then
player:startEvent(0x03e9); -- Have mission already activated
else
mission_mask, repeat_mask = getMissionMask(player);
player:startEvent(0x03f1,mission_mask, 0, 0 ,0 ,0 ,repeat_mask); -- Mission List
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("onUpdateCSID: %u",csid);
-- printf("onUpdateOPTION: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("onFinishCSID: %u",csid);
-- printf("onFinishOPTION: %u",option);
finishMissionTimeline(player,1,csid,option);
if (csid == 0x040b) then
player:setVar("MissionStatus",4);
player:delKeyItem(ANCIENT_SANDORIAN_BOOK);
player:setVar("Wait1DayForRanperre_date", os.date("%j"));
elseif (csid == 0x040d) then
player:setVar("MissionStatus",6);
elseif (csid == 0x040f) then
player:setVar("MissionStatus",7);
player:setVar("Wait1DayForRanperre_date",0);
elseif (csid == 0x0409) then
finishMissionTimeline(player,2,csid,option);
elseif (csid == 0x003d) then
player:setVar("SecretWeaponStatus",1);
elseif (csid == 0x0413) then
finishMissionTimeline(player,2,csid,option);
end
end;
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Pashhow_Marshlands_[S]/Zone.lua | 12 | 2041 | -----------------------------------
--
-- Zone: Pashhow_Marshlands_[S] (90)
--
-----------------------------------
package.loaded["scripts/zones/Pashhow_Marshlands_[S]/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Pashhow_Marshlands_[S]/TextIDs");
require("scripts/globals/settings");
require("scripts/globals/weather");
require("scripts/globals/status");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(547.841,23.192,696.323,134);
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onZoneWeatherChange
-----------------------------------
function onZoneWeatherChange(weather)
local npc = GetNPCByID(17146627); -- Indescript Markings (BOOTS)
if (npc ~= nil) then
if (weather == WEATHER_RAIN or weather == WEATHER_THUNDER) then
npc:setStatus(STATUS_DISAPPEAR);
else
npc:setStatus(STATUS_NORMAL);
end
end
npc = GetNPCByID(17146628); -- Indescript Markings (BODY)
if (npc ~= nil) then
if (weather == WEATHER_RAIN) then
npc:setStatus(STATUS_DISAPPEAR);
else
npc:setStatus(STATUS_NORMAL);
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);
end; | gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Sacrificial_Chamber/npcs/_4j4.lua | 14 | 1440 | -----------------------------------
-- Area: Sacrificial Chamber
-- NPC: Mahogany Door
-- @pos 300 30 -324 163
-------------------------------------
package.loaded["scripts/zones/Sacrificial_Chamber/TextIDs"] = nil;
-------------------------------------
require("scripts/globals/bcnm");
require("scripts/globals/missions");
require("scripts/zones/Sacrificial_Chamber/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (TradeBCNM(player,player:getZoneID(),trade,npc)) then
return;
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (EventTriggerBCNM(player,npc)) then
return 1;
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("onUpdate CSID: %u",csid);
-- printf("onUpdate RESULT: %u",option);
if (EventUpdateBCNM(player,csid,option)) then
return;
end
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("onFinish CSID: %u",csid);
-- printf("onFinish RESULT: %u",option);
if (EventFinishBCNM(player,csid,option)) then
return;
end
end; | gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c14735698.lua | 2 | 4524 | --影霊衣の降魔鏡
function c14735698.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,14735698)
e1:SetTarget(c14735698.target)
e1:SetOperation(c14735698.activate)
c:RegisterEffect(e1)
--search
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_GRAVE)
e2:SetCondition(c14735698.thcon)
e2:SetCost(c14735698.thcost)
e2:SetTarget(c14735698.thtg)
e2:SetOperation(c14735698.thop)
c:RegisterEffect(e2)
end
function c14735698.filter(c,e,tp,m1,m2,ft)
if not c:IsSetCard(0xb4) or bit.band(c:GetType(),0x81)~=0x81
or not c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_RITUAL,tp,false,true) then return false end
local mg=m1:Filter(Card.IsCanBeRitualMaterial,c,c)
mg:Merge(m2)
if c:IsCode(21105106) then return c:ritual_custom_condition(mg,ft) end
if c.mat_filter then
mg=mg:Filter(c.mat_filter,nil)
end
if ft>0 then
return mg:CheckWithSumEqual(Card.GetRitualLevel,c:GetLevel(),1,99,c)
else
return ft>-1 and mg:IsExists(c14735698.mfilterf,1,nil,tp,mg,c)
end
end
function c14735698.mfilterf(c,tp,mg,rc)
if c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) then
Duel.SetSelectedCard(c)
return mg:CheckWithSumEqual(Card.GetRitualLevel,rc:GetLevel(),0,99,rc)
else return false end
end
function c14735698.mfilter(c)
return c:GetLevel()>0 and c:IsSetCard(0xb4) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemove()
end
function c14735698.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local mg1=Duel.GetRitualMaterial(tp)
local mg2=Duel.GetMatchingGroup(c14735698.mfilter,tp,LOCATION_GRAVE,0,nil)
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
return Duel.IsExistingMatchingCard(c14735698.filter,tp,LOCATION_HAND,0,1,nil,e,tp,mg1,mg2,ft)
end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND)
end
function c14735698.activate(e,tp,eg,ep,ev,re,r,rp)
local mg1=Duel.GetRitualMaterial(tp)
local mg2=Duel.GetMatchingGroup(c14735698.mfilter,tp,LOCATION_GRAVE,0,nil)
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tg=Duel.SelectMatchingCard(tp,c14735698.filter,tp,LOCATION_HAND,0,1,1,nil,e,tp,mg1,mg2,ft)
local tc=tg:GetFirst()
if tc then
local mg=mg1:Filter(Card.IsCanBeRitualMaterial,tc,tc)
mg:Merge(mg2)
if tc:IsCode(21105106) then
tc:ritual_custom_operation(mg)
local mat=tc:GetMaterial()
Duel.ReleaseRitualMaterial(mat)
else
if tc.mat_filter then
mg=mg:Filter(tc.mat_filter,nil)
end
local mat=nil
if ft>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
mat=mg:SelectWithSumEqual(tp,Card.GetRitualLevel,tc:GetLevel(),1,99,tc)
else
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
mat=mg:FilterSelect(tp,c14735698.mfilterf,1,1,nil,tp,mg,tc)
Duel.SetSelectedCard(mat)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
local mat2=mg:SelectWithSumEqual(tp,Card.GetRitualLevel,tc:GetLevel(),0,99,tc)
mat:Merge(mat2)
end
tc:SetMaterial(mat)
Duel.ReleaseRitualMaterial(mat)
end
Duel.BreakEffect()
Duel.SpecialSummon(tc,SUMMON_TYPE_RITUAL,tp,tp,false,true,POS_FACEUP)
tc:CompleteProcedure()
end
end
function c14735698.thcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)==0
end
function c14735698.cfilter(c)
return c:IsSetCard(0xb4) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost()
end
function c14735698.thcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost()
and Duel.IsExistingMatchingCard(c14735698.cfilter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectMatchingCard(tp,c14735698.cfilter,tp,LOCATION_GRAVE,0,1,1,nil)
g:AddCard(e:GetHandler())
Duel.Remove(g,POS_FACEUP,REASON_COST)
end
function c14735698.thfilter(c)
return c:IsSetCard(0xb4) and c:IsType(TYPE_SPELL) and c:IsAbleToHand()
end
function c14735698.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c14735698.thfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c14735698.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c14735698.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/languages/objc++/check_main.lua | 3 | 1130 | --!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 check_main.lua
--
-- check it
function main(sourcefile)
-- load source code
local sourcecode = io.readfile(sourcefile)
-- remove comment first
sourcecode = sourcecode:gsub("/%*.-%*/", "")
sourcecode = sourcecode:gsub("//.-\n", "\n")
-- find int main(int argc, char** argv) {}
if sourcecode:find("%s+main%s*%(.-%)") then
return true
end
-- no main function
return false
end
| apache-2.0 |
sempiternum/telegram-bot | plugins/danbooru.lua | 616 | 1750 | do
local URL = "http://danbooru.donmai.us"
local URL_NEW = "/posts.json"
local URL_POP = "/explore/posts/popular.json"
local scale_day = "?scale=day"
local scale_week = "?scale=week"
local scale_month = "?scale=month"
local function get_post(url)
local b, c, h = http.request(url)
if c ~= 200 then return nil end
local posts = json:decode(b)
return posts[math.random(#posts)]
end
local function run(msg, matches)
local url = URL
if matches[1] == "!danbooru" then
url = url .. URL_NEW
else
url = url .. URL_POP
if matches[1] == "d" then
url = url .. scale_day
elseif matches[1] == "w" then
url = url .. scale_week
elseif matches[1] == "m" then
url = url .. scale_month
end
end
local post = get_post(url)
if post then
vardump(post)
local img = URL .. post.large_file_url
send_photo_from_url(get_receiver(msg), img)
local txt = ''
if post.tag_string_artist ~= '' then
txt = 'Artist: ' .. post.tag_string_artist .. '\n'
end
if post.tag_string_character ~= '' then
txt = txt .. 'Character: ' .. post.tag_string_character .. '\n'
end
if post.file_size ~= '' then
txt = txt .. '[' .. math.ceil(post.file_size/1000) .. 'kb] ' .. URL .. post.file_url
end
return txt
end
end
return {
description = "Gets a random fresh or popular image from Danbooru",
usage = {
"!danbooru - gets a random fresh image from Danbooru 🔞",
"!danboorud - random daily popular image 🔞",
"!danbooruw - random weekly popular image 🔞",
"!danboorum - random monthly popular image 🔞"
},
patterns = {
"^!danbooru$",
"^!danbooru ?(d)$",
"^!danbooru ?(w)$",
"^!danbooru ?(m)$"
},
run = run
}
end | gpl-2.0 |
retep998/Vana | scripts/npcs/goback_cbd.lua | 2 | 2162 | --[[
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.
--]]
-- Kerny, sends player back to Singapore (from both in flight and waiting room and sends player to Kerning on the trip from Kerning)
dofile("scripts/utils/npcHelper.lua");
m = getMap();
if m == 540010001 then
-- Waiting room to Kerning
addText("The plane will be taking off soon. ");
addText("Will you leave now? ");
addText("You will have buy the plane ticket again to come in here.");
answer = askYesNo();
if answer == answer_yes then
addText("I have already told you the ticket is not refunable~ hope to see you again~");
sendOk();
setMap(540010000);
else
addText("Please hold on for a sec. ");
addText("The plane will be taking off soon. ");
addText("Thanks for your patience.");
sendOk();
end
elseif m == 540010002 then
-- Trip to Kerning
addText("The plane will be arriving soon. ");
addText("Are you sure you want to leave now? ");
answer = askYesNo();
if answer == answer_yes then
setMap(540010000);
else
addText("Please hold on for a sec. ");
addText("The plane will be arriving shortly. ");
addText("Thanks for your patience.");
sendOk();
end
elseif m == 540010101 then
-- Trip to CBD
addText("The plane will be arriving soon. ");
addText("Are you sure you want to leave now? ");
answer = askYesNo();
if answer == answer_yes then
setMap(103000000);
else
addText("Please hold on for a sec. ");
addText("The plane will be arriving shortly. ");
addText("Thanks for your patience.");
sendOk();
end
end | gpl-2.0 |
dr01d3r/darkstar | scripts/zones/Northern_San_dOria/npcs/Pinok-Morok.lua | 53 | 1880 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Pinok-Morok
-- Type: Smithing Synthesis Image Support
-- @pos -186.650 10.25 148.380 231
-----------------------------------
package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/crafting");
require("scripts/zones/Northern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local guildMember = isGuildMember(player,8);
local SkillCap = getCraftSkillCap(player,SKILL_SMITHING);
local SkillLevel = player:getSkillLevel(SKILL_SMITHING);
if (guildMember == 1) then
if (player:hasStatusEffect(EFFECT_SMITHING_IMAGERY) == false) then
player:startEvent(0x0275,SkillCap,SkillLevel,1,205,player:getGil(),0,4095,0);
else
player:startEvent(0x0275,SkillCap,SkillLevel,1,205,player:getGil(),7128,4095,0);
end
else
player:startEvent(0x0275,SkillCap,SkillLevel,1,201,player:getGil(),0,0,0); -- Standard Dialogue
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0275 and option == 1) then
player:messageSpecial(IMAGE_SUPPORT,0,2,1);
player:addStatusEffect(EFFECT_SMITHING_IMAGERY,1,0,120);
end
end; | gpl-3.0 |
dr01d3r/darkstar | scripts/globals/items/crepe_forestiere.lua | 12 | 1467 | -----------------------------------------
-- ID: 5774
-- Item: crepe_forestiere
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Mind 2
-- MP % 10 (cap 35)
-- Magic Accuracy +15
-- Magic Def. Bonus +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,1800,5774);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_MND, 2);
target:addMod(MOD_FOOD_MPP, 10);
target:addMod(MOD_FOOD_MP_CAP, 35);
target:addMod(MOD_MACC, 15);
target:addMod(MOD_MDEF, 6);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_MND, 2);
target:delMod(MOD_FOOD_MPP, 10);
target:delMod(MOD_FOOD_MP_CAP, 35);
target:delMod(MOD_MACC, 15);
target:delMod(MOD_MDEF, 6);
end;
| gpl-3.0 |
felipebetancur/omim | 3party/osrm/osrm-backend/profiles/bicycle.lua | 59 | 12992 | require("lib/access")
require("lib/maxspeed")
-- Begin of globals
barrier_whitelist = { [""] = true, ["cycle_barrier"] = true, ["bollard"] = true, ["entrance"] = true, ["cattle_grid"] = true, ["border_control"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true, ["no"] = true }
access_tag_whitelist = { ["yes"] = true, ["permissive"] = true, ["designated"] = true }
access_tag_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestery"] = true }
access_tag_restricted = { ["destination"] = true, ["delivery"] = true }
access_tags_hierachy = { "bicycle", "vehicle", "access" }
cycleway_tags = {["track"]=true,["lane"]=true,["opposite"]=true,["opposite_lane"]=true,["opposite_track"]=true,["share_busway"]=true,["sharrow"]=true,["shared"]=true }
service_tag_restricted = { ["parking_aisle"] = true }
restriction_exception_tags = { "bicycle", "vehicle", "access" }
default_speed = 15
walking_speed = 6
bicycle_speeds = {
["cycleway"] = default_speed,
["primary"] = default_speed,
["primary_link"] = default_speed,
["secondary"] = default_speed,
["secondary_link"] = default_speed,
["tertiary"] = default_speed,
["tertiary_link"] = default_speed,
["residential"] = default_speed,
["unclassified"] = default_speed,
["living_street"] = default_speed,
["road"] = default_speed,
["service"] = default_speed,
["track"] = 12,
["path"] = 12
--["footway"] = 12,
--["pedestrian"] = 12,
}
pedestrian_speeds = {
["footway"] = walking_speed,
["pedestrian"] = walking_speed,
["steps"] = 2
}
railway_speeds = {
["train"] = 10,
["railway"] = 10,
["subway"] = 10,
["light_rail"] = 10,
["monorail"] = 10,
["tram"] = 10
}
platform_speeds = {
["platform"] = walking_speed
}
amenity_speeds = {
["parking"] = 10,
["parking_entrance"] = 10
}
man_made_speeds = {
["pier"] = walking_speed
}
route_speeds = {
["ferry"] = 5
}
bridge_speeds = {
["movable"] = 5
}
surface_speeds = {
["asphalt"] = default_speed,
["cobblestone:flattened"] = 10,
["paving_stones"] = 10,
["compacted"] = 10,
["cobblestone"] = 6,
["unpaved"] = 6,
["fine_gravel"] = 6,
["gravel"] = 6,
["fine_gravel"] = 6,
["pebbelstone"] = 6,
["ground"] = 6,
["dirt"] = 6,
["earth"] = 6,
["grass"] = 6,
["mud"] = 3,
["sand"] = 3
}
take_minimum_of_speeds = true
obey_oneway = true
obey_bollards = false
use_restrictions = true
ignore_areas = true -- future feature
traffic_signal_penalty = 5
u_turn_penalty = 20
use_turn_restrictions = false
turn_penalty = 60
turn_bias = 1.4
--modes
mode_normal = 1
mode_pushing = 2
mode_ferry = 3
mode_train = 4
mode_movable_bridge = 5
local function parse_maxspeed(source)
if not source then
return 0
end
local n = tonumber(source:match("%d*"))
if not n then
n = 0
end
if string.match(source, "mph") or string.match(source, "mp/h") then
n = (n*1609)/1000;
end
return n
end
function get_exceptions(vector)
for i,v in ipairs(restriction_exception_tags) do
vector:Add(v)
end
end
function node_function (node, result)
local barrier = node:get_value_by_key("barrier")
local access = Access.find_access_tag(node, access_tags_hierachy)
local traffic_signal = node:get_value_by_key("highway")
-- flag node if it carries a traffic light
if traffic_signal and traffic_signal == "traffic_signals" then
result.traffic_lights = true
end
-- parse access and barrier tags
if access and access ~= "" then
if access_tag_blacklist[access] then
result.barrier = true
else
result.barrier = false
end
elseif barrier and barrier ~= "" then
if barrier_whitelist[barrier] then
result.barrier = false
else
result.barrier = true
end
end
end
function way_function (way, result)
-- initial routability check, filters out buildings, boundaries, etc
local highway = way:get_value_by_key("highway")
local route = way:get_value_by_key("route")
local man_made = way:get_value_by_key("man_made")
local railway = way:get_value_by_key("railway")
local amenity = way:get_value_by_key("amenity")
local public_transport = way:get_value_by_key("public_transport")
local bridge = way:get_value_by_key("bridge")
if (not highway or highway == '') and
(not route or route == '') and
(not railway or railway=='') and
(not amenity or amenity=='') and
(not man_made or man_made=='') and
(not public_transport or public_transport=='') and
(not bridge or bridge=='')
then
return
end
-- don't route on ways or railways that are still under construction
if highway=='construction' or railway=='construction' then
return
end
-- access
local access = Access.find_access_tag(way, access_tags_hierachy)
if access and access_tag_blacklist[access] then
return
end
-- other tags
local name = way:get_value_by_key("name")
local ref = way:get_value_by_key("ref")
local junction = way:get_value_by_key("junction")
local maxspeed = parse_maxspeed(way:get_value_by_key ( "maxspeed") )
local maxspeed_forward = parse_maxspeed(way:get_value_by_key( "maxspeed:forward"))
local maxspeed_backward = parse_maxspeed(way:get_value_by_key( "maxspeed:backward"))
local barrier = way:get_value_by_key("barrier")
local oneway = way:get_value_by_key("oneway")
local onewayClass = way:get_value_by_key("oneway:bicycle")
local cycleway = way:get_value_by_key("cycleway")
local cycleway_left = way:get_value_by_key("cycleway:left")
local cycleway_right = way:get_value_by_key("cycleway:right")
local duration = way:get_value_by_key("duration")
local service = way:get_value_by_key("service")
local area = way:get_value_by_key("area")
local foot = way:get_value_by_key("foot")
local surface = way:get_value_by_key("surface")
local bicycle = way:get_value_by_key("bicycle")
-- name
if ref and "" ~= ref and name and "" ~= name then
result.name = name .. ' / ' .. ref
elseif ref and "" ~= ref then
result.name = ref
elseif name and "" ~= name then
result.name = name
elseif highway then
-- if no name exists, use way type
-- this encoding scheme is excepted to be a temporary solution
result.name = "{highway:"..highway.."}"
end
-- roundabout handling
if junction and "roundabout" == junction then
result.roundabout = true;
end
-- speed
local bridge_speed = bridge_speeds[bridge]
if (bridge_speed and bridge_speed > 0) then
highway = bridge;
if duration and durationIsValid(duration) then
result.duration = math.max( parseDuration(duration), 1 );
end
result.forward_mode = mode_movable_bridge
result.backward_mode = mode_movable_bridge
result.forward_speed = bridge_speed
result.backward_speed = bridge_speed
elseif route_speeds[route] then
-- ferries (doesn't cover routes tagged using relations)
result.forward_mode = mode_ferry
result.backward_mode = mode_ferry
result.ignore_in_grid = true
if duration and durationIsValid(duration) then
result.duration = math.max( 1, parseDuration(duration) )
else
result.forward_speed = route_speeds[route]
result.backward_speed = route_speeds[route]
end
elseif railway and platform_speeds[railway] then
-- railway platforms (old tagging scheme)
result.forward_speed = platform_speeds[railway]
result.backward_speed = platform_speeds[railway]
elseif platform_speeds[public_transport] then
-- public_transport platforms (new tagging platform)
result.forward_speed = platform_speeds[public_transport]
result.backward_speed = platform_speeds[public_transport]
elseif railway and railway_speeds[railway] then
result.forward_mode = mode_train
result.backward_mode = mode_train
-- railways
if access and access_tag_whitelist[access] then
result.forward_speed = railway_speeds[railway]
result.backward_speed = railway_speeds[railway]
end
elseif amenity and amenity_speeds[amenity] then
-- parking areas
result.forward_speed = amenity_speeds[amenity]
result.backward_speed = amenity_speeds[amenity]
elseif bicycle_speeds[highway] then
-- regular ways
result.forward_speed = bicycle_speeds[highway]
result.backward_speed = bicycle_speeds[highway]
elseif access and access_tag_whitelist[access] then
-- unknown way, but valid access tag
result.forward_speed = default_speed
result.backward_speed = default_speed
else
-- biking not allowed, maybe we can push our bike?
-- essentially requires pedestrian profiling, for example foot=no mean we can't push a bike
if foot ~= 'no' and junction ~= "roundabout" then
if pedestrian_speeds[highway] then
-- pedestrian-only ways and areas
result.forward_speed = pedestrian_speeds[highway]
result.backward_speed = pedestrian_speeds[highway]
result.forward_mode = mode_pushing
result.backward_mode = mode_pushing
elseif man_made and man_made_speeds[man_made] then
-- man made structures
result.forward_speed = man_made_speeds[man_made]
result.backward_speed = man_made_speeds[man_made]
result.forward_mode = mode_pushing
result.backward_mode = mode_pushing
elseif foot == 'yes' then
result.forward_speed = walking_speed
result.backward_speed = walking_speed
result.forward_mode = mode_pushing
result.backward_mode = mode_pushing
elseif foot_forward == 'yes' then
result.forward_speed = walking_speed
result.forward_mode = mode_pushing
result.backward_mode = 0
elseif foot_backward == 'yes' then
result.forward_speed = walking_speed
result.forward_mode = 0
result.backward_mode = mode_pushing
end
end
end
-- direction
local impliedOneway = false
if junction == "roundabout" or highway == "motorway_link" or highway == "motorway" then
impliedOneway = true
end
if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then
result.backward_mode = 0
elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then
-- prevent implied oneway
elseif onewayClass == "-1" then
result.forward_mode = 0
elseif oneway == "no" or oneway == "0" or oneway == "false" then
-- prevent implied oneway
elseif cycleway and string.find(cycleway, "opposite") == 1 then
if impliedOneway then
result.forward_mode = 0
result.backward_mode = mode_normal
result.backward_speed = bicycle_speeds["cycleway"]
end
elseif cycleway_left and cycleway_tags[cycleway_left] and cycleway_right and cycleway_tags[cycleway_right] then
-- prevent implied
elseif cycleway_left and cycleway_tags[cycleway_left] then
if impliedOneway then
result.forward_mode = 0
result.backward_mode = mode_normal
result.backward_speed = bicycle_speeds["cycleway"]
end
elseif cycleway_right and cycleway_tags[cycleway_right] then
if impliedOneway then
result.forward_mode = mode_normal
result.backward_speed = bicycle_speeds["cycleway"]
result.backward_mode = 0
end
elseif oneway == "-1" then
result.forward_mode = 0
elseif oneway == "yes" or oneway == "1" or oneway == "true" or impliedOneway then
result.backward_mode = 0
end
-- pushing bikes
if bicycle_speeds[highway] or pedestrian_speeds[highway] then
if foot ~= "no" and junction ~= "roundabout" then
if result.backward_mode == 0 then
result.backward_speed = walking_speed
result.backward_mode = mode_pushing
elseif result.forward_mode == 0 then
result.forward_speed = walking_speed
result.forward_mode = mode_pushing
end
end
end
-- cycleways
if cycleway and cycleway_tags[cycleway] then
result.forward_speed = bicycle_speeds["cycleway"]
elseif cycleway_left and cycleway_tags[cycleway_left] then
result.forward_speed = bicycle_speeds["cycleway"]
elseif cycleway_right and cycleway_tags[cycleway_right] then
result.forward_speed = bicycle_speeds["cycleway"]
end
-- dismount
if bicycle == "dismount" then
result.forward_mode = mode_pushing
result.backward_mode = mode_pushing
result.forward_speed = walking_speed
result.backward_speed = walking_speed
end
-- surfaces
if surface then
surface_speed = surface_speeds[surface]
if surface_speed then
if result.forward_speed > 0 then
result.forward_speed = surface_speed
end
if result.backward_speed > 0 then
result.backward_speed = surface_speed
end
end
end
-- maxspeed
MaxSpeed.limit( result, maxspeed, maxspeed_forward, maxspeed_backward )
end
function turn_function (angle)
-- compute turn penalty as angle^2, with a left/right bias
k = turn_penalty/(90.0*90.0)
if angle>=0 then
return angle*angle*k/turn_bias
else
return angle*angle*k*turn_bias
end
end
| apache-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c54860010.lua | 9 | 1914 | --ワーム・プリンス
function c54860010.initial_effect(c)
--search
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(54860010,0))
e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_BATTLE_DESTROYING)
e1:SetTarget(c54860010.thtg)
e1:SetOperation(c54860010.thop)
c:RegisterEffect(e1)
--destroy
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(54860010,1))
e2:SetCategory(CATEGORY_DESTROY)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e2:SetCode(EVENT_PHASE+PHASE_END)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1)
e2:SetCondition(c54860010.descon)
e2:SetTarget(c54860010.destg)
e2:SetOperation(c54860010.desop)
c:RegisterEffect(e2)
end
function c54860010.filter(c)
return c:IsSetCard(0x3e) and c:IsRace(RACE_REPTILE) and c:IsAbleToHand()
end
function c54860010.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c54860010.filter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c54860010.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c54860010.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
function c54860010.cfilter(c)
return c:IsFaceup() and c:IsSetCard(0x3e) and c:IsRace(RACE_REPTILE)
end
function c54860010.descon(e,tp,eg,ep,ev,re,r,rp)
return not Duel.IsExistingMatchingCard(c54860010.cfilter,tp,LOCATION_MZONE,0,1,e:GetHandler())
end
function c54860010.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 c54860010.desop(e,tp,eg,ep,ev,re,r,rp)
if e:GetHandler():IsRelateToEffect(e) then
Duel.Destroy(e:GetHandler(),REASON_EFFECT)
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c31053337.lua | 2 | 2424 | --BF-激震のアブロオロス
function c31053337.initial_effect(c)
--special summon limit
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
e1:SetValue(aux.FALSE)
c:RegisterEffect(e1)
--to hand1
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(31053337,0))
e2:SetCategory(CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetCountLimit(1)
e2:SetRange(LOCATION_MZONE)
e2:SetCondition(c31053337.condition)
e2:SetTarget(c31053337.target)
e2:SetOperation(c31053337.operation)
c:RegisterEffect(e2)
--indes
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e3:SetRange(LOCATION_MZONE)
e3:SetTargetRange(0,LOCATION_MZONE)
e3:SetTarget(c31053337.indestg)
e3:SetValue(1)
c:RegisterEffect(e3)
--to hand2
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(31053337,1))
e4:SetCategory(CATEGORY_TOHAND)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e4:SetCode(EVENT_BATTLED)
e4:SetOperation(c31053337.operation2)
c:RegisterEffect(e4)
end
function c31053337.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()==PHASE_MAIN1
end
function c31053337.filter(c)
return c:IsAbleToHand() and c:GetSequence()<5
end
function c31053337.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():GetAttack()>=1000 and Duel.IsExistingMatchingCard(c31053337.filter,tp,0,LOCATION_SZONE,1,nil) end
local g=Duel.GetMatchingGroup(c31053337.filter,tp,0,LOCATION_SZONE,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,g:GetCount(),0,0)
end
function c31053337.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) and c:IsFaceup() then
local g=Duel.GetMatchingGroup(c31053337.filter,tp,0,LOCATION_SZONE,nil)
Duel.SendtoHand(g,nil,REASON_EFFECT)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_COPY_INHERIT)
e1:SetReset(RESET_EVENT+0x1ff0000)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(-1000)
c:RegisterEffect(e1)
end
end
function c31053337.indestg(e,c)
return c==e:GetHandler():GetBattleTarget()
end
function c31053337.operation2(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local bc=c:GetBattleTarget()
if bc and bc:IsRelateToBattle() then
Duel.SendtoHand(bc,nil,REASON_EFFECT)
end
end
| gpl-2.0 |
ghoulsblade/vegaogre | lugre/lib/LuaJIT-1.1.5/dynasm/dynasm.lua | 3 | 30171 | ------------------------------------------------------------------------------
-- DynASM. A dynamic assembler for code generation engines.
-- Originally designed and implemented for LuaJIT.
--
-- Copyright (C) 2005-2008 Mike Pall. All rights reserved.
-- See below for full copyright notice.
------------------------------------------------------------------------------
-- Application information.
local _info = {
name = "DynASM",
description = "A dynamic assembler for code generation engines",
version = "1.1.4",
vernum = 10104,
release = "2008-01-29",
author = "Mike Pall",
url = "http://luajit.org/dynasm.html",
license = "MIT",
copyright = [[
Copyright (C) 2005-2008 Mike Pall. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[ MIT license: http://www.opensource.org/licenses/mit-license.php ]
]],
}
-- Cache library functions.
local type, pairs, ipairs = type, pairs, ipairs
local pcall, error, assert = pcall, error, assert
local _s = string
local sub, match, gmatch, gsub = _s.sub, _s.match, _s.gmatch, _s.gsub
local format, rep, upper = _s.format, _s.rep, _s.upper
local _t = table
local insert, remove, concat, sort = _t.insert, _t.remove, _t.concat, _t.sort
local exit = os.exit
local io = io
local stdin, stdout, stderr = io.stdin, io.stdout, io.stderr
------------------------------------------------------------------------------
-- Program options.
local g_opt = {}
-- Global state for current file.
local g_fname, g_curline, g_indent, g_lineno, g_synclineno, g_arch
local g_errcount = 0
-- Write buffer for output file.
local g_wbuffer, g_capbuffer
------------------------------------------------------------------------------
-- Write an output line (or callback function) to the buffer.
local function wline(line, needindent)
local buf = g_capbuffer or g_wbuffer
buf[#buf+1] = needindent and g_indent..line or line
g_synclineno = g_synclineno + 1
end
-- Write assembler line as a comment, if requestd.
local function wcomment(aline)
if g_opt.comment then
wline(g_opt.comment..aline..g_opt.endcomment, true)
end
end
-- Resync CPP line numbers.
local function wsync()
if g_synclineno ~= g_lineno and g_opt.cpp then
wline("# "..g_lineno..' "'..g_fname..'"')
g_synclineno = g_lineno
end
end
-- Dummy action flush function. Replaced with arch-specific function later.
local function wflush(term)
end
-- Dump all buffered output lines.
local function wdumplines(out, buf)
for _,line in ipairs(buf) do
if type(line) == "string" then
assert(out:write(line, "\n"))
else
-- Special callback to dynamically insert lines after end of processing.
line(out)
end
end
end
------------------------------------------------------------------------------
-- Emit an error. Processing continues with next statement.
local function werror(msg)
error(format("%s:%s: error: %s:\n%s", g_fname, g_lineno, msg, g_curline), 0)
end
-- Emit a fatal error. Processing stops.
local function wfatal(msg)
g_errcount = "fatal"
werror(msg)
end
-- Print a warning. Processing continues.
local function wwarn(msg)
stderr:write(format("%s:%s: warning: %s:\n%s\n",
g_fname, g_lineno, msg, g_curline))
end
-- Print caught error message. But suppress excessive errors.
local function wprinterr(...)
if type(g_errcount) == "number" then
-- Regular error.
g_errcount = g_errcount + 1
if g_errcount < 21 then -- Seems to be a reasonable limit.
stderr:write(...)
elseif g_errcount == 21 then
stderr:write(g_fname,
":*: warning: too many errors (suppressed further messages).\n")
end
else
-- Fatal error.
stderr:write(...)
return true -- Stop processing.
end
end
------------------------------------------------------------------------------
-- Map holding all option handlers.
local opt_map = {}
local opt_current
-- Print error and exit with error status.
local function opterror(...)
stderr:write("dynasm.lua: ERROR: ", ...)
stderr:write("\n")
exit(1)
end
-- Get option parameter.
local function optparam(args)
local argn = args.argn
local p = args[argn]
if not p then
opterror("missing parameter for option `", opt_current, "'.")
end
args.argn = argn + 1
return p
end
------------------------------------------------------------------------------
-- Core pseudo-opcodes.
local map_coreop = {}
-- Dummy opcode map. Replaced by arch-specific map.
local map_op = {}
-- Forward declarations.
local dostmt
local readfile
------------------------------------------------------------------------------
-- Map for defines (initially empty, chains to arch-specific map).
local map_def = {}
-- Pseudo-opcode to define a substitution.
map_coreop[".define_2"] = function(params, nparams)
if not params then return nparams == 1 and "name" or "name, subst" end
local name, def = params[1], params[2] or "1"
if not match(name, "^[%a_][%w_]*$") then werror("bad or duplicate define") end
map_def[name] = def
end
map_coreop[".define_1"] = map_coreop[".define_2"]
-- Define a substitution on the command line.
function opt_map.D(args)
local namesubst = optparam(args)
local name, subst = match(namesubst, "^([%a_][%w_]*)=(.*)$")
if name then
map_def[name] = subst
elseif match(namesubst, "^[%a_][%w_]*$") then
map_def[namesubst] = "1"
else
opterror("bad define")
end
end
-- Undefine a substitution on the command line.
function opt_map.U(args)
local name = optparam(args)
if match(name, "^[%a_][%w_]*$") then
map_def[name] = nil
else
opterror("bad define")
end
end
-- Helper for definesubst.
local gotsubst
local function definesubst_one(word)
local subst = map_def[word]
if subst then gotsubst = word; return subst else return word end
end
-- Iteratively substitute defines.
local function definesubst(stmt)
-- Limit number of iterations.
for i=1,100 do
gotsubst = false
stmt = gsub(stmt, "#?[%w_]+", definesubst_one)
if not gotsubst then break end
end
if gotsubst then wfatal("recursive define involving `"..gotsubst.."'") end
return stmt
end
-- Dump all defines.
local function dumpdefines(out, lvl)
local t = {}
for name in pairs(map_def) do
t[#t+1] = name
end
sort(t)
out:write("Defines:\n")
for _,name in ipairs(t) do
local subst = map_def[name]
if g_arch then subst = g_arch.revdef(subst) end
out:write(format(" %-20s %s\n", name, subst))
end
out:write("\n")
end
------------------------------------------------------------------------------
-- Support variables for conditional assembly.
local condlevel = 0
local condstack = {}
-- Evaluate condition with a Lua expression. Substitutions already performed.
local function cond_eval(cond)
local func, err = loadstring("return "..cond)
if func then
setfenv(func, {}) -- No globals. All unknown identifiers evaluate to nil.
local ok, res = pcall(func)
if ok then
if res == 0 then return false end -- Oh well.
return not not res
end
err = res
end
wfatal("bad condition: "..err)
end
-- Skip statements until next conditional pseudo-opcode at the same level.
local function stmtskip()
local dostmt_save = dostmt
local lvl = 0
dostmt = function(stmt)
local op = match(stmt, "^%s*(%S+)")
if op == ".if" then
lvl = lvl + 1
elseif lvl ~= 0 then
if op == ".endif" then lvl = lvl - 1 end
elseif op == ".elif" or op == ".else" or op == ".endif" then
dostmt = dostmt_save
dostmt(stmt)
end
end
end
-- Pseudo-opcodes for conditional assembly.
map_coreop[".if_1"] = function(params)
if not params then return "condition" end
local lvl = condlevel + 1
local res = cond_eval(params[1])
condlevel = lvl
condstack[lvl] = res
if not res then stmtskip() end
end
map_coreop[".elif_1"] = function(params)
if not params then return "condition" end
if condlevel == 0 then wfatal(".elif without .if") end
local lvl = condlevel
local res = condstack[lvl]
if res then
if res == "else" then wfatal(".elif after .else") end
else
res = cond_eval(params[1])
if res then
condstack[lvl] = res
return
end
end
stmtskip()
end
map_coreop[".else_0"] = function(params)
if condlevel == 0 then wfatal(".else without .if") end
local lvl = condlevel
local res = condstack[lvl]
condstack[lvl] = "else"
if res then
if res == "else" then wfatal(".else after .else") end
stmtskip()
end
end
map_coreop[".endif_0"] = function(params)
local lvl = condlevel
if lvl == 0 then wfatal(".endif without .if") end
condlevel = lvl - 1
end
-- Check for unfinished conditionals.
local function checkconds()
if g_errcount ~= "fatal" and condlevel ~= 0 then
wprinterr(g_fname, ":*: error: unbalanced conditional\n")
end
end
------------------------------------------------------------------------------
-- Search for a file in the given path and open it for reading.
local function pathopen(path, name)
local dirsep = match(package.path, "\\") and "\\" or "/"
for _,p in ipairs(path) do
local fullname = p == "" and name or p..dirsep..name
local fin = io.open(fullname, "r")
if fin then
g_fname = fullname
return fin
end
end
end
-- Include a file.
map_coreop[".include_1"] = function(params)
if not params then return "filename" end
local name = params[1]
-- Save state. Ugly, I know. but upvalues are fast.
local gf, gl, gcl, gi = g_fname, g_lineno, g_curline, g_indent
-- Read the included file.
local fatal = readfile(pathopen(g_opt.include, name) or
wfatal("include file `"..name.."' not found"))
-- Restore state.
g_synclineno = -1
g_fname, g_lineno, g_curline, g_indent = gf, gl, gcl, gi
if fatal then wfatal("in include file") end
end
-- Make .include initially available, too.
map_op[".include_1"] = map_coreop[".include_1"]
------------------------------------------------------------------------------
-- Support variables for macros.
local mac_capture, mac_lineno, mac_name
local mac_active = {}
local mac_list = {}
-- Pseudo-opcode to define a macro.
map_coreop[".macro_*"] = function(mparams)
if not mparams then return "name [, params...]" end
-- Split off and validate macro name.
local name = remove(mparams, 1)
if not name then werror("missing macro name") end
if not (match(name, "^[%a_][%w_%.]*$") or match(name, "^%.[%w_%.]+$")) then
wfatal("bad macro name `"..name.."'")
end
-- Validate macro parameter names.
local mdup = {}
for _,mp in ipairs(mparams) do
if not match(mp, "^[%a_][%w_]*$") then
wfatal("bad macro parameter name `"..mp.."'")
end
if mdup[mp] then wfatal("duplicate macro parameter name `"..mp.."'") end
mdup[mp] = true
end
-- Check for duplicate or recursive macro definitions.
local opname = name.."_"..#mparams
if map_op[opname] or map_op[name.."_*"] then
wfatal("duplicate macro `"..name.."' ("..#mparams.." parameters)")
end
if mac_capture then wfatal("recursive macro definition") end
-- Enable statement capture.
local lines = {}
mac_lineno = g_lineno
mac_name = name
mac_capture = function(stmt) -- Statement capture function.
-- Stop macro definition with .endmacro pseudo-opcode.
if not match(stmt, "^%s*.endmacro%s*$") then
lines[#lines+1] = stmt
return
end
mac_capture = nil
mac_lineno = nil
mac_name = nil
mac_list[#mac_list+1] = opname
-- Add macro-op definition.
map_op[opname] = function(params)
if not params then return mparams, lines end
-- Protect against recursive macro invocation.
if mac_active[opname] then wfatal("recursive macro invocation") end
mac_active[opname] = true
-- Setup substitution map.
local subst = {}
for i,mp in ipairs(mparams) do subst[mp] = params[i] end
local mcom
if g_opt.maccomment and g_opt.comment then
mcom = " MACRO "..name.." ("..#mparams..")"
wcomment("{"..mcom)
end
-- Loop through all captured statements
for _,stmt in ipairs(lines) do
-- Substitute macro parameters.
local st = gsub(stmt, "[%w_]+", subst)
st = definesubst(st)
st = gsub(st, "%s*%.%.%s*", "") -- Token paste a..b.
if mcom and sub(st, 1, 1) ~= "|" then wcomment(st) end
-- Emit statement. Use a protected call for better diagnostics.
local ok, err = pcall(dostmt, st)
if not ok then
-- Add the captured statement to the error.
wprinterr(err, "\n", g_indent, "| ", stmt,
"\t[MACRO ", name, " (", #mparams, ")]\n")
end
end
if mcom then wcomment("}"..mcom) end
mac_active[opname] = nil
end
end
end
-- An .endmacro pseudo-opcode outside of a macro definition is an error.
map_coreop[".endmacro_0"] = function(params)
wfatal(".endmacro without .macro")
end
-- Dump all macros and their contents (with -PP only).
local function dumpmacros(out, lvl)
sort(mac_list)
out:write("Macros:\n")
for _,opname in ipairs(mac_list) do
local name = sub(opname, 1, -3)
local params, lines = map_op[opname]()
out:write(format(" %-20s %s\n", name, concat(params, ", ")))
if lvl > 1 then
for _,line in ipairs(lines) do
out:write(" |", line, "\n")
end
out:write("\n")
end
end
out:write("\n")
end
-- Check for unfinished macro definitions.
local function checkmacros()
if mac_capture then
wprinterr(g_fname, ":", mac_lineno,
": error: unfinished .macro `", mac_name ,"'\n")
end
end
------------------------------------------------------------------------------
-- Support variables for captures.
local cap_lineno, cap_name
local cap_buffers = {}
local cap_used = {}
-- Start a capture.
map_coreop[".capture_1"] = function(params)
if not params then return "name" end
wflush()
local name = params[1]
if not match(name, "^[%a_][%w_]*$") then
wfatal("bad capture name `"..name.."'")
end
if cap_name then
wfatal("already capturing to `"..cap_name.."' since line "..cap_lineno)
end
cap_name = name
cap_lineno = g_lineno
-- Create or continue a capture buffer and start the output line capture.
local buf = cap_buffers[name]
if not buf then buf = {}; cap_buffers[name] = buf end
g_capbuffer = buf
g_synclineno = 0
end
-- Stop a capture.
map_coreop[".endcapture_0"] = function(params)
wflush()
if not cap_name then wfatal(".endcapture without a valid .capture") end
cap_name = nil
cap_lineno = nil
g_capbuffer = nil
g_synclineno = 0
end
-- Dump a capture buffer.
map_coreop[".dumpcapture_1"] = function(params)
if not params then return "name" end
wflush()
local name = params[1]
if not match(name, "^[%a_][%w_]*$") then
wfatal("bad capture name `"..name.."'")
end
cap_used[name] = true
wline(function(out)
local buf = cap_buffers[name]
if buf then wdumplines(out, buf) end
end)
g_synclineno = 0
end
-- Dump all captures and their buffers (with -PP only).
local function dumpcaptures(out, lvl)
out:write("Captures:\n")
for name,buf in pairs(cap_buffers) do
out:write(format(" %-20s %4s)\n", name, "("..#buf))
if lvl > 1 then
local bar = rep("=", 76)
out:write(" ", bar, "\n")
for _,line in ipairs(buf) do
out:write(" ", line, "\n")
end
out:write(" ", bar, "\n\n")
end
end
out:write("\n")
end
-- Check for unfinished or unused captures.
local function checkcaptures()
if cap_name then
wprinterr(g_fname, ":", cap_lineno,
": error: unfinished .capture `", cap_name,"'\n")
return
end
for name in pairs(cap_buffers) do
if not cap_used[name] then
wprinterr(g_fname, ":*: error: missing .dumpcapture ", name ,"\n")
end
end
end
------------------------------------------------------------------------------
-- Sections names.
local map_sections = {}
-- Pseudo-opcode to define code sections.
-- TODO: Data sections, BSS sections. Needs extra C code and API.
map_coreop[".section_*"] = function(params)
if not params then return "name..." end
if #map_sections > 0 then werror("duplicate section definition") end
wflush()
for sn,name in ipairs(params) do
local opname = "."..name.."_0"
if not match(name, "^[%a][%w_]*$") or
map_op[opname] or map_op["."..name.."_*"] then
werror("bad section name `"..name.."'")
end
map_sections[#map_sections+1] = name
wline(format("#define DASM_SECTION_%s\t%d", upper(name), sn-1))
map_op[opname] = function(params) g_arch.section(sn-1) end
end
wline(format("#define DASM_MAXSECTION\t\t%d", #map_sections))
end
-- Dump all sections.
local function dumpsections(out, lvl)
out:write("Sections:\n")
for _,name in ipairs(map_sections) do
out:write(format(" %s\n", name))
end
out:write("\n")
end
------------------------------------------------------------------------------
-- Load architecture-specific module.
local function loadarch(arch)
if not match(arch, "^[%w_]+$") then return "bad arch name" end
local ok, m_arch = pcall(require, "dasm_"..arch)
if not ok then return "cannot load module: "..m_arch end
g_arch = m_arch
wflush = m_arch.passcb(wline, werror, wfatal, wwarn)
m_arch.setup(arch, g_opt)
map_op, map_def = m_arch.mergemaps(map_coreop, map_def)
end
-- Dump architecture description.
function opt_map.dumparch(args)
local name = optparam(args)
if not g_arch then
local err = loadarch(name)
if err then opterror(err) end
end
local t = {}
for name in pairs(map_coreop) do t[#t+1] = name end
for name in pairs(map_op) do t[#t+1] = name end
sort(t)
local out = stdout
local _arch = g_arch._info
out:write(format("%s version %s, released %s, %s\n",
_info.name, _info.version, _info.release, _info.url))
g_arch.dumparch(out)
local pseudo = true
out:write("Pseudo-Opcodes:\n")
for _,sname in ipairs(t) do
local name, nparam = match(sname, "^(.+)_([0-9%*])$")
if name then
if pseudo and sub(name, 1, 1) ~= "." then
out:write("\nOpcodes:\n")
pseudo = false
end
local f = map_op[sname]
local s
if nparam ~= "*" then nparam = nparam + 0 end
if nparam == 0 then
s = ""
elseif type(f) == "string" then
s = map_op[".template__"](nil, f, nparam)
else
s = f(nil, nparam)
end
if type(s) == "table" then
for _,s2 in ipairs(s) do
out:write(format(" %-12s %s\n", name, s2))
end
else
out:write(format(" %-12s %s\n", name, s))
end
end
end
out:write("\n")
exit(0)
end
-- Pseudo-opcode to set the architecture.
-- Only initially available (map_op is replaced when called).
map_op[".arch_1"] = function(params)
if not params then return "name" end
local err = loadarch(params[1])
if err then wfatal(err) end
end
-- Dummy .arch pseudo-opcode to improve the error report.
map_coreop[".arch_1"] = function(params)
if not params then return "name" end
wfatal("duplicate .arch statement")
end
------------------------------------------------------------------------------
-- Dummy pseudo-opcode. Don't confuse '.nop' with 'nop'.
map_coreop[".nop_*"] = function(params)
if not params then return "[ignored...]" end
end
-- Pseudo-opcodes to raise errors.
map_coreop[".error_1"] = function(params)
if not params then return "message" end
werror(params[1])
end
map_coreop[".fatal_1"] = function(params)
if not params then return "message" end
wfatal(params[1])
end
-- Dump all user defined elements.
local function dumpdef(out)
local lvl = g_opt.dumpdef
if lvl == 0 then return end
dumpsections(out, lvl)
dumpdefines(out, lvl)
if g_arch then g_arch.dumpdef(out, lvl) end
dumpmacros(out, lvl)
dumpcaptures(out, lvl)
end
------------------------------------------------------------------------------
-- Helper for splitstmt.
local splitlvl
local function splitstmt_one(c)
if c == "(" then
splitlvl = ")"..splitlvl
elseif c == "[" then
splitlvl = "]"..splitlvl
elseif c == ")" or c == "]" then
if sub(splitlvl, 1, 1) ~= c then werror("unbalanced () or []") end
splitlvl = sub(splitlvl, 2)
elseif splitlvl == "" then
return " \0 "
end
return c
end
-- Split statement into (pseudo-)opcode and params.
local function splitstmt(stmt)
-- Convert label with trailing-colon into .label statement.
local label = match(stmt, "^%s*(.+):%s*$")
if label then return ".label", {label} end
-- Split at commas and equal signs, but obey parentheses and brackets.
splitlvl = ""
stmt = gsub(stmt, "[,%(%)%[%]]", splitstmt_one)
if splitlvl ~= "" then werror("unbalanced () or []") end
-- Split off opcode.
local op, other = match(stmt, "^%s*([^%s%z]+)%s*(.*)$")
if not op then werror("bad statement syntax") end
-- Split parameters.
local params = {}
for p in gmatch(other, "%s*(%Z+)%z?") do
params[#params+1] = gsub(p, "%s+$", "")
end
if #params > 16 then werror("too many parameters") end
params.op = op
return op, params
end
-- Process a single statement.
dostmt = function(stmt)
-- Ignore empty statements.
if match(stmt, "^%s*$") then return end
-- Capture macro defs before substitution.
if mac_capture then return mac_capture(stmt) end
stmt = definesubst(stmt)
-- Emit C code without parsing the line.
if sub(stmt, 1, 1) == "|" then
local tail = sub(stmt, 2)
wflush()
if sub(tail, 1, 2) == "//" then wcomment(tail) else wline(tail, true) end
return
end
-- Split into (pseudo-)opcode and params.
local op, params = splitstmt(stmt)
-- Get opcode handler (matching # of parameters or generic handler).
local f = map_op[op.."_"..#params] or map_op[op.."_*"]
if not f then
if not g_arch then wfatal("first statement must be .arch") end
-- Improve error report.
for i=0,16 do
if map_op[op.."_"..i] then
werror("wrong number of parameters for `"..op.."'")
end
end
werror("unknown statement `"..op.."'")
end
-- Call opcode handler or special handler for template strings.
if type(f) == "string" then
map_op[".template__"](params, f)
else
f(params)
end
end
-- Process a single line.
local function doline(line)
if g_opt.flushline then wflush() end
-- Assembler line?
local indent, aline = match(line, "^(%s*)%|(.*)$")
if not aline then
-- No, plain C code line, need to flush first.
wflush()
wsync()
wline(line, false)
return
end
g_indent = indent -- Remember current line indentation.
-- Emit C code (even from macros). Avoids echo and line parsing.
if sub(aline, 1, 1) == "|" then
if not mac_capture then
wsync()
elseif g_opt.comment then
wsync()
wcomment(aline)
end
dostmt(aline)
return
end
-- Echo assembler line as a comment.
if g_opt.comment then
wsync()
wcomment(aline)
end
-- Strip assembler comments.
aline = gsub(aline, "//.*$", "")
-- Split line into statements at semicolons.
if match(aline, ";") then
for stmt in gmatch(aline, "[^;]+") do dostmt(stmt) end
else
dostmt(aline)
end
end
------------------------------------------------------------------------------
-- Write DynASM header.
local function dasmhead(out)
out:write(format([[
/*
** This file has been pre-processed with DynASM.
** %s
** DynASM version %s, DynASM %s version %s
** DO NOT EDIT! The original file is in "%s".
*/
#if DASM_VERSION != %d
#error "Version mismatch between DynASM and included encoding engine"
#endif
]], _info.url,
_info.version, g_arch._info.arch, g_arch._info.version,
g_fname, _info.vernum))
end
-- Read input file.
readfile = function(fin)
g_indent = ""
g_lineno = 0
g_synclineno = -1
-- Process all lines.
for line in fin:lines() do
g_lineno = g_lineno + 1
g_curline = line
local ok, err = pcall(doline, line)
if not ok and wprinterr(err, "\n") then return true end
end
wflush()
-- Close input file.
assert(fin == stdin or fin:close())
end
-- Write output file.
local function writefile(outfile)
local fout
-- Open output file.
if outfile == nil or outfile == "-" then
fout = stdout
else
fout = assert(io.open(outfile, "w"))
end
-- Write all buffered lines
wdumplines(fout, g_wbuffer)
-- Close output file.
assert(fout == stdout or fout:close())
-- Optionally dump definitions.
dumpdef(fout == stdout and stderr or stdout)
end
-- Translate an input file to an output file.
local function translate(infile, outfile)
g_wbuffer = {}
g_indent = ""
g_lineno = 0
g_synclineno = -1
-- Put header.
wline(dasmhead)
-- Read input file.
local fin
if infile == "-" then
g_fname = "(stdin)"
fin = stdin
else
g_fname = infile
fin = assert(io.open(infile, "r"))
end
readfile(fin)
-- Check for errors.
if not g_arch then
wprinterr(g_fname, ":*: error: missing .arch directive\n")
end
checkconds()
checkmacros()
checkcaptures()
if g_errcount ~= 0 then
stderr:write(g_fname, ":*: info: ", g_errcount, " error",
(type(g_errcount) == "number" and g_errcount > 1) and "s" or "",
" in input file -- no output file generated.\n")
dumpdef(stderr)
exit(1)
end
-- Write output file.
writefile(outfile)
end
------------------------------------------------------------------------------
-- Print help text.
function opt_map.help()
stdout:write("DynASM -- ", _info.description, ".\n")
stdout:write("DynASM ", _info.version, " ", _info.release, " ", _info.url, "\n")
stdout:write[[
Usage: dynasm [OPTION]... INFILE.dasc|-
-h, --help Display this help text.
-V, --version Display version and copyright information.
-o, --outfile FILE Output file name (default is stdout).
-I, --include DIR Add directory to the include search path.
-c, --ccomment Use /* */ comments for assembler lines.
-C, --cppcomment Use // comments for assembler lines (default).
-N, --nocomment Suppress assembler lines in output.
-M, --maccomment Show macro expansions as comments (default off).
-L, --nolineno Suppress CPP line number information in output.
-F, --flushline Flush action list for every line.
-D NAME[=SUBST] Define a substitution.
-U NAME Undefine a substitution.
-P, --dumpdef Dump defines, macros, etc. Repeat for more output.
-A, --dumparch ARCH Load architecture ARCH and dump description.
]]
exit(0)
end
-- Print version information.
function opt_map.version()
stdout:write(format("%s version %s, released %s\n%s\n\n%s",
_info.name, _info.version, _info.release, _info.url, _info.copyright))
exit(0)
end
-- Misc. options.
function opt_map.outfile(args) g_opt.outfile = optparam(args) end
function opt_map.include(args) insert(g_opt.include, 1, optparam(args)) end
function opt_map.ccomment() g_opt.comment = "/*|"; g_opt.endcomment = " */" end
function opt_map.cppcomment() g_opt.comment = "//|"; g_opt.endcomment = "" end
function opt_map.nocomment() g_opt.comment = false end
function opt_map.maccomment() g_opt.maccomment = true end
function opt_map.nolineno() g_opt.cpp = false end
function opt_map.flushline() g_opt.flushline = true end
function opt_map.dumpdef() g_opt.dumpdef = g_opt.dumpdef + 1 end
------------------------------------------------------------------------------
-- Short aliases for long options.
local opt_alias = {
h = "help", ["?"] = "help", V = "version",
o = "outfile", I = "include",
c = "ccomment", C = "cppcomment", N = "nocomment", M = "maccomment",
L = "nolineno", F = "flushline",
P = "dumpdef", A = "dumparch",
}
-- Parse single option.
local function parseopt(opt, args)
opt_current = #opt == 1 and "-"..opt or "--"..opt
local f = opt_map[opt] or opt_map[opt_alias[opt]]
if not f then
opterror("unrecognized option `", opt_current, "'. Try `--help'.\n")
end
f(args)
end
-- Parse arguments.
local function parseargs(args)
-- Default options.
g_opt.comment = "//|"
g_opt.endcomment = ""
g_opt.cpp = true
g_opt.dumpdef = 0
g_opt.include = { "" }
-- Process all option arguments.
args.argn = 1
repeat
local a = args[args.argn]
if not a then break end
local lopt, opt = match(a, "^%-(%-?)(.+)")
if not opt then break end
args.argn = args.argn + 1
if lopt == "" then
-- Loop through short options.
for o in gmatch(opt, ".") do parseopt(o, args) end
else
-- Long option.
parseopt(opt, args)
end
until false
-- Check for proper number of arguments.
local nargs = #args - args.argn + 1
if nargs ~= 1 then
if nargs == 0 then
if g_opt.dumpdef > 0 then return dumpdef(stdout) end
end
opt_map.help()
end
-- Translate a single input file to a single output file
-- TODO: Handle multiple files?
translate(args[args.argn], g_opt.outfile)
end
------------------------------------------------------------------------------
-- Add the directory dynasm.lua resides in to the Lua module search path.
local arg = arg
if arg and arg[0] then
local prefix = match(arg[0], "^(.*/)")
if prefix then package.path = prefix.."?.lua;"..package.path end
end
-- Start DynASM.
parseargs{...}
------------------------------------------------------------------------------
| mit |
dr01d3r/darkstar | scripts/zones/North_Gustaberg_[S]/Zone.lua | 12 | 1674 | -----------------------------------
--
-- Zone: North_Gustaberg_[S] (88)
--
-----------------------------------
package.loaded["scripts/zones/North_Gustaberg_[S]/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/North_Gustaberg_[S]/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(380.038,-2.25,147.627,192);
end
if (prevZone == 87 and player:getCampaignAllegiance() > 0 and player:getQuestStatus(CRYSTAL_WAR,BETTER_PART_OF_VALOR) == QUEST_AVAILABLE) then
cs = 0x0001;
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0001) then
player:addQuest(CRYSTAL_WAR,BETTER_PART_OF_VALOR);
player:addKeyItem(CLUMP_OF_ANIMAL_HAIR);
player:messageSpecial(KEYITEM_OBTAINED,CLUMP_OF_ANIMAL_HAIR);
end
end; | gpl-3.0 |
gokmen/koding | go/src/vendor/github.com/caglar10ur/lxc/src/lxc/lxc-top.lua | 62 | 7453 | #!/usr/bin/env lua
--
-- top(1) like monitor for lxc containers
--
-- Copyright © 2012 Oracle.
--
-- Authors:
-- Dwight Engen <dwight.engen@oracle.com>
--
-- This library is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License version 2, as
-- published by the Free Software Foundation.
--
-- 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 lxc = require("lxc")
local core = require("lxc.core")
local getopt = require("alt_getopt")
local USER_HZ = 100
local ESC = string.format("%c", 27)
local TERMCLEAR = ESC.."[H"..ESC.."[J"
local TERMNORM = ESC.."[0m"
local TERMBOLD = ESC.."[1m"
local TERMRVRS = ESC.."[7m"
local containers = {}
local stats = {}
local stats_total = {}
local max_containers
function printf(...)
local function wrapper(...) io.write(string.format(...)) end
local status, result = pcall(wrapper, ...)
if not status then
error(result, 2)
end
end
function string:split(delim, max_cols)
local cols = {}
local start = 1
local nextc
repeat
nextc = string.find(self, delim, start)
if (nextc and #cols ~= max_cols - 1) then
table.insert(cols, string.sub(self, start, nextc-1))
start = nextc + #delim
else
table.insert(cols, string.sub(self, start, string.len(self)))
nextc = nil
end
until nextc == nil or start > #self
return cols
end
function strsisize(size, width)
local KiB = 1024
local MiB = 1048576
local GiB = 1073741824
local TiB = 1099511627776
local PiB = 1125899906842624
local EiB = 1152921504606846976
local ZiB = 1180591620717411303424
if (size >= ZiB) then
return string.format("%d.%2.2d ZB", size / ZiB, (math.floor(size % ZiB) * 100) / ZiB)
end
if (size >= EiB) then
return string.format("%d.%2.2d EB", size / EiB, (math.floor(size % EiB) * 100) / EiB)
end
if (size >= PiB) then
return string.format("%d.%2.2d PB", size / PiB, (math.floor(size % PiB) * 100) / PiB)
end
if (size >= TiB) then
return string.format("%d.%2.2d TB", size / TiB, (math.floor(size % TiB) * 100) / TiB)
end
if (size >= GiB) then
return string.format("%d.%2.2d GB", size / GiB, (math.floor(size % GiB) * 100) / GiB)
end
if (size >= MiB) then
return string.format("%d.%2.2d MB", size / MiB, (math.floor(size % MiB) * 1000) / (MiB * 10))
end
if (size >= KiB) then
return string.format("%d.%2.2d KB", size / KiB, (math.floor(size % KiB) * 1000) / (KiB * 10))
end
return string.format("%3d.00 ", size)
end
function tty_lines()
local rows = 25
local f = assert(io.popen("stty -a | head -n 1"))
for line in f:lines() do
local stty_rows
_,_,stty_rows = string.find(line, "rows (%d+)")
if (stty_rows ~= nil) then
rows = stty_rows
break
end
end
f:close()
return rows
end
function container_sort(a, b)
if (optarg["r"]) then
if (optarg["s"] == "n") then return (a > b)
elseif (optarg["s"] == "c") then return (stats[a].cpu_use_nanos < stats[b].cpu_use_nanos)
elseif (optarg["s"] == "d") then return (stats[a].blkio < stats[b].blkio)
elseif (optarg["s"] == "m") then return (stats[a].mem_used < stats[b].mem_used)
elseif (optarg["s"] == "k") then return (stats[a].kmem_used < stats[b].kmem_used)
end
else
if (optarg["s"] == "n") then return (a < b)
elseif (optarg["s"] == "c") then return (stats[a].cpu_use_nanos > stats[b].cpu_use_nanos)
elseif (optarg["s"] == "d") then return (stats[a].blkio > stats[b].blkio)
elseif (optarg["s"] == "m") then return (stats[a].mem_used > stats[b].mem_used)
elseif (optarg["s"] == "k") then return (stats[a].kmem_used > stats[b].kmem_used)
end
end
end
function container_list_update()
local now_running
now_running = lxc.containers_running(true)
-- check for newly started containers
for _,v in ipairs(now_running) do
if (containers[v] == nil) then
local ct = lxc.container:new(v)
-- note, this is a "mixed" table, ie both dictionary and list
containers[v] = ct
table.insert(containers, v)
end
end
-- check for newly stopped containers
local indx = 1
while (indx <= #containers) do
local ctname = containers[indx]
if (now_running[ctname] == nil) then
containers[ctname] = nil
stats[ctname] = nil
table.remove(containers, indx)
else
indx = indx + 1
end
end
-- get stats for all current containers and resort the list
lxc.stats_clear(stats_total)
for _,ctname in ipairs(containers) do
stats[ctname] = containers[ctname]:stats_get(stats_total)
end
table.sort(containers, container_sort)
end
function stats_print_header(stats_total)
printf(TERMRVRS .. TERMBOLD)
printf("%-15s %8s %8s %8s %10s %10s", "Container", "CPU", "CPU", "CPU", "BlkIO", "Mem")
if (stats_total.kmem_used > 0) then printf(" %10s", "KMem") end
printf("\n")
printf("%-15s %8s %8s %8s %10s %10s", "Name", "Used", "Sys", "User", "Total", "Used")
if (stats_total.kmem_used > 0) then printf(" %10s", "Used") end
printf("\n")
printf(TERMNORM)
end
function stats_print(name, stats, stats_total)
printf("%-15s %8.2f %8.2f %8.2f %10s %10s",
name,
stats.cpu_use_nanos / 1000000000,
stats.cpu_use_sys / USER_HZ,
stats.cpu_use_user / USER_HZ,
strsisize(stats.blkio),
strsisize(stats.mem_used))
if (stats_total.kmem_used > 0) then
printf(" %10s", strsisize(stats.kmem_used))
end
end
function usage()
printf("Usage: lxc-top [options]\n" ..
" -h|--help print this help message\n" ..
" -m|--max display maximum number of containers\n" ..
" -d|--delay delay in seconds between refreshes (default: 3.0)\n" ..
" -s|--sort sort by [n,c,d,m] (default: n) where\n" ..
" n = Name\n" ..
" c = CPU use\n" ..
" d = Disk I/O use\n" ..
" m = Memory use\n" ..
" k = Kernel memory use\n" ..
" -r|--reverse sort in reverse (descending) order\n"
)
os.exit(1)
end
local long_opts = {
help = "h",
delay = "d",
max = "m",
reverse = "r",
sort = "s",
}
optarg,optind = alt_getopt.get_opts (arg, "hd:m:rs:", long_opts)
optarg["d"] = tonumber(optarg["d"]) or 3.0
optarg["m"] = tonumber(optarg["m"]) or tonumber(tty_lines() - 3)
optarg["r"] = optarg["r"] or false
optarg["s"] = optarg["s"] or "n"
if (optarg["h"] ~= nil) then
usage()
end
while true
do
container_list_update()
-- if some terminal we care about doesn't support the simple escapes, we
-- may fall back to this, or ncurses. ug.
--os.execute("tput clear")
printf(TERMCLEAR)
stats_print_header(stats_total)
for index,ctname in ipairs(containers) do
stats_print(ctname, stats[ctname], stats_total)
printf("\n")
if (index >= optarg["m"]) then
break
end
end
stats_print(string.format("TOTAL (%-2d)", #containers), stats_total, stats_total)
io.flush()
core.usleep(optarg["d"] * 1000000)
end
| agpl-3.0 |
dr01d3r/darkstar | scripts/globals/items/bowl_of_quadav_stew.lua | 12 | 1385 | -----------------------------------------
-- ID: 4569
-- Item: Bowl of Quadav Stew
-- Food Effect: 180Min, All Races
-----------------------------------------
-- Agility -4
-- Vitality 2
-- Defense % 17
-- Defense Cap 60
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,10800,4569);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_AGI, -4);
target:addMod(MOD_VIT, 2);
target:addMod(MOD_FOOD_DEFP, 17);
target:addMod(MOD_FOOD_DEF_CAP, 60);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_AGI, -4);
target:delMod(MOD_VIT, 2);
target:delMod(MOD_FOOD_DEFP, 17);
target:delMod(MOD_FOOD_DEF_CAP, 60);
end;
| gpl-3.0 |
thegrb93/wire | lua/entities/gmod_wire_gyroscope.lua | 7 | 2542 | AddCSLuaFile()
DEFINE_BASECLASS( "base_wire_entity" )
ENT.PrintName = "Wire Gyroscope"
ENT.WireDebugName = "Gyroscope"
function ENT:SetupDataTables()
self:NetworkVar( "Bool", 0, "Out180" )
end
if CLIENT then
--handle overlay text client side instead (TAD2020)
function ENT:Think()
BaseClass.Think(self)
if self:GetModel() == "models/bull/various/gyroscope.mdl" then
local lineOfNodes = self:WorldToLocal( ( Vector(0,0,1):Cross( self:GetUp() ) ):GetNormal( ) + self:GetPos() )
self:SetPoseParameter( "rot_yaw" , math.deg( math.atan2( lineOfNodes[2] , lineOfNodes[1] ) ) )
self:SetPoseParameter( "rot_roll" , -math.deg( math.acos( self:GetUp():DotProduct( Vector(0,0,1) ) ) or 0 ) )
end
local ang = self:GetAngles()
if (ang.p < 0 && !self:GetOut180()) then ang.p = ang.p + 360 end
if (ang.y < 0 && !self:GetOut180()) then ang.y = ang.y + 360 end
if (ang.r < 0 && !self:GetOut180()) then ang.r = ang.r + 360
elseif (ang.r > 180 && self:GetOut180()) then ang.r = ang.r - 360 end
self:ShowOutput(ang.p, ang.y, ang.r)
self:NextThink(CurTime()+0.04)
return true
end
function ENT:ShowOutput(p, y, r)
self:SetOverlayText(string.format("Angles = %.3f, %.3f, %.3f", p, y, r))
end
return -- No more client
end
-- Server
function ENT:Initialize()
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self.Outputs = WireLib.CreateSpecialOutputs(self, { "Pitch", "Yaw", "Roll", "Angle" }, {"NORMAL", "NORMAL", "NORMAL", "ANGLE"})
end
function ENT:Setup( out180 )
if out180 ~= nil then self:SetOut180(out180) end
Wire_TriggerOutput(self, "Pitch", 0)
Wire_TriggerOutput(self, "Yaw", 0)
Wire_TriggerOutput(self, "Roll", 0)
WireLib.TriggerOutput(self, "Angle", Angle( 0, 0, 0 ))
end
function ENT:Think()
BaseClass.Think(self)
local ang = self:GetAngles()
if (ang.p < 0 && !self:GetOut180()) then ang.p = ang.p + 360 end
if (ang.y < 0 && !self:GetOut180()) then ang.y = ang.y + 360 end
if (ang.r < 0 && !self:GetOut180()) then ang.r = ang.r + 360
elseif (ang.r > 180 && self:GetOut180()) then ang.r = ang.r - 360 end
Wire_TriggerOutput(self, "Pitch", ang.p)
Wire_TriggerOutput(self, "Yaw", ang.y)
Wire_TriggerOutput(self, "Roll", ang.r)
Wire_TriggerOutput(self, "Angle", Angle( ang.p, ang.y, ang.r ))
--now handled client side (TAD2020)
--self:ShowOutput(ang.p, ang.y, ang.r)
self:NextThink(CurTime()+0.04)
return true
end
duplicator.RegisterEntityClass("gmod_wire_gyroscope", WireLib.MakeWireEnt, "Data", "out180")
| apache-2.0 |
dr01d3r/darkstar | scripts/globals/items/balik_sis.lua | 12 | 1663 | -----------------------------------------
-- ID: 5600
-- Item: Balik Sis
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Dexterity 4
-- Mind -2
-- Attack % 13
-- Attack Cap 65
-- Ranged ACC 1
-- Ranged ATT % 13
-- Ranged ATT Cap 65
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,1800,5600);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEX, 4);
target:addMod(MOD_MND, -2);
target:addMod(MOD_FOOD_ATTP, 13);
target:addMod(MOD_FOOD_ATT_CAP, 65);
target:addMod(MOD_RACC, 1);
target:addMod(MOD_FOOD_RATTP, 13);
target:addMod(MOD_FOOD_RATT_CAP, 65);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_DEX, 4);
target:delMod(MOD_MND, -2);
target:delMod(MOD_FOOD_ATTP, 13);
target:delMod(MOD_FOOD_ATT_CAP, 65);
target:delMod(MOD_RACC, 1);
target:delMod(MOD_FOOD_RATTP, 13);
target:delMod(MOD_FOOD_RATT_CAP, 65);
end;
| gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c100000038.lua | 2 | 1306 | --オーロラ・ドロー
function c100000038.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_DRAW)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCondition(c100000038.ntcon)
e1:SetTarget(c100000038.target)
e1:SetOperation(c100000038.activate)
c:RegisterEffect(e1)
end
function c100000038.cfilter(c)
return c:IsFaceup() and c:IsSetCard(0x3013)
end
function c100000038.cfilter2(c)
return c:GetCode()==100000038
end
function c100000038.ntcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c==nil then return true end
return Duel.IsExistingMatchingCard(c100000038.cfilter,tp,LOCATION_MZONE,0,1,nil) and (Duel.GetFieldGroupCount(c:GetControler(),LOCATION_HAND,0)==1 and Duel.IsExistingMatchingCard(c100000038.cfilter2,tp,LOCATION_HAND,0,1,nil))
or Duel.GetFieldGroupCount(c:GetControler(),LOCATION_HAND,0)==0
end
function c100000038.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsPlayerCanDraw(tp,2) end
Duel.SetTargetPlayer(tp)
Duel.SetTargetParam(2)
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,2)
end
function c100000038.activate(e,tp,eg,ep,ev,re,r,rp)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Draw(p,d,REASON_EFFECT)
end
| gpl-2.0 |
Herve-M/OpenRA | mods/ra/maps/ant-01/ant-attack.lua | 7 | 2347 | --[[
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.
]]
timeTracker = 0
amount = 1
SendAnts = true
AttackAngles = {
{ waypoint4.Location, waypoint18.Location, waypoint5.Location, waypoint15.Location },
{ waypoint20.Location, waypoint2.Location },
{ waypoint21.Location, waypoint10.Location, waypoint2.Location },
{ waypoint7.Location, waypoint17.Location, waypoint1.Location },
{ waypoint8.Location, waypoint9.Location, waypoint19.Location }
}
AttackInterval = {
easy = DateTime.Seconds(40),
normal = DateTime.Seconds(30),
hard = DateTime.Seconds(25)
}
AntTypes = {
"scoutant",
"fireant"
}
MaxAnts = {
easy = 3,
normal = 5,
hard = 6
}
MaxFireAnts = {
easy = 2,
normal = 3,
hard = 4
}
StartAntAttack = function()
local path = Utils.Random(AttackAngles)
local antType = "scoutant"
local index = 0
local amount = 1
local timeTracker = GetTicks()
if timeTracker > DateTime.Minutes(6) then
antType = Utils.Random(AntTypes)
end
if antType == "warriorant" and Difficulty == "easy" then
antType = "scoutant"
end
if Difficulty == "normal" and timeTracker < DateTime.Minutes(6) and antType == "scoutant" then
antType = "warriorant"
elseif Difficulty == "hard" and timeTracker < DateTime.Minutes(8) and antType == "scoutant" then
antType = "warriorant"
end
local max = MaxAnts[Difficulty] - math.ceil(timeTracker / DateTime.Minutes(6))
if timeTracker > DateTime.Minutes(3) and antType == "fireant" then
amount = Utils.RandomInteger(1, MaxFireAnts[Difficulty])
elseif timeTracker > 15 and antType == "fireant" then
antType = "scoutant"
else
amount = Utils.RandomInteger(1, max)
end
for i = 0,amount,1 do
Reinforcements.Reinforce(AntMan, { antType }, path, DateTime.Seconds(5), function(actor)
actor.AttackMove(CPos.New(65, 65))
Trigger.OnIdle(actor, function()
actor.Hunt()
end)
end)
end
-- Setup next wave
if SendAnts then
Trigger.AfterDelay(AttackInterval[Difficulty], function()
StartAntAttack()
end)
end
end
EndAntAttack = function()
SendAnts = false
end
| gpl-3.0 |
dr01d3r/darkstar | scripts/zones/Cape_Teriggan/npcs/Cermet_Headstone.lua | 14 | 4139 | -----------------------------------
-- Area: Cape Teriggan
-- NPC: Cermet Headstone
-- Involved in Mission: ZM5 Headstone Pilgrimage (Wind Headstone)
-- @pos -107 -8 450 113
-----------------------------------
package.loaded["scripts/zones/Cape_Teriggan/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/titles");
require("scripts/globals/missions");
require("scripts/zones/Cape_Teriggan/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (trade:hasItemQty(949,1) and trade:getItemCount() == 1) then
if (player:getCurrentMission(ZILART) == HEADSTONE_PILGRIMAGE and player:hasKeyItem(WIND_FRAGMENT) and player:hasCompleteQuest(OUTLANDS,WANDERING_SOULS) == false) then
player:addQuest(OUTLANDS,WANDERING_SOULS);
player:startEvent(0x00CA,949);
elseif (player:hasCompletedMission(ZILART,HEADSTONE_PILGRIMAGE) and player:hasCompleteQuest(OUTLANDS,WANDERING_SOULS) == false) then
player:addQuest(OUTLANDS,WANDERING_SOULS);
player:startEvent(0x00CA,949);
else
player:messageSpecial(NOTHING_HAPPENS);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getCurrentMission(ZILART) == HEADSTONE_PILGRIMAGE) then
-- if requirements are met and 15 mins have passed since mobs were last defeated, spawn them
if (player:hasKeyItem(WIND_FRAGMENT) == false and GetServerVariable("[ZM4]Wind_Headstone_Active") < os.time()) then
player:startEvent(0x00C8,WIND_FRAGMENT);
-- if 15 min window is open and requirements are met, recieve key item
elseif (player:hasKeyItem(WIND_FRAGMENT) == false and GetServerVariable("[ZM4]Wind_Headstone_Active") > os.time()) then
player:addKeyItem(WIND_FRAGMENT);
-- Check and see if all fragments have been found (no need to check wind and dark frag)
if (player:hasKeyItem(ICE_FRAGMENT) and player:hasKeyItem(EARTH_FRAGMENT) and player:hasKeyItem(WATER_FRAGMENT) and
player:hasKeyItem(FIRE_FRAGMENT) and player:hasKeyItem(LIGHTNING_FRAGMENT) and player:hasKeyItem(LIGHT_FRAGMENT)) then
player:messageSpecial(FOUND_ALL_FRAGS,WIND_FRAGMENT);
player:addTitle(BEARER_OF_THE_EIGHT_PRAYERS);
player:completeMission(ZILART,HEADSTONE_PILGRIMAGE);
player:addMission(ZILART,THROUGH_THE_QUICKSAND_CAVES);
else
player:messageSpecial(KEYITEM_OBTAINED,WIND_FRAGMENT);
end
else
player:messageSpecial(ALREADY_OBTAINED_FRAG,WIND_FRAGMENT);
end
elseif (player:hasCompletedMission(ZILART,HEADSTONE_PILGRIMAGE)) then
player:messageSpecial(ZILART_MONUMENT);
else
player:messageSpecial(CANNOT_REMOVE_FRAG);
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 == 0x00C8 and option == 1) then
SpawnMob(17240414):updateClaim(player); -- Axesarion the Wanderer
SetServerVariable("[ZM4]Wind_Headstone_Active",0);
elseif (csid == 0x00CA) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,13248);
else
player:tradeComplete();
player:addItem(13248);
player:messageSpecial(ITEM_OBTAINED,13248);
player:completeQuest(OUTLANDS,WANDERING_SOULS);
player:addTitle(BEARER_OF_BONDS_BEYOND_TIME);
end
end
end; | gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-Production | c34026662.lua | 2 | 1271 | --進化の奇跡
function c34026662.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(c34026662.target)
e1:SetOperation(c34026662.activate)
c:RegisterEffect(e1)
end
function c34026662.filter(c)
local st=c:GetSummonType()
return c:IsFaceup() and st>=(SUMMON_TYPE_SPECIAL+150) and st<(SUMMON_TYPE_SPECIAL+180)
end
function c34026662.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c34026662.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c34026662.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
local g=Duel.SelectTarget(tp,c34026662.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
end
function c34026662.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
e1:SetValue(1)
tc:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
tc:RegisterEffect(e2)
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c64801562.lua | 7 | 2126 | --明鏡止水の心
function c64801562.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(c64801562.target)
e1:SetOperation(c64801562.operation)
c:RegisterEffect(e1)
--Indes
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_EQUIP)
e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e2:SetValue(1)
c:RegisterEffect(e2)
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_EQUIP)
e3:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
e3:SetValue(c64801562.indval)
c:RegisterEffect(e3)
--Equip limit
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetCode(EFFECT_EQUIP_LIMIT)
e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e4:SetValue(1)
c:RegisterEffect(e4)
--selfdes
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_SINGLE)
e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e5:SetRange(LOCATION_SZONE)
e5:SetCode(EFFECT_SELF_DESTROY)
e5:SetCondition(c64801562.descon)
c:RegisterEffect(e5)
end
function c64801562.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsFaceup() end
if chk==0 then return Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
function c64801562.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 c64801562.indval(e,re,rp)
local tc=e:GetHandler():GetEquipTarget()
local rc=re:GetHandler()
return (re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) and Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):IsContains(tc))
or (re:IsHasType(EFFECT_TYPE_CONTINUOUS) and rc:IsHasCardTarget(tc))
end
function c64801562.descon(e)
local tc=e:GetHandler():GetEquipTarget()
return tc and tc:GetAttack()>=1300
end
| gpl-2.0 |
Ali-2h/linuxw | bot/creed.lua | 2 | 9276 | package.path = package.path .. ';.luarocks/share/lua/5.2/?.lua'
..';.luarocks/share/lua/5.2/?/init.lua'
package.cpath = package.cpath .. ';.luarocks/lib/lua/5.2/?.so'
require("./bot/utils")
VERSION = '1.0'
-- This function is called when tg receive a msg
function on_msg_receive (msg)
if not started then
return
end
local receiver = get_receiver(msg)
print (receiver)
-- vardump(msg)
msg = pre_process_service_msg(msg)
if msg_valid(msg) then
msg = pre_process_msg(msg)
if msg then
match_plugins(msg)
-- mark_read(receiver, ok_cb, false)
end
end
end
function ok_cb(extra, success, result)
end
function on_binlog_replay_end()
started = true
postpone (cron_plugins, false, 60*5.0)
_config = load_config()
-- load plugins
plugins = {}
load_plugins()
end
function msg_valid(msg)
-- Don't process outgoing messages
if msg.out then
print('\27[36mNot valid: msg from us\27[39m')
return false
end
-- Before bot was started
if msg.date < now then
print('\27[36mNot valid: old msg\27[39m')
return false
end
if msg.unread == 0 then
print('\27[36mNot valid: readed\27[39m')
return false
end
if not msg.to.id then
print('\27[36mNot valid: To id not provided\27[39m')
return false
end
if not msg.from.id then
print('\27[36mNot valid: From id not provided\27[39m')
return false
end
if msg.from.id == our_id then
print('\27[36mNot valid: Msg from our id\27[39m')
return false
end
if msg.to.type == 'encr_chat' then
print('\27[36mNot valid: Encrypted chat\27[39m')
return false
end
if msg.from.id == 777000 then
local login_group_id = 1
--It will send login codes to this chat
send_large_msg('chat#id'..login_group_id, msg.text)
end
return true
end
--
function pre_process_service_msg(msg)
if msg.service then
local action = msg.action or {type=""}
-- Double ! to discriminate of normal actions
msg.text = "!!tgservice " .. action.type
-- wipe the data to allow the bot to read service messages
if msg.out then
msg.out = false
end
if msg.from.id == our_id then
msg.from.id = 0
end
end
return msg
end
-- Apply plugin.pre_process function
function pre_process_msg(msg)
for name,plugin in pairs(plugins) do
if plugin.pre_process and msg then
print('Preprocess', name)
msg = plugin.pre_process(msg)
end
end
return msg
end
-- Go over enabled plugins patterns.
function match_plugins(msg)
for name, plugin in pairs(plugins) do
match_plugin(plugin, name, msg)
end
end
-- Check if plugin is on _config.disabled_plugin_on_chat table
local function is_plugin_disabled_on_chat(plugin_name, receiver)
local disabled_chats = _config.disabled_plugin_on_chat
-- Table exists and chat has disabled plugins
if disabled_chats and disabled_chats[receiver] then
-- Checks if plugin is disabled on this chat
for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do
if disabled_plugin == plugin_name and disabled then
local warning = 'Plugin '..disabled_plugin..' is disabled on this chat'
print(warning)
send_msg(receiver, warning, ok_cb, false)
return true
end
end
end
return false
end
function match_plugin(plugin, plugin_name, msg)
local receiver = get_receiver(msg)
-- Go over patterns. If one matches it's enough.
for k, pattern in pairs(plugin.patterns) do
local matches = match_pattern(pattern, msg.text)
if matches then
print("msg matches: ", pattern)
if is_plugin_disabled_on_chat(plugin_name, receiver) then
return nil
end
-- Function exists
if plugin.run then
-- If plugin is for privileged users only
if not warns_user_not_allowed(plugin, msg) then
local result = plugin.run(msg, matches)
if result then
send_large_msg(receiver, result)
end
end
end
-- One patterns matches
return
end
end
end
-- DEPRECATED, use send_large_msg(destination, text)
function _send_msg(destination, text)
send_large_msg(destination, text)
end
-- Save the content of _config to config.lua
function save_config( )
serialize_to_file(_config, './data/config.lua')
print ('saved config into ./data/config.lua')
end
-- Returns the config from config.lua file.
-- If file doesn't exist, create it.
function load_config( )
local f = io.open('./data/config.lua', "r")
-- If config.lua doesn't exist
if not f then
print ("Created new config file: data/config.lua")
create_config()
else
f:close()
end
local config = loadfile ("./data/config.lua")()
for v,user in pairs(config.sudo_users) do
print("Allowed user: " .. user)
end
return config
end
-- Create a basic config.json file and saves it.
function create_config( )
-- A simple config with basic plugins and ourselves as privileged user
config = {
enabled_plugins = {
"onservice",
"inrealm",
"Moderator_Gp",
"LockTag",
"banhammer",
"stats",
"anti_spam",
"owners",
"arabic_lock",
"set",
"get",
"broadcast",
"plugins",
"lock_link",
"all"
},
sudo_users = {162998208,152046992},--Sudo users
disabled_channels = {},
realm = {48687411,41151446},--Realms Id
moderation = {data = 'data/moderation.json'},
about_text = [[Creed bot 2.0
Hello my Good friends 😀🖐🏻
‼️ this bot is made by : @creed_is_dead
〰〰〰〰〰〰〰〰
🚩 Our admins are :
🔰 @sorblack_creed
🔰 @amircc_creed
🔰 @aria_creed
🔰 @alireza_mah_creed
〰〰〰〰〰〰〰〰
♻️ You can send your Ideas and messages to Us By sending them into bots account by this command :
!feedback (your ideas and messages)
]],
help_text = [[
Creed bots Help for mods : 😈
Plugins : 🔻
1. banhammer ⭕️
Help For Banhammer👇
!Kick @UserName 😜
And You Can do It by Replay 🙈
!Ban @UserName 〽️
You Can Do It By Replay👌
!Unban @UserName
You Can Do it By Replay😱
For Admins : 👇
!banall @UserName or (user_id)😺
you Can do it By Replay 👤
!unbanall 🆔User_Id🆔
〰〰〰〰〰〰〰〰〰〰
2. GroupManager :🔹
!Creategroup "GroupName" 🙈
You Can CreateGroup With this command😱
!setflood😃
Set the group flood control🈹
!settings ❌
Watch group settings
!owner🚫
watch group owner
!setowner user_id❗️
You can set someone to the group owner‼️
!modlist💯
watch Group mods🔆
!lock (bots-member-flood-photo-name-Arabic-english-tag-join-link)✅
lock Something🚼
!unlock (bots-member-flood-photo-name-Arabic-english-tag-join-link)✅
Unlock Something🚼
!rules 🆙 or !set rules🆗
watch group rules or set
!about or !set about 🔴
!res @username🔘
See UserInfo©
!who♦️
Get Ids Chat🔺
!log 🎴
get members id ♠️
!all🔴
this is like stats in a file🔸
added !clink *
and !glink :)
〰〰〰〰〰〰〰〰
Admins :®
!add 😎
You Can add the group to moderation.json😱
!rem😏
You Can Remove the group from mod.json⭕️
!setgpowner (Gpid) user_id ⚫️
from realm®®
!addadmin 🔶
set some one to global admin🔸
!removeadmin🔘
remove somone from global admin🔹
〰〰〰〰〰〰〰〰〰〰〰
3. Stats :©
!stats creedbot (sudoers)✔️
shows bt stats🔚
!stats🔘
shows group stats💲
〰〰〰〰〰〰〰〰
4. Feedback⚫️
!feedback txt🔻◼️
send maseage to admins via bot🔈
〰〰〰〰〰〰〰〰〰〰〰
5. Tagall◻️
!tagall txt🔸
will tag users©
〰〰〰〰〰〰〰〰〰
🔜 more plugins
⚠️ We are Creeds ... ⚠️
our channel : @creedantispam_channel🔋
You Can user both "!" & "/" for them🎧
]]
}
serialize_to_file(config, './data/config.lua')
print('saved config into ./data/config.lua')
end
function on_our_id (id)
our_id = id
end
function on_user_update (user, what)
--vardump (user)
end
function on_chat_update (chat, what)
end
function on_secret_chat_update (schat, what)
--vardump (schat)
end
function on_get_difference_end ()
end
-- Enable plugins in config.json
function load_plugins()
for k, v in pairs(_config.enabled_plugins) do
print("Loading plugin", v)
local ok, err = pcall(function()
local t = loadfile("plugins/"..v..'.lua')()
plugins[v] = t
end)
if not ok then
print('\27[31mError loading plugin '..v..'\27[39m')
print('\27[31m'..err..'\27[39m')
end
end
end
-- custom add
function load_data(filename)
local f = io.open(filename)
if not f then
return {}
end
local s = f:read('*all')
f:close()
local data = JSON.decode(s)
return data
end
function save_data(filename, data)
local s = JSON.encode(data)
local f = io.open(filename, 'w')
f:write(s)
f:close()
end
-- Call and postpone execution for cron plugins
function cron_plugins()
for name, plugin in pairs(plugins) do
-- Only plugins with cron function
if plugin.cron ~= nil then
plugin.cron()
end
end
-- Called again in 2 mins
postpone (cron_plugins, false, 120)
end
-- Start and load values
our_id = 0
now = os.time()
math.randomseed(now)
started = false
| gpl-2.0 |
dr01d3r/darkstar | scripts/zones/Windurst_Walls/npcs/Hiwon-Biwon.lua | 17 | 3908 | -----------------------------------
-- Area: Windurst Walls
-- NPC: Hiwon-Biwon
-- Involved In Quest: Making Headlines, Curses, Foiled...Again!?
-- Working 100%
-----------------------------------
package.loaded["scripts/zones/Windurst_Walls/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/zones/Windurst_Walls/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
function testflag(set,flag)
return (set % (2*flag) >= flag)
end
local MakingHeadlines = player:getQuestStatus(WINDURST,MAKING_HEADLINES);
local CFA2 = player:getQuestStatus(WINDURST,CURSES_FOILED_AGAIN_2);
-- Curses,Foiled ... Again!?
if (CFA2 == QUEST_ACCEPTED and player:hasItem(552) == false) then
player:startEvent(0x00B6); -- get Hiwon's hair
elseif (CFA2 == QUEST_COMPLETED and MakingHeadlines ~= QUEST_ACCEPTED) then
player:startEvent(0x00B9); -- New Dialog after CFA2
-- Making Headlines
elseif (MakingHeadlines == 1) then
prog = player:getVar("QuestMakingHeadlines_var");
-- Variable to track if player has talked to 4 NPCs and a door
-- 1 = Kyume
-- 2 = Yujuju
-- 4 = Hiwom
-- 8 = Umumu
-- 16 = Mahogany Door
if (testflag(tonumber(prog),4) == false) then
if (player:getQuestStatus(WINDURST,CURSES_FOILED_AGAIN_1) == 1) then
if (math.random(1,2) == 1) then
player:startEvent(0x011b); -- Give scoop while sick
else
player:startEvent(0x011c); -- Give scoop while sick
end
else
player:startEvent(0x0119); -- Give scoop
end
else
player:startEvent(0x011a); -- "Getting back to the maater at hand-wand..."
end
else
local rand = math.random(1,5);
if (rand == 1) then
print (rand);
player:startEvent(0x0131); -- Standard Conversation
elseif (rand == 2) then
print (rand);
player:startEvent(0x0132); -- Standard Conversation
elseif (rand == 3) then
print (rand);
player:startEvent(0x00a8); -- Standard Conversation
elseif (rand == 4) then
print (rand);
player:startEvent(0x00aa); -- Standard Conversation
elseif (rand == 5) then
print (rand);
player:startEvent(0x00a9); -- Standard Conversation
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);
-- Making Headlines
if (csid == 0x0119 or csid == 0x011b or csid == 0x011c) then
prog = player:getVar("QuestMakingHeadlines_var");
player:addKeyItem(WINDURST_WALLS_SCOOP);
player:messageSpecial(KEYITEM_OBTAINED,WINDURST_WALLS_SCOOP);
player:setVar("QuestMakingHeadlines_var",prog+4);
-- Curses,Foiled...Again!?
elseif (csid == 0x00B6) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,552); -- Hiwon's hair
else
player:addItem(552);
player:messageSpecial(ITEM_OBTAINED,552); -- Hiwon's hair
end
end
end;
| gpl-3.0 |
SOCLE15/mMediaWiki | extensions/Scribunto/engines/LuaCommon/lualib/mw.lua | 2 | 19649 | mw = mw or {}
local packageCache
local packageModuleFunc
local php
local allowEnvFuncs = false
local logBuffer = ''
local currentFrame
local loadedData = {}
local executeFunctionDepth = 0
--- Put an isolation-friendly package module into the specified environment
-- table. The package module will have an empty cache, because caching of
-- module functions from other cloned environments would break module isolation.
--
-- @param env The cloned environment
local function makePackageModule( env )
-- Remove loaders from env, we don't want it inheriting our loadPackage.
if env.package then
env.package.loaders = nil
end
-- Create the package globals in the given environment
setfenv( packageModuleFunc, env )()
-- Make a loader function
local function loadPackage( modName )
local init
if packageCache[modName] == 'missing' then
return nil
elseif packageCache[modName] == nil then
local lib = php.loadPHPLibrary( modName )
if lib ~= nil then
init = function ()
return mw.clone( lib )
end
else
init = php.loadPackage( modName )
if init == nil then
packageCache[modName] = 'missing'
return nil
end
end
packageCache[modName] = init
else
init = packageCache[modName]
end
setfenv( init, env )
return init
end
table.insert( env.package.loaders, loadPackage )
end
--- Set up the base environment. The PHP host calls this function after any
-- necessary host-side initialisation has been done.
function mw.setupInterface( options )
-- Don't allow any more calls
mw.setupInterface = nil
-- Don't allow getmetatable() on a non-table, since if you can get the metatable,
-- you can set values in it, breaking isolation
local old_getmetatable = getmetatable
function getmetatable(obj)
if type(obj) == 'table' then
return old_getmetatable(obj)
else
return nil
end
end
if options.allowEnvFuncs then
allowEnvFuncs = true
end
-- Store the interface table
--
-- mw_interface.loadPackage() returns function values with their environment
-- set to the base environment, which would violate module isolation if they
-- were run from a cloned environment. We can only allow access to
-- mw_interface.loadPackage via our environment-setting wrapper.
--
php = mw_interface
mw_interface = nil
packageModuleFunc = php.loadPackage( 'package' )
makePackageModule( _G )
package.loaded.mw = mw
packageCache = {}
end
--- Create a table like the one os.date() returns, but with a metatable that sets TTLs as the values are looked at.
local function wrapDateTable( now )
return setmetatable( {}, {
__index = function( t, k )
if k == 'sec' then
php.setTTL( 1 )
elseif k == 'min' then
php.setTTL( 60 - now.sec )
elseif k == 'hour' then
php.setTTL( 3600 - now.min * 60 - now.sec )
elseif now[k] ~= nil then
php.setTTL( 86400 - now.hour * 3600 - now.min * 60 - now.sec )
end
t[k] = now[k]
return now[k]
end
} )
end
--- Wrappers for os.date() and os.time() that set the TTL of the output, if necessary
local function ttlDate( format, time )
if time == nil and ( format == nil or type( format ) == 'string' ) then
local now = os.date( format and format:sub( 1, 1 ) == '!' and '!*t' or '*t' )
if format == '!*t' or format == '*t' then
return wrapDateTable( now )
end
local cleanedFormat = format and format:gsub( '%%%%', '' )
if not format or cleanedFormat:find( '%%[EO]?[crsSTX+]' ) then
php.setTTL( 1 ) -- second
elseif cleanedFormat:find( '%%[EO]?[MR]' ) then
php.setTTL( 60 - now.sec ) -- minute
elseif cleanedFormat:find( '%%[EO]?[HIkl]' ) then
php.setTTL( 3600 - now.min * 60 - now.sec ) -- hour
elseif cleanedFormat:find( '%%[EO]?[pP]' ) then
php.setTTL( 43200 - ( now.hour % 12 ) * 3600 - now.min * 60 - now.sec ) -- am/pm
else
-- It's not worth the complexity to figure out the exact TTL of larger units than days.
-- If they haven't used anything shorter than days, then just set the TTL to expire at
-- the end of today.
php.setTTL( 86400 - now.hour * 3600 - now.min * 60 - now.sec )
end
end
return os.date( format, time )
end
local function ttlTime( t )
if t == nil then
php.setTTL( 1 )
end
return os.time( t )
end
local function newFrame( frameId, ... )
if not php.frameExists( frameId ) then
return nil
end
local frame = {}
local parentFrameIds = { ... }
local argCache = {}
local argNames
local args_mt = {}
local function checkSelf( self, method )
if self ~= frame then
error( "frame:" .. method .. ": invalid frame object. " ..
"Did you call " .. method .. " with a dot instead of a colon, i.e. " ..
"frame." .. method .. "() instead of frame:" .. method .. "()?",
3 )
end
end
-- Getter for args
local function getExpandedArgument( dummy, name )
name = tostring( name )
if argCache[name] == nil then
local arg = php.getExpandedArgument( frameId, name )
if arg == nil then
argCache[name] = false
else
argCache[name] = arg
end
end
if argCache[name] == false then
return nil
else
return argCache[name]
end
end
args_mt.__index = getExpandedArgument
-- pairs handler for args
args_mt.__pairs = function ()
if not argNames then
local arguments = php.getAllExpandedArguments( frameId )
argNames = {}
for name, value in pairs( arguments ) do
table.insert( argNames, name )
argCache[name] = value
end
end
local index = 0
return function ()
index = index + 1
if argNames[index] then
return argNames[index], argCache[argNames[index]]
end
end
end
-- ipairs 'next' function for args
local function argsInext( dummy, i )
local value = getExpandedArgument( dummy, i + 1 )
if value then
return i + 1, value
end
end
args_mt.__ipairs = function () return argsInext, nil, 0 end
frame.args = {}
setmetatable( frame.args, args_mt )
local function newCallbackParserValue( callback )
local value = {}
local cache
function value:expand()
if not cache then
cache = callback()
end
return cache
end
return value
end
function frame:getArgument( opt )
checkSelf( self, 'getArgument' )
local name
if type( opt ) == 'table' then
name = opt.name
else
name = opt
end
return newCallbackParserValue(
function ()
return getExpandedArgument( nil, name )
end
)
end
function frame:getParent()
checkSelf( self, 'getParent' )
return newFrame( unpack( parentFrameIds ) )
end
local function checkArgs( name, args )
local ret = {}
for k, v in pairs( args ) do
local tp = type( k )
if tp ~= 'string' and tp ~= 'number' then
error( name .. ": arg keys must be strings or numbers, " .. tp .. " given", 3 )
end
tp = type( v )
if tp == 'boolean' then
ret[k] = v and '1' or ''
elseif tp == 'string' or tp == 'number' then
ret[k] = tostring( v )
else
error( name .. ": invalid type " .. tp .. " for arg '" .. k .. "'", 3 )
end
end
return ret
end
function frame:newChild( opt )
checkSelf( self, 'newChild' )
if type( opt ) ~= 'table' then
error( "frame:newChild: the first parameter must be a table", 2 )
end
local title, args
if opt.title == nil then
title = false
else
title = tostring( opt.title )
end
if opt.args == nil then
args = {}
elseif type( opt.args ) ~= 'table' then
error( "frame:newChild: args must be a table", 2 )
else
args = checkArgs( 'frame:newChild', opt.args )
end
local newFrameId = php.newChildFrame( frameId, title, args )
return newFrame( newFrameId, frameId, unpack( parentFrameIds ) )
end
function frame:expandTemplate( opt )
checkSelf( self, 'expandTemplate' )
local title
if type( opt ) ~= 'table' then
error( "frame:expandTemplate: the first parameter must be a table" )
end
if opt.title == nil then
error( "frame:expandTemplate: a title is required" )
else
if type( opt.title ) == 'table' and opt.title.namespace == 0 then
title = ':' .. tostring( opt.title )
else
title = tostring( opt.title )
end
end
local args
if opt.args == nil then
args = {}
elseif type( opt.args ) ~= 'table' then
error( "frame:expandTemplate: args must be a table" )
else
args = checkArgs( 'frame:expandTemplate', opt.args )
end
return php.expandTemplate( frameId, title, args )
end
function frame:callParserFunction( name, args, ... )
checkSelf( self, 'callParserFunction' )
if type( name ) == 'table' then
name, args = name.name, name.args
if type( args ) ~= 'table' then
args = { args }
end
elseif type( args ) ~= 'table' then
args = { args, ... }
end
if name == nil then
error( "frame:callParserFunction: a function name is required", 2 )
elseif type( name ) == 'string' or type( name ) == 'number' then
name = tostring( name )
else
error( "frame:callParserFunction: function name must be a string or number", 2 )
end
args = checkArgs( 'frame:callParserFunction', args )
return php.callParserFunction( frameId, name, args )
end
function frame:extensionTag( name, content, args )
checkSelf( self, 'extensionTag' )
if type( name ) == 'table' then
name, content, args = name.name, name.content, name.args
end
if name == nil then
error( "frame:extensionTag: a function name is required", 2 )
elseif type( name ) == 'string' or type( name ) == 'number' then
name = tostring( name )
else
error( "frame:extensionTag: tag name must be a string or number", 2 )
end
if content == nil then
content = ''
elseif type( content ) == 'string' or type( content ) == 'number' then
content = tostring( content )
else
error( "frame:extensionTag: content must be a string or number", 2 )
end
if args == nil then
args = { content }
elseif type( args ) == 'string' or type( args ) == 'number' then
args = { content, args }
elseif type( args ) == 'table' then
args = checkArgs( 'frame:extensionTag', args )
table.insert( args, 1, content )
else
error( "frame:extensionTag: args must be a string, number, or table", 2 )
end
return php.callParserFunction( frameId, '#tag:' .. name, args )
end
function frame:preprocess( opt )
checkSelf( self, 'preprocess' )
local text
if type( opt ) == 'table' then
text = opt.text
else
text = opt
end
text = tostring( text )
return php.preprocess( frameId, text )
end
function frame:newParserValue( opt )
checkSelf( self, 'newParserValue' )
local text
if type( opt ) == 'table' then
text = opt.text
else
text = opt
end
return newCallbackParserValue(
function ()
return self:preprocess( text )
end
)
end
function frame:newTemplateParserValue( opt )
checkSelf( self, 'newTemplateParserValue' )
if type( opt ) ~= 'table' then
error( "frame:newTemplateParserValue: the first parameter must be a table" )
end
if opt.title == nil then
error( "frame:newTemplateParserValue: a title is required" )
end
return newCallbackParserValue(
function ()
return self:expandTemplate( opt )
end
)
end
function frame:getTitle()
checkSelf( self, 'getTitle' )
return php.getFrameTitle( frameId )
end
-- For backwards compat
function frame:argumentPairs()
checkSelf( self, 'argumentPairs' )
return pairs( self.args )
end
return frame
end
--- Set up a cloned environment for execution of a module chunk, then execute
-- the module in that environment. This is called by the host to implement
-- {{#invoke}}.
--
-- @param chunk The module chunk
-- @param name The name of the function to be returned. Nil or false causes the entire export table to be returned
-- @return boolean Whether the requested value was able to be returned
-- @return table|function|string The requested value, or if that was unable to be returned, the type of the value returned by the module
function mw.executeModule( chunk, name )
local env = mw.clone( _G )
makePackageModule( env )
-- These are unsafe
env.mw.makeProtectedEnvFuncs = nil
env.mw.executeModule = nil
if name ~= false then -- console sets name to false when evaluating its code and nil when evaluating a module's
env.mw.getLogBuffer = nil
env.mw.clearLogBuffer = nil
end
if allowEnvFuncs then
env.setfenv, env.getfenv = mw.makeProtectedEnvFuncs( {[_G] = true}, {} )
else
env.setfenv = nil
env.getfenv = nil
end
env.os.date = ttlDate
env.os.time = ttlTime
setfenv( chunk, env )
local oldFrame = currentFrame
if not currentFrame then
currentFrame = newFrame( 'current', 'parent' )
end
local res = chunk()
currentFrame = oldFrame
if not name then -- catch console whether it's evaluating its own code or a module's
return true, res
end
if type(res) ~= 'table' then
return false, type(res)
end
return true, res[name]
end
function mw.executeFunction( chunk )
local frame = newFrame( 'current', 'parent' )
local oldFrame = currentFrame
if executeFunctionDepth == 0 then
-- math.random is defined as using C's rand(), and C's rand() uses 1 as
-- a seed if not explicitly seeded. So reseed with 1 for each top-level
-- #invoke to avoid people passing state via the RNG.
math.randomseed( 1 )
end
executeFunctionDepth = executeFunctionDepth + 1
currentFrame = frame
local results = { chunk( frame ) }
currentFrame = oldFrame
local stringResults = {}
for i, result in ipairs( results ) do
stringResults[i] = tostring( result )
end
executeFunctionDepth = executeFunctionDepth - 1
return table.concat( stringResults )
end
function mw.allToString( ... )
local t = { ... }
for i = 1, select( '#', ... ) do
t[i] = tostring( t[i] )
end
return table.concat( t, '\t' )
end
function mw.log( ... )
logBuffer = logBuffer .. mw.allToString( ... ) .. '\n'
end
function mw.dumpObject( object )
local doneTable = {}
local doneObj = {}
local ct = {}
local function sorter( a, b )
local ta, tb = type( a ), type( b )
if ta ~= tb then
return ta < tb
end
if ta == 'string' or ta == 'number' then
return a < b
end
if ta == 'boolean' then
return tostring( a ) < tostring( b )
end
return false -- Incomparable
end
local function _dumpObject( object, indent, expandTable )
local tp = type( object )
if tp == 'number' or tp == 'nil' or tp == 'boolean' then
return tostring( object )
elseif tp == 'string' then
return string.format( "%q", object )
elseif tp == 'table' then
if not doneObj[object] then
local s = tostring( object )
if s == 'table' then
ct[tp] = ( ct[tp] or 0 ) + 1
doneObj[object] = 'table#' .. ct[tp]
else
doneObj[object] = s
doneTable[object] = true
end
end
if doneTable[object] or not expandTable then
return doneObj[object]
end
doneTable[object] = true
local ret = { doneObj[object], ' {\n' }
local mt = getmetatable( object )
if mt then
ret[#ret + 1] = string.rep( " ", indent + 2 )
ret[#ret + 1] = 'metatable = '
ret[#ret + 1] = _dumpObject( mt, indent + 2, false )
ret[#ret + 1] = "\n"
end
local doneKeys = {}
for key, value in ipairs( object ) do
doneKeys[key] = true
ret[#ret + 1] = string.rep( " ", indent + 2 )
ret[#ret + 1] = _dumpObject( value, indent + 2, true )
ret[#ret + 1] = ',\n'
end
local keys = {}
for key in pairs( object ) do
if not doneKeys[key] then
keys[#keys + 1] = key
end
end
table.sort( keys, sorter )
for i = 1, #keys do
local key = keys[i]
ret[#ret + 1] = string.rep( " ", indent + 2 )
ret[#ret + 1] = '['
ret[#ret + 1] = _dumpObject( key, indent + 3, false )
ret[#ret + 1] = '] = '
ret[#ret + 1] = _dumpObject( object[key], indent + 2, true )
ret[#ret + 1] = ",\n"
end
ret[#ret + 1] = string.rep( " ", indent )
ret[#ret + 1] = '}'
return table.concat( ret )
else
if not doneObj[object] then
ct[tp] = ( ct[tp] or 0 ) + 1
doneObj[object] = tostring( object ) .. '#' .. ct[tp]
end
return doneObj[object]
end
end
return _dumpObject( object, 0, true )
end
function mw.logObject( object, prefix )
if prefix and prefix ~= '' then
logBuffer = logBuffer .. prefix .. ' = '
end
logBuffer = logBuffer .. mw.dumpObject( object ) .. '\n'
end
function mw.clearLogBuffer()
logBuffer = ''
end
function mw.getLogBuffer()
return logBuffer
end
function mw.getCurrentFrame()
if not currentFrame then
currentFrame = newFrame( 'current', 'parent' )
end
return currentFrame
end
function mw.isSubsting()
return php.isSubsting()
end
function mw.incrementExpensiveFunctionCount()
php.incrementExpensiveFunctionCount()
end
---
-- Wrapper for mw.loadData. This creates the read-only dummy table for
-- accessing the real data.
--
-- @param data table Data to access
-- @param seen table|nil Table of already-seen tables.
-- @return table
local function dataWrapper( data, seen )
local t = {}
seen = seen or { [data] = t }
local function pairsfunc( s, k )
k = next( data, k )
if k ~= nil then
return k, t[k]
end
return nil
end
local function ipairsfunc( s, i )
i = i + 1
if data[i] ~= nil then
return i, t[i]
end
return -- no nil to match default ipairs()
end
local mt = {
__index = function ( tt, k )
assert( t == tt )
local v = data[k]
if type( v ) == 'table' then
seen[v] = seen[v] or dataWrapper( v, seen )
return seen[v]
end
return v
end,
__newindex = function ( t, k, v )
error( "table from mw.loadData is read-only", 2 )
end,
__pairs = function ( tt )
assert( t == tt )
return pairsfunc, t, nil
end,
__ipairs = function ( tt )
assert( t == tt )
return ipairsfunc, t, 0
end,
}
-- This is just to make setmetatable() fail
mt.__metatable = mt
return setmetatable( t, mt )
end
---
-- Validator for mw.loadData. This scans through the data looking for things
-- that are not supported, e.g. functions (which may be closures).
--
-- @param d table Data to access.
-- @param seen table|nil Table of already-seen tables.
-- @return string|nil Error message, if any
local function validateData( d, seen )
seen = seen or {}
local tp = type( d )
if tp == 'nil' or tp == 'boolean' or tp == 'number' or tp == 'string' then
return nil
elseif tp == 'table' then
if seen[d] then
return nil
end
seen[d] = true
if getmetatable( d ) ~= nil then
return "data for mw.loadData contains a table with a metatable"
end
for k, v in pairs( d ) do
if type( k ) == 'table' then
return "data for mw.loadData contains a table as a key"
end
local err = validateData( k, seen ) or validateData( v, seen )
if err then
return err
end
end
return nil
else
return "data for mw.loadData contains unsupported data type '" .. tp .. "'"
end
end
function mw.loadData( module )
local data = loadedData[module]
if type( data ) == 'string' then
-- No point in re-validating
error( data, 2 )
end
if not data then
-- Don't allow accessing the current frame's info (bug 65687)
local oldFrame = currentFrame
currentFrame = newFrame( 'empty' )
-- The point of this is to load big data, so don't save it in package.loaded
-- where it will have to be copied for all future modules.
local l = package.loaded[module]
local _
_, data = mw.executeModule( function() return require( module ) end )
package.loaded[module] = l
currentFrame = oldFrame
-- Validate data
local err
if type( data ) == 'table' then
err = validateData( data )
else
err = module .. ' returned ' .. type( data ) .. ', table expected'
end
if err then
loadedData[module] = err
error( err, 2 )
end
loadedData[module] = data
end
return dataWrapper( data )
end
return mw
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-Production | c59907935.lua | 6 | 1747 | --サイバーデーモン
function c59907935.initial_effect(c)
--draw
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(59907935,0))
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetRange(LOCATION_MZONE)
e1:SetCode(EVENT_PREDRAW)
e1:SetCondition(c59907935.drcon)
e1:SetTarget(c59907935.drtg)
e1:SetOperation(c59907935.drop)
c:RegisterEffect(e1)
--destroy
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(59907935,1))
e2:SetCategory(CATEGORY_DESTROY)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1)
e2:SetCode(EVENT_PHASE+PHASE_END)
e2:SetCondition(c59907935.descon)
e2:SetTarget(c59907935.destg)
e2:SetOperation(c59907935.desop)
c:RegisterEffect(e2)
end
function c59907935.drcon(e,tp,eg,ep,ev,re,r,rp)
return ep==tp and Duel.GetFieldGroupCount(tp,LOCATION_HAND,0)==0
end
function c59907935.drtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end
Duel.SetTargetPlayer(tp)
Duel.SetTargetParam(1)
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1)
end
function c59907935.drop(e,tp,eg,ep,ev,re,r,rp,c)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Draw(p,d,REASON_EFFECT)
end
function c59907935.descon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==tp and Duel.GetFieldGroupCount(tp,LOCATION_HAND,0)>0
end
function c59907935.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 c59907935.desop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) and c:IsFaceup() then
Duel.Destroy(c,REASON_EFFECT)
end
end
| gpl-2.0 |
dr01d3r/darkstar | scripts/globals/items/bowl_of_soy_ramen.lua | 12 | 1807 | -----------------------------------------
-- ID: 6458
-- Item: bowl_of_soy_ramen
-- Food Effect: 30Min, All Races
-----------------------------------------
-- HP +50
-- STR +5
-- VIT +5
-- AGI +3
-- Attack +10% (cap 170)
-- Ranged Attack +10% (cap 170)
-- Resist Slow +10
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,1800,6458);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 50);
target:addMod(MOD_STR, 5);
target:addMod(MOD_VIT, 5);
target:addMod(MOD_AGI, 3);
target:addMod(MOD_FOOD_ATTP, 10);
target:addMod(MOD_FOOD_ATT_CAP, 170);
target:addMod(MOD_FOOD_RATTP, 10);
target:addMod(MOD_FOOD_RATT_CAP, 170);
target:addMod(MOD_SLOWRES, 10);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 50);
target:delMod(MOD_STR, 5);
target:delMod(MOD_VIT, 5);
target:delMod(MOD_AGI, 3);
target:delMod(MOD_FOOD_ATTP, 10);
target:delMod(MOD_FOOD_ATT_CAP, 170);
target:delMod(MOD_FOOD_RATTP, 10);
target:delMod(MOD_FOOD_RATT_CAP, 170);
target:delMod(MOD_SLOWRES, 10);
end;
| gpl-3.0 |
kequanJiang/skynet_start | mjlib/base/hulib.lua | 2 | 3064 | package.path = "../../lualib/?.lua;"..package.path
local utils = require "utils"
local wave_table = require "auto_table"
local wave_table_eye = require "auto_table_with_eye"
local mjlib = require "mjlib"
local M = {}
function M.check_7dui(hand_cards, waves)
if #waves > 0 then return false end
for _,c in ipairs(hand_cards) do
if c % 2 ~= 0 then
return false
end
end
return true
end
function M.check_pengpeng()
end
function M.get_hu_info(hand_cards, waves, self_card, other_card)
local hand_cards_tmp = {}
for i,v in ipairs(hand_cards) do
hand_cards_tmp[i] = v
end
if other_card then
hand_cards_tmp[other_card] = hand_cards_tmp[other_card] + 1
end
local first_info = {
eye = false, -- 当前是否有将
dui_array = {},
}
for color, cfg in pairs(mjlib.CardType) do
if cfg.chi and not M.check_color_chi(hand_cards_tmp, cfg, first_info) then
return false
elseif not cfg.chi and not M.check_color(hand_cards_tmp, cfg, first_info) then
return false
end
end
return true
end
function M.check_color(cards, cfg, info)
for i = cfg.min, cfg.max do
local count = cards[i]
if count == 1 or count == 4 then
return false
end
if count == 2 then
if info.eye then
return false
end
info.eye = true
end
end
return true
end
function M.check_color_chi(cards, cfg, info)
local tbl = {}
for i = cfg.min, cfg.max do
repeat
local count = cards[i]
if count > 0 then
table.insert(tbl, count)
end
if count == 0 or i == cfg.max then
if #tbl == 0 then
break
end
if not M.check_sub(tbl, info) then
return false
end
tbl = {}
end
until(true)
end
return true
end
function M.check_sub(tbl, info)
local count = 0
for _,v in ipairs(tbl) do
count = count + v
end
local yu = (count % 3)
if yu == 1 then
return false
elseif yu == 2 then
if info.eye then
return false
end
info.eye = true
return M.check_wave_and_eye(tbl)
end
return M.check_wave(tbl)
end
function M.check_wave(tbl)
local num = 0
for _,c in ipairs(tbl) do
num = num * 10 + c
end
if wave_table[num] then
return true
end
if wave_table.collect then
wave_table[num] = true
end
return false
end
-- 检查是否匹配3*n + 2
function M.check_wave_and_eye(tbl)
if #tbl == 1 then
return true
end
local num = 0
for _,c in ipairs(tbl) do
num = num * 10 + c
end
if wave_table_eye[num] then
return true
end
if wave_table_eye.collect then
wave_table_eye[num] = true
end
return false
end
return M
| mit |
dr01d3r/darkstar | scripts/zones/RuAun_Gardens/npcs/HomePoint#2.lua | 27 | 1265 | -----------------------------------
-- Area: RuAun_Gardens
-- NPC: HomePoint#2
-- @pos -499 -42 167 130
-----------------------------------
package.loaded["scripts/zones/RuAun_Gardens/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/RuAun_Gardens/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fd, 60);
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 == 0x21fd) then
if (option == 1) then
player:setHomePoint();
player:messageSpecial(HOMEPOINT_SET);
else
hpTeleport( player, option);
end
end
end; | gpl-3.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.