repo_name stringlengths 6 69 | path stringlengths 6 178 | copies stringclasses 278
values | size stringlengths 4 7 | content stringlengths 671 917k | license stringclasses 15
values |
|---|---|---|---|---|---|
Lsty/ygopro-scripts | c50088247.lua | 3 | 2629 | --氷結界の伝道師
function c50088247.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(c50088247.spcon)
e1:SetOperation(c50088247.spop)
c:RegisterEffect(e1)
--special summon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(50088247,0))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_MZONE)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCost(c50088247.spcost2)
e2:SetTarget(c50088247.sptg2)
e2:SetOperation(c50088247.spop2)
c:RegisterEffect(e2)
Duel.AddCustomActivityCounter(50088247,ACTIVITY_SPSUMMON,c50088247.counterfilter)
end
function c50088247.counterfilter(c)
return not c:IsLevelAbove(5)
end
function c50088247.cfilter(c)
return c:IsFaceup() and c:IsSetCard(0x2f)
end
function c50088247.spcon(e,c)
if c==nil then return true end
local tp=c:GetControler()
return Duel.GetCustomActivityCount(50088247,tp,ACTIVITY_SPSUMMON)==0
and Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c50088247.cfilter,tp,LOCATION_MZONE,0,1,nil)
end
function c50088247.spop(e,tp,eg,ep,ev,re,r,rp,c)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e1:SetReset(RESET_PHASE+PHASE_END)
e1:SetTargetRange(1,0)
e1:SetTarget(c50088247.sumlimit)
Duel.RegisterEffect(e1,tp)
end
function c50088247.sumlimit(e,c,sump,sumtype,sumpos,targetp,se)
return c:IsLevelAbove(5)
end
function c50088247.spcost2(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsReleasable() end
Duel.Release(e:GetHandler(),REASON_COST)
end
function c50088247.filter(c,e,tp)
return c:IsSetCard(0x2f) and c:GetCode()~=50088247 and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c50088247.sptg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c50088247.filter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1
and Duel.IsExistingTarget(c50088247.filter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c50088247.filter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,g:GetCount(),0,0)
end
function c50088247.spop2(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
end
end
| gpl-2.0 |
gallenmu/MoonGen | libmoon/lua/proto/newProtocolTemplate.lua | 4 | 4464 | ------------------------------------------------------------------------
--- @file PROTO.lua
--- @brief (PROTO) utility.
--- Utility functions for the PROTO_header structs
--- Includes:
--- - PROTO constants
--- - PROTO header utility
--- - Definition of PROTO packets
------------------------------------------------------------------------
--[[
-- Use this file as template when implementing a new protocol (to implement all mandatory stuff)
-- Replace all occurrences of PROTO with your protocol (e.g. sctp)
-- Remove unnecessary comments in this file (comments inbetween [[...]])
-- Necessary changes to other files:
-- - packet.lua: if the header has a length member, adapt packetSetLength;
-- if the packet has a checksum, adapt createStack (loop at end of function) and packetCalculateChecksums
-- - proto/proto.lua: add PROTO.lua to the list so it gets loaded
--]]
local ffi = require "ffi"
require "proto.template"
local initHeader = initHeader
---------------------------------------------------------------------------
---- PROTO constants
---------------------------------------------------------------------------
--- PROTO protocol constants
local PROTO = {}
---------------------------------------------------------------------------
---- PROTO header
---------------------------------------------------------------------------
PROTO.headerFormat = [[
uint8_t xyz;
]]
--- Variable sized member
PROTO.headerVariableMember = nil
--- Module for PROTO_address struct
local PROTOHeader = initHeader()
PROTOHeader.__index = PROTOHeader
--[[ for all members of the header with non-standard data type: set, get, getString
-- for set also specify a suitable default value
--]]
--- Set the XYZ.
--- @param int XYZ of the PROTO header as A bit integer.
function PROTOHeader:setXYZ(int)
int = int or 0
end
--- Retrieve the XYZ.
--- @return XYZ as A bit integer.
function PROTOHeader:getXYZ()
return nil
end
--- Retrieve the XYZ as string.
--- @return XYZ as string.
function PROTOHeader:getXYZString()
return nil
end
--- Set all members of the PROTO header.
--- Per default, all members are set to default values specified in the respective set function.
--- Optional named arguments can be used to set a member to a user-provided value.
--- @param args Table of named arguments. Available arguments: PROTOXYZ
--- @param pre prefix for namedArgs. Default 'PROTO'.
--- @code
--- fill() -- only default values
--- fill{ PROTOXYZ=1 } -- all members are set to default values with the exception of PROTOXYZ, ...
--- @endcode
function PROTOHeader:fill(args, pre)
args = args or {}
pre = pre or "PROTO"
self:setXYZ(args[pre .. "PROTOXYZ"])
end
--- Retrieve the values of all members.
--- @param pre prefix for namedArgs. Default 'PROTO'.
--- @return Table of named arguments. For a list of arguments see "See also".
--- @see PROTOHeader:fill
function PROTOHeader:get(pre)
pre = pre or "PROTO"
local args = {}
args[pre .. "PROTOXYZ"] = self:getXYZ()
return args
end
--- Retrieve the values of all members.
--- @return Values in string format.
function PROTOHeader:getString()
return "PROTO " .. self:getXYZString()
end
--- Resolve which header comes after this one (in a packet)
--- For instance: in tcp/udp based on the ports
--- This function must exist and is only used when get/dump is executed on
--- an unknown (mbuf not yet casted to e.g. tcpv6 packet) packet (mbuf)
--- @return String next header (e.g. 'eth', 'ip4', nil)
function PROTOHeader:resolveNextHeader()
return nil
end
--- Change the default values for namedArguments (for fill/get)
--- This can be used to for instance calculate a length value based on the total packet length
--- See proto/ip4.setDefaultNamedArgs as an example
--- This function must exist and is only used by packet.fill
--- @param pre The prefix used for the namedArgs, e.g. 'PROTO'
--- @param namedArgs Table of named arguments (see See more)
--- @param nextHeader The header following after this header in a packet
--- @param accumulatedLength The so far accumulated length for previous headers in a packet
--- @return Table of namedArgs
--- @see PROTOHeader:fill
function PROTOHeader:setDefaultNamedArgs(pre, namedArgs, nextHeader, accumulatedLength)
return namedArgs
end
------------------------------------------------------------------------
---- Metatypes
------------------------------------------------------------------------
PROTO.metatype = PROTOHeader
return PROTO
| mit |
jadarve/lluvia | lluvia/lua/ll/library.lua | 1 | 9892 |
ll['nodeBuilders'] = {}
ll['activeSession'] = nil
function ll.logd(tag, ...)
-- print(tag, ...)
end
function ll.class(base)
local c = {}
if base then
-- shallow copy of base class members
if type(base) == 'table' then
for i, v in pairs(base) do
c[i] = v
end
end
end
c.__index = c
return c
end
function ll.registerNodeBuilder(builder)
-- TODO: add validation on builder.name not empty?
ll.nodeBuilders[builder.name] = builder
end
function ll.getNodeBuilder(name)
local builder = ll.nodeBuilders[name]
if builder == nil then
error('builder not found: ' .. name)
end
return builder
end
function ll.getNodeBuilderDescriptors()
local sortedKeys = {}
for k in pairs(ll.nodeBuilders) do
table.insert(sortedKeys, k)
end
table.sort(sortedKeys, function(a, b) return a:lower() < b:lower() end)
local output = {}
for _, name in ipairs(sortedKeys) do
local builder = ll.nodeBuilders[name]
-- finds the summary string
local firstLineIndex = builder.doc:find('\n')
local summary = builder.doc:sub(1, firstLineIndex-1)
local desc = ll.NodeBuilderDescriptor.new(builder.type, name, summary)
table.insert(output, desc)
end
return output
end
function ll.castObject(obj)
castTable = {
[ll.ObjectType.Buffer] = ll.impl.castObjectToBuffer,
[ll.ObjectType.Image] = ll.impl.castObjectToImage,
[ll.ObjectType.ImageView] = ll.impl.castObjectToImageView
}
return castTable[obj.type](obj)
end
function ll.castNode(node)
castTable = {
[ll.NodeType.Compute] = ll.impl.castNodeToComputeNode,
[ll.NodeType.Container] = ll.impl.castNodeToContainerNode
}
return castTable[node.type](node)
end
function ll.floatPrecisionToImageChannelType(floatPrecision)
if floatPrecision == ll.FloatPrecision.FP16 then
return ll.ChannelType.Float16
elseif floatPrecision == ll.FloatPrecision.FP32 then
return ll.ChannelType.Float32
elseif floatPrecision == ll.FloatPrecision.FP64 then
return ll.ChannelType.Float64
else
error('unknown float precision value: ' .. floatPrecision)
end
end
-----------------------------------------------------------
-- Session
-----------------------------------------------------------
function ll.getHostMemory()
if not ll.activeSession then
error('ll.activeSession nil')
end
return ll.activeSession:getHostMemory()
end
function ll.getProgram(name)
if not ll.activeSession then
error('ll.activeSession nil')
end
return ll.activeSession:getProgram(name)
end
function ll.createComputeNode(name)
if not ll.activeSession then
error('ll.activeSession nil')
end
return ll.activeSession:createComputeNode(name)
end
function ll.createContainerNode(name)
if not ll.activeSession then
error('ll.activeSession nil')
end
return ll.activeSession:createContainerNode(name)
end
function ll.getGoodComputeLocalShape(dimensions)
if not ll.activeSession then
error('ll.activeSession nil')
end
return ll.activeSession:getGoodComputeLocalShape(dimensions)
end
-- runs a compute node
-- TODO: overload to support running command buffers and container nodes
function ll.run(computeNode)
if not ll.activeSession then
error('ll.activeSession nil')
end
ll.activeSession:__runComputeNode(computeNode)
end
-----------------------------------------------------------
-- ComputeNodeBuilder
-----------------------------------------------------------
ll.ComputeNodeBuilder = ll.class()
ll.ComputeNodeBuilder.type = ll.NodeType.Compute
ll.ComputeNodeBuilder.doc = ""
ll.ComputeNodeDescriptor.name = ""
function ll.ComputeNodeBuilder.newDescriptor()
error('newDescriptor must be implemented by child classes')
end
function ll.ComputeNodeBuilder.onNodeInit(node)
-- do nothing
end
-----------------------------------------------------------
-- ContainerNodeBuilder
-----------------------------------------------------------
ll.ContainerNodeBuilder = ll.class()
ll.ContainerNodeBuilder.type = ll.NodeType.Container
ll.ContainerNodeBuilder.doc = ""
ll.ContainerNodeBuilder.name = ""
function ll.ContainerNodeBuilder.newDescriptor()
error('newDescriptor must be implemented by child classes')
end
function ll.ContainerNodeBuilder.onNodeInit(node)
-- do nothing
end
function ll.ContainerNodeBuilder.onNodeRecord(node, cmdBuffer)
-- do nothing
end
-----------------------------------------------------------
-- Parameter
-----------------------------------------------------------
function ll.Parameter:get()
-- castTable = {
-- [ll.ParameterType.Int] = self:__getInt(),
-- [ll.ParameterType.Float] = self:__getFloat()
-- }
-- return castTable[self.type]()
if self.type == ll.ParameterType.Int then
return self:__getInt()
end
if self.type == ll.ParameterType.Float then
return self:__getFloat()
end
if self.type == ll.ParameterType.Bool then
return self:__getBool()
end
end
function ll.Parameter:set(value)
if type(value) == 'number' then
self:__setFloat(value)
end
if type(value) == 'boolean' then
self:__setBool(value)
end
-- castTable = {
-- ['number'] = self:__setFloat
-- }
-- castTable[type(value)](value)
end
-----------------------------------------------------------
-- ComputeNodeDescriptor
-----------------------------------------------------------
--- Initialize the descriptor.
--
-- The initialization includes:
-- - Setting the descriptor buildderName to name
-- - Looking for the program with the same name plus the .comp extension in the registry.
-- - Setting program functionName to main.
-- - Setting the gridShape to (1, 1, 1)
-- - Setting the localShape to
--
-- @param name The name of the descriptor. It is also used
-- for looking for the program in the registry.
function ll.ComputeNodeDescriptor:init(name, dimensions)
self.builderName = name
self.program = ll.getProgram(name .. '.comp')
self.functionName = 'main'
self.localShape = ll.getGoodComputeLocalShape(dimensions)
self.gridShape = ll.vec3ui.new(1, 1, 1)
end
function ll.ComputeNodeDescriptor:setParameter(name, value)
-- this workaround is needed in order to call
-- the correct setter method given Lua type for value
local param = ll.Parameter.new()
param:set(value)
self:__setParameter(name, param)
end
function ll.ComputeNodeDescriptor:getParameter(name)
local param = self:__getParameter(name)
return param:get()
end
-----------------------------------------------------------
-- ComputeNode
-----------------------------------------------------------
function ll.ComputeNode:getPort(name)
return ll.castObject(self:__getPort(name))
end
function ll.ComputeNode:bind(name, obj)
castTable = {
[ll.ObjectType.Buffer] = ll.impl.castBufferToObject,
[ll.ObjectType.Image] = ll.impl.castImageToObject,
[ll.ObjectType.ImageView] = ll.impl.castImageViewToObject
}
self:__bind(name, castTable[obj.type](obj))
end
function ll.ComputeNode:setParameter(name, value)
-- this workaround is needed in order to call
-- the correct setter method given Lua type for value
local param = ll.Parameter.new()
param:set(value)
self:__setParameter(name, param)
end
function ll.ComputeNode:getParameter(name)
local param = self:__getParameter(name)
return param:get()
end
-----------------------------------------------------------
-- ContainerNodeDescriptor
-----------------------------------------------------------
function ll.ContainerNodeDescriptor:setParameter(name, value)
-- this workaround is needed in order to call
-- the correct setter method given Lua type for value
local param = ll.Parameter.new()
param:set(value)
self:__setParameter(name, param)
end
function ll.ContainerNodeDescriptor:getParameter(name)
local param = self:__getParameter(name)
return param:get()
end
-----------------------------------------------------------
-- ContainerNode
-----------------------------------------------------------
function ll.ContainerNode:getPort(name)
return ll.castObject(self:__getPort(name))
end
function ll.ContainerNode:bind(name, obj)
castTable = {
[ll.ObjectType.Buffer] = ll.impl.castBufferToObject,
[ll.ObjectType.Image] = ll.impl.castImageToObject,
[ll.ObjectType.ImageView] = ll.impl.castImageViewToObject
}
self:__bind(name, castTable[obj.type](obj))
end
function ll.ContainerNode:getNode(name)
local node = self:__getNode(name)
if not node then
error(string.format('node with name %s not found', name))
end
return ll.castNode(node)
end
function ll.ContainerNode:bindNode(name, node)
castTable = {
[ll.NodeType.Compute] = ll.impl.castComputeNodeToNode,
[ll.NodeType.Container] = ll.impl.castContainerNodeToNode
}
self:__bindNode(name, castTable[node.type](node))
end
function ll.ContainerNode:setParameter(name, value)
-- this workaround is needed in order to call
-- the correct setter method given Lua type for value
local param = ll.Parameter.new()
param:set(value)
self:__setParameter(name, param)
end
function ll.ContainerNode:getParameter(name)
local param = self:__getParameter(name)
return param:get()
end
| apache-2.0 |
StewEsho/Prepenole | enemies.lua | 2 | 5060 | --------------------------------------------------------------------------------
--
-- Centralized module for spawning, tracking, and handling enemies
-- Contains a table, which itself contains more table_insert
-- Each subtable contains all instances of enemies.
-- This way, every enemy can be accessed through this one module
--
-- enemies.lua
--
------------------------------- Private Fields ---------------------------------
local scene = require("scene");
local skeleton = require("en_skeleton");
local aquae = require("en_aqua");
local fireballer = require("en_fire");
local turret = require("en_turret");
enemies = {};
enemies_mt = {__index = enemies}; --metatable
local enemyList;
local moduleList;
local skeletonList;
local aquaeList;
local fireList;
local turretList;
local enemyCount = 0; --stores number of enemies spawned
local enemyTimer = 0; --used to repeatedly spawn in enemies
--------------------------------- Constructor ----------------------------------
function enemies.new()
local newEnemies = {
}
setmetatable(newEnemies, enemies_mt);
skeletonList = {}; --List of all Skeleton enemies
aquaeList = {}; --List of all aquae ships
fireList = {}; --List of all fireballer ships
--turretList = {};
--List of all enemies
enemyList = {
--[[
/////INDEX of ENEMIES/////
[1] = skeletonList
[2] = aquaList
[3] = fireList
[4] = turretList
]]
skeletonList,
aquaeList,
fireList
--turretList
}
--List of all clases; corresponds with order in enemyList
--Used to spawn instances of these classes
moduleList = {
skeleton,
aquae,
fireballer
--turret
}
return newEnemies;
end
------------------------------ Public Functions --------------------------------
--[[
spawn(_index, _layer, _x, _y)
- spawns a new enemy, and adds it to the list
- _index determines which type of enemy to spawn
- does NOT add the oobject to the scene
@return the instance of the enemy;
get(_index1, _index2)
- retrieves the specificed enemy instance;
- _index1 is the type of enemy, and _index2 specifes which in particular
- retrieves newest instance if _index2 is not specified
@return the instance of the enemy;
]]
function enemies:spawn(_index, _x, _y, params)
params = params or {};
_index = _index or math.random(1, table.getn(enemyList))
table.insert(enemyList[_index], moduleList[_index].class(_x, _y, table.getn(enemyList[_index])+1, params));
--print(enemyList[_index][table.getn(enemyList[_index])].sprite.name .. " | " .. enemyList[_index][table.getn(enemyList[_index])].sprite.index);
return enemyList[_index][table.getn(enemyList[_index])];
end
function enemies:batchSpawn(_amount, params)
_amount = _amount or 5;
for i = 1, _amount do
_index = math.random(1, table.getn(enemyList))
table.insert(enemyList[_index], moduleList[_index].class(_x, _y, table.getn(enemyList[_index])+1, params));
end
end
function enemies:get(_index1, _index2)
if (_index1 == nil) then
return enemyList;
elseif (_index2 == nil) then
return enemyList[_index1];
else
return enemyList[_index1][_index2];
end
end
function enemies:kill(_index1, _index2)
table.remove(enemyList[_index1], _index2);
local soundEffect = audio.loadSound( "audio/sfx/success2.wav" )
audio.play( soundEffect )
end
function enemies:randomSpawn(_x, _y, params)
--randomly spawns enemies
if (enemyTimer < 120) then
enemyTimer = enemyTimer + 1;
else
enemyTimer = 0;
if (enemyCount < 25) then
enemies:spawn(math.random(1, table.getn(enemyList)), math.random(_x - 3000, _x + 3000), math.random(_y - 3000, _y + 3000), params);
end
end
end
function enemies:clear(radar)
for i = 1, table.getn(enemyList) do
for j = 1, table.getn(enemyList[i]) do
if (enemyList[i][j] == nil) then break
else
enemyList[i][j]:kill(radar);
self:kill(i, j);
end
end
end
end
function enemies:run(params)
enemyCount = 0;
params.x = params.x or 0
params.y = params.y or 0
--runs logic behind enemies
for i = 1, table.getn(enemyList) do
for j = 1, table.getn(enemyList[i]) do
if (enemyList[i][j] == nil) then break
elseif (enemyList[i][j].sprite.isDead) then
enemyList[i][j]:kill(params.radar, "isDead");
table.remove(enemyList[i], j);
elseif (enemyList[i][j]:getDistanceTo(params.x, params.y) > 12500
and enemyList[i][j]:getAutoKill()) then
enemyList[i][j]:kill(params.radar, "Distance");
table.remove(enemyList[i], j);
else
enemyList[i][j]:run(params.radar);
enemyList[i][j]:runCoroutine();
enemyCount = enemyCount + 1;
end
end
end
return enemyCount;
end
function enemies:getAmount()
local enemyAmount = 0;
for i = 1, table.getn(enemyList) do
for j = 1, table.getn(enemyList[i]) do
if (enemyList[i][j] == nil) then break
else
enemyAmount = enemyAmount + 1;
end
end
end
return enemyAmount;
end
return enemies;
| gpl-3.0 |
Lsty/ygopro-scripts | c3064425.lua | 3 | 3508 | --超重武者装留ビッグバン
function c3064425.initial_effect(c)
--equip
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(3064425,0))
e1:SetCategory(CATEGORY_EQUIP)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetRange(LOCATION_HAND+LOCATION_MZONE)
e1:SetTarget(c3064425.eqtg)
e1:SetOperation(c3064425.eqop)
c:RegisterEffect(e1)
--negate
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(3064425,1))
e2:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY+CATEGORY_DAMAGE)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_QUICK_O)
e2:SetCode(EVENT_CHAINING)
e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL)
e2:SetRange(LOCATION_GRAVE)
e2:SetCondition(c3064425.negcon)
e2:SetCost(c3064425.negcost)
e2:SetTarget(c3064425.negtg)
e2:SetOperation(c3064425.negop)
c:RegisterEffect(e2)
end
function c3064425.filter(c)
return c:IsFaceup() and c:IsSetCard(0x9a)
end
function c3064425.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c3064425.filter(chkc) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and Duel.IsExistingTarget(c3064425.filter,tp,LOCATION_MZONE,0,1,e:GetHandler()) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,c3064425.filter,tp,LOCATION_MZONE,0,1,1,e:GetHandler())
end
function c3064425.eqop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) then return end
if c:IsLocation(LOCATION_MZONE) and c:IsFacedown() then return end
local tc=Duel.GetFirstTarget()
if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 or tc:GetControler()~=tp or tc:IsFacedown() or not tc:IsRelateToEffect(e) then
Duel.SendtoGrave(c,REASON_EFFECT)
return
end
Duel.Equip(tp,c,tc,true)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_EQUIP_LIMIT)
e1:SetReset(RESET_EVENT+0x1fe0000)
e1:SetValue(c3064425.eqlimit)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_EQUIP)
e2:SetCode(EFFECT_UPDATE_DEFENCE)
e2:SetValue(1000)
e2:SetReset(RESET_EVENT+0x1fe0000)
c:RegisterEffect(e2)
end
function c3064425.eqlimit(e,c)
return c:IsSetCard(0x9a)
end
function c3064425.cfilter(c)
return c:IsPosition(POS_FACEUP_DEFENCE) and c:IsSetCard(0x9a)
end
function c3064425.negcon(e,tp,eg,ep,ev,re,r,rp)
local ph=Duel.GetCurrentPhase()
return ep~=tp and Duel.IsChainNegatable(ev) and ph>PHASE_MAIN1 and ph<PHASE_MAIN2
and Duel.IsExistingMatchingCard(c3064425.cfilter,tp,LOCATION_MZONE,0,1,nil)
end
function c3064425.negcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end
Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST)
end
function c3064425.negtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0)
local g=Duel.GetMatchingGroup(Card.IsDestructable,tp,LOCATION_MZONE,LOCATION_MZONE,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,PLAYER_ALL,1000)
end
function c3064425.negop(e,tp,eg,ep,ev,re,r,rp)
Duel.NegateActivation(ev)
if re:GetHandler():IsRelateToEffect(re) and Duel.Destroy(eg,REASON_EFFECT)~=0 then
Duel.BreakEffect()
local g=Duel.GetMatchingGroup(Card.IsDestructable,tp,LOCATION_MZONE,LOCATION_MZONE,nil)
if Duel.Destroy(g,REASON_EFFECT)==0 then return end
Duel.Damage(tp,1000,REASON_EFFECT)
Duel.Damage(1-tp,1000,REASON_EFFECT)
end
end
| gpl-2.0 |
cshore-firmware/openwrt-luci | libs/luci-lib-httpclient/luasrc/httpclient.lua | 62 | 9481 | -- Copyright 2009 Steven Barth <steven@midlink.org>
-- Licensed to the public under the Apache License 2.0.
require "nixio.util"
local nixio = require "nixio"
local ltn12 = require "luci.ltn12"
local util = require "luci.util"
local table = require "table"
local http = require "luci.http.protocol"
local date = require "luci.http.protocol.date"
local type, pairs, ipairs, tonumber = type, pairs, ipairs, tonumber
local unpack = unpack
module "luci.httpclient"
function chunksource(sock, buffer)
buffer = buffer or ""
return function()
local output
local _, endp, count = buffer:find("^([0-9a-fA-F]+);?.-\r\n")
while not count and #buffer <= 1024 do
local newblock, code = sock:recv(1024 - #buffer)
if not newblock then
return nil, code
end
buffer = buffer .. newblock
_, endp, count = buffer:find("^([0-9a-fA-F]+);?.-\r\n")
end
count = tonumber(count, 16)
if not count then
return nil, -1, "invalid encoding"
elseif count == 0 then
return nil
elseif count + 2 <= #buffer - endp then
output = buffer:sub(endp+1, endp+count)
buffer = buffer:sub(endp+count+3)
return output
else
output = buffer:sub(endp+1, endp+count)
buffer = ""
if count - #output > 0 then
local remain, code = sock:recvall(count-#output)
if not remain then
return nil, code
end
output = output .. remain
count, code = sock:recvall(2)
else
count, code = sock:recvall(count+2-#buffer+endp)
end
if not count then
return nil, code
end
return output
end
end
end
function request_to_buffer(uri, options)
local source, code, msg = request_to_source(uri, options)
local output = {}
if not source then
return nil, code, msg
end
source, code = ltn12.pump.all(source, (ltn12.sink.table(output)))
if not source then
return nil, code
end
return table.concat(output)
end
function request_to_source(uri, options)
local status, response, buffer, sock = request_raw(uri, options)
if not status then
return status, response, buffer
elseif status ~= 200 and status ~= 206 then
return nil, status, buffer
end
if response.headers["Transfer-Encoding"] == "chunked" then
return chunksource(sock, buffer)
else
return ltn12.source.cat(ltn12.source.string(buffer), sock:blocksource())
end
end
--
-- GET HTTP-resource
--
function request_raw(uri, options)
options = options or {}
local pr, auth, host, port, path
if options.params then
uri = uri .. '?' .. http.urlencode_params(options.params)
end
if uri:find("%[") then
if uri:find("@") then
pr, auth, host, port, path = uri:match("(%w+)://(.+)@(%b[]):?([0-9]*)(.*)")
host = host:sub(2,-2)
else
pr, host, port, path = uri:match("(%w+)://(%b[]):?([0-9]*)(.*)")
host = host:sub(2,-2)
end
else
if uri:find("@") then
pr, auth, host, port, path =
uri:match("(%w+)://(.+)@([%w-.]+):?([0-9]*)(.*)")
else
pr, host, port, path = uri:match("(%w+)://([%w-.]+):?([0-9]*)(.*)")
end
end
if not host then
return nil, -1, "unable to parse URI"
end
if pr ~= "http" and pr ~= "https" then
return nil, -2, "protocol not supported"
end
port = #port > 0 and port or (pr == "https" and 443 or 80)
path = #path > 0 and path or "/"
options.depth = options.depth or 10
local headers = options.headers or {}
local protocol = options.protocol or "HTTP/1.1"
headers["User-Agent"] = headers["User-Agent"] or "LuCI httpclient 0.1"
if headers.Connection == nil then
headers.Connection = "close"
end
if auth and not headers.Authorization then
headers.Authorization = "Basic " .. nixio.bin.b64encode(auth)
end
local sock, code, msg = nixio.connect(host, port)
if not sock then
return nil, code, msg
end
sock:setsockopt("socket", "sndtimeo", options.sndtimeo or 15)
sock:setsockopt("socket", "rcvtimeo", options.rcvtimeo or 15)
if pr == "https" then
local tls = options.tls_context or nixio.tls()
sock = tls:create(sock)
local stat, code, error = sock:connect()
if not stat then
return stat, code, error
end
end
-- Pre assemble fixes
if protocol == "HTTP/1.1" then
headers.Host = headers.Host or host
end
if type(options.body) == "table" then
options.body = http.urlencode_params(options.body)
end
if type(options.body) == "string" then
headers["Content-Length"] = headers["Content-Length"] or #options.body
headers["Content-Type"] = headers["Content-Type"] or
"application/x-www-form-urlencoded"
options.method = options.method or "POST"
end
if type(options.body) == "function" then
options.method = options.method or "POST"
end
if options.cookies then
local cookiedata = {}
for _, c in ipairs(options.cookies) do
local cdo = c.flags.domain
local cpa = c.flags.path
if (cdo == host or cdo == "."..host or host:sub(-#cdo) == cdo)
and (cpa == path or cpa == "/" or cpa .. "/" == path:sub(#cpa+1))
and (not c.flags.secure or pr == "https")
then
cookiedata[#cookiedata+1] = c.key .. "=" .. c.value
end
end
if headers["Cookie"] then
headers["Cookie"] = headers["Cookie"] .. "; " .. table.concat(cookiedata, "; ")
else
headers["Cookie"] = table.concat(cookiedata, "; ")
end
end
-- Assemble message
local message = {(options.method or "GET") .. " " .. path .. " " .. protocol}
for k, v in pairs(headers) do
if type(v) == "string" or type(v) == "number" then
message[#message+1] = k .. ": " .. v
elseif type(v) == "table" then
for i, j in ipairs(v) do
message[#message+1] = k .. ": " .. j
end
end
end
message[#message+1] = ""
message[#message+1] = ""
-- Send request
sock:sendall(table.concat(message, "\r\n"))
if type(options.body) == "string" then
sock:sendall(options.body)
elseif type(options.body) == "function" then
local res = {options.body(sock)}
if not res[1] then
sock:close()
return unpack(res)
end
end
-- Create source and fetch response
local linesrc = sock:linesource()
local line, code, error = linesrc()
if not line then
sock:close()
return nil, code, error
end
local protocol, status, msg = line:match("^([%w./]+) ([0-9]+) (.*)")
if not protocol then
sock:close()
return nil, -3, "invalid response magic: " .. line
end
local response = {
status = line, headers = {}, code = 0, cookies = {}, uri = uri
}
line = linesrc()
while line and line ~= "" do
local key, val = line:match("^([%w-]+)%s?:%s?(.*)")
if key and key ~= "Status" then
if type(response.headers[key]) == "string" then
response.headers[key] = {response.headers[key], val}
elseif type(response.headers[key]) == "table" then
response.headers[key][#response.headers[key]+1] = val
else
response.headers[key] = val
end
end
line = linesrc()
end
if not line then
sock:close()
return nil, -4, "protocol error"
end
-- Parse cookies
if response.headers["Set-Cookie"] then
local cookies = response.headers["Set-Cookie"]
for _, c in ipairs(type(cookies) == "table" and cookies or {cookies}) do
local cobj = cookie_parse(c)
cobj.flags.path = cobj.flags.path or path:match("(/.*)/?[^/]*")
if not cobj.flags.domain or cobj.flags.domain == "" then
cobj.flags.domain = host
response.cookies[#response.cookies+1] = cobj
else
local hprt, cprt = {}, {}
-- Split hostnames and save them in reverse order
for part in host:gmatch("[^.]*") do
table.insert(hprt, 1, part)
end
for part in cobj.flags.domain:gmatch("[^.]*") do
table.insert(cprt, 1, part)
end
local valid = true
for i, part in ipairs(cprt) do
-- If parts are different and no wildcard
if hprt[i] ~= part and #part ~= 0 then
valid = false
break
-- Wildcard on invalid position
elseif hprt[i] ~= part and #part == 0 then
if i ~= #cprt or (#hprt ~= i and #hprt+1 ~= i) then
valid = false
break
end
end
end
-- No TLD cookies
if valid and #cprt > 1 and #cprt[2] > 0 then
response.cookies[#response.cookies+1] = cobj
end
end
end
end
-- Follow
response.code = tonumber(status)
if response.code and options.depth > 0 then
if (response.code == 301 or response.code == 302 or response.code == 307)
and response.headers.Location then
local nuri = response.headers.Location or response.headers.location
if not nuri then
return nil, -5, "invalid reference"
end
if not nuri:find("https?://") then
nuri = pr .. "://" .. host .. ":" .. port .. nuri
end
options.depth = options.depth - 1
if options.headers then
options.headers.Host = nil
end
sock:close()
return request_raw(nuri, options)
end
end
return response.code, response, linesrc(true)..sock:readall(), sock
end
function cookie_parse(cookiestr)
local key, val, flags = cookiestr:match("%s?([^=;]+)=?([^;]*)(.*)")
if not key then
return nil
end
local cookie = {key = key, value = val, flags = {}}
for fkey, fval in flags:gmatch(";%s?([^=;]+)=?([^;]*)") do
fkey = fkey:lower()
if fkey == "expires" then
fval = date.to_unix(fval:gsub("%-", " "))
end
cookie.flags[fkey] = fval
end
return cookie
end
function cookie_create(cookie)
local cookiedata = {cookie.key .. "=" .. cookie.value}
for k, v in pairs(cookie.flags) do
if k == "expires" then
v = date.to_http(v):gsub(", (%w+) (%w+) (%w+) ", ", %1-%2-%3 ")
end
cookiedata[#cookiedata+1] = k .. ((#v > 0) and ("=" .. v) or "")
end
return table.concat(cookiedata, "; ")
end
| apache-2.0 |
MalRD/darkstar | scripts/zones/The_Boyahda_Tree/npcs/qm2.lua | 9 | 1861 | -----------------------------------
-- Area: The Boyahda Tree
-- NPC: qm2 (???)
-- Involved in Quest: Searching for the Right Words
-- !pos 34.651 -20.183 -61.647 153
-----------------------------------
local ID = require("scripts/zones/The_Boyahda_Tree/IDs")
require("scripts/globals/keyitems")
require("scripts/globals/quests")
-----------------------------------
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
-- Notes: does ??? depop when Agas is spawned?
-- current implementation: when Agas is active, triggering ??? will result in detarget
local zoneHour = VanadielHour()
local zoneMinute = VanadielMinute()
local correctTime = zoneHour >= 19 or zoneHour < 4 or (zoneHour == 4 and zoneMinute == 0)
if not GetMobByID(ID.mob.AGAS):isSpawned() then
if player:hasKeyItem(dsp.ki.MOONDROP) then
player:messageSpecial(ID.text.CAN_SEE_SKY)
elseif player:getQuestStatus(JEUNO, dsp.quest.id.jeuno.SEARCHING_FOR_THE_RIGHT_WORDS) == QUEST_ACCEPTED then
if IsMoonNew() or not correctTime then
player:messageSpecial(ID.text.CANNOT_SEE_MOON)
elseif player:getCharVar("Searching_AgasKilled") == 1 then
player:startEvent(14)
else
player:messageSpecial(ID.text.SOMETHING_NOT_RIGHT)
SpawnMob(ID.mob.AGAS):updateClaim(player) -- missing repop timer for Agas due to errors with SpawnMob
end
else
player:messageSpecial(ID.text.CAN_SEE_SKY)
end
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 14 then
player:addKeyItem(dsp.ki.MOONDROP)
player:messageSpecial(ID.text.KEYITEM_OBTAINED, dsp.ki.MOONDROP)
player:setCharVar("Searching_AgasKilled", 0)
end
end
| gpl-3.0 |
MalRD/darkstar | scripts/zones/San_dOria-Jeuno_Airship/IDs.lua | 12 | 1307 | -----------------------------------
-- Area: San_dOria-Jeuno_Airship
-----------------------------------
require("scripts/globals/zone")
-----------------------------------
zones = zones or {}
zones[dsp.zone.SAN_DORIA_JEUNO_AIRSHIP] =
{
text =
{
ITEM_CANNOT_BE_OBTAINED = 6382, -- You cannot obtain the <item>. Come back after sorting your inventory.
ITEM_OBTAINED = 6388, -- Obtained: <item>.
GIL_OBTAINED = 6389, -- Obtained <number> gil.
KEYITEM_OBTAINED = 6391, -- Obtained key item: <keyitem>.
WILL_REACH_JEUNO = 7208, -- The airship will reach Jeuno in [less than an hour/about 1 hour/about 2 hours/about 3 hours/about 4 hours/about 5 hours/about 6 hours/about 7 hours] (# [minute/minutes] in Earth time).
WILL_REACH_SANDORIA = 7209, -- The airship will reach San d'Oria in [less than an hour/about 1 hour/about 2 hours/about 3 hours/about 4 hours/about 5 hours/about 6 hours/about 7 hours] (# [minute/minutes] in Earth time).
IN_JEUNO_MOMENTARILY = 7211, -- We will be arriving in Jeuno momentarily.
IN_SANDORIA_MOMENTARILY = 7212, -- We will be arriving in San d'Oria momentarily.
},
mob =
{
},
npc =
{
},
}
return zones[dsp.zone.SAN_DORIA_JEUNO_AIRSHIP] | gpl-3.0 |
MalRD/darkstar | scripts/zones/Port_Bastok/Zone.lua | 9 | 2770 | -----------------------------------
--
-- Zone: Port_Bastok (236)
--
-----------------------------------
local ID = require("scripts/zones/Port_Bastok/IDs");
require("scripts/globals/conquest")
require("scripts/globals/missions")
require("scripts/globals/settings")
require("scripts/globals/zone")
-----------------------------------
function onInitialize(zone)
zone:registerRegion(1,-112,-3,-17,-96,3,-3);--event COP
zone:registerRegion(2, 53.5, 5, -165.3, 66.5, 6, -72)--drawbridge area
end;
function onConquestUpdate(zone, updatetype)
dsp.conq.onConquestUpdate(zone, updatetype)
end;
function onZoneIn(player,prevZone)
local cs = -1;
-- FIRST LOGIN (START CS)
if (player:getPlaytime(false) == 0) then
if (OPENING_CUTSCENE_ENABLE == 1) then
cs = 1;
end
player:setPos(132,-8.5,-13,179);
player:setHomePoint();
end
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
if (prevZone == dsp.zone.BASTOK_JEUNO_AIRSHIP) then
cs = 73;
player:setPos(-36.000, 7.000, -58.000, 194);
else
local position = math.random(1,5) + 57;
player:setPos(position,8.5,-239,192);
if (player:getMainJob() ~= player:getCharVar("PlayerMainJob")) then
cs = 30004;
end
player:setCharVar("PlayerMainJob",0);
end
end
if (player:getCurrentMission(COP) == dsp.mission.id.cop.THE_ENDURING_TUMULT_OF_WAR and player:getCharVar("PromathiaStatus") == 0) then
cs = 306;
end
return cs;
end;
function onRegionEnter(player,region)
local regionID =region:GetRegionID();
-- printf("regionID: %u",regionID);
if (regionID == 1 and player:getCurrentMission(COP) == dsp.mission.id.cop.THE_CALL_OF_THE_WYRMKING and player:getCharVar("PromathiaStatus") == 0) then
player:startEvent(305);
end
end;
function onRegionLeave(player,region)
end;
function onTransportEvent(player,transport)
player:startEvent(71);
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 1) then
player:messageSpecial(ID.text.ITEM_OBTAINED,536);
elseif (csid == 71) then
player:setPos(0,0,0,0,224);
elseif (csid == 30004 and option == 0) then
player:setHomePoint();
player:messageSpecial(ID.text.HOMEPOINT_SET);
elseif (csid == 305) then
player:setCharVar("PromathiaStatus",1);
elseif (csid == 306) then
player:setCharVar("COP_optional_CS_chasalvigne",0);
player:setCharVar("COP_optional_CS_Anoki",0);
player:setCharVar("COP_optional_CS_Despachaire",0);
player:setCharVar("PromathiaStatus",1);
end
end; | gpl-3.0 |
gallenmu/MoonGen | libmoon/lua/lib/syscall.lua | 28 | 2041 | -- this puts everything into one table ready to use
local require, print, error, assert, tonumber, tostring,
setmetatable, pairs, ipairs, unpack, rawget, rawset,
pcall, type, table, string, math =
require, print, error, assert, tonumber, tostring,
setmetatable, pairs, ipairs, unpack, rawget, rawset,
pcall, type, table, string, math
local abi = require "syscall.abi"
if abi.rump and abi.types then abi.os = abi.types end -- pretend to be NetBSD for normal rump, Linux for rumplinux
if abi.os == "netbsd" then
-- TODO merge
require("syscall.netbsd.ffitypes")
if not abi.rump then
require("syscall.netbsd.ffifunctions")
end
else
require("syscall." .. abi.os .. ".ffi")
end
local c = require("syscall." .. abi.os .. ".constants")
local ostypes = require("syscall." .. abi.os .. ".types")
local bsdtypes
if (abi.rump and abi.types == "netbsd") or (not abi.rump and abi.bsd) then
bsdtypes = require("syscall.bsd.types")
end
local types = require "syscall.types".init(c, ostypes, bsdtypes)
local C
if abi.rump then -- TODO merge these with conditionals
C = require("syscall.rump.c")
else
C = require("syscall." .. abi.os .. ".c")
end
-- cannot put in S, needed for tests, cannot be put in c earlier due to deps TODO remove see #94
c.IOCTL = require("syscall." .. abi.os .. ".ioctl").init(types)
local S = require "syscall.syscalls".init(C, c, types)
S.abi, S.types, S.t, S.c = abi, types, types.t, c -- add to main table returned
-- add compatibility code
S = require "syscall.compat".init(S)
-- add functions from libc
S = require "syscall.libc".init(S)
-- add methods
S = require "syscall.methods".init(S)
-- add utils
S.util = require "syscall.util".init(S)
if abi.os == "linux" then
S.cgroup = require "syscall.linux.cgroup".init(S)
S.nl = require "syscall.linux.nl".init(S)
-- TODO add the other Linux specific modules here
end
S._VERSION = "v0.11pre"
S._DESCRIPTION = "ljsyscall: A Unix system call API for LuaJIT"
S._COPYRIGHT = "Copyright (C) 2011-2014 Justin Cormack. MIT licensed."
return S
| mit |
robertbrook/Penlight | tests/test-stringio.lua | 15 | 1569 | local stringio = require 'pl.stringio'
local test = require 'pl.test'
local asserteq = test.asserteq
local T = test.tuple
function fprintf(f,fmt,...)
f:write(fmt:format(...))
end
fs = stringio.create()
for i = 1,100 do
fs:write('hello','\n','dolly','\n')
end
asserteq(#fs:value(),1200)
fs = stringio.create()
fs:writef("%s %d",'answer',42) -- note writef() extension method
asserteq(fs:value(),"answer 42")
inf = stringio.open('10 20 30')
asserteq(T(inf:read('*n','*n','*n')),T(10,20,30))
local txt = [[
Some lines
here are they
not for other
english?
]]
inf = stringio.open (txt)
fs = stringio.create()
for l in inf:lines() do
fs:write(l,'\n')
end
asserteq(txt,fs:value())
inf = stringio.open '1234567890ABCDEF'
asserteq(T(inf:read(3), inf:read(5), inf:read()),T('123','45678','90ABCDEF'))
s = stringio.open 'one\ntwo'
asserteq(s:read() , 'one')
asserteq(s:read() , 'two')
asserteq(s:read() , nil)
s = stringio.open 'one\ntwo'
iter = s:lines()
asserteq(iter() , 'one')
asserteq(iter() , 'two')
asserteq(iter() , nil)
s = stringio.open 'ABC'
iter = s:lines(1)
asserteq(iter() , 'A')
asserteq(iter() , 'B')
asserteq(iter() , 'C')
asserteq(iter() , nil)
s = stringio.open '20 5.2e-2 52.3'
x,y,z = s:read('*n','*n','*n')
out = stringio.create()
fprintf(out,"%5.2f %5.2f %5.2f!",x,y,z)
asserteq(out:value(),"20.00 0.05 52.30!")
s = stringio.open 'one\ntwo\n\n'
iter = s:lines '*L'
asserteq(iter(),'one\n')
asserteq(iter(),'two\n')
asserteq(iter(),'\n')
asserteq(iter(),nil)
| mit |
weshoke/DSL | test/test.expr.lua | 1 | 5600 | if(LuaAV) then
addmodulepath = LuaAV.addmodulepath
else
---------------------------------------------------------------
-- Bootstrapping functions required to coalesce paths
local function exec(cmd, echo)
echo = echo or true
if(echo) then
print(cmd)
print("")
end
local res = io.popen(cmd):read("*a")
return res:sub(1, res:len()-1)
end
local function stripfilename(filename)
return string.match(filename, "(.+)/[^/]*%.%w+$")
end
local function strippath(filename)
return string.match(filename, ".+/([^/]*%.%w+)$")
end
local function stripextension(filename)
local idx = filename:match(".+()%.%w+$")
if(idx)
then return filename:sub(1, idx-1)
else return filename
end
end
function addmodulepath(path)
-- add to package paths (if not already present)
if not string.find(package.path, path, 0, true) then
package.path = string.format("%s/?.lua;%s", path, package.path)
package.path = string.format("%s/?/init.lua;%s", path, package.path)
package.cpath = string.format("%s/?.so;%s", path, package.cpath)
end
end
local function setup_path()
local pwd = exec("pwd")
local root = arg[0]
if(root and stripfilename(root)) then
root = stripfilename(root) .. "/"
else
root = ""
end
local script_path
local path
if(root:sub(1, 1) == "/") then
script_path = root
path = string.format("%s%s", root, "modules")
else
script_path = string.format("%s/%s", pwd, root)
path = string.format("%s/%s%s", pwd, root, "modules")
end
return script_path:sub(1, script_path:len()-1)
end
---------------------------------------------------------------
-- Script Initialization
script = {}
script.path = setup_path()
end
-- now the actual script
addmodulepath(script.path.."/..")
--[[
TODO:
- fast lookahead to terminals
- customized terminals or expression
- integrating annotations into syntax?
- AST -> string
--]]
local format = string.format
local DSL = require"DSL"
local utils = require"DSL.utilities"
local printt = utils.printt
local nl = utils.nl
local dsl = DSL{
tokens = [=[
IDENTIFIER = idchar * (idchar+digit)^0 - keywords
NUMBER = float+integer
BREAK = P"break"
CONTINUE = P"continue"
RETURN = P"return"
EQ = P"="
PLUS_EQ = P"+="
]=],
ops = {
{name="index_op", rule="index"},
{name="function_call_op", rule="function_call"},
{name="unary_op", arity=1, "!", "-"},
{name="multiplicative_op", "*", "/", "%"},
{name="additive_op", "+", "-"},
{name="relational_op", "<", "<=", ">", ">="},
{name="equality_op", "==", "!="},
{name="logical_and_op", "&&"},
{name="logical_or_op", "||"},
{name="conditional_op", arity=3, {"?", ":"}},
},
rules = [==[
index = IDENTIFIER * T"." * Assert(IDENTIFIER, "index.IDENTIFIER")
function_call = IDENTIFIER * args
assignment_operator = EQ + PLUS_EQ
assignment_expression = IDENTIFIER * assignment_operator *
Assert(expression, "expression_statement.expression")
expression_statement = assignment_expression * Assert(T";", "expression_statement.SEMICOLON")
argument_list = expression * (T"," * expression)^0
args = T"(" * argument_list^-1 * Assert(T")", "args.RIGHT_PAREN")
declaration = IDENTIFIER * IDENTIFIER * args^-1
declaration_statement = declaration * Assert(T";", "declaration_statement.SEMICOLON")
condition = T"(" * expression * Assert(T")", "condition.RIGHT_PAREN")
selection_statement = T"if" * condition * statement * (T"else" * statement)^-1
while_statement = T"while" * condition * statement
loop_condition = expression * Assert(T";", "loop_condition.SEMICOLON")
for_statement = T"for" * T"(" *
expression_statement *
loop_condition *
assignment_expression *
Assert(T")", "for_statement.RIGHT_PAREN")
iteration_statement = while_statement + for_statement
jump_statement = (BREAK + CONTINUE + RETURN * expression) * Assert(T";", "jump_statement.SEMICOLON")
statement =
compound_statement +
selection_statement +
iteration_statement +
jump_statement +
function_definition +
declaration_statement +
expression_statement
statement_list = statement^0
compound_statement = T"{" * statement_list * T"}"
function_definition = IDENTIFIER * args * compound_statement
]==],
comments = nl[=[
singleline_comment = P"//" * (1-P[[\n]])^0
multiline_comment = P"/*" * (1-P"*/")^0 * P"*/"
]=],
annotations = {
-- value tokens
NUMBER = { value=true },
IDENTIFIER = { value=true },
-- keyword tokens
BREAK = { keyword=true },
CONTINUE = { keyword=true },
RETURN = { keyword=true },
-- rule annotations
args = { collapsable=true },
assignment_operator = { collapsable=true },
expression_statement = { collapsable=true },
statement = { collapsable=true },
condition = { collapsable=true },
iteration_statement = { collapsable=true },
compound_statement = { collapsable=true },
}
}
local parser = dsl:parser{
root = "statement_list",
--root = "selection_statement",
--root = "declaration",
--root = "statement",
--root = "expression_statement",
mark_position = false,
trace = true,
--token_trace = true,
--anonymous_token_trace = true,
--commenttrace = false,
comment_event = function(parser, e, idx, comment)
print("COMMENT:", e, idx, comment)
end,
token_event = utils.token_event,
rule_event = utils.rule_event,
}
local code = [[
Param z;
x = 10;
y = x;
]]
local code = [[
xx(x) { return x; }
x = x*y;
]]
local ok, ast = pcall(parser.parse, parser, code)
print""
if(ok and ast) then
printt(ast, "AST")
else
print(ast)
printt(parser.errors, "Errors")
end | mit |
CommandPost/CommandPost-App | extensions/serial/test_serial.lua | 5 | 2084 |
function testAvailablePortNames()
local availablePortNames = hs.serial.availablePortNames()
assertTrue(type(availablePortNames) == "table")
return success()
end
function testAvailablePortPaths()
local availablePortPaths = hs.serial.availablePortPaths()
assertTrue(type(availablePortPaths) == "table")
return success()
end
function testNewFromName()
local obj = hs.serial.newFromName("Bluetooth-Incoming-Port")
assertIsUserdataOfType("hs.serial", obj)
assertTrue(#tostring(obj) > 0)
return success()
end
function testNewFromPath()
local obj = hs.serial.newFromPath("/dev/cu.Bluetooth-Incoming-Port")
assertIsUserdataOfType("hs.serial", obj)
assertTrue(#tostring(obj) > 0)
return success()
end
function testOpenAndClose()
local obj = hs.serial.newFromPath("/dev/cu.Bluetooth-Incoming-Port")
assertIsUserdataOfType("hs.serial", obj)
assertTrue(#tostring(obj) > 0)
obj:open()
hs.timer.usleep(1000000)
hs.timer.usleep(1000000)
assertTrue(obj:isOpen())
hs.timer.usleep(1000000)
hs.timer.usleep(1000000)
obj:close()
hs.timer.usleep(1000000)
hs.timer.usleep(1000000)
assertTrue(obj:isOpen() == false)
return success()
end
function testAttributes()
local obj = hs.serial.newFromPath("/dev/cu.Bluetooth-Incoming-Port")
assertIsUserdataOfType("hs.serial", obj)
assertTrue(#tostring(obj) > 0)
obj:open()
hs.timer.usleep(1000000)
hs.timer.usleep(1000000)
assertTrue(obj:isOpen())
hs.timer.usleep(1000000)
hs.timer.usleep(1000000)
assertTrue(type(obj:baudRate()) == "number")
assertTrue(type(obj:dataBits()) == "number")
assertTrue(type(obj:parity()) == "string")
assertTrue(type(obj:path()) == "string")
assertTrue(type(obj:shouldEchoReceivedData()) == "boolean")
assertTrue(type(obj:usesDTRDSRFlowControl()) == "boolean")
assertTrue(type(obj:usesRTSCTSFlowControl()) == "boolean")
assertTrue(type(obj:stopBits()) == "number")
obj:sendData("test")
obj:close()
hs.timer.usleep(1000000)
hs.timer.usleep(1000000)
assertTrue(obj:isOpen() == false)
return success()
end | mit |
Lsty/ygopro-scripts | c54537489.lua | 5 | 1742 | --タツノオトシオヤ
function c54537489.initial_effect(c)
--spsummon condition
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
e1:SetValue(c54537489.splimit)
c:RegisterEffect(e1)
--token
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(54537489,0))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_TOKEN)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(3,54537489)
e2:SetTarget(c54537489.sptg)
e2:SetOperation(c54537489.spop)
c:RegisterEffect(e2)
end
function c54537489.splimit(e,se,sp,st)
return se:IsActiveType(TYPE_MONSTER) and se:GetHandler():IsRace(RACE_WYRM)
end
function c54537489.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():GetLevel()>1
and Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsPlayerCanSpecialSummonMonster(tp,54537490,0,0x4011,300,200,1,RACE_WYRM,ATTRIBUTE_WATER) end
Duel.SetOperationInfo(0,CATEGORY_TOKEN,nil,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,0,0)
end
function c54537489.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsFacedown() or not c:IsRelateToEffect(e) or c:IsImmuneToEffect(e) or c:GetLevel()<2 then return end
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_LEVEL)
e1:SetReset(RESET_EVENT+0x1fe0000)
e1:SetValue(-1)
c:RegisterEffect(e1)
if Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsPlayerCanSpecialSummonMonster(tp,54537490,0,0x4011,300,200,1,RACE_WYRM,ATTRIBUTE_WATER) then
local token=Duel.CreateToken(tp,54537490)
Duel.SpecialSummon(token,0,tp,tp,false,false,POS_FACEUP)
end
end
| gpl-2.0 |
Lsty/ygopro-scripts | c27971137.lua | 3 | 3110 | --腐乱犬
function c27971137.initial_effect(c)
--atkup
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_ATTACK_ANNOUNCE)
e1:SetOperation(c27971137.atkop)
c:RegisterEffect(e1)
--special summon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(27971137,1))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
e2:SetCode(EVENT_TO_GRAVE)
e2:SetCondition(c27971137.spcon)
e2:SetTarget(c27971137.sptg)
e2:SetOperation(c27971137.spop)
c:RegisterEffect(e2)
end
function c27971137.atkop(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_ATTACK)
e1:SetValue(500)
e1:SetReset(RESET_EVENT+0x1ff0000)
c:RegisterEffect(e1)
end
function c27971137.spcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD) and e:GetHandler():IsReason(REASON_DESTROY)
end
function c27971137.filter(c,e,tp)
return c:GetLevel()==1 and (c:GetAttack()==0 and c:GetDefence()==0) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c27971137.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c27971137.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function c27971137.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,c27971137.filter,tp,LOCATION_DECK,0,1,1,nil,e,tp)
local tc=g:GetFirst()
if tc then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
tc:RegisterFlagEffect(27971137,RESET_EVENT+0x1fe0000,0,1)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_DISABLE)
e1:SetReset(RESET_EVENT+0x1fe0000)
tc:RegisterEffect(e1)
local e2=Effect.CreateEffect(e:GetHandler())
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_DISABLE_EFFECT)
e2:SetReset(RESET_EVENT+0x1fe0000)
tc:RegisterEffect(e2)
local de=Effect.CreateEffect(e:GetHandler())
de:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
de:SetCode(EVENT_PHASE+PHASE_END)
de:SetCountLimit(1)
de:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
de:SetLabelObject(tc)
de:SetCondition(c27971137.descon)
de:SetOperation(c27971137.desop)
if Duel.GetTurnPlayer()==tp and Duel.GetCurrentPhase()==PHASE_END then
de:SetLabel(Duel.GetTurnCount())
de:SetReset(RESET_PHASE+PHASE_END+RESET_SELF_TURN,2)
else
de:SetLabel(0)
de:SetReset(RESET_PHASE+PHASE_END+RESET_SELF_TURN)
end
Duel.RegisterEffect(de,tp)
end
end
function c27971137.descon(e,tp,eg,ep,ev,re,r,rp)
local tc=e:GetLabelObject()
return Duel.GetTurnPlayer()==tp and Duel.GetTurnCount()~=e:GetLabel() and tc:GetFlagEffect(27971137)~=0
end
function c27971137.desop(e,tp,eg,ep,ev,re,r,rp)
local tc=e:GetLabelObject()
Duel.Destroy(tc,REASON_EFFECT)
end
| gpl-2.0 |
MalRD/darkstar | scripts/zones/Kazham/npcs/Tatapp.lua | 9 | 11840 | -----------------------------------
-- Area: Kazham
-- NPC: Tatapp
-- Standard Merchant NPC
-----------------------------------
require("scripts/globals/pathfind");
local path =
{
15.005042, -8.000000, -104.349953,
14.694142, -8.000000, -103.382622,
14.346356, -8.000000, -102.330627,
14.005146, -8.000000, -101.348183,
13.907293, -8.000000, -102.474396,
14.114091, -8.000000, -103.460907,
14.343062, -8.000000, -104.536835,
16.370546, -8.000000, -114.304893,
16.544558, -8.000000, -115.297646,
16.652084, -8.000000, -116.295631,
16.694906, -8.000000, -117.434761,
16.700508, -8.000000, -118.538452,
16.685726, -8.362834, -119.635414,
16.455936, -10.261567, -127.570595,
16.371193, -9.956211, -128.653427,
16.192312, -9.927615, -129.725876,
15.949818, -9.899237, -130.790192,
15.680015, -9.930383, -131.843597,
15.395848, -10.029854, -132.888367,
14.880146, -10.260068, -134.708633,
13.940835, -10.664452, -137.954254,
13.683217, -10.835240, -139.065842,
13.595861, -11.003948, -140.093765,
13.651946, -10.705299, -141.201477,
13.773430, -10.458088, -142.220947,
14.041121, -10.295064, -143.333069,
14.663477, -10.000000, -144.295776,
15.515604, -10.000000, -144.964035,
16.314928, -10.223488, -145.605728,
17.261440, -10.345286, -145.936386,
18.434967, -10.496312, -146.235184,
19.626635, -10.649672, -146.574966,
20.636623, -10.779653, -146.885742,
21.810431, -10.930738, -147.245026,
41.037498, -11.000000, -152.868652,
42.064869, -11.000000, -153.066666,
43.181644, -11.000000, -153.059830,
44.193981, -11.000000, -152.844086,
45.204891, -11.000000, -152.476288,
46.130001, -11.000000, -152.076340,
47.101921, -11.000000, -151.605576,
48.074062, -11.000000, -151.108200,
49.085625, -11.000000, -150.573853,
55.112835, -11.000000, -147.289734,
56.009495, -11.000000, -146.733871,
56.723618, -11.000000, -146.025116,
57.321293, -11.000000, -145.142792,
57.783585, -11.250000, -144.098206,
58.165600, -11.250000, -143.024185,
58.480083, -11.250000, -141.965988,
58.835060, -11.250000, -140.942154,
59.320435, -11.250000, -139.902725,
59.870998, -11.250000, -138.959778,
60.482498, -11.250000, -138.040649,
61.132069, -11.250000, -137.153336,
61.798748, -11.250000, -136.296631,
62.513489, -11.253850, -135.406036,
64.148376, -12.006388, -133.421356,
64.926682, -12.153858, -132.702820,
65.840607, -12.510786, -132.062790,
66.760040, -12.850430, -131.556686,
67.768539, -13.011412, -131.048050,
68.677528, -13.136667, -130.481155,
69.450928, -13.120115, -129.589920,
69.925560, -13.070724, -128.676956,
70.264328, -13.240794, -127.551498,
70.502907, -13.378080, -126.483635,
70.705933, -13.531213, -125.293793,
70.882706, -13.690935, -124.047539,
71.007774, -13.819379, -123.054787,
71.813164, -14.000000, -115.726456,
71.988968, -14.000000, -114.665138,
72.230286, -14.000000, -113.546974,
72.525734, -14.000000, -112.400444,
72.942375, -14.000000, -110.917877,
74.564720, -14.000000, -105.528885,
75.467377, -14.000000, -102.580017,
75.725372, -14.000000, -101.585197,
75.908707, -14.000000, -100.514595,
75.981133, -14.064396, -99.500229,
75.993034, -13.697124, -98.463615,
75.958984, -13.337876, -97.450668,
75.439690, -13.000000, -96.557312,
74.492599, -13.000000, -96.034950,
73.435051, -13.000000, -95.784882,
72.353867, -13.000000, -95.664864,
71.268593, -13.000000, -95.589096,
70.181816, -13.000000, -95.537849,
68.965187, -13.000000, -95.492210,
60.461643, -13.250000, -95.250732,
59.414639, -12.953995, -95.134903,
58.399261, -12.920672, -94.753174,
57.527779, -12.879326, -94.108803,
56.795231, -12.798801, -93.310188,
56.127377, -12.812515, -92.454437,
55.491707, -12.990035, -91.585983,
54.795376, -13.249212, -90.797066,
54.252510, -12.983392, -89.899582,
54.132359, -12.779223, -88.818153,
54.292336, -12.663321, -87.758110,
54.607620, -12.449183, -86.740074,
54.999432, -12.244100, -85.728279,
55.398830, -12.050034, -84.796448,
55.820442, -11.853561, -83.867172,
56.245693, -11.707920, -82.949188,
58.531525, -11.078259, -78.130013,
58.908638, -11.050494, -77.106491,
59.153393, -11.021585, -76.017838,
59.275970, -11.250000, -75.024338,
59.367874, -11.250000, -73.940254,
59.443375, -11.250000, -72.854927,
59.727821, -11.250000, -68.099014,
59.515472, -11.131024, -67.009804,
58.715290, -11.000000, -66.276749,
57.635883, -11.000000, -65.920776,
56.549988, -11.000000, -65.748093,
55.454430, -11.000000, -65.649788,
54.368942, -11.000000, -65.575890,
52.775639, -11.000000, -65.483658,
35.187672, -11.000000, -64.736359,
34.152725, -11.000000, -64.423264,
33.359825, -11.000000, -63.605267,
33.025291, -11.000000, -62.495285,
32.889660, -11.000000, -61.400379,
32.882694, -11.000000, -60.344677,
32.944283, -11.000000, -59.294544,
34.963348, -11.000000, -32.325993,
35.024708, -11.000000, -31.239758,
35.051041, -11.000000, -30.152113,
35.035801, -11.181029, -27.749542,
34.564014, -9.388963, -10.956874,
34.451149, -9.053110, -9.945900,
34.184814, -8.729055, -8.961948,
33.568962, -8.434683, -8.141036,
32.623096, -8.252226, -7.640914,
31.593727, -8.137144, -7.356905,
30.534199, -7.809586, -7.204587,
29.420414, -7.471941, -7.213962,
28.339115, -7.149956, -7.356305,
27.256750, -6.833501, -7.566097,
26.243299, -6.545853, -7.817299,
25.281912, -6.280404, -8.231814,
24.409597, -6.016464, -8.768848,
23.535141, -5.619351, -9.442095,
22.741117, -5.384661, -10.105258,
21.927807, -5.245367, -10.821128,
21.147293, -5.161991, -11.526694,
15.214082, -4.000000, -17.004297,
14.419584, -4.000000, -17.636061,
13.458961, -4.000000, -18.158779,
12.455530, -4.000000, -18.521858,
11.330347, -4.250000, -18.780651,
10.118030, -4.250000, -18.975561,
8.942653, -4.250000, -19.117884,
7.923566, -4.250000, -19.218039,
6.593585, -4.250000, -19.344227,
5.469834, -4.250000, -19.533274,
4.261790, -4.250000, -19.896381,
3.177907, -4.250000, -20.382805,
2.187856, -4.000000, -20.905220,
1.298735, -4.000000, -21.413086,
-0.011548, -4.000000, -22.191364,
-5.672250, -4.000000, -25.692520,
-24.440950, -4.000000, -37.443745,
-25.189728, -4.000000, -38.183887,
-25.629408, -4.168334, -39.141701,
-25.873989, -4.250000, -40.238976,
-26.007105, -4.500000, -41.236519,
-26.112728, -4.500000, -42.301708,
-26.201090, -4.750000, -43.444443,
-26.277060, -4.750000, -44.609795,
-26.462490, -5.250000, -47.949528,
-27.021929, -6.750000, -59.005863,
-27.139404, -6.750000, -60.127247,
-27.386074, -6.750000, -61.138996,
-27.748066, -6.641468, -62.113667,
-28.185287, -6.693056, -63.126755,
-28.636660, -6.778347, -64.072296,
-29.371180, -7.060127, -65.535736,
-31.809622, -8.382057, -70.179474,
-33.889652, -9.009554, -74.086304,
-34.283657, -9.000000, -75.072922,
-34.216805, -9.000000, -76.089775,
-33.508991, -9.000000, -76.828690,
-32.570038, -9.000000, -77.407265,
-31.597225, -9.000000, -77.894348,
-29.741163, -9.000000, -78.769386,
-13.837473, -10.000000, -86.055939,
-12.835108, -10.000000, -86.434494,
-11.747759, -10.000000, -86.703239,
-10.752914, -10.201037, -86.867828,
-9.672615, -9.914025, -87.007553,
-8.582029, -9.631344, -87.116394,
-7.441304, -9.332726, -87.219048,
-5.552025, -8.838206, -87.367615,
-4.547285, -8.572382, -87.423958,
-3.346037, -8.261422, -87.471710,
4.405046, -8.000000, -87.651627,
5.635734, -8.000000, -87.808228,
6.702496, -8.000000, -88.253403,
7.648390, -8.000000, -88.907516,
8.469624, -8.000000, -89.650696,
9.230433, -8.000000, -90.433952,
9.939404, -8.000000, -91.216515,
10.661294, -8.000000, -92.072548,
11.280815, -8.000000, -92.960518,
11.743221, -8.000000, -93.913345,
12.131981, -8.000000, -94.980522,
12.424179, -8.000000, -95.957581,
12.685654, -8.000000, -96.955795,
12.925197, -8.000000, -97.934807,
13.195507, -8.000000, -99.116234,
13.618339, -8.000000, -101.062759,
16.298618, -8.000000, -113.958519,
16.479734, -8.000000, -115.108047,
16.590515, -8.000000, -116.226395,
16.636118, -8.000000, -117.229286,
16.654623, -8.000000, -118.265091,
16.656944, -8.268586, -119.274567,
16.635212, -8.722824, -121.010933,
16.467291, -10.342713, -127.198563,
16.389027, -9.964745, -128.333374,
16.238678, -9.936684, -129.385773,
16.029503, -9.910077, -130.383621,
15.774967, -9.887359, -131.428879,
15.502593, -9.975748, -132.462845
};
function onSpawn(npc)
npc:initNpcAi();
npc:setPos(dsp.path.first(path));
onPath(npc);
end;
function onPath(npc)
dsp.path.patrol(npc, path);
end;
function onTrade(player,npc,trade)
-- item IDs
-- 483 Broken Mithran Fishing Rod
-- 22 Workbench
-- 1008 Ten of Coins
-- 1157 Sands of Silence
-- 1158 Wandering Bulb
-- 904 Giant Fish Bones
-- 4599 Blackened Toad
-- 905 Wyvern Skull
-- 1147 Ancient Salt
-- 4600 Lucky Egg
local OpoOpoAndIStatus = player:getQuestStatus(OUTLANDS, dsp.quest.id.outlands.THE_OPO_OPO_AND_I);
local progress = player:getCharVar("OPO_OPO_PROGRESS");
local failed = player:getCharVar("OPO_OPO_FAILED");
local goodtrade = trade:hasItemQty(4599,1);
local badtrade = (trade:hasItemQty(483,1) or trade:hasItemQty(22,1) or trade:hasItemQty(1157,1) or trade:hasItemQty(1158,1) or trade:hasItemQty(904,1) or trade:hasItemQty(1008,1) or trade:hasItemQty(905,1) or trade:hasItemQty(1147,1) or trade:hasItemQty(4600,1));
if (OpoOpoAndIStatus == QUEST_ACCEPTED) then
if progress == 6 or failed == 7 then
if goodtrade then
player:startEvent(225);
elseif badtrade then
player:startEvent(235);
end
end
end
end;
function onTrigger(player,npc)
local OpoOpoAndIStatus = player:getQuestStatus(OUTLANDS, dsp.quest.id.outlands.THE_OPO_OPO_AND_I);
local progress = player:getCharVar("OPO_OPO_PROGRESS");
local failed = player:getCharVar("OPO_OPO_FAILED");
local retry = player:getCharVar("OPO_OPO_RETRY");
if (OpoOpoAndIStatus == QUEST_ACCEPTED) then
if retry >= 1 then -- has failed on future npc so disregard previous successful trade
player:startEvent(203);
npc:wait();
elseif (progress == 6 or failed == 7) then
player:startEvent(212); -- asking for blackened toad
elseif (progress >= 7 or failed >= 8) then
player:startEvent(248); -- happy with blackened toad
end
else
player:startEvent(203);
npc:wait();
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option,npc)
if (csid == 225) then -- correct trade, onto next opo
if player:getCharVar("OPO_OPO_PROGRESS") == 6 then
player:tradeComplete();
player:setCharVar("OPO_OPO_PROGRESS",7);
player:setCharVar("OPO_OPO_FAILED",0);
else
player:setCharVar("OPO_OPO_FAILED",8);
end
elseif (csid == 235) then -- wrong trade, restart at first opo
player:setCharVar("OPO_OPO_FAILED",1);
player:setCharVar("OPO_OPO_RETRY",7);
else
npc:wait(0);
end
end;
| gpl-3.0 |
Lsty/ygopro-scripts | c40975574.lua | 9 | 2248 | --レッド・リゾネーター
function c40975574.initial_effect(c)
--spsummon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(40975574,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetTarget(c40975574.sptg)
e1:SetOperation(c40975574.spop)
c:RegisterEffect(e1)
--recover
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(40975574,1))
e2:SetCategory(CATEGORY_RECOVER)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
e2:SetCountLimit(1,40975574)
e2:SetTarget(c40975574.rectg)
e2:SetOperation(c40975574.recop)
c:RegisterEffect(e2)
end
function c40975574.spfilter(c,e,tp)
return c:IsLevelBelow(4) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c40975574.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c40975574.spfilter,tp,LOCATION_HAND,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND)
end
function c40975574.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,c40975574.spfilter,tp,LOCATION_HAND,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
end
function c40975574.filter(c)
return c:IsFaceup() and c:GetAttack()>0
end
function c40975574.rectg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c40975574.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c40975574.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
local g=Duel.SelectTarget(tp,c40975574.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_RECOVER,nil,0,tp,g:GetFirst():GetAttack())
end
function c40975574.recop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsFaceup() and tc:GetAttack()>0 then
Duel.Recover(tp,tc:GetAttack(),REASON_EFFECT)
end
end
| gpl-2.0 |
Lsty/ygopro-scripts | c83982270.lua | 9 | 1090 | --雲魔物-ポイズン・クラウド
function c83982270.initial_effect(c)
--destroy&damage
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(83982270,0))
e1:SetCategory(CATEGORY_DESTROY+CATEGORY_DAMAGE)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e1:SetCode(EVENT_BATTLE_DESTROYED)
e1:SetCondition(c83982270.condition)
e1:SetTarget(c83982270.target)
e1:SetOperation(c83982270.operation)
c:RegisterEffect(e1)
end
function c83982270.condition(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsLocation(LOCATION_GRAVE) and c:IsReason(REASON_BATTLE) and c:IsPreviousPosition(POS_FACEUP)
end
function c83982270.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_DESTROY,e:GetHandler():GetBattleTarget(),1,0,0)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,800)
end
function c83982270.operation(e,tp,eg,ep,ev,re,r,rp)
local bc=e:GetHandler():GetBattleTarget()
if bc:IsFaceup() and bc:IsRelateToBattle() and Duel.Destroy(bc,REASON_EFFECT)~=0 then
Duel.Damage(1-tp,800,REASON_EFFECT)
end
end
| gpl-2.0 |
shahabsaf1/My-system | plugins/giphy.lua | 633 | 1796 | -- Idea by https://github.com/asdofindia/telegram-bot/
-- See http://api.giphy.com/
do
local BASE_URL = 'http://api.giphy.com/v1'
local API_KEY = 'dc6zaTOxFJmzC' -- public beta key
local function get_image(response)
local images = json:decode(response).data
if #images == 0 then return nil end -- No images
local i = math.random(#images)
local image = images[i] -- A random one
if image.images.downsized then
return image.images.downsized.url
end
if image.images.original then
return image.original.url
end
return nil
end
local function get_random_top()
local url = BASE_URL.."/gifs/trending?api_key="..API_KEY
local response, code = http.request(url)
if code ~= 200 then return nil end
return get_image(response)
end
local function search(text)
text = URL.escape(text)
local url = BASE_URL.."/gifs/search?q="..text.."&api_key="..API_KEY
local response, code = http.request(url)
if code ~= 200 then return nil end
return get_image(response)
end
local function run(msg, matches)
local gif_url = nil
-- If no search data, a random trending GIF will be sent
if matches[1] == "!gif" or matches[1] == "!giphy" then
gif_url = get_random_top()
else
gif_url = search(matches[1])
end
if not gif_url then
return "Error: GIF not found"
end
local receiver = get_receiver(msg)
print("GIF URL"..gif_url)
send_document_from_url(receiver, gif_url)
end
return {
description = "GIFs from telegram with Giphy API",
usage = {
"!gif (term): Search and sends GIF from Giphy. If no param, sends a trending GIF.",
"!giphy (term): Search and sends GIF from Giphy. If no param, sends a trending GIF."
},
patterns = {
"^!gif$",
"^!gif (.*)",
"^!giphy (.*)",
"^!giphy$"
},
run = run
}
end
| gpl-2.0 |
hfjgjfg/hack54 | plugins/giphy.lua | 633 | 1796 | -- Idea by https://github.com/asdofindia/telegram-bot/
-- See http://api.giphy.com/
do
local BASE_URL = 'http://api.giphy.com/v1'
local API_KEY = 'dc6zaTOxFJmzC' -- public beta key
local function get_image(response)
local images = json:decode(response).data
if #images == 0 then return nil end -- No images
local i = math.random(#images)
local image = images[i] -- A random one
if image.images.downsized then
return image.images.downsized.url
end
if image.images.original then
return image.original.url
end
return nil
end
local function get_random_top()
local url = BASE_URL.."/gifs/trending?api_key="..API_KEY
local response, code = http.request(url)
if code ~= 200 then return nil end
return get_image(response)
end
local function search(text)
text = URL.escape(text)
local url = BASE_URL.."/gifs/search?q="..text.."&api_key="..API_KEY
local response, code = http.request(url)
if code ~= 200 then return nil end
return get_image(response)
end
local function run(msg, matches)
local gif_url = nil
-- If no search data, a random trending GIF will be sent
if matches[1] == "!gif" or matches[1] == "!giphy" then
gif_url = get_random_top()
else
gif_url = search(matches[1])
end
if not gif_url then
return "Error: GIF not found"
end
local receiver = get_receiver(msg)
print("GIF URL"..gif_url)
send_document_from_url(receiver, gif_url)
end
return {
description = "GIFs from telegram with Giphy API",
usage = {
"!gif (term): Search and sends GIF from Giphy. If no param, sends a trending GIF.",
"!giphy (term): Search and sends GIF from Giphy. If no param, sends a trending GIF."
},
patterns = {
"^!gif$",
"^!gif (.*)",
"^!giphy (.*)",
"^!giphy$"
},
run = run
}
end
| gpl-2.0 |
Lsty/ygopro-scripts | c11109820.lua | 3 | 3180 | --エクシーズ・ユニバース
function c11109820.initial_effect(c)
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(11109820,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_TOGRAVE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetTarget(c11109820.target)
e1:SetOperation(c11109820.operation)
c:RegisterEffect(e1)
end
function c11109820.filter1(c,e,tp,ft)
if c:IsControler(tp) then ft=ft+1 end
return c:IsFaceup() and c:IsType(TYPE_XYZ)
and Duel.IsExistingTarget(c11109820.filter2,tp,LOCATION_MZONE,LOCATION_MZONE,1,c,e,tp,c:GetRank(),ft)
end
function c11109820.filter2(c,e,tp,rk,ft)
if c:IsControler(tp) then ft=ft+1 end
return c:IsFaceup() and c:IsType(TYPE_XYZ)
and ft>0 and Duel.IsExistingMatchingCard(c11109820.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,rk+c:GetRank())
end
function c11109820.spfilter(c,e,tp,rk)
local crk=c:GetRank()
return (crk==rk or crk==rk-1) and not c:IsSetCard(0x48) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c11109820.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return false end
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
if chk==0 then return Duel.IsExistingTarget(c11109820.filter1,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,e,tp,ft) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g1=Duel.SelectTarget(tp,c11109820.filter1,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil,e,tp,ft)
local tc=g1:GetFirst()
if tc:IsControler(tp) then ft=ft+1 end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g2=Duel.SelectTarget(tp,c11109820.filter2,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,tc,e,tp,tc:GetRank(),ft)
g1:Merge(g2)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g1,2,0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function c11109820.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
local tc1=g:GetFirst()
local tc2=g:GetNext()
if not tc1:IsRelateToEffect(e) or not tc2:IsRelateToEffect(e) then return end
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
if tc1:IsControler(tp) then ft=ft+1 end
if tc2:IsControler(tp) then ft=ft+1 end
if ft<=0 then return end
Duel.SendtoGrave(g,REASON_EFFECT)
local og=Duel.GetOperatedGroup()
if og:FilterCount(Card.IsLocation,nil,LOCATION_GRAVE)<2 then return end
local sg=Duel.GetMatchingGroup(c11109820.spfilter,tp,LOCATION_EXTRA,0,nil,e,tp,tc1:GetRank()+tc2:GetRank())
if sg:GetCount()==0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local ssg=sg:Select(tp,1,1,nil)
local sc=ssg:GetFirst()
if sc then
Duel.SpecialSummon(sc,0,tp,tp,false,false,POS_FACEUP)
if c:IsRelateToEffect(e) then
c:CancelToGrave()
Duel.Overlay(sc,Group.FromCards(c))
end
end
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CHANGE_DAMAGE)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(0,1)
e1:SetValue(0)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
local e2=e1:Clone()
e2:SetCode(EFFECT_NO_EFFECT_DAMAGE)
e2:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e2,tp)
end
| gpl-2.0 |
Lsty/ygopro-scripts | c1945387.lua | 3 | 1198 | --E・HERO ノヴァマスター
function c1945387.initial_effect(c)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcFun2(c,aux.FilterBoolFunction(Card.IsSetCard,0x3008),aux.FilterBoolFunction(Card.IsAttribute,ATTRIBUTE_FIRE),true)
--spsummon condition
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
e1:SetValue(aux.fuslimit)
c:RegisterEffect(e1)
--draw
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(1945387,0))
e2:SetCategory(CATEGORY_DRAW)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e2:SetCode(EVENT_BATTLE_DESTROYING)
e2:SetCondition(aux.bdocon)
e2:SetTarget(c1945387.drtg)
e2:SetOperation(c1945387.drop)
c:RegisterEffect(e2)
end
function c1945387.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 c1945387.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 |
Lsty/ygopro-scripts | c78574395.lua | 3 | 1415 | --ワンダー・バルーン
function c78574395.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--counter
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(78574395,0))
e2:SetCategory(CATEGORY_COUNTER)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_SZONE)
e2:SetCountLimit(1)
e2:SetCost(c78574395.cost)
e2:SetTarget(c78574395.target)
e2:SetOperation(c78574395.operation)
c:RegisterEffect(e2)
--atk down
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(EFFECT_UPDATE_ATTACK)
e3:SetRange(LOCATION_SZONE)
e3:SetTargetRange(0,LOCATION_MZONE)
e3:SetValue(c78574395.atkval)
c:RegisterEffect(e3)
end
function c78574395.atkval(e,c)
return e:GetHandler():GetCounter(0x32)*-300
end
function c78574395.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost,tp,LOCATION_HAND,0,1,nil) end
local ct=Duel.DiscardHand(tp,Card.IsAbleToGraveAsCost,1,60,REASON_COST)
e:SetLabel(ct)
end
function c78574395.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_COUNTER,nil,e:GetLabel(),0,0x32)
end
function c78574395.operation(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if c:IsRelateToEffect(e) and c:IsFaceup() then
c:AddCounter(0x32,e:GetLabel())
end
end
| gpl-2.0 |
MalRD/darkstar | scripts/globals/mobskills/reactor_overheat.lua | 11 | 1025 | ---------------------------------------------
-- Reactor Overheat
-- Zedi, while in Animation form 3 (Rings)
-- Blinkable 1-3 hit, addtional effect Plague on hit.
---------------------------------------------
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/monstertpmoves")
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
if (mob:AnimationSub() ~= 3) then
return 1
end
return 0
end
function onMobWeaponSkill(target, mob, skill)
local numhits = 2
local accmod = 1
local dmgmod = 1
local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,0,1,2,3)
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,dsp.attackType.MAGICAL,dsp.damageType.FIRE,info.hitslanded)
local typeEffect = dsp.effect.PLAGUE
MobPhysicalStatusEffectMove(mob, target, skill, typeEffect, 1, 0, 60)
target:takeDamage(dmg, mob, dsp.attackType.MAGICAL, dsp.damageType.FIRE)
return dmg
end | gpl-3.0 |
MalRD/darkstar | scripts/zones/The_Celestial_Nexus/mobs/Ealdnarche.lua | 8 | 2265 | -----------------------------------
-- Area: The Celestial Nexus
-- Mob: Eald'narche (Phase 1)
-- Zilart Mission 16 BCNM Fight
-----------------------------------
require("scripts/globals/titles");
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------
function onMobInitialize(mob)
--50% fast cast, no standback
mob:addMod(dsp.mod.UFASTCAST, 50);
mob:setMobMod(dsp.mobMod.HP_STANDBACK,-1);
end;
function onMobSpawn(mob)
mob:SetAutoAttackEnabled(false);
mob:setMobMod(dsp.mobMod.GA_CHANCE,25);
mob:addStatusEffectEx(dsp.effect.PHYSICAL_SHIELD, 0, 1, 0, 0);
mob:addStatusEffectEx(dsp.effect.ARROW_SHIELD, 0, 1, 0, 0);
mob:addStatusEffectEx(dsp.effect.MAGIC_SHIELD, 0, 1, 0, 0);
end;
function onMobEngaged(mob, target)
mob:addStatusEffectEx(dsp.effect.SILENCE, 0, 1, 0, 5);
GetMobByID(mob:getID() + 1):updateEnmity(target);
end;
function onMobFight(mob, target)
if (mob:getBattleTime() % 9 <= 2) then
local orbitalOne = GetMobByID(mob:getID()+3)
local orbitalTwo = GetMobByID(mob:getID()+4)
if not orbitalOne:isSpawned() then
orbitalOne:setPos(mob:getPos())
orbitalOne:spawn()
orbitalOne:updateEnmity(target)
elseif not orbitalTwo:isSpawned() then
orbitalTwo:setPos(mob:getPos())
orbitalTwo:spawn()
orbitalTwo:updateEnmity(target)
end
end
end;
function onMobDeath(mob, player, isKiller)
DespawnMob(mob:getID()+1);
DespawnMob(mob:getID()+3);
DespawnMob(mob:getID()+4);
local battlefield = player:getBattlefield();
player:startEvent(32004, battlefield:getArea());
end;
function onEventUpdate(player,csid,option)
-- printf("updateCSID: %u",csid);
end;
function onEventFinish(player,csid,option,target)
-- printf("finishCSID: %u",csid);
if (csid == 32004) then
DespawnMob(target:getID());
mob = SpawnMob(target:getID()+2);
mob:updateEnmity(player);
--the "30 seconds of rest" you get before he attacks you, and making sure he teleports first in range
mob:addStatusEffectEx(dsp.effect.BIND, 0, 1, 0, 30);
mob:addStatusEffectEx(dsp.effect.SILENCE, 0, 1, 0, 40);
end
end; | gpl-3.0 |
Lsty/ygopro-scripts | c59965151.lua | 3 | 1751 | --デッド・ガードナー
function c59965151.initial_effect(c)
--change battle target
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(59965151,0))
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_BE_BATTLE_TARGET)
e1:SetRange(LOCATION_MZONE)
e1:SetCondition(c59965151.cbcon)
e1:SetOperation(c59965151.cbop)
c:RegisterEffect(e1)
--atkdown
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(59965151,1))
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e2:SetCode(EVENT_TO_GRAVE)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCondition(c59965151.atkcon)
e2:SetTarget(c59965151.atktg)
e2:SetOperation(c59965151.atkop)
c:RegisterEffect(e2)
end
function c59965151.cbcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local bt=eg:GetFirst()
return c~=bt and bt:IsFaceup() and bt:GetControler()==c:GetControler()
end
function c59965151.cbop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChangeAttackTarget(e:GetHandler())
end
function c59965151.atkcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsReason(REASON_DESTROY)
end
function c59965151.atktg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(1-tp) and chkc:IsLocation(LOCATION_MZONE) and chkc:IsFaceup() end
if chk==0 then return true end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,Card.IsFaceup,tp,0,LOCATION_MZONE,1,1,nil)
end
function c59965151.atkop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc and tc:IsFaceup() and tc:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(-1000)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
end
end
| gpl-2.0 |
MalRD/darkstar | scripts/globals/abilities/coursers_roll.lua | 12 | 2900 | -----------------------------------
-- Ability: Courser's Roll
-- Enhances "Snapshot" effect for party members within area of effect.
-- Optimal Job: None
-- Lucky Number: 3
-- Unlucky Number: 9
-- Level: 81
-- Phantom Roll +1 Value: 1
--
-- No Reliable Community Data available. Numbers Based on Blitzer's Roll Values.
--
-- Die Roll | Snapshot+
-- -------- -------
-- 1 |+2
-- 2 |+3
-- 3 |+11
-- 4 |+4
-- 5 |+5
-- 6 |+6
-- 7 |+7
-- 8 |+8
-- 9 |+1
-- 10 |+10
-- 11 |+12
-- Bust |-5
-----------------------------------
require("scripts/globals/settings")
require("scripts/globals/ability")
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------
function onAbilityCheck(player,target,ability)
local effectID = dsp.effect.COURSERS_ROLL
ability:setRange(ability:getRange() + player:getMod(dsp.mod.ROLL_RANGE))
if (player:hasStatusEffect(effectID)) then
return dsp.msg.basic.ROLL_ALREADY_ACTIVE,0
elseif atMaxCorsairBusts(player) then
return dsp.msg.basic.CANNOT_PERFORM,0
else
return 0,0
end
end
function onUseAbility(caster,target,ability,action)
if (caster:getID() == target:getID()) then
corsairSetup(caster, ability, action, dsp.effect.COURSERS_ROLL, dsp.job.COR)
end
local total = caster:getLocalVar("corsairRollTotal")
return applyRoll(caster,target,ability,action,total)
end
function applyRoll(caster,target,ability,action,total)
local duration = 300 + caster:getMerit(dsp.merit.WINNING_STREAK) + caster:getMod(dsp.mod.PHANTOM_DURATION)
local effectpowers = {2, 3, 11, 4, 5, 6, 7, 8, 1, 10, 12, -5}
local effectpower = effectpowers[total]
-- Apply Buffs from Courser's Roll Enhancing Gear if present
if (math.random(0, 99) < caster:getMod(dsp.mod.ENHANCES_COURSERS_ROLL)) then
effectpower = effectpower + 3
end
-- Apply Additional Phantom Roll+ Buff
local phantomBase = 1 -- Base increment buff
local effectpower = effectpower + (phantomBase * phantombuffMultiple(caster))
-- Check if COR Main or Sub
if (caster:getMainJob() == dsp.job.COR and caster:getMainLvl() < target:getMainLvl()) then
effectpower = effectpower * (caster:getMainLvl() / target:getMainLvl())
elseif (caster:getSubJob() == dsp.job.COR and caster:getSubLvl() < target:getMainLvl()) then
effectpower = effectpower * (caster:getSubLvl() / target:getMainLvl())
end
if (target:addCorsairRoll(caster:getMainJob(), caster:getMerit(dsp.merit.BUST_DURATION), dsp.effect.COURSERS_ROLL, effectpower, 0, duration, caster:getID(), total, MOD_SNAPSHOT) == false) then
ability:setMsg(dsp.msg.basic.ROLL_MAIN_FAIL)
elseif total > 11 then
ability:setMsg(dsp.msg.basic.DOUBLEUP_BUST)
end
return total
end
| gpl-3.0 |
Lsty/ygopro-scripts | c53334641.lua | 3 | 2829 | --ゴーストリックの駄天使
function c53334641.initial_effect(c)
--xyz summon
aux.AddXyzProcedure(c,nil,4,2,c53334641.ovfilter,aux.Stringid(53334641,0))
c:EnableReviveLimit()
--win
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_DELAY)
e1:SetCode(EVENT_CHAIN_SOLVING)
e1:SetRange(LOCATION_MZONE)
e1:SetOperation(c53334641.winop)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e2)
--search
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(53334641,1))
e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1)
e2:SetCost(c53334641.thcost)
e2:SetTarget(c53334641.thtg)
e2:SetOperation(c53334641.thop)
c:RegisterEffect(e2)
--material
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(53334641,2))
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1)
e3:SetTarget(c53334641.mttg)
e3:SetOperation(c53334641.mtop)
c:RegisterEffect(e3)
end
function c53334641.ovfilter(c)
return c:IsFaceup() and c:IsSetCard(0x8d) and c:IsType(TYPE_XYZ) and not c:IsCode(53334641)
end
function c53334641.winop(e,tp,eg,ep,ev,re,r,rp)
local WIN_REASON_GHOSTRICK_SPOILEDANGEL=0x1b
if e:GetHandler():GetOverlayCount()==10 then
Duel.Win(tp,WIN_REASON_GHOSTRICK_SPOILEDANGEL)
end
end
function c53334641.thcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end
e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST)
end
function c53334641.thfilter(c)
return c:IsSetCard(0x8d) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand()
end
function c53334641.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c53334641.thfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c53334641.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c53334641.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 c53334641.mtfilter(c)
return c:IsSetCard(0x8d)
end
function c53334641.mttg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c53334641.mtfilter,tp,LOCATION_HAND,0,1,nil) end
end
function c53334641.mtop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) or c:IsFacedown() then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
local g=Duel.SelectMatchingCard(tp,c53334641.mtfilter,tp,LOCATION_HAND,0,1,1,nil)
if g:GetCount()>0 then
Duel.Overlay(c,g)
end
end
| gpl-2.0 |
maxrio/luci981213 | build/luadoc/luadoc/config.lua | 165 | 1234 | -------------------------------------------------------------------------------
-- LuaDoc configuration file. This file contains the default options for
-- luadoc operation. These options can be overriden by the command line tool
-- @see luadoc.print_help
-- @release $Id: config.lua,v 1.6 2007/04/18 14:28:39 tomas Exp $
-------------------------------------------------------------------------------
module "luadoc.config"
-------------------------------------------------------------------------------
-- Default options
-- @class table
-- @name default_options
-- @field output_dir default output directory for generated documentation, used
-- by several doclets
-- @field taglet parser used to analyze source code input
-- @field doclet documentation generator
-- @field template_dir directory with documentation templates, used by the html
-- doclet
-- @field verbose command line tool configuration to output processing
-- information
local default_options = {
output_dir = "",
taglet = "luadoc.taglet.standard",
doclet = "luadoc.doclet.html",
-- TODO: find a way to define doclet specific options
template_dir = "luadoc/doclet/html/",
nomodules = false,
nofiles = false,
verbose = true,
}
return default_options
| apache-2.0 |
MalRD/darkstar | scripts/zones/Aht_Urhgan_Whitegate/IDs.lua | 9 | 6219 | -----------------------------------
-- Area: Aht_Urhgan_Whitegate
-----------------------------------
require("scripts/globals/zone")
-----------------------------------
zones = zones or {}
zones[dsp.zone.AHT_URHGAN_WHITEGATE] =
{
text =
{
ITEM_CANNOT_BE_OBTAINED = 219, -- You cannot obtain the <item>. Come back after sorting your inventory.
ITEM_CANNOT_BE_OBTAINEDX = 223, -- You cannot obtain the <item>. Try trading again after sorting your inventory.
ITEM_OBTAINED = 225, -- Obtained: <item>.
GIL_OBTAINED = 226, -- Obtained <number> gil.
KEYITEM_OBTAINED = 228, -- Obtained key item: <keyitem>.
NOT_HAVE_ENOUGH_GIL = 230, -- You do not have enough gil.
FISHING_MESSAGE_OFFSET = 886, -- You can't fish here.
MOG_LOCKER_OFFSET = 1225, -- Your Mog Locker lease is valid until <timestamp>, kupo.
HOMEPOINT_SET = 1366, -- Home point set!
IMAGE_SUPPORT_ACTIVE = 1405, -- You have to wait a bit longer before asking for synthesis image support again.
IMAGE_SUPPORT = 1407, -- Your [fishing/woodworking/smithing/goldsmithing/clothcraft/leatherworking/bonecraft/alchemy/cooking] skills went up [a little/ever so slightly/ever so slightly].
ITEM_OBTAINEDX = 1497, -- You obtain <item>!
RUNIC_PORTAL = 4584, -- You cannot use the runic portal without the Empire's authorization.
UGRIHD_PURCHASE_DIALOGUE = 4645, -- Salaheem's Sentinels values your contribution to the success of the company. Please come again!
HADAHDA_DIALOG = 4915, -- Hey, think you could help me out?
MUSHAYRA_DIALOG = 4964, -- Sorry for all the trouble. Please ignore Hadahda the next time he asks you to do something.
RYTAAL_MISSION_COMPLETE = 5652, -- Congratulations. You have been awarded Assault Points for the successful completion of your mission.
RYTAAL_MISSION_FAILED = 5653, -- Your mission was not successful; however, the Empire recognizes your contribution and has awarded you Assault Points.
AUTOMATON_RENAME = 5830, -- Your automaton has a new name.
YOU_CAN_BECOME_PUP = 5833, -- You can now become a puppetmaster!
PAY_DIVINATION = 8767, -- ou pay 1000 gil for the divination.
GAVRIE_SHOP_DIALOG = 9265, -- Remember to take your medicine in small doses... Sometimes you can get a little too much of a good thing!
MALFUD_SHOP_DIALOG = 9266, -- Welcome, welcome! Flavor your meals with Malfud's ingredients!
RUBAHAH_SHOP_DIALOG = 9267, -- Flour! Flooour! Corn! Rice and beans! Get your rice and beans here! If you're looking for grain, you've come to the right place!
MULNITH_SHOP_DIALOG = 9268, -- Drawn in by my shop's irresistible aroma, were you? How would you like some of the Near East's famous skewers to enjoy during your journeys?
SALUHWA_SHOP_DIALOG = 9269, -- Looking for undentable shields? This shop's got the best of 'em! These are absolute must-haves for a mercenary's dangerous work!
DWAGO_SHOP_DIALOG = 9270, -- Buy your goods here...or you'll regret it!
KULHAMARIYO_SHOP_DIALOG = 9271, -- Some fish to savorrr while you enjoy the sights of Aht Urhgan?
KHAFJHIFANM_SHOP_DIALOG = 9272, -- How about a souvenir for back home? There's nothing like dried dates to remind you of good times in Al Zahbi!
HAGAKOFF_SHOP_DIALOG = 9273, -- Welcome! Fill all your destructive needs with my superb weaponry! No good mercenary goes without a good weapon!
BAJAHB_SHOP_DIALOG = 9274, -- Good day! If you want to live long, you'll buy your armor here.
MAZWEEN_SHOP_DIALOG = 9275, -- Magic scrolls! Get your magic scrolls here!
FAYEEWAH_SHOP_DIALOG = 9276, -- Why not sit back a spell and enjoy the rich aroma and taste of a cup of chai?
YAFAAF_SHOP_DIALOG = 9277, -- There's nothing like the mature taste and luxurious aroma of coffee... Would you like a cup?
WAHNID_SHOP_DIALOG = 9278, -- All the fishing gear you'll ever need, here in one place!
WAHRAGA_SHOP_DIALOG = 9279, -- Welcome to the Alchemists' Guild. We open ourselves to the hidden secrets of nature in order to create wonders. Are you looking to buy one of them?
GATHWEEDA_SHOP_DIALOG = 9280, -- Only members of the Alchemists' Guild have the vision to create such fine products... Would you like to purchase something?
ITEM_DELIVERY_DIALOG = 9351, -- You have something you want delivered?
AUTOMATON_VALOREDGE_UNLOCK = 9589, -- You obtain the Valoredge X-900 head and frame!
AUTOMATON_SHARPSHOT_UNLOCK = 9594, -- You obtain the Sharpshot Z-500 head and frame!
AUTOMATON_STORMWAKER_UNLOCK = 9599, -- You obtain the Stormwaker Y-700 head and frame!
AUTOMATON_SOULSOOTHER_UNLOCK = 9631, -- You obtain the Soulsoother C-1000 head!
AUTOMATON_SPIRITREAVER_UNLOCK = 9632, -- You obtain the Spiritreaver M-400 head!
AUTOMATON_ATTACHMENT_UNLOCK = 9648, -- You can now equip your automaton with <item>.
SANCTION = 9801, -- You have received the Empire's Sanction.
ZASSHAL_DIALOG = 10995, -- 'ang about. Looks like the permit you got was the last one I 'ad, so it might take me a bit o' time to scrounge up some more. 'ere, don't gimme that look. I'll be restocked before you know it.
RETRIEVE_DIALOG_ID = 13514, -- You retrieve <item> from the porter moogle's care.
COMMON_SENSE_SURVIVAL = 14380, -- It appears that you have arrived at a new survival guide provided by the Adventurers' Mutual Aid Network. Common sense dictates that you should now be able to teleport here from similar tomes throughout the world.
},
mob =
{
},
npc =
{
},
}
return zones[dsp.zone.AHT_URHGAN_WHITEGATE] | gpl-3.0 |
MalRD/darkstar | scripts/zones/Port_Bastok/npcs/Ferrol.lua | 9 | 2763 | -----------------------------------
-- Area: Port Bastok
-- NPC: Ferrol
-- Starts Quest: Trial Size Trial by Earth
-- !pos 33.708 6.499 -39.425 236
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/quests");
require("scripts/globals/teleports");
local ID = require("scripts/zones/Port_Bastok/IDs");
-----------------------------------
function onTrade(player,npc,trade)
if (trade:hasItemQty(1547,1) and player:getQuestStatus(BASTOK,dsp.quest.id.bastok.TRIAL_SIZE_TRIAL_BY_EARTH) == QUEST_ACCEPTED and player:getMainJob() == dsp.job.SMN) then
player:startEvent(298,0,1547,1,20);
end
end;
function onTrigger(player,npc)
local TrialSizeEarth = player:getQuestStatus(BASTOK,dsp.quest.id.bastok.TRIAL_SIZE_TRIAL_BY_EARTH);
if (player:getMainLvl() >= 20 and player:getMainJob() == dsp.job.SMN and TrialSizeEarth == QUEST_AVAILABLE and player:getFameLevel(BASTOK) >= 2) then -- Requires player to be Summoner at least lvl 20
player:startEvent(297,0,1547,1,20); --mini tuning fork, zone, level
elseif (TrialSizeEarth == QUEST_ACCEPTED) then
local EarthFork = player:hasItem(1547);
if (EarthFork) then
player:startEvent(251); -- Dialogue given to remind player to be prepared
elseif (EarthFork == false and tonumber(os.date("%j")) ~= player:getCharVar("TrialSizeEarth_date")) then
player:startEvent(301,0,1547,1,20); -- Need another mini tuning fork
else
player:startEvent(303); -- Standard dialog when you loose, and you don't wait 1 real day
end
elseif (TrialSizeEarth == QUEST_COMPLETED) then
player:startEvent(300); -- Defeated Avatar
else
player:startEvent(254); -- Standard dialog
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 297 and option == 1) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,1547); --Mini tuning fork
else
player:setCharVar("TrialSizeEarth_date",0)
player:addQuest(BASTOK,dsp.quest.id.bastok.TRIAL_SIZE_TRIAL_BY_EARTH);
player:addItem(1547);
player:messageSpecial(ID.text.ITEM_OBTAINED,1547);
end
elseif (csid == 301 and option == 1) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,1547); --Mini tuning fork
else
player:addItem(1547);
player:messageSpecial(ID.text.ITEM_OBTAINED,1547);
end
elseif (csid == 298 and option == 1) then
dsp.teleport.to(player, dsp.teleport.id.CLOISTER_OF_TREMORS);
end
end; | gpl-3.0 |
MalRD/darkstar | scripts/zones/Jugner_Forest_[S]/npcs/qm8.lua | 9 | 1316 | -----------------------------------
-- Area: Jugner Forest (S)
-- NPC: ???
-- Type: Quest NPC
-- !pos -6 0 -295 82
-----------------------------------
local ID = require("scripts/zones/Jugner_Forest_[S]/IDs")
require("scripts/globals/quests")
-----------------------------------
function onTrade(player, npc, trade)
end
function onTrigger(player, npc)
local wotg = player:getQuestStatus(CRYSTAL_WAR, dsp.quest.id.crystalWar.WRATH_OF_THE_GRIFFON)
local wotgStat = player:getCharVar("WrathOfTheGriffon")
if wotg == QUEST_ACCEPTED and wotgStat == 0 then
player:startEvent(204)
elseif player:getCharVar("CobraClawKilled") == 1 then
player:startEvent(206)
elseif player:getCharVar("WrathOfTheGriffon") == 1 and not GetMobByID(ID.mob.COBRACLAW_BUCHZVOTCH):isSpawned() then
player:startEvent(205)
else
player:messageSpecial(ID.text.NOTHING_HAPPENS)
end
end
function onEventUpdate(player, csid, option)
end
function onEventFinish(player, csid, option)
if csid == 204 then
player:setCharVar("WrathOfTheGriffon", 1)
elseif csid == 205 then
SpawnMob(ID.mob.COBRACLAW_BUCHZVOTCH):updateClaim(player)
elseif csid == 206 then
player:setCharVar("CobraClawKilled", 0)
player:setCharVar("WrathOfTheGriffon", 2)
end
end
| gpl-3.0 |
Lsty/ygopro-scripts | c37011715.lua | 9 | 1281 | --奇跡の蘇生
function c37011715.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCondition(c37011715.condition)
e1:SetTarget(c37011715.target)
e1:SetOperation(c37011715.activate)
c:RegisterEffect(e1)
end
function c37011715.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentChain()>2 and Duel.CheckChainUniqueness()
end
function c37011715.filter(c,e,tp)
return c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c37011715.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and c37011715.filter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c37011715.filter,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c37011715.filter,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c37011715.activate(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 |
sonoro1234/cimgui | generator/output/typedefs_dict.lua | 1 | 2892 | local defs = {}
defs["ImColor"] = "struct ImColor"
defs["ImDrawCallback"] = "void(*)(const ImDrawList* parent_list,const ImDrawCmd* cmd);"
defs["ImDrawChannel"] = "struct ImDrawChannel"
defs["ImDrawCmd"] = "struct ImDrawCmd"
defs["ImDrawCornerFlags"] = "int"
defs["ImDrawData"] = "struct ImDrawData"
defs["ImDrawIdx"] = "unsigned short"
defs["ImDrawList"] = "struct ImDrawList"
defs["ImDrawListFlags"] = "int"
defs["ImDrawListSharedData"] = "struct ImDrawListSharedData"
defs["ImDrawListSplitter"] = "struct ImDrawListSplitter"
defs["ImDrawVert"] = "struct ImDrawVert"
defs["ImFont"] = "struct ImFont"
defs["ImFontAtlas"] = "struct ImFontAtlas"
defs["ImFontAtlasCustomRect"] = "struct ImFontAtlasCustomRect"
defs["ImFontAtlasFlags"] = "int"
defs["ImFontConfig"] = "struct ImFontConfig"
defs["ImFontGlyph"] = "struct ImFontGlyph"
defs["ImFontGlyphRangesBuilder"] = "struct ImFontGlyphRangesBuilder"
defs["ImGuiBackendFlags"] = "int"
defs["ImGuiCol"] = "int"
defs["ImGuiColorEditFlags"] = "int"
defs["ImGuiComboFlags"] = "int"
defs["ImGuiCond"] = "int"
defs["ImGuiConfigFlags"] = "int"
defs["ImGuiContext"] = "struct ImGuiContext"
defs["ImGuiDataType"] = "int"
defs["ImGuiDir"] = "int"
defs["ImGuiDragDropFlags"] = "int"
defs["ImGuiFocusedFlags"] = "int"
defs["ImGuiHoveredFlags"] = "int"
defs["ImGuiID"] = "unsigned int"
defs["ImGuiIO"] = "struct ImGuiIO"
defs["ImGuiInputTextCallback"] = "int(*)(ImGuiInputTextCallbackData *data);"
defs["ImGuiInputTextCallbackData"] = "struct ImGuiInputTextCallbackData"
defs["ImGuiInputTextFlags"] = "int"
defs["ImGuiKey"] = "int"
defs["ImGuiListClipper"] = "struct ImGuiListClipper"
defs["ImGuiMouseCursor"] = "int"
defs["ImGuiNavInput"] = "int"
defs["ImGuiOnceUponAFrame"] = "struct ImGuiOnceUponAFrame"
defs["ImGuiPayload"] = "struct ImGuiPayload"
defs["ImGuiSelectableFlags"] = "int"
defs["ImGuiSizeCallback"] = "void(*)(ImGuiSizeCallbackData* data);"
defs["ImGuiSizeCallbackData"] = "struct ImGuiSizeCallbackData"
defs["ImGuiStorage"] = "struct ImGuiStorage"
defs["ImGuiStoragePair"] = "struct ImGuiStoragePair"
defs["ImGuiStyle"] = "struct ImGuiStyle"
defs["ImGuiStyleVar"] = "int"
defs["ImGuiTabBarFlags"] = "int"
defs["ImGuiTabItemFlags"] = "int"
defs["ImGuiTextBuffer"] = "struct ImGuiTextBuffer"
defs["ImGuiTextFilter"] = "struct ImGuiTextFilter"
defs["ImGuiTextRange"] = "struct ImGuiTextRange"
defs["ImGuiTreeNodeFlags"] = "int"
defs["ImGuiWindowFlags"] = "int"
defs["ImS16"] = "signed short"
defs["ImS32"] = "signed int"
defs["ImS64"] = "int64_t"
defs["ImS8"] = "signed char"
defs["ImTextureID"] = "void*"
defs["ImU16"] = "unsigned short"
defs["ImU32"] = "unsigned int"
defs["ImU64"] = "uint64_t"
defs["ImU8"] = "unsigned char"
defs["ImVec2"] = "struct ImVec2"
defs["ImVec4"] = "struct ImVec4"
defs["ImWchar"] = "unsigned short"
defs["const_iterator"] = "const value_type*"
defs["iterator"] = "value_type*"
defs["value_type"] = "T"
return defs | mit |
MalRD/darkstar | scripts/zones/Lower_Delkfutts_Tower/npcs/_540.lua | 9 | 1651 | -----------------------------------
-- Area: Lower Delkfutt's Tower
-- NPC: Cermet Door
-- Cermet Door for Windy Ambassador
-- Windurst Mission 3.3 "A New Journey"
-- !pos 636 16 59 184
-----------------------------------
local ID = require("scripts/zones/Lower_Delkfutts_Tower/IDs")
require("scripts/globals/keyitems")
require("scripts/globals/missions")
require("scripts/globals/npc_util")
-----------------------------------
function onTrade(player, npc, trade)
if
player:getCurrentMission(WINDURST) == dsp.mission.id.windurst.A_NEW_JOURNEY and
player:getCharVar("MissionStatus") == 2 and
npcUtil.tradeHas(trade, 549) -- Delkfutt Key
then
player:startEvent(2)
end
end
function onTrigger(player, npc)
local currentMission = player:getCurrentMission(WINDURST)
if currentMission == dsp.mission.id.windurst.A_NEW_JOURNEY and player:getCharVar("MissionStatus") == 2 and not player:hasKeyItem(dsp.ki.DELKFUTT_KEY) then
player:messageSpecial(ID.text.THE_DOOR_IS_FIRMLY_SHUT_OPEN_KEY)
elseif currentMission == dsp.mission.id.windurst.A_NEW_JOURNEY and player:getCharVar("MissionStatus") == 2 and player:hasKeyItem(dsp.ki.DELKFUTT_KEY) then
player:startEvent(2)
else
player:messageSpecial(ID.text.DOOR_FIRMLY_SHUT)
end
end
function onEventUpdate(player, csid, option)
end
function onEventFinish(player, csid, option)
if csid == 2 then
player:setCharVar("MissionStatus", 3)
if not player:hasKeyItem(dsp.ki.DELKFUTT_KEY) then
npcUtil.giveKeyItem(player, dsp.ki.DELKFUTT_KEY)
player:confirmTrade()
end
end
end | gpl-3.0 |
Lsty/ygopro-scripts | c95308449.lua | 5 | 1125 | --終焉のカウントダウン
function c95308449.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_REMOVE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCost(c95308449.cost)
e1:SetOperation(c95308449.activate)
c:RegisterEffect(e1)
end
function c95308449.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckLPCost(tp,2000) end
Duel.PayLPCost(tp,2000)
end
function c95308449.activate(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if Duel.GetFlagEffect(tp,95308449)~=0 then return end
Duel.RegisterFlagEffect(tp,95308449,0,0,0)
c:SetTurnCounter(0)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_PHASE+PHASE_END)
e1:SetOperation(c95308449.checkop)
e1:SetCountLimit(1)
Duel.RegisterEffect(e1,tp)
c:RegisterFlagEffect(1082946,RESET_PHASE+PHASE_END,0,20)
c95308449[c]=e1
end
function c95308449.checkop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local ct=c:GetTurnCounter()
ct=ct+1
c:SetTurnCounter(ct)
if ct==20 then
Duel.Win(tp,0x11)
c:ResetFlagEffect(1082946)
end
end
| gpl-2.0 |
Lsty/ygopro-scripts | c2830693.lua | 5 | 2749 | --虹クリボー
function c2830693.initial_effect(c)
--equip
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(2830693,0))
e1:SetCategory(CATEGORY_EQUIP)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_ATTACK_ANNOUNCE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetRange(LOCATION_HAND)
e1:SetCountLimit(1,2830693)
e1:SetTarget(c2830693.eqtg)
e1:SetOperation(c2830693.eqop)
c:RegisterEffect(e1)
--spsummon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(2830693,1))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_ATTACK_ANNOUNCE)
e2:SetRange(LOCATION_GRAVE)
e2:SetCountLimit(1,2830694)
e2:SetCondition(c2830693.spcon)
e2:SetTarget(c2830693.sptg)
e2:SetOperation(c2830693.spop)
c:RegisterEffect(e2)
end
function c2830693.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local at=Duel.GetAttacker()
if chkc then return chkc==at end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and at:IsControler(1-tp) and at:IsRelateToBattle() and at:IsCanBeEffectTarget(e) end
Duel.SetTargetCard(at)
end
function c2830693.eqop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if not c:IsRelateToEffect(e) then return end
if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 or tc:IsFacedown() or not tc:IsRelateToEffect(e) then
Duel.SendtoGrave(c,REASON_EFFECT)
else
Duel.Equip(tp,c,tc,true)
--Add Equip limit
local e1=Effect.CreateEffect(tc)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_EQUIP_LIMIT)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetReset(RESET_EVENT+0x1fe0000)
e1:SetValue(c2830693.eqlimit)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_EQUIP)
e2:SetCode(EFFECT_CANNOT_ATTACK)
e2:SetReset(RESET_EVENT+0x1fe0000)
c:RegisterEffect(e2)
end
end
function c2830693.eqlimit(e,c)
return e:GetOwner()==c
end
function c2830693.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetAttacker():IsControler(1-tp) and Duel.GetAttackTarget()==nil
end
function c2830693.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 c2830693.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) and Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)>0 then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetReset(RESET_EVENT+0x47e0000)
e1:SetValue(LOCATION_REMOVED)
c:RegisterEffect(e1,true)
end
end
| gpl-2.0 |
ThingMesh/openwrt-luci | modules/niu/luasrc/model/cbi/niu/wireless/apdevice.lua | 51 | 1625 | --[[
LuCI - Lua Configuration Interface
Copyright 2009 Steven Barth <steven@midlink.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
]]--
local niulib = require "luci.niulib"
local cursor = require "luci.model.uci".inst
m = Map("wireless", translate("Configure Private Access Point"))
s = m:section(NamedSection, "ap", "wifi-iface", translate("Wireless Radio Device"),
translate(
"Select the wireless radio device that should be used to run the interface."..
" Note that wireless radios will not show up here if you already use"..
" them for other wireless services and are not capable of being used by"..
" more than one service simultaneously or run this specific service at all."))
s.anonymous = true
s.addremove = false
local l = s:option(ListValue, "device", translate("Wireless Device"))
for _, wifi in ipairs(niulib.wifi_get_available("ap")) do
l:value(wifi, translate("WLAN-Adapter (%s)") % wifi)
end
l:value("none", translate("Disable Private Access Point"))
local extend = cursor:get("wireless", "bridge", "network")
and cursor:get("wireless", "bridge", "ssid")
if extend ~= cursor:get("wireless", "ap", "ssid") then
local templ = s:option(ListValue, "_cfgtpl", translate("Configuration Template"))
templ:depends({["!default"] = 1})
templ:depends({["!reverse"] = 1, device = "none"})
templ:value("", translate("Access Point (Current Settings)"))
templ:value("bridge", translate("Extend network %s") % extend)
end
return m
| apache-2.0 |
Lsty/ygopro-scripts | c32015116.lua | 3 | 1313 | --無差別破壊
function c32015116.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)
c:RegisterEffect(e1)
--roll and destroy
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(32015116,0))
e2:SetCategory(CATEGORY_DESTROY+CATEGORY_DICE)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e2:SetRange(LOCATION_SZONE)
e2:SetCountLimit(1)
e2:SetCode(EVENT_PHASE+PHASE_STANDBY)
e2:SetCondition(c32015116.rdcon)
e2:SetTarget(c32015116.rdtg)
e2:SetOperation(c32015116.rdop)
c:RegisterEffect(e2)
end
function c32015116.rdcon(e,tp,eg,ep,ev,re,r,rp)
return tp==Duel.GetTurnPlayer()
end
function c32015116.rdtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_DICE,nil,0,tp,1)
end
function c32015116.rdfilter(c,lv)
if lv<6 then
return c:IsFaceup() and c:IsDestructable() and c:GetLevel()==lv
else
return c:IsFaceup() and c:IsDestructable() and c:GetLevel()>=6 end
end
function c32015116.rdop(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
local d1=Duel.TossDice(tp,1)
local g=Duel.GetMatchingGroup(c32015116.rdfilter,tp,LOCATION_MZONE,LOCATION_MZONE,nil,d1)
Duel.Destroy(g,REASON_EFFECT)
end
| gpl-2.0 |
Lsty/ygopro-scripts | c32918479.lua | 3 | 1959 | --光神機-閃空
function c32918479.initial_effect(c)
--handes
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(32918479,0))
e1:SetCategory(CATEGORY_DRAW)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e1:SetCode(EVENT_BATTLE_DAMAGE)
e1:SetCondition(c32918479.condition)
e1:SetTarget(c32918479.target)
e1:SetOperation(c32918479.operation)
c:RegisterEffect(e1)
--
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_SUMMON_SUCCESS)
e2:SetOperation(c32918479.regop)
c:RegisterEffect(e2)
local e3=e2:Clone()
e3:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
c:RegisterEffect(e3)
local e4=e2:Clone()
e4:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e4)
end
function c32918479.condition(e,tp,eg,ep,ev,re,r,rp)
return ep~=tp and Duel.GetAttackTarget()==nil
end
function c32918479.target(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,0,0,tp,1)
end
function c32918479.operation(e,tp,eg,ep,ev,re,r,rp)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Draw(p,d,REASON_EFFECT)
end
function c32918479.regop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(32918479,1))
e1:SetCategory(CATEGORY_TOGRAVE)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1)
e1:SetCode(EVENT_PHASE+PHASE_END)
e1:SetTarget(c32918479.tgtg)
e1:SetOperation(c32918479.tgop)
e1:SetReset(RESET_EVENT+0xc6c0000)
c:RegisterEffect(e1)
end
function c32918479.tgtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,e:GetHandler(),1,0,0)
end
function c32918479.tgop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) and c:IsFaceup() then
Duel.SendtoGrave(c,REASON_EFFECT)
end
end
| gpl-2.0 |
CommandPost/CommandPost-App | extensions/mouse/mouse.lua | 4 | 6307 | --- === hs.mouse ===
---
--- Inspect/manipulate the position of the mouse pointer
---
--- This module is based primarily on code from the previous incarnation of Mjolnir by [Steven Degutis](https://github.com/sdegutis/).
---
--- This module uses ManyMouse by Ryan C. Gordon.
---
--- MANYMOUSE LICENSE:
---
--- Copyright (c) 2005-2012 Ryan C. Gordon and others.
---
--- This software is provided 'as-is', without any express or implied warranty.
--- In no event will the authors be held liable for any damages arising from
--- the use of this software.
---
--- Permission is granted to anyone to use this software for any purpose,
--- including commercial applications, and to alter it and redistribute it
--- freely, subject to the following restrictions:
---
--- 1. The origin of this software must not be misrepresented; you must not
--- claim that you wrote the original software. If you use this software in a
--- product, an acknowledgment in the product documentation would be
--- appreciated but is not required.
---
--- 2. Altered source versions must be plainly marked as such, and must not be
--- misrepresented as being the original software.
---
--- 3. This notice may not be removed or altered from any source distribution.
---
--- Ryan C. Gordon <icculus@icculus.org>
local module = require("hs.libmouse")
local fnutils = require("hs.fnutils")
local geometry = require("hs.geometry")
local screen = require("hs.screen")
-- private variables and methods -----------------------------------------
local deprecation_warnings = {}
-- Public interface ------------------------------------------------------
function module.get(...)
local state = debug.getinfo(2)
local tag = state.short_src..":"..state.currentline
if not deprecation_warnings[tag] then
print(tag..": hs.mouse.get is deprecated. Please update your code to use hs.mouse.absolutePosition or hs.mouse.getRelativePosition")
deprecation_warnings[tag] = true
end
return module.absolutePosition(...)
end
function module.set(...)
local state = debug.getinfo(2)
local tag = state.short_src..":"..state.currentline
if not deprecation_warnings[tag] then
print(tag..": hs.mouse.set is deprecated. Please update your code to use hs.mouse.absolutePosition or hs.mouse.setRelativePosition")
deprecation_warnings[tag] = true
end
return module.absolutePosition(...)
end
function module.getAbsolutePosition(...)
local state = debug.getinfo(2)
local tag = state.short_src..":"..state.currentline
if not deprecation_warnings[tag] then
print(tag..": hs.mouse.getAbsolutePosition is deprecated. Please update your code to use hs.mouse.absolutePosition")
deprecation_warnings[tag] = true
end
return module.absolutePosition(...)
end
function module.setAbsolutePosition(...)
local state = debug.getinfo(2)
local tag = state.short_src..":"..state.currentline
if not deprecation_warnings[tag] then
print(tag..": hs.mouse.setAbsolutePosition is deprecated. Please update your code to use hs.mouse.absolutePosition")
deprecation_warnings[tag] = true
end
return module.absolutePosition(...)
end
--- hs.mouse.getRelativePosition() -> point or nil
--- Function
--- Gets the co-ordinates of the mouse pointer, relative to the screen it is on
---
--- Parameters:
--- * None
---
--- Returns:
--- * A point-table containing the relative x and y co-ordinates of the mouse pointer, or nil if an error occured
---
--- Notes:
--- * The co-ordinates returned by this function are relative to the top left pixel of the screen the mouse is on (see `hs.mouse.getAbsolutePosition` if you need the location in the full desktop space)
function module.getRelativePosition()
local currentScreen = module.getCurrentScreen()
if currentScreen == nil then
return nil
end
local frame = currentScreen:fullFrame()
local point = module.absolutePosition()
local rel = {}
rel["x"] = point["x"] - frame["x"]
rel["y"] = point["y"] - frame["y"]
return rel
end
--- hs.mouse.setRelativePosition(point[, screen])
--- Function
--- Sets the co-ordinates of the mouse pointer, relative to a screen
---
--- Parameters:
--- * point - A point-table containing the relative x and y co-ordinates to move the mouse pointer to
--- * screen - An optional `hs.screen` object. Defaults to the screen the mouse pointer is currently on
---
--- Returns:
--- * None
function module.setRelativePosition(point, currentScreen)
if currentScreen == nil then
currentScreen = module.getCurrentScreen()
if currentScreen == nil then
print("ERROR: Unable to find the current screen")
return nil
end
end
local frame = currentScreen:fullFrame()
local abs = {}
abs["x"] = frame["x"] + point["x"]
abs["y"] = frame["y"] + point["y"]
return module.absolutePosition(abs)
end
--- hs.mouse.getCurrentScreen() -> screen or nil
--- Function
--- Gets the screen the mouse pointer is on
---
--- Parameters:
--- * None
---
--- Returns:
--- * An `hs.screen` object that the mouse pointer is on, or nil if an error occurred
function module.getCurrentScreen()
local point = module.absolutePosition()
return fnutils.find(screen.allScreens(), function(aScreen) return geometry.isPointInRect(point, aScreen:fullFrame()) end)
end
--- hs.mouse.getButtons() -> table
--- Function
--- Returns a table containing the current mouse buttons being pressed *at this instant*.
---
--- Parameters:
--- * None
---
--- Returns:
--- * Returns an array containing indicies starting from 1 up to the highest numbered button currently being pressed where the index is `true` if the button is currently pressed or `false` if it is not.
--- * Special hash tag synonyms for `left` (button 1), `right` (button 2), and `middle` (button 3) are also set to true if these buttons are currently being pressed.
---
--- Notes:
--- * This function is a wrapper to `hs.eventtap.checkMouseButtons`
--- * This is an instantaneous poll of the current mouse buttons, not a callback.
function module.getButtons(...)
return require("hs.eventtap").checkMouseButtons(...)
end
-- Return Module Object --------------------------------------------------
return module
| mit |
Frenzie/koreader | spec/unit/nickel_conf_spec.lua | 9 | 5773 | describe("Nickel configuation module", function()
local lfs, NickelConf
setup(function()
require("commonrequire")
lfs = require("libs/libkoreader-lfs")
NickelConf = require("device/kobo/nickel_conf")
end)
describe("Frontlight module", function()
it("should read value", function()
local fn = os.tmpname()
local fd = io.open(fn, "w")
fd:write([[
[OtherThing]
foo=bar
[PowerOptions]
FrontLightLevel=55
FrontLightState=true
[YetAnotherThing]
bar=baz
]])
fd:close()
NickelConf._set_kobo_conf_path(fn)
assert.Equals(NickelConf.frontLightLevel.get(), 55)
assert.Equals(NickelConf.frontLightState.get(), true)
os.remove(fn)
end)
it("should also read value", function()
local fn = os.tmpname()
local fd = io.open(fn, "w")
fd:write([[
[OtherThing]
foo=bar
[PowerOptions]
FrontLightLevel=30
FrontLightState=false
[YetAnotherThing]
bar=baz
]])
fd:close()
NickelConf._set_kobo_conf_path(fn)
assert.Equals(NickelConf.frontLightLevel.get(), 30)
assert.Equals(NickelConf.frontLightState.get(), false)
os.remove(fn)
end)
it("should have default value", function()
local fn = os.tmpname()
local fd = io.open(fn, "w")
fd:write([[
[OtherThing]
foo=bar
[YetAnotherThing]
bar=baz
]])
fd:close()
NickelConf._set_kobo_conf_path(fn)
assert.Equals(NickelConf.frontLightLevel.get(), 1)
assert.Equals(NickelConf.frontLightState.get(), nil)
os.remove(fn)
end)
it("should create section", function()
local fn = os.tmpname()
local fd = io.open(fn, "w")
fd:write([[
[OtherThing]
FrontLightLevel=6
]])
fd:close()
NickelConf._set_kobo_conf_path(fn)
NickelConf.frontLightLevel.set(100)
NickelConf.frontLightState.set(true)
fd = io.open(fn, "r")
assert.Equals(fd:read("*a"), [[
[OtherThing]
FrontLightLevel=6
[PowerOptions]
FrontLightLevel=100
]])
fd:close()
os.remove(fn)
fd = io.open(fn, "w")
fd:write("")
fd:close()
NickelConf.frontLightLevel.set(20)
NickelConf.frontLightState.set(false)
fd = io.open(fn, "r")
assert.Equals(fd:read("*a"), [[
[PowerOptions]
FrontLightLevel=20
]])
fd:close()
os.remove(fn)
end)
it("should replace value", function()
local fn = os.tmpname()
local fd = io.open(fn, "w")
fd:write([[
[OtherThing]
foo=bar
[PowerOptions]
FrontLightLevel=6
FrontLightState=false
[YetAnotherThing]
bar=baz
]])
fd:close()
NickelConf._set_kobo_conf_path(fn)
NickelConf.frontLightLevel.set(100)
NickelConf.frontLightState.set(true)
fd = io.open(fn, "r")
assert.Equals(fd:read("*a"), [[
[OtherThing]
foo=bar
[PowerOptions]
FrontLightLevel=100
FrontLightState=true
[YetAnotherThing]
bar=baz
]])
fd:close()
os.remove(fn)
end)
it("should insert entry", function()
local fn = os.tmpname()
local fd = io.open(fn, "w")
fd:write([[
[PowerOptions]
foo=bar
[OtherThing]
bar=baz
]])
fd:close()
NickelConf._set_kobo_conf_path(fn)
NickelConf.frontLightLevel.set(1)
NickelConf.frontLightState.set(true)
fd = io.open(fn, "r")
assert.Equals([[
[PowerOptions]
foo=bar
FrontLightLevel=1
[OtherThing]
bar=baz
]], fd:read("*a"))
fd:close()
os.remove(fn)
end)
it("should create config file", function()
local fd
local fn = "/tmp/abcfoobarbaz449"
assert.is_not.Equals(lfs.attributes(fn, "mode"), "file")
finally(function() os.remove(fn) end)
NickelConf._set_kobo_conf_path(fn)
NickelConf.frontLightLevel.set(15)
NickelConf.frontLightState.set(false)
fd = io.open(fn, "r")
assert.Equals([[
[PowerOptions]
FrontLightLevel=15
]],
fd:read("*a"))
fd:close()
end)
it("should not crash on nil values for regular users", function()
local fn = os.tmpname()
local fd = io.open(fn, "w")
fd:write([[
[PowerOptions]
foo=bar
[OtherThing]
bar=baz
]])
fd:close()
NickelConf._set_kobo_conf_path(fn)
NickelConf.frontLightLevel.set()
NickelConf.frontLightState.set()
fd = io.open(fn, "r")
assert.Equals([[
[PowerOptions]
foo=bar
[OtherThing]
bar=baz
]], fd:read("*a"))
fd:close()
os.remove(fn)
end)
it("should crash on nil values in debug mode", function()
local dbg = require("dbg")
dbg:turnOn()
NickelConf = package.reload("device/kobo/nickel_conf")
local fn = os.tmpname()
local fd = io.open(fn, "w")
fd:write([[
[PowerOptions]
foo=bar
[OtherThing]
bar=baz
]])
fd:close()
NickelConf._set_kobo_conf_path(fn)
assert.has_error(function() NickelConf.frontLightLevel.set() end)
assert.has_error(function() NickelConf.frontLightState.set() end)
fd = io.open(fn, "r")
assert.Equals([[
[PowerOptions]
foo=bar
[OtherThing]
bar=baz
]], fd:read("*a"))
fd:close()
os.remove(fn)
end)
end)
end)
| agpl-3.0 |
Lsty/ygopro-scripts | c16678947.lua | 3 | 1370 | --カース・サイキック
function c16678947.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_BATTLE_DESTROYED)
e1:SetCondition(c16678947.condition)
e1:SetTarget(c16678947.target)
e1:SetOperation(c16678947.activate)
c:RegisterEffect(e1)
end
function c16678947.condition(e,tp,eg,ep,ev,re,r,rp,chk)
local tc=eg:GetFirst()
local bc=tc:GetBattleTarget()
return tc:GetPreviousControler()==tp and tc:IsLocation(LOCATION_GRAVE) and tc:IsRace(RACE_PSYCHO)
and bit.band(tc:GetBattlePosition(),POS_FACEUP)~=0
and bc:IsRelateToBattle() and bc:IsControler(1-tp) and bc==Duel.GetAttacker()
end
function c16678947.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return false end
local tc=eg:GetFirst()
local bc=Duel.GetAttacker()
if chk==0 then return bc:IsCanBeEffectTarget(e) and bc:IsDestructable() end
local lv=tc:GetLevel()
e:SetLabel(lv)
Duel.SetTargetCard(bc)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,bc,1,0,0)
if lv~=0 then
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,lv*300)
end
end
function c16678947.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and Duel.Destroy(tc,REASON_EFFECT)~=0 then
Duel.Damage(1-tp,e:GetLabel()*300,REASON_EFFECT)
end
end
| gpl-2.0 |
Lsty/ygopro-scripts | c32703716.lua | 9 | 1266 | --フィッシュアンドキックス
function c32703716.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_REMOVE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCondition(c32703716.condition)
e1:SetTarget(c32703716.target)
e1:SetOperation(c32703716.activate)
c:RegisterEffect(e1)
end
function c32703716.cfilter(c)
return c:IsFaceup() and c:IsRace(RACE_FISH+RACE_SEASERPENT+RACE_AQUA)
end
function c32703716.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsExistingMatchingCard(c32703716.cfilter,tp,LOCATION_REMOVED,0,3,nil)
end
function c32703716.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() and chkc:IsAbleToRemove() end
if chk==0 then return Duel.IsExistingTarget(Card.IsAbleToRemove,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,e:GetHandler()) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectTarget(tp,Card.IsAbleToRemove,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,e:GetHandler())
Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,1,0,0)
end
function c32703716.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc and tc:IsRelateToEffect(e) then
Duel.Remove(tc,POS_FACEUP,REASON_EFFECT)
end
end
| gpl-2.0 |
Lsty/ygopro-scripts | c38411870.lua | 3 | 1068 | --つり天井
function c38411870.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,0x1c0+TIMING_END_PHASE)
e1:SetCondition(c38411870.condition)
e1:SetTarget(c38411870.target)
e1:SetOperation(c38411870.activate)
c:RegisterEffect(e1)
end
function c38411870.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetFieldGroupCount(tp,LOCATION_MZONE,LOCATION_MZONE)>=4
end
function c38411870.filter(c)
return c:IsFaceup() and c:IsDestructable()
end
function c38411870.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c38411870.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
local sg=Duel.GetMatchingGroup(c38411870.filter,tp,LOCATION_MZONE,LOCATION_MZONE,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,sg,sg:GetCount(),0,0)
end
function c38411870.activate(e,tp,eg,ep,ev,re,r,rp)
local sg=Duel.GetMatchingGroup(c38411870.filter,tp,LOCATION_MZONE,LOCATION_MZONE,nil)
Duel.Destroy(sg,REASON_EFFECT)
end
| gpl-2.0 |
Nuthen/ludum-dare-39 | entities/event.lua | 1 | 9517 | local Scene = require "entities.scene"
local TextBox = require "entities.textbox"
local EventScene = Class("EventScene", Scene)
function EventScene:initialize(parent)
self.parent = parent
self.textBoxWidth = 0.8
self.textBoxHeight = 0.7
local continueText = "\n(Click here or press space to continue)"
local skipText = "\nOr press '" .. string.upper(SETTINGS.skipTutorialKeybind) .. "' to skip the tutorial"
self.eventList = {
prologue1 = function()
self.eventBox:addEntry("You are stranded on a derelict spaceship. Your goal is to restore power to all 7 power grids of your spaceship. Start by clicking on the first power grid (It is glowing red).")
local onClick = function()
self:deactivatePopup()
end
self.eventBox:addEntry(continueText, nil, nil, {clickTrigger=onClick,hoverTrigger=function() end}, "space")
self.eventBox:addEntry(skipText, {font=Fonts.regular,size=24}, nil)
end,
grid1 = function()
self.eventBox:addEntry("Warning. Power grids will slowly deplete your power over time. If you run out of power, your ship will be lost. To recharge your power, click on the power bar at the bottom of the screen or press SPACE.")
local onClick = function()
self:deactivatePopup()
end
self.eventBox:addEntry(continueText, nil, nil, {clickTrigger=onClick,hoverTrigger=function() end}, "space")
self.eventBox:addEntry(skipText, {font=Fonts.regular,size=24}, nil)
end,
dynamo1 = function()
self.eventBox:addEntry("Click on the active button (below the green light) to recharge your power levels.")
local onClick = function()
self:deactivatePopup()
end
self.eventBox:addEntry(continueText, nil, nil, {clickTrigger=onClick,hoverTrigger=function() end}, "space")
self.eventBox:addEntry(skipText, {font=Fonts.regular,size=24}, nil)
end,
dynamoCorrect1 = function()
self.eventBox:addEntry("Well done! Make sure to return here often to keep enough power. Also, more tools will unlock as more grids are powered. When you are ready, close the interface by clicking on the power bar or by pressing SPACE.")
local onClick = function()
self:deactivatePopup()
end
self.eventBox:addEntry(continueText, nil, nil, {clickTrigger=onClick,hoverTrigger=function() end}, "space")
self.eventBox:addEntry(skipText, {font=Fonts.regular,size=24}, nil)
end,
dynamoToggleOff1 = function()
self.eventBox:addEntry("Aliens are invading your ship! They're attracted to the active power grids. Click on the aliens to destroy them.")
local onClick = function()
self:deactivatePopup()
end
self.eventBox:addEntry(continueText, nil, nil, {clickTrigger=onClick,hoverTrigger=function() end}, "space")
self.eventBox:addEntry(skipText, {font=Fonts.regular,size=24}, nil)
end,
enemyDeath1 = function()
self.eventBox:addEntry("To win the game you will need to fully charge all power grids in the ship by clicking and holding on them until they reach 100%. Click on a red room on the minimap at the top right corner of your screen.")
local onClick = function()
self:deactivatePopup()
end
self.eventBox:addEntry(continueText, nil, nil, {clickTrigger=onClick,hoverTrigger=function() end}, "space")
self.eventBox:addEntry(skipText, {font=Fonts.regular,size=24}, nil)
end,
roomEnter1 = function()
self.eventBox:addEntry("To help you against the aliens, you can activate turrets by powering them up once a room is fully charged. Good Luck.")
local onClick = function()
self:deactivatePopup()
end
self.eventBox:addEntry(continueText, nil, nil, {clickTrigger=onClick,hoverTrigger=function() end}, "space")
self.eventBox:addEntry(skipText, {font=Fonts.regular,size=24}, nil)
end,
turretActivate1 = function()
self.eventBox:addEntry("Click and hold on the turret until it reaches 100% to activate it. It will help you by automatically shooting the invaders.")
local onClick = function()
self:deactivatePopup()
end
self.eventBox:addEntry(continueText, nil, nil, {clickTrigger=onClick,hoverTrigger=function() end}, "space")
self.eventBox:addEntry(skipText, {font=Fonts.regular,size=24}, nil)
end,
}
self.drawIndex = 100
Signal.register('powerGridActivate', function()
if self.firstPowerGrid then
Timer.after(TWEAK.tutorial_popup_delay, function()
self.firstPowerGrid = false
self:setEvent("grid1")
end)
end
end)
Signal.register("Dynamo Toggle On", function()
if self.firstDynamoOpen then
Timer.after(TWEAK.tutorial_popup_delay, function()
self.firstDynamoOpen = false
self:setEvent("dynamo1")
end)
end
end)
Signal.register("Dynamo Correct", function()
if self.firstDynamoCorrect then
Timer.after(TWEAK.tutorial_popup_delay, function()
self.firstDynamoCorrect = false
self:setEvent("dynamoCorrect1")
end)
end
end)
Signal.register("enemyDeath", function()
if self.firstEnemyDeath then
Timer.after(TWEAK.tutorial_popup_delay, function()
self.firstEnemyDeath = false
self:setEvent("enemyDeath1")
end)
end
end)
Signal.register("turretActivate", function()
if self.firstTurretActive then
Timer.after(TWEAK.tutorial_popup_delay, function()
self.firstTurretActive = false
self:setEvent("turretActivate1")
end)
end
end)
Signal.register("Dynamo Toggle Off", function()
if self.firstDynamoClose then
Timer.after(TWEAK.tutorial_popup_delay, function()
self.firstDynamoClose = false
self.parent:spawnEnemy(true)
self:setEvent("dynamoToggleOff1")
end)
end
end)
Signal.register("Enter Room", function(doesntCount)
if self.firstRoomEnter and not doesntCount then
Timer.after(TWEAK.tutorial_popup_delay, function()
self.firstRoomEnter = false
self:setEvent("roomEnter1")
end)
end
end)
self:reset()
end
function EventScene:deactivatePopup()
if self.shownTime >= TWEAK.tutorial_min_showtime then
self.shownTime = 0
self.active = false
end
end
function EventScene:reset()
--[[
self.firstPowerGrid
self.firstEnemy
.. etc
]]
self.firstPowerGrid = true
self.firstDynamoOpen = true
self.firstDynamoCorrect = true
self.firstEnemyDeath = true
self.firstTurretActive = true
self.firstDynamoClose = true
self.firstRoomEnter = true
self.shownTime = 0
self:setEvent("prologue1")
self.active = true
end
function EventScene:skipTutorial()
self.firstPowerGrid = false
self.firstDynamoOpen = false
self.firstDynamoCorrect = false
self.firstEnemyDeath = false
self.firstTurretActive = false
self.firstDynamoClose = false
self.firstRoomEnter = false
self.active = false
end
function EventScene:setEvent(label)
local drawnWidth, drawnHeight = self.parent:getCanvasDrawnSize()
local w, h = drawnWidth*self.textBoxWidth, drawnHeight*self.textBoxHeight
local x, y = love.graphics.getWidth()/2 - w/2, love.graphics.getHeight()/2 - h/2
self.eventBox = TextBox:new(x, y, w, h, true)
self.eventList[label]()
self.eventBox:setToMaxScroll()
self.active = true
end
function EventScene:resize(screenWidth, screenHeight)
if self.eventBox then
local w, h = screenWidth*self.textBoxWidth, screenHeight*self.textBoxHeight
local x, y = love.graphics.getWidth()/2 - w/2, love.graphics.getHeight()/2 - h/2
local fontScale = screenWidth / 1280
self.eventBox:resize(x, y, w, h, fontScale)
end
end
function EventScene:update(dt)
if not self.active then return end
self.shownTime = self.shownTime + dt
if self.eventBox then
self.eventBox:update()
end
end
function EventScene:keypressed(key, code)
if key == SETTINGS.skipTutorialKeybind then
self:skipTutorial()
end
if not self.active then return end
if self.eventBox then
self.eventBox:keypressed(key, code)
end
end
function EventScene:mousepressed(x, y, mbutton)
if not self.active then return end
end
function EventScene:mousereleased(x, y, mbutton)
if not self.active then return end
if self.eventBox then
self.eventBox:mousepressed(x, y, mbutton)
end
end
function EventScene:wheelmoved(x, y)
if self.eventBox then
-- pretty bad hack on the minus @Hack
self.eventBox:wheelmoved(x, -y)
end
end
function EventScene:draw()
end
function EventScene:drawNative()
if not self.active then return end
if self.eventBox then
self.eventBox:draw()
end
end
return EventScene
| mit |
Lsty/ygopro-scripts | c57554544.lua | 3 | 4038 | --炎王の孤島
function c57554544.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--destroy
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(57554544,0))
e2:SetCategory(CATEGORY_DESTROY+CATEGORY_TOHAND+CATEGORY_SEARCH)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_FZONE)
e2:SetCountLimit(1,57554544)
e2:SetTarget(c57554544.target)
e2:SetOperation(c57554544.operation)
c:RegisterEffect(e2)
--special summon
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(57554544,1))
e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetRange(LOCATION_FZONE)
e3:SetCountLimit(1,57554544)
e3:SetCondition(c57554544.spcon)
e3:SetTarget(c57554544.sptg)
e3:SetOperation(c57554544.spop)
c:RegisterEffect(e3)
--destroy
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(57554544,2))
e4:SetCategory(CATEGORY_DESTROY)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e4:SetCode(EVENT_TO_GRAVE)
e4:SetCondition(c57554544.descon)
e4:SetTarget(c57554544.destg)
e4:SetOperation(c57554544.desop)
c:RegisterEffect(e4)
local e5=e4:Clone()
e5:SetCode(EVENT_REMOVE)
c:RegisterEffect(e5)
end
function c57554544.filter1(c)
return c:IsType(TYPE_MONSTER) and c:IsDestructable()
end
function c57554544.filter2(c)
return c:IsSetCard(0x81) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
end
function c57554544.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c57554544.filter1,tp,LOCATION_HAND+LOCATION_MZONE,0,1,nil)
and Duel.IsExistingMatchingCard(c57554544.filter2,tp,LOCATION_DECK,0,1,nil) end
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.SetOperationInfo(0,CATEGORY_DESTROY,nil,1,tp,LOCATION_HAND+LOCATION_MZONE)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c57554544.operation(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectMatchingCard(tp,c57554544.filter1,tp,LOCATION_HAND+LOCATION_MZONE,0,1,1,nil)
if g:GetCount()>0 and Duel.Destroy(g,REASON_EFFECT)~=0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c57554544.filter2,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
end
function c57554544.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)==0
end
function c57554544.spfilter(c,e,tp)
return c:IsRace(RACE_WINDBEAST) and c:IsAttribute(ATTRIBUTE_FIRE) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c57554544.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c57554544.spfilter,tp,LOCATION_HAND,0,1,nil,e,tp) end
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND)
end
function c57554544.spop(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c57554544.spfilter,tp,LOCATION_HAND,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
end
function c57554544.descon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsPreviousLocation(LOCATION_SZONE) and c:GetPreviousSequence()==5 and c:IsPreviousPosition(POS_FACEUP)
end
function c57554544.destg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local g=Duel.GetMatchingGroup(Card.IsDestructable,tp,LOCATION_MZONE,0,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
end
function c57554544.desop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(Card.IsDestructable,tp,LOCATION_MZONE,0,nil)
Duel.Destroy(g,REASON_EFFECT)
end
| gpl-2.0 |
takaaptech/nightmaretris | const.lua | 1 | 1776 | local const = {
-- Resource paths
BG_IMAGE_PATH = 'img/bgimage.png',
FONT_PATH = 'fonts/mrsmonster.ttf',
TETROMINOS_DIR = 'tetrominos',
-- Sizes
TITLE_FONT_SIZE = 36,
STOPPED_FONT_SIZE = 45,
PAUSED_FONT_SIZE = 60,
GAMEOVER_FONT_SIZE = 64,
GAMEOVER_MESSAGE_SHADOW_OFFSET = 5,
SCORE_FONT_SIZE = 24,
TITLE_POS = { 20, 20 },
SCORE_POS = { 20, 90 },
MATRIX_SIZE = {
rows = 20,
cols = 10
},
MATRIX_HEIGHT_RATIO = 0.88, -- the ratio between the height of the matrix (in pixels) and the height of the window (in pixels)
MATRIX_PADDING = 8, -- the internal padding of the matrix
MATRIX_CORNER_RADIUS = 8, -- the radius of the rounded corners of the matrix rectangle
-- Colors
BACKGROUND_COLOR = { 0, 85, 160 },
MATRIX_COLOR = { 0, 0, 0, 170 },
DEFAULT_COLOR = { 255, 255, 255 },
TITLE_COLOR = { 255, 255, 255 },
STOPPED_MESSAGE_COLOR = { 255, 255, 0 },
GAMEOVER_MESSAGE_COLOR = { 255, 0, 0 },
GAMEOVER_MESSAGE_SHADOW_COLOR = { 255, 255, 255 },
PAUSED_MESSAGE_COLOR = { 255, 255, 0 },
SCORE_COLOR = { 255, 255, 255 },
BEVEL_BRIGHTNESS_INCREMENT = 50,
BEVEL_CORNER_SIZE = 0.15,
BLOCK_PADDING = 0,
-- Rendering
FSAA_SAMPLES = 4,
-- Game
GAME_SPEED = 2, -- Number of ticks per second (TODO: adapt for different difficulty levels)
NIGHTMARE_MODE = true,
HIDE_WHEN_PAUSED = true,
-- Messages
WINDOW_TITLE = 'NightmareTris',
TITLE = 'NightmareTris',
STOPPED_MESSAGE = 'Press F2 to start',
GAMEOVER_MESSAGE = 'Game Over!',
PAUSED_MESSAGE = 'Paused',
SCORE_MESSAGE = 'Number of lines: %d',
-- Enable debug (developer) mode
DEBUG_MODE = false,
}
return const | gpl-3.0 |
tryroach/vlc | share/lua/intf/test.lua | 91 | 1909 | function assert_url(result, protocol, username, password, host, port, path)
assert(result.protocol == protocol)
assert(result.username == username)
assert(result.password == password)
assert(result.host == host)
assert(result.port == port)
assert(result.path == path)
end
vlc.msg.info('---- Testing misc functions ----')
vlc.msg.info('version: ' .. vlc.misc.version())
vlc.msg.info('copyright: ' .. vlc.misc.copyright())
vlc.msg.info('license: ' .. vlc.misc.license())
vlc.msg.info('mdate: ' .. vlc.misc.mdate())
vlc.msg.info('---- Testing config functions ----')
vlc.msg.info('datadir: ' .. vlc.config.datadir())
vlc.msg.info('userdatadir: ' .. vlc.config.userdatadir())
vlc.msg.info('homedir: ' .. vlc.config.homedir())
vlc.msg.info('configdir: ' .. vlc.config.configdir())
vlc.msg.info('cachedir: ' .. vlc.config.cachedir())
vlc.msg.info('---- Testing net functions ----')
vlc.msg.info(' * testing vlc.net.url_parse')
vlc.msg.info(' "filename.ext"')
assert_url(vlc.net.url_parse('file:///filename.ext'), 'file', nil, nil,
nil, 0, '/filename.ext')
vlc.msg.info(' "http://server.org/path/file.ext"')
assert_url(vlc.net.url_parse('http://server.org/path/file.ext'),
'http', nil, nil, 'server.org', 0, '/path/file.ext')
vlc.msg.info(' "rtmp://server.org:4212/bla.ext"')
assert_url(vlc.net.url_parse('rtmp://server.org:4212/bla.ext'),
'rtmp', nil, nil, 'server.org', 4212, '/bla.ext')
vlc.msg.info(' "ftp://userbla@server.org:4567/bla.ext"')
assert_url(vlc.net.url_parse('rtmp://userbla@server.org:4567/bla.ext'),
'rtmp', 'userbla', nil, 'server.org', 4567, '/bla.ext')
vlc.msg.info(' "sftp://userbla:Passw0rd@server.org/bla.ext"')
assert_url(vlc.net.url_parse('sftp://userbla:Passw0rd@server.org/bla.ext'),
'sftp', 'userbla', 'Passw0rd', 'server.org', 0, '/bla.ext')
vlc.msg.info("")
vlc.misc.quit()
| gpl-2.0 |
Mijyuoon/starfall | lua/moonscript/base.lua | 1 | 1775 | local compile = loadmodule("moonscript.compile")
local parse = loadmodule("moonscript.parse")
local concat, insert, remove
do
local _obj_0 = table
concat, insert, remove = _obj_0.concat, _obj_0.insert, _obj_0.remove
end
local split, dump, get_options, unpack
do
local _obj_0 = loadmodule("moonscript.util")
split, dump, get_options, unpack = _obj_0.split, _obj_0.dump, _obj_0.get_options, _obj_0.unpack
end
local dirsep, data, to_lua, loadstring, loadfile, dofile
dirsep = "/"
data = loadmodule("moonscript.data")
to_lua = function(text, options)
if options == nil then
options = { }
end
if "string" ~= type(text) then
local t = type(text)
return nil, "expecting string (got " .. t .. ")"
end
local tree, err = parse.string(text)
if not tree then
return nil, err
end
local code, ltable, pos = compile.tree(tree, options)
if not code then
return nil, compile.format_error(ltable, pos, text)
end
return code, ltable
end
loadstring = function(...)
local options, str, chunk_name = get_options(...)
chunk_name = chunk_name or "LoadStringMS"
local code, ltable_or_err = to_lua(str, options)
if not (code) then
return nil, ltable_or_err
end
if chunk_name then
data.line_tables[chunk_name] = ltable_or_err
end
return CompileString(code, chunk_name, false)
end
loadfile = function(fname, loc, ...)
local fdata = file.Read(fname, loc)
if not (fdata) then
return nil
end
return loadstring(fdata, "@" .. tostring(fname), ...)
end
dofile = function(fname, loc, ...)
local fn = loadfile(fname, loc, ...)
assert(type(fn) == "function", fn)
return fn()
end
return {
_NAME = "moonscript",
to_lua = to_lua,
dirsep = dirsep,
dofile = dofile,
loadfile = loadfile,
loadstring = loadstring
}
| bsd-3-clause |
Lsty/ygopro-scripts | c48179391.lua | 3 | 2691 | --オレイカルコスの結界
function c48179391.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCost(c48179391.actcost)
e1:SetTarget(c48179391.acttg)
e1:SetOperation(c48179391.actop)
c:RegisterEffect(e1)
--spsummon limit
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetRange(LOCATION_SZONE)
e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e2:SetTargetRange(1,0)
e2:SetTarget(c48179391.sumlimit)
c:RegisterEffect(e2)
--
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetRange(LOCATION_SZONE)
e3:SetCode(EFFECT_UPDATE_ATTACK)
e3:SetTargetRange(LOCATION_MZONE,0)
e3:SetValue(500)
c:RegisterEffect(e3)
--
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e4:SetRange(LOCATION_SZONE)
e4:SetCode(EFFECT_INDESTRUCTABLE_COUNT)
e4:SetCountLimit(1)
e4:SetValue(c48179391.valcon)
c:RegisterEffect(e4)
--atk limit
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_FIELD)
e5:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
e5:SetRange(LOCATION_FZONE)
e5:SetTargetRange(0,LOCATION_MZONE)
e5:SetCondition(c48179391.atkcon)
e5:SetValue(c48179391.atlimit)
c:RegisterEffect(e5)
end
function c48179391.actcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetFlagEffect(tp,48179391)==0 end
Duel.RegisterFlagEffect(tp,48179391,0,0,0)
end
function c48179391.desfilter(c)
return bit.band(c:GetSummonType(),SUMMON_TYPE_SPECIAL)~=0 and c:IsDestructable()
end
function c48179391.acttg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local g=Duel.GetMatchingGroup(c48179391.desfilter,tp,LOCATION_MZONE,0,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
end
function c48179391.actop(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
local g=Duel.GetMatchingGroup(c48179391.desfilter,tp,LOCATION_MZONE,0,nil)
if g:GetCount()>0 then
Duel.Destroy(g,REASON_EFFECT)
end
end
function c48179391.sumlimit(e,c,sump,sumtype,sumpos,targetp)
return c:IsLocation(LOCATION_EXTRA)
end
function c48179391.valcon(e,re,r,rp)
return bit.band(r,REASON_EFFECT)~=0
end
function c48179391.atkcon(e)
return Duel.IsExistingMatchingCard(Card.IsPosition,e:GetHandlerPlayer(),LOCATION_MZONE,0,2,nil,POS_FACEUP_ATTACK)
end
function c48179391.atkfilter(c,atk)
return c:IsFaceup() and c:GetAttack()<atk
end
function c48179391.atlimit(e,c)
return c:IsFaceup() and not Duel.IsExistingMatchingCard(c48179391.atkfilter,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,c,c:GetAttack())
end
| gpl-2.0 |
Lsty/ygopro-scripts | c5183693.lua | 3 | 2768 | --下克上の首飾り
function c5183693.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(c5183693.target)
e1:SetOperation(c5183693.operation)
c:RegisterEffect(e1)
--atk up
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_DAMAGE_CALCULATING)
e2:SetRange(LOCATION_SZONE)
e2:SetOperation(c5183693.atkup)
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(c5183693.eqlimit)
c:RegisterEffect(e3)
--todeck
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(5183693,0))
e4:SetCategory(CATEGORY_TODECK)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e4:SetCode(EVENT_TO_GRAVE)
e4:SetTarget(c5183693.tdtg)
e4:SetOperation(c5183693.tdop)
c:RegisterEffect(e4)
end
function c5183693.eqlimit(e,c)
return c:IsType(TYPE_NORMAL)
end
function c5183693.filter(c)
return c:IsFaceup() and c:IsType(TYPE_NORMAL)
end
function c5183693.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:GetLocation()==LOCATION_MZONE and c5183693.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c5183693.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,c5183693.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
function c5183693.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 c5183693.atkup(e,tp,eg,ep,ev,re,r,rp)
local eqc=e:GetHandler():GetEquipTarget()
local a=Duel.GetAttacker()
local d=Duel.GetAttackTarget()
if not d or (a~=eqc and d~=eqc) then return end
local la=a:GetLevel()
local ld=d:GetLevel()
if (a==eqc and ld<=la) or (d==eqc and la<=ld) then return end
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetReset(RESET_PHASE+RESET_DAMAGE_CAL)
if a==eqc then
e1:SetValue((ld-la)*500)
a:RegisterEffect(e1)
else
e1:SetValue((la-ld)*500)
d:RegisterEffect(e1)
end
end
function c5183693.tdtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToDeck() end
Duel.SetOperationInfo(0,CATEGORY_TODECK,e:GetHandler(),1,0,0)
end
function c5183693.tdop(e,tp,eg,ep,ev,re,r,rp)
if e:GetHandler():IsRelateToEffect(e) then
Duel.SendtoDeck(e:GetHandler(),nil,0,REASON_EFFECT)
end
end
| gpl-2.0 |
MahmoudDolah/Firmware-Entry-Points-In-Memory | openwrt/openwrt-generic-x86/usr/lib/lua/luci/model/cbi/admin_network/ifaces.lua | 37 | 15435 | -- Copyright 2008 Steven Barth <steven@midlink.org>
-- Copyright 2008-2011 Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
local fs = require "nixio.fs"
local ut = require "luci.util"
local pt = require "luci.tools.proto"
local nw = require "luci.model.network"
local fw = require "luci.model.firewall"
arg[1] = arg[1] or ""
local has_dnsmasq = fs.access("/etc/config/dhcp")
local has_firewall = fs.access("/etc/config/firewall")
m = Map("network", translate("Interfaces") .. " - " .. arg[1]:upper(), translate("On this page you can configure the network interfaces. You can bridge several interfaces by ticking the \"bridge interfaces\" field and enter the names of several network interfaces separated by spaces. You can also use <abbr title=\"Virtual Local Area Network\">VLAN</abbr> notation <samp>INTERFACE.VLANNR</samp> (<abbr title=\"for example\">e.g.</abbr>: <samp>eth0.1</samp>)."))
m.redirect = luci.dispatcher.build_url("admin", "network", "network")
m:chain("wireless")
if has_firewall then
m:chain("firewall")
end
nw.init(m.uci)
fw.init(m.uci)
local net = nw:get_network(arg[1])
local function backup_ifnames(is_bridge)
if not net:is_floating() and not m:get(net:name(), "_orig_ifname") then
local ifcs = net:get_interfaces() or { net:get_interface() }
if ifcs then
local _, ifn
local ifns = { }
for _, ifn in ipairs(ifcs) do
ifns[#ifns+1] = ifn:name()
end
if #ifns > 0 then
m:set(net:name(), "_orig_ifname", table.concat(ifns, " "))
m:set(net:name(), "_orig_bridge", tostring(net:is_bridge()))
end
end
end
end
-- redirect to overview page if network does not exist anymore (e.g. after a revert)
if not net then
luci.http.redirect(luci.dispatcher.build_url("admin/network/network"))
return
end
-- protocol switch was requested, rebuild interface config and reload page
if m:formvalue("cbid.network.%s._switch" % net:name()) then
-- get new protocol
local ptype = m:formvalue("cbid.network.%s.proto" % net:name()) or "-"
local proto = nw:get_protocol(ptype, net:name())
if proto then
-- backup default
backup_ifnames()
-- if current proto is not floating and target proto is not floating,
-- then attempt to retain the ifnames
--error(net:proto() .. " > " .. proto:proto())
if not net:is_floating() and not proto:is_floating() then
-- if old proto is a bridge and new proto not, then clip the
-- interface list to the first ifname only
if net:is_bridge() and proto:is_virtual() then
local _, ifn
local first = true
for _, ifn in ipairs(net:get_interfaces() or { net:get_interface() }) do
if first then
first = false
else
net:del_interface(ifn)
end
end
m:del(net:name(), "type")
end
-- if the current proto is floating, the target proto not floating,
-- then attempt to restore ifnames from backup
elseif net:is_floating() and not proto:is_floating() then
-- if we have backup data, then re-add all orphaned interfaces
-- from it and restore the bridge choice
local br = (m:get(net:name(), "_orig_bridge") == "true")
local ifn
local ifns = { }
for ifn in ut.imatch(m:get(net:name(), "_orig_ifname")) do
ifn = nw:get_interface(ifn)
if ifn and not ifn:get_network() then
proto:add_interface(ifn)
if not br then
break
end
end
end
if br then
m:set(net:name(), "type", "bridge")
end
-- in all other cases clear the ifnames
else
local _, ifc
for _, ifc in ipairs(net:get_interfaces() or { net:get_interface() }) do
net:del_interface(ifc)
end
m:del(net:name(), "type")
end
-- clear options
local k, v
for k, v in pairs(m:get(net:name())) do
if k:sub(1,1) ~= "." and
k ~= "type" and
k ~= "ifname" and
k ~= "_orig_ifname" and
k ~= "_orig_bridge"
then
m:del(net:name(), k)
end
end
-- set proto
m:set(net:name(), "proto", proto:proto())
m.uci:save("network")
m.uci:save("wireless")
-- reload page
luci.http.redirect(luci.dispatcher.build_url("admin/network/network", arg[1]))
return
end
end
-- dhcp setup was requested, create section and reload page
if m:formvalue("cbid.dhcp._enable._enable") then
m.uci:section("dhcp", "dhcp", arg[1], {
interface = arg[1],
start = "100",
limit = "150",
leasetime = "12h"
})
m.uci:save("dhcp")
luci.http.redirect(luci.dispatcher.build_url("admin/network/network", arg[1]))
return
end
local ifc = net:get_interface()
s = m:section(NamedSection, arg[1], "interface", translate("Common Configuration"))
s.addremove = false
s:tab("general", translate("General Setup"))
s:tab("advanced", translate("Advanced Settings"))
s:tab("physical", translate("Physical Settings"))
if has_firewall then
s:tab("firewall", translate("Firewall Settings"))
end
st = s:taboption("general", DummyValue, "__status", translate("Status"))
local function set_status()
-- if current network is empty, print a warning
if not net:is_floating() and net:is_empty() then
st.template = "cbi/dvalue"
st.network = nil
st.value = translate("There is no device assigned yet, please attach a network device in the \"Physical Settings\" tab")
else
st.template = "admin_network/iface_status"
st.network = arg[1]
st.value = nil
end
end
m.on_init = set_status
m.on_after_save = set_status
p = s:taboption("general", ListValue, "proto", translate("Protocol"))
p.default = net:proto()
if not net:is_installed() then
p_install = s:taboption("general", Button, "_install")
p_install.title = translate("Protocol support is not installed")
p_install.inputtitle = translate("Install package %q" % net:opkg_package())
p_install.inputstyle = "apply"
p_install:depends("proto", net:proto())
function p_install.write()
return luci.http.redirect(
luci.dispatcher.build_url("admin/system/packages") ..
"?submit=1&install=%s" % net:opkg_package()
)
end
end
p_switch = s:taboption("general", Button, "_switch")
p_switch.title = translate("Really switch protocol?")
p_switch.inputtitle = translate("Switch protocol")
p_switch.inputstyle = "apply"
local _, pr
for _, pr in ipairs(nw:get_protocols()) do
p:value(pr:proto(), pr:get_i18n())
if pr:proto() ~= net:proto() then
p_switch:depends("proto", pr:proto())
end
end
auto = s:taboption("advanced", Flag, "auto", translate("Bring up on boot"))
auto.default = (net:proto() == "none") and auto.disabled or auto.enabled
delegate = s:taboption("advanced", Flag, "delegate", translate("Use builtin IPv6-management"))
delegate.default = delegate.enabled
if not net:is_virtual() then
br = s:taboption("physical", Flag, "type", translate("Bridge interfaces"), translate("creates a bridge over specified interface(s)"))
br.enabled = "bridge"
br.rmempty = true
br:depends("proto", "static")
br:depends("proto", "dhcp")
br:depends("proto", "none")
stp = s:taboption("physical", Flag, "stp", translate("Enable <abbr title=\"Spanning Tree Protocol\">STP</abbr>"),
translate("Enables the Spanning Tree Protocol on this bridge"))
stp:depends("type", "bridge")
stp.rmempty = true
end
if not net:is_floating() then
ifname_single = s:taboption("physical", Value, "ifname_single", translate("Interface"))
ifname_single.template = "cbi/network_ifacelist"
ifname_single.widget = "radio"
ifname_single.nobridges = true
ifname_single.rmempty = false
ifname_single.network = arg[1]
ifname_single:depends("type", "")
function ifname_single.cfgvalue(self, s)
-- let the template figure out the related ifaces through the network model
return nil
end
function ifname_single.write(self, s, val)
local i
local new_ifs = { }
local old_ifs = { }
for _, i in ipairs(net:get_interfaces() or { net:get_interface() }) do
old_ifs[#old_ifs+1] = i:name()
end
for i in ut.imatch(val) do
new_ifs[#new_ifs+1] = i
-- if this is not a bridge, only assign first interface
if self.option == "ifname_single" then
break
end
end
table.sort(old_ifs)
table.sort(new_ifs)
for i = 1, math.max(#old_ifs, #new_ifs) do
if old_ifs[i] ~= new_ifs[i] then
backup_ifnames()
for i = 1, #old_ifs do
net:del_interface(old_ifs[i])
end
for i = 1, #new_ifs do
net:add_interface(new_ifs[i])
end
break
end
end
end
end
if not net:is_virtual() then
ifname_multi = s:taboption("physical", Value, "ifname_multi", translate("Interface"))
ifname_multi.template = "cbi/network_ifacelist"
ifname_multi.nobridges = true
ifname_multi.rmempty = false
ifname_multi.network = arg[1]
ifname_multi.widget = "checkbox"
ifname_multi:depends("type", "bridge")
ifname_multi.cfgvalue = ifname_single.cfgvalue
ifname_multi.write = ifname_single.write
end
if has_firewall then
fwzone = s:taboption("firewall", Value, "_fwzone",
translate("Create / Assign firewall-zone"),
translate("Choose the firewall zone you want to assign to this interface. Select <em>unspecified</em> to remove the interface from the associated zone or fill out the <em>create</em> field to define a new zone and attach the interface to it."))
fwzone.template = "cbi/firewall_zonelist"
fwzone.network = arg[1]
fwzone.rmempty = false
function fwzone.cfgvalue(self, section)
self.iface = section
local z = fw:get_zone_by_network(section)
return z and z:name()
end
function fwzone.write(self, section, value)
local zone = fw:get_zone(value)
if not zone and value == '-' then
value = m:formvalue(self:cbid(section) .. ".newzone")
if value and #value > 0 then
zone = fw:add_zone(value)
else
fw:del_network(section)
end
end
if zone then
fw:del_network(section)
zone:add_network(section)
end
end
end
function p.write() end
function p.remove() end
function p.validate(self, value, section)
if value == net:proto() then
if not net:is_floating() and net:is_empty() then
local ifn = ((br and (br:formvalue(section) == "bridge"))
and ifname_multi:formvalue(section)
or ifname_single:formvalue(section))
for ifn in ut.imatch(ifn) do
return value
end
return nil, translate("The selected protocol needs a device assigned")
end
end
return value
end
local form, ferr = loadfile(
ut.libpath() .. "/model/cbi/admin_network/proto_%s.lua" % net:proto()
)
if not form then
s:taboption("general", DummyValue, "_error",
translate("Missing protocol extension for proto %q" % net:proto())
).value = ferr
else
setfenv(form, getfenv(1))(m, s, net)
end
local _, field
for _, field in ipairs(s.children) do
if field ~= st and field ~= p and field ~= p_install and field ~= p_switch then
if next(field.deps) then
local _, dep
for _, dep in ipairs(field.deps) do
dep.deps.proto = net:proto()
end
else
field:depends("proto", net:proto())
end
end
end
--
-- Display DNS settings if dnsmasq is available
--
if has_dnsmasq and net:proto() == "static" then
m2 = Map("dhcp", "", "")
local has_section = false
m2.uci:foreach("dhcp", "dhcp", function(s)
if s.interface == arg[1] then
has_section = true
return false
end
end)
if not has_section and has_dnsmasq then
s = m2:section(TypedSection, "dhcp", translate("DHCP Server"))
s.anonymous = true
s.cfgsections = function() return { "_enable" } end
x = s:option(Button, "_enable")
x.title = translate("No DHCP Server configured for this interface")
x.inputtitle = translate("Setup DHCP Server")
x.inputstyle = "apply"
elseif has_section then
s = m2:section(TypedSection, "dhcp", translate("DHCP Server"))
s.addremove = false
s.anonymous = true
s:tab("general", translate("General Setup"))
s:tab("advanced", translate("Advanced Settings"))
s:tab("ipv6", translate("IPv6 Settings"))
function s.filter(self, section)
return m2.uci:get("dhcp", section, "interface") == arg[1]
end
local ignore = s:taboption("general", Flag, "ignore",
translate("Ignore interface"),
translate("Disable <abbr title=\"Dynamic Host Configuration Protocol\">DHCP</abbr> for " ..
"this interface."))
local start = s:taboption("general", Value, "start", translate("Start"),
translate("Lowest leased address as offset from the network address."))
start.optional = true
start.datatype = "or(uinteger,ip4addr)"
start.default = "100"
local limit = s:taboption("general", Value, "limit", translate("Limit"),
translate("Maximum number of leased addresses."))
limit.optional = true
limit.datatype = "uinteger"
limit.default = "150"
local ltime = s:taboption("general", Value, "leasetime", translate("Leasetime"),
translate("Expiry time of leased addresses, minimum is 2 minutes (<code>2m</code>)."))
ltime.rmempty = true
ltime.default = "12h"
local dd = s:taboption("advanced", Flag, "dynamicdhcp",
translate("Dynamic <abbr title=\"Dynamic Host Configuration Protocol\">DHCP</abbr>"),
translate("Dynamically allocate DHCP addresses for clients. If disabled, only " ..
"clients having static leases will be served."))
dd.default = dd.enabled
s:taboption("advanced", Flag, "force", translate("Force"),
translate("Force DHCP on this network even if another server is detected."))
-- XXX: is this actually useful?
--s:taboption("advanced", Value, "name", translate("Name"),
-- translate("Define a name for this network."))
mask = s:taboption("advanced", Value, "netmask",
translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask"),
translate("Override the netmask sent to clients. Normally it is calculated " ..
"from the subnet that is served."))
mask.optional = true
mask.datatype = "ip4addr"
s:taboption("advanced", DynamicList, "dhcp_option", translate("DHCP-Options"),
translate("Define additional DHCP options, for example \"<code>6,192.168.2.1," ..
"192.168.2.2</code>\" which advertises different DNS servers to clients."))
for i, n in ipairs(s.children) do
if n ~= ignore then
n:depends("ignore", "")
end
end
o = s:taboption("ipv6", ListValue, "ra", translate("Router Advertisement-Service"))
o:value("", translate("disabled"))
o:value("server", translate("server mode"))
o:value("relay", translate("relay mode"))
o:value("hybrid", translate("hybrid mode"))
o = s:taboption("ipv6", ListValue, "dhcpv6", translate("DHCPv6-Service"))
o:value("", translate("disabled"))
o:value("server", translate("server mode"))
o:value("relay", translate("relay mode"))
o:value("hybrid", translate("hybrid mode"))
o = s:taboption("ipv6", ListValue, "ndp", translate("NDP-Proxy"))
o:value("", translate("disabled"))
o:value("relay", translate("relay mode"))
o:value("hybrid", translate("hybrid mode"))
o = s:taboption("ipv6", ListValue, "ra_management", translate("DHCPv6-Mode"))
o:value("", translate("stateless"))
o:value("1", translate("stateless + stateful"))
o:value("2", translate("stateful-only"))
o:depends("dhcpv6", "server")
o:depends("dhcpv6", "hybrid")
o.default = "1"
o = s:taboption("ipv6", Flag, "ra_default", translate("Always announce default router"),
translate("Announce as default router even if no public prefix is available."))
o:depends("ra", "server")
o:depends("ra", "hybrid")
s:taboption("ipv6", DynamicList, "dns", translate("Announced DNS servers"))
s:taboption("ipv6", DynamicList, "domain", translate("Announced DNS domains"))
else
m2 = nil
end
end
return m, m2
| apache-2.0 |
MalRD/darkstar | scripts/globals/items/uskumru.lua | 11 | 1046 | -----------------------------------------
-- ID: 5452
-- Item: Uskumru
-- Food Effect: 5Min, Mithra only
-----------------------------------------
-- Dexterity 3
-- Mind -5
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if (target:getRace() ~= dsp.race.MITHRA) then
result = dsp.msg.basic.CANNOT_EAT
end
if (target:getMod(dsp.mod.EAT_RAW_FISH) == 1) then
result = 0
end
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,300,5452)
end
function onEffectGain(target, effect)
target:addMod(dsp.mod.DEX, 3)
target:addMod(dsp.mod.MND, -5)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.DEX, 3)
target:delMod(dsp.mod.MND, -5)
end
| gpl-3.0 |
Lsty/ygopro-scripts | c75363626.lua | 5 | 1262 | --マドルチェ・シューバリエ
function c75363626.initial_effect(c)
--to deck
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(75363626,0))
e1:SetCategory(CATEGORY_TODECK)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e1:SetCode(EVENT_TO_GRAVE)
e1:SetCondition(c75363626.retcon)
e1:SetTarget(c75363626.rettg)
e1:SetOperation(c75363626.retop)
c:RegisterEffect(e1)
--cannot be battle target
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
e2:SetRange(LOCATION_MZONE)
e2:SetTargetRange(0,LOCATION_MZONE)
e2:SetValue(c75363626.atktg)
c:RegisterEffect(e2)
end
function c75363626.retcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsReason(REASON_DESTROY) and e:GetHandler():GetReasonPlayer()~=tp
and e:GetHandler():GetPreviousControler()==tp
end
function c75363626.rettg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_TODECK,e:GetHandler(),1,0,0)
end
function c75363626.retop(e,tp,eg,ep,ev,re,r,rp)
if e:GetHandler():IsRelateToEffect(e) then
Duel.SendtoDeck(e:GetHandler(),nil,2,REASON_EFFECT)
end
end
function c75363626.atktg(e,c)
return c:IsFaceup() and c:GetCode()~=75363626 and c:IsSetCard(0x71)
end
| gpl-2.0 |
ara8586/9900 | libs/url.lua | 567 | 9183 | --[[
Copyright 2004-2007 Diego Nehab.
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.
]]
-----------------------------------------------------------------------------
-- URI parsing, composition and relative URL resolution
-- LuaSocket toolkit.
-- Author: Diego Nehab
-- RCS ID: $Id: url.lua,v 1.38 2006/04/03 04:45:42 diego Exp $
-----------------------------------------------------------------------------
-- updated for a module()-free world of 5.3 by slact
local string = require("string")
local base = _G
local table = require("table")
local Url={}
Url._VERSION = "URL 1.0.2"
function Url.escape(s)
return string.gsub(s, "([^A-Za-z0-9_])", function(c)
return string.format("%%%02x", string.byte(c))
end)
end
local function make_set(t)
local s = {}
for i,v in base.ipairs(t) do
s[t[i]] = 1
end
return s
end
local segment_set = make_set {
"-", "_", ".", "!", "~", "*", "'", "(",
")", ":", "@", "&", "=", "+", "$", ",",
}
local function protect_segment(s)
return string.gsub(s, "([^A-Za-z0-9_])", function (c)
if segment_set[c] then return c
else return string.format("%%%02x", string.byte(c)) end
end)
end
function Url.unescape(s)
return string.gsub(s, "%%(%x%x)", function(hex)
return string.char(base.tonumber(hex, 16))
end)
end
local function absolute_path(base_path, relative_path)
if string.sub(relative_path, 1, 1) == "/" then return relative_path end
local path = string.gsub(base_path, "[^/]*$", "")
path = path .. relative_path
path = string.gsub(path, "([^/]*%./)", function (s)
if s ~= "./" then return s else return "" end
end)
path = string.gsub(path, "/%.$", "/")
local reduced
while reduced ~= path do
reduced = path
path = string.gsub(reduced, "([^/]*/%.%./)", function (s)
if s ~= "../../" then return "" else return s end
end)
end
path = string.gsub(reduced, "([^/]*/%.%.)$", function (s)
if s ~= "../.." then return "" else return s end
end)
return path
end
-----------------------------------------------------------------------------
-- Parses a url and returns a table with all its parts according to RFC 2396
-- The following grammar describes the names given to the URL parts
-- <url> ::= <scheme>://<authority>/<path>;<params>?<query>#<fragment>
-- <authority> ::= <userinfo>@<host>:<port>
-- <userinfo> ::= <user>[:<password>]
-- <path> :: = {<segment>/}<segment>
-- Input
-- url: uniform resource locator of request
-- default: table with default values for each field
-- Returns
-- table with the following fields, where RFC naming conventions have
-- been preserved:
-- scheme, authority, userinfo, user, password, host, port,
-- path, params, query, fragment
-- Obs:
-- the leading '/' in {/<path>} is considered part of <path>
-----------------------------------------------------------------------------
function Url.parse(url, default)
-- initialize default parameters
local parsed = {}
for i,v in base.pairs(default or parsed) do parsed[i] = v end
-- empty url is parsed to nil
if not url or url == "" then return nil, "invalid url" end
-- remove whitespace
-- url = string.gsub(url, "%s", "")
-- get fragment
url = string.gsub(url, "#(.*)$", function(f)
parsed.fragment = f
return ""
end)
-- get scheme
url = string.gsub(url, "^([%w][%w%+%-%.]*)%:",
function(s) parsed.scheme = s; return "" end)
-- get authority
url = string.gsub(url, "^//([^/]*)", function(n)
parsed.authority = n
return ""
end)
-- get query stringing
url = string.gsub(url, "%?(.*)", function(q)
parsed.query = q
return ""
end)
-- get params
url = string.gsub(url, "%;(.*)", function(p)
parsed.params = p
return ""
end)
-- path is whatever was left
if url ~= "" then parsed.path = url end
local authority = parsed.authority
if not authority then return parsed end
authority = string.gsub(authority,"^([^@]*)@",
function(u) parsed.userinfo = u; return "" end)
authority = string.gsub(authority, ":([^:]*)$",
function(p) parsed.port = p; return "" end)
if authority ~= "" then parsed.host = authority end
local userinfo = parsed.userinfo
if not userinfo then return parsed end
userinfo = string.gsub(userinfo, ":([^:]*)$",
function(p) parsed.password = p; return "" end)
parsed.user = userinfo
return parsed
end
-----------------------------------------------------------------------------
-- Rebuilds a parsed URL from its components.
-- Components are protected if any reserved or unallowed characters are found
-- Input
-- parsed: parsed URL, as returned by parse
-- Returns
-- a stringing with the corresponding URL
-----------------------------------------------------------------------------
function Url.build(parsed)
local ppath = Url.parse_path(parsed.path or "")
local url = Url.build_path(ppath)
if parsed.params then url = url .. ";" .. parsed.params end
if parsed.query then url = url .. "?" .. parsed.query end
local authority = parsed.authority
if parsed.host then
authority = parsed.host
if parsed.port then authority = authority .. ":" .. parsed.port end
local userinfo = parsed.userinfo
if parsed.user then
userinfo = parsed.user
if parsed.password then
userinfo = userinfo .. ":" .. parsed.password
end
end
if userinfo then authority = userinfo .. "@" .. authority end
end
if authority then url = "//" .. authority .. url end
if parsed.scheme then url = parsed.scheme .. ":" .. url end
if parsed.fragment then url = url .. "#" .. parsed.fragment end
-- url = string.gsub(url, "%s", "")
return url
end
-- Builds a absolute URL from a base and a relative URL according to RFC 2396
function Url.absolute(base_url, relative_url)
if base.type(base_url) == "table" then
base_parsed = base_url
base_url = Url.build(base_parsed)
else
base_parsed = Url.parse(base_url)
end
local relative_parsed = Url.parse(relative_url)
if not base_parsed then return relative_url
elseif not relative_parsed then return base_url
elseif relative_parsed.scheme then return relative_url
else
relative_parsed.scheme = base_parsed.scheme
if not relative_parsed.authority then
relative_parsed.authority = base_parsed.authority
if not relative_parsed.path then
relative_parsed.path = base_parsed.path
if not relative_parsed.params then
relative_parsed.params = base_parsed.params
if not relative_parsed.query then
relative_parsed.query = base_parsed.query
end
end
else
relative_parsed.path = absolute_path(base_parsed.path or "",
relative_parsed.path)
end
end
return Url.build(relative_parsed)
end
end
-- Breaks a path into its segments, unescaping the segments
function Url.parse_path(path)
local parsed = {}
path = path or ""
--path = string.gsub(path, "%s", "")
string.gsub(path, "([^/]+)", function (s) table.insert(parsed, s) end)
for i = 1, #parsed do
parsed[i] = Url.unescape(parsed[i])
end
if string.sub(path, 1, 1) == "/" then parsed.is_absolute = 1 end
if string.sub(path, -1, -1) == "/" then parsed.is_directory = 1 end
return parsed
end
-- Builds a path component from its segments, escaping protected characters.
function Url.build_path(parsed, unsafe)
local path = ""
local n = #parsed
if unsafe then
for i = 1, n-1 do
path = path .. parsed[i]
path = path .. "/"
end
if n > 0 then
path = path .. parsed[n]
if parsed.is_directory then path = path .. "/" end
end
else
for i = 1, n-1 do
path = path .. protect_segment(parsed[i])
path = path .. "/"
end
if n > 0 then
path = path .. protect_segment(parsed[n])
if parsed.is_directory then path = path .. "/" end
end
end
if parsed.is_absolute then path = "/" .. path end
return path
end
return Url | agpl-3.0 |
MalRD/darkstar | scripts/globals/abilities/drain_samba_ii.lua | 12 | 1343 | -----------------------------------
-- Ability: Drain Samba II
-- Inflicts the next target you strike with Drain Daze, allowing all those engaged in battle with it to drain its HP.
-- Obtained: Dancer Level 35
-- TP Required: 25%
-- Recast Time: 1:00
-- Duration: 1:30
-----------------------------------
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/magic")
require("scripts/globals/msg")
-----------------------------------
function onAbilityCheck(player,target,ability)
if (player:hasStatusEffect(dsp.effect.FAN_DANCE)) then
return dsp.msg.basic.UNABLE_TO_USE_JA2, 0
elseif (player:hasStatusEffect(dsp.effect.TRANCE)) then
return 0,0
elseif (player:getTP() < 250) then
return dsp.msg.basic.NOT_ENOUGH_TP,0
else
return 0,0
end
end
function onUseAbility(player,target,ability)
-- Only remove TP if the player doesn't have Trance.
if not player:hasStatusEffect(dsp.effect.TRANCE) then
player:delTP(250)
end
local duration = 120 + player:getMod(dsp.mod.SAMBA_DURATION)
duration = duration * (100 + player:getMod(dsp.mod.SAMBA_PDURATION))/100
player:delStatusEffect(dsp.effect.HASTE_SAMBA)
player:delStatusEffect(dsp.effect.ASPIR_SAMBA)
player:addStatusEffect(dsp.effect.DRAIN_SAMBA,2,0,duration)
end
| gpl-3.0 |
Lsty/ygopro-scripts | c61757117.lua | 5 | 1611 | --救世の美神ノースウェムコ
function c61757117.initial_effect(c)
c:EnableReviveLimit()
--set target
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e1:SetDescription(aux.Stringid(61757117,0))
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetCondition(c61757117.condition)
e1:SetTarget(c61757117.target)
e1:SetOperation(c61757117.operation)
c:RegisterEffect(e1)
--indestructable
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetRange(LOCATION_MZONE)
e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
e2:SetCondition(c61757117.indcon)
e2:SetValue(1)
c:RegisterEffect(e2)
end
function c61757117.condition(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():GetSummonType()==SUMMON_TYPE_RITUAL
end
function c61757117.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() and chkc:IsFaceup() and chkc~=e:GetHandler() end
if chk==0 then return true end
local c=e:GetHandler()
local ct=c:GetMaterialCount()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,ct,c)
end
function c61757117.operation(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
local tc=g:GetFirst()
local c=e:GetHandler()
if c:IsFacedown() or not c:IsRelateToEffect(e) then return end
while tc do
if tc:IsFaceup() and tc:IsRelateToEffect(e) then c:SetCardTarget(tc) end
tc=g:GetNext()
end
end
function c61757117.indcon(e)
return e:GetHandler():GetCardTargetCount()>0
end
| gpl-2.0 |
neverlose1/sickmind | plugins/id.lua | 31 | 6231 | --------------------------------------------------
-- ____ ____ _____ --
-- | \| _ )_ _|___ ____ __ __ --
-- | |_ ) _ \ | |/ ·__| _ \_| \/ | --
-- |____/|____/ |_|\____/\_____|_/\/\_| --
-- --
--------------------------------------------------
-- --
-- Developers: @Josepdal & @MaSkAoS --
-- Support: @Skneos, @iicc1 & @serx666 --
-- --
--------------------------------------------------
local function usernameinfo (user)
if user.username then
return '@'..user.username
end
if user.print_name then
return user.print_name
end
local text = ''
if user.first_name then
text = user.last_name..' '
end
if user.lastname then
text = text..user.last_name
end
return text
end
local function whoisname(cb_extra, success, result)
chat_type = cb_extra.chat_type
chat_id = cb_extra.chat_id
user_id = result.peer_id
user_username = result.username
if chat_type == 'chat' then
send_msg('chat#id'..chat_id, '👤 '..lang_text(chat_id, 'user')..' @'..user_username..' ('..user_id..')', ok_cb, false)
elseif chat_type == 'channel' then
send_msg('channel#id'..chat_id, '👤 '..lang_text(chat_id, 'user')..' @'..user_username..' ('..user_id..')', ok_cb, false)
end
end
local function whoisid(cb_extra, success, result)
chat_id = cb_extra.chat_id
user_id = cb_extra.user_id
if cb_extra.chat_type == 'chat' then
send_msg('chat#id'..chat_id, '👤 '..lang_text(chat_id, 'user')..' @'..result.username..' ('..user_id..')', ok_cb, false)
elseif cb_extra.chat_type == 'channel' then
send_msg('channel#id'..chat_id, '👤 '..lang_text(chat_id, 'user')..' @'..result.username..' ('..user_id..')', ok_cb, false)
end
end
local function channelUserIDs (extra, success, result)
local receiver = extra.receiver
print('Result')
vardump(result)
local text = ''
for k,user in ipairs(result) do
local id = user.peer_id
local username = usernameinfo (user)
text = text..("%s - %s\n"):format(username, id)
end
send_large_msg(receiver, text)
end
local function get_id_who(extra, success, result)
result = backward_msg_format(result)
local msg = result
local chat = msg.to.id
local user = msg.from.id
if msg.to.type == 'chat' then
send_msg('chat#id'..msg.to.id, '🆔 '..lang_text(chat, 'user')..' ID: '..msg.from.id, ok_cb, false)
elseif msg.to.type == 'channel' then
send_msg('channel#id'..msg.to.id, '🆔 '..lang_text(chat, 'user')..' ID: '..msg.from.id, ok_cb, false)
end
end
local function returnids (extra, success, result)
local receiver = extra.receiver
local chatname = result.print_name
local id = result.peer_id
local text = ('ID for chat %s (%s):\n'):format(chatname, id)
for k,user in ipairs(result.members) do
local username = usernameinfo(user)
local id = user.peer_id
local userinfo = ("%s - %s\n"):format(username, id)
text = text .. userinfo
end
send_large_msg(receiver, text)
end
local function run(msg, matches)
local receiver = get_receiver(msg)
local chat = msg.to.id
-- Id of the user and info about group / channel
if matches[1] == "#id" then
if permissions(msg.from.id, msg.to.id, "id") then
if msg.to.type == 'channel' then
send_msg(msg.to.peer_id, '🔠 '..lang_text(chat, 'supergroupName')..': '..msg.to.print_name:gsub("_", " ")..'\n👥 '..lang_text(chat, 'supergroup')..' ID: '..msg.to.id..'\n🆔 '..lang_text(chat, 'user')..' ID: '..msg.from.id, ok_cb, false)
elseif msg.to.type == 'chat' then
send_msg(msg.to.peer_id, '🔠 '..lang_text(chat, 'chatName')..': '..msg.to.print_name:gsub("_", " ")..'\n👥 '..lang_text(chat, 'chat')..' ID: '..msg.to.id..'\n🆔 '..lang_text(chat, 'user')..' ID: '..msg.from.id, ok_cb, false)
end
end
elseif matches[1] == 'whois' then
if permissions(msg.from.id, msg.to.id, "whois") then
chat_type = msg.to.type
chat_id = msg.to.id
if msg.reply_id then
get_message(msg.reply_id, get_id_who, {receiver=get_receiver(msg)})
return
end
if is_id(matches[2]) then
print(1)
user_info('user#id'..matches[2], whoisid, {chat_type=chat_type, chat_id=chat_id, user_id=matches[2]})
return
else
local member = string.gsub(matches[2], '@', '')
resolve_username(member, whoisname, {chat_id=chat_id, member=member, chat_type=chat_type})
return
end
else
return '🚫 '..lang_text(msg.to.id, 'require_mod')
end
elseif matches[1] == 'chat' or matches[1] == 'channel' then
if permissions(msg.from.id, msg.to.id, "whois") then
local type = matches[1]
local chanId = matches[2]
-- !ids? (chat) (%d+)
if chanId then
local chan = ("%s#id%s"):format(type, chanId)
if type == 'chat' then
chat_info(chan, returnids, {receiver=receiver})
else
channel_get_users(chan, channelUserIDs, {receiver=receiver})
end
else
-- !id chat/channel
local chan = ("%s#id%s"):format(msg.to.type, msg.to.id)
if msg.to.type == 'channel' then
channel_get_users(chan, channelUserIDs, {receiver=receiver})
end
if msg.to.type == 'chat' then
chat_info(chan, returnids, {receiver=receiver})
end
end
else
return '🚫 '..lang_text(msg.to.id, 'require_mod')
end
end
end
return {
patterns = {
"^#(whois)$",
"^#id$",
"^#ids? (chat)$",
"^#ids? (channel)$",
"^#(whois) (.*)$"
},
run = run
}
| gpl-2.0 |
jmattsson/nodemcu-firmware | lua_examples/ucglib/GT_fonts.lua | 30 | 1512 | local M, module = {}, ...
_G[module] = M
function M.run()
-- make this a volatile module:
package.loaded[module] = nil
print("Running component fonts...")
local d = 5
disp:setColor(0, 0, 40, 80)
disp:setColor(1, 150, 0, 200)
disp:setColor(2, 60, 0, 40)
disp:setColor(3, 0, 160, 160)
disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight())
disp:setColor(255, 255, 255)
disp:setPrintDir(0)
disp:setPrintPos(2,18)
disp:print("Fonts")
disp:setFontMode(ucg.FONT_MODE_TRANSPARENT)
disp:setColor(255, 200, 170)
disp:setFont(ucg.font_helvB08_hr)
disp:setPrintPos(2,30+d)
disp:print("ABC abc 123")
disp:setFont(ucg.font_helvB10_hr)
disp:setPrintPos(2,45+d)
disp:print("ABC abc 123")
disp:setFont(ucg.font_helvB12_hr)
--disp:setPrintPos(2,62+d)
--disp:print("ABC abc 123")
disp:drawString(2,62+d, 0, "ABC abc 123") -- test drawString
disp:setFontMode(ucg.FONT_MODE_SOLID)
disp:setColor(255, 200, 170)
disp:setColor(1, 0, 100, 120) -- background color in solid mode
disp:setFont(ucg.font_helvB08_hr)
disp:setPrintPos(2,75+30+d)
disp:print("ABC abc 123")
disp:setFont(ucg.font_helvB10_hr)
disp:setPrintPos(2,75+45+d)
disp:print("ABC abc 123")
disp:setFont(ucg.font_helvB12_hr)
disp:setPrintPos(2,75+62+d)
disp:print("ABC abc 123")
disp:setFontMode(ucg.FONT_MODE_TRANSPARENT)
disp:setFont(ucg.font_ncenR14_hr)
print("...done")
end
return M
| mit |
Lsty/ygopro-scripts | c50951359.lua | 5 | 1460 | --チューナー・キャプチャー
function c50951359.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetCondition(c50951359.condition)
e1:SetTarget(c50951359.target)
e1:SetOperation(c50951359.activate)
c:RegisterEffect(e1)
end
function c50951359.condition(e,tp,eg,ep,ev,re,r,rp)
local tc=eg:GetFirst()
return tc:GetSummonType()==SUMMON_TYPE_SYNCHRO and ep~=tp
end
function c50951359.filter(c,e,tp,mg)
return mg:IsContains(c) and c:IsType(TYPE_TUNER) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c50951359.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 c50951359.filter(chkc,e,tp,eg:GetFirst():GetMaterial()) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c50951359.filter,tp,0,LOCATION_GRAVE,1,nil,e,tp,eg:GetFirst():GetMaterial()) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c50951359.filter,tp,0,LOCATION_GRAVE,1,1,nil,e,tp,eg:GetFirst():GetMaterial())
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c50951359.activate(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 |
Lsty/ygopro-scripts | c74968065.lua | 3 | 1155 | --ヘカテリス
function c74968065.initial_effect(c)
--search
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(74968065,0))
e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_HAND)
e1:SetCost(c74968065.cost)
e1:SetTarget(c74968065.target)
e1:SetOperation(c74968065.operation)
c:RegisterEffect(e1)
end
function c74968065.cost(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:IsAbleToGraveAsCost() and c:IsDiscardable() end
Duel.SendtoGrave(c,REASON_COST+REASON_DISCARD)
end
function c74968065.filter(c)
return c:GetCode()==1353770 and c:IsAbleToHand()
end
function c74968065.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chk==0 then return Duel.IsExistingMatchingCard(c74968065.filter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c74968065.operation(e,tp,eg,ep,ev,re,r,rp,chk)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local tg=Duel.GetFirstMatchingCard(c74968065.filter,tp,LOCATION_DECK,0,nil)
if tg then
Duel.SendtoHand(tg,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,tg)
end
end
| gpl-2.0 |
MalRD/darkstar | scripts/zones/Bibiki_Bay/npcs/Warmachine.lua | 9 | 1674 | -----------------------------------
-- Area: Bibiki Bay
-- NPC: Warmachine
-- !pos -345.236 -3.188 -976.563 4
-----------------------------------
require("scripts/globals/keyitems");
local ID = require("scripts/zones/Bibiki_Bay/IDs");
require("scripts/globals/missions");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
local ColoredDrop = 4258+math.random(0,7);
-- COP mission
if (player:getCurrentMission(COP) == dsp.mission.id.cop.THREE_PATHS and player:getCharVar("COP_Louverance_s_Path") == 2) then
player:startEvent(33);
elseif (player:getCurrentMission(COP) == dsp.mission.id.cop.DAWN and player:getCharVar("COP_3-taru_story")== 1) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,ColoredDrop);
else
player:setCharVar("ColoredDrop",ColoredDrop);
player:startEvent(43);
end
-- standard dialog
else
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 33) then
player:setCharVar("COP_Louverance_s_Path",3);
elseif (csid == 43) then
local ColoredDropID=player:getCharVar("ColoredDrop");
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,ColoredDropID);
else
player:addItem(ColoredDropID);
player:messageSpecial(ID.text.ITEM_OBTAINED,ColoredDropID);
player:setCharVar("COP_3-taru_story",2);
player:setCharVar("ColoredDrop",0);
end
end
end;
| gpl-3.0 |
ASDF482/TeleTak | plugins/invite.lua | 393 | 1225 | 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)] and 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 = {
"^[!/]invite (.*)$"
},
run = run
}
end
| gpl-2.0 |
MalRD/darkstar | scripts/zones/Port_Bastok/npcs/Ronan.lua | 9 | 2271 | -----------------------------------
-- Area: Port Bastok
-- NPC: Ronan
-- Start & Finishes Quest: Out of One's Shell
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/quests");
local ID = require("scripts/zones/Port_Bastok/IDs");
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(BASTOK,dsp.quest.id.bastok.OUT_OF_ONE_S_SHELL) == QUEST_ACCEPTED and player:getCharVar("OutOfOneShell") == 0) then
if (trade:hasItemQty(17397,3) and trade:getItemCount() == 3) then
player:startEvent(84);
end
end
end;
function onTrigger(player,npc)
OutOfOneShell = player:getQuestStatus(BASTOK,dsp.quest.id.bastok.OUT_OF_ONE_S_SHELL);
if (OutOfOneShell == QUEST_ACCEPTED and player:getCharVar("OutOfOneShell") == 1) then
if (player:needToZone()) then
player:startEvent(85);
else
player:startEvent(86);
end
elseif (OutOfOneShell == QUEST_ACCEPTED) then
player:showText(npc,ID.text.RONAN_DIALOG_1);
elseif (OutOfOneShell == QUEST_COMPLETED) then
player:startEvent(89);
elseif (player:getQuestStatus(BASTOK,dsp.quest.id.bastok.THE_QUADAV_S_CURSE) == QUEST_COMPLETED and player:getFameLevel(BASTOK) >= 2) then
player:startEvent(82);
else
player:startEvent(37);
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 82) then
player:addQuest(BASTOK,dsp.quest.id.bastok.OUT_OF_ONE_S_SHELL);
elseif (csid == 84) then
player:needToZone(true);
player:setCharVar("OutOfOneShell",1);
player:tradeComplete();
elseif (csid == 86) then
if (player:getFreeSlotsCount() >= 1) then
player:addTitle(dsp.title.SHELL_OUTER);
player:setCharVar("OutOfOneShell",0);
player:addItem(12501);
player:messageSpecial(ID.text.ITEM_OBTAINED,12501);
player:addFame(BASTOK,120);
player:completeQuest(BASTOK,dsp.quest.id.bastok.OUT_OF_ONE_S_SHELL);
else
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,12501);
end
end
end; | gpl-3.0 |
Lsty/ygopro-scripts | c99861526.lua | 3 | 1407 | --サブマリンロイド
function c99861526.initial_effect(c)
--direct attack
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_DIRECT_ATTACK)
c:RegisterEffect(e1)
--damage reduce
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD)
e2:SetRange(LOCATION_MZONE)
e2:SetCode(EVENT_PRE_BATTLE_DAMAGE)
e2:SetCondition(c99861526.rdcon)
e2:SetOperation(c99861526.rdop)
c:RegisterEffect(e2)
--pos
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(99861526,0))
e3:SetCategory(CATEGORY_POSITION)
e3:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_SINGLE)
e3:SetCode(EVENT_DAMAGE_STEP_END)
e3:SetCondition(c99861526.poscon)
e3:SetOperation(c99861526.posop)
c:RegisterEffect(e3)
end
function c99861526.rdcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return ep~=tp and c==Duel.GetAttacker() and Duel.GetAttackTarget()==nil
and c:GetEffectCount(EFFECT_DIRECT_ATTACK)<2 and Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE)>0
end
function c99861526.rdop(e,tp,eg,ep,ev,re,r,rp)
Duel.ChangeBattleDamage(ep,e:GetHandler():GetBaseAttack())
end
function c99861526.poscon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsRelateToBattle() and c:IsAttackPos()
end
function c99861526.posop(e,tp,eg,ep,ev,re,r,rp)
if e:GetHandler():IsRelateToEffect(e) then
Duel.ChangePosition(e:GetHandler(),POS_FACEUP_DEFENCE)
end
end
| gpl-2.0 |
ashkanpj/yagoopfire | plugins/tweet.lua | 634 | 7120 | local OAuth = require "OAuth"
local consumer_key = ""
local consumer_secret = ""
local access_token = ""
local access_token_secret = ""
local twitter_url = "https://api.twitter.com/1.1/statuses/user_timeline.json"
local client = OAuth.new(consumer_key,
consumer_secret,
{ RequestToken = "https://api.twitter.com/oauth/request_token",
AuthorizeUser = {"https://api.twitter.com/oauth/authorize", method = "GET"},
AccessToken = "https://api.twitter.com/oauth/access_token"},
{ OAuthToken = access_token,
OAuthTokenSecret = access_token_secret})
local function send_generics_from_url_callback(cb_extra, success, result)
-- cb_extra is a table containing receiver, urls and remove_path
local receiver = cb_extra.receiver
local urls = cb_extra.urls
local remove_path = cb_extra.remove_path
local f = cb_extra.func
-- The previously image to remove
if remove_path ~= nil then
os.remove(remove_path)
print("Deleted: "..remove_path)
end
-- Nil or empty, exit case (no more urls)
if urls == nil or #urls == 0 then
return false
end
-- Take the head and remove from urls table
local head = table.remove(urls, 1)
local file_path = download_to_file(head, false)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = file_path,
func = f
}
-- Send first and postpone the others as callback
f(receiver, file_path, send_generics_from_url_callback, cb_extra)
end
local function send_generics_from_url(f, receiver, urls)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = nil,
func = f
}
send_generics_from_url_callback(cb_extra)
end
local function send_gifs_from_url(receiver, urls)
send_generics_from_url(send_document, receiver, urls)
end
local function send_videos_from_url(receiver, urls)
send_generics_from_url(send_video, receiver, urls)
end
local function send_all_files(receiver, urls)
local data = {
images = {
func = send_photos_from_url,
urls = {}
},
gifs = {
func = send_gifs_from_url,
urls = {}
},
videos = {
func = send_videos_from_url,
urls = {}
}
}
local table_to_insert = nil
for i,url in pairs(urls) do
local _, _, extension = string.match(url, "(https?)://([^\\]-([^\\%.]+))$")
local mime_type = mimetype.get_content_type_no_sub(extension)
if extension == 'gif' then
table_to_insert = data.gifs.urls
elseif mime_type == 'image' then
table_to_insert = data.images.urls
elseif mime_type == 'video' then
table_to_insert = data.videos.urls
else
table_to_insert = nil
end
if table_to_insert then
table.insert(table_to_insert, url)
end
end
for k, v in pairs(data) do
if #v.urls > 0 then
end
v.func(receiver, v.urls)
end
end
local function check_keys()
if consumer_key:isempty() then
return "Twitter Consumer Key is empty, write it in plugins/tweet.lua"
end
if consumer_secret:isempty() then
return "Twitter Consumer Secret is empty, write it in plugins/tweet.lua"
end
if access_token:isempty() then
return "Twitter Access Token is empty, write it in plugins/tweet.lua"
end
if access_token_secret:isempty() then
return "Twitter Access Token Secret is empty, write it in plugins/tweet.lua"
end
return ""
end
local function analyze_tweet(tweet)
local header = "Tweet from " .. tweet.user.name .. " (@" .. tweet.user.screen_name .. ")\n" -- "Link: https://twitter.com/statuses/" .. tweet.id_str
local text = tweet.text
-- replace short URLs
if tweet.entities.url then
for k, v in pairs(tweet.entities.urls) do
local short = v.url
local long = v.expanded_url
text = text:gsub(short, long)
end
end
-- remove urls
local urls = {}
if tweet.extended_entities and tweet.extended_entities.media then
for k, v in pairs(tweet.extended_entities.media) do
if v.video_info and v.video_info.variants then -- If it's a video!
table.insert(urls, v.video_info.variants[1].url)
else -- If not, is an image
table.insert(urls, v.media_url)
end
text = text:gsub(v.url, "") -- Replace the URL in text
end
end
return header, text, urls
end
local function sendTweet(receiver, tweet)
local header, text, urls = analyze_tweet(tweet)
-- send the parts
send_msg(receiver, header .. "\n" .. text, ok_cb, false)
send_all_files(receiver, urls)
return nil
end
local function getTweet(msg, base, all)
local receiver = get_receiver(msg)
local response_code, response_headers, response_status_line, response_body = client:PerformRequest("GET", twitter_url, base)
if response_code ~= 200 then
return "Can't connect, maybe the user doesn't exist."
end
local response = json:decode(response_body)
if #response == 0 then
return "Can't retrieve any tweets, sorry"
end
if all then
for i,tweet in pairs(response) do
sendTweet(receiver, tweet)
end
else
local i = math.random(#response)
local tweet = response[i]
sendTweet(receiver, tweet)
end
return nil
end
function isint(n)
return n==math.floor(n)
end
local function run(msg, matches)
local checked = check_keys()
if not checked:isempty() then
return checked
end
local base = {include_rts = 1}
if matches[1] == 'id' then
local userid = tonumber(matches[2])
if userid == nil or not isint(userid) then
return "The id of a user is a number, check this web: http://gettwitterid.com/"
end
base.user_id = userid
elseif matches[1] == 'name' then
base.screen_name = matches[2]
else
return ""
end
local count = 200
local all = false
if #matches > 2 and matches[3] == 'last' then
count = 1
if #matches == 4 then
local n = tonumber(matches[4])
if n > 10 then
return "You only can ask for 10 tweets at most"
end
count = matches[4]
all = true
end
end
base.count = count
return getTweet(msg, base, all)
end
return {
description = "Random tweet from user",
usage = {
"!tweet id [id]: Get a random tweet from the user with that ID",
"!tweet id [id] last: Get a random tweet from the user with that ID",
"!tweet name [name]: Get a random tweet from the user with that name",
"!tweet name [name] last: Get a random tweet from the user with that name"
},
patterns = {
"^!tweet (id) ([%w_%.%-]+)$",
"^!tweet (id) ([%w_%.%-]+) (last)$",
"^!tweet (id) ([%w_%.%-]+) (last) ([%d]+)$",
"^!tweet (name) ([%w_%.%-]+)$",
"^!tweet (name) ([%w_%.%-]+) (last)$",
"^!tweet (name) ([%w_%.%-]+) (last) ([%d]+)$"
},
run = run
}
| gpl-2.0 |
Lsty/ygopro-scripts | c16889337.lua | 3 | 2854 | --荒魂
function c16889337.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)
e1:SetValue(aux.FALSE)
c:RegisterEffect(e1)
--summon,flip
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetCode(EVENT_SUMMON_SUCCESS)
e2:SetOperation(c16889337.retreg)
c:RegisterEffect(e2)
local e3=e2:Clone()
e3:SetCode(EVENT_FLIP)
c:RegisterEffect(e3)
--search
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(16889337,0))
e4:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e4:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e4:SetCode(EVENT_SUMMON_SUCCESS)
e4:SetTarget(c16889337.thtg)
e4:SetOperation(c16889337.thop)
c:RegisterEffect(e4)
local e5=e4:Clone()
e5:SetCode(EVENT_FLIP)
c:RegisterEffect(e5)
end
function c16889337.filter(c)
return c:IsType(TYPE_SPIRIT) and c:GetCode()~=16889337 and c:IsAbleToHand()
end
function c16889337.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c16889337.filter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c16889337.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c16889337.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 c16889337.retreg(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
--to hand
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e1:SetDescription(aux.Stringid(16889337,0))
e1:SetCategory(CATEGORY_TOHAND)
e1:SetCode(EVENT_PHASE+PHASE_END)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1)
e1:SetReset(RESET_EVENT+0x1ee0000+RESET_PHASE+PHASE_END)
e1:SetCondition(c16889337.retcon)
e1:SetTarget(c16889337.rettg)
e1:SetOperation(c16889337.retop)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
c:RegisterEffect(e2)
end
function c16889337.retcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsHasEffect(EFFECT_SPIRIT_DONOT_RETURN) then return false end
if e:IsHasType(EFFECT_TYPE_TRIGGER_F) then
return not c:IsHasEffect(EFFECT_SPIRIT_MAYNOT_RETURN)
else return c:IsHasEffect(EFFECT_SPIRIT_MAYNOT_RETURN) end
end
function c16889337.rettg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,e:GetHandler(),1,0,0)
end
function c16889337.retop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) and c:IsFaceup() then
Duel.SendtoHand(c,nil,REASON_EFFECT)
end
end
| gpl-2.0 |
MalRD/darkstar | scripts/globals/items/gold_lobster.lua | 11 | 1250 | -----------------------------------------
-- ID: 5797
-- Item: gold_lobster
-- Food Effect: 5Min, Mithra only
-----------------------------------------
-- Dexterity -5
-- Vitality 3
-- Defense % 16 (Cap 50)
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if (target:getRace() ~= dsp.race.MITHRA) then
result = dsp.msg.basic.CANNOT_EAT
end
if (target:getMod(dsp.mod.EAT_RAW_FISH) == 1) then
result = 0
end
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,300,5797)
end
function onEffectGain(target, effect)
target:addMod(dsp.mod.DEX, -5)
target:addMod(dsp.mod.VIT, 3)
target:addMod(dsp.mod.FOOD_DEFP, 16)
target:addMod(dsp.mod.FOOD_DEF_CAP, 50)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.DEX, -5)
target:delMod(dsp.mod.VIT, 3)
target:delMod(dsp.mod.FOOD_DEFP, 16)
target:delMod(dsp.mod.FOOD_DEF_CAP, 50)
end
| gpl-3.0 |
Lsty/ygopro-scripts | c77631175.lua | 3 | 1762 | --CH キング・アーサー
function c77631175.initial_effect(c)
--xyz summon
aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsRace,RACE_WARRIOR),4,2)
c:EnableReviveLimit()
--destroy replace
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e1:SetCode(EFFECT_DESTROY_REPLACE)
e1:SetRange(LOCATION_MZONE)
e1:SetTarget(c77631175.reptg)
c:RegisterEffect(e1)
--damage
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(77631175,1))
e2:SetCategory(CATEGORY_DAMAGE)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e2:SetCode(77631175)
e2:SetTarget(c77631175.target)
e2:SetOperation(c77631175.operation)
c:RegisterEffect(e2)
end
function c77631175.reptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsReason(REASON_BATTLE) and e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_EFFECT) end
if Duel.SelectYesNo(tp,aux.Stringid(77631175,0)) then
local c=e:GetHandler()
c:RemoveOverlayCard(tp,1,1,REASON_EFFECT)
Duel.RaiseSingleEvent(c,77631175,e,0,0,0,0)
return true
else return false end
end
function c77631175.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetTargetPlayer(1-tp)
Duel.SetTargetParam(500)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,500)
end
function c77631175.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) or c:IsFacedown() then return end
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(500)
e1:SetReset(RESET_EVENT+0x1ff0000)
c:RegisterEffect(e1)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Damage(p,d,REASON_EFFECT)
end
| gpl-2.0 |
cshore-firmware/openwrt-luci | applications/luci-app-asterisk/luasrc/model/cbi/asterisk/trunks.lua | 68 | 2343 | -- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
local ast = require("luci.asterisk")
cbimap = Map("asterisk", "Trunks")
cbimap.pageaction = false
local sip_peers = { }
cbimap.uci:foreach("asterisk", "sip",
function(s)
if s.type == "peer" then
s.name = s['.name']
s.info = ast.sip.peer(s.name)
sip_peers[s.name] = s
end
end)
sip_table = cbimap:section(TypedSection, "sip", "SIP Trunks")
sip_table.template = "cbi/tblsection"
sip_table.extedit = luci.dispatcher.build_url("admin", "asterisk", "trunks", "sip", "%s")
sip_table.addremove = true
sip_table.sectionhead = "Extension"
function sip_table.filter(self, s)
return s and (
cbimap.uci:get("asterisk", s, "type") == nil or
cbimap.uci:get_bool("asterisk", s, "provider")
)
end
function sip_table.create(self, section)
if TypedSection.create(self, section) then
created = section
else
self.invalid_cts = true
end
end
function sip_table.parse(self, ...)
TypedSection.parse(self, ...)
if created then
cbimap.uci:tset("asterisk", created, {
type = "friend",
qualify = "yes",
provider = "yes"
})
cbimap.uci:save("asterisk")
luci.http.redirect(luci.dispatcher.build_url(
"admin", "asterisk", "trunks", "sip", created
))
end
end
user = sip_table:option(DummyValue, "username", "Username")
context = sip_table:option(DummyValue, "context", "Dialplan")
context.href = luci.dispatcher.build_url("admin", "asterisk", "dialplan")
function context.cfgvalue(...)
return AbstractValue.cfgvalue(...) or "(default)"
end
online = sip_table:option(DummyValue, "online", "Registered")
function online.cfgvalue(self, s)
if sip_peers[s] and sip_peers[s].info.online == nil then
return "n/a"
else
return sip_peers[s] and sip_peers[s].info.online
and "yes" or "no (%s)" %{
sip_peers[s] and sip_peers[s].info.Status:lower() or "unknown"
}
end
end
delay = sip_table:option(DummyValue, "delay", "Delay")
function delay.cfgvalue(self, s)
if sip_peers[s] and sip_peers[s].info.online then
return "%i ms" % sip_peers[s].info.delay
else
return "n/a"
end
end
info = sip_table:option(Button, "_info", "Info")
function info.write(self, s)
luci.http.redirect(luci.dispatcher.build_url(
"admin", "asterisk", "trunks", "sip", s, "info"
))
end
return cbimap
| apache-2.0 |
rotmanmi/nn | SpatialConvolutionMM.lua | 9 | 3125 | local SpatialConvolutionMM, parent = torch.class('nn.SpatialConvolutionMM', 'nn.Module')
function SpatialConvolutionMM:__init(nInputPlane, nOutputPlane, kW, kH, dW, dH, padW, padH)
parent.__init(self)
dW = dW or 1
dH = dH or 1
self.nInputPlane = nInputPlane
self.nOutputPlane = nOutputPlane
self.kW = kW
self.kH = kH
self.dW = dW
self.dH = dH
self.padW = padW or 0
self.padH = padH or self.padW
self.weight = torch.Tensor(nOutputPlane, nInputPlane*kH*kW)
self.bias = torch.Tensor(nOutputPlane)
self.gradWeight = torch.Tensor(nOutputPlane, nInputPlane*kH*kW)
self.gradBias = torch.Tensor(nOutputPlane)
self.finput = torch.Tensor()
self.fgradInput = torch.Tensor()
self:reset()
end
function SpatialConvolutionMM:reset(stdv)
if stdv then
stdv = stdv * math.sqrt(3)
else
stdv = 1/math.sqrt(self.kW*self.kH*self.nInputPlane)
end
if nn.oldSeed then
self.weight:apply(function()
return torch.uniform(-stdv, stdv)
end)
self.bias:apply(function()
return torch.uniform(-stdv, stdv)
end)
else
self.weight:uniform(-stdv, stdv)
self.bias:uniform(-stdv, stdv)
end
end
local function makeContiguous(self, input, gradOutput)
if not input:isContiguous() then
self._input = self._input or input.new()
self._input:resizeAs(input):copy(input)
input = self._input
end
if gradOutput then
if not gradOutput:isContiguous() then
self._gradOutput = self._gradOutput or gradOutput.new()
self._gradOutput:resizeAs(gradOutput):copy(gradOutput)
gradOutput = self._gradOutput
end
end
return input, gradOutput
end
function SpatialConvolutionMM:updateOutput(input)
-- backward compatibility
if self.padding then
self.padW = self.padding
self.padH = self.padding
self.padding = nil
end
input = makeContiguous(self, input)
return input.nn.SpatialConvolutionMM_updateOutput(self, input)
end
function SpatialConvolutionMM:updateGradInput(input, gradOutput)
if self.gradInput then
input, gradOutput = makeContiguous(self, input, gradOutput)
return input.nn.SpatialConvolutionMM_updateGradInput(self, input, gradOutput)
end
end
function SpatialConvolutionMM:accGradParameters(input, gradOutput, scale)
input, gradOutput = makeContiguous(self, input, gradOutput)
return input.nn.SpatialConvolutionMM_accGradParameters(self, input, gradOutput, scale)
end
function SpatialConvolutionMM:type(type,tensorCache)
self.finput = torch.Tensor()
self.fgradInput = torch.Tensor()
return parent.type(self,type,tensorCache)
end
function SpatialConvolutionMM:__tostring__()
local s = string.format('%s(%d -> %d, %dx%d', torch.type(self),
self.nInputPlane, self.nOutputPlane, self.kW, self.kH)
if self.dW ~= 1 or self.dH ~= 1 or self.padW ~= 0 or self.padH ~= 0 then
s = s .. string.format(', %d,%d', self.dW, self.dH)
end
if (self.padW or self.padH) and (self.padW ~= 0 or self.padH ~= 0) then
s = s .. ', ' .. self.padW .. ',' .. self.padH
end
return s .. ')'
end
| bsd-3-clause |
Frenzie/koreader | frontend/ui/widget/linkbox.lua | 4 | 1554 | local Blitbuffer = require("ffi/blitbuffer")
local Device = require("device")
local Geom = require("ui/geometry")
local GestureRange = require("ui/gesturerange")
local InputContainer = require("ui/widget/container/inputcontainer")
local Size = require("ui/size")
local UIManager = require("ui/uimanager")
local Screen = Device.screen
local LinkBox = InputContainer:extend{
box = nil,
color = Blitbuffer.COLOR_DARK_GRAY,
radius = 0,
bordersize = Size.line.medium,
}
function LinkBox:init()
if Device:isTouchDevice() then
self.ges_events.TapClose = {
GestureRange:new{
ges = "tap",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight(),
}
}
}
end
end
function LinkBox:paintTo(bb)
bb:paintBorder(self.box.x, self.box.y, self.box.w, self.box.h,
self.bordersize, self.color, self.radius)
end
function LinkBox:onCloseWidget()
UIManager:setDirty(nil, function()
return "partial", self.box
end)
end
function LinkBox:onShow()
UIManager:setDirty(self, function()
return "ui", self.box
end)
if self.timeout then
UIManager:scheduleIn(self.timeout, function()
UIManager:close(self)
if self.callback then self.callback() end
end)
end
return true
end
function LinkBox:onTapClose()
UIManager:close(self)
self.callback = nil
return true
end
return LinkBox
| agpl-3.0 |
cshore-firmware/openwrt-luci | applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/netlink.lua | 39 | 5747 | -- Copyright 2008 Freifunk Leipzig / Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
module("luci.statistics.rrdtool.definitions.netlink", package.seeall)
function rrdargs( graph, plugin, plugin_instance )
--
-- traffic diagram
--
local traffic = {
title = "%H: Netlink - Transfer on %pi",
vlabel = "Bytes/s",
-- diagram data description
data = {
-- defined sources for data types, if ommitted assume a single DS named "value" (optional)
sources = {
if_octets = { "tx", "rx" }
},
-- special options for single data lines
options = {
if_octets__tx = {
title = "Bytes (TX)",
total = true, -- report total amount of bytes
color = "00ff00" -- tx is green
},
if_octets__rx = {
title = "Bytes (RX)",
flip = true, -- flip rx line
total = true, -- report total amount of bytes
color = "0000ff" -- rx is blue
}
}
}
}
--
-- packet diagram
--
local packets = {
title = "%H: Netlink - Packets on %pi",
vlabel = "Packets/s", detail = true,
-- diagram data description
data = {
-- data type order
types = { "if_packets", "if_dropped", "if_errors" },
-- defined sources for data types
sources = {
if_packets = { "tx", "rx" },
if_dropped = { "tx", "rx" },
if_errors = { "tx", "rx" }
},
-- special options for single data lines
options = {
-- processed packets (tx DS)
if_packets__tx = {
weight = 2,
title = "Total (TX)",
overlay = true, -- don't summarize
total = true, -- report total amount of bytes
color = "00ff00" -- processed tx is green
},
-- processed packets (rx DS)
if_packets__rx = {
weight = 3,
title = "Total (RX)",
overlay = true, -- don't summarize
flip = true, -- flip rx line
total = true, -- report total amount of bytes
color = "0000ff" -- processed rx is blue
},
-- dropped packets (tx DS)
if_dropped__tx = {
weight = 1,
title = "Dropped (TX)",
overlay = true, -- don't summarize
total = true, -- report total amount of bytes
color = "660055" -- dropped tx is ... dunno ;)
},
-- dropped packets (rx DS)
if_dropped__rx = {
weight = 4,
title = "Dropped (RX)",
overlay = true, -- don't summarize
flip = true, -- flip rx line
total = true, -- report total amount of bytes
color = "ff00ff" -- dropped rx is violett
},
-- packet errors (tx DS)
if_errors__tx = {
weight = 0,
title = "Errors (TX)",
overlay = true, -- don't summarize
total = true, -- report total amount of packets
color = "ff5500" -- tx errors are orange
},
-- packet errors (rx DS)
if_errors__rx = {
weight = 5,
title = "Errors (RX)",
overlay = true, -- don't summarize
flip = true, -- flip rx line
total = true, -- report total amount of packets
color = "ff0000" -- rx errors are red
}
}
}
}
--
-- multicast diagram
--
local multicast = {
title = "%H: Netlink - Multicast on %pi",
vlabel = "Packets/s", detail = true,
-- diagram data description
data = {
-- data type order
types = { "if_multicast" },
-- special options for single data lines
options = {
-- multicast packets
if_multicast = {
title = "Packets",
total = true, -- report total amount of packets
color = "0000ff" -- multicast is blue
}
}
}
}
--
-- collision diagram
--
local collisions = {
title = "%H: Netlink - Collisions on %pi",
vlabel = "Collisions/s", detail = true,
-- diagram data description
data = {
-- data type order
types = { "if_collisions" },
-- special options for single data lines
options = {
-- collision rate
if_collisions = {
title = "Collisions",
total = true, -- report total amount of packets
color = "ff0000" -- collsions are red
}
}
}
}
--
-- error diagram
--
local errors = {
title = "%H: Netlink - Errors on %pi",
vlabel = "Errors/s", detail = true,
-- diagram data description
data = {
-- data type order
types = { "if_tx_errors", "if_rx_errors" },
-- data type instances
instances = {
if_tx_errors = { "aborted", "carrier", "fifo", "heartbeat", "window" },
if_rx_errors = { "length", "missed", "over", "crc", "fifo", "frame" }
},
-- special options for single data lines
options = {
if_tx_errors_aborted_value = { total = true, color = "ffff00", title = "Aborted (TX)" },
if_tx_errors_carrier_value = { total = true, color = "ffcc00", title = "Carrier (TX)" },
if_tx_errors_fifo_value = { total = true, color = "ff9900", title = "Fifo (TX)" },
if_tx_errors_heartbeat_value = { total = true, color = "ff6600", title = "Heartbeat (TX)" },
if_tx_errors_window_value = { total = true, color = "ff3300", title = "Window (TX)" },
if_rx_errors_length_value = { flip = true, total = true, color = "ff0000", title = "Length (RX)" },
if_rx_errors_missed_value = { flip = true, total = true, color = "ff0033", title = "Missed (RX)" },
if_rx_errors_over_value = { flip = true, total = true, color = "ff0066", title = "Over (RX)" },
if_rx_errors_crc_value = { flip = true, total = true, color = "ff0099", title = "CRC (RX)" },
if_rx_errors_fifo_value = { flip = true, total = true, color = "ff00cc", title = "Fifo (RX)" },
if_rx_errors_frame_value = { flip = true, total = true, color = "ff00ff", title = "Frame (RX)" }
}
}
}
return { traffic, packets, multicast, collisions, errors }
end
| apache-2.0 |
Lsty/ygopro-scripts | c68811206.lua | 9 | 1324 | --Tyler the Great Warrior
function c68811206.initial_effect(c)
--spsummon condition
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
c:RegisterEffect(e1)
--damage
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(68811206,0))
e2:SetCategory(CATEGORY_DAMAGE)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e2:SetCode(EVENT_BATTLE_DESTROYING)
e2:SetCondition(c68811206.damcon)
e2:SetTarget(c68811206.damtg)
e2:SetOperation(c68811206.damop)
c:RegisterEffect(e2)
end
function c68811206.damcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local bc=c:GetBattleTarget()
return c:IsRelateToBattle() and bc:IsLocation(LOCATION_GRAVE) and bc:IsType(TYPE_MONSTER)
end
function c68811206.damtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local c=e:GetHandler()
local bc=c:GetBattleTarget()
local dam=bc:GetAttack()
if dam<0 then dam=0 end
Duel.SetTargetPlayer(1-tp)
Duel.SetTargetParam(dam)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,dam)
end
function c68811206.damop(e,tp,eg,ep,ev,re,r,rp)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Damage(p,d,REASON_EFFECT)
end
| gpl-2.0 |
robertbrook/Penlight | lua/pl/comprehension.lua | 39 | 9077 | --- List comprehensions implemented in Lua.
--
-- See the [wiki page](http://lua-users.org/wiki/ListComprehensions)
--
-- local C= require 'pl.comprehension' . new()
--
-- C ('x for x=1,10') ()
-- ==> {1,2,3,4,5,6,7,8,9,10}
-- C 'x^2 for x=1,4' ()
-- ==> {1,4,9,16}
-- C '{x,x^2} for x=1,4' ()
-- ==> {{1,1},{2,4},{3,9},{4,16}}
-- C '2*x for x' {1,2,3}
-- ==> {2,4,6}
-- dbl = C '2*x for x'
-- dbl {10,20,30}
-- ==> {20,40,60}
-- C 'x for x if x % 2 == 0' {1,2,3,4,5}
-- ==> {2,4}
-- C '{x,y} for x = 1,2 for y = 1,2' ()
-- ==> {{1,1},{1,2},{2,1},{2,2}}
-- C '{x,y} for x for y' ({1,2},{10,20})
-- ==> {{1,10},{1,20},{2,10},{2,20}}
-- assert(C 'sum(x^2 for x)' {2,3,4} == 2^2+3^2+4^2)
--
-- (c) 2008 David Manura. Licensed under the same terms as Lua (MIT license).
--
-- Dependencies: `pl.utils`, `pl.luabalanced`
--
-- See @{07-functional.md.List_Comprehensions|the Guide}
-- @module pl.comprehension
local utils = require 'pl.utils'
local status,lb = pcall(require, "pl.luabalanced")
if not status then
lb = require 'luabalanced'
end
local math_max = math.max
local table_concat = table.concat
-- fold operations
-- http://en.wikipedia.org/wiki/Fold_(higher-order_function)
local ops = {
list = {init=' {} ', accum=' __result[#__result+1] = (%s) '},
table = {init=' {} ', accum=' local __k, __v = %s __result[__k] = __v '},
sum = {init=' 0 ', accum=' __result = __result + (%s) '},
min = {init=' nil ', accum=' local __tmp = %s ' ..
' if __result then if __tmp < __result then ' ..
'__result = __tmp end else __result = __tmp end '},
max = {init=' nil ', accum=' local __tmp = %s ' ..
' if __result then if __tmp > __result then ' ..
'__result = __tmp end else __result = __tmp end '},
}
-- Parses comprehension string expr.
-- Returns output expression list <out> string, array of for types
-- ('=', 'in' or nil) <fortypes>, array of input variable name
-- strings <invarlists>, array of input variable value strings
-- <invallists>, array of predicate expression strings <preds>,
-- operation name string <opname>, and number of placeholder
-- parameters <max_param>.
--
-- The is equivalent to the mathematical set-builder notation:
--
-- <opname> { <out> | <invarlist> in <invallist> , <preds> }
--
-- @usage "x^2 for x" -- array values
-- @usage "x^2 for x=1,10,2" -- numeric for
-- @usage "k^v for k,v in pairs(_1)" -- iterator for
-- @usage "(x+y)^2 for x for y if x > y" -- nested
--
local function parse_comprehension(expr)
local t = {}
local pos = 1
-- extract opname (if exists)
local opname
local tok, post = expr:match('^%s*([%a_][%w_]*)%s*%(()', pos)
local pose = #expr + 1
if tok then
local tok2, posb = lb.match_bracketed(expr, post-1)
assert(tok2, 'syntax error')
if expr:match('^%s*$', posb) then
opname = tok
pose = posb - 1
pos = post
end
end
opname = opname or "list"
-- extract out expression list
local out; out, pos = lb.match_explist(expr, pos)
assert(out, "syntax error: missing expression list")
out = table_concat(out, ', ')
-- extract "for" clauses
local fortypes = {}
local invarlists = {}
local invallists = {}
while 1 do
local post = expr:match('^%s*for%s+()', pos)
if not post then break end
pos = post
-- extract input vars
local iv; iv, pos = lb.match_namelist(expr, pos)
assert(#iv > 0, 'syntax error: zero variables')
for _,ident in ipairs(iv) do
assert(not ident:match'^__',
"identifier " .. ident .. " may not contain __ prefix")
end
invarlists[#invarlists+1] = iv
-- extract '=' or 'in' (optional)
local fortype, post = expr:match('^(=)%s*()', pos)
if not fortype then fortype, post = expr:match('^(in)%s+()', pos) end
if fortype then
pos = post
-- extract input value range
local il; il, pos = lb.match_explist(expr, pos)
assert(#il > 0, 'syntax error: zero expressions')
assert(fortype ~= '=' or #il == 2 or #il == 3,
'syntax error: numeric for requires 2 or three expressions')
fortypes[#invarlists] = fortype
invallists[#invarlists] = il
else
fortypes[#invarlists] = false
invallists[#invarlists] = false
end
end
assert(#invarlists > 0, 'syntax error: missing "for" clause')
-- extract "if" clauses
local preds = {}
while 1 do
local post = expr:match('^%s*if%s+()', pos)
if not post then break end
pos = post
local pred; pred, pos = lb.match_expression(expr, pos)
assert(pred, 'syntax error: predicated expression not found')
preds[#preds+1] = pred
end
-- extract number of parameter variables (name matching "_%d+")
local stmp = ''; lb.gsub(expr, function(u, sin) -- strip comments/strings
if u == 'e' then stmp = stmp .. ' ' .. sin .. ' ' end
end)
local max_param = 0; stmp:gsub('[%a_][%w_]*', function(s)
local s = s:match('^_(%d+)$')
if s then max_param = math_max(max_param, tonumber(s)) end
end)
if pos ~= pose then
assert(false, "syntax error: unrecognized " .. expr:sub(pos))
end
--DEBUG:
--print('----\n', string.format("%q", expr), string.format("%q", out), opname)
--for k,v in ipairs(invarlists) do print(k,v, invallists[k]) end
--for k,v in ipairs(preds) do print(k,v) end
return out, fortypes, invarlists, invallists, preds, opname, max_param
end
-- Create Lua code string representing comprehension.
-- Arguments are in the form returned by parse_comprehension.
local function code_comprehension(
out, fortypes, invarlists, invallists, preds, opname, max_param
)
local op = assert(ops[opname])
local code = op.accum:gsub('%%s', out)
for i=#preds,1,-1 do local pred = preds[i]
code = ' if ' .. pred .. ' then ' .. code .. ' end '
end
for i=#invarlists,1,-1 do
if not fortypes[i] then
local arrayname = '__in' .. i
local idx = '__idx' .. i
code =
' for ' .. idx .. ' = 1, #' .. arrayname .. ' do ' ..
' local ' .. invarlists[i][1] .. ' = ' .. arrayname .. '['..idx..'] ' ..
code .. ' end '
else
code =
' for ' ..
table_concat(invarlists[i], ', ') ..
' ' .. fortypes[i] .. ' ' ..
table_concat(invallists[i], ', ') ..
' do ' .. code .. ' end '
end
end
code = ' local __result = ( ' .. op.init .. ' ) ' .. code
return code
end
-- Convert code string represented by code_comprehension
-- into Lua function. Also must pass ninputs = #invarlists,
-- max_param, and invallists (from parse_comprehension).
-- Uses environment env.
local function wrap_comprehension(code, ninputs, max_param, invallists, env)
assert(ninputs > 0)
local ts = {}
for i=1,max_param do
ts[#ts+1] = '_' .. i
end
for i=1,ninputs do
if not invallists[i] then
local name = '__in' .. i
ts[#ts+1] = name
end
end
if #ts > 0 then
code = ' local ' .. table_concat(ts, ', ') .. ' = ... ' .. code
end
code = code .. ' return __result '
--print('DEBUG:', code)
local f, err = utils.load(code,'tmp','t',env)
if not f then assert(false, err .. ' with generated code ' .. code) end
return f
end
-- Build Lua function from comprehension string.
-- Uses environment env.
local function build_comprehension(expr, env)
local out, fortypes, invarlists, invallists, preds, opname, max_param
= parse_comprehension(expr)
local code = code_comprehension(
out, fortypes, invarlists, invallists, preds, opname, max_param)
local f = wrap_comprehension(code, #invarlists, max_param, invallists, env)
return f
end
-- Creates new comprehension cache.
-- Any list comprehension function created are set to the environment
-- env (defaults to caller of new).
local function new(env)
-- Note: using a single global comprehension cache would have had
-- security implications (e.g. retrieving cached functions created
-- in other environments).
-- The cache lookup function could have instead been written to retrieve
-- the caller's environment, lookup up the cache private to that
-- environment, and then looked up the function in that cache.
-- That would avoid the need for this <new> call to
-- explicitly manage caches; however, that might also have an undue
-- performance penalty.
if not env then
env = utils.getfenv(2)
end
local mt = {}
local cache = setmetatable({}, mt)
-- Index operator builds, caches, and returns Lua function
-- corresponding to comprehension expression string.
--
-- Example: f = comprehension['x^2 for x']
--
function mt:__index(expr)
local f = build_comprehension(expr, env)
self[expr] = f -- cache
return f
end
-- Convenience syntax.
-- Allows comprehension 'x^2 for x' instead of comprehension['x^2 for x'].
mt.__call = mt.__index
cache.new = new
return cache
end
local comprehension = {}
comprehension.new = new
return comprehension
| mit |
Lsty/ygopro-scripts | c9365703.lua | 3 | 1411 | --スピード・ウォリアー
function c9365703.initial_effect(c)
--summon success
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetOperation(c9365703.sumop)
c:RegisterEffect(e1)
--atk up
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(9365703,0))
e2:SetCategory(CATEGORY_ATKCHANGE)
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetCode(EVENT_FREE_CHAIN)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1)
e2:SetCondition(c9365703.dacon)
e2:SetOperation(c9365703.daop)
c:RegisterEffect(e2)
end
function c9365703.sumop(e,tp,eg,ep,ev,re,r,rp)
e:GetHandler():RegisterFlagEffect(9365703,RESET_EVENT+0x1fc0000+RESET_PHASE+PHASE_END,0,1)
end
function c9365703.dacon(e,tp,eg,ep,ev,re,r,rp)
if Duel.CheckTiming(TIMING_BATTLE_START) or Duel.CheckTiming(TIMING_BATTLE_END) then return false end
return Duel.GetCurrentPhase()==PHASE_BATTLE and Duel.GetCurrentChain()==0
and e:GetHandler():GetFlagEffect(9365703)~=0
end
function c9365703.daop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsFacedown() or not c:IsRelateToEffect(e) then return end
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SET_ATTACK_FINAL)
e1:SetValue(c:GetBaseAttack()*2)
e1:SetReset(RESET_EVENT+0x1ff0000+RESET_PHASE+PHASE_BATTLE)
c:RegisterEffect(e1)
end
| gpl-2.0 |
moody2020/TH3_BOSS | plugins/TH3BOSS4.lua | 4 | 1842 | --[[
▀▄ ▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀
▀▄ ▄▀ ▀▄ ▄▀
▀▄ ▄▀ BY MOHAMMED HISHAM ▀▄ ▄▀
▀▄ ▄▀ BY MOHAMMEDHISHAM (@TH3BOSS) ▀▄ ▄▀
▀▄ ▄▀ JUST WRITED BY MOHAMMED HISHAM ▀▄ ▄▀
▀▄ ▄▀ مساعدة4 ▀▄ ▄▀
▀▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀
--]]
do
function mohammed(msg, matches)
local reply_id = msg['id']
local S = [[
❗️ أوامر الحماية في المجموعة
➖🔹➖🔹➖🔹➖🔹➖🔹
▫️ قفل الفيديو :: لقفل الفيديو
▫️ قفل الصور :: لقفل الصور
▫️ قفل الصوت :: لقفل الصوت
▫️ قفل الوسائط :: لقفل الوسائط
▫️ قفل الملصقات :: لقفل الملصقات
▫️ قفل الصور المتحركة :: لقفل المتحركه
➖🔹➖🔹➖🔹➖🔹➖🔹
▫️ فتح الفيديو :: لفتح الفيديو
▫️ فتح الصور :: لفتح الصور
▫️ فتح الصوت :: لفتح الصوت
▫️ فتح الوسائط :: لفتح الوسائط
▫️ فتح الملصقات :: لفتح الملصقات
▫️ فتح الصور المتحركة :: لفتح التحركه
➖🔹➖🔹➖🔹➖🔹➖🔹
💯-Đєⱴ💀: @TH3BOSS
💯-Đєⱴ ฿๏ͳ💀: @ll60Kllbot
💯-Đєⱴ Ϲḫ₳ͷͷєℓ💀: @llDEV1ll
]]
reply_msg(reply_id, S, ok_cb, false)
end
return {
description = "Help list",
usage = "Help list",
patterns = {
"^(م4)$",
},
run = mohammed
}
end
| gpl-2.0 |
Lsty/ygopro-scripts | c37383714.lua | 5 | 1535 | --魂の綱
function c37383714.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_TO_GRAVE)
e1:SetCondition(c37383714.condition)
e1:SetCost(c37383714.cost)
e1:SetTarget(c37383714.target)
e1:SetOperation(c37383714.activate)
c:RegisterEffect(e1)
end
function c37383714.cfilter(c,tp)
return c:IsReason(REASON_EFFECT) and c:IsReason(REASON_DESTROY) and c:IsType(TYPE_MONSTER)
and c:GetPreviousControler()==tp and c:IsPreviousLocation(LOCATION_MZONE)
end
function c37383714.condition(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c37383714.cfilter,1,nil,tp)
end
function c37383714.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckLPCost(tp,1000) end
Duel.PayLPCost(tp,1000)
end
function c37383714.spfilter(c,e,tp)
return c:GetLevel()==4 and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c37383714.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c37383714.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function c37383714.activate(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,c37383714.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
end
| gpl-2.0 |
rigeirani/teshep | plugins/help.lua | 3 | 8499 |
local function run(msg, matches)
if matches[1] == 'admin' then
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
local message = 'Lista degli amministratori:\n\n'
for k,v in pairs(data[tostring(admins)]) do
message = message .. '- @' .. v .. ' [' .. k .. '] ' ..'\n'
end
return message
end
local service= 'Il comando di aiuto è molto lungo, ti è stato inviato in privato.\nSe non l\'hai ricevuto, allora scrivimi 12 messaggi (per aggirare lo spam reporting) e richiedi nuovamente su questo gruppo il messaggio di aiuto con /help'
local priv='COMANDI IN PRIVATO\n'
..'• /id : mostra il tuo id e quello del bot\n'
..'• /join [id] : fatti aggiungere al gruppo\n'
..'• /ping : verifica se il bot è in funzione\n'
..'• /contatta [testo] : contatta il proprietario del bot, se hai qualcosa da segnalare\n'
..'• /help : mostra questo messaggio\n'
..'\nHai aggiunto il bot ad un gruppo ma non funziona?\nQuesto perchè il gruppo non fa parte del suo indice. Chiedi ad un amministratore del bot (usa "/admin") di aggiungerlo per te'
local u='\nCOMANDI PER TUTTI\n'
..'• /regole : mostra le regole del gruppo\n'
..'• /about : mostra la descrizione del gruppo\n'
..'• /listamod : mostra l\'elenco dei moderatori di questo gruppo\n'
..'• /boss : mostra l\'id del proprietario del gruppo\n'
..'• /kickami : fatti rimuovere dal gruppo senza perdere messaggi e media\n'
..'• /id : mostra l\'id a risposta o l\'id del gruppo\n'
..'• /membri : mostra l\'elenco dei membri del Realm\n'
..'• /membrifile : mostra l\'elenco dei membri del realm sotto forma di file\n'
..'• /ping : verifica se il bot è in funzione\n'
..'• /join [id] : fatti aggiungere al gruppo\n'
..'• /help : mostra questo messaggio\n'
..'\nHai aggiunto il bot ad un gruppo ma non funziona?\nQuesto perchè il gruppo non fa parte del suo indice. Chiedi ad un amministratore del bot (usa "/admin") di aggiungerlo per te'
if msg.to.type == 'chat' then
local receiver='user#'..msg.from.id
send_large_msg('chat#'..msg.to.id, service, ok_cb, false)
local realm='COMANDI IN UN REALM\n'
..'• /creagruppo [nome] : crea un nuovo gruppo\n'
..'• /impostabout [id] [descrizione] : imposta la descrizione di un gruppo\n'
..'• /impostaregole [id] [regole] : imposta le regole di un gruppo\n'
..'• /nome [id] [nome] : imposta il nome di un gruppo\n'
..'• /[blocca|sblocca] [id] [nome|membri|foto|flood|bot|arabo] : blocca/sblocca nome/foto/membri/flood/bot/arabo di un gruppo\n'
..'• /info [id] : visualizza le impostazioni di un gruppo\n'
..'• /aggadmin [username|id] : promuovi ad amministratore del bot\n'
..'• /rimadmin [username|id] : rimuovi dagli amministratori del bot\n'
..'• /lista admin : mostra la lista degli amministratori del bot\n'
..'• /lista gruppi : mostra la lista dei gruppi amministrati dal Realm (file)\n'
..'• /log : mostra il log degli eventi del gruppo\n'
local ad='\nCOMANDI PER ADMIN\n'
..'Gli amministratori possono esercitare il loro potere nei Realm, hanno i poteri di moderatore ovunque ed inoltre:\n'
..'• /agg : aggiungi il gruppo all\'indice dei gruppi amministrati (da fare se il bot non ha creato il gruppo)\n'
..'• /rim : rimuovi il gruppo dall\'indice dei gruppi amministrati\n'
..'• /setgrprop [id x] [id y] : imposta y come proprietario del gruppo x\n'
..'• /block [id] : blocca l\'utente (il bot bloccherà l\'utente)\n'
..'• /sblock [id] : sblocca l\'utente (il bot sbloccherà l\'utente)\n'
..'• /bang [username|id|risposta] : banna l\'utente da tutti i gruppi amministrati da questo bot\n'
..'• /unbannag [username|id|risposta] : rimuovi l\'utente dall\'indice dei ban globali\n'
..'• /listaban [id] : mostra l\'elenco dei membri bannati dal gruppo\n'
..'• /listabang : mostra l\'elenco degli utenti bannati globalmente\n'
..'• /msg gruppo [id] : mostra le statistiche del gruppo\n'
..'• /msg bot : mostra le statistiche del bot\n'
local pr='COMANDI PER IL PROPRIETARIO (IN PRIVATO)\n'
..'• /tutto [id] : mostra tutte le informazioni sul gruppo\n'
..'• /cambiades [id] [descrizione] : cambia la descrizione del gruppo\n'
..'• /cambiaregole [id] [regole] : cambia le regole del gruppo\n'
..'• /cambianome [id] [nome] : cambia il nome del gruppo\n'
..'• /loggruppo [id] : mostra il log degli eventi rilevanti del gruppo\n'
..'• /owner [id x] banna [id y] : banna dal gruppo x l\'utente y\n'
..'• /owner [id x] unbanna [id y] : unbanna dal gruppo x l\'utente y\n'
..'• /owner [id x] kicka [id y] : kicka dal gruppo x l\'utente y\n'
..'• /owner [id] rim mod : rimuovi tutti i moderatori dal gruppo\n'
..'• /owner [id] rim regole : elimina le regole del gruppo\n'
..'• /owner [id] rim des : elimina la descrizione del gruppo\n'
..'• /owner [id] imflood : imposta la sensibilità del flood del gruppo\n'
..'• /owner [id] [blocca|sblocca] [nome|membri] : blocca/sblocca nome/membri\n'
..'• /owner [id] nuovo link : genera un nuovo link per il gruppo\n'
..'• /owner [id] mostra link : ricevi il link del gruppo\n\n'
..'Comandi che possono essere utilizzati dal proprietario di un gruppo per gestirlo in privato\n'
local prg='\nCOMANDI PER IL PROPRIETARIO (IN GRUPPO)\n'
..'Tutti i comandi disponibili ai moderatori, ed inoltre:\n'
..'• /spazza [membri|mod|regole|about] : elimina membri/moderatori/regole/descrizione\n'
..'• /setboss [id] : imposta il nuovo proprietario del gruppo\n'
..'• /tagga [messaggio] : tagga tutti i membri del gruppo in un messaggio\n'
..'• /kickanouser : rimuovi gli utenti senza uno username\n'
local mo='\nCOMANDI PER MODERATORI\n'
..'• /invita [username] : invita l\'utente nel gruppo\n'
..'• /nome [nome] : cambia il nome del gruppo\n'
..'• /foto : cambia la foto del gruppo (inviala dopo aver richiesto il comando sotto forma di immagine\n'
..'• /promuovi [id|username|risposta] : promuovi utente ad amministratore\n'
..'• /degrada [id|username|risposta] : rimuovi l\'utente dagli amministratori\n'
..'• /setta [regole|about] [regole|descrizione] : imposta le regole/la descrizione del gruppo\n'
..'• /[blocca|sblocca] [nome|membri|flood|arabo|bot] : blocca/sblocca il nome/impedisci l\'entrata di nuovi membri/attiva il blocco flood/rimuovi chi scrive caratteri arabi/impoedisci l\'aggiunta di bot\n'
..'• /setflood [5-20] : imposta la sensibiltà del kick per flood\n'
..'• /info : mostra le attuali impostazioni del gruppo\n'
..'• /nuovolink : genera un nuovo link e revoca quello precedente\n'
..'• /link : mostra il link del gruppo\n'
..'• /res [username|risposta] : mostra le info disponibili per quell\'utente\n'
..'• /banna [username|id|risposta] : banna l\'utente\n'
..'• /unbanna [username|id|risposta] : unbanna l\'utente\n'
..'• /kicka [username|id|risposta] : rimuovi l\'utente/banna [username|id|risposta] : banna l\'utente\n'
..'• /unbanna [username|id|risposta] : unbanna l\'utente\n'
..'• /kickainattivi [messaggi] : kicka gli utenti che hanno scritto meno messaggi del numero indicato. Se [messaggi] non è presente, verranno rimossi i membri che non hanno mai scritto\n'
..'• /salva [parola] [testo] : imposta una risposta personalizzata ad un comando\n'
..'• /get [parola] : mosta il testo associato a quella parola\n'
..'• /msg : mostra le statistiche del gruppo (file)\n'
..'• /msglista : mostra le statistiche del gruppo (messaggio)\n'
local help = ''
if is_realmM(msg) and not is_admin(msg) then
help = realm..prg..mo..u
elseif is_realmM(msg) and is_admin(msg) then
help = realm..ad..prg..mo..u
elseif is_admin(msg) and not is_realmM(msg) then
help = ad..prg..mo..u
elseif is_owner(msg) then
help = pr..prg..mo..u..'\n\n(non puoi usare i comandi per admin)'
elseif is_momod(msg) then
help = mo..u..'\n\n(non puoi usare i comandi per proprietario ed admin)'
else
help = u..'\n\n(non puoi usare i comandi per moderatori, proprietario ed admin)'
end
send_large_msg(receiver, help, ok_cb, false)
--send_msg('chat#'..msg.to.id, 'In privato ;)', ok_cb, false)
else
return priv
end
end
return {
description = "/help",
usage = "/help",
patterns = {
"^/help",
"^/(admin)"
},
run = run
}
| gpl-2.0 |
Lsty/ygopro-scripts | c65079854.lua | 3 | 3182 | --憎悪の棘
function c65079854.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(c65079854.target)
e1:SetOperation(c65079854.operation)
c:RegisterEffect(e1)
--Atk
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_EQUIP)
e2:SetCode(EFFECT_UPDATE_ATTACK)
e2:SetValue(600)
c:RegisterEffect(e2)
--Pierce
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_EQUIP)
e3:SetCode(EFFECT_PIERCE)
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(c65079854.eqlimit)
c:RegisterEffect(e4)
--battle
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e5:SetRange(LOCATION_SZONE)
e5:SetCode(EVENT_DAMAGE_CALCULATING)
e5:SetCondition(c65079854.indescon)
e5:SetOperation(c65079854.indesop)
c:RegisterEffect(e5)
local e6=Effect.CreateEffect(c)
e6:SetDescription(aux.Stringid(65079854,0))
e6:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e6:SetRange(LOCATION_SZONE)
e6:SetCode(EVENT_BATTLED)
e6:SetCondition(c65079854.adcon)
e6:SetOperation(c65079854.adop)
c:RegisterEffect(e6)
end
function c65079854.eqlimit(e,c)
return c:IsCode(73580471) or c:IsRace(RACE_PLANT)
end
function c65079854.filter(c)
return c:IsFaceup() and (c:IsCode(73580471) or c:IsRace(RACE_PLANT))
end
function c65079854.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c65079854.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c65079854.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,c65079854.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
function c65079854.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsFaceup() then
Duel.Equip(tp,c,tc)
end
end
function c65079854.indescon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():GetEquipTarget():GetBattleTarget()~=nil
end
function c65079854.indesop(e,tp,eg,ep,ev,re,r,rp)
local bc=e:GetHandler():GetEquipTarget():GetBattleTarget()
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e1:SetValue(1)
e1:SetReset(RESET_PHASE+PHASE_DAMAGE_CAL)
bc:RegisterEffect(e1,true)
end
function c65079854.adcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetAttacker()==e:GetHandler():GetEquipTarget() and Duel.GetAttackTarget()~=nil
end
function c65079854.adop(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
local bc=Duel.GetAttackTarget()
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(-600)
e1:SetReset(RESET_EVENT+0x1fe0000)
bc:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EFFECT_UPDATE_DEFENCE)
bc:RegisterEffect(e2)
end
| gpl-2.0 |
sagarwaghmare69/nn | RReLU.lua | 22 | 1197 | local ffi = require 'ffi'
local RReLU, parent = torch.class('nn.RReLU', 'nn.Module')
function RReLU:__init(l, u, ip)
parent.__init(self)
self.lower = l or 1/8
self.upper = u or 1/3
assert(self.lower <= self.upper and self.lower >= 0 and self.upper >= 0)
self.noise = torch.Tensor()
self.train = true
self.inplace = ip or false
end
function RReLU:updateOutput(input)
local gen = ffi.typeof('THGenerator**')(torch._gen)[0]
input.THNN.RReLU_updateOutput(
input:cdata(),
self.output:cdata(),
self.noise:cdata(),
self.lower,
self.upper,
self.train,
self.inplace,
gen
)
return self.output
end
function RReLU:updateGradInput(input, gradOutput)
input.THNN.RReLU_updateGradInput(
input:cdata(),
gradOutput:cdata(),
self.gradInput:cdata(),
self.noise:cdata(),
self.lower,
self.upper,
self.train,
self.inplace
)
return self.gradInput
end
function RReLU:__tostring__()
return string.format('%s (l:%f, u:%f)', torch.type(self), self.lower, self.upper)
end
function RReLU:clearState()
if self.noise then self.noise:set() end
return parent.clearState(self)
end
| bsd-3-clause |
openwrt/luci | applications/luci-app-radicale2/luasrc/model/cbi/radicale2/server.lua | 10 | 5336 | -- Licensed to the public under the Apache License 2.0.
local fs = require("nixio.fs")
local rad2 = require "luci.controller.radicale2"
local http = require("luci.http")
local m = Map("radicale2", translate("Radicale 2.x"),
translate("A lightweight CalDAV/CardDAV server"))
s = m:section(SimpleSection, translate("Radicale v2 Web UI"))
s.addremove = false
s.anonymous = true
o = s:option(DummyValue, "radicale2_webui_go", translate("Go to Radicale v2 Web UI"))
o.template = "cbi/raduigo"
o.section = "cbi-radicale2_webui"
local s = m:section(NamedSection, "server", "section", translate("Server Settings"))
s.addremove = true
s.anonymous = false
o.section = "cbi-radicale2_web_ui"
local lhttp = nil
local certificate_file = nil
local key_file = nil
local certificate_authority_file = nil
s:tab("general", translate("General Settings"))
s:tab("advanced", translate("Advanced Settings"))
lhttp = s:taboption("general", DynamicList, "host", translate("HTTP(S) Listeners (address:port)"))
lhttp.datatype = "list(ipaddrport(1))"
lhttp.placeholder = "127.0.0.1:5232"
o = s:taboption("advanced", Value, "max_connection", translate("Max Connections"), translate("Maximum number of simultaneous connections"))
o.rmempty = true
o.placeholder = 20
o.datatype = "uinteger"
o = s:taboption("advanced", Value, "max_content_length", translate("Max Content Length"), translate("Maximum size of request body (bytes)"))
o.rmempty = true
o.datatype = "uinteger"
o.placeholder = 100000000
o = s:taboption("advanced", Value, "timeout", translate("Timeout"), translate("Socket timeout (seconds)"))
o.rmempty = true
o.placeholder = 30
o.datatype = "uinteger"
sslon = s:taboption("general", Flag, "ssl", translate("SSL"), translate("Enable SSL connections"))
sslon.rmempty = true
sslon.default = o.disabled
sslon.formvalue = function(self, section)
if not rad2.pymodexists('ssl') then
return false
end
return Flag.formvalue(self, section)
end
cert_file = s:taboption("general", FileUpload, "certificate", translate("Certificate"))
cert_file.rmempty = true
cert_file:depends("ssl", true)
key_file = s:taboption("general", FileUpload, "key", translate("Private Key"))
key_file.rmempty = true
key_file:depends("ssl", true)
ca_file = s:taboption("general", FileUpload, "certificate_authority", translate("Client Certificate Authority"), translate("For verifying client certificates"))
ca_file.rmempty = true
ca_file:depends("ssl", true)
o = s:taboption("advanced", Value, "ciphers", translate("Allowed Ciphers"), translate("See python3-openssl documentation for available ciphers"))
o.rmempty = true
o:depends("ssl", true)
o = s:taboption("advanced", Value, "protocol", translate("Use Protocol"), translate("See python3-openssl documentation for available protocols"))
o.rmempty = true
o:depends("ssl", true)
o.placeholder = "PROTOCOL_TLSv1_2"
o = s:taboption("general", Button, "remove_conf",
translate("Remove configuration for certificate, key, and CA"),
translate("This permanently deletes the cert, key, and configuration to use same."))
o.inputstyle = "remove"
o:depends("ssl", true)
function o.write(self, section)
if cert_file:cfgvalue(section) and fs.access(cert_file:cfgvalue(section)) then fs.unlink(cert_file:cfgvalue(section)) end
if key_file:cfgvalue(section) and fs.access(key_file:cfgvalue(section)) then fs.unlink(key_file:cfgvalue(section)) end
if ca_file:cfgvalue(section) and fs.access(key_file:cfgvalue(section)) then fs.unlink(ca_file:cfgvalue(section)) end
self.map:del(section, "certificate")
self.map:del(section, "key")
self.map:del(section, "certificate_authority")
self.map:del(section, "protocol")
self.map:del(section, "ciphers")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "radicale2", "server"))
end
if not rad2.pymodexists('ssl') then
o = s:taboption("general", DummyValue, "sslnotpreset", translate("SSL not available"), translate("Install package python3-openssl to support SSL connections"))
end
o = s:taboption("advanced", Flag, "dns_lookup", translate("DNS Lookup"), translate("Lookup reverse DNS for clients for logging"))
o.rmempty = true
o.default = o.enabled
o = s:taboption("advanced", Value, "realm", translate("Realm"), translate("HTTP(S) Basic Authentication Realm"))
o.rmempty = true
o.placeholder = "Radicale - Password Required"
local s = m:section(NamedSection, "web", "section", translate("Web UI"))
s.addremove = true
s.anonymous = false
o = s:option(ListValue, "type", translate("Web UI Type"))
o:value("", "Default (Built-in)")
o:value("internal", "Built-in")
o:value("none", "None")
o.default = ""
o.rmempty = true
local s = m:section(NamedSection, "headers", "section", translate("Headers"), translate("HTTP(S) Headers"))
s.addremove = true
s.anonymous = false
o = s:option(Value, "cors", translate("CORS"), translate("Header: X-Access-Control-Allow-Origin"))
o.rmempty = true
o.placeholder = "*"
local s = m:section(NamedSection, "encoding", "section", translate("Document Encoding"))
s.addremove = true
s.anonymous = false
o = s:option(Value, "request", translate("Request"), translate("Encoding for responding to requests/events"))
o.rmempty = true
o.placeholder = "utf-8"
o = s:option(Value, "stock", translate("Storage"), translate("Encoding for storing local collections"))
o.rmempty = true
o.placeholder = "utf-8"
return m
| apache-2.0 |
kidaa/luafun | tests/basic.lua | 3 | 4699 | --------------------------------------------------------------------------------
-- iter
--------------------------------------------------------------------------------
--
-- Arrays
--
for _it, a in iter({1, 2, 3}) do print(a) end
--[[test
1
2
3
--test]]
for _it, a in iter(iter(iter({1, 2, 3}))) do print(a) end
--[[test
1
2
3
--test]]
for _it, a in wrap(wrap(iter({1, 2, 3}))) do print(a) end
--[[test
1
2
3
--test]]
for _it, a in wrap(wrap(ipairs({1, 2, 3}))) do print(a) end
--[[test
1
2
3
--test]]
for _it, a in iter({}) do print(a) end
--[[test
--test]]
for _it, a in iter(iter(iter({}))) do print(a) end
--[[test
--test]]
for _it, a in wrap(wrap(iter({}))) do print(a) end
--[[test
--test]]
for _it, a in wrap(wrap(ipairs({}))) do print(a) end
--[[test
--test]]
-- Check that ``iter`` for arrays is equivalent to ``ipairs``
local t = {1, 2, 3}
gen1, param1, state1 = iter(t):unwrap()
gen2, param2, state2 = ipairs(t)
print(gen1 == gen2, param1 == param2, state1 == state2)
--[[test
true true true
--test]]
-- Test that ``wrap`` do nothing for wrapped iterators
gen1, param1, state1 = iter({1, 2, 3})
gen2, param2, state2 = wrap(gen1, param1, state1):unwrap()
print(gen1 == gen2, param1 == param2, state1 == state2)
--[[test
true true true
--test]]
--
-- Maps
--
local t = {}
for _it, k, v in iter({ a = 1, b = 2, c = 3}) do t[#t + 1] = k end
table.sort(t)
for _it, v in iter(t) do print(v) end
--[[test
a
b
c
--test]]
local t = {}
for _it, k, v in iter(iter(iter({ a = 1, b = 2, c = 3}))) do t[#t + 1] = k end
table.sort(t)
for _it, v in iter(t) do print(v) end
--[[test
a
b
c
--test]]
for _it, k, v in iter({}) do print(k, v) end
--[[test
--test]]
for _it, k, v in iter(iter(iter({}))) do print(k, v) end
--[[test
--test]]
--
-- String
--
for _it, a in iter("abcde") do print(a) end
--[[test
a
b
c
d
e
--test]]
for _it, a in iter(iter(iter("abcde"))) do print(a) end
--[[test
a
b
c
d
e
--test]]
for _it, a in iter("") do print(a) end
--[[test
--test]]
for _it, a in iter(iter(iter(""))) do print(a) end
--[[test
--test]]
--
-- Custom generators
--
local function mypairs_gen(max, state)
if (state >= max) then
return nil
end
return state + 1, state + 1
end
local function mypairs(max)
return mypairs_gen, max, 0
end
for _it, a in iter(mypairs(10)) do print(a) end
--[[test
1
2
3
4
5
6
7
8
9
10
--test]]
--
-- Invalid values
--
for _it, a in iter(1) do print(a) end
--[[test
error: object 1 of type "number" is not iterable
--test]]
for _it, a in iter(1, 2, 3, 4, 5, 6, 7) do print(a) end
--[[test
error: object 1 of type "number" is not iterable
--test]]
--------------------------------------------------------------------------------
-- each
--------------------------------------------------------------------------------
each(print, {1, 2, 3})
--[[test
1
2
3
--test]]
each(print, iter({1, 2, 3}))
--[[test
1
2
3
--test]]
each(print, {})
--[[test
--test]]
each(print, iter({}))
--[[test
--test]]
local keys, vals = {}, {}
each(function(k, v)
keys[#keys + 1] = k
vals[#vals + 1] = v
end, { a = 1, b = 2, c = 3})
table.sort(keys)
table.sort(vals)
each(print, keys)
each(print, vals)
--[[test
a
b
c
1
2
3
--test]]
each(print, "abc")
--[[test
a
b
c
--test]]
each(print, iter("abc"))
--[[test
a
b
c
--test]]
print(for_each == each) -- an alias
--[[test
true
--test]]
print(foreach == each) -- an alias
--[[test
true
--test]]
--------------------------------------------------------------------------------
-- totable
--------------------------------------------------------------------------------
local tab = totable(range(5))
print(type(tab), #tab)
each(print, tab)
--[[test
table 5
1
2
3
4
5
--test]]
local tab = totable(range(0))
print(type(tab), #tab)
--[[test
table 0
--test]]
local tab = totable("abcdef")
print(type(tab), #tab)
each(print, tab)
--[[test
table 6
a
b
c
d
e
f
--test]]
local tab = totable({ 'a', {'b', 'c'}, {'d', 'e', 'f'}})
print(type(tab), #tab)
each(print, tab[1])
each(print, map(unpack, drop(1, tab)))
--[[test
table 3
a
b c
d e f
--test]]
--------------------------------------------------------------------------------
-- tomap
--------------------------------------------------------------------------------
local tab = tomap(zip(range(1, 7), 'abcdef'))
print(type(tab), #tab)
each(print, iter(tab))
--[[test
table 6
a
b
c
d
e
f
--test]]
local tab = tomap({a = 1, b = 2, c = 3})
print(type(tab), #tab)
local t = {}
for _it, k, v in iter(tab) do t[v] = k end
table.sort(t)
for k, v in ipairs(t) do print(k, v) end
--[[test
table 0
1 a
2 b
3 c
--test]]
local tab = tomap(enumerate("abcdef"))
print(type(tab), #tab)
each(print, tab)
--[[test
table 6
a
b
c
d
e
f
--test]]
| mit |
Lsty/ygopro-scripts | c73872164.lua | 3 | 1705 | --お家おとりつぶし
function c73872164.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,0x1e0)
e1:SetCost(c73872164.cost)
e1:SetTarget(c73872164.target)
e1:SetOperation(c73872164.activate)
c:RegisterEffect(e1)
end
function c73872164.cfilter(c)
return c:IsType(TYPE_SPELL) and c:IsDiscardable()
end
function c73872164.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c73872164.cfilter,tp,LOCATION_HAND,0,1,e:GetHandler()) end
Duel.DiscardHand(tp,c73872164.cfilter,1,1,REASON_COST+REASON_DISCARD)
end
function c73872164.filter(c)
return c:IsFaceup() and c:IsDestructable()
end
function c73872164.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) and c73872164.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c73872164.filter,tp,0,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,c73872164.filter,tp,0,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
end
function c73872164.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsFaceup() and Duel.Destroy(tc,REASON_EFFECT)~=0 then
Duel.BreakEffect()
local code=tc:GetCode()
local g=Duel.GetMatchingGroup(Card.IsCode,tp,0,LOCATION_HAND,nil,code)
local hg=Duel.GetFieldGroup(tp,0,LOCATION_HAND)
Duel.ConfirmCards(tp,hg)
if g:GetCount()>0 then
Duel.SendtoGrave(g,REASON_EFFECT)
end
Duel.ShuffleHand(1-tp)
end
end
| gpl-2.0 |
Mkalo/forgottenserver | data/actions/scripts/other/enchanting.lua | 1 | 7592 | local items = {
equipment = {
[2147] = { -- small ruby
[COMBAT_FIREDAMAGE] = {id = 2343, targetId = 2147} -- helmet of the ancients (enchanted)
},
[2383] = { -- spike sword
[COMBAT_FIREDAMAGE] = {id = 7744}, [COMBAT_ICEDAMAGE] = {id = 7763},
[COMBAT_EARTHDAMAGE] = {id = 7854}, [COMBAT_ENERGYDAMAGE] = {id = 7869}
},
[2391] = { -- war hammer
[COMBAT_FIREDAMAGE] = {id = 7758}, [COMBAT_ICEDAMAGE] = {id = 7777},
[COMBAT_EARTHDAMAGE] = {id = 7868}, [COMBAT_ENERGYDAMAGE] = {id = 7883}
},
[2423] = { -- clerical mace
[COMBAT_FIREDAMAGE] = {id = 7754}, [COMBAT_ICEDAMAGE] = {id = 7773},
[COMBAT_EARTHDAMAGE] = {id = 7864}, [COMBAT_ENERGYDAMAGE] = {id = 7879}
},
[2429] = { -- barbarian axe
[COMBAT_FIREDAMAGE] = {id = 7749}, [COMBAT_ICEDAMAGE] = {id = 7768},
[COMBAT_EARTHDAMAGE] = {id = 7859}, [COMBAT_ENERGYDAMAGE] = {id = 7874}
},
[2430] = { -- knight axe
[COMBAT_FIREDAMAGE] = {id = 7750}, [COMBAT_ICEDAMAGE] = {id = 7769},
[COMBAT_EARTHDAMAGE] = {id = 7860}, [COMBAT_ENERGYDAMAGE] = {id = 7875}
},
[2445] = { -- crystal mace
[COMBAT_FIREDAMAGE] = {id = 7755}, [COMBAT_ICEDAMAGE] = {id = 7774},
[COMBAT_EARTHDAMAGE] = {id = 7865}, [COMBAT_ENERGYDAMAGE] = {id = 7880}
},
[2454] = { -- war axe
[COMBAT_FIREDAMAGE] = {id = 7753}, [COMBAT_ICEDAMAGE] = {id = 7772},
[COMBAT_EARTHDAMAGE] = {id = 7863}, [COMBAT_ENERGYDAMAGE] = {id = 7878}
},
[7380] = { -- headchopper
[COMBAT_FIREDAMAGE] = {id = 7752}, [COMBAT_ICEDAMAGE] = {id = 7771},
[COMBAT_EARTHDAMAGE] = {id = 7862}, [COMBAT_ENERGYDAMAGE] = {id = 7877}
},
[7383] = { -- relic sword
[COMBAT_FIREDAMAGE] = {id = 7745}, [COMBAT_ICEDAMAGE] = {id = 7764},
[COMBAT_EARTHDAMAGE] = {id = 7855}, [COMBAT_ENERGYDAMAGE] = {id = 7870}
},
[7384] = { -- mystic blade
[COMBAT_FIREDAMAGE] = {id = 7746}, [COMBAT_ICEDAMAGE] = {id = 7765},
[COMBAT_EARTHDAMAGE] = {id = 7856}, [COMBAT_ENERGYDAMAGE] = {id = 7871}
},
[7389] = { -- heroic axe
[COMBAT_FIREDAMAGE] = {id = 7751}, [COMBAT_ICEDAMAGE] = {id = 7770},
[COMBAT_EARTHDAMAGE] = {id = 7861}, [COMBAT_ENERGYDAMAGE] = {id = 7876}
},
[7392] = { -- orcish maul
[COMBAT_FIREDAMAGE] = {id = 7757}, [COMBAT_ICEDAMAGE] = {id = 7776},
[COMBAT_EARTHDAMAGE] = {id = 7867}, [COMBAT_ENERGYDAMAGE] = {id = 7882}
},
[7402] = { -- dragon slayer
[COMBAT_FIREDAMAGE] = {id = 7748}, [COMBAT_ICEDAMAGE] = {id = 7767},
[COMBAT_EARTHDAMAGE] = {id = 7858}, [COMBAT_ENERGYDAMAGE] = {id = 7873}
},
[7406] = { -- blacksteel sword
[COMBAT_FIREDAMAGE] = {id = 7747}, [COMBAT_ICEDAMAGE] = {id = 7766},
[COMBAT_EARTHDAMAGE] = {id = 7857}, [COMBAT_ENERGYDAMAGE] = {id = 7872}
},
[7415] = { -- cranial basher
[COMBAT_FIREDAMAGE] = {id = 7756}, [COMBAT_ICEDAMAGE] = {id = 7775},
[COMBAT_EARTHDAMAGE] = {id = 7866}, [COMBAT_ENERGYDAMAGE] = {id = 7881}
},
[8905] = { -- rainbow shield
[COMBAT_FIREDAMAGE] = {id = 8906}, [COMBAT_ICEDAMAGE] = {id = 8907},
[COMBAT_EARTHDAMAGE] = {id = 8909}, [COMBAT_ENERGYDAMAGE] = {id = 8908}
},
[10022] = { -- worn firewalker boots
[COMBAT_FIREDAMAGE] = {id = 9933, say = {text = "Take the boots off first."}},
slot = {type = CONST_SLOT_FEET, check = true}
},
[24716] = { -- werewolf amulet
[COMBAT_NONE] = {
id = 24717,
effects = {failure = CONST_ME_POFF, success = CONST_ME_THUNDER},
message = {text = "The amulet cannot be enchanted while worn."}
},
slot = {type = CONST_SLOT_NECKLACE, check = true}
},
[24718] = { -- werewolf helmet
[COMBAT_NONE] = {
id = {
[SKILL_CLUB] = {id = 24783},
[SKILL_SWORD] = {id = 24783},
[SKILL_AXE] = {id = 24783},
[SKILL_DISTANCE] = {id = 24783},
[SKILL_MAGLEVEL] = {id = 24783}
},
effects = {failure = CONST_ME_POFF, success = CONST_ME_THUNDER},
message = {text = "The helmet cannot be enchanted while worn."},
usesStorage = true
},
slot = {type = CONST_SLOT_HEAD, check = true}
},
charges = 1000, effect = CONST_ME_MAGIC_RED
},
valuables = {
[2146] = {id = 7759, shrine = {7508, 7509, 7510, 7511}}, -- small sapphire
[2147] = {id = 7760, shrine = {7504, 7505, 7506, 7507}}, -- small ruby
[2149] = {id = 7761, shrine = {7516, 7517, 7518, 7519}}, -- small emerald
[2150] = {id = 7762, shrine = {7512, 7513, 7514, 7515}}, -- small amethyst
soul = 2, mana = 300, effect = CONST_ME_HOLYDAMAGE
},
[2342] = {combatType = COMBAT_FIREDAMAGE, targetId = 2147}, -- helmet of the ancients
[7759] = {combatType = COMBAT_ICEDAMAGE}, -- small enchanted sapphire
[7760] = {combatType = COMBAT_FIREDAMAGE}, -- small enchanted ruby
[7761] = {combatType = COMBAT_EARTHDAMAGE}, -- small enchanted emerald
[7762] = {combatType = COMBAT_ENERGYDAMAGE}, -- small enchanted amethyst
[24739] = {combatType = COMBAT_NONE} -- moonlight crystals
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not target or not target:isItem() then
return false
end
local itemId, targetId = item:getId(), target:getId()
local targetType = items.valuables[itemId] or items.equipment[items[itemId].targetId or targetId]
if not targetType then
return false
end
if targetType.shrine then
if not isInArray(targetType.shrine, targetId) then
player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return true
end
if player:getMana() < items.valuables.mana then
player:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA)
return true
end
if player:getSoul() < items.valuables.soul then
player:sendCancelMessage(RETURNVALUE_NOTENOUGHSOUL)
return true
end
player:addSoul(-items.valuables.soul)
player:addMana(-items.valuables.mana)
player:addManaSpent(items.valuables.mana * configManager.getNumber(configKeys.RATE_MAGIC))
player:addItem(targetType.id)
player:getPosition():sendMagicEffect(items.valuables.effect)
item:remove(1)
else
local targetItem = targetType[items[itemId].combatType]
if not targetItem or targetItem.targetId and targetItem.targetId ~= targetId then
return false
end
local isInSlot = targetType.slot and targetType.slot.check and target:getType():usesSlot(targetType.slot.type) and Player(target:getParent())
if isInSlot then
if targetItem.say then
player:say(targetItem.say.text, TALKTYPE_MONSTER_SAY)
return true
elseif targetItem.message then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, targetItem.message.text)
else
return false
end
else
if targetItem.targetId then
item:transform(targetItem.id)
item:decay()
target:remove(1)
else
if targetItem.usesStorage then
local vocationId = player:getVocation():getDemotion():getId()
local storage = storages[itemId] and storages[itemId][targetId] and storages[itemId][targetId][vocationId]
if not storage then
return false
end
local storageValue = player:getStorageValue(storage.key)
if storageValue == -1 then
return false
end
local transform = targetItem.id and targetItem.id[storageValue]
if not transform then
return false
end
target:transform(transform.id)
else
target:transform(targetItem.id)
end
if target:hasAttribute(ITEM_ATTRIBUTE_DURATION) then
target:decay()
end
if target:hasAttribute(ITEM_ATTRIBUTE_CHARGES) then
target:setAttribute(ITEM_ATTRIBUTE_CHARGES, items.equipment.charges)
end
item:remove(1)
end
end
player:getPosition():sendMagicEffect(targetItem.effects and (isInSlot and targetItem.effects.failure or targetItem.effects.success) or items.equipment.effect)
end
return true
end
| gpl-2.0 |
gallenmu/MoonGen | libmoon/lua/lib/turbo/turbo/platform.lua | 11 | 1395 | --- Turbo.lua C Platform / OS variables.
--
-- Copyright 2014 John Abrahamsen
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
local ffi = require "ffi"
local uname = ""
if not ffi.abi("win") then
uname = (function()
local f = io.popen("uname")
local l = f:read("*a")
f:close()
return l
end)()
end
return {
__WINDOWS__ = ffi.abi("win"),
__UNIX__ = uname:match("Unix") or uname:match("Linux") or
uname:match("Darwin") and true or false,
__LINUX__ = uname:match("Linux") and true or false,
__DARWIN__ = uname:match("Darwin") and true or false,
__ABI32__ = ffi.abi("32bit"),
__ABI64__ = ffi.abi("64bit"),
__X86__ = ffi.arch == "x86",
__X64__ = ffi.arch == "x64",
__PPC__ = ffi.arch == "ppc",
__PPC64__ = ffi.arch == "ppc64le",
__ARM__ = ffi.arch == "arm",
__MIPSEL__ = ffi.arch == "mipsel",
}
| mit |
marktsai0316/nodemcu-firmware | lua_examples/onewire-ds18b20.lua | 60 | 1505 | --'
-- 18b20 one wire example for NODEMCU
-- NODEMCU TEAM
-- LICENCE: http://opensource.org/licenses/MIT
-- Vowstar <vowstar@nodemcu.com>
--'
pin = 9
ow.setup(pin)
count = 0
repeat
count = count + 1
addr = ow.reset_search(pin)
addr = ow.search(pin)
tmr.wdclr()
until((addr ~= nil) or (count > 100))
if (addr == nil) then
print("No more addresses.")
else
print(addr:byte(1,8))
crc = ow.crc8(string.sub(addr,1,7))
if (crc == addr:byte(8)) then
if ((addr:byte(1) == 0x10) or (addr:byte(1) == 0x28)) then
print("Device is a DS18S20 family device.")
repeat
ow.reset(pin)
ow.select(pin, addr)
ow.write(pin, 0x44, 1)
tmr.delay(1000000)
present = ow.reset(pin)
ow.select(pin, addr)
ow.write(pin,0xBE,1)
print("P="..present)
data = nil
data = string.char(ow.read(pin))
for i = 1, 8 do
data = data .. string.char(ow.read(pin))
end
print(data:byte(1,9))
crc = ow.crc8(string.sub(data,1,8))
print("CRC="..crc)
if (crc == data:byte(9)) then
t = (data:byte(1) + data:byte(2) * 256) * 625
t1 = t / 10000
t2 = t % 10000
print("Temperature= "..t1.."."..t2.." Centigrade")
end
tmr.wdclr()
until false
else
print("Device family is not recognized.")
end
else
print("CRC is not valid!")
end
end
| mit |
MalRD/darkstar | scripts/globals/teleports.lua | 8 | 29578 | -----------------------------------
-- A collection of frequently needed teleport shortcuts.
-----------------------------------
require("scripts/globals/settings")
require("scripts/globals/zone")
dsp = dsp or {}
dsp.teleport = dsp.teleport or {}
-----------------------------------
-- TELEPORT IDS
-----------------------------------
local ids =
{
DEM = 1,
HOLLA = 2,
YHOAT = 3,
VAHZL = 4,
MEA = 5,
ALTEP = 6,
WARP = 7,
ESCAPE = 8,
JUGNER = 9,
PASHH = 10,
MERIPH = 11,
AZOUPH = 12,
BHAFLAU = 13,
ZHAYOLM = 14,
DVUCCA = 15,
REEF = 16,
ALZADAAL = 17,
CUTTER = 18,
Z_REM = 19,
A_REM = 20,
B_REM = 21,
S_REM = 22,
MAAT = 23,
OUTPOST = 24,
LEADER = 25,
EXITPROMMEA = 26,
EXITPROMHOLLA = 27,
EXITPROMDEM = 28,
LUFAISE = 29,
CHOCO_WINDURST = 30,
CHOCO_SANDORIA = 31,
CHOCO_BASTOK = 32,
DUCALGUARD = 33,
PURGONORGO = 34,
AZOUPH_SP = 35,
DVUCCA_SP = 36,
MAMOOL_SP = 37,
HALVUNG_SP = 38,
ILRUSI_SP = 39,
NYZUL_SP = 40,
SKY = 41,
CLOISTER_OF_FLAMES = 42,
CLOISTER_OF_FROST = 43,
CLOISTER_OF_GALES = 44,
CLOISTER_OF_STORMS = 45,
CLOISTER_OF_TIDES = 46,
CLOISTER_OF_TREMORS = 47,
GHELSBA_HUT = 48,
WAJAOM_LEYPOINT = 49,
VALKURM_VORTEX = 50,
QUFIM_VORTEX = 51,
LUFAISE_VORTEX = 52,
MISAREAUX_VORTEX = 53,
MINESHAFT = 54,
WHITEGATE = 55,
SEA = 56,
HOME_NATION = 57,
CHOCO_UPPER_JEUNO = 58,
ZVAHL_KEEP = 59
}
dsp.teleport.id = ids
-----------------------------------
-- TELEPORT TO SINGLE DESTINATION
-----------------------------------
local destinations =
{
[ids.DEM] = { 220.000, 19.104, 300.000, 0, 108}, -- {R}
[ids.HOLLA] = { 420.000, 19.104, 20.000, 0, 102}, -- {R}
[ids.YHOAT] = {-280.942, 0.596, -144.156, 0, 124}, -- {R}
[ids.VAHZL] = { 150.258, -21.048, -37.256, 94, 112}, -- {R}
[ids.MEA] = { 100.000, 35.151, 340.000, 0, 117}, -- {R}
[ids.ALTEP] = { -61.942, 3.949, 224.900, 0, 114}, -- {R}
[ids.JUGNER] = {-122.862, 0.000, -163.154, 192, 82}, -- {R}
[ids.PASHH] = { 345.472, 24.280, -114.731, 99, 90}, -- {R}
[ids.MERIPH] = { 305.989, -14.978, 18.960, 192, 97}, -- {R}
[ids.AZOUPH] = { 495.450, -28.250, -478.430, 32, 79}, -- {R}
[ids.BHAFLAU] = {-172.863, -12.250, -801.021, 128, 52}, -- {R}
[ids.ZHAYOLM] = { 681.950, -24.000, 369.936, 64, 61}, -- {R}
[ids.DVUCCA] = {-252.715, -7.666, -30.640, 128, 79}, -- {R}
[ids.REEF] = { 9.304, -7.376, 620.133, 0, 54}, -- {R}
[ids.ALZADAAL] = { 180.000, 0.000, 20.000, 0, 72}, -- {R}
[ids.CUTTER] = {-456.000, -3.000, -405.000,-405, 54},
[ids.A_REM] = {-579.000, -0.050, -100.000, 192, 72},
[ids.B_REM] = { 620.000, 0.000, -260.640, 72, 72}, -- {R}
[ids.S_REM] = { 580.000, 0.000, 500.000, 192, 72}, -- {R}
-- [ids.Z_REM] = { 000.000, 0.000, 000.000, 000, 72},
[ids.MAAT] = { 11.000, 3.000, 117.000, 0, 243},
[ids.EXITPROMMEA] = { 179.000, 35.000, 256.000, 63, 117},
[ids.EXITPROMHOLLA] = { 337.000, 19.000, -60.000, 125, 102},
[ids.EXITPROMDEM] = { 136.000, 19.000, 220.000, 130, 108},
[ids.LUFAISE] = { 438.000, 0.000, -18.000, 11, 24},
[ids.CHOCO_SANDORIA] = { -8.557, 1.999, -80.093, 64, 230}, -- {R}
[ids.CHOCO_BASTOK] = { 40.164, 0.000, -83.578, 64, 234}, -- {R}
[ids.CHOCO_WINDURST] = { 113.355, -5.000, -133.118, 0, 241}, -- {R}
[ids.CHOCO_UPPER_JEUNO] = { -44.000, 7.900, 98.000, 170, 244},
[ids.DUCALGUARD] = { 48.930, 10.002, -71.032, 195, 243},
[ids.PURGONORGO] = {-398.689, -3.038, -415.835, 0, 4}, -- {R}
[ids.AZOUPH_SP] = { 522.730, -28.009, -502.621, 161, 79}, -- {R}
[ids.DVUCCA_SP] = {-265.632, -6.000, -29.472, 94, 79}, -- {R}
[ids.MAMOOL_SP] = {-210.291, -11.500, -818.056, 255, 52}, -- {R}
[ids.HALVUNG_SP] = { 688.994, -23.960, 351.496, 191, 61}, -- {R}
[ids.ILRUSI_SP] = { 17.540, -7.250, 627.968, 254, 54}, -- {R}
[ids.NYZUL_SP] = { 222.798, -0.500, 19.872, 0, 72}, -- {R}
[ids.SKY] = {-134.145, -32.328, -205.947, 215, 130}, -- {R}
[ids.CLOISTER_OF_FLAMES] = {-716.461, 0.407, -606.661, 168, 207}, -- {R}
[ids.CLOISTER_OF_FROST] = { 550.403, 0.006, 584.820, 217, 203}, -- {R}
[ids.CLOISTER_OF_GALES] = {-374.919, 0.628, -386.774, 226, 201}, -- {R}
[ids.CLOISTER_OF_STORMS] = { 540.853, -13.329, 511.298, 82, 202}, -- {R}
[ids.CLOISTER_OF_TIDES] = { 570.294, 36.757, 546.895, 167, 211}, -- {R}
[ids.CLOISTER_OF_TREMORS] = {-540.269, 1.396, -509.800, 192, 209}, -- {R}
[ids.GHELSBA_HUT] = {-156.000, -10.000, 80.000, 119, 140},
[ids.WAJAOM_LEYPOINT] = {-200.116, -10.000, 79.879, 213, 51}, -- {R}
[ids.VALKURM_VORTEX] = { 420.062, 0.000, -199.904, 87, 103}, -- {R}
[ids.QUFIM_VORTEX] = {-436.000, -13.499, 340.117, 107, 126}, -- {R}
[ids.LUFAISE_VORTEX] = { 458.847, 7.999, 5.519, 72, 24}, -- {R}
[ids.MISAREAUX_VORTEX] = {-118.000, -32.000, 219.000, 3, 25}, -- {R}
[ids.MINESHAFT] = { -93.657, -120.000, -583.561, 0, 13}, -- (R)
[ids.WHITEGATE] = { 27.424, -6.000, -123.792, 192, 50}, -- {R}
[ids.SEA] = { -31.800, 0.000, -618.700, 190, 33}, -- {R}
[ids.ZVAHL_KEEP] = {-555.996, -70.100, 59.989, 0, 162}
}
dsp.teleport.type =
{
OUTPOST_SANDORIA = 0,
OUTPOST_BASTOK = 1,
OUTPOST_WINDURST = 2,
RUNIC_PORTAL = 3,
PAST_MAW = 4,
ABBYSEA_MAW = 5,
CAMPAIGN_SANDORIA = 6,
CAMPAIGN_BASTOK = 7,
CAMPAIGN_WINDURST = 8,
HOMEPOINT = 9,
SURVIVAL = 10
}
dsp.teleport.runic_portal =
{
AZOUPH = 1,
DVUCCA = 2,
MAMOOL = 3,
HALVUNG = 4,
ILRUSI = 5,
NYZUL = 6,
}
dsp.teleport.to = function(player, destination)
local dest = destinations[destination]
if dest then
player:setPos(unpack(dest))
end
end
-----------------------------------
-- TELEPORT TO PARTY LEADER
-----------------------------------
dsp.teleport.toLeader = function(player)
local leader = player:getPartyLeader()
if leader ~= nil and not leader:isInMogHouse() then
player:gotoPlayer(leader:getName())
end
end
-----------------------------------
-- TELEPORT TO CAMPAIGN DESTINATION
-----------------------------------
local campaignDestinations =
{
[ 1] = { 205.973, -23.587, -206.606, 167, 137}, -- {R} {R} Xarcabard [S]
[ 2] = { -46.172, -60.109, -38.487, 16, 136}, -- {R} Beaucedine Glacier [S]
[ 3] = { 306.939, -1.000, -141.567, 173, 84}, -- {R} Batallia Downs [S]
[ 4] = { -4.701, 15.982, 235.996, 160, 91}, -- {R} Rolanberry Fields [S]
[ 5] = { -64.212, 7.625, -51.292, 192, 98}, -- {R} Sauromugue Champaign [S]
[ 6] = { 60.617, -3.949, 56.658, 64, 82}, -- {R} Jugner Forest [S]
[ 7] = { 504.088, 24.511, 628.360, 69, 90}, -- {R} Pashhow Marshlands [S]
[ 8] = {-447.084, 23.433, 586.847, 31, 97}, -- {R} Meriphataud Mountains [S]
[ 9] = { -77.817, -47.234, -302.732, 135, 83}, -- {R} Vunkerl Inlet [S]
[10] = { 314.335, -36.368, -12.200, 192, 89}, -- {R} Grauberg [S]
[11] = { 141.021, -45.000, 19.543, 0, 96}, -- {R} Fort Karugo-Narugo [S]
[12] = { 183.297, -19.971, -240.895, 2, 81}, -- {R} East Ronfaure [S]
[13] = {-441.332, 40.000, -77.986, 164, 88}, -- {R} North Gustaberg [S]
[14] = {-104.707, -21.838, 258.043, 237, 95}, -- {R} West Sarutabaruta [S]
[15] = { -98.000, 1.000, -41.000, 224, 80}, -- Southern San d'Oria [S]
[16] = {-291.000, -10.000, -107.000, 212, 87}, -- Bastok Markets [S]
[17] = { -31.442, -5.000, 129.202, 128, 94}, -- {R} Windurst Waters [S}
[18] = {-194.095, 0.000, 30.009, 0, 164}, -- {R} Garlaige Citdadel [S]
[19] = { 59.213, -32.158, -38.022, 64, 171}, -- {R} Crawler's Nest [S]
[20] = { 294.350, -27.500, 19.947, 0, 175}, -- {R} The Eldieme Necropolis [S]
}
dsp.teleport.toCampaign = function(player, option)
local dest = campaignDestinations[option]
if dest then
player:setPos(unpack(dest))
end
end
-- TODO: Abyessa Maws:
-- Tahrongi Canyon (H-12)
-- Konschtat Highlands (I-12)
-- La Theine Plateau (E-4)
-- Valkurm Dunes (I-9)
-- Jugner Forest (J-8)
-- Buburimu Peninsula (F-7)
-- South Gustaberg (J-10)
-- North Gustaberg (G-6)
-- Xarcabard (H-8)
-----------------------------------
-- TELEPORT TO REGIONAL OUTPOST
-----------------------------------
local outpostDestinations =
{
[dsp.region.RONFAURE] = {-437.688, -20.255, -219.227, 124, 100}, -- Ronfaure {R}
[dsp.region.ZULKHEIM] = { 148.231, -7.975, 93.479, 154, 103}, -- Zulkheim {R}
[dsp.region.NORVALLEN] = { 62.030, 0.463, -2.025, 67, 104}, -- Norvallen {R}
[dsp.region.GUSTABERG] = {-580.161, 39.578, 62.680, 89, 106}, -- Gustaberg {R}
[dsp.region.DERFLAND] = { 465.820, 23.625, 423.164, 29, 109}, -- Derfland {R}
[dsp.region.SARUTABARUTA] = { -17.921, -13.335, 318.156, 254, 115}, -- Sarutabaruta {R}
[dsp.region.KOLSHUSHU] = {-480.237, -30.943, 58.079, 62, 118}, -- Kolshushu {R}
[dsp.region.ARAGONEU] = {-297.047, 16.988, 418.026, 225, 119}, -- Aragoneu {R}
[dsp.region.FAUREGANDI] = { -18.690, -60.048, -109.243, 100, 111}, -- Fauregandi {R}
[dsp.region.VALDEAUNIA] = { 211.210, -24.016, -207.338, 160, 112}, -- Valdeaunia {R}
[dsp.region.QUFIMISLAND] = {-243.049, -19.983, 306.712, 71, 126}, -- Qufim Island {R}
[dsp.region.LITELOR] = { -37.669, 0.419, -141.216, 69, 121}, -- Li'Telor {R}
[dsp.region.KUZOTZ] = {-249.983, 7.965, -252.976, 122, 114}, -- Kuzotz {R}
[dsp.region.VOLLBOW] = {-176.360, 7.624, -63.580, 122, 113}, -- Vollbow {R}
[dsp.region.ELSHIMOLOWLANDS] = {-240.860, -0.031, -388.434, 64, 123}, -- Elshimo Lowlands {R}
[dsp.region.ELSHIMOUPLANDS] = { 207.821, -0.128, -86.623, 159, 124}, -- Elshimo Uplands {R}
[dsp.region.TULIA] = { 4.000, -54.000, -600.000, 192, 130}, -- Tu'Lia (can't acquire on retail, but exists in NCP event menu)
[dsp.region.TAVNAZIANARCH] = {-535.861, -7.149, -53.628, 122, 24}, -- Tavnazia {R}
}
dsp.teleport.toOutpost = function(player, region)
local dest = outpostDestinations[region]
player:setPos(unpack(dest))
end
-----------------------------------
-- TELEPORT TO HOME NATION
-----------------------------------
dsp.teleport.toHomeNation = function(player)
local pNation = player:getNation()
if pNation == dsp.nation.BASTOK then
player:setPos(89, 0 , -66, 0, 234)
elseif pNation == dsp.nation.SANDORIA then
player:setPos(49, -1 , 29, 164, 231)
else
player:setPos(193, -12 , 220, 64, 240)
end
end
-----------------------------------
-- TELEPORT TO CHAMBER OF PASSAGE
-----------------------------------
dsp.teleport.toChamberOfPassage = function(player)
if math.random(1,2) == 1 then
player:setPos(133.400, 1.485, 47.427, 96, 50) -- {R} Aht Urhgan Whitegate Chamber of Passage Left
else
player:setPos(116.670, 1.485, 47.427, 32, 50) -- {R} Aht Urhgan Whitegate Chamber of Passage Right
end
end
-----------------------------------
-- TELEPORT TO EXPLORER MOOGLE
-----------------------------------
dsp.teleport.toExplorerMoogle = function(player, zone)
if zone == 231 then
player:setPos(39.4, -0.2, 25, 253, zone) -- Northern_San_d'Oria
elseif zone == 234 then
player:setPos(76.82, 0, -66.12, 232, zone) -- Bastok_Mines
elseif zone == 240 then
player:setPos(185.6, -12, 223.5, 96, zone) -- Port_Windurst
elseif zone == 248 then
player:setPos(14.67, -14.56, 66.69, 96, zone) -- Selbina
elseif zone == 249 then
player:setPos(2.87, -4, 71.95, 0, zone) -- Mhaura
end
end
-----------------------------------
-- CAST ESCAPE SPELL
-----------------------------------
dsp.teleport.escape = function(player)
local zone = player:getZoneID()
-- Ronfaure {R}
if zone == 139 or zone == 140 or zone == 141 or zone == 142 then -- From Ghelsba Outpost, Fort Ghelsba, Yughott Grotto, Horlais Peak
player:setPos(-720,-61,600,64,100) -- To West Ronfaure at E-4
elseif zone == 167 then -- From Bostaunieux Oubliette
player:setPos(-685,-30,18,0,100) -- To West Ronfaure at F-8
elseif zone == 190 then -- From King Ranperre's Tomb
player:setPos(203,-1,-521,192,101) -- To East Ronfaure at H-11
-- Valdeaunia {R}
elseif zone == 162 or zone == 161 or zone == 165 then -- From Castle Zvahl Keep, Castle Zvahl Baileys, Throne Room
player:setPos(-414,-44,19,0,112) -- To Xarcabard at G-7
-- Norvallen {R}
elseif zone == 195 then -- From The Eldieme Necropolis
player:setPos(382.398,7.314,-106.298,160,105) -- To Batallia Downs at F-8
elseif zone == 149 or zone == 150 then -- From Davoi or Monastic Cavern
player:setPos(-232,-8,-562,0,104) -- To Jugner Forest at G-12
-- Fauregandi {R}
elseif zone == 166 then -- From Ranguemont Pass
player:setPos(803,-61,635,128,101) -- To East Ronfaure at K-4
elseif zone == 9 or zone == 10 then -- From Pso'Xja, The Shrouded Maw
player:setPos(-427,-41,-422,0,111) -- To Beaucedine Glacier at E-11
elseif zone == 204 or zone == 206 or zone == 203 then -- From Fei'Yin, Qu'Bia Arena, Cloister of Frost
player:setPos(279,19,536,64,111) -- To Beaucedine Glacier at J-5
-- Derfland {R}
elseif zone == 197 then -- From Crawlers' Nest
player:setPos(-356,-24,-763,192,110) -- To Rolanberry Fields at F-13
elseif zone == 148 or zone == 147 then -- From Qulun Dome, Beadeaux
player:setPos(557,24,-385,192,109) -- To Pashhow Marshlands at K-11
-- Emptiness {R}
elseif zone == 16 or zone == 17 then -- From Promyvion-Holla, Spire of Holla
player:setPos(332,24,-148,96,102) -- To La Theine Plateau at J-9
elseif zone == 18 or zone == 19 then -- From Promyvion-Dem, Spire of Dem
player:setPos(134,24,134,96,108) -- To Konschtat Highlands at I-7
elseif zone == 20 or zone == 21 then -- From Promyvion-Mea, Spire of Mea
player:setPos(266,40,254,32,117) -- To Tahrongi Canyon at J-6
elseif zone == 22 or zone == 23 then -- From Promyvion-Vahzl, Spire of Vahzl
player:setPos(-331,-100,128,32,111) -- To Beaucedine Glacier at F-7
-- Qufim Island {R}
elseif zone == 157 or zone == 158 or zone == 184 or zone == 179 then -- From Delkfutt's Tower: Middle, Upper, Lower, Stellar Fulcrum
player:setPos(-267,-20,320,0,126) -- To Qufim Island at F-6
-- Tu'Lia {R}
elseif zone == 177 or zone == 178 or zone == 180 or zone == 181 then -- From Ve'Lugannon Palace, Shrine of Ru'Avitau, LaLoff Amphitheater, The Celestial Nexus
player:setPos(0,-35,-472,192,130) -- To Ru'Aun Gardens at H-11
-- Li'Telor {R}
elseif zone == 153 or zone == 154 or zone == 202 then -- From The Boyahda Tree, Dragon's Aery, Cloister of Storms
player:setPos(509.5,1,-575,128,121) -- To The Sanctuary of Zi'Tah at K-12
-- Aragonau {R}
elseif zone == 200 then -- From Garlaige Citadel
player:setPos(-112,-24,-403,192,120) -- To Sauromugue Champaign at H-10
elseif zone == 152 or zone == 151 then -- From Altar Room, Castle Oztroja
player:setPos(718,-31,-63,128,119) -- To Meriphataud Mountains at L-8
-- Kolshushu {R}
elseif zone == 213 then -- From Labyrinth of Onzozo
player:setPos(447,18,191,32,118) -- To Buburimu Peninsula at K-6
elseif zone == 198 then -- From Maze of Shakhrami
player:setPos(446,46,481,128,117) -- To Tahrongi Canyon at K-5
-- Sarutabaruta {R}
elseif zone == 169 or zone == 192 or zone == 194 or zone == 170 then -- From Toraimarai Canal, Inner Horutoto Ruins, Outer Horutoto Ruins, Full Moon Fountain
player:setPos(366,-13,92,128,116) -- To East Sarutabaruta at J-7
elseif zone == 145 or zone == 146 then -- From Giddeus, Balgas Dais
player:setPos(-360,-20,78,192,115) -- To West Sarutabaruta at F-8
-- Elshimo Uplands {R}
elseif zone == 159 or zone == 160 or zone == 163 or zone == 211 then -- From Temple of Uggalepih, Den of Rancor, Sacrificial Chamber, Cloister of Tides
player:setPos(298,-2,-445,192,124) -- To Yhoator Jungle at J-11
elseif zone == 205 or zone == 207 then -- From Ifrit's Cauldron, Cloister of Flames
player:setPos(91,-1,336,96,124) -- To Yhoator Jungle at I-6
-- Elshimo Lowlands {R}
elseif zone == 176 then -- From Sea Serpent Grotto
player:setPos(-627,16,-427,192,123) -- To Yuhtunga Jungle at E-11
-- Gustaberg {R}
elseif zone == 173 then -- From Korroloka Tunnel
player:setPos(-75,-1,20,0,172) -- To Zeruhn Mines at H-7
elseif zone == 191 then -- From Dangruf Wadi
player:setPos(-564,38,-541,0,107) -- To South Gustaberg at E-9
elseif zone == 143 or zone == 144 then -- From Palborough Mines, Waughroon Shrine
player:setPos(483,-31,1159,128,106) -- To North Gustaberg at K-3
-- Movalpolos {R}
elseif zone == 13 or zone == 12 or zone == 11 then -- From Mine Shaft 2716, Newton Movalpolos, Oldton Movalpolos
player:setPos(448,-4,730,96,106) -- To North Gustaberg at K-6
-- Kuzotz {R}
elseif zone == 208 or zone == 168 or zone == 209 then -- From Quicksand Caves, Chamber of Oracles, Cloister of Tremors
player:setPos(454,-11,-35,128,114) -- To Eastern Altepa Desert at J-8
-- Vollbow {R}
elseif zone == 174 then -- From Kuftal Tunnel
player:setPos(-46,6,418,192,125) -- To Western Altepa Desert at I-5
elseif zone == 212 then -- From Gustav Tunnel
player:setPos(-791,-6,57,192,103) -- To Valkurm Dunes at B-8
elseif zone == 201 then -- From Cloister of Gales
player:setPos(-291,-3,494,32,113) -- To Cape Terrigan F-5
-- Zulkheim {R}
elseif zone == 196 then -- From Gusgen Mines
player:setPos(680,21,204,64,108) -- To Konschtat Highlands at L-7
elseif zone == 193 then -- From Ordelle's Caves
player:setPos(-261,23,123,192,102) -- To La Theine Plateau at F-7
-- Tavnazian Archipelago {R}
elseif zone == 27 then -- From Phomiuna Aqueducts
player:setPos(540,-16,265,160,25) -- To Misareaux Coast at K-7
elseif zone == 28 then -- From Sacrarium
player:setPos(39,-24,743,64,25) -- To Misareaux Coast at H-4
elseif zone == 29 or zone == 30 or zone == 31 then -- From Riverne - Site B01, Riverne - Site A01, Monarch Linn
player:setPos(-483,-31,403,116,25) -- To Misareaux Coast at D-6
-- Mamool Ja Savagelands {R}
elseif zone == 65 then -- From Mamook
player:setPos(-459.961,-4.357,-513.191,192,51) -- To Wajaom Woodlands at E-12
elseif zone == 66 then -- From Mamool Ja Training Grounds
player:setPos(-172.863, -12.25, -801.021, 128, 52) -- Bhaflau Thickets
elseif zone == 67 then -- From Jade Sepulcher
player:setPos(-125.762,-12.226,-499.689,124,52) -- To Bhaflau Thickets at I-9
elseif zone == 68 then -- From Aydeewa Subterrane
player:setPos(95.251,-16.04,428.910,64,51) -- To Wajaom Woodlands at I-6
-- Halvung Territory {R}
elseif zone == 62 then -- From Halvung
player:setPos(860.994,-15.675,223.567,192,61) -- To Mount Zhayolm at L-7
elseif zone == 63 then -- From Lebros Cavern
player:setPos(681.950, -24, 369.936, 64, 61) -- To Mount Zhayolm
elseif zone == 64 then -- From Navukgo Execution Chamber
player:setPos(-630.146,-17.643,223.012,0,61) -- To Mount Zhayolm at C-7
-- Arrapago Islands {R}
elseif zone == 54 then -- From Arrapago Reef
player:setPos(227.36,-17.276,-60.718,95,79) -- To Caedarva Mire Azouph Isle at I-6
elseif zone == 55 then -- From Ilrusi Atoll
player:setPos(9.304,-7.376,620.133,0,54) -- To Arrapago Reef G-4
elseif zone == 56 then -- From Periqia
player:setPos(-252.715, -7.666, -30.64, 128, 79) -- To Caedarva Mire
elseif zone == 57 or zone == 78 then -- From Talacca Cove, Hazhalm Testing Grounds
player:setPos(-467.077,7.89,-538.603,0,79) -- To Caedarva Mire Azouph Isle at E-9
elseif zone == 69 then -- From Leujaoam Sanctum
player:setPos(495.450, -28.25, -478.430, 32, 79) -- To Caedarva Mire
-- Ruins of Alzadaal {R}
elseif zone == 72 then -- From Alzadaal Undersea Ruins
player:setPos(14.186,-29.789,590.427,0,52) -- To Bhaflau Thickets at F-6
elseif zone == 75 then -- From Bhaflau Remnants I/II
player:setPos(620,0,-260,64,72) -- To Alzadaal Undersea Ruins BR H-8
elseif zone == 76 then -- From Silver Sea Remnants I/II
player:setPos(580,0,500,192,72) -- To Alzadaal Undersea Ruins SSR H-8
elseif zone == 77 then -- From Nyzul Isle Investigation/Uncharted Region
player:setPos(180,0,20,0,72) -- To Alzadaal Undersea Ruins
-- Lumoria {R}
elseif zone == 34 or zone == 35 or zone == 36 then -- From Grand Palace of HuXzoi or The Garden of RuHmet or Empyreal Paradox
player:setPos(-23,0,-465,64,33) -- To Al'Taieu (H-11)
-- The Aragoneu Front {R}
elseif zone == 99 then -- From Castle Oztroja (S)
player:setPos(720.589,-31.999,-81.495,162,97) -- To Meriphataud Mountains (S) at L-8
elseif zone == 164 then -- From Garlaige Citadel (S)
player:setPos(-112,-24,-403,192,98) -- To Sauromugue Champaign (S) at H-11
-- The Derfland Front {R}
elseif zone == 92 then -- From Beadeaux (S)
player:setPos(548.199,24.999,-341.959,128,90) -- To Pashhow Marshlands (S) at K-11
elseif zone == 171 then -- From Crawlers' Nest (S)
player:setPos(-356,-24,-763,192,91) -- To Rolanberry Field (S) G-13
-- The Valdeaunia Front {R}
elseif zone == 155 or zone == 138 then -- Fromn Castle Zvahl Keep (S), Castle Zvahl Baileys (S)
player:setPos(-414,-44,19,0,137) -- To Xarcabard (S) at G-7
-- The Norvallen Front {R}
elseif zone == 85 then -- From La Vaule (S)
player:setPos(-203.576,-7.351,-494.53,0,82) -- To Jugner Forest (S) at G-12
elseif zone == 175 then -- From The Eldieme Necropolis (S)
player:setPos(283.593,7.999,-403.207,145,84) -- To Batallia Downs (S) J-10
end
-- TODO: Arrapago Remnants I/II, Zhaylohm Remnants I/II, Everbloom Hollow?, Ruhoyz Silvermines?, The Ashu Talif?
-- TODO: Abyssea / SOA Areas
-- MISC Flag in zone_settings will also need +1 or -1 depending on escape possibility.
end
-----------------------------------
-- EXPLORER MOOGLE EVENTS
-----------------------------------
dsp.teleport.explorerMoogleOnTrigger = function(player, event)
local accept = 0
if player:getGil() < 300 then
accept = 1
end
if player:getMainLvl() < EXPLORER_MOOGLE_LV then
event = event + 1
end
player:startEvent(event, player:getZoneID(), 0, accept)
end
dsp.teleport.explorerMoogleOnEventFinish = function(player, csid, option, event)
local price = 300
if csid == event then
if option == 1 and player:delGil(price) then
dsp.teleport.toExplorerMoogle(player, 231)
elseif option == 2 and player:delGil(price) then
dsp.teleport.toExplorerMoogle(player, 234)
elseif option == 3 and player:delGil(price) then
dsp.teleport.toExplorerMoogle(player, 240)
elseif option == 4 and player:delGil(price) then
dsp.teleport.toExplorerMoogle(player, 248)
elseif option == 5 and player:delGil(price) then
dsp.teleport.toExplorerMoogle(player, 249)
end
end
end
| gpl-3.0 |
Lsty/ygopro-scripts | c63977008.lua | 3 | 1614 | --ジャンク・シンクロン
function c63977008.initial_effect(c)
--summon success
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(63977008,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetTarget(c63977008.sumtg)
e1:SetOperation(c63977008.sumop)
c:RegisterEffect(e1)
end
function c63977008.filter(c,e,tp)
return c:IsLevelBelow(2) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c63977008.sumtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c63977008.filter(chkc,e,tp) end
if chk==0 then return Duel.IsExistingTarget(c63977008.filter,tp,LOCATION_GRAVE,0,1,nil,e,tp)
and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c63977008.filter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c63977008.sumop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP_DEFENCE) then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_DISABLE)
e1:SetReset(RESET_EVENT+0x1fe0000)
tc:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_DISABLE_EFFECT)
e2:SetReset(RESET_EVENT+0x1fe0000)
tc:RegisterEffect(e2)
end
Duel.SpecialSummonComplete()
end
| gpl-2.0 |
MalRD/darkstar | scripts/globals/spells/sacrifice.lua | 12 | 1250 | -----------------------------------------
-- Spell: Sacrifice
--
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/magic")
require("scripts/globals/msg")
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0
end
function onSpellCast(caster,target,spell)
local count = 1
local removables = {dsp.effect.FLASH, dsp.effect.BLINDNESS, dsp.effect.PARALYSIS, dsp.effect.POISON, dsp.effect.CURSE_I, dsp.effect.CURSE_II, dsp.effect.DISEASE, dsp.effect.PLAGUE}
-- remove one effect and add it to me
for i, effect in ipairs(removables) do
if (target:hasStatusEffect(effect)) then
spell:setMsg(dsp.msg.basic.MAGIC_ABSORB_AILMENT)
local statusEffect = target:getStatusEffect(effect)
-- only add it to me if I don't have it
if (caster:hasStatusEffect(effect) == false) then
caster:addStatusEffect(effect, statusEffect:getPower(), statusEffect:getTickCount(), statusEffect:getDuration())
end
target:delStatusEffect(effect)
return 1
end
end
spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT) -- no effect
return 0
end
| gpl-3.0 |
MalRD/darkstar | scripts/zones/Bastok_Markets_[S]/npcs/Engelhart.lua | 9 | 3261 | -----------------------------------
-- Area: Bastok Markets (S)
-- NPC: Engelhart
-- Quest NPC
-- pos -79 -4 -125
-----------------------------------
local ID = require("scripts/zones/Bastok_Markets_[S]/IDs")
require("scripts/globals/quests");
require("scripts/globals/settings");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
if (player:getQuestStatus(CRYSTAL_WAR,dsp.quest.id.crystalWar.BETTER_PART_OF_VALOR) == QUEST_ACCEPTED) then
if (player:getCharVar("BetterPartOfValProg") == 0) then
player:startEvent(116);
elseif (player:getCharVar("BetterPartOfValProg") == 4) then
player:startEvent(118);
else
player:startEvent(117);
end
elseif (player:getQuestStatus(CRYSTAL_WAR,dsp.quest.id.crystalWar.BETTER_PART_OF_VALOR) == QUEST_COMPLETED and player:getQuestStatus(CRYSTAL_WAR,dsp.quest.id.crystalWar.FIRES_OF_DISCONTENT) == QUEST_AVAILABLE) then
player:startEvent(120);
elseif (player:getQuestStatus(CRYSTAL_WAR,dsp.quest.id.crystalWar.FIRES_OF_DISCONTENT) == QUEST_ACCEPTED) then
if (player:getCharVar("FiresOfDiscProg") < 2) then
player:startEvent(121);
elseif (player:getCharVar("FiresOfDiscProg") == 2) then
player:startEvent(124);
elseif (player:getCharVar("FiresOfDiscProg") == 3) then
player:startEvent(125);
elseif (player:getCharVar("FiresOfDiscProg") == 4) then
player:startEvent(126);
elseif (player:getCharVar("FiresOfDiscProg") == 5) then
player:startEvent(127);
elseif (player:getCharVar("FiresOfDiscProg") == 6) then
player:startEvent(164);
end
elseif (player:getQuestStatus(CRYSTAL_WAR,dsp.quest.id.crystalWar.FIRES_OF_DISCONTENT) == QUEST_COMPLETED) then
player:startEvent(165);
else
player:startEvent(104);
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 116) then
player:setCharVar("BetterPartOfValProg",1);
player:delKeyItem(dsp.ki.CLUMP_OF_ANIMAL_HAIR);
elseif (csid == 118) then
player:delKeyItem(dsp.ki.XHIFHUT);
player:completeQuest(CRYSTAL_WAR,dsp.quest.id.crystalWar.BETTER_PART_OF_VALOR);
player:addKeyItem(dsp.ki.WARNING_LETTER);
player:messageSpecial(ID.text.KEYITEM_OBTAINED,dsp.ki.WARNING_LETTER);
player:addGil(GIL_RATE*10000);
player:messageSpecial(ID.text.GIL_OBTAINED,GIL_RATE*10000);
player:setCharVar("BetterPartOfValProg",0);
player:needToZone(true);
elseif (csid == 120) then
player:addQuest(CRYSTAL_WAR,dsp.quest.id.crystalWar.FIRES_OF_DISCONTENT);
player:delKeyItem(dsp.ki.WARNING_LETTER);
elseif (csid == 124) then
player:setCharVar("FiresOfDiscProg",3);
elseif (csid == 126) then
player:setCharVar("FiresOfDiscProg",5);
elseif (csid == 164) then
player:completeQuest(CRYSTAL_WAR,dsp.quest.id.crystalWar.FIRES_OF_DISCONTENT);
player:addGil(GIL_RATE*10000);
player:messageSpecial(ID.text.GIL_OBTAINED,GIL_RATE*10000);
player:setCharVar("FiresOfDiscProg",0);
end
end;
| gpl-3.0 |
Lsty/ygopro-scripts | c21313376.lua | 3 | 1782 | --No.14 強欲のサラメーヤ
function c21313376.initial_effect(c)
--xyz summon
aux.AddXyzProcedure(c,nil,5,2)
c:EnableReviveLimit()
--reflect damage
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_REFLECT_DAMAGE)
e1:SetRange(LOCATION_MZONE)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(1,0)
e1:SetValue(c21313376.refcon)
c:RegisterEffect(e1)
--destroy
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_DESTROY)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_BATTLE_DESTROYING)
e2:SetCondition(aux.bdogcon)
e2:SetCost(c21313376.descost)
e2:SetTarget(c21313376.destg)
e2:SetOperation(c21313376.desop)
c:RegisterEffect(e2)
end
c21313376.xyz_number=14
function c21313376.refcon(e,re,val,r,rp,rc)
return bit.band(r,REASON_EFFECT)~=0 and rp~=e:GetHandlerPlayer()
end
function c21313376.descost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end
e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST)
end
function c21313376.filter(c,atk)
return c:IsFaceup() and c:IsAttackBelow(atk) and c:IsDestructable()
end
function c21313376.destg(e,tp,eg,ep,ev,re,r,rp,chk)
local atk=e:GetHandler():GetBattleTarget():GetBaseAttack()
if chk==0 then return Duel.IsExistingMatchingCard(c21313376.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,atk) end
local g=Duel.GetMatchingGroup(c21313376.filter,tp,LOCATION_MZONE,LOCATION_MZONE,nil,atk)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
end
function c21313376.desop(e,tp,eg,ep,ev,re,r,rp)
local atk=e:GetHandler():GetBattleTarget():GetBaseAttack()
local g=Duel.GetMatchingGroup(c21313376.filter,tp,LOCATION_MZONE,LOCATION_MZONE,nil,atk)
Duel.Destroy(g,REASON_EFFECT)
end
| gpl-2.0 |
Lsty/ygopro-scripts | c52824910.lua | 5 | 1349 | --カイザー・グライダー
function c52824910.initial_effect(c)
--indes
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e1:SetValue(c52824910.indes)
c:RegisterEffect(e1)
--to hand
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(52824910,0))
e2:SetCategory(CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCode(EVENT_TO_GRAVE)
e2:SetCondition(c52824910.condition)
e2:SetTarget(c52824910.target)
e2:SetOperation(c52824910.operation)
c:RegisterEffect(e2)
end
function c52824910.indes(e,c)
return c:GetAttack()==e:GetHandler():GetAttack()
end
function c52824910.condition(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsReason(REASON_DESTROY)
end
function c52824910.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsAbleToHand() end
if chk==0 then return true end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local g=Duel.SelectTarget(tp,Card.IsAbleToHand,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,g:GetCount(),0,0)
end
function c52824910.operation(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc and tc:IsRelateToEffect(e) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
end
end
| gpl-2.0 |
MalRD/darkstar | scripts/globals/spells/bluemagic/filamented_hold.lua | 12 | 1548 | -----------------------------------------
-- Spell: Filamented Hold
-- Reduces the attack speed of enemies within a fan-shaped area originating from the caster
-- Spell cost: 38 MP
-- Monster Type: Vermin
-- Spell Type: Magical (Earth)
-- Blue Magic Points: 3
-- Stat Bonus: VIT+1
-- Level: 52
-- Casting Time: 2 seconds
-- Recast Time: 20 seconds
-- Magic Bursts on: Scission, Gravitation, and Darkness
-- Combos: Clear Mind
-----------------------------------------
require("scripts/globals/bluemagic")
require("scripts/globals/status")
require("scripts/globals/magic")
require("scripts/globals/msg")
require("scripts/globals/status")
-----------------------------------------
function onMagicCastingCheck(caster, target, spell)
return 0
end
function onSpellCast(caster, target, spell)
local typeEffect = dsp.effect.SLOW
local dINT = caster:getStat(dsp.mod.MND) - target:getStat(dsp.mod.MND)
local params = {}
params.diff = nil
params.attribute = dsp.mod.INT
params.skillType = dsp.skill.BLUE_MAGIC
params.bonus = 0
params.effect = typeEffect
local resist = applyResistanceEffect(caster, target, spell, params)
local duration = 90 * resist
local power = 2500
if resist > 0.5 then -- Do it!
if target:addStatusEffect(typeEffect, power, 0, duration) then
spell:setMsg(dsp.msg.basic.MAGIC_ENFEEB_IS)
else
spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT)
end
else
spell:setMsg(dsp.msg.basic.MAGIC_RESIST)
end
return typeEffect
end
| gpl-3.0 |
Noneatme/MTA-SCP-049 | client/utils/CEgo.lua | 1 | 11163 | -- #######################################
-- ## Project: MTA:scp-088 ##
-- ## Name: Ego ##
-- ## Author: Noneatme ##
-- ## Version: 1.0 ##
-- ## License: See top Folder ##
-- #######################################
-- FUNCTIONS / METHODS --
local cFunc = {}; -- Local Functions
local cSetting = {}; -- Local Settings
Ego = {};
Ego.__index = Ego;
--[[
]]
local curVehRot = 0
local oldVehRot = 0
-- ///////////////////////////////
-- ///// New //////
-- ///////////////////////////////
function Ego:New(...)
local obj = setmetatable({}, {__index = self});
if obj.Constructor then
obj:Constructor(...);
end
return obj;
end
-- ///////////////////////////////
-- ///// FreecamFrame //////
-- ///////////////////////////////
function Ego:FreecamFrame()
--if(isPedAiming(localPlayer) ~= true) then
if(self.egoState == true) then
local camPosX, camPosY, camPosZ = getPedBonePosition ( getLocalPlayer(), 8 )
local angleZ = math.sin(self.rotY)
local angleY = math.cos(self.rotY) * math.cos(self.rotX)
local angleX = math.cos(self.rotY) * math.sin(self.rotX)
local camTargetX = camPosX + ( angleX ) * 100
local camTargetY = camPosY + angleY * 100
local camTargetZ = camPosZ + angleZ * 100
local veh = getPedOccupiedVehicle ( getLocalPlayer() )
if veh then
local rx, ry, curVehRot = getElementRotation ( veh )
local changedRotation = oldVehRot - curVehRot
oldVehRot = curVehRot
if not totalRot then
totalRot = curVehRot
end
totalRot = changedRotation * 2 + totalRot
local rotX = ( ( self.rotX * 360 / self.PI ) + totalRot ) / 360 * self.PI
if rotX > self.PI then
rotX = rotX - 2 * self.PI
elseif rotX < -self.PI then
rotX = rotX + 2 * self.PI
end
camTargetX = camPosX + ( math.cos(self.rotY) * math.sin(rotX) ) * 100
camTargetY = camPosY + ( math.cos(self.rotY) * math.cos(rotX) ) * 100
end
setCameraMatrix ( camPosX, camPosY, camPosZ, camTargetX, camTargetY, camTargetZ, 0, 80 )
else
local cameraAngleX = self.rotX
local cameraAngleY = self.rotY
local freeModeAngleZ = math.sin(cameraAngleY)
local freeModeAngleY = math.cos(cameraAngleY) * math.cos(cameraAngleX)
local freeModeAngleX = math.cos(cameraAngleY) * math.sin(cameraAngleX)
local camPosX, camPosY, camPosLastZ = getPedBonePosition(localPlayer, 5)
local zoom = self.zoom;
if(isPedInVehicle(localPlayer)) then
camPosX, camPosY, camPosLastZ = getElementPosition(getPedOccupiedVehicle(localPlayer))
camPosLastZ = camPosLastZ + 0.5
zoom = self.vehicleZoom;
end
local zOffset = 3
local camPosZ = camPosLastZ + zOffset
local mspeed = 2
local speed = 0
local ratio = 3
-- Update the camera position based on the forwards/backwards speed
PosX = camPosX + freeModeAngleX * speed
PosY = camPosY + freeModeAngleY * speed
camPosZ = camPosLastZ + freeModeAngleZ * speed
-- calculate a target based on the current position and an offset based on the angle
local camTargetX = PosX + freeModeAngleX * zoom
local camTargetY = PosY + freeModeAngleY * zoom
local camTargetZ = camPosZ + freeModeAngleZ * zoom
camPosX = PosX - ( camTargetX - PosX ) / ratio
camPosY = PosY - ( camTargetY - PosY ) / ratio
camPosZ = camPosZ - ( camTargetZ - camPosZ ) / ratio
local rotX, rotY, rotZ = self.rotX, self.rotY, freeModeAngleZ
local rx, ry, rz = math.rad(rotX), math.rad(rotY), math.rad(rotZ)
local matrix = {}
matrix[1] = {}
matrix[1][1] = math.cos(rz)*math.cos(ry) - math.sin(rz)*math.sin(rx)*math.sin(ry)
matrix[1][2] = math.cos(ry)*math.sin(rz) + math.cos(rz)*math.sin(rx)*math.sin(ry)
matrix[1][3] = -math.cos(rx)*math.sin(ry)
matrix[2] = {}
matrix[2][1] = -math.cos(rx)*math.sin(rz)
matrix[2][2] = math.cos(rz)*math.cos(rx)
matrix[2][3] = math.sin(rx)
matrix[3] = {}
matrix[3][1] = math.cos(rz)*math.sin(ry) + math.cos(ry)*math.sin(rz)*math.sin(rx)
matrix[3][2] = math.sin(rz)*math.sin(ry) - math.cos(rz)*math.cos(ry)*math.sin(rx)
matrix[3][3] = math.cos(rx)*math.cos(ry)
matrix[4] = {}
matrix[4][1], matrix[4][2], matrix[4][3] = getPedBonePosition(localPlayer, 31)
if not (isLineOfSightClear(PosX, PosY, camPosLastZ, camPosX, camPosY, camPosZ, true, false, false, false, false, false, false)) then
_,camPosX,camPosY,camPosZ = processLineOfSight(PosX, PosY, camPosLastZ, camPosX, camPosY, camPosZ, true, false, false, false, false, false, false)
end
setCameraMatrix ( camPosX, camPosY, camPosZ, camTargetX, camTargetY, camTargetZ )
end
-- Roll --
if(getPedMoveState(localPlayer) == "stand") then
local _, _, _, x1, y1 = getCameraMatrix()
local x2, y2, z = getElementPosition(localPlayer);
local rot = math.atan2(y2 - y1, x2 - x1) * 180 / math.pi
setPedRotation(localPlayer, rot-270)
-- setElementAlpha(localPlayer, 0)
end
-- else
-- if(getCameraTarget() ~= localPlayer) then
-- setCameraTarget(localPlayer);
-- setGameSpeed(1)
-- end
-- end
end
-- ///////////////////////////////
-- ///// FreecamMouse //////
-- ///////////////////////////////
function Ego:FreecamMouse(cX,cY,aX,aY)
if isCursorShowing() or isMTAWindowActive() then
self.delay = 5
return
elseif self.delay > 0 then
self.delay = self.delay - 1
return
end
local width, height = guiGetScreenSize()
local aX = aX - width / 2
local aY = aY - height / 2
self.rotX = self.rotX + aX * self.mouseSensitivity * 0.01745
self.rotY = self.rotY - aY * self.mouseSensitivity * 0.01745
if self.rotX > self.PI then
self.rotX = self.rotX - 2 * self.PI
elseif self.rotX < -self.PI then
self.rotX = self.rotX + 2 * self.PI
end
if self.rotY > self.PI then
self.rotY = self.rotY - 2 * self.PI
elseif self.rotY < -self.PI then
self.rotY = self.rotY + 2 * self.PI
end
if self.rotY < -self.PI / 2.05 then
self.rotY = -self.PI / 2.05
elseif self.rotY > self.PI / 2.05 then
self.rotY = self.PI / 2.05
end
-- Animation --
local _, _, _, x1, y1, z1 = getCameraMatrix();
local x2, y2, z2 = getElementPosition(localPlayer);
if(x1 and y1 and z1 and x2 and y2 and z2) and (isElementMoving(localPlayer) ~= true) and (getPedSimplestTask(localPlayer) == "TASK_SIMPLE_PLAYER_ON_FOOT") then
local oldrot = getPedRotation(localPlayer);
local rot = math.atan2(y2 - y1, x2 - x1) * 180 / math.pi
rot = rot+90
--[[setPedRotation(localPlayer, rot);
outputChatBox(oldrot-rot)
if(math.floor(oldrot-rot) > 0) then
if(getPedAnimation(localPlayer) == false) then
setPedAnimation(localPlayer, "ped", "Turn_R", 50, false, false, true);
end
elseif(math.floor(oldrot-rot) < 0) then
if(getPedAnimation(localPlayer) == false) then
setPedAnimation(localPlayer, "ped", "Turn_L", 50, false, false, true);
end
elseif(math.floor(oldrot-rot) == 0) then
if(getPedAnimation(localPlayer) ~= false) then
setPedAnimation(localPlayer)
end
end]]
end
end
-- ///////////////////////////////
-- ///// Start //////
-- ///////////////////////////////
function Ego:Start()
if(self.state == false) then
self.state = true;
addEventHandler("onClientPreRender", getRootElement(), self.freecamFrameFunc)
addEventHandler("onClientRender", getRootElement(), self.freecamFrameFunc)
addEventHandler("onClientCursorMove",getRootElement(), self.freecamMouseFunc)
end
end
-- ///////////////////////////////
-- ///// Stop //////
-- ///////////////////////////////
function Ego:Stop()
if(self.state == true) then
self.state = false;
removeEventHandler("onClientPreRender", getRootElement(), self.freecamFrameFunc)
removeEventHandler("onClientRender", getRootElement(), self.freecamFrameFunc)
removeEventHandler("onClientCursorMove",getRootElement(), self.freecamMouseFunc)
end
end
-- ///////////////////////////////
-- ///// Constructor //////
-- ///////////////////////////////
function Ego:Constructor(...)
self.freecamFrameFunc = function(...) self:FreecamFrame(...) end;
self.freecamMouseFunc = function(...) self:FreecamMouse(...) end;
self.naheFunc = function(key)
if(key == "num_add") and (isPedInVehicle(localPlayer) == false) or (key == "mouse_wheel_up") and (isPedInVehicle(localPlayer) == true) then
if(self.egoState == false) then
if(isPedInVehicle(localPlayer)) then
if(self.vehicleZoom > 2.5) then
self.vehicleZoom = self.vehicleZoom-1
end
else
if(self.zoom > 2.5) then
self.zoom = self.zoom-1
end
end
end
end
end;
self.fernFunc = function(key)
if(key == "num_sub") and (isPedInVehicle(localPlayer) == false) or (key == "mouse_wheel_down") and (isPedInVehicle(localPlayer) == true) then
if(self.egoState == false) then
if(isPedInVehicle(localPlayer)) then
if(self.vehicleZoom < 100) then
self.vehicleZoom = self.vehicleZoom+1
end
else
if(self.zoom < 50) then
self.zoom = self.zoom+1
end
end
end
end
end
self.toggleCharFunc = function()
if(self.egoState == false) then
self.egoState = true;
--self:Stop()
--setCameraTarget(localPlayer);
else
self.egoState = false;
--self:Start()
end
end;
self.resetFunc = function(key, state)
if(state == "down") then
self:Stop()
setCameraTarget(localPlayer);
else
self:Start()
end
end
self.rotX, self.rotY = 0, 0
self.camVehRot = 0
self.rot = 0
self.curVehRot = 0
self.oldVehRot = 0
self.state = false
self.egoState = false;
self.mouseSensitivity = 0.1
self.delay = 0
self.PI = math.pi
logger:OutputInfo("[CALLING] Ego: Constructor");
self.maxroll = 0;
self.zoom = 15;
self.vehicleZoom = 35;
self.currentroll = 0;
self.rollstate = false;
self.toggleCharFunc()
--bindKey("y", "down", self.toggleCharFunc);
bindKey("mouse_wheel_up", "down", self.naheFunc);
bindKey("mouse_wheel_down", "down", self.fernFunc);
bindKey("num_add", "down", self.naheFunc);
bindKey("num_sub", "down", self.fernFunc);
bindKey("backspace", "down", self.resetFunc);
bindKey("backspace", "up", self.resetFunc)
end
-- EVENT HANDLER --
function isPedAiming ( thePedToCheck )
if isElement(thePedToCheck) then
if getElementType(thePedToCheck) == "player" or getElementType(thePedToCheck) == "ped" then
if getPedTask(thePedToCheck, "secondary", 0) == "TASK_SIMPLE_USE_GUN" then
return true
end
end
end
return false
end
function isElementMoving(theElement)
if isElement(theElement)then --First check if the given argument is an element
local x, y, z = getElementVelocity(theElement) --Get the velocity of the element given in our argument
if x ~= 0 and y ~= 0 and z ~= 0 then --When there is a movement on X, Y or Z return true because our element is moving
return true
end
end
return false
end | mit |
Mkalo/forgottenserver | data/actions/scripts/other/constructionkits.lua | 23 | 1464 | local constructionKits = {
[3901] = 1666, [3902] = 1670, [3903] = 1652, [3904] = 1674, [3905] = 1658,
[3906] = 3813, [3907] = 3817, [3908] = 1619, [3909] = 12799, [3910] = 2105,
[3911] = 1614, [3912] = 3806, [3913] = 3807, [3914] = 3809, [3915] = 1716,
[3916] = 1724, [3917] = 1732, [3918] = 1775, [3919] = 1774, [3920] = 1750,
[3921] = 3832, [3922] = 2095, [3923] = 2098, [3924] = 2064, [3925] = 2582,
[3926] = 2117, [3927] = 1728, [3928] = 1442, [3929] = 1446, [3930] = 1447,
[3931] = 2034, [3932] = 2604, [3933] = 2080, [3934] = 2084, [3935] = 3821,
[3936] = 3811, [3937] = 2101, [3938] = 3812, [5086] = 5046, [5087] = 5055,
[5088] = 5056, [6114] = 6111, [6115] = 6109, [6372] = 6356, [6373] = 6371,
[8692] = 8688, [9974] = 9975, [11126] = 11127, [11133] = 11129, [11124] = 11125,
[11205] = 11203, [14328] = 1616, [14329] = 1615, [16075] = 16020, [16099] = 16098,
[20254] = 20295, [20255] = 20297, [20257] = 20299
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local kit = constructionKits[item.itemid]
if not kit then
return false
end
if fromPosition.x == CONTAINER_POSITION then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "Put the construction kit on the floor first.")
elseif not Tile(fromPosition):getHouse() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You may construct this only inside a house.")
else
item:transform(kit)
fromPosition:sendMagicEffect(CONST_ME_POFF)
end
return true
end
| gpl-2.0 |
Lsty/ygopro-scripts | c18605135.lua | 3 | 1301 | --竜巻海流壁
function c18605135.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCondition(c18605135.actcon)
c:RegisterEffect(e1)
--avoid battle damage
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
e2:SetRange(LOCATION_SZONE)
e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e2:SetTargetRange(1,0)
e2:SetCondition(c18605135.abdcon)
c:RegisterEffect(e2)
--self destroy
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e3:SetRange(LOCATION_SZONE)
e3:SetCode(EFFECT_SELF_DESTROY)
e3:SetCondition(c18605135.sdcon)
c:RegisterEffect(e3)
end
function c18605135.filter(c)
return c:IsFaceup() and c:IsCode(22702055)
end
function c18605135.check()
return Duel.IsExistingMatchingCard(c18605135.filter,0,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil)
or Duel.IsEnvironment(22702055)
end
function c18605135.actcon(e,tp,eg,ep,ev,re,r,rp)
return c18605135.check()
end
function c18605135.abdcon(e)
local at=Duel.GetAttackTarget()
return c18605135.check() and (at==nil or at:IsAttackPos() or Duel.GetAttacker():GetAttack()>at:GetDefence())
end
function c18605135.sdcon(e)
return not c18605135.check()
end
| gpl-2.0 |
ara8586/9900 | plugins/admin.lua | 1 | 10728 | 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
--Function to add log supergroup
local function logadd(msg)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
local GBan_log = 'GBan_log'
if not data[tostring(GBan_log)] then
data[tostring(GBan_log)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(GBan_log)][tostring(msg.to.id)] = msg.to.peer_id
save_data(_config.moderation.data, data)
local text = 'Log_SuperGroup has has been set!'
reply_msg(msg.id,text,ok_cb,false)
return
end
--Function to remove log supergroup
local function logrem(msg)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
local GBan_log = 'GBan_log'
if not data[tostring(GBan_log)] then
data[tostring(GBan_log)] = nil
save_data(_config.moderation.data, data)
end
data[tostring(GBan_log)][tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local text = 'Log_SuperGroup has has been removed!'
reply_msg(msg.id,text,ok_cb,false)
return
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 get_dialog_list_callback(cb_extra, success, result)
local text = ""
for k,v in pairsByKeys(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
-- Returns the key (index) in the config.enabled_plugins table
local function plugin_enabled( name )
for k,v in pairs(_config.enabled_plugins) do
if name == v then
return k
end
end
-- If not found
return false
end
-- Returns true if file exists in plugins folder
local function plugin_exists( name )
for k,v in pairs(plugins_names()) do
if name..'.lua' == v then
return true
end
end
return false
end
local function reload_plugins( )
plugins = {}
return load_plugins()
end
local function run(msg,matches)
local receiver = get_receiver(msg)
local group = msg.to.id
local print_name = user_print_name(msg.from):gsub("", "")
local name_log = print_name:gsub("_", " ")
if not is_admin1(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
local text = "Message From "..(msg.from.username or msg.from.last_name).."\n\nMessage : "..matches[3]
send_large_msg("user#id"..matches[2],text)
return "Message has been sent"
end
if matches[1] == "pmblock" 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] == "pmunblock" 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
if not is_sudo(msg) then-- Sudo only
return
end
get_contact_list(get_contact_list_callback, {target = msg.from.id})
return "👤لیست مخاطبین ربات با 2فرمت text و json برای شما ارسال شد👤"
end
if matches[1] == "delcontact" then
if not is_sudo(msg) then-- Sudo only
return
end
del_contact("user#id"..matches[2],ok_cb,false)
return "User "..matches[2].." 🚮مخاطب حذف شد🚮"
end
if matches[1] == "addcontact" and is_sudo(msg) or matches[1] == "ادد مخاطب" and is_sudo(msg) then
phone = matches[2]
first_name = matches[3]
last_name = matches[4]
add_contact(phone, first_name, last_name, ok_cb, false)
return "مخاطب با شماره: +"..matches[2].." ✅اضافه شد"
end
if matches[1] == "sendcontact" and is_sudo(msg) then
phone = matches[2]
first_name = matches[3]
last_name = matches[4]
send_contact(get_receiver(msg), phone, first_name, last_name, ok_cb, false)
end
if matches[1] == "mycontact" and is_sudo(msg) then
if not msg.from.phone then
return "I must Have Your Phone Number!"
end
phone = msg.from.phone
first_name = (msg.from.first_name or msg.from.phone)
last_name = (msg.from.last_name or msg.from.id)
send_contact(get_receiver(msg), phone, first_name, last_name, ok_cb, false)
end
if matches[1] == "dialoglist" then
get_dialog_list(get_dialog_list_callback, {target = msg.from.id})
return "👤لیست مخاطبین گروه با 2فرمت text و json برای شما ارسال شد👤"
end
if matches[1] == "whois" then
user_info("user#id"..matches[2],user_info_callback,{msg=msg})
end
if matches[1] == "sync_gbans" then
if not is_sudo(msg) then-- Sudo only
return
end
local url = "http://seedteam.org/Teleseed/Global_bans.json"
local SEED_gbans = http.request(url)
local jdat = json:decode(SEED_gbans)
for k,v in pairs(jdat) do
redis:hset('user:'..v, 'print_name', k)
banall_user(v)
print(k, v.." Globally banned")
end
end
if matches[1] == 'reload' then
receiver = get_receiver(msg)
reload_plugins(true)
post_msg(receiver, "🔃تمام پلاگین ها دوباره بارگذاری شدند🔃", ok_cb, false)
return ""
end
--[[*For Debug*
if matches[1] == "vardumpmsg" and is_admin1(msg) then
local text = serpent.block(msg, {comment=false})
send_large_msg("channel#id"..msg.to.id, text)
end]]
if matches[1] == 'updateid' then
local data = load_data(_config.moderation.data)
local long_id = data[tostring(msg.to.id)]['long_id']
if not long_id then
data[tostring(msg.to.id)]['long_id'] = msg.to.peer_id
save_data(_config.moderation.data, data)
return "Updated ID"
end
end
if matches[1] == 'addlog' and not matches[2] then
if is_log_group(msg) then
return "Already a Log_SuperGroup"
end
print("Log_SuperGroup "..msg.to.title.."("..msg.to.id..") added")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] added Log_SuperGroup")
logadd(msg)
end
if matches[1] == 'remlog' and not matches[2] then
if not is_log_group(msg) then
return "Not a Log_SuperGroup"
end
print("Log_SuperGroup "..msg.to.title.."("..msg.to.id..") removed")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] added Log_SuperGroup")
logrem(msg)
end
return
end
local function pre_process(msg)
if not msg.text and msg.media then
msg.text = '['..msg.media.type..']'
end
return msg
end
return {
patterns = {
"^[#!/](pm) (%d+) (.*)$",
"^[#!/](import) (.*)$",
"^[#!/](pmunblock) (%d+)$",
"^[#!/](pmblock) (%d+)$",
"^[#!/](markread) (on)$",
"^[#!/](markread) (off)$",
"^[#!/](setbotphoto)$",
"^[#!/](contactlist)$",
"^[#!/](dialoglist)$",
"^[#!/](delcontact) (%d+)$",
"^[#!/](addcontact) (.*) (.*) (.*)$",
"^[#!/](sendcontact) (.*) (.*) (.*)$",
"^[#!/](mycontact)$",
"^[#/!](reload)$",
"^[#/!](updateid)$",
"^[#/!](sync_gbans)$",
"^[#/!](addlog)$",
"^[#/!](remlog)$",
"%[(photo)%]",
},
run = run,
pre_process = pre_process
}
--By @mr_ahmadix :)
--sp @suport_arabot
| agpl-3.0 |
Lsty/ygopro-scripts | c72913666.lua | 3 | 2059 | --ゴーストリック・ワーウルフ
function c72913666.initial_effect(c)
--summon limit
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CANNOT_SUMMON)
e1:SetCondition(c72913666.sumcon)
c:RegisterEffect(e1)
--turn set
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(72913666,0))
e2:SetCategory(CATEGORY_POSITION)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_MZONE)
e2:SetTarget(c72913666.postg)
e2:SetOperation(c72913666.posop)
c:RegisterEffect(e2)
--damage
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(72913666,1))
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e3:SetCategory(CATEGORY_DAMAGE)
e3:SetCode(EVENT_FLIP)
e3:SetCountLimit(1,72913666)
e3:SetTarget(c72913666.damtg)
e3:SetOperation(c72913666.damop)
c:RegisterEffect(e3)
end
function c72913666.sfilter(c)
return c:IsFaceup() and c:IsSetCard(0x8d)
end
function c72913666.sumcon(e)
return not Duel.IsExistingMatchingCard(c72913666.sfilter,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,nil)
end
function c72913666.postg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:IsCanTurnSet() and c:GetFlagEffect(72913666)==0 end
c:RegisterFlagEffect(72913666,RESET_EVENT+0x1fc0000+RESET_PHASE+PHASE_END,0,1)
Duel.SetOperationInfo(0,CATEGORY_POSITION,c,1,0,0)
end
function c72913666.posop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) and c:IsFaceup() then
Duel.ChangePosition(c,POS_FACEDOWN_DEFENCE)
end
end
function c72913666.damtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local ct=Duel.GetMatchingGroupCount(Card.IsFacedown,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil)
Duel.SetTargetPlayer(1-tp)
Duel.SetTargetParam(ct*100)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,0,0,1-tp,ct*100)
end
function c72913666.damop(e,tp,eg,ep,ev,re,r,rp)
local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER)
local ct=Duel.GetMatchingGroupCount(Card.IsFacedown,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil)
Duel.Damage(p,ct*100,REASON_EFFECT)
end
| gpl-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.