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 |
|---|---|---|---|---|---|
mahdibagheri/mohammad | plugins/all.lua | 1321 | 4661 | do
data = load_data(_config.moderation.data)
local function get_msgs_user_chat(user_id, chat_id)
local user_info = {}
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..user_id..':'..chat_id
user_info.msgs = tonumber(redis:get(um_hash) or 0)
user_info.name = user_print_name(user)..' ['..user_id..']'
return user_info
end
local function chat_stats(chat_id)
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'Chat stats:\n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
return text
end
local function get_group_type(target)
local data = load_data(_config.moderation.data)
local group_type = data[tostring(target)]['group_type']
if not group_type or group_type == nil then
return 'No group type available.'
end
return group_type
end
local function show_group_settings(target)
local data = load_data(_config.moderation.data)
if data[tostring(target)] then
if data[tostring(target)]['settings']['flood_msg_max'] then
NUM_MSG_MAX = tonumber(data[tostring(target)]['settings']['flood_msg_max'])
print('custom'..NUM_MSG_MAX)
else
NUM_MSG_MAX = 5
end
end
local settings = data[tostring(target)]['settings']
local text = "Lock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nflood sensitivity : "..NUM_MSG_MAX
return text
end
local function get_description(target)
local data = load_data(_config.moderation.data)
local data_cat = 'description'
if not data[tostring(target)][data_cat] then
return 'No description available.'
end
local about = data[tostring(target)][data_cat]
return about
end
local function get_rules(target)
local data = load_data(_config.moderation.data)
local data_cat = 'rules'
if not data[tostring(target)][data_cat] then
return 'No rules available.'
end
local rules = data[tostring(target)][data_cat]
return rules
end
local function modlist(target)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] or not data[tostring(groups)][tostring(target)] then
return 'Group is not added or is Realm.'
end
if next(data[tostring(target)]['moderators']) == nil then
return 'No moderator in this group.'
end
local i = 1
local message = '\nList of moderators :\n'
for k,v in pairs(data[tostring(target)]['moderators']) do
message = message ..i..' - @'..v..' [' ..k.. '] \n'
i = i + 1
end
return message
end
local function get_link(target)
local data = load_data(_config.moderation.data)
local group_link = data[tostring(target)]['settings']['set_link']
if not group_link or group_link == nil then
return "No link"
end
return "Group link:\n"..group_link
end
local function all(target, receiver)
local text = "All the things I know about this group\n\n"
local group_type = get_group_type(target)
text = text.."Group Type: \n"..group_type
local settings = show_group_settings(target)
text = text.."\n\nGroup settings: \n"..settings
local rules = get_rules(target)
text = text.."\n\nRules: \n"..rules
local description = get_description(target)
text = text.."\n\nAbout: \n"..description
local modlist = modlist(target)
text = text.."\n\nMods: \n"..modlist
local link = get_link(target)
text = text.."\n\nLink: \n"..link
local stats = chat_stats(target)
text = text.."\n\n"..stats
local ban_list = ban_list(target)
text = text.."\n\n"..ban_list
local file = io.open("./groups/all/"..target.."all.txt", "w")
file:write(text)
file:flush()
file:close()
send_document(receiver,"./groups/all/"..target.."all.txt", ok_cb, false)
return
end
function run(msg, matches)
if matches[1] == "all" and matches[2] and is_owner2(msg.from.id, matches[2]) then
local receiver = get_receiver(msg)
local target = matches[2]
return all(target, receiver)
end
if not is_owner(msg) then
return
end
if matches[1] == "all" and not matches[2] then
local receiver = get_receiver(msg)
if not is_owner(msg) then
return
end
return all(msg.to.id, receiver)
end
end
return {
patterns = {
"^[!/](all)$",
"^[!/](all) (%d+)$"
},
run = run
}
end
| gpl-2.0 |
samijon/suofi | plugins/all.lua | 1321 | 4661 | do
data = load_data(_config.moderation.data)
local function get_msgs_user_chat(user_id, chat_id)
local user_info = {}
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..user_id..':'..chat_id
user_info.msgs = tonumber(redis:get(um_hash) or 0)
user_info.name = user_print_name(user)..' ['..user_id..']'
return user_info
end
local function chat_stats(chat_id)
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'Chat stats:\n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
return text
end
local function get_group_type(target)
local data = load_data(_config.moderation.data)
local group_type = data[tostring(target)]['group_type']
if not group_type or group_type == nil then
return 'No group type available.'
end
return group_type
end
local function show_group_settings(target)
local data = load_data(_config.moderation.data)
if data[tostring(target)] then
if data[tostring(target)]['settings']['flood_msg_max'] then
NUM_MSG_MAX = tonumber(data[tostring(target)]['settings']['flood_msg_max'])
print('custom'..NUM_MSG_MAX)
else
NUM_MSG_MAX = 5
end
end
local settings = data[tostring(target)]['settings']
local text = "Lock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nflood sensitivity : "..NUM_MSG_MAX
return text
end
local function get_description(target)
local data = load_data(_config.moderation.data)
local data_cat = 'description'
if not data[tostring(target)][data_cat] then
return 'No description available.'
end
local about = data[tostring(target)][data_cat]
return about
end
local function get_rules(target)
local data = load_data(_config.moderation.data)
local data_cat = 'rules'
if not data[tostring(target)][data_cat] then
return 'No rules available.'
end
local rules = data[tostring(target)][data_cat]
return rules
end
local function modlist(target)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] or not data[tostring(groups)][tostring(target)] then
return 'Group is not added or is Realm.'
end
if next(data[tostring(target)]['moderators']) == nil then
return 'No moderator in this group.'
end
local i = 1
local message = '\nList of moderators :\n'
for k,v in pairs(data[tostring(target)]['moderators']) do
message = message ..i..' - @'..v..' [' ..k.. '] \n'
i = i + 1
end
return message
end
local function get_link(target)
local data = load_data(_config.moderation.data)
local group_link = data[tostring(target)]['settings']['set_link']
if not group_link or group_link == nil then
return "No link"
end
return "Group link:\n"..group_link
end
local function all(target, receiver)
local text = "All the things I know about this group\n\n"
local group_type = get_group_type(target)
text = text.."Group Type: \n"..group_type
local settings = show_group_settings(target)
text = text.."\n\nGroup settings: \n"..settings
local rules = get_rules(target)
text = text.."\n\nRules: \n"..rules
local description = get_description(target)
text = text.."\n\nAbout: \n"..description
local modlist = modlist(target)
text = text.."\n\nMods: \n"..modlist
local link = get_link(target)
text = text.."\n\nLink: \n"..link
local stats = chat_stats(target)
text = text.."\n\n"..stats
local ban_list = ban_list(target)
text = text.."\n\n"..ban_list
local file = io.open("./groups/all/"..target.."all.txt", "w")
file:write(text)
file:flush()
file:close()
send_document(receiver,"./groups/all/"..target.."all.txt", ok_cb, false)
return
end
function run(msg, matches)
if matches[1] == "all" and matches[2] and is_owner2(msg.from.id, matches[2]) then
local receiver = get_receiver(msg)
local target = matches[2]
return all(target, receiver)
end
if not is_owner(msg) then
return
end
if matches[1] == "all" and not matches[2] then
local receiver = get_receiver(msg)
if not is_owner(msg) then
return
end
return all(msg.to.id, receiver)
end
end
return {
patterns = {
"^[!/](all)$",
"^[!/](all) (%d+)$"
},
run = run
}
end
| gpl-2.0 |
mercury233/ygopro-scripts | c73178098.lua | 4 | 1080 | --虚栄巨影
function c73178098.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_ATKCHANGE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_ATTACK_ANNOUNCE)
e1:SetTarget(c73178098.target)
e1:SetOperation(c73178098.activate)
c:RegisterEffect(e1)
end
function c73178098.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsFaceup() end
if chk==0 then return Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
local g=Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
end
function c73178098.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsFaceup() then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_BATTLE)
e1:SetValue(1000)
tc:RegisterEffect(e1)
end
end
| gpl-2.0 |
AlmightyLaxz/gmRPG | entities/entities/rpg_npc_civilian_old.lua | 1 | 2361 | AddCSLuaFile()
ENT.Base = "rpg_npc_base"
ENT.Type = "ai"
ENT.PrintName = "NPC Civilian"
ENT.Author = "Almighty Laxz"
ENT.Contact = ""
ENT.Purpose = ""
ENT.Instructions = ""
ENT.Category = "gmRPG"
ENT.Spawnable = true
ENT.randText = {}
ENT.randText[0] = "Hello, what's up?"
ENT.randText[1] = "Can I help you?"
ENT.randText[2] = "Do I know you?"
ENT.randText[3] = "Do you need something?"
ENT.randText[4] = "What do you want?"
ENT.civModels = {}
ENT.civModels[0] = "models/humans/group01/female_01.mdl"
ENT.civModels[1] = "models/humans/group01/female_02.mdl"
ENT.civModels[2] = "models/humans/group01/female_03.mdl"
ENT.civModels[3] = "models/humans/group01/female_04.mdl"
ENT.civModels[4] = "models/humans/group01/female_06.mdl"
ENT.civModels[5] = "models/humans/group01/female_07.mdl"
ENT.civModels[6] = "models/humans/group01/male_01.mdl"
ENT.civModels[7] = "models/humans/group01/male_02.mdl"
ENT.civModels[8] = "models/humans/group01/male_03.mdl"
ENT.civModels[9] = "models/humans/group01/male_04.mdl"
ENT.civModels[10] = "models/humans/group01/male_05.mdl"
ENT.civModels[11] = "models/humans/group01/male_06.mdl"
ENT.civModels[12] = "models/humans/group01/male_07.mdl"
ENT.civModels[13] = "models/humans/group01/male_08.mdl"
ENT.civModels[14] = "models/humans/group01/male_09.mdl"
ENT.titleText = "Civilian"
if SERVER then
function ENT:Initialize()
self:SetModel(self.civModels[math.random(0, 14)])
self:SetHullType( HULL_HUMAN )
self:SetHullSizeNormal( )
self:SetNPCState( NPC_STATE_SCRIPT )
self:SetSolid( SOLID_BBOX )
self:CapabilitiesAdd( CAP_ANIMATEDFACE, CAP_TURN_HEAD )
self:SetUseType( SIMPLE_USE )
self:DropToFloor()
end
function ENT:AcceptInput( Name, Activator, Caller )
if !Activator.cantUse and Activator:IsPlayer() then
Activator.cantUse = true
net.Start("rpgSingleDialogueDermaStart")
net.WriteString(self.titleText)
net.WriteString(self.randText[math.random(0, 4)])
net.WriteString("Close")
net.WriteEntity(self)
net.Send(Activator)
timer.Simple(1, function()
Activator.cantUse = false
end)
end
end
end
| gpl-3.0 |
linushsao/marsu_game-linus-v0.2 | mods/technical/technic/technic_worldgen/oregen.lua | 2 | 5664 | local uranium_params = {offset = 0, scale = 1, spread = {x = 100, y = 100, z = 100}, seed = 420, octaves = 3, persist = 0.7}
local uranium_threshhold = 0.55
local chromium_params = {offset = 0, scale = 1, spread = {x = 100, y = 100, z = 100}, seed = 421, octaves = 3, persist = 0.7}
local chromium_threshhold = 0.55
local zinc_params = {offset = 0, scale = 1, spread = {x = 100, y = 100, z = 100}, seed = 422, octaves = 3, persist = 0.7}
local zinc_threshhold = 0.5
local lead_params = {offset = 0, scale = 1, spread = {x = 100, y = 100, z = 100}, seed = 423, octaves = 3, persist = 0.7}
local lead_threshhold = 0.3
minetest.register_ore({
ore_type = "scatter",
ore = "technic:mineral_uranium",
wherein = "default:stone",
clust_scarcity = 8*8*8,
clust_num_ores = 4,
clust_size = 3,
y_min = -300,
y_max = -80,
noise_params = uranium_params,
noise_threshhold = uranium_threshhold,
})
minetest.register_ore({
ore_type = "scatter",
ore = "technic:mineral_chromium",
wherein = "default:stone",
clust_scarcity = 8*8*8,
clust_num_ores = 2,
clust_size = 3,
y_min = -200,
y_max = -100,
noise_params = chromium_params,
noise_threshhold = chromium_threshhold,
})
minetest.register_ore({
ore_type = "scatter",
ore = "technic:mineral_chromium",
wherein = "default:stone",
clust_scarcity = 6*6*6,
clust_num_ores = 2,
clust_size = 3,
y_min = -31000,
y_max = -200,
flags = "absheight",
noise_params = chromium_params,
noise_threshhold = chromium_threshhold,
})
minetest.register_ore({
ore_type = "scatter",
ore = "technic:mineral_zinc",
wherein = "default:stone",
clust_scarcity = 8*8*8,
clust_num_ores = 4,
clust_size = 3,
y_min = -32,
y_max = 2,
noise_params = zinc_params,
noise_threshhold = zinc_threshhold,
})
minetest.register_ore({
ore_type = "scatter",
ore = "technic:mineral_zinc",
wherein = "default:stone",
clust_scarcity = 6*6*6,
clust_num_ores = 4,
clust_size = 3,
y_min = -31000,
y_max = -32,
flags = "absheight",
noise_params = zinc_params,
noise_threshhold = zinc_threshhold,
})
minetest.register_ore({
ore_type = "scatter",
ore = "technic:mineral_lead",
wherein = "default:stone",
clust_scarcity = 9*9*9,
clust_num_ores = 5,
clust_size = 3,
y_min = -16,
y_max = 16,
noise_params = lead_params,
noise_threshhold = lead_threshhold,
})
minetest.register_ore({
ore_type = "scatter",
ore = "technic:mineral_lead",
wherein = "default:stone",
clust_scarcity = 8*8*8,
clust_num_ores = 5,
clust_size = 3,
y_min = -128,
y_max = -16,
noise_params = lead_params,
noise_threshhold = lead_threshhold,
})
minetest.register_ore({
ore_type = "scatter",
ore = "technic:mineral_lead",
wherein = "default:stone",
clust_scarcity = 6*6*6,
clust_num_ores = 5,
clust_size = 3,
y_min = -31000,
y_max = -128,
flags = "absheight",
noise_params = lead_params,
noise_threshhold = lead_threshhold,
})
-- Sulfur
minetest.register_on_generated(function(minp, maxp, seed)
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local a = VoxelArea:new{
MinEdge = {x = emin.x, y = emin.y, z = emin.z},
MaxEdge = {x = emax.x, y = emax.y, z = emax.z},
}
local data = vm:get_data()
local pr = PseudoRandom(17 * minp.x + 42 * minp.y + 101 * minp.z)
local noise = minetest.get_perlin(9876, 3, 0.5, 100)
local c_lava = minetest.get_content_id("default:lava_source")
local c_lava_flowing = minetest.get_content_id("default:lava_flowing")
local c_stone = minetest.get_content_id("default:stone")
local c_sulfur = minetest.get_content_id("technic:mineral_sulfur")
local grid_size = 5
for x = minp.x + math.floor(grid_size / 2), maxp.x, grid_size do
for y = minp.y + math.floor(grid_size / 2), maxp.y, grid_size do
for z = minp.z + math.floor(grid_size / 2), maxp.z, grid_size do
local c = data[a:index(x, y, z)]
if (c == c_lava or c == c_lava_flowing) and noise:get3d({x = x, y = z, z = z}) >= 0.4 then
for xx = math.max(minp.x, x - grid_size), math.min(maxp.x, x + grid_size) do
for yy = math.max(minp.y, y - grid_size), math.min(maxp.y, y + grid_size) do
for zz = math.max(minp.z, z - grid_size), math.min(maxp.z, z + grid_size) do
local i = a:index(xx, yy, zz)
if data[i] == c_stone and pr:next(1, 10) <= 7 then
data[i] = c_sulfur
end
end
end
end
end
end
end
end
vm:set_data(data)
vm:write_to_map(data)
end)
if technic.config:get_bool("enable_marble_generation") then
minetest.register_ore({
ore_type = "sheet",
ore = "technic:marble",
wherein = "default:stone",
clust_scarcity = 1,
clust_num_ores = 1,
clust_size = 3,
y_min = -31000,
y_max = -50,
noise_threshhold = 0.4,
noise_params = {offset=0, scale=15, spread={x=150, y=150, z=150}, seed=23, octaves=3, persist=0.70}
})
end
if technic.config:get_bool("enable_granite_generation") then
minetest.register_ore({
ore_type = "sheet",
ore = "technic:granite",
wherein = "default:stone",
clust_scarcity = 1,
clust_num_ores = 1,
clust_size = 4,
y_min = -31000,
y_max = -150,
noise_threshhold = 0.4,
noise_params = {offset=0, scale=15, spread={x=130, y=130, z=130}, seed=24, octaves=3, persist=0.70}
})
end
| gpl-3.0 |
rouing/FHLG-BW | entities/entities/item_superdrugoffense/init.lua | 1 | 1256 |
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include('shared.lua')
function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 20
local ent = ents.Create( "item_superdrug" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end
function ENT:Initialize()
self.Entity:SetModel( "models/props_lab/jar01a.mdl")
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
local phys = self.Entity:GetPhysicsObject()
if(phys:IsValid()) then phys:Wake() end
self.Time = CurTime()
end
function ENT:Use(activator,caller)
if !caller:GetTable().Superdrugoffense && !caller:GetTable().Superdrugdefense && !caller:GetTable().Superdrugweapmod then
caller:SetNWBool("superdrug", true)
Roidup(caller, CfgVars["superduration"])
DoubleJumpup(caller, CfgVars["superduration"])
Randup(caller,CfgVars["superduration"])
Superup(caller,CfgVars["superduration"],"offense")
caller:SetNWBool("superdrug", false)
self.Entity:Remove()
end
end
function ENT:Think()
end
// it takes so much in the game to create a single one, lets not have it just be destroyed so easily
function ENT:OnTakeDamage(dmg)
end | unlicense |
Zenny89/darkstar | scripts/globals/abilities/pets/fire_iv.lua | 20 | 1157 | ---------------------------------------------------
-- Aero 2
---------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
require("scripts/globals/magic");
---------------------------------------------------
function onAbilityCheck(player, target, ability)
return 0,0;
end;
function onPetAbility(target, pet, skill)
local spell = getSpell(147);
--calculate raw damage
local dmg = calculateMagicDamage(472,2,pet,spell,target,ELEMENTAL_MAGIC_SKILL,MOD_INT,false);
--get resist multiplier (1x if no resist)
local resist = applyPlayerResistance(pet,-1,target,pet:getStat(MOD_INT)-target:getStat(MOD_INT),ELEMENTAL_MAGIC_SKILL, ELE_FIRE);
--get the resisted damage
dmg = dmg*resist;
--add on bonuses (staff/day/weather/jas/mab/etc all go in this function)
dmg = mobAddBonuses(pet,spell,target,dmg, 1);
--add on TP bonuses
local tp = skill:getTP();
if tp < 100 then
tp = 100;
end
dmg = dmg * tp / 100;
--add in final adjustments
dmg = finalMagicAdjustments(pet,target,spell,dmg);
return dmg;
end | gpl-3.0 |
mercury233/ygopro-scripts | c99427357.lua | 2 | 3654 | --サイバー・エンジェル-那沙帝弥-
function c99427357.initial_effect(c)
c:EnableReviveLimit()
--recover
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(99427357,0))
e1:SetCategory(CATEGORY_RECOVER)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1)
e1:SetTarget(c99427357.rectg)
e1:SetOperation(c99427357.recop)
c:RegisterEffect(e1)
--negate attack
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(99427357,1))
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_BE_BATTLE_TARGET)
e2:SetRange(LOCATION_MZONE)
e2:SetCondition(c99427357.negcon)
e2:SetOperation(c99427357.negop)
c:RegisterEffect(e2)
--special summon
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(99427357,2))
e3:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_CONTROL)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetRange(LOCATION_GRAVE)
e3:SetCost(c99427357.cost)
e3:SetTarget(c99427357.target)
e3:SetOperation(c99427357.operation)
c:RegisterEffect(e3)
end
function c99427357.recfilter(c)
return c:IsFaceup() and c:GetAttack()>0
end
function c99427357.rectg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and c99427357.recfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c99427357.recfilter,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
local g=Duel.SelectTarget(tp,c99427357.recfilter,tp,LOCATION_MZONE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_RECOVER,nil,0,tp,math.ceil(g:GetFirst():GetAttack()/2))
end
function c99427357.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,math.ceil(tc:GetAttack()/2),REASON_EFFECT)
end
end
function c99427357.negcon(e,tp,eg,ep,ev,re,r,rp)
local d=Duel.GetAttackTarget()
return d and d:IsControler(tp) and d:IsFaceup() and d:IsType(TYPE_RITUAL)
end
function c99427357.negop(e,tp,eg,ep,ev,re,r,rp)
Duel.NegateAttack()
end
function c99427357.cfilter(c)
return c:IsSetCard(0x2093) and c:IsAbleToRemoveAsCost() and c:IsType(TYPE_MONSTER)
end
function c99427357.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c99427357.cfilter,tp,LOCATION_GRAVE,0,1,e:GetHandler()) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectMatchingCard(tp,c99427357.cfilter,tp,LOCATION_GRAVE,0,1,1,e:GetHandler())
Duel.Remove(g,POS_FACEUP,REASON_COST)
end
function c99427357.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 chkc:IsAbleToChangeControler() end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.GetLocationCount(tp,LOCATION_MZONE,tp,LOCATION_REASON_CONTROL)>0
and Duel.GetLocationCount(tp,LOCATION_MZONE,tp,0)>1
and Duel.IsExistingTarget(Card.IsAbleToChangeControler,tp,0,LOCATION_MZONE,1,nil)
and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONTROL)
local g=Duel.SelectTarget(tp,Card.IsAbleToChangeControler,tp,0,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_CONTROL,g,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function c99427357.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if c:IsRelateToEffect(e) and Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)>0
and tc:IsRelateToEffect(e) then
Duel.GetControl(tc,tp)
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c43225434.lua | 4 | 1140 | --決闘融合-バトル・フュージョン
function c43225434.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_ATKCHANGE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_ATTACK_ANNOUNCE)
e1:SetCountLimit(1,43225434+EFFECT_COUNT_CODE_OATH)
e1:SetCondition(c43225434.condition)
e1:SetOperation(c43225434.activate)
c:RegisterEffect(e1)
end
function c43225434.condition(e,tp,eg,ep,ev,re,r,rp)
local a=Duel.GetAttacker()
local at=Duel.GetAttackTarget()
return at and ((a:IsControler(tp) and a:IsType(TYPE_FUSION))
or (at:IsControler(tp) and at:IsFaceup() and at:IsType(TYPE_FUSION)))
end
function c43225434.activate(e,tp,eg,ep,ev,re,r,rp)
local a=Duel.GetAttacker()
local at=Duel.GetAttackTarget()
if a:IsControler(1-tp) then a,at=at,a end
if not a:IsRelateToBattle() or a:IsFacedown() or not at:IsRelateToBattle() or at:IsFacedown() then return end
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_DAMAGE)
e1:SetValue(at:GetAttack())
a:RegisterEffect(e1)
end
| gpl-2.0 |
mercury233/ygopro-scripts | c36016907.lua | 2 | 3695 | --ジャック・ア・ボーラン
function c36016907.initial_effect(c)
--spsummon1
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(36016907,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_HAND)
e1:SetCountLimit(1,36016907)
e1:SetCost(c36016907.spcost1)
e1:SetTarget(c36016907.sptg1)
e1:SetOperation(c36016907.spop1)
c:RegisterEffect(e1)
--spsummon2
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(36016907,1))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_REMOVE)
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetCode(EVENT_FREE_CHAIN)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetRange(LOCATION_MZONE)
e2:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_MAIN_END)
e2:SetCountLimit(1,36016908)
e2:SetCondition(c36016907.spcon2)
e2:SetTarget(c36016907.sptg2)
e2:SetOperation(c36016907.spop2)
c:RegisterEffect(e2)
end
function c36016907.spfilter1(c)
return c:IsRace(RACE_ZOMBIE) and c:IsDiscardable()
end
function c36016907.spcost1(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.IsExistingMatchingCard(c36016907.spfilter1,tp,LOCATION_HAND,0,1,c) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISCARD)
local g=Duel.SelectMatchingCard(tp,c36016907.spfilter1,tp,LOCATION_HAND,0,1,1,c)
Duel.SendtoGrave(g,REASON_COST+REASON_DISCARD)
end
function c36016907.sptg1(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,0)
end
function c36016907.spop1(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) then
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
end
end
function c36016907.spfilter2(c,e,tp)
return c:IsRace(RACE_ZOMBIE) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c36016907.spcon2(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==1-tp and (Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2)
end
function c36016907.sptg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local c=e:GetHandler()
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and c36016907.spfilter2(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c36016907.spfilter2,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,nil,e,tp) and c:IsAbleToRemove() end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c36016907.spfilter2,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,c,1,0,0)
end
function c36016907.spop2(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)~=0 then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetReset(RESET_EVENT+RESETS_REDIRECT)
e1:SetValue(LOCATION_REMOVED)
tc:RegisterEffect(e1,true)
if c:IsFaceup() and c:IsRelateToEffect(e) and c:IsAbleToRemove() then
Duel.BreakEffect()
if Duel.Remove(c,0,REASON_EFFECT+REASON_TEMPORARY)~=0 then
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_PHASE+PHASE_END)
e2:SetReset(RESET_PHASE+PHASE_END)
e2:SetLabelObject(tc)
e2:SetCountLimit(1)
e2:SetOperation(c36016907.retop)
Duel.RegisterEffect(e2,tp)
end
end
end
end
function c36016907.retop(e,tp,eg,ep,ev,re,r,rp)
Duel.ReturnToField(e:GetHandler())
end
| gpl-2.0 |
Zenny89/darkstar | scripts/zones/Cloister_of_Gales/bcnms/sugar-coated_directive.lua | 19 | 1709 | ----------------------------------------
-- Area: Cloister of Gales
-- BCNM: Sugar Coated Directive (ASA-4)
----------------------------------------
package.loaded["scripts/zones/Cloister_of_Gales/TextIDs"] = nil;
----------------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/zones/Cloister_of_Gales/TextIDs");
----------------------------------------
-- After registering the BCNM via bcnmRegister(bcnmid)
function onBcnmRegister(player,instance)
end;
-- Physically entering the BCNM via bcnmEnter(bcnmid)
function onBcnmEnter(player,instance)
end;
-- Leaving the BCNM by every mean possible, given by the LeaveCode
-- 1=Select Exit on circle
-- 2=Winning the BC
-- 3=Disconnected or warped out
-- 4=Losing the BC
-- via bcnmLeave(1) or bcnmLeave(2). LeaveCodes 3 and 4 are called
-- from the core when a player disconnects or the time limit is up, etc
function onBcnmLeave(player,instance,leavecode)
-- print("leave code "..leavecode);
if (leavecode == 2) then -- play end CS. Need time and battle id for record keeping + storage
if (player:hasCompletedMission(ASA,SUGAR_COATED_DIRECTIVE)) then
player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,4,1);
else
player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,4,0);
end
elseif (leavecode == 4) then
player:startEvent(0x7d02);
end
end;
function onEventUpdate(player,csid,option)
-- print("bc update csid "..csid.." and option "..option);
end;
function onEventFinish(player,csid,option)
-- print("bc finish csid "..csid.." and option "..option);
if (csid == 0x7d01) then
player:addExp(400);
player:setVar("ASA4_Emerald","1");
end
end; | gpl-3.0 |
Zenny89/darkstar | scripts/zones/Windurst_Waters/npcs/Kipo-Opo.lua | 53 | 1913 | -----------------------------------
-- Area: Windurst Waters
-- NPC: Kipo-Opo
-- Type: Cooking Adv. Image Support
-- @pos -119.750 -5.239 64.500 238
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/crafting");
require("scripts/zones/Windurst_Waters/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local guildMember = isGuildMember(player,4);
local SkillLevel = player:getSkillLevel(SKILL_COOKING);
local Cost = getAdvImageSupportCost(player,SKILL_COOKING);
if (guildMember == 1) then
if (player:hasStatusEffect(EFFECT_COOKING_IMAGERY) == false) then
player:startEvent(0x271F,Cost,SkillLevel,0,495,player:getGil(),0,0,0); -- p1 = skill level
else
player:startEvent(0x271F,Cost,SkillLevel,0,495,player:getGil(),28589,0,0);
end
else
player:startEvent(0x271F); -- Standard Dialogue
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
local Cost = getAdvImageSupportCost(player,SKILL_COOKING);
if (csid == 0x271F and option == 1) then
player:delGil(Cost);
player:messageSpecial(COOKING_SUPPORT,0,8,0);
player:addStatusEffect(EFFECT_COOKING_IMAGERY,3,0,480);
end
end; | gpl-3.0 |
mercury233/ygopro-scripts | c25472513.lua | 2 | 2478 | --天輪の双星道士
function c25472513.initial_effect(c)
--synchro summon
aux.AddSynchroProcedure(c,nil,aux.NonTuner(nil),1,1)
c:EnableReviveLimit()
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(25472513,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetCountLimit(1,25472513)
e1:SetCondition(c25472513.spcon)
e1:SetTarget(c25472513.sptg)
e1:SetOperation(c25472513.spop)
c:RegisterEffect(e1)
end
function c25472513.spcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
end
function c25472513.spfilter(c,e,tp)
return c:IsLevel(2) and not c:IsType(TYPE_TUNER) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_DEFENSE)
end
function c25472513.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c25472513.spfilter,tp,LOCATION_HAND+LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND+LOCATION_GRAVE)
end
function c25472513.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local ft=math.min((Duel.GetLocationCount(tp,LOCATION_MZONE)),4)
if ft>1 and Duel.IsPlayerAffectedByEffect(tp,59822133) then ft=1 end
if ft>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(c25472513.spfilter),tp,LOCATION_HAND+LOCATION_GRAVE,0,1,ft,nil,e,tp)
if g:GetCount()>0 then
local tc=g:GetFirst()
while tc do
Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP_DEFENSE)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_DISABLE)
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
tc:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_DISABLE_EFFECT)
e2:SetValue(RESET_TURN_SET)
e2:SetReset(RESET_EVENT+RESETS_STANDARD)
tc:RegisterEffect(e2)
tc=g:GetNext()
end
Duel.SpecialSummonComplete()
end
end
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(1,0)
e1:SetTarget(c25472513.splimit)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
end
function c25472513.splimit(e,c)
return not c:IsType(TYPE_SYNCHRO) and c:IsLocation(LOCATION_EXTRA)
end
| gpl-2.0 |
ZeroK-RTS/SpringRTS-Tools | aoplate baker/units/plategunship.lua | 1 | 3137 | return { plategunship = {
unitname = [[plategunship]],
name = [[Gunship Plate]],
description = [[Augments Production]],
acceleration = 0,
brakeRate = 0,
buildCostMetal = Shared.FACTORY_PLATE_COST,
builder = true,
buildingGroundDecalDecaySpeed = 30,
buildingGroundDecalSizeX = 8,
buildingGroundDecalSizeY = 8,
buildingGroundDecalType = [[pad_decal_square.dds]],
buildoptions = {
[[gunshipcon]],
[[gunshipbomb]],
[[gunshipemp]],
[[gunshipraid]],
[[gunshipskirm]],
[[gunshipheavyskirm]],
[[gunshipassault]],
[[gunshipkrow]],
[[gunshipaa]],
[[gunshiptrans]],
[[gunshipheavytrans]],
},
buildPic = [[plategunship.png]],
canMove = true,
canPatrol = true,
category = [[FLOAT UNARMED]],
collisionVolumeOffsets = [[0 0 0]],
collisionVolumeScales = [[86 86 86]],
collisionVolumeType = [[ellipsoid]],
selectionVolumeOffsets = [[0 10 0]],
selectionVolumeScales = [[104 60 96]],
selectionVolumeType = [[box]],
corpse = [[DEAD]],
customParams = {
landflystate = [[0]],
sortName = [[3]],
modelradius = [[43]],
nongroundfac = [[1]],
default_spacing = 4,
selectionscalemult = 1,
child_of_factory = [[factorygunship]],
},
energyUse = 0,
explodeAs = [[FAC_PLATEEX]],
footprintX = 5,
footprintZ = 5,
iconType = [[padgunship]],
idleAutoHeal = 5,
idleTime = 1800,
maxDamage = Shared.FACTORY_PLATE_HEALTH,
maxSlope = 15,
maxVelocity = 0,
maxWaterDepth = 0,
minCloakDistance = 150,
moveState = 1,
noAutoFire = false,
objectName = [[plate_gunship.s3o]],
script = [[plategunship.lua]],
selfDestructAs = [[FAC_PLATEEX]],
showNanoSpray = false,
sightDistance = 273,
turnRate = 0,
useBuildingGroundDecal = true,
workerTime = Shared.FACTORY_BUILDPOWER,
yardMap = [[yoooy ooooo ooooo ooooo yoooy]],
featureDefs = {
DEAD = {
blocking = true,
featureDead = [[HEAP]],
footprintX = 5,
footprintZ = 5,
object = [[plate_gunship_dead.s3o]],
},
HEAP = {
blocking = false,
footprintX = 5,
footprintZ = 5,
object = [[debris4x4c.s3o]],
},
},
} }
| gpl-2.0 |
mercury233/ygopro-scripts | c48421595.lua | 2 | 2592 | --ネクロ・シンクロン
function c48421595.initial_effect(c)
--code
aux.EnableChangeCode(c,19642774,LOCATION_MZONE+LOCATION_GRAVE)
--lv up
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(48421595,0))
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1,48421595)
e1:SetTarget(c48421595.lvltg)
e1:SetOperation(c48421595.lvlop)
c:RegisterEffect(e1)
--special summon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(48421595,1))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetProperty(EFFECT_FLAG_DELAY)
e2:SetCode(EVENT_BE_MATERIAL)
e2:SetCountLimit(1,48421596)
e2:SetCondition(c48421595.spcon)
e2:SetTarget(c48421595.sptg)
e2:SetOperation(c48421595.spop)
c:RegisterEffect(e2)
end
function c48421595.lvltg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsFaceup() and chkc:IsControler(tp) end
if chk==0 then return Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_MZONE,0,1,e:GetHandler()) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_MZONE,0,1,1,e:GetHandler())
end
function c48421595.lvlop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if tc:IsFaceup() and tc:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(c)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_LEVEL)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
e1:SetValue(2)
tc:RegisterEffect(e1)
end
end
function c48421595.spcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsLocation(LOCATION_GRAVE) and r==REASON_SYNCHRO and c:GetReasonCard():IsAttribute(ATTRIBUTE_WIND)
end
function c48421595.spfilter(c,e,tp)
return c:IsLevel(1) and c:IsRace(RACE_PLANT) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c48421595.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c48421595.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function c48421595.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<1 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c48421595.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 |
mercury233/ygopro-scripts | c43011492.lua | 3 | 1571 | --惨禍の呪眼
function c43011492.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,TIMING_END_PHASE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCountLimit(1,43011492+EFFECT_COUNT_CODE_OATH)
e1:SetCondition(c43011492.condition)
e1:SetTarget(c43011492.target)
e1:SetOperation(c43011492.activate)
c:RegisterEffect(e1)
end
function c43011492.filter(c)
return c:IsSetCard(0x129) and c:IsFaceup()
end
function c43011492.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsExistingMatchingCard(c43011492.filter,tp,LOCATION_MZONE,0,1,nil)
end
function c43011492.desfilter(c)
return c:IsType(TYPE_SPELL+TYPE_TRAP)
end
function c43011492.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() and c43011492.desfilter(chkc) and chkc:IsControler(1-tp) end
if chk==0 then return Duel.IsExistingTarget(c43011492.desfilter,tp,0,LOCATION_ONFIELD,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,c43011492.desfilter,tp,0,LOCATION_ONFIELD,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
end
function c43011492.filter1(c)
return c:IsCode(44133040) and c:IsFaceup()
end
function c43011492.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
if Duel.IsExistingMatchingCard(c43011492.filter1,tp,LOCATION_SZONE,0,1,nil) then
Duel.Destroy(tc,REASON_EFFECT,LOCATION_REMOVED)
else
Duel.Destroy(tc,REASON_EFFECT)
end
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c18511384.lua | 2 | 1409 | --融合回収
function c18511384.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_TOHAND)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(c18511384.target)
e1:SetOperation(c18511384.activate)
c:RegisterEffect(e1)
end
function c18511384.filter1(c)
return c:IsCode(24094653) and c:IsAbleToHand()
end
function c18511384.filter2(c)
return c:GetReason()&(REASON_FUSION+REASON_MATERIAL)==(REASON_FUSION+REASON_MATERIAL) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
end
function c18511384.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return false end
if chk==0 then return Duel.IsExistingTarget(c18511384.filter1,tp,LOCATION_GRAVE,0,1,nil)
and Duel.IsExistingTarget(c18511384.filter2,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g1=Duel.SelectTarget(tp,c18511384.filter1,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g2=Duel.SelectTarget(tp,c18511384.filter2,tp,LOCATION_GRAVE,0,1,1,nil)
g1:Merge(g2)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g1,2,0,0)
end
function c18511384.activate(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
local sg=g:Filter(Card.IsRelateToEffect,nil,e)
if sg:GetCount()>0 then
Duel.SendtoHand(sg,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,sg)
end
end
| gpl-2.0 |
AntonioModer/fuccboiGDX | fuccboi/resources/particles/sperm/loveframes/objects/internal/menuoption.lua | 3 | 5958 | --[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- menuoption object
local newobject = loveframes.NewObject("menuoption", "loveframes_object_menuoption", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(parent, option_type, menu)
self.type = "menuoption"
self.text = "Option"
self.width = 100
self.height = 25
self.contentwidth = 0
self.contentheight = 0
self.parent = parent
self.option_type = option_type or "option"
self.menu = menu
self.activated = false
self.internal = true
self.icon = false
self.func = nil
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
self:CheckHover()
local hover = self.hover
local parent = self.parent
local option_type = self.option_type
local activated = self.activated
local base = loveframes.base
local update = self.Update
if option_type == "submenu_activator" then
if hover and not activated then
self.menu:SetVisible(true)
self.menu:MoveToTop()
self.activated = true
elseif not hover and activated then
local hoverobject = loveframes.hoverobject
if hoverobject and hoverobject:GetBaseParent() == self.parent then
self.menu:SetVisible(false)
self.activated = false
end
elseif activated then
local screen_width = love.graphics.getWidth()
local screen_height = love.graphics.getHeight()
local sx = self.x
local sy = self.y
local width = self.width
local height = self.height
local x1 = sx + width
if x1 + self.menu.width <= screen_width then
self.menu.x = x1
else
self.menu.x = sx - self.menu.width
end
if sy + self.menu.height <= screen_height then
self.menu.y = sy
else
self.menu.y = (sy + height) - self.menu.height
end
end
end
-- move to parent if there is a parent
if parent ~= base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawMenuOption or skins[defaultskin].DrawMenuOption
local draw = self.Draw
local drawcount = loveframes.drawcount
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local hover = self.hover
local option_type = self.option_type
if hover and option_type ~= "divider" and button == "l" then
local func = self.func
if func then
local text = self.text
func(self, text)
end
local basemenu = self.parent:GetBaseMenu()
basemenu:SetVisible(false)
end
end
--[[---------------------------------------------------------
- func: SetText(text)
- desc: sets the object's text
--]]---------------------------------------------------------
function newobject:SetText(text)
self.text = text
end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the object's text
--]]---------------------------------------------------------
function newobject:GetText()
return self.text
end
--[[---------------------------------------------------------
- func: SetIcon(icon)
- desc: sets the object's icon
--]]---------------------------------------------------------
function newobject:SetIcon(icon)
if type(icon) == "string" then
self.icon = love.graphics.newImage(icon)
elseif type(icon) == "userdata" then
self.icon = icon
end
end
--[[---------------------------------------------------------
- func: GetIcon()
- desc: gets the object's icon
--]]---------------------------------------------------------
function newobject:GetIcon()
return self.icon
end
--[[---------------------------------------------------------
- func: SetFunction(func)
- desc: sets the object's function
--]]---------------------------------------------------------
function newobject:SetFunction(func)
self.func = func
end | mit |
Zenny89/darkstar | scripts/globals/items/balik_sis.lua | 35 | 1661 | -----------------------------------------
-- ID: 5600
-- Item: Balik Sis
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Dexterity 4
-- Mind -2
-- Attack % 13
-- Attack Cap 40
-- Ranged ACC 1
-- Ranged ATT % 13
-- Ranged ATT Cap 40
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,1800,5600);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEX, 4);
target:addMod(MOD_MND, -2);
target:addMod(MOD_FOOD_ATTP, 13);
target:addMod(MOD_FOOD_ATT_CAP, 40);
target:addMod(MOD_RACC, 1);
target:addMod(MOD_FOOD_RATTP, 13);
target:addMod(MOD_FOOD_RATT_CAP, 40);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_DEX, 4);
target:delMod(MOD_MND, -2);
target:delMod(MOD_FOOD_ATTP, 13);
target:delMod(MOD_FOOD_ATT_CAP, 40);
target:delMod(MOD_RACC, 1);
target:delMod(MOD_FOOD_RATTP, 13);
target:delMod(MOD_FOOD_RATT_CAP, 40);
end;
| gpl-3.0 |
ZeroK-RTS/SpringRTS-Tools | aoplate baker/plateamph.lua | 1 | 3258 | return { plateamph = {
unitname = [[plateamph]],
name = [[Amphbot Plate]],
description = [[Augments Production]],
buildCostMetal = Shared.FACTORY_PLATE_COST,
builder = true,
buildingGroundDecalDecaySpeed = 30,
buildingGroundDecalSizeX = 10,
buildingGroundDecalSizeY = 10,
buildingGroundDecalType = [[pad_decal.dds]],
buildoptions = {
[[amphcon]],
[[amphraid]],
[[amphimpulse]],
[[amphfloater]],
[[amphriot]],
[[amphassault]],
[[amphlaunch]],
[[amphaa]],
[[amphbomb]],
[[amphtele]],
},
buildPic = [[plateamph.png]],
canMove = true,
canPatrol = true,
category = [[UNARMED SINK]],
collisionVolumeOffsets = [[0 0 -16]],
collisionVolumeScales = [[104 70 36]],
collisionVolumeType = [[box]],
selectionVolumeOffsets = [[0 0 14]],
selectionVolumeScales = [[104 70 96]],
selectionVolumeType = [[box]],
corpse = [[DEAD]],
customParams = {
modelradius = [[100]],
aimposoffset = [[0 0 -26]],
midposoffset = [[0 0 -10]],
sortName = [[8]],
solid_factory = [[3]],
default_spacing = 4,
unstick_help = 1,
selectionscalemult = 1,
child_of_factory = [[factoryamph]],
cus_noflashlight = 1,
},
energyUse = 0,
explodeAs = [[FAC_PLATEEX]],
footprintX = 5,
footprintZ = 7,
iconType = [[padamph]],
idleAutoHeal = 5,
idleTime = 1800,
maxDamage = Shared.FACTORY_PLATE_HEALTH,
maxSlope = 15,
minCloakDistance = 150,
moveState = 1,
noAutoFire = false,
objectName = [[plate_amph.s3o]],
script = "plateamph.lua",
selfDestructAs = [[FAC_PLATEEX]],
showNanoSpray = false,
sightDistance = 273,
useBuildingGroundDecal = true,
workerTime = Shared.FACTORY_BUILDPOWER,
yardMap = [[ooooo ooooo ooooo yyyyy yyyyy yyyyy yyyyy]],
featureDefs = {
DEAD = {
blocking = true,
featureDead = [[HEAP]],
footprintX = 5,
footprintZ = 7,
object = [[plate_amph_dead.s3o]],
collisionVolumeOffsets = [[0 0 -16]],
collisionVolumeScales = [[104 70 36]],
collisionVolumeType = [[box]],
},
HEAP = {
blocking = false,
footprintX = 5,
footprintZ = 7,
object = [[debris4x4c.s3o]],
},
},
buildingGroundDecalDecaySpeed=30,
buildingGroundDecalSizeX=10,
buildingGroundDecalSizeY=10,
useBuildingGroundDecal = true,
buildingGroundDecalType=[[plateamph_aoplane.dds]],
}
| gpl-2.0 |
mercury233/ygopro-scripts | c27869883.lua | 9 | 1096 | --プリーステス・オーム
function c27869883.initial_effect(c)
--damage
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(27869883,0))
e1:SetCategory(CATEGORY_DAMAGE)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_MZONE)
e1:SetCost(c27869883.damcost)
e1:SetTarget(c27869883.damtg)
e1:SetOperation(c27869883.damop)
c:RegisterEffect(e1)
end
function c27869883.cfilter(c)
return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_DARK)
end
function c27869883.damcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckReleaseGroup(tp,c27869883.cfilter,1,nil) end
local g=Duel.SelectReleaseGroup(tp,c27869883.cfilter,1,1,nil)
Duel.Release(g,REASON_COST)
end
function c27869883.damtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetTargetPlayer(1-tp)
Duel.SetTargetParam(800)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,0,0,1-tp,800)
end
function c27869883.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 |
mercury233/ygopro-scripts | c9852718.lua | 4 | 1525 | --決別
function c9852718.initial_effect(c)
--activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCondition(c9852718.condition)
e1:SetCost(c9852718.cost)
e1:SetOperation(c9852718.activate)
c:RegisterEffect(e1)
end
function c9852718.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()~=tp and (Duel.GetCurrentPhase()>=PHASE_BATTLE_START and Duel.GetCurrentPhase()<=PHASE_BATTLE)
end
function c9852718.cfilter(c)
return c:IsType(TYPE_SPELL) and c:IsAbleToGraveAsCost()
end
function c9852718.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c9852718.cfilter,tp,LOCATION_HAND,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,c9852718.cfilter,tp,LOCATION_HAND,0,1,1,nil)
Duel.SendtoGrave(g,REASON_COST)
end
function c9852718.activate(e,tp,eg,ep,ev,re,r,rp)
Duel.SkipPhase(1-tp,PHASE_BATTLE,RESET_PHASE+PHASE_BATTLE_STEP,1)
local g=Duel.GetMatchingGroup(Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,nil)
local tc=g:GetFirst()
while tc do
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_DISABLE)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
local e2=Effect.CreateEffect(e:GetHandler())
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_DISABLE_EFFECT)
e2:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e2)
tc=g:GetNext()
end
end
| gpl-2.0 |
Zenny89/darkstar | scripts/globals/weaponskills/iron_tempest.lua | 30 | 1350 | -----------------------------------
-- Iron Tempest
-- Great Axe weapon skill
-- Skill Level: 40
-- Delivers a single-hit attack. Damage varies with TP.
-- Will stack with Sneak Attack.
-- Aligned with the Soil Gorget.
-- Aligned with the Soil Belt.
-- Element: None
-- Modifiers: STR:30%
-- 100%TP 200%TP 300%TP
-- 1.00 1.00 1.00
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID)
local params = {};
params.numHits = 1;
params.ftp100 = 1; params.ftp200 = 1; params.ftp300 = 1;
params.str_wsc = 0.3; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0;
params.canCrit = false;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.str_wsc = 0.6;
params.atkmulti = 1.25;
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params);
damage = damage * WEAPON_SKILL_POWER
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
mercury233/ygopro-scripts | c85121942.lua | 2 | 2760 | --CNo.105 BK 彗星のカエストス
function c85121942.initial_effect(c)
--xyz summon
aux.AddXyzProcedure(c,nil,5,4)
c:EnableReviveLimit()
--damage
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(85121942,0))
e1:SetCategory(CATEGORY_DAMAGE)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetCode(EVENT_BATTLE_DESTROYING)
e1:SetCondition(c85121942.damcon)
e1:SetTarget(c85121942.damtg)
e1:SetOperation(c85121942.damop)
c:RegisterEffect(e1)
--destroy
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_DESTROY+CATEGORY_DAMAGE)
e2:SetDescription(aux.Stringid(85121942,1))
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCountLimit(1)
e2:SetRange(LOCATION_MZONE)
e2:SetCondition(c85121942.descon)
e2:SetCost(c85121942.descost)
e2:SetTarget(c85121942.destg)
e2:SetOperation(c85121942.desop)
c:RegisterEffect(e2)
end
aux.xyz_number[85121942]=105
function c85121942.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 c85121942.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=math.floor(bc:GetTextAttack()/2)
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 c85121942.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
function c85121942.descon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():GetOverlayGroup():IsExists(Card.IsCode,1,nil,59627393)
end
function c85121942.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 c85121942.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) end
if chk==0 then return Duel.IsExistingTarget(aux.TRUE,tp,0,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,aux.TRUE,tp,0,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,g:GetFirst():GetAttack())
end
function c85121942.desop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsControler(1-tp) then
local atk=tc:GetAttack()
if atk<0 or tc:IsFacedown() then atk=0 end
if Duel.Destroy(tc,REASON_EFFECT)~=0 then
Duel.Damage(1-tp,atk,REASON_EFFECT)
end
end
end
| gpl-2.0 |
bryancall/trafficserver | tests/gold_tests/pluginTest/lua/watermark.lua | 6 | 1344 | -- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
function send_response()
-- Set Water Mark of Input Buffer
ts.http.resp_transform.set_upstream_watermark_bytes(31337)
local wm = ts.http.resp_transform.get_upstream_watermark_bytes()
ts.debug(string.format('WMbytes(%d)', wm))
return 0
end
function do_remap()
local req_host = ts.client_request.header.Host
if req_host == nil then
return 0
end
ts.hook(TS_LUA_RESPONSE_TRANSFORM, send_response)
ts.http.resp_cache_transformed(0)
ts.http.resp_cache_untransformed(1)
return 0
end
| apache-2.0 |
Zenny89/darkstar | scripts/globals/effects/addendum_black.lua | 74 | 1952 | -----------------------------------
--
--
--
-----------------------------------
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:recalculateAbilitiesTable();
local bonus = effect:getPower();
local helix = effect:getSubPower();
target:addMod(MOD_BLACK_MAGIC_COST, -bonus);
target:addMod(MOD_BLACK_MAGIC_CAST, -bonus);
target:addMod(MOD_BLACK_MAGIC_RECAST, -bonus);
if not (target:hasStatusEffect(EFFECT_TABULA_RASA)) then
target:addMod(MOD_BLACK_MAGIC_COST, -10);
target:addMod(MOD_BLACK_MAGIC_CAST, -10);
target:addMod(MOD_BLACK_MAGIC_RECAST, -10);
target:addMod(MOD_WHITE_MAGIC_COST, 20);
target:addMod(MOD_WHITE_MAGIC_CAST, 20);
target:addMod(MOD_WHITE_MAGIC_RECAST, 20);
target:addMod(MOD_HELIX_EFFECT, helix);
target:addMod(MOD_HELIX_DURATION, 72);
end
target:recalculateSkillsTable();
end;
-----------------------------------
-- onEffectTick Action
-----------------------------------
function onEffectTick(target,effect)
end;
-----------------------------------
-- onEffectLose Action
-----------------------------------
function onEffectLose(target,effect)
target:recalculateAbilitiesTable();
local bonus = effect:getPower();
local helix = effect:getSubPower();
target:delMod(MOD_BLACK_MAGIC_COST, -bonus);
target:delMod(MOD_BLACK_MAGIC_CAST, -bonus);
target:delMod(MOD_BLACK_MAGIC_RECAST, -bonus);
if not (target:hasStatusEffect(EFFECT_TABULA_RASA)) then
target:delMod(MOD_BLACK_MAGIC_COST, -10);
target:delMod(MOD_BLACK_MAGIC_CAST, -10);
target:delMod(MOD_BLACK_MAGIC_RECAST, -10);
target:delMod(MOD_WHITE_MAGIC_COST, 20);
target:delMod(MOD_WHITE_MAGIC_CAST, 20);
target:delMod(MOD_WHITE_MAGIC_RECAST, 20);
target:delMod(MOD_HELIX_EFFECT, helix);
target:delMod(MOD_HELIX_DURATION, 72);
end
target:recalculateSkillsTable();
end; | gpl-3.0 |
mercury233/ygopro-scripts | c95169481.lua | 6 | 1601 | --恐牙狼 ダイヤウルフ
function c95169481.initial_effect(c)
--xyz summon
aux.AddXyzProcedure(c,nil,4,2)
c:EnableReviveLimit()
--destroy
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(95169481,0))
e1:SetCategory(CATEGORY_DESTROY)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetCountLimit(1)
e1:SetRange(LOCATION_MZONE)
e1:SetCost(c95169481.descost)
e1:SetTarget(c95169481.destg)
e1:SetOperation(c95169481.desop)
c:RegisterEffect(e1)
end
function c95169481.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 c95169481.desfilter(c)
return c:IsFaceup() and c:IsRace(RACE_BEAST+RACE_WINDBEAST+RACE_BEASTWARRIOR)
and Duel.IsExistingTarget(aux.TRUE,0,LOCATION_ONFIELD,LOCATION_ONFIELD,1,c)
end
function c95169481.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return false end
if chk==0 then return Duel.IsExistingTarget(c95169481.desfilter,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g1=Duel.SelectTarget(tp,c95169481.desfilter,tp,LOCATION_MZONE,0,1,1,nil)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g2=Duel.SelectTarget(tp,aux.TRUE,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,g1:GetFirst())
g1:Merge(g2)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g1,g1:GetCount(),0,0)
end
function c95169481.desop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e)
Duel.Destroy(g,REASON_EFFECT)
end
| gpl-2.0 |
mercury233/ygopro-scripts | c61370518.lua | 2 | 1628 | --迅雷の魔王-スカル・デーモン
function c61370518.initial_effect(c)
--maintain
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EVENT_PHASE+PHASE_STANDBY)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1)
e1:SetCondition(c61370518.mtcon)
e1:SetOperation(c61370518.mtop)
c:RegisterEffect(e1)
--disable and destroy
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_CHAIN_SOLVING)
e2:SetRange(LOCATION_MZONE)
e2:SetOperation(c61370518.disop)
c:RegisterEffect(e2)
end
c61370518.toss_dice=true
function c61370518.mtcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==tp
end
function c61370518.mtop(e,tp,eg,ep,ev,re,r,rp)
if Duel.CheckLPCost(tp,500) or Duel.IsPlayerAffectedByEffect(tp,94585852) then
if not Duel.IsPlayerAffectedByEffect(tp,94585852)
or not Duel.SelectEffectYesNo(tp,e:GetHandler(),aux.Stringid(94585852,1)) then
Duel.PayLPCost(tp,500)
end
else
Duel.Destroy(e:GetHandler(),REASON_COST)
end
end
function c61370518.disop(e,tp,eg,ep,ev,re,r,rp)
if ep==tp then return end
if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then return false end
local tg=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS)
if not tg or not tg:IsContains(e:GetHandler()) or not Duel.IsChainDisablable(ev) then return false end
local rc=re:GetHandler()
local dc=Duel.TossDice(tp,1)
if dc==1 or dc==3 or dc==6 then
if Duel.NegateEffect(ev,true) and rc:IsRelateToEffect(re) then
Duel.Destroy(rc,REASON_EFFECT)
end
end
end
| gpl-2.0 |
Josepdal/DBTeam | plugins/spam.lua | 34 | 1560 | --------------------------------------------------
-- ____ ____ _____ --
-- | \| _ )_ _|___ ____ __ __ --
-- | |_ ) _ \ | |/ ·__| _ \_| \/ | --
-- |____/|____/ |_|\____/\_____|_/\/\_| --
-- --
--------------------------------------------------
-- --
-- Developers: @Josepdal & @MaSkAoS --
-- Support: @Skneos, @iicc1 & @serx666 --
-- --
--------------------------------------------------
local function kick_user(msg)
local chat = 'chat#id'..msg.to.id
local channel = 'channel#id'..msg.to.id
local user = msg.from.id
if msg.to.type == 'chat' then
chat_del_user(chat, 'user#id'..user, ok_cb, true)
elseif msg.to.type == 'channel' then
channel_kick_user(channel, 'user#id'..user, ok_cb, true)
end
end
local function run(msg, matches)
if not permissions(msg.from.id, msg.to.id, "settings") then
local hash = 'spam:'..msg.to.id
if redis:get(hash) then
kick_user(msg)
delete_msg(msg.id, ok_cb, false)
send_report(msg)
end
end
end
return {
patterns = {
-- You can add much as patterns you want to stop all spam traffic
"[Tt][Ee][Ll][Ee][Gg][Rr][Aa][Mm]%.[Mm][Ee]",
"[Tt][Ee][Ll][Ee][Gg][Rr][Aa][Mm]%.[Oo][Rr][Gg]",
"[Aa][Dd][Ff]%.[Ll][Yy]",
"[Bb][Ii][Tt]%.[Ll][Yy]",
"[Gg][Oo][Oo]%.[Gg][Ll]"
}, run = run}
| gpl-2.0 |
Zenny89/darkstar | scripts/globals/spells/absorb-chr.lua | 18 | 1298 | --------------------------------------
-- Spell: Absorb-CHR
-- Steals an enemy's Charism.
--------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
if (target:hasStatusEffect(EFFECT_CHR_DOWN) or caster:hasStatusEffect(EFFECT_CHR_BOOST)) then
spell:setMsg(75); -- no effect
else
local dINT = caster:getStat(MOD_INT) - target:getStat(MOD_INT);
local resist = applyResistance(caster,spell,target,dINT,37,0);
if (resist <= 0.125) then
spell:setMsg(85);
else
spell:setMsg(335);
caster:addStatusEffect(EFFECT_CHR_BOOST,ABSORB_SPELL_AMOUNT*resist*((100+(caster:getMod(MOD_AUGMENTS_ABSORB)))/100), ABSORB_SPELL_TICK, ABSORB_SPELL_AMOUNT*ABSORB_SPELL_TICK,FLAG_DISPELABLE); -- caster gains CHR
target:addStatusEffect(EFFECT_CHR_DOWN,ABSORB_SPELL_AMOUNT*resist*((100+(caster:getMod(MOD_AUGMENTS_ABSORB)))/100), ABSORB_SPELL_TICK, ABSORB_SPELL_AMOUNT*ABSORB_SPELL_TICK,FLAG_ERASBLE); -- target loses CHR
end
end
return EFFECT_CHR_DOWN;
end; | gpl-3.0 |
noname007/koreader | frontend/ui/message/zyremessagequeue.lua | 6 | 1413 | local ffi = require("ffi")
local DEBUG = require("dbg")
local util = require("ffi/util")
local Event = require("ui/event")
local MessageQueue = require("ui/message/messagequeue")
local dummy = require("ffi/zeromq_h")
local czmq = ffi.load("libs/libczmq.so.1")
local zyre = ffi.load("libs/libzyre.so.1")
local ZyreMessageQueue = MessageQueue:new{
header = {},
}
function ZyreMessageQueue:start()
self.node = zyre.zyre_new()
self.poller = czmq.zpoller_new(zyre.zyre_socket(self.node), nil)
for key, value in pairs(self.header) do
zyre.zyre_set_header(self.node, key, value)
end
--zyre.zyre_set_verbose(self.node)
zyre.zyre_set_interface(self.node, "wlan0")
zyre.zyre_start(self.node)
zyre.zyre_join(self.node, "GLOBAL")
--zyre.zyre_dump(self.node)
end
function ZyreMessageQueue:stop()
if self.node ~= nil then
DEBUG("stop zyre node")
zyre.zyre_stop(self.node)
zyre.zyre_destroy(ffi.new('zyre_t *[1]', self.node))
end
if self.poller ~= nil then
czmq.zpoller_destroy(ffi.new('zpoller_t *[1]', self.poller))
end
end
function ZyreMessageQueue:waitEvent()
if czmq.zpoller_wait(self.poller, 0) ~= nil then
local msg = zyre.zyre_recv(self.node)
if msg ~= nil then
table.insert(self.messages, msg)
end
end
return self:handleZMsgs(self.messages)
end
return ZyreMessageQueue
| agpl-3.0 |
mercury233/ygopro-scripts | c33918636.lua | 3 | 2571 | --超重武者カカ-C
function c33918636.initial_effect(c)
c:EnableReviveLimit()
--link summon
aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkSetCard,0x9a),1,1)
--cannot be link material
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL)
e1:SetValue(1)
c:RegisterEffect(e1)
--no damage
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetRange(LOCATION_MZONE)
e2:SetCondition(c33918636.condition)
e2:SetValue(1)
c:RegisterEffect(e2)
--special summon
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(33918636,0))
e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1,33918636)
e3:SetCondition(c33918636.condition)
e3:SetCost(c33918636.spcost)
e3:SetTarget(c33918636.sptg)
e3:SetOperation(c33918636.spop)
c:RegisterEffect(e3)
end
function c33918636.condition(e)
return Duel.GetMatchingGroupCount(Card.IsType,e:GetHandlerPlayer(),LOCATION_GRAVE,0,nil,TYPE_SPELL+TYPE_TRAP)==0
end
function c33918636.cfilter(c)
return c:IsType(TYPE_MONSTER) and c:IsDiscardable()
end
function c33918636.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c33918636.cfilter,tp,LOCATION_HAND,0,1,nil) end
Duel.DiscardHand(tp,c33918636.cfilter,1,1,REASON_COST+REASON_DISCARD)
end
function c33918636.spfilter(c,e,tp,zone)
return c:IsSetCard(0x9a) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_DEFENSE,tp,zone)
end
function c33918636.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local zone=bit.band(e:GetHandler():GetLinkedZone(tp),0x1f)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c33918636.spfilter(chkc,e,tp,zone) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c33918636.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp,zone) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c33918636.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp,zone)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c33918636.spop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
local zone=bit.band(e:GetHandler():GetLinkedZone(tp),0x1f)
if tc:IsRelateToEffect(e) and zone~=0 then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP_DEFENSE,zone)
end
end
| gpl-2.0 |
Zenny89/darkstar | scripts/zones/Port_San_dOria/npcs/Leonora.lua | 17 | 1498 | -----------------------------------
-- Area: Port San d'Oria
-- NPC: Leonora
-- Involved in Quest:
-- @zone 232
-- @pos -24 -8 15
-----------------------------------
package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/zones/Port_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- "Flyers for Regine" conditional script
FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE);
if (FlyerForRegine == 1) then
count = trade:getItemCount();
MagicFlyer = trade:hasItemQty(532,1);
if (MagicFlyer == true and count == 1) then
player:messageSpecial(FLYER_REFUSED);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getZPos() >= 12) then
player:startEvent(0x0206);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
Zenny89/darkstar | scripts/zones/Apollyon/mobs/Na_Qba_Chirurgeon.lua | 16 | 2315 | -----------------------------------
-- Area: Apollyon CS
-- NPC: Na_Qba_Chirurgeon
-----------------------------------
package.loaded["scripts/zones/Apollyon/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/limbus");
require("scripts/zones/Apollyon/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
mob:setMobMod(MOBMOD_SUPERLINK, mob:getShortID());
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
local mobID = mob:getID();
local X = mob:getXPos();
local Y = mob:getYPos();
local Z = mob:getZPos();
SpawnMob(16933139):setMobMod(MOBMOD_SUPERLINK, mob:getShortID());
SpawnMob(16933140):setMobMod(MOBMOD_SUPERLINK, mob:getShortID());
SpawnMob(16933138):setMobMod(MOBMOD_SUPERLINK, mob:getShortID());
end;
-----------------------------------
-- onMobFight Action
-----------------------------------
function onMobFight(mob,target)
local mobID = mob:getID();
local X = mob:getXPos();
local Y = mob:getYPos();
local Z = mob:getZPos();
local lifepourcent= ((mob:getHP()/mob:getMaxHP())*100);
local instancetime = target:getSpecialBattlefieldLeftTime(5);
if (lifepourcent < 50 and GetNPCByID(16933246):getAnimation() == 8) then
SpawnMob(16933142):setMobMod(MOBMOD_SUPERLINK, mob:getShortID());
SpawnMob(16933143):setMobMod(MOBMOD_SUPERLINK, mob:getShortID());
SpawnMob(16933141):setMobMod(MOBMOD_SUPERLINK, mob:getShortID());
GetNPCByID(16933246):setAnimation(9);
end
if (instancetime < 13) then
if (IsMobDead(16933129)==false) then
GetMobByID(16933129):updateEnmity(target);
elseif (IsMobDead(16933144)==false) then
GetMobByID(16933144):updateEnmity(target);
end
end
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob,killer)
if ((IsMobDead(16933129)==false or IsMobDead(16933144)==false) and alreadyReceived(killer,2,GetInstanceRegion(1294)) == false) then
killer:addTimeToSpecialBattlefield(5,5);
addLimbusList(killer,2,GetInstanceRegion(1294));
end
end; | gpl-3.0 |
focusworld/telemamal | plugins/meme.lua | 637 | 5791 | local helpers = require "OAuth.helpers"
local _file_memes = './data/memes.lua'
local _cache = {}
local function post_petition(url, arguments)
local response_body = {}
local request_constructor = {
url = url,
method = "POST",
sink = ltn12.sink.table(response_body),
headers = {},
redirect = false
}
local source = arguments
if type(arguments) == "table" then
local source = helpers.url_encode_arguments(arguments)
end
request_constructor.headers["Content-Type"] = "application/x-www-form-urlencoded"
request_constructor.headers["Content-Length"] = tostring(#source)
request_constructor.source = ltn12.source.string(source)
local ok, response_code, response_headers, response_status_line = http.request(request_constructor)
if not ok then
return nil
end
response_body = json:decode(table.concat(response_body))
return response_body
end
local function upload_memes(memes)
local base = "http://hastebin.com/"
local pet = post_petition(base .. "documents", memes)
if pet == nil then
return '', ''
end
local key = pet.key
return base .. key, base .. 'raw/' .. key
end
local function analyze_meme_list()
local function get_m(res, n)
local r = "<option.*>(.*)</option>.*"
local start = string.find(res, "<option.*>", n)
if start == nil then
return nil, nil
end
local final = string.find(res, "</option>", n) + #"</option>"
local sub = string.sub(res, start, final)
local f = string.match(sub, r)
return f, final
end
local res, code = http.request('http://apimeme.com/')
local r = "<option.*>(.*)</option>.*"
local n = 0
local f, n = get_m(res, n)
local ult = {}
while f ~= nil do
print(f)
table.insert(ult, f)
f, n = get_m(res, n)
end
return ult
end
local function get_memes()
local memes = analyze_meme_list()
return {
last_time = os.time(),
memes = memes
}
end
local function load_data()
local data = load_from_file(_file_memes)
if not next(data) or data.memes == {} or os.time() - data.last_time > 86400 then
data = get_memes()
-- Upload only if changed?
link, rawlink = upload_memes(table.concat(data.memes, '\n'))
data.link = link
data.rawlink = rawlink
serialize_to_file(data, _file_memes)
end
return data
end
local function match_n_word(list1, list2)
local n = 0
for k,v in pairs(list1) do
for k2, v2 in pairs(list2) do
if v2:find(v) then
n = n + 1
end
end
end
return n
end
local function match_meme(name)
local _memes = load_data()
local name = name:lower():split(' ')
local max = 0
local id = nil
for k,v in pairs(_memes.memes) do
local n = match_n_word(name, v:lower():split(' '))
if n > 0 and n > max then
max = n
id = v
end
end
return id
end
local function generate_meme(id, textup, textdown)
local base = "http://apimeme.com/meme"
local arguments = {
meme=id,
top=textup,
bottom=textdown
}
return base .. "?" .. helpers.url_encode_arguments(arguments)
end
local function get_all_memes_names()
local _memes = load_data()
local text = 'Last time: ' .. _memes.last_time .. '\n-----------\n'
for k, v in pairs(_memes.memes) do
text = text .. '- ' .. v .. '\n'
end
text = text .. '--------------\n' .. 'You can see the images here: http://apimeme.com/'
return text
end
local function callback_send(cb_extra, success, data)
if success == 0 then
send_msg(cb_extra.receiver, "Something wrong happened, probably that meme had been removed from server: " .. cb_extra.url, ok_cb, false)
end
end
local function run(msg, matches)
local receiver = get_receiver(msg)
if matches[1] == 'list' then
local _memes = load_data()
return 'I have ' .. #_memes.memes .. ' meme names.\nCheck this link to see all :)\n' .. _memes.link
elseif matches[1] == 'listall' then
if not is_sudo(msg) then
return "You can't list this way, use \"!meme list\""
else
return get_all_memes_names()
end
elseif matches[1] == "search" then
local meme_id = match_meme(matches[2])
if meme_id == nil then
return "I can't match that search with any meme."
end
return "With that search your meme is " .. meme_id
end
local searchterm = string.gsub(matches[1]:lower(), ' ', '')
local meme_id = _cache[searchterm] or match_meme(matches[1])
if not meme_id then
return 'I don\'t understand the meme name "' .. matches[1] .. '"'
end
_cache[searchterm] = meme_id
print("Generating meme: " .. meme_id .. " with texts " .. matches[2] .. ' and ' .. matches[3])
local url_gen = generate_meme(meme_id, matches[2], matches[3])
send_photo_from_url(receiver, url_gen, callback_send, {receiver=receiver, url=url_gen})
return nil
end
return {
description = "Generate a meme image with up and bottom texts.",
usage = {
"!meme search (name): Return the name of the meme that match.",
"!meme list: Return the link where you can see the memes.",
"!meme listall: Return the list of all memes. Only admin can call it.",
'!meme [name] - [text_up] - [text_down]: Generate a meme with the picture that match with that name with the texts provided.',
'!meme [name] "[text_up]" "[text_down]": Generate a meme with the picture that match with that name with the texts provided.',
},
patterns = {
"^!meme (search) (.+)$",
'^!meme (list)$',
'^!meme (listall)$',
'^!meme (.+) "(.*)" "(.*)"$',
'^!meme "(.+)" "(.*)" "(.*)"$',
"^!meme (.+) %- (.*) %- (.*)$"
},
run = run
}
| gpl-2.0 |
AntonioModer/fuccboiGDX | fuccboi/resources/particles/sperm/loveframes/objects/internal/columnlist/columnlistarea.lua | 3 | 9515 | --[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- columnlistarea class
local newobject = loveframes.NewObject("columnlistarea", "loveframes_object_columnlistarea", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: intializes the element
--]]---------------------------------------------------------
function newobject:initialize(parent)
self.type = "columnlistarea"
self.display = "vertical"
self.parent = parent
self.width = 80
self.height = 25
self.clickx = 0
self.clicky = 0
self.offsety = 0
self.offsetx = 0
self.extrawidth = 0
self.extraheight = 0
self.rowcolorindex = 1
self.rowcolorindexmax = 2
self.buttonscrollamount = parent.buttonscrollamount
self.mousewheelscrollamount = parent.mousewheelscrollamount
self.bar = false
self.dtscrolling = parent.dtscrolling
self.internal = true
self.internals = {}
self.children = {}
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local cwidth, cheight = self.parent:GetColumnSize()
local parent = self.parent
local base = loveframes.base
local update = self.Update
local internals = self.internals
local children = self.children
self:CheckHover()
-- move to parent if there is a parent
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
for k, v in ipairs(internals) do
v:update(dt)
end
for k, v in ipairs(children) do
v:update(dt)
v:SetClickBounds(self.x, self.y, self.width, self.height)
v.y = (v.parent.y + v.staticy) - self.offsety + cheight
v.x = (v.parent.x + v.staticx) - self.offsetx
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
local visible = self.visible
if not visible then
return
end
local x = self.x
local y = self.y
local width = self.width
local height = self.height
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
local loveversion = love._version
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawColumnListArea or skins[defaultskin].DrawColumnListArea
local drawoverfunc = skin.DrawOverColumnListArea or skins[defaultskin].DrawOverColumnListArea
local draw = self.Draw
local drawcount = loveframes.drawcount
local internals = self.internals
local children = self.children
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
if loveversion == "0.8.0" then
local stencil = love.graphics.newStencil(stencilfunc)
love.graphics.setStencil(stencil)
else
love.graphics.setStencil(stencilfunc)
end
for k, v in ipairs(children) do
local col = loveframes.util.BoundingBox(self.x, v.x, self.y, v.y, self.width, v.width, self.height, v.height)
if col == true then
v:draw()
end
end
love.graphics.setStencil()
for k, v in ipairs(internals) do
v:draw()
end
if not draw then
skin.DrawOverColumnListArea(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local toplist = self:IsTopList()
local scrollamount = self.mousewheelscrollamount
local internals = self.internals
local children = self.children
if self.hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
end
if self.bar and toplist then
local bar = self:GetScrollBar()
local dtscrolling = self.dtscrolling
if dtscrolling then
local dt = love.timer.getDelta()
if button == "wu" then
bar:Scroll(-scrollamount * dt)
elseif button == "wd" then
bar:Scroll(scrollamount * dt)
end
else
if button == "wu" then
bar:Scroll(-scrollamount)
elseif button == "wd" then
bar:Scroll(scrollamount)
end
end
end
for k, v in ipairs(internals) do
v:mousepressed(x, y, button)
end
for k, v in ipairs(children) do
v:mousepressed(x, y, button)
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local internals = self.internals
local children = self.children
for k, v in ipairs(internals) do
v:mousereleased(x, y, button)
end
for k, v in ipairs(children) do
v:mousereleased(x, y, button)
end
end
--[[---------------------------------------------------------
- func: CalculateSize()
- desc: calculates the size of the object's children
--]]---------------------------------------------------------
function newobject:CalculateSize()
local columnheight = self.parent.columnheight
local numitems = #self.children
local height = self.height
local width = self.width
local itemheight = columnheight
local itemwidth = 0
local bar = self.bar
local children = self.children
for k, v in ipairs(children) do
itemheight = itemheight + v.height
end
self.itemheight = itemheight
if self.itemheight > height then
self.extraheight = self.itemheight - height
if not bar then
table.insert(self.internals, loveframes.objects["scrollbody"]:new(self, "vertical"))
self.bar = true
self:GetScrollBar().autoscroll = self.parent.autoscroll
end
else
if bar then
self.internals[1]:Remove()
self.bar = false
self.offsety = 0
end
end
end
--[[---------------------------------------------------------
- func: RedoLayout()
- desc: used to redo the layour of the object
--]]---------------------------------------------------------
function newobject:RedoLayout()
local children = self.children
local starty = 0
local startx = 0
local bar = self.bar
local display = self.display
if #children > 0 then
for k, v in ipairs(children) do
local height = v.height
v.staticx = startx
v.staticy = starty
if bar then
v:SetWidth(self.width - self.internals[1].width)
self.internals[1].staticx = self.width - self.internals[1].width
self.internals[1].height = self.height
else
v:SetWidth(self.width)
end
starty = starty + v.height
v.lastheight = v.height
end
end
end
--[[---------------------------------------------------------
- func: AddRow(data)
- desc: adds a row to the object
--]]---------------------------------------------------------
function newobject:AddRow(data)
local row = loveframes.objects["columnlistrow"]:new(self, data)
local colorindex = self.rowcolorindex
local colorindexmax = self.rowcolorindexmax
if colorindex == colorindexmax then
self.rowcolorindex = 1
else
self.rowcolorindex = colorindex + 1
end
table.insert(self.children, row)
self:CalculateSize()
self:RedoLayout()
self.parent:AdjustColumns()
end
--[[---------------------------------------------------------
- func: GetScrollBar()
- desc: gets the object's scroll bar
--]]---------------------------------------------------------
function newobject:GetScrollBar()
local internals = self.internals
if self.bar then
local scrollbody = internals[1]
local scrollarea = scrollbody.internals[1]
local scrollbar = scrollarea.internals[1]
return scrollbar
else
return false
end
end
--[[---------------------------------------------------------
- func: Sort()
- desc: sorts the object's children
--]]---------------------------------------------------------
function newobject:Sort(column, desc)
self.rowcolorindex = 1
local colorindexmax = self.rowcolorindexmax
local children = self.children
table.sort(children, function(a, b)
if desc then
return (tostring(a.columndata[column]) or a.columndata[column]) < (tostring(b.columndata[column]) or b.columndata[column])
else
return (tostring(a.columndata[column]) or a.columndata[column]) > (tostring(b.columndata[column]) or b.columndata[column])
end
end)
for k, v in ipairs(children) do
local colorindex = self.rowcolorindex
v.colorindex = colorindex
if colorindex == colorindexmax then
self.rowcolorindex = 1
else
self.rowcolorindex = colorindex + 1
end
end
self:CalculateSize()
self:RedoLayout()
end
--[[---------------------------------------------------------
- func: Clear()
- desc: removes all items from the object's list
--]]---------------------------------------------------------
function newobject:Clear()
self.children = {}
self:CalculateSize()
self:RedoLayout()
self.parent:AdjustColumns()
end | mit |
mercury233/ygopro-scripts | c28929131.lua | 2 | 3840 | --時械神ザフィオン
function c28929131.initial_effect(c)
--cannot special summon
local e1=Effect.CreateEffect(c)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_SINGLE_RANGE)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetRange(LOCATION_DECK)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
c:RegisterEffect(e1)
--summon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(28929131,0))
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_SUMMON_PROC)
e2:SetCondition(c28929131.ntcon)
c:RegisterEffect(e2)
--indes
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e3:SetRange(LOCATION_MZONE)
e3:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e3:SetValue(1)
c:RegisterEffect(e3)
local e4=e3:Clone()
e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
c:RegisterEffect(e4)
local e5=e3:Clone()
e5:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
c:RegisterEffect(e5)
--to deck
local e6=Effect.CreateEffect(c)
e6:SetDescription(aux.Stringid(28929131,1))
e6:SetCategory(CATEGORY_TODECK)
e6:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e6:SetCode(EVENT_PHASE+PHASE_BATTLE)
e6:SetCountLimit(1)
e6:SetRange(LOCATION_MZONE)
e6:SetCondition(c28929131.tdcon)
e6:SetTarget(c28929131.tdtg)
e6:SetOperation(c28929131.tdop)
c:RegisterEffect(e6)
--draw
local e7=Effect.CreateEffect(c)
e7:SetDescription(aux.Stringid(28929131,2))
e7:SetCategory(CATEGORY_DRAW)
e7:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e7:SetProperty(EFFECT_FLAG_DELAY)
e7:SetCode(EVENT_TO_GRAVE)
e7:SetCountLimit(1)
e7:SetCondition(c28929131.drcon)
e7:SetTarget(c28929131.drtg)
e7:SetOperation(c28929131.drop)
c:RegisterEffect(e7)
--to deck
local e8=Effect.CreateEffect(c)
e8:SetDescription(aux.Stringid(28929131,3))
e8:SetCategory(CATEGORY_TODECK)
e8:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e8:SetCode(EVENT_PHASE+PHASE_STANDBY)
e8:SetCountLimit(1)
e8:SetRange(LOCATION_MZONE)
e8:SetCondition(c28929131.rtdcon)
e8:SetTarget(c28929131.rtdtg)
e8:SetOperation(c28929131.rtdop)
c:RegisterEffect(e8)
end
function c28929131.ntcon(e,c,minc)
if c==nil then return true end
return minc==0 and c:IsLevelAbove(5)
and Duel.GetFieldGroupCount(c:GetControler(),LOCATION_MZONE,0)==0
and Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0
end
function c28929131.tdcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():GetBattledGroupCount()>0
end
function c28929131.tdfilter(c)
return c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToDeck()
end
function c28929131.tdtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local g=Duel.GetMatchingGroup(c28929131.tdfilter,tp,0,LOCATION_ONFIELD,nil)
Duel.SetOperationInfo(0,CATEGORY_TODECK,g,g:GetCount(),0,0)
end
function c28929131.tdop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(c28929131.tdfilter,tp,0,LOCATION_ONFIELD,nil)
if g:GetCount()>0 then
Duel.SendtoDeck(g,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)
end
end
function c28929131.drcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD)
end
function c28929131.drtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end
Duel.SetTargetPlayer(tp)
Duel.SetTargetParam(1)
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1)
end
function c28929131.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
function c28929131.rtdcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==tp
end
function c28929131.rtdtg(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 c28929131.rtdop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) then
Duel.SendtoDeck(c,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)
end
end
| gpl-2.0 |
yipf/lua-svg | svg.last.lua | 1 | 15770 |
local gmatch=string.gmatch
local obj={}
local str2args=function(str)
local n=0
for w in gmatch(str.."|","(.-)|") do
n=n+1;obj[n]=w
end
return unpack(obj,1,n)
end
--~ add_shape=function(svg,pos,style,rx,ry)
--~ local m=svg.m,svg.shapes
--~ local r,c=unpack(pos)
--~ local shape,arg1,arg2=str2args(style)
--~ local mr=m[r]
--~ if not mr then mr={}; m[r]=mr end
--~ mr[c]={shape=shape or "rect",arg1=arg1, arg2=arg2, rx=rx,ry=ry}
--~ return pos
--~ end
local push=table.insert
add_path=function(svg,style,...)
local paths=svg.paths
arg.style=style
push(paths,arg)
return paths
end
add_label=function(svg,pos,label,dir)
local labels=svg.labels
local l={label=label,dir=dir,pos=pos}
push(labels,l)
return pos
end
add_shape=function(svg,pos,shape,rx,ry)
local shapes=svg.shapes
local s={shape=shape,pos=pos,rx=rx,ry=ry}
push(shapes,s)
return pos
end
add_image=function(svg,pos,src,rx,ry)
local shapes=svg.shapes
local s={shape="img",src=src,pos=pos,rx=rx,ry=ry}
push(shapes,s)
return pos
end
add_unit=function(svg,pos,shape,rx,ry)
local m=svg.m
local r,c=unpack(pos)
local mr=m[r]
if not mr then mr={}; m[r]=mr end
mr[c]={shape=shape,rx=rx,ry=ry}
return pos
end
add_node=function(g,pos,label,shape,rx,ry)
add_label(g,pos,label,"CM")
add_unit(g,pos,shape,rx,ry)
return add_shape(g,pos,shape,rx,ry)
end
add_edge=function(g,from,to,label,shape,style,off)
local pt={from,to}
local fr,fc,tr,tc=from[1],from[2],to[1],to[2]
local lr,lc,dir=(fr+tr)/2,(fc+tc)/2,"CM"
shape=shape or "-"
style=style or "solid"
off=off or 1
if shape=="-" then
elseif shape=="7" then
lr=fr;lc=tc;
push(pt,2,{lr,lc})
elseif shape=="L" then
lr=tr;lc=fc;
push(pt,2,{lr,lc})
elseif shape=="Z" then
push(pt,2,{fr,lc})
push(pt,3,{tr,lc})
elseif shape=="N" then
push(pt,2,{lr,fc})
push(pt,3,{lr,tc})
elseif shape=="C" then
lc= fc>tc and tc-off or tc+off
push(pt,2,{fr,lc})
push(pt,3,{tr,lc})
elseif shape=="U" then
lr=fr<tr and tr+off or tr-off
push(pt,2,{lr,fc})
push(pt,3,{lr,tc})
end
local pos={lr,lc}
if label then
local fs=g.fs
add_shape(g,pos,"label_bg",(string.len(label)*fs/4),fs/2)
add_label(g,pos,label,dir)
end
add_path(g,style,unpack(pt))
return pos
end
make_g=function(x,y,w,h,row,col,fs)
x=x or 0; y=y or 0; w=w or 600; h=h or 600
row=row or 2; col=col or 2;
return {x=x,y=y,w=w,h=h,cw=w/col,ch=h/row,fs=fs,m={},shapes={},paths={},labels={},fs=fs or 16}
end
local SHAPES
local type=type
local make_eval_f=function(env)
local f
local loadstring,setfenv=loadstring,setfenv
return function(str)
f=loadstring("return "..str)
return f and setfenv(f,env)()
end
end
local gsub=string.gsub
local convert=function(tp,o)
local tmp=SHAPES[tp]
if not tmp then return "No invalid handle for: "..tp end
return type(tmp)=="function" and tmp(o) or (gsub(tmp,"@%s*(.-)%s*@",type(o)=="table" and make_eval_f(o) or o))
end
local POINT_FMT="%s %d %d"
local format=string.format
local CUBIC_CURVE_POINT="M %d %d C %d %d %d %d %d %d"
local QUADRATIC_CURVE_POINT="M %d %d Q %d %d %d %d"
local points2str=function(t,curve)
local n=#t
if curve and n==4 then return format(CUBIC_CURVE_POINT,t[1][1],t[1][2],t[2][1],t[2][2],t[3][1],t[3][2],t[4][1],t[4][2]) end
if curve and n==3 then return format(QUADRATIC_CURVE_POINT,t[1][1],t[1][2],t[2][1],t[2][2],t[3][1],t[3][2]) end
for i,v in ipairs(t) do
t[i]= format(POINT_FMT,i==1 and "M" or "L",unpack(v))
end
return table.concat(t," ")
end
local offset=function(from,to,rx)
return from>to and rx or from<to and -rx or 0
end
local match=string.match
local dir2off=function(dir,fs)
dir=dir or "CM"
local ox,oy,align,valign=0,0,"middle","middle"
local off
off=match(dir,"M()") if off then oy=fs/2 end
off=match(dir,"C()") if off then align="middle" end
off=match(dir,"D(%d*)") if off then oy=fs+(tonumber(off) or 0) end
off=match(dir,"U(%d*)") if off then oy=-(tonumber(off) or 0) end
off=match(dir,"L(%d*)") if off then align="end";ox=-(tonumber(off) or 0) end
off=match(dir,"R(%d*)") if off then ox=(tonumber(off) or 0); align="start" end
return ox,oy,align,valign
end
export=function(svg,path)
local m,x,y,cw,ch,fs=svg.m,svg.x,svg.y,svg.cw,svg.ch,svg.fs
local push=table.insert
local t={}
local rx,ry,cx,cy=cw/3,ch/6
-- draw paths
local paths=svg.paths
local style,pre,nex,ps,cx,cy
local pt,mr
for i,v in ipairs(paths) do
ps=#v
if ps>1 then
pt={}
for ii,vv in ipairs(v) do
cy=vv[1]*ch; cx=vv[2]*cw;
mr=m[vv[1]]
n=mr and mr[vv[2]]
if ii==1 and n then -- come from a node
nex=v[2]
cx=cx+offset(nex[2],vv[2],n.rx or rx)
cy=cy+offset(nex[1],vv[1],n.ry or ry)
elseif ii==ps and n then -- point to a node
pre=v[ps-1]
cx=cx+offset(pre[2],vv[2],n.rx or rx)
cy=cy+offset(pre[1],vv[1],n.ry or ry)
end
pt[ii]={cx,cy}
end
local style,curve=str2args(v.style)
print(style)
push(t,convert(style,points2str(pt,curve)))
end
end
-- draw shapes
--~ local n
--~ for i,mr in pairs(m) do
--~ for j,n in pairs(mr) do
--~ n.cx,n.cy=j*cw,i*ch
--~ n.rx,n.ry=n.rx or rx, n.ry or ry
--~ n.fs=fs
--~ push(t,convert(n.shape,n))
--~ end
--~ end
local shapes=svg.shapes
local n,r,c,cx,cy
for i,v in ipairs(shapes) do
r,c=unpack(v.pos)
cx,cy=c*cw,r*ch
v.cx,v.cy=cx,cy
v.rx,v.ry=v.rx or rx, v.ry or ry
v.fs=fs
push(t,convert(v.shape,v))
end
-- draw labels
local labels=svg.labels
local dir,r,c,offset,ox,oy,align,valign
for i,v in ipairs(labels) do
r,c=unpack(v.pos)
cx,cy=c*cw,r*ch
ox,oy,align,valign=dir2off(v.dir,fs)
v.cx=cx+ox; v.cy=cy+oy; v.align=align;
push(t,convert("label",v))
end
-- draw g
svg.VALUE=table.concat(t,"\n")
local str=convert("SVG",svg)
if not path then print(str) return end
local f=path and io.open(path,"w")
if f then f:write(str); f:close() end
end
SHAPES={
ellipse=[[<ellipse cx="@cx@" cy="@cy@" rx="@rx@" ry="@ry@" fill="url(#node)"/>]],
roundrect=[[<rect x="@cx-rx@" y="@cy-ry@" rx="10" ry="10" width="@rx+rx@" height="@ry+ry@" fill="url(#node)"/>]],
rect=[[<rect x="@cx-rx@" y="@cy-ry@" width="@rx+rx@" height="@ry+ry@" fill="url(#node)"/>]],
label=[[<text x="@cx@" y="@cy@" stroke-width="0" fill="black" text-anchor="@align@" vertical-align="@valign@">@label@</text>]],
label_bg=[[<rect x="@cx-rx@" y="@cy-ry@" rx="10" ry="10" width="@rx+rx@" height="@ry+ry@" fill="#ffffff" stroke="none"/>]],
img=[[<image x="@cx+rx@" y="@cy+ry@" width="@rx+rx@" height="@ry+ry@" xlink:href="@src@" />]],
point=[[<circle cx="@cx@" cy="@cy@" r="@rx@" fill="url(#point)" />]],
solid=[[<path d = "@path@" fill = "none" stroke = "black" stroke-linejoin="round" marker-end = "url(#arrow-head)" marker-mid="url(#middle)"/>]],
dashed=[[<path d = "@path@" fill = "none" stroke = "black" stroke-linejoin="round" marker-end = "url(#arrow-head)" style="stroke-dasharray:10,3"/>]],
dotted=[[<path d = "@path@" fill = "none" stroke = "black" stroke-linejoin="round" marker-end = "url(#arrow-head)" style="stroke-dasharray:3,3"/>]],
-- complex shapes
diamond=[[<path d="M @cx-rx@ @cy@ L @cx@ @cy-ry@ L @cx+rx@ @cy@ L @cx@ @cy+ry@ z" fill="url(#node)" />]],
round1=[[<path d="M @cx-rx+ry@ @cy-ry@ Q @cx-rx@ @cy-ry@ @cx-rx@ @cy@ T @cx-rx+ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ Q @cx+rx@ @cy+ry@ @cx+rx@ @cy@ T @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" />]],
round2=[[<path d="M @cx-rx-ry@ @cy-ry@ Q @cx-rx@ @cy-ry@ @cx-rx@ @cy@ T @cx-rx-ry@ @cy+ry@ L @cx+rx+ry@ @cy+ry@ Q @cx+rx@ @cy+ry@ @cx+rx@ @cy@ T @cx+rx+ry@ @cy-ry@ z " fill="url(#node)" />]],
round3=[[<path d="M @cx-rx+ry@ @cy-ry@ Q @cx-rx@ @cy-ry@ @cx-rx@ @cy@ T @cx-rx+ry@ @cy+ry@ L @cx+rx+ry@ @cy+ry@ Q @cx+rx@ @cy+ry@ @cx+rx@ @cy@ T @cx+rx+ry@ @cy-ry@ z " fill="url(#node)" />]],
round4=[[<path d="M @cx-rx-ry@ @cy-ry@ Q @cx-rx@ @cy-ry@ @cx-rx@ @cy@ T @cx-rx-ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ Q @cx+rx@ @cy+ry@ @cx+rx@ @cy@ T @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" />]],
case1=[[<path d="M @cx-rx+ry@ @cy-ry@ L @cx-rx@ @cy@ L @cx-rx+ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ L @cx+rx@ @cy@ L @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" />]],
case2=[[<path d="M @cx-rx+ry@ @cy-ry@ L @cx-rx@ @cy-ry@ L @cx-rx+ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ L @cx+rx@ @cy+ry@ L @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" />]],
case3=[[<path d="M @cx-rx+ry@ @cy-ry@ L @cx-rx@ @cy-ry@ L @cx-rx+ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ L @cx+rx@ @cy+ry@ L @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" />]],
case4=[[<path d="M @cx-rx+ry@ @cy-ry@ L @cx-rx@ @cy-ry@ L @cx-rx+ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ L @cx+rx@ @cy+ry@ L @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" />]],
['round2-shadow']=[[<path d="M @cx-rx-ry@ @cy-ry@ Q @cx-rx@ @cy-ry@ @cx-rx@ @cy@ T @cx-rx-ry@ @cy+ry@ L @cx+rx+ry@ @cy+ry@ Q @cx+rx@ @cy+ry@ @cx+rx@ @cy@ T @cx+rx+ry@ @cy-ry@ z " fill="url(#node)" filter='url(#shadow)' /><path d="M @cx-rx-ry@ @cy-ry@ Q @cx-rx@ @cy-ry@ @cx-rx@ @cy@ T @cx-rx-ry@ @cy+ry@ L @cx+rx+ry@ @cy+ry@ Q @cx+rx@ @cy+ry@ @cx+rx@ @cy@ T @cx+rx+ry@ @cy-ry@ z " fill="url(#node)" /> ]],
['point-shadow']=[[<circle cx="@cx@" cy="@cy@" r="@rx@" fill="url(#point)" filter='url(#shadow)' /><circle cx="@cx@" cy="@cy@" r="@rx@" fill="url(#point)" /> ]],
['label-shadow']=[[<text x="@cx@" y="@cy@" stroke-width="0" fill="black" text-anchor="@align@" vertical-align="@valign@">@label@</text>]],
['ellipse-shadow']=[[<ellipse cx="@cx@" cy="@cy@" rx="@rx@" ry="@ry@" fill="url(#node)" filter='url(#shadow)'/><ellipse cx="@cx@" cy="@cy@" rx="@rx@" ry="@ry@" fill="url(#node)" />]],
['label_bg-shadow']=[[<rect x="@cx-rx@" y="@cy-ry@" rx="10" ry="10" width="@rx+rx@" height="@ry+ry@" fill="#ffffff" stroke="none" filter='url(#shadow)' /><rect x="@cx-rx@" y="@cy-ry@" rx="10" ry="10" width="@rx+rx@" height="@ry+ry@" fill="#ffffff" stroke="none"/> ]],
['diamond-shadow']=[[<path d="M @cx-rx@ @cy@ L @cx@ @cy-ry@ L @cx+rx@ @cy@ L @cx@ @cy+ry@ z" fill="url(#node)" filter='url(#shadow)' /><path d="M @cx-rx@ @cy@ L @cx@ @cy-ry@ L @cx+rx@ @cy@ L @cx@ @cy+ry@ z" fill="url(#node)" /> ]],
['case1-shadow']=[[<path d="M @cx-rx+ry@ @cy-ry@ L @cx-rx@ @cy@ L @cx-rx+ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ L @cx+rx@ @cy@ L @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" filter='url(#shadow)' /><path d="M @cx-rx+ry@ @cy-ry@ L @cx-rx@ @cy@ L @cx-rx+ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ L @cx+rx@ @cy@ L @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" /> ]],
['dashed-shadow']=[[<path d = "@path@" fill = "none" stroke = "black" stroke-linejoin="round" marker-end = "url(#arrow-head)" style="stroke-dasharray:10,3" filter='url(#shadow)' /><path d = "@path@" fill = "none" stroke = "black" stroke-linejoin="round" marker-end = "url(#arrow-head)" style="stroke-dasharray:10,3"/> ]],
['round3-shadow']=[[<path d="M @cx-rx+ry@ @cy-ry@ Q @cx-rx@ @cy-ry@ @cx-rx@ @cy@ T @cx-rx+ry@ @cy+ry@ L @cx+rx+ry@ @cy+ry@ Q @cx+rx@ @cy+ry@ @cx+rx@ @cy@ T @cx+rx+ry@ @cy-ry@ z " fill="url(#node)" filter='url(#shadow)' /><path d="M @cx-rx+ry@ @cy-ry@ Q @cx-rx@ @cy-ry@ @cx-rx@ @cy@ T @cx-rx+ry@ @cy+ry@ L @cx+rx+ry@ @cy+ry@ Q @cx+rx@ @cy+ry@ @cx+rx@ @cy@ T @cx+rx+ry@ @cy-ry@ z " fill="url(#node)" /> ]],
['dotted-shadow']=[[<path d = "@path@" fill = "none" stroke = "black" stroke-linejoin="round" marker-end = "url(#arrow-head)" style="stroke-dasharray:3,3" filter='url(#shadow)' /><path d = "@path@" fill = "none" stroke = "black" stroke-linejoin="round" marker-end = "url(#arrow-head)" style="stroke-dasharray:3,3"/> ]],
['case4-shadow']=[[<path d="M @cx-rx+ry@ @cy-ry@ L @cx-rx@ @cy-ry@ L @cx-rx+ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ L @cx+rx@ @cy+ry@ L @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" filter='url(#shadow)' /><path d="M @cx-rx+ry@ @cy-ry@ L @cx-rx@ @cy-ry@ L @cx-rx+ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ L @cx+rx@ @cy+ry@ L @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" /> ]],
['solid-shadow']=[[<path d = "@path@" fill = "none" stroke = "black" stroke-linejoin="round" marker-end = "url(#arrow-head)" filter='url(#shadow)' /><path d = "@path@" fill = "none" stroke = "black" stroke-linejoin="round" marker-end = "url(#arrow-head)" /> ]],
['rect-shadow']=[[<rect x="@cx-rx@" y="@cy-ry@" width="@rx+rx@" height="@ry+ry@" fill="url(#node)" filter='url(#shadow)' /><rect x="@cx-rx@" y="@cy-ry@" width="@rx+rx@" height="@ry+ry@" fill="url(#node)"/> ]],
['case2-shadow']=[[<path d="M @cx-rx+ry@ @cy-ry@ L @cx-rx@ @cy-ry@ L @cx-rx+ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ L @cx+rx@ @cy+ry@ L @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" filter='url(#shadow)' /><path d="M @cx-rx+ry@ @cy-ry@ L @cx-rx@ @cy-ry@ L @cx-rx+ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ L @cx+rx@ @cy+ry@ L @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" /> ]],
['roundrect-shadow']=[[<rect x="@cx-rx@" y="@cy-ry@" rx="10" ry="10" width="@rx+rx@" height="@ry+ry@" fill="url(#node)" filter='url(#shadow)' /><rect x="@cx-rx@" y="@cy-ry@" rx="10" ry="10" width="@rx+rx@" height="@ry+ry@" fill="url(#node)"/> ]],
['round1-shadow']=[[<path d="M @cx-rx+ry@ @cy-ry@ Q @cx-rx@ @cy-ry@ @cx-rx@ @cy@ T @cx-rx+ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ Q @cx+rx@ @cy+ry@ @cx+rx@ @cy@ T @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" filter='url(#shadow)' /><path d="M @cx-rx+ry@ @cy-ry@ Q @cx-rx@ @cy-ry@ @cx-rx@ @cy@ T @cx-rx+ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ Q @cx+rx@ @cy+ry@ @cx+rx@ @cy@ T @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" /> ]],
['case3-shadow']=[[<path d="M @cx-rx+ry@ @cy-ry@ L @cx-rx@ @cy-ry@ L @cx-rx+ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ L @cx+rx@ @cy+ry@ L @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" filter='url(#shadow)' /><path d="M @cx-rx+ry@ @cy-ry@ L @cx-rx@ @cy-ry@ L @cx-rx+ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ L @cx+rx@ @cy+ry@ L @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" /> ]],
['round4-shadow']=[[<path d="M @cx-rx-ry@ @cy-ry@ Q @cx-rx@ @cy-ry@ @cx-rx@ @cy@ T @cx-rx-ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ Q @cx+rx@ @cy+ry@ @cx+rx@ @cy@ T @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" filter='url(#shadow)' /><path d="M @cx-rx-ry@ @cy-ry@ Q @cx-rx@ @cy-ry@ @cx-rx@ @cy@ T @cx-rx-ry@ @cy+ry@ L @cx+rx-ry@ @cy+ry@ Q @cx+rx@ @cy+ry@ @cx+rx@ @cy@ T @cx+rx-ry@ @cy-ry@ z " fill="url(#node)" /> ]],
['img-shadow']=[[<image x="@cx+rx@" y="@cy+ry@" width="@rx+rx@" height="@ry+ry@" xlink:href="@src@" filter='url(#shadow)' /><image x="@cx+rx@" y="@cy+ry@" width="@rx+rx@" height="@ry+ry@" xlink:href="@src@" /> ]],
SVG=[[
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="@w@" height="@h@" version="1.1"
xmlns="http://www.w3.org/2000/svg" font-size="@fs@" stroke-width = "1.5" fill="white" stroke="black">
<defs>
<marker id="arrow-head" viewBox="0 0 20 20" refX="20" refY="10" markerUnits="strokeWidth" fill="black" markerWidth="8" markerHeight="6" orient="auto">
<path d="M 0 0 L 20 10 L 0 20 L 10 10 z"/>
</marker>
<marker id="middle" viewBox="0 0 20 20" refX="10" refY="10" markerUnits="strokeWidth" fill="orange" markerWidth="6" markerHeight="6" orient="auto">
<circle cx="10" cy="10" r="10" />
</marker>
<filter id='shadow' filterRes='50' x='0' y='0'>
<feGaussianBlur stdDeviation='2 2'/>
<feOffset dx='2' dy='2'/>
</filter>
<linearGradient x1='0%' x2='100%' id='node' y1='0%' y2='100%'>
<stop offset='0%' style='stop-color:rgb(255,255,255);stop-opacity:1'/>
<stop offset='100%' style='stop-color:rgb(220,220,220);stop-opacity:1'/>
</linearGradient>
<radialGradient id="point" cx="30%" cy="30%" r="50%">
<stop offset="0%" style="stop-color:rgb(255,255,255); stop-opacity:0" />
<stop offset="100%" style="stop-color:rgb(0,0,255);stop-opacity:1" />
</radialGradient>
</defs>
@VALUE@
</svg>
]],
}
--~ for k,v in pairs(SHAPES) do
--~ if k~="SVG" then
--~ print(string.format("['%s-shadow']=[[%s]],",k,(gsub(v,"^(.-)(/>)$","%1 filter='url(#shadow)' %2%1%2 "))))
--~ end
--~ end
| mit |
couchbaselabs/couchstore-specials | tests/corrupt.lua | 6 | 1879 | package.path = package.path .. ";tests/?.lua"
local testlib = require("testlib")
function simpletrunc(dbname)
local db = couch.open(dbname, true)
db:save("k", "original value", 1)
db:commit()
testlib.check_doc(db, "k", "original value")
db:save("k", "second value", 1)
db:commit()
testlib.check_doc(db, "k", "second value")
db:truncate(-10)
db:close()
db = couch.open(dbname)
testlib.check_doc(db, "k", "original value")
db:save("k", "third value", 1)
db:commit()
db:close()
db = couch.open(dbname)
testlib.check_doc(db, "k", "third value")
end
function do_mangle(dbname, offset)
local db = couch.open(dbname, true)
db:save("k", "original value", 1)
db:commit()
testlib.check_doc(db, "k", "original value")
db:save("k", "second value", 1)
db:commit()
testlib.check_doc(db, "k", "second value")
db:close()
local f = io.open(dbname, "r+")
local corruptWith = "here be some garbage"
local treelen = f:seek("end") % 4096
if offset > treelen then
return false
end
f:seek("end", 0 - treelen)
f:write(corruptWith)
f:close()
db = couch.open(dbname)
testlib.check_doc(db, "k", "original value")
db:save("k", "third value", 1)
db:commit()
db:close()
db = couch.open(dbname)
testlib.check_doc(db, "k", "third value")
return true
end
-- Mangle the header with some arbitrary data from the beginning of
-- the header boundary to the end. The header is located by the EOF %
-- 4096. Should probably do something special when EOF *is* at a 4k
-- boundary, but this test is valuable without it.
function header_mangling(dbname)
local i = 0
while do_mangle(dbname, i) do
i = i + 1
os.remove(dbname)
end
end
testlib.run_test("Simple truncation test", simpletrunc)
testlib.run_test("Various mangling of headers", header_mangling)
| apache-2.0 |
Zenny89/darkstar | scripts/zones/Qulun_Dome/npcs/qm1.lua | 19 | 1353 | -----------------------------------
-- Area: Qulun Dome
-- NPC: qm1 (???)
-- Used In Quest: Whence Blows the Wind
-- @pos 261 39 79 148
-----------------------------------
package.loaded["scripts/zones/Qulun_Dome/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/zones/Qulun_Dome/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getQuestStatus(JEUNO,WHENCE_BLOWS_THE_WIND) == QUEST_ACCEPTED and player:hasKeyItem(QUADAV_CREST) == false) then
player:addKeyItem(QUADAV_CREST);
player:messageSpecial(KEYITEM_OBTAINED, QUADAV_CREST);
else
player:messageSpecial(YOU_FIND_NOTHING);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end; | gpl-3.0 |
Zenny89/darkstar | scripts/zones/Bastok_Markets/npcs/Sinon.lua | 36 | 4438 | -----------------------------------
-- Area: Bastok Markets
-- NPC: Sinon
-- Armor Storage NPC
-----------------------------------
package.loaded["scripts/zones/Bastok_Markets/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/globals/armorstorage");
require("scripts/zones/Bastok_Markets/TextIDs");
Deposit = 0x018b;
Withdrawl = 0x018c;
ArraySize = table.getn(StorageArray);
G1 = 0;
G2 = 0;
G3 = 0;
G4 = 0;
G5 = 0;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
for SetId = 1,ArraySize,11 do
TradeCount = trade:getItemCount();
T1 = trade:hasItemQty(StorageArray[SetId + 5],1);
if (T1 == true) then
if (player:hasKeyItem(StorageArray[SetId + 10]) == false) then
if (TradeCount == StorageArray[SetId + 3]) then
T2 = trade:hasItemQty(StorageArray[SetId + 4],1);
T3 = trade:hasItemQty(StorageArray[SetId + 6],1);
T4 = trade:hasItemQty(StorageArray[SetId + 7],1);
T5 = trade:hasItemQty(StorageArray[SetId + 8],1);
if (StorageArray[SetId + 4] == 0) then
T2 = true;
end;
if (StorageArray[SetId + 6] == 0) then
T3 = true;
end;
if (StorageArray[SetId + 7] == 0) then
T4 = true;
end;
if (StorageArray[SetId + 8] == 0) then
T5 = true;
end;
if (T2 == true and T3 == true and T4 == true and T5 == true) then
player:startEvent(Deposit,0,0,0,0,0,StorageArray[SetId + 9]);
player:addKeyItem(StorageArray[SetId + 10]);
player:messageSpecial(KEYITEM_OBTAINED,StorageArray[SetId + 10]);
break;
end;
end;
end;
end;
end;
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
CurrGil = player:getGil();
for KeyItem = 11,ArraySize,11 do
if player:hasKeyItem(StorageArray[KeyItem]) then
if StorageArray[KeyItem - 9] == 1 then
G1 = G1 + StorageArray[KeyItem - 8];
elseif StorageArray[KeyItem - 9] == 2 then
G2 = G2 + StorageArray[KeyItem - 8];
elseif StorageArray[KeyItem - 9] == 3 then
G3 = G3 + StorageArray[KeyItem - 8];
elseif StorageArray[KeyItem - 9] == 4 then
G4 = G4 + StorageArray[KeyItem - 8];
elseif StorageArray[KeyItem - 9] == 6 then
G5 = G5 + StorageArray[KeyItem - 8];
end;
end;
end;
player:startEvent(Withdrawl,G1,G2,G3,G4,CurrGil,G5);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
if (csid == Withdrawl) then
player:updateEvent(StorageArray[option * 11 - 6],
StorageArray[option * 11 - 5],
StorageArray[option * 11 - 4],
StorageArray[option * 11 - 3],
StorageArray[option * 11 - 2],
StorageArray[option * 11 - 1]);
end;
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
if (csid == Withdrawl) then
if (option > 0 and option <= StorageArray[ArraySize] - 10) then
if (player:getFreeSlotsCount() >= StorageArray[option * 11 - 7]) then
for Item = 2,6,1 do
if (StorageArray[option * 11 - Item] > 0) then
player:addItem(StorageArray[option * 11 - Item],1);
player:messageSpecial(ITEM_OBTAINED,StorageArray[option * 11 - Item]);
end;
end;
player:delKeyItem(StorageArray[option * 11]);
player:setGil(player:getGil() - StorageArray[option * 11 - 1]);
else
for Item = 2,6,1 do
if (StorageArray[option * 11 - Item] > 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,StorageArray[option * 11 - Item]);
end;
end;
end;
end;
end;
if (csid == Deposit) then
player:tradeComplete();
end;
end; | gpl-3.0 |
terminar/lua-handlers | handler/acceptor.lua | 2 | 8500 | -- Copyright (c) 2010-2011 by Robert G. Jakabosky <bobby@neoawareness.com>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
local setmetatable = setmetatable
local print = print
local assert = assert
local tostring = tostring
local tonumber = tonumber
local error = error
local ev = require"ev"
local nixio = require"nixio"
local new_socket = nixio.socket
local connection = require"handler.connection"
local wrap_connected = connection.wrap_connected
local tls_connection = require"handler.connection.tls_backend"
local tls_wrap_connected = connection.tls_wrap_connected
local uri_mod = require"handler.uri"
local uri_parse = uri_mod.parse
local query_parse = uri_mod.parse_query
local function n_assert(test, errno, msg)
return assert(test, msg)
end
local acceptor_mt = {
set_accept_max = function(self, max)
self.accept_max = max
end,
close = function(self)
self.io:stop(self.loop)
self.server:close()
end,
}
acceptor_mt.__index = acceptor_mt
local function sock_new_bind_listen(loop, handler, domain, _type, host, port, tls, backlog)
local is_dgram = (_type == 'dgram')
-- nixio uses nil to mean any local address.
if host == '*' then host = nil end
-- 'backlog' is optional, it defaults to 256
backlog = backlog or 256
-- create nixio socket
local server = new_socket(domain, _type)
-- create acceptor
local self = {
loop = loop,
handler = handler,
server = server,
host = host,
port = port,
tls = tls,
-- max sockets to try to accept on one event
accept_max = 100,
backlog = backlog,
}
setmetatable(self, acceptor_mt)
-- make nixio socket non-blocking
server:setblocking(false)
-- create callback closure
local accept_cb
if is_dgram then
local udp_clients = setmetatable({},{__mode="v"})
accept_cb = function()
local max = self.accept_max
local count = 0
repeat
local data, c_ip, c_port = server:recvfrom(8192)
if not data then
if data ~= false then
print('dgram_accept.error:', c_ip, c_port)
end
break
else
local client
local c_key = c_ip .. tostring(c_port)
-- look for existing client socket.
local sock = udp_clients[c_key]
-- check if socket is still valid.
if sock and sock:is_closed() then
sock = nil
end
-- if no cached socket, make a new one.
if not sock then
-- make a duplicate server socket
sock = new_socket(domain, _type)
n_assert(sock:setsockopt('socket', 'reuseaddr', 1))
n_assert(sock:bind(host, port))
-- connect dupped socket to client's ip:port
n_assert(sock:connect(c_ip, c_port))
-- wrap nixio socket
sock = wrap_connected(loop, nil, sock)
udp_clients[c_key] = sock
-- pass client socket to new connection handler.
if handler(sock) == nil then
-- connect handler returned nil, maybe they are rejecting connections.
break
end
-- get socket handler object from socket
client = sock.handler
else
-- get socket handler object from socket
client = sock.handler
end
-- handle first data block from udp client
client:handle_data(data)
end
count = count + 1
until count >= max
end
else
accept_cb = function()
local max = self.accept_max
local count = 0
repeat
local sock, errno, err = server:accept()
if not sock then
if sock ~= false then
print('stream_accept.error:', errno, err)
end
break
else
-- wrap nixio socket
if tls then
sock = tls_wrap_connected(loop, nil, sock, tls)
else
sock = wrap_connected(loop, nil, sock)
end
if handler(sock) == nil then
-- connect handler returned nil, maybe they are rejecting connections.
break
end
end
count = count + 1
until count >= max
end
end
-- create IO watcher.
local fd = server:fileno()
self.io = ev.IO.new(accept_cb, fd, ev.READ)
self.io:start(loop)
-- allow the address to be re-used.
n_assert(server:setsockopt('socket', 'reuseaddr', 1))
-- bind socket to local host:port
n_assert(server:bind(host, port))
if not is_dgram then
-- set the socket to listening mode
n_assert(server:listen(backlog))
end
return self
end
module(...)
function tcp6(loop, handler, host, port, backlog)
-- remove '[]' from IPv6 addresses
if host:sub(1,1) == '[' then
host = host:sub(2,-2)
end
return sock_new_bind_listen(loop, handler, 'inet6', 'stream', host, port, nil, backlog)
end
function tcp(loop, handler, host, port, backlog)
if host:sub(1,1) == '[' then
return tcp6(loop, handler, host, port, backlog)
else
return sock_new_bind_listen(loop, handler, 'inet', 'stream', host, port, nil, backlog)
end
end
function tls_tcp6(loop, handler, host, port, tls, backlog)
-- remove '[]' from IPv6 addresses
if host:sub(1,1) == '[' then
host = host:sub(2,-2)
end
return sock_new_bind_listen(loop, handler, 'inet6', 'stream', host, port, tls, backlog)
end
function tls_tcp(loop, handler, host, port, tls, backlog)
if host:sub(1,1) == '[' then
return tls_tcp6(loop, handler, host, port, tls, backlog)
else
return sock_new_bind_listen(loop, handler, 'inet', 'stream', host, port, tls, backlog)
end
end
function udp6(loop, handler, host, port, backlog)
-- remove '[]' from IPv6 addresses
if host:sub(1,1) == '[' then
host = host:sub(2,-2)
end
return sock_new_bind_listen(loop, handler, 'inet6', 'dgram', host, port, nil, backlog)
end
function udp(loop, handler, host, port, backlog)
if host:sub(1,1) == '[' then
return udp6(loop, handler, host, port, backlog)
else
return sock_new_bind_listen(loop, handler, 'inet', 'dgram', host, port, nil, backlog)
end
end
function unix(loop, handler, path, backlog)
-- check if socket already exists.
local stat, errno, err = nixio.fs.lstat(path)
if stat then
-- socket already exists, try to delete it.
local stat, errno, err = nixio.fs.unlink(path)
if not stat then
print('Warning failed to delete old Unix domain socket: ', err)
end
end
return sock_new_bind_listen(loop, handler, 'unix', 'stream', path, nil, nil, backlog)
end
function uri(loop, handler, uri, backlog, default_port)
local orig_uri = uri
-- parse uri
uri = uri_parse(uri)
local scheme = uri.scheme
assert(scheme, "Invalid listen URI: " .. orig_uri)
local q = query_parse(uri.query)
-- check if query has a 'backlog' parameter
if q.backlog then
backlog = tonumber(q.backlog)
end
-- use scheme to select socket type.
if scheme == 'unix' then
return unix(loop, handler, uri.path, backlog)
else
local host, port = uri.host, uri.port or default_port
if scheme == 'tcp' then
return tcp(loop, handler, host, port, backlog)
elseif scheme == 'tcp6' then
return tcp6(loop, handler, host, port, backlog)
elseif scheme == 'udp' then
return udp(loop, handler, host, port, backlog)
elseif scheme == 'udp6' then
return udp6(loop, handler, host, port, backlog)
else
-- create TLS context
local tls = nixio.tls(q.mode or 'server') -- default to server-side
-- set key
if q.key then
tls:set_key(q.key)
end
-- set certificate
if q.cert then
tls:set_cert(q.cert)
end
-- set ciphers
if q.ciphers then
tls:set_ciphers(q.ciphers)
end
if scheme == 'tls' then
return tls_tcp(loop, handler, host, port, tls, backlog)
elseif scheme == 'tls6' then
return tls_tcp6(loop, handler, host, port, tls, backlog)
end
end
end
error("Unknown listen URI scheme: " .. scheme)
end
| mit |
m4h4n/telegram-bot | plugins/search_youtube.lua | 674 | 1270 | do
local google_config = load_from_file('data/google.lua')
local function httpsRequest(url)
print(url)
local res,code = https.request(url)
if code ~= 200 then return nil end
return json:decode(res)
end
local function searchYoutubeVideos(text)
local url = 'https://www.googleapis.com/youtube/v3/search?'
url = url..'part=snippet'..'&maxResults=4'..'&type=video'
url = url..'&q='..URL.escape(text)
if google_config.api_keys then
local i = math.random(#google_config.api_keys)
local api_key = google_config.api_keys[i]
if api_key then
url = url.."&key="..api_key
end
end
local data = httpsRequest(url)
if not data then
print("HTTP Error")
return nil
elseif not data.items then
return nil
end
return data.items
end
local function run(msg, matches)
local text = ''
local items = searchYoutubeVideos(matches[1])
if not items then
return "Error!"
end
for k,item in pairs(items) do
text = text..'http://youtu.be/'..item.id.videoId..' '..
item.snippet.title..'\n\n'
end
return text
end
return {
description = "Search video on youtube and send it.",
usage = "!youtube [term]: Search for a youtube video and send it.",
patterns = {
"^!youtube (.*)"
},
run = run
}
end
| gpl-2.0 |
The-Three-Otakus/Joint-Animator | loveframes/objects/internal/tabbutton.lua | 14 | 5632 | --[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012-2014 Kenny Shields --
--]]------------------------------------------------
-- get the current require path
local path = string.sub(..., 1, string.len(...) - string.len(".objects.internal.tabbutton"))
local loveframes = require(path .. ".libraries.common")
-- tabbutton class
local newobject = loveframes.NewObject("tabbutton", "loveframes_object_tabbutton", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize(parent, text, tabnumber, tip, image, onopened, onclosed)
self.type = "tabbutton"
self.font = loveframes.smallfont
self.text = text
self.tabnumber = tabnumber
self.parent = parent
self.state = parent.state
self.staticx = 0
self.staticy = 0
self.width = 50
self.height = 25
self.internal = true
self.down = false
self.image = nil
self.OnOpened = nil
self.OnClosed = nil
if tip then
self.tooltip = loveframes.objects["tooltip"]:new(self, tip)
self.tooltip:SetFollowCursor(false)
self.tooltip:SetFollowObject(true)
self.tooltip:SetOffsets(0, -(self.tooltip.internals[1]:GetHeight() + 12))
end
if image then
self:SetImage(image)
end
if onopened then
self.OnOpened = onopened
end
if onclosed then
self.OnClosed = onclosed
end
-- apply template properties to the object
loveframes.templates.ApplyToObject(self)
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover()
self:SetClickBounds(parent.x, parent.y, parent.width, parent.height)
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function newobject:draw()
if not self.visible then
return
end
local image = self.image
local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawTabButton or skins[defaultskin].DrawTabButton
local draw = self.Draw
local drawcount = loveframes.drawcount
local internals = self.internals
-- set the object's draw order
self:SetDrawOrder()
if draw then
draw(self)
else
drawfunc(self)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
local internals = self.internals
if hover and button == "l" then
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
self.down = true
loveframes.downobject = self
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function newobject:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
local parent = self.parent
local tabnumber = self.tabnumber
if hover and button == "l" then
if button == "l" then
local tab = parent.tab
local internals = parent.internals
local onopened = self.OnOpened
local prevtab = internals[tab]
local onclosed = prevtab.OnClosed
parent:SwitchToTab(tabnumber)
if onopened then
onopened(self)
end
if onclosed then
onclosed(prevtab)
end
end
end
self.down = false
end
--[[---------------------------------------------------------
- func: SetText(text)
- desc: sets the object's text
--]]---------------------------------------------------------
function newobject:SetText(text)
self.text = text
end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the object's text
--]]---------------------------------------------------------
function newobject:GetText()
return self.text
end
--[[---------------------------------------------------------
- func: SetImage(image)
- desc: adds an image to the object
--]]---------------------------------------------------------
function newobject:SetImage(image)
if type(image) == "string" then
self.image = love.graphics.newImage(image)
else
self.image = image
end
end
--[[---------------------------------------------------------
- func: GetImage()
- desc: gets the object's image
--]]---------------------------------------------------------
function newobject:GetImage()
return self.image
end
--[[---------------------------------------------------------
- func: GetTabNumber()
- desc: gets the object's tab number
--]]---------------------------------------------------------
function newobject:GetTabNumber()
return self.tabnumber
end
| gpl-3.0 |
rodamaral/smw-tas | lsnes/scripts/lib/menu.lua | 1 | 30574 | local M = {show_menu = false, current_tab = 'Show/hide options'}
local gui, memory, settings, exec, tostringx = _G.gui, _G.memory, _G.settings, _G.exec, _G.tostringx
local luap = require 'luap'
local draw = require 'draw'
local config = require 'config'
local lsnes = require 'lsnes'
local cheat = require 'cheat'
local lagmeter = require 'lagmeter'
local smw = require 'game.smw'
local tile = require 'game.tile'
local smwdebug = require 'game.smwdebug'
local OPTIONS = config.OPTIONS
local COLOUR = config.COLOUR
local LSNES_FONT_WIDTH = config.LSNES_FONT_WIDTH
local controller = lsnes.controller
local fmt = string.format
-- Lateral Paddings (those persist if the script is closed and can be edited under Configure > Settings > Advanced > UI)
function M.adjust_lateral_gaps()
draw.Font = false
local left_gap, right_gap = OPTIONS.left_gap, OPTIONS.right_gap
local top_gap, bottom_gap = OPTIONS.top_gap, OPTIONS.bottom_gap
-- rectangle the helps to see the padding values
gui.rectangle(-left_gap, -top_gap, draw.Buffer_width + right_gap + left_gap,
draw.Buffer_height + bottom_gap + top_gap, 1,
M.show_menu and COLOUR.warning2 or 0xb0808080) -- unlisted color
draw.button(-draw.Border_left, draw.Buffer_middle_y, '+',
function() OPTIONS.left_gap = OPTIONS.left_gap + 32 end,
{always_on_client = true, ref_y = 1.0})
draw.button(-draw.Border_left, draw.Buffer_middle_y, '-', function()
if left_gap > 32 then
OPTIONS.left_gap = OPTIONS.left_gap - 32
else
OPTIONS.left_gap = 0
end
end, {always_on_client = true})
draw.button(draw.Buffer_width, draw.Buffer_middle_y, '+',
function() OPTIONS.right_gap = OPTIONS.right_gap + 32 end,
{always_on_client = true, ref_y = 1.0})
draw.button(draw.Buffer_width, draw.Buffer_middle_y, '-', function()
if right_gap > 32 then
OPTIONS.right_gap = OPTIONS.right_gap - 32
else
OPTIONS.right_gap = 0
end
end, {always_on_client = true})
draw.button(draw.Buffer_middle_x, -draw.Border_top, '+',
function() OPTIONS.top_gap = OPTIONS.top_gap + 32 end,
{always_on_client = true, ref_x = 1.0})
draw.button(draw.Buffer_middle_x, -draw.Border_top, '-', function()
if top_gap > 32 then
OPTIONS.top_gap = OPTIONS.top_gap - 32
else
OPTIONS.top_gap = 0
end
end, {always_on_client = true})
draw.button(draw.Buffer_middle_x, draw.Buffer_height, '+',
function() OPTIONS.bottom_gap = OPTIONS.bottom_gap + 32 end,
{always_on_client = true, ref_x = 1.0})
draw.button(draw.Buffer_middle_x, draw.Buffer_height, '-', function()
if bottom_gap > 32 then
OPTIONS.bottom_gap = OPTIONS.bottom_gap - 32
else
OPTIONS.bottom_gap = 0
end
end, {always_on_client = true})
end
function M.print_help()
print('\n')
print(' - - - TIPS - - - ')
print('MOUSE:')
print('Use the left click to draw blocks and to see the Map16 properties.')
print('Use the right click to toogle the hitbox mode of Mario and sprites.')
print('\n')
print('CHEATS(better turn off while recording a movie):')
print('L+R+up: stop gravity for Mario fly / L+R+down to cancel')
print('Use the mouse to drag and drop sprites')
print('While paused: B+select to get out of the level')
print(' X+select to beat the level (main exit)')
print(' A+select to get the secret exit (don\'t use it if there isn\'t one)')
print('Command cheats(use lsnes:Messages and type the commands, that are cAse-SENSitiVE):')
print('score <value>: set the score to <value>.')
print('coin <value>: set the coin number to <value>.')
print('powerup <value>: set the powerup number to <value>.')
print('\n')
print('OTHERS:')
print(fmt('Press "%s" for more and "%s" for less opacity.', OPTIONS.hotkey_increase_opacity,
OPTIONS.hotkey_decrease_opacity))
print('If performance suffers, disable some options that are not needed at the moment.')
print('', '(input display and sprites are the ones that slow down the most).')
print('It\'s better to play without the mouse over the game window.')
print(' - - - end of tips - - - ')
end
function M.display()
if not M.show_menu then return end
-- Pauses emulator and draws the background
if lsnes.runmode == 'normal' then exec('pause-emulator') end
gui.rectangle(0, 0, draw.Buffer_width, draw.Buffer_height, 2, COLOUR.mainmenu_outline,
COLOUR.mainmenu_bg)
-- Font stuff
draw.Font = false
local delta_x = draw.font_width()
local delta_y = draw.font_height() + 4
local x_pos, y_pos = 4, 4
local tmp
-- Exit menu button
gui.solidrectangle(0, 0, draw.Buffer_width, delta_y, 0xa0ffffff) -- tab's shadow / unlisted color
draw.button(draw.Buffer_width, 0, ' X ', function() M.show_menu = false end,
{always_on_game = true})
-- External buttons
tmp = OPTIONS.display_controller_input and 'Hide Input' or 'Show Input'
draw.button(0, 0, tmp, function()
OPTIONS.display_controller_input = not OPTIONS.display_controller_input
end, {always_on_client = true, ref_x = 1.0, ref_y = 1.0})
tmp = cheat.allow_cheats and 'Cheats: allowed' or 'Cheats: blocked'
draw.button(-draw.Border_left, draw.Buffer_height, tmp, function()
cheat.allow_cheats = not cheat.allow_cheats
draw.message('Cheats ' .. (cheat.allow_cheats and 'allowed.' or 'blocked.'))
end, {always_on_client = true, ref_y = 1.0})
draw.button(draw.Buffer_width + draw.Border_right, draw.Buffer_height, 'Erase Tiles',
function()
tile.layer1 = {}
tile.layer2 = {}
end, {always_on_client = true, ref_y = 1.0})
-- Tabs
draw.button(x_pos, y_pos, 'Show/hide', function() M.current_tab = 'Show/hide options' end,
{button_pressed = M.current_tab == 'Show/hide options'})
x_pos = x_pos + 9 * delta_x + 2
draw.button(x_pos, y_pos, 'Settings', function() M.current_tab = 'Misc options' end,
{button_pressed = M.current_tab == 'Misc options'})
x_pos = x_pos + 8 * delta_x + 2
draw.button(x_pos, y_pos, 'Lag', function() M.current_tab = 'Lag options' end,
{button_pressed = M.current_tab == 'Lag options'})
x_pos = x_pos + 3 * delta_x + 2
draw.button(x_pos, y_pos, 'Debug info', function() M.current_tab = 'Debug info' end,
{button_pressed = M.current_tab == 'Debug info'})
x_pos = x_pos + 10 * delta_x + 2
draw.button(x_pos, y_pos, 'Sprite tables',
function() M.current_tab = 'Sprite miscellaneous tables' end,
{button_pressed = M.current_tab == 'Sprite miscellaneous tables'})
-- x_pos = x_pos + 13*delta_x + 2
x_pos, y_pos = 4, y_pos + delta_y + 8
if M.current_tab == 'Show/hide options' then
tmp = OPTIONS.display_movie_info and true or ' '
draw.button(x_pos, y_pos, tmp,
function() OPTIONS.display_movie_info = not OPTIONS.display_movie_info end)
gui.text(x_pos + delta_x + 3, y_pos, 'Display Movie Info?')
y_pos = y_pos + delta_y
tmp = OPTIONS.display_misc_info and true or ' '
draw.button(x_pos, y_pos, tmp,
function() OPTIONS.display_misc_info = not OPTIONS.display_misc_info end)
gui.text(x_pos + delta_x + 3, y_pos, 'Display Misc Info?')
x_pos = x_pos + 20 * delta_x + 8
tmp = OPTIONS.display_RNG_info and true or ' '
draw.button(x_pos, y_pos, tmp,
function() OPTIONS.display_RNG_info = not OPTIONS.display_RNG_info end)
gui.text(x_pos + delta_x + 3, y_pos, 'Display RNG?')
x_pos = 4
y_pos = y_pos + delta_y + 8
-- Player properties
gui.text(x_pos, y_pos, 'Player:')
x_pos = x_pos + 8 * delta_x
tmp = OPTIONS.display_player_info and true or ' '
draw.button(x_pos, y_pos, tmp,
function() OPTIONS.display_player_info = not OPTIONS.display_player_info end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Info')
x_pos = x_pos + 5 * delta_x
tmp = OPTIONS.display_player_hitbox and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_player_hitbox = not OPTIONS.display_player_hitbox
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Hitbox')
x_pos = x_pos + 7 * delta_x
tmp = OPTIONS.display_interaction_points and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_interaction_points = not OPTIONS.display_interaction_points
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Clipping')
x_pos = x_pos + 9 * delta_x
tmp = OPTIONS.display_cape_hitbox and true or ' '
draw.button(x_pos, y_pos, tmp,
function() OPTIONS.display_cape_hitbox = not OPTIONS.display_cape_hitbox end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Cape')
x_pos = x_pos + 5 * delta_x
tmp = OPTIONS.display_debug_player_extra and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_debug_player_extra = not OPTIONS.display_debug_player_extra
end)
gui.text(x_pos + delta_x + 3, y_pos, 'Extra')
x_pos, y_pos = 4, y_pos + delta_y + 8 -- reset
-- Sprites properties
gui.text(x_pos, y_pos, 'Sprites:')
x_pos = x_pos + 9 * delta_x
tmp = OPTIONS.display_sprite_info and true or ' '
draw.button(x_pos, y_pos, tmp,
function() OPTIONS.display_sprite_info = not OPTIONS.display_sprite_info end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Info')
x_pos = x_pos + 5 * delta_x
tmp = OPTIONS.display_sprite_hitbox and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_sprite_hitbox = not OPTIONS.display_sprite_hitbox
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Hitbox')
x_pos = x_pos + 7 * delta_x
tmp = OPTIONS.display_sprite_vs_sprite_hitbox and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_sprite_vs_sprite_hitbox = not OPTIONS.display_sprite_vs_sprite_hitbox
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'vs sprites')
x_pos = x_pos + 11 * delta_x
tmp = OPTIONS.display_debug_sprite_tweakers and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_debug_sprite_tweakers = not OPTIONS.display_debug_sprite_tweakers
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Tweakers')
x_pos = x_pos + 9 * delta_x
tmp = OPTIONS.display_debug_sprite_extra and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_debug_sprite_extra = not OPTIONS.display_debug_sprite_extra
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Extra')
x_pos, y_pos = 4, y_pos + delta_y + 8 -- reset
-- Extended sprites properties
gui.text(x_pos, y_pos, 'Extended sprites:')
x_pos = x_pos + 18 * delta_x
tmp = OPTIONS.display_extended_sprite_info and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_extended_sprite_info = not OPTIONS.display_extended_sprite_info
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Info')
x_pos = x_pos + 5 * delta_x
tmp = OPTIONS.display_extended_sprite_hitbox and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_extended_sprite_hitbox = not OPTIONS.display_extended_sprite_hitbox
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Hitbox')
x_pos = x_pos + 7 * delta_x
tmp = OPTIONS.display_debug_extended_sprite and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_debug_extended_sprite = not OPTIONS.display_debug_extended_sprite
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Extra')
x_pos, y_pos = 4, y_pos + delta_y + 8 -- reset
-- Cluster sprites properties
gui.text(x_pos, y_pos, 'Cluster sprites:')
x_pos = x_pos + 17 * delta_x
tmp = OPTIONS.display_cluster_sprite_info and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_cluster_sprite_info = not OPTIONS.display_cluster_sprite_info
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Info')
x_pos = x_pos + 5 * delta_x
tmp = OPTIONS.display_cluster_sprite_hitbox and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_cluster_sprite_hitbox = not OPTIONS.display_cluster_sprite_hitbox
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Hitbox')
x_pos = x_pos + 7 * delta_x
tmp = OPTIONS.display_debug_cluster_sprite and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_debug_cluster_sprite = not OPTIONS.display_debug_cluster_sprite
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Extra')
x_pos, y_pos = 4, y_pos + delta_y + 8 -- reset
-- Minor extended sprites properties
gui.text(x_pos, y_pos, 'Minor ext. sprites:')
x_pos = x_pos + 20 * delta_x
tmp = OPTIONS.display_minor_extended_sprite_info and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_minor_extended_sprite_info =
not OPTIONS.display_minor_extended_sprite_info
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Info')
x_pos = x_pos + 5 * delta_x
tmp = OPTIONS.display_minor_extended_sprite_hitbox and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_minor_extended_sprite_hitbox =
not OPTIONS.display_minor_extended_sprite_hitbox
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Hitbox')
x_pos = x_pos + 7 * delta_x
tmp = OPTIONS.display_debug_minor_extended_sprite and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_debug_minor_extended_sprite =
not OPTIONS.display_debug_minor_extended_sprite
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Extra')
x_pos, y_pos = 4, y_pos + delta_y + 8 -- reset
-- Bounce sprites properties
gui.text(x_pos, y_pos, 'Bounce sprites:')
x_pos = x_pos + 16 * delta_x
tmp = OPTIONS.display_bounce_sprite_info and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_bounce_sprite_info = not OPTIONS.display_bounce_sprite_info
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Info')
x_pos = x_pos + 5 * delta_x
tmp = OPTIONS.display_quake_sprite_info and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_quake_sprite_info = not OPTIONS.display_quake_sprite_info
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Quake')
x_pos = x_pos + 6 * delta_x
tmp = OPTIONS.display_debug_bounce_sprite and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_debug_bounce_sprite = not OPTIONS.display_debug_bounce_sprite
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Extra')
x_pos, y_pos = 4, y_pos + delta_y + 8 -- reset
-- Generator sprites
gui.text(x_pos, y_pos, 'Generators:')
x_pos = x_pos + 11 * delta_x + 3
tmp = OPTIONS.display_generator_info and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_generator_info = not OPTIONS.display_generator_info
end)
x_pos = x_pos + delta_x + 16
-- Shooter sprites
gui.text(x_pos, y_pos, 'Shooters:')
x_pos = x_pos + 9 * delta_x + 3
tmp = OPTIONS.display_shooter_sprite_info and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_shooter_sprite_info = not OPTIONS.display_shooter_sprite_info
end)
x_pos, y_pos = 4, y_pos + delta_y + 8 -- reset
-- Coin sprites
gui.text(x_pos, y_pos, 'Coin sprites:')
x_pos = x_pos + 13 * delta_x + 3
tmp = OPTIONS.display_coin_sprite_info and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_coin_sprite_info = not OPTIONS.display_coin_sprite_info
end)
x_pos = x_pos + delta_x + 16
-- Score sprites
gui.text(x_pos, y_pos, 'Score sprites:')
x_pos = x_pos + 14 * delta_x + 3
tmp = OPTIONS.display_score_sprite_info and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_score_sprite_info = not OPTIONS.display_score_sprite_info
end)
x_pos = x_pos + delta_x + 16
-- Smoke sprites
gui.text(x_pos, y_pos, 'Smoke sprites:')
x_pos = x_pos + 14 * delta_x + 3
tmp = OPTIONS.display_smoke_sprite_info and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_smoke_sprite_info = not OPTIONS.display_smoke_sprite_info
end)
x_pos, y_pos = 4, y_pos + delta_y + 8 -- reset
-- Level boundaries
gui.text(x_pos, y_pos, 'Level boundary:')
x_pos = x_pos + 16 * delta_x
tmp = OPTIONS.display_level_boundary_always and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_level_boundary_always = not OPTIONS.display_level_boundary_always
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Always')
x_pos = x_pos + 7 * delta_x
tmp = OPTIONS.display_sprite_vanish_area and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_sprite_vanish_area = not OPTIONS.display_sprite_vanish_area
end)
x_pos = x_pos + delta_x + 3
gui.text(x_pos, y_pos, 'Sprites')
x_pos, y_pos = 4, y_pos + delta_y + 8
tmp = OPTIONS.display_level_info and true or ' '
draw.button(x_pos, y_pos, tmp,
function() OPTIONS.display_level_info = not OPTIONS.display_level_info end)
gui.text(x_pos + delta_x + 3, y_pos, 'Show Level Info?')
y_pos = y_pos + delta_y
tmp = OPTIONS.display_yoshi_info and true or ' '
draw.button(x_pos, y_pos, tmp,
function() OPTIONS.display_yoshi_info = not OPTIONS.display_yoshi_info end)
gui.text(x_pos + delta_x + 3, y_pos, 'Show Yoshi Info?')
y_pos = y_pos + delta_y
tmp = OPTIONS.display_counters and true or ' '
draw.button(x_pos, y_pos, tmp,
function() OPTIONS.display_counters = not OPTIONS.display_counters end)
gui.text(x_pos + delta_x + 3, y_pos, 'Show Counters Info?')
y_pos = y_pos + delta_y
tmp = OPTIONS.display_static_camera_region and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_static_camera_region = not OPTIONS.display_static_camera_region
end)
gui.text(x_pos + delta_x + 3, y_pos, 'Show Camera Region?')
y_pos = y_pos + delta_y
tmp = OPTIONS.use_block_duplication_predictor and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.use_block_duplication_predictor = not OPTIONS.use_block_duplication_predictor
end)
gui.text(x_pos + delta_x + 3, y_pos, 'Use block duplication predictor?')
y_pos = y_pos + delta_y
tmp = OPTIONS.register_player_position_changes
if tmp == 'simple' then
tmp = ' simple '
elseif (not tmp) then
tmp = 'disabled'
end
draw.button(x_pos, y_pos, tmp, function()
if OPTIONS.register_player_position_changes == 'simple' then
OPTIONS.register_player_position_changes = 'complete'
elseif OPTIONS.register_player_position_changes == 'complete' then
OPTIONS.register_player_position_changes = false
else
OPTIONS.register_player_position_changes = 'simple'
end
end)
gui.text(x_pos + 8 * delta_x + 3, y_pos, 'Register player position changes between frames?')
elseif M.current_tab == 'Misc options' then
tmp = OPTIONS.register_ACE_debug_callback and true or ' '
draw.button(x_pos, y_pos, tmp, function() smwdebug.register_debug_callback(true) end)
gui.text(x_pos + delta_x + 3, y_pos,
'Detect arbitrary code execution for some addresses? (ACE)')
y_pos = y_pos + delta_y
tmp = OPTIONS.draw_tiles_with_click and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.draw_tiles_with_click = not OPTIONS.draw_tiles_with_click
end)
gui.text(x_pos + delta_x + 3, y_pos, 'Draw tiles with left click?')
y_pos = y_pos + delta_y
tmp = OPTIONS.use_custom_fonts and true or ' '
draw.button(x_pos, y_pos, tmp,
function() OPTIONS.use_custom_fonts = not OPTIONS.use_custom_fonts end)
gui.text(x_pos + delta_x + 3, y_pos, 'Use custom fonts?')
y_pos = y_pos + delta_y
tmp = 'Background:'
draw.button(x_pos, y_pos, tmp, function()
if OPTIONS.text_background_type == 'automatic' then
OPTIONS.text_background_type = 'full'
elseif OPTIONS.text_background_type == 'full' then
OPTIONS.text_background_type = 'outline'
else
OPTIONS.text_background_type = 'automatic'
end
end)
draw.Font = 'Uzebox6x8'
tmp = draw.text(x_pos + 11 * delta_x + 6, y_pos, tostringx(OPTIONS.text_background_type),
COLOUR.warning, COLOUR.warning_bg)
draw.Font = false
draw.text(tmp + 3, y_pos, tostringx(OPTIONS.text_background_type), COLOUR.warning,
COLOUR.warning_bg)
y_pos = y_pos + delta_y
tmp = OPTIONS.is_simple_comparison_ghost_loaded and true or ' '
draw.button(x_pos, y_pos, tmp, function()
if not OPTIONS.is_simple_comparison_ghost_loaded then
Ghost_player = require 'ghost' -- FIXME:
Ghost_player.init()
else
luap.unrequire 'ghost'
Ghost_player = nil
end
OPTIONS.is_simple_comparison_ghost_loaded =
not OPTIONS.is_simple_comparison_ghost_loaded
end)
gui.text(x_pos + delta_x + 3, y_pos, 'Load comparison ghost?')
y_pos = y_pos + delta_y
-- Manage opacity / filter
x_pos, y_pos = 4, y_pos + delta_y
gui.text(x_pos, y_pos, 'Opacity:')
y_pos = y_pos + delta_y
draw.button(x_pos, y_pos, '-', function()
if OPTIONS.filter_opacity >= 1 then
OPTIONS.filter_opacity = OPTIONS.filter_opacity - 1
end
COLOUR.filter_color = draw.change_transparency(COLOUR.filter_tonality,
OPTIONS.filter_opacity / 10)
end)
draw.button(x_pos + delta_x + 2, y_pos, '+', function()
if OPTIONS.filter_opacity <= 9 then
OPTIONS.filter_opacity = OPTIONS.filter_opacity + 1
end
COLOUR.filter_color = draw.change_transparency(COLOUR.filter_tonality,
OPTIONS.filter_opacity / 10)
end)
gui.text(x_pos + 2 * delta_x + 5, y_pos,
'Change filter opacity (' .. 10 * OPTIONS.filter_opacity .. '%)')
y_pos = y_pos + delta_y
draw.button(x_pos, y_pos, '-', draw.decrease_opacity)
draw.button(x_pos + delta_x + 2, y_pos, '+', draw.increase_opacity)
gui.text(x_pos + 2 * delta_x + 5, y_pos,
fmt('Text opacity: (%.0f%%, %.0f%%)', 100 * draw.Text_max_opacity,
100 * draw.Background_max_opacity))
y_pos = y_pos + delta_y
gui.text(x_pos, y_pos,
fmt('\'%s\' and \'%s\' are hotkeys for this.', OPTIONS.hotkey_decrease_opacity,
OPTIONS.hotkey_increase_opacity), COLOUR.weak)
y_pos = y_pos + delta_y
-- Video and AVI settings
y_pos = y_pos + delta_y
gui.text(x_pos, y_pos, 'Video settings:')
y_pos = y_pos + delta_y
tmp = OPTIONS.make_lua_drawings_on_video and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.make_lua_drawings_on_video = not OPTIONS.make_lua_drawings_on_video
end)
gui.text(x_pos + delta_x + 3, y_pos, 'Make lua drawings on video?')
y_pos = y_pos + delta_y
-- Others
y_pos = y_pos + delta_y
gui.text(x_pos, y_pos, 'Help:')
y_pos = y_pos + delta_y
draw.button(x_pos, y_pos, 'Reset Permanent Lateral Paddings', function()
settings.set('left-border', '0')
settings.set('right-border', '0')
settings.set('top-border', '0')
settings.set('bottom-border', '0')
end)
y_pos = y_pos + delta_y
draw.button(x_pos, y_pos, 'Reset Lateral Gaps', function()
OPTIONS.left_gap = LSNES_FONT_WIDTH * (controller.total_width + 6)
OPTIONS.right_gap = config.DEFAULT_OPTIONS.right_gap
OPTIONS.top_gap = config.DEFAULT_OPTIONS.top_gap
OPTIONS.bottom_gap = config.DEFAULT_OPTIONS.bottom_gap
end)
y_pos = y_pos + delta_y
draw.button(x_pos, y_pos, 'Show tips in lsnes: Messages', M.print_help)
elseif M.current_tab == 'Lag options' then
tmp = OPTIONS.use_lagmeter_tool and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.use_lagmeter_tool = not OPTIONS.use_lagmeter_tool
local task = OPTIONS.use_lagmeter_tool and 'registerexec' or 'unregisterexec'
memory[task]('BUS', 0x8075, lagmeter.get_master_cycles) -- unlisted ROM
end)
gui.text(x_pos + delta_x + 3, y_pos, 'Lagmeter tool? (experimental/for SMW only)')
y_pos = y_pos + delta_y
tmp = OPTIONS.use_custom_lag_detector and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.use_custom_lag_detector = not OPTIONS.use_custom_lag_detector
end)
gui.text(x_pos + delta_x + 3, y_pos, 'Use custom lag detector?')
y_pos = y_pos + delta_y
tmp = OPTIONS.use_custom_lagcount and true or ' '
draw.button(x_pos, y_pos, tmp,
function() OPTIONS.use_custom_lagcount = not OPTIONS.use_custom_lagcount end)
gui.text(x_pos + delta_x + 3, y_pos, 'Use custom lag count?')
y_pos = y_pos + delta_y
tmp = 'Print help'
draw.button(x_pos, y_pos, tmp, function()
print('\nLagmeter tool:\n' ..
'This tool displays almost exactly how laggy the last frame has been.\n' ..
'Only works well for SMW(NTSC) and inside the level, where it usually matters.\n' ..
'Anything below 100% is not lagged, otherwise the game lagged.\n' ..
'\nCustom lag detector:\n' ..
'On some games, lsnes has false positives for lag.\n' ..
'This custom detector only checks if the game polled input and if WRAM $10 is zero.\n' ..
'For SMW, this also detects lag 1 frame sooner, which is useful.\n' ..
'By letting the lag count obey this custom detector, the number will persist ' ..
'even after the script is finished.\n')
end)
elseif M.current_tab == 'Debug info' then
tmp = OPTIONS.display_debug_controller_data and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_debug_controller_data = not OPTIONS.display_debug_controller_data
end)
gui.text(x_pos + delta_x + 3, y_pos, 'Controller data (freezes the lag counter!)')
y_pos = y_pos + delta_y
tmp = OPTIONS.debug_collision_routine and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.debug_collision_routine = not OPTIONS.debug_collision_routine
end)
gui.text(x_pos + delta_x + 3, y_pos, fmt(
'Debug collision routine 1 ($%.6x). May not work in ROMhacks',
smw.CHECK_FOR_CONTACT_ROUTINE))
y_pos = y_pos + delta_y
if OPTIONS.debug_collision_routine then
tmp = OPTIONS.display_collision_routine_fail and true or ' '
draw.button(x_pos + 16, y_pos, tmp, function()
OPTIONS.display_collision_routine_fail = not OPTIONS.display_collision_routine_fail
end)
gui.text(x_pos + delta_x + 3 + 16, y_pos, 'Show collision checks without contact?')
end
elseif M.current_tab == 'Sprite miscellaneous tables' then
tmp = OPTIONS.display_miscellaneous_sprite_table and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_miscellaneous_sprite_table =
not OPTIONS.display_miscellaneous_sprite_table
end)
gui.text(x_pos + delta_x + 3, y_pos, 'Show Miscellaneous Sprite Table?')
x_pos = 4
y_pos = y_pos + delta_y
tmp = OPTIONS.display_sprite_load_status and true or ' '
draw.button(x_pos, y_pos, tmp, function()
OPTIONS.display_sprite_load_status = not OPTIONS.display_sprite_load_status
end)
gui.text(x_pos + delta_x + 3, y_pos, 'Show sprite load status within level?')
end
-- Lateral Paddings
M.adjust_lateral_gaps()
return true
end
return M
| mit |
guillaume144/jeu-rp | entities/entities/drug_lab/init.lua | 10 | 1061 | AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
DEFINE_BASECLASS("lab_base")
ENT.SeizeReward = 350
function ENT:Initialize()
BaseClass.Initialize(self)
self.SID = self:Getowning_ent().SID
end
function ENT:SalePrice(activator)
return math.random(math.Round(self:Getprice() / 8), math.Round(self:Getprice() / 4))
end
function ENT:canUse(activator)
if activator.maxDrugs and activator.maxDrugs >= GAMEMODE.Config.maxdrugs then
DarkRP.notify(activator, 1, 3, DarkRP.getPhrase("limit", self.itemPhrase))
return false
end
return true
end
function ENT:createItem(activator)
local drugPos = self:GetPos()
local drug = ents.Create("drug")
drug:SetPos(Vector(drugPos.x, drugPos.y, drugPos.z + 35))
drug:Setowning_ent(activator)
drug.SID = activator.SID
drug.nodupe = true
drug:Setprice(self:Getprice() or self.initialPrice)
drug:Spawn()
if not activator.maxDrugs then
activator.maxDrugs = 0
end
activator.maxDrugs = activator.maxDrugs + 1
end
| mit |
Zenny89/darkstar | scripts/globals/spells/shock.lua | 18 | 1590 | -----------------------------------------
-- Spell: Shock
-- Deals lightning damage that lowers an enemy's mind and gradually reduces its HP.
-----------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
if (target:getStatusEffect(EFFECT_RASP) ~= nil) then
spell:setMsg(75); -- no effect
else
local dINT = caster:getStat(MOD_INT)-target:getStat(MOD_INT);
local resist = applyResistance(caster,spell,target,dINT,36,0);
if (resist <= 0.125) then
spell:setMsg(85);
else
if (target:getStatusEffect(EFFECT_DROWN) ~= nil) then
target:delStatusEffect(EFFECT_DROWN);
end;
local sINT = caster:getStat(MOD_INT);
local DOT = getElementalDebuffDOT(sINT);
local effect = target:getStatusEffect(EFFECT_SHOCK);
local noeffect = false;
if (effect ~= nil) then
if (effect:getPower() >= DOT) then
noeffect = true;
end;
end;
if (noeffect) then
spell:setMsg(75); -- no effect
else
if (effect ~= nil) then
target:delStatusEffect(EFFECT_SHOCK);
end;
spell:setMsg(237);
local duration = math.floor(ELEMENTAL_DEBUFF_DURATION * resist);
target:addStatusEffect(EFFECT_SHOCK,DOT, 3, ELEMENTAL_DEBUFF_DURATION,FLAG_ERASBLE);
end;
end;
end;
return EFFECT_SHOCK;
end; | gpl-3.0 |
mercury233/ygopro-scripts | c66750703.lua | 2 | 4423 | --炎傑の梁山閣
function c66750703.initial_effect(c)
c:EnableCounterPermit(0x56)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--add counter
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_SUMMON_SUCCESS)
e2:SetRange(LOCATION_FZONE)
e2:SetOperation(c66750703.ctop)
c:RegisterEffect(e2)
local e3=e2:Clone()
e3:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e3)
--actlimit
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(66750703,0))
e4:SetType(EFFECT_TYPE_IGNITION)
e4:SetRange(LOCATION_FZONE)
e4:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE)
e4:SetCost(c66750703.actcost)
e4:SetOperation(c66750703.actop)
c:RegisterEffect(e4)
--tohand
local e5=Effect.CreateEffect(c)
e5:SetDescription(aux.Stringid(66750703,1))
e5:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e5:SetType(EFFECT_TYPE_IGNITION)
e5:SetRange(LOCATION_FZONE)
e5:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE)
e5:SetCost(c66750703.thcost)
e5:SetTarget(c66750703.thtg)
e5:SetOperation(c66750703.thop)
c:RegisterEffect(e5)
--special summon
local e6=Effect.CreateEffect(c)
e6:SetDescription(aux.Stringid(66750703,2))
e6:SetCategory(CATEGORY_SPECIAL_SUMMON)
e6:SetType(EFFECT_TYPE_IGNITION)
e6:SetRange(LOCATION_FZONE)
e6:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE)
e6:SetCost(c66750703.spcost)
e6:SetTarget(c66750703.sptg)
e6:SetOperation(c66750703.spop)
c:RegisterEffect(e6)
end
function c66750703.ctfilter(c)
return c:IsFaceup() and c:IsSetCard(0x79)
end
function c66750703.ctop(e,tp,eg,ep,ev,re,r,rp)
if eg:IsExists(c66750703.ctfilter,1,nil) then
e:GetHandler():AddCounter(0x56,1)
end
end
function c66750703.actcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsCanRemoveCounter(tp,1,0,0x56,2,REASON_COST) end
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.RemoveCounter(tp,1,0,0x56,2,REASON_COST)
end
function c66750703.actop(e,tp,eg,ep,ev,re,r,rp)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetCode(EFFECT_CANNOT_ACTIVATE)
e1:SetTargetRange(0,1)
e1:SetCondition(c66750703.actcon)
e1:SetValue(1)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
end
function c66750703.actcon(e)
local tc=Duel.GetAttacker()
local tp=e:GetHandlerPlayer()
return tc and tc:IsControler(tp) and tc:IsRace(RACE_BEASTWARRIOR)
end
function c66750703.thcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsCanRemoveCounter(tp,1,0,0x56,6,REASON_COST) end
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.RemoveCounter(tp,1,0,0x56,6,REASON_COST)
end
function c66750703.thfilter(c)
return c:IsRace(RACE_BEASTWARRIOR) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
end
function c66750703.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chk==0 then return Duel.IsExistingMatchingCard(c66750703.thfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c66750703.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c66750703.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 c66750703.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsCanRemoveCounter(tp,1,0,0x56,10,REASON_COST) end
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.RemoveCounter(tp,1,0,0x56,10,REASON_COST)
end
function c66750703.spfilter(c,e,tp)
return c:IsRace(RACE_BEASTWARRIOR) and c:IsType(TYPE_MONSTER) and c:IsCanBeSpecialSummoned(e,0,tp,true,false)
and (c:IsLocation(LOCATION_DECK) and Duel.GetMZoneCount(tp)>0
or c:IsLocation(LOCATION_EXTRA) and Duel.GetLocationCountFromEx(tp,tp,nil,c)>0)
end
function c66750703.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c66750703.spfilter,tp,LOCATION_DECK+LOCATION_EXTRA,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK+LOCATION_EXTRA)
end
function c66750703.spop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c66750703.spfilter,tp,LOCATION_DECK+LOCATION_EXTRA,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,true,false,POS_FACEUP)
end
end
| gpl-2.0 |
tfussell/rana | build/premake5.lua | 1 | 1908 | solution "rana"
configurations { "debug", "release" }
platforms { "x64" }
location ("./" .. _ACTION)
configuration "debug"
flags { "Symbols" }
optimize "Off"
configuration "release"
optimize "Full"
project "rana.test"
kind "ConsoleApp"
language "C++"
targetname "rana.test"
includedirs {
"../include/rana",
"/usr/local/Cellar/cxxtest/4.3"
}
files {
"../tests/*.hpp",
"../tests/runner-autogen.cpp",
"../include/rana/*.hpp"
}
prebuildcommands { "/usr/local/Cellar/cxxtest/4.3/bin/cxxtestgen --runner=ErrorPrinter -o ../../tests/runner-autogen.cpp ../../tests/*.hpp" }
flags {
"Unicode",
"NoEditAndContinue",
"NoManifest",
"NoPCH",
"NoBufferSecurityCheck"
}
configuration "debug"
targetdir "../bin"
configuration "release"
flags { "LinkTimeOptimization" }
optimize "Full"
targetdir "../bin"
configuration "not windows"
buildoptions {
"-std=c++11",
"-Wno-unknown-pragmas"
}
configuration { "not windows", "debug" }
buildoptions { "-ggdb" }
project "rana.benchmark"
kind "ConsoleApp"
language "C++"
targetname "rana.benchmark"
includedirs {
"../include/rana"
}
files {
"../benchmark/main.cpp",
"../include/rana/*.hpp"
}
flags {
"Unicode",
"NoEditAndContinue",
"NoManifest",
"NoPCH",
"NoBufferSecurityCheck"
}
configuration "debug"
targetdir "../bin"
configuration "release"
flags { "LinkTimeOptimization" }
optimize "Full"
targetdir "../bin"
configuration "not windows"
buildoptions {
"-std=c++11",
"-Wno-unknown-pragmas"
}
configuration { "not windows", "debug" }
buildoptions { "-ggdb" }
| mit |
mercury233/ygopro-scripts | c9030160.lua | 2 | 2531 | --常闇の契約書
function c9030160.initial_effect(c)
--activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--cannot be target
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
e2:SetRange(LOCATION_SZONE)
e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE+EFFECT_FLAG_SET_AVAILABLE)
e2:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e2:SetCondition(c9030160.condition)
e2:SetValue(c9030160.evalue)
c:RegisterEffect(e2)
--cannot release
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetRange(LOCATION_SZONE)
e3:SetCode(EFFECT_UNRELEASABLE_SUM)
e3:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
e3:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e3:SetCondition(c9030160.condition)
e3:SetValue(c9030160.sumlimit)
c:RegisterEffect(e3)
local e5=e3:Clone()
e5:SetCode(EFFECT_CANNOT_BE_FUSION_MATERIAL)
e5:SetValue(c9030160.fuslimit)
c:RegisterEffect(e5)
local e6=e3:Clone()
e6:SetCode(EFFECT_CANNOT_BE_SYNCHRO_MATERIAL)
c:RegisterEffect(e6)
local e7=e3:Clone()
e7:SetCode(EFFECT_CANNOT_BE_XYZ_MATERIAL)
c:RegisterEffect(e7)
--damage
local e8=Effect.CreateEffect(c)
e8:SetDescription(aux.Stringid(9030160,0))
e8:SetCategory(CATEGORY_DAMAGE)
e8:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e8:SetCode(EVENT_PHASE+PHASE_STANDBY)
e8:SetRange(LOCATION_SZONE)
e8:SetCountLimit(1)
e8:SetCondition(c9030160.damcon)
e8:SetTarget(c9030160.damtg)
e8:SetOperation(c9030160.damop)
c:RegisterEffect(e8)
end
function c9030160.condition(e)
return Duel.IsExistingMatchingCard(Card.IsSetCard,e:GetHandlerPlayer(),LOCATION_PZONE,0,2,nil,0xaf)
end
function c9030160.sumlimit(e,c)
if not c then return false end
return not c:IsControler(e:GetHandlerPlayer())
end
function c9030160.fuslimit(e,c,sumtype)
if not c then return false end
return not c:IsControler(e:GetHandlerPlayer()) and sumtype==SUMMON_TYPE_FUSION
end
function c9030160.evalue(e,re,rp)
return re:IsActiveType(TYPE_SPELL+TYPE_TRAP) and rp==1-e:GetHandlerPlayer()
end
function c9030160.damcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==tp
end
function c9030160.damtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetTargetPlayer(tp)
Duel.SetTargetParam(1000)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,0,0,tp,1000)
end
function c9030160.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 |
mercury233/ygopro-scripts | c76384284.lua | 2 | 1259 | --トロイの剣闘獣
function c76384284.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_DRAW)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,TIMING_END_PHASE)
e1:SetTarget(c76384284.target)
e1:SetOperation(c76384284.activate)
c:RegisterEffect(e1)
end
function c76384284.filter(c,e,tp)
return c:IsSetCard(0x19) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP,1-tp)
end
function c76384284.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(1-tp,LOCATION_MZONE,tp)>0
and Duel.IsExistingMatchingCard(c76384284.filter,tp,LOCATION_HAND,0,1,nil,e,tp)
and Duel.IsPlayerCanDraw(tp,1) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND)
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1)
end
function c76384284.activate(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(1-tp,LOCATION_MZONE,tp)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c76384284.filter,tp,LOCATION_HAND,0,1,1,nil,e,tp)
if g:GetCount()>0 and Duel.SpecialSummon(g,0,tp,1-tp,false,false,POS_FACEUP)~=0 then
Duel.BreakEffect()
Duel.Draw(tp,1,REASON_EFFECT)
end
end
| gpl-2.0 |
GuntherStruyf/luaunit | test/test_with_err_fail_pass.lua | 4 | 1415 | local lu = require('luaunit')
--[[ Test used by functional tests ]]
TestSomething = {} --class
function TestSomething:test1_Success1()
lu.assertEquals( 1+1, 2 )
end
function TestSomething:test1_Success2()
lu.assertEquals( 1+2, 3 )
end
function TestSomething:test2_Fail1()
lu.assertEquals( 1+1, 0 )
end
function TestSomething:test2_Fail2()
lu.assertEquals( 1+2, 0 )
end
function TestSomething:test3_Err1()
local v = 1 + { 1,2 }
end
function TestSomething:test3_Err2()
local v = 1 + { 1,2 }
end
TestAnotherThing = {} --class
function TestAnotherThing:test1_Success1()
lu.assertEquals( 1+1, 2 )
end
function TestAnotherThing:test1_Success2()
lu.assertEquals( 1+2, 3 )
end
function TestAnotherThing:test2_Err1()
local v = 1 + { 1,2 }
end
function TestAnotherThing:test2_Err2()
local v = 1 + { 1,2 }
end
function TestAnotherThing:test3_Fail1()
lu.assertEquals( 1+1, 0 )
end
function TestAnotherThing:test3_Fail2()
lu.assertEquals( 1+2, 0 )
end
function testFuncSuccess1()
lu.assertEquals( 1+1, 2 )
end
function testFuncFail1()
lu.assertEquals( 1+2, 0 )
end
function testFuncErr1()
local v = 1 + { 1,2 }
end
local runner = lu.LuaUnit.new()
runner:setOutputType("text")
os.exit( runner:runSuite() )
| bsd-2-clause |
Zenny89/darkstar | scripts/zones/Xarcabard_[S]/Zone.lua | 28 | 1313 | -----------------------------------
--
-- Zone: Xarcabard_[S] (137)
--
-----------------------------------
package.loaded["scripts/zones/Xarcabard_[S]/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Xarcabard_[S]/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(-414,-46.5,20,253);
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
Zenny89/darkstar | scripts/zones/Kazham/npcs/Kocho_Phunakcham.lua | 15 | 1103 | -----------------------------------
-- Area: Kazham
-- NPC: Kocho Phunakcham
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Kazham/TextIDs"] = nil;
require("scripts/zones/Kazham/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getVar("BathedInScent") == 1) then
player:startEvent(0x00AA); -- scent from Blue Rafflesias
else
player:startEvent(0x0041);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
mercury233/ygopro-scripts | c12338068.lua | 2 | 1436 | --真魔獣 ガーゼット
function c12338068.initial_effect(c)
c:EnableReviveLimit()
--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)
--special summon
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_SPSUMMON_PROC)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e2:SetRange(LOCATION_HAND)
e2:SetCondition(c12338068.spcon)
e2:SetOperation(c12338068.spop)
c:RegisterEffect(e2)
--pierce
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_PIERCE)
c:RegisterEffect(e3)
end
function c12338068.spcon(e,c)
if c==nil then return true end
local tp=c:GetControler()
local g=Duel.GetFieldGroup(tp,LOCATION_MZONE,0)
local rg=Duel.GetReleaseGroup(tp)
return (g:GetCount()>0 or rg:GetCount()>0) and g:FilterCount(Card.IsReleasable,nil)==g:GetCount()
end
function c12338068.spop(e,tp,eg,ep,ev,re,r,rp,c)
local g=Duel.GetReleaseGroup(tp)
Duel.Release(g,REASON_COST)
local atk=0
local tc=g:GetFirst()
while tc do
local batk=tc:GetTextAttack()
if batk>0 then
atk=atk+batk
end
tc=g:GetNext()
end
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SET_ATTACK)
e1:SetValue(atk)
e1:SetReset(RESET_EVENT+0xff0000)
c:RegisterEffect(e1)
end
| gpl-2.0 |
mercury233/ygopro-scripts | c30968774.lua | 4 | 1744 | --スワップリースト
function c30968774.initial_effect(c)
--reduce atk and draw
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(30968774,0))
e1:SetCategory(CATEGORY_DRAW+CATEGORY_ATKCHANGE)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCode(EVENT_BE_MATERIAL)
e1:SetCountLimit(1,30968774)
e1:SetCondition(c30968774.drcon)
e1:SetTarget(c30968774.drtg)
e1:SetOperation(c30968774.drop)
c:RegisterEffect(e1)
--reg
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_BE_MATERIAL)
e2:SetCondition(c30968774.drcon)
e2:SetOperation(c30968774.regop)
c:RegisterEffect(e2)
end
function c30968774.drcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsLocation(LOCATION_GRAVE) and r==REASON_LINK
end
function c30968774.drtg(e,tp,eg,ep,ev,re,r,rp,chk)
local rc=e:GetHandler():GetReasonCard()
if chk==0 then return Duel.IsPlayerCanDraw(tp,1) and rc:IsAttackAbove(500) and rc:GetFlagEffect(30968774)~=0 end
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1)
end
function c30968774.drop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local rc=c:GetReasonCard()
if not rc:IsAttackAbove(500) or rc:IsImmuneToEffect(e) or rc:GetFlagEffect(30968774)==0 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+RESETS_STANDARD)
rc:RegisterEffect(e1)
if not rc:IsHasEffect(EFFECT_REVERSE_UPDATE) then
Duel.BreakEffect()
Duel.Draw(tp,1,REASON_EFFECT)
end
end
function c30968774.regop(e,tp,eg,ep,ev,re,r,rp)
local rc=e:GetHandler():GetReasonCard()
rc:RegisterFlagEffect(30968774,RESET_EVENT+RESETS_STANDARD,0,1)
end
| gpl-2.0 |
linushsao/marsu_game-linus-v0.2 | mods/deprecated/bitchange/bank_currency.lua | 2 | 7134 | --Created by Krock for the BitChange mod
-- Bank node for the mod: currency (by Dan Duncombe)
--License: WTFPL
local file_path = minetest.get_worldpath() .. "/bitchange_bank_currency"
local exchange_worth = 15 -- default worth in "money" for one MineCoin, change if not okay
local bank = {}
local changes_made = false
local fs_1 = io.open(file_path, "r")
if fs_1 then
exchange_worth = tonumber(fs_1:read("*l"))
io.close(fs_1)
end
local function round(num, idp)
if idp and idp>0 then
local mult = 10^idp
return math.floor(num * mult + 0.5) / mult
end
return math.floor(num + 0.5)
end
local function save_exchange_rate()
local fs_2 = io.open(file_path, "w")
fs_2:write(tostring(exchange_worth))
io.close(fs_2)
end
local ttime = 0
minetest.register_globalstep(function(t)
ttime = ttime + t
if ttime < 240 then --every 4min'
return
end
if(changes_made) then
save_exchange_rate()
end
ttime = 0
end)
minetest.register_on_shutdown(function()
save_exchange_rate()
end)
local function has_bank_privilege(meta, player)
local player_name = player:get_player_name()
return ((player_name == meta:get_string("owner")) or minetest.get_player_privs(player_name).server)
end
local function get_bank_formspec(number, pos)
local formspec = ""
local name = "nodemeta:"..pos.x..","..pos.y..","..pos.z
if(number == 1) then
-- customer
formspec = ("size[8,8]"..
"label[0,0;Bank]"..
"label[2,0;(View reserve with (E) + (Right click))]"..
"label[1,1;Current worth of a MineCoin:]"..
"label[3,1.5;~ "..round(exchange_worth, 2).." MineGeld]"..
"button[2,3;3,1;sell10;Buy 10 MineCoins]"..
"button[2,2;3,1;buy10;Sell 10 MineCoins]"..
"list[current_player;main;0,4;8,4;]")
elseif(number == 2) then
-- owner
formspec = ("size[8,9;]"..
"label[0,0;Bank]"..
"label[1,0.5;Current MineCoin reserve: (Editable by owner)]"..
"list["..name..";coins;0,1;8,3;]"..
"list[current_player;main;0,5;8,4;]")
end
return formspec
end
minetest.register_on_player_receive_fields(function(sender, formname, fields)
if(formname == "bitchange:bank_formspec") then
local player_name = sender:get_player_name()
if(fields.quit) then
bank[player_name] = nil
return
end
if(exchange_worth < 1) then
exchange_worth = 1
end
local pos = bank[player_name]
local bank_inv = minetest.get_meta(pos):get_inventory()
local player_inv = sender:get_inventory()
local coin_stack = "bitchange:minecoin 10"
local geld_stack = "currency:minegeld "
local err_msg = ""
if(fields.buy10) then
geld_stack = geld_stack..(round(exchange_worth * 0.995, 1) * 10)
if(not player_inv:contains_item("main", coin_stack)) then
err_msg = "You do not have the needed MineCoins."
end
if(err_msg == "") then
if(not bank_inv:room_for_item("coins", coin_stack)) then
err_msg = "This bank has no space to buy more MineCoins."
end
end
if(err_msg == "") then
if(not bank_inv:contains_item("coins", geld_stack)) then
err_msg = "This bank has no MineGeld ready to sell."
end
end
if(err_msg == "") then
if(not player_inv:room_for_item("main", geld_stack)) then
err_msg = "You do not have enough space in your inventory."
end
end
if(err_msg == "") then
exchange_worth = exchange_worth * 0.995
local price = round(exchange_worth - 0.01, 1) * 10
bank_inv:remove_item("coins", geld_stack)
player_inv:add_item("main", geld_stack)
player_inv:remove_item("main", coin_stack)
bank_inv:add_item("coins", coin_stack)
changes_made = true
err_msg = "Sold 10 MineCoins for "..price.." MineGeld"
end
elseif(fields.sell10) then
local price = round(exchange_worth, 1) * 10
geld_stack = geld_stack..(round(exchange_worth, 1) * 10)
if(not player_inv:contains_item("main", geld_stack)) then
err_msg = "You do not have the required money. ("..price.." x 1 MineGeld pieces)"
end
if(err_msg == "") then
if(not bank_inv:room_for_item("coins", geld_stack)) then
err_msg = "This bank has no space to buy more MineGeld."
end
end
if(err_msg == "") then
if(not bank_inv:contains_item("coins", coin_stack)) then
err_msg = "This bank has no MineCoins ready to sell."
end
end
if(err_msg == "") then
if(not player_inv:room_for_item("main", coin_stack)) then
err_msg = "You do not have enough space in your inventory."
end
end
if(err_msg == "") then
player_inv:remove_item("main", geld_stack)
bank_inv:add_item("coins", geld_stack)
bank_inv:remove_item("coins", coin_stack)
player_inv:add_item("main", coin_stack)
exchange_worth = exchange_worth * 1.005
changes_made = true
err_msg = "Bought 10 MineCoins for "..price.." MineGeld"
end
end
if(err_msg ~= "") then
minetest.chat_send_player(player_name, "Bank: "..err_msg)
end
end
end)
minetest.register_node("bitchange:bank", {
description = "Bank",
tiles = {"bitchange_bank_side.png", "bitchange_bank_side.png",
"bitchange_bank_side.png", "bitchange_bank_side.png",
"bitchange_bank_side.png", "bitchange_bank_front.png"},
paramtype2 = "facedir",
groups = {cracky=1,level=1},
sounds = default.node_sound_stone_defaults(),
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name())
meta:set_string("infotext", "COIN Exchanger (owned by "..
meta:get_string("owner")..")")
end,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Bank (constructing)")
meta:set_string("formspec", "")
meta:set_string("owner", "")
local inv = meta:get_inventory()
inv:set_size("coins", 8*3)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)
if(meta:get_string("owner") == player:get_player_name()) then
return meta:get_inventory():is_empty("coins")
else
return false
end
end,
on_rightclick = function(pos, node, clicker, itemstack)
local player_name = clicker:get_player_name()
local view = 1
bank[player_name] = pos
if(clicker:get_player_control().aux1) then
view = 2
end
minetest.show_formspec(player_name,"bitchange:bank_formspec",get_bank_formspec(view, pos))
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos)
if(has_bank_privilege(meta, player)) then
return count
end
return 0
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
if (has_bank_privilege(meta, player)) then
return stack:get_count()
end
return 0
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
if (has_bank_privilege(meta, player)) then
return stack:get_count()
end
return 0
end,
})
| gpl-3.0 |
mercury233/ygopro-scripts | c1329620.lua | 2 | 3044 | --壱世壊に澄み渡る残響
function c1329620.initial_effect(c)
aux.AddCodeList(c,56099748)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_NEGATE+CATEGORY_TODECK+CATEGORY_TOGRAVE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_CHAINING)
e1:SetCountLimit(1,1329620)
e1:SetCondition(c1329620.condition)
e1:SetTarget(c1329620.target)
e1:SetOperation(c1329620.activate)
c:RegisterEffect(e1)
--to hand
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_TO_GRAVE)
e2:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET)
e2:SetCountLimit(1,1329620)
e2:SetCondition(c1329620.thcon)
e2:SetTarget(c1329620.thtg)
e2:SetOperation(c1329620.thop)
c:RegisterEffect(e2)
end
function c1329620.actcfilter(c)
return ((c:IsSetCard(0x181) and c:IsLocation(LOCATION_MZONE)) or c:IsCode(56099748)) and c:IsFaceup()
end
function c1329620.condition(e,tp,eg,ep,ev,re,r,rp)
return (re:IsActiveType(TYPE_MONSTER) or re:IsHasType(EFFECT_TYPE_ACTIVATE)) and Duel.IsChainNegatable(ev)
and Duel.IsExistingMatchingCard(c1329620.actcfilter,tp,LOCATION_ONFIELD,0,1,nil)
end
function c1329620.cfilter(c)
return c:IsType(TYPE_MONSTER) and c:IsAbleToGrave()
end
function c1329620.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c1329620.cfilter,tp,LOCATION_HAND,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0)
if re:GetHandler():IsRelateToEffect(re) then
Duel.SetOperationInfo(0,CATEGORY_TODECK,eg,1,0,0)
end
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_HAND)
end
function c1329620.activate(e,tp,eg,ep,ev,re,r,rp)
local ec=re:GetHandler()
if Duel.NegateActivation(ev) and ec:IsRelateToEffect(re) then
ec:CancelToGrave()
if Duel.SendtoDeck(ec,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)~=0 and ec:IsLocation(LOCATION_DECK+LOCATION_EXTRA) then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,c1329620.cfilter,tp,LOCATION_HAND,0,1,1,nil)
if #g>0 then
Duel.BreakEffect()
Duel.SendtoGrave(g,REASON_EFFECT)
end
end
end
end
function c1329620.thcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsReason(REASON_EFFECT)
end
function c1329620.thfilter(c)
return c:IsSetCard(0x181) and c:IsType(TYPE_MONSTER) and c:IsFaceup() and c:IsAbleToHand()
end
function c1329620.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and c1329620.thfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c1329620.thfilter,tp,LOCATION_REMOVED,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectTarget(tp,c1329620.thfilter,tp,LOCATION_REMOVED,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function c1329620.thop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
end
end
| gpl-2.0 |
Zenny89/darkstar | scripts/globals/weaponskills/spirits_within.lua | 30 | 1518 | -----------------------------------
-- Spirits Within
-- Sword weapon skill
-- Spirits Within Sword Weapon Skill
-- TrolandAdded by Troland
-- Skill Level: 175
-- Delivers an unavoidable attack. Damage varies with HP and TP.
-- Not aligned with any "elemental gorgets" or "elemental belts" due to it's absence of Skillchain properties.
-- Element: None
-- Modifiers: HP:
-- 100%TP 200%TP 300%TP
-- 12.5% 50% 100%
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
require("scripts/globals/utils");
-----------------------------------
function onUseWeaponSkill(player, target, wsID)
local HP = player:getHP();
local TP = player:getTP();
local WSC = 0;
if (TP == 300) then
WSC = HP * 0.46875;
elseif (TP >= 200) then
WSC = HP * ((TP - 200) / (100 / (0.46875 - 0.1875)));
elseif (TP >= 100) then
WSC = HP * ((TP - 100) / (100 / (0.1875 - 0.125)));
end
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
-- Damage calculations changed based on: http://www.bg-wiki.com/bg/Spirits_Within http://www.bluegartr.com/threads/121610-Rehauled-Weapon-Skills-tier-lists?p=6142188&viewfull=1#post6142188
if (TP == 300) then
WSC = HP;
elseif (TP >= 200) then
WSC = HP * .5
elseif (TP >= 100) then
WSC = HP * .125;
end
end
local damage = target:breathDmgTaken(WSC);
damage = damage * WEAPON_SKILL_POWER
return 1, 0, false, damage;
end
| gpl-3.0 |
mercury233/ygopro-scripts | c52098461.lua | 2 | 1624 | --ラス・オブ・ネオス
function c52098461.initial_effect(c)
aux.AddCodeList(c,89943723)
aux.AddSetNameMonsterList(c,0x3008)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_TODECK+CATEGORY_DESTROY)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(c52098461.target)
e1:SetOperation(c52098461.activate)
c:RegisterEffect(e1)
end
function c52098461.filter(c)
return c:IsFaceup() and c:IsCode(89943723) and c:IsAbleToDeck()
end
function c52098461.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and c52098461.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c52098461.filter,tp,LOCATION_MZONE,0,1,nil)
and Duel.IsExistingMatchingCard(aux.TRUE,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,2,e:GetHandler()) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local g=Duel.SelectTarget(tp,c52098461.filter,tp,LOCATION_MZONE,0,1,1,nil)
local dg=Duel.GetMatchingGroup(aux.TRUE,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,e:GetHandler())
dg:RemoveCard(g:GetFirst())
Duel.SetOperationInfo(0,CATEGORY_TODECK,g,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,dg,dg:GetCount(),0,0)
end
function c52098461.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and c52098461.filter(tc)
and Duel.SendtoDeck(tc,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)~=0 and tc:IsLocation(LOCATION_DECK) then
local g=Duel.GetMatchingGroup(aux.TRUE,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,aux.ExceptThisCard(e))
Duel.Destroy(g,REASON_EFFECT)
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c8057630.lua | 2 | 2655 | --コアの再練成
function c8057630.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,TIMING_END_PHASE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetTarget(c8057630.target)
e1:SetOperation(c8057630.operation)
c:RegisterEffect(e1)
--Destroy
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_SINGLE)
e2:SetCode(EVENT_LEAVE_FIELD)
e2:SetOperation(c8057630.desop)
c:RegisterEffect(e2)
--Destroy2
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD)
e3:SetRange(LOCATION_SZONE)
e3:SetCode(EVENT_LEAVE_FIELD)
e3:SetCondition(c8057630.descon2)
e3:SetOperation(c8057630.desop2)
e2:SetLabelObject(e3)
c:RegisterEffect(e3)
end
function c8057630.filter(c,e,tp)
return c:IsSetCard(0x1d) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_ATTACK)
end
function c8057630.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c8057630.filter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c8057630.filter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c8057630.filter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c8057630.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 Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP_ATTACK) then
c:SetCardTarget(tc)
end
Duel.SpecialSummonComplete()
end
function c8057630.desop(e,tp,eg,ep,ev,re,r,rp)
local tc=e:GetHandler():GetFirstCardTarget()
if not tc then return end
if tc:IsLocation(LOCATION_MZONE) and Duel.Destroy(tc,REASON_EFFECT)==0 then return end
if re~=e:GetLabelObject() and Duel.GetTurnPlayer()==tp and Duel.GetCurrentPhase()==PHASE_END then
local atk=tc:GetBaseAttack()
if atk<0 then atk=0 end
Duel.Damage(tp,atk,REASON_EFFECT)
end
end
function c8057630.descon2(e,tp,eg,ep,ev,re,r,rp)
local tc=e:GetHandler():GetFirstCardTarget()
return tc and eg:IsContains(tc) and tc:IsReason(REASON_DESTROY)
end
function c8057630.desop2(e,tp,eg,ep,ev,re,r,rp)
local tc=e:GetHandler():GetFirstCardTarget()
if Duel.GetTurnPlayer()==tp and Duel.GetCurrentPhase()==PHASE_END then
local atk=tc:GetBaseAttack()
if atk<0 then atk=0 end
Duel.Damage(tp,atk,REASON_EFFECT)
end
Duel.Destroy(e:GetHandler(),REASON_EFFECT)
end
| gpl-2.0 |
mercury233/ygopro-scripts | c74586817.lua | 2 | 4976 | --PSYフレームロード・Ω
function c74586817.initial_effect(c)
--synchro summon
aux.AddSynchroProcedure(c,nil,aux.NonTuner(nil),1)
c:EnableReviveLimit()
--remove
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(74586817,0))
e1:SetCategory(CATEGORY_REMOVE)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetRange(LOCATION_MZONE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_MAIN_END)
e1:SetCountLimit(1)
e1:SetCondition(c74586817.rmcon)
e1:SetTarget(c74586817.rmtg)
e1:SetOperation(c74586817.rmop)
c:RegisterEffect(e1)
--to grave
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(74586817,1))
e2:SetCategory(CATEGORY_TOGRAVE)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetRange(LOCATION_MZONE)
e2:SetCode(EVENT_PHASE+PHASE_STANDBY)
e2:SetCountLimit(1)
e2:SetCondition(c74586817.tgcon)
e2:SetTarget(c74586817.tgtg)
e2:SetOperation(c74586817.tgop)
c:RegisterEffect(e2)
--to deck
local e3=Effect.CreateEffect(c)
e3:SetCategory(CATEGORY_TODECK)
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetRange(LOCATION_GRAVE)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
e3:SetTarget(c74586817.tdtg)
e3:SetOperation(c74586817.tdop)
c:RegisterEffect(e3)
end
function c74586817.rmcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2
end
function c74586817.rmtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemove()
and Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,0,LOCATION_HAND,1,nil) end
local g=Duel.GetMatchingGroup(Card.IsAbleToRemove,tp,0,LOCATION_HAND,nil)
g:AddCard(e:GetHandler())
Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,2,0,0)
end
function c74586817.rmop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local g=Duel.GetFieldGroup(1-tp,LOCATION_HAND,0)
if g:GetCount()==0 or not c:IsRelateToEffect(e) or c:IsFacedown() then return end
local rs=g:RandomSelect(1-tp,1)
local rg=Group.FromCards(c,rs:GetFirst())
if Duel.Remove(rg,POS_FACEUP,REASON_EFFECT+REASON_TEMPORARY)~=0 then
local fid=c:GetFieldID()
local og=Duel.GetOperatedGroup()
local oc=og:GetFirst()
while oc do
oc:RegisterFlagEffect(74586817,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN,0,1,fid)
oc=og:GetNext()
end
og:KeepAlive()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetCode(EVENT_PHASE+PHASE_STANDBY)
e1:SetCountLimit(1)
e1:SetLabel(fid)
e1:SetLabelObject(og)
e1:SetCondition(c74586817.retcon)
e1:SetOperation(c74586817.retop)
e1:SetReset(RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN)
Duel.RegisterEffect(e1,tp)
end
end
function c74586817.tgcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()~=tp
end
function c74586817.tgtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_REMOVED) end
if chk==0 then return Duel.IsExistingTarget(nil,tp,LOCATION_REMOVED,LOCATION_REMOVED,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(74586817,2))
local g=Duel.SelectTarget(tp,nil,tp,LOCATION_REMOVED,LOCATION_REMOVED,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g,1,0,0)
end
function c74586817.tgop(e,tp,eg,ep,ev,re,r,rp)
local tg=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
local sg=tg:Filter(Card.IsRelateToEffect,nil,e)
if sg:GetCount()>0 then
Duel.SendtoGrave(sg,REASON_EFFECT+REASON_RETURN)
end
end
function c74586817.retfilter(c,fid)
return c:GetFlagEffectLabel(74586817)==fid
end
function c74586817.retcon(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetTurnPlayer()~=tp then return false end
local g=e:GetLabelObject()
if not g:IsExists(c74586817.retfilter,1,nil,e:GetLabel()) then
g:DeleteGroup()
e:Reset()
return false
else return true end
end
function c74586817.retop(e,tp,eg,ep,ev,re,r,rp)
local g=e:GetLabelObject()
local sg=g:Filter(c74586817.retfilter,nil,e:GetLabel())
g:DeleteGroup()
local tc=sg:GetFirst()
while tc do
if tc==e:GetHandler() then
Duel.ReturnToField(tc)
else
Duel.SendtoHand(tc,tc:GetPreviousControler(),REASON_EFFECT)
end
tc=sg:GetNext()
end
end
function c74586817.tdtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsAbleToDeck() and chkc~=e:GetHandler() end
if chk==0 then return e:GetHandler():IsAbleToExtra()
and Duel.IsExistingTarget(Card.IsAbleToDeck,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,e:GetHandler()) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local g=Duel.SelectTarget(tp,Card.IsAbleToDeck,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,1,e:GetHandler())
g:AddCard(e:GetHandler())
Duel.SetOperationInfo(0,CATEGORY_TODECK,g,2,0,0)
end
function c74586817.tdop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) then
local g=Group.FromCards(c,tc)
Duel.SendtoDeck(g,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)
end
end
| gpl-2.0 |
focusworld/aaab | plugins/owners.lua | 284 | 12473 |
local function lock_group_namemod(msg, data, target)
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'yes' then
return 'Group name is already locked'
else
data[tostring(target)]['settings']['lock_name'] = 'yes'
save_data(_config.moderation.data, data)
rename_chat('chat#id'..target, group_name_set, ok_cb, false)
return 'Group name has been locked'
end
end
local function unlock_group_namemod(msg, data, target)
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'no' then
return 'Group name is already unlocked'
else
data[tostring(target)]['settings']['lock_name'] = 'no'
save_data(_config.moderation.data, data)
return 'Group name has been unlocked'
end
end
local function lock_group_floodmod(msg, data, target)
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'yes' then
return 'Group flood is locked'
else
data[tostring(target)]['settings']['flood'] = 'yes'
save_data(_config.moderation.data, data)
return 'Group flood has been locked'
end
end
local function unlock_group_floodmod(msg, data, target)
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'no' then
return 'Group flood is not locked'
else
data[tostring(target)]['settings']['flood'] = 'no'
save_data(_config.moderation.data, data)
return 'Group flood has been unlocked'
end
end
local function lock_group_membermod(msg, data, target)
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'yes' then
return 'Group members are already locked'
else
data[tostring(target)]['settings']['lock_member'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group members has been locked'
end
local function unlock_group_membermod(msg, data, target)
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'no' then
return 'Group members are not locked'
else
data[tostring(target)]['settings']['lock_member'] = 'no'
save_data(_config.moderation.data, data)
return 'Group members has been unlocked'
end
end
local function unlock_group_photomod(msg, data, target)
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'no' then
return 'Group photo is not locked'
else
data[tostring(target)]['settings']['lock_photo'] = 'no'
save_data(_config.moderation.data, data)
return 'Group photo has been unlocked'
end
end
local function show_group_settingsmod(msg, data, target)
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['settings']['flood_msg_max'] then
NUM_MSG_MAX = tonumber(data[tostring(msg.to.id)]['settings']['flood_msg_max'])
print('custom'..NUM_MSG_MAX)
else
NUM_MSG_MAX = 5
end
end
local settings = data[tostring(target)]['settings']
local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nflood sensitivity : "..NUM_MSG_MAX
return text
end
local function set_rules(target, rules)
local data = load_data(_config.moderation.data)
local data_cat = 'rules'
data[tostring(target)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..rules
end
local function set_description(target, about)
local data = load_data(_config.moderation.data)
local data_cat = 'description'
data[tostring(target)][data_cat] = about
save_data(_config.moderation.data, data)
return 'Set group description to:\n'..about
end
local function run(msg, matches)
if msg.to.type ~= 'chat' then
local chat_id = matches[1]
local receiver = get_receiver(msg)
local data = load_data(_config.moderation.data)
if matches[2] == 'ban' then
local chat_id = matches[1]
if not is_owner2(msg.from.id, chat_id) then
return "You are not the owner of this group"
end
if tonumber(matches[3]) == tonumber(our_id) then return false end
local user_id = matches[3]
if tonumber(matches[3]) == tonumber(msg.from.id) then
return "You can't ban yourself"
end
ban_user(matches[3], matches[1])
local name = user_print_name(msg.from)
savelog(matches[1], name.." ["..msg.from.id.."] banned user ".. matches[3])
return 'User '..user_id..' banned'
end
if matches[2] == 'unban' then
if tonumber(matches[3]) == tonumber(our_id) then return false end
local chat_id = matches[1]
if not is_owner2(msg.from.id, chat_id) then
return "You are not the owner of this group"
end
local user_id = matches[3]
if tonumber(matches[3]) == tonumber(msg.from.id) then
return "You can't unban yourself"
end
local hash = 'banned:'..matches[1]
redis:srem(hash, user_id)
local name = user_print_name(msg.from)
savelog(matches[1], name.." ["..msg.from.id.."] unbanned user ".. matches[3])
return 'User '..user_id..' unbanned'
end
if matches[2] == 'kick' then
local chat_id = matches[1]
if not is_owner2(msg.from.id, chat_id) then
return "You are not the owner of this group"
end
if tonumber(matches[3]) == tonumber(our_id) then return false end
local user_id = matches[3]
if tonumber(matches[3]) == tonumber(msg.from.id) then
return "You can't kick yourself"
end
kick_user(matches[3], matches[1])
local name = user_print_name(msg.from)
savelog(matches[1], name.." ["..msg.from.id.."] kicked user ".. matches[3])
return 'User '..user_id..' kicked'
end
if matches[2] == 'clean' then
if matches[3] == 'modlist' then
if not is_owner2(msg.from.id, chat_id) then
return "You are not the owner of this group"
end
for k,v in pairs(data[tostring(matches[1])]['moderators']) do
data[tostring(matches[1])]['moderators'][tostring(k)] = nil
save_data(_config.moderation.data, data)
end
local name = user_print_name(msg.from)
savelog(matches[1], name.." ["..msg.from.id.."] cleaned modlist")
end
if matches[3] == 'rules' then
if not is_owner2(msg.from.id, chat_id) then
return "You are not the owner of this group"
end
local data_cat = 'rules'
data[tostring(matches[1])][data_cat] = nil
save_data(_config.moderation.data, data)
local name = user_print_name(msg.from)
savelog(matches[1], name.." ["..msg.from.id.."] cleaned rules")
end
if matches[3] == 'about' then
if not is_owner2(msg.from.id, chat_id) then
return "You are not the owner of this group"
end
local data_cat = 'description'
data[tostring(matches[1])][data_cat] = nil
save_data(_config.moderation.data, data)
local name = user_print_name(msg.from)
savelog(matches[1], name.." ["..msg.from.id.."] cleaned about")
end
end
if matches[2] == "setflood" then
if not is_owner2(msg.from.id, chat_id) then
return "You are not the owner of this group"
end
if tonumber(matches[3]) < 5 or tonumber(matches[3]) > 20 then
return "Wrong number,range is [5-20]"
end
local flood_max = matches[3]
data[tostring(matches[1])]['settings']['flood_msg_max'] = flood_max
save_data(_config.moderation.data, data)
local name = user_print_name(msg.from)
savelog(matches[1], name.." ["..msg.from.id.."] set flood to ["..matches[3].."]")
return 'Group flood has been set to '..matches[3]
end
if matches[2] == 'lock' then
if not is_owner2(msg.from.id, chat_id) then
return "You are not the owner of this group"
end
local target = matches[1]
if matches[3] == 'name' then
local name = user_print_name(msg.from)
savelog(matches[1], name.." ["..msg.from.id.."] locked name ")
return lock_group_namemod(msg, data, target)
end
if matches[3] == 'member' then
local name = user_print_name(msg.from)
savelog(matches[1], name.." ["..msg.from.id.."] locked member ")
return lock_group_membermod(msg, data, target)
end
end
if matches[2] == 'unlock' then
if not is_owner2(msg.from.id, chat_id) then
return "You are not the owner of this group"
end
local target = matches[1]
if matches[3] == 'name' then
local name = user_print_name(msg.from)
savelog(matches[1], name.." ["..msg.from.id.."] unlocked name ")
return unlock_group_namemod(msg, data, target)
end
if matches[3] == 'member' then
local name = user_print_name(msg.from)
savelog(matches[1], name.." ["..msg.from.id.."] unlocked member ")
return unlock_group_membermod(msg, data, target)
end
end
if matches[2] == 'new' then
if matches[3] == 'link' then
if not is_owner2(msg.from.id, chat_id) then
return "You are not the owner of this group"
end
local function callback (extra , success, result)
local receiver = 'chat#'..matches[1]
vardump(result)
data[tostring(matches[1])]['settings']['set_link'] = result
save_data(_config.moderation.data, data)
return
end
local receiver = 'chat#'..matches[1]
local name = user_print_name(msg.from)
savelog(matches[1], name.." ["..msg.from.id.."] revoked group link ")
export_chat_link(receiver, callback, true)
return "Created a new new link ! \n owner can get it by /owners "..matches[1].." get link"
end
end
if matches[2] == 'get' then
if matches[3] == 'link' then
if not is_owner2(msg.from.id, chat_id) then
return "You are not the owner of this group"
end
local group_link = data[tostring(matches[1])]['settings']['set_link']
if not group_link then
return "Create a link using /newlink first !"
end
local name = user_print_name(msg.from)
savelog(matches[1], name.." ["..msg.from.id.."] requested group link ["..group_link.."]")
return "Group link:\n"..group_link
end
end
if matches[1] == 'changeabout' and matches[2] and is_owner2(msg.from.id, matches[2]) then
local target = matches[2]
local about = matches[3]
local name = user_print_name(msg.from)
savelog(matches[2], name.." ["..msg.from.id.."] has changed group description to ["..matches[3].."]")
return set_description(target, about)
end
if matches[1] == 'changerules' and is_owner2(msg.from.id, matches[2]) then
local rules = matches[3]
local target = matches[2]
local name = user_print_name(msg.from)
savelog(matches[2], name.." ["..msg.from.id.."] has changed group rules to ["..matches[3].."]")
return set_rules(target, rules)
end
if matches[1] == 'changename' and is_owner2(msg.from.id, matches[2]) then
local new_name = string.gsub(matches[3], '_', ' ')
data[tostring(matches[2])]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(matches[2])]['settings']['set_name']
local to_rename = 'chat#id'..matches[2]
local name = user_print_name(msg.from)
savelog(matches[2], "Group {} name changed to [ "..new_name.." ] by "..name.." ["..msg.from.id.."]")
rename_chat(to_rename, group_name_set, ok_cb, false)
end
if matches[1] == 'loggroup' and matches[2] and is_owner2(msg.from.id, matches[2]) then
savelog(matches[2], "------")
send_document("user#id".. msg.from.id,"./groups/"..matches[2].."log.txt", ok_cb, false)
end
end
end
return {
patterns = {
"^[!/]owners (%d+) ([^%s]+) (.*)$",
"^[!/]owners (%d+) ([^%s]+)$",
"^[!/](changeabout) (%d+) (.*)$",
"^[!/](changerules) (%d+) (.*)$",
"^[!/](changename) (%d+) (.*)$",
"^[!/](loggroup) (%d+)$"
},
run = run
}
| gpl-2.0 |
Zenny89/darkstar | scripts/zones/Xarcabard/npcs/Trail_Markings.lua | 17 | 2473 | -----------------------------------
-- Area: Xarcabard
-- NPC: Trail Markings
-- Dynamis-Xarcabard Enter
-- @pos 570 0 -272 112
-----------------------------------
package.loaded["scripts/zones/Xarcabard/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/dynamis");
require("scripts/zones/Xarcabard/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getVar("DynaXarcabard_Win") == 1) then
player:startEvent(0x0020,HYDRA_CORPS_BATTLE_STANDARD); -- Win CS
elseif (player:hasKeyItem(HYDRA_CORPS_INSIGNIA)) then
local firstDyna = 0;
local realDay = os.time();
local dynaWaitxDay = player:getVar("dynaWaitxDay");
if (checkFirstDyna(player,6)) then -- First Dyna-Xarcabard => CS
firstDyna = 1;
end
if (player:getMainLvl() < DYNA_LEVEL_MIN) then
player:messageSpecial(PLAYERS_HAVE_NOT_REACHED_LEVEL,DYNA_LEVEL_MIN);
elseif ((dynaWaitxDay + (BETWEEN_2DYNA_WAIT_TIME * 24 * 60 * 60)) < realDay or player:getVar("DynamisID") == GetServerVariable("[DynaXarcabard]UniqueID")) then
player:startEvent(0x0010,6,firstDyna,0,BETWEEN_2DYNA_WAIT_TIME,32,VIAL_OF_SHROUDED_SAND,4236,4237);
else
dayRemaining = math.floor(((dynaWaitxDay + (BETWEEN_2DYNA_WAIT_TIME * 24 * 60 * 60)) - realDay)/3456);
player:messageSpecial(YOU_CANNOT_ENTER_DYNAMIS,dayRemaining,6);
end
else
player:messageSpecial(UNUSUAL_ARRANGEMENT_OF_PEBBLES);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("updateRESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("finishRESULT: %u",option);
if (csid == 0x0020) then
player:setVar("DynaXarcabard_Win",0);
elseif (csid == 0x0010 and option == 0) then
if (checkFirstDyna(player,6)) then
player:setVar("Dynamis_Status",player:getVar("Dynamis_Status") + 64);
end
player:setPos(569.312,-0.098,-270.158,90,0x87);
end
end; | gpl-3.0 |
linushsao/marsu_game-linus-v0.2 | mods/administration/linus_added/functions.lua | 1 | 3179 |
--extra functions for other mods
--[[function sky_change(player,ratio)
if ratio > 0.83 or ratio < 0.18 then
-- print("STARRY NIGHT@@@@@@@@@@@@")
player:set_sky({r=0, g=0, b=0},"skybox",{"marssurvive_space_sky.png","marssurvive_space_sky.png","marssurvive_space_sky_star.png","marssurvive_space_sky.png","marssurvive_space_sky.png","marssurvive_space_sky.png"})
else
if ratio < 0.5 then ratio = 1*(ratio/0.5)
else
if ratio > 0.8 then ratio = 1 end
ratio = (1-ratio)/0.5
end
-- print("TIME RATOI in globalsetup:"..ratio)
player:set_sky({r=math.floor(219*ratio), g=math.floor(168*ratio), b=20+math.floor(117*ratio)},"plain",{})
end
end]]--
function if_air(pos)
n=minetest.get_node({x=pos.x,y=pos.y+2,z=pos.z}).name
if n=="air" then
return 0.1
else
return 1
end
end
function if_fire(pos)
n=minetest.get_node({x=pos.x,y=pos.y+2,z=pos.z}).name
if n=="air" then
return "default_furnace_fire_fg-1.png"
else
return "default_furnace_fire_fg.png"
end
end
function save_table(table,file_name)
local path_to = minetest.get_worldpath() .. "/"..file_name
local output = io.open(path_to, "w")
output:write(minetest.serialize(table).."\n")
io.close(output)
end
--codes grab from hudhugry mod & walkinglight mod
-- update hud elemtens if value has changed
local function update_hud(player)
local name = player:get_player_name()
--hunger
local h_out = tonumber(hbhunger.hunger_out[name])
local h = tonumber(hbhunger.hunger[name])
if h_out ~= h then
hbhunger.hunger_out[name] = h
hb.change_hudbar(player, "satiation", h)
end
end
-- food functions
function get_food_saturation(item_name)
if hbhunger.food[item_name] == nil then return 0
else return hbhunger.food[item_name].saturation
end
end
local timer = 0
local timer_autoeat = 150 -- time in seconds to check autoeat
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer > timer_autoeat then
-- if timer > 3 then
timer = 0
for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
local h = tonumber(hbhunger.hunger[name])
local hp = player:get_hp()
local itemstack = player:get_wielded_item()
local stackid=player:get_wield_index()
local wielded_item = itemstack:get_name()
-- print("GET WIELDED ITEM "..wielded_item)
-- print("SATUATION "..get_food_saturation(wielded_item))
if get_food_saturation(wielded_item) ~= nil and get_food_saturation(wielded_item) ~= 0 then
if autoeat[name] == "on" then --if autoeat is enable
-- print("START TO AUTOEAT...")
-- Saturation
if h < 20 then
h = h + get_food_saturation(wielded_item)
hbhunger.hunger[name] = h
-- hbhunger.set_hunger_raw(name)
itemstack:take_item()
player:get_inventory():set_stack("main",stackid,itemstack)
-- update all hud elements
update_hud(player)
end
end
end
end
end
end)
| gpl-3.0 |
mercury233/ygopro-scripts | c87047074.lua | 2 | 2037 | --甲虫装機の魔弓 ゼクトアロー
function c87047074.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+EFFECT_FLAG_CONTINUOUS_TARGET)
e1:SetTarget(c87047074.target)
e1:SetOperation(c87047074.operation)
c:RegisterEffect(e1)
--Atk
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_EQUIP)
e2:SetCode(EFFECT_UPDATE_ATTACK)
e2:SetValue(500)
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(c87047074.eqlimit)
c:RegisterEffect(e3)
--chain limit
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e4:SetRange(LOCATION_SZONE)
e4:SetCode(EVENT_CHAINING)
e4:SetCondition(c87047074.chcon)
e4:SetOperation(c87047074.chop)
c:RegisterEffect(e4)
end
function c87047074.eqlimit(e,c)
return c:IsSetCard(0x56)
end
function c87047074.filter(c)
return c:IsFaceup() and c:IsSetCard(0x56)
end
function c87047074.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c87047074.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c87047074.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,c87047074.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
function c87047074.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 c87047074.chcon(e,tp,eg,ep,ev,re,r,rp)
return re:GetHandler()==e:GetHandler():GetEquipTarget()
end
function c87047074.chop(e,tp,eg,ep,ev,re,r,rp)
Duel.SetChainLimit(c87047074.chlimit)
end
function c87047074.chlimit(e,ep,tp)
return ep==tp
end
| gpl-2.0 |
mercury233/ygopro-scripts | c4440873.lua | 9 | 1211 | --強烈なはたき落とし
function c4440873.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCategory(CATEGORY_TOGRAVE+CATEGORY_HANDES)
e1:SetCode(EVENT_TO_HAND)
e1:SetCondition(c4440873.condition)
e1:SetTarget(c4440873.target)
e1:SetOperation(c4440873.activate)
c:RegisterEffect(e1)
end
function c4440873.cfilter(c,tp)
return c:IsControler(tp) and c:IsPreviousLocation(LOCATION_DECK)
end
function c4440873.condition(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c4440873.cfilter,1,nil,1-tp)
end
function c4440873.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetTargetCard(eg)
Duel.SetOperationInfo(0,CATEGORY_HANDES,nil,0,1-tp,1)
end
function c4440873.filter(c,e,tp)
return c:IsRelateToEffect(e) and c:IsControler(tp) and c:IsPreviousLocation(LOCATION_DECK)
end
function c4440873.activate(e,tp,eg,ep,ev,re,r,rp)
local sg=eg:Filter(c4440873.filter,nil,e,1-tp)
if sg:GetCount()==0 then
elseif sg:GetCount()==1 then
Duel.SendtoGrave(sg,REASON_EFFECT+REASON_DISCARD)
else
Duel.Hint(HINT_SELECTMSG,1-tp,HINTMSG_DISCARD)
local dg=sg:Select(1-tp,1,1,nil)
Duel.SendtoGrave(dg,REASON_EFFECT+REASON_DISCARD)
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c95372220.lua | 2 | 3356 | --マズルフラッシュ・ドラゴン
--not fully implemented
function c95372220.initial_effect(c)
--link summon
c:EnableReviveLimit()
aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkRace,RACE_DRAGON),2)
--zone limit
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_MUST_USE_MZONE)
e1:SetRange(LOCATION_MZONE)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetTargetRange(1,0)
e1:SetValue(c95372220.zonelimit)
c:RegisterEffect(e1)
--destroy
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(95372220,0))
e3:SetCategory(CATEGORY_REMOVE+CATEGORY_DAMAGE)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e3:SetCode(EVENT_SUMMON_SUCCESS)
e3:SetProperty(EFFECT_FLAG_DELAY)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE)
e3:SetCondition(c95372220.descon)
e3:SetTarget(c95372220.destg)
e3:SetOperation(c95372220.desop)
c:RegisterEffect(e3)
local e4=e3:Clone()
e4:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e4)
--negate
local e5=Effect.CreateEffect(c)
e5:SetDescription(aux.Stringid(95372220,1))
e5:SetCategory(CATEGORY_NEGATE)
e5:SetType(EFFECT_TYPE_QUICK_O)
e5:SetCode(EVENT_CHAINING)
e5:SetRange(LOCATION_MZONE)
e5:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL)
e5:SetCondition(c95372220.negcon)
e5:SetCost(c95372220.negcost)
e5:SetTarget(c95372220.negtg)
e5:SetOperation(c95372220.negop)
c:RegisterEffect(e5)
end
function c95372220.zonelimit(e)
return 0x7f007f & ~e:GetHandler():GetLinkedZone()
end
function c95372220.cfilter(c,ec)
if c:IsLocation(LOCATION_MZONE) then
return ec:GetLinkedGroup():IsContains(c)
else
return bit.band(ec:GetLinkedZone(c:GetPreviousControler()),bit.lshift(0x1,c:GetPreviousSequence()))~=0
end
end
function c95372220.descon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c95372220.cfilter,1,nil,e:GetHandler())
end
function c95372220.destg(e,tp,eg,ep,ev,re,r,rp,chk)
local g=e:GetHandler():GetLinkedGroup()
if chk==0 then return g:GetCount()>0 end
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,500)
end
function c95372220.desop(e,tp,eg,ep,ev,re,r,rp)
local g=e:GetHandler():GetLinkedGroup()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local tg=g:Select(tp,1,1,nil)
if tg:GetCount()>0 then
Duel.HintSelection(tg)
if Duel.Destroy(tg,REASON_EFFECT)>0 then
Duel.Damage(1-tp,500,REASON_EFFECT)
end
end
end
function c95372220.negcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsStatus(STATUS_BATTLE_DESTROYED) then return false end
if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then return end
local tg=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS)
return tg and tg:IsContains(c) and Duel.IsChainNegatable(ev)
end
function c95372220.costfilter(c)
return not c:IsStatus(STATUS_BATTLE_DESTROYED)
end
function c95372220.negcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckReleaseGroup(tp,c95372220.costfilter,1,nil) end
local g=Duel.SelectReleaseGroup(tp,c95372220.costfilter,1,1,nil)
Duel.Release(g,REASON_COST)
end
function c95372220.negtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0)
end
function c95372220.negop(e,tp,eg,ep,ev,re,r,rp)
Duel.NegateActivation(ev)
end
| gpl-2.0 |
linushsao/marsu_game-linus-v0.2 | mods/libs/vector_extras/init.lua | 1 | 16536 | local load_time_start = os.clock()
local funcs = {}
function funcs.pos_to_string(pos)
return "("..pos.x.."|"..pos.y.."|"..pos.z..")"
end
local r_corr = 0.25 --remove a bit more nodes (if shooting diagonal) to let it look like a hole (sth like antialiasing)
-- this doesn't need to be calculated every time
local f_1 = 0.5-r_corr
local f_2 = 0.5+r_corr
--returns information about the direction
local function get_used_dir(dir)
local abs_dir = {x=math.abs(dir.x), y=math.abs(dir.y), z=math.abs(dir.z)}
local dir_max = math.max(abs_dir.x, abs_dir.y, abs_dir.z)
if dir_max == abs_dir.x then
local tab = {"x", {x=1, y=dir.y/dir.x, z=dir.z/dir.x}}
if dir.x >= 0 then
tab[3] = "+"
end
return tab
end
if dir_max == abs_dir.y then
local tab = {"y", {x=dir.x/dir.y, y=1, z=dir.z/dir.y}}
if dir.y >= 0 then
tab[3] = "+"
end
return tab
end
local tab = {"z", {x=dir.x/dir.z, y=dir.y/dir.z, z=1}}
if dir.z >= 0 then
tab[3] = "+"
end
return tab
end
local function node_tab(z, d)
local n1 = math.floor(z*d+f_1)
local n2 = math.floor(z*d+f_2)
if n1 == n2 then
return {n1}
end
return {n1, n2}
end
local function return_line(pos, dir, range) --range ~= length
local tab = {}
local num = 1
local t_dir = get_used_dir(dir)
local dir_typ = t_dir[1]
if t_dir[3] == "+" then
f_tab = {0, range, 1}
else
f_tab = {0, -range, -1}
end
local d_ch = t_dir[2]
if dir_typ == "x" then
for d = f_tab[1],f_tab[2],f_tab[3] do
local x = d
local ytab = node_tab(d_ch.y, d)
local ztab = node_tab(d_ch.z, d)
for _,y in ipairs(ytab) do
for _,z in ipairs(ztab) do
tab[num] = {x=pos.x+x, y=pos.y+y, z=pos.z+z}
num = num+1
end
end
end
elseif dir_typ == "y" then
for d = f_tab[1],f_tab[2],f_tab[3] do
local xtab = node_tab(d_ch.x, d)
local y = d
local ztab = node_tab(d_ch.z, d)
for _,x in ipairs(xtab) do
for _,z in ipairs(ztab) do
tab[num] = {x=pos.x+x, y=pos.y+y, z=pos.z+z}
num = num+1
end
end
end
else
for d = f_tab[1],f_tab[2],f_tab[3] do
local xtab = node_tab(d_ch.x, d)
local ytab = node_tab(d_ch.y, d)
local z = d
for _,x in ipairs(xtab) do
for _,y in ipairs(ytab) do
tab[num] = {x=pos.x+x, y=pos.y+y, z=pos.z+z}
num = num+1
end
end
end
end
return tab
end
function funcs.rayIter(pos, dir)
-- make a table of possible movements
local step = {}
for i in pairs(pos) do
local v = math.sign(dir[i])
if v ~= 0 then
step[i] = v
end
end
local p
return function()
if not p then
-- avoid skipping the first position
p = vector.round(pos)
return vector.new(p)
end
-- find the position which has the smallest distance to the line
local choose = {}
local choosefit = vector.new()
for i in pairs(step) do
choose[i] = vector.new(p)
choose[i][i] = choose[i][i] + step[i]
choosefit[i] = vector.scalar(vector.normalize(vector.subtract(choose[i], pos)), dir)
end
p = choose[vector.get_max_coord(choosefit)]
return vector.new(p)
end
end
function funcs.fine_line(pos, dir, range)
if not range then --dir = pos2
dir, range = vector.direction(pos, dir), vector.distance(pos, dir)
end
local result,n = {},1
for p in vector.rayIter(pos, dir) do
if vector.distance(p, pos) > range then
break
end
result[n] = p
n = n+1
end
return result
end
function funcs.line(pos, dir, range, alt)
--assert_vector(pos)
if alt then
if not range then --dir = pos2
dir, range = vector.direction(pos, dir), vector.distance(pos, dir)
end
return return_line(pos, dir, range)
end
if range then
dir = vector.round(vector.multiply(dir, range))
else --dir = pos2
dir = vector.subtract(dir, pos)
end
local line,n = {},1
for _,i in ipairs(vector.threeline(dir.x, dir.y, dir.z)) do
line[n] = {x=pos.x+i[1], y=pos.y+i[2], z=pos.z+i[3]}
n = n+1
end
return line
end
local twolines = {}
function funcs.twoline(x, y)
local pstr = x.." "..y
local line = twolines[pstr]
if line then
return line
end
line = {}
local n = 1
local dirx = 1
if x < 0 then
dirx = -dirx
end
local ymin, ymax = 0, y
if y < 0 then
ymin, ymax = ymax, ymin
end
local m = y/x --y/0 works too
local dir = 1
if m < 0 then
dir = -dir
end
for i = 0,x,dirx do
local p1 = math.max(math.min(math.floor((i-0.5)*m+0.5), ymax), ymin)
local p2 = math.max(math.min(math.floor((i+0.5)*m+0.5), ymax), ymin)
for j = p1,p2,dir do
line[n] = {i, j}
n = n+1
end
end
twolines[pstr] = line
return line
end
local threelines = {}
function funcs.threeline(x, y, z)
local pstr = x.." "..y.." "..z
local line = threelines[pstr]
if line then
return line
end
if x ~= math.floor(x) then
minetest.log("error", "[vector_extras] INFO: The position used for vector.threeline isn't round.")
end
local two_line = vector.twoline(x, y)
line = {}
local n = 1
local zmin, zmax = 0, z
if z < 0 then
zmin, zmax = zmax, zmin
end
local m = z/math.hypot(x, y)
local dir = 1
if m < 0 then
dir = -dir
end
for _,i in ipairs(two_line) do
local px, py = unpack(i)
local ph = math.hypot(px, py)
local z1 = math.max(math.min(math.floor((ph-0.5)*m+0.5), zmax), zmin)
local z2 = math.max(math.min(math.floor((ph+0.5)*m+0.5), zmax), zmin)
for pz = z1,z2,dir do
line[n] = {px, py, pz}
n = n+1
end
end
threelines[pstr] = line
return line
end
function funcs.sort_positions(ps, preferred_coords)
preferred_coords = preferred_coords or {"z", "y", "x"}
local a,b,c = unpack(preferred_coords)
local function ps_sorting(p1, p2)
if p1[a] == p2[a] then
if p1[b] == p2[a] then
if p1[c] < p2[c] then
return true
end
elseif p1[b] < p2[b] then
return true
end
elseif p1[a] < p2[a] then
return true
end
end
table.sort(ps, ps_sorting)
end
function funcs.scalar(v1, v2)
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z
end
function funcs.cross(v1, v2)
return {
x = v1.y*v2.z - v1.z*v2.y,
y = v1.z*v2.x - v1.x*v2.z,
z = v1.x*v2.y - v1.y*v2.x
}
end
--not optimized
--local areas = {}
function funcs.plane(ps)
-- sort positions and imagine the first one (A) as vector.zero
ps = vector.sort_positions(ps)
local pos = ps[1]
local B = vector.subtract(ps[2], pos)
local C = vector.subtract(ps[3], pos)
-- get the positions for the fors
local cube_p1 = {x=0, y=0, z=0}
local cube_p2 = {x=0, y=0, z=0}
for i in pairs(cube_p1) do
cube_p1[i] = math.min(B[i], C[i], 0)
cube_p2[i] = math.max(B[i], C[i], 0)
end
cube_p1 = vector.apply(cube_p1, math.floor)
cube_p2 = vector.apply(cube_p2, math.ceil)
local vn = vector.normalize(vector.cross(B, C))
local nAB = vector.normalize(B)
local nAC = vector.normalize(C)
local angle_BAC = math.acos(vector.scalar(nAB, nAC))
local nBA = vector.multiply(nAB, -1)
local nBC = vector.normalize(vector.subtract(C, B))
local angle_ABC = math.acos(vector.scalar(nBA, nBC))
for z = cube_p1.z, cube_p2.z do
for y = cube_p1.y, cube_p2.y do
for x = cube_p1.x, cube_p2.x do
local p = {x=x, y=y, z=z}
local n = -vector.scalar(p, vn)/vector.scalar(vn, vn)
if math.abs(n) <= 0.5 then
local ep = vector.add(p, vector.multiply(vn, n))
local nep = vector.normalize(ep)
local angle_BAep = math.acos(vector.scalar(nAB, nep))
local angle_CAep = math.acos(vector.scalar(nAC, nep))
local angldif = angle_BAC - (angle_BAep+angle_CAep)
if math.abs(angldif) < 0.001 then
ep = vector.subtract(ep, B)
nep = vector.normalize(ep)
local angle_ABep = math.acos(vector.scalar(nBA, nep))
local angle_CBep = math.acos(vector.scalar(nBC, nep))
local angldif = angle_ABC - (angle_ABep+angle_CBep)
if math.abs(angldif) < 0.001 then
table.insert(ps, vector.add(pos, p))
end
end
end
end
end
end
return ps
end
function funcs.straightdelay(s, v, a)
if not a then
return s/v
end
return (math.sqrt(v*v+2*a*s)-v)/a
end
vector.zero = vector.new()
function funcs.sun_dir(time)
if not time then
time = minetest.get_timeofday()
end
local t = (time-0.5)*5/6+0.5 --the sun rises at 5 o'clock, not at 6
if t < 0.25
or t > 0.75 then
return
end
local tmp = math.cos(math.pi*(2*t-0.5))
return {x=tmp, y=math.sqrt(1-tmp*tmp), z=0}
end
function funcs.inside(pos, minp, maxp)
for _,i in pairs({"x", "y", "z"}) do
if pos[i] < minp[i]
or pos[i] > maxp[i] then
return false
end
end
return true
end
function funcs.minmax(p1, p2)
local p1 = vector.new(p1)
local p2 = vector.new(p2)
for _,i in ipairs({"x", "y", "z"}) do
if p1[i] > p2[i] then
p1[i], p2[i] = p2[i], p1[i]
end
end
return p1, p2
end
function funcs.move(p1, p2, s)
return vector.round(
vector.add(
vector.multiply(
vector.direction(
p1,
p2
),
s
),
p1
)
)
end
function funcs.from_number(i)
return {x=i, y=i, z=i}
end
local explosion_tables = {}
function funcs.explosion_table(r)
local table = explosion_tables[r]
if table then
return table
end
local t1 = os.clock()
local tab, n = {}, 1
local tmp = r*r + r
for x=-r,r do
for y=-r,r do
for z=-r,r do
local rc = x*x+y*y+z*z
if rc <= tmp then
local np={x=x, y=y, z=z}
if math.floor(math.sqrt(rc) +0.5) > r-1 then
tab[n] = {np, true}
else
tab[n] = {np}
end
n = n+1
end
end
end
end
explosion_tables[r] = tab
minetest.log("info", string.format("[vector_extras] table created after ca. %.2fs", os.clock() - t1))
return tab
end
local default_nparams = {
offset = 0,
scale = 1,
seed = 1337,
octaves = 6,
persist = 0.6
}
function funcs.explosion_perlin(rmin, rmax, nparams)
local t1 = os.clock()
local r = math.ceil(rmax)
nparams = nparams or {}
for i,v in pairs(default_nparams) do
nparams[i] = nparams[i] or v
end
nparams.spread = nparams.spread or vector.from_number(r*5)
local pos = {x=math.random(-30000, 30000), y=math.random(-30000, 30000), z=math.random(-30000, 30000)}
local map = minetest.get_perlin_map(nparams, vector.from_number(r+r+1)):get3dMap_flat(pos)
local id = 1
local bare_maxdist = rmax*rmax
local bare_mindist = rmin*rmin
local mindist = math.sqrt(bare_mindist)
local dist_diff = math.sqrt(bare_maxdist)-mindist
mindist = mindist/dist_diff
local pval_min, pval_max
local tab, n = {}, 1
for z=-r,r do
local bare_dist = z*z
for y=-r,r do
local bare_dist = bare_dist+y*y
for x=-r,r do
local bare_dist = bare_dist+x*x
local add = bare_dist < bare_mindist
local pval, distdiv
if not add
and bare_dist <= bare_maxdist then
distdiv = math.sqrt(bare_dist)/dist_diff-mindist
pval = math.abs(map[id]) -- strange perlin values…
if not pval_min then
pval_min = pval
pval_max = pval
else
pval_min = math.min(pval, pval_min)
pval_max = math.max(pval, pval_max)
end
add = true--distdiv < 1-math.abs(map[id])
end
if add then
tab[n] = {{x=x, y=y, z=z}, pval, distdiv}
n = n+1
end
id = id+1
end
end
end
map = nil
collectgarbage()
-- change strange values
local pval_diff = pval_max - pval_min
pval_min = pval_min/pval_diff
for n,i in pairs(tab) do
if i[2] then
local new_pval = math.abs(i[2]/pval_diff - pval_min)
if i[3]+0.33 < new_pval then
tab[n] = {i[1]}
elseif i[3] < new_pval then
tab[n] = {i[1], true}
else
tab[n] = nil
end
end
end
minetest.log("info", string.format("[vector_extras] table created after ca. %.2fs", os.clock() - t1))
return tab
end
local circle_tables = {}
function funcs.circle(r)
local table = circle_tables[r]
if table then
return table
end
local t1 = os.clock()
local tab, n = {}, 1
for i = -r, r do
for j = -r, r do
if math.floor(math.sqrt(i*i+j*j)+0.5) == r then
tab[n] = {x=i, y=0, z=j}
n = n+1
end
end
end
circle_tables[r] = tab
minetest.log("info", string.format("[vector_extras] table created after ca. %.2fs", os.clock() - t1))
return tab
end
local ring_tables = {}
function funcs.ring(r)
local table = ring_tables[r]
if table then
return table
end
local t1 = os.clock()
local tab, n = {}, 1
local tmp = r*r
local p = {x=math.floor(r+0.5), z=0}
while p.x > 0 do
tab[n] = p
n = n+1
local p1, p2 = {x=p.x-1, z=p.z}, {x=p.x, z=p.z+1}
local dif1 = math.abs(tmp-p1.x*p1.x-p1.z*p1.z)
local dif2 = math.abs(tmp-p2.x*p2.x-p2.z*p2.z)
if dif1 <= dif2 then
p = p1
else
p = p2
end
end
local tab2, n = {}, 1
for _,i in ipairs(tab) do
for _,j in ipairs({
{i.x, i.z},
{-i.z, i.x},
{-i.x, -i.z},
{i.z, -i.x},
}) do
tab2[n] = {x=j[1], y=0, z=j[2]}
n = n+1
end
end
ring_tables[r] = tab2
minetest.log("info", string.format("[vector_extras] table created after ca. %.2fs", os.clock() - t1))
return tab2
end
function funcs.chunkcorner(pos)
return {x=pos.x-pos.x%16, y=pos.y-pos.y%16, z=pos.z-pos.z%16}
end
function funcs.point_distance_minmax(p1, p2)
local p1 = vector.new(p1)
local p2 = vector.new(p2)
local min, max, vmin, vmax, num
for _,i in ipairs({"x", "y", "z"}) do
num = math.abs(p1[i] - p2[i])
if not vmin or num < vmin then
vmin = num
min = i
end
if not vmax or num > vmax then
vmax = num
max = i
end
end
return min, max
end
function funcs.collision(p1, p2)
local clear, node_pos, collision_pos, max, min, dmax, dcmax, pt
clear, node_pos = minetest.line_of_sight(p1, p2)
if clear then
return false
end
collision_pos = {}
min, max = funcs.point_distance_minmax(node_pos, p2)
if node_pos[max] > p2[max] then
collision_pos[max] = node_pos[max] - 0.5
else
collision_pos[max] = node_pos[max] + 0.5
end
dmax = p2[max] - node_pos[max]
dcmax = p2[max] - collision_pos[max]
pt = dcmax/dmax
for _,i in ipairs({"x", "y", "z"}) do
collision_pos[i] = p2[i] - (p2[i] - node_pos[i]) * pt
end
return true, collision_pos, node_pos
end
function funcs.get_data_from_pos(tab, z,y,x)
local data = tab[z]
if data then
data = data[y]
if data then
return data[x]
end
end
end
function funcs.set_data_to_pos(tab, z,y,x, data)
if tab[z] then
if tab[z][y] then
tab[z][y][x] = data
return
end
tab[z][y] = {[x] = data}
return
end
tab[z] = {[y] = {[x] = data}}
end
function funcs.set_data_to_pos_optional(tab, z,y,x, data)
if vector.get_data_from_pos(tab, z,y,x) ~= nil then
return
end
funcs.set_data_to_pos(tab, z,y,x, data)
end
function funcs.remove_data_from_pos(tab, z,y,x)
if vector.get_data_from_pos(tab, z,y,x) == nil then
return
end
tab[z][y][x] = nil
if not next(tab[z][y]) then
tab[z][y] = nil
end
if not next(tab[z]) then
tab[z] = nil
end
end
function funcs.get_data_pos_table(tab)
local t,n = {},1
local minz, miny, minx, maxz, maxy, maxx
for z,yxs in pairs(tab) do
if not minz then
minz = z
maxz = z
else
minz = math.min(minz, z)
maxz = math.max(maxz, z)
end
for y,xs in pairs(yxs) do
if not miny then
miny = y
maxy = y
else
miny = math.min(miny, y)
maxy = math.max(maxy, y)
end
for x,v in pairs(xs) do
if not minx then
minx = x
maxx = x
else
minx = math.min(minx, x)
maxx = math.max(maxx, x)
end
t[n] = {z,y,x, v}
n = n+1
end
end
end
return t, {x=minx, y=miny, z=minz}, {x=maxx, y=maxy, z=maxz}, n-1
end
function funcs.update_minp_maxp(minp, maxp, pos)
for _,i in pairs({"z", "y", "x"}) do
minp[i] = math.min(minp[i], pos[i])
maxp[i] = math.max(maxp[i], pos[i])
end
end
function funcs.quickadd(pos, z,y,x)
if z then
pos.z = pos.z+z
end
if y then
pos.y = pos.y+y
end
if x then
pos.x = pos.x+x
end
end
function funcs.unpack(pos)
return pos.z, pos.y, pos.x
end
function funcs.get_max_coord(vec)
if vec.x < vec.y then
if vec.y < vec.z then
return "z"
end
return "y"
end
if vec.x < vec.z then
return "z"
end
return "x"
end
function funcs.get_max_coords(pos)
if pos.x < pos.y then
if pos.y < pos.z then
return "z", "y", "x"
end
if pos.x < pos.z then
return "y", "z", "x"
end
return "y", "x", "z"
end
if pos.x < pos.z then
return "z", "x", "y"
end
if pos.y < pos.z then
return "x", "z", "y"
end
return "x", "y", "z"
end
function funcs.serialize(vec)
return "{x=" .. vec.x .. ",y=" .. vec.y .. ",z=" .. vec.z .. "}"
end
--dofile(minetest.get_modpath("vector_extras").."/vector_meta.lua")
for name,func in pairs(funcs) do
if vector[name] then
minetest.log("error", "[vector_extras] vector."..name.." already exists.")
else
vector[name] = func
end
end
minetest.log("info", string.format("[vector_extras] loaded after ca. %.2fs", os.clock() - load_time_start))
| gpl-3.0 |
mercury233/ygopro-scripts | c17052477.lua | 2 | 1181 | --守護神の宝札
function c17052477.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_DRAW)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCost(c17052477.cost)
e1:SetTarget(c17052477.target)
e1:SetOperation(c17052477.operation)
c:RegisterEffect(e1)
--Effect Draw
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_DRAW_COUNT)
e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e2:SetRange(LOCATION_SZONE)
e2:SetTargetRange(1,0)
e2:SetValue(2)
c:RegisterEffect(e2)
end
function c17052477.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDiscardable,tp,LOCATION_HAND,0,5,e:GetHandler()) end
Duel.DiscardHand(tp,Card.IsDiscardable,5,5,REASON_COST+REASON_DISCARD)
end
function c17052477.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsPlayerCanDraw(tp,2) end
Duel.SetTargetPlayer(tp)
Duel.SetTargetParam(2)
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,2)
end
function c17052477.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
| gpl-2.0 |
mercury233/ygopro-scripts | c81769387.lua | 2 | 2305 | --扇風機塊プロペライオン
function c81769387.initial_effect(c)
--link summon
aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkSetCard,0x14b),1,1)
c:EnableReviveLimit()
--cannot link material
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL)
e1:SetValue(c81769387.lmlimit)
c:RegisterEffect(e1)
--direct attack
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_DIRECT_ATTACK)
c:RegisterEffect(e2)
--atk
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(81769387,0))
e3:SetType(EFFECT_TYPE_QUICK_O)
e3:SetCode(EVENT_PRE_DAMAGE_CALCULATE)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1)
e3:SetCondition(c81769387.atkcon1)
e3:SetTarget(c81769387.atktg)
e3:SetOperation(c81769387.atkop)
c:RegisterEffect(e3)
--atk
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(81769387,1))
e4:SetType(EFFECT_TYPE_QUICK_O)
e4:SetCode(EVENT_PRE_DAMAGE_CALCULATE)
e4:SetRange(LOCATION_MZONE)
e4:SetCountLimit(1)
e4:SetCondition(c81769387.atkcon2)
e4:SetTarget(c81769387.atktg)
e4:SetOperation(c81769387.atkop)
c:RegisterEffect(e4)
end
function c81769387.lmlimit(e)
local c=e:GetHandler()
return c:IsStatus(STATUS_SPSUMMON_TURN) and c:IsSummonType(SUMMON_TYPE_LINK)
end
function c81769387.atkcon1(e,tp,eg,ep,ev,re,r,rp)
local a=Duel.GetAttacker()
local d=Duel.GetAttackTarget()
return e:GetHandler():GetMutualLinkedGroupCount()>0 and d and a:GetControler()~=d:GetControler()
end
function c81769387.atktg(e,tp,eg,ep,ev,re,r,rp,chk)
local tc=Duel.GetBattleMonster(1-tp)
if chk==0 then return tc and not tc:IsAttack(0) end
end
function c81769387.atkop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetBattleMonster(1-tp)
if tc and tc:IsFaceup() and tc:IsRelateToBattle() then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SET_ATTACK_FINAL)
e1:SetValue(0)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_DAMAGE_CAL)
tc:RegisterEffect(e1)
end
end
function c81769387.atkcon2(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local bc=c:GetBattleTarget()
return c:GetMutualLinkedGroupCount()==0 and bc and bc:IsControler(1-tp)
end
| gpl-2.0 |
mercury233/ygopro-scripts | c90452877.lua | 4 | 2058 | --Kozmo-エナジーアーツ
function c90452877.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_DESTROY+CATEGORY_REMOVE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCountLimit(1,90452877+EFFECT_COUNT_CODE_OATH)
e1:SetTarget(c90452877.destg)
e1:SetOperation(c90452877.desop)
c:RegisterEffect(e1)
end
function c90452877.desfilter(c)
return c:IsFaceup() and c:IsSetCard(0xd2)
end
function c90452877.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c90452877.desfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c90452877.desfilter,tp,LOCATION_MZONE,0,1,nil)
and Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,0,LOCATION_ONFIELD+LOCATION_GRAVE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,c90452877.desfilter,tp,LOCATION_MZONE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,1-tp,LOCATION_ONFIELD+LOCATION_GRAVE)
end
function c90452877.desop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and Duel.Destroy(tc,REASON_EFFECT)~=0 then
local b1=Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,0,LOCATION_ONFIELD,1,nil)
local b2=Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,nil)
local op=0
if b1 and b2 then
op=Duel.SelectOption(tp,aux.Stringid(90452877,0),aux.Stringid(90452877,1))
else
op=2
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=nil
if op==0 then
g=Duel.SelectMatchingCard(tp,Card.IsAbleToRemove,tp,0,LOCATION_ONFIELD,1,1,nil)
elseif op==1 then
g=Duel.SelectMatchingCard(tp,Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,1,nil)
else
g=Duel.SelectMatchingCard(tp,Card.IsAbleToRemove,tp,0,LOCATION_ONFIELD+LOCATION_GRAVE,1,1,nil)
end
Duel.Remove(g,POS_FACEUP,REASON_EFFECT)
end
end
| gpl-2.0 |
Zenny89/darkstar | scripts/zones/Balgas_Dais/npcs/Armoury_Crate.lua | 36 | 1024 | -----------------------------------
-- Area: Balgas Dais
-- NPC: Armoury Crate
-- Balgas Dais Burning Cicrcle Armoury Crate
-----------------------------------
package.loaded["scripts/zones/Balgas_Dais/TextIDs"] = nil;
-------------------------------------
require("scripts/globals/titles");
require("scripts/globals/quests");
require("scripts/zones/Balgas_Dais/TextIDs");
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:getBCNMloot();
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
end;
| gpl-3.0 |
linushsao/marsu_game-linus-v0.2 | mods/technical/mesecons/mesecons_receiver/init.lua | 1 | 4423 | rcvboxes = {
{ -3/16, -3/16, -8/16 , 3/16, 3/16 , -13/32 }, -- the smaller bump
{ -1/32, -1/32, -3/2 , 1/32, 1/32 , -1/2 }, -- the wire through the block
{ -2/32, -1/2 , -.5 , 2/32, 0 , -.5002+3/32 }, -- the vertical wire bit
{ -2/32, -1/2 , -7/16+0.002 , 2/32, -14/32, 16/32+0.001 } -- the horizontal wire
}
local receiver_get_rules = function (node)
local rules = { {x = 1, y = 0, z = 0},
{x = -2, y = 0, z = 0}}
if node.param2 == 2 then
rules = mesecon.rotate_rules_left(rules)
elseif node.param2 == 3 then
rules = mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules))
elseif node.param2 == 0 then
rules = mesecon.rotate_rules_right(rules)
end
return rules
end
minetest.register_node("mesecons_receiver:receiver_on", {
drawtype = "nodebox",
tiles = {
"receiver_top_on.png",
"receiver_bottom_on.png",
"receiver_lr_on.png",
"receiver_lr_on.png",
"receiver_fb_on.png",
"receiver_fb_on.png",
},
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 }
},
node_box = {
type = "fixed",
fixed = rcvboxes
},
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
drop = "mesecons:wire_00000000_off",
mesecons = {conductor = {
state = mesecon.state.on,
rules = receiver_get_rules,
offstate = "mesecons_receiver:receiver_off"
}}
})
minetest.register_node("mesecons_receiver:receiver_off", {
drawtype = "nodebox",
description = "You hacker you",
tiles = {
"receiver_top_off.png",
"receiver_bottom_off.png",
"receiver_lr_off.png",
"receiver_lr_off.png",
"receiver_fb_off.png",
"receiver_fb_off.png",
},
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 }
},
node_box = {
type = "fixed",
fixed = rcvboxes
},
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
drop = "mesecons:wire_00000000_off",
mesecons = {conductor = {
state = mesecon.state.off,
rules = receiver_get_rules,
onstate = "mesecons_receiver:receiver_on"
}}
})
function mesecon.receiver_get_pos_from_rcpt(pos, param2)
local rules = {{x = 2, y = 0, z = 0}}
if param2 == nil then param2 = minetest.get_node(pos).param2 end
if param2 == 2 then
rules = mesecon.rotate_rules_left(rules)
elseif param2 == 3 then
rules = mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules))
elseif param2 == 0 then
rules = mesecon.rotate_rules_right(rules)
end
local np = { x = pos.x + rules[1].x,
y = pos.y + rules[1].y,
z = pos.z + rules[1].z}
return np
end
function mesecon.receiver_place(rcpt_pos)
local node = minetest.get_node(rcpt_pos)
local pos = mesecon.receiver_get_pos_from_rcpt(rcpt_pos, node.param2)
local nn = minetest.get_node(pos)
if string.find(nn.name, "mesecons:wire_") ~= nil then
minetest.dig_node(pos)
minetest.set_node(pos, {name = "mesecons_receiver:receiver_off", param2 = node.param2})
mesecon.on_placenode(pos, nn)
end
end
function mesecon.receiver_remove(rcpt_pos, dugnode)
local pos = mesecon.receiver_get_pos_from_rcpt(rcpt_pos, dugnode.param2)
local nn = minetest.get_node(pos)
if string.find(nn.name, "mesecons_receiver:receiver_") ~=nil then
minetest.dig_node(pos)
local node = {name = "mesecons:wire_00000000_off"}
minetest.set_node(pos, node)
mesecon.on_placenode(pos, node)
end
end
minetest.register_on_placenode(function (pos, node)
if minetest.get_item_group(node.name, "mesecon_needs_receiver") == 1 then
mesecon.receiver_place(pos)
end
end)
minetest.register_on_dignode(function(pos, node)
if minetest.get_item_group(node.name, "mesecon_needs_receiver") == 1 then
mesecon.receiver_remove(pos, node)
end
end)
minetest.register_on_placenode(function (pos, node)
if string.find(node.name, "mesecons:wire_") ~=nil then
local rules = { {x = 2, y = 0, z = 0},
{x =-2, y = 0, z = 0},
{x = 0, y = 0, z = 2},
{x = 0, y = 0, z =-2}}
local i = 1
while rules[i] ~= nil do
local np = { x = pos.x + rules[i].x,
y = pos.y + rules[i].y,
z = pos.z + rules[i].z}
if minetest.get_item_group(minetest.get_node(np).name, "mesecon_needs_receiver") == 1 then
mesecon.receiver_place(np)
end
i = i + 1
end
end
end)
| gpl-3.0 |
linushsao/marsu_game-linus-v0.2 | mods/technical/technic/technic/machines/register/extractor_recipes.lua | 4 | 1971 |
local S = technic.getter
technic.register_recipe_type("extracting", { description = S("Extracting") })
function technic.register_extractor_recipe(data)
data.time = data.time or 4
technic.register_recipe("extracting", data)
end
if minetest.get_modpath("dye") then
-- check if we are using dye or unifieddyes
local unifieddyes = minetest.get_modpath("unifieddyes")
-- register recipes with the same crafting ratios as `dye` provides
local dye_recipes = {
{"technic:coal_dust", "dye:black 2"},
{"default:grass_1", "dye:green 1"},
{"default:dry_shrub", "dye:brown 1"},
{"default:junglegrass", "dye:green 2"},
{"default:cactus", "dye:green 4"},
{"flowers:geranium", "dye:blue 4"},
{"flowers:dandelion_white", "dye:white 4"},
{"flowers:dandelion_yellow", "dye:yellow 4"},
{"flowers:tulip", "dye:orange 4"},
{"flowers:rose", "dye:red 4"},
{"flowers:viola", "dye:violet 4"},
{"bushes:blackberry", unifieddyes and "unifieddyes:magenta_s50 4" or "dye:violet 4"},
{"bushes:blueberry", unifieddyes and "unifieddyes:magenta_s50 4" or "dye:magenta 4"},
}
for _, data in ipairs(dye_recipes) do
technic.register_extractor_recipe({input = {data[1]}, output = data[2]})
end
-- overwrite the existing crafting recipes
local dyes = {"white", "red", "yellow", "blue", "violet", "orange"}
for _, color in ipairs(dyes) do
minetest.register_craft({
type = "shapeless",
output = "dye:"..color.." 1",
recipe = {"group:flower,color_"..color},
})
end
minetest.register_craft({
type = "shapeless",
output = "dye:black 1",
recipe = {"group:coal"},
})
if unifieddyes then
minetest.register_craft({
type = "shapeless",
output = "dye:green 1",
recipe = {"default:cactus"},
})
end
end
| gpl-3.0 |
Zenny89/darkstar | scripts/zones/Port_Jeuno/npcs/qm1.lua | 17 | 2397 | -----------------------------------
-- Area: Port Jeuno
-- NPC: ???
-- Finish Quest: Borghertz's Hands (AF Hands, Many job)
-- @zone 246
-- @pos -51 8 -4
-----------------------------------
package.loaded["scripts/zones/Port_Jeuno/TextIDs"] = nil;
package.loaded["scripts/globals/settings"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/shop");
require("scripts/globals/quests");
require("scripts/zones/Port_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
OldGauntlets = player:hasKeyItem(OLD_GAUNTLETS);
ShadowFlames = player:hasKeyItem(SHADOW_FLAMES);
BorghertzCS = player:getVar("BorghertzCS");
if (OldGauntlets == true and ShadowFlames == false and BorghertzCS == 1) then
player:startEvent(0x0014);
elseif (OldGauntlets == true and ShadowFlames == false and BorghertzCS == 2) then
player:startEvent(0x0031);
elseif (OldGauntlets == true and ShadowFlames == true) then
player:startEvent(0x0030);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x0014 and option == 1) then
player:setVar("BorghertzCS",2);
elseif (csid == 0x0030) then
NumQuest = 43 + player:getVar("BorghertzAlreadyActiveWithJob");
NumHands = 13960 + player:getVar("BorghertzAlreadyActiveWithJob");
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,NumHands);
else
player:addItem(NumHands);
player:messageSpecial(ITEM_OBTAINED,NumHands);
player:delKeyItem(OLD_GAUNTLETS);
player:delKeyItem(SHADOW_FLAMES);
player:setVar("BorghertzCS",0);
player:setVar("BorghertzAlreadyActiveWithJob",0);
player:addFame(JEUNO,30);
player:completeQuest(JEUNO,NumQuest);
end
end
end; | gpl-3.0 |
Zenny89/darkstar | scripts/zones/Bastok_Markets/TextIDs.lua | 7 | 5351 | -- Variable TextID Description text
-- General Texts
ITEM_CANNOT_BE_OBTAINED = 6379; --Come back after sorting your inventory.
FULL_INVENTORY_AFTER_TRADE = 6382; --Try trading again after sorting your inventory.
ITEM_OBTAINED = 6383; --Obtained: <<<Unknown Parameter (Type: 80) 1>>><<<Possible Special Code: 01>>><<<Possible Special Code: 05>>>
GIL_OBTAINED = 6384; --Obtained <<<Numeric Parameter 0>>> gil.
KEYITEM_OBTAINED = 6386; --Obtained key item: <<<Unknown Parameter (Type: 80) 1>>>
NOT_HAVE_ENOUGH_GIL = 6388; --You do not have enough gil.
ITEMS_OBTAINED = 6392; --You obtain ?Numeric Parameter 1? ?Possible Special Code: 01??Speaker Name?)??BAD CHAR: 80??BAD CHAR: 80??BAD CHAR: 8280??BAD CHAR: 80??BAD CHAR: 80?!?Prompt?
HOMEPOINT_SET = 6470; --Home point set!
GOLDSMITHING_SUPPORT = 7055; --Your ?Multiple Choice (Parameter 1)?[fishing/woodworking/smithing/goldsmithing/clothcraft/leatherworking/bonecraft/alchemy/cooking] skills went up ...
GUILD_TERMINATE_CONTRACT = 7069; --You have terminated your trading contract with the ?Multiple Choice (Parameter 1)?[Fishermen's/Carpenters'/Blacksmiths'/Goldsmiths'/Weavers'/Tanners'/Boneworkers'/Alchemists'/Culinarians'] Guild and formed a new one with the ?Multiple Choice (Parameter 0)?[Fishermen's/Carpenters'/Blacksmiths'/Goldsmiths'/Weavers'/Tanners'/Boneworkers'/Alchemists'/Culinarians'] Guild.?Prompt?
GUILD_NEW_CONTRACT = 7077; --You have formed a new trading contract with the ?Multiple Choice (Parameter 0)?[Fishermen's/Carpenters'/Blacksmiths'/Goldsmiths'/Weavers'/Tanners'/Boneworkers'/Alchemists'/Culinarians'] Guild.?Prompt?
NO_MORE_GP_ELIGIBLE = 7084; --You are not eligible to receive guild points at this time.
GP_OBTAINED = 7073; --Obtained <<<Numeric Parameter 0>>> guild points.
NOT_HAVE_ENOUGH_GP = 7090; --You do not have enough guild points.
FISHING_MESSAGE_OFFSET = 7184; --You can't fish here.
-- Conquest System
CONQUEST = 7751; --You've earned conquest points!
-- Mission Dialogs
YOU_ACCEPT_THE_MISSION = 6491; --You have accepted the mission.
ORIGINAL_MISSION_OFFSET = 6496; -- You can consult the ission section of the main menu to review your objectives. Speed and efficiency are your priorities. Dismissed.
EXTENDED_MISSION_OFFSET = 8113; --Go to Ore Street and talk to Medicine Eagle. He says he was there when the commotion started.
-- Other Dialogs
ITEM_DELIVERY_DIALOG = 7634; --Need something sent to a friend's house? Sending items to your own room? You've come to the right place
-- Harvest Festival
TRICK_OR_TREAT = 8236; --Trick or treat...
THANK_YOU_TREAT = 8237; --And now for your treat...
HERE_TAKE_THIS = 8238; --Here, take this...
IF_YOU_WEAR_THIS = 8239; --If you put this on and walk around, something...unexpected might happen...
THANK_YOU = 8237; --Thank you...
-- Shop Texts
SOMNPAEMN_CLOSED_DIALOG = 7545; --I'm trying to start a business selling goods from Sarutabaruta,
YAFAFA_CLOSED_DIALOG = 7546; --I'm trying to start a business selling goods from Kolshushu,
OGGODETT_CLOSED_DIALOG = 7547; --I'm trying to start a business selling goods from Aragoneu,
TEERTH_SHOP_DIALOG = 7648; --Welcome to the Goldsmiths' Guild shop. What can I do for you?
VISALA_SHOP_DIALOG = 7649; --Welcome to the Goldsmiths' Guild shop. How may I help you?
ZHIKKOM_SHOP_DIALOG = 7650; --Welcome to the only weaponry store in Bastok, the Dragon's Claws!
CIQALA_SHOP_DIALOG = 7651; --A weapon is the most precious thing to an adventurer! Well, after his life, of course.
PERITRAGE_SHOP_DIALOG = 7652; --Hey! I've got just the thing for you!
BRUNHILDE_SHOP_DIALOG = 7653; --Welcome to my store! You want armor, you want shields? I've got them all!
CHARGINGCHOKOBO_SHOP_DIALOG = 7654; --Hello. What piece of armor are you missing?
BALTHILDA_SHOP_DIALOG = 7655; --Feeling defenseless of late? Brunhilde's Armory has got you covered!
MJOLL_SHOP_DIALOG = 7656; --Welcome. Have a look and compare! You'll never find better wares anywhere.
OLWYN_SHOP_DIALOG = 7657; --Welcome to Mjoll's Goods! What can I do for you?
ZAIRA_SHOP_DIALOG = 7658; --Greetings. What spell are you looking for?
SORORO_SHOP_DIALOG = 7659; --Hello-mellow, welcome to Sororo's Scribe and Notary!
HARMODIOS_SHOP_DIALOG = 7660; --Add music to your adventuring life! Welcome to Harmodios's.
CARMELIDE_SHOP_DIALOG = 7661; --Ah, welcome, welcome! What might I interest you in?
RAGHD_SHOP_DIALOG = 7662; --Give a smile to that special someone! Welcome to Carmelide's.
HORTENSE_SHOP_DIALOG = 7663; --Hello there! We have instruments and music sheets at Harmodios's!
OGGODETT_OPEN_DIALOG = 7664; --Hello there! Might I interest you in some specialty goods from Aragoneu?
YAFAFA_OPEN_DIALOG = 7665; --Hello! I've got some goods from Kolshushu--interested?
SOMNPAEMN_OPEN_DIALOG = 7666; --Welcome! I have goods straight from Sarutabaruta! What say you?
-- conquest Base
CONQUEST_BASE = 6564; -- Tallying conquest results...
-- Porter Moogle
RETRIEVE_DIALOG_ID = 12828; -- You retrieve a <item> from the porter moogle's care.
| gpl-3.0 |
mercury233/ygopro-scripts | c55554175.lua | 2 | 3327 | --EMクラシックリボー
function c55554175.initial_effect(c)
--pendulum summon
aux.EnablePendulumAttribute(c)
--destroy
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_ATTACK_ANNOUNCE)
e1:SetRange(LOCATION_PZONE)
e1:SetCondition(c55554175.descon)
e1:SetOperation(c55554175.desop)
c:RegisterEffect(e1)
--scale
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(55554175,0))
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_HAND)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCountLimit(1,55554175)
e2:SetCost(c55554175.sccost)
e2:SetTarget(c55554175.sctg)
e2:SetOperation(c55554175.scop)
c:RegisterEffect(e2)
--pendulum set
local e3=Effect.CreateEffect(c)
e3:SetCategory(CATEGORY_LEAVE_GRAVE)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e3:SetCode(EVENT_BATTLE_DAMAGE)
e3:SetRange(LOCATION_GRAVE)
e3:SetCountLimit(1,55554176)
e3:SetCondition(c55554175.pencon)
e3:SetTarget(c55554175.pentg)
e3:SetOperation(c55554175.penop)
c:RegisterEffect(e3)
--end battle phase
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e4:SetCode(EVENT_DESTROYED)
e4:SetCondition(c55554175.endcon)
e4:SetOperation(c55554175.endop)
c:RegisterEffect(e4)
end
function c55554175.descon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetAttacker():IsControler(1-tp) and Duel.GetAttackTarget()==nil
end
function c55554175.desop(e,tp,eg,ep,ev,re,r,rp)
Duel.Destroy(e:GetHandler(),REASON_EFFECT)
end
function c55554175.sccost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsDiscardable() end
Duel.SendtoGrave(e:GetHandler(),REASON_DISCARD+REASON_COST)
end
function c55554175.scfilter(c)
return c:GetCurrentScale()~=1
end
function c55554175.sctg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_PZONE) and chkc:IsControler(tp) and c55554175.scfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c55554175.scfilter,tp,LOCATION_PZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
Duel.SelectTarget(tp,c55554175.scfilter,tp,LOCATION_PZONE,0,1,1,nil)
end
function c55554175.scop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CHANGE_LSCALE)
e1:SetValue(1)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EFFECT_CHANGE_RSCALE)
tc:RegisterEffect(e2)
end
end
function c55554175.pencon(e,tp,eg,ep,ev,re,r,rp)
return ep==tp
end
function c55554175.pentg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckLocation(tp,LOCATION_PZONE,0) or Duel.CheckLocation(tp,LOCATION_PZONE,1) end
Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,e:GetHandler(),1,0,0)
end
function c55554175.penop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) then
Duel.MoveToField(c,tp,tp,LOCATION_PZONE,POS_FACEUP,true)
end
end
function c55554175.endcon(e,tp,eg,ep,ev,re,r,rp)
if not re then return end
local c=e:GetHandler()
local rc=re:GetHandler()
return c:IsReason(REASON_EFFECT) and rc==c
end
function c55554175.endop(e,tp,eg,ep,ev,re,r,rp)
Duel.SkipPhase(1-tp,PHASE_BATTLE,RESET_PHASE+PHASE_BATTLE_STEP,1)
end
| gpl-2.0 |
mercury233/ygopro-scripts | c16209941.lua | 3 | 2850 | --未界域のチュパカブラ
function c16209941.initial_effect(c)
--special summon (self)
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(16209941,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_HANDES+CATEGORY_DRAW)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_HAND)
e1:SetCost(c16209941.spcost)
e1:SetTarget(c16209941.sptg)
e1:SetOperation(c16209941.spop)
c:RegisterEffect(e1)
--special summon (grave)
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(16209941,1))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
e2:SetCode(EVENT_DISCARD)
e2:SetCountLimit(1,16209941)
e2:SetTarget(c16209941.sptg2)
e2:SetOperation(c16209941.spop2)
c:RegisterEffect(e2)
end
function c16209941.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return not e:GetHandler():IsPublic() end
end
function c16209941.spfilter(c,e,tp)
return c:IsCode(16209941) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c16209941.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDiscardable,tp,LOCATION_HAND,0,1,nil,REASON_EFFECT) end
Duel.SetOperationInfo(0,CATEGORY_HANDES,nil,0,tp,1)
end
function c16209941.spop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetFieldGroup(tp,LOCATION_HAND,0)
if g:GetCount()<=0 then return end
local tc=g:RandomSelect(1-tp,1):GetFirst()
if Duel.SendtoGrave(tc,REASON_DISCARD+REASON_EFFECT)~=0 and not tc:IsCode(16209941)
and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then
local spg=Duel.GetMatchingGroup(c16209941.spfilter,tp,LOCATION_HAND,0,nil,e,tp)
if spg:GetCount()<=0 then return end
local sg=spg:GetFirst()
if spg:GetCount()~=1 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
sg=spg:Select(tp,1,1,nil)
end
Duel.BreakEffect()
if Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEUP)~=0 then
Duel.Draw(tp,1,REASON_EFFECT)
end
end
end
function c16209941.spfilter2(c,e,tp)
return c:IsSetCard(0x11e) and not c:IsCode(16209941) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c16209941.sptg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c16209941.spfilter2(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c16209941.spfilter2,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c16209941.spfilter2,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c16209941.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 |
guillaume144/jeu-rp | gamemode/modules/positions/sv_interface.lua | 13 | 4573 | DarkRP.storeJailPos = DarkRP.stub{
name = "storeJailPos",
description = "Store a jailposition from a player's location.",
parameters = {
{
name = "ply",
description = "The player of whom to get the location.",
type = "Player",
optional = false
},
{
name = "addingPos",
description = "Whether to reset all jailpositions and to create a new one here or to add it to the existing jailpos.",
type = "boolean",
optional = true
}
},
returns = {
},
metatable = DarkRP
}
DarkRP.setJailPos = DarkRP.stub{
name = "setJailPos",
description = "Remove all jail positions in this map and create a new one. To add a jailpos without removing previous ones use DarkRP.addJailPos. This jail position will be saved in the database.",
parameters = {
{
name = "pos",
description = "The position to set as jailpos.",
type = "Vector",
optional = false
}
},
returns = {
},
metatable = DarkRP
}
DarkRP.addJailPos = DarkRP.stub{
name = "addJailPos",
description = "Add a jail position to the map. This jail position will be saved in the database.",
parameters = {
{
name = "pos",
description = "The position to add as jailpos.",
type = "Vector",
optional = false
}
},
returns = {
},
metatable = DarkRP
}
DarkRP.retrieveJailPos = DarkRP.stub{
name = "retrieveJailPos",
description = "Retrieve a jail position.",
parameters = {
{
name = "index",
description = "Which jailpos to return.",
type = "number",
optional = true
}
},
returns = {
{
name = "pos",
description = "A jail position.",
type = "Vector"
}
},
metatable = DarkRP
}
DarkRP.jailPosCount = DarkRP.stub{
name = "jailPosCount",
description = "The amount of jail positions in the current map.",
parameters = {
},
returns = {
{
name = "count",
description = "The amount of jail positions in the current map.",
type = "number"
}
},
metatable = DarkRP
}
DarkRP.storeTeamSpawnPos = DarkRP.stub{
name = "storeTeamSpawnPos",
description = "Store a spawn position of a job in the database (replaces all other spawn positions).",
parameters = {
{
name = "team",
description = "The job to store the spawn position of.",
type = "number",
optional = false
},
{
name = "pos",
description = "The position to store.",
type = "Vector",
optional = false
}
},
returns = {
},
metatable = DarkRP
}
DarkRP.addTeamSpawnPos = DarkRP.stub{
name = "addTeamSpawnPos",
description = "Add a spawn position to the database. The position will not replace other spawn positions.",
parameters = {
{
name = "team",
description = "The job to store the spawn position of.",
type = "number",
optional = false
},
{
name = "pos",
description = "The position to store.",
type = "Vector",
optional = false
}
},
returns = {
},
metatable = DarkRP
}
DarkRP.removeTeamSpawnPos = DarkRP.stub{
name = "removeTeamSpawnPos",
description = "Remove a single spawn position.",
parameters = {
{
name = "team",
description = "The job to remove the spawn position of.",
type = "number",
optional = false
},
{
name = "pos",
description = "The position to remove.",
type = "Vector",
optional = false
}
},
returns = {
},
metatable = DarkRP
}
DarkRP.retrieveTeamSpawnPos = DarkRP.stub{
name = "retrieveTeamSpawnPos",
description = "Retrieve a random spawn position for a job.",
parameters = {
{
name = "team",
description = "The job to get a spawn position for.",
type = "number",
optional = false
}
},
returns = {
{
name = "pos",
description = "A nice spawn position.",
type = "Vector"
}
},
metatable = DarkRP
}
| mit |
mercury233/ygopro-scripts | c15066114.lua | 2 | 2400 | --セグメンタル・ドラゴン
function c15066114.initial_effect(c)
--summon & set with no tribute
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(15066114,0))
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EFFECT_SUMMON_PROC)
e1:SetCondition(c15066114.ntcon)
e1:SetOperation(c15066114.ntop)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EFFECT_SET_PROC)
c:RegisterEffect(e2)
--destroy
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(15066114,1))
e3:SetType(EFFECT_TYPE_QUICK_O)
e3:SetCategory(CATEGORY_DESTROY)
e3:SetCode(EVENT_FREE_CHAIN)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1)
e3:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e3:SetCondition(c15066114.descon)
e3:SetTarget(c15066114.destg)
e3:SetOperation(c15066114.desop)
c:RegisterEffect(e3)
end
function c15066114.ntcon(e,c,minc)
if c==nil then return true end
return minc==0 and c:IsLevelAbove(5) and Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0
end
function c15066114.ntop(e,tp,eg,ep,ev,re,r,rp,c)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SET_BASE_ATTACK)
e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e1:SetRange(LOCATION_MZONE)
e1:SetValue(1300)
e1:SetReset(RESET_EVENT+0xff0000)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EFFECT_SET_BASE_DEFENSE)
e2:SetValue(1200)
c:RegisterEffect(e2)
end
function c15066114.descon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsSummonType(SUMMON_TYPE_NORMAL)
end
function c15066114.desfilter(c,atk)
return c:IsFaceup() and c:IsAttackBelow(atk) and c:GetSequence()<5
end
function c15066114.destg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.IsExistingMatchingCard(c15066114.desfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,c,c:GetAttack()) end
local g=Duel.GetMatchingGroup(c15066114.desfilter,tp,LOCATION_MZONE,LOCATION_MZONE,c,c:GetAttack())
g:AddCard(c)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
end
function c15066114.desop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) and c:IsFaceup() then
local atk=c:GetAttack()
if Duel.Destroy(c,REASON_EFFECT)~=0 then
local g=Duel.GetMatchingGroup(c15066114.desfilter,tp,LOCATION_MZONE,LOCATION_MZONE,nil,atk)
Duel.Destroy(g,REASON_EFFECT)
end
end
end
| gpl-2.0 |
Zenny89/darkstar | scripts/zones/West_Ronfaure/npcs/Harvetour.lua | 17 | 1867 | -----------------------------------
-- Area: West Ronfaure
-- NPC: Harvetour
-- Type: Outpost Vendor
-- @pos -448 -19 -214 100
-----------------------------------
package.loaded["scripts/zones/West_Ronfaure/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/shop");
require("scripts/globals/conquest");
require("scripts/zones/West_Ronfaure/TextIDs");
local region = RONFAURE;
local csid = 0x7ff4;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local owner = GetRegionOwner(region);
local arg1 = getArg1(owner,player);
if (owner == player:getNation()) then
nation = 1;
elseif (arg1 < 1792) then
nation = 2;
else
nation = 0;
end
player:startEvent(csid,nation,OP_TeleFee(player,region),0,OP_TeleFee(player,region),player:getCP(),0,0,0);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("OPTION: %u",option);
player:updateEvent(player:getGil(),OP_TeleFee(player,region),0,OP_TeleFee(player,region),player:getCP());
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("OPTION: %u",option);
if (option == 1) then
ShowOPVendorShop(player);
elseif (option == 2) then
if (player:delGil(OP_TeleFee(player,region))) then
toHomeNation(player);
end
elseif (option == 6) then
player:delCP(OP_TeleFee(player,region));
toHomeNation(player);
end
end; | gpl-3.0 |
Cavitt/vanilla-ot | data/npc/lib/npcsystem/npchandler.lua | 1 | 23435 | -- Advanced NPC System (Created by Jiddo),
-- Modified by TheForgottenServer Team.
if(NpcHandler == nil) then
-- Constant talkdelay behaviors.
TALKDELAY_NONE = 0 -- No talkdelay. Npc will reply immedeatly.
TALKDELAY_ONTHINK = 1 -- Talkdelay handled through the onThink callback function. (Default)
TALKDELAY_EVENT = 2 -- Not yet implemented
-- Currently applied talkdelay behavior. TALKDELAY_ONTHINK is default.
NPCHANDLER_TALKDELAY = TALKDELAY_ONTHINK
-- Constant conversation behaviors.
CONVERSATION_DEFAULT = 0 -- Conversation through default window, like it was before 8.2 update.
CONVERSATION_PRIVATE = 1 -- Conversation through NPCs chat window, as of 8.2 update. (Default)
--Small Note: Private conversations also means the NPC will use multi-focus system.
-- Currently applied conversation behavior. CONVERSATION_PRIVATE is default.
NPCHANDLER_CONVBEHAVIOR = CONVERSATION_PRIVATE
-- Constant indexes for defining default messages.
MESSAGE_GREET = 1 -- When the player greets the npc.
MESSAGE_FAREWELL = 2 -- When the player unGreets the npc.
MESSAGE_BUY = 3 -- When the npc asks the player if he wants to buy something.
MESSAGE_ONBUY = 4 -- When the player successfully buys something via talk.
MESSAGE_BOUGHT = 5 -- When the player bought something through the shop window.
MESSAGE_SELL = 6 -- When the npc asks the player if he wants to sell something.
MESSAGE_ONSELL = 7 -- When the player successfully sells something via talk.
MESSAGE_SOLD = 8 -- When the player sold something through the shop window.
MESSAGE_MISSINGMONEY = 9 -- When the player does not have enough money.
MESSAGE_MISSINGITEM = 10 -- When the player is trying to sell an item he does not have.
MESSAGE_NEEDMONEY = 11 -- Same as above, used for shop window.
MESSAGE_NEEDITEM = 12 -- Same as above, used for shop window.
MESSAGE_NEEDSPACE = 13 -- When the player don't have any space to buy an item
MESSAGE_NEEDMORESPACE = 14 -- When the player has some space to buy an item, but not enough space
MESSAGE_IDLETIMEOUT = 15 -- When the player has been idle for longer then idleTime allows.
MESSAGE_WALKAWAY = 16 -- When the player walks out of the talkRadius of the npc.
MESSAGE_DECLINE = 17 -- When the player says no to something.
MESSAGE_SENDTRADE = 18 -- When the npc sends the trade window to the player
MESSAGE_NOSHOP = 19 -- When the npc's shop is requested but he doesn't have any
MESSAGE_ONCLOSESHOP = 20 -- When the player closes the npc's shop window
MESSAGE_ALREADYFOCUSED = 21 -- When the player already has the focus of this npc.
MESSAGE_PLACEDINQUEUE = 22 -- When the player has been placed in the costumer queue.
-- Constant indexes for callback functions. These are also used for module callback ids.
CALLBACK_CREATURE_APPEAR = 1
CALLBACK_CREATURE_DISAPPEAR = 2
CALLBACK_CREATURE_SAY = 3
CALLBACK_ONTHINK = 4
CALLBACK_GREET = 5
CALLBACK_FAREWELL = 6
CALLBACK_MESSAGE_DEFAULT = 7
CALLBACK_PLAYER_ENDTRADE = 8
CALLBACK_PLAYER_CLOSECHANNEL = 9
CALLBACK_ONBUY = 10
CALLBACK_ONSELL = 11
-- Addidional module callback ids
CALLBACK_MODULE_INIT = 12
CALLBACK_MODULE_RESET = 13
-- Constant strings defining the keywords to replace in the default messages.
TAG_PLAYERNAME = '|PLAYERNAME|'
TAG_ITEMCOUNT = '|ITEMCOUNT|'
TAG_TOTALCOST = '|TOTALCOST|'
TAG_ITEMNAME = '|ITEMNAME|'
TAG_QUEUESIZE = '|QUEUESIZE|'
NpcHandler = {
keywordHandler = nil,
focuses = nil,
talkStart = nil,
idleTime = 300,
talkRadius = 3,
talkDelayTime = 350, -- Seconds to delay outgoing messages.
queue = nil,
talkDelay = nil,
callbackFunctions = nil,
modules = nil,
shopItems = nil, -- They must be here since ShopModule uses "static" functions
messages = {
-- These are the default replies of all npcs. They can/should be changed individually for each npc.
[MESSAGE_GREET] = 'Welcome, |PLAYERNAME|! I have been expecting you.',
[MESSAGE_FAREWELL] = 'Good bye, |PLAYERNAME|!',
[MESSAGE_BUY] = 'Do you want to buy |ITEMCOUNT| |ITEMNAME| for |TOTALCOST| gold coins?',
[MESSAGE_ONBUY] = 'It was a pleasure doing business with you.',
[MESSAGE_BOUGHT] = 'Bought |ITEMCOUNT|x |ITEMNAME| for |TOTALCOST| gold.',
[MESSAGE_SELL] = 'Do you want to sell |ITEMCOUNT| |ITEMNAME| for |TOTALCOST| gold coins?',
[MESSAGE_ONSELL] = 'Thank you for this |ITEMNAME|, |PLAYERNAME|.',
[MESSAGE_SOLD] = 'Sold |ITEMCOUNT|x |ITEMNAME| for |TOTALCOST| gold.',
[MESSAGE_MISSINGMONEY] = 'Sorry, you don\'t have enough money.',
[MESSAGE_MISSINGITEM] = 'You don\'t even have that item, |PLAYERNAME|!',
[MESSAGE_NEEDMONEY] = 'You do not have enough money.',
[MESSAGE_NEEDITEM] = 'You do not have this object.',
[MESSAGE_NEEDSPACE] = 'You do not have enough capacity.',
[MESSAGE_NEEDMORESPACE] = 'You do not have enough capacity for all items.',
[MESSAGE_IDLETIMEOUT] = 'Next, please!',
[MESSAGE_WALKAWAY] = 'How rude!',
[MESSAGE_DECLINE] = 'Not good enough, is it... ?',
[MESSAGE_SENDTRADE] = 'Here\'s my offer, |PLAYERNAME|. Don\'t you like it?',
[MESSAGE_NOSHOP] = 'Sorry, I\'m not offering anything.',
[MESSAGE_ONCLOSESHOP] = 'Thank you, come back when you want something more.',
[MESSAGE_ALREADYFOCUSED]= '|PLAYERNAME|! I am already talking to you...',
[MESSAGE_PLACEDINQUEUE] = '|PLAYERNAME|, please wait for your turn. There are |QUEUESIZE| customers before you.'
}
}
-- Creates a new NpcHandler with an empty callbackFunction stack.
function NpcHandler:new(keywordHandler)
local obj = {}
obj.messages = {}
obj.keywordHandler = keywordHandler
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
obj.focuses = {}
obj.talkStart = {}
else
obj.queue = Queue:new(obj)
obj.focuses = 0
obj.talkStart = 0
end
obj.callbackFunctions = {}
obj.modules = {}
obj.talkDelay = {}
obj.shopItems = {}
setmetatable(obj.messages, self.messages)
self.messages.__index = self.messages
setmetatable(obj, self)
self.__index = self
return obj
end
-- Re-defines the maximum idle time allowed for a player when talking to this npc.
function NpcHandler:setMaxIdleTime(newTime)
self.idleTime = newTime
end
-- Attackes a new keyword handler to this npchandler
function NpcHandler:setKeywordHandler(newHandler)
self.keywordHandler = newHandler
end
-- Function used to change the focus of this npc.
function NpcHandler:addFocus(newFocus)
if(not isCreature(newFocus)) then
return
end
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
if(self:isFocused(newFocus, true)) then
return
end
table.insert(self.focuses, newFocus)
else
self.focuses = newFocus
end
self:updateFocus(true)
end
NpcHandler.changeFocus = NpcHandler.addFocus -- "changeFocus" looks better for CONVERSATION_DEFAULT
-- Function used to verify if npc is focused to certain player
function NpcHandler:isFocused(focus, creatureCheck)
local creatureCheck = creatureCheck or false
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
for k, v in pairs(self.focuses) do
if(v == focus) then
if(creatureCheck or isCreature(v)) then
return true
end
self:unsetFocus(focus, k)
return false
end
end
return false
end
if(creatureCheck or isCreature(self.focuses)) then
return self.focuses == focus
end
self:changeFocus(0)
return false
end
-- This function should be called on each onThink and makes sure the npc faces the player it is talking to.
-- Should also be called whenever a new player is focused.
function NpcHandler:updateFocus(creatureCheck)
local creatureCheck = creatureCheck or false
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
for _, focus in pairs(self.focuses) do
if(creatureCheck or isCreature(focus)) then
doNpcSetCreatureFocus(focus)
return
end
end
elseif(creatureCheck or isCreature(self.focuses)) then
doNpcSetCreatureFocus(self.focuses)
return
end
doNpcSetCreatureFocus(0)
end
-- Used when the npc should un-focus the player.
function NpcHandler:releaseFocus(focus)
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
if(not self:isFocused(focus)) then
return
end
local pos = nil
for k, v in pairs(self.focuses) do
if(v == focus) then
pos = k
end
end
if(pos ~= nil) then
closeShopWindow(focus)
self:unsetFocus(focus, pos)
end
elseif(self.focuses == focus) then
if(isCreature(focus)) then
closeShopWindow(focus)
end
self:changeFocus(0)
end
end
-- Internal un-focusing function, beware using!
function NpcHandler:unsetFocus(focus, pos)
if(type(self.focuses) ~= "table" or pos == nil or self.focuses[pos] == nil) then
return
end
table.remove(self.focuses, pos)
self.talkStart[focus] = nil
self:updateFocus()
end
-- Returns the callback function with the specified id or nil if no such callback function exists.
function NpcHandler:getCallback(id)
local ret = nil
if(self.callbackFunctions ~= nil) then
ret = self.callbackFunctions[id]
end
return ret
end
-- Changes the callback function for the given id to callback.
function NpcHandler:setCallback(id, callback)
if(self.callbackFunctions ~= nil) then
self.callbackFunctions[id] = callback
end
end
-- Adds a module to this npchandler and inits it.
function NpcHandler:addModule(module)
if(self.modules == nil or module == nil) then
return false
end
module:init(self)
if(module.parseParameters ~= nil) then
module:parseParameters()
end
table.insert(self.modules, module)
return true
end
-- Calls the callback function represented by id for all modules added to this npchandler with the given arguments.
function NpcHandler:processModuleCallback(id, ...)
local ret = true
for _, module in pairs(self.modules) do
local tmpRet = true
if(id == CALLBACK_CREATURE_APPEAR and module.callbackOnCreatureAppear ~= nil) then
tmpRet = module:callbackOnCreatureAppear(...)
elseif(id == CALLBACK_CREATURE_DISAPPEAR and module.callbackOnCreatureDisappear ~= nil) then
tmpRet = module:callbackOnCreatureDisappear(...)
elseif(id == CALLBACK_CREATURE_SAY and module.callbackOnCreatureSay ~= nil) then
tmpRet = module:callbackOnCreatureSay(...)
elseif(id == CALLBACK_PLAYER_ENDTRADE and module.callbackOnPlayerEndTrade ~= nil) then
tmpRet = module:callbackOnPlayerEndTrade(...)
elseif(id == CALLBACK_PLAYER_CLOSECHANNEL and module.callbackOnPlayerCloseChannel ~= nil) then
tmpRet = module:callbackOnPlayerCloseChannel(...)
elseif(id == CALLBACK_ONBUY and module.callbackOnBuy ~= nil) then
tmpRet = module:callbackOnBuy(...)
elseif(id == CALLBACK_ONSELL and module.callbackOnSell ~= nil) then
tmpRet = module:callbackOnSell(...)
elseif(id == CALLBACK_ONTHINK and module.callbackOnThink ~= nil) then
tmpRet = module:callbackOnThink(...)
elseif(id == CALLBACK_GREET and module.callbackOnGreet ~= nil) then
tmpRet = module:callbackOnGreet(...)
elseif(id == CALLBACK_FAREWELL and module.callbackOnFarewell ~= nil) then
tmpRet = module:callbackOnFarewell(...)
elseif(id == CALLBACK_MESSAGE_DEFAULT and module.callbackOnMessageDefault ~= nil) then
tmpRet = module:callbackOnMessageDefault(...)
elseif(id == CALLBACK_MODULE_RESET and module.callbackOnModuleReset ~= nil) then
tmpRet = module:callbackOnModuleReset(...)
end
if(not tmpRet) then
ret = false
break
end
end
return ret
end
-- Returns the message represented by id.
function NpcHandler:getMessage(id)
local ret = nil
if(self.messages ~= nil) then
ret = self.messages[id]
end
return ret
end
-- Changes the default response message with the specified id to newMessage.
function NpcHandler:setMessage(id, newMessage)
if(self.messages ~= nil) then
self.messages[id] = newMessage
end
end
-- Translates all message tags found in msg using parseInfo
function NpcHandler:parseMessage(msg, parseInfo)
for search, replace in pairs(parseInfo) do
if(replace ~= nil) then
msg = msg:gsub(search, replace)
end
end
return msg
end
-- Makes sure the npc un-focuses the currently focused player
function NpcHandler:unGreet(cid)
if(not self:isFocused(cid)) then
return
end
local callback = self:getCallback(CALLBACK_FAREWELL)
if(callback == nil or callback(cid)) then
if(self:processModuleCallback(CALLBACK_FAREWELL)) then
if(self.queue == nil or not self.queue:greetNext()) then
local msg = self:getMessage(MESSAGE_FAREWELL)
msg = self:parseMessage(msg, { [TAG_PLAYERNAME] = getPlayerName(cid) or -1 })
self:resetNpc(cid)
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
self:say(msg, cid, 0, true)
msg = msg:gsub('{', ''):gsub('}', '')
local ghost, position = isPlayerGhost(cid), getThingPosition(getNpcId())
local spectators, nid = getSpectators(position, 7, 7), getNpcId()
for _, pid in ipairs(spectators) do
if(isPlayer(pid) and pid ~= cid) then
if(NPCHANDLER_TALKDELAY ~= TALKDELAY_NONE) then
addEvent(doCreatureSay, self.talkDelayTime, nid, msg, TALKTYPE_SAY, ghost, pid, position)
else
doCreatureSay(nid, msg, TALKTYPE_SAY, ghost, pid, position)
end
end
end
else
self:say(msg)
end
self:releaseFocus(cid)
end
end
end
end
-- Greets a new player.
function NpcHandler:greet(cid)
local callback = self:getCallback(CALLBACK_GREET)
if(callback == nil or callback(cid)) then
if(self:processModuleCallback(CALLBACK_GREET, cid)) then
local msg = self:getMessage(MESSAGE_GREET)
msg = self:parseMessage(msg, { [TAG_PLAYERNAME] = getCreatureName(cid) })
self:addFocus(cid)
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
self:say(msg, cid, 0, true)
msg = msg:gsub('{', ''):gsub('}', '')
local ghost, position = isPlayerGhost(cid), getThingPosition(getNpcId())
local spectators, nid = getSpectators(position, 7, 7), getNpcId()
for _, pid in ipairs(spectators) do
if(isPlayer(pid) and pid ~= cid) then
if(NPCHANDLER_TALKDELAY ~= TALKDELAY_NONE) then
addEvent(doCreatureSay, self.talkDelayTime, nid, msg, TALKTYPE_SAY, ghost, pid, position)
else
doCreatureSay(nid, msg, TALKTYPE_SAY, ghost, pid, position)
end
end
end
else
self:say(msg)
end
end
end
end
-- Handles onCreatureAppear events. If you with to handle this yourself, please use the CALLBACK_CREATURE_APPEAR callback.
function NpcHandler:onCreatureAppear(cid)
local callback = self:getCallback(CALLBACK_CREATURE_APPEAR)
if(callback == nil or callback(cid)) then
if(self:processModuleCallback(CALLBACK_CREATURE_APPEAR, cid)) then
--
end
end
end
-- Handles onCreatureDisappear events. If you with to handle this yourself, please use the CALLBACK_CREATURE_DISAPPEAR callback.
function NpcHandler:onCreatureDisappear(cid)
local callback = self:getCallback(CALLBACK_CREATURE_DISAPPEAR)
if(callback == nil or callback(cid)) then
if(self:processModuleCallback(CALLBACK_CREATURE_DISAPPEAR, cid)) then
if(self:isFocused(cid)) then
self:unGreet(cid)
end
end
end
end
-- Handles onCreatureSay events. If you with to handle this yourself, please use the CALLBACK_CREATURE_SAY callback.
function NpcHandler:onCreatureSay(cid, class, msg)
local callback = self:getCallback(CALLBACK_CREATURE_SAY)
if(callback == nil or callback(cid, class, msg)) then
if(self:processModuleCallback(CALLBACK_CREATURE_SAY, cid, class, msg)) then
if(not self:isInRange(cid)) then
return
end
if(self.keywordHandler ~= nil) then
if((self:isFocused(cid) and (class == TALKTYPE_PRIVATE_PN or NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT)) or not self:isFocused(cid)) then
local ret = self.keywordHandler:processMessage(cid, msg)
if(not ret) then
local callback = self:getCallback(CALLBACK_MESSAGE_DEFAULT)
if(callback ~= nil and callback(cid, class, msg)) then
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
self.talkStart[cid] = os.time()
else
self.talkStart = os.time()
end
end
elseif(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
self.talkStart[cid] = os.time()
else
self.talkStart = os.time()
end
end
end
end
end
end
-- Handles onPlayerEndTrade events. If you wish to handle this yourself, use the CALLBACK_PLAYER_ENDTRADE callback.
function NpcHandler:onPlayerEndTrade(cid)
local callback = self:getCallback(CALLBACK_PLAYER_ENDTRADE)
if(callback == nil or callback(cid)) then
if(self:processModuleCallback(CALLBACK_PLAYER_ENDTRADE, cid)) then
if(self:isFocused(cid)) then
local parseInfo = { [TAG_PLAYERNAME] = getPlayerName(cid) }
local msg = self:parseMessage(self:getMessage(MESSAGE_ONCLOSESHOP), parseInfo)
self:say(msg, cid)
end
end
end
end
-- Handles onPlayerCloseChannel events. If you wish to handle this yourself, use the CALLBACK_PLAYER_CLOSECHANNEL callback.
function NpcHandler:onPlayerCloseChannel(cid)
local callback = self:getCallback(CALLBACK_PLAYER_CLOSECHANNEL)
if(callback == nil or callback(cid)) then
if(self:processModuleCallback(CALLBACK_PLAYER_CLOSECHANNEL, cid)) then
if(self:isFocused(cid)) then
self:unGreet(cid)
end
end
end
end
-- Handles onBuy events. If you wish to handle this yourself, use the CALLBACK_ONBUY callback.
function NpcHandler:onBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks)
local callback = self:getCallback(CALLBACK_ONBUY)
if(callback == nil or callback(cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
if(self:processModuleCallback(CALLBACK_ONBUY, cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
--
end
end
end
-- Handles onSell events. If you wish to handle this yourself, use the CALLBACK_ONSELL callback.
function NpcHandler:onSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)
local callback = self:getCallback(CALLBACK_ONSELL)
if(callback == nil or callback(cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
if(self:processModuleCallback(CALLBACK_ONSELL, cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
--
end
end
end
-- Handles onThink events. If you wish to handle this yourself, please use the CALLBACK_ONTHINK callback.
function NpcHandler:onThink()
local callback = self:getCallback(CALLBACK_ONTHINK)
if(callback == nil or callback()) then
for i, speech in pairs(self.talkDelay) do
if((speech.cid == nil or speech.cid == 0) and speech.time ~= nil and speech.message ~= nil) then
if(os.mtime() >= speech.time) then
selfSay(speech.message)
self.talkDelay[i] = nil
end
elseif(isCreature(speech.cid) and speech.start ~= nil and speech.time ~= nil and speech.message ~= nil) then
if(os.mtime() >= speech.time) then
local talkStart = (NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT and self.talkStart[speech.cid] or self.talkStart)
if(speech.force or (self:isFocused(speech.cid) and talkStart == speech.start)) then
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
selfSay(speech.message, speech.cid)
else
selfSay(speech.message)
end
end
self.talkDelay[i] = nil
end
else
self.talkDelay[i] = nil
end
end
if(self:processModuleCallback(CALLBACK_ONTHINK)) then
for _, cid in ipairs(getSpectators(getNpcPosition(), 4, 4, false)) do
if(getCreatureStorage(cid, "TargetTrade") == getNpcId())then
doCreatureSetStorage(cid, "TargetTrade", -1)
end
end
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
for _, focus in pairs(self.focuses) do
if(focus ~= nil) then
if(not self:isInRange(focus)) then
self:onWalkAway(focus)
elseif((os.time() - self.talkStart[focus]) > self.idleTime) then
self:unGreet(focus)
else
self:updateFocus()
end
end
end
elseif(self.focuses ~= 0) then
if(not self:isInRange(self.focuses)) then
self:onWalkAway(self.focuses)
elseif((os.time() - self.talkStart) > self.idleTime) then
self:unGreet(self.focuses)
else
self:updateFocus()
end
end
end
end
end
-- Tries to greet the player with the given cid.
function NpcHandler:onGreet(cid)
if(self:isInRange(cid)) then
if(NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE) then
if(not self:isFocused(cid)) then
self:greet(cid)
return
end
elseif(NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT) then
if(self.focuses == 0) then
self:greet(cid)
elseif(self.focuses == cid) then
local msg = self:getMessage(MESSAGE_ALREADYFOCUSED)
local parseInfo = { [TAG_PLAYERNAME] = getCreatureName(cid) }
msg = self:parseMessage(msg, parseInfo)
self:say(msg)
else
if(not self.queue:isInQueue(cid)) then
self.queue:push(cid)
end
local msg = self:getMessage(MESSAGE_PLACEDINQUEUE)
local parseInfo = { [TAG_PLAYERNAME] = getCreatureName(cid), [TAG_QUEUESIZE] = self.queue:getSize() }
msg = self:parseMessage(msg, parseInfo)
self:say(msg)
end
end
end
end
-- Simply calls the underlying unGreet function.
function NpcHandler:onFarewell(cid)
self:unGreet(cid)
end
-- Should be called on this npc's focus if the distance to focus is greater then talkRadius.
function NpcHandler:onWalkAway(cid)
if(self:isFocused(cid)) then
local callback = self:getCallback(CALLBACK_CREATURE_DISAPPEAR)
if(callback == nil or callback(cid)) then
if(self:processModuleCallback(CALLBACK_CREATURE_DISAPPEAR, cid)) then
if(self.queue == nil or not self.queue:greetNext()) then
local msg = self:getMessage(MESSAGE_WALKAWAY)
self:resetNpc(cid)
self:say(self:parseMessage(msg, { [TAG_PLAYERNAME] = getPlayerName(cid) or -1 }))
self:releaseFocus(cid)
end
end
end
end
end
-- Returns true if cid is within the talkRadius of this npc.
function NpcHandler:isInRange(cid)
if not isPlayer(cid) then
return false
end
local distance = getNpcDistanceTo(cid) or -1
return distance ~= -1 and distance <= self.talkRadius
end
-- Resets the npc into it's initial state (in regard of the keyrodhandler).
-- All modules are also receiving a reset call through their callbackOnModuleReset function.
function NpcHandler:resetNpc(cid)
if(self:processModuleCallback(CALLBACK_MODULE_RESET)) then
self.keywordHandler:reset(cid)
end
end
-- Makes the npc represented by this instance of NpcHandler say something.
-- This implements the currently set type of talkdelay.
function NpcHandler:say(message, focus, delay, force)
local delay = delay or 0
if(NPCHANDLER_TALKDELAY == TALKDELAY_NONE or delay <= 0) then
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
selfSay(message, focus)
else
selfSay(message)
end
return
end
-- TODO: Add an event handling method for delayed messages
table.insert(self.talkDelay, {
id = getNpcId(),
cid = focus,
message = message,
time = os.mtime() + (delay and delay or self.talkDelayTime),
start = os.time(),
force = force or false
})
end
end
| agpl-3.0 |
mercury233/ygopro-scripts | c48447192.lua | 2 | 3306 | --剣の煌き
function c48447192.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+EFFECT_FLAG_CONTINUOUS_TARGET)
e1:SetTarget(c48447192.target)
e1:SetOperation(c48447192.operation)
c:RegisterEffect(e1)
--destroy
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetCategory(CATEGORY_DESTROY)
e2:SetDescription(aux.Stringid(48447192,0))
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCode(EVENT_BATTLE_DESTROYING)
e2:SetRange(LOCATION_SZONE)
e2:SetCondition(c48447192.descon)
e2:SetTarget(c48447192.destg)
e2:SetOperation(c48447192.desop)
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(c48447192.eqlimit)
c:RegisterEffect(e3)
--todeck
local e4=Effect.CreateEffect(c)
e4:SetCategory(CATEGORY_TODECK)
e4:SetDescription(aux.Stringid(48447192,1))
e4:SetType(EFFECT_TYPE_IGNITION)
e4:SetRange(LOCATION_GRAVE)
e4:SetCost(c48447192.retcost)
e4:SetTarget(c48447192.rettg)
e4:SetOperation(c48447192.retop)
c:RegisterEffect(e4)
end
function c48447192.eqlimit(e,c)
return c:IsSetCard(0x100d)
end
function c48447192.filter(c)
return c:IsFaceup() and c:IsSetCard(0x100d)
end
function c48447192.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c48447192.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c48447192.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,c48447192.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
function c48447192.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 c48447192.descon(e,tp,eg,ep,ev,re,r,rp)
local ec=e:GetHandler():GetEquipTarget()
return ec and eg:IsContains(ec)
end
function c48447192.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() and chkc:IsControler(1-tp) end
if chk==0 then return Duel.IsExistingTarget(aux.TRUE,tp,0,LOCATION_ONFIELD,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,aux.TRUE,tp,0,LOCATION_ONFIELD,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
end
function c48447192.desop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc and tc:IsRelateToEffect(e) then
Duel.Destroy(tc,REASON_EFFECT)
end
end
function c48447192.retcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckReleaseGroup(tp,aux.TRUE,1,nil) end
local g=Duel.SelectReleaseGroup(tp,aux.TRUE,1,1,nil)
Duel.Release(g,REASON_COST)
end
function c48447192.rettg(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 c48447192.retop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) then
Duel.SendtoDeck(c,nil,SEQ_DECKTOP,REASON_EFFECT)
end
end
| gpl-2.0 |
Zenny89/darkstar | scripts/zones/Port_Bastok/npcs/Evi.lua | 17 | 1985 | -----------------------------------
-- Area: Port Bastok
-- NPC: Evi
-- Starts Quests: Past Perfect (100%)
-----------------------------------
package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/zones/Port_Bastok/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
PastPerfect = player:getQuestStatus(BASTOK,PAST_PERFECT);
if (PastPerfect == QUEST_ACCEPTED and player:hasKeyItem(TATTERED_MISSION_ORDERS)) then
player:startEvent(0x0083);
elseif (player:getFameLevel(BASTOK) >= 2 and player:getVar("PastPerfectVar") == 2) then
player:startEvent(0x0082);
elseif (PastPerfect == QUEST_AVAILABLE) then
player:startEvent(0x0068);
else
player:startEvent(0x0015);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID2: %u",csid);
--printf("RESULT2: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x0068 and player:getVar("PastPerfectVar") == 0) then
player:setVar("PastPerfectVar",1);
elseif (csid == 0x0082) then
player:addQuest(BASTOK,PAST_PERFECT);
elseif (csid == 0x0083) then
player:delKeyItem(TATTERED_MISSION_ORDERS);
player:setVar("PastPerfectVar",0);
player:addItem(12560);
player:messageSpecial(ITEM_OBTAINED,12560);
player:addFame(BASTOK,BAS_FAME*110);
player:completeQuest(BASTOK,PAST_PERFECT);
end
end; | gpl-3.0 |
linushsao/marsu_game-linus-v0.2 | mods/minetest_game/creative/init.lua | 2 | 1794 | creative = {}
local creative_mode_cache = minetest.setting_getbool("creative_mode")
function creative.is_enabled_for(name)
return creative_mode_cache
end
dofile(minetest.get_modpath("creative") .. "/inventory.lua")
if creative_mode_cache then
-- Dig time is modified according to difference (leveldiff) between tool
-- 'maxlevel' and node 'level'. Digtime is divided by the larger of
-- leveldiff and 1.
-- To speed up digging in creative, hand 'maxlevel' and 'digtime' have been
-- increased such that nodes of differing levels have an insignificant
-- effect on digtime.
local digtime = 42
local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 256}
minetest.register_item(":", {
type = "none",
wield_image = "wieldhand.png",
wield_scale = {x = 1, y = 1, z = 2.5},
range = 10,
tool_capabilities = {
full_punch_interval = 0.5,
max_drop_level = 3,
groupcaps = {
crumbly = caps,
cracky = caps,
snappy = caps,
choppy = caps,
oddly_breakable_by_hand = caps,
},
damage_groups = {fleshy = 10},
}
})
end
-- Unlimited node placement
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
return creative.is_enabled_for(placer:get_player_name())
end)
-- Don't pick up if the item is already in the inventory
local old_handle_node_drops = minetest.handle_node_drops
function minetest.handle_node_drops(pos, drops, digger)
if not digger or not digger:is_player() then
return
end
if not creative.is_enabled_for(digger:get_player_name()) then
return old_handle_node_drops(pos, drops, digger)
end
local inv = digger:get_inventory()
if inv then
for _, item in ipairs(drops) do
if not inv:contains_item("main", item, true) then
inv:add_item("main", item)
end
end
end
end
| gpl-3.0 |
Zenny89/darkstar | scripts/zones/Temenos/mobs/Cryptonberry_Skulker.lua | 16 | 1141 | -----------------------------------
-- Area: Temenos N T
-- NPC: Cryptonberry_Skulker
-----------------------------------
package.loaded["scripts/zones/Temenos/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/limbus");
require("scripts/zones/Temenos/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob,killer)
if (IsMobDead(16928816)==true and IsMobDead(16928817)==true ) then
GetNPCByID(16928768+38):setPos(-412,-78,426);
GetNPCByID(16928768+38):setStatus(STATUS_NORMAL);
GetNPCByID(16928768+172):setPos(-415,-78,427);
GetNPCByID(16928768+172):setStatus(STATUS_NORMAL);
GetNPCByID(16928768+214):setPos(-412,-78,422);
GetNPCByID(16928768+214):setStatus(STATUS_NORMAL);
GetNPCByID(16928770+455):setStatus(STATUS_NORMAL);
end
end;
| gpl-3.0 |
goblinor/BomBus | tg/tdcli.lua | 102 | 88571 | --[[
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
]]--
-- Vector example form is like this: {[0] = v} or {v1, v2, v3, [0] = v}
-- If false or true crashed your telegram-cli, try to change true to 1 and false to 0
-- Main Bot Framework
local M = {}
-- @chat_id = user, group, channel, and broadcast
-- @group_id = normal group
-- @channel_id = channel and broadcast
local function getChatId(chat_id)
local chat = {}
local chat_id = tostring(chat_id)
if chat_id:match('^-100') then
local channel_id = chat_id:gsub('-100', '')
chat = {ID = channel_id, type = 'channel'}
else
local group_id = chat_id:gsub('-', '')
chat = {ID = group_id, type = 'group'}
end
return chat
end
local function getInputFile(file)
if file:match('/') then
infile = {ID = "InputFileLocal", path_ = file}
elseif file:match('^%d+$') then
infile = {ID = "InputFileId", id_ = file}
else
infile = {ID = "InputFilePersistentId", persistent_id_ = file}
end
return infile
end
-- User can send bold, italic, and monospace text uses HTML or Markdown format.
local function getParseMode(parse_mode)
if parse_mode then
local mode = parse_mode:lower()
if mode == 'markdown' or mode == 'md' then
P = {ID = "TextParseModeMarkdown"}
elseif mode == 'html' then
P = {ID = "TextParseModeHTML"}
end
end
return P
end
-- Returns current authorization state, offline request
local function getAuthState(dl_cb, cmd)
tdcli_function ({
ID = "GetAuthState",
}, dl_cb, cmd)
end
M.getAuthState = getAuthState
-- Sets user's phone number and sends authentication code to the user.
-- Works only when authGetState returns authStateWaitPhoneNumber.
-- If phone number is not recognized or another error has happened, returns an error. Otherwise returns authStateWaitCode
-- @phone_number User's phone number in any reasonable format
-- @allow_flash_call Pass True, if code can be sent via flash call to the specified phone number
-- @is_current_phone_number Pass true, if the phone number is used on the current device. Ignored if allow_flash_call is False
local function setAuthPhoneNumber(phone_number, allow_flash_call, is_current_phone_number, dl_cb, cmd)
tdcli_function ({
ID = "SetAuthPhoneNumber",
phone_number_ = phone_number,
allow_flash_call_ = allow_flash_call,
is_current_phone_number_ = is_current_phone_number
}, dl_cb, cmd)
end
M.setAuthPhoneNumber = setAuthPhoneNumber
-- Resends authentication code to the user.
-- Works only when authGetState returns authStateWaitCode and next_code_type of result is not null.
-- Returns authStateWaitCode on success
local function resendAuthCode(dl_cb, cmd)
tdcli_function ({
ID = "ResendAuthCode",
}, dl_cb, cmd)
end
M.resendAuthCode = resendAuthCode
-- Checks authentication code.
-- Works only when authGetState returns authStateWaitCode.
-- Returns authStateWaitPassword or authStateOk on success
-- @code Verification code from SMS, Telegram message, voice call or flash call
-- @first_name User first name, if user is yet not registered, 1-255 characters
-- @last_name Optional user last name, if user is yet not registered, 0-255 characters
local function checkAuthCode(code, first_name, last_name, dl_cb, cmd)
tdcli_function ({
ID = "CheckAuthCode",
code_ = code,
first_name_ = first_name,
last_name_ = last_name
}, dl_cb, cmd)
end
M.checkAuthCode = checkAuthCode
-- Checks password for correctness.
-- Works only when authGetState returns authStateWaitPassword.
-- Returns authStateOk on success
-- @password Password to check
local function checkAuthPassword(password, dl_cb, cmd)
tdcli_function ({
ID = "CheckAuthPassword",
password_ = password
}, dl_cb, cmd)
end
M.checkAuthPassword = checkAuthPassword
-- Requests to send password recovery code to email.
-- Works only when authGetState returns authStateWaitPassword.
-- Returns authStateWaitPassword on success
local function requestAuthPasswordRecovery(dl_cb, cmd)
tdcli_function ({
ID = "RequestAuthPasswordRecovery",
}, dl_cb, cmd)
end
M.requestAuthPasswordRecovery = requestAuthPasswordRecovery
-- Recovers password with recovery code sent to email.
-- Works only when authGetState returns authStateWaitPassword.
-- Returns authStateOk on success
-- @recovery_code Recovery code to check
local function recoverAuthPassword(recovery_code, dl_cb, cmd)
tdcli_function ({
ID = "RecoverAuthPassword",
recovery_code_ = recovery_code
}, dl_cb, cmd)
end
M.recoverAuthPassword = recoverAuthPassword
-- Logs out user.
-- If force == false, begins to perform soft log out, returns authStateLoggingOut after completion.
-- If force == true then succeeds almost immediately without cleaning anything at the server, but returns error with code 401 and description "Unauthorized"
-- @force If true, just delete all local data. Session will remain in list of active sessions
local function resetAuth(force, dl_cb, cmd)
tdcli_function ({
ID = "ResetAuth",
force_ = force or nil
}, dl_cb, cmd)
end
M.resetAuth = resetAuth
-- Check bot's authentication token to log in as a bot.
-- Works only when authGetState returns authStateWaitPhoneNumber.
-- Can be used instead of setAuthPhoneNumber and checkAuthCode to log in.
-- Returns authStateOk on success
-- @token Bot token
local function checkAuthBotToken(token, dl_cb, cmd)
tdcli_function ({
ID = "CheckAuthBotToken",
token_ = token
}, dl_cb, cmd)
end
M.checkAuthBotToken = checkAuthBotToken
-- Returns current state of two-step verification
local function getPasswordState(dl_cb, cmd)
tdcli_function ({
ID = "GetPasswordState",
}, dl_cb, cmd)
end
M.getPasswordState = getPasswordState
-- Changes user password.
-- If new recovery email is specified, then error EMAIL_UNCONFIRMED is returned and password change will not be applied until email confirmation.
-- Application should call getPasswordState from time to time to check if email is already confirmed
-- @old_password Old user password
-- @new_password New user password, may be empty to remove the password
-- @new_hint New password hint, can be empty
-- @set_recovery_email Pass True, if recovery email should be changed
-- @new_recovery_email New recovery email, may be empty
local function setPassword(old_password, new_password, new_hint, set_recovery_email, new_recovery_email, dl_cb, cmd)
tdcli_function ({
ID = "SetPassword",
old_password_ = old_password,
new_password_ = new_password,
new_hint_ = new_hint,
set_recovery_email_ = set_recovery_email,
new_recovery_email_ = new_recovery_email
}, dl_cb, cmd)
end
M.setPassword = setPassword
-- Returns set up recovery email.
-- This method can be used to verify a password provided by the user
-- @password Current user password
local function getRecoveryEmail(password, dl_cb, cmd)
tdcli_function ({
ID = "GetRecoveryEmail",
password_ = password
}, dl_cb, cmd)
end
M.getRecoveryEmail = getRecoveryEmail
-- Changes user recovery email.
-- If new recovery email is specified, then error EMAIL_UNCONFIRMED is returned and email will not be changed until email confirmation.
-- Application should call getPasswordState from time to time to check if email is already confirmed.
-- If new_recovery_email coincides with the current set up email succeeds immediately and aborts all other requests waiting for email confirmation
-- @password Current user password
-- @new_recovery_email New recovery email
local function setRecoveryEmail(password, new_recovery_email, dl_cb, cmd)
tdcli_function ({
ID = "SetRecoveryEmail",
password_ = password,
new_recovery_email_ = new_recovery_email
}, dl_cb, cmd)
end
M.setRecoveryEmail = setRecoveryEmail
-- Requests to send password recovery code to email
local function requestPasswordRecovery(dl_cb, cmd)
tdcli_function ({
ID = "RequestPasswordRecovery",
}, dl_cb, cmd)
end
M.requestPasswordRecovery = requestPasswordRecovery
-- Recovers password with recovery code sent to email
-- @recovery_code Recovery code to check
local function recoverPassword(recovery_code, dl_cb, cmd)
tdcli_function ({
ID = "RecoverPassword",
recovery_code_ = tostring(recovery_code)
}, dl_cb, cmd)
end
M.recoverPassword = recoverPassword
-- Returns current logged in user
local function getMe(dl_cb, cmd)
tdcli_function ({
ID = "GetMe",
}, dl_cb, cmd)
end
M.getMe = getMe
-- Returns information about a user by its identifier, offline request if current user is not a bot
-- @user_id User identifier
local function getUser(user_id, dl_cb, cmd)
tdcli_function ({
ID = "GetUser",
user_id_ = user_id
}, dl_cb, cmd)
end
M.getUser = getUser
-- Returns full information about a user by its identifier
-- @user_id User identifier
local function getUserFull(user_id, dl_cb, cmd)
tdcli_function ({
ID = "GetUserFull",
user_id_ = user_id
}, dl_cb, cmd)
end
M.getUserFull = getUserFull
-- Returns information about a group by its identifier, offline request if current user is not a bot
-- @group_id Group identifier
local function getGroup(group_id, dl_cb, cmd)
tdcli_function ({
ID = "GetGroup",
group_id_ = getChatId(group_id).ID
}, dl_cb, cmd)
end
M.getGroup = getGroup
-- Returns full information about a group by its identifier
-- @group_id Group identifier
local function getGroupFull(group_id, dl_cb, cmd)
tdcli_function ({
ID = "GetGroupFull",
group_id_ = getChatId(group_id).ID
}, dl_cb, cmd)
end
M.getGroupFull = getGroupFull
-- Returns information about a channel by its identifier, offline request if current user is not a bot
-- @channel_id Channel identifier
local function getChannel(channel_id, dl_cb, cmd)
tdcli_function ({
ID = "GetChannel",
channel_id_ = getChatId(channel_id).ID
}, dl_cb, cmd)
end
M.getChannel = getChannel
-- Returns full information about a channel by its identifier, cached for at most 1 minute
-- @channel_id Channel identifier
local function getChannelFull(channel_id, dl_cb, cmd)
tdcli_function ({
ID = "GetChannelFull",
channel_id_ = getChatId(channel_id).ID
}, dl_cb, cmd)
end
M.getChannelFull = getChannelFull
-- Returns information about a secret chat by its identifier, offline request
-- @secret_chat_id Secret chat identifier
local function getSecretChat(secret_chat_id, dl_cb, cmd)
tdcli_function ({
ID = "GetSecretChat",
secret_chat_id_ = secret_chat_id
}, dl_cb, cmd)
end
M.getSecretChat = getSecretChat
-- Returns information about a chat by its identifier, offline request if current user is not a bot
-- @chat_id Chat identifier
local function getChat(chat_id, dl_cb, cmd)
tdcli_function ({
ID = "GetChat",
chat_id_ = chat_id
}, dl_cb, cmd)
end
M.getChat = getChat
-- Returns information about a message
-- @chat_id Identifier of the chat, message belongs to
-- @message_id Identifier of the message to get
local function getMessage(chat_id, message_id, dl_cb, cmd)
tdcli_function ({
ID = "GetMessage",
chat_id_ = chat_id,
message_id_ = message_id
}, dl_cb, cmd)
end
M.getMessage = getMessage
-- Returns information about messages.
-- If message is not found, returns null on the corresponding position of the result
-- @chat_id Identifier of the chat, messages belongs to
-- @message_ids Identifiers of the messages to get
local function getMessages(chat_id, message_ids, dl_cb, cmd)
tdcli_function ({
ID = "GetMessages",
chat_id_ = chat_id,
message_ids_ = message_ids -- vector
}, dl_cb, cmd)
end
M.getMessages = getMessages
-- Returns information about a file, offline request
-- @file_id Identifier of the file to get
local function getFile(file_id, dl_cb, cmd)
tdcli_function ({
ID = "GetFile",
file_id_ = file_id
}, dl_cb, cmd)
end
M.getFile = getFile
-- Returns information about a file by its persistent id, offline request
-- @persistent_file_id Persistent identifier of the file to get
local function getFilePersistent(persistent_file_id, dl_cb, cmd)
tdcli_function ({
ID = "GetFilePersistent",
persistent_file_id_ = persistent_file_id
}, dl_cb, cmd)
end
M.getFilePersistent = getFilePersistent
-- Returns list of chats in the right order, chats are sorted by (order, chat_id) in decreasing order.
-- For example, to get list of chats from the beginning, the offset_order should be equal 2^63 - 1
-- @offset_order Chat order to return chats from
-- @offset_chat_id Chat identifier to return chats from
-- @limit Maximum number of chats to be returned
local function getChats(offset_order, offset_chat_id, limit, dl_cb, cmd)
if not limit or limit > 20 then
limit = 20
end
tdcli_function ({
ID = "GetChats",
offset_order_ = offset_order or 9223372036854775807,
offset_chat_id_ = offset_chat_id or 0,
limit_ = limit
}, dl_cb, cmd)
end
M.getChats = getChats
-- Searches public chat by its username.
-- Currently only private and channel chats can be public.
-- Returns chat if found, otherwise some error is returned
-- @username Username to be resolved
local function searchPublicChat(username, dl_cb, cmd)
tdcli_function ({
ID = "SearchPublicChat",
username_ = username
}, dl_cb, cmd)
end
M.searchPublicChat = searchPublicChat
-- Searches public chats by prefix of their username.
-- Currently only private and channel (including supergroup) chats can be public.
-- Returns meaningful number of results.
-- Returns nothing if length of the searched username prefix is less than 5.
-- Excludes private chats with contacts from the results
-- @username_prefix Prefix of the username to search
local function searchPublicChats(username_prefix, dl_cb, cmd)
tdcli_function ({
ID = "SearchPublicChats",
username_prefix_ = username_prefix
}, dl_cb, cmd)
end
M.searchPublicChats = searchPublicChats
-- Searches for specified query in the title and username of known chats, offline request.
-- Returns chats in the order of them in the chat list
-- @query Query to search for, if query is empty, returns up to 20 recently found chats
-- @limit Maximum number of chats to be returned
local function searchChats(query, limit, dl_cb, cmd)
if not limit or limit > 20 then
limit = 20
end
tdcli_function ({
ID = "SearchChats",
query_ = query,
limit_ = limit
}, dl_cb, cmd)
end
M.searchChats = searchChats
-- Adds chat to the list of recently found chats.
-- The chat is added to the beginning of the list.
-- If the chat is already in the list, at first it is removed from the list
-- @chat_id Identifier of the chat to add
local function addRecentlyFoundChat(chat_id, dl_cb, cmd)
tdcli_function ({
ID = "AddRecentlyFoundChat",
chat_id_ = chat_id
}, dl_cb, cmd)
end
M.addRecentlyFoundChat = addRecentlyFoundChat
-- Deletes chat from the list of recently found chats
-- @chat_id Identifier of the chat to delete
local function deleteRecentlyFoundChat(chat_id, dl_cb, cmd)
tdcli_function ({
ID = "DeleteRecentlyFoundChat",
chat_id_ = chat_id
}, dl_cb, cmd)
end
M.deleteRecentlyFoundChat = deleteRecentlyFoundChat
-- Clears list of recently found chats
local function deleteRecentlyFoundChats(dl_cb, cmd)
tdcli_function ({
ID = "DeleteRecentlyFoundChats",
}, dl_cb, cmd)
end
M.deleteRecentlyFoundChats = deleteRecentlyFoundChats
-- Returns list of common chats with an other given user.
-- Chats are sorted by their type and creation date
-- @user_id User identifier
-- @offset_chat_id Chat identifier to return chats from, use 0 for the first request
-- @limit Maximum number of chats to be returned, up to 100
local function getCommonChats(user_id, offset_chat_id, limit, dl_cb, cmd)
if not limit or limit > 100 then
limit = 100
end
tdcli_function ({
ID = "GetCommonChats",
user_id_ = user_id,
offset_chat_id_ = offset_chat_id,
limit_ = limit
}, dl_cb, cmd)
end
M.getCommonChats = getCommonChats
-- Returns messages in a chat.
-- Automatically calls openChat.
-- Returns result in reverse chronological order, i.e. in order of decreasing message.message_id
-- @chat_id Chat identifier
-- @from_message_id Identifier of the message near which we need a history, you can use 0 to get results from the beginning, i.e. from oldest to newest
-- @offset Specify 0 to get results exactly from from_message_id or negative offset to get specified message and some newer messages
-- @limit Maximum number of messages to be returned, should be positive and can't be greater than 100.
-- If offset is negative, limit must be greater than -offset.
-- There may be less than limit messages returned even the end of the history is not reached
local function getChatHistory(chat_id, from_message_id, offset, limit, dl_cb, cmd)
if not limit or limit > 100 then
limit = 100
end
tdcli_function ({
ID = "GetChatHistory",
chat_id_ = chat_id,
from_message_id_ = from_message_id,
offset_ = offset or 0,
limit_ = limit
}, dl_cb, cmd)
end
M.getChatHistory = getChatHistory
-- Deletes all messages in the chat.
-- Can't be used for channel chats
-- @chat_id Chat identifier
-- @remove_from_chat_list Pass true, if chat should be removed from the chat list
local function deleteChatHistory(chat_id, remove_from_chat_list, dl_cb, cmd)
tdcli_function ({
ID = "DeleteChatHistory",
chat_id_ = chat_id,
remove_from_chat_list_ = remove_from_chat_list
}, dl_cb, cmd)
end
M.deleteChatHistory = deleteChatHistory
-- Searches for messages with given words in the chat.
-- Returns result in reverse chronological order, i. e. in order of decreasimg message_id.
-- Doesn't work in secret chats
-- @chat_id Chat identifier to search in
-- @query Query to search for
-- @from_message_id Identifier of the message from which we need a history, you can use 0 to get results from beginning
-- @limit Maximum number of messages to be returned, can't be greater than 100
-- @filter Filter for content of searched messages
-- filter = Empty|Animation|Audio|Document|Photo|Video|Voice|PhotoAndVideo|Url|ChatPhoto
local function searchChatMessages(chat_id, query, from_message_id, limit, filter, dl_cb, cmd)
if not limit or limit > 100 then
limit = 100
end
tdcli_function ({
ID = "SearchChatMessages",
chat_id_ = chat_id,
query_ = query,
from_message_id_ = from_message_id,
limit_ = limit,
filter_ = {
ID = 'SearchMessagesFilter' .. filter
},
}, dl_cb, cmd)
end
M.searchChatMessages = searchChatMessages
-- Searches for messages in all chats except secret chats. Returns result in reverse chronological order, i. e. in order of decreasing (date, chat_id, message_id)
-- @query Query to search for
-- @offset_date Date of the message to search from, you can use 0 or any date in the future to get results from the beginning
-- @offset_chat_id Chat identifier of the last found message or 0 for the first request
-- @offset_message_id Message identifier of the last found message or 0 for the first request
-- @limit Maximum number of messages to be returned, can't be greater than 100
local function searchMessages(query, offset_date, offset_chat_id, offset_message_id, limit, dl_cb, cmd)
if not limit or limit > 100 then
limit = 100
end
tdcli_function ({
ID = "SearchMessages",
query_ = query,
offset_date_ = offset_date,
offset_chat_id_ = offset_chat_id,
offset_message_id_ = offset_message_id,
limit_ = limit
}, dl_cb, cmd)
end
M.searchMessages = searchMessages
-- Invites bot to a chat (if it is not in the chat) and send /start to it.
-- Bot can't be invited to a private chat other than chat with the bot.
-- Bots can't be invited to broadcast channel chats and secret chats.
-- Returns sent message.
-- UpdateChatTopMessage will not be sent, so returned message should be used to update chat top message
-- @bot_user_id Identifier of the bot
-- @chat_id Identifier of the chat
-- @parameter Hidden parameter sent to bot for deep linking (https://api.telegram.org/bots#deep-linking)
-- parameter=start|startgroup or custom as defined by bot creator
local function sendBotStartMessage(bot_user_id, chat_id, parameter, dl_cb, cmd)
tdcli_function ({
ID = "SendBotStartMessage",
bot_user_id_ = bot_user_id,
chat_id_ = chat_id,
parameter_ = parameter
}, dl_cb, cmd)
end
M.sendBotStartMessage = sendBotStartMessage
-- Sends result of the inline query as a message.
-- Returns sent message.
-- UpdateChatTopMessage will not be sent, so returned message should be used to update chat top message.
-- Always clears chat draft message
-- @chat_id Chat to send message
-- @reply_to_message_id Identifier of a message to reply to or 0
-- @disable_notification Pass true, to disable notification about the message, doesn't works in secret chats
-- @from_background Pass true, if the message is sent from background
-- @query_id Identifier of the inline query
-- @result_id Identifier of the inline result
local function sendInlineQueryResultMessage(chat_id, reply_to_message_id, disable_notification, from_background, query_id, result_id, dl_cb, cmd)
tdcli_function ({
ID = "SendInlineQueryResultMessage",
chat_id_ = chat_id,
reply_to_message_id_ = reply_to_message_id,
disable_notification_ = disable_notification,
from_background_ = from_background,
query_id_ = query_id,
result_id_ = result_id
}, dl_cb, cmd)
end
M.sendInlineQueryResultMessage = sendInlineQueryResultMessage
-- Forwards previously sent messages.
-- Returns forwarded messages in the same order as message identifiers passed in message_ids.
-- If message can't be forwarded, null will be returned instead of the message.
-- UpdateChatTopMessage will not be sent, so returned messages should be used to update chat top message
-- @chat_id Identifier of a chat to forward messages
-- @from_chat_id Identifier of a chat to forward from
-- @message_ids Identifiers of messages to forward
-- @disable_notification Pass true, to disable notification about the message, doesn't works if messages are forwarded to secret chat
-- @from_background Pass true, if the message is sent from background
local function forwardMessages(chat_id, from_chat_id, message_ids, disable_notification, dl_cb, cmd)
tdcli_function ({
ID = "ForwardMessages",
chat_id_ = chat_id,
from_chat_id_ = from_chat_id,
message_ids_ = message_ids, -- vector
disable_notification_ = disable_notification,
from_background_ = 1
}, dl_cb, cmd)
end
M.forwardMessages = forwardMessages
-- Changes current ttl setting in a secret chat and sends corresponding message
-- @chat_id Chat identifier
-- @ttl New value of ttl in seconds
local function sendChatSetTtlMessage(chat_id, ttl, dl_cb, cmd)
tdcli_function ({
ID = "SendChatSetTtlMessage",
chat_id_ = chat_id,
ttl_ = ttl
}, dl_cb, cmd)
end
M.sendChatSetTtlMessage = sendChatSetTtlMessage
-- Deletes messages.
-- UpdateDeleteMessages will not be sent for messages deleted through that function
-- @chat_id Chat identifier
-- @message_ids Identifiers of messages to delete
local function deleteMessages(chat_id, message_ids, dl_cb, cmd)
tdcli_function ({
ID = "DeleteMessages",
chat_id_ = chat_id,
message_ids_ = message_ids -- vector
}, dl_cb, cmd)
end
M.deleteMessages = deleteMessages
-- Deletes all messages in the chat sent by the specified user.
-- Works only in supergroup channel chats, needs appropriate privileges
-- @chat_id Chat identifier
-- @user_id User identifier
local function deleteMessagesFromUser(chat_id, user_id, dl_cb, cmd)
tdcli_function ({
ID = "DeleteMessagesFromUser",
chat_id_ = chat_id,
user_id_ = user_id
}, dl_cb, cmd)
end
M.deleteMessagesFromUser = deleteMessagesFromUser
-- Edits text of text or game message.
-- Non-bots can edit message in a limited period of time.
-- Returns edited message after edit is complete server side
-- @chat_id Chat the message belongs to
-- @message_id Identifier of the message
-- @reply_markup Bots only. New message reply markup
-- @input_message_content New text content of the message. Should be of type InputMessageText
local function editMessageText(chat_id, message_id, reply_markup, text, disable_web_page_preview, parse_mode, dl_cb, cmd)
local TextParseMode = getParseMode(parse_mode)
tdcli_function ({
ID = "EditMessageText",
chat_id_ = chat_id,
message_id_ = message_id,
reply_markup_ = reply_markup, -- reply_markup:ReplyMarkup
input_message_content_ = {
ID = "InputMessageText",
text_ = text,
disable_web_page_preview_ = disable_web_page_preview,
clear_draft_ = 0,
entities_ = {},
parse_mode_ = TextParseMode,
},
}, dl_cb, cmd)
end
M.editMessageText = editMessageText
-- Edits message content caption.
-- Non-bots can edit message in a limited period of time.
-- Returns edited message after edit is complete server side
-- @chat_id Chat the message belongs to
-- @message_id Identifier of the message
-- @reply_markup Bots only. New message reply markup
-- @caption New message content caption, 0-200 characters
local function editMessageCaption(chat_id, message_id, reply_markup, caption, dl_cb, cmd)
tdcli_function ({
ID = "EditMessageCaption",
chat_id_ = chat_id,
message_id_ = message_id,
reply_markup_ = reply_markup, -- reply_markup:ReplyMarkup
caption_ = caption
}, dl_cb, cmd)
end
M.editMessageCaption = editMessageCaption
-- Bots only.
-- Edits message reply markup.
-- Returns edited message after edit is complete server side
-- @chat_id Chat the message belongs to
-- @message_id Identifier of the message
-- @reply_markup New message reply markup
local function editMessageReplyMarkup(inline_message_id, reply_markup, caption, dl_cb, cmd)
tdcli_function ({
ID = "EditInlineMessageCaption",
inline_message_id_ = inline_message_id,
reply_markup_ = reply_markup, -- reply_markup:ReplyMarkup
caption_ = caption
}, dl_cb, cmd)
end
M.editMessageReplyMarkup = editMessageReplyMarkup
-- Bots only.
-- Edits text of an inline text or game message sent via bot
-- @inline_message_id Inline message identifier
-- @reply_markup New message reply markup
-- @input_message_content New text content of the message. Should be of type InputMessageText
local function editInlineMessageText(inline_message_id, reply_markup, text, disable_web_page_preview, dl_cb, cmd)
tdcli_function ({
ID = "EditInlineMessageText",
inline_message_id_ = inline_message_id,
reply_markup_ = reply_markup, -- reply_markup:ReplyMarkup
input_message_content_ = {
ID = "InputMessageText",
text_ = text,
disable_web_page_preview_ = disable_web_page_preview,
clear_draft_ = 0,
entities_ = {}
},
}, dl_cb, cmd)
end
M.editInlineMessageText = editInlineMessageText
-- Bots only.
-- Edits caption of an inline message content sent via bot
-- @inline_message_id Inline message identifier
-- @reply_markup New message reply markup
-- @caption New message content caption, 0-200 characters
local function editInlineMessageCaption(inline_message_id, reply_markup, caption, dl_cb, cmd)
tdcli_function ({
ID = "EditInlineMessageCaption",
inline_message_id_ = inline_message_id,
reply_markup_ = reply_markup, -- reply_markup:ReplyMarkup
caption_ = caption
}, dl_cb, cmd)
end
M.editInlineMessageCaption = editInlineMessageCaption
-- Bots only.
-- Edits reply markup of an inline message sent via bot
-- @inline_message_id Inline message identifier
-- @reply_markup New message reply markup
local function editInlineMessageReplyMarkup(inline_message_id, reply_markup, dl_cb, cmd)
tdcli_function ({
ID = "EditInlineMessageReplyMarkup",
inline_message_id_ = inline_message_id,
reply_markup_ = reply_markup -- reply_markup:ReplyMarkup
}, dl_cb, cmd)
end
M.editInlineMessageReplyMarkup = editInlineMessageReplyMarkup
-- Sends inline query to a bot and returns its results.
-- Unavailable for bots
-- @bot_user_id Identifier of the bot send query to
-- @chat_id Identifier of the chat, where the query is sent
-- @user_location User location, only if needed
-- @query Text of the query
-- @offset Offset of the first entry to return
local function getInlineQueryResults(bot_user_id, chat_id, latitude, longitude, query, offset, dl_cb, cmd)
tdcli_function ({
ID = "GetInlineQueryResults",
bot_user_id_ = bot_user_id,
chat_id_ = chat_id,
user_location_ = {
ID = "Location",
latitude_ = latitude,
longitude_ = longitude
},
query_ = query,
offset_ = offset
}, dl_cb, cmd)
end
M.getInlineQueryResults = getInlineQueryResults
-- Bots only.
-- Sets result of the inline query
-- @inline_query_id Identifier of the inline query
-- @is_personal Does result of the query can be cached only for specified user
-- @results Results of the query
-- @cache_time Allowed time to cache results of the query in seconds
-- @next_offset Offset for the next inline query, pass empty string if there is no more results
-- @switch_pm_text If non-empty, this text should be shown on the button, which opens private chat with the bot and sends bot start message with parameter switch_pm_parameter
-- @switch_pm_parameter Parameter for the bot start message
local function answerInlineQuery(inline_query_id, is_personal, cache_time, next_offset, switch_pm_text, switch_pm_parameter, dl_cb, cmd)
tdcli_function ({
ID = "AnswerInlineQuery",
inline_query_id_ = inline_query_id,
is_personal_ = is_personal,
results_ = results, --vector<InputInlineQueryResult>,
cache_time_ = cache_time,
next_offset_ = next_offset,
switch_pm_text_ = switch_pm_text,
switch_pm_parameter_ = switch_pm_parameter
}, dl_cb, cmd)
end
M.answerInlineQuery = answerInlineQuery
-- Sends callback query to a bot and returns answer to it.
-- Unavailable for bots
-- @chat_id Identifier of the chat with a message
-- @message_id Identifier of the message, from which the query is originated
-- @payload Query payload
-- @text Text of the answer
-- @show_alert If true, an alert should be shown to the user instead of a toast
-- @url URL to be open
local function getCallbackQueryAnswer(chat_id, message_id, text, show_alert, url, dl_cb, cmd)
tdcli_function ({
ID = "GetCallbackQueryAnswer",
chat_id_ = chat_id,
message_id_ = message_id,
payload_ = {
ID = "CallbackQueryAnswer",
text_ = text,
show_alert_ = show_alert,
url_ = url
},
}, dl_cb, cmd)
end
M.getCallbackQueryAnswer = getCallbackQueryAnswer
-- Bots only.
-- Sets result of the callback query
-- @callback_query_id Identifier of the callback query
-- @text Text of the answer
-- @show_alert If true, an alert should be shown to the user instead of a toast
-- @url Url to be opened
-- @cache_time Allowed time to cache result of the query in seconds
local function answerCallbackQuery(callback_query_id, text, show_alert, url, cache_time, dl_cb, cmd)
tdcli_function ({
ID = "AnswerCallbackQuery",
callback_query_id_ = callback_query_id,
text_ = text,
show_alert_ = show_alert,
url_ = url,
cache_time_ = cache_time
}, dl_cb, cmd)
end
M.answerCallbackQuery = answerCallbackQuery
-- Bots only.
-- Updates game score of the specified user in the game
-- @chat_id Chat a message with the game belongs to
-- @message_id Identifier of the message
-- @edit_message True, if message should be edited
-- @user_id User identifier
-- @score New score
-- @force Pass True to update the score even if it decreases. If score is 0, user will be deleted from the high scores table
local function setGameScore(chat_id, message_id, edit_message, user_id, score, force, dl_cb, cmd)
tdcli_function ({
ID = "SetGameScore",
chat_id_ = chat_id,
message_id_ = message_id,
edit_message_ = edit_message,
user_id_ = user_id,
score_ = score,
force_ = force
}, dl_cb, cmd)
end
M.setGameScore = setGameScore
-- Bots only.
-- Updates game score of the specified user in the game
-- @inline_message_id Inline message identifier
-- @edit_message True, if message should be edited
-- @user_id User identifier
-- @score New score
-- @force Pass True to update the score even if it decreases. If score is 0, user will be deleted from the high scores table
local function setInlineGameScore(inline_message_id, edit_message, user_id, score, force, dl_cb, cmd)
tdcli_function ({
ID = "SetInlineGameScore",
inline_message_id_ = inline_message_id,
edit_message_ = edit_message,
user_id_ = user_id,
score_ = score,
force_ = force
}, dl_cb, cmd)
end
M.setInlineGameScore = setInlineGameScore
-- Bots only.
-- Returns game high scores and some part of the score table around of the specified user in the game
-- @chat_id Chat a message with the game belongs to
-- @message_id Identifier of the message
-- @user_id User identifie
local function getGameHighScores(chat_id, message_id, user_id, dl_cb, cmd)
tdcli_function ({
ID = "GetGameHighScores",
chat_id_ = chat_id,
message_id_ = message_id,
user_id_ = user_id
}, dl_cb, cmd)
end
M.getGameHighScores = getGameHighScores
-- Bots only.
-- Returns game high scores and some part of the score table around of the specified user in the game
-- @inline_message_id Inline message identifier
-- @user_id User identifier
local function getInlineGameHighScores(inline_message_id, user_id, dl_cb, cmd)
tdcli_function ({
ID = "GetInlineGameHighScores",
inline_message_id_ = inline_message_id,
user_id_ = user_id
}, dl_cb, cmd)
end
M.getInlineGameHighScores = getInlineGameHighScores
-- Deletes default reply markup from chat.
-- This method needs to be called after one-time keyboard or ForceReply reply markup has been used.
-- UpdateChatReplyMarkup will be send if reply markup will be changed
-- @chat_id Chat identifier
-- @message_id Message identifier of used keyboard
local function deleteChatReplyMarkup(chat_id, message_id, dl_cb, cmd)
tdcli_function ({
ID = "DeleteChatReplyMarkup",
chat_id_ = chat_id,
message_id_ = message_id
}, dl_cb, cmd)
end
M.deleteChatReplyMarkup = deleteChatReplyMarkup
-- Sends notification about user activity in a chat
-- @chat_id Chat identifier
-- @action Action description
-- action = Typing|Cancel|RecordVideo|UploadVideo|RecordVoice|UploadVoice|UploadPhoto|UploadDocument|GeoLocation|ChooseContact|StartPlayGame
local function sendChatAction(chat_id, action, progress, dl_cb, cmd)
tdcli_function ({
ID = "SendChatAction",
chat_id_ = chat_id,
action_ = {
ID = "SendMessage" .. action .. "Action",
progress_ = progress or 100
}
}, dl_cb, cmd)
end
M.sendChatAction = sendChatAction
-- Sends notification about screenshot taken in a chat.
-- Works only in secret chats
-- @chat_id Chat identifier
local function sendChatScreenshotTakenNotification(chat_id, dl_cb, cmd)
tdcli_function ({
ID = "SendChatScreenshotTakenNotification",
chat_id_ = chat_id
}, dl_cb, cmd)
end
M.sendChatScreenshotTakenNotification = sendChatScreenshotTakenNotification
-- Chat is opened by the user.
-- Many useful activities depends on chat being opened or closed. For example, in channels all updates are received only for opened chats
-- @chat_id Chat identifier
local function openChat(chat_id, dl_cb, cmd)
tdcli_function ({
ID = "OpenChat",
chat_id_ = chat_id
}, dl_cb, cmd)
end
M.openChat = openChat
-- Chat is closed by the user.
-- Many useful activities depends on chat being opened or closed.
-- @chat_id Chat identifier
local function closeChat(chat_id, dl_cb, cmd)
tdcli_function ({
ID = "CloseChat",
chat_id_ = chat_id
}, dl_cb, cmd)
end
M.closeChat = closeChat
-- Messages are viewed by the user.
-- Many useful activities depends on message being viewed. For example, marking messages as read, incrementing of view counter, updating of view counter, removing of deleted messages in channels
-- @chat_id Chat identifier
-- @message_ids Identifiers of viewed messages
local function viewMessages(chat_id, message_ids, dl_cb, cmd)
tdcli_function ({
ID = "ViewMessages",
chat_id_ = chat_id,
message_ids_ = message_ids -- vector
}, dl_cb, cmd)
end
M.viewMessages = viewMessages
-- Message content is opened, for example the user has opened a photo, a video, a document, a location or a venue or have listened to an audio or a voice message
-- @chat_id Chat identifier of the message
-- @message_id Identifier of the message with opened content
local function openMessageContent(chat_id, message_id, dl_cb, cmd)
tdcli_function ({
ID = "OpenMessageContent",
chat_id_ = chat_id,
message_id_ = message_id
}, dl_cb, cmd)
end
M.openMessageContent = openMessageContent
-- Returns existing chat corresponding to the given user
-- @user_id User identifier
local function createPrivateChat(user_id, dl_cb, cmd)
tdcli_function ({
ID = "CreatePrivateChat",
user_id_ = user_id
}, dl_cb, cmd)
end
M.createPrivateChat = createPrivateChat
-- Returns existing chat corresponding to the known group
-- @group_id Group identifier
local function createGroupChat(group_id, dl_cb, cmd)
tdcli_function ({
ID = "CreateGroupChat",
group_id_ = getChatId(group_id).ID
}, dl_cb, cmd)
end
M.createGroupChat = createGroupChat
-- Returns existing chat corresponding to the known channel
-- @channel_id Channel identifier
local function createChannelChat(channel_id, dl_cb, cmd)
tdcli_function ({
ID = "CreateChannelChat",
channel_id_ = getChatId(channel_id).ID
}, dl_cb, cmd)
end
M.createChannelChat = createChannelChat
-- Returns existing chat corresponding to the known secret chat
-- @secret_chat_id SecretChat identifier
local function createSecretChat(secret_chat_id, dl_cb, cmd)
tdcli_function ({
ID = "CreateSecretChat",
secret_chat_id_ = secret_chat_id
}, dl_cb, cmd)
end
M.createSecretChat = createSecretChat
-- Creates new group chat and send corresponding messageGroupChatCreate, returns created chat
-- @user_ids Identifiers of users to add to the group
-- @title Title of new group chat, 0-255 characters
local function createNewGroupChat(user_ids, title, dl_cb, cmd)
tdcli_function ({
ID = "CreateNewGroupChat",
user_ids_ = user_ids, -- vector
title_ = title
}, dl_cb, cmd)
end
M.createNewGroupChat = createNewGroupChat
-- Creates new channel chat and send corresponding messageChannelChatCreate, returns created chat
-- @title Title of new channel chat, 0-255 characters
-- @is_supergroup True, if supergroup chat should be created
-- @about Information about the channel, 0-255 characters
local function createNewChannelChat(title, is_supergroup, about, dl_cb, cmd)
tdcli_function ({
ID = "CreateNewChannelChat",
title_ = title,
is_supergroup_ = is_supergroup,
about_ = about
}, dl_cb, cmd)
end
M.createNewChannelChat = createNewChannelChat
-- Creates new secret chat, returns created chat
-- @user_id Identifier of a user to create secret chat with
local function createNewSecretChat(user_id, dl_cb, cmd)
tdcli_function ({
ID = "CreateNewSecretChat",
user_id_ = user_id
}, dl_cb, cmd)
end
M.createNewSecretChat = createNewSecretChat
-- Creates new channel supergroup chat from existing group chat and send corresponding messageChatMigrateTo and messageChatMigrateFrom. Deactivates group
-- @chat_id Group chat identifier
local function migrateGroupChatToChannelChat(chat_id, dl_cb, cmd)
tdcli_function ({
ID = "MigrateGroupChatToChannelChat",
chat_id_ = chat_id
}, dl_cb, cmd)
end
M.migrateGroupChatToChannelChat = migrateGroupChatToChannelChat
-- Changes chat title.
-- Title can't be changed for private chats.
-- Title will not change until change will be synchronized with the server.
-- Title will not be changed if application is killed before it can send request to the server.
-- There will be update about change of the title on success. Otherwise error will be returned
-- @chat_id Chat identifier
-- @title New title of a chat, 0-255 characters
local function changeChatTitle(chat_id, title, dl_cb, cmd)
tdcli_function ({
ID = "ChangeChatTitle",
chat_id_ = chat_id,
title_ = title
}, dl_cb, cmd)
end
M.changeChatTitle = changeChatTitle
-- Changes chat photo.
-- Photo can't be changed for private chats.
-- Photo will not change until change will be synchronized with the server.
-- Photo will not be changed if application is killed before it can send request to the server.
-- There will be update about change of the photo on success. Otherwise error will be returned
-- @chat_id Chat identifier
-- @photo New chat photo. You can use zero InputFileId to delete photo. Files accessible only by HTTP URL are not acceptable
local function changeChatPhoto(chat_id, photo, dl_cb, cmd)
tdcli_function ({
ID = "ChangeChatPhoto",
chat_id_ = chat_id,
photo_ = getInputFile(photo)
}, dl_cb, cmd)
end
M.changeChatPhoto = changeChatPhoto
-- Changes chat draft message
-- @chat_id Chat identifier
-- @draft_message New draft message, nullable
local function changeChatDraftMessage(chat_id, reply_to_message_id, text, disable_web_page_preview, clear_draft, parse_mode, dl_cb, cmd)
local TextParseMode = getParseMode(parse_mode)
tdcli_function ({
ID = "ChangeChatDraftMessage",
chat_id_ = chat_id,
draft_message_ = {
ID = "DraftMessage",
reply_to_message_id_ = reply_to_message_id,
input_message_text_ = {
ID = "InputMessageText",
text_ = text,
disable_web_page_preview_ = disable_web_page_preview,
clear_draft_ = clear_draft,
entities_ = {},
parse_mode_ = TextParseMode,
},
},
}, dl_cb, cmd)
end
M.changeChatDraftMessage = changeChatDraftMessage
-- Adds new member to chat.
-- Members can't be added to private or secret chats.
-- Member will not be added until chat state will be synchronized with the server.
-- Member will not be added if application is killed before it can send request to the server
-- @chat_id Chat identifier
-- @user_id Identifier of the user to add
-- @forward_limit Number of previous messages from chat to forward to new member, ignored for channel chats
local function addChatMember(chat_id, user_id, forward_limit, dl_cb, cmd)
tdcli_function ({
ID = "AddChatMember",
chat_id_ = chat_id,
user_id_ = user_id,
forward_limit_ = forward_limit or 50
}, dl_cb, cmd)
end
M.addChatMember = addChatMember
-- Adds many new members to the chat.
-- Currently, available only for channels.
-- Can't be used to join the channel.
-- Member will not be added until chat state will be synchronized with the server.
-- Member will not be added if application is killed before it can send request to the server
-- @chat_id Chat identifier
-- @user_ids Identifiers of the users to add
local function addChatMembers(chat_id, user_ids, dl_cb, cmd)
tdcli_function ({
ID = "AddChatMembers",
chat_id_ = chat_id,
user_ids_ = user_ids -- vector
}, dl_cb, cmd)
end
M.addChatMembers = addChatMembers
-- Changes status of the chat member, need appropriate privileges.
-- In channel chats, user will be added to chat members if he is yet not a member and there is less than 200 members in the channel.
-- Status will not be changed until chat state will be synchronized with the server.
-- Status will not be changed if application is killed before it can send request to the server
-- @chat_id Chat identifier
-- @user_id Identifier of the user to edit status, bots can be editors in the channel chats
-- @status New status of the member in the chat
-- status = Creator|Editor|Moderator|Member|Left|Kicked
local function changeChatMemberStatus(chat_id, user_id, status, dl_cb, cmd)
tdcli_function ({
ID = "ChangeChatMemberStatus",
chat_id_ = chat_id,
user_id_ = user_id,
status_ = {
ID = "ChatMemberStatus" .. status
},
}, dl_cb, cmd)
end
M.changeChatMemberStatus = changeChatMemberStatus
-- Returns information about one participant of the chat
-- @chat_id Chat identifier
-- @user_id User identifier
local function getChatMember(chat_id, user_id, dl_cb, cmd)
tdcli_function ({
ID = "GetChatMember",
chat_id_ = chat_id,
user_id_ = user_id
}, dl_cb, cmd)
end
M.getChatMember = getChatMember
-- Asynchronously downloads file from cloud.
-- Updates updateFileProgress will notify about download progress.
-- Update updateFile will notify about successful download
-- @file_id Identifier of file to download
local function downloadFile(file_id, dl_cb, cmd)
tdcli_function ({
ID = "DownloadFile",
file_id_ = file_id
}, dl_cb, cmd)
end
M.downloadFile = downloadFile
-- Stops file downloading.
-- If file already downloaded do nothing.
-- @file_id Identifier of file to cancel download
local function cancelDownloadFile(file_id, dl_cb, cmd)
tdcli_function ({
ID = "CancelDownloadFile",
file_id_ = file_id
}, dl_cb, cmd)
end
M.cancelDownloadFile = cancelDownloadFile
-- Next part of a file was generated
-- @generation_id Identifier of the generation process
-- @ready Number of bytes already generated. Negative number means that generation has failed and should be terminated
local function setFileGenerationProgress(generation_id, ready, dl_cb, cmd)
tdcli_function ({
ID = "SetFileGenerationProgress",
generation_id_ = generation_id,
ready_ = ready
}, dl_cb, cmd)
end
M.setFileGenerationProgress = setFileGenerationProgress
-- Finishes file generation
-- @generation_id Identifier of the generation process
local function finishFileGeneration(generation_id, dl_cb, cmd)
tdcli_function ({
ID = "FinishFileGeneration",
generation_id_ = generation_id
}, dl_cb, cmd)
end
M.finishFileGeneration = finishFileGeneration
-- Generates new chat invite link, previously generated link is revoked.
-- Available for group and channel chats.
-- Only creator of the chat can export chat invite link
-- @chat_id Chat identifier
local function exportChatInviteLink(chat_id, dl_cb, cmd)
tdcli_function ({
ID = "ExportChatInviteLink",
chat_id_ = chat_id
}, dl_cb, cmd)
end
M.exportChatInviteLink = exportChatInviteLink
-- Checks chat invite link for validness and returns information about the corresponding chat
-- @invite_link Invite link to check. Should begin with "https://telegram.me/joinchat/"
local function checkChatInviteLink(link, dl_cb, cmd)
tdcli_function ({
ID = "CheckChatInviteLink",
invite_link_ = link
}, dl_cb, cmd)
end
M.checkChatInviteLink = checkChatInviteLink
-- Imports chat invite link, adds current user to a chat if possible.
-- Member will not be added until chat state will be synchronized with the server.
-- Member will not be added if application is killed before it can send request to the server
-- @invite_link Invite link to import. Should begin with "https://telegram.me/joinchat/"
local function importChatInviteLink(invite_link, dl_cb, cmd)
tdcli_function ({
ID = "ImportChatInviteLink",
invite_link_ = invite_link
}, dl_cb, cmd)
end
M.importChatInviteLink = importChatInviteLink
-- Adds user to black list
-- @user_id User identifier
local function blockUser(user_id, dl_cb, cmd)
tdcli_function ({
ID = "BlockUser",
user_id_ = user_id
}, dl_cb, cmd)
end
M.blockUser = blockUser
-- Removes user from black list
-- @user_id User identifier
local function unblockUser(user_id, dl_cb, cmd)
tdcli_function ({
ID = "UnblockUser",
user_id_ = user_id
}, dl_cb, cmd)
end
M.unblockUser = unblockUser
-- Returns users blocked by the current user
-- @offset Number of users to skip in result, must be non-negative
-- @limit Maximum number of users to return, can't be greater than 100
local function getBlockedUsers(offset, limit, dl_cb, cmd)
tdcli_function ({
ID = "GetBlockedUsers",
offset_ = offset,
limit_ = limit
}, dl_cb, cmd)
end
M.getBlockedUsers = getBlockedUsers
-- Adds new contacts/edits existing contacts, contacts user identifiers are ignored.
-- Returns list of corresponding users in the same order as input contacts.
-- If contact doesn't registered in Telegram, user with id == 0 will be returned
-- @contacts List of contacts to import/edit
local function importContacts(phone_number, first_name, last_name, user_id, dl_cb, cmd)
tdcli_function ({
ID = "ImportContacts",
contacts_ = {[0] = {
phone_number_ = tostring(phone_number),
first_name_ = tostring(first_name),
last_name_ = tostring(last_name),
user_id_ = user_id
},
},
}, dl_cb, cmd)
end
M.importContacts = importContacts
-- Searches for specified query in the first name, last name and username of the known user contacts
-- @query Query to search for, can be empty to return all contacts
-- @limit Maximum number of users to be returned
local function searchContacts(query, limit, dl_cb, cmd)
tdcli_function ({
ID = "SearchContacts",
query_ = query,
limit_ = limit
}, dl_cb, cmd)
end
M.searchContacts = searchContacts
-- Deletes users from contacts list
-- @user_ids Identifiers of users to be deleted
local function deleteContacts(user_ids, dl_cb, cmd)
tdcli_function ({
ID = "DeleteContacts",
user_ids_ = user_ids -- vector
}, dl_cb, cmd)
end
M.deleteContacts = deleteContacts
-- Returns profile photos of the user.
-- Result of this query can't be invalidated, so it must be used with care
-- @user_id User identifier
-- @offset Photos to skip, must be non-negative
-- @limit Maximum number of photos to be returned, can't be greater than 100
local function getUserProfilePhotos(user_id, offset, limit, dl_cb, cmd)
tdcli_function ({
ID = "GetUserProfilePhotos",
user_id_ = user_id,
offset_ = offset,
limit_ = limit
}, dl_cb, cmd)
end
M.getUserProfilePhotos = getUserProfilePhotos
-- Returns stickers corresponding to given emoji
-- @emoji String representation of emoji. If empty, returns all known stickers
local function getStickers(emoji, dl_cb, cmd)
tdcli_function ({
ID = "GetStickers",
emoji_ = emoji
}, dl_cb, cmd)
end
M.getStickers = getStickers
-- Returns list of installed sticker sets without archived sticker sets
-- @is_masks Pass true to return masks, pass false to return stickers
local function getStickerSets(is_masks, dl_cb, cmd)
tdcli_function ({
ID = "GetStickerSets",
is_masks_ = is_masks
}, dl_cb, cmd)
end
M.getStickerSets = getStickerSets
-- Returns list of archived sticker sets
-- @is_masks Pass true to return masks, pass false to return stickers
-- @offset_sticker_set_id Identifier of the sticker set from which return the result
-- @limit Maximum number of sticker sets to return
local function getArchivedStickerSets(is_masks, offset_sticker_set_id, limit, dl_cb, cmd)
tdcli_function ({
ID = "GetArchivedStickerSets",
is_masks_ = is_masks,
offset_sticker_set_id_ = offset_sticker_set_id,
limit_ = limit
}, dl_cb, cmd)
end
M.getArchivedStickerSets = getArchivedStickerSets
-- Returns list of trending sticker sets
local function getTrendingStickerSets(dl_cb, cmd)
tdcli_function ({
ID = "GetTrendingStickerSets"
}, dl_cb, cmd)
end
M.getTrendingStickerSets = getTrendingStickerSets
-- Returns list of sticker sets attached to a file, currently only photos and videos can have attached sticker sets
-- @file_id File identifier
local function getAttachedStickerSets(file_id, dl_cb, cmd)
tdcli_function ({
ID = "GetAttachedStickerSets",
file_id_ = file_id
}, dl_cb, cmd)
end
M.getAttachedStickerSets = getAttachedStickerSets
-- Returns information about sticker set by its identifier
-- @set_id Identifier of the sticker set
local function getStickerSet(set_id, dl_cb, cmd)
tdcli_function ({
ID = "GetStickerSet",
set_id_ = set_id
}, dl_cb, cmd)
end
M.getStickerSet = getStickerSet
-- Searches sticker set by its short name
-- @name Name of the sticker set
local function searchStickerSet(name, dl_cb, cmd)
tdcli_function ({
ID = "SearchStickerSet",
name_ = name
}, dl_cb, cmd)
end
M.searchStickerSet = searchStickerSet
-- Installs/uninstalls or enables/archives sticker set.
-- Official sticker set can't be uninstalled, but it can be archived
-- @set_id Identifier of the sticker set
-- @is_installed New value of is_installed
-- @is_archived New value of is_archived
local function updateStickerSet(set_id, is_installed, is_archived, dl_cb, cmd)
tdcli_function ({
ID = "UpdateStickerSet",
set_id_ = set_id,
is_installed_ = is_installed,
is_archived_ = is_archived
}, dl_cb, cmd)
end
M.updateStickerSet = updateStickerSet
-- Trending sticker sets are viewed by the user
-- @sticker_set_ids Identifiers of viewed trending sticker sets
local function viewTrendingStickerSets(sticker_set_ids, dl_cb, cmd)
tdcli_function ({
ID = "ViewTrendingStickerSets",
sticker_set_ids_ = sticker_set_ids -- vector
}, dl_cb, cmd)
end
M.viewTrendingStickerSets = viewTrendingStickerSets
-- Changes the order of installed sticker sets
-- @is_masks Pass true to change masks order, pass false to change stickers order
-- @sticker_set_ids Identifiers of installed sticker sets in the new right order
local function reorderStickerSets(is_masks, sticker_set_ids, dl_cb, cmd)
tdcli_function ({
ID = "ReorderStickerSets",
is_masks_ = is_masks,
sticker_set_ids_ = sticker_set_ids -- vector
}, dl_cb, cmd)
end
M.reorderStickerSets = reorderStickerSets
-- Returns list of recently used stickers
-- @is_attached Pass true to return stickers and masks recently attached to photo or video files, pass false to return recently sent stickers
local function getRecentStickers(is_attached, dl_cb, cmd)
tdcli_function ({
ID = "GetRecentStickers",
is_attached_ = is_attached
}, dl_cb, cmd)
end
M.getRecentStickers = getRecentStickers
-- Manually adds new sticker to the list of recently used stickers.
-- New sticker is added to the beginning of the list.
-- If the sticker is already in the list, at first it is removed from the list
-- @is_attached Pass true to add the sticker to the list of stickers recently attached to photo or video files, pass false to add the sticker to the list of recently sent stickers
-- @sticker Sticker file to add
local function addRecentSticker(is_attached, sticker, dl_cb, cmd)
tdcli_function ({
ID = "AddRecentSticker",
is_attached_ = is_attached,
sticker_ = getInputFile(sticker)
}, dl_cb, cmd)
end
M.addRecentSticker = addRecentSticker
-- Removes a sticker from the list of recently used stickers
-- @is_attached Pass true to remove the sticker from the list of stickers recently attached to photo or video files, pass false to remove the sticker from the list of recently sent stickers
-- @sticker Sticker file to delete
local function deleteRecentSticker(is_attached, sticker, dl_cb, cmd)
tdcli_function ({
ID = "DeleteRecentSticker",
is_attached_ = is_attached,
sticker_ = getInputFile(sticker)
}, dl_cb, cmd)
end
M.deleteRecentSticker = deleteRecentSticker
-- Clears list of recently used stickers
-- @is_attached Pass true to clear list of stickers recently attached to photo or video files, pass false to clear the list of recently sent stickers
local function clearRecentStickers(is_attached, dl_cb, cmd)
tdcli_function ({
ID = "ClearRecentStickers",
is_attached_ = is_attached
}, dl_cb, cmd)
end
M.clearRecentStickers = clearRecentStickers
-- Returns emojis corresponding to a sticker
-- @sticker Sticker file identifier
local function getStickerEmojis(sticker, dl_cb, cmd)
tdcli_function ({
ID = "GetStickerEmojis",
sticker_ = getInputFile(sticker)
}, dl_cb, cmd)
end
M.getStickerEmojis = getStickerEmojis
-- Returns saved animations
local function getSavedAnimations(dl_cb, cmd)
tdcli_function ({
ID = "GetSavedAnimations",
}, dl_cb, cmd)
end
M.getSavedAnimations = getSavedAnimations
-- Manually adds new animation to the list of saved animations.
-- New animation is added to the beginning of the list.
-- If the animation is already in the list, at first it is removed from the list.
-- Only non-secret video animations with MIME type "video/mp4" can be added to the list
-- @animation Animation file to add. Only known to server animations (i. e. successfully sent via message) can be added to the list
local function addSavedAnimation(animation, dl_cb, cmd)
tdcli_function ({
ID = "AddSavedAnimation",
animation_ = getInputFile(animation)
}, dl_cb, cmd)
end
M.addSavedAnimation = addSavedAnimation
-- Removes animation from the list of saved animations
-- @animation Animation file to delete
local function deleteSavedAnimation(animation, dl_cb, cmd)
tdcli_function ({
ID = "DeleteSavedAnimation",
animation_ = getInputFile(animation)
}, dl_cb, cmd)
end
M.deleteSavedAnimation = deleteSavedAnimation
-- Returns up to 20 recently used inline bots in the order of the last usage
local function getRecentInlineBots(dl_cb, cmd)
tdcli_function ({
ID = "GetRecentInlineBots",
}, dl_cb, cmd)
end
M.getRecentInlineBots = getRecentInlineBots
-- Get web page preview by text of the message.
-- Do not call this function to often
-- @message_text Message text
local function getWebPagePreview(message_text, dl_cb, cmd)
tdcli_function ({
ID = "GetWebPagePreview",
message_text_ = message_text
}, dl_cb, cmd)
end
M.getWebPagePreview = getWebPagePreview
-- Returns notification settings for a given scope
-- @scope Scope to return information about notification settings
-- scope = Chat(chat_id)|PrivateChats|GroupChats|AllChats|
local function getNotificationSettings(scope, chat_id, dl_cb, cmd)
tdcli_function ({
ID = "GetNotificationSettings",
scope_ = {
ID = 'NotificationSettingsFor' .. scope,
chat_id_ = chat_id or nil
},
}, dl_cb, cmd)
end
M.getNotificationSettings = getNotificationSettings
-- Changes notification settings for a given scope
-- @scope Scope to change notification settings
-- @notification_settings New notification settings for given scope
-- scope = Chat(chat_id)|PrivateChats|GroupChats|AllChats|
local function setNotificationSettings(scope, chat_id, mute_for, show_preview, dl_cb, cmd)
tdcli_function ({
ID = "SetNotificationSettings",
scope_ = {
ID = 'NotificationSettingsFor' .. scope,
chat_id_ = chat_id or nil
},
notification_settings_ = {
ID = "NotificationSettings",
mute_for_ = mute_for,
sound_ = "default",
show_preview_ = show_preview
}
}, dl_cb, cmd)
end
M.setNotificationSettings = setNotificationSettings
-- Resets all notification settings to the default value.
-- By default the only muted chats are supergroups, sound is set to 'default' and message previews are showed
local function resetAllNotificationSettings(dl_cb, cmd)
tdcli_function ({
ID = "ResetAllNotificationSettings"
}, dl_cb, cmd)
end
M.resetAllNotificationSettings = resetAllNotificationSettings
-- Uploads new profile photo for logged in user.
-- Photo will not change until change will be synchronized with the server.
-- Photo will not be changed if application is killed before it can send request to the server.
-- If something changes, updateUser will be sent
-- @photo_path Path to new profile photo
local function setProfilePhoto(photo_path, dl_cb, cmd)
tdcli_function ({
ID = "SetProfilePhoto",
photo_path_ = photo_path
}, dl_cb, cmd)
end
M.setProfilePhoto = setProfilePhoto
-- Deletes profile photo.
-- If something changes, updateUser will be sent
-- @profile_photo_id Identifier of profile photo to delete
local function deleteProfilePhoto(profile_photo_id, dl_cb, cmd)
tdcli_function ({
ID = "DeleteProfilePhoto",
profile_photo_id_ = profile_photo_id
}, dl_cb, cmd)
end
M.deleteProfilePhoto = deleteProfilePhoto
-- Changes first and last names of logged in user.
-- If something changes, updateUser will be sent
-- @first_name New value of user first name, 1-255 characters
-- @last_name New value of optional user last name, 0-255 characters
local function changeName(first_name, last_name, dl_cb, cmd)
tdcli_function ({
ID = "ChangeName",
first_name_ = first_name,
last_name_ = last_name
}, dl_cb, cmd)
end
M.changeName = changeName
-- Changes about information of logged in user
-- @about New value of userFull.about, 0-255 characters
local function changeAbout(about, dl_cb, cmd)
tdcli_function ({
ID = "ChangeAbout",
about_ = about
}, dl_cb, cmd)
end
M.changeAbout = changeAbout
-- Changes username of logged in user.
-- If something changes, updateUser will be sent
-- @username New value of username. Use empty string to remove username
local function changeUsername(username, dl_cb, cmd)
tdcli_function ({
ID = "ChangeUsername",
username_ = username
}, dl_cb, cmd)
end
M.changeUsername = changeUsername
-- Changes user's phone number and sends authentication code to the new user's phone number.
-- Returns authStateWaitCode with information about sent code on success
-- @phone_number New user's phone number in any reasonable format
-- @allow_flash_call Pass True, if code can be sent via flash call to the specified phone number
-- @is_current_phone_number Pass true, if the phone number is used on the current device. Ignored if allow_flash_call is False
local function changePhoneNumber(phone_number, allow_flash_call, is_current_phone_number, dl_cb, cmd)
tdcli_function ({
ID = "ChangePhoneNumber",
phone_number_ = phone_number,
allow_flash_call_ = allow_flash_call,
is_current_phone_number_ = is_current_phone_number
}, dl_cb, cmd)
end
M.changePhoneNumber = changePhoneNumber
-- Resends authentication code sent to change user's phone number.
-- Works only if in previously received authStateWaitCode next_code_type was not null.
-- Returns authStateWaitCode on success
local function resendChangePhoneNumberCode(dl_cb, cmd)
tdcli_function ({
ID = "ResendChangePhoneNumberCode",
}, dl_cb, cmd)
end
M.resendChangePhoneNumberCode = resendChangePhoneNumberCode
-- Checks authentication code sent to change user's phone number.
-- Returns authStateOk on success
-- @code Verification code from SMS, voice call or flash call
local function checkChangePhoneNumberCode(code, dl_cb, cmd)
tdcli_function ({
ID = "CheckChangePhoneNumberCode",
code_ = code
}, dl_cb, cmd)
end
M.checkChangePhoneNumberCode = checkChangePhoneNumberCode
-- Returns all active sessions of logged in user
local function getActiveSessions(dl_cb, cmd)
tdcli_function ({
ID = "GetActiveSessions",
}, dl_cb, cmd)
end
M.getActiveSessions = getActiveSessions
-- Terminates another session of logged in user
-- @session_id Session identifier
local function terminateSession(session_id, dl_cb, cmd)
tdcli_function ({
ID = "TerminateSession",
session_id_ = session_id
}, dl_cb, cmd)
end
M.terminateSession = terminateSession
-- Terminates all other sessions of logged in user
local function terminateAllOtherSessions(dl_cb, cmd)
tdcli_function ({
ID = "TerminateAllOtherSessions",
}, dl_cb, cmd)
end
M.terminateAllOtherSessions = terminateAllOtherSessions
-- Gives or revokes all members of the group editor rights.
-- Needs creator privileges in the group
-- @group_id Identifier of the group
-- @anyone_can_edit New value of anyone_can_edit
local function toggleGroupEditors(group_id, anyone_can_edit, dl_cb, cmd)
tdcli_function ({
ID = "ToggleGroupEditors",
group_id_ = getChatId(group_id).ID,
anyone_can_edit_ = anyone_can_edit
}, dl_cb, cmd)
end
M.toggleGroupEditors = toggleGroupEditors
-- Changes username of the channel.
-- Needs creator privileges in the channel
-- @channel_id Identifier of the channel
-- @username New value of username. Use empty string to remove username
local function changeChannelUsername(channel_id, username, dl_cb, cmd)
tdcli_function ({
ID = "ChangeChannelUsername",
channel_id_ = getChatId(channel_id).ID,
username_ = username
}, dl_cb, cmd)
end
M.changeChannelUsername = changeChannelUsername
-- Gives or revokes right to invite new members to all current members of the channel.
-- Needs creator privileges in the channel.
-- Available only for supergroups
-- @channel_id Identifier of the channel
-- @anyone_can_invite New value of anyone_can_invite
local function toggleChannelInvites(channel_id, anyone_can_invite, dl_cb, cmd)
tdcli_function ({
ID = "ToggleChannelInvites",
channel_id_ = getChatId(channel_id).ID,
anyone_can_invite_ = anyone_can_invite
}, dl_cb, cmd)
end
M.toggleChannelInvites = toggleChannelInvites
-- Enables or disables sender signature on sent messages in the channel.
-- Needs creator privileges in the channel.
-- Not available for supergroups
-- @channel_id Identifier of the channel
-- @sign_messages New value of sign_messages
local function toggleChannelSignMessages(channel_id, sign_messages, dl_cb, cmd)
tdcli_function ({
ID = "ToggleChannelSignMessages",
channel_id_ = getChatId(channel_id).ID,
sign_messages_ = sign_messages
}, dl_cb, cmd)
end
M.toggleChannelSignMessages = toggleChannelSignMessages
-- Changes information about the channel.
-- Needs creator privileges in the broadcast channel or editor privileges in the supergroup channel
-- @channel_id Identifier of the channel
-- @about New value of about, 0-255 characters
local function changeChannelAbout(channel_id, about, dl_cb, cmd)
tdcli_function ({
ID = "ChangeChannelAbout",
channel_id_ = getChatId(channel_id).ID,
about_ = about
}, dl_cb, cmd)
end
M.changeChannelAbout = changeChannelAbout
-- Pins a message in a supergroup channel chat.
-- Needs editor privileges in the channel
-- @channel_id Identifier of the channel
-- @message_id Identifier of the new pinned message
-- @disable_notification True, if there should be no notification about the pinned message
local function pinChannelMessage(channel_id, message_id, disable_notification, dl_cb, cmd)
tdcli_function ({
ID = "PinChannelMessage",
channel_id_ = getChatId(channel_id).ID,
message_id_ = message_id,
disable_notification_ = disable_notification
}, dl_cb, cmd)
end
M.pinChannelMessage = pinChannelMessage
-- Removes pinned message in the supergroup channel.
-- Needs editor privileges in the channel
-- @channel_id Identifier of the channel
local function unpinChannelMessage(channel_id, dl_cb, cmd)
tdcli_function ({
ID = "UnpinChannelMessage",
channel_id_ = getChatId(channel_id).ID
}, dl_cb, cmd)
end
M.unpinChannelMessage = unpinChannelMessage
-- Reports some supergroup channel messages from a user as spam messages
-- @channel_id Channel identifier
-- @user_id User identifier
-- @message_ids Identifiers of messages sent in the supergroup by the user, the list should be non-empty
local function reportChannelSpam(channel_id, user_id, message_ids, dl_cb, cmd)
tdcli_function ({
ID = "ReportChannelSpam",
channel_id_ = getChatId(channel_id).ID,
user_id_ = user_id,
message_ids_ = message_ids -- vector
}, dl_cb, cmd)
end
M.reportChannelSpam = reportChannelSpam
-- Returns information about channel members or kicked from channel users.
-- Can be used only if channel_full->can_get_members == true
-- @channel_id Identifier of the channel
-- @filter Kind of channel users to return, defaults to channelMembersRecent
-- @offset Number of channel users to skip
-- @limit Maximum number of users be returned, can't be greater than 200
-- filter = Recent|Administrators|Kicked|Bots
local function getChannelMembers(channel_id, offset, filter, limit, dl_cb, cmd)
if not limit or limit > 200 then
limit = 200
end
tdcli_function ({
ID = "GetChannelMembers",
channel_id_ = getChatId(channel_id).ID,
filter_ = {
ID = "ChannelMembers" .. filter
},
offset_ = offset,
limit_ = limit
}, dl_cb, cmd)
end
M.getChannelMembers = getChannelMembers
-- Deletes channel along with all messages in corresponding chat.
-- Releases channel username and removes all members.
-- Needs creator privileges in the channel.
-- Channels with more than 1000 members can't be deleted
-- @channel_id Identifier of the channel
local function deleteChannel(channel_id, dl_cb, cmd)
tdcli_function ({
ID = "DeleteChannel",
channel_id_ = getChatId(channel_id).ID
}, dl_cb, cmd)
end
M.deleteChannel = deleteChannel
-- Returns list of created public channels
local function getCreatedPublicChannels(dl_cb, cmd)
tdcli_function ({
ID = "GetCreatedPublicChannels"
}, dl_cb, cmd)
end
M.getCreatedPublicChannels = getCreatedPublicChannels
-- Closes secret chat
-- @secret_chat_id Secret chat identifier
local function closeSecretChat(secret_chat_id, dl_cb, cmd)
tdcli_function ({
ID = "CloseSecretChat",
secret_chat_id_ = secret_chat_id
}, dl_cb, cmd)
end
M.closeSecretChat = closeSecretChat
-- Returns user that can be contacted to get support
local function getSupportUser(dl_cb, cmd)
tdcli_function ({
ID = "GetSupportUser",
}, dl_cb, cmd)
end
M.getSupportUser = getSupportUser
-- Returns background wallpapers
local function getWallpapers(dl_cb, cmd)
tdcli_function ({
ID = "GetWallpapers",
}, dl_cb, cmd)
end
M.getWallpapers = getWallpapers
-- Registers current used device for receiving push notifications
-- @device_token Device token
-- device_token = apns|gcm|mpns|simplePush|ubuntuPhone|blackberry
local function registerDevice(device_token, token, device_token_set, dl_cb, cmd)
local dToken = {ID = device_token .. 'DeviceToken', token_ = token}
if device_token_set then
dToken = {ID = "DeviceTokenSet", token_ = device_token_set} -- tokens:vector<DeviceToken>
end
tdcli_function ({
ID = "RegisterDevice",
device_token_ = dToken
}, dl_cb, cmd)
end
M.registerDevice = registerDevice
-- Returns list of used device tokens
local function getDeviceTokens(dl_cb, cmd)
tdcli_function ({
ID = "GetDeviceTokens",
}, dl_cb, cmd)
end
M.getDeviceTokens = getDeviceTokens
-- Changes privacy settings
-- @key Privacy key
-- @rules New privacy rules
-- @privacyKeyUserStatus Privacy key for managing visibility of the user status
-- @privacyKeyChatInvite Privacy key for managing ability of invitation of the user to chats
-- @privacyRuleAllowAll Rule to allow all users
-- @privacyRuleAllowContacts Rule to allow all user contacts
-- @privacyRuleAllowUsers Rule to allow specified users
-- @user_ids User identifiers
-- @privacyRuleDisallowAll Rule to disallow all users
-- @privacyRuleDisallowContacts Rule to disallow all user contacts
-- @privacyRuleDisallowUsers Rule to disallow all specified users
-- key = UserStatus|ChatInvite
-- rules = AllowAll|AllowContacts|AllowUsers(user_ids)|DisallowAll|DisallowContacts|DisallowUsers(user_ids)
local function setPrivacy(key, rule, allowed_user_ids, disallowed_user_ids, dl_cb, cmd)
local rules = {[0] = {ID = 'PrivacyRule' .. rule}}
if allowed_user_ids then
rules = {
{
ID = 'PrivacyRule' .. rule
},
[0] = {
ID = "PrivacyRuleAllowUsers",
user_ids_ = allowed_user_ids -- vector
},
}
end
if disallowed_user_ids then
rules = {
{
ID = 'PrivacyRule' .. rule
},
[0] = {
ID = "PrivacyRuleDisallowUsers",
user_ids_ = disallowed_user_ids -- vector
},
}
end
if allowed_user_ids and disallowed_user_ids then
rules = {
{
ID = 'PrivacyRule' .. rule
},
{
ID = "PrivacyRuleAllowUsers",
user_ids_ = allowed_user_ids
},
[0] = {
ID = "PrivacyRuleDisallowUsers",
user_ids_ = disallowed_user_ids
},
}
end
tdcli_function ({
ID = "SetPrivacy",
key_ = {
ID = 'PrivacyKey' .. key
},
rules_ = {
ID = "PrivacyRules",
rules_ = rules
},
}, dl_cb, cmd)
end
M.setPrivacy = setPrivacy
-- Returns current privacy settings
-- @key Privacy key
-- key = UserStatus|ChatInvite
local function getPrivacy(key, dl_cb, cmd)
tdcli_function ({
ID = "GetPrivacy",
key_ = {
ID = "PrivacyKey" .. key
},
}, dl_cb, cmd)
end
M.getPrivacy = getPrivacy
-- Returns value of an option by its name.
-- See list of available options on https://core.telegram.org/tdlib/options
-- @name Name of the option
local function getOption(name, dl_cb, cmd)
tdcli_function ({
ID = "GetOption",
name_ = name
}, dl_cb, cmd)
end
M.getOption = getOption
-- Sets value of an option.
-- See list of available options on https://core.telegram.org/tdlib/options.
-- Only writable options can be set
-- @name Name of the option
-- @value New value of the option
local function setOption(name, option, value, dl_cb, cmd)
tdcli_function ({
ID = "SetOption",
name_ = name,
value_ = {
ID = 'Option' .. option,
value_ = value
},
}, dl_cb, cmd)
end
M.setOption = setOption
-- Changes period of inactivity, after which the account of currently logged in user will be automatically deleted
-- @ttl New account TTL
local function changeAccountTtl(days, dl_cb, cmd)
tdcli_function ({
ID = "ChangeAccountTtl",
ttl_ = {
ID = "AccountTtl",
days_ = days
},
}, dl_cb, cmd)
end
M.changeAccountTtl = changeAccountTtl
-- Returns period of inactivity, after which the account of currently logged in user will be automatically deleted
local function getAccountTtl(dl_cb, cmd)
tdcli_function ({
ID = "GetAccountTtl",
}, dl_cb, cmd)
end
M.getAccountTtl = getAccountTtl
-- Deletes the account of currently logged in user, deleting from the server all information associated with it.
-- Account's phone number can be used to create new account, but only once in two weeks
-- @reason Optional reason of account deletion
local function deleteAccount(reason, dl_cb, cmd)
tdcli_function ({
ID = "DeleteAccount",
reason_ = reason
}, dl_cb, cmd)
end
M.deleteAccount = deleteAccount
-- Returns current chat report spam state
-- @chat_id Chat identifier
local function getChatReportSpamState(chat_id, dl_cb, cmd)
tdcli_function ({
ID = "GetChatReportSpamState",
chat_id_ = chat_id
}, dl_cb, cmd)
end
M.getChatReportSpamState = getChatReportSpamState
-- Reports chat as a spam chat or as not a spam chat.
-- Can be used only if ChatReportSpamState.can_report_spam is true.
-- After this request ChatReportSpamState.can_report_spam became false forever
-- @chat_id Chat identifier
-- @is_spam_chat If true, chat will be reported as a spam chat, otherwise it will be marked as not a spam chat
local function changeChatReportSpamState(chat_id, is_spam_chat, dl_cb, cmd)
tdcli_function ({
ID = "ChangeChatReportSpamState",
chat_id_ = chat_id,
is_spam_chat_ = is_spam_chat
}, dl_cb, cmd)
end
M.changeChatReportSpamState = changeChatReportSpamState
-- Bots only.
-- Informs server about number of pending bot updates if they aren't processed for a long time
-- @pending_update_count Number of pending updates
-- @error_message Last error's message
local function setBotUpdatesStatus(pending_update_count, error_message, dl_cb, cmd)
tdcli_function ({
ID = "SetBotUpdatesStatus",
pending_update_count_ = pending_update_count,
error_message_ = error_message
}, dl_cb, cmd)
end
M.setBotUpdatesStatus = setBotUpdatesStatus
-- Returns Ok after specified amount of the time passed
-- @seconds Number of seconds before that function returns
local function setAlarm(seconds, dl_cb, cmd)
tdcli_function ({
ID = "SetAlarm",
seconds_ = seconds
}, dl_cb, cmd)
end
M.setAlarm = setAlarm
-- Text message
-- @text Text to send
-- @disable_notification Pass true, to disable notification about the message, doesn't works in secret chats
-- @from_background Pass true, if the message is sent from background
-- @reply_markup Bots only. Markup for replying to message
-- @disable_web_page_preview Pass true to disable rich preview for link in the message text
-- @clear_draft Pass true if chat draft message should be deleted
-- @entities Bold, Italic, Code, Pre, PreCode and TextUrl entities contained in the text. Non-bot users can't use TextUrl entities. Can't be used with non-null parse_mode
-- @parse_mode Text parse mode, nullable. Can't be used along with enitities
local function sendMessage(chat_id, reply_to_message_id, disable_notification, text, disable_web_page_preview, parse_mode)
local TextParseMode = getParseMode(parse_mode)
tdcli_function ({
ID = "SendMessage",
chat_id_ = chat_id,
reply_to_message_id_ = reply_to_message_id,
disable_notification_ = disable_notification,
from_background_ = 1,
reply_markup_ = nil,
input_message_content_ = {
ID = "InputMessageText",
text_ = text,
disable_web_page_preview_ = disable_web_page_preview,
clear_draft_ = 0,
entities_ = {},
parse_mode_ = TextParseMode,
},
}, dl_cb, nil)
end
M.sendMessage = sendMessage
-- Animation message
-- @animation Animation file to send
-- @thumb Animation thumb, if available
-- @width Width of the animation, may be replaced by the server
-- @height Height of the animation, may be replaced by the server
-- @caption Animation caption, 0-200 characters
local function sendAnimation(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, animation, width, height, caption, dl_cb, cmd)
tdcli_function ({
ID = "SendMessage",
chat_id_ = chat_id,
reply_to_message_id_ = reply_to_message_id,
disable_notification_ = disable_notification,
from_background_ = from_background,
reply_markup_ = reply_markup,
input_message_content_ = {
ID = "InputMessageAnimation",
animation_ = getInputFile(animation),
--thumb_ = {
--ID = "InputThumb",
--path_ = path,
--width_ = width,
--height_ = height
--},
width_ = width or '',
height_ = height or '',
caption_ = caption or ''
},
}, dl_cb, cmd)
end
M.sendAnimation = sendAnimation
-- Audio message
-- @audio Audio file to send
-- @album_cover_thumb Thumb of the album's cover, if available
-- @duration Duration of audio in seconds, may be replaced by the server
-- @title Title of the audio, 0-64 characters, may be replaced by the server
-- @performer Performer of the audio, 0-64 characters, may be replaced by the server
-- @caption Audio caption, 0-200 characters
local function sendAudio(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, audio, duration, title, performer, caption, dl_cb, cmd)
tdcli_function ({
ID = "SendMessage",
chat_id_ = chat_id,
reply_to_message_id_ = reply_to_message_id,
disable_notification_ = disable_notification,
from_background_ = from_background,
reply_markup_ = reply_markup,
input_message_content_ = {
ID = "InputMessageAudio",
audio_ = getInputFile(audio),
--album_cover_thumb_ = {
--ID = "InputThumb",
--path_ = path,
--width_ = width,
--height_ = height
--},
duration_ = duration or '',
title_ = title or '',
performer_ = performer or '',
caption_ = caption or ''
},
}, dl_cb, cmd)
end
M.sendAudio = sendAudio
-- Document message
-- @document Document to send
-- @thumb Document thumb, if available
-- @caption Document caption, 0-200 characters
local function sendDocument(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, document, caption, dl_cb, cmd)
tdcli_function ({
ID = "SendMessage",
chat_id_ = chat_id,
reply_to_message_id_ = reply_to_message_id,
disable_notification_ = disable_notification,
from_background_ = from_background,
reply_markup_ = reply_markup,
input_message_content_ = {
ID = "InputMessageDocument",
document_ = getInputFile(document),
--thumb_ = {
--ID = "InputThumb",
--path_ = path,
--width_ = width,
--height_ = height
--},
caption_ = caption
},
}, dl_cb, cmd)
end
M.sendDocument = sendDocument
-- Photo message
-- @photo Photo to send
-- @caption Photo caption, 0-200 characters
local function sendPhoto(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, photo, caption, dl_cb, cmd)
tdcli_function ({
ID = "SendMessage",
chat_id_ = chat_id,
reply_to_message_id_ = reply_to_message_id,
disable_notification_ = disable_notification,
from_background_ = from_background,
reply_markup_ = reply_markup,
input_message_content_ = {
ID = "InputMessagePhoto",
photo_ = getInputFile(photo),
added_sticker_file_ids_ = {},
width_ = 0,
height_ = 0,
caption_ = caption
},
}, dl_cb, cmd)
end
M.sendPhoto = sendPhoto
-- Sticker message
-- @sticker Sticker to send
-- @thumb Sticker thumb, if available
local function sendSticker(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, sticker, dl_cb, cmd)
tdcli_function ({
ID = "SendMessage",
chat_id_ = chat_id,
reply_to_message_id_ = reply_to_message_id,
disable_notification_ = disable_notification,
from_background_ = from_background,
reply_markup_ = reply_markup,
input_message_content_ = {
ID = "InputMessageSticker",
sticker_ = getInputFile(sticker),
--thumb_ = {
--ID = "InputThumb",
--path_ = path,
--width_ = width,
--height_ = height
--},
},
}, dl_cb, cmd)
end
M.sendSticker = sendSticker
-- Video message
-- @video Video to send
-- @thumb Video thumb, if available
-- @duration Duration of video in seconds
-- @width Video width
-- @height Video height
-- @caption Video caption, 0-200 characters
local function sendVideo(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, video, duration, width, height, caption, dl_cb, cmd)
tdcli_function ({
ID = "SendMessage",
chat_id_ = chat_id,
reply_to_message_id_ = reply_to_message_id,
disable_notification_ = disable_notification,
from_background_ = from_background,
reply_markup_ = reply_markup,
input_message_content_ = {
ID = "InputMessageVideo",
video_ = getInputFile(video),
--thumb_ = {
--ID = "InputThumb",
--path_ = path,
--width_ = width,
--height_ = height
--},
added_sticker_file_ids_ = {},
duration_ = duration or '',
width_ = width or '',
height_ = height or '',
caption_ = caption or ''
},
}, dl_cb, cmd)
end
M.sendVideo = sendVideo
-- Voice message
-- @voice Voice file to send
-- @duration Duration of voice in seconds
-- @waveform Waveform representation of the voice in 5-bit format
-- @caption Voice caption, 0-200 characters
local function sendVoice(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, voice, duration, waveform, caption, dl_cb, cmd)
tdcli_function ({
ID = "SendMessage",
chat_id_ = chat_id,
reply_to_message_id_ = reply_to_message_id,
disable_notification_ = disable_notification,
from_background_ = from_background,
reply_markup_ = reply_markup,
input_message_content_ = {
ID = "InputMessageVoice",
voice_ = getInputFile(voice),
duration_ = duration or '',
waveform_ = waveform or '',
caption_ = caption or ''
},
}, dl_cb, cmd)
end
M.sendVoice = sendVoice
-- Message with location
-- @latitude Latitude of location in degrees as defined by sender
-- @longitude Longitude of location in degrees as defined by sender
local function sendLocation(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, latitude, longitude, dl_cb, cmd)
tdcli_function ({
ID = "SendMessage",
chat_id_ = chat_id,
reply_to_message_id_ = reply_to_message_id,
disable_notification_ = disable_notification,
from_background_ = from_background,
reply_markup_ = reply_markup,
input_message_content_ = {
ID = "InputMessageLocation",
location_ = {
ID = "Location",
latitude_ = latitude,
longitude_ = longitude
},
},
}, dl_cb, cmd)
end
M.sendLocation = sendLocation
-- Message with information about venue
-- @venue Venue to send
-- @latitude Latitude of location in degrees as defined by sender
-- @longitude Longitude of location in degrees as defined by sender
-- @title Venue name as defined by sender
-- @address Venue address as defined by sender
-- @provider Provider of venue database as defined by sender. Only "foursquare" need to be supported currently
-- @id Identifier of the venue in provider database as defined by sender
local function sendVenue(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, latitude, longitude, title, address, id, dl_cb, cmd)
tdcli_function ({
ID = "SendMessage",
chat_id_ = chat_id,
reply_to_message_id_ = reply_to_message_id,
disable_notification_ = disable_notification,
from_background_ = from_background,
reply_markup_ = reply_markup,
input_message_content_ = {
ID = "InputMessageVenue",
venue_ = {
ID = "Venue",
location_ = {
ID = "Location",
latitude_ = latitude,
longitude_ = longitude
},
title_ = title,
address_ = address,
provider_ = 'foursquare',
id_ = id
},
},
}, dl_cb, cmd)
end
M.sendVenue = sendVenue
-- User contact message
-- @contact Contact to send
-- @phone_number User's phone number
-- @first_name User first name, 1-255 characters
-- @last_name User last name
-- @user_id User identifier if known, 0 otherwise
local function sendContact(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, phone_number, first_name, last_name, user_id, dl_cb, cmd)
tdcli_function ({
ID = "SendMessage",
chat_id_ = chat_id,
reply_to_message_id_ = reply_to_message_id,
disable_notification_ = disable_notification,
from_background_ = from_background,
reply_markup_ = reply_markup,
input_message_content_ = {
ID = "InputMessageContact",
contact_ = {
ID = "Contact",
phone_number_ = phone_number,
first_name_ = first_name,
last_name_ = last_name,
user_id_ = user_id
},
},
}, dl_cb, cmd)
end
M.sendContact = sendContact
-- Message with a game
-- @bot_user_id User identifier of a bot owned the game
-- @game_short_name Game short name
local function sendGame(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, bot_user_id, game_short_name, dl_cb, cmd)
tdcli_function ({
ID = "SendMessage",
chat_id_ = chat_id,
reply_to_message_id_ = reply_to_message_id,
disable_notification_ = disable_notification,
from_background_ = from_background,
reply_markup_ = reply_markup,
input_message_content_ = {
ID = "InputMessageGame",
bot_user_id_ = bot_user_id,
game_short_name_ = game_short_name
},
}, dl_cb, cmd)
end
M.sendGame = sendGame
-- Forwarded message
-- @from_chat_id Chat identifier of the message to forward
-- @message_id Identifier of the message to forward
local function sendForwarded(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, from_chat_id, message_id, dl_cb, cmd)
tdcli_function ({
ID = "SendMessage",
chat_id_ = chat_id,
reply_to_message_id_ = reply_to_message_id,
disable_notification_ = disable_notification,
from_background_ = from_background,
reply_markup_ = reply_markup,
input_message_content_ = {
ID = "InputMessageForwarded",
from_chat_id_ = from_chat_id,
message_id_ = message_id
},
}, dl_cb, cmd)
end
M.sendForwarded = sendForwarded
return M
| gpl-2.0 |
mercury233/ygopro-scripts | c47658964.lua | 2 | 1787 | --紅蓮の炎壁
function c47658964.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCost(c47658964.cost)
e1:SetTarget(c47658964.target)
e1:SetOperation(c47658964.activate)
c:RegisterEffect(e1)
end
function c47658964.cfilter(c)
return c:IsSetCard(0x39) and c:IsAbleToRemoveAsCost()
end
function c47658964.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c47658964.cfilter,tp,LOCATION_GRAVE,0,1,nil) end
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
if Duel.IsPlayerAffectedByEffect(tp,59822133) then ft=1 end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectMatchingCard(tp,c47658964.cfilter,tp,LOCATION_GRAVE,0,1,ft,nil)
e:SetLabel(g:GetCount())
Duel.Remove(g,POS_FACEUP,REASON_COST)
end
function c47658964.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsPlayerCanSpecialSummonMonster(tp,47658965,0x39,TYPES_TOKEN_MONSTER,0,0,1,RACE_PYRO,ATTRIBUTE_FIRE,POS_FACEUP_DEFENSE) end
Duel.SetOperationInfo(0,CATEGORY_TOKEN,nil,e:GetLabel(),0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,e:GetLabel(),0,0)
end
function c47658964.activate(e,tp,eg,ep,ev,re,r,rp)
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
if ft<e:GetLabel() or not Duel.IsPlayerCanSpecialSummonMonster(tp,47658965,0x39,TYPES_TOKEN_MONSTER,0,0,1,RACE_PYRO,ATTRIBUTE_FIRE,POS_FACEUP_DEFENSE)
or (e:GetLabel()>1 and Duel.IsPlayerAffectedByEffect(tp,59822133)) then return end
for i=1,e:GetLabel() do
local token=Duel.CreateToken(tp,47658965)
Duel.SpecialSummonStep(token,0,tp,tp,false,false,POS_FACEUP_DEFENSE)
end
Duel.SpecialSummonComplete()
end
| gpl-2.0 |
Zenny89/darkstar | scripts/zones/Phomiuna_Aqueducts/npcs/_0rm.lua | 17 | 1337 | -----------------------------------
-- Area: Phomiuna_Aqueducts
-- NPC: _0rm (Oil lamp)
-- Notes: Opens South door at J-7 from inside.
-- @pos -63.703 -26.227 83.000 27
-----------------------------------
package.loaded["scripts/zones/Phomiuna_Aqueducts/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/missions");
require("scripts/zones/Phomiuna_Aqueducts/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local DoorOffset = npc:getID() - 1;
if (GetNPCByID(DoorOffset):getAnimation() == 9) then
if (player:getZPos() < 84) then
npc:openDoor(15); -- lamp animation
GetNPCByID(DoorOffset):openDoor(7); -- _0rf
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end; | gpl-3.0 |
mercury233/ygopro-scripts | c98416533.lua | 2 | 2906 | --メルフィー・ワラビィ
function c98416533.initial_effect(c)
--to hand
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(98416533,0))
e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SPECIAL_SUMMON+CATEGORY_DECKDES)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1,98416533)
e1:SetCondition(c98416533.thcon)
e1:SetTarget(c98416533.thtg)
e1:SetOperation(c98416533.thop)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e2)
local e3=e1:Clone()
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetCode(EVENT_BE_BATTLE_TARGET)
e3:SetCondition(c98416533.thcon2)
c:RegisterEffect(e3)
--spsummon
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(98416533,1))
e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e4:SetCode(EVENT_PHASE+PHASE_END)
e4:SetRange(LOCATION_HAND)
e4:SetCountLimit(1,98416534)
e4:SetCondition(c98416533.spcon)
e4:SetTarget(c98416533.sptg)
e4:SetOperation(c98416533.spop)
c:RegisterEffect(e4)
end
function c98416533.cfilter(c,sp)
return c:IsSummonPlayer(sp)
end
function c98416533.thcon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c98416533.cfilter,1,nil,1-tp)
end
function c98416533.thcon2(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetAttacker():IsControler(1-tp)
end
function c98416533.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:IsAbleToHand() end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,c,1,0,0)
end
function c98416533.spfilter(c,e,tp)
return c:IsSetCard(0x146) and not c:IsCode(98416533) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c98416533.thop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local g=Duel.GetMatchingGroup(c98416533.spfilter,tp,LOCATION_DECK,0,nil,e,tp)
if c:IsRelateToEffect(e) and Duel.SendtoHand(c,nil,REASON_EFFECT)~=0 and c:IsLocation(LOCATION_HAND)
and Duel.GetLocationCount(tp,LOCATION_MZONE)>1
and not Duel.IsPlayerAffectedByEffect(tp,59822133)
and g:GetClassCount(Card.GetCode)>1
and Duel.SelectYesNo(tp,aux.Stringid(98416533,2)) then
Duel.BreakEffect()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=g:SelectSubGroup(tp,aux.dncheck,false,2,2)
Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEUP)
end
end
function c98416533.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==tp
end
function c98416533.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,0)
end
function c98416533.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) then
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c73639099.lua | 2 | 3243 | --セラの蟲惑魔
function c73639099.initial_effect(c)
--link summon
aux.AddLinkProcedure(c,c73639099.matfilter,1,1)
c:EnableReviveLimit()
--immune
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e1:SetCode(EFFECT_IMMUNE_EFFECT)
e1:SetRange(LOCATION_MZONE)
e1:SetCondition(c73639099.imcon)
e1:SetValue(c73639099.efilter)
c:RegisterEffect(e1)
--
--special summon
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(73639099,0))
e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e3:SetProperty(EFFECT_FLAG_DELAY)
e3:SetCode(EVENT_CHAINING)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1,73639099)
e3:SetCondition(c73639099.spcon)
e3:SetTarget(c73639099.sptg)
e3:SetOperation(c73639099.spop)
c:RegisterEffect(e3)
--set
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(73639099,1))
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e4:SetProperty(EFFECT_FLAG_DELAY)
e4:SetCode(EVENT_CHAINING)
e4:SetRange(LOCATION_MZONE)
e4:SetCountLimit(1,73639100)
e4:SetCondition(c73639099.setcon)
e4:SetTarget(c73639099.settg)
e4:SetOperation(c73639099.setop)
c:RegisterEffect(e4)
end
function c73639099.matfilter(c)
return c:IsLinkSetCard(0x108a) and not c:IsLinkType(TYPE_LINK)
end
function c73639099.imcon(e)
return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
end
function c73639099.efilter(e,te)
return te:IsActiveType(TYPE_TRAP)
end
function c73639099.spcon(e,tp,eg,ep,ev,re,r,rp)
return re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:GetHandler():GetType()==TYPE_TRAP
end
function c73639099.cfilter(c,code)
return c:IsFaceup() and c:IsCode(code)
end
function c73639099.spfilter(c,e,tp)
return c:IsSetCard(0x108a) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
and not Duel.IsExistingMatchingCard(c73639099.cfilter,tp,LOCATION_ONFIELD,0,1,nil,c:GetCode())
end
function c73639099.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c73639099.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function c73639099.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,c73639099.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
function c73639099.setcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local rc=re:GetHandler()
return re:IsActiveType(TYPE_MONSTER) and rc~=c and rc:IsSetCard(0x108a) and rc:IsControler(tp)
end
function c73639099.setfilter(c)
return c:IsSetCard(0x4c,0x89) and c:GetType()==TYPE_TRAP and c:IsSSetable()
end
function c73639099.settg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c73639099.setfilter,tp,LOCATION_DECK,0,1,nil) end
end
function c73639099.setop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET)
local g=Duel.SelectMatchingCard(tp,c73639099.setfilter,tp,LOCATION_DECK,0,1,1,nil)
local tc=g:GetFirst()
if tc then
Duel.SSet(tp,tc)
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c99157310.lua | 2 | 3548 | --ティンダングル・ドロネー
function c99157310.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_DESTROY+CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_BATTLE_DAMAGE)
e1:SetCondition(c99157310.condition)
e1:SetTarget(c99157310.target)
e1:SetOperation(c99157310.activate)
c:RegisterEffect(e1)
--special summon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(99157310,0))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCode(EVENT_FREE_CHAIN)
e2:SetRange(LOCATION_GRAVE)
e2:SetHintTiming(0,TIMING_END_PHASE)
e2:SetCondition(c99157310.spcon)
e2:SetCost(aux.bfgcost)
e2:SetTarget(c99157310.sptg)
e2:SetOperation(c99157310.spop)
c:RegisterEffect(e2)
end
function c99157310.cfilter1(c)
return c:IsSetCard(0x10b) and c:IsType(TYPE_MONSTER)
end
function c99157310.condition(e,tp,eg,ep,ev,re,r,rp)
return ep==tp and Duel.GetAttacker():IsControler(1-tp)
and Duel.IsExistingMatchingCard(c99157310.cfilter1,tp,LOCATION_GRAVE,0,3,nil)
end
function c99157310.filter(c,e,tp)
return c:IsCode(75119040) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and Duel.GetLocationCountFromEx(tp,tp,nil,c)>0
end
function c99157310.target(e,tp,eg,ep,ev,re,r,rp,chk)
local tg=Duel.GetAttacker()
if chk==0 then return tg:IsOnField()
and Duel.IsExistingMatchingCard(c99157310.filter,tp,LOCATION_EXTRA,0,1,nil,e,tp) end
Duel.SetTargetCard(tg)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,tg,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function c99157310.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsRelateToBattle() and Duel.Destroy(tc,REASON_EFFECT)~=0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c99157310.filter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
end
end
function c99157310.cfilter2(c)
return c:GetSequence()>=5
end
function c99157310.spcon(e,tp,eg,ep,ev,re,r,rp)
return not Duel.IsExistingMatchingCard(c99157310.cfilter2,tp,LOCATION_MZONE,0,1,nil)
end
function c99157310.spfilter(c,e,tp)
return c:IsSetCard(0x10b) and c:IsCanBeEffectTarget(e) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEDOWN_DEFENSE)
end
function c99157310.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return false end
local g=Duel.GetMatchingGroup(c99157310.spfilter,tp,LOCATION_GRAVE,0,nil,e,tp)
if chk==0 then return not Duel.IsPlayerAffectedByEffect(tp,59822133)
and Duel.GetLocationCount(tp,LOCATION_MZONE)>2
and g:GetClassCount(Card.GetCode)>2 end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tg=g:SelectSubGroup(tp,aux.dncheck,false,3,3)
Duel.SetTargetCard(tg)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,tg,tg:GetCount(),0,0)
end
function c99157310.spop(e,tp,eg,ep,ev,re,r,rp)
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e)
if ft<=0 or g:GetCount()==0 or (g:GetCount()>1 and Duel.IsPlayerAffectedByEffect(tp,59822133)) then return end
if g:GetCount()<=ft then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEDOWN_DEFENSE)
Duel.ConfirmCards(1-tp,g)
else
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=g:Select(tp,ft,ft,nil)
Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEDOWN_DEFENSE)
Duel.ConfirmCards(1-tp,sg)
end
end
| gpl-2.0 |
Zenny89/darkstar | scripts/zones/Kazham/npcs/Tatapp.lua | 15 | 11872 | -----------------------------------
-- Area: Kazham
-- NPC: Tatapp
-- Standard Merchant NPC
-----------------------------------
package.loaded["scripts/zones/Kazham/TextIDs"] = nil;
require("scripts/zones/Kazham/TextIDs");
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(pathfind.first(path));
onPath(npc);
end;
function onPath(npc)
pathfind.patrol(npc, path);
end;
-----------------------------------
-- onTrade Action
-----------------------------------
-- 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
function onTrade(player,npc,trade)
local OpoOpoAndIStatus = player:getQuestStatus(OUTLANDS, THE_OPO_OPO_AND_I);
local progress = player:getVar("OPO_OPO_PROGRESS");
local failed = player:getVar("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(0x00E1);
elseif badtrade then
player:startEvent(0x00EB);
end
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local OpoOpoAndIStatus = player:getQuestStatus(OUTLANDS, THE_OPO_OPO_AND_I);
local progress = player:getVar("OPO_OPO_PROGRESS");
local failed = player:getVar("OPO_OPO_FAILED");
local retry = player:getVar("OPO_OPO_RETRY");
if (OpoOpoAndIStatus == QUEST_ACCEPTED) then
if retry >= 1 then -- has failed on future npc so disregard previous successful trade
player:startEvent(0x00CB);
npc:wait(-1);
elseif (progress == 6 or failed == 7) then
player:startEvent(0x00D4); -- asking for blackened toad
elseif (progress >= 7 or failed >= 8) then
player:startEvent(0x00F8); -- happy with blackened toad
end
else
player:startEvent(0x00CB);
npc:wait(-1);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option,npc)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x00E1) then -- correct trade, onto next opo
if player:getVar("OPO_OPO_PROGRESS") == 6 then
player:tradeComplete();
player:setVar("OPO_OPO_PROGRESS",7);
player:setVar("OPO_OPO_FAILED",0);
else
player:setVar("OPO_OPO_FAILED",8);
end
elseif (csid == 0x00EB) then -- wrong trade, restart at first opo
player:setVar("OPO_OPO_FAILED",1);
player:setVar("OPO_OPO_RETRY",7);
else
npc:wait(0);
end
end;
| gpl-3.0 |
mercury233/ygopro-scripts | c34365442.lua | 2 | 3730 | --Evil★Twin イージーゲーム
function c34365442.initial_effect(c)
--activate
local e0=Effect.CreateEffect(c)
e0:SetDescription(aux.Stringid(34365442,0))
e0:SetType(EFFECT_TYPE_ACTIVATE)
e0:SetCode(EVENT_FREE_CHAIN)
e0:SetCost(aux.TRUE)
c:RegisterEffect(e0)
--attack
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(34365442,1))
e1:SetCategory(CATEGORY_ATKCHANGE+CATEGORY_DEFCHANGE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(TIMING_DAMAGE_STEP)
e1:SetCountLimit(1,34365442)
e1:SetCost(c34365442.cost1)
e1:SetTarget(c34365442.target1)
e1:SetOperation(c34365442.activate1)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetRange(LOCATION_SZONE)
c:RegisterEffect(e2)
--disable
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(34365442,2))
e3:SetCategory(CATEGORY_DISABLE)
e3:SetType(EFFECT_TYPE_ACTIVATE)
e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL)
e3:SetCode(EVENT_CHAINING)
e3:SetCountLimit(1,34365442)
e3:SetCondition(c34365442.condition2)
e3:SetCost(c34365442.cost2)
e3:SetTarget(c34365442.target2)
e3:SetOperation(c34365442.activate2)
c:RegisterEffect(e3)
local e4=e3:Clone()
e4:SetType(EFFECT_TYPE_QUICK_O)
e4:SetRange(LOCATION_SZONE)
c:RegisterEffect(e4)
end
function c34365442.tgfilter1(c)
return c:IsSetCard(0x152,0x153) and c:IsFaceup()
end
function c34365442.cfilter1(c,tp)
return c:IsSetCard(0x152,0x153) and c:GetBaseAttack()>0
and (c:IsControler(tp) or c:IsFaceup()) and not c:IsStatus(STATUS_BATTLE_DESTROYED)
and Duel.IsExistingTarget(c34365442.tgfilter1,tp,LOCATION_MZONE,0,1,c)
end
function c34365442.cost1(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckReleaseGroup(tp,c34365442.cfilter1,1,nil,tp) end
local sg=Duel.SelectReleaseGroup(tp,c34365442.cfilter1,1,1,nil,tp)
e:SetLabel(sg:GetFirst():GetBaseAttack())
Duel.Release(sg,REASON_COST)
end
function c34365442.target1(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c34365442.tgfilter1(c) end
if chk==0 then return true end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
Duel.SelectTarget(tp,c34365442.tgfilter1,tp,LOCATION_MZONE,0,1,1,nil)
end
function c34365442.activate1(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if tc:IsFaceup() and tc:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(e:GetLabel())
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
end
end
function c34365442.condition2(e,tp,eg,ep,ev,re,r,rp)
if not Duel.IsChainDisablable(ev) then return false end
if re:IsHasCategory(CATEGORY_NEGATE)
and Duel.GetChainInfo(ev-1,CHAININFO_TRIGGERING_EFFECT):IsHasType(EFFECT_TYPE_ACTIVATE) then return false end
local ex,tg,tc=Duel.GetOperationInfo(ev,CATEGORY_DESTROY)
return ex and tg~=nil and tc+tg:FilterCount(Card.IsOnField,nil)-tg:GetCount()>0
end
function c34365442.cfilter2(c,tp)
return c:IsSetCard(0x152,0x153)
and (c:IsControler(tp) or c:IsFaceup()) and not c:IsStatus(STATUS_BATTLE_DESTROYED)
end
function c34365442.cost2(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckReleaseGroup(tp,c34365442.cfilter2,1,nil,tp) end
local sg=Duel.SelectReleaseGroup(tp,c34365442.cfilter2,1,1,nil,tp)
Duel.Release(sg,REASON_COST)
end
function c34365442.target2(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_DISABLE,eg,1,0,0)
end
function c34365442.activate2(e,tp,eg,ep,ev,re,r,rp)
Duel.NegateEffect(ev)
end
| gpl-2.0 |
mercury233/ygopro-scripts | c42110604.lua | 4 | 2142 | --HSRチャンバライダー
function c42110604.initial_effect(c)
c:SetSPSummonOnce(42110604)
--synchro summon
aux.AddSynchroProcedure(c,nil,aux.NonTuner(nil),1)
c:EnableReviveLimit()
--extra attack
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_EXTRA_ATTACK)
e1:SetValue(1)
c:RegisterEffect(e1)
--attack up
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(42110604,0))
e2:SetCategory(CATEGORY_ATKCHANGE)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e2:SetCode(EVENT_BATTLE_START)
e2:SetCondition(c42110604.condition)
e2:SetOperation(c42110604.operation)
c:RegisterEffect(e2)
--tohand
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(42110604,1))
e3:SetCategory(CATEGORY_TOHAND)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetCode(EVENT_TO_GRAVE)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e3:SetTarget(c42110604.thtg)
e3:SetOperation(c42110604.thop)
c:RegisterEffect(e3)
end
function c42110604.condition(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsRelateToBattle()
end
function c42110604.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsFaceup() and c:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(200)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_DISABLE)
c:RegisterEffect(e1)
end
end
function c42110604.thfilter(c)
return c:IsFaceup() and c:IsSetCard(0x2016) and c:IsAbleToHand()
end
function c42110604.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and c42110604.thfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c42110604.thfilter,tp,LOCATION_REMOVED,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectTarget(tp,c42110604.thfilter,tp,LOCATION_REMOVED,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function c42110604.thop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c2830693.lua | 3 | 2762 | --虹クリボー
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)
--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+RESETS_STANDARD)
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+RESETS_STANDARD)
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+RESETS_REDIRECT)
e1:SetValue(LOCATION_REMOVED)
c:RegisterEffect(e1,true)
end
end
| gpl-2.0 |
Zenny89/darkstar | scripts/globals/items/serving_of_emperor_roe.lua | 35 | 1354 | -----------------------------------------
-- ID: 4275
-- Item: serving_of_emperor_roe
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Health 8
-- Magic 8
-- Dexterity 4
-- Mind -4
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,1800,4275);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 8);
target:addMod(MOD_MP, 8);
target:addMod(MOD_DEX, 4);
target:addMod(MOD_MND, -4);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 8);
target:delMod(MOD_MP, 8);
target:delMod(MOD_DEX, 4);
target:delMod(MOD_MND, -4);
end;
| gpl-3.0 |
CyberSecurityBot/Cyber | system/commands.lua | 2 | 32007 | URL = require "socket.url"
http = require "socket.http"
https = require "ssl.https"
ltn12 = require "ltn12"
serpent = (loadfile "./system/libs/serpent.lua")()
feedparser = (loadfile "./system/libs/feedparser.lua")()
json = (loadfile "./system/libs/JSON.lua")()
mimetype = (loadfile "./system/libs/mimetype.lua")()
redis = (loadfile "./system/libs/redis.lua")()
JSON = (loadfile "./system/libs/dkjson.lua")()
http.TIMEOUT = 10
function get_receiver(msg)
if msg.to.type == 'user' then
return 'user#id'..msg.from.id
end
if msg.to.type == 'chat' then
return 'chat#id'..msg.to.id
end
if msg.to.type == 'encr_chat' then
return msg.to.print_name
end
if msg.to.type == 'channel' then
return 'channel#id'..msg.to.id
end
end
function is_chat_msg( msg )
if msg.to.type == 'chat' then
return true
end
return false
end
function string.random(length)
local str = "";
for i = 1, length do
math.random(97, 122)
str = str..string.char(math.random(97, 122));
end
return str;
end
function string.random(length)
local str = "";
for i = 1, length do
math.random(97, 122)
str = str..string.char(math.random(97, 122));
end
return str;
end
function string:split(sep)
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
self:gsub(pattern, function(c) fields[#fields+1] = c end)
return fields
end
-- DEPRECATED
function string.trim(s)
print("string.trim(s) is DEPRECATED use string:trim() instead")
return s:gsub("^%s*(.-)%s*$", "%1")
end
-- Removes spaces
function string:trim()
return self:gsub("^%s*(.-)%s*$", "%1")
end
function get_http_file_name(url, headers)
-- Eg: foo.var
local file_name = url:match("[^%w]+([%.%w]+)$")
-- Any delimited alphanumeric on the url
file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$")
-- Random name, hope content-type works
file_name = file_name or str:random(5)
local content_type = headers["content-type"]
local extension = nil
if content_type then
extension = mimetype.get_mime_extension(content_type)
end
if extension then
file_name = file_name.."."..extension
end
local disposition = headers["content-disposition"]
if disposition then
-- attachment; filename=CodeCogsEqn.png
file_name = disposition:match('filename=([^;]+)') or file_name
end
return file_name
end
-- Saves file to /tmp/. If file_name isn't provided,
-- will get the text after the last "/" for filename
-- and content-type for extension
function download_to_file(url, file_name)
print("(@csgroup) file has been saved in: "..url)
local respbody = {}
local options = {
url = url,
sink = ltn12.sink.table(respbody),
redirect = true
}
-- nil, code, headers, status
local response = nil
if url:starts('https') then
options.redirect = false
response = {https.request(options)}
else
response = {http.request(options)}
end
local code = response[2]
local headers = response[3]
local status = response[4]
if code ~= 200 then return nil end
file_name = file_name or get_http_file_name(url, headers)
local file_path = "data/tmp/"..file_name
print("Saved to: "..file_path)
file = io.open(file_path, "w+")
file:write(table.concat(respbody))
file:close()
return file_path
end
function vardump(value)
print(serpent.block(value, {comment=false}))
end
-- taken from http://stackoverflow.com/a/11130774/3163199
function scandir(directory)
local i, t, popen = 0, {}, io.popen
for filename in popen('ls -a "'..directory..'"'):lines() do
i = i + 1
t[i] = filename
end
return t
end
-- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen
function run_command(str)
local cmd = io.popen(str)
local result = cmd:read('*all')
cmd:close()
return result
end
-- User has privileges
function is_sudo(msg)
local var = false
-- Check users id in config
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_admin(msg)
local var = false
-- Check users id in config
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_vip(msg)
local var = false
-- Check users id in config
for v,user in pairs(_config.vip_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_support(msg)
local var = false
-- Check users id in config
for v,user in pairs(_config.support_gp) do
if user == msg.from.id then
var = true
end
end
return var
end
-- Returns the name of the sender
function get_name(msg)
local name = msg.from.first_name
if name == nil then
name = msg.from.id
end
return name
end
-- Returns at table of lua files inside plugins
function plugins_names( )
local files = {}
for k, v in pairs(scandir("plugins")) do
-- Ends with .lua
if (v:match(".lua$")) then
table.insert(files, v)
end
end
return files
end
-- Function name explains what it does.
function file_exists(name)
local f = io.open(name,"r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
-- Save into file the data serialized for lua.
-- Set uglify true to minify the file.
function serialize_to_file(data, file, uglify)
file = io.open(file, 'w+')
local serialized
if not uglify then
serialized = serpent.block(data, {
comment = false,
name = '_'
})
else
serialized = serpent.dump(data)
end
file:write(serialized)
file:close()
end
-- Returns true if the string is empty
function string:isempty()
return self == nil or self == ''
end
-- Returns true if the string is blank
function string:isblank()
self = self:trim()
return self:isempty()
end
-- DEPRECATED!!!!!
function string.starts(String, Start)
print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead")
return Start == string.sub(String,1,string.len(Start))
end
-- Returns true if String starts with Start
function string:starts(text)
return text == string.sub(self,1,string.len(text))
end
-- Send image to user and delete it when finished.
-- cb_function and cb_extra are optionals callback
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_photo_from_url(receiver, url, cb_function, cb_extra)
-- If callback not provided
cb_function = cb_function or ok_cb
cb_extra = cb_extra or false
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Error downloading the image'
send_msg(receiver, text, cb_function, cb_extra)
else
print("File path: "..file_path)
_send_photo(receiver, file_path, cb_function, cb_extra)
end
end
-- Same as send_photo_from_url but as callback function
function send_photo_from_url_callback(cb_extra, success, result)
local receiver = cb_extra.receiver
local url = cb_extra.url
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Error downloading the image'
send_msg(receiver, text, ok_cb, false)
else
print("File path: "..file_path)
_send_photo(receiver, file_path, ok_cb, false)
end
end
-- Send multiple images asynchronous.
-- param urls must be a table.
function send_photos_from_url(receiver, urls)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = nil
}
send_photos_from_url_callback(cb_extra)
end
-- Use send_photos_from_url.
-- This function might be difficult to understand.
function send_photos_from_url_callback(cb_extra, success, result)
-- cb_extra is a table containing receiver, urls and remove_path
local receiver = cb_extra.receiver
local urls = cb_extra.urls
local remove_path = cb_extra.remove_path
-- The previously image to remove
if remove_path ~= nil then
os.remove(remove_path)
print("Deleted: "..remove_path)
end
-- Nil or empty, exit case (no more urls)
if urls == nil or #urls == 0 then
return false
end
-- Take the head and remove from urls table
local head = table.remove(urls, 1)
local file_path = download_to_file(head, false)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = file_path
}
-- Send first and postpone the others as callback
send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra)
end
-- Callback to remove a file
function rmtmp_cb(cb_extra, success, result)
local file_path = cb_extra.file_path
local cb_function = cb_extra.cb_function or ok_cb
local cb_extra = cb_extra.cb_extra
if file_path ~= nil then
os.remove(file_path)
print("Deleted: "..file_path)
end
-- Finally call the callback
cb_function(cb_extra, success, result)
end
-- Send document to user and delete it when finished.
-- cb_function and cb_extra are optionals callback
function _send_document(receiver, file_path, cb_function, cb_extra)
local cb_extra = {
file_path = file_path,
cb_function = cb_function or ok_cb,
cb_extra = cb_extra or false
}
-- Call to remove with optional callback
send_document(receiver, file_path, rmtmp_cb, cb_extra)
end
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_document_from_url(receiver, url, cb_function, cb_extra)
local file_path = download_to_file(url, false)
print("File path: "..file_path)
_send_document(receiver, file_path, cb_function, cb_extra)
end
-- Parameters in ?a=1&b=2 style
function format_http_params(params, is_get)
local str = ''
-- If is get add ? to the beginning
if is_get then str = '?' end
local first = true -- Frist param
for k,v in pairs (params) do
if v then -- nil value
if first then
first = false
str = str..k.. "="..v
else
str = str.."&"..k.. "="..v
end
end
end
return str
end
-- Check if user can use the plugin and warns user
-- Returns true if user was warned and false if not warned (is allowed)
function warns_user_not_allowed(plugin, msg)
if not user_allowed(plugin, msg) then
local text = 'This plugin requires privileged user'
local receiver = get_receiver(msg)
send_msg(receiver, text, ok_cb, false)
return true
else
return false
end
end
-- Check if user can use the plugin
function user_allowed(plugin, msg)
if plugin.privileged and not is_sudo(msg) then
return false
end
return true
end
function send_order_msg(destination, msgs)
local cb_extra = {
destination = destination,
msgs = msgs
}
send_order_msg_callback(cb_extra, true)
end
function send_order_msg_callback(cb_extra, success, result)
local destination = cb_extra.destination
local msgs = cb_extra.msgs
local file_path = cb_extra.file_path
if file_path ~= nil then
os.remove(file_path)
print("Deleted: " .. file_path)
end
if type(msgs) == 'string' then
send_large_msg(destination, msgs)
elseif type(msgs) ~= 'table' then
return
end
if #msgs < 1 then
return
end
local msg = table.remove(msgs, 1)
local new_cb_extra = {
destination = destination,
msgs = msgs
}
if type(msg) == 'string' then
send_msg(destination, msg, send_order_msg_callback, new_cb_extra)
elseif type(msg) == 'table' then
local typ = msg[1]
local nmsg = msg[2]
new_cb_extra.file_path = nmsg
if typ == 'document' then
send_document(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'image' or typ == 'photo' then
send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'audio' then
send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'video' then
send_video(destination, nmsg, send_order_msg_callback, new_cb_extra)
else
send_file(destination, nmsg, send_order_msg_callback, new_cb_extra)
end
end
end
-- Same as send_large_msg_callback but friendly params
function send_large_msg(destination, text)
local cb_extra = {
destination = destination,
text = text
}
send_large_msg_callback(cb_extra, true)
end
-- If text is longer than 4096 chars, send multiple msg.
-- https://core.telegram.org/method/messages.sendMessage
function send_large_msg_callback(cb_extra, success, result)
local text_max = 4096
local destination = cb_extra.destination
local text = cb_extra.text
if not text or type(text) == 'boolean' then
return
end
local text_len = string.len(text)
local num_msg = math.ceil(text_len / text_max)
if num_msg <= 1 then
send_msg(destination, text, ok_cb, false)
else
local my_text = string.sub(text, 1, 4096)
local rest = string.sub(text, 4096, text_len)
local cb_extra = {
destination = destination,
text = rest
}
send_msg(destination, my_text, send_large_msg_callback, cb_extra)
end
end
function post_large_msg(destination, text)
local cb_extra = {
destination = destination,
text = text
}
post_large_msg_callback(cb_extra, true)
end
function post_large_msg_callback(cb_extra, success, result)
local text_max = 4096
local destination = cb_extra.destination
local text = cb_extra.text
local text_len = string.len(text)
local num_msg = math.ceil(text_len / text_max)
if num_msg <= 1 then
post_msg(destination, text, ok_cb, false)
else
local my_text = string.sub(text, 1, 4096)
local rest = string.sub(text, 4096, text_len)
local cb_extra = {
destination = destination,
text = rest
}
post_msg(destination, my_text, post_large_msg_callback, cb_extra)
end
end
-- Returns a table with matches or nil
function match_pattern(pattern, text, lower_case)
if text then
local matches = {}
if lower_case then
matches = { string.match(text:lower(), pattern) }
else
matches = { string.match(text, pattern) }
end
if next(matches) then
return matches
end
end
-- nil
end
-- Function to read data from files
function load_from_file(file, default_data)
local f = io.open(file, "r+")
-- If file doesn't exists
if f == nil then
-- Create a new empty table
default_data = default_data or {}
serialize_to_file(default_data, file)
print ('Created file', file)
else
print ('Data loaded from file', file)
f:close()
end
return loadfile (file)()
end
-- See http://stackoverflow.com/a/14899740
function unescape_html(str)
local map = {
["lt"] = "<",
["gt"] = ">",
["amp"] = "&",
["quot"] = '"',
["apos"] = "'"
}
new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s)
var = map[s] or n == "#" and string.char(s)
var = var or n == "#x" and string.char(tonumber(s,16))
var = var or orig
return var
end)
return new
end
-- Workarrond to format the message as previously was received
function backward_msg_format (msg)
for k,name in pairs({'from', 'to'}) do
local longid = msg[name].id
msg[name].id = msg[name].peer_id
msg[name].peer_id = longid
msg[name].type = msg[name].peer_type
end
if msg.action and (msg.action.user or msg.action.link_issuer) then
local user = msg.action.user or msg.action.link_issuer
local longid = user.id
user.id = user.peer_id
user.peer_id = longid
user.type = user.peer_type
end
return msg
end
--Table Sort
function pairsByKeys (t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0 -- iterator variable
local iter = function () -- iterator function
i = i + 1
if a[i] == nil then return nil
else return a[i], t[a[i]]
end
end
return iter
end
--End Table Sort
--Check if this chat is realm or not
function is_realm(msg)
local var = false
local realms = 'realms'
local data = load_data(_config.moderation.data)
local chat = msg.to.id
if data[tostring(realms)] then
if data[tostring(realms)][tostring(chat)] then
var = true
end
return var
end
end
--Check if this chat is a group or not
function is_group(msg)
local var = false
local data = load_data(_config.moderation.data)
local groups = 'groups'
local chat = msg.to.id
if data[tostring(groups)] then
if data[tostring(groups)][tostring(chat)] then
if msg.to.type == 'chat' then
var = true
end
end
return var
end
end
function is_super_group(msg)
local var = false
local data = load_data(_config.moderation.data)
local groups = 'groups'
local chat = msg.to.id
if data[tostring(groups)] then
if data[tostring(groups)][tostring(chat)] then
if msg.to.type == 'channel' then
var = true
end
return var
end
end
end
function is_log_group(msg)
local var = false
local data = load_data(_config.moderation.data)
local GBan_log = 'GBan_log'
if data[tostring(GBan_log)] then
if data[tostring(GBan_log)][tostring(msg.to.id)] then
if msg.to.type == 'channel' then
var = true
end
return var
end
end
end
--Trying to increase 5% of speed bye @P9999
function savelog(group, logtxt)
local text = (os.date("[ %c ]=> "..logtxt.."\n \n"))
local file = io.open("./system/chats/logs/"..group.."log.txt", "a")
file:write(text)
file:close()
end
function user_print_name(user)
if user.print_name then
return user.print_name
end
local text = ''
if user.first_name then
text = user.last_name..' '
end
if user.lastname then
text = text..user.last_name
end
return text
end
--Check if user is the owner of that group or not
function is_owner(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['set_owner'] then
if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then
var = true
end
end
end
local hash = 'support'
local support = redis:sismember(hash, user)
if support then
var = true
end
if data['admins'] then
if data['admins'][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_owner2(user_id, group_id)
local var = false
local data = load_data(_config.moderation.data)
local user = user_id
if data[tostring(group_id)] then
if data[tostring(group_id)]['set_owner'] then
if data[tostring(group_id)]['set_owner'] == tostring(user_id) then
var = true
end
end
end
local hash = 'support'
local support = redis:sismember(hash, user)
if support then
var = true
end
if data['admins'] then
if data['admins'][tostring(user_id)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == user_id then
var = true
end
end
return var
end
--Check if user is admin or not
function is_admin1(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
local admins = 'admins'
if data[tostring(admins)] then
if data[tostring(admins)][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_admin2(user_id)
local var = false
local data = load_data(_config.moderation.data)
local user = user_id
local admins = 'admins'
if data[tostring(admins)] then
if data[tostring(admins)][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == user_id then
var = true
end
end
return var
end
--Check if user is the mod of that group or not
function is_momod(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['moderators'] then
if data[tostring(msg.to.id)]['moderators'][tostring(user)] then
var = true
end
end
end
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['set_owner'] then
if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then
var = true
end
end
end
local hash = 'support'
local support = redis:sismember(hash, user)
if support then
var = true
end
if data['admins'] then
if data['admins'][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_momod2(user_id, group_id)
local var = false
local data = load_data(_config.moderation.data)
local usert = user_id
if data[tostring(group_id)] then
if data[tostring(group_id)]['moderators'] then
if data[tostring(group_id)]['moderators'][tostring(usert)] then
var = true
end
end
end
if data[tostring(group_id)] then
if data[tostring(group_id)]['set_owner'] then
if data[tostring(group_id)]['set_owner'] == tostring(user_id) then
var = true
end
end
end
local hash = 'support'
local support = redis:sismember(hash, user_id)
if support then
var = true
end
if data['admins'] then
if data['admins'][tostring(user_id)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == usert then
var = true
end
end
return var
end
-- Returns the name of the sender
function kick_user_any(user_id, chat_id)
local channel = 'channel#id'..chat_id
local chat = 'chat#id'..chat_id
local user = 'user#id'..user_id
chat_del_user(chat, user, ok_cb, true)
channel_kick(channel, user, ok_cb, false)
end
-- Returns the name of the sender
function kick_user(user_id, chat_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(user_id) then -- Ignore admins
return
end
local channel = 'channel#id'..chat_id
local chat = 'chat#id'..chat_id
local user = 'user#id'..user_id
chat_del_user(chat, user, ok_cb, false)
channel_kick(channel, user, ok_cb, false)
end
-- Ban
function ban_user(user_id, chat_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(user_id) then -- Ignore admins
return
end
-- Save to redis
local hash = 'banned:'..chat_id
redis:sadd(hash, user_id)
-- Kick from chat
kick_user(user_id, chat_id)
end
-- Global ban
function banall_user(user_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(user_id) then -- Ignore admins
return
end
-- Save to redis
local hash = 'gbanned'
redis:sadd(hash, user_id)
end
-- Global unban
function unbanall_user(user_id)
--Save on redis
local hash = 'gbanned'
redis:srem(hash, user_id)
end
-- Check if user_id is banned in chat_id or not
function is_banned(user_id, chat_id)
--Save on redis
local hash = 'banned:'..chat_id
local banned = redis:sismember(hash, user_id)
return banned or false
end
-- Check if user_id is globally banned or not
function is_gbanned(user_id)
--Save on redis
local hash = 'gbanned'
local banned = redis:sismember(hash, user_id)
return banned or false
end
-- Returns chat_id ban list
function ban_list(chat_id)
local hash = 'banned:'..chat_id
local list = redis:smembers(hash)
local text = "Ban list for: [ID: "..chat_id.." ]:\n\n"
for k,v in pairs(list) do
local user_info = redis:hgetall('user:'..v)
if user_info and user_info.print_name then
local print_name = string.gsub(user_info.print_name, "_", " ")
local print_name = string.gsub(print_name, "", "")
text = text..k.." - "..print_name.." ["..v.."]\n"
else
text = text..k.." - "..v.."\n"
end
end
return text
end
-- Returns globally ban list
function banall_list()
local hash = 'gbanned'
local list = redis:smembers(hash)
local text = "Global bans!\n\n"
for k,v in pairs(list) do
local user_info = redis:hgetall('user:'..v)
if user_info and user_info.print_name then
local print_name = string.gsub(user_info.print_name, "_", " ")
local print_name = string.gsub(print_name, "", "")
text = text..k.." - "..print_name.." ["..v.."]\n"
else
text = text..k.." - "..v.."\n"
end
end
return text
end
-- Support Team
function support_add(support_id)
-- Save to redis
local hash = 'support'
redis:sadd(hash, support_id)
end
function is_support(support_id)
--Save on redis
local hash = 'support'
local support = redis:sismember(hash, support_id)
return support or false
end
function support_remove(support_id)
--Save on redis
local hash = 'support'
redis:srem(hash, support_id)
end
-- Whitelist
function is_whitelisted(user_id)
--Save on redis
local hash = 'whitelist'
local is_whitelisted = redis:sismember(hash, user_id)
return is_whitelisted or false
end
--Begin Chat Mutes
function set_mutes(chat_id)
mutes = {[1]= "Audio: no",[2]= "Photo: no",[3]= "All: no",[4]="Documents: no",[5]="Text: no",[6]= "Video: no",[7]= "Gifs: no"}
local hash = 'mute:'..chat_id
for k,v in pairsByKeys(mutes) do
setting = v
redis:sadd(hash, setting)
end
end
function has_mutes(chat_id)
mutes = {[1]= "Audio: no",[2]= "Photo: no",[3]= "All: no",[4]="Documents: no",[5]="Text: no",[6]= "Video: no",[7]= "Gifs: no"}
local hash = 'mute:'..chat_id
for k,v in pairsByKeys(mutes) do
setting = v
local has_mutes = redis:sismember(hash, setting)
return has_mutes or false
end
end
function rem_mutes(chat_id)
local hash = 'mute:'..chat_id
redis:del(hash)
end
function mute(chat_id, msg_type)
local hash = 'mute:'..chat_id
local yes = "yes"
local no = 'no'
local old_setting = msg_type..': '..no
local setting = msg_type..': '..yes
redis:srem(hash, old_setting)
redis:sadd(hash, setting)
end
function is_muted(chat_id, msg_type)
local hash = 'mute:'..chat_id
local setting = msg_type
local muted = redis:sismember(hash, setting)
return muted or false
end
function unmute(chat_id, msg_type)
--Save on redis
local hash = 'mute:'..chat_id
local yes = 'yes'
local no = 'no'
local old_setting = msg_type..': '..yes
local setting = msg_type..': '..no
redis:srem(hash, old_setting)
redis:sadd(hash, setting)
end
function mute_user(chat_id, user_id)
local hash = 'mute_user:'..chat_id
redis:sadd(hash, user_id)
end
function is_muted_user(chat_id, user_id)
local hash = 'mute_user:'..chat_id
local muted = redis:sismember(hash, user_id)
return muted or false
end
function unmute_user(chat_id, user_id)
--Save on redis
local hash = 'mute_user:'..chat_id
redis:srem(hash, user_id)
end
-- Returns chat_id mute list
function mutes_list(chat_id)
local hash = 'mute:'..chat_id
local list = redis:smembers(hash)
local text = "Mutes for: [ID: "..chat_id.." ]:\n\n"
for k,v in pairsByKeys(list) do
text = text.."Mute "..v.."\n"
end
return text
end
-- Returns chat_user mute list
function muted_user_list(chat_id)
local hash = 'mute_user:'..chat_id
local list = redis:smembers(hash)
local text = "Muted Users for: [ID: "..chat_id.." ]:\n\n"
for k,v in pairsByKeys(list) do
local user_info = redis:hgetall('user:'..v)
if user_info and user_info.print_name then
local print_name = string.gsub(user_info.print_name, "_", " ")
local print_name = string.gsub(print_name, "", "")
text = text..k.." - "..print_name.." ["..v.."]\n"
else
text = text..k.." - [ "..v.." ]\n"
end
end
return text
end
--End Chat Mutes
-- /id by reply
function get_message_callback_id(extra, success, result)
if type(result) == 'boolean' then
print('Old message :(')
return false
end
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.peer_id
send_large_msg(chat, result.from.peer_id)
else
return
end
end
-- kick by reply for mods and owner
function Kick_by_reply(extra, success, result)
if type(result) == 'boolean' then
print('Old message :(')
return false
end
if result.to.type == 'chat' or result.to.type == 'channel' then
local chat = 'chat#id'..result.to.peer_id
if tonumber(result.from.peer_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_momod2(result.from.peer_id, result.to.peer_id) then -- Ignore mods,owner,admin
return "you can't kick mods,owner and admins"
end
chat_del_user(chat, 'user#id'..result.from.peer_id, ok_cb, false)
channel_kick(channel, 'user#id'..result.from.peer_id, ok_cb, false)
else
return
end
end
-- Kick by reply for admins
function Kick_by_reply_admins(extra, success, result)
if type(result) == 'boolean' then
print('Old message :(')
return false
end
if result.to.type == 'chat' or result.to.type == 'channel' then
local chat = 'chat#id'..result.to.peer_id
local channel = 'channel#id'..result.to.peer_id
if tonumber(result.from.peer_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(result.from.peer_id) then -- Ignore admins
return
end
chat_del_user(chat, 'user#id'..result.from.peer_id, ok_cb, false)
channel_kick(channel, 'user#id'..result.from.peer_id, ok_cb, false)
else
return
end
end
--Ban by reply for admins
function ban_by_reply(extra, success, result)
if type(result) == 'boolean' then
print('Old message :(')
return false
end
if result.to.type == 'chat' or result.to.type == 'channel' then
local chat = 'chat#id'..result.to.peer_id
local channel = 'channel#id'..result.to.peer_id
if tonumber(result.from.peer_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_momod2(result.from.peer_id, result.to.peer_id) then -- Ignore mods,owner,admin
return "you can't kick mods,owner and admins"
end
ban_user(result.from.peer_id, result.to.peer_id)
send_large_msg(chat, "User "..result.from.peer_id.." Banned")
else
return
end
end
-- Ban by reply for admins
function ban_by_reply_admins(extra, success, result)
if type(result) == 'boolean' then
print('Old message :(')
return false
end
if result.to.peer_type == 'chat' or result.to.peer_type == 'channel' then
local chat = 'chat#id'..result.to.peer_id
local channel = 'channel#id'..result.to.peer_id
if tonumber(result.from.peer_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(result.from.peer_id) then -- Ignore admins
return
end
ban_user(result.from.peer_id, result.to.peer_id)
send_large_msg(chat, "User "..result.from.peer_id.." Banned")
send_large_msg(channel, "User "..result.from.peer_id.." Banned")
else
return
end
end
-- Unban by reply
function unban_by_reply(extra, success, result)
if type(result) == 'boolean' then
print('Old message :(')
return false
end
if result.to.type == 'chat' or result.to.type == 'channel' then
local chat = 'chat#id'..result.to.peer_id
local channel = 'channel#id'..result.to.peer_id
if tonumber(result.from.peer_id) == tonumber(our_id) then -- Ignore bot
return
end
send_large_msg(chat, "User "..result.from.peer_id.." Unbanned")
-- Save on redis
local hash = 'banned:'..result.to.peer_id
redis:srem(hash, result.from.peer_id)
else
return
end
end
function banall_by_reply(extra, success, result)
if type(result) == 'boolean' then
print('Old message :(')
return false
end
if result.to.type == 'chat' or result.to.type == 'channel' then
local chat = 'chat#id'..result.to.peer_id
local channel = 'channel#id'..result.to.peer_id
if tonumber(result.from.peer_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(result.from.peer_id) then -- Ignore admins
return
end
local name = user_print_name(result.from)
banall_user(result.from.peer_id)
chat_del_user(chat, 'user#id'..result.from.peer_id, ok_cb, false)
send_large_msg(chat, "User "..name.."["..result.from.peer_id.."] globally banned")
else
return
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c61190918.lua | 2 | 1805 | --トゥーン・バスター・ブレイダー
function c61190918.initial_effect(c)
aux.AddCodeList(c,15259703)
--cannot attack
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetOperation(c61190918.atklimit)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e2)
local e3=e1:Clone()
e3:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
c:RegisterEffect(e3)
--atkup
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e4:SetCode(EFFECT_UPDATE_ATTACK)
e4:SetRange(LOCATION_MZONE)
e4:SetValue(c61190918.val)
c:RegisterEffect(e4)
--direct attack
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_SINGLE)
e5:SetCode(EFFECT_DIRECT_ATTACK)
e5:SetCondition(c61190918.dircon)
c:RegisterEffect(e5)
end
function c61190918.atklimit(e,tp,eg,ep,ev,re,r,rp)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CANNOT_ATTACK)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
e:GetHandler():RegisterEffect(e1)
end
function c61190918.dirfilter1(c)
return c:IsFaceup() and c:IsCode(15259703)
end
function c61190918.dirfilter2(c)
return c:IsFaceup() and c:IsType(TYPE_TOON)
end
function c61190918.dircon(e)
return Duel.IsExistingMatchingCard(c61190918.dirfilter1,e:GetHandlerPlayer(),LOCATION_ONFIELD,0,1,nil)
and not Duel.IsExistingMatchingCard(c61190918.dirfilter2,e:GetHandlerPlayer(),0,LOCATION_MZONE,1,nil)
end
function c61190918.val(e,c)
return Duel.GetMatchingGroupCount(c61190918.filter,c:GetControler(),0,LOCATION_GRAVE+LOCATION_MZONE,nil)*500
end
function c61190918.filter(c)
return c:IsRace(RACE_DRAGON) and (c:IsLocation(LOCATION_GRAVE) or c:IsFaceup())
end
| gpl-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.